Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,36 @@ public void testSyncRemove() {
System.out.println("END " + testName + " at " + new Date(System.currentTimeMillis()));
}

@Test
public void testDeleteNodeWithChildren() {
String root = _rootPath;

ZkBaseDataAccessor<ZNRecord> accessor = new ZkBaseDataAccessor<>(_gZkClient);

// CreateChildren
List<ZNRecord> records = new ArrayList<>();
List<String> paths = new ArrayList<>();
for (int i = 0; i < 10; i++) {
String msgId = "msg_" + i;
paths.add(PropertyPathBuilder.instanceMessage(root, "host_1", msgId));
records.add(new ZNRecord(msgId));
}
boolean[] success = accessor.createChildren(paths, records, AccessOption.PERSISTENT);

// Attempt to remove parent. Shouldn't throw an error or warning log.
// Should return True if recursive deletion succeeds.
Assert.assertTrue(accessor.remove(PropertyPathBuilder.instanceMessage(root, "host_1"), 0),
"Should return True despite log errors.");

// Assert child message nodes were removed when calling remove on parent
for (int i = 0; i < 10; i++) {
String msgId = "msg_" + i;
String path = PropertyPathBuilder.instanceMessage(root, "host_1", msgId);
boolean pathExists = _gZkClient.exists(path);
Assert.assertFalse(pathExists, "Message znode should have been removed by accessor msgId=" + msgId);
}
}

@Test
public void testSyncGet() {
String className = TestHelper.getTestClassName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2066,14 +2066,11 @@ public Object call() throws Exception {
success = true;
} catch (ZkNoNodeException e) {
success = false;
if (LOG.isDebugEnabled()) {
LOG.debug("zkclient {}, Failed to delete path {}, znode does not exist!", _uid, path);
}
LOG.debug("zkclient {}, Failed to delete path {}, znode does not exist!", _uid, path);
}
record(path, null, startT, ZkClientMonitor.AccessType.WRITE);
} catch (Exception e) {
recordFailure(path, ZkClientMonitor.AccessType.WRITE);
LOG.warn("zkclient {}, Failed to delete path {}! ", _uid, path, e);
throw e;
} finally {
long endT = System.currentTimeMillis();
Expand Down