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")
  • Field Details

  • 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()