Class ServiceInfoSnapshot

java.lang.Object
eu.cloudnetservice.driver.service.ServiceInfoSnapshot
All Implemented Interfaces:
Named, DefaultedDocPropertyHolder, DocPropertyHolder, Cloneable, Comparable<ServiceInfoSnapshot>

public class ServiceInfoSnapshot extends Object implements Named, DefaultedDocPropertyHolder, Cloneable, Comparable<ServiceInfoSnapshot>
Represents the state of a service at the snapshot creation time. A service snapshot (once created) will never change its state again. If the latest information is needed from a service, make sure you actually force the service into updating its last snapshot to get a new, clean version of it.
Since:
4.0
  • Field Details

    • creationTime

      protected final long creationTime
    • address

      protected final HostAndPort address
    • processSnapshot

      protected final ProcessSnapshot processSnapshot
    • configuration

      protected final ServiceConfiguration configuration
    • connectedTime

      protected final long connectedTime
    • lifeCycle

      protected final ServiceLifeCycle lifeCycle
    • properties

      protected final Document properties
  • Constructor Details

    • ServiceInfoSnapshot

      @Internal public ServiceInfoSnapshot(long creationTime, @NonNull @NonNull HostAndPort address, @NonNull @NonNull ProcessSnapshot processSnapshot, @NonNull @NonNull ServiceConfiguration configuration, long connectedTime, @NonNull @NonNull ServiceLifeCycle lifeCycle, @NonNull @NonNull Document properties)
      Constructs a new service info snapshot. This constructor is for internal use only, there should be no reason normally why you need to create a service info snapshot instance yourself.
      Parameters:
      creationTime - the unix timestamp of the snapshot creation time.
      address - the address to which the service was bound if started.
      processSnapshot - the current snapshot of the process resource usage.
      configuration - the configuration base used to create the service.
      connectedTime - the time when the service connected to the node, -1 if not yet connected.
      lifeCycle - the lifecycle the service is in when creating the snapshot.
      properties - the properties of the service.
      Throws:
      NullPointerException - if one of the constructor parameters is null.
  • Method Details

    • creationTime

      public long creationTime()
      Get the unix timestamp when this snapshot was created. No changes on the service since that timestamp are reflected into this snapshot.
      Returns:
      the creation timestamp of this snapshot.
    • serviceId

      @NonNull public @NonNull ServiceId serviceId()
      Get the service id of the service this snapshot was created for.
      Returns:
      the id of the service wrapped by this snapshot.
    • address

      @NonNull public @NonNull HostAndPort address()
      Get the address to which the service was / will be bound when started.
      Returns:
      the address of the service.
    • connected

      public boolean connected()
      Get if the wrapped service was started and is connected to the node which started it.
      Returns:
      true if the service is connected to the handling node, false otherwise.
    • connectedTime

      public long connectedTime()
      Get the unix timestamp when the service connected to the handling node. This method returns -1 when the service is not yet connected to the node.
      Returns:
      the unix timestamp when the service connected to the handling node.
    • lifeCycle

      @NonNull public @NonNull ServiceLifeCycle lifeCycle()
      Get the current lifecycle of the service at the snapshot creation time.
      Returns:
      the lifecycle of the service at the snapshot creation time.
    • processSnapshot

      @NonNull public @NonNull ProcessSnapshot processSnapshot()
      Get the process snapshot of the service process at the creation time of this snapshot.
      Returns:
      the process snapshot of the service.
    • configuration

      @NonNull public @NonNull ServiceConfiguration configuration()
      Get the configuration which was used to create the service this snapshot wraps.
      Returns:
      the configuration for the service wrapped by this snapshot.
    • provider

      Get the associated service provider for the service wrapped by this snapshot. This method returns the exact snapshot based on the unique id of the wrapped service. The returned provider might be a no-op one if the service wrapped by this snapshot no longer exists.
      Returns:
      a service provider targeting the current wrapped service.
    • name

      @NonNull public @NonNull String name()
      Get the unique name identifier of this object in the related scope.
      Specified by:
      name in interface Named
      Returns:
      the unique name identifier of this object in the related scope.
    • propertyHolder

      @NonNull public @NonNull Document propertyHolder()
      Get the underlying document that all read and write operations are delegated to.
      Specified by:
      propertyHolder in interface DocPropertyHolder
      Returns:
      the underlying document.
    • compareTo

      public int compareTo(@NonNull @NonNull ServiceInfoSnapshot serviceInfoSnapshot)
      Specified by:
      compareTo in interface Comparable<ServiceInfoSnapshot>
    • clone

      Overrides:
      clone in class Object