LOGGER.info("Updating IdealState for table {}", tableName); if (zkBaseDataAccessor .set(idealStateKey.getPath(), nextIdealState.getRecord(), currentIdealState.getRecord().getVersion(), AccessOption.PERSISTENT)) {
@Override public boolean[] setChildren(List<String> paths, List<T> records, int options) { final int size = paths.size(); List<String> serverPaths = prependChroot(paths); Cache<T> cache = getCache(serverPaths); if (cache != null) { try { cache.lockWrite(); List<Stat> setStats = new ArrayList<Stat>(); List<List<String>> pathsCreatedList = new ArrayList<List<String>>(Collections.<List<String>> nCopies(size, null)); boolean[] success = _baseAccessor.set(serverPaths, records, pathsCreatedList, setStats, options); for (int i = 0; i < size; i++) { updateCache(cache, pathsCreatedList.get(i), success[i], serverPaths.get(i), records.get(i), setStats.get(i)); } return success; } finally { cache.unlockWrite(); } } return _baseAccessor.setChildren(serverPaths, records, options); }
/** * async set * TODO: rename to set */ @Override public boolean[] setChildren(List<String> paths, List<T> records, int options) { return set(paths, records, null, null, options); }
@Override public boolean[] setChildren(List<String> paths, List<T> records, int options) { final int size = paths.size(); List<String> serverPaths = prependChroot(paths); Cache<T> cache = getCache(serverPaths); if (cache != null) { try { cache.lockWrite(); List<Stat> setStats = new ArrayList<Stat>(); List<List<String>> pathsCreatedList = new ArrayList<List<String>>(Collections.<List<String>>nCopies(size, null)); boolean[] success = _baseAccessor.set(serverPaths, records, pathsCreatedList, setStats, options); for (int i = 0; i < size; i++) { updateCache(cache, pathsCreatedList.get(i), success[i], serverPaths.get(i), records.get(i), setStats.get(i)); } return success; } finally { cache.unlockWrite(); } } return _baseAccessor.setChildren(serverPaths, records, options); }
/** * async set * TODO: rename to set */ @Override public boolean[] setChildren(List<String> paths, List<T> records, int options) { return set(paths, records, null, null, options); }
/** * sync set */ @Override public boolean set(String path, T record, int options) { return set(path, record, -1, options); }
/** * sync set */ @Override public boolean set(String path, T record, int options) { return set(path, record, -1, options); }
success = accessor.set(mergedKey, merged, readStat.getVersion(), options); if (!success) { LOG.error("Fail to group commit. path: " + mergedKey + ", value: " + merged
new ArrayList<List<String>>(Collections.<List<String>> nCopies(setPaths.size(), null)); boolean[] success = accessor.set(setPaths, setRecords, pathsCreated, null, AccessOption.PERSISTENT); System.out.println("pathsCreated: " + pathsCreated); System.out.println("setSuccess: " + Arrays.toString(success));
success = accessor.set(mergedKey, merged, readStat.getVersion(), options); if (!success) { LOG.error("Fail to group commit. path: " + mergedKey + ", value: " + merged
@Override public boolean set(String path, T data, int expectVersion, int options) { String clientPath = path; String serverPath = prependChroot(clientPath); Cache<T> cache = getCache(serverPath); boolean success = false; try { if (cache != null) { cache.lockWrite(); ZkBaseDataAccessor<T>.AccessResult result = _baseAccessor.doSet(serverPath, data, expectVersion, options); success = result._retCode == RetCode.OK; updateCache(cache, result._pathCreated, success, serverPath, data, result._stat); } else { // no cache success = _baseAccessor.set(serverPath, data, expectVersion, options); } } catch (Exception e) { } finally { if (cache != null) { cache.unlockWrite(); } } return success; }
@Override public boolean set(String path, T data, int expectVersion, int options) { String clientPath = path; String serverPath = prependChroot(clientPath); Cache<T> cache = getCache(serverPath); boolean success = false; try { if (cache != null) { cache.lockWrite(); ZkBaseDataAccessor<T>.AccessResult result = _baseAccessor.doSet(serverPath, data, expectVersion, options); success = result._retCode == RetCode.OK; updateCache(cache, result._pathCreated, success, serverPath, data, result._stat); } else { // no cache success = _baseAccessor.set(serverPath, data, expectVersion, options); } } catch (Exception e) { } finally { if (cache != null) { cache.unlockWrite(); } } return success; }
success = accessor.set(path, record, AccessOption.PERSISTENT); Assert.assertTrue(success);
ZNRecord data = accessor.get(path, stat, 2); data.getSimpleFields().put("SESSION_ID", "invalid-id"); accessor.set(path, data, 2); Thread.sleep(2000);