mirror of https://github.com/apache/lucene.git
SOLR-6196: The overseerstatus collection API instruments amILeader and ZK state update calls
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1605805 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c296d9df0f
commit
fa405e1a59
|
@ -89,6 +89,11 @@ Other Changes
|
|||
|
||||
================== 4.10.0 =================
|
||||
|
||||
New Features
|
||||
----------------------
|
||||
* SOLR-6196: The overseerstatus collection API instruments amILeader and ZK state update calls.
|
||||
(shalin)
|
||||
|
||||
Bug Fixes
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -293,9 +293,20 @@ public class Overseer {
|
|||
}
|
||||
|
||||
private void updateZkStates(ClusterState clusterState) throws KeeperException, InterruptedException {
|
||||
lastUpdatedTime = System.nanoTime();
|
||||
zkClient.setData(ZkStateReader.CLUSTER_STATE, ZkStateReader.toJSON(clusterState), true);
|
||||
|
||||
TimerContext timerContext = stats.time("update_state");
|
||||
boolean success = false;
|
||||
try {
|
||||
zkClient.setData(ZkStateReader.CLUSTER_STATE, ZkStateReader.toJSON(clusterState), true);
|
||||
lastUpdatedTime = System.nanoTime();
|
||||
success = true;
|
||||
} finally {
|
||||
timerContext.stop();
|
||||
if (success) {
|
||||
stats.success("update_state");
|
||||
} else {
|
||||
stats.error("update_state");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkIfIamStillLeader() {
|
||||
|
@ -585,6 +596,8 @@ public class Overseer {
|
|||
}
|
||||
|
||||
private LeaderStatus amILeader() {
|
||||
TimerContext timerContext = stats.time("am_i_leader");
|
||||
boolean success = true;
|
||||
try {
|
||||
ZkNodeProps props = ZkNodeProps.load(zkClient.getData(
|
||||
"/overseer_elect/leader", null, null, true));
|
||||
|
@ -592,6 +605,7 @@ public class Overseer {
|
|||
return LeaderStatus.YES;
|
||||
}
|
||||
} catch (KeeperException e) {
|
||||
success = false;
|
||||
if (e.code() == KeeperException.Code.CONNECTIONLOSS) {
|
||||
log.error("", e);
|
||||
return LeaderStatus.DONT_KNOW;
|
||||
|
@ -601,7 +615,15 @@ public class Overseer {
|
|||
log.warn("", e);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
success = false;
|
||||
Thread.currentThread().interrupt();
|
||||
} finally {
|
||||
timerContext.stop();
|
||||
if (success) {
|
||||
stats.success("am_i_leader");
|
||||
} else {
|
||||
stats.error("am_i_leader");
|
||||
}
|
||||
}
|
||||
log.info("According to ZK I (id=" + myId + ") am no longer a leader.");
|
||||
return LeaderStatus.NO;
|
||||
|
|
|
@ -508,6 +508,8 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
|
|||
}
|
||||
|
||||
protected LeaderStatus amILeader() {
|
||||
TimerContext timerContext = stats.time("collection_am_i_leader");
|
||||
boolean success = true;
|
||||
try {
|
||||
ZkNodeProps props = ZkNodeProps.load(zkStateReader.getZkClient().getData(
|
||||
"/overseer_elect/leader", null, null, true));
|
||||
|
@ -515,6 +517,7 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
|
|||
return LeaderStatus.YES;
|
||||
}
|
||||
} catch (KeeperException e) {
|
||||
success = false;
|
||||
if (e.code() == KeeperException.Code.CONNECTIONLOSS) {
|
||||
log.error("", e);
|
||||
return LeaderStatus.DONT_KNOW;
|
||||
|
@ -524,7 +527,15 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
|
|||
log.warn("", e);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
success = false;
|
||||
Thread.currentThread().interrupt();
|
||||
} finally {
|
||||
timerContext.stop();
|
||||
if (success) {
|
||||
stats.success("collection_am_i_leader");
|
||||
} else {
|
||||
stats.error("collection_am_i_leader");
|
||||
}
|
||||
}
|
||||
log.info("According to ZK I (id=" + myId + ") am no longer a leader.");
|
||||
return LeaderStatus.NO;
|
||||
|
|
|
@ -121,6 +121,27 @@ public class OverseerStatusTest extends BasicDistributedZkTest {
|
|||
assertEquals("No stats for split in OverseerCollectionProcessor", 1, split.get("errors"));
|
||||
assertNotNull(split.get("recent_failures"));
|
||||
|
||||
SimpleOrderedMap<Object> amIleader = (SimpleOrderedMap<Object>) collection_operations.get("am_i_leader");
|
||||
assertNotNull("OverseerCollectionProcessor amILeader stats should not be null", amIleader);
|
||||
assertNotNull(amIleader.get("requests"));
|
||||
assertTrue(Integer.parseInt(amIleader.get("requests").toString()) > 0);
|
||||
assertNotNull(amIleader.get("errors"));
|
||||
assertNotNull(amIleader.get("avgTimePerRequest"));
|
||||
|
||||
amIleader = (SimpleOrderedMap<Object>) overseer_operations.get("am_i_leader");
|
||||
assertNotNull("Overseer amILeader stats should not be null", amIleader);
|
||||
assertNotNull(amIleader.get("requests"));
|
||||
assertTrue(Integer.parseInt(amIleader.get("requests").toString()) > 0);
|
||||
assertNotNull(amIleader.get("errors"));
|
||||
assertNotNull(amIleader.get("avgTimePerRequest"));
|
||||
|
||||
SimpleOrderedMap<Object> updateState = (SimpleOrderedMap<Object>) overseer_operations.get("update_state");
|
||||
assertNotNull("Overseer update_state stats should not be null", updateState);
|
||||
assertNotNull(updateState.get("requests"));
|
||||
assertTrue(Integer.parseInt(updateState.get("requests").toString()) > 0);
|
||||
assertNotNull(updateState.get("errors"));
|
||||
assertNotNull(updateState.get("avgTimePerRequest"));
|
||||
|
||||
waitForThingsToLevelOut(15);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue