Search in sources :

Example 1 with StatelessRemote

use of org.jboss.as.test.clustering.cluster.ejb2.stateless.bean.StatelessRemote in project wildfly by wildfly.

the class RemoteStatelessFailoverTestCase method loadbalance.

/**
 * Basic load balance testing. A random distribution is used amongst nodes for client now.
 */
private void loadbalance(EJBDirectory directory, String deployment1, String deployment2) throws Exception {
    this.start(NODE_1);
    this.deploy(NODE_1, deployment1);
    this.start(NODE_2);
    this.deploy(NODE_2, deployment2);
    // TODO Elytron: Once support for legacy Jakarta Enterprise Beans properties has been added back, actually set the Jakarta Enterprise Beans properties
    // that should be used for this test using CLIENT_PROPERTIES and ensure the Jakarta Enterprise Beans client context is reset
    // to its original state at the end of the test
    // EJBClientContextSelector.setup(CLIENT_PROPERTIES);
    int numberOfServers = 2;
    int numberOfCalls = 40;
    // there will be at least 20% of calls processed by all servers
    double serversProcessedAtLeast = 0.2;
    try {
        StatelessRemoteHome home = directory.lookupHome(StatelessBean.class, StatelessRemoteHome.class);
        StatelessRemote bean = home.create();
        String node = bean.getNodeName();
        log.trace("Node called : " + node);
        validateBalancing(bean, numberOfCalls, numberOfServers, serversProcessedAtLeast);
        // Properties contextChangeProperties = new Properties();
        // contextChangeProperties.put(REMOTE_PORT_PROPERTY_NAME, PORT_2.toString());
        // contextChangeProperties.put(REMOTE_HOST_PROPERTY_NAME, HOST_2.toString());
        // EJBClientContextSelector.setup(CLIENT_PROPERTIES, contextChangeProperties);
        bean = home.create();
        node = bean.getNodeName();
        log.trace("Node called : " + node);
        validateBalancing(bean, numberOfCalls, numberOfServers, serversProcessedAtLeast);
    } finally {
        // undeploy&shutdown the containers
        undeployAll();
        shutdownAll();
    }
}
Also used : StatelessRemote(org.jboss.as.test.clustering.cluster.ejb2.stateless.bean.StatelessRemote) StatelessRemoteHome(org.jboss.as.test.clustering.cluster.ejb2.stateless.bean.StatelessRemoteHome)

Example 2 with StatelessRemote

use of org.jboss.as.test.clustering.cluster.ejb2.stateless.bean.StatelessRemote in project wildfly by wildfly.

the class RemoteStatelessFailoverTestCase method doFailover.

private void doFailover(boolean isStop, EJBDirectory directory, String deployment1, String deployment2) throws Exception {
    this.start(NODE_1);
    this.deploy(NODE_1, deployment1);
    try {
        StatelessRemoteHome home = directory.lookupHome(StatelessBean.class, StatelessRemoteHome.class);
        StatelessRemote bean = home.create();
        assertEquals("The only " + TWO_NODES[0] + " is active. Bean had to be invoked on it but it wasn't.", TWO_NODES[0], bean.getNodeName());
        this.start(NODE_2);
        this.deploy(NODE_2, deployment2);
        if (isStop) {
            this.stop(NODE_1);
        } else {
            this.undeploy(NODE_1, deployment1);
        }
        assertEquals("Only " + TWO_NODES[1] + " is active. The bean had to be invoked on it but it wasn't.", TWO_NODES[1], bean.getNodeName());
    } finally {
        // need to have the container started to undeploy deployment afterwards
        this.start(NODE_1);
        // shutdown the containers
        undeployAll();
        shutdownAll();
    }
}
Also used : StatelessRemote(org.jboss.as.test.clustering.cluster.ejb2.stateless.bean.StatelessRemote) StatelessRemoteHome(org.jboss.as.test.clustering.cluster.ejb2.stateless.bean.StatelessRemoteHome)

Aggregations

StatelessRemote (org.jboss.as.test.clustering.cluster.ejb2.stateless.bean.StatelessRemote)2 StatelessRemoteHome (org.jboss.as.test.clustering.cluster.ejb2.stateless.bean.StatelessRemoteHome)2