- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKWatcher
类的一些代码示例,展示了ZKWatcher
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKWatcher
类的具体详情如下:
包路径:org.apache.hadoop.hbase.zookeeper.ZKWatcher
类名称:ZKWatcher
[英]Acts as the single ZooKeeper Watcher. One instance of this is instantiated for each Master, RegionServer, and client process.
This is the only class that implements Watcher. Other internal classes which need to be notified of ZooKeeper events must register with the local instance of this watcher via #registerListener.
This class also holds and manages the connection to ZooKeeper. Code to deal with connection related events and exceptions are handled here.
[中]充当单一的动物园管理员和观察者。为每个主进程、RegionServer和客户端进程实例化一个实例。
这是唯一实现Watcher的类。其他需要通知ZooKeeper事件的内部类必须通过#registerListener向该观察者的本地实例注册。
这个类还保存和管理与ZooKeeper的连接。处理连接相关事件和异常的代码在这里处理。
代码示例来源:origin: apache/hbase
@Override
public void setConf(Configuration config) {
// Make my own Configuration. Then I'll have my own connection to zk that
// I can close myself when comes time.
Configuration conf = new Configuration(config);
try {
setConf(conf, new ZKWatcher(conf, "replicationLogCleaner", null));
} catch (IOException e) {
LOG.error("Error while configuring " + this.getClass().getName(), e);
}
}
代码示例来源:origin: apache/hbase
private static void resetAcls(final Configuration conf, boolean eraseAcls)
throws Exception {
ZKWatcher zkw = new ZKWatcher(conf, "ZKAclReset", null);
try {
LOG.info((eraseAcls ? "Erase" : "Set") + " HBase ACLs for " +
zkw.getQuorum() + " " + zkw.getZNodePaths().baseZNode);
resetAcls(zkw, zkw.getZNodePaths().baseZNode, eraseAcls);
} finally {
zkw.close();
}
}
代码示例来源:origin: apache/hbase
@Override
public void checkTaskStillAvailable(String path) {
// A negative retry count will lead to ignoring all error processing.
this.watcher
.getRecoverableZooKeeper()
.getZooKeeper()
.getData(path, this.watcher, new GetDataAsyncCallback(),
Long.valueOf(-1) /* retry count */);
SplitLogCounters.tot_mgr_get_data_queued.increment();
}
代码示例来源: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 HFileArchiveManager(Connection connection, Configuration conf)
throws ZooKeeperConnectionException, IOException {
this.zooKeeper = new ZKWatcher(conf, "hfileArchiveManager-on-" + connection.toString(),
connection);
this.archiveZnode = ZKTableArchiveClient.getArchiveZNode(this.zooKeeper.getConfiguration(),
this.zooKeeper);
}
代码示例来源:origin: apache/hbase
/**
* Get the authentication token of the user for the cluster specified in the configuration
* @return null if the user does not have the token, otherwise the auth token for the cluster.
*/
private static Token<AuthenticationTokenIdentifier> getAuthToken(Configuration conf, User user)
throws IOException, InterruptedException {
ZKWatcher zkw = new ZKWatcher(conf, "TokenUtil-getAuthToken", null);
try {
String clusterId = ZKClusterId.readClusterIdZNode(zkw);
if (clusterId == null) {
throw new IOException("Failed to get cluster ID");
}
return new AuthenticationTokenSelector().selectToken(new Text(clusterId), user.getTokens());
} catch (KeeperException e) {
throw new IOException(e);
} finally {
zkw.close();
}
}
代码示例来源:origin: apache/hbase
/**
* Creates a cluster status tracker.
*
* <p>After construction, use {@link #start} to kick off tracking.
*
* @param watcher reference to the {@link ZKWatcher} which also contains configuration and
* constants
* @param abortable used to abort if a fatal error occurs
*/
public ClusterStatusTracker(ZKWatcher watcher, Abortable abortable) {
super(watcher, watcher.getZNodePaths().clusterStateZNode, abortable);
}
代码示例来源: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
@After
public void tearDown()
throws KeeperException, ZooKeeperConnectionException, IOException {
// Make sure zk is clean before we run the next test.
ZKWatcher zkw = new ZKWatcher(TESTUTIL.getConfiguration(),
"@Before", new Abortable() {
@Override
public void abort(String why, Throwable e) {
throw new RuntimeException(why, e);
}
@Override
public boolean isAborted() {
return false;
}
});
ZKUtil.deleteNodeRecursively(zkw, zkw.getZNodePaths().baseZNode);
zkw.close();
}
代码示例来源:origin: apache/hbase
/**
* Stop this tracker and the passed zookeeper
*/
public void stop() {
if (this.stopped) return;
this.stopped = true;
this.watcher.close();
}
}
代码示例来源:origin: apache/hbase
private void testZNodeACLs() throws IOException, KeeperException, InterruptedException {
ZKWatcher watcher = new ZKWatcher(conf, "IntegrationTestZnodeACLs", null);
RecoverableZooKeeper zk = ZKUtil.connect(this.conf, watcher);
String baseZNode = watcher.getZNodePaths().baseZNode;
LOG.info("");
LOG.info("***********************************************************************************");
LOG.info("Checking ZK permissions, root znode: " + baseZNode);
LOG.info("***********************************************************************************");
LOG.info("");
checkZnodePermsRecursive(watcher, zk, baseZNode);
LOG.info("Checking ZK permissions: SUCCESS");
}
代码示例来源: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;
}
代码示例来源: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
/**
* @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
try {
ZKWatcher zkw = TEST_UTIL.getZooKeeperWatcher();
List<String> servers = ZKUtil.listChildrenNoWatch(zkw, zkw.getZNodePaths().rsZNode);
server.startsWith(hostName.toLowerCase(Locale.ROOT)+","));
zkw.close();
} finally {
TEST_UTIL.shutdownMiniCluster();
代码示例来源:origin: apache/hbase
/**
* Delete the specified node with the specified version. Sets no watches.
* Throws all exceptions.
*/
public static boolean deleteNode(ZKWatcher zkw, String node,
int version)
throws KeeperException {
try {
zkw.getRecoverableZooKeeper().delete(node, version);
return true;
} catch(KeeperException.BadVersionException bve) {
return false;
} catch(InterruptedException ie) {
zkw.interruptedException(ie);
return false;
}
}
代码示例来源:origin: apache/hbase
private static byte[] getDataInternal(ZKWatcher zkw, String znode, Stat stat,
boolean watcherSet)
throws KeeperException {
try {
byte [] data = zkw.getRecoverableZooKeeper().getData(znode, zkw, stat);
logRetrievedMsg(zkw, znode, data, watcherSet);
return data;
} catch (KeeperException.NoNodeException e) {
// This log can get pretty annoying when we cycle on 100ms waits.
// Enable trace if you really want to see it.
LOG.trace(zkw.prefix("Unable to get data of znode " + znode + " " +
"because node does not exist (not an error)"));
return null;
} catch (KeeperException e) {
LOG.warn(zkw.prefix("Unable to get data of znode " + znode), e);
zkw.keeperException(e);
return null;
} catch (InterruptedException e) {
LOG.warn(zkw.prefix("Unable to get data of znode " + znode), e);
zkw.interruptedException(e);
return null;
}
}
代码示例来源:origin: apache/hbase
/**
* Get znode data. Does not set a watcher.
*
* @return ZNode data, null if the node does not exist or if there is an error.
*/
public static byte [] getData(ZKWatcher zkw, String znode)
throws KeeperException, InterruptedException {
try {
byte [] data = zkw.getRecoverableZooKeeper().getData(znode, null, null);
logRetrievedMsg(zkw, znode, data, false);
return data;
} catch (KeeperException.NoNodeException e) {
LOG.debug(zkw.prefix("Unable to get data of znode " + znode + " " +
"because node does not exist (not an error)"));
return null;
} catch (KeeperException e) {
LOG.warn(zkw.prefix("Unable to get data of znode " + znode), e);
zkw.keeperException(e);
return null;
}
}
代码示例来源:origin: apache/hbase
if (zkw.getConfiguration().get("hbase.zookeeper.useMulti") != null) {
LOG.warn("hbase.zookeeper.useMulti is deprecated. Default to true always.");
zkw.getRecoverableZooKeeper().multi(zkOps);
} catch (KeeperException ke) {
switch (ke.code()) {
zkw.interruptedException(ie);
代码示例来源:origin: apache/hbase
public static ArrayList<ACL> createACL(ZKWatcher zkw, String node,
boolean isSecureZooKeeper) {
if (!node.startsWith(zkw.getZNodePaths().baseZNode)) {
return Ids.OPEN_ACL_UNSAFE;
ArrayList<ACL> acls = new ArrayList<>();
String[] superUsers = zkw.getConfiguration().getStrings(Superusers.SUPERUSER_CONF_KEY);
String hbaseUser = null;
try {
if (zkw.getZNodePaths().isClientReadable(node)) {
acls.addAll(Ids.CREATOR_ALL_ACL);
acls.addAll(Ids.READ_ACL_UNSAFE);
发出时Delete对于 hbase,我知道它不会立即删除数据。但是什么时候删除数据,我的意思是,物理上? 最佳答案 当您向 HBase 写入内容时,它会存储在内存存储 (RAM) 中,然后再写入磁盘。
同一行的列族属于同一个 RegionServer。 那么,这里的问题是一个 RegionServer 会在不同的机器上存储不同的列族吗? 最佳答案 不一定,但在某些时候它会。这是基本 HBase 架构
如果我想插入表格: row | fam:qualifier | timestamp | value 1 | foo:bar | 12345 | 2 1 | foo:bar | 12346 | 3 1
有时我想退出我在 HBase shell 中运行的命令,例如扫描操作通常需要太多时间。 所以我想停止运行这个命令,但我不想退出 HBase shell。 我常用的停止运行命令的方式,我使用了Ctrl+
有没有办法设置 Hbase 以便我们可以在同一个集群中创建多个数据库? 最佳答案 只是为了刷新主题:http://hbase.apache.org/book.html#namespace 5.3.1.
怎么看version的 hbase我在用? 你能下命令吗? 最佳答案 hbase version命令行界面中的命令给出了 version的 hbase正在使用中。 以下是来自 Cloudera 的两个
高级问题: HBase 是否对所有分布(因此不是实现的工件)通用的每行施加了最大大小,无论是在 方面吗?字节存储 或在 方面细胞数 ? 如果是这样: 限制是什么? 极限存在的原因是什么? 限制在哪里记
假设,假设我在数据仓库设置中有一个星型模式。 有一个非常非常长的事实表(想想几十亿到几万亿行)和几个低基数维度表(想想 100 个维度表)。每个事实表外键 指向一个维度表的主键是位图索引的。每个维度表
版本:Hadoop: 2.0.0-cdh4.3.1 HBase: 0.94.6-cdh4.3.1 我正在运行 cloudera quick start vm,这是我的小型远程 HBase Java 客
我正在尝试以完全分布式模式配置 HBase。 (使用 Ubuntu 12.04,Apache Hadoop 2.2(以伪模式运行,HBase 版本 0.98) 以下是我的 bashrc 设置: exp
我想知道如何正确配置 hbase.zookeeper.quorum 以将 zookeeper 实例指向集群模式。 最佳答案 hbase.zookeeper.quorum 属性是运行 ZooKeeper
我想知道如何正确配置 hbase.zookeeper.quorum 以将 zookeeper 实例指向集群模式。 最佳答案 hbase.zookeeper.quorum 属性是运行 ZooKeeper
我正在尝试对位于 Hbase 中的两个表进行映射连接。我的目的是在hashmap中保留小表的记录并与大表进行比较,一旦匹配,再次将记录写入hbase中的表中。我使用 Mapper 和 Reducer
我正在尝试编写一个程序来连接到 HBase。但是当我执行以下命令时HBaseConfiguration.create();我收到以下错误:. "hbase-default.xml 文件似乎是旧版本的
基于HBase documentation ,再次遵循 Google BigTable 论文的引用,据说这些行是按行键的字典顺序存储的。 很明显,当我们在 rowkey 中有一个字符串或者如果我们将一
我有一个 hbase 表,其中的行键如 row1、row2、row3 .... 和 rowN,我想要的是获取行键从 row100 到 row200 的行,如何编写查询子句或将 hbase 表设计为让查
我正在尝试创建命名空间,但出现类似下面给出的错误 hbase(main):031:0> create namespace 'Aniruddha'
我发现为以下要求建模 HBase 表有困难。 我有一个表“商店”,它存储了商店的详细信息(必胜客)。 我有一个表格“订单”,其中包含交易摘要(总交易金额等...)。 我有另一个表“Order_Item
谁能告诉我如果在不首先禁用表的情况下使用“alter”命令可能影响表结构的可能影响? 据我所知,禁用表意味着关闭与表的所有连接。如果我在不禁用表的情况下使用 alter,可能会发生什么异常情况? 我正
我无法将表从 HBase 导出到 HDFS。下面是错误跟踪。它是相当大的尺寸。还有其他方法可以导出吗? 我使用以下命令导出。我增加了 rpc 超时,但工作仍然失败。 sudo -u hdfs hbas
我是一名优秀的程序员,十分优秀!