Class DiscoveryNode
- All Implemented Interfaces:
Writeable,org.elasticsearch.common.xcontent.ToXContent,org.elasticsearch.common.xcontent.ToXContentFragment
public class DiscoveryNode extends java.lang.Object implements Writeable, org.elasticsearch.common.xcontent.ToXContentFragment
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
-
Constructor Summary
Constructors Constructor Description DiscoveryNode(java.lang.String nodeName, java.lang.String nodeId, java.lang.String ephemeralId, java.lang.String hostName, java.lang.String hostAddress, TransportAddress address, java.util.Map<java.lang.String,java.lang.String> attributes, java.util.Set<DiscoveryNodeRole> roles, Version version)Creates a newDiscoveryNode.DiscoveryNode(java.lang.String nodeName, java.lang.String nodeId, TransportAddress address, java.util.Map<java.lang.String,java.lang.String> attributes, java.util.Set<DiscoveryNodeRole> roles, Version version)Creates a newDiscoveryNodeDiscoveryNode(java.lang.String id, TransportAddress address, java.util.Map<java.lang.String,java.lang.String> attributes, java.util.Set<DiscoveryNodeRole> roles, Version version)Creates a newDiscoveryNodeDiscoveryNode(java.lang.String id, TransportAddress address, Version version)Creates a newDiscoveryNodeDiscoveryNode(StreamInput in)Creates a newDiscoveryNodeby reading from the stream provided as argument -
Method Summary
Modifier and Type Method Description static DiscoveryNodecreateLocal(Settings settings, TransportAddress publishAddress, java.lang.String nodeId)Creates a DiscoveryNode representing the local node.booleanequals(java.lang.Object o)TransportAddressgetAddress()The address that the node can be communicated with.java.util.Map<java.lang.String,java.lang.String>getAttributes()The node attributes.java.lang.StringgetEphemeralId()The unique ephemeral id of the node.java.lang.StringgetHostAddress()java.lang.StringgetHostName()java.lang.StringgetId()The unique id of the node.java.lang.StringgetName()The name of the node.static java.util.Set<java.lang.String>getPossibleRoleNames()static java.util.Set<DiscoveryNodeRole>getPossibleRoles()static DiscoveryNodeRolegetRoleFromRoleName(java.lang.String roleName)java.util.Set<DiscoveryNodeRole>getRoles()Returns a set of all the roles that the node has.static java.util.Set<DiscoveryNodeRole>getRolesFromSettings(Settings settings)extract node roles from the given settingsVersiongetVersion()inthashCode()static booleanhasRole(Settings settings, DiscoveryNodeRole role)booleanisDataNode()Should this node hold data (shards) or not.static booleanisDataNode(Settings settings)Due to the way that plugins may not be available when settings are being initialized, not all roles may be available from a static/initializing context such as aSettingdefault value function.booleanisIngestNode()Returns a boolean that tells whether this an ingest node or notstatic booleanisIngestNode(Settings settings)booleanisMasterNode()Can this node become master or not.static booleanisMasterNode(Settings settings)booleanisRemoteClusterClient()Returns whether or not the node can be a remote cluster client.static booleanisRemoteClusterClient(Settings settings)static booleannodeRequiresLocalStorage(Settings settings)static voidsetAdditionalRoles(java.util.Set<DiscoveryNodeRole> additionalRoles)java.lang.StringtoString()org.elasticsearch.common.xcontent.XContentBuildertoXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)voidwriteTo(StreamOutput out)Write this into the StreamOutput.
-
Constructor Details
-
DiscoveryNode
Creates a newDiscoveryNodeNote: 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 addressversion- the version of the node
-
DiscoveryNode
public DiscoveryNode(java.lang.String id, TransportAddress address, java.util.Map<java.lang.String,java.lang.String> attributes, java.util.Set<DiscoveryNodeRole> roles, Version version)Creates a newDiscoveryNodeNote: 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 addressattributes- node attributesroles- node rolesversion- the version of the node
-
DiscoveryNode
public DiscoveryNode(java.lang.String nodeName, java.lang.String nodeId, TransportAddress address, java.util.Map<java.lang.String,java.lang.String> attributes, java.util.Set<DiscoveryNodeRole> roles, Version version)Creates a newDiscoveryNodeNote: 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 namenodeId- the nodes unique persistent id. An ephemeral id will be auto generated.address- the nodes transport addressattributes- node attributesroles- node rolesversion- the version of the node
-
DiscoveryNode
public DiscoveryNode(java.lang.String nodeName, java.lang.String nodeId, java.lang.String ephemeralId, java.lang.String hostName, java.lang.String hostAddress, TransportAddress address, java.util.Map<java.lang.String,java.lang.String> attributes, java.util.Set<DiscoveryNodeRole> roles, Version version)Creates a newDiscoveryNode.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 namenodeId- the nodes unique persistent idephemeralId- the nodes unique ephemeral idhostAddress- the nodes host addressaddress- the nodes transport addressattributes- node attributesroles- node rolesversion- the version of the node
-
DiscoveryNode
Creates a newDiscoveryNodeby reading from the stream provided as argument- Parameters:
in- the stream- Throws:
java.io.IOException- if there is an error while reading from the stream
-
-
Method Details
-
nodeRequiresLocalStorage
-
hasRole
-
isMasterNode
-
isDataNode
Due to the way that plugins may not be available when settings are being initialized, not all roles may be available from a static/initializing context such as aSettingdefault value function. In that case, be warned that this may not include all plugin roles. -
isIngestNode
-
isRemoteClusterClient
-
createLocal
public static DiscoveryNode createLocal(Settings settings, TransportAddress publishAddress, java.lang.String nodeId)Creates a DiscoveryNode representing the local node. -
getRolesFromSettings
extract node roles from the given settings -
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput. -
getAddress
The address that the node can be communicated with. -
getId
public java.lang.String getId()The unique id of the node. -
getEphemeralId
public java.lang.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'sgetId()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 inequals(Object). -
getName
public java.lang.String getName()The name of the node. -
getAttributes
public java.util.Map<java.lang.String,java.lang.String> getAttributes()The node attributes. -
isDataNode
public boolean isDataNode()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
-
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
-
getHostName
public java.lang.String getHostName() -
getHostAddress
public java.lang.String getHostAddress() -
equals
public boolean equals(java.lang.Object o)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
toXContent
public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException- Specified by:
toXContentin interfaceorg.elasticsearch.common.xcontent.ToXContent- Throws:
java.io.IOException
-
getRoleFromRoleName
-
getPossibleRoles
-
setAdditionalRoles
-
getPossibleRoleNames
public static java.util.Set<java.lang.String> getPossibleRoleNames()
-