Class LaunchIdLockSocket

  • All Implemented Interfaces:
    LaunchIdLock

    public class LaunchIdLockSocket
    extends AbstractLaunchIdLock
    A service to perform blocking I/O operations on network sockets to get single launch UUID for multiple clients on a machine. This class uses local networking, therefore applicable in scope of a single hardware machine. You can control port number with ListenerProperty.CLIENT_JOIN_LOCK_PORT property.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void finishInstanceUuid​(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.String obtainLaunchUuid​(java.lang.String uuid)
      Returns a Launch UUID for many Clients launched on one machine.
      void updateInstanceUuid​(java.lang.String instanceUuid)
      Update self UUID in a lock, means that the Client still executing its Launch.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • TRANSFER_CHARSET

        public static final java.nio.charset.Charset TRANSFER_CHARSET
    • Constructor Detail

      • LaunchIdLockSocket

        public LaunchIdLockSocket​(ListenerParameters listenerParameters)
    • Method Detail

      • obtainLaunchUuid

        public java.lang.String obtainLaunchUuid​(@Nonnull
                                                 java.lang.String uuid)
        Returns a Launch UUID for many Clients launched on one machine.
        Parameters:
        uuid - a Client instance UUID, which will be written to lock and sync files and, if it 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)
        Description copied from interface: LaunchIdLock
        Update self UUID in a lock, means that the Client still executing its Launch.
        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: LaunchIdLock
        Return all instance UUIDs which are still running.
        Returns:
        a collection of live instance UUIDs