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

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


   @Override
   protected NonGloballyExclusiveClusterLockSupport createClusteredLockManager(String serviceHAName,
         HAPartition partition, LocalLockHandler handler)
   {
      return new NonGloballyExclusiveClusterLockSupport(serviceHAName, partition, handler);
   }
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);
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);
View Full Code Here

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

  
   private void basicClusterLockFailsAgainstLocalLockTest(int viewSize) throws Exception
   {
      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"),
                                           aryEq(new Object[]{"test", node1}),
                                           aryEq(AbstractClusterLockSupport.RELEASE_REMOTE_LOCK_TYPES),
                                           eq(true))).andReturn(new ArrayList<Object>()).atLeastOnce();
      replay(partition);
      replay(handler);
     
      assertFalse(testee.lock("test", 10));
     
      verify(partition);
      verify(handler);
   }
View Full Code Here

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

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

TOP

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

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.