Package org.jboss.ha.framework.server.lock

Examples of org.jboss.ha.framework.server.lock.LocalLockHandler


   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));
     
View Full Code Here


  
   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));
     
View Full Code Here

    */
   public void testDeadMemberCleanupAllowsRemoteLock() throws Exception
   {
      TesteeSet<YieldingGloballyExclusiveClusterLockSupport> testeeSet = getTesteeSet(node1, 1, 3);
      YieldingGloballyExclusiveClusterLockSupport 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));
View Full Code Here

  
   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);
View Full Code Here

  
   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);
View Full Code Here

    */  
   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);
      assertFalse(node1.equals(caller2));

     
      resetToStrict(handler);  
      makeThreadSafe(handler, true);
      // When caller 1 invokes, block before giving response
      CountDownLatch answerStartLatch = new CountDownLatch(1);
      CountDownLatch answerDoneLatch = new CountDownLatch(1);
      BlockingAnswer<Boolean> caller1Answer = new BlockingAnswer<Boolean>(Boolean.TRUE, answerStartLatch, null, answerDoneLatch);
      BlockingAnswer<Boolean> caller2Answer = new BlockingAnswer<Boolean>(new TimeoutException(caller1), answerDoneLatch, 0, null, null);
      handler.lockFromCluster("test", caller1, 1000);
      expectLastCall().andAnswer(caller1Answer);
      handler.lockFromCluster("test", caller2, 1000);

     
      // There is a race where t1 may have already marked the lock as LOCKED in
      // which case t2 will not call handler.lockFromCluster("test", caller2, 1000);
      // See FIXME in method javadoc. So, we use times(0, 1) to specify no
View Full Code Here

  
   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);
View Full Code Here

   {
      int viewPos = viewSize == 1 ? 0 : 1;
      TesteeSet<NonGloballyExclusiveClusterLockSupport> testeeSet = getTesteeSet(node1, viewPos, viewSize);
      NonGloballyExclusiveClusterLockSupport testee = testeeSet.impl;
      HAPartition partition = testee.getPartition();
      LocalLockHandler handler = testee.getLocalHandler();
     
      resetToNice(partition);
      resetToStrict(handler);
     
      ArrayList<RemoteLockResponse> rspList = new ArrayList<RemoteLockResponse>();
      for (int i = 0; i < viewSize - 1; i++)
      {
         rspList.add(new RemoteLockResponse(null, RemoteLockResponse.Flag.OK));
      }
     
      expect(partition.callMethodOnCluster(eq("test"),
                                           eq("remoteLock"),
                                           eqLockParams(node1, 2000000),
                                           aryEq(AbstractClusterLockSupport.REMOTE_LOCK_TYPES),
                                           eq(true))).andReturn(rspList).atLeastOnce();
     
      handler.lockFromCluster(eq("test"), eq(node1), anyLong());
      expectLastCall().andThrow(new TimeoutException(node1)).atLeastOnce();

     
      expect(partition.callMethodOnCluster(eq("test"),
                                           eq("releaseRemoteLock"),
View Full Code Here

    */
   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);
View Full Code Here

   public void testSpuriousLockReleaseIgnored2() throws Exception
   {
      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);
View Full Code Here

TOP

Related Classes of org.jboss.ha.framework.server.lock.LocalLockHandler

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.