Java 类org.apache.hadoop.hdfs.qjournal.client.QuorumCall 实例源码

项目:hadoop    文件:TestQuorumCall.java   
@Test(timeout=10000)
public void testQuorums() throws Exception {
  Map<String, SettableFuture<String>> futures = ImmutableMap.of(
      "f1", SettableFuture.<String>create(),
      "f2", SettableFuture.<String>create(),
      "f3", SettableFuture.<String>create());

  QuorumCall<String, String> q = QuorumCall.create(futures);
  assertEquals(0, q.countResponses());

  futures.get("f1").set("first future");
  q.waitFor(1, 0, 0, 100000, "test"); // wait for 1 response
  q.waitFor(0, 1, 0, 100000, "test"); // wait for 1 success
  assertEquals(1, q.countResponses());


  futures.get("f2").setException(new Exception("error"));
  assertEquals(2, q.countResponses());

  futures.get("f3").set("second future");
  q.waitFor(3, 0, 100, 100000, "test"); // wait for 3 responses
  q.waitFor(0, 2, 100, 100000, "test"); // 2 successes

  assertEquals(3, q.countResponses());
  assertEquals("f1=first future,f3=second future",
      Joiner.on(",").withKeyValueSeparator("=").join(
          new TreeMap<String, String>(q.getResults())));

  try {
    q.waitFor(0, 4, 100, 10, "test");
    fail("Didn't time out waiting for more responses than came back");
  } catch (TimeoutException te) {
    // expected
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestQuorumCall.java   
@Test(timeout=10000)
public void testQuorums() throws Exception {
  Map<String, SettableFuture<String>> futures = ImmutableMap.of(
      "f1", SettableFuture.<String>create(),
      "f2", SettableFuture.<String>create(),
      "f3", SettableFuture.<String>create());

  QuorumCall<String, String> q = QuorumCall.create(futures);
  assertEquals(0, q.countResponses());

  futures.get("f1").set("first future");
  q.waitFor(1, 0, 0, 100000, "test"); // wait for 1 response
  q.waitFor(0, 1, 0, 100000, "test"); // wait for 1 success
  assertEquals(1, q.countResponses());


  futures.get("f2").setException(new Exception("error"));
  assertEquals(2, q.countResponses());

  futures.get("f3").set("second future");
  q.waitFor(3, 0, 100, 100000, "test"); // wait for 3 responses
  q.waitFor(0, 2, 100, 100000, "test"); // 2 successes

  assertEquals(3, q.countResponses());
  assertEquals("f1=first future,f3=second future",
      Joiner.on(",").withKeyValueSeparator("=").join(
          new TreeMap<String, String>(q.getResults())));

  try {
    q.waitFor(0, 4, 100, 10, "test");
    fail("Didn't time out waiting for more responses than came back");
  } catch (TimeoutException te) {
    // expected
  }
}
项目:big-c    文件:TestQuorumCall.java   
@Test(timeout=10000)
public void testQuorums() throws Exception {
  Map<String, SettableFuture<String>> futures = ImmutableMap.of(
      "f1", SettableFuture.<String>create(),
      "f2", SettableFuture.<String>create(),
      "f3", SettableFuture.<String>create());

  QuorumCall<String, String> q = QuorumCall.create(futures);
  assertEquals(0, q.countResponses());

  futures.get("f1").set("first future");
  q.waitFor(1, 0, 0, 100000, "test"); // wait for 1 response
  q.waitFor(0, 1, 0, 100000, "test"); // wait for 1 success
  assertEquals(1, q.countResponses());


  futures.get("f2").setException(new Exception("error"));
  assertEquals(2, q.countResponses());

  futures.get("f3").set("second future");
  q.waitFor(3, 0, 100, 100000, "test"); // wait for 3 responses
  q.waitFor(0, 2, 100, 100000, "test"); // 2 successes

  assertEquals(3, q.countResponses());
  assertEquals("f1=first future,f3=second future",
      Joiner.on(",").withKeyValueSeparator("=").join(
          new TreeMap<String, String>(q.getResults())));

  try {
    q.waitFor(0, 4, 100, 10, "test");
    fail("Didn't time out waiting for more responses than came back");
  } catch (TimeoutException te) {
    // expected
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestQuorumCall.java   
@Test(timeout=10000)
public void testQuorums() throws Exception {
  Map<String, SettableFuture<String>> futures = ImmutableMap.of(
      "f1", SettableFuture.<String>create(),
      "f2", SettableFuture.<String>create(),
      "f3", SettableFuture.<String>create());

  QuorumCall<String, String> q = QuorumCall.create(futures);
  assertEquals(0, q.countResponses());

  futures.get("f1").set("first future");
  q.waitFor(1, 0, 0, 100000, "test"); // wait for 1 response
  q.waitFor(0, 1, 0, 100000, "test"); // wait for 1 success
  assertEquals(1, q.countResponses());


  futures.get("f2").setException(new Exception("error"));
  assertEquals(2, q.countResponses());

  futures.get("f3").set("second future");
  q.waitFor(3, 0, 100, 100000, "test"); // wait for 3 responses
  q.waitFor(0, 2, 100, 100000, "test"); // 2 successes

  assertEquals(3, q.countResponses());
  assertEquals("f1=first future,f3=second future",
      Joiner.on(",").withKeyValueSeparator("=").join(
          new TreeMap<String, String>(q.getResults())));

  try {
    q.waitFor(0, 4, 100, 10, "test");
    fail("Didn't time out waiting for more responses than came back");
  } catch (TimeoutException te) {
    // expected
  }
}
项目:hadoop-EAR    文件:TestQuorumCall.java   
@Test(timeout=10000)
public void testQuorums() throws Exception {
  Map<String, SettableFuture<String>> futures = ImmutableMap.of(
      "f1", SettableFuture.<String>create(),
      "f2", SettableFuture.<String>create(),
      "f3", SettableFuture.<String>create());

  QuorumCall<String, String> q = QuorumCall.create(futures);
  assertEquals(0, q.countResponses());

  futures.get("f1").set("first future");
  q.waitFor(1, 0, 0, 100000, "test"); // wait for 1 response
  q.waitFor(0, 1, 0, 100000, "test"); // wait for 1 success
  assertEquals(1, q.countResponses());


  futures.get("f2").setException(new Exception("error"));
  assertEquals(2, q.countResponses());

  futures.get("f3").set("second future");
  q.waitFor(3, 0, 100, 100000, "test"); // wait for 3 responses
  q.waitFor(0, 2, 100, 100000, "test"); // 2 successes

  assertEquals(3, q.countResponses());
  assertEquals("f1=first future,f3=second future",
      Joiner.on(",").withKeyValueSeparator("=").join(
          new TreeMap<String, String>(q.getResults())));

  try {
    q.waitFor(0, 4, 100, 10, "test");
    fail("Didn't time out waiting for more responses than came back");
  } catch (TimeoutException te) {
    // expected
  }
}
项目:hadoop-plus    文件:TestQuorumCall.java   
@Test(timeout=10000)
public void testQuorums() throws Exception {
  Map<String, SettableFuture<String>> futures = ImmutableMap.of(
      "f1", SettableFuture.<String>create(),
      "f2", SettableFuture.<String>create(),
      "f3", SettableFuture.<String>create());

  QuorumCall<String, String> q = QuorumCall.create(futures);
  assertEquals(0, q.countResponses());

  futures.get("f1").set("first future");
  q.waitFor(1, 0, 0, 100000, "test"); // wait for 1 response
  q.waitFor(0, 1, 0, 100000, "test"); // wait for 1 success
  assertEquals(1, q.countResponses());


  futures.get("f2").setException(new Exception("error"));
  assertEquals(2, q.countResponses());

  futures.get("f3").set("second future");
  q.waitFor(3, 0, 100, 100000, "test"); // wait for 3 responses
  q.waitFor(0, 2, 100, 100000, "test"); // 2 successes

  assertEquals(3, q.countResponses());
  assertEquals("f1=first future,f3=second future",
      Joiner.on(",").withKeyValueSeparator("=").join(
          new TreeMap<String, String>(q.getResults())));

  try {
    q.waitFor(0, 4, 100, 10, "test");
    fail("Didn't time out waiting for more responses than came back");
  } catch (TimeoutException te) {
    // expected
  }
}
项目:FlexMap    文件:TestQuorumCall.java   
@Test(timeout=10000)
public void testQuorums() throws Exception {
  Map<String, SettableFuture<String>> futures = ImmutableMap.of(
      "f1", SettableFuture.<String>create(),
      "f2", SettableFuture.<String>create(),
      "f3", SettableFuture.<String>create());

  QuorumCall<String, String> q = QuorumCall.create(futures);
  assertEquals(0, q.countResponses());

  futures.get("f1").set("first future");
  q.waitFor(1, 0, 0, 100000, "test"); // wait for 1 response
  q.waitFor(0, 1, 0, 100000, "test"); // wait for 1 success
  assertEquals(1, q.countResponses());


  futures.get("f2").setException(new Exception("error"));
  assertEquals(2, q.countResponses());

  futures.get("f3").set("second future");
  q.waitFor(3, 0, 100, 100000, "test"); // wait for 3 responses
  q.waitFor(0, 2, 100, 100000, "test"); // 2 successes

  assertEquals(3, q.countResponses());
  assertEquals("f1=first future,f3=second future",
      Joiner.on(",").withKeyValueSeparator("=").join(
          new TreeMap<String, String>(q.getResults())));

  try {
    q.waitFor(0, 4, 100, 10, "test");
    fail("Didn't time out waiting for more responses than came back");
  } catch (TimeoutException te) {
    // expected
  }
}
项目:hadoop-TCP    文件:TestQuorumCall.java   
@Test(timeout=10000)
public void testQuorums() throws Exception {
  Map<String, SettableFuture<String>> futures = ImmutableMap.of(
      "f1", SettableFuture.<String>create(),
      "f2", SettableFuture.<String>create(),
      "f3", SettableFuture.<String>create());

  QuorumCall<String, String> q = QuorumCall.create(futures);
  assertEquals(0, q.countResponses());

  futures.get("f1").set("first future");
  q.waitFor(1, 0, 0, 100000, "test"); // wait for 1 response
  q.waitFor(0, 1, 0, 100000, "test"); // wait for 1 success
  assertEquals(1, q.countResponses());


  futures.get("f2").setException(new Exception("error"));
  assertEquals(2, q.countResponses());

  futures.get("f3").set("second future");
  q.waitFor(3, 0, 100, 100000, "test"); // wait for 3 responses
  q.waitFor(0, 2, 100, 100000, "test"); // 2 successes

  assertEquals(3, q.countResponses());
  assertEquals("f1=first future,f3=second future",
      Joiner.on(",").withKeyValueSeparator("=").join(
          new TreeMap<String, String>(q.getResults())));

  try {
    q.waitFor(0, 4, 100, 10, "test");
    fail("Didn't time out waiting for more responses than came back");
  } catch (TimeoutException te) {
    // expected
  }
}
项目:hardfs    文件:TestQuorumCall.java   
@Test(timeout=10000)
public void testQuorums() throws Exception {
  Map<String, SettableFuture<String>> futures = ImmutableMap.of(
      "f1", SettableFuture.<String>create(),
      "f2", SettableFuture.<String>create(),
      "f3", SettableFuture.<String>create());

  QuorumCall<String, String> q = QuorumCall.create(futures);
  assertEquals(0, q.countResponses());

  futures.get("f1").set("first future");
  q.waitFor(1, 0, 0, 100000, "test"); // wait for 1 response
  q.waitFor(0, 1, 0, 100000, "test"); // wait for 1 success
  assertEquals(1, q.countResponses());


  futures.get("f2").setException(new Exception("error"));
  assertEquals(2, q.countResponses());

  futures.get("f3").set("second future");
  q.waitFor(3, 0, 100, 100000, "test"); // wait for 3 responses
  q.waitFor(0, 2, 100, 100000, "test"); // 2 successes

  assertEquals(3, q.countResponses());
  assertEquals("f1=first future,f3=second future",
      Joiner.on(",").withKeyValueSeparator("=").join(
          new TreeMap<String, String>(q.getResults())));

  try {
    q.waitFor(0, 4, 100, 10, "test");
    fail("Didn't time out waiting for more responses than came back");
  } catch (TimeoutException te) {
    // expected
  }
}
项目:hadoop-on-lustre2    文件:TestQuorumCall.java   
@Test(timeout=10000)
public void testQuorums() throws Exception {
  Map<String, SettableFuture<String>> futures = ImmutableMap.of(
      "f1", SettableFuture.<String>create(),
      "f2", SettableFuture.<String>create(),
      "f3", SettableFuture.<String>create());

  QuorumCall<String, String> q = QuorumCall.create(futures);
  assertEquals(0, q.countResponses());

  futures.get("f1").set("first future");
  q.waitFor(1, 0, 0, 100000, "test"); // wait for 1 response
  q.waitFor(0, 1, 0, 100000, "test"); // wait for 1 success
  assertEquals(1, q.countResponses());


  futures.get("f2").setException(new Exception("error"));
  assertEquals(2, q.countResponses());

  futures.get("f3").set("second future");
  q.waitFor(3, 0, 100, 100000, "test"); // wait for 3 responses
  q.waitFor(0, 2, 100, 100000, "test"); // 2 successes

  assertEquals(3, q.countResponses());
  assertEquals("f1=first future,f3=second future",
      Joiner.on(",").withKeyValueSeparator("=").join(
          new TreeMap<String, String>(q.getResults())));

  try {
    q.waitFor(0, 4, 100, 10, "test");
    fail("Didn't time out waiting for more responses than came back");
  } catch (TimeoutException te) {
    // expected
  }
}