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 Summary

Nested Classes
Modifier and Type
Class
Description
`static interface`
`DocCollection.CollectionStateProps`
JSON properties related to a collection's state.
`static interface`
`DocCollection.PrsSupplier`

## Nested classes/interfaces inherited from interface org.apache.solr.common.MapWriter

`MapWriter.EntryWriter`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`COLLECTIONS_ZKNODE`

### Fields inherited from class org.apache.solr.common.cloud.ZkNodeProps

`propMap`

### Fields inherited from interface org.apache.solr.common.MapWriter

`EMPTY`

## Method Summary

Modifier and Type
Method
Description
`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
`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
`boolean`
`equals(Object that)`
`void`
`forEachReplica(BiConsumer<String,Replica> consumer)`
`Collection<Slice>`
`getActiveSlices()`
Return the list of active slices for this collection.
`Map<String,Slice>`
`getActiveSlicesMap()`
Get the map of active slices (sliceName->Slice) for this collection.
`int`
`getChildNodesVersion()`
`static String`
`getCollectionPath(String coll)`
`static String`
`getCollectionPathRoot(String coll)`
`String`
`getConfigName()`
Return non-null config name
`Instant`
`getCreationTime()`
The creation time of the Collection.
`Replica`
`getLeader(String sliceName)`
`String`
`getName()`
Return collection name.
`int`
`getNumReplicas(Replica.Type type)`
`PerReplicaStates`
`getPerReplicaStates()`
`Replica`
`getReplica(String coreNodeName)`
`List<Replica>`
`getReplicas()`
Deprecated.
`List<Replica>`
`getReplicasOnNode(String nodeName)`
Get the list of replicas hosted on the given node, or an empty list if none.
`Integer`
`getReplicationFactor()`
`DocRouter`
`getRouter()`
`Slice`
`getSlice(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.
`String`
`getZNode()`
`int`
`getZNodeVersion()`
`int`
`hashCode()`
`boolean`
`isModified(int dataVersion, int childVersion)`
`boolean`
`isPerReplicaState()`
`boolean`
`isReadOnly()`
`Iterator<Slice>`
`iterator()`
`final DocCollection`
`setPerReplicaStates(PerReplicaStates newPerReplicaStates)`
Update our state with a state of a `PerReplicaStates` which could override states of `Replica`.
`String`
`toString()`
`static Object`
`verifyProp(Map<String,Object> props, String propName)`
`void`
`writeMap(MapWriter.EntryWriter ew)`
Writes this object's entries out to `ew`.

### Methods inherited from class org.apache.solr.common.cloud.ZkNodeProps

`containsKey, get, getBool, getInt, getProperties, getStr, getStr, keySet, load, plus, plus, shallowCopy`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`

### Methods inherited from interface org.apache.solr.common.MapWriter

`jsonStr, toMap, write`

### Methods inherited from interface org.apache.solr.common.NavigableObject

`_forEachEntry, _forEachEntry, _forEachEntry, _get, _get, _getStr, _getStr, _size`

## Field Details

### COLLECTIONS_ZKNODE

public static final String COLLECTIONS_ZKNODE

See Also:
  - Constant Field Values

## Method Details

### create

public 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

### getCollectionPath

public static String getCollectionPath(String coll)

### getCollectionPathRoot

public static String getCollectionPathRoot(String coll)

### setPerReplicaStates

public final DocCollection setPerReplicaStates(PerReplicaStates newPerReplicaStates)
Update our state with a state of a `PerReplicaStates` which could override states of `Replica`.

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.

### verifyProp

public 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.

### copyWithSlices

public 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

### getName

public String getName()
Return collection name.

### getConfigName

public String getConfigName()
Return non-null config name

### getSlice

public Slice getSlice(String sliceName)

### forEachReplica

public void forEachReplica(BiConsumer<String,Replica> consumer)

Parameters:
  `consumer` - consume shardName vs. replica

### getSlices

public Collection<Slice> getSlices()
Gets the list of all slices for this collection.

### getActiveSlices

public Collection<Slice> getActiveSlices()
Return the list of active slices for this collection.

### getSlicesMap

public Map<String,Slice> getSlicesMap()
Get the map of all slices (sliceName->Slice) for this collection.

### getActiveSlicesMap

public Map<String,Slice> getActiveSlicesMap()
Get the map of active slices (sliceName->Slice) for this collection.

### getReplicasOnNode

public List<Replica> getReplicasOnNode(String nodeName)
Get the list of replicas hosted on the given node, or an empty list if none.

### getZNodeVersion

public int getZNodeVersion()

### getChildNodesVersion

public int getChildNodesVersion()

### isModified

public boolean isModified(int dataVersion, int childVersion)

### getReplicationFactor

public Integer getReplicationFactor()

Returns:
  replication factor for this collection or null if no replication factor exists.

### getZNode

public String getZNode()

### getRouter

public DocRouter getRouter()

### isReadOnly

public boolean isReadOnly()

### getCreationTime

public Instant getCreationTime()
The creation time of the Collection. When this collection is read from ZooKeeper, this is the creation time of the collection node.

### toString

public String toString()

Overrides:
  `toString` in class `ZkNodeProps`

### writeMap

public void writeMap(MapWriter.EntryWriter ew) throws IOException
Description copied from interface: `MapWriter`
Writes this object's entries out to `ew`.

Specified by:
  `writeMap` in interface `MapWriter`
Overrides:
  `writeMap` in class `ZkNodeProps`
Throws:
  `IOException`

### getReplica

public Replica getReplica(String coreNodeName)

### getLeader

public Replica getLeader(String sliceName)

### iterator

public Iterator<Slice> iterator()

Specified by:
  `iterator` in interface `Iterable<Slice>`

### getReplicas

@Deprecated public List<Replica> getReplicas()
Deprecated.

### equals

public boolean equals(Object that)

Overrides:
  `equals` in class `ZkNodeProps`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `ZkNodeProps`

### getNumReplicas

public int getNumReplicas(Replica.Type type)

Returns:
  the number of replicas of a given type this collection was created with

### isPerReplicaState

public boolean isPerReplicaState()

### getPerReplicaStates

public PerReplicaStates getPerReplicaStates()