org.apache.hadoop.hbase.zookeeper.ZKUtil.createSetData()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(160)

本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKUtil.createSetData()方法的一些代码示例,展示了ZKUtil.createSetData()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKUtil.createSetData()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.zookeeper.ZKUtil
类名称:ZKUtil
方法名:createSetData

ZKUtil.createSetData介绍

[英]Set data into node creating node if it doesn't yet exist. Does not set watch.
[中]如果数据还不存在,则将其设置为节点创建节点。不定表。

代码示例

代码示例来源:origin: apache/hbase

  1. /**
  2. * Store the rpc throttle value.
  3. * @param enable Set to <code>true</code> to enable, <code>false</code> to disable.
  4. * @throws IOException if an unexpected io exception occurs
  5. */
  6. public void switchRpcThrottle(boolean enable) throws IOException {
  7. try {
  8. byte[] upData = Bytes.toBytes(enable);
  9. ZKUtil.createSetData(zookeeper, rpcThrottleZNode, upData);
  10. } catch (KeeperException e) {
  11. throw new IOException("Failed to store rpc throttle", e);
  12. }
  13. }
  14. }

代码示例来源:origin: apache/hbase

  1. public static void setClusterId(ZKWatcher watcher, ClusterId id)
  2. throws KeeperException {
  3. ZKUtil.createSetData(watcher, watcher.getZNodePaths().clusterIdZNode, id.toByteArray());
  4. }

代码示例来源:origin: apache/hbase

  1. /**
  2. * Perform a best effort enable of hfile retention, which relies on zookeeper communicating the //
  3. * * change back to the hfile cleaner.
  4. * <p>
  5. * No attempt is made to make sure that backups are successfully created - it is inherently an
  6. * <b>asynchronous operation</b>.
  7. * @param zooKeeper watcher connection to zk cluster
  8. * @param table table name on which to enable archiving
  9. * @throws KeeperException
  10. */
  11. private void enable(ZKWatcher zooKeeper, byte[] table)
  12. throws KeeperException {
  13. LOG.debug("Ensuring archiving znode exists");
  14. ZKUtil.createAndFailSilent(zooKeeper, archiveZnode);
  15. // then add the table to the list of znodes to archive
  16. String tableNode = this.getTableNode(table);
  17. LOG.debug("Creating: " + tableNode + ", data: []");
  18. ZKUtil.createSetData(zooKeeper, tableNode, new byte[0]);
  19. }

代码示例来源:origin: apache/hbase

  1. @Override
  2. public void setPeerNewSyncReplicationState(String peerId, SyncReplicationState state)
  3. throws ReplicationException {
  4. try {
  5. ZKUtil.createSetData(zookeeper, getNewSyncReplicationStateNode(peerId),
  6. SyncReplicationState.toByteArray(state));
  7. } catch (KeeperException e) {
  8. throw new ReplicationException(
  9. "Unable to set the new sync replication state for peer with id=" + peerId, e);
  10. }
  11. }

代码示例来源:origin: apache/hbase

  1. public void addKeyToZK(AuthenticationKey key) {
  2. String keyZNode = getKeyNode(key.getKeyId());
  3. try {
  4. byte[] keyData = Writables.getBytes(key);
  5. // TODO: is there any point in retrying beyond what ZK client does?
  6. ZKUtil.createSetData(watcher, keyZNode, keyData);
  7. } catch (KeeperException ke) {
  8. LOG.error(HBaseMarkers.FATAL, "Unable to synchronize master key "+key.getKeyId()+
  9. " to znode "+keyZNode, ke);
  10. watcher.abort("Unable to synchronize secret key "+
  11. key.getKeyId()+" in zookeeper", ke);
  12. } catch (IOException ioe) {
  13. // this can only happen from an error serializing the key
  14. watcher.abort("Failed serializing key "+key.getKeyId(), ioe);
  15. }
  16. }

