Class DiscoveryNode

java.lang.Object
org.elasticsearch.cluster.node.DiscoveryNode
All Implemented Interfaces:
Writeable, org.elasticsearch.xcontent.ToXContent, org.elasticsearch.xcontent.ToXContentFragment

public class DiscoveryNode extends Object implements Writeable, org.elasticsearch.xcontent.ToXContentFragment
A discovery node represents a node that is part of the cluster.
  • Constructor Details

    • DiscoveryNode

      public DiscoveryNode(String id, TransportAddress address, Version version)
      Creates a new DiscoveryNode

      Note: if the version of the node is unknown Version.minimumCompatibilityVersion() should be used for the current version. it corresponds to the minimum version this elasticsearch version can communicate with. If a higher version is used the node might not be able to communicate with the remote node. After initial handshakes node versions will be discovered and updated.

      Parameters:
      id - the nodes unique (persistent) node id. This constructor will auto generate a random ephemeral id.
      address - the nodes transport address
      version - the version of the node
    • DiscoveryNode

      public DiscoveryNode(String id, TransportAddress address, Map<String,String> attributes, Set<DiscoveryNodeRole> roles, Version version)
      Creates a new DiscoveryNode

      Note: if the version of the node is unknown Version.minimumCompatibilityVersion() should be used for the current version. it corresponds to the minimum version this elasticsearch version can communicate with. If a higher version is used the node might not be able to communicate with the remote node. After initial handshakes node versions will be discovered and updated.

      Parameters:
      id - the nodes unique (persistent) node id. This constructor will auto generate a random ephemeral id.
      address - the nodes transport address
      attributes - node attributes
      roles - node roles
      version - the version of the node
    • DiscoveryNode

      public DiscoveryNode(String nodeName, String nodeId, TransportAddress address, Map<String,String> attributes, Set<DiscoveryNodeRole> roles, Version version)
      Creates a new DiscoveryNode

      Note: if the version of the node is unknown Version.minimumCompatibilityVersion() should be used for the current version. it corresponds to the minimum version this elasticsearch version can communicate with. If a higher version is used the node might not be able to communicate with the remote node. After initial handshakes node versions will be discovered and updated.

      Parameters:
      nodeName - the nodes name
      nodeId - the nodes unique persistent id. An ephemeral id will be auto generated.
      address - the nodes transport address
      attributes - node attributes
      roles - node roles
      version - the version of the node
    • DiscoveryNode

      public DiscoveryNode(String nodeName, String nodeId, String ephemeralId, String hostName, String hostAddress, TransportAddress address, Map<String,String> attributes, Set<DiscoveryNodeRole> roles, Version version)
      Creates a new DiscoveryNode.

      Note: if the version of the node is unknown Version.minimumCompatibilityVersion() should be used for the current version. it corresponds to the minimum version this elasticsearch version can communicate with. If a higher version is used the node might not be able to communicate with the remote node. After initial handshakes node versions will be discovered and updated.

      Parameters:
      nodeName - the nodes name
      nodeId - the nodes unique persistent id
      ephemeralId - the nodes unique ephemeral id
      hostAddress - the nodes host address
      address - the nodes transport address
      attributes - node attributes
      roles - node roles
      version - the version of the node
    • DiscoveryNode

      public DiscoveryNode(StreamInput in) throws IOException
      Creates a new DiscoveryNode by reading from the stream provided as argument
      Parameters:
      in - the stream
      Throws:
      IOException - if there is an error while reading from the stream
  • Method Details

    • nodeRequiresLocalStorage

      public static boolean nodeRequiresLocalStorage(Settings settings)
    • hasRole

      public static boolean hasRole(Settings settings, DiscoveryNodeRole role)
    • isMasterNode

      public static boolean isMasterNode(Settings settings)
    • hasDataRole

      public static boolean hasDataRole(Settings settings)
      Check if the given settings are indicative of having the top-level data role. Note that if you want to test for whether or not the given settings are indicative of any role that can contain data, you should use canContainData(Settings).
      Parameters:
      settings - the settings
      Returns:
      true if the given settings are indicative of having the top-level data role, otherwise false
    • canContainData

      public static boolean canContainData(Settings settings)
      Check if the given settings are indicative of any role that can contain data. Note that if you want to test for exactly the data role, you should use hasDataRole(Settings).
      Parameters:
      settings - the settings
      Returns:
      true if the given settings are indicative of having any role that can contain data, otherwise false
    • isIngestNode

      public static boolean isIngestNode(Settings settings)
    • isRemoteClusterClient

      public static boolean isRemoteClusterClient(Settings settings)
    • isDedicatedFrozenNode

      public static boolean isDedicatedFrozenNode(Settings settings)
      Check if the settings are for a dedicated frozen node, i.e. has frozen role and no other data roles.
    • createLocal

      public static DiscoveryNode createLocal(Settings settings, TransportAddress publishAddress, String nodeId)
      Creates a DiscoveryNode representing the local node.
    • getRolesFromSettings

      public static Set<DiscoveryNodeRole> getRolesFromSettings(Settings settings)
      extract node roles from the given settings
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • getAddress

      public TransportAddress getAddress()
      The address that the node can be communicated with.
    • getId

      public String getId()
      The unique id of the node.
    • getEphemeralId

      public String getEphemeralId()
      The unique ephemeral id of the node. Ephemeral ids are meant to be attached the life span of a node process. When ever a node is restarted, it's ephemeral id is required to change (while it's getId() will be read from the data folder and will remain the same across restarts). Since all node attributes and addresses are maintained during the life span of a node process, we can (and are) using the ephemeralId in equals(Object).
    • getName

      public String getName()
      The name of the node.
    • getAttributes

      public Map<String,String> getAttributes()
      The node attributes.
    • canContainData

      public boolean canContainData()
      Should this node hold data (shards) or not.
    • isMasterNode

      public boolean isMasterNode()
      Can this node become master or not.
    • isIngestNode

      public boolean isIngestNode()
      Returns a boolean that tells whether this an ingest node or not
    • isRemoteClusterClient

      public boolean isRemoteClusterClient()
      Returns whether or not the node can be a remote cluster client.
      Returns:
      true if the node can be a remote cluster client, false otherwise
    • isDedicatedFrozenNode

      public boolean isDedicatedFrozenNode()
      Returns whether or not the node is a frozen only node, i.e., has data frozen role and no other data roles.
      Returns:
    • getRoles

      public Set<DiscoveryNodeRole> getRoles()
      Returns a set of all the roles that the node has. The roles are returned in sorted order by the role name.

      If a node does not have any specific role, the returned set is empty, which means that the node is a coordinating-only node.

      Returns:
      the sorted set of roles
    • getVersion

      public Version getVersion()
    • getHostName

      public String getHostName()
    • getHostAddress

      public String getHostAddress()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • appendDescriptionWithoutAttributes

      public void appendDescriptionWithoutAttributes(StringBuilder stringBuilder)
    • descriptionWithoutAttributes

      public String descriptionWithoutAttributes()
    • toXContent

      public org.elasticsearch.xcontent.XContentBuilder toXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface org.elasticsearch.xcontent.ToXContent
      Throws:
      IOException
    • getRoleFromRoleName

      public static DiscoveryNodeRole getRoleFromRoleName(String roleName)
    • getPossibleRoles

      public static Collection<DiscoveryNodeRole> getPossibleRoles()
    • setAdditionalRoles

      public static void setAdditionalRoles(Set<DiscoveryNodeRole> additionalRoles)
    • getPossibleRoleNames

      public static Set<String> getPossibleRoleNames()