Package org.elasticsearch.cluster.node
Class DiscoveryNodes
java.lang.Object
org.elasticsearch.cluster.AbstractDiffable<DiscoveryNodes>
org.elasticsearch.cluster.node.DiscoveryNodes
- All Implemented Interfaces:
java.lang.Iterable<DiscoveryNode>,Diffable<DiscoveryNodes>,Writeable
public class DiscoveryNodes extends AbstractDiffable<DiscoveryNodes> implements java.lang.Iterable<DiscoveryNode>
This class holds all
DiscoveryNode in the cluster and provides convenience methods to
access, modify merge / diff discovery nodes.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDiscoveryNodes.Builderstatic classDiscoveryNodes.DeltaNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
Fields Modifier and Type Field Description static DiscoveryNodesEMPTY_NODES -
Method Summary
Modifier and Type Method Description static DiscoveryNodes.Builderbuilder()static DiscoveryNodes.Builderbuilder(DiscoveryNodes nodes)DiscoveryNodes.Deltadelta(DiscoveryNodes other)Returns the changes comparing this nodes to the provided nodes.DiscoveryNodefindByAddress(TransportAddress address)Get a node by its addressDiscoveryNodeget(java.lang.String nodeId)Get a node by its idImmutableOpenMap<java.lang.String,DiscoveryNode>getCoordinatingOnlyNodes()Get aMapof the coordinating only nodes (nodes which are neither master, nor data, nor ingest nodes) arranged by their idsImmutableOpenMap<java.lang.String,DiscoveryNode>getDataNodes()Get aMapof the discovered data nodes arranged by their idsImmutableOpenMap<java.lang.String,DiscoveryNode>getIngestNodes()VersiongetLargestNonClientNodeVersion()Returns the version of the node with the youngest version in the cluster that is not a client node.DiscoveryNodegetLocalNode()Get the local nodejava.lang.StringgetLocalNodeId()Get the id of the local nodeImmutableOpenMap<java.lang.String,DiscoveryNode>getMasterAndDataNodes()Get aMapof the discovered master and data nodes arranged by their idsDiscoveryNodegetMasterNode()Returns the master node, ornullif there is no master nodejava.lang.StringgetMasterNodeId()Get the id of the master nodeImmutableOpenMap<java.lang.String,DiscoveryNode>getMasterNodes()Get aMapof the discovered master nodes arranged by their idsVersiongetMaxNodeVersion()Returns the version of the node with the youngest version in the clusterVersiongetMinNodeVersion()Returns the version of the node with the oldest version in the cluster.ImmutableOpenMap<java.lang.String,DiscoveryNode>getNodes()Get aMapof the discovered nodes arranged by their idsintgetSize()Get the number of known nodesVersiongetSmallestNonClientNodeVersion()Returns the version of the node with the oldest version in the cluster that is not a client node If there are no non-client nodes, Version.CURRENT will be returned.booleanisLocalNodeElectedMaster()Returnstrueif the local node is the elected master node.java.util.Iterator<DiscoveryNode>iterator()java.util.stream.Stream<DiscoveryNode>mastersFirstStream()Returns a stream of all nodes, with master nodes at the frontDiscoveryNodesnewNode(DiscoveryNode node)booleannodeExists(java.lang.String nodeId)Determine if a given node id existsbooleannodeExists(DiscoveryNode node)Determine if a given node existsstatic Diff<DiscoveryNodes>readDiffFrom(StreamInput in, DiscoveryNode localNode)static DiscoveryNodesreadFrom(StreamInput in, DiscoveryNode localNode)DiscoveryNoderesolveNode(java.lang.String node)Resolve a node with a given idjava.lang.String[]resolveNodes(java.lang.String... nodes)Resolves a set of nodes according to the given sequence of node specifications.java.lang.StringtoString()voidwriteTo(StreamOutput out)Write this into the StreamOutput.
-
Field Details
-
Method Details
-
iterator
- Specified by:
iteratorin interfacejava.lang.Iterable<DiscoveryNode>
-
isLocalNodeElectedMaster
public boolean isLocalNodeElectedMaster()Returnstrueif the local node is the elected master node. -
getSize
public int getSize()Get the number of known nodes- Returns:
- number of nodes
-
getNodes
Get aMapof the discovered nodes arranged by their ids- Returns:
Mapof the discovered nodes arranged by their ids
-
getDataNodes
Get aMapof the discovered data nodes arranged by their ids- Returns:
Mapof the discovered data nodes arranged by their ids
-
getMasterNodes
Get aMapof the discovered master nodes arranged by their ids- Returns:
Mapof the discovered master nodes arranged by their ids
-
getIngestNodes
- Returns:
- All the ingest nodes arranged by their ids
-
getMasterAndDataNodes
Get aMapof the discovered master and data nodes arranged by their ids- Returns:
Mapof the discovered master and data nodes arranged by their ids
-
getCoordinatingOnlyNodes
Get aMapof the coordinating only nodes (nodes which are neither master, nor data, nor ingest nodes) arranged by their ids- Returns:
Mapof the coordinating only nodes arranged by their ids
-
mastersFirstStream
Returns a stream of all nodes, with master nodes at the front -
get
Get a node by its id- Parameters:
nodeId- id of the wanted node- Returns:
- wanted node if it exists. Otherwise
null
-
nodeExists
public boolean nodeExists(java.lang.String nodeId)Determine if a given node id exists- Parameters:
nodeId- id of the node which existence should be verified- Returns:
trueif the node exists. Otherwisefalse
-
nodeExists
Determine if a given node exists- Parameters:
node- of the node which existence should be verified- Returns:
trueif the node exists. Otherwisefalse
-
getMasterNodeId
public java.lang.String getMasterNodeId()Get the id of the master node- Returns:
- id of the master
-
getLocalNodeId
public java.lang.String getLocalNodeId()Get the id of the local node- Returns:
- id of the local node
-
getLocalNode
Get the local node- Returns:
- local node
-
getMasterNode
Returns the master node, ornullif there is no master node -
findByAddress
Get a node by its address- Parameters:
address-TransportAddressof the wanted node- Returns:
- node identified by the given address or
nullif no such node exists
-
getSmallestNonClientNodeVersion
Returns the version of the node with the oldest version in the cluster that is not a client node If there are no non-client nodes, Version.CURRENT will be returned.- Returns:
- the oldest version in the cluster
-
getLargestNonClientNodeVersion
Returns the version of the node with the youngest version in the cluster that is not a client node. If there are no non-client nodes, Version.CURRENT will be returned.- Returns:
- the youngest version in the cluster
-
getMinNodeVersion
Returns the version of the node with the oldest version in the cluster.- Returns:
- the oldest version in the cluster
-
getMaxNodeVersion
Returns the version of the node with the youngest version in the cluster- Returns:
- the youngest version in the cluster
-
resolveNode
Resolve a node with a given id- Parameters:
node- id of the node to discover- Returns:
- discovered node matching the given id
- Throws:
java.lang.IllegalArgumentException- if more than one node matches the request or no nodes have been resolved
-
resolveNodes
public java.lang.String[] resolveNodes(java.lang.String... nodes)Resolves a set of nodes according to the given sequence of node specifications. Implements the logic in various APIs that allow the user to run the action on a subset of the nodes in the cluster. See [Node specification] in the reference manual for full details. Works by tracking the current set of nodes and applying each node specification in sequence. The set starts out empty and each node specification may either add or remove nodes. For instance: - _local, _master and _all respectively add to the subset the local node, the currently-elected master, and all the nodes - node IDs, names, hostnames and IP addresses all add to the subset any nodes which match - a wildcard-based pattern of the form "attr*:value*" adds to the subset all nodes with a matching attribute with a matching value - role:true adds to the subset all nodes with a matching role - role:false removes from the subset all nodes with a matching role. An empty sequence of node specifications returns all nodes, since the corresponding actions run on all nodes by default. -
newNode
-
delta
Returns the changes comparing this nodes to the provided nodes. -
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput. -
readFrom
public static DiscoveryNodes readFrom(StreamInput in, DiscoveryNode localNode) throws java.io.IOException- Throws:
java.io.IOException
-
readDiffFrom
public static Diff<DiscoveryNodes> readDiffFrom(StreamInput in, DiscoveryNode localNode) throws java.io.IOException- Throws:
java.io.IOException
-
builder
-
builder
-