public class ClusterState extends Object implements org.noggit.JSONWriter.Writable
ZkStateReader.getClusterState()
.Modifier and Type | Class and Description |
---|---|
static class |
ClusterState.CollectionRef |
Constructor and Description |
---|
ClusterState(Integer znodeVersion,
Set<String> liveNodes,
Map<String,DocCollection> collectionStates)
Use this constr when ClusterState is meant for consumption.
|
ClusterState(Set<String> liveNodes,
Map<String,ClusterState.CollectionRef> collectionStates,
Integer znodeVersion)
Use this if all the collection states are not readily available and some needs to be lazily loaded
|
Modifier and Type | Method and Description |
---|---|
ClusterState |
copyWith(String collectionName,
DocCollection collection)
Returns a new cluster state object modified with the given collection.
|
boolean |
equals(Object obj) |
Collection<Slice> |
getActiveSlices(String collection) |
Map<String,Slice> |
getActiveSlicesMap(String collection) |
DocCollection |
getCollection(String collection)
Get the named DocCollection object, or throw an exception if it doesn't exist.
|
DocCollection |
getCollectionOrNull(String coll) |
ClusterState.CollectionRef |
getCollectionRef(String coll) |
Set<String> |
getCollections()
Get collection names.
|
Replica |
getLeader(String collection,
String sliceName)
Get the lead replica for specific collection, or null if one currently doesn't exist.
|
Set<String> |
getLiveNodes()
Get names of the currently live nodes.
|
Replica |
getReplica(String collection,
String coreNodeName)
Gets the replica by the core name (assuming the slice is unknown) or null if replica is not found.
|
String |
getShardId(String nodeName,
String coreName) |
String |
getShardId(String collectionName,
String nodeName,
String coreName) |
Slice |
getSlice(String collection,
String sliceName)
Get the named Slice for collection, or null if not found.
|
Collection<Slice> |
getSlices(String collection) |
Map<String,Slice> |
getSlicesMap(String collection) |
Integer |
getZkClusterStateVersion()
The version of clusterstate.json in ZooKeeper.
|
boolean |
hasCollection(String coll) |
int |
hashCode() |
boolean |
liveNodesContain(String name)
Check if node is alive.
|
static Aliases |
load(byte[] bytes) |
static ClusterState |
load(Integer version,
byte[] bytes,
Set<String> liveNodes) |
static ClusterState |
load(Integer version,
byte[] bytes,
Set<String> liveNodes,
String znode)
Create ClusterState from json string that is typically stored in zookeeper.
|
String |
toString() |
void |
write(org.noggit.JSONWriter jsonWriter) |
public ClusterState(Integer znodeVersion, Set<String> liveNodes, Map<String,DocCollection> collectionStates)
public ClusterState copyWith(String collectionName, DocCollection collection)
collectionName
- the name of the modified (or deleted) collectioncollection
- the collection object. A null value deletes the collection from the statepublic Replica getLeader(String collection, String sliceName)
public boolean hasCollection(String coll)
public Replica getReplica(String collection, String coreNodeName)
public Slice getSlice(String collection, String sliceName)
public Collection<Slice> getSlices(String collection)
public Collection<Slice> getActiveSlices(String collection)
public DocCollection getCollection(String collection)
public ClusterState.CollectionRef getCollectionRef(String coll)
public DocCollection getCollectionOrNull(String coll)
public boolean liveNodesContain(String name)
public static ClusterState load(Integer version, byte[] bytes, Set<String> liveNodes)
public static ClusterState load(Integer version, byte[] bytes, Set<String> liveNodes, String znode)
version
- zk version of the clusterstate.json file (bytes)bytes
- clusterstate.json as a byte arrayliveNodes
- list of live nodespublic static Aliases load(byte[] bytes)
public void write(org.noggit.JSONWriter jsonWriter)
write
in interface org.noggit.JSONWriter.Writable
public Integer getZkClusterStateVersion()
Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.