Class ClusterState
- java.lang.Object
- 
- org.apache.solr.common.cloud.ClusterState
 
- 
- All Implemented Interfaces:
- MapSerializable,- MapWriter,- NavigableObject,- org.noggit.JSONWriter.Writable
 
 public class ClusterState extends Object implements MapWriter Immutable state of the cloud. Normally you can get the state by usingZkStateReader#getClusterState().However, the list of live nodesis updated when nodes go up and down.- WARNING: This API is experimental and might change in incompatible ways in the next release.
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classClusterState.CollectionRef- 
Nested classes/interfaces inherited from interface org.apache.solr.common.MapWriterMapWriter.EntryWriter
 
- 
 - 
Field SummaryFields Modifier and Type Field Description static StringURL_SCHEMECluster Prop that is http or https.
 - 
Constructor SummaryConstructors Constructor Description ClusterState(Map<String,ClusterState.CollectionRef> collectionStates, Set<String> liveNodes)Use this if all the collection states are not readily available and some needs to be lazily loaded (parameter order different from constructor above to have different erasures)ClusterState(Set<String> liveNodes, Map<String,DocCollection> collectionStates)Use this constr when ClusterState is meant for consumption.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static DocCollectioncollectionFromObjects(String name, Map<String,Object> objs, int version, Instant creationTime, DocCollection.PrsSupplier prsSupplier)Stream<DocCollection>collectionStream()Streams the resolvedDocCollections, which will often fetch from ZooKeeper for each one for a many-collection scenario.ClusterStatecopyWith(String collectionName, DocCollection collection)Returns a new cluster state object modified with the given collection.static ClusterStatecreateFromCollectionMap(int version, Map<String,Object> stateMap, Set<String> liveNodes)Deprecated.static ClusterStatecreateFromCollectionMap(int version, Map<String,Object> stateMap, Set<String> liveNodes, Instant creationTime, DocCollection.PrsSupplier prsSupplier)Deprecated.static ClusterStatecreateFromJson(int version, byte[] bytes, Set<String> liveNodes)Deprecated.static ClusterStatecreateFromJson(int version, byte[] bytes, Set<String> liveNodes, Instant creationTime, DocCollection.PrsSupplier prsSupplier)Deprecated.booleanequals(Object obj)voidforEachCollection(Consumer<DocCollection> consumer)Deprecated.DocCollectiongetCollection(String collection)Get the named DocCollection object, or throw an exception if it doesn't exist.Collection<String>getCollectionNames()The collection names.DocCollectiongetCollectionOrNull(String collectionName)Returns the correspondingDocCollectionobject for the given collection name if such a collection exists.DocCollectiongetCollectionOrNull(String collectionName, boolean allowCached)Returns the correspondingDocCollectionobject for the given collection name if such a collection exists.ClusterState.CollectionRefgetCollectionRef(String coll)Map<String,DocCollection>getCollectionsMap()Deprecated.Map<String,ClusterState.CollectionRef>getCollectionStates()Deprecated.Set<String>getLiveNodes()Get names of the currently live nodes.Map<String,List<Replica>>getReplicaNamesPerCollectionOnNode(String nodeName)Deprecated.StringgetShardId(String nodeName, String coreName)Deprecated.StringgetShardId(String collectionName, String nodeName, String coreName)Deprecated.booleanhasCollection(String collectionName)Returns true if the specified collection name exists, false otherwise.inthashCode()booleanliveNodesContain(String name)Check if node is alive.static voidsetStrInternerParser(Function<org.noggit.JSONParser,org.noggit.ObjectBuilder> fun)intsize()The approximate number of collections.StringtoString()voidwriteMap(MapWriter.EntryWriter ew)- 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface org.apache.solr.common.NavigableObject_forEachEntry, _forEachEntry, _forEachEntry, _get, _get, _getStr, _getStr, _size
 
- 
 
- 
- 
- 
Field Detail- 
URL_SCHEMEpublic static final String URL_SCHEME Cluster Prop that is http or https.- See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
ClusterStatepublic ClusterState(Set<String> liveNodes, Map<String,DocCollection> collectionStates) Use this constr when ClusterState is meant for consumption.
 - 
ClusterStatepublic ClusterState(Map<String,ClusterState.CollectionRef> collectionStates, Set<String> liveNodes) Use this if all the collection states are not readily available and some needs to be lazily loaded (parameter order different from constructor above to have different erasures)
 
- 
 - 
Method Detail- 
copyWithpublic ClusterState copyWith(String collectionName, DocCollection collection) Returns a new cluster state object modified with the given collection.- Parameters:
- collectionName- the name of the modified (or deleted) collection
- collection- the collection object. A null value deletes the collection from the state
- Returns:
- the updated cluster state which preserves the current live nodes
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
 
 - 
