Class NodeShutdownTestUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclearShutdownMetadata(ClusterService clusterService) Synchronously removes all node shutdown metadata from the cluster state, replacing it withNodesShutdownMetadata.EMPTY.static voidflushMasterQueue(ClusterService clusterService, ActionListener<Void> listener) Submits a no-op cluster state update atPriority.LANGUIDto drain all pending master tasks, then notifieslisteneronce it is processed.static voidputShutdownForRemovalMetadata(String nodeName, ClusterService clusterService) Synchronously marks the given node for shutdown, randomly choosing amongREMOVEandSIGTERM.static voidputShutdownForRemovalMetadata(ClusterService clusterService, String nodeName, ActionListener<Void> listener) Asynchronously marks the given node for shutdown, randomly choosing amongREMOVEandSIGTERM, then flushes the master queue.static voidputShutdownMetadata(String nodeName, ClusterService clusterService, EnumSet<SingleNodeShutdownMetadata.Type> candidateShutdownTypes) Synchronously marks the given node for shutdown, randomly choosing fromcandidateShutdownTypes.static voidputShutdownMetadata(ClusterService clusterService, String nodeName, ActionListener<Void> listener, EnumSet<SingleNodeShutdownMetadata.Type> candidateShutdownTypes) Asynchronously marks the given node for shutdown, randomly choosing fromcandidateShutdownTypes, then flushes the master queue.static voidputShutdownMetadata(ClusterService clusterService, SingleNodeShutdownMetadata.Builder shutdownMetadataBuilder, String nodeName, ActionListener<Void> listener) Updates the cluster state to mark a node for shutdown by adding or updating its shutdown metadata.
-
Constructor Details
-
NodeShutdownTestUtils
public NodeShutdownTestUtils()
-
-
Method Details
-
putShutdownForRemovalMetadata
Synchronously marks the given node for shutdown, randomly choosing amongREMOVEandSIGTERM. Blocks until the cluster state update and master-queue flush complete.- See Also:
-
putShutdownForRemovalMetadata
public static void putShutdownForRemovalMetadata(ClusterService clusterService, String nodeName, ActionListener<Void> listener) Asynchronously marks the given node for shutdown, randomly choosing amongREMOVEandSIGTERM, then flushes the master queue. Notifieslisteneron completion.- See Also:
-
putShutdownMetadata
public static void putShutdownMetadata(String nodeName, ClusterService clusterService, EnumSet<SingleNodeShutdownMetadata.Type> candidateShutdownTypes) Synchronously marks the given node for shutdown, randomly choosing fromcandidateShutdownTypes. Blocks until the cluster state update and master-queue flush complete. -
putShutdownMetadata
public static void putShutdownMetadata(ClusterService clusterService, String nodeName, ActionListener<Void> listener, EnumSet<SingleNodeShutdownMetadata.Type> candidateShutdownTypes) Asynchronously marks the given node for shutdown, randomly choosing fromcandidateShutdownTypes, then flushes the master queue. Notifieslisteneron completion.REPLACEis intentionally excluded from all default sets because it requires specifying a replacement node. -
putShutdownMetadata
public static void putShutdownMetadata(ClusterService clusterService, SingleNodeShutdownMetadata.Builder shutdownMetadataBuilder, String nodeName, ActionListener<Void> listener) Updates the cluster state to mark a node for shutdown by adding or updating its shutdown metadata. Must be cleared at the end of the test by callingclearShutdownMetadata(ClusterService)This method submits an unbatched state update task to the provided
ClusterService, which sets the shutdown metadata for the specified node. The metadata is built using the providedSingleNodeShutdownMetadata.Builder. Upon completion, the providedActionListeneris notified.NB: If using
ESIntegTestCase.Scope.SUITE, at the beginning of each test, the test cluster is reset. Therefore, node names can be reused between tests if they manually start nodes. When a test adds shutdown metadata for its manually started node, it must be cleared at the end of the test by callingclearShutdownMetadata(ClusterService). Otherwise, the subsequent test can start a node with the same name which is still shutting down and cannot accept shards which leads to create index timeout.NB If using
ESIntegTestCase.Scope.TEST, the test cluster exists only for the duration of the test, and so callingclearShutdownMetadata(ClusterService)is not strictly required.- Parameters:
clusterService- theClusterServiceused to submit the state update taskshutdownMetadataBuilder- the builder for the node's shutdown metadatanodeName- the name of the node to mark for shutdownlistener- theActionListenerto be notified when the operation completes or fails
-
flushMasterQueue
Submits a no-op cluster state update atPriority.LANGUIDto drain all pending master tasks, then notifieslisteneronce it is processed. -
clearShutdownMetadata
Synchronously removes all node shutdown metadata from the cluster state, replacing it withNodesShutdownMetadata.EMPTY. Must be called at the end of any test that usedputShutdownMetadata(java.lang.String, org.elasticsearch.cluster.service.ClusterService, java.util.EnumSet<org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata.Type>)orputShutdownForRemovalMetadata(String, ClusterService)when running underESIntegTestCase.Scope.SUITE.
-