Examples of FamilyClusterInfo


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

   {
      ArrayList targets = new ArrayList();
      targets.add("ONE");
      targets.add("TWO");
      ClusteringTargetsRepository.initTarget("testImmutability", targets, 0);
      FamilyClusterInfo fci = ClusteringTargetsRepository.getFamilyClusterInfo("testImmutability");
     
      List fciTargets = fci.getTargets();
     
      // Confirm the targets are what we expect
      assertEquals("Expected number of targets", 2, fciTargets.size());
      assertEquals("First target as expected", "ONE", fciTargets.get(0));
      assertEquals("Second target as expected", "TWO", fciTargets.get(1));
     
      try
      {
         fciTargets.add("FAIL");
         fail("add call did not fail");
      }
      catch (UnsupportedOperationException good) {}
     
      try
      {
         fciTargets.addAll(targets);
         fail("addAll call did not fail");
      }
      catch (UnsupportedOperationException good) {}
     
      try
      {
         fciTargets.clear();
         fail("clear call did not fail");
      }
      catch (UnsupportedOperationException good) {}
     
      if (fciTargets instanceof ArrayList)
      {
         ArrayList fciArrayList = (ArrayList) fciTargets;
         try
         {
            fciArrayList.ensureCapacity(5);
            fail("ensureCapacity call did not fail");
         }
         catch (UnsupportedOperationException good) {}
        
         try
         {
            fciArrayList.trimToSize();
            fail("trimToSize call did not fail");
         }
         catch (UnsupportedOperationException good) {}
      }
     
      try
      {
         fciTargets.remove(0);
         fail("remove call did not fail");
      }
      catch (UnsupportedOperationException good) {}
     
      try
      {
         fciTargets.set(0, "FAIL");
         fail("set call did not fail");
      }
      catch (UnsupportedOperationException good) {}
     
      try
      {
         fciTargets.removeAll(targets);
         fail("removeAll call did not fail");
      }
      catch (UnsupportedOperationException good) {}
     
      try
      {
         fciTargets.retainAll(targets);
         fail("retainAll call did not fail");
      }
      catch (UnsupportedOperationException good) {}
     
      Iterator iter = fciTargets.iterator();
      int count = 0;
      while (iter.hasNext())
      {
         iter.next();
         count++;        
      }
      assertEquals("Correct count", 2, count);
      try
      {
         iter.remove();
         fail("Iterator.remove call did not fail");
      }
      catch (UnsupportedOperationException good) {}
     
      ListIterator listIter = fciTargets.listIterator();
      count = 0;
      while (listIter.hasNext())
      {
         listIter.next();
         count++;        
      }
      assertEquals("Correct count", 2, count);
      try
      {
         listIter.remove();
         fail("Iterator.remove call did not fail");
      }
      catch (UnsupportedOperationException good) {}
     
      while (listIter.hasPrevious())
      {
         listIter.previous();
         count--;
      }
      assertEquals("Correct count", 0, count);
     
      listIter = fciTargets.listIterator(1);
      while (listIter.hasNext())
      {
         listIter.next();
         count++;        
      }
      assertEquals("Correct count", 1, count);
      try
      {
         listIter.remove();
         fail("Iterator.remove call did not fail");
      }
      catch (UnsupportedOperationException good) {}
     
      while (listIter.hasPrevious())
      {
         listIter.previous();
         count--;
      }
      assertEquals("Correct count", -1, count);
     
      // Check the lists returned by other methods
      fciTargets = fci.updateClusterInfo(targets, 0);

      try
      {
         fciTargets.add("FAIL");
         fail("add call did not fail");
      }
      catch (UnsupportedOperationException good) {}
     
      fciTargets = fci.removeDeadTarget(targets.get(0));

      try
      {
         fciTargets.add("FAIL");
         fail("add call did not fail");
View Full Code Here

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

   @Override
   public void testInitialSelection()
   {
      testCount++;
      FamilyClusterInfo fci = ClusteringTargetsRepository.initTarget(FAMILY_BASE + testCount, Arrays.asList(TARGETS));
     
      LoadBalancePolicy lbp = getLoadBalancePolicy();
      Object target = lbp.chooseTarget(fci);
     
      for (int i = 0; i < 10000; i++)
View Full Code Here

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

   }
  
   public void testIdenticalAfterFailover()
   {
      testCount++;
      FamilyClusterInfo fci = ClusteringTargetsRepository.initTarget(FAMILY_BASE + testCount, Arrays.asList(TARGETS));
     
      LoadBalancePolicy lbp1 = getLoadBalancePolicy();
      Object target1 = lbp1.chooseTarget(fci);
     
      LoadBalancePolicy lbp2 = getLoadBalancePolicy();
     
      assertSame(target1, lbp2.chooseTarget(fci));
     
      fci.removeDeadTarget(target1);
     
      Object target3 = lbp1.chooseTarget(fci);
     
      assertFalse(target1.equals(target3));
     
View Full Code Here

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

  
   public void testBasicStickiness()
   {
      testCount++;
      List<String> targets = Arrays.asList(TARGETS);
      FamilyClusterInfo fci = ClusteringTargetsRepository.initTarget(FAMILY_BASE + testCount, targets);
     
      LoadBalancePolicy lbp = getLoadBalancePolicy();
      Object target = lbp.chooseTarget(fci);
     
      assertTrue(targets.contains(target));
View Full Code Here

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

   }
  
   public void testInitialSelection()
   {
      testCount++;
      FamilyClusterInfo fci = ClusteringTargetsRepository.initTarget(FAMILY_BASE + testCount, Arrays.asList(TARGETS));
     
      Set<Object> selected = new HashSet<Object>();
     
      for (int i = 0; i < 10000; i++)
      {
View Full Code Here

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

  
   public void testStickinessAfterFailover()
   {
      testCount++;
      List<String> targets = Arrays.asList(TARGETS);
      FamilyClusterInfo fci = ClusteringTargetsRepository.initTarget(FAMILY_BASE + testCount, targets);
     
      LoadBalancePolicy lbp = getLoadBalancePolicy();
      Object firstTarget;
      Object target = firstTarget = lbp.chooseTarget(fci);
     
      assertTrue(targets.contains(target));
     
      for (int i = 0; i < 5; i++)
         assertEquals(target, lbp.chooseTarget(fci));
     
      fci.removeDeadTarget(target);
      Object secondTarget;
      target = secondTarget = lbp.chooseTarget(fci);
     
      assertFalse(firstTarget.equals(secondTarget));
      assertTrue(targets.contains(target));
     
      for (int i = 0; i < 5; i++)
         assertEquals(target, lbp.chooseTarget(fci));
     
      fci.removeDeadTarget(target);
      Object thirdTarget;
      target = thirdTarget = lbp.chooseTarget(fci);
     
      assertFalse(firstTarget.equals(thirdTarget));
      assertFalse(secondTarget.equals(thirdTarget));
      assertTrue(targets.contains(target));
     
      for (int i = 0; i < 5; i++)
         assertEquals(target, lbp.chooseTarget(fci));
     
      fci.removeDeadTarget(target);
     
      assertNull(lbp.chooseTarget(fci));
   }
View Full Code Here

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

   }
  
   public void testNoAvailableTargets()
   {
      testCount++;
      FamilyClusterInfo fci = ClusteringTargetsRepository.initTarget(FAMILY_BASE + testCount, new ArrayList<Object>());
     
      assertNull(getLoadBalancePolicy().chooseTarget(fci));
   }
View Full Code Here

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

         return;
      }
     
      Context context = bindings.getContext();
     
      FamilyClusterInfo fci = beanClusteringInfo.getFamilyWrapper().get();    
      String familyName = fci.getFamilyName();
     
      for (JndiReferenceBinding binding : bindings.getDefaultRemoteBindings())
      {
         RefAddr refAddr = getFirstRefAddr(binding.getReference(), ClusteredProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_CLUSTER_FAMILY_NAME);
         if (refAddr != null && familyName.equals(refAddr.getContent()))
View Full Code Here

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

     
      RefAddr partitionRef = new StringRefAddr(ClusteredProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_CLUSTER_PARTITION_NAME, bci.getPartitionName());
      addRefAddrToReference(ref, partitionRef);
      RefAddr lbpRef = new StringRefAddr(ClusteredProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_CLUSTER_PROXY_FACTORY_LOAD_BALANCE_POLICY, bci.getHomeLoadBalancePolicy().getName());
      addRefAddrToReference(ref, lbpRef);
      FamilyClusterInfo fci = bci.getFamilyWrapper().get();
      RefAddr familyNameRef = new StringRefAddr(ClusteredProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_CLUSTER_FAMILY_NAME,
                                                fci.getFamilyName());
      addRefAddrToReference(ref, familyNameRef);
     
      decorateReferenceForClusteringTargets(ref, fci);
   }
View Full Code Here

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

   }

   public void testBasicCycle()
   {
      testCount++;
      FamilyClusterInfo fci = ClusteringTargetsRepository.initTarget(FAMILY_BASE + testCount, Arrays.asList(TARGETS));
      LoadBalancePolicy lbp = getLoadBalancePolicy();
      int expectedCursor = -1;
      for (int i = 0; i < 100; i++)
      {
         Object target = lbp.chooseTarget(fci);
         if (expectedCursor < 0)
         {
            expectedCursor = fci.getCursor();
         }
         else
         {
            expectedCursor = ++expectedCursor % TARGETS.length;
            assertEquals(expectedCursor, fci.getCursor());
         }
        
         assertEquals(TARGETS[expectedCursor], target);
        
      }
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.