@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); }
boolean[] success = extBaseAccessor.createChildren(paths, records, AccessOption.PERSISTENT); for (int i = 0; i < 10; i++) { Assert.assertTrue(success[i], "Should succeed in create: " + paths.get(i));
records.add(new ZNRecord(msgId)); boolean[] success = accessor.createChildren(paths, records, AccessOption.PERSISTENT); for (int i = 0; i < 10; i++) { String msgId = "msg_" + i;