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
-
Nested Class Summary
Nested classes/interfaces inherited from interface DefaultedDocPropertyHolder
DefaultedDocPropertyHolder.Mutable<S> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final HostAndPortprotected final ServiceConfigurationprotected final longprotected final longprotected final ServiceLifeCycleprotected final ProcessSnapshotprotected final Document -
Constructor Summary
ConstructorsConstructorDescriptionServiceInfoSnapshot(long creationTime, @NonNull HostAndPort address, @NonNull ProcessSnapshot processSnapshot, @NonNull ServiceConfiguration configuration, long connectedTime, @NonNull ServiceLifeCycle lifeCycle, @NonNull Document properties) Constructs a new service info snapshot. -
Method Summary
Modifier and TypeMethodDescriptionaddress()Get the address to which the service was / will be bound when started.clone()intcompareTo(@NonNull ServiceInfoSnapshot serviceInfoSnapshot) Get the configuration which was used to create the service this snapshot wraps.booleanGet if the wrapped service was started and is connected to the node which started it.longGet the unix timestamp when the service connected to the handling node.longGet the unix timestamp when this snapshot was created.Get the current lifecycle of the service at the snapshot creation time.name()Get the unique name identifier of this object in the related scope.Get the process snapshot of the service process at the creation time of this snapshot.Get the underlying document that all read and write operations are delegated to.provider()Get the associated service provider for the service wrapped by this snapshot.Get the service id of the service this snapshot was created for.Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface DefaultedDocPropertyHolder
propertyAbsent, propertyPresent, readProperty, readPropertyOrDefault, readPropertyOrGet, readPropertyOrThrow, readPropertyOrThrow
-
Field Details
-
creationTime
protected final long creationTime -
address
-
processSnapshot
-
configuration
-
connectedTime
protected final long connectedTime -
lifeCycle
-
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
-
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
Get the current lifecycle of the service at the snapshot creation time.- Returns:
- the lifecycle of the service at the snapshot creation time.
-
processSnapshot
Get the process snapshot of the service process at the creation time of this snapshot.- Returns:
- the process snapshot of the service.
-
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
-
propertyHolder
Get the underlying document that all read and write operations are delegated to.- Specified by:
propertyHolderin interfaceDocPropertyHolder- Returns:
- the underlying document.
-
compareTo
- Specified by:
compareToin interfaceComparable<ServiceInfoSnapshot>
-
clone
-