Examples of HAPartition


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

  
   public void testLocalLockingStateRejectsSuperiorRemoteCaller() throws Exception
   {
      TesteeSet<T> testeeSet = getTesteeSet(node1, 1, 3);
      T testee = testeeSet.impl;
      HAPartition partition = testee.getPartition();
      LocalLockHandler handler = testee.getLocalHandler();
      final RpcTarget target = testeeSet.target;
     
      ClusterNode superiorCaller = testee.getCurrentView().get(0);
      assertFalse(node1.equals(superiorCaller));

      resetToStrict(partition);   
      makeThreadSafe(partition, true);
      resetToStrict(handler);  
      makeThreadSafe(handler, true);
     
      ArrayList<RemoteLockResponse> rspList = new ArrayList<RemoteLockResponse>();
      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

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

  
   public void testRemoteLockingStateAllowsSuperiorRemoteCaller() throws Exception
   {
      TesteeSet<T> testeeSet = getTesteeSet(node1, 1, 3);
      T testee = testeeSet.impl;
      HAPartition partition = testee.getPartition();
      LocalLockHandler handler = testee.getLocalHandler();
      final RpcTarget target = testeeSet.target;
     
      ClusterNode superiorCaller = testee.getCurrentView().get(0);
      assertFalse(node1.equals(superiorCaller));

      resetToNice(partition);   // nice as we may loop retrying and failing
      makeThreadSafe(partition, true);
      resetToStrict(handler);  
      makeThreadSafe(handler, true);
     
      // When caller 1 invokes, block before giving response
      CountDownLatch answerAwaitLatch = new CountDownLatch(1);
      CountDownLatch answerStartLatch = new CountDownLatch(1);
     
      ArrayList<RemoteLockResponse> rspList = new ArrayList<RemoteLockResponse>();
      rspList.add(new RemoteLockResponse(null, RemoteLockResponse.Flag.OK));
      rspList.add(new RemoteLockResponse(null, RemoteLockResponse.Flag.REJECT, superiorCaller));
     
      BlockingAnswer<ArrayList<RemoteLockResponse>> caller1Answer = new BlockingAnswer<ArrayList<RemoteLockResponse>>(rspList, answerAwaitLatch, answerStartLatch, null);
     
      expect(partition.callMethodOnCluster(eq("test"),
                                           eq("remoteLock"),
                                           eqLockParams(node1, 200000),
                                           aryEq(AbstractClusterLockSupport.REMOTE_LOCK_TYPES),
                                           eq(true))).andAnswer(caller1Answer).atLeastOnce();
     
      handler.lockFromCluster(eq("test"), eq(superiorCaller), anyLong());  
     
      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();
         
View Full Code Here

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

  
   public void testRemoteLockingStateRejectsInferiorRemoteCaller() throws Exception
   {
      TesteeSet<T> testeeSet = getTesteeSet(node1, 1, 3);
      T testee = testeeSet.impl;
      HAPartition partition = testee.getPartition();
      LocalLockHandler handler = testee.getLocalHandler();
      final RpcTarget target = testeeSet.target;
     
      ClusterNode inferiorNode = testee.getCurrentView().get(2);
      assertFalse(node1.equals(inferiorNode));
     
      ClusterNode superiorNode = testee.getCurrentView().get(0);
      assertFalse(node1.equals(superiorNode));

      resetToStrict(partition);   
      makeThreadSafe(partition, true);
      resetToStrict(handler);  
      makeThreadSafe(handler, true);
     
      // When caller 1 invokes, block before giving response
      CountDownLatch answerAwaitLatch = new CountDownLatch(1);
      CountDownLatch answerStartLatch = new CountDownLatch(1);
     
      ArrayList<RemoteLockResponse> rspList = new ArrayList<RemoteLockResponse>();
      rspList.add(new RemoteLockResponse(superiorNode, RemoteLockResponse.Flag.OK));
      rspList.add(new RemoteLockResponse(inferiorNode, RemoteLockResponse.Flag.REJECT, inferiorNode));
     
      BlockingAnswer<ArrayList<RemoteLockResponse>> caller1Answer =
         new BlockingAnswer<ArrayList<RemoteLockResponse>>(rspList, answerAwaitLatch, answerStartLatch, null);
     
      expect(partition.callMethodOnCluster(eq("test"),
                                           eq("remoteLock"),
                                           eqLockParams(node1, 200000),
                                           aryEq(AbstractClusterLockSupport.REMOTE_LOCK_TYPES),
                                           eq(true))).andAnswer(caller1Answer)
     
      expect(partition.callMethodOnCluster(eq("test"),
            eq("releaseRemoteLock"),
            aryEq(new Object[]{"test", node1}),
            aryEq(AbstractClusterLockSupport.RELEASE_REMOTE_LOCK_TYPES),
            eq(true))).andReturn(new ArrayList<Object>());
     
      rspList = new ArrayList<RemoteLockResponse>();
      rspList.add(new RemoteLockResponse(superiorNode, RemoteLockResponse.Flag.OK));
      rspList.add(new RemoteLockResponse(inferiorNode, 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

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

    */
   public void testSpuriousRemoteLockReleaseIgnored() throws Exception
   {
      TesteeSet<T> testeeSet = getTesteeSet(node1, 1, 2);
      AbstractClusterLockSupport testee = testeeSet.impl;
      HAPartition partition = testee.getPartition();
      LocalLockHandler handler = testee.getLocalHandler();
     
      ClusterNode other = testee.getCurrentView().get(0);
      resetToStrict(partition);
      resetToStrict(handler);
     
      ArrayList<RemoteLockResponse> rspList = new ArrayList<RemoteLockResponse>();
      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

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

      verify(handler);
   }

   protected TesteeSet<T> getTesteeSet(ClusterNode node, int viewPos, int viewSize) throws Exception
   {
      HAPartition haPartition = createNiceMock(HAPartition.class);     
      LocalLockHandler handler = createNiceMock(LocalLockHandler.class);      
      expect(haPartition.getClusterNode()).andReturn(node);
      expect(haPartition.getPartitionName()).andReturn("TestPartition");
     
      Capture<RpcTarget>  c = new Capture<RpcTarget>();
      haPartition.registerRPCHandler(eq("test"), and(isA(RpcTarget.class), capture(c)));
      Vector<ClusterNode> view = getView(node, viewPos, viewSize);
      expect(haPartition.getClusterNodes()).andReturn(view.toArray(new ClusterNode[view.size()]));
     
      replay(haPartition);
      replay(handler);     
     
      T testee = createClusteredLockManager("test", haPartition, handler);
View Full Code Here

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

   {
      String clientBindUrl = ProxyFactoryHelper.getClientBindUrl(binding);
      locator = new InvokerLocator(clientBindUrl);
      String partitionName = ((StatelessContainer) getContainer()).getPartitionName();
      proxyFamilyName = ((StatelessContainer) getContainer()).getDeploymentQualifiedName() + locator.getProtocol() + partitionName;
      HAPartition partition = (HAPartition) getContainer().getInitialContext().lookup("/HAPartition/" + partitionName);
      hatarget = new HATarget(partition, proxyFamilyName, locator, HATarget.ENABLE_INVOCATIONS);
      ClusteringTargetsRepository.initTarget(proxyFamilyName, hatarget.getReplicants());
      ((StatelessContainer) getContainer()).getClusterFamilies().put(proxyFamilyName, hatarget);
      if (clustered.loadBalancePolicy() == null || clustered.loadBalancePolicy().equals(LoadBalancePolicy.class))
      {
         lbPolicy = new RandomRobin();
      }
      else
      {
         lbPolicy = clustered.loadBalancePolicy().newInstance();
      }
      wrapper = new FamilyWrapper(proxyFamilyName, hatarget.getReplicants());
     
      this.drm = partition.getDistributedReplicantManager();
      drm.registerListener(proxyFamilyName, this);
     
      super.start();
   }
View Full Code Here

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

   {
      String clientBindUrl = ProxyFactoryHelper.getClientBindUrl(binding);
      locator = new InvokerLocator(clientBindUrl);
      String partitionName = ((SessionContainer) getContainer()).getPartitionName();
      proxyFamilyName = ((SessionContainer) getContainer()).getDeploymentQualifiedName() + locator.getProtocol() + partitionName;
      HAPartition partition = (HAPartition) getContainer().getInitialContext().lookup("/HAPartition/" + partitionName);
      hatarget = new HATarget(partition, proxyFamilyName, locator, HATarget.ENABLE_INVOCATIONS);
      ClusteringTargetsRepository.initTarget(proxyFamilyName, hatarget.getReplicants());
      ((SessionContainer) getContainer()).getClusterFamilies().put(proxyFamilyName, hatarget);
      if (clustered.loadBalancePolicy() == null || clustered.loadBalancePolicy().equals(LoadBalancePolicy.class))
      {
         lbPolicy = new FirstAvailable();
      }
      else
      {
         lbPolicy = clustered.loadBalancePolicy().newInstance();
      }
      wrapper = new FamilyWrapper(proxyFamilyName, hatarget.getReplicants());
     
      this.drm = partition.getDistributedReplicantManager();
      drm.registerListener(proxyFamilyName, this);
     
      super.start();
     
      Class[] interfaces = {ProxyFactory.class};
View Full Code Here

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

    *
    * @throws IllegalStateException if no matching partition can be found
    */
   public HAPartition getHAPartition(String partitionName, Hashtable<?, ?> jndiProperties)
   {
      HAPartition partition = findInRegistry(partitionName);
      if (partition == null)
      {
         try
         {
            partition = findInJndi(partitionName, jndiProperties);
View Full Code Here

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

      String clientBindUrl = ProxyFactoryHelper.getClientBindUrl(binding);
      locator = new InvokerLocator(clientBindUrl);
      StatelessContainer container = (StatelessContainer) getContainer();
      String partitionName = container.getPartitionName();
      proxyFamilyName = container.getDeploymentQualifiedName() + locator.getProtocol() + partitionName;
      HAPartition partition = HAPartitionLocator.getHAPartitionLocator().getHAPartition(partitionName, container.getInitialContextProperties());
      drm = partition.getDistributedReplicantManager();
      hatarget = new HATarget(partition, proxyFamilyName, locator, HATarget.ENABLE_INVOCATIONS);
      ClusteringTargetsRepository.initTarget(proxyFamilyName, hatarget.getReplicants());
     
      container.getClusterFamilies().put(proxyFamilyName, hatarget);
     
View Full Code Here

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

    *
    * @throws IllegalStateException if no matching partition can be found
    */
   public HAPartition getHAPartition(String partitionName, Hashtable jndiProperties)
   {
      HAPartition partition = findInRegistry(partitionName);
      if (partition == null)
      {
         try
         {
            partition = findInJndi(partitionName, jndiProperties);
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.