代码示例来源:origin: apache/hbase

  1. public void updateKeyInZK(AuthenticationKey key) {
  2. String keyZNode = getKeyNode(key.getKeyId());
  3. try {
  4. byte[] keyData = Writables.getBytes(key);
  5. try {
  6. ZKUtil.updateExistingNodeData(watcher, keyZNode, keyData, -1);
  7. } catch (KeeperException.NoNodeException ne) {
  8. // node was somehow removed, try adding it back
  9. ZKUtil.createSetData(watcher, keyZNode, keyData);
  10. }
  11. } catch (KeeperException ke) {
  12. LOG.error(HBaseMarkers.FATAL, "Unable to update master key "+key.getKeyId()+
  13. " in znode "+keyZNode);
  14. watcher.abort("Unable to synchronize secret key "+
  15. key.getKeyId()+" in zookeeper", ke);
  16. } catch (IOException ioe) {
  17. // this can only happen from an error serializing the key
  18. watcher.abort("Failed serializing key "+key.getKeyId(), ioe);
  19. }
  20. }

代码示例来源:origin: apache/hbase

  1. private SyncReplicationState getSyncReplicationState(String peerId, String path)
  2. throws ReplicationException {
  3. try {
  4. byte[] data = ZKUtil.getData(zookeeper, path);
  5. if (data == null || data.length == 0) {
  6. if (ZKUtil.checkExists(zookeeper, getPeerNode(peerId)) != -1) {
  7. // should be a peer from previous version, set the sync replication state for it.
  8. ZKUtil.createSetData(zookeeper, path, NONE_STATE_ZNODE_BYTES);
  9. return SyncReplicationState.NONE;
  10. } else {
  11. throw new ReplicationException(
  12. "Replication peer sync state shouldn't be empty, peerId=" + peerId);
  13. }
  14. }
  15. return SyncReplicationState.parseFrom(data);
  16. } catch (KeeperException | InterruptedException | IOException e) {
  17. throw new ReplicationException(
  18. "Error getting sync replication state of path " + path + " for peer with id=" + peerId, e);
  19. }
  20. }

代码示例来源:origin: apache/hbase

  1. ZKUtil.createSetData(watcher, prepare, ProtobufUtil.prependPBMagic(data));

代码示例来源:origin: co.cask.hbase/hbase

  1. public static void setClusterId(ZooKeeperWatcher watcher, String id)
  2. throws KeeperException {
  3. ZKUtil.createSetData(watcher, watcher.clusterIdZNode, Bytes.toBytes(id));
  4. }
  5. }

代码示例来源:origin: XiaoMi/themis

  1. public void setExpiredTsToZk(long currentExpiredTs) throws Exception {
  2. ZKUtil.createSetData(zk, themisExpiredTsZNodePath,
  3. Bytes.toBytes(String.valueOf(currentExpiredTs)));
  4. LOG.info("successfully set currentExpiredTs to zk, currentExpiredTs=" + currentExpiredTs
  5. + ", zkPath=" + themisExpiredTsZNodePath);
  6. }

代码示例来源:origin: harbby/presto-connectors

  1. public static void setClusterId(ZooKeeperWatcher watcher, ClusterId id)
  2. throws KeeperException {
  3. ZKUtil.createSetData(watcher, watcher.clusterIdZNode, id.toByteArray());
  4. }

代码示例来源:origin: org.apache.hbase/hbase-zookeeper

  1. public static void setClusterId(ZKWatcher watcher, ClusterId id)
  2. throws KeeperException {
  3. ZKUtil.createSetData(watcher, watcher.getZNodePaths().clusterIdZNode, id.toByteArray());
  4. }

代码示例来源:origin: harbby/presto-connectors

  1. /**
  2. * Perform a best effort enable of hfile retention, which relies on zookeeper communicating the //
  3. * * change back to the hfile cleaner.
  4. * <p>
  5. * No attempt is made to make sure that backups are successfully created - it is inherently an
  6. * <b>asynchronous operation</b>.
  7. * @param zooKeeper watcher connection to zk cluster
  8. * @param table table name on which to enable archiving
  9. * @throws KeeperException
  10. */
  11. private void enable(ZooKeeperWatcher zooKeeper, byte[] table)
  12. throws KeeperException {
  13. LOG.debug("Ensuring archiving znode exists");
  14. ZKUtil.createAndFailSilent(zooKeeper, archiveZnode);
  15. // then add the table to the list of znodes to archive
  16. String tableNode = this.getTableNode(table);
  17. LOG.debug("Creating: " + tableNode + ", data: []");
  18. ZKUtil.createSetData(zooKeeper, tableNode, new byte[0]);
  19. }

