Let ClusterStateObserver only hold onto state that's needed for change detection

Companion commit for elastic/elasticsearchelastic/elasticsearch#21631

Original commit: elastic/x-pack-elasticsearch@3333480707
This commit is contained in:
Yannick Welsch 2016-12-20 15:23:00 +01:00
parent b994f16f4a
commit 68bfc90cea
1 changed files with 4 additions and 2 deletions

View File

@ -166,13 +166,15 @@ public class SecurityTribeIT extends NativeRealmIntegTestCase {
classpathPlugins.addAll(getMockPlugins());
tribeNode = new MockNode(merged, classpathPlugins).start();
tribeClient = getClientWrapper().apply(tribeNode.client());
ClusterStateObserver observer = new ClusterStateObserver(tribeNode.injector().getInstance(ClusterService.class),
ClusterService tribeClusterService = tribeNode.injector().getInstance(ClusterService.class);
ClusterState clusterState = tribeClusterService.state();
ClusterStateObserver observer = new ClusterStateObserver(clusterState, tribeClusterService, null,
logger, new ThreadContext(settings));
final int cluster1Nodes = internalCluster().size();
final int cluster2Nodes = cluster2.size();
logger.info("waiting for [{}] nodes to be added to the tribe cluster state", cluster1Nodes + cluster2Nodes + 2);
final Predicate<ClusterState> nodeCountPredicate = state -> state.nodes().getSize() == cluster1Nodes + cluster2Nodes + 3;
if (nodeCountPredicate.test(observer.observedState()) == false) {
if (nodeCountPredicate.test(clusterState) == false) {
CountDownLatch latch = new CountDownLatch(1);
observer.waitForNextChange(new ClusterStateObserver.Listener() {
@Override