Class WorkDirManager


  • @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
    public class WorkDirManager
    extends Object
    Performs working directory management in remoting. Using this manager remoting can initialize its working directory and put the data there. The structure of the directory is described in WorkDirManager.DirType.
    Since:
    3.8
    Author:
    Oleg Nenashev
    • Field Detail

      • DEFAULT_FAIL_IF_WORKDIR_IS_MISSING

        public static final boolean DEFAULT_FAIL_IF_WORKDIR_IS_MISSING
        Default value for the behavior when the requested working directory is missing. The default value is false, because otherwise agents would fail on the first startup.
        See Also:
        Constant Field Values
      • SUPPORTED_INTERNAL_DIR_NAME_MASK

        public static final String SUPPORTED_INTERNAL_DIR_NAME_MASK
        Regular expression, which declares restrictions of the remoting internal directory symbols
        See Also:
        Constant Field Values
      • JUL_CONFIG_FILE_SYSTEM_PROPERTY_NAME

        public static final String JUL_CONFIG_FILE_SYSTEM_PROPERTY_NAME
        Name of the standard System Property, which points to the java.util.logging config file.
        See Also:
        Constant Field Values
    • Method Detail

      • getInstance

        @NonNull
        public static WorkDirManager getInstance()
        Retrieves the instance of the WorkDirManager. Currently the implementation is hardcoded, but it may change in the future.
        Returns:
        Workspace manager
      • getLocationPath

        @CheckForNull
        public Path getLocationPath​(@NonNull
                                    WorkDirManager.DirType type)
                             throws IOException
        Get Path of the directory.
        Parameters:
        type - Type of the directory
        Returns:
        Path
        Throws:
        IOException - Invalid path, e.g. ig the root directory is incorrect
        Since:
        3.14
      • setLoggingConfig

        public void setLoggingConfig​(@NonNull
                                     File configFile)
        Sets path to the Logging JUL property file with logging settings.
        Parameters:
        configFile - config file
      • getLoggingConfigFile

        @CheckForNull
        public File getLoggingConfigFile()
        Gets path to the property file with JUL settings. This method checks the value passed from setLoggingConfig(java.io.File) first. If the value is not specified, it also checks the standard java.util.logging.config.file System property.
        Returns:
        Path to the logging config file. null if it cannot be found.
      • initializeWorkDir

        @CheckForNull
        public Path initializeWorkDir​(@CheckForNull
                                      File workDir,
                                      @NonNull
                                      String internalDir,
                                      boolean failIfMissing)
                               throws IOException
        Initializes the working directory for the agent. Within the working directory the method also initializes a working directory for internal needs (like logging)
        Parameters:
        workDir - Working directory
        internalDir - Name of the remoting internal data directory within the working directory. The range of the supported symbols is restricted to SUPPORTED_INTERNAL_DIR_NAME_MASK.
        failIfMissing - Fail the initialization if the workDir or internalDir are missing. This option presumes that the workspace structure gets initialized previously in order to ensure that we do not start up with a borked instance (e.g. if a mount gets disconnected).
        Returns:
        Initialized directory for internal files within workDir or null if it is disabled
        Throws:
        IOException - Workspace allocation issue (e.g. the specified directory is not writable). In such case Remoting should not start up at all.
      • setupLogging

        public void setupLogging​(@CheckForNull
                                 Path internalDirPath,
                                 @CheckForNull
                                 Path overrideLogPath)
                          throws IOException
        Sets up logging subsystem in the working directory. If the logging system is already initialized, do nothing
        Parameters:
        internalDirPath - Path to the internal remoting directory within the WorkDir. If this value and overrideLogPath are null, the logging subsystem woill not be initialized at all
        overrideLogPath - Overrides the common location of the remoting log. If specified, logging system will be initialized in the legacy way. If null, the behavior is defined by internalDirPath.
        Throws:
        IOException - Initialization error