Class SplitShardCmd
- java.lang.Object
-
- org.apache.solr.cloud.api.collections.SplitShardCmd
-
- All Implemented Interfaces:
CollApiCmds.CollectionApiCommand
public class SplitShardCmd extends Object implements CollApiCmds.CollectionApiCommand
SolrCloud logic for splitting a shard. It's complicated! Seesplit()
below.
-
-
Field Summary
Fields Modifier and Type Field Description static String
SHARDSPLIT_CHECKDISKSPACE_ENABLED
-
Constructor Summary
Constructors Constructor Description SplitShardCmd(CollectionCommandContext ccc)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
call(org.apache.solr.common.cloud.ClusterState state, org.apache.solr.common.cloud.ZkNodeProps message, org.apache.solr.common.util.NamedList<Object> results)
static void
checkDiskSpace(String collection, String shard, org.apache.solr.common.cloud.Replica parentShardLeader, SolrIndexSplitter.SplitMethod method, org.apache.solr.client.solrj.cloud.SolrCloudManager cloudManager)
static String
fillRanges(org.apache.solr.client.solrj.cloud.SolrCloudManager cloudManager, org.apache.solr.common.cloud.ZkNodeProps message, org.apache.solr.common.cloud.DocCollection collection, org.apache.solr.common.cloud.Slice parentSlice, List<org.apache.solr.common.cloud.DocRouter.Range> subRanges, List<String> subSlices, List<String> subShardNames, boolean firstReplicaNrt)
static org.apache.solr.common.cloud.Slice
getParentSlice(org.apache.solr.common.cloud.ClusterState clusterState, String collectionName, AtomicReference<String> slice, String splitKey)
static boolean
lockForSplit(org.apache.solr.client.solrj.cloud.SolrCloudManager cloudManager, String collection, String shard)
boolean
split(org.apache.solr.common.cloud.ClusterState clusterState, org.apache.solr.common.cloud.ZkNodeProps message, org.apache.solr.common.util.NamedList<Object> results)
Shard splits start here and make additional requests to the host of the parent shard.static void
unlockForSplit(org.apache.solr.client.solrj.cloud.SolrCloudManager cloudManager, String collection, String shard)
-
-
-
Field Detail
-
SHARDSPLIT_CHECKDISKSPACE_ENABLED
public static final String SHARDSPLIT_CHECKDISKSPACE_ENABLED
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SplitShardCmd
public SplitShardCmd(CollectionCommandContext ccc)
-
-
Method Detail
-
call
public void call(org.apache.solr.common.cloud.ClusterState state, org.apache.solr.common.cloud.ZkNodeProps message, org.apache.solr.common.util.NamedList<Object> results) throws Exception
- Specified by:
call
in interfaceCollApiCmds.CollectionApiCommand
- Throws:
Exception
-
split
public boolean split(org.apache.solr.common.cloud.ClusterState clusterState, org.apache.solr.common.cloud.ZkNodeProps message, org.apache.solr.common.util.NamedList<Object> results) throws Exception
Shard splits start here and make additional requests to the host of the parent shard. The sequence of requests is as follows:- 1. Verify that there is enough disk space to create sub-shards.
- 2. If splitByPrefix is true, make request to get prefix ranges.
- 3. If this split was attempted previously and there are lingering sub-shards, delete them.
- 4. Create sub-shards in CONSTRUCTION state.
- 5. Add an initial replica to each sub-shard.
- 6. Request that parent shard wait for children to become ACTIVE.
- 7. Execute split: either LINK or REWRITE.
- 8. Apply buffered updates to the sub-shards so they are up-to-date with parent.
- 9. Determine node placement for additional replicas (but do not create yet).
- 10. If replicationFactor is more than 1, set shard state for sub-shards to RECOVERY; else mark ACTIVE.
- 11. Create additional replicas of sub-shards.
There is a shard split doc (dev-docs/shard-split/shard-split.adoc) on how shard split works; illustrated with diagrams.
- Throws:
Exception
-
checkDiskSpace
public static void checkDiskSpace(String collection, String shard, org.apache.solr.common.cloud.Replica parentShardLeader, SolrIndexSplitter.SplitMethod method, org.apache.solr.client.solrj.cloud.SolrCloudManager cloudManager) throws org.apache.solr.common.SolrException, IOException
- Throws:
org.apache.solr.common.SolrException
IOException
-
getParentSlice
public static org.apache.solr.common.cloud.Slice getParentSlice(org.apache.solr.common.cloud.ClusterState clusterState, String collectionName, AtomicReference<String> slice, String splitKey)
-
fillRanges
public static String fillRanges(org.apache.solr.client.solrj.cloud.SolrCloudManager cloudManager, org.apache.solr.common.cloud.ZkNodeProps message, org.apache.solr.common.cloud.DocCollection collection, org.apache.solr.common.cloud.Slice parentSlice, List<org.apache.solr.common.cloud.DocRouter.Range> subRanges, List<String> subSlices, List<String> subShardNames, boolean firstReplicaNrt)
-
lockForSplit
public static boolean lockForSplit(org.apache.solr.client.solrj.cloud.SolrCloudManager cloudManager, String collection, String shard) throws Exception
- Throws:
Exception
-
-