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! See split() below.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    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, org.apache.solr.common.cloud.Replica.Type replicaType)
     
    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)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • 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 interface CollApiCmds.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 Exception
      Throws:
      Exception
    • 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, org.apache.solr.common.cloud.Replica.Type replicaType)
    • lockForSplit

      public static boolean lockForSplit(org.apache.solr.client.solrj.cloud.SolrCloudManager cloudManager, String collection, String shard) throws Exception
      Throws:
      Exception
    • unlockForSplit

      public static void unlockForSplit(org.apache.solr.client.solrj.cloud.SolrCloudManager cloudManager, String collection, String shard) throws Exception
      Throws:
      Exception