Class Slice

  • All Implemented Interfaces:
    Iterable<Replica>, org.noggit.JSONWriter.Writable

    public class Slice
    extends ZkNodeProps
    implements Iterable<Replica>
    A Slice contains immutable information about a logical shard (all replicas that share the same shard id).
    • Field Detail

      • collection

        public final String collection
    • Constructor Detail

      • Slice

        public Slice​(String name,
                     Map<String,​Replica> replicas,
                     Map<String,​Object> props,
                     String collection)
        Parameters:
        name - The name of the slice
        replicas - The replicas of the slice. This is used directly and a copy is not made. If null, replicas will be constructed from props.
        props - The properties of the slice - a shallow copy will always be made.
    • Method Detail

      • loadAllFromMap

        public static Map<String,​Slice> loadAllFromMap​(String collection,
                                                             Map<String,​Object> genericSlices)
        Loads multiple slices into a Map from a generic Map that probably came from deserialized JSON.
      • copyWith

        public Slice copyWith​(Replica modified)
        Make a copy with a modified replica
      • getCollection

        public String getCollection()
      • getName

        public String getName()
        Return slice name (shard id).
      • getReplicas

        public Collection<Replica> getReplicas()
        Gets the list of all replicas for this slice.
      • getReplicaNames

        public Set<String> getReplicaNames()
      • getReplicasMap

        public Map<String,​Replica> getReplicasMap()
        Get the map of coreNodeName to replicas for this slice.
      • getLeader

        public Replica getLeader()
      • getNumLeaderReplicas

        public int getNumLeaderReplicas()
      • getParent

        public String getParent()
      • write

        public void write​(org.noggit.JSONWriter jsonWriter)
        Specified by:
        write in interface org.noggit.JSONWriter.Writable
        Overrides:
        write in class ZkNodeProps