XComp commented on code in PR #23327:
URL: https://github.com/apache/flink/pull/23327#discussion_r1310207449
##########
flink-runtime/src/main/java/org/apache/flink/runtime/util/ZooKeeperUtils.java:
##########
@@ -610,12 +611,41 @@ FileSystemStateStorageHelper<T>
createFileSystemStateStorage(
prefix);
}
- /** Creates a ZooKeeper path of the form "/a/b/.../z". */
- public static String generateZookeeperPath(String... paths) {
- return Arrays.stream(paths)
+ /** Creates an absolute ZooKeeper path of the form "/a/b/.../z". */
+ public static String generateAbsoluteZookeeperPath(String... pathElements)
{
+ return generateZookeeperPath("/", pathElements);
+ }
+
+ /** Creates a relative ZooKeeper path of the form "a/b/.../z". */
+ public static String generateRelativeZooKeeperPath(String... pathElements)
{
+ return generateZookeeperPath("", pathElements);
+ }
+
+ private static String generateZookeeperPath(String prefix, String...
pathElements) {
+ return Arrays.stream(pathElements)
.map(ZooKeeperUtils::trimSlashes)
.filter(s -> !s.isEmpty())
- .collect(Collectors.joining("/", "/", ""));
+ .collect(Collectors.joining("/", prefix, ""));
+ }
+
+ private static boolean isAbsolutePath(String path) {
+ return path.startsWith("/");
+ }
+
+ /** Extracts the parent path from the given {@code path}. */
+ public static String extractParentPath(String path) {
Review Comment:
oooh, now I get what you mean. I actually wanted to use `extractParentPath`
to derive the path from `ZooKeeperLeaderElectionDriver#leaderLatch.getOurPath`.
But I noticed that it's not possible if the leader election is not started.
That is why I reverted the change but didn't remove the utility methods. I will
revert that. :facepalm:
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]