mirror of https://github.com/apache/lucene.git
SOLR-7420: Overseer stats are not reset on loss of ZK connection
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1674458 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8573f64b9c
commit
e541bccd45
|
@ -128,6 +128,8 @@ Bug Fixes
|
|||
* SOLR-6087: SolrIndexSearcher makes no DelegatingCollector.finish() call when IndexSearcher
|
||||
throws an expected exception. (Christine Poerschke via shalin)
|
||||
|
||||
* SOLR-7420: Overseer stats are not reset on loss of ZK connection. (Jessica Cheng, shalin)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -825,6 +825,7 @@ public class Overseer implements Closeable {
|
|||
this.id = id;
|
||||
closed = false;
|
||||
doClose();
|
||||
stats = new Stats();
|
||||
log.info("Overseer (id=" + id + ") starting");
|
||||
createOverseerNode(reader.getZkClient());
|
||||
//launch cluster state updater thread
|
||||
|
@ -1048,6 +1049,10 @@ public class Overseer implements Closeable {
|
|||
public void setQueueLength(int queueLength) {
|
||||
this.queueLength = queueLength;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
stats.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Stat {
|
||||
|
|
|
@ -434,7 +434,7 @@ public class OverseerTest extends SolrTestCaseJ4 {
|
|||
|
||||
Thread.sleep(200);
|
||||
}
|
||||
assertEquals("Unable to verify all cores have been assigned an id in cloudstate",
|
||||
assertEquals("Unable to verify all cores have been assigned an id in cloudstate",
|
||||
coreCount, cloudStateSliceCount);
|
||||
|
||||
// make sure all cores have been returned an id
|
||||
|
@ -689,6 +689,69 @@ public class OverseerTest extends SolrTestCaseJ4 {
|
|||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOverseerStatsReset() throws Exception {
|
||||
String zkDir = createTempDir("zkData").toFile().getAbsolutePath();
|
||||
ZkTestServer server = new ZkTestServer(zkDir);
|
||||
ZkStateReader reader = null;
|
||||
MockZKController mockController = null;
|
||||
|
||||
SolrZkClient zkClient = null;
|
||||
try {
|
||||
server.run();
|
||||
|
||||
AbstractZkTestCase.tryCleanSolrZkNode(server.getZkHost());
|
||||
AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
|
||||
|
||||
zkClient = new SolrZkClient(server.getZkAddress(), TIMEOUT);
|
||||
|
||||
ZkController.createClusterZkNodes(zkClient);
|
||||
|
||||
reader = new ZkStateReader(zkClient);
|
||||
reader.createClusterStateWatchersAndUpdate();
|
||||
|
||||
mockController = new MockZKController(server.getZkAddress(), "node1");
|
||||
|
||||
LeaderElector overseerElector = new LeaderElector(zkClient);
|
||||
if (overseers.size() > 0) {
|
||||
overseers.get(overseers.size() -1).close();
|
||||
overseers.get(overseers.size() -1).getZkStateReader().getZkClient().close();
|
||||
}
|
||||
UpdateShardHandler updateShardHandler = new UpdateShardHandler(UpdateShardHandlerConfig.DEFAULT);
|
||||
updateShardHandlers.add(updateShardHandler);
|
||||
HttpShardHandlerFactory httpShardHandlerFactory = new HttpShardHandlerFactory();
|
||||
httpShardHandlerFactorys.add(httpShardHandlerFactory);
|
||||
Overseer overseer = new Overseer(httpShardHandlerFactory.getShardHandler(), updateShardHandler, "/admin/cores", reader, null,
|
||||
new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983, "").build());
|
||||
overseers.add(overseer);
|
||||
ElectionContext ec = new OverseerElectionContext(zkClient, overseer,
|
||||
server.getZkAddress().replaceAll("/", "_"));
|
||||
overseerElector.setup(ec);
|
||||
overseerElector.joinElection(ec, false);
|
||||
|
||||
mockController.publishState(collection, "core1", "core_node1", Replica.State.RECOVERING, 1);
|
||||
|
||||
assertNotNull(overseer.getStats());
|
||||
assertEquals(1, (overseer.getStats().getSuccessCount(OverseerAction.STATE.toLower())));
|
||||
|
||||
// shut it down
|
||||
overseer.close();
|
||||
ec.cancelElection();
|
||||
|
||||
// start it again
|
||||
overseerElector.setup(ec);
|
||||
overseerElector.joinElection(ec, false);
|
||||
assertNotNull(overseer.getStats());
|
||||
assertEquals(0, (overseer.getStats().getSuccessCount(OverseerAction.STATE.toLower())));
|
||||
|
||||
} finally {
|
||||
close(mockController);
|
||||
close(zkClient);
|
||||
close(reader);
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private AtomicInteger killCounter = new AtomicInteger();
|
||||
|
||||
|
|
Loading…
Reference in New Issue