/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
continue; merged = ent._updater.update(merged); if (LOG.isDebugEnabled()) { LOG.debug("After merging processed entry. path: " + mergedKey + ", value: " + merged); merged = ent._updater.update(merged); if (LOG.isDebugEnabled()) { LOG.debug("After merging pending entry. path: " + mergedKey + ", value: " + merged);
/** * 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); }
continue; merged = ent._updater.update(merged); if (LOG.isDebugEnabled()) { LOG.debug("After merging processed entry. path: " + mergedKey + ", value: " + merged); merged = ent._updater.update(merged); if (LOG.isDebugEnabled()) { LOG.debug("After merging pending entry. path: " + mergedKey + ", value: " + merged);
T newData = updater.update(curDataList.get(i)); newDataList.add(newData); if (newData == null) {
T newData = updater.update(curDataList.get(i)); newDataList.add(newData); if (newData == null) {
@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; }
if (type.mergeOnUpdate) { ZNRecord znRecord = new ZNRecord((ZNRecord) _baseDataAccessor.get(path, null, 0)); ZNRecord newZNRecord = updater.update(znRecord); if (newZNRecord != null) { _baseDataAccessor.set(path, newZNRecord, 0); if (_baseDataAccessor.exists(path, 0)) { ZNRecord znRecord = new ZNRecord((ZNRecord) _baseDataAccessor.get(path, null, 0)); ZNRecord newZNRecord = updater.update(znRecord); if (newZNRecord != null) { _baseDataAccessor.set(path, newZNRecord, 0);