本文整理汇总了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);
}
示例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);
}
示例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;
}
}