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

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

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

ZKUtil.updateExistingNodeData介绍

[英]Update the data of an existing node with the expected version to have the specified data. Throws an exception if there is a version mismatch or some other problem. Sets no watches under any conditions.
[中]使用预期版本更新现有节点的数据,以获得指定的数据。如果存在版本不匹配或其他问题,则引发异常。在任何情况下都不设置手表。

代码示例

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

/**
  * Write a labels mirror or user auths mirror into zookeeper
  *
  * @param data
  * @param labelsOrUserAuths true for writing labels and false for user auths.
  */
 public void writeToZookeeper(byte[] data, boolean labelsOrUserAuths) {
  String znode = this.labelZnode;
  if (!labelsOrUserAuths) {
   znode = this.userAuthsZnode;
  }
  try {
   ZKUtil.updateExistingNodeData(watcher, znode, data, -1);
  } catch (KeeperException e) {
   LOG.error("Failed writing to " + znode, e);
   watcher.abort("Failed writing node " + znode + " to zookeeper", e);
  }
 }
}

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

/***
 * Write a table's access controls to the permissions mirror in zookeeper
 * @param entry
 * @param permsData
 */
public void writeToZookeeper(byte[] entry, byte[] permsData) {
 String entryName = Bytes.toString(entry);
 String zkNode = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, ACL_NODE);
 zkNode = ZNodePaths.joinZNode(zkNode, entryName);
 try {
  ZKUtil.createWithParents(watcher, zkNode);
  ZKUtil.updateExistingNodeData(watcher, zkNode, permsData, -1);
 } catch (KeeperException e) {
  LOG.error("Failed updating permissions for entry '" +
    entryName + "'", e);
  watcher.abort("Failed writing node "+zkNode+" to zookeeper", e);
 }
}

代码示例来源: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

/**
  * Write a labels mirror or user auths mirror into zookeeper
  * 
  * @param data
  * @param labelsOrUserAuths true for writing labels and false for user auths.
  */
 public void writeToZookeeper(byte[] data, boolean labelsOrUserAuths) {
  String znode = this.labelZnode;
  if (!labelsOrUserAuths) {
   znode = this.userAuthsZnode;
  }
  try {
   ZKUtil.updateExistingNodeData(watcher, znode, data, -1);
  } catch (KeeperException e) {
   LOG.error("Failed writing to " + znode, e);
   watcher.abort("Failed writing node " + znode + " to zookeeper", e);
  }
 }
}

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

/***
 * Write a table's access controls to the permissions mirror in zookeeper
 * @param entry
 * @param permsData
 */
public void writeToZookeeper(byte[] entry, byte[] permsData) {
 String entryName = Bytes.toString(entry);
 String zkNode = ZKUtil.joinZNode(watcher.baseZNode, ACL_NODE);
 zkNode = ZKUtil.joinZNode(zkNode, entryName);
 try {
  ZKUtil.createWithParents(watcher, zkNode);
  ZKUtil.updateExistingNodeData(watcher, zkNode, permsData, -1);
 } catch (KeeperException e) {
  LOG.error("Failed updating permissions for entry '" +
    entryName + "'", e);
  watcher.abort("Failed writing node "+zkNode+" to zookeeper", e);
 }
}

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

private void writeNamespace(NamespaceDescriptor ns) throws IOException {
 String zNode = ZKUtil.joinZNode(nsZNode, ns.getName());
 try {
  ZKUtil.createWithParents(watcher, zNode);
  ZKUtil.updateExistingNodeData(watcher, zNode,
    ProtobufUtil.toProtoNamespaceDescriptor(ns).toByteArray(), -1);
 } catch (KeeperException e) {
  LOG.error("Failed updating permissions for namespace "+ns.getName(), e);
  throw new IOException("Failed updating permissions for namespace "+ns.getName(), e);
 }
}

代码示例来源: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);
 }
}

相关文章

微信公众号

最新文章

更多