Package org.jboss.ha.framework.interfaces

Examples of org.jboss.ha.framework.interfaces.HAPartition


   }

   public void start() throws Exception
   {
      // Lookup the parition
      HAPartition partition = HAPartitionLocator.getHAPartitionLocator().getHAPartition(partitionName, null);
      drm = partition.getDistributedReplicantManager();
      log.debug("Obtained DistributedReplicantManager from partition="+partitionName);
      drm.registerListener(category, this);
      // Bind the jboss.bind.address value into the DRM
      String address = System.getProperty("jboss.bind.address");
      drm.add(category, address);
View Full Code Here


      super.tearDown();
   }

   public void testConstructor() throws Exception
   {
      HAPartition haPartition = createNiceMock(HAPartition.class);     
      LocalLockHandler handler = createNiceMock(LocalLockHandler.class);
     
      try
      {
         createClusteredLockManager(null, haPartition, handler);
         fail("Null serviceHAName should prevent construction");
      }
      catch (IllegalArgumentException good) {}
     
      try
      {
         createClusteredLockManager("test", null, handler);
         fail("Null HAPartition should prevent construction");
      }
      catch (IllegalArgumentException good) {}    
     
      try
      {
         createClusteredLockManager("test", haPartition, null);
         fail("Null LocalLockHandler should prevent construction");
      }
      catch (IllegalArgumentException good) {} 
     
      expect(haPartition.getClusterNode()).andReturn(node1);
      expect(haPartition.getPartitionName()).andReturn("TestPartition");
     
      replay(haPartition);
      replay(handler);
     
      T testee = createClusteredLockManager("test", haPartition, handler);
View Full Code Here

      assertEquals("TestPartition", testee.getPartitionName());
   }

   public void testStart() throws Exception
   {
      HAPartition haPartition = createNiceMock(HAPartition.class);     
      LocalLockHandler handler = createNiceMock(LocalLockHandler.class);      
      expect(haPartition.getClusterNode()).andReturn(node1);
      expect(haPartition.getPartitionName()).andReturn("TestPartition");
     
      replay(haPartition);
      replay(handler);     
     
      T testee = createClusteredLockManager("test", haPartition, handler);
     
      try
      {
         testee.lock("id", 1000);
         fail("Call to lock() should fail if not started");
      }
      catch (IllegalStateException good) {}
     
      try
      {
         testee.unlock("id");
         fail("Call to unlock() should fail if not started");
      }
      catch (IllegalStateException good) {}
     
      reset(haPartition);
     
      assertEquals("Current view is empty when unstarted", 0, testee.getCurrentView().size());
     
      haPartition.registerRPCHandler(eq("test"), isA(RpcTarget.class));
      haPartition.registerMembershipListener(testee);
      expect(haPartition.getClusterNodes()).andReturn(new ClusterNode[]{node1});
      replay(haPartition);
     
      testee.start();
     
      verify(haPartition);
View Full Code Here

   public void testStop() throws Exception
   {
      TesteeSet<T> testeeSet = getTesteeSet(node1, 0, 1);
      T testee = testeeSet.impl;
      HAPartition haPartition = testee.getPartition();     
     
      reset(haPartition);
  
      haPartition.unregisterMembershipListener(testee);
      haPartition.unregisterRPCHandler(eq("test"), same(testeeSet.target));
     
      replay(haPartition);
     
      testee.stop();
     
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);
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);
View Full Code Here

      InitialContext ctx = new InitialContext(env);
      String partitionName = env.getProperty(NamingContext.JNP_PARTITION_NAME);
      if( partitionName != null )
      {
         String partitionJndiName = "/HAPartition/" + partitionName;
         HAPartition partition = (HAPartition) ctx.lookup(partitionJndiName);
         Vector view = partition.getCurrentView();
         log.debug("Found HAPartition: "+partitionName);
         hosts = new String[view.size()];
         for(int v = 0; v < view.size(); v ++)
         {
            Object addr = view.get(v);
            log.debug(addr);
            hosts[v] = addr.toString();
         }
      }
      else
      {
         NamingEnumeration iter = ctx.list("/HAPartition");
         while( iter.hasMore() )
         {
            NameClassPair pair = (NameClassPair) iter.next();
            partitionName = pair.getName();
            String partitionJndiName = "/HAPartition/" + partitionName;
            HAPartition partition = (HAPartition) ctx.lookup(partitionJndiName);
            env.setProperty(NamingContext.JNP_PARTITION_NAME, partitionName);
            Vector view = partition.getCurrentView();
            log.debug("Found HAPartition: "+partitionName);
            hosts = new String[view.size()];
            for(int v = 0; v < view.size(); v ++)
            {
               Object addr = view.get(v);
View Full Code Here

   private void basicClusterLockTest(int viewSize) throws Exception
   {
      int viewPos = viewSize == 1 ? 0 : 1;
      TesteeSet<T> testeeSet = getTesteeSet(node1, viewPos, viewSize);
      AbstractClusterLockSupport testee = testeeSet.impl;
      HAPartition partition = testee.getPartition();
      LocalLockHandler handler = testee.getLocalHandler();
     
      resetToStrict(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, 200000),
                                           aryEq(AbstractClusterLockSupport.REMOTE_LOCK_TYPES),
                                           eq(true))).andReturn(rspList);
     
View Full Code Here

  
   public void testRemoteRejectionFromSuperiorCaller() throws Exception
   {
      TesteeSet<T> testeeSet = getTesteeSet(node1, 1, 3);
      AbstractClusterLockSupport testee = testeeSet.impl;
      HAPartition partition = testee.getPartition();
      LocalLockHandler handler = testee.getLocalHandler();
     
      resetToNice(partition);
      resetToStrict(handler);
     
      ClusterNode superior = testee.getCurrentView().get(0);
     
      ArrayList<RemoteLockResponse> rspList = new ArrayList<RemoteLockResponse>();
      rspList.add(new RemoteLockResponse(null, RemoteLockResponse.Flag.OK));
      rspList.add(new RemoteLockResponse(null, RemoteLockResponse.Flag.REJECT, superior));
     
     
      expect(partition.callMethodOnCluster(eq("test"),
                                           eq("remoteLock"),
                                           eqLockParams(node1, 200000),
                                           aryEq(AbstractClusterLockSupport.REMOTE_LOCK_TYPES),
                                           eq(true))).andReturn(rspList).atLeastOnce();
     
View Full Code Here

  
   public void testRemoteRejectionFromInferiorCaller() throws Exception
   {
      TesteeSet<T> testeeSet = getTesteeSet(node1, 1, 3);
      AbstractClusterLockSupport testee = testeeSet.impl;
      HAPartition partition = testee.getPartition();
      LocalLockHandler handler = testee.getLocalHandler();
     
      resetToStrict(partition);
      resetToStrict(handler);
     
      ClusterNode inferior = testee.getCurrentView().get(2);
     
      ArrayList<RemoteLockResponse> rspList = new ArrayList<RemoteLockResponse>();
      rspList.add(new RemoteLockResponse(null, RemoteLockResponse.Flag.OK));
      rspList.add(new RemoteLockResponse(null, RemoteLockResponse.Flag.REJECT, inferior));
     
     
      expect(partition.callMethodOnCluster(eq("test"),
                                           eq("remoteLock"),
                                           eqLockParams(node1, 200000),
                                           aryEq(AbstractClusterLockSupport.REMOTE_LOCK_TYPES),
                                           eq(true))).andReturn(rspList);

     
      expect(partition.callMethodOnCluster(eq("test"),
                                           eq("releaseRemoteLock"),
                                           aryEq(new Object[]{"test", node1}),
                                           aryEq(AbstractClusterLockSupport.RELEASE_REMOTE_LOCK_TYPES),
                                           eq(true))).andReturn(rspList);
     
      rspList = new ArrayList<RemoteLockResponse>();
      rspList.add(new RemoteLockResponse(null, RemoteLockResponse.Flag.OK));
      rspList.add(new RemoteLockResponse(null, RemoteLockResponse.Flag.OK));
     
      expect(partition.callMethodOnCluster(eq("test"),
                                           eq("remoteLock"),
                                           eqLockParams(node1, 200000),
                                           aryEq(AbstractClusterLockSupport.REMOTE_LOCK_TYPES),
                                           eq(true))).andReturn(rspList);
     
View Full Code Here

TOP

Related Classes of org.jboss.ha.framework.interfaces.HAPartition

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.