Search in sources :

Example 1 with LeaderInformationWithComponentId

use of org.apache.flink.runtime.leaderelection.LeaderInformationWithComponentId in project flink by apache.

the class KubernetesMultipleComponentLeaderElectionDriver method extractLeaderInformation.

private static Collection<LeaderInformationWithComponentId> extractLeaderInformation(KubernetesConfigMap configMap) {
    final Map<String, String> data = configMap.getData();
    final Collection<LeaderInformationWithComponentId> leaderInformationWithLeaderNames = new ArrayList<>();
    for (Map.Entry<String, String> keyValuePair : data.entrySet()) {
        final String key = keyValuePair.getKey();
        if (KubernetesUtils.isSingleLeaderKey(key)) {
            final String leaderName = KubernetesUtils.extractLeaderName(key);
            final LeaderInformation leaderInformation = KubernetesUtils.parseLeaderInformationSafely(keyValuePair.getValue()).orElse(LeaderInformation.empty());
            leaderInformationWithLeaderNames.add(LeaderInformationWithComponentId.create(leaderName, leaderInformation));
        }
    }
    return leaderInformationWithLeaderNames;
}
Also used : LeaderInformationWithComponentId(org.apache.flink.runtime.leaderelection.LeaderInformationWithComponentId) ArrayList(java.util.ArrayList) KubernetesConfigMap(org.apache.flink.kubernetes.kubeclient.resources.KubernetesConfigMap) Map(java.util.Map) LeaderInformation(org.apache.flink.runtime.leaderelection.LeaderInformation)

Aggregations

ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 KubernetesConfigMap (org.apache.flink.kubernetes.kubeclient.resources.KubernetesConfigMap)1 LeaderInformation (org.apache.flink.runtime.leaderelection.LeaderInformation)1 LeaderInformationWithComponentId (org.apache.flink.runtime.leaderelection.LeaderInformationWithComponentId)1