tillrohrmann commented on a change in pull request #17485:
URL: https://github.com/apache/flink/pull/17485#discussion_r791709987



##########
File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/utils/KubernetesUtils.java
##########
@@ -500,5 +502,49 @@ public static String 
tryToGetPrettyPrintYaml(KubernetesResource kubernetesResour
         TASK_MANAGER
     }
 
+    private static final String LEADER_PREFIX = "org.apache.flink.k8s.leader.";
+    public static final char LEADER_INFORMATION_SEPARATOR = ',';
+
+    public static String encodeLeaderInformation(LeaderInformation 
leaderInformation) {
+        Preconditions.checkState(!leaderInformation.isEmpty());
+        return leaderInformation.getLeaderSessionID().toString()
+                + LEADER_INFORMATION_SEPARATOR
+                + leaderInformation.getLeaderAddress();
+    }
+
+    public static LeaderInformation parseLeaderInformationSafely(String value) 
{
+        try {
+            return parseLeaderInformation(value);
+        } catch (Throwable throwable) {
+            LOG.debug("Could not parse value {} into LeaderInformation.", 
value, throwable);
+            return LeaderInformation.empty();
+        }
+    }
+
+    private static LeaderInformation parseLeaderInformation(String value) {
+        final int splitIndex = value.indexOf(LEADER_INFORMATION_SEPARATOR);
+
+        Preconditions.checkState(splitIndex >= 0, "Expecting 
'<session_id>,<leader_address>'");
+
+        final UUID leaderSessionId = UUID.fromString(value.substring(0, 
splitIndex));
+        final String leaderAddress = value.substring(splitIndex + 1);
+
+        return LeaderInformation.known(leaderSessionId, leaderAddress);
+    }
+
+    @Nonnull
+    public static String createSingleLeaderKey(String componentId) {
+        return LEADER_PREFIX + componentId;
+    }
+
+    public static boolean isSingleLeaderKey(String key) {
+        return key.startsWith(LEADER_PREFIX);
+    }
+
+    @Nonnull

Review comment:
       I don't think so. Will remove them.




-- 
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]


Reply via email to