Class DocCollection

    • Method Detail

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

      • 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

        public Slice[] getActiveSlicesArr()
        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

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

        public List<Replica> getLeaderReplicas​(String nodeName)
        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()
      • 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.
      • getReplica

        public Replica getReplica​(String coreNodeName)
      • isFullyActive

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

        public Replica getReplica​(BiPredicate<String,​Replica> predicate)
        Parameters:
        predicate - test against shardName vs. replica
        Returns:
        the first replica that matches the predicate
      • getShardId

        public String getShardId​(String nodeName,
                                 String coreName)
        Get the shardId of a core on a specific node
      • getNumNrtReplicas

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

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

        public Integer getNumPullReplicas()
        Returns:
        the number of replicas of type Replica.Type.PULL this collection was created with
      • isPerReplicaState

        public boolean isPerReplicaState()
      • getExpectedReplicaCount

        public int getExpectedReplicaCount​(Replica.Type type,
                                           int def)