org.I0Itec.zkclient.ZkClient.writeDataReturnStat()方法的使用及代码示例

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

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

ZkClient.writeDataReturnStat介绍

暂无

代码示例

代码示例来源:origin: com.101tec/zkclient

public void writeData(final String path, Object datat, final int expectedVersion) {
  writeDataReturnStat(path, datat, expectedVersion);
}

代码示例来源:origin: confluentinc/common

ConditionalUpdateCallback customConditionCallback) {
try {
 Stat stat = client.writeDataReturnStat(path, data, expectedVersion);
 log.debug(
   "Conditional update of path %s with value %s and expected version %d succeeded, returning the new version: %d"

代码示例来源:origin: org.apache.samza/samza-core_2.11

/**
 * publish the version number of the next JobModel
 * @param oldVersion - used to validate, that no one has changed the version in the meanwhile.
 * @param newVersion - new version.
 */
public void publishJobModelVersion(String oldVersion, String newVersion) {
 Stat stat = new Stat();
 String currentVersion = zkClient.readData(keyBuilder.getJobModelVersionPath(), stat);
 metrics.reads.inc();
 LOG.info("publishing new version: " + newVersion + "; oldVersion = " + oldVersion + "(" + stat
   .getVersion() + ")");
 if (currentVersion != null && !currentVersion.equals(oldVersion)) {
  throw new SamzaException(
    "Someone changed JobModelVersion while the leader was generating one: expected" + oldVersion + ", got " + currentVersion);
 }
 // data version is the ZK version of the data from the ZK.
 int dataVersion = stat.getVersion();
 try {
  stat = zkClient.writeDataReturnStat(keyBuilder.getJobModelVersionPath(), newVersion, dataVersion);
  metrics.writes.inc();
 } catch (Exception e) {
  String msg = "publish job model version failed for new version = " + newVersion + "; old version = " + oldVersion;
  LOG.error(msg, e);
  throw new SamzaException(msg, e);
 }
 LOG.info("published new version: " + newVersion + "; expected data version = " + (dataVersion + 1) +
   "(actual data version after update = " + stat.getVersion() + ")");
}

代码示例来源:origin: org.apache.samza/samza-core_2.10

/**
 * publish the version number of the next JobModel
 * @param oldVersion - used to validate, that no one has changed the version in the meanwhile.
 * @param newVersion - new version.
 */
public void publishJobModelVersion(String oldVersion, String newVersion) {
 Stat stat = new Stat();
 String currentVersion = zkClient.readData(keyBuilder.getJobModelVersionPath(), stat);
 metrics.reads.inc();
 LOG.info("publishing new version: " + newVersion + "; oldVersion = " + oldVersion + "(" + stat
   .getVersion() + ")");
 if (currentVersion != null && !currentVersion.equals(oldVersion)) {
  throw new SamzaException(
    "Someone changed JobModelVersion while the leader was generating one: expected" + oldVersion + ", got " + currentVersion);
 }
 // data version is the ZK version of the data from the ZK.
 int dataVersion = stat.getVersion();
 try {
  stat = zkClient.writeDataReturnStat(keyBuilder.getJobModelVersionPath(), newVersion, dataVersion);
  metrics.writes.inc();
 } catch (Exception e) {
  String msg = "publish job model version failed for new version = " + newVersion + "; old version = " + oldVersion;
  LOG.error(msg, e);
  throw new SamzaException(msg, e);
 }
 LOG.info("published new version: " + newVersion + "; expected data version = " + (dataVersion + 1) +
   "(actual data version after update = " + stat.getVersion() + ")");
}

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

/**
 * publish the version number of the next JobModel
 * @param oldVersion - used to validate, that no one has changed the version in the meanwhile.
 * @param newVersion - new version.
 */
public void publishJobModelVersion(String oldVersion, String newVersion) {
 Stat stat = new Stat();
 String currentVersion = zkClient.readData(keyBuilder.getJobModelVersionPath(), stat);
 metrics.reads.inc();
 LOG.info("publishing new version: " + newVersion + "; oldVersion = " + oldVersion + "(" + stat
   .getVersion() + ")");
 if (currentVersion != null && !currentVersion.equals(oldVersion)) {
  throw new SamzaException(
    "Someone changed JobModelVersion while the leader was generating one: expected" + oldVersion + ", got " + currentVersion);
 }
 // data version is the ZK version of the data from the ZK.
 int dataVersion = stat.getVersion();
 try {
  stat = zkClient.writeDataReturnStat(keyBuilder.getJobModelVersionPath(), newVersion, dataVersion);
  metrics.writes.inc();
 } catch (Exception e) {
  String msg = "publish job model version failed for new version = " + newVersion + "; old version = " + oldVersion;
  LOG.error(msg, e);
  throw new SamzaException(msg, e);
 }
 LOG.info("published new version: " + newVersion + "; expected data version = " + (dataVersion + 1) +
   "(actual data version after update = " + stat.getVersion() + ")");
}

代码示例来源:origin: org.apache.samza/samza-core

/**
 * publish the version number of the next JobModel
 * @param oldVersion - used to validate, that no one has changed the version in the meanwhile.
 * @param newVersion - new version.
 */
public void publishJobModelVersion(String oldVersion, String newVersion) {
 Stat stat = new Stat();
 String currentVersion = zkClient.readData(keyBuilder.getJobModelVersionPath(), stat);
 metrics.reads.inc();
 LOG.info("publishing new version: " + newVersion + "; oldVersion = " + oldVersion + "(" + stat
   .getVersion() + ")");
 if (currentVersion != null && !currentVersion.equals(oldVersion)) {
  throw new SamzaException(
    "Someone changed JobModelVersion while the leader was generating one: expected" + oldVersion + ", got " + currentVersion);
 }
 // data version is the ZK version of the data from the ZK.
 int dataVersion = stat.getVersion();
 try {
  stat = zkClient.writeDataReturnStat(keyBuilder.getJobModelVersionPath(), newVersion, dataVersion);
  metrics.writes.inc();
 } catch (Exception e) {
  String msg = "publish job model version failed for new version = " + newVersion + "; old version = " + oldVersion;
  LOG.error(msg, e);
  throw new SamzaException(msg, e);
 }
 LOG.info("published new version: " + newVersion + "; expected data version = " + (dataVersion + 1) +
   "(actual data version after update = " + stat.getVersion() + ")");
}

代码示例来源:origin: org.apache.samza/samza-core_2.12

/**
 * publish the version number of the next JobModel
 * @param oldVersion - used to validate, that no one has changed the version in the meanwhile.
 * @param newVersion - new version.
 */
public void publishJobModelVersion(String oldVersion, String newVersion) {
 Stat stat = new Stat();
 String currentVersion = zkClient.readData(keyBuilder.getJobModelVersionPath(), stat);
 metrics.reads.inc();
 LOG.info("publishing new version: " + newVersion + "; oldVersion = " + oldVersion + "(" + stat
   .getVersion() + ")");
 if (currentVersion != null && !currentVersion.equals(oldVersion)) {
  throw new SamzaException(
    "Someone changed JobModelVersion while the leader was generating one: expected" + oldVersion + ", got " + currentVersion);
 }
 // data version is the ZK version of the data from the ZK.
 int dataVersion = stat.getVersion();
 try {
  stat = zkClient.writeDataReturnStat(keyBuilder.getJobModelVersionPath(), newVersion, dataVersion);
  metrics.writes.inc();
 } catch (Exception e) {
  String msg = "publish job model version failed for new version = " + newVersion + "; old version = " + oldVersion;
  LOG.error(msg, e);
  throw new SamzaException(msg, e);
 }
 LOG.info("published new version: " + newVersion + "; expected data version = " + (dataVersion + 1) +
   "(actual data version after update = " + stat.getVersion() + ")");
}

相关文章

微信公众号

最新文章

更多