Class NodeInfoSnapshot
java.lang.Object
eu.cloudnetservice.driver.cluster.NodeInfoSnapshot
- All Implemented Interfaces:
DefaultedDocPropertyHolder,DocPropertyHolder
Holds information about a node which is connected to the cluster. Every node in the cluster should be connected to
each other node, so that every node knows everything about each other node.
- Since:
- 4.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface eu.cloudnetservice.driver.document.property.DefaultedDocPropertyHolder
DefaultedDocPropertyHolder.Mutable<S extends DocPropertyHolder.Mutable<S>> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final longprotected final intprotected final booleanprotected final doubleprotected final intprotected final Collection<ModuleConfiguration> protected final NetworkClusterNodeprotected final ProcessSnapshotprotected final Documentprotected final intprotected final longprotected final intprotected final CloudNetVersion -
Constructor Summary
ConstructorsConstructorDescriptionNodeInfoSnapshot(long creationTime, long startupMillis, int maxMemory, int usedMemory, int reservedMemory, int currentServicesCount, boolean drain, @NonNull NetworkClusterNode node, @NonNull CloudNetVersion version, @NonNull ProcessSnapshot processSnapshot, double maxCPUUsageToStartServices, @NonNull Collection<ModuleConfiguration> modules, @NonNull Document properties) Constructs a new network cluster node info snapshot instance. -
Method Summary
Modifier and TypeMethodDescriptionlongGet the epoch milli creation time of this snapshot.intGet the amount of services in any state on the associated node.booleandraining()Get the current draining state of associated node.intGet the maximum amount of memory the associated node is allowed to use to start services.doubleGet the maximum amount of cpu the associated node is allowed to consume before stopping and delaying service starts.intGet a rounded percentage of the memory the associated node is currently using.modules()Get all modules which are running on the associated node.node()Get the offline node information associated with this node.Get the process snapshot made when this snapshot was created on the associated node.Get the underlying document that all read and write operations are delegated to.intGet the amount of memory currently reserved by all services in any state on the associated node.longGet the epoch milli startup time of the associated node.intGet the amount of memory currently used by all services which are running on the associated node.version()Get the version the associated node is running on.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface eu.cloudnetservice.driver.document.property.DefaultedDocPropertyHolder
propertyAbsent, propertyPresent, readProperty, readPropertyOrDefault, readPropertyOrGet, readPropertyOrThrow, readPropertyOrThrow
-
Field Details
-
creationTime
protected final long creationTime -
startupMillis
protected final long startupMillis -
maxMemory
protected final int maxMemory -
usedMemory
protected final int usedMemory -
reservedMemory
protected final int reservedMemory -
currentServicesCount
protected final int currentServicesCount -
drain
protected final boolean drain -
node
-
version
-
processSnapshot
-
maxCPUUsageToStartServices
protected final double maxCPUUsageToStartServices -
modules
-
properties
-
-
Constructor Details
-
NodeInfoSnapshot
public NodeInfoSnapshot(long creationTime, long startupMillis, int maxMemory, int usedMemory, int reservedMemory, int currentServicesCount, boolean drain, @NonNull @NonNull NetworkClusterNode node, @NonNull @NonNull CloudNetVersion version, @NonNull @NonNull ProcessSnapshot processSnapshot, double maxCPUUsageToStartServices, @NonNull @NonNull Collection<ModuleConfiguration> modules, @NonNull @NonNull Document properties) Constructs a new network cluster node info snapshot instance.- Parameters:
creationTime- the epoch milli creation time of the snapshot, normally the current time.startupMillis- the epoch milli when the node first started.maxMemory- the maximum amount of memory the node is allowed to use to start services.usedMemory- the currently used memory, including only services which are running.reservedMemory- the currently reserved memory, including each service in any state.currentServicesCount- the current amount of services, including each service in any state.drain- if the current node no longer starts services and will shut down when all services on it are stopped.node- the network node information of the node.version- the version this node is running on.processSnapshot- the process snapshot of this.maxCPUUsageToStartServices- the maximum amount of cpu the node is allowed to use to start services.modules- the modules which are running on this node.properties- the properties of this node, mainly for developers.- Throws:
NullPointerException- if either the given node, version, process snapshot, modules or properties are null.
-
-
Method Details
-
creationTime
public long creationTime()Get the epoch milli creation time of this snapshot.- Returns:
- the creation time of this snapshot.
-
startupMillis
public long startupMillis()Get the epoch milli startup time of the associated node.- Returns:
- the startup time of the associated node.
-
maxMemory
public int maxMemory()Get the maximum amount of memory the associated node is allowed to use to start services.- Returns:
- the maximum amount of memory to start services.
-
usedMemory
public int usedMemory()Get the amount of memory currently used by all services which are running on the associated node.- Returns:
- the amount of memory currently used by all services which are running.
-
reservedMemory
public int reservedMemory()Get the amount of memory currently reserved by all services in any state on the associated node.- Returns:
- the amount of memory currently reserved by all services in any state.
-
currentServicesCount
public int currentServicesCount()Get the amount of services in any state on the associated node.- Returns:
- the amount of services in any state on the associated node.
-
draining
public boolean draining()Get the current draining state of associated node. If a node is marked as draining, the head node will no longer request service starts and only wait for existing services to stop.- Returns:
- the current draining state.
-
node
Get the offline node information associated with this node.- Returns:
- the offline node information.
-
version
Get the version the associated node is running on.- Returns:
- the version.
-
processSnapshot
Get the process snapshot made when this snapshot was created on the associated node.- Returns:
- the process snapshot made when this snapshot was created.
-
maxProcessorUsageToStartServices
public double maxProcessorUsageToStartServices()Get the maximum amount of cpu the associated node is allowed to consume before stopping and delaying service starts.- Returns:
- the maximum amount of the cpu (in percent).
-
modules
Get all modules which are running on the associated node.- Returns:
- all modules which are running on the associated node.
-
memoryUsagePercentage
public int memoryUsagePercentage()Get a rounded percentage of the memory the associated node is currently using.- Returns:
- a rounded percentage of the memory the associated node is currently using.
-
propertyHolder
Get the underlying document that all read and write operations are delegated to.- Specified by:
propertyHolderin interfaceDocPropertyHolder- Returns:
- the underlying document.
-