Class MultiNodeCoordinator

java.lang.Object
com.tibco.ep.testing.framework.MultiNodeCoordinator

public final class MultiNodeCoordinator extends Object

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

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final String
    Finished waiting for nodes
    (package private) static final String
    Timeout error
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create an instance of node coordinator with a default name
    Create an instance of node coordinator with a custom source name
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static void
    Cleanup to avoid leaks
    void
    waitForState(Enum<?> state)
    Waits for all nodes in the cluster to declare that they have got to this state
    void
    waitForState(Enum<?> state, int waitSeconds)
    Waits for all nodes in the cluster to declare that they have got to this state
    void
    Waits for all nodes in the cluster to declare that they have got to this state
    void
    waitForState(String state, int waitSeconds)
    Waits for all nodes in the cluster to declare that they have got to this state

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • MultiNodeCoordinator

      public MultiNodeCoordinator(String source)

      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

      public void waitForState(Enum<?> state, int waitSeconds) throws MultiNodeException

      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 for
      waitSeconds - maximum time to wait
      Throws:
      MultiNodeException - On timeout or invalid configuration
    • waitForState

      public void waitForState(String state, int waitSeconds) throws MultiNodeException

      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 for
      waitSeconds - maximum time to wait
      Throws:
      MultiNodeException - On timeout or invalid configuration
    • waitForState

      public void waitForState(Enum<?> state) throws MultiNodeException

      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

      public void waitForState(String state) throws MultiNodeException

      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