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


Java State类代码示例

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


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

示例1: testDontJoinElectionOnDisconnectAndReconnect

import org.apache.hadoop.ha.ActiveStandbyElector.State; //导入依赖的package包/类
@Test(timeout=15000)
public void testDontJoinElectionOnDisconnectAndReconnect() throws Exception {
  electors[0].ensureParentZNode();

  stopServer();
  ActiveStandbyElectorTestUtil.waitForElectorState(
      null, electors[0], State.NEUTRAL);
  startServer();
  waitForServerUp(hostPort, CONNECTION_TIMEOUT);
  // Have to sleep to allow time for the clients to reconnect.
  Thread.sleep(2000);
  Mockito.verify(cbs[0], Mockito.never()).becomeActive();
  Mockito.verify(cbs[1], Mockito.never()).becomeActive();
  checkFatalsAndReset();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:16,代码来源:TestActiveStandbyElectorRealZK.java

示例2: testHandleSessionExpirationOfStandby

import org.apache.hadoop.ha.ActiveStandbyElector.State; //导入依赖的package包/类
@Test(timeout=15000)
public void testHandleSessionExpirationOfStandby() throws Exception {
  // Let elector 0 be active
  electors[0].ensureParentZNode();
  electors[0].joinElection(appDatas[0]);
  ZooKeeperServer zks = getServer(serverFactory);
  ActiveStandbyElectorTestUtil.waitForActiveLockData(null,
      zks, PARENT_DIR, appDatas[0]);
  Mockito.verify(cbs[0], Mockito.timeout(1000)).becomeActive();
  checkFatalsAndReset();
  
  // Let elector 1 be standby
  electors[1].joinElection(appDatas[1]);
  ActiveStandbyElectorTestUtil.waitForElectorState(null, electors[1],
      State.STANDBY);
  
  LOG.info("========================== Expiring standby's session");
  zks.closeSession(electors[1].getZKSessionIdForTests());

  // Should enter neutral mode when disconnected
  Mockito.verify(cbs[1], Mockito.timeout(1000)).enterNeutralMode();

  // Should re-join the election and go back to STANDBY
  ActiveStandbyElectorTestUtil.waitForElectorState(null, electors[1],
      State.STANDBY);
  checkFatalsAndReset();
  
  LOG.info("========================== Quitting election");
  electors[1].quitElection(false);

  // Double check that we don't accidentally re-join the election
  // by quitting elector 0 and ensuring elector 1 doesn't become active
  electors[0].quitElection(false);
  
  // due to receiving the "expired" event.
  Thread.sleep(1000);
  Mockito.verify(cbs[1], Mockito.never()).becomeActive();
  ActiveStandbyElectorTestUtil.waitForActiveLockData(null,
      zks, PARENT_DIR, null);

  checkFatalsAndReset();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:43,代码来源:TestActiveStandbyElectorRealZK.java


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