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 class
PerReplicaStatesOps.PrsZkNodeNotFoundException
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PerReplicaStatesOps
addReplica(String replica, org.apache.solr.common.cloud.Replica.State state, boolean isLeader, org.apache.solr.common.cloud.PerReplicaStates rs)
static PerReplicaStatesOps
deleteReplica(String replica, org.apache.solr.common.cloud.PerReplicaStates rs)
Delete a replica entry from per-replica statesstatic PerReplicaStatesOps
disable(org.apache.solr.common.cloud.PerReplicaStates rs)
Switch a collection /to perReplicaState=falsestatic PerReplicaStatesOps
downReplicas(List<String> replicas, org.apache.solr.common.cloud.PerReplicaStates rs)
Mark the given replicas as DOWNstatic PerReplicaStatesOps
enable(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.PerReplicaStates
fetch(String path, SolrZkClient zkClient, org.apache.solr.common.cloud.PerReplicaStates current)
Fetch the latestPerReplicaStates
.static PerReplicaStatesOps
flipLeader(Set<String> allReplicas, String next, org.apache.solr.common.cloud.PerReplicaStates rs)
Flip the leader replica to a new onestatic PerReplicaStatesOps
flipState(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.PerReplicaStates
getPerReplicaStates()
static org.apache.solr.common.cloud.DocCollection.PrsSupplier
getZkClientPrsSupplier(SolrZkClient zkClient, String collectionPath)
void
persist(String znode, SolrZkClient zkClient)
This is a persist operation with retry if a write fails due to stale stateString
toString()
-
-
-
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.KeeperException
InterruptedException
-
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)
-
-