Class Node

java.lang.Object
org.elasticsearch.node.Node
All Implemented Interfaces:
Closeable, AutoCloseable

public class Node extends Object implements Closeable
A node represent a node within a cluster (cluster.name). The client() can be used in order to use a Client to perform actions/operations against the cluster.
  • Field Details

    • WRITE_PORTS_FILE_SETTING

      public static final Setting<Boolean> WRITE_PORTS_FILE_SETTING
    • NODE_NAME_SETTING

      public static final Setting<String> NODE_NAME_SETTING
    • NODE_EXTERNAL_ID_SETTING

      public static final Setting<String> NODE_EXTERNAL_ID_SETTING
    • NODE_ATTRIBUTES

      public static final Setting.AffixSetting<String> NODE_ATTRIBUTES
    • BREAKER_TYPE_KEY

      public static final Setting<String> BREAKER_TYPE_KEY
    • INITIAL_STATE_TIMEOUT_SETTING

      public static final Setting<TimeValue> INITIAL_STATE_TIMEOUT_SETTING
    • MAXIMUM_SHUTDOWN_TIMEOUT_SETTING

      public static final Setting<TimeValue> MAXIMUM_SHUTDOWN_TIMEOUT_SETTING
  • Constructor Details

    • Node

      public Node(Environment environment)
      Constructs a node
      Parameters:
      environment - the initial environment for this node, which will be added to by plugins
  • Method Details

    • deleteTemporaryApmConfig

      public static void deleteTemporaryApmConfig(JvmInfo jvmInfo, BiConsumer<Exception,Path> errorHandler)
      If the JVM was started with the Elastic APM agent and a config file argument was specified, then delete the config file. The agent only reads it once, when supplied in this fashion, and it may contain a secret token.

      Public for testing only

    • settings

      public Settings settings()
      The settings that are used by this node. Contains original settings as well as additional settings provided by plugins.
    • client

      public Client client()
      A client that can be used to execute actions (operations) against the cluster.
    • getEnvironment

      public Environment getEnvironment()
      Returns the environment of the node
    • getNodeEnvironment

      public NodeEnvironment getNodeEnvironment()
      Returns the NodeEnvironment instance of this node
    • start

      public Node start() throws NodeValidationException
      Start the node. If the node is already started, this method is no-op.
      Throws:
      NodeValidationException
    • configureNodeAndClusterIdStateListener

      protected void configureNodeAndClusterIdStateListener(ClusterService clusterService)
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • prepareForClose

      public void prepareForClose()
      Invokes hooks to prepare this node to be closed. This should be called when Elasticsearch receives a request to shut down gracefully from the underlying operating system, before system resources are closed. This method will block until the node is ready to shut down. Note that this class is part of infrastructure to react to signals from the operating system - most graceful shutdown logic should use Node Shutdown, see NodesShutdownMetadata.
    • awaitClose

      public boolean awaitClose(long timeout, TimeUnit timeUnit) throws InterruptedException
      Wait for this node to be effectively closed.
      Throws:
      InterruptedException
    • isClosed

      public boolean isClosed()
      Returns true if the node is closed.
    • injector

      public Injector injector()
    • validateNodeBeforeAcceptingRequests

      protected void validateNodeBeforeAcceptingRequests(BootstrapContext context, BoundTransportAddress boundTransportAddress, List<BootstrapCheck> bootstrapChecks) throws NodeValidationException
      Hook for validating the node after network services are started but before the cluster service is started and before the network service starts accepting incoming network requests.
      Parameters:
      context - the bootstrap context for this node
      boundTransportAddress - the network addresses the node is bound and publishing to
      Throws:
      NodeValidationException
    • getPluginsService

      protected PluginsService getPluginsService()
      The PluginsService used to build this node's components.