mirror of https://github.com/apache/lucene.git
SOLR-5476 handle nonode exception
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1559936 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1941777fdc
commit
172b0b5231
|
@ -307,7 +307,13 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
|
|||
}
|
||||
|
||||
public static String getLeaderNode(SolrZkClient zkClient) throws KeeperException, InterruptedException {
|
||||
Map m = (Map) ZkStateReader.fromJSON(zkClient.getData("/overseer_elect/leader", null, new Stat(), true));
|
||||
byte[] data = new byte[0];
|
||||
try {
|
||||
data = zkClient.getData("/overseer_elect/leader", null, new Stat(), true);
|
||||
} catch (KeeperException.NoNodeException e) {
|
||||
return null;
|
||||
}
|
||||
Map m = (Map) ZkStateReader.fromJSON(data);
|
||||
String s = (String) m.get("id");
|
||||
// log.info("leader-id {}",s);
|
||||
String nodeName = LeaderElector.getNodeName(s);
|
||||
|
|
|
@ -99,7 +99,7 @@ public class OverseerRolesTest extends AbstractFullDistribZkTestBase{
|
|||
|
||||
ArrayList<String> l = new ArrayList<>(nodes);
|
||||
log.info("All nodes {}", l);
|
||||
String currentLeader = getLeaderNode(client);
|
||||
String currentLeader = OverseerCollectionProcessor.getLeaderNode(client.getZkStateReader().getZkClient());
|
||||
log.info("Current leader {} ", currentLeader);
|
||||
l.remove(currentLeader);
|
||||
|
||||
|
@ -112,7 +112,7 @@ public class OverseerRolesTest extends AbstractFullDistribZkTestBase{
|
|||
|
||||
boolean leaderchanged = false;
|
||||
for(;System.currentTimeMillis() < timeout;){
|
||||
if(getLeaderNode(client).equals(overseerDesignate)){
|
||||
if(overseerDesignate.equals(OverseerCollectionProcessor.getLeaderNode(client.getZkStateReader().getZkClient()))){
|
||||
log.info("overseer designate is the new overseer");
|
||||
leaderchanged =true;
|
||||
break;
|
||||
|
@ -168,15 +168,6 @@ public class OverseerRolesTest extends AbstractFullDistribZkTestBase{
|
|||
client.request(request);
|
||||
}
|
||||
|
||||
private String getLeaderNode(CloudSolrServer client) throws KeeperException, InterruptedException {
|
||||
Map m = (Map) ZkStateReader.fromJSON(client.getZkStateReader().getZkClient().getData("/overseer_elect/leader", null, new Stat(), true));
|
||||
String s = (String) m.get("id");
|
||||
// log.info("leader-id {}",s);
|
||||
String nodeName = LeaderElector.getNodeName(s);
|
||||
// log.info("Leader {}", nodeName);
|
||||
return nodeName;
|
||||
}
|
||||
|
||||
protected void createCollection(String COLL_NAME, CloudSolrServer client) throws Exception {
|
||||
int replicationFactor = 2;
|
||||
int numShards = 4;
|
||||
|
|
Loading…
Reference in New Issue