- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.hadoop.hbase.security.token.ZKSecretWatcher
类的一些代码示例,展示了ZKSecretWatcher
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKSecretWatcher
类的具体详情如下:
包路径:org.apache.hadoop.hbase.security.token.ZKSecretWatcher
类名称:ZKSecretWatcher
[英]Synchronizes token encryption keys across cluster nodes.
[中]跨群集节点同步令牌加密密钥。
代码示例来源:origin: apache/hbase
/**
* Create a new secret manager instance for generating keys.
* @param conf Configuration to use
* @param zk Connection to zookeeper for handling leader elections
* @param keyUpdateInterval Time (in milliseconds) between rolling a new master key for token signing
* @param tokenMaxLifetime Maximum age (in milliseconds) before a token expires and is no longer valid
*/
/* TODO: Restrict access to this constructor to make rogues instances more difficult.
* For the moment this class is instantiated from
* org.apache.hadoop.hbase.ipc.SecureServer so public access is needed.
*/
public AuthenticationTokenSecretManager(Configuration conf,
ZKWatcher zk, String serverName,
long keyUpdateInterval, long tokenMaxLifetime) {
this.zkWatcher = new ZKSecretWatcher(conf, zk, this);
this.keyUpdateInterval = keyUpdateInterval;
this.tokenMaxLifetime = tokenMaxLifetime;
this.leaderElector = new LeaderElector(zk, serverName);
this.name = NAME_PREFIX+serverName;
this.clusterId = new ZKClusterId(zk, zk);
}
代码示例来源:origin: apache/hbase
if(zkWatcher.getWatcher().isAborted()) {
LOG.error("ZKWatcher is abort");
throw new InvalidToken("Token keys could not be sync from zookeeper"
zkWatcher.refreshKeys();
if (LOG.isDebugEnabled()) {
LOG.debug("Sync token keys from zookeeper");
代码示例来源:origin: apache/hbase
synchronized void rollCurrentKey() {
if (!leaderElector.isMaster()) {
LOG.info("Skipping rollCurrentKey() because not running as master.");
return;
}
long now = EnvironmentEdgeManager.currentTime();
AuthenticationKey prev = currentKey;
AuthenticationKey newKey = new AuthenticationKey(++idSeq,
Long.MAX_VALUE, // don't allow to expire until it's replaced by a new key
generateSecret());
allKeys.put(newKey.getKeyId(), newKey);
currentKey = newKey;
zkWatcher.addKeyToZK(newKey);
lastKeyUpdate = now;
if (prev != null) {
// make sure previous key is still stored
prev.setExpiration(now + tokenMaxLifetime);
allKeys.put(prev.getKeyId(), prev);
zkWatcher.updateKeyInZK(prev);
}
}
代码示例来源:origin: apache/hbase
@Test
public void testRefreshKeys() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
ZKWatcher zk = newZK(conf, "127.0.0.1", new MockAbortable());
AuthenticationTokenSecretManager keyManager =
new AuthenticationTokenSecretManager(conf, zk, "127.0.0.1",
60 * 60 * 1000, 60 * 1000);
ZKSecretWatcher watcher = new ZKSecretWatcher(conf, zk, keyManager);
ZKUtil.deleteChildrenRecursively(zk, watcher.getKeysParentZNode());
Integer[] keys = { 1, 2, 3, 4, 5, 6 };
for (Integer key : keys) {
AuthenticationKey ak = new AuthenticationKey(key,
System.currentTimeMillis() + 600 * 1000, null);
ZKUtil.createWithParents(zk,
ZNodePaths.joinZNode(watcher.getKeysParentZNode(), key.toString()),
Writables.getBytes(ak));
}
Assert.assertNull(keyManager.getCurrentKey());
watcher.refreshKeys();
for (Integer key : keys) {
Assert.assertNotNull(keyManager.getKey(key.intValue()));
}
}
}
代码示例来源:origin: apache/hbase
@Override
public void nodeCreated(String path) {
if (path.equals(keysParentZNode)) {
try {
List<ZKUtil.NodeAndData> nodes =
ZKUtil.getChildDataAndWatchForNewChildren(watcher, keysParentZNode);
refreshNodes(nodes);
} catch (KeeperException ke) {
LOG.error(HBaseMarkers.FATAL, "Error reading data from zookeeper", ke);
watcher.abort("Error reading new key znode "+path, ke);
}
}
}
代码示例来源:origin: apache/hbase
public void removeKeyFromZK(AuthenticationKey key) {
String keyZNode = getKeyNode(key.getKeyId());
try {
ZKUtil.deleteNode(watcher, keyZNode);
} catch (KeeperException.NoNodeException nne) {
LOG.error("Non-existent znode "+keyZNode+" for key "+key.getKeyId(), nne);
} catch (KeeperException ke) {
LOG.error(HBaseMarkers.FATAL, "Failed removing znode "+keyZNode+" for key "+
key.getKeyId(), ke);
watcher.abort("Unhandled zookeeper error removing znode "+keyZNode+
" for key "+key.getKeyId(), ke);
}
}
代码示例来源:origin: apache/hbase
public void start() {
try {
// populate any existing keys
this.zkWatcher.start();
// try to become leader
this.leaderElector.start();
} catch (KeeperException ke) {
LOG.error("ZooKeeper initialization failed", ke);
}
}
代码示例来源: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
synchronized void removeExpiredKeys() {
if (!leaderElector.isMaster()) {
LOG.info("Skipping removeExpiredKeys() because not running as master.");
return;
}
long now = EnvironmentEdgeManager.currentTime();
Iterator<AuthenticationKey> iter = allKeys.values().iterator();
while (iter.hasNext()) {
AuthenticationKey key = iter.next();
if (key.getExpiration() < now) {
if (LOG.isDebugEnabled()) {
LOG.debug("Removing expired key "+key.getKeyId());
}
iter.remove();
zkWatcher.removeKeyFromZK(key);
}
}
}
代码示例来源:origin: org.apache.hbase/hbase-server
@Test
public void testRefreshKeys() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
ZKWatcher zk = newZK(conf, "127.0.0.1", new MockAbortable());
AuthenticationTokenSecretManager keyManager =
new AuthenticationTokenSecretManager(conf, zk, "127.0.0.1",
60 * 60 * 1000, 60 * 1000);
ZKSecretWatcher watcher = new ZKSecretWatcher(conf, zk, keyManager);
ZKUtil.deleteChildrenRecursively(zk, watcher.getKeysParentZNode());
Integer[] keys = { 1, 2, 3, 4, 5, 6 };
for (Integer key : keys) {
AuthenticationKey ak = new AuthenticationKey(key,
System.currentTimeMillis() + 600 * 1000, null);
ZKUtil.createWithParents(zk,
ZNodePaths.joinZNode(watcher.getKeysParentZNode(), key.toString()),
Writables.getBytes(ak));
}
Assert.assertNull(keyManager.getCurrentKey());
watcher.refreshKeys();
for (Integer key : keys) {
Assert.assertNotNull(keyManager.getKey(key.intValue()));
}
}
}
代码示例来源:origin: apache/hbase
@Override
public void nodeChildrenChanged(String path) {
if (path.equals(keysParentZNode)) {
// keys changed
try {
List<ZKUtil.NodeAndData> nodes =
ZKUtil.getChildDataAndWatchForNewChildren(watcher, keysParentZNode);
refreshNodes(nodes);
} catch (KeeperException ke) {
LOG.error(HBaseMarkers.FATAL, "Error reading data from zookeeper", ke);
watcher.abort("Error reading changed keys from zookeeper", ke);
}
}
}
代码示例来源:origin: apache/hbase
public void addKeyToZK(AuthenticationKey key) {
String keyZNode = getKeyNode(key.getKeyId());
try {
byte[] keyData = Writables.getBytes(key);
// TODO: is there any point in retrying beyond what ZK client does?
ZKUtil.createSetData(watcher, keyZNode, keyData);
} catch (KeeperException ke) {
LOG.error(HBaseMarkers.FATAL, "Unable to synchronize master key "+key.getKeyId()+
" to znode "+keyZNode, ke);
watcher.abort("Unable to synchronize secret key "+
key.getKeyId()+" in zookeeper", ke);
} catch (IOException ioe) {
// this can only happen from an error serializing the key
watcher.abort("Failed serializing key "+key.getKeyId(), ioe);
}
}
代码示例来源:origin: harbby/presto-connectors
public void start() {
try {
// populate any existing keys
this.zkWatcher.start();
// try to become leader
this.leaderElector.start();
} catch (KeeperException ke) {
LOG.error("Zookeeper initialization failed", ke);
}
}
代码示例来源: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: harbby/presto-connectors
synchronized void removeExpiredKeys() {
if (!leaderElector.isMaster()) {
LOG.info("Skipping removeExpiredKeys() because not running as master.");
return;
}
long now = EnvironmentEdgeManager.currentTime();
Iterator<AuthenticationKey> iter = allKeys.values().iterator();
while (iter.hasNext()) {
AuthenticationKey key = iter.next();
if (key.getExpiration() < now) {
if (LOG.isDebugEnabled()) {
LOG.debug("Removing expired key "+key.getKeyId());
}
iter.remove();
zkWatcher.removeKeyFromZK(key);
}
}
}
代码示例来源:origin: harbby/presto-connectors
if(zkWatcher.getWatcher().isAborted()) {
LOG.error("ZookeeperWatcher is abort");
throw new InvalidToken("Token keys could not be sync from zookeeper"
zkWatcher.refreshKeys();
if (LOG.isDebugEnabled()) {
LOG.debug("Sync token keys from zookeeper");
代码示例来源:origin: apache/hbase
/**
* refresh keys
*/
synchronized void refreshKeys() {
try {
List<ZKUtil.NodeAndData> nodes =
ZKUtil.getChildDataAndWatchForNewChildren(watcher, keysParentZNode);
refreshNodes(nodes);
} catch (KeeperException ke) {
LOG.error(HBaseMarkers.FATAL, "Error reading data from zookeeper", ke);
watcher.abort("Error reading changed keys from zookeeper", ke);
}
}
代码示例来源:origin: harbby/presto-connectors
synchronized void rollCurrentKey() {
if (!leaderElector.isMaster()) {
LOG.info("Skipping rollCurrentKey() because not running as master.");
return;
}
long now = EnvironmentEdgeManager.currentTime();
AuthenticationKey prev = currentKey;
AuthenticationKey newKey = new AuthenticationKey(++idSeq,
Long.MAX_VALUE, // don't allow to expire until it's replaced by a new key
generateSecret());
allKeys.put(newKey.getKeyId(), newKey);
currentKey = newKey;
zkWatcher.addKeyToZK(newKey);
lastKeyUpdate = now;
if (prev != null) {
// make sure previous key is still stored
prev.setExpiration(now + tokenMaxLifetime);
allKeys.put(prev.getKeyId(), prev);
zkWatcher.updateKeyInZK(prev);
}
}
代码示例来源:origin: apache/hbase
public void updateKeyInZK(AuthenticationKey key) {
String keyZNode = getKeyNode(key.getKeyId());
try {
byte[] keyData = Writables.getBytes(key);
try {
ZKUtil.updateExistingNodeData(watcher, keyZNode, keyData, -1);
} catch (KeeperException.NoNodeException ne) {
// node was somehow removed, try adding it back
ZKUtil.createSetData(watcher, keyZNode, keyData);
}
} catch (KeeperException ke) {
LOG.error(HBaseMarkers.FATAL, "Unable to update master key "+key.getKeyId()+
" in znode "+keyZNode);
watcher.abort("Unable to synchronize secret key "+
key.getKeyId()+" in zookeeper", ke);
} catch (IOException ioe) {
// this can only happen from an error serializing the key
watcher.abort("Failed serializing key "+key.getKeyId(), ioe);
}
}
代码示例来源:origin: harbby/presto-connectors
/**
* Create a new secret manager instance for generating keys.
* @param conf Configuration to use
* @param zk Connection to zookeeper for handling leader elections
* @param keyUpdateInterval Time (in milliseconds) between rolling a new master key for token signing
* @param tokenMaxLifetime Maximum age (in milliseconds) before a token expires and is no longer valid
*/
/* TODO: Restrict access to this constructor to make rogues instances more difficult.
* For the moment this class is instantiated from
* org.apache.hadoop.hbase.ipc.SecureServer so public access is needed.
*/
public AuthenticationTokenSecretManager(Configuration conf,
ZooKeeperWatcher zk, String serverName,
long keyUpdateInterval, long tokenMaxLifetime) {
this.zkWatcher = new ZKSecretWatcher(conf, zk, this);
this.keyUpdateInterval = keyUpdateInterval;
this.tokenMaxLifetime = tokenMaxLifetime;
this.leaderElector = new LeaderElector(zk, serverName);
this.name = NAME_PREFIX+serverName;
this.clusterId = new ZKClusterId(zk, zk);
}
发出时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
我是一名优秀的程序员,十分优秀!