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 allDiscoveryNode
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 class
DiscoveryNodes.Builder
static class
DiscoveryNodes.Delta
-
Nested 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 DiscoveryNodes
EMPTY_NODES
-
Method Summary
Modifier and Type Method Description static DiscoveryNodes.Builder
builder()
static DiscoveryNodes.Builder
builder(DiscoveryNodes nodes)
DiscoveryNodes.Delta
delta(DiscoveryNodes other)
Returns the changes comparing this nodes to the provided nodes.DiscoveryNode
findByAddress(TransportAddress address)
Get a node by its addressDiscoveryNode
get(java.lang.String nodeId)
Get a node by its idImmutableOpenMap<java.lang.String,DiscoveryNode>
getCoordinatingOnlyNodes()
Get aMap
of the coordinating only nodes (nodes which are neither master, nor data, nor ingest nodes) arranged by their idsImmutableOpenMap<java.lang.String,DiscoveryNode>
getDataNodes()
Get aMap
of the discovered data nodes arranged by their idsImmutableOpenMap<java.lang.String,DiscoveryNode>
getIngestNodes()
Version
getLargestNonClientNodeVersion()
Returns the version of the node with the youngest version in the cluster that is not a client node.DiscoveryNode
getLocalNode()
Get the local nodejava.lang.String
getLocalNodeId()
Get the id of the local nodeImmutableOpenMap<java.lang.String,DiscoveryNode>
getMasterAndDataNodes()
Get aMap
of the discovered master and data nodes arranged by their idsDiscoveryNode
getMasterNode()
Get the master nodejava.lang.String
getMasterNodeId()
Get the id of the master nodeImmutableOpenMap<java.lang.String,DiscoveryNode>
getMasterNodes()
Get aMap
of the discovered master nodes arranged by their idsVersion
getMaxNodeVersion()
Returns the version of the node with the youngest version in the clusterVersion
getMinNodeVersion()
Returns the version of the node with the oldest version in the cluster.ImmutableOpenMap<java.lang.String,DiscoveryNode>
getNodes()
Get aMap
of the discovered nodes arranged by their idsint
getSize()
Get the number of known nodesVersion
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.boolean
isLocalNodeElectedMaster()
Returnstrue
if the local node is the elected master node.java.util.Iterator<DiscoveryNode>
iterator()
DiscoveryNodes
newNode(DiscoveryNode node)
boolean
nodeExists(java.lang.String nodeId)
Determine if a given node id existsboolean
nodeExists(DiscoveryNode node)
Determine if a given node existsstatic Diff<DiscoveryNodes>
readDiffFrom(StreamInput in, DiscoveryNode localNode)
static DiscoveryNodes
readFrom(StreamInput in, DiscoveryNode localNode)
DiscoveryNode
resolveNode(java.lang.String node)
Resolve a node with a given idjava.lang.String[]
resolveNodes(java.lang.String... nodes)
resolves a set of node "descriptions" to concrete and existing node ids.java.lang.String
toString()
void
writeTo(StreamOutput out)
Write this into the StreamOutput.-
Methods inherited from class org.elasticsearch.cluster.AbstractDiffable
diff, get, readDiffFrom
-
-
-
-
Field Detail
-
EMPTY_NODES
public static final DiscoveryNodes EMPTY_NODES
-
-
Method Detail
-
iterator
public java.util.Iterator<DiscoveryNode> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<DiscoveryNode>
-
isLocalNodeElectedMaster
public boolean isLocalNodeElectedMaster()
Returnstrue
if the local node is the elected master node.
-
getSize
public int getSize()
Get the number of known nodes- Returns:
- number of nodes
-
getNodes
public ImmutableOpenMap<java.lang.String,DiscoveryNode> getNodes()
Get aMap
of the discovered nodes arranged by their ids- Returns:
Map
of the discovered nodes arranged by their ids
-
getDataNodes
public ImmutableOpenMap<java.lang.String,DiscoveryNode> getDataNodes()
Get aMap
of the discovered data nodes arranged by their ids- Returns:
Map
of the discovered data nodes arranged by their ids
-
getMasterNodes
public ImmutableOpenMap<java.lang.String,DiscoveryNode> getMasterNodes()
Get aMap
of the discovered master nodes arranged by their ids- Returns:
Map
of the discovered master nodes arranged by their ids
-
getIngestNodes
public ImmutableOpenMap<java.lang.String,DiscoveryNode> getIngestNodes()
- Returns:
- All the ingest nodes arranged by their ids
-
getMasterAndDataNodes
public ImmutableOpenMap<java.lang.String,DiscoveryNode> getMasterAndDataNodes()
Get aMap
of the discovered master and data nodes arranged by their ids- Returns:
Map
of the discovered master and data nodes arranged by their ids
-
getCoordinatingOnlyNodes
public ImmutableOpenMap<java.lang.String,DiscoveryNode> getCoordinatingOnlyNodes()
Get aMap
of the coordinating only nodes (nodes which are neither master, nor data, nor ingest nodes) arranged by their ids- Returns:
Map
of the coordinating only nodes arranged by their ids
-
get
public DiscoveryNode get(java.lang.String nodeId)
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:
true
if the node exists. Otherwisefalse
-
nodeExists
public boolean nodeExists(DiscoveryNode node)
Determine if a given node exists- Parameters:
node
- of the node which existence should be verified- Returns:
true
if 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
public DiscoveryNode getLocalNode()
Get the local node- Returns:
- local node
-
getMasterNode
public DiscoveryNode getMasterNode()
Get the master node- Returns:
- master node
-
findByAddress
public DiscoveryNode findByAddress(TransportAddress address)
Get a node by its address- Parameters:
address
-TransportAddress
of the wanted node- Returns:
- node identified by the given address or
null
if no such node exists
-
getSmallestNonClientNodeVersion
public Version 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
public Version 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
public Version getMinNodeVersion()
Returns the version of the node with the oldest version in the cluster.- Returns:
- the oldest version in the cluster
-
getMaxNodeVersion
public Version getMaxNodeVersion()
Returns the version of the node with the youngest version in the cluster- Returns:
- the youngest version in the cluster
-
resolveNode
public DiscoveryNode resolveNode(java.lang.String node)
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 node "descriptions" to concrete and existing node ids. "descriptions" can be (resolved in this order): - "_local" or "_master" for the relevant nodes - a node id - a wild card pattern that will be matched against node names - a "attr:value" pattern, where attr can be a node role (master, data, ingest etc.) in which case the value can be true or false, or a generic node attribute name in which case value will be treated as a wildcard and matched against the node attribute values.
-
newNode
public DiscoveryNodes newNode(DiscoveryNode node)
-
delta
public DiscoveryNodes.Delta delta(DiscoveryNodes other)
Returns the changes comparing this nodes to the provided nodes.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
Description copied from interface:Writeable
Write 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
public static DiscoveryNodes.Builder builder()
-
builder
public static DiscoveryNodes.Builder builder(DiscoveryNodes nodes)
-
-