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


Java DataUpdater.update方法代码示例

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


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

示例1: updateDataSerialized

import org.I0Itec.zkclient.DataUpdater; //导入方法依赖的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.DataUpdater; //导入方法依赖的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: update

import org.I0Itec.zkclient.DataUpdater; //导入方法依赖的package包/类
@Override
public boolean update(String path, DataUpdater<ZNRecord> updater, int options) {
  ZNode zNode = _recordMap.get(path);
  ZNRecord current = zNode != null ? zNode.getRecord() : null;
  ZNRecord newRecord = updater.update(current);
  if (newRecord != null) {
    return set(path, newRecord, options);
  }
  return false;
}
 
开发者ID:apache,项目名称:helix,代码行数:11,代码来源:MockBaseDataAccessor.java

示例4: update

import org.I0Itec.zkclient.DataUpdater; //导入方法依赖的package包/类
@Override
public boolean update(String path, DataUpdater<T> updater, int options) {
  T newRecord = null;
  boolean exceptionDuringUpdater = false;
  try {
    newRecord = updater.update(pathToRecords.get(path));
  } catch (Exception e) {
    exceptionDuringUpdater = true;
  }
  if (exceptionDuringUpdater) {
    return false;
  } else {
    return setAndNotify(path, newRecord);
  }
}
 
开发者ID:linkedin,项目名称:ambry,代码行数:16,代码来源:MockHelixPropertyStore.java


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