Package com.levigo.jadice.server.core
Class WorkingDirectory
- java.lang.Object
-
- com.levigo.jadice.server.core.WorkingDirectory
-
- All Implemented Interfaces:
org.springframework.context.Lifecycle
,org.springframework.jmx.export.naming.SelfNaming
@ManagedResource("The working directory of jadice server") public class WorkingDirectory extends Object implements org.springframework.context.Lifecycle, org.springframework.jmx.export.naming.SelfNaming
This class represents the working directory where jadice server can store temporary files for working with them.- Since:
- jadice server 5.6.0.0
-
-
Constructor Summary
Constructors Constructor Description WorkingDirectory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description File
getBaseDirectory()
int
getNumberOfFiles()
Counts the number of all files in the working directory recursivelyObjectName
getObjectName()
BigInteger
getSize()
Counts the size of the working directory recursively (sum of the length of all files).boolean
isPurgeOnStart()
boolean
isPurgeOnStop()
boolean
isRunning()
void
purge()
Purges the temp directory.void
setBaseDirectory(File baseDir)
Sets the location of the jadice server's working directoryvoid
setPurgeOnStart(boolean purgeOnStart)
void
setPurgeOnStop(boolean purgeOnStop)
Set if the working directory shall be purged on shutdownvoid
start()
void
stop()
-
-
-
Method Detail
-
getBaseDirectory
@ManagedAttribute(description="The base directory") public File getBaseDirectory()
-
setBaseDirectory
public void setBaseDirectory(File baseDir)
Sets the location of the jadice server's working directory- Parameters:
baseDir
- the base directory to use
-
getSize
@ManagedMetric(description="Size of the working directory", metricType=GAUGE, unit="Bytes") public BigInteger getSize()
Counts the size of the working directory recursively (sum of the length of all files).- Returns:
- Size of the working directory in bytes
-
getNumberOfFiles
@ManagedMetric(description="Number of files in the working directory", metricType=GAUGE) public int getNumberOfFiles()
Counts the number of all files in the working directory recursively- Returns:
- The number of files
-
purge
@ManagedOperation(description="Purges the working directory. Use carefully!") public void purge() throws IOException
Purges the temp directory. Be careful not to remove stuff we are't supposed to remove, ifbaseDir
is mis-configured. We do this by checking whether a marker file exists.This operation does not consider if there are
Job
s in progress that need a file which is stored in this working directory- Throws:
IOException
- if the marker file cannot be (re-)created.
-
getObjectName
public ObjectName getObjectName() throws MalformedObjectNameException
- Specified by:
getObjectName
in interfaceorg.springframework.jmx.export.naming.SelfNaming
- Throws:
MalformedObjectNameException
-
start
public void start()
- Specified by:
start
in interfaceorg.springframework.context.Lifecycle
-
stop
public void stop()
- Specified by:
stop
in interfaceorg.springframework.context.Lifecycle
-
isRunning
public boolean isRunning()
- Specified by:
isRunning
in interfaceorg.springframework.context.Lifecycle
-
isPurgeOnStart
@ManagedAttribute(description="Purge the working directory on start") public boolean isPurgeOnStart()
- Returns:
true
iff the working directory is purged on start
-
setPurgeOnStart
public void setPurgeOnStart(boolean purgeOnStart)
-
isPurgeOnStop
@ManagedAttribute(description="Purge the working directory on shutdown") public boolean isPurgeOnStop()
- Returns:
true
iff the working directory shall be purged on shutdown
-
setPurgeOnStop
@ManagedAttribute public void setPurgeOnStop(boolean purgeOnStop)
Set if the working directory shall be purged on shutdown- Parameters:
purgeOnStop
- iftrue
the working directory shall be purged
-
-