Package org.apache.solr.common.cloud
Class DocCollection
- java.lang.Object
- 
- org.apache.solr.common.cloud.ZkNodeProps
- 
- org.apache.solr.common.cloud.DocCollection
 
 
- 
- All Implemented Interfaces:
- Iterable<Slice>,- MapSerializable,- MapWriter,- NavigableObject,- org.noggit.JSONWriter.Writable
 
 public class DocCollection extends ZkNodeProps implements Iterable<Slice> Models a Collection in zookeeper (but that Java name is obviously taken, hence "DocCollection")
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static interfaceDocCollection.CollectionStatePropsJSON properties related to a collection's state.static interfaceDocCollection.PrsSupplier- 
Nested classes/interfaces inherited from interface org.apache.solr.common.MapWriterMapWriter.EntryWriter
 
- 
 - 
Field SummaryFields Modifier and Type Field Description static StringCOLLECTIONS_ZKNODE- 
Fields inherited from class org.apache.solr.common.cloud.ZkNodePropspropMap
 
- 
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DocCollectioncopyWithSlices(Map<String,Slice> slices)Use this to make an exact copy of DocCollection with a new set of Slices and every other property as isstatic DocCollectioncreate(String name, Map<String,Slice> slices, Map<String,Object> props, DocRouter router, int zkVersion, Instant creationTime, DocCollection.PrsSupplier prsSupplier)Builds a DocCollection with an optional PrsSupplierbooleanequals(Object that)voidforEachReplica(BiConsumer<String,Replica> consumer)Collection<Slice>getActiveSlices()Return the list of active slices for this collection.Slice[]getActiveSlicesArr()Deprecated.Map<String,Slice>getActiveSlicesMap()Get the map of active slices (sliceName->Slice) for this collection.intgetChildNodesVersion()static StringgetCollectionPath(String coll)static StringgetCollectionPathRoot(String coll)StringgetConfigName()Return non-null config nameInstantgetCreationTime()The creation time of the Collection.intgetExpectedReplicaCount(Replica.Type type, int def)ReplicagetLeader(String sliceName)List<Replica>getLeaderReplicas(String nodeName)Deprecated.StringgetName()Return collection name.IntegergetNumNrtReplicas()IntegergetNumPullReplicas()IntegergetNumTlogReplicas()PerReplicaStatesgetPerReplicaStates()ReplicagetReplica(String coreNodeName)ReplicagetReplica(BiPredicate<String,Replica> predicate)Deprecated.List<Replica>getReplicas()Deprecated.List<Replica>getReplicas(String nodeName)Get the list of replicas hosted on the given node ornullif none.List<Replica>getReplicas(EnumSet<Replica.Type> s)Deprecated.IntegergetReplicationFactor()DocRoutergetRouter()StringgetShardId(String nodeName, String coreName)Get the shardId of a core on a specific nodeSlicegetSlice(String sliceName)Collection<Slice>getSlices()Gets the list of all slices for this collection.Map<String,Slice>getSlicesMap()Get the map of all slices (sliceName->Slice) for this collection.StringgetZNode()intgetZNodeVersion()inthashCode()static booleanisFullyActive(Set<String> liveNodes, DocCollection collectionState, int expectedShards, int expectedReplicas)Check that all replicas in a collection are livebooleanisModified(int dataVersion, int childVersion)booleanisPerReplicaState()booleanisReadOnly()Iterator<Slice>iterator()DocCollectionsetPerReplicaStates(PerReplicaStates newPerReplicaStates)Update our state with a state of aPerReplicaStateswhich could override states ofReplica.StringtoString()static ObjectverifyProp(Map<String,Object> props, String propName)voidwriteMap(MapWriter.EntryWriter ew)- 
Methods inherited from class org.apache.solr.common.cloud.ZkNodePropscontainsKey, fromKeyVals, get, getBool, getInt, getProperties, getStr, getStr, keySet, load, plus, plus, shallowCopy
 - 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface java.lang.IterableforEach, spliterator
 - 
Methods inherited from interface org.apache.solr.common.NavigableObject_forEachEntry, _forEachEntry, _forEachEntry, _get, _get, _getStr, _getStr, _size
 
- 
 
- 
- 
- 
Field Detail- 
COLLECTIONS_ZKNODEpublic static final String COLLECTIONS_ZKNODE - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
DocCollection@Deprecated public DocCollection(String name, Map<String,Slice> slices, Map<String,Object> props, DocRouter router) Deprecated.
 
- 
 - 
Method Detail- 
createpublic static DocCollection create(String name, Map<String,Slice> slices, Map<String,Object> props, DocRouter router, int zkVersion, Instant creationTime, DocCollection.PrsSupplier prsSupplier) Builds a DocCollection with an optional PrsSupplier- Parameters:
- name- The name of the collection
- slices- The logical shards of the collection. This is used directly and a copy is not made.
- props- The properties of the slice. This is used directly and a copy is not made.
- router- router to partition int range into n ranges
- zkVersion- The version of the Collection node in Zookeeper (used for conditional updates).
- creationTime- The creation time of the collection
- prsSupplier- optional supplier for PerReplicaStates (PRS) for PRS enabled collections
- Returns:
- a newly constructed DocCollection
 
 - 
setPerReplicaStatespublic final DocCollection setPerReplicaStates(PerReplicaStates newPerReplicaStates) Update our state with a state of aPerReplicaStateswhich could override states ofReplica.Take note that it updates the underlying AtomicReference such that all Slice and Replica that holds the same AtomicReference will see the same update This does not create a new DocCollection. - NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
 
 - 
verifyProppublic static Object verifyProp(Map<String,Object> props, String propName) - NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
 
 - 
copyWithSlicespublic DocCollection copyWithSlices(Map<String,Slice> slices) Use this to make an exact copy of DocCollection with a new set of Slices and every other property as is- Parameters:
- slices- the new set of Slices
- Returns:
- the resulting DocCollection
 
 - 
getNamepublic String getName() Return collection name.
 - 
getConfigNamepublic String getConfigName() Return non-null config name
 - 
forEachReplicapublic void forEachReplica(BiConsumer<String,Replica> consumer) - Parameters:
- consumer- consume shardName vs. replica
 
 - 
getSlicespublic Collection<Slice> getSlices() Gets the list of all slices for this collection.
 - 
getActiveSlicespublic Collection<Slice> getActiveSlices() Return the list of active slices for this collection.
 - 
getActiveSlicesArr@Deprecated public Slice[] getActiveSlicesArr() Deprecated.Return array of active slices for this collection (performance optimization).
 - 
getSlicesMappublic Map<String,Slice> getSlicesMap() Get the map of all slices (sliceName->Slice) for this collection.
 - 
getActiveSlicesMappublic Map<String,Slice> getActiveSlicesMap() Get the map of active slices (sliceName->Slice) for this collection.
 - 
getReplicaspublic List<Replica> getReplicas(String nodeName) Get the list of replicas hosted on the given node ornullif none.
 - 
getLeaderReplicas@Deprecated public List<Replica> getLeaderReplicas(String nodeName) Deprecated.Get the list of all leaders hosted on the given node ornullif none.
 - 
getZNodeVersionpublic int getZNodeVersion() 
 - 
getChildNodesVersionpublic int getChildNodesVersion() 
 - 
isModifiedpublic boolean isModified(int dataVersion, int childVersion)
 - 
getReplicationFactorpublic Integer getReplicationFactor() - Returns:
- replication factor for this collection or null if no replication factor exists.
 
 - 
getZNodepublic String getZNode() 
 - 
getRouterpublic DocRouter getRouter() 
 - 
isReadOnlypublic boolean isReadOnly() 
 - 
getCreationTimepublic Instant getCreationTime() The creation time of the Collection. When this collection is read from ZooKeeper, this is the creation time of the collection node.
 - 
toStringpublic String toString() - Overrides:
- toStringin class- ZkNodeProps
 
 - 
writeMappublic void writeMap(MapWriter.EntryWriter ew) throws IOException - Specified by:
- writeMapin interface- MapWriter
- Overrides:
- writeMapin class- ZkNodeProps
- Throws:
- IOException
 
 - 
isFullyActivepublic static boolean isFullyActive(Set<String> liveNodes, DocCollection collectionState, int expectedShards, int expectedReplicas) Check that all replicas in a collection are live- See Also:
- CollectionStatePredicate
 
 - 
getReplicas@Deprecated public List<Replica> getReplicas() Deprecated.
 - 
getReplica@Deprecated public Replica getReplica(BiPredicate<String,Replica> predicate) Deprecated.- Parameters:
- predicate- test against shardName vs. replica
- Returns:
- the first replica that matches the predicate
 
 - 
getReplicas@Deprecated public List<Replica> getReplicas(EnumSet<Replica.Type> s) Deprecated.
 - 
getShardIdpublic String getShardId(String nodeName, String coreName) Get the shardId of a core on a specific node
 - 
equalspublic boolean equals(Object that) - Overrides:
- equalsin class- ZkNodeProps
 
 - 
hashCodepublic int hashCode() - Overrides:
- hashCodein class- ZkNodeProps
 
 - 
getNumNrtReplicaspublic Integer getNumNrtReplicas() - Returns:
- the number of replicas of type Replica.Type.NRTthis collection was created with
 
 - 
getNumTlogReplicaspublic Integer getNumTlogReplicas() - Returns:
- the number of replicas of type Replica.Type.TLOGthis collection was created with
 
 - 
getNumPullReplicaspublic Integer getNumPullReplicas() - Returns:
- the number of replicas of type Replica.Type.PULLthis collection was created with
 
 - 
isPerReplicaStatepublic boolean isPerReplicaState() 
 - 
getPerReplicaStatespublic PerReplicaStates getPerReplicaStates() 
 - 
getExpectedReplicaCountpublic int getExpectedReplicaCount(Replica.Type type, int def) 
 
- 
 
-