当前位置: 首页>>代码示例>>Java>>正文


Java ZkBadVersionException类代码示例

本文整理汇总了Java中org.I0Itec.zkclient.exception.ZkBadVersionException的典型用法代码示例。如果您正苦于以下问题:Java ZkBadVersionException类的具体用法?Java ZkBadVersionException怎么用?Java ZkBadVersionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ZkBadVersionException类属于org.I0Itec.zkclient.exception包,在下文中一共展示了ZkBadVersionException类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateDataSerialized

import org.I0Itec.zkclient.exception.ZkBadVersionException; //导入依赖的package包/类
/**
 * Updates data of an existing znode. The current content of the znode is passed to the {@link DataUpdater} that is
 * passed into this method, which returns the new content. The new content is only written back to ZooKeeper if
 * nobody has modified the given znode in between. If a concurrent change has been detected the new data of the
 * znode is passed to the updater once again until the new contents can be successfully written back to ZooKeeper.
 *
 * @param <T>
 * @param path
 *            The path of the znode.
 * @param updater
 *            Updater that creates the new contents.
 */
@SuppressWarnings("unchecked") public <T extends Object> void updateDataSerialized(String path,
    DataUpdater<T> updater) {
  Stat stat = new Stat();
  boolean retry;
  do {
    retry = false;
    try {
      T oldData = (T) readData(path, stat);
      T newData = updater.update(oldData);
      writeData(path, newData, stat.getVersion());
    } catch (ZkBadVersionException e) {
      retry = true;
    }
  } while (retry);
}
 
开发者ID:apache,项目名称:helix,代码行数:28,代码来源:ZkClient.java

示例2: updateDataSerialized

import org.I0Itec.zkclient.exception.ZkBadVersionException; //导入依赖的package包/类
/**
 * Updates data of an existing znode. The current content of the znode is passed to the {@link DataUpdater} that is
 * passed into this method, which returns the new content. The new content is only written back to ZooKeeper if
 * nobody has modified the given znode in between. If a concurrent change has been detected the new data of the
 * znode is passed to the updater once again until the new contents can be successfully written back to ZooKeeper.
 * 
 * @param <T>
 * @param path The path of the znode.
 * @param updater Updater that creates the new contents.
 */
public <T extends Object> void updateDataSerialized(String path, DataUpdater<T> updater) {
    Stat stat = new Stat();
    boolean retry;
    do {
        retry = false;
        try {
            T oldData = (T) readData(path, stat);
            T newData = updater.update(oldData);
            writeData(path, newData, stat.getVersion());
        } catch (ZkBadVersionException e) {
            retry = true;
        }
    } while (retry);
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:25,代码来源:ZkClientx.java

示例3: setOfflineSegmentZKMetadata

import org.I0Itec.zkclient.exception.ZkBadVersionException; //导入依赖的package包/类
public static boolean setOfflineSegmentZKMetadata(ZkHelixPropertyStore<ZNRecord> propertyStore,
    OfflineSegmentZKMetadata offlineSegmentZKMetadata, int expectedVersion) {
  // NOTE: Helix will throw ZkBadVersionException if version does not match
  try {
    return propertyStore.set(constructPropertyStorePathForSegment(
        TableNameBuilder.OFFLINE.tableNameWithType(offlineSegmentZKMetadata.getTableName()),
        offlineSegmentZKMetadata.getSegmentName()), offlineSegmentZKMetadata.toZNRecord(), expectedVersion,
        AccessOption.PERSISTENT);
  } catch (ZkBadVersionException e) {
    return false;
  }
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:13,代码来源:ZKMetadataProvider.java


注:本文中的org.I0Itec.zkclient.exception.ZkBadVersionException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。