Package org.jboss.as.clustering

Examples of org.jboss.as.clustering.ClusterNode


        InetAddress address1 = InetAddress.getByName("127.0.0.1");
        InetAddress address2 = InetAddress.getByName("127.0.0.2");

        Preference preference = new SocketAddressPreference(new InetSocketAddress(address1, 1));

        ClusterNode node1 = mock(ClusterNode.class);
        ClusterNode node2 = mock(ClusterNode.class);
        ClusterNode node3 = mock(ClusterNode.class);

        when(node1.getIpAddress()).thenReturn(address1);
        when(node2.getIpAddress()).thenReturn(address2);
        when(node3.getIpAddress()).thenReturn(address1);
        when(node1.getPort()).thenReturn(1);
        when(node2.getPort()).thenReturn(1);
        when(node3.getPort()).thenReturn(2);

        assertTrue(preference.preferred(node1));
        assertFalse(preference.preferred(node2));
        assertFalse(preference.preferred(node3));
    }
View Full Code Here


public class NamePreferenceTestCase {
    @Test
    public void test() {
        Preference preference = new NamePreference("node1");

        ClusterNode node1 = mock(ClusterNode.class);
        ClusterNode node2 = mock(ClusterNode.class);

        when(node1.getName()).thenReturn("node1");
        when(node2.getName()).thenReturn("node2");

        assertTrue(preference.preferred(node1));
        assertFalse(preference.preferred(node2));
    }
View Full Code Here

            this.stopOldMaster();
        }
    }

    private boolean elected(Set<ClusterNode> candidates) {
        ClusterNode elected = this.election(candidates);
        SingletonLogger.ROOT_LOGGER.elected(elected.getName(), this.singletonServiceName.getCanonicalName());
        return (elected != null) ? elected.equals(this.dispatcher.getClusterNode()) : false;
    }
View Full Code Here

* @author Paul Ferraro
*/
public class SimpleSingletonElectionPolicyTestCase {
    @Test
    public void elect() {
        ClusterNode node1 = mock(ClusterNode.class);
        ClusterNode node2 = mock(ClusterNode.class);
        ClusterNode node3 = mock(ClusterNode.class);
        List<ClusterNode> nodes = Arrays.asList(node1, node2, node3);

        assertSame(node1, new SimpleSingletonElectionPolicy().elect(nodes));
        assertSame(node1, new SimpleSingletonElectionPolicy(0).elect(nodes));
        assertSame(node2, new SimpleSingletonElectionPolicy(1).elect(nodes));
View Full Code Here

    @Test
    public void elect() {
        SingletonElectionPolicy policy = mock(SingletonElectionPolicy.class);
        Preference preference = mock(Preference.class);

        ClusterNode node1 = mock(ClusterNode.class);
        ClusterNode node2 = mock(ClusterNode.class);
        ClusterNode node3 = mock(ClusterNode.class);

        when(preference.preferred(same(node1))).thenReturn(true);
        when(preference.preferred(same(node2))).thenReturn(false);
        when(preference.preferred(same(node3))).thenReturn(false);
View Full Code Here

        List<ClusterNode> members = testee.getCurrentView();
        assertEquals(2, members.size());
        assertEquals(node1, members.get(1));

        ClusterNode dead = members.get(0);
        assertFalse(node1.equals(dead));

        List<ClusterNode> newView = getView(node1, 0, 3);
        newView.remove(dead);
View Full Code Here

        GroupRpcDispatcher rpcDispatcher = testee.getGroupRpcDispatcher();
/*
        resetToNice(partition);
        resetToStrict(handler);
*/
        ClusterNode superior = testee.getCurrentView().get(0);

        List<RemoteLockResponse> rspList = new ArrayList<RemoteLockResponse>();
        rspList.add(new RemoteLockResponse(null, RemoteLockResponse.Flag.OK));
        rspList.add(new RemoteLockResponse(null, RemoteLockResponse.Flag.REJECT, superior));

View Full Code Here

        LocalLockHandler handler = testee.getLocalHandler();
/*
        resetToStrict(partition);
        resetToStrict(handler);
*/
        ClusterNode inferior = testee.getCurrentView().get(2);

        List<RemoteLockResponse> rspList = new ArrayList<RemoteLockResponse>();
        rspList.add(new RemoteLockResponse(null, RemoteLockResponse.Flag.OK));
        rspList.add(new RemoteLockResponse(null, RemoteLockResponse.Flag.REJECT, inferior));

View Full Code Here

        T testee = testeeSet.impl;
        GroupRpcDispatcher rpcDispatcher = testee.getGroupRpcDispatcher();
        LocalLockHandler handler = testee.getLocalHandler();
        final RpcTarget target = testeeSet.target;

        ClusterNode superiorCaller = testee.getCurrentView().get(0);
        assertFalse(node1.equals(superiorCaller));
/*
        resetToStrict(partition);
        makeThreadSafe(partition, true);
        resetToStrict(handler);
View Full Code Here

        T testee = testeeSet.impl;
        GroupRpcDispatcher rpcDispatcher = testee.getGroupRpcDispatcher();
        LocalLockHandler handler = testee.getLocalHandler();
        final RpcTarget target = testeeSet.target;

        ClusterNode superiorCaller = testee.getCurrentView().get(0);
        assertFalse(node1.equals(superiorCaller));

        // When caller 1 invokes, block before giving response
        CountDownLatch answerAwaitLatch = new CountDownLatch(1);
        CountDownLatch answerStartLatch = new CountDownLatch(1);
View Full Code Here

TOP

Related Classes of org.jboss.as.clustering.ClusterNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.