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


Java AlwaysSucceedFencer.fenceCalled方法代码示例

本文整理汇总了Java中org.apache.hadoop.ha.TestNodeFencer.AlwaysSucceedFencer.fenceCalled方法的典型用法代码示例。如果您正苦于以下问题:Java AlwaysSucceedFencer.fenceCalled方法的具体用法?Java AlwaysSucceedFencer.fenceCalled怎么用?Java AlwaysSucceedFencer.fenceCalled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.ha.TestNodeFencer.AlwaysSucceedFencer的用法示例。


在下文中一共展示了AlwaysSucceedFencer.fenceCalled方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFailoverAndFailback

import org.apache.hadoop.ha.TestNodeFencer.AlwaysSucceedFencer; //导入方法依赖的package包/类
@Test
public void testFailoverAndFailback() throws Exception {
  DummyHAService svc1 = new DummyHAService(HAServiceState.ACTIVE, svc1Addr);
  DummyHAService svc2 = new DummyHAService(HAServiceState.STANDBY, svc2Addr);
  svc1.fencer = svc2.fencer = setupFencer(AlwaysSucceedFencer.class.getName());

  AlwaysSucceedFencer.fenceCalled = 0;
  doFailover(svc1, svc2, false, false);
  assertEquals(0, TestNodeFencer.AlwaysSucceedFencer.fenceCalled);
  assertEquals(HAServiceState.STANDBY, svc1.state);
  assertEquals(HAServiceState.ACTIVE, svc2.state);

  AlwaysSucceedFencer.fenceCalled = 0;
  doFailover(svc2, svc1, false, false);
  assertEquals(0, TestNodeFencer.AlwaysSucceedFencer.fenceCalled);
  assertEquals(HAServiceState.ACTIVE, svc1.state);
  assertEquals(HAServiceState.STANDBY, svc2.state);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:19,代码来源:TestFailoverController.java

示例2: testFailoverFromFaultyServiceSucceeds

import org.apache.hadoop.ha.TestNodeFencer.AlwaysSucceedFencer; //导入方法依赖的package包/类
@Test
public void testFailoverFromFaultyServiceSucceeds() throws Exception {
  DummyHAService svc1 = new DummyHAService(HAServiceState.ACTIVE, svc1Addr);
  Mockito.doThrow(new ServiceFailedException("Failed!"))
      .when(svc1.proxy).transitionToStandby(anyReqInfo());

  DummyHAService svc2 = new DummyHAService(HAServiceState.STANDBY, svc2Addr);
  svc1.fencer = svc2.fencer = setupFencer(AlwaysSucceedFencer.class.getName());

  AlwaysSucceedFencer.fenceCalled = 0;
  try {
    doFailover(svc1, svc2, false, false);
  } catch (FailoverFailedException ffe) {
    fail("Faulty active prevented failover");
  }

  // svc1 still thinks it's active, that's OK, it was fenced
  assertEquals(1, AlwaysSucceedFencer.fenceCalled);
  assertSame(svc1, AlwaysSucceedFencer.fencedSvc);
  assertEquals(HAServiceState.ACTIVE, svc1.state);
  assertEquals(HAServiceState.ACTIVE, svc2.state);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:23,代码来源:TestFailoverController.java

示例3: testWeFenceOnFailbackIfTransitionToActiveFails

import org.apache.hadoop.ha.TestNodeFencer.AlwaysSucceedFencer; //导入方法依赖的package包/类
@Test
public void testWeFenceOnFailbackIfTransitionToActiveFails() throws Exception {
  DummyHAService svc1 = new DummyHAService(HAServiceState.ACTIVE, svc1Addr);
  DummyHAService svc2 = new DummyHAService(HAServiceState.STANDBY, svc2Addr);
  Mockito.doThrow(new ServiceFailedException("Failed!"))
      .when(svc2.proxy).transitionToActive(anyReqInfo());
  svc1.fencer = svc2.fencer = setupFencer(AlwaysSucceedFencer.class.getName());
  AlwaysSucceedFencer.fenceCalled = 0;

  try {
    doFailover(svc1, svc2, false, false);
    fail("Failed over to service that won't transition to active");
  } catch (FailoverFailedException ffe) {
    // Expected
  }

  // We failed to failover. We did not fence svc1 because it cooperated
  // and we didn't force it, so we failed back to svc1 and fenced svc2.
  // Note svc2 still thinks it's active, that's OK, we fenced it.
  assertEquals(HAServiceState.ACTIVE, svc1.state);
  assertEquals(1, AlwaysSucceedFencer.fenceCalled);
  assertSame(svc2, AlwaysSucceedFencer.fencedSvc);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:24,代码来源:TestFailoverController.java


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