Package org.jenkinsci.remoting.engine
Class WorkDirManager
java.lang.Object
org.jenkinsci.remoting.engine.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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Defines components of the Working directory. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final boolean
Default value for the behavior when the requested working directory is missing.static final String
Name of the standard System Property, which points to thejava.util.logging
config file.static final String
Regular expression, which declares restrictions of the remoting internal directory symbols -
Method Summary
Modifier and TypeMethodDescriptionvoid
static WorkDirManager
Retrieves the instance of theWorkDirManager
.GetPath
of the directory.Gets path to the property file with JUL settings.initializeWorkDir
(File workDir, String internalDir, boolean failIfMissing) Initializes the working directory for the agent.void
setLoggingConfig
(File configFile) Sets path to the Logging JUL property file with logging settings.void
setupLogging
(Path internalDirPath, Path overrideLogPath) Sets up logging subsystem in the working directory.
-
Field Details
-
DEFAULT_FAIL_IF_WORKDIR_IS_MISSING
public static final boolean DEFAULT_FAIL_IF_WORKDIR_IS_MISSINGDefault value for the behavior when the requested working directory is missing. The default value isfalse
, because otherwise agents would fail on the first startup.- See Also:
-
SUPPORTED_INTERNAL_DIR_NAME_MASK
Regular expression, which declares restrictions of the remoting internal directory symbols- See Also:
-
JUL_CONFIG_FILE_SYSTEM_PROPERTY_NAME
Name of the standard System Property, which points to thejava.util.logging
config file.- See Also:
-
-
Method Details
-
getInstance
Retrieves the instance of theWorkDirManager
. Currently the implementation is hardcoded, but it may change in the future.- Returns:
- Workspace manager
-
disable
-
getLocation
-
getLocationPath
GetPath
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
Sets path to the Logging JUL property file with logging settings.- Parameters:
configFile
- config file
-
getLoggingConfigFile
Gets path to the property file with JUL settings. This method checks the value passed fromsetLoggingConfig(File)
first. If the value is not specified, it also checks the standardjava.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 directoryinternalDir
- Name of the remoting internal data directory within the working directory. The range of the supported symbols is restricted toSUPPORTED_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 andoverrideLogPath
are null, the logging subsystem woill not be initialized at alloverrideLogPath
- Overrides the common location of the remoting log. If specified, logging system will be initialized in the legacy way. Ifnull
, the behavior is defined byinternalDirPath
.- Throws:
IOException
- Initialization error
-