Search in sources :

Example 21 with EJBDirectory

use of org.jboss.as.test.clustering.ejb.EJBDirectory in project wildfly by wildfly.

the class RemoteStatefulEJBConcurrentFailoverTestCase method test.

public void test(Lifecycle lifecycle) throws Exception {
    try (EJBDirectory directory = new RemoteEJBDirectory(MODULE_NAME)) {
        Incrementor bean = directory.lookupStateful(SlowStatefulIncrementorBean.class, Incrementor.class);
        AtomicInteger count = new AtomicInteger();
        // Allow sufficient time for client to receive full topology
        Thread.sleep(CLIENT_TOPOLOGY_UPDATE_WAIT);
        String target = bean.increment().getNode();
        count.incrementAndGet();
        ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
        try {
            CountDownLatch latch = new CountDownLatch(1);
            Future<?> future = executor.scheduleWithFixedDelay(new IncrementTask(bean, count, latch), 0, 1, TimeUnit.MILLISECONDS);
            latch.await();
            lifecycle.stop(target);
            future.cancel(false);
            try {
                future.get();
            } catch (CancellationException e) {
            // Ignore
            }
            bean.remove();
            lifecycle.start(target);
            latch = new CountDownLatch(1);
            future = executor.scheduleWithFixedDelay(new LookupTask(directory, SlowStatefulIncrementorBean.class, latch), 0, 1, TimeUnit.MILLISECONDS);
            latch.await();
            lifecycle.stop(target);
            future.cancel(false);
            try {
                future.get();
            } catch (CancellationException e) {
            // Ignore
            }
            lifecycle.start(target);
        } finally {
            executor.shutdownNow();
        }
    }
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CancellationException(java.util.concurrent.CancellationException) Incrementor(org.jboss.as.test.clustering.cluster.ejb.remote.bean.Incrementor) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) CountDownLatch(java.util.concurrent.CountDownLatch) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) EJBDirectory(org.jboss.as.test.clustering.ejb.EJBDirectory)

Example 22 with EJBDirectory

use of org.jboss.as.test.clustering.ejb.EJBDirectory in project wildfly by wildfly.

the class CommandDispatcherTestCase method test.

@Test
public void test() throws Exception {
    try (EJBDirectory directory = new RemoteEJBDirectory(MODULE_NAME)) {
        ClusterTopologyRetriever bean = directory.lookupStateless(ClusterTopologyRetrieverBean.class, ClusterTopologyRetriever.class);
        ClusterTopology topology = bean.getClusterTopology();
        assertEquals(1, topology.getNodes().size());
        assertTrue(topology.getNodes().toString(), topology.getNodes().contains(NODE_1));
        assertTrue(topology.getRemoteNodes().toString() + " should be empty", topology.getRemoteNodes().isEmpty());
    }
}
Also used : ClusterTopologyRetriever(org.jboss.as.test.clustering.cluster.dispatcher.bean.ClusterTopologyRetriever) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) ClusterTopology(org.jboss.as.test.clustering.cluster.dispatcher.bean.ClusterTopology) EJBDirectory(org.jboss.as.test.clustering.ejb.EJBDirectory) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) Test(org.junit.Test)

Example 23 with EJBDirectory

use of org.jboss.as.test.clustering.ejb.EJBDirectory in project wildfly by wildfly.

the class RegistryTestCase method test.

@Test
public void test() throws Exception {
    try (EJBDirectory context = new RemoteEJBDirectory(MODULE_NAME)) {
        RegistryRetriever bean = context.lookupStateless(RegistryRetrieverBean.class, RegistryRetriever.class);
        Collection<String> names = bean.getNodes();
        assertEquals(1, names.size());
        assertTrue(names.toString(), names.contains(NODE_1));
    }
}
Also used : RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) RegistryRetriever(org.jboss.as.test.clustering.cluster.registry.bean.RegistryRetriever) EJBDirectory(org.jboss.as.test.clustering.ejb.EJBDirectory) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) Test(org.junit.Test)

Example 24 with EJBDirectory

use of org.jboss.as.test.clustering.ejb.EJBDirectory in project wildfly by wildfly.

the class ServiceProviderRegistrationTestCase method test.

@Test
public void test() throws Exception {
    try (EJBDirectory directory = new RemoteEJBDirectory(MODULE_NAME)) {
        ServiceProviderRetriever bean = directory.lookupStateless(ServiceProviderRetrieverBean.class, ServiceProviderRetriever.class);
        Collection<String> names = bean.getProviders();
        assertEquals(1, names.size());
        assertTrue(names.toString(), names.contains(NODE_1));
    }
}
Also used : ServiceProviderRetriever(org.jboss.as.test.clustering.cluster.provider.bean.ServiceProviderRetriever) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) EJBDirectory(org.jboss.as.test.clustering.ejb.EJBDirectory) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) Test(org.junit.Test)

Aggregations

EJBDirectory (org.jboss.as.test.clustering.ejb.EJBDirectory)24 RemoteEJBDirectory (org.jboss.as.test.clustering.ejb.RemoteEJBDirectory)23 Test (org.junit.Test)20 Incrementor (org.jboss.as.test.clustering.cluster.ejb.remote.bean.Incrementor)10 InSequence (org.jboss.arquillian.junit.InSequence)8 IOException (java.io.IOException)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 CancellationException (java.util.concurrent.CancellationException)3 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)3 Heartbeat (org.jboss.as.test.clustering.cluster.ejb.remote.bean.Heartbeat)3 HeartbeatRemote (org.jboss.as.test.clustering.cluster.ejb2.remote.bean.HeartbeatRemote)3 HeartbeatRemoteHome (org.jboss.as.test.clustering.cluster.ejb2.remote.bean.HeartbeatRemoteHome)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 EJBException (javax.ejb.EJBException)2 NoSuchEJBException (javax.ejb.NoSuchEJBException)2 ClusterTopology (org.jboss.as.test.clustering.cluster.dispatcher.bean.ClusterTopology)2 ClusterTopologyRetriever (org.jboss.as.test.clustering.cluster.dispatcher.bean.ClusterTopologyRetriever)2 ServiceProviderRetriever (org.jboss.as.test.clustering.cluster.provider.bean.ServiceProviderRetriever)2 RegistryRetriever (org.jboss.as.test.clustering.cluster.registry.bean.RegistryRetriever)2 ArrayList (java.util.ArrayList)1