Examples of FamilyClusterInfo


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

   }
  
   public void testSynchronization() throws Exception
   {
      ClusteringTargetsRepository.initTarget("testSynchronization", new ArrayList(), 0);
      FamilyClusterInfo fci = ClusteringTargetsRepository.getFamilyClusterInfo("testSynchronization");
     
      Updater updater = new Updater(fci);
      Remover remover = new Remover(fci);
      Resetter resetter = new Resetter(fci);
     
View Full Code Here

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

     
   }
  
   public void testCursor()
   {
      FamilyClusterInfo fci = ClusteringTargetsRepository.initTarget("testSynchronization", new ArrayList(), 0);
      fci.setCursor(1);
      assertEquals(1, fci.getCursor());
     
      fci.updateClusterInfo(Arrays.asList(new String[]{"A", "B"}), 1);
      assertEquals(1, fci.getCursor());
     
      fci.removeDeadTarget("B");
      assertEquals(1, fci.getCursor());
     
      fci.resetView();
      assertEquals(1, fci.getCursor());
     
      fci.setCursor(1);
      assertEquals(1, fci.getCursor());
     
      fci.setCursor(2);
      assertEquals(2, fci.getCursor());     
  
View Full Code Here

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

   public void testArbitaryObject()
   {
      Object ONE = new Integer(1);
      Object TWO = new Integer(2);
     
      FamilyClusterInfo fci = ClusteringTargetsRepository.initTarget("testSynchronization", new ArrayList(), 0);
      fci.setObject(ONE);
      assertSame(ONE, fci.getObject());
     
      fci.updateClusterInfo(Arrays.asList(new String[]{"A", "B"}), 1);
      assertSame(ONE, fci.getObject());
     
      fci.removeDeadTarget("B");
      assertSame(ONE, fci.getObject());
     
      fci.resetView();
      assertSame(ONE, fci.getObject());
     
      fci.setObject(ONE);
      assertSame(ONE, fci.getObject());
     
      fci.setObject(TWO);
      assertSame(TWO, fci.getObject());   
  
View Full Code Here

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

  
   public void testSerialization() throws IOException, ClassNotFoundException
   {
      List targets = Arrays.asList(new String[]{"A", "B"});
      FamilyWrapper wrapper = new FamilyWrapper("testSerialization", targets);
      FamilyClusterInfo fci = wrapper.get();
      assertNotNull(fci);
      assertEquals(targets, fci.getTargets());
     
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(baos);
      oos.writeObject(wrapper);
      oos.close();
      byte[] bytes = baos.toByteArray();
     
      List newTargets = Arrays.asList(new String[]{"C", "D"});
     
      FamilyClusterInfo fci2 = ClusteringTargetsRepository.initTarget("testSerialization", newTargets, 1);
     
      assertSame(fci, fci2);
     
      assertEquals(newTargets, fci.getTargets());
     
      ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
      ObjectInputStream ois = new ObjectInputStream(bais);
      FamilyWrapper deserialized = (FamilyWrapper) ois.readObject();
     
      FamilyClusterInfo fci3 = deserialized.get();
     
      assertSame(fci, fci3);
     
      assertEquals(targets, fci3.getTargets());
     
      assertSame(fci3, ClusteringTargetsRepository.getFamilyClusterInfo("testSerialization"));
   }
View Full Code Here

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

   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);
      int cursor = fci.getCursor();
      assertEquals(target, fci.getTargets().get(cursor));
     
      while (targets.size() > 1)
      {
         fci.removeDeadTarget(target);
         targets.remove(target);
         assertEquals(targets, fci.getTargets());
        
         int expectedCursor = ++cursor % targets.size();
        
         target = (String) lbp.chooseTarget(fci);
         cursor = fci.getCursor();
         assertEquals(expectedCursor, cursor);
         assertEquals(target, fci.getTargets().get(cursor));
      }
   }
View Full Code Here

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

   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

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

   }

   public void testSelectionSpread()
   {
      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++)
View Full Code Here

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

   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

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

   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
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.