Package org.jboss.ha.client.loadbalance

Examples of org.jboss.ha.client.loadbalance.LoadBalancePolicy


   public void testTopologyChange()
   {
      testCount++;
      List<String> targets = Arrays.asList(TARGETS);
      FamilyClusterInfo fci = ClusteringTargetsRepository.initTarget(FAMILY_BASE + testCount, targets);
      LoadBalancePolicy lbp = getLoadBalancePolicy();
     
      String target = (String) lbp.chooseTarget(fci);
      int cursor = fci.getCursor();
      assertEquals(target, fci.getTargets().get(cursor));
     
      targets = Arrays.asList(new String[]{"W", "X", "Y", "Z"});
      fci.updateClusterInfo(targets, 1);
     
      int expectedCursor = ++cursor % targets.size();
     
      target = (String) lbp.chooseTarget(fci);
      cursor = fci.getCursor();
      assertEquals(expectedCursor, cursor);
      assertEquals(target, targets.get(cursor));
   }
View Full Code Here


   {
      testCount++;
      FamilyClusterInfo fci = ClusteringTargetsRepository.initTarget(FAMILY_BASE + testCount, Arrays.asList(TARGETS));
     
      Set<Object> selected = new HashSet<Object>();
      LoadBalancePolicy lbp = getLoadBalancePolicy();
     
      for (int i = 0; i < 10000; i++)
      {
         selected.add(lbp.chooseTarget(fci));
         if (selected.size() == TARGETS.length)
            break;
      }
     
      assertEquals(TARGETS.length, selected.size());
View Full Code Here

   public void testFailover()
   {
      testCount++;
      List<String> targets = new ArrayList<String>(Arrays.asList(TARGETS));
      FamilyClusterInfo fci = ClusteringTargetsRepository.initTarget(FAMILY_BASE + testCount, targets);
      LoadBalancePolicy lbp = getLoadBalancePolicy();
     
      String target = (String) lbp.chooseTarget(fci);
      assertTrue(targets.contains(target));
     
      while (targets.size() > 1)
      {
         fci.removeDeadTarget(target);
         targets.remove(target);
         assertEquals(targets, fci.getTargets());
        
         target = (String) lbp.chooseTarget(fci);
         assertTrue(targets.contains(target));
      }
   }
View Full Code Here

   public void testTopologyChange()
   {
      testCount++;
      List<String> targets = Arrays.asList(TARGETS);
      FamilyClusterInfo fci = ClusteringTargetsRepository.initTarget(FAMILY_BASE + testCount, targets);
      LoadBalancePolicy lbp = getLoadBalancePolicy();
     
      String target = (String) lbp.chooseTarget(fci);
      assertTrue(targets.contains(target));
     
      targets = Arrays.asList(new String[]{"W", "X", "Y", "Z"});
      fci.updateClusterInfo(targets, 1);
     
      target = (String) lbp.chooseTarget(fci);
      assertTrue(targets.contains(target));
   }
View Full Code Here

     
      Set<Object> selected = new HashSet<Object>();
     
      for (int i = 0; i < 10000; i++)
      {
         LoadBalancePolicy lbp = getLoadBalancePolicy();
         selected.add(lbp.chooseTarget(fci));
         if (selected.size() == TARGETS.length)
            break;
      }
     
      assertEquals(TARGETS.length, selected.size());
View Full Code Here

   {
      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));
     
      for (int i = 0; i < 10; i++)
         assertEquals(target, lbp.chooseTarget(fci));
   }
View Full Code Here

   {
      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

   {
      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));
     
      targets = Arrays.asList(new String[]{(String) target, "X", "Y"});
     
      fci.updateClusterInfo(targets, 1);
     
      for (int i = 0; i < 5; i++)
         assertEquals(target, lbp.chooseTarget(fci));
   }
View Full Code Here

   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++)
      {
         assertSame(target, getLoadBalancePolicy().chooseTarget(fci));
      }
View Full Code Here

   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));
     
      assertSame(target3, lbp2.chooseTarget(fci));
     
   }
View Full Code Here

TOP

Related Classes of org.jboss.ha.client.loadbalance.LoadBalancePolicy

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.