@@ -263,6 +263,15 @@ public void clusterStateProcessed(ClusterState initialState, ClusterState newSta
263263        );
264264    }
265265
266+     /** 
267+      * Creates a {@link ClusterStateListener} which subscribes to the given {@link ClusterService} and waits for it to apply a cluster state 
268+      * that satisfies {@code predicate}, at which point it unsubscribes itself. 
269+      * 
270+      * @return A {@link SubscribableListener} which is completed when the first cluster state matching {@code predicate} is applied by the 
271+      *         given {@code clusterService}. If the current cluster state already matches {@code predicate} then the returned listener is 
272+      *         already complete. If no matching cluster state is seen within {@link ESTestCase#SAFE_AWAIT_TIMEOUT} then the listener is 
273+      *         completed exceptionally on the scheduler thread that belongs to {@code clusterService}. 
274+      */ 
266275    public  static  SubscribableListener <Void > addTemporaryStateListener (ClusterService  clusterService , Predicate <ClusterState > predicate ) {
267276        return  addTemporaryStateListener (clusterService , predicate , ESTestCase .SAFE_AWAIT_TIMEOUT );
268277    }
@@ -308,4 +317,35 @@ public String toString() {
308317        }
309318        return  listener ;
310319    }
320+ 
321+     /** 
322+      * Creates a {@link ClusterStateListener} which subscribes to the {@link ClusterService} of one of the nodes in the 
323+      * {@link ESIntegTestCase#internalCluster()}. When the chosen {@link ClusterService} applies a state that satisfies {@code predicate} 
324+      * the listener unsubscribes itself. 
325+      * 
326+      * @return A {@link SubscribableListener} which is completed when the first cluster state matching {@code predicate} is applied by the 
327+      *         {@link ClusterService} belonging to one of the nodes in the {@link ESIntegTestCase#internalCluster()}. If the current cluster 
328+      *         state already matches {@code predicate} then the returned listener is already complete. If no matching cluster state is seen 
329+      *         within {@link ESTestCase#SAFE_AWAIT_TIMEOUT} then the listener is completed exceptionally on the scheduler thread that 
330+      *         belongs to the chosen node's {@link ClusterService}. 
331+      */ 
332+     public  static  SubscribableListener <Void > addTemporaryStateListener (Predicate <ClusterState > predicate ) {
333+         return  addTemporaryStateListener (ESIntegTestCase .internalCluster ().clusterService (), predicate );
334+     }
335+ 
336+     /** 
337+      * Creates a {@link ClusterStateListener} which subscribes to the {@link ClusterService} of the current elected master node in the 
338+      * {@link ESIntegTestCase#internalCluster()}. When this node's {@link ClusterService} applies a state that satisfies {@code predicate} 
339+      * the listener unsubscribes itself. 
340+      * 
341+      * @return A {@link SubscribableListener} which is completed when the first cluster state matching {@code predicate} is applied by the 
342+      *         {@link ClusterService} belonging to the node that was the elected master node in the 
343+      *         {@link ESIntegTestCase#internalCluster()} when this method was first called. If the current cluster state already matches 
344+      *         {@code predicate} then the returned listener is already complete. If no matching cluster state is seen within 
345+      *         {@link ESTestCase#SAFE_AWAIT_TIMEOUT} then the listener is completed exceptionally on the scheduler thread that belongs to 
346+      *         the elected master node's {@link ClusterService}. 
347+      */ 
348+     public  static  SubscribableListener <Void > addMasterTemporaryStateListener (Predicate <ClusterState > predicate ) {
349+         return  addTemporaryStateListener (ESIntegTestCase .internalCluster ().getCurrentMasterNodeInstance (ClusterService .class ), predicate );
350+     }
311351}
0 commit comments