Package org.apache.solr.common.cloud
Class PerReplicaStatesOps
- java.lang.Object
-
- org.apache.solr.common.cloud.PerReplicaStatesOps
-
public class PerReplicaStatesOps extends Object
This is a helper class that encapsulates various operations performed on the per-replica states Do not directly manipulate the per replica states as it can become difficult to debug them
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPerReplicaStatesOps.PrsZkNodeNotFoundException
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PerReplicaStatesOpsaddReplica(String replica, org.apache.solr.common.cloud.Replica.State state, boolean isLeader, org.apache.solr.common.cloud.PerReplicaStates rs)static PerReplicaStatesOpsdeleteReplica(String replica, org.apache.solr.common.cloud.PerReplicaStates rs)Delete a replica entry from per-replica statesstatic PerReplicaStatesOpsdisable(org.apache.solr.common.cloud.PerReplicaStates rs)Switch a collection /to perReplicaState=falsestatic PerReplicaStatesOpsdownReplicas(List<String> replicas, org.apache.solr.common.cloud.PerReplicaStates rs)Mark the given replicas as DOWNstatic PerReplicaStatesOpsenable(org.apache.solr.common.cloud.DocCollection coll, org.apache.solr.common.cloud.PerReplicaStates rs)Switch a collection /to perReplicaState=truestatic org.apache.solr.common.cloud.PerReplicaStatesfetch(String path, SolrZkClient zkClient, org.apache.solr.common.cloud.PerReplicaStates current)Fetch the latestPerReplicaStates.static PerReplicaStatesOpsflipLeader(Set<String> allReplicas, String next, org.apache.solr.common.cloud.PerReplicaStates rs)Flip the leader replica to a new onestatic PerReplicaStatesOpsflipState(String replica, org.apache.solr.common.cloud.Replica.State newState, org.apache.solr.common.cloud.PerReplicaStates rs)Change the state of a replicaList<org.apache.solr.common.cloud.PerReplicaStates.Operation>get()List<org.apache.solr.common.cloud.PerReplicaStates.Operation>get(org.apache.solr.common.cloud.PerReplicaStates rs)org.apache.solr.common.cloud.PerReplicaStatesgetPerReplicaStates()static org.apache.solr.common.cloud.DocCollection.PrsSuppliergetZkClientPrsSupplier(SolrZkClient zkClient, String collectionPath)voidpersist(String znode, SolrZkClient zkClient)This is a persist operation with retry if a write fails due to stale stateStringtoString()
-
-
-
Method Detail
-
fetch
public static org.apache.solr.common.cloud.PerReplicaStates fetch(String path, SolrZkClient zkClient, org.apache.solr.common.cloud.PerReplicaStates current)
Fetch the latestPerReplicaStates. It fetches data after checking theStat.getCversion()of state.json. If this is not modified, the same object is returned
-
getZkClientPrsSupplier
public static org.apache.solr.common.cloud.DocCollection.PrsSupplier getZkClientPrsSupplier(SolrZkClient zkClient, String collectionPath)
-
persist
public void persist(String znode, SolrZkClient zkClient) throws org.apache.zookeeper.KeeperException, InterruptedException
This is a persist operation with retry if a write fails due to stale state- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
getPerReplicaStates
public org.apache.solr.common.cloud.PerReplicaStates getPerReplicaStates()
-
flipState
public static PerReplicaStatesOps flipState(String replica, org.apache.solr.common.cloud.Replica.State newState, org.apache.solr.common.cloud.PerReplicaStates rs)
Change the state of a replica- Parameters:
newState- the new state
-
enable
public static PerReplicaStatesOps enable(org.apache.solr.common.cloud.DocCollection coll, org.apache.solr.common.cloud.PerReplicaStates rs)
Switch a collection /to perReplicaState=true
-
disable
public static PerReplicaStatesOps disable(org.apache.solr.common.cloud.PerReplicaStates rs)
Switch a collection /to perReplicaState=false
-
flipLeader
public static PerReplicaStatesOps flipLeader(Set<String> allReplicas, String next, org.apache.solr.common.cloud.PerReplicaStates rs)
Flip the leader replica to a new one- Parameters:
allReplicas- allReplicas of the shardnext- next leader
-
deleteReplica
public static PerReplicaStatesOps deleteReplica(String replica, org.apache.solr.common.cloud.PerReplicaStates rs)
Delete a replica entry from per-replica states- Parameters:
replica- name of the replica to be deleted
-
addReplica
public static PerReplicaStatesOps addReplica(String replica, org.apache.solr.common.cloud.Replica.State state, boolean isLeader, org.apache.solr.common.cloud.PerReplicaStates rs)
-
downReplicas
public static PerReplicaStatesOps downReplicas(List<String> replicas, org.apache.solr.common.cloud.PerReplicaStates rs)
Mark the given replicas as DOWN
-
get
public List<org.apache.solr.common.cloud.PerReplicaStates.Operation> get()
-
get
public List<org.apache.solr.common.cloud.PerReplicaStates.Operation> get(org.apache.solr.common.cloud.PerReplicaStates rs)
-
-