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

  • Constructor 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.
    • getActiveSlicesArr

      @Deprecated public Slice[] getActiveSlicesArr()
      Deprecated.
      Return array of active slices for this collection (performance optimization).
    • 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.
    • getReplicas

      @Deprecated public List<Replica> getReplicas(String nodeName)
      Deprecated.
      Get the list of replicas hosted on the given node or null if none.
    • getReplicasOnNode

      public List<Replica> getReplicasOnNode(String nodeName)
      Get the list of replicas hosted on the given node or null if none.
    • getLeaderReplicas

      @Deprecated public List<Replica> getLeaderReplicas(String nodeName)
      Deprecated.
      Get the list of all leaders hosted on the given node or null 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
      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)
    • isFullyActive

      @Deprecated public static boolean isFullyActive(Set<String> liveNodes, DocCollection collectionState, int expectedShards, int expectedReplicas)
      Deprecated.
      Check that all replicas in a collection are live
      See Also:
    • iterator

      public Iterator<Slice> iterator()
      Specified by:
      iterator in interface Iterable<Slice>
    • 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.
    • getShardId

      @Deprecated public String getShardId(String nodeName, String coreName)
      Deprecated.
      Get the shardId of a core on a specific node
    • equals

      public boolean equals(Object that)
      Overrides:
      equals in class ZkNodeProps
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class ZkNodeProps
    • getNumNrtReplicas

      @Deprecated public Integer getNumNrtReplicas()
      Deprecated.
      Returns:
      the number of replicas of type Replica.Type.NRT this collection was created with
    • getNumTlogReplicas

      @Deprecated public Integer getNumTlogReplicas()
      Deprecated.
      Returns:
      the number of replicas of type Replica.Type.TLOG this collection was created with
    • getNumPullReplicas

      @Deprecated public Integer getNumPullReplicas()
      Deprecated.
      Returns:
      the number of replicas of type Replica.Type.PULL this collection was created with
    • 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()
    • getExpectedReplicaCount

      @Deprecated public int getExpectedReplicaCount(Replica.Type type, int def)
      Deprecated.