Package 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>`, `MapSerializable`, `MapWriter`, `NavigableObject`, `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
Modifier and Type
Class
Description
`static interface`
`Slice.SliceStateProps`
JSON properties related to a slice's state.
`static enum`
`Slice.State`
The slice's state.

## Nested classes/interfaces inherited from interface org.apache.solr.common.MapWriter

`MapWriter.EntryWriter`

## Field Summary

Fields
Modifier and Type
Field
Description
`final String`
`collection`

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

`propMap`

### Fields inherited from interface org.apache.solr.common.MapWriter

`EMPTY`

## Constructor Summary

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

## Method Summary

Modifier and Type
Method
Description
`Slice`
`copyWith(Replica modified)`
Make a copy with a modified replica
`String`
`getCollection()`
`Replica`
`getLeader()`
`String`
`getName()`
Return slice name (shard id).
`int`
`getNumLeaderReplicas()`
`String`
`getParent()`
`DocRouter.Range`
`getRange()`
`Replica`
`getReplica(String replicaName)`
`Set<String>`
`getReplicaNames()`
`Collection<Replica>`
`getReplicas()`
Gets the list of all replicas for this slice.
`List<Replica>`
`getReplicas(EnumSet<Replica.Type> s)`
Gets the list of replicas that have a type present in s
`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(String collection, Map<String,Object> genericSlices)`
Loads multiple slices into a Map from a generic Map that probably came from deserialized JSON.
`String`
`toString()`

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

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

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

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

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

`forEach, spliterator`

### Methods inherited from interface org.apache.solr.common.MapWriter

`jsonStr, toMap, write`

### Methods inherited from interface org.apache.solr.common.NavigableObject

`_forEachEntry, _forEachEntry, _forEachEntry, _get, _get, _getStr, _getStr, _size`

## Field Details

### collection

public final String collection

## Constructor Details

### 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 Details

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

### iterator

public Iterator<Replica> iterator()

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

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

### getReplicas

public List<Replica> getReplicas(Predicate<Replica> pred)
Gets all replicas that match a predicate

### getReplicas

public List<Replica> getReplicas(EnumSet<Replica.Type> s)
Gets the list of replicas that have a type present in s

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

### getNumLeaderReplicas

public int getNumLeaderReplicas()

### 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`