hasCollectionpublic boolean hasCollection(String collectionName) Returns true if the specified collection name exists, false otherwise.Implementation note: This method resolves the collection reference by calling ClusterState.CollectionRef.get()which can make a call to ZooKeeper. This is necessary because the semantics of how collection list is loaded have changed in SOLR-6629.
 - 
getCollectionpublic DocCollection getCollection(String collection) Get the named DocCollection object, or throw an exception if it doesn't exist.
 - 
getCollectionRefpublic ClusterState.CollectionRef getCollectionRef(String coll) 
 - 
getCollectionOrNullpublic DocCollection getCollectionOrNull(String collectionName) Returns the correspondingDocCollectionobject for the given collection name if such a collection exists. Returns null otherwise. Equivalent to getCollectionOrNull(collectionName, false)
 - 
getCollectionOrNullpublic DocCollection getCollectionOrNull(String collectionName, boolean allowCached) Returns the correspondingDocCollectionobject for the given collection name if such a collection exists. Returns null otherwise.- Parameters:
- collectionName- Name of the collection
- allowCached- allow LazyCollectionRefs to use a time-based cached value- Implementation note: This method resolves the collection reference by calling - ClusterState.CollectionRef.get()which may make a call to ZooKeeper. This is necessary because the semantics of how collection list is loaded have changed in SOLR-6629.
 
 - 
getCollectionNamespublic Collection<String> getCollectionNames() The collection names. Like a Set but might not implement it. Immutable; non-null. Some names returned might not resolve viagetCollectionOrNull(String), so consider this a close approximation.
 - 
getCollectionsMap@Deprecated public Map<String,DocCollection> getCollectionsMap() Deprecated.Get a map of collection name vs DocCollection objectsImplementation note: This method resolves the collection reference by calling ClusterState.CollectionRef.get()which can make a call to ZooKeeper. This is necessary because the semantics of how collection list is loaded have changed in SOLR-6629.- Returns:
- a map of collection name vs DocCollection object
 
 - 
getShardId@Deprecated public String getShardId(String nodeName, String coreName) Deprecated.
 - 
getShardId@Deprecated public String getShardId(String collectionName, String nodeName, String coreName) Deprecated.
 - 
getReplicaNamesPerCollectionOnNode@Deprecated public Map<String,List<Replica>> getReplicaNamesPerCollectionOnNode(String nodeName) Deprecated.
 - 
liveNodesContainpublic boolean liveNodesContain(String name) Check if node is alive.
 - 
createFromJson@Deprecated public static ClusterState createFromJson(int version, byte[] bytes, Set<String> liveNodes, Instant creationTime, DocCollection.PrsSupplier prsSupplier) Deprecated.Create a ClusterState from Json. This method doesn't support legacy configName location and thus don't call it where that's important- Parameters:
- bytes- a byte array of a Json representation of a mapping from collection name to the Json representation of a- DocCollectionas written by- MapWriter.write(JSONWriter). It can represent one or more collections.
- liveNodes- list of live nodes
- creationTime- assigns this date to all- DocCollectionreferenced by the returned- ClusterState
- Returns:
- the ClusterState
 
 - 
createFromJson@Deprecated public static ClusterState createFromJson(int version, byte[] bytes, Set<String> liveNodes) Deprecated.
 - 
createFromCollectionMap@Deprecated public static ClusterState createFromCollectionMap(int version, Map<String,Object> stateMap, Set<String> liveNodes, Instant creationTime, DocCollection.PrsSupplier prsSupplier) Deprecated.
 - 
createFromCollectionMap@Deprecated public static ClusterState createFromCollectionMap(int version, Map<String,Object> stateMap, Set<String> liveNodes) Deprecated.
 - 
collectionFromObjectspublic static DocCollection collectionFromObjects(String name, Map<String,Object> objs, int version, Instant creationTime, DocCollection.PrsSupplier prsSupplier) - NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
 
 - 
writeMappublic void writeMap(MapWriter.EntryWriter ew) throws IOException - Specified by:
- writeMapin interface- MapWriter
- Throws:
- IOException
 
 - 
getCollectionStates@Deprecated public Map<String,ClusterState.CollectionRef> getCollectionStates() Deprecated.Be aware that this may return collections which may not exist now. You can confirm that this collection exists after verifying CollectionRef.get() != null
 - 
collectionStreampublic Stream<DocCollection> collectionStream() Streams the resolvedDocCollections, which will often fetch from ZooKeeper for each one for a many-collection scenario. Use this sparingly; some users have thousands of collections!
 - 
forEachCollection@Deprecated public void forEachCollection(Consumer<DocCollection> consumer) Deprecated.Callsconsumerwith a resolvedDocCollections for all collections. Use this sparingly in case there are many collections.
 - 
sizepublic int size() The approximate number of collections.
 - 
setStrInternerParserpublic static void setStrInternerParser(Function<org.noggit.JSONParser,org.noggit.ObjectBuilder> fun) - NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
 
 
- 
 
-