Search in sources :

Example 1 with RemoteStatefulSB

use of org.jboss.as.test.clustering.cluster.ejb.forwarding.bean.stateful.RemoteStatefulSB in project wildfly by wildfly.

the class AbstractRemoteEJBForwardingTestCase method test.

/**
 * Tests that Jakarta Enterprise Beans Client invocations on stateful session beans can still successfully be processed
 * as long as one node in each cluster is available.
 */
@Test
public void test() throws Exception {
    ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
    try (EJBDirectory directory = directorySupplier.get()) {
        // get the correct forwarder deployment on cluster A
        RemoteStatefulSB bean = directory.lookupStateful(implementationClass, RemoteStatefulSB.class);
        // Allow sufficient time for client to receive full topology
        logger.debug("Waiting for clusters to form.");
        Thread.sleep(FAILURE_FREE_TIME);
        int newSerialValue = bean.getSerialAndIncrement();
        logger.debugf("First invocation: serial = %d", newSerialValue);
        ClientInvocationTask client = new ClientInvocationTask(bean, newSerialValue);
        // set up the client invocations
        executor.scheduleWithFixedDelay(client, 0, INVOCATION_WAIT, TimeUnit.MILLISECONDS);
        // a few seconds of non-failure behaviour
        Thread.sleep(FAILURE_FREE_TIME);
        client.assertNoExceptions("at the beginning of the test");
        logger.debugf("------ Shutdown clusterA-node0 -----");
        stop(GRACEFUL_SHUTDOWN_TIMEOUT, NODE_1);
        Thread.sleep(SERVER_DOWN_TIME);
        client.assertNoExceptions("after clusterA-node0 was shut down");
        logger.debug("------ Startup clusterA-node0 -----");
        start(NODE_1);
        Thread.sleep(FAILURE_FREE_TIME);
        client.assertNoExceptions("after clusterA-node0 was brought up");
        logger.debug("----- Shutdown clusterA-node1 -----");
        stop(GRACEFUL_SHUTDOWN_TIMEOUT, NODE_2);
        Thread.sleep(SERVER_DOWN_TIME);
        logger.debug("------ Startup clusterA-node1 -----");
        start(NODE_2);
        Thread.sleep(FAILURE_FREE_TIME);
        client.assertNoExceptions("after clusterA-node1 was brought back up");
        logger.debug("----- Shutdown clusterB-node0 -----");
        stop(GRACEFUL_SHUTDOWN_TIMEOUT, NODE_3);
        Thread.sleep(SERVER_DOWN_TIME);
        client.assertNoExceptions("after clusterB-node0 was shut down");
        logger.debug("------ Startup clusterB-node0 -----");
        start(NODE_3);
        Thread.sleep(FAILURE_FREE_TIME);
        client.assertNoExceptions("after clusterB-node0 was brought back up");
        logger.debug("----- Shutdown clusterB-node1 -----");
        stop(GRACEFUL_SHUTDOWN_TIMEOUT, NODE_4);
        Thread.sleep(SERVER_DOWN_TIME);
        logger.debug("------ Startup clusterB-node1 -----");
        start(NODE_4);
        Thread.sleep(FAILURE_FREE_TIME);
        // final assert
        client.assertNoExceptions("after clusterB-node1 was brought back up");
    } finally {
        executor.shutdownNow();
    }
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) RemoteStatefulSB(org.jboss.as.test.clustering.cluster.ejb.forwarding.bean.stateful.RemoteStatefulSB) NamingEJBDirectory(org.jboss.as.test.clustering.ejb.NamingEJBDirectory) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) EJBDirectory(org.jboss.as.test.clustering.ejb.EJBDirectory) Test(org.junit.Test)

Aggregations

ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 RemoteStatefulSB (org.jboss.as.test.clustering.cluster.ejb.forwarding.bean.stateful.RemoteStatefulSB)1 EJBDirectory (org.jboss.as.test.clustering.ejb.EJBDirectory)1 NamingEJBDirectory (org.jboss.as.test.clustering.ejb.NamingEJBDirectory)1 RemoteEJBDirectory (org.jboss.as.test.clustering.ejb.RemoteEJBDirectory)1 Test (org.junit.Test)1