Class LaunchIdLockFile
- java.lang.Object
-
- com.epam.reportportal.service.launch.lock.AbstractLaunchIdLock
-
- com.epam.reportportal.service.launch.lock.LaunchIdLockFile
-
- All Implemented Interfaces:
LaunchIdLock
public class LaunchIdLockFile extends AbstractLaunchIdLock
A service to perform blocking I/O operations on '.lock' and '.sync' file to get single launch UUID for multiple clients on a machine. This class uses a local storage disk, therefore applicable in scope of a single hardware machine. You can control lock and sync file paths withListenerProperty.FILE_LOCK_NAMEandListenerProperty.FILE_SYNC_NAMEproperties.
-
-
Field Summary
Fields Modifier and Type Field Description static java.nio.charset.CharsetLOCK_FILE_CHARSETstatic java.lang.StringTIME_SEPARATOR-
Fields inherited from class com.epam.reportportal.service.launch.lock.AbstractLaunchIdLock
parameters
-
Fields inherited from interface com.epam.reportportal.service.LaunchIdLock
MAX_WAIT_TIME_DISCREPANCY
-
-
Constructor Summary
Constructors Constructor Description LaunchIdLockFile(ListenerParameters listenerParameters)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfinishInstanceUuid(java.lang.String instanceUuid)Remove self UUID from sync file, means that a client finished its Launch.java.util.Collection<java.lang.String>getLiveInstanceUuids()Return all instance UUIDs which are still running.java.lang.StringobtainLaunchUuid(java.lang.String instanceUuid)Returns a Launch UUID for many Clients launched on one machine.voidupdateInstanceUuid(java.lang.String instanceUuid)Update timestamp for instance record in sync file.
-
-
-
Field Detail
-
LOCK_FILE_CHARSET
public static final java.nio.charset.Charset LOCK_FILE_CHARSET
-
TIME_SEPARATOR
public static final java.lang.String TIME_SEPARATOR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LaunchIdLockFile
public LaunchIdLockFile(@Nonnull ListenerParameters listenerParameters)
-
-
Method Detail
-
obtainLaunchUuid
@Nullable public java.lang.String obtainLaunchUuid(@Nonnull java.lang.String instanceUuid)Returns a Launch UUID for many Clients launched on one machine.- Parameters:
instanceUuid- a Client instance UUID, which will be written to lock and sync files and, if it is the first thread which managed to obtain lock on '.lock' file, returned to every client instance.- Returns:
- either a Client instance UUID, either the first UUID which thread managed to place a lock on a '.lock' file.
-
updateInstanceUuid
public void updateInstanceUuid(@Nonnull java.lang.String instanceUuid)Update timestamp for instance record in sync file.- Parameters:
instanceUuid- instanceUuid a Client instance UUID
-
finishInstanceUuid
public void finishInstanceUuid(@Nonnull java.lang.String instanceUuid)Remove self UUID from sync file, means that a client finished its Launch. If this is the last UUID in the sync file, lock and sync files will be removed.- Parameters:
instanceUuid- a Client instance UUID.
-
getLiveInstanceUuids
@Nonnull public java.util.Collection<java.lang.String> getLiveInstanceUuids()
Description copied from interface:LaunchIdLockReturn all instance UUIDs which are still running.- Returns:
- a collection of live instance UUIDs
-
-