- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKWatcher.registerListener()
方法的一些代码示例,展示了ZKWatcher.registerListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKWatcher.registerListener()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.zookeeper.ZKWatcher
类名称:ZKWatcher
方法名:registerListener
[英]Register the specified listener to receive ZooKeeper events.
[中]注册指定的侦听器以接收ZooKeeper事件。
代码示例来源:origin: apache/hbase
/**
* @param watcher
* @param sn ServerName
* @param master In an instance of a Master.
*/
ActiveMasterManager(ZKWatcher watcher, ServerName sn, Server master) {
super(watcher);
watcher.registerListener(this);
this.sn = sn;
this.master = master;
}
代码示例来源:origin: apache/hbase
@Override
public void registerListener() {
watcher.registerListener(this);
}
代码示例来源:origin: apache/hbase
/**
* Starts the tracking of whether master is in Maintenance Mode.
*/
public void start() {
watcher.registerListener(this);
update();
}
代码示例来源:origin: apache/hbase
@Override
public void init() throws IOException {
this.zkretries = conf.getLong("hbase.splitlog.zk.retries", DEFAULT_ZK_RETRIES);
this.resubmitThreshold = conf.getLong("hbase.splitlog.max.resubmit", DEFAULT_MAX_RESUBMIT);
this.timeout = conf.getInt(HConstants.HBASE_SPLITLOG_MANAGER_TIMEOUT, DEFAULT_TIMEOUT);
if (this.watcher != null) {
this.watcher.registerListener(this);
lookForOrphans();
}
}
代码示例来源:origin: apache/hbase
public void start() throws KeeperException {
try {
watcher.registerListener(this);
if (ZKUtil.watchAndCheckExists(watcher, aclZNode)) {
try {
executor.submit(new Callable<Void>() {
@Override
public Void call() throws KeeperException {
List<ZKUtil.NodeAndData> existing =
ZKUtil.getChildDataAndWatchForNewChildren(watcher, aclZNode);
if (existing != null) {
refreshNodes(existing);
}
return null;
}
}).get();
} catch (ExecutionException ex) {
if (ex.getCause() instanceof KeeperException) {
throw (KeeperException)ex.getCause();
} else {
throw new RuntimeException(ex.getCause());
}
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
} finally {
initialized.countDown();
}
}
代码示例来源:origin: apache/hbase
private TableHFileArchiveTracker(ZKWatcher watcher, HFileArchiveTableMonitor monitor) {
super(watcher);
watcher.registerListener(this);
this.monitor = monitor;
this.archiveHFileZNode = ZKTableArchiveClient.getArchiveZNode(watcher.getConfiguration(),
watcher);
}
代码示例来源:origin: apache/hbase
public ReplicationTrackerZKImpl(ZKWatcher zookeeper, Abortable abortable, Stoppable stopper) {
this.zookeeper = zookeeper;
this.abortable = abortable;
this.stopper = stopper;
this.zookeeper.registerListener(new OtherRegionServerWatcher(this.zookeeper));
// watch the changes
refreshOtherRegionServersList(true);
}
代码示例来源:origin: apache/hbase
/**
* Starts the syncer
* @throws KeeperException if error occurs when trying to create base nodes on client ZK
*/
public void start() throws KeeperException {
LOG.debug("Starting " + getClass().getSimpleName());
this.watcher.registerListener(this);
// create base znode on remote ZK
ZKUtil.createWithParents(clientZkWatcher, watcher.getZNodePaths().baseZNode);
// set meta znodes for client ZK
Collection<String> nodes = getNodesToWatch();
LOG.debug("Znodes to watch: " + nodes);
// initialize queues and threads
for (String node : nodes) {
BlockingQueue<byte[]> queue = new ArrayBlockingQueue<>(1);
queues.put(node, queue);
Thread updater = new ClientZkUpdater(node, queue);
updater.setDaemon(true);
updater.start();
watchAndCheckExists(node);
}
}
代码示例来源:origin: apache/hbase
public void start() throws KeeperException {
watcher.registerListener(this);
// make sure the base node exists
ZKUtil.createWithParents(watcher, keysParentZNode);
if (ZKUtil.watchAndCheckExists(watcher, keysParentZNode)) {
List<ZKUtil.NodeAndData> nodes =
ZKUtil.getChildDataAndWatchForNewChildren(watcher, keysParentZNode);
refreshNodes(nodes);
}
}
代码示例来源:origin: apache/hbase
/**
* Starts the tracking of the node in ZooKeeper.
*
* <p>Use {@link #blockUntilAvailable()} to block until the node is available
* or {@link #getData(boolean)} to get the data of the node if it is available.
*/
public synchronized void start() {
this.watcher.registerListener(this);
try {
if(ZKUtil.watchAndCheckExists(watcher, node)) {
byte [] data = ZKUtil.getDataAndWatch(watcher, node);
if(data != null) {
this.data = data;
} else {
// It existed but now does not, try again to ensure a watch is set
LOG.debug("Try starting again because there is no data from " + node);
start();
}
}
} catch (KeeperException e) {
abortable.abort("Unexpected exception during initialization, aborting", e);
}
}
代码示例来源:origin: apache/hbase
public WaitToGetDataThread(ZKWatcher zk, String node) {
tracker = new TestTracker(zk, node, null);
tracker.start();
zk.registerListener(tracker);
hasData = false;
}
代码示例来源:origin: apache/hbase
watcher.registerListener(this);
synchronized (this) {
List<String> servers =
代码示例来源:origin: apache/hbase
/**
* Starts the tracking of draining RegionServers.
*
* <p>All Draining RSs will be tracked after this method is called.
*
* @throws KeeperException
*/
public void start() throws KeeperException, IOException {
watcher.registerListener(this);
// Add a ServerListener to check if a server is draining when it's added.
serverManager.registerListener(new ServerListener() {
@Override
public void serverAdded(ServerName sn) {
if (drainingServers.contains(sn)){
serverManager.addServerToDrainList(sn);
}
}
});
List<String> servers =
ZKUtil.listChildrenAndWatchThem(watcher, watcher.getZNodePaths().drainingZNode);
add(servers);
}
代码示例来源:origin: apache/hbase
/**
* Closes the current ZKW (if not null) and creates a new one
* @throws IOException If anything goes wrong connecting
*/
synchronized void reloadZkWatcher() throws IOException {
if (zkw != null) zkw.close();
zkw = new ZKWatcher(ctx.getConfiguration(),
"connection to cluster: " + ctx.getPeerId(), this);
getZkw().registerListener(new PeerRegionServerListener(this));
}
代码示例来源:origin: apache/hbase
public void start() {
try {
watcher.registerListener(this);
String parent = ZKUtil.getParent(leaderZNode);
if (ZKUtil.checkExists(watcher, parent) < 0) {
ZKUtil.createWithParents(watcher, parent);
}
} catch (KeeperException ke) {
watcher.abort("Unhandled zk exception when starting", ke);
candidate.stop("Unhandled zk exception starting up: "+ke.getMessage());
}
}
代码示例来源:origin: apache/hbase
public void start() throws KeeperException {
watcher.registerListener(this);
ZKUtil.createWithParents(watcher, labelZnode);
ZKUtil.createWithParents(watcher, userAuthsZnode);
byte[] data = ZKUtil.getDataAndWatch(watcher, labelZnode);
if (data != null && data.length > 0) {
refreshVisibilityLabelsCache(data);
}
data = ZKUtil.getDataAndWatch(watcher, userAuthsZnode);
if (data != null && data.length > 0) {
refreshUserAuthsCache(data);
}
}
代码示例来源:origin: apache/hbase
public DummyMaster(ZKWatcher zk, ServerName master) {
this.clusterStatusTracker =
new ClusterStatusTracker(zk, this);
clusterStatusTracker.start();
this.activeMasterManager =
new ActiveMasterManager(zk, master, this);
zk.registerListener(activeMasterManager);
}
代码示例来源:origin: apache/hbase
/**
* Top-level watcher/controller for procedures across the cluster.
* <p>
* On instantiation, this ensures the procedure znodes exist. This however requires the passed in
* watcher has been started.
* @param watcher watcher for the cluster ZK. Owned by <tt>this</tt> and closed via
* {@link #close()}
* @param procDescription name of the znode describing the procedure to run
* @throws KeeperException when the procedure znodes cannot be created
*/
public ZKProcedureUtil(ZKWatcher watcher, String procDescription)
throws KeeperException {
super(watcher);
// make sure we are listening for events
watcher.registerListener(this);
// setup paths for the zknodes used in procedures
this.baseZNode = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, procDescription);
acquiredZnode = ZNodePaths.joinZNode(baseZNode, ACQUIRED_BARRIER_ZNODE_DEFAULT);
reachedZnode = ZNodePaths.joinZNode(baseZNode, REACHED_BARRIER_ZNODE_DEFAULT);
abortZnode = ZNodePaths.joinZNode(baseZNode, ABORT_ZNODE_DEFAULT);
// first make sure all the ZK nodes exist
// make sure all the parents exist (sometimes not the case in tests)
ZKUtil.createWithParents(watcher, acquiredZnode);
// regular create because all the parents exist
ZKUtil.createAndFailSilent(watcher, reachedZnode);
ZKUtil.createAndFailSilent(watcher, abortZnode);
}
代码示例来源:origin: apache/hbase
private String submitTaskAndWait(TaskBatch batch, String name) throws KeeperException,
InterruptedException {
String tasknode = ZKSplitLog.getEncodedNodeName(zkw, name);
NodeCreationListener listener = new NodeCreationListener(zkw, tasknode);
zkw.registerListener(listener);
ZKUtil.watchAndCheckExists(zkw, tasknode);
slm.enqueueSplitTask(name, batch);
assertEquals(1, batch.installed);
assertTrue(findOrCreateOrphanTask(tasknode).batch == batch);
assertEquals(1L, tot_mgr_node_create_queued.sum());
LOG.debug("waiting for task node creation");
listener.waitForCreation();
LOG.debug("task created");
return tasknode;
}
代码示例来源:origin: apache/hbase
/**
* create an address tracker instance
* @param sn if not-null set the active master
* @param infoPort if there is an active master, set its info port.
*/
private MasterAddressTracker setupMasterTracker(final ServerName sn, final int infoPort)
throws Exception {
ZKWatcher zk = new ZKWatcher(TEST_UTIL.getConfiguration(),
name.getMethodName(), null);
ZKUtil.createAndFailSilent(zk, zk.getZNodePaths().baseZNode);
// Should not have a master yet
MasterAddressTracker addressTracker = new MasterAddressTracker(zk, null);
addressTracker.start();
assertFalse(addressTracker.hasMaster());
zk.registerListener(addressTracker);
// Use a listener to capture when the node is actually created
NodeCreationListener listener = new NodeCreationListener(zk,
zk.getZNodePaths().masterAddressZNode);
zk.registerListener(listener);
if (sn != null) {
LOG.info("Creating master node");
MasterAddressTracker.setMasterAddress(zk, zk.getZNodePaths().masterAddressZNode,
sn, infoPort);
// Wait for the node to be created
LOG.info("Waiting for master address manager to be notified");
listener.waitForCreation();
LOG.info("Master node created");
}
return addressTracker;
}
本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKWatcher.abort()方法的一些代码示例,展示了ZKWatcher.abort()的具体用法。这些代
本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKWatcher.getQuorum()方法的一些代码示例,展示了ZKWatcher.getQuorum()的
本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKWatcher.isSuperUserId()方法的一些代码示例,展示了ZKWatcher.isSuperU
本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKWatcher.getConfiguration()方法的一些代码示例,展示了ZKWatcher.getCo
本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKWatcher.()方法的一些代码示例,展示了ZKWatcher.()的具体用法。这些代码示例主要来源于Gi
本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKWatcher.close()方法的一些代码示例,展示了ZKWatcher.close()的具体用法。这些代
本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKWatcher.getZNodePaths()方法的一些代码示例,展示了ZKWatcher.getZNode
本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKWatcher.getRecoverableZooKeeper()方法的一些代码示例,展示了ZKWatche
本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKWatcher.registerListener()方法的一些代码示例,展示了ZKWatcher.regis
我是一名优秀的程序员,十分优秀!