fix(zookeeper): show system znodes in root listing
This commit is contained in:
1 parent
7748c13a1e
commit
313ae2d071
2 files changed
+19
-10
No files matched your search
@@ -140,7 +140,6 @@ public final class ZooKeeperAgent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<String> paths = recursive ? listRecursive(active, root) : listDirectChildren(active, root);
|
List<String> paths = recursive ? listRecursive(active, root) : listDirectChildren(active, root);
|
||||||
paths.removeIf(path -> shouldHideFromRootListing(root, path));
|
|
||||||
Collections.sort(paths);
|
Collections.sort(paths);
|
||||||
int offset = cursor == null ? 0 : Math.max(0, cursor.offset);
|
int offset = cursor == null ? 0 : Math.max(0, cursor.offset);
|
||||||
int end = Math.min(paths.size(), offset + limit);
|
int end = Math.min(paths.size(), offset + limit);
|
||||||
@@ -480,10 +479,6 @@ public final class ZooKeeperAgent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean shouldHideFromRootListing(String root, String path) {
|
|
||||||
return "/".equals(root) && ("/zookeeper".equals(path) || path.startsWith("/zookeeper/"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean hasTlsOptions(JsonObject connection) {
|
private static boolean hasTlsOptions(JsonObject connection) {
|
||||||
return boolOrDefault(connection, "ssl", false)
|
return boolOrDefault(connection, "ssl", false)
|
||||||
|| firstNonBlank(
|
|| firstNonBlank(
|
||||||
|
|||||||
+19
-5
@@ -398,7 +398,7 @@ final class ZooKeeperAgentTest {
|
|||||||
|
|
||||||
JsonObject list = result(request(5, "kv_list_prefix", "{\"prefix\":\"/\",\"recursive\":false}"));
|
JsonObject list = result(request(5, "kv_list_prefix", "{\"prefix\":\"/\",\"recursive\":false}"));
|
||||||
|
|
||||||
Assertions.assertEquals(List.of("/app", "/config"), listedKeys(list));
|
Assertions.assertEquals(List.of("/app", "/config", "/zookeeper"), listedKeys(list));
|
||||||
Assertions.assertTrue(list.get("continuation").isJsonNull());
|
Assertions.assertTrue(list.get("continuation").isJsonNull());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -412,7 +412,10 @@ final class ZooKeeperAgentTest {
|
|||||||
|
|
||||||
JsonObject list = result(request(5, "kv_list_prefix", "{\"prefix\":\"/\"}"));
|
JsonObject list = result(request(5, "kv_list_prefix", "{\"prefix\":\"/\"}"));
|
||||||
|
|
||||||
Assertions.assertEquals(List.of("/app", "/app/name", "/config"), listedKeys(list));
|
Assertions.assertEquals(
|
||||||
|
List.of("/app", "/app/name", "/config", "/zookeeper", "/zookeeper/config", "/zookeeper/quota"),
|
||||||
|
listedKeys(list)
|
||||||
|
);
|
||||||
Assertions.assertTrue(list.get("continuation").isJsonNull());
|
Assertions.assertTrue(list.get("continuation").isJsonNull());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -426,7 +429,10 @@ final class ZooKeeperAgentTest {
|
|||||||
|
|
||||||
JsonObject list = result(request(6, "kv_list_prefix", "{\"prefix\":\"/\",\"recursive\":true}"));
|
JsonObject list = result(request(6, "kv_list_prefix", "{\"prefix\":\"/\",\"recursive\":true}"));
|
||||||
|
|
||||||
Assertions.assertEquals(List.of("/app", "/app/name", "/config"), listedKeys(list));
|
Assertions.assertEquals(
|
||||||
|
List.of("/app", "/app/name", "/config", "/zookeeper", "/zookeeper/config", "/zookeeper/quota"),
|
||||||
|
listedKeys(list)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,11 +463,19 @@ final class ZooKeeperAgentTest {
|
|||||||
"kv_list_prefix",
|
"kv_list_prefix",
|
||||||
"{\"prefix\":\"/\",\"limit\":2,\"continuation\":\"" + continuation + "\"}"
|
"{\"prefix\":\"/\",\"limit\":2,\"continuation\":\"" + continuation + "\"}"
|
||||||
));
|
));
|
||||||
|
String secondContinuation = second.get("continuation").getAsString();
|
||||||
|
JsonObject third = result(request(
|
||||||
|
7,
|
||||||
|
"kv_list_prefix",
|
||||||
|
"{\"prefix\":\"/\",\"limit\":2,\"continuation\":\"" + secondContinuation + "\"}"
|
||||||
|
));
|
||||||
|
|
||||||
Assertions.assertEquals(List.of("/a", "/b"), listedKeys(first));
|
Assertions.assertEquals(List.of("/a", "/b"), listedKeys(first));
|
||||||
Assertions.assertFalse(continuation.isBlank());
|
Assertions.assertFalse(continuation.isBlank());
|
||||||
Assertions.assertEquals(List.of("/c"), listedKeys(second));
|
Assertions.assertEquals(List.of("/c", "/zookeeper"), listedKeys(second));
|
||||||
Assertions.assertTrue(second.get("continuation").isJsonNull());
|
Assertions.assertFalse(secondContinuation.isBlank());
|
||||||
|
Assertions.assertEquals(List.of("/zookeeper/config", "/zookeeper/quota"), listedKeys(third));
|
||||||
|
Assertions.assertTrue(third.get("continuation").isJsonNull());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user