Package net.sf.katta.util

Examples of net.sf.katta.util.SleepServer


  @SuppressWarnings("unused")
  private static Logger LOG = Logger.getLogger(SleepServerTest.class);

  @Test
  public void testNoSleep() throws Exception {
    SleepServer server = new SleepServer();
    long start = System.currentTimeMillis();
    server.sleep(0, 0, null);
    long time = System.currentTimeMillis() - start;
    assertTrue(time < 10);
  }
View Full Code Here


    assertTrue(time < 10);
  }

  @Test
  public void testSleep() throws Exception {
    SleepServer server = new SleepServer();
    long start = System.currentTimeMillis();
    server.sleep(100, 0, null);
    long time = System.currentTimeMillis() - start;
    assertTrue("took " + time, time >= 100);
  }
View Full Code Here

    assertTrue("took " + time, time >= 100);
  }

  @Test
  public void testVariation() throws IllegalArgumentException {
    SleepServer server = new SleepServer();
    long min = Integer.MAX_VALUE;
    long max = -1;
    for (int i = 0; i < 200; i++) {
      long n = checkTime(server);
      max = Math.max(n, max);
View Full Code Here

    return System.currentTimeMillis() - start;
  }

  @Test
  public void testShards() throws IllegalArgumentException {
    SleepServer server = new SleepServer();
    server.init("sleepy", newNodeConfiguration());
    try {
      server.sleep(0L, 0, new String[] { "not-found" });
      fail("Should have failed");
    } catch (IllegalArgumentException e) {
      assertEquals("Node sleepy invalid shards: not-found", e.getMessage());
    }
    server.addShard("s1", null);
    server.sleep(0L, 0, new String[] { "s1" });
    try {
      server.sleep(0L, 0, new String[] { "s1", "s2" });
    } catch (IllegalArgumentException e) {
      assertEquals("Node sleepy invalid shards: s2", e.getMessage());
    }
    server.addShard("s2", null);
    server.sleep(0L, 0, new String[] { "s1", "s2" });
  }
View Full Code Here

TOP

Related Classes of net.sf.katta.util.SleepServer

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.