Class ResourceUsageCollectorService

java.lang.Object
org.opensearch.common.lifecycle.AbstractLifecycleComponent
org.opensearch.node.ResourceUsageCollectorService
All Implemented Interfaces:
Closeable, AutoCloseable, ClusterStateListener, org.opensearch.common.lease.Releasable, org.opensearch.common.lifecycle.LifecycleComponent

public class ResourceUsageCollectorService extends org.opensearch.common.lifecycle.AbstractLifecycleComponent implements ClusterStateListener
This collects node level resource usage statistics such as cpu, memory, IO of each node and makes it available for coordinator node to aid in throttling, ranking etc
  • Constructor Details

  • Method Details

    • clusterChanged

      public void clusterChanged(ClusterChangedEvent event)
      Description copied from interface: ClusterStateListener
      Called when cluster state changes.
      Specified by:
      clusterChanged in interface ClusterStateListener
    • collectNodeResourceUsageStats

      public void collectNodeResourceUsageStats(String nodeId, long timestamp, double memoryUtilizationPercent, double cpuUtilizationPercent, IoUsageStats ioUsageStats)
      Collect node resource usage stats along with the timestamp
    • getAllNodeStatistics

      public Map<String,NodeResourceUsageStats> getAllNodeStatistics()
      Get all node resource usage statistics which will be used for node stats
    • getNodeStatistics

      public Optional<NodeResourceUsageStats> getNodeStatistics(String nodeId)
      Optionally return a NodeResourceUsageStats for the given nodeid, if resource usage stats information exists for the given node. Returns an empty Optional if the node was not found.
    • stats

      public NodesResourceUsageStats stats()
      Returns collected resource usage statistics of all nodes
    • doStart

      protected void doStart()
      Specified by:
      doStart in class org.opensearch.common.lifecycle.AbstractLifecycleComponent
    • doStop

      protected void doStop()
      Specified by:
      doStop in class org.opensearch.common.lifecycle.AbstractLifecycleComponent
    • doClose

      protected void doClose()
      Specified by:
      doClose in class org.opensearch.common.lifecycle.AbstractLifecycleComponent