org.apache.solr.common.cloud

## Class Slice

- java.lang.Object
- - org.apache.solr.common.cloud.ZkNodeProps
  - - org.apache.solr.common.cloud.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).

### Nested Class Summary

Nested Classes
`static class` `Slice.State` The slice's state.

### Field Summary

Fields
`static String` `LEADER`
`static String` `PARENT`
`static String` `RANGE`
`static String` `REPLICAS`

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

`propMap`

### Constructor Summary

Constructors
Constructor and Description
`Slice(String name, Map<String,Replica> replicas, Map<String,Object> props)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`Replica` `getLeader()`
`String` `getName()` Return slice name (shard id).
`String` `getParent()`
`DocRouter.Range` `getRange()`
`Replica` `getReplica(String replicaName)`
`Collection<Replica>` `getReplicas()` Gets the list of replicas for this slice.
`List<Replica>` `getReplicas(Predicate<Replica> pred)` Gets all replicas that match a predicate
`Map<String,Replica>` `getReplicasCopy()`
`Map<String,Replica>` `getReplicasMap()` Get the map of coreNodeName to replicas for this slice.
`Map<String,RoutingRule>` `getRoutingRules()`
`Slice.State` `getState()`
`Iterator<Replica>` `iterator()`
`static Map<String,Slice>` `loadAllFromMap(Map<String,Object> genericSlices)` Loads multiple slices into a Map from a generic Map that probably came from deserialized JSON.
`String` `toString()`
`void` `write(org.noggit.JSONWriter jsonWriter)`

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

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

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

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

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

`forEach, spliterator`

### Field Detail

#### REPLICAS

    public static final String REPLICAS

See Also:
  Constant Field Values

#### RANGE

    public static final String RANGE

See Also:
  Constant Field Values

#### LEADER

    public static final String LEADER

See Also:
  Constant Field Values

#### PARENT

    public static final String PARENT

See Also:
  Constant Field Values

### Constructor Detail

#### Slice

    public Slice(String name,
                 Map<String,Replica> replicas,
                 Map<String,Object> props)

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(Map<String,Object> genericSlices)

Loads multiple slices into a Map from a generic Map that probably came from deserialized JSON.

#### iterator

    public Iterator<Replica> iterator()

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

#### getName

    public String getName()

Return slice name (shard id).

#### getReplicas

    public Collection<Replica> getReplicas()

Gets the list of replicas for this slice.

#### getReplicas

    public List<Replica> getReplicas(Predicate<Replica> pred)

Gets all replicas that match a predicate

#### getReplicasMap

    public Map<String,Replica> getReplicasMap()

Get the map of coreNodeName to replicas for this slice.

#### getReplicasCopy

    public Map<String,Replica> getReplicasCopy()

#### getLeader

    public Replica getLeader()

#### getReplica

    public Replica getReplica(String replicaName)

#### getRange

    public DocRouter.Range getRange()

#### getState

    public Slice.State getState()

#### getParent

    public String getParent()

#### getRoutingRules

    public Map<String,RoutingRule> getRoutingRules()

#### toString

    public String toString()

Overrides:
  `toString` in class `ZkNodeProps`

#### write

    public void write(org.noggit.JSONWriter jsonWriter)

Specified by:
  `write` in interface `org.noggit.JSONWriter.Writable`
Overrides:
  `write` in class `ZkNodeProps`