@Override public boolean[] remove(List<String> paths, int options) { final int size = paths.size(); List<String> serverPaths = prependChroot(paths); Cache<T> cache = getCache(serverPaths); if (cache != null) { try { cache.lockWrite(); boolean[] success = _baseAccessor.remove(serverPaths, options); for (int i = 0; i < size; i++) { if (success[i]) { cache.purgeRecursive(serverPaths.get(i)); } } return success; } finally { cache.unlockWrite(); } } // no cache return _baseAccessor.remove(serverPaths, options); }
@Override public boolean[] remove(List<String> paths, int options) { final int size = paths.size(); List<String> serverPaths = prependChroot(paths); Cache<T> cache = getCache(serverPaths); if (cache != null) { try { cache.lockWrite(); boolean[] success = _baseAccessor.remove(serverPaths, options); for (int i = 0; i < size; i++) { if (success[i]) { cache.purgeRecursive(serverPaths.get(i)); } } return success; } finally { cache.unlockWrite(); } } // no cache return _baseAccessor.remove(serverPaths, options); }
@Override public boolean remove(String path, int options) { String clientPath = path; String serverPath = prependChroot(clientPath); Cache<T> cache = getCache(serverPath); if (cache != null) { try { cache.lockWrite(); boolean success = _baseAccessor.remove(serverPath, options); if (success) { cache.purgeRecursive(serverPath); } return success; } finally { cache.unlockWrite(); } } // no cache return _baseAccessor.remove(serverPath, options); }
@Override public boolean remove(String path, int options) { String clientPath = path; String serverPath = prependChroot(clientPath); Cache<T> cache = getCache(serverPath); if (cache != null) { try { cache.lockWrite(); boolean success = _baseAccessor.remove(serverPath, options); if (success) { cache.purgeRecursive(serverPath); } return success; } finally { cache.unlockWrite(); } } // no cache return _baseAccessor.remove(serverPath, options); }
@Test public void testSyncRemove() { String className = TestHelper.getTestClassName(); String methodName = TestHelper.getTestMethodName(); String testName = className + "_" + methodName; System.out.println("START " + testName + " at " + new Date(System.currentTimeMillis())); String path = String.format("/%s/%s", _rootPath, "msg_0"); ZNRecord record = new ZNRecord("msg_0"); ZkBaseDataAccessor<ZNRecord> accessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient); // Base data accessor shall not fail when remove a non-exist path boolean success = accessor.remove(path, 0); Assert.assertTrue(success); success = accessor.create(path, record, AccessOption.PERSISTENT); Assert.assertTrue(success); ZNRecord getRecord = _gZkClient.readData(path); Assert.assertNotNull(getRecord); Assert.assertEquals(getRecord.getId(), "msg_0"); success = accessor.remove(path, 0); Assert.assertTrue(success); Assert.assertFalse(_gZkClient.exists(path)); System.out.println("END " + testName + " at " + new Date(System.currentTimeMillis())); }
success = extBaseAccessor.remove(paths, 0); for (int i = 0; i < 10; i++) { Assert.assertTrue(success[i], "Should succeed in remove: " + paths.get(i));
paths.add(PropertyPathBuilder.instanceMessage(root, "host_1", msgId)); success = accessor.remove(paths, 0); for (int i = 0; i < 10; i++) { String msgId = "msg_" + i;