Class 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 Detail

      • WorkingDirectory

        public WorkingDirectory()
    • 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, if baseDir is mis-configured. We do this by checking whether a marker file exists.

        This operation does not consider if there are Jobs in progress that need a file which is stored in this working directory

        Throws:
        IOException - if the marker file cannot be (re-)created.
      • start

        public void start()
        Specified by:
        start in interface org.springframework.context.Lifecycle
      • stop

        public void stop()
        Specified by:
        stop in interface org.springframework.context.Lifecycle
      • isRunning

        public boolean isRunning()
        Specified by:
        isRunning in interface org.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 - if true the working directory shall be purged