gpt4 book ai didi

org.apache.hadoop.ha.ZKFCProtocol.cedeActive()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 02:56:49 26 4
gpt4 key购买 nike

本文整理了Java中org.apache.hadoop.ha.ZKFCProtocol.cedeActive()方法的一些代码示例,展示了ZKFCProtocol.cedeActive()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKFCProtocol.cedeActive()方法的具体详情如下:
包路径:org.apache.hadoop.ha.ZKFCProtocol
类名称:ZKFCProtocol
方法名:cedeActive

ZKFCProtocol.cedeActive介绍

[英]Request that this service yield from the active node election for the specified time period. If the node is not currently active, it simply prevents any attempts to become active for the specified time period. Otherwise, it first tries to transition the local service to standby state, and then quits the election. If the attempt to transition to standby succeeds, then the ZKFC receiving this RPC will delete its own breadcrumb node in ZooKeeper. Thus, the next node to become active will not run any fencing process. Otherwise, the breadcrumb will be left, such that the next active will fence this node. After the specified time period elapses, the node will attempt to re-join the election, provided that its service is healthy. If the node has previously been instructed to cede active, and is still within the specified time period, the later command's time period will take precedence, resetting the timer. A call to cedeActive which specifies a 0 or negative time period will allow the target node to immediately rejoin the election, so long as it is healthy.
[中]请求此服务在指定的时间段内从活动节点选择中产生。如果该节点当前未处于活动状态,它只会在指定的时间段内阻止任何变为活动状态的尝试。否则,它会首先尝试将本地服务转换为待机状态,然后退出选举。如果尝试转换到待机状态成功,则接收此RPC的ZKFC将删除ZooKeeper中自己的面包屑节点。因此,下一个激活的节点将不会运行任何防护过程。否则,面包屑将被保留,以便下一个活动节点将隔离此节点。在指定的时间段过后,节点将尝试重新加入选举,前提是其服务正常。如果节点之前已被指示退出活动状态,且仍在指定的时间段内,则将以后面命令的时间段为准,重置计时器。对cedeActive的调用指定了0或负的时间段,只要目标节点正常,它将允许目标节点立即重新加入选举。

代码示例

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * Ask the remote zkfc to cede its active status and wait for the specified
 * timeout before attempting to claim leader status.
 * @param remote node to ask
 * @param timeout amount of time to cede
 * @return the {@link ZKFCProtocol} used to talk to the ndoe
 * @throws IOException
 */
private ZKFCProtocol cedeRemoteActive(HAServiceTarget remote, int timeout)
 throws IOException {
 LOG.info("Asking " + remote + " to cede its active state for "
       + timeout + "ms");
 ZKFCProtocol oldZkfc = remote.getZKFCProxy(conf, timeout);
 oldZkfc.cedeActive(timeout);
 return oldZkfc;
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

@Override
public CedeActiveResponseProto cedeActive(RpcController controller,
  CedeActiveRequestProto request) throws ServiceException {
 try {
  server.cedeActive(request.getMillisToCede());
  return CedeActiveResponseProto.getDefaultInstance();
 } catch (IOException e) {
  throw new ServiceException(e);
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

zkfc.cedeActive(-1);

代码示例来源:origin: ch.cern.hadoop/hadoop-common

@Override
public CedeActiveResponseProto cedeActive(RpcController controller,
  CedeActiveRequestProto request) throws ServiceException {
 try {
  server.cedeActive(request.getMillisToCede());
  return CedeActiveResponseProto.getDefaultInstance();
 } catch (IOException e) {
  throw new ServiceException(e);
 }
}

代码示例来源:origin: io.prestosql.hadoop/hadoop-apache

@Override
public CedeActiveResponseProto cedeActive(RpcController controller,
  CedeActiveRequestProto request) throws ServiceException {
 try {
  server.cedeActive(request.getMillisToCede());
  return CedeActiveResponseProto.getDefaultInstance();
 } catch (IOException e) {
  throw new ServiceException(e);
 }
}

代码示例来源:origin: io.hops/hadoop-common

@Override
public CedeActiveResponseProto cedeActive(RpcController controller,
  CedeActiveRequestProto request) throws ServiceException {
 try {
  server.cedeActive(request.getMillisToCede());
  return CedeActiveResponseProto.getDefaultInstance();
 } catch (IOException e) {
  throw new ServiceException(e);
 }
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

@Override
public CedeActiveResponseProto cedeActive(RpcController controller,
  CedeActiveRequestProto request) throws ServiceException {
 try {
  server.cedeActive(request.getMillisToCede());
  return CedeActiveResponseProto.getDefaultInstance();
 } catch (IOException e) {
  throw new ServiceException(e);
 }
}

代码示例来源:origin: io.hops/hadoop-common

timeout + "ms");
ZKFCProtocol oldZkfc = oldActive.getZKFCProxy(conf, timeout);
oldZkfc.cedeActive(timeout);
oldZkfc.cedeActive(-1);

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

timeout + "ms");
ZKFCProtocol oldZkfc = oldActive.getZKFCProxy(conf, timeout);
oldZkfc.cedeActive(timeout);
oldZkfc.cedeActive(-1);

代码示例来源:origin: ch.cern.hadoop/hadoop-common

timeout + "ms");
ZKFCProtocol oldZkfc = oldActive.getZKFCProxy(conf, timeout);
oldZkfc.cedeActive(timeout);
oldZkfc.cedeActive(-1);

代码示例来源:origin: io.prestosql.hadoop/hadoop-apache

timeout + "ms");
ZKFCProtocol oldZkfc = oldActive.getZKFCProxy(conf, timeout);
oldZkfc.cedeActive(timeout);
oldZkfc.cedeActive(-1);

代码示例来源:origin: ch.cern.hadoop/hadoop-common

/**
 * 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);
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

proxy.cedeActive(3000);
long et = Time.now();
assertTrue("RPC to cedeActive took " + (et - st) + " ms",

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com