Search in sources :

Example 1 with ClusterTopologyRetriever

use of org.jboss.as.test.clustering.cluster.dispatcher.bean.ClusterTopologyRetriever in project wildfly by wildfly.

the class CommandDispatcherTestCase method test.

@Test
public void test() throws Exception {
    // TODO Elytron: Once support for legacy EJB properties has been added back, actually set the EJB properties
    // that should be used for this test using CLIENT_PROPERTIES and ensure the EJB client context is reset
    // to its original state at the end of the test
    EJBClientContextSelector.setup(CLIENT_PROPERTIES);
    try (EJBDirectory directory = new RemoteEJBDirectory(MODULE_NAME)) {
        ClusterTopologyRetriever bean = directory.lookupStateless(ClusterTopologyRetrieverBean.class, ClusterTopologyRetriever.class);
        ClusterTopology topology = bean.getClusterTopology();
        assertEquals(2, topology.getNodes().size());
        assertTrue(topology.getNodes().toString(), topology.getNodes().contains(NODE_1));
        assertTrue(topology.getNodes().toString(), topology.getNodes().contains(NODE_2));
        assertFalse(topology.getRemoteNodes().toString() + " should not contain " + topology.getLocalNode(), topology.getRemoteNodes().contains(topology.getLocalNode()));
        undeploy(DEPLOYMENT_2);
        topology = bean.getClusterTopology();
        assertEquals(1, topology.getNodes().size());
        assertTrue(topology.getNodes().contains(NODE_1));
        assertEquals(NODE_1, topology.getLocalNode());
        assertTrue(topology.getRemoteNodes().toString(), topology.getRemoteNodes().isEmpty());
        deploy(DEPLOYMENT_2);
        Thread.sleep(VIEW_CHANGE_WAIT);
        topology = bean.getClusterTopology();
        assertEquals(2, topology.getNodes().size());
        assertTrue(topology.getNodes().contains(NODE_1));
        assertTrue(topology.getNodes().contains(NODE_2));
        assertFalse(topology.getRemoteNodes().toString() + " should not contain " + topology.getLocalNode(), topology.getRemoteNodes().contains(topology.getLocalNode()));
        stop(CONTAINER_1);
        topology = bean.getClusterTopology();
        assertEquals(1, topology.getNodes().size());
        assertTrue(topology.getNodes().contains(NODE_2));
        assertEquals(NODE_2, topology.getLocalNode());
        assertTrue(topology.getRemoteNodes().toString(), topology.getRemoteNodes().isEmpty());
        start(CONTAINER_1);
        Thread.sleep(VIEW_CHANGE_WAIT);
        topology = bean.getClusterTopology();
        assertEquals(topology.getNodes().toString(), 2, topology.getNodes().size());
        assertTrue(topology.getNodes().toString() + " should contain " + NODE_1, topology.getNodes().contains(NODE_1));
        assertTrue(topology.getNodes().toString() + " should contain " + NODE_2, topology.getNodes().contains(NODE_2));
        assertFalse(topology.getRemoteNodes().toString() + " should not contain " + topology.getLocalNode(), topology.getRemoteNodes().contains(topology.getLocalNode()));
    }
}
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 2 with ClusterTopologyRetriever

use of org.jboss.as.test.clustering.cluster.dispatcher.bean.ClusterTopologyRetriever in project wildfly by wildfly.

the class CommandDispatcherTestCase method test.

@Test
public void test() throws Exception {
    JBossEJBProperties properties = JBossEJBProperties.fromClassPath(CommandDispatcherTestCase.class.getClassLoader(), CLIENT_PROPERTIES);
    properties.runCallable(() -> {
        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());
        }
        return null;
    });
}
Also used : JBossEJBProperties(org.jboss.ejb.client.legacy.JBossEJBProperties) 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)

Aggregations

ClusterTopology (org.jboss.as.test.clustering.cluster.dispatcher.bean.ClusterTopology)2 ClusterTopologyRetriever (org.jboss.as.test.clustering.cluster.dispatcher.bean.ClusterTopologyRetriever)2 EJBDirectory (org.jboss.as.test.clustering.ejb.EJBDirectory)2 RemoteEJBDirectory (org.jboss.as.test.clustering.ejb.RemoteEJBDirectory)2 Test (org.junit.Test)2 JBossEJBProperties (org.jboss.ejb.client.legacy.JBossEJBProperties)1