Package org.apache.solr.common.cloud
Class ClusterState
java.lang.Object
org.apache.solr.common.cloud.ClusterState
- All Implemented Interfaces:
MapSerializable,MapWriter,NavigableObject,org.noggit.JSONWriter.Writable
Immutable state of the cloud. Normally you can get the state by using
ZkStateReader#getClusterState().
However, the list of live nodes is updated when nodes go up and down.
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.apache.solr.common.MapWriter
MapWriter.EntryWriter -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionClusterState(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 Summary
Modifier and TypeMethodDescriptionstatic DocCollectioncollectionFromObjects(String name, Map<String, Object> objs, int version, Instant creationTime, DocCollection.PrsSupplier prsSupplier) Streams the resolvedDocCollections, which will often fetch from ZooKeeper for each one for a many-collection scenario.copyWith(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, Instant creationTime, DocCollection.PrsSupplier prsSupplier) Deprecated.static ClusterStatecreateFromJson(int version, byte[] bytes, Set<String> liveNodes, Instant creationTime, DocCollection.PrsSupplier prsSupplier) Deprecated.booleangetCollection(String collection) Get the named DocCollection object, or throw an exception if it doesn't exist.The collection names.getCollectionOrNull(String collectionName) Returns the correspondingDocCollectionobject for the given collection name if such a collection exists.getCollectionOrNull(String collectionName, boolean allowCached) Returns the correspondingDocCollectionobject for the given collection name if such a collection exists.getCollectionRef(String coll) Get names of the currently live nodes.getReplicaNamesPerCollectionOnNode(String nodeName) 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.toString()voidWrites this object's entries out toew.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.solr.common.NavigableObject
_forEachEntry, _forEachEntry, _forEachEntry, _get, _get, _getStr, _getStr, _size
-
Field Details
-
URL_SCHEME
Cluster Prop that is http or https.- See Also:
-
-
Constructor Details
-
ClusterState
Use this constr when ClusterState is meant for consumption. -
ClusterState
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 Details
-
copyWith
Returns a new cluster state object modified with the given collection.- Parameters:
collectionName- the name of the modified (or deleted) collectioncollection- 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.
-
hasCollection
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. -
getCollection
Get the named DocCollection object, or throw an exception if it doesn't exist. -
getCollectionRef
-
getCollectionOrNull
Returns the correspondingDocCollectionobject for the given collection name if such a collection exists. Returns null otherwise. Equivalent to getCollectionOrNull(collectionName, false) -
getCollectionOrNull
Returns the correspondingDocCollectionobject for the given collection name if such a collection exists. Returns null otherwise.- Parameters:
collectionName- Name of the collectionallowCached- allow LazyCollectionRefs to use a time-based cached valueImplementation 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.
-
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. -
getLiveNodes
Get names of the currently live nodes. -
getReplicaNamesPerCollectionOnNode
Deprecated. -
liveNodesContain
Check if node is alive. -
toString
-
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 aDocCollectionas written byMapWriter.write(JSONWriter). It can represent one or more collections.liveNodes- list of live nodescreationTime- assigns this date to allDocCollectionreferenced by the returnedClusterState- Returns:
- the ClusterState
-
createFromCollectionMap
@Deprecated public static ClusterState createFromCollectionMap(int version, Map<String, Object> stateMap, Set<String> liveNodes, Instant creationTime, DocCollection.PrsSupplier prsSupplier) Deprecated. -
collectionFromObjects
public 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.
-
writeMap
Description copied from interface:MapWriterWrites this object's entries out toew.- Specified by:
writeMapin interfaceMapWriter- Throws:
IOException
-
hashCode
public int hashCode() -
equals
-
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! -
size
public int size()The approximate number of collections. -
setStrInternerParser
public 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.
-