当前位置: 首页>>代码示例>>Java>>正文


Java DummyZKFC类代码示例

本文整理汇总了Java中org.apache.hadoop.ha.MiniZKFCCluster.DummyZKFC的典型用法代码示例。如果您正苦于以下问题:Java DummyZKFC类的具体用法?Java DummyZKFC怎么用?Java DummyZKFC使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DummyZKFC类属于org.apache.hadoop.ha.MiniZKFCCluster包,在下文中一共展示了DummyZKFC类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFormatOneClusterLeavesOtherClustersAlone

import org.apache.hadoop.ha.MiniZKFCCluster.DummyZKFC; //导入依赖的package包/类
@Test
public void testFormatOneClusterLeavesOtherClustersAlone() throws Exception {
  DummyHAService svc = cluster.getService(1);

  DummyZKFC zkfcInOtherCluster = new DummyZKFC(conf, cluster.getService(1)) {
    @Override
    protected String getScopeInsideParentNode() {
      return "other-scope";
    }
  };
  
  // Run without formatting the base dir,
  // should barf
  assertEquals(ZKFailoverController.ERR_CODE_NO_PARENT_ZNODE,
      runFC(svc));

  // Format the base dir, should succeed
  assertEquals(0, runFC(svc, "-formatZK"));
  
  // Run the other cluster without formatting, should barf because
  // it uses a different parent znode
  assertEquals(ZKFailoverController.ERR_CODE_NO_PARENT_ZNODE,
      zkfcInOtherCluster.run(new String[]{}));
  
  // Should succeed in formatting the second cluster
  assertEquals(0, zkfcInOtherCluster.run(new String[]{"-formatZK"}));

  // But should not have deleted the original base node from the first
  // cluster
  assertEquals(ZKFailoverController.ERR_CODE_FORMAT_DENIED,
      runFC(svc, "-formatZK", "-nonInteractive"));
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:33,代码来源:TestZKFailoverController.java

示例2: testCedeActive

import org.apache.hadoop.ha.MiniZKFCCluster.DummyZKFC; //导入依赖的package包/类
/**
 * Test that the ZKFC can gracefully cede its active status.
 */
@Test
public void testCedeActive() throws Exception {
  cluster.start();
  DummyZKFC zkfc = cluster.getZkfc(0);
  // It should be in active to start.
  assertEquals(ActiveStandbyElector.State.ACTIVE,
      zkfc.getElectorForTests().getStateForTests());

  // Ask it to cede active for 3 seconds. It should respond promptly
  // (i.e. the RPC itself should not take 3 seconds!)
  ZKFCProtocol proxy = zkfc.getLocalTarget().getZKFCProxy(conf, 5000);
  long st = Time.now();
  proxy.cedeActive(3000);
  long et = Time.now();
  assertTrue("RPC to cedeActive took " + (et - st) + " ms",
      et - st < 1000);

  // Should be in "INIT" state since it's not in the election
  // at this point.
  assertEquals(ActiveStandbyElector.State.INIT,
      zkfc.getElectorForTests().getStateForTests());

  // After the prescribed 3 seconds, should go into STANDBY state,
  // since the other node in the cluster would have taken ACTIVE.
  cluster.waitForElectorState(0, ActiveStandbyElector.State.STANDBY);
  long et2 = Time.now();
  assertTrue("Should take ~3 seconds to rejoin. Only took " + (et2 - et) +
      "ms before rejoining.",
      et2 - et > 2800);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:34,代码来源:TestZKFailoverController.java

示例3: testCedeActive

import org.apache.hadoop.ha.MiniZKFCCluster.DummyZKFC; //导入依赖的package包/类
/**
 * Test that the ZKFC can gracefully cede its active status.
 */
@Test(timeout=15000)
public void testCedeActive() throws Exception {
  try {
    cluster.start();
    DummyZKFC zkfc = cluster.getZkfc(0);
    // It should be in active to start.
    assertEquals(ActiveStandbyElector.State.ACTIVE,
        zkfc.getElectorForTests().getStateForTests());

    // Ask it to cede active for 3 seconds. It should respond promptly
    // (i.e. the RPC itself should not take 3 seconds!)
    ZKFCProtocol proxy = zkfc.getLocalTarget().getZKFCProxy(conf, 5000);
    long st = Time.now();
    proxy.cedeActive(3000);
    long et = Time.now();
    assertTrue("RPC to cedeActive took " + (et - st) + " ms",
        et - st < 1000);
    
    // Should be in "INIT" state since it's not in the election
    // at this point.
    assertEquals(ActiveStandbyElector.State.INIT,
        zkfc.getElectorForTests().getStateForTests());

    // After the prescribed 3 seconds, should go into STANDBY state,
    // since the other node in the cluster would have taken ACTIVE.
    cluster.waitForElectorState(0, ActiveStandbyElector.State.STANDBY);
    long et2 = Time.now();
    assertTrue("Should take ~3 seconds to rejoin. Only took " + (et2 - et) +
        "ms before rejoining.",
        et2 - et > 2800);      
  } finally {
    cluster.stop();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:38,代码来源:TestZKFailoverController.java

示例4: runFC

import org.apache.hadoop.ha.MiniZKFCCluster.DummyZKFC; //导入依赖的package包/类
private int runFC(DummyHAService target, String ... args) throws Exception {
  DummyZKFC zkfc = new DummyZKFC(conf, target);
  return zkfc.run(args);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:5,代码来源:TestZKFailoverController.java


注:本文中的org.apache.hadoop.ha.MiniZKFCCluster.DummyZKFC类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。