代码示例来源:origin: harbby/presto-connectors

  1. if (data == null) {
  2. ZKUtil
  3. .createSetData(this.watcher, nodePath, ZKUtil.positionToByteArray(lastSequenceId));
  4. } else {
  5. lastRecordedFlushedSequenceId =
  6. ZKUtil.createSetData(this.watcher, nodePath,
  7. ZKUtil.regionSequenceIdsToByteArray(lastSequenceId, null));
  8. if (LOG.isDebugEnabled()) {

代码示例来源:origin: harbby/presto-connectors

  1. public void addKeyToZK(AuthenticationKey key) {
  2. String keyZNode = getKeyNode(key.getKeyId());
  3. try {
  4. byte[] keyData = Writables.getBytes(key);
  5. // TODO: is there any point in retrying beyond what ZK client does?
  6. ZKUtil.createSetData(watcher, keyZNode, keyData);
  7. } catch (KeeperException ke) {
  8. LOG.fatal("Unable to synchronize master key "+key.getKeyId()+
  9. " to znode "+keyZNode, ke);
  10. watcher.abort("Unable to synchronize secret key "+
  11. key.getKeyId()+" in zookeeper", ke);
  12. } catch (IOException ioe) {
  13. // this can only happen from an error serializing the key
  14. watcher.abort("Failed serializing key "+key.getKeyId(), ioe);
  15. }
  16. }

代码示例来源:origin: org.apache.hbase/hbase-server

  1. ZKUtil.createSetData(watcher, prepare, ProtobufUtil.prependPBMagic(data));

代码示例来源:origin: harbby/presto-connectors

  1. public void updateKeyInZK(AuthenticationKey key) {
  2. String keyZNode = getKeyNode(key.getKeyId());
  3. try {
  4. byte[] keyData = Writables.getBytes(key);
  5. try {
  6. ZKUtil.updateExistingNodeData(watcher, keyZNode, keyData, -1);
  7. } catch (KeeperException.NoNodeException ne) {
  8. // node was somehow removed, try adding it back
  9. ZKUtil.createSetData(watcher, keyZNode, keyData);
  10. }
  11. } catch (KeeperException ke) {
  12. LOG.fatal("Unable to update master key "+key.getKeyId()+
  13. " in znode "+keyZNode);
  14. watcher.abort("Unable to synchronize secret key "+
  15. key.getKeyId()+" in zookeeper", ke);
  16. } catch (IOException ioe) {
  17. // this can only happen from an error serializing the key
  18. watcher.abort("Failed serializing key "+key.getKeyId(), ioe);
  19. }
  20. }

代码示例来源:origin: XiaoMi/themis

  1. ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk),
  2. Bytes.toBytes(String.valueOf(Long.MIN_VALUE)));
  3. ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk),
  4. Bytes.toBytes(String.valueOf(prewriteTs + 5)));

代码示例来源:origin: XiaoMi/themis

  1. ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk),
  2. Bytes.toBytes(String.valueOf(Long.MIN_VALUE)));
  3. admin.flush(TABLENAME);
  4. ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk),
  5. Bytes.toBytes(String.valueOf(prewriteTs + 1)));
  6. admin.flush(TABLENAME);
  7. ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk),
  8. Bytes.toBytes(String.valueOf(Long.MIN_VALUE)));
  9. ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk),
  10. Bytes.toBytes(String.valueOf(prewriteTs + 5)));

代码示例来源:origin: XiaoMi/themis

  1. ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk),
  2. Bytes.toBytes(String.valueOf(Long.MIN_VALUE)));
  3. admin.flush(TABLENAME);
  4. ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk),
  5. Bytes.toBytes(String.valueOf(prewriteTs + 1)));
  6. admin.flush(TABLENAME);
  7. ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk),
  8. Bytes.toBytes(String.valueOf(prewriteTs + 5)));
  9. admin.flush(TABLENAME);

相关文章