Object BrowserFiles
-
- All Implemented Interfaces:
public class BrowserFiles
-
-
Field Summary
Fields Modifier and Type Field Description public final static StringCONTEXT_DIR_PREFIXpublic final static StringPID_FILE_NAMEpublic final static StringPORT_FILE_NAMEpublic final static StringCONTEXT_LOCK_NAMEprivate final DurationTEMPORARY_UDD_EXPIRYpublic final static BrowserFilesINSTANCE
-
Method Summary
Modifier and Type Method Description final PathcomputeTestContextDir(Fingerprint fingerprint, Integer maxAgents)Compute the next sequential test context directory. final PathcomputeNextSequentialContextDir(String group, Fingerprint fingerprint, Integer maxAgents)Compute the next sequential context directory. final PathcomputeRandomTmpContextDir(String group)final UnitcleanOldestContextTmpDirs(Duration expiry, Integer recentNToKeep)final UnitcleanUpContextTmpDir(Duration expiry)Clean up the context directories that are expired. final UnitcleanUpContextDir(Path contextDir, Duration expiry)Clear the browser's user data dir inside the given context path. final UnitdeleteTemporaryUserDataDirWithLock(String group, Path userDataDir, Duration expiry)Deletes the temporary user data directory if specific conditions are met. final PathgetContextGroupDirLockFile(String group)Get the lock file of the context group. final PathgetTempContextGroupDirLockFile(String group)Get the lock file of the context group. final PathgetContextGroupLockFileFromUserDataDir(Path userDataDir)Get the lock file of the context group from the user data directory. final DurationgetTEMPORARY_UDD_EXPIRY()-
-
Method Detail
-
computeTestContextDir
@Synchronized() final Path computeTestContextDir(Fingerprint fingerprint, Integer maxAgents)
Compute the next sequential test context directory. A typical context directory is like: /tmp/pulsar-vincent/context/group/test/cx.1
- Parameters:
fingerprint- The fingerprintmaxAgents- The maximum number of available agents, every agent has its own context directory- Returns:
The next sequential context directory
-
computeNextSequentialContextDir
@Synchronized() final Path computeNextSequentialContextDir(String group, Fingerprint fingerprint, Integer maxAgents)
Compute the next sequential context directory. A typical context directory is like: /tmp/pulsar-vincent/context/group/default/cx.1
- Parameters:
group- The group name, default is "default"fingerprint- The fingerprintmaxAgents- The maximum number of available agents, every agent has its own context directory- Returns:
The next sequential context directory
-
computeRandomTmpContextDir
@Synchronized() final Path computeRandomTmpContextDir(String group)
-
cleanOldestContextTmpDirs
final Unit cleanOldestContextTmpDirs(Duration expiry, Integer recentNToKeep)
-
cleanUpContextTmpDir
final Unit cleanUpContextTmpDir(Duration expiry)
Clean up the context directories that are expired.
- Parameters:
expiry- The expiry duration
-
cleanUpContextDir
final Unit cleanUpContextDir(Path contextDir, Duration expiry)
Clear the browser's user data dir inside the given context path.
Only clean the context directory which starts with "cx."
- Parameters:
contextDir- The path to the context directoryexpiry- The expiry duration
-
deleteTemporaryUserDataDirWithLock
@Synchronized() final Unit deleteTemporaryUserDataDirWithLock(String group, Path userDataDir, Duration expiry)
Deletes the temporary user data directory if specific conditions are met.
This function ensures that the directory is only deleted if:
The lock file is locked, no other thread is accessing it.
The directory is not already in the cleaned set.
The directory is within the temporary context directory.
The directory has expired based on its modification time.
The directory has a sibling file named "PID_FILE_NAME".
- Parameters:
group- The group name, default is "default"userDataDir- The path to the user data directory that needs to be checked and potentially deleted.expiry- The duration after which the directory is considered expired and eligible for deletion.
-
getContextGroupDirLockFile
final Path getContextGroupDirLockFile(String group)
Get the lock file of the context group. The lock file is used to ensure that only one process can access the context group directory at a time.
A typical lock file is like: /tmp/pulsar-vincent/context/group/default/context.lock The lock file is created in the context group directory.
- Parameters:
group- The context group name.- Returns:
The lock file of the context group.
-
getTempContextGroupDirLockFile
final Path getTempContextGroupDirLockFile(String group)
Get the lock file of the context group. The lock file is used to ensure that only one process can access the context group directory at a time.
A typical lock file is like: /tmp/pulsar-vincent/context/tmp/groups/default/context.lock The lock file is created in the context group directory.
- Parameters:
group- The context group name.- Returns:
The lock file of the context group.
-
getContextGroupLockFileFromUserDataDir
final Path getContextGroupLockFileFromUserDataDir(Path userDataDir)
Get the lock file of the context group from the user data directory. The lock file is used to ensure that only one process can access the context group directory at a time.
A typical lock file is like: /tmp/pulsar-vincent/context/group/default/context.lock The lock file is created in the context group directory.
- Parameters:
userDataDir- The user data directory of the context group.- Returns:
The lock file of the context group.
-
getTEMPORARY_UDD_EXPIRY
final Duration getTEMPORARY_UDD_EXPIRY()
-
-
-
-