本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKUtil.createSetData()
方法的一些代码示例,展示了ZKUtil.createSetData()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKUtil.createSetData()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.zookeeper.ZKUtil
类名称:ZKUtil
方法名:createSetData
[英]Set data into node creating node if it doesn't yet exist. Does not set watch.
[中]如果数据还不存在,则将其设置为节点创建节点。不定表。
代码示例来源:origin: apache/hbase
/**
* Store the rpc throttle value.
* @param enable Set to <code>true</code> to enable, <code>false</code> to disable.
* @throws IOException if an unexpected io exception occurs
*/
public void switchRpcThrottle(boolean enable) throws IOException {
try {
byte[] upData = Bytes.toBytes(enable);
ZKUtil.createSetData(zookeeper, rpcThrottleZNode, upData);
} catch (KeeperException e) {
throw new IOException("Failed to store rpc throttle", e);
}
}
}
代码示例来源:origin: apache/hbase
public static void setClusterId(ZKWatcher watcher, ClusterId id)
throws KeeperException {
ZKUtil.createSetData(watcher, watcher.getZNodePaths().clusterIdZNode, id.toByteArray());
}
代码示例来源:origin: apache/hbase
/**
* Perform a best effort enable of hfile retention, which relies on zookeeper communicating the //
* * change back to the hfile cleaner.
* <p>
* No attempt is made to make sure that backups are successfully created - it is inherently an
* <b>asynchronous operation</b>.
* @param zooKeeper watcher connection to zk cluster
* @param table table name on which to enable archiving
* @throws KeeperException
*/
private void enable(ZKWatcher zooKeeper, byte[] table)
throws KeeperException {
LOG.debug("Ensuring archiving znode exists");
ZKUtil.createAndFailSilent(zooKeeper, archiveZnode);
// then add the table to the list of znodes to archive
String tableNode = this.getTableNode(table);
LOG.debug("Creating: " + tableNode + ", data: []");
ZKUtil.createSetData(zooKeeper, tableNode, new byte[0]);
}
代码示例来源:origin: apache/hbase
@Override
public void setPeerNewSyncReplicationState(String peerId, SyncReplicationState state)
throws ReplicationException {
try {
ZKUtil.createSetData(zookeeper, getNewSyncReplicationStateNode(peerId),
SyncReplicationState.toByteArray(state));
} catch (KeeperException e) {
throw new ReplicationException(
"Unable to set the new sync replication state for peer with id=" + peerId, e);
}
}
代码示例来源: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: 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: apache/hbase
private SyncReplicationState getSyncReplicationState(String peerId, String path)
throws ReplicationException {
try {
byte[] data = ZKUtil.getData(zookeeper, path);
if (data == null || data.length == 0) {
if (ZKUtil.checkExists(zookeeper, getPeerNode(peerId)) != -1) {
// should be a peer from previous version, set the sync replication state for it.
ZKUtil.createSetData(zookeeper, path, NONE_STATE_ZNODE_BYTES);
return SyncReplicationState.NONE;
} else {
throw new ReplicationException(
"Replication peer sync state shouldn't be empty, peerId=" + peerId);
}
}
return SyncReplicationState.parseFrom(data);
} catch (KeeperException | InterruptedException | IOException e) {
throw new ReplicationException(
"Error getting sync replication state of path " + path + " for peer with id=" + peerId, e);
}
}
代码示例来源:origin: apache/hbase
ZKUtil.createSetData(watcher, prepare, ProtobufUtil.prependPBMagic(data));
代码示例来源:origin: co.cask.hbase/hbase
public static void setClusterId(ZooKeeperWatcher watcher, String id)
throws KeeperException {
ZKUtil.createSetData(watcher, watcher.clusterIdZNode, Bytes.toBytes(id));
}
}
代码示例来源:origin: XiaoMi/themis
public void setExpiredTsToZk(long currentExpiredTs) throws Exception {
ZKUtil.createSetData(zk, themisExpiredTsZNodePath,
Bytes.toBytes(String.valueOf(currentExpiredTs)));
LOG.info("successfully set currentExpiredTs to zk, currentExpiredTs=" + currentExpiredTs
+ ", zkPath=" + themisExpiredTsZNodePath);
}
代码示例来源:origin: harbby/presto-connectors
public static void setClusterId(ZooKeeperWatcher watcher, ClusterId id)
throws KeeperException {
ZKUtil.createSetData(watcher, watcher.clusterIdZNode, id.toByteArray());
}
代码示例来源:origin: org.apache.hbase/hbase-zookeeper
public static void setClusterId(ZKWatcher watcher, ClusterId id)
throws KeeperException {
ZKUtil.createSetData(watcher, watcher.getZNodePaths().clusterIdZNode, id.toByteArray());
}
代码示例来源:origin: harbby/presto-connectors
/**
* Perform a best effort enable of hfile retention, which relies on zookeeper communicating the //
* * change back to the hfile cleaner.
* <p>
* No attempt is made to make sure that backups are successfully created - it is inherently an
* <b>asynchronous operation</b>.
* @param zooKeeper watcher connection to zk cluster
* @param table table name on which to enable archiving
* @throws KeeperException
*/
private void enable(ZooKeeperWatcher zooKeeper, byte[] table)
throws KeeperException {
LOG.debug("Ensuring archiving znode exists");
ZKUtil.createAndFailSilent(zooKeeper, archiveZnode);
// then add the table to the list of znodes to archive
String tableNode = this.getTableNode(table);
LOG.debug("Creating: " + tableNode + ", data: []");
ZKUtil.createSetData(zooKeeper, tableNode, new byte[0]);
}
代码示例来源:origin: harbby/presto-connectors
if (data == null) {
ZKUtil
.createSetData(this.watcher, nodePath, ZKUtil.positionToByteArray(lastSequenceId));
} else {
lastRecordedFlushedSequenceId =
ZKUtil.createSetData(this.watcher, nodePath,
ZKUtil.regionSequenceIdsToByteArray(lastSequenceId, null));
if (LOG.isDebugEnabled()) {
代码示例来源:origin: harbby/presto-connectors
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.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: org.apache.hbase/hbase-server
ZKUtil.createSetData(watcher, prepare, ProtobufUtil.prependPBMagic(data));
代码示例来源:origin: harbby/presto-connectors
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.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: XiaoMi/themis
ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk),
Bytes.toBytes(String.valueOf(Long.MIN_VALUE)));
ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk),
Bytes.toBytes(String.valueOf(prewriteTs + 5)));
代码示例来源:origin: XiaoMi/themis
ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk),
Bytes.toBytes(String.valueOf(Long.MIN_VALUE)));
admin.flush(TABLENAME);
ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk),
Bytes.toBytes(String.valueOf(prewriteTs + 1)));
admin.flush(TABLENAME);
ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk),
Bytes.toBytes(String.valueOf(Long.MIN_VALUE)));
ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk),
Bytes.toBytes(String.valueOf(prewriteTs + 5)));
代码示例来源:origin: XiaoMi/themis
ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk),
Bytes.toBytes(String.valueOf(Long.MIN_VALUE)));
admin.flush(TABLENAME);
ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk),
Bytes.toBytes(String.valueOf(prewriteTs + 1)));
admin.flush(TABLENAME);
ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk),
Bytes.toBytes(String.valueOf(prewriteTs + 5)));
admin.flush(TABLENAME);
内容来源于网络,如有侵权,请联系作者删除!