Package org.jboss.as.clustering.lock.AbstractClusterLockSupport

Examples of org.jboss.as.clustering.lock.AbstractClusterLockSupport.RpcTarget


    @Test
    public void testDeadMemberCleanupAllowsRemoteLock() throws Exception {
        TesteeSet<NonGloballyExclusiveClusterLockSupport> testeeSet = getTesteeSet(node1, 1, 3);
        NonGloballyExclusiveClusterLockSupport testee = testeeSet.impl;
        LocalLockHandler handler = testee.getLocalHandler();
        RpcTarget target = testeeSet.target;

        List<ClusterNode> members = testee.getCurrentView();
        ClusterNode caller1 = members.get(0);
        assertFalse(node1.equals(caller1));

        ClusterNode caller2 = members.get(2);
        assertFalse(node1.equals(caller2));

        RemoteLockResponse rsp = target.remoteLock("test", caller1, 1000);

        verify(handler).lockFromCluster("test", caller1, 1000);

        assertEquals(RemoteLockResponse.Flag.OK, rsp.flag);
        assertNull(rsp.holder);

        // Change the view
        Vector<ClusterNode> dead = new Vector<ClusterNode>();
        dead.add(caller1);

        Vector<ClusterNode> all = new Vector<ClusterNode>(members);
        all.remove(caller1);

        when(handler.getLockHolder("test")).thenReturn(caller1);

        testee.membershipChanged(dead, new Vector<ClusterNode>(), all);

        verify(handler).unlockFromCluster("test", caller1);
       
        // A call from a different caller should work
        rsp = target.remoteLock("test", caller2, 1000);

        verify(handler).lockFromCluster("test", caller2, 1000);

        assertEquals(RemoteLockResponse.Flag.OK, rsp.flag);
        assertNull(rsp.holder);
View Full Code Here


    @Test
    public void testSpuriousLockReleaseIgnored2() throws Exception {
        TesteeSet<NonGloballyExclusiveClusterLockSupport> testeeSet = getTesteeSet(node1, 1, 3);
        NonGloballyExclusiveClusterLockSupport testee = testeeSet.impl;
        LocalLockHandler handler = testee.getLocalHandler();
        RpcTarget target = testeeSet.target;

        ClusterNode caller1 = testee.getCurrentView().get(0);
        ClusterNode caller2 = testee.getCurrentView().get(2);

        when(handler.getLockHolder("test")).thenReturn(caller1);

        RemoteLockResponse rsp = target.remoteLock("test", caller1, 1);
       
        verify(handler).lockFromCluster(eq("test"), eq(caller1), anyLong());

        assertEquals(RemoteLockResponse.Flag.OK, rsp.flag);

        target.releaseRemoteLock("test", caller2);
       
        verify(handler, never()).unlockFromCluster("test", caller2);
    }
View Full Code Here

TOP

Related Classes of org.jboss.as.clustering.lock.AbstractClusterLockSupport.RpcTarget

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.