Examples of RpcTarget


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

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

    @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

Examples of org.jboss.ha.framework.server.lock.AbstractClusterLockSupport.RpcTarget

   public void testBasicRemoteLock() throws Exception
   {
      TesteeSet<NonGloballyExclusiveClusterLockSupport> testeeSet = getTesteeSet(node1, 1, 2);
      NonGloballyExclusiveClusterLockSupport testee = testeeSet.impl;
      LocalLockHandler handler = testee.getLocalHandler();
      RpcTarget target = testeeSet.target;
     
      ClusterNode caller = testee.getCurrentView().get(0);
      assertFalse(node1.equals(caller));
     
      resetToStrict(handler);     
      handler.lockFromCluster("test", caller, 1000);
      replay(handler);
     
      RemoteLockResponse rsp = target.remoteLock("test", caller, 1000);
     
      assertEquals(RemoteLockResponse.Flag.OK, rsp.flag);
      assertNull(rsp.holder);
     
      verify(handler);
     
      // Do it again; should fail as another thread from caller already
      // acquired the lock
      resetToStrict(handler); // fail if we call the local handler
      replay(handler);
     
      rsp = target.remoteLock("test", caller, 1000);
     
      assertEquals(RemoteLockResponse.Flag.REJECT, rsp.flag);
      assertEquals(caller, rsp.holder);
     
      verify(handler);  
View Full Code Here

Examples of org.jboss.ha.framework.server.lock.AbstractClusterLockSupport.RpcTarget

   public void testContestedRemoteLock() 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);
      assertFalse(node1.equals(caller1));
     
      ClusterNode caller2 = testee.getCurrentView().get(2);
      assertFalse(node1.equals(caller2));
     
      resetToStrict(handler);       
      handler.lockFromCluster("test", caller1, 1000);   
      replay(handler);
     
      RemoteLockResponse rsp = target.remoteLock("test", caller1, 1000);
     
      assertEquals(RemoteLockResponse.Flag.OK, rsp.flag);
      assertNull(rsp.holder);
     
      verify(handler);
     
      // A call from a different caller should be rejected without need
      // to go to the LocalLockHandler
      resetToStrict(handler);
      replay(handler);
     
      rsp = target.remoteLock("test", caller2, 1000);
     
      assertEquals(RemoteLockResponse.Flag.REJECT, rsp.flag);
      assertEquals(caller1, rsp.holder);
     
      verify(handler);     
View Full Code Here

Examples of org.jboss.ha.framework.server.lock.AbstractClusterLockSupport.RpcTarget

   public void testConcurrentRemoteLock() throws Exception
   {
      TesteeSet<NonGloballyExclusiveClusterLockSupport> testeeSet = getTesteeSet(node1, 1, 3);
      NonGloballyExclusiveClusterLockSupport testee = testeeSet.impl;
      LocalLockHandler handler = testee.getLocalHandler();
      final RpcTarget target = testeeSet.target;
     
      ClusterNode caller1 = testee.getCurrentView().get(0);
      assertFalse(node1.equals(caller1));
     
      ClusterNode caller2 = testee.getCurrentView().get(2);
View Full Code Here

Examples of org.jboss.ha.framework.server.lock.AbstractClusterLockSupport.RpcTarget

   public void testRemoteLockFailsAgainstLocalLock() throws Exception
   {
      TesteeSet<NonGloballyExclusiveClusterLockSupport> testeeSet = getTesteeSet(node1, 1, 2);
      NonGloballyExclusiveClusterLockSupport testee = testeeSet.impl;
      LocalLockHandler handler = testee.getLocalHandler();
      RpcTarget target = testeeSet.target;
     
      ClusterNode caller1 = testee.getCurrentView().get(0);
      assertFalse(node1.equals(caller1));
     
      resetToStrict(handler);  
      // We throw TimeoutException to indicate "node1" holds the lock
      handler.lockFromCluster("test", caller1, 1000);
      expectLastCall().andThrow(new TimeoutException(node1));   
      replay(handler);
     
      RemoteLockResponse rsp = target.remoteLock("test", caller1, 1000);
     
      assertEquals(RemoteLockResponse.Flag.FAIL, rsp.flag);
      assertEquals(node1, rsp.holder);
     
      verify(handler)
     
      // A second attempt should succeed if the local lock is released
     
      resetToStrict(handler);    
      // We return normally to indicate success
      handler.lockFromCluster("test", caller1, 1000);   
      replay(handler);
     
      rsp = target.remoteLock("test", caller1, 1000);
     
      assertEquals(RemoteLockResponse.Flag.OK, rsp.flag);
      assertNull(rsp.holder);
     
      verify(handler)
View Full Code Here

Examples of org.jboss.ha.framework.server.lock.AbstractClusterLockSupport.RpcTarget

   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));
     
      resetToStrict(handler);            
      handler.lockFromCluster("test", caller1, 1000);
      replay(handler);
     
      RemoteLockResponse rsp = target.remoteLock("test", caller1, 1000);
     
      assertEquals(RemoteLockResponse.Flag.OK, rsp.flag);
      assertNull(rsp.holder);
     
      verify(handler);
     
      // Change the view
      Vector<ClusterNode> dead = new Vector<ClusterNode>();
      dead.add(caller1);
     
      Vector<ClusterNode> all = new Vector<ClusterNode>(members);
      all.remove(caller1);
     
      resetToStrict(handler);
      expect(handler.getLockHolder("test")).andReturn(caller1);
      handler.unlockFromCluster("test", caller1);
      replay(handler);
     
      testee.membershipChanged(dead, new Vector<ClusterNode>(), all);
     
      verify(handler);
     
      // A call from a different caller should work
      resetToStrict(handler);            
      handler.lockFromCluster("test", caller2, 1000);
      replay(handler);
     
      rsp = target.remoteLock("test", caller2, 1000);
     
      assertEquals(RemoteLockResponse.Flag.OK, rsp.flag);
      assertNull(rsp.holder);
     
      verify(handler);
View Full Code Here

Examples of org.jboss.ha.framework.server.lock.AbstractClusterLockSupport.RpcTarget

   {
      TesteeSet<NonGloballyExclusiveClusterLockSupport> testeeSet = getTesteeSet(node1, 1, 3);
      NonGloballyExclusiveClusterLockSupport testee = testeeSet.impl;
      HAPartition partition = testee.getPartition();
      LocalLockHandler handler = testee.getLocalHandler();
      RpcTarget target = testeeSet.target;
     
      ClusterNode caller1 = testee.getCurrentView().get(0);
      ClusterNode caller2 = testee.getCurrentView().get(2);
     
      resetToStrict(partition);
      resetToStrict(handler);
     
      handler.lockFromCluster(eq("test"), eq(caller1), anyLong());
     
      expect(handler.getLockHolder("test")).andReturn(caller1);
     
      replay(partition);
      replay(handler);
     
      RemoteLockResponse rsp = target.remoteLock("test", caller1, 1);
      assertEquals(RemoteLockResponse.Flag.OK, rsp.flag);
     
      target.releaseRemoteLock("test", caller2);
     
      verify(partition);
      verify(handler);
   }
View Full Code Here

Examples of org.jboss.ha.framework.server.lock.AbstractClusterLockSupport.RpcTarget

   public void testBasicRemoteLock() throws Exception
   {
      TesteeSet<YieldingGloballyExclusiveClusterLockSupport> testeeSet = getTesteeSet(node1, 1, 2);
      YieldingGloballyExclusiveClusterLockSupport testee = testeeSet.impl;
      LocalLockHandler handler = testee.getLocalHandler();
      RpcTarget target = testeeSet.target;
     
      ClusterNode caller = testee.getCurrentView().get(0);
      assertFalse(node1.equals(caller));
     
      resetToStrict(handler);     
      replay(handler);
     
      RemoteLockResponse rsp = target.remoteLock("test", caller, 1000);
     
      assertEquals(RemoteLockResponse.Flag.OK, rsp.flag);
      assertNull(rsp.holder);
     
      verify(handler);
     
      // Do it again; should still work
      resetToStrict(handler);     
      replay(handler);
     
      rsp = target.remoteLock("test", caller, 1000);
     
      assertEquals(RemoteLockResponse.Flag.OK, rsp.flag);
      assertNull(rsp.holder);
     
      verify(handler);
View Full Code Here

Examples of org.jboss.ha.framework.server.lock.AbstractClusterLockSupport.RpcTarget

   public void testContestedRemoteLock() throws Exception
   {
      TesteeSet<YieldingGloballyExclusiveClusterLockSupport> testeeSet = getTesteeSet(node1, 1, 3);
      YieldingGloballyExclusiveClusterLockSupport testee = testeeSet.impl;
      LocalLockHandler handler = testee.getLocalHandler();
      RpcTarget target = testeeSet.target;
     
      ClusterNode caller1 = testee.getCurrentView().get(0);
      assertFalse(node1.equals(caller1));
     
      ClusterNode caller2 = testee.getCurrentView().get(2);
      assertFalse(node1.equals(caller2));
     
      resetToStrict(handler);     
      replay(handler);
     
      RemoteLockResponse rsp = target.remoteLock("test", caller1, 1000);
     
      assertEquals(RemoteLockResponse.Flag.OK, rsp.flag);
      assertNull(rsp.holder);
     
      verify(handler);
     
      // A call from a different caller should still work as
      // w/ supportLockOnly==false we only reject if WE hold the lock
      resetToStrict(handler);
      replay(handler);
     
      rsp = target.remoteLock("test", caller2, 1000);
     
      assertEquals(RemoteLockResponse.Flag.OK, rsp.flag);
      assertNull(rsp.holder);
     
      verify(handler);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.