Class MultiNodeCoordinator
Tools to allow tests to run in-step on multiple nodes
Tests are launched on all nodes and use waitForState() to ensure each node is kept in-sync with each other as the test cases progress :
enum Steps { STARTED, CONFIGURED, RUNNING, TESTS, FINISHED };
// create coordinator for this test // MultiNodeCoordinator coordinator = new MultiNodeCoordinator(); // Wait for all nodes to get here // coordinator.waitForState(Steps.STARTED); // load configuration // // wait for all nodes to complete loading configuration // coordinator.waitForState(Steps.CONFIGURED); // start embedded server // // wait for all nodes to complete starting application // coordinator.waitForState(Steps.RUNNING); // run tests // // wait for all nodes to complete tests // coordinator.waitForState(Steps.TESTS); // wait for all nodes to finish this test // coordinator.waitForState(Steps.FINISHED);
Strings can also be used to specify states :
MultiNodeCoordinator coordinator = new MultiNodeCoordinator(); coordinator.waitForState("One"); coordinator.waitForState("Two"); coordinator.waitForState("Three");
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreate an instance of node coordinator with a default nameMultiNodeCoordinator
(String source) Create an instance of node coordinator with a custom source name -
Method Summary
Modifier and TypeMethodDescription(package private) static void
cleanup()
Cleanup to avoid leaksvoid
waitForState
(Enum<?> state) Waits for all nodes in the cluster to declare that they have got to this statevoid
waitForState
(Enum<?> state, int waitSeconds) Waits for all nodes in the cluster to declare that they have got to this statevoid
waitForState
(String state) Waits for all nodes in the cluster to declare that they have got to this statevoid
waitForState
(String state, int waitSeconds) Waits for all nodes in the cluster to declare that they have got to this state
-
Field Details
-
TIMEOUT
Timeout error- See Also:
-
FINISHED
Finished waiting for nodes- See Also:
-
-
Constructor Details
-
MultiNodeCoordinator
Create an instance of node coordinator with a custom source name
- Parameters:
source
- name of this coordinator
-
MultiNodeCoordinator
public MultiNodeCoordinator()Create an instance of node coordinator with a default name
Source name is derived from test class name and method
-
-
Method Details
-
cleanup
static void cleanup()Cleanup to avoid leaks -
waitForState
Waits for all nodes in the cluster to declare that they have got to this state
This method can be run within or outside a transaction
- Parameters:
state
- state to wait forwaitSeconds
- maximum time to wait- Throws:
MultiNodeException
- On timeout or invalid configuration
-
waitForState
Waits for all nodes in the cluster to declare that they have got to this state
This method can be run within or outside a transaction
- Parameters:
state
- state to wait forwaitSeconds
- maximum time to wait- Throws:
MultiNodeException
- On timeout or invalid configuration
-
waitForState
Waits for all nodes in the cluster to declare that they have got to this state
maximum wait time is 300 seconds
This method can be run within or outside a transaction
- Parameters:
state
- state to wait for- Throws:
MultiNodeException
- On timeout or invalid configuration
-
waitForState
Waits for all nodes in the cluster to declare that they have got to this state
maximum wait time is 300 seconds
This method can be run within or outside a transaction
- Parameters:
state
- state to wait for- Throws:
MultiNodeException
- On timeout or invalid configuration
-