本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKLeaderManager
类的一些代码示例,展示了ZKLeaderManager
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKLeaderManager
类的具体详情如下:
包路径:org.apache.hadoop.hbase.zookeeper.ZKLeaderManager
类名称:ZKLeaderManager
[英]Handles coordination of a single "leader" instance among many possible candidates. The first ZKLeaderManager to successfully create the given znode becomes the leader, allowing the instance to continue with whatever processing must be protected. Other ZKLeaderManagerinstances will wait to be notified of changes to the leader znode. If the current master instance fails, the ephemeral leader znode will be removed, and all waiting instances will be notified, with the race to claim the leader znode beginning all over again.
[中]处理多个可能的候选人之间单个“领导者”实例的协调。第一个成功创建给定znode的ZKLeaderManager成为leader,允许实例继续进行必须保护的任何处理。其他ZKLeaderManagerinstances将等待有关leader znode更改的通知。如果当前主实例失败,短暂的前导znode将被删除,并通知所有等待的实例,争夺前导znode的竞赛将重新开始。
代码示例来源:origin: apache/hbase
public LeaderElector(ZKWatcher watcher, String serverName) {
setDaemon(true);
setName("ZKSecretWatcher-leaderElector");
zkLeader = new ZKLeaderManager(watcher,
ZNodePaths.joinZNode(zkWatcher.getRootKeyZNode(), "keymaster"),
Bytes.toBytes(serverName), this);
}
代码示例来源:origin: apache/hbase
@Override
public void run() {
while (!stopped) {
zkLeader.start();
zkLeader.waitToBecomeLeader();
master.set(true);
while (master.get() && !stopped) {
try {
Thread.sleep(10);
} catch (InterruptedException ignored) {}
}
}
}
代码示例来源:origin: apache/hbase
@Override
public void stop(String reason) {
if (stopped) {
return;
}
stopped = true;
// prevent further key generation when stopping
if (isMaster) {
zkLeader.stepDownAsLeader();
}
isMaster = false;
LOG.info("Stopping leader election, because: "+reason);
interrupt();
}
代码示例来源:origin: apache/hbase
@Override
public void nodeDeleted(String path) {
if (leaderZNode.equals(path) && !candidate.isStopped()) {
handleLeaderChange();
}
}
代码示例来源:origin: apache/hbase
@Override
public void nodeCreated(String path) {
if (leaderZNode.equals(path) && !candidate.isStopped()) {
handleLeaderChange();
}
}
代码示例来源:origin: apache/hbase
@Override
public void run() {
zkLeader.start();
zkLeader.waitToBecomeLeader();
isMaster = true;
while (!stopped) {
long now = EnvironmentEdgeManager.currentTime();
// clear any expired
removeExpiredKeys();
long localLastKeyUpdate = getLastKeyUpdate();
if (localLastKeyUpdate + keyUpdateInterval < now) {
// roll a new master key
rollCurrentKey();
}
try {
Thread.sleep(5000);
} catch (InterruptedException ie) {
if (LOG.isDebugEnabled()) {
LOG.debug("Interrupted waiting for next update", ie);
}
}
}
}
}
代码示例来源:origin: apache/hbase
public MockLeader(ZKWatcher watcher, int index) {
setDaemon(true);
setName("TestZKLeaderManager-leader-" + index);
this.index = index;
this.watcher = watcher;
this.zkLeader = new ZKLeaderManager(watcher, LEADER_ZNODE,
Bytes.toBytes(index), this);
}
代码示例来源:origin: apache/hbase
public void abdicate() {
zkLeader.stepDownAsLeader();
master.set(false);
}
代码示例来源:origin: co.cask.hbase/hbase
@Override
public void nodeDeleted(String path) {
if (leaderZNode.equals(path) && !candidate.isStopped()) {
handleLeaderChange();
}
}
代码示例来源:origin: com.aliyun.hbase/alihbase-zookeeper
@Override
public void run() {
while (!stopped) {
zkLeader.start();
zkLeader.waitToBecomeLeader();
master.set(true);
while (master.get() && !stopped) {
try {
Thread.sleep(10);
} catch (InterruptedException ignored) {}
}
}
}
代码示例来源:origin: harbby/presto-connectors
public LeaderElector(ZooKeeperWatcher watcher, String serverName) {
setDaemon(true);
setName("ZKSecretWatcher-leaderElector");
zkLeader = new ZKLeaderManager(watcher,
ZKUtil.joinZNode(zkWatcher.getRootKeyZNode(), "keymaster"),
Bytes.toBytes(serverName), this);
}
代码示例来源:origin: com.aliyun.hbase/alihbase-zookeeper
public void abdicate() {
zkLeader.stepDownAsLeader();
master.set(false);
}
代码示例来源:origin: harbby/presto-connectors
@Override
public void nodeCreated(String path) {
if (leaderZNode.equals(path) && !candidate.isStopped()) {
handleLeaderChange();
}
}
代码示例来源:origin: org.apache.hbase/hbase-zookeeper
@Override
public void run() {
while (!stopped) {
zkLeader.start();
zkLeader.waitToBecomeLeader();
master.set(true);
while (master.get() && !stopped) {
try {
Thread.sleep(10);
} catch (InterruptedException ignored) {}
}
}
}
代码示例来源:origin: com.aliyun.hbase/alihbase-zookeeper
public MockLeader(ZKWatcher watcher, int index) {
setDaemon(true);
setName("TestZKLeaderManager-leader-" + index);
this.index = index;
this.watcher = watcher;
this.zkLeader = new ZKLeaderManager(watcher, LEADER_ZNODE,
Bytes.toBytes(index), this);
}
代码示例来源:origin: org.apache.hbase/hbase-zookeeper
public void abdicate() {
zkLeader.stepDownAsLeader();
master.set(false);
}
代码示例来源:origin: org.apache.hbase/hbase-zookeeper
@Override
public void nodeCreated(String path) {
if (leaderZNode.equals(path) && !candidate.isStopped()) {
handleLeaderChange();
}
}
代码示例来源:origin: harbby/presto-connectors
public void run() {
zkLeader.start();
zkLeader.waitToBecomeLeader();
isMaster = true;
while (!stopped) {
long now = EnvironmentEdgeManager.currentTime();
// clear any expired
removeExpiredKeys();
long localLastKeyUpdate = getLastKeyUpdate();
if (localLastKeyUpdate + keyUpdateInterval < now) {
// roll a new master key
rollCurrentKey();
}
try {
Thread.sleep(5000);
} catch (InterruptedException ie) {
if (LOG.isDebugEnabled()) {
LOG.debug("Interrupted waiting for next update", ie);
}
}
}
}
}
代码示例来源:origin: org.apache.hbase/hbase-zookeeper
public MockLeader(ZKWatcher watcher, int index) {
setDaemon(true);
setName("TestZKLeaderManager-leader-" + index);
this.index = index;
this.watcher = watcher;
this.zkLeader = new ZKLeaderManager(watcher, LEADER_ZNODE,
Bytes.toBytes(index), this);
}
代码示例来源:origin: harbby/presto-connectors
@Override
public void stop(String reason) {
if (stopped) {
return;
}
stopped = true;
// prevent further key generation when stopping
if (isMaster) {
zkLeader.stepDownAsLeader();
}
isMaster = false;
LOG.info("Stopping leader election, because: "+reason);
interrupt();
}
内容来源于网络,如有侵权,请联系作者删除!