java.lang.Object
org.elasticsearch.cluster.routing.GlobalRoutingTable
- All Implemented Interfaces:
Iterable<RoutingTable>,Diffable<GlobalRoutingTable>,Writeable
public class GlobalRoutingTable
extends Object
implements Iterable<RoutingTable>, Diffable<GlobalRoutingTable>
A routing table for the whole cluster (potentially containing multiple projects)
The global routing table holds a separate
RoutingTable for each project that exists in the cluster-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic GlobalRoutingTable.Builderbuilder()static GlobalRoutingTable.Builderbuilder(GlobalRoutingTable routingTable) diff(GlobalRoutingTable previousState) Returns serializable object representing differences between this and previousStateDeprecated.booleanbooleanindexRouting(Metadata metadata, Index index) indexRouting(ProjectId id, Index index) initializeProjects(Set<ProjectId> projectIds) iterator()static Diff<GlobalRoutingTable> static GlobalRoutingTablereadFrom(StreamInput in) rebuild(RoutingNodes routingNodes, Metadata metadata) Constructs a new routing table with the project routing tables rebuilt based on the providedRoutingNodesparameter.removeProject(ProjectId project) routingTable(ProjectId projectId) intsize()toString()booleanValidates that this routing table is consistent with the set of projects that exist in theMetadata.voidwriteTo(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
EMPTY_ROUTING_TABLE
-
-
Constructor Details
-
GlobalRoutingTable
-
-
Method Details
-
rebuild
Constructs a new routing table with the project routing tables rebuilt based on the providedRoutingNodesparameter. -
getRoutingTable
Deprecated.TODO: Remove this method, replace with routingTable(ProjectId)- Returns:
- If this routing table is empty (has no projects), then an empty
RoutingTable - If this routing table has one element (a single project), then the
RoutingTablefor that project - Otherwise throws an exception
- If this routing table is empty (has no projects), then an empty
-
routingTable
- Returns:
- THe routing table for project
projectId, or throws an exception if the project does not exist in this routing table - See Also:
-
routingTables
- Returns:
- A
Mapof project-scopedRoutingTableinstances
-
size
public int size()- Returns:
- The number of projects in this routing table
- See Also:
-
iterator
- Specified by:
iteratorin interfaceIterable<RoutingTable>
-
diff
Description copied from interface:DiffableReturns serializable object representing differences between this and previousState- Specified by:
diffin interfaceDiffable<GlobalRoutingTable>
-
readDiffFrom
- Throws:
IOException
-
readFrom
- Throws:
IOException
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
hasSameIndexRouting
- Returns:
trueif this table has exactly the sameindex routingas theotherrouting table. In this case "same" refers to object-identity, not just equality - this method is intended to be used as an efficient shortcut to determine if twoGlobalRoutingTableinstances have identical state.
-
removeProject
- Returns:
- If this routing table contains
project, then a new routing table that is a clone of this routing table with the specified project removed Otherwise returns this routing table unchanged.
-
initializeProjects
- Returns:
- A routing table that contains all of the projects in this routing-table plus, an empty routing table for any project
in
projectIdsthat does not already exist in this routing table. The returned routing table may bethisobject if it satisfies these conditions.
-
validate
Validates that this routing table is consistent with the set of projects that exist in theMetadata.- Returns:
- A
booleanso that this method can be used in anassertstatement. This will betrueif the routing table and metadata are in-sync. Will never returnfalsebecause validation execptions always throw an exception. - Throws:
IllegalStateException- if validation fails
-
indexRouting
-
indexRouting
-
indexRouting
-
hasIndices
public boolean hasIndices() -
builder
-
builder
-
toString
-