@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); }
@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); }
updateCache(cache, pathsCreatedList.get(i), success[i], serverPaths.get(i), updateData.get(i), setStats.get(i));
updateCache(cache, pathsCreatedList.get(i), success[i], serverPaths.get(i), updateData.get(i), setStats.get(i));
@Override public boolean[] createChildren(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(); boolean[] needCreate = new boolean[size]; Arrays.fill(needCreate, true); List<List<String>> pathsCreatedList = new ArrayList<List<String>>(Collections.<List<String>> nCopies(size, null)); CreateCallbackHandler[] createCbList = _baseAccessor.create(serverPaths, records, needCreate, pathsCreatedList, options); boolean[] success = new boolean[size]; for (int i = 0; i < size; i++) { CreateCallbackHandler cb = createCbList[i]; success[i] = (Code.get(cb.getRc()) == Code.OK); updateCache(cache, pathsCreatedList.get(i), success[i], serverPaths.get(i), records.get(i), ZNode.ZERO_STAT); } return success; } finally { cache.unlockWrite(); } } // no cache return _baseAccessor.createChildren(serverPaths, records, options); }
@Override public boolean[] createChildren(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(); boolean[] needCreate = new boolean[size]; Arrays.fill(needCreate, true); List<List<String>> pathsCreatedList = new ArrayList<List<String>>(Collections.<List<String>>nCopies(size, null)); CreateCallbackHandler[] createCbList = _baseAccessor.create(serverPaths, records, needCreate, pathsCreatedList, options); boolean[] success = new boolean[size]; for (int i = 0; i < size; i++) { CreateCallbackHandler cb = createCbList[i]; success[i] = (Code.get(cb.getRc()) == Code.OK); updateCache(cache, pathsCreatedList.get(i), success[i], serverPaths.get(i), records.get(i), ZNode.ZERO_STAT); } return success; } finally { cache.unlockWrite(); } } // no cache return _baseAccessor.createChildren(serverPaths, records, options); }
@Override public boolean update(String path, DataUpdater<T> updater, int options) { String clientPath = path; String serverPath = prependChroot(clientPath); Cache<T> cache = getCache(serverPath); if (cache != null) { try { cache.lockWrite(); ZkBaseDataAccessor<T>.AccessResult result = _baseAccessor.doUpdate(serverPath, updater, options); boolean success = (result._retCode == RetCode.OK); updateCache(cache, result._pathCreated, success, serverPath, result._updatedValue, result._stat); return success; } finally { cache.unlockWrite(); } } // no cache return _groupCommit.commit(_baseAccessor, options, serverPath, updater); // return _baseAccessor.update(serverPath, updater, options); }
@Override public boolean create(String path, T data, int options) { String clientPath = path; String serverPath = prependChroot(clientPath); Cache<T> cache = getCache(serverPath); if (cache != null) { try { cache.lockWrite(); ZkBaseDataAccessor<T>.AccessResult result = _baseAccessor.doCreate(serverPath, data, options); boolean success = (result._retCode == RetCode.OK); updateCache(cache, result._pathCreated, success, serverPath, data, ZNode.ZERO_STAT); return success; } finally { cache.unlockWrite(); } } // no cache return _baseAccessor.create(serverPath, data, options); }
@Override public boolean create(String path, T data, int options) { String clientPath = path; String serverPath = prependChroot(clientPath); Cache<T> cache = getCache(serverPath); if (cache != null) { try { cache.lockWrite(); ZkBaseDataAccessor<T>.AccessResult result = _baseAccessor.doCreate(serverPath, data, options); boolean success = (result._retCode == RetCode.OK); updateCache(cache, result._pathCreated, success, serverPath, data, ZNode.ZERO_STAT); return success; } finally { cache.unlockWrite(); } } // no cache return _baseAccessor.create(serverPath, data, options); }
@Override public boolean update(String path, DataUpdater<T> updater, int options) { String clientPath = path; String serverPath = prependChroot(clientPath); Cache<T> cache = getCache(serverPath); if (cache != null) { try { cache.lockWrite(); ZkBaseDataAccessor<T>.AccessResult result = _baseAccessor.doUpdate(serverPath, updater, options); boolean success = (result._retCode == RetCode.OK); updateCache(cache, result._pathCreated, success, serverPath, result._updatedValue, result._stat); return success; } finally { cache.unlockWrite(); } } // no cache return _groupCommit.commit(_baseAccessor, options, serverPath, updater); // return _baseAccessor.update(serverPath, updater, options); }
@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; }