Package org.apache.accumulo.server.master.balancer

Examples of org.apache.accumulo.server.master.balancer.SimpleLoggerBalancer.balance()


  public void testBalanceNewLoggers() {
    SimpleLoggerBalancer balancer = new SimpleLoggerBalancer(0);
    List<String> loggers = Arrays.asList("logger1", "logger2", "logger3");
    LoggerUser[] tservers = {new MockServer("tserv1", "logger1"), new MockServer("tserv2", "logger1"), new MockServer("tserv3", "logger1")};
    Map<LoggerUser,List<String>> assignmentsOut = new HashMap<LoggerUser,List<String>>();
    balancer.balance(Arrays.asList(tservers), loggers, assignmentsOut, 1);
    assertEquals(2, assignmentsOut.size());
    Map<String,Integer> computeUses = computeUses(tservers, assignmentsOut, 1);
   
    assertEquals(new Integer(1), computeUses.get("logger1"));
    assertEquals(new Integer(1), computeUses.get("logger2"));
View Full Code Here


  public void testBalanceTrivial() {
    SimpleLoggerBalancer balancer = new SimpleLoggerBalancer(0);
    LoggerUser[] tservers = {new MockServer("tserv1", "logger1"), new MockServer("tserv2", "logger2"), new MockServer("tserv3", "logger3")};
    List<String> loggers = Arrays.asList("logger1", "logger2", "logger3");
    Map<LoggerUser,List<String>> assignmentsOut = new HashMap<LoggerUser,List<String>>();
    balancer.balance(Arrays.asList(tservers), loggers, assignmentsOut, 1);
    assertEquals(0, assignmentsOut.size());
  }
 
  @Test
  public void testBalanceUneven() {
View Full Code Here

    SimpleLoggerBalancer balancer = new SimpleLoggerBalancer(0);
    List<String> loggers = Arrays.asList("logger1", "logger2", "logger3");
    LoggerUser[] tservers = {new MockServer("tserv1", "logger1", "logger2"), new MockServer("tserv2", "logger1", "logger2"),
        new MockServer("tserv3", "logger1", "logger2")};
    Map<LoggerUser,List<String>> assignmentsOut = new HashMap<LoggerUser,List<String>>();
    balancer.balance(Arrays.asList(tservers), loggers, assignmentsOut, 2);
    Map<String,Integer> computeUses = computeUses(tservers, assignmentsOut, 2);
    // make sure our unloaded logger got some work
    assertEquals(new Integer(2), computeUses.get("logger3"));
    // make sure the other loggers are still used
    Integer uses = computeUses.get("logger1").intValue() + computeUses.get("logger2").intValue();
View Full Code Here

    assertEquals(new Integer(2), computeUses.get("logger3"));
    // make sure the other loggers are still used
    Integer uses = computeUses.get("logger1").intValue() + computeUses.get("logger2").intValue();
    assertEquals(new Integer(4), uses);
    // re-run balancer
    balancer.balance(Arrays.asList(tservers), loggers, assignmentsOut, 2);
    computeUses = computeUses(tservers, assignmentsOut, 2);
    assertEquals(new Integer(2), computeUses.get("logger1"));
    assertEquals(new Integer(2), computeUses.get("logger2"));
    assertEquals(new Integer(2), computeUses.get("logger3"));
  }
View Full Code Here

    SimpleLoggerBalancer balancer = new SimpleLoggerBalancer(0);
    List<String> loggers = Arrays.asList("logger1", "logger2", "logger3", "logger4");
    LoggerUser[] tservers = {new MockServer("tserv1", "logger1", "logger2"), new MockServer("tserv2", "logger1", "logger2"),
        new MockServer("tserv3", "logger1", "logger2")};
    Map<LoggerUser,List<String>> assignmentsOut = new HashMap<LoggerUser,List<String>>();
    balancer.balance(Arrays.asList(tservers), loggers, assignmentsOut, 2);
    Map<String,Integer> computeUses = computeUses(tservers, assignmentsOut, 2);
    assertTrue(computeUses.get("logger1") <= 2);
    assertTrue(computeUses.get("logger2") <= 2);
    assertTrue(computeUses.get("logger3") <= 2);
    assertTrue(computeUses.get("logger4") <= 2);
View Full Code Here

    LoggerUser[] tservers = new LoggerUser[MANY];
    for (int i = 0; i < MANY; i++) {
      tservers[i] = new MockServer(String.format("tserv%s", i), "logger0", "logger1");
    }
    Map<LoggerUser,List<String>> assignmentsOut = new HashMap<LoggerUser,List<String>>();
    balancer.balance(Arrays.asList(tservers), loggers, assignmentsOut, 2);
    Map<String,Integer> computeUses = computeUses(tservers, assignmentsOut, 2);
    for (String logger : loggers) {
      assertTrue(computeUses.get(logger) == 2);
    }
  }
View Full Code Here

  public void testBalanceNewLoggers() {
    SimpleLoggerBalancer balancer = new SimpleLoggerBalancer(0);
    List<String> loggers = Arrays.asList("logger1", "logger2", "logger3");
    LoggerUser[] tservers = {new TabletServer("tserv1", "logger1"), new TabletServer("tserv2", "logger1"), new TabletServer("tserv3", "logger1")};
    Map<LoggerUser,List<String>> assignmentsOut = new HashMap<LoggerUser,List<String>>();
    balancer.balance(Arrays.asList(tservers), loggers, assignmentsOut, 1);
    assertEquals(2, assignmentsOut.size());
    Map<String,Integer> computeUses = computeUses(tservers, assignmentsOut, 1);
   
    assertEquals(new Integer(1), computeUses.get("logger1"));
    assertEquals(new Integer(1), computeUses.get("logger2"));
View Full Code Here

  public void testBalanceTrivial() {
    SimpleLoggerBalancer balancer = new SimpleLoggerBalancer(0);
    LoggerUser[] tservers = {new TabletServer("tserv1", "logger1"), new TabletServer("tserv2", "logger2"), new TabletServer("tserv3", "logger3")};
    List<String> loggers = Arrays.asList("logger1", "logger2", "logger3");
    Map<LoggerUser,List<String>> assignmentsOut = new HashMap<LoggerUser,List<String>>();
    balancer.balance(Arrays.asList(tservers), loggers, assignmentsOut, 1);
    assertEquals(0, assignmentsOut.size());
  }
 
  @Test
  public void testBalanceUneven() {
View Full Code Here

    SimpleLoggerBalancer balancer = new SimpleLoggerBalancer(0);
    List<String> loggers = Arrays.asList("logger1", "logger2", "logger3");
    LoggerUser[] tservers = {new TabletServer("tserv1", "logger1", "logger2"), new TabletServer("tserv2", "logger1", "logger2"),
        new TabletServer("tserv3", "logger1", "logger2")};
    Map<LoggerUser,List<String>> assignmentsOut = new HashMap<LoggerUser,List<String>>();
    balancer.balance(Arrays.asList(tservers), loggers, assignmentsOut, 2);
    Map<String,Integer> computeUses = computeUses(tservers, assignmentsOut, 2);
    // make sure our unloaded logger got some work
    assertEquals(new Integer(2), computeUses.get("logger3"));
    // make sure the other loggers are still used
    Integer uses = computeUses.get("logger1").intValue() + computeUses.get("logger2").intValue();
View Full Code Here

    assertEquals(new Integer(2), computeUses.get("logger3"));
    // make sure the other loggers are still used
    Integer uses = computeUses.get("logger1").intValue() + computeUses.get("logger2").intValue();
    assertEquals(new Integer(4), uses);
    // re-run balancer
    balancer.balance(Arrays.asList(tservers), loggers, assignmentsOut, 2);
    computeUses = computeUses(tservers, assignmentsOut, 2);
    assertEquals(new Integer(2), computeUses.get("logger1"));
    assertEquals(new Integer(2), computeUses.get("logger2"));
    assertEquals(new Integer(2), computeUses.get("logger3"));
  }
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.