Package org.elasticsearch.test
Class ClusterServiceUtils
java.lang.Object
org.elasticsearch.test.ClusterServiceUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SubscribableListener
<Void> addMasterTemporaryStateListener
(Predicate<ClusterState> predicate) Creates aClusterStateListener
which subscribes to theClusterService
of the current elected master node in theESIntegTestCase.internalCluster()
.static SubscribableListener
<Void> addTemporaryStateListener
(Predicate<ClusterState> predicate) Creates aClusterStateListener
which subscribes to theClusterService
of one of the nodes in theESIntegTestCase.internalCluster()
.static SubscribableListener
<Void> addTemporaryStateListener
(ClusterService clusterService, Predicate<ClusterState> predicate) Creates aClusterStateListener
which subscribes to the givenClusterService
and waits for it to apply a cluster state that satisfiespredicate
, at which point it unsubscribes itself.static SubscribableListener
<Void> addTemporaryStateListener
(ClusterService clusterService, Predicate<ClusterState> predicate, org.elasticsearch.core.TimeValue timeout) Creates aClusterStateListener
which subscribes to the givenClusterService
and waits for it to apply a cluster state that satisfiespredicate
, at which point it unsubscribes itself.static void
awaitClusterState
(org.apache.logging.log4j.Logger logger, Predicate<ClusterState> statePredicate, ClusterService clusterService) static void
awaitNoPendingTasks
(ClusterService clusterService) static ClusterService
createClusterService
(ClusterState initialState, ThreadPool threadPool) static ClusterService
createClusterService
(ClusterState initialState, ThreadPool threadPool, ClusterSettings clusterSettings) static ClusterService
createClusterService
(ThreadPool threadPool) static ClusterService
createClusterService
(ThreadPool threadPool, DiscoveryNode localNode) static ClusterService
createClusterService
(ThreadPool threadPool, DiscoveryNode localNode, ClusterSettings clusterSettings) static ClusterService
createClusterService
(ThreadPool threadPool, DiscoveryNode localNode, Settings providedSettings, ClusterSettings clusterSettings) static ClusterService
createClusterService
(ThreadPool threadPool, ClusterSettings clusterSettings) static ClusterStatePublisher
createClusterStatePublisher
(ClusterApplier clusterApplier) static NodeConnectionsService
static void
setAllElapsedMillis
(ClusterStatePublicationEvent clusterStatePublicationEvent) static void
setState
(ClusterApplierService executor, ClusterState clusterState) static void
setState
(ClusterService clusterService, ClusterState clusterState) Sets the state on the cluster applier servicestatic void
setState
(ClusterService clusterService, ClusterState.Builder clusterStateBuilder) static void
setState
(MasterService executor, ClusterState clusterState)
-
Constructor Details
-
ClusterServiceUtils
public ClusterServiceUtils()
-
-
Method Details
-
setState
-
setState
-
createClusterService
-
createClusterService
-
createClusterService
public static ClusterService createClusterService(ThreadPool threadPool, ClusterSettings clusterSettings) -
createClusterService
public static ClusterService createClusterService(ThreadPool threadPool, DiscoveryNode localNode, ClusterSettings clusterSettings) -
createClusterService
public static ClusterService createClusterService(ThreadPool threadPool, DiscoveryNode localNode, Settings providedSettings, ClusterSettings clusterSettings) -
createNoOpNodeConnectionsService
-
createClusterStatePublisher
-
createClusterService
-
createClusterService
public static ClusterService createClusterService(ClusterState initialState, ThreadPool threadPool, ClusterSettings clusterSettings) -
setState
public static void setState(ClusterService clusterService, ClusterState.Builder clusterStateBuilder) -
setState
Sets the state on the cluster applier service -
setAllElapsedMillis
-
awaitClusterState
public static void awaitClusterState(org.apache.logging.log4j.Logger logger, Predicate<ClusterState> statePredicate, ClusterService clusterService) throws Exception - Throws:
Exception
-
awaitNoPendingTasks
-
addTemporaryStateListener
public static SubscribableListener<Void> addTemporaryStateListener(ClusterService clusterService, Predicate<ClusterState> predicate) Creates aClusterStateListener
which subscribes to the givenClusterService
and waits for it to apply a cluster state that satisfiespredicate
, at which point it unsubscribes itself.- Returns:
- A
SubscribableListener
which is completed when the first cluster state matchingpredicate
is applied by the givenclusterService
. If the current cluster state already matchespredicate
then the returned listener is already complete. If no matching cluster state is seen withinESTestCase.SAFE_AWAIT_TIMEOUT
then the listener is completed exceptionally on the scheduler thread that belongs toclusterService
.
-
addTemporaryStateListener
public static SubscribableListener<Void> addTemporaryStateListener(ClusterService clusterService, Predicate<ClusterState> predicate, org.elasticsearch.core.TimeValue timeout) Creates aClusterStateListener
which subscribes to the givenClusterService
and waits for it to apply a cluster state that satisfiespredicate
, at which point it unsubscribes itself.- Returns:
- A
SubscribableListener
which is completed when the first cluster state matchingpredicate
is applied by the givenclusterService
. If the current cluster state already matchespredicate
then the returned listener is already complete. If no matching cluster state is seen within the providedtimeout
then the listener is completed exceptionally on the scheduler thread that belongs toclusterService
.
-
addTemporaryStateListener
public static SubscribableListener<Void> addTemporaryStateListener(Predicate<ClusterState> predicate) Creates aClusterStateListener
which subscribes to theClusterService
of one of the nodes in theESIntegTestCase.internalCluster()
. When the chosenClusterService
applies a state that satisfiespredicate
the listener unsubscribes itself.- Returns:
- A
SubscribableListener
which is completed when the first cluster state matchingpredicate
is applied by theClusterService
belonging to one of the nodes in theESIntegTestCase.internalCluster()
. If the current cluster state already matchespredicate
then the returned listener is already complete. If no matching cluster state is seen withinESTestCase.SAFE_AWAIT_TIMEOUT
then the listener is completed exceptionally on the scheduler thread that belongs to the chosen node'sClusterService
.
-
addMasterTemporaryStateListener
public static SubscribableListener<Void> addMasterTemporaryStateListener(Predicate<ClusterState> predicate) Creates aClusterStateListener
which subscribes to theClusterService
of the current elected master node in theESIntegTestCase.internalCluster()
. When this node'sClusterService
applies a state that satisfiespredicate
the listener unsubscribes itself.- Returns:
- A
SubscribableListener
which is completed when the first cluster state matchingpredicate
is applied by theClusterService
belonging to the node that was the elected master node in theESIntegTestCase.internalCluster()
when this method was first called. If the current cluster state already matchespredicate
then the returned listener is already complete. If no matching cluster state is seen withinESTestCase.SAFE_AWAIT_TIMEOUT
then the listener is completed exceptionally on the scheduler thread that belongs to the elected master node'sClusterService
.
-