Search in sources :

Example 11 with LeaderInformation

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

the class ZooKeeperUtilsITCase method runWriteAndReadLeaderInformationTest.

private void runWriteAndReadLeaderInformationTest(LeaderInformation leaderInformation) throws Exception {
    final CuratorFrameworkWithUnhandledErrorListener curatorFramework = startCuratorFramework();
    final String path = "/foobar";
    try {
        ZooKeeperUtils.writeLeaderInformationToZooKeeper(leaderInformation, curatorFramework.asCuratorFramework(), () -> true, path);
        final LeaderInformation readLeaderInformation = ZooKeeperUtils.readLeaderInformation(curatorFramework.asCuratorFramework().getData().forPath(path));
        assertThat(readLeaderInformation).isEqualTo(leaderInformation);
    } finally {
        curatorFramework.close();
    }
}
Also used : CuratorFrameworkWithUnhandledErrorListener(org.apache.flink.runtime.highavailability.zookeeper.CuratorFrameworkWithUnhandledErrorListener) LeaderInformation(org.apache.flink.runtime.leaderelection.LeaderInformation)

Aggregations

LeaderInformation (org.apache.flink.runtime.leaderelection.LeaderInformation)11 Test (org.junit.Test)6 FlinkKubeClient (org.apache.flink.kubernetes.kubeclient.FlinkKubeClient)3 KubernetesConfigMap (org.apache.flink.kubernetes.kubeclient.resources.KubernetesConfigMap)3 Map (java.util.Map)2 UUID (java.util.UUID)2 ExecutorService (java.util.concurrent.ExecutorService)2 KubernetesLeaderElectionConfiguration (org.apache.flink.kubernetes.configuration.KubernetesLeaderElectionConfiguration)2 KubernetesConfigMapSharedWatcher (org.apache.flink.kubernetes.kubeclient.KubernetesConfigMapSharedWatcher)2 LeaderElectionEvent (org.apache.flink.runtime.leaderelection.LeaderElectionEvent)2 Test (org.junit.jupiter.api.Test)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 Configuration (org.apache.flink.configuration.Configuration)1 Watch (org.apache.flink.kubernetes.kubeclient.KubernetesSharedWatcher.Watch)1 KubernetesException (org.apache.flink.kubernetes.kubeclient.resources.KubernetesException)1 KubernetesLeaderElector (org.apache.flink.kubernetes.kubeclient.resources.KubernetesLeaderElector)1 LABEL_CONFIGMAP_TYPE_HIGH_AVAILABILITY (org.apache.flink.kubernetes.utils.Constants.LABEL_CONFIGMAP_TYPE_HIGH_AVAILABILITY)1 LEADER_ADDRESS_KEY (org.apache.flink.kubernetes.utils.Constants.LEADER_ADDRESS_KEY)1