Class NodeInfoSnapshot

java.lang.Object
eu.cloudnetservice.driver.cluster.NodeInfoSnapshot
All Implemented Interfaces:
DefaultedDocPropertyHolder, DocPropertyHolder

public final class NodeInfoSnapshot extends Object implements DefaultedDocPropertyHolder
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
  • 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

      protected final NetworkClusterNode node
    • version

      protected final CloudNetVersion version
    • processSnapshot

      protected final ProcessSnapshot processSnapshot
    • maxCPUUsageToStartServices

      protected final double maxCPUUsageToStartServices
    • modules

      protected final Collection<ModuleConfiguration> modules
    • properties

      protected final Document 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

      @NonNull public @NonNull CloudNetVersion version()
      Get the version the associated node is running on.
      Returns:
      the version.
    • processSnapshot

      @NonNull public @NonNull ProcessSnapshot 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

      @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.