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:
parent
b994f16f4a
commit
68bfc90cea
|
@ -166,13 +166,15 @@ public class SecurityTribeIT extends NativeRealmIntegTestCase {
|
||||||
classpathPlugins.addAll(getMockPlugins());
|
classpathPlugins.addAll(getMockPlugins());
|
||||||
tribeNode = new MockNode(merged, classpathPlugins).start();
|
tribeNode = new MockNode(merged, classpathPlugins).start();
|
||||||
tribeClient = getClientWrapper().apply(tribeNode.client());
|
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));
|
logger, new ThreadContext(settings));
|
||||||
final int cluster1Nodes = internalCluster().size();
|
final int cluster1Nodes = internalCluster().size();
|
||||||
final int cluster2Nodes = cluster2.size();
|
final int cluster2Nodes = cluster2.size();
|
||||||
logger.info("waiting for [{}] nodes to be added to the tribe cluster state", cluster1Nodes + cluster2Nodes + 2);
|
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;
|
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);
|
CountDownLatch latch = new CountDownLatch(1);
|
||||||
observer.waitForNextChange(new ClusterStateObserver.Listener() {
|
observer.waitForNextChange(new ClusterStateObserver.Listener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue