A shaded JAR library that bundles Apache Curator dependencies for ZooKeeper coordination capabilities within Apache Flink's distributed architecture.
npx @tessl/cli install tessl/maven-org-apache-flink--flink-shaded-curator@1.10.0Flink Shaded Curator is a shaded JAR library that provides Apache Curator's distributed coordination capabilities specifically designed for Apache Flink's distributed stream processing framework. It bundles Apache Curator dependencies with relocated classes to avoid classpath conflicts, enabling reliable ZooKeeper-based coordination services within Flink applications.
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-shaded-curator</artifactId>
<version>1.10.3</version>
</dependency>import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.recipes.leader.LeaderLatch;
import org.apache.curator.framework.recipes.cache.NodeCache;
import org.apache.curator.framework.recipes.shared.SharedCount;
import org.apache.curator.retry.ExponentialBackoffRetry;Important: This library relocates certain Guava classes to avoid conflicts. If you need to use Guava functions, import from the shaded namespace:
import org.apache.flink.curator.shaded.com.google.common.base.Function;
import org.apache.flink.curator.shaded.com.google.common.base.Predicate;import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.recipes.leader.LeaderLatch;
import org.apache.curator.retry.ExponentialBackoffRetry;
// Create a Curator client (typical Flink usage pattern)
CuratorFramework client = CuratorFrameworkFactory.newClient(
"localhost:2181",
new ExponentialBackoffRetry(1000, 3)
);
client.start();
// Leader election (primary use case in Flink)
LeaderLatch leaderLatch = new LeaderLatch(client, "/flink/leader", "jobmanager-1");
leaderLatch.start();
try {
// Wait to become leader
leaderLatch.await();
System.out.println("I am the leader!");
// Do leader work...
} finally {
leaderLatch.close();
}
client.close();Flink Shaded Curator is built around Apache Curator's distributed coordination patterns:
This library is specifically designed for Apache Flink and relocates certain dependencies to avoid classpath conflicts:
org.apache.curator.* namespace and provide full functionalitycom.google.common.base.Function → org.apache.flink.curator.shaded.com.google.common.base.Functioncom.google.common.base.Predicate → org.apache.flink.curator.shaded.com.google.common.base.Predicatecom.google.common.reflect.TypeToken → org.apache.flink.curator.shaded.com.google.common.reflect.TypeTokenNote: This library bundles Apache Curator 2.12.0 and is primarily used within Flink for JobManager leader election, checkpoint coordination, and configuration management.
Leader election capabilities for coordinating which process should act as the primary in a distributed system. This is the primary use case within Flink for JobManager coordination.
public class LeaderLatch implements Closeable {
public LeaderLatch(CuratorFramework client, String latchPath);
public LeaderLatch(CuratorFramework client, String latchPath, String id);
public void start() throws Exception;
public boolean hasLeadership();
public void await() throws InterruptedException;
}
public class LeaderSelector implements Closeable {
public LeaderSelector(CuratorFramework client, String mutexPath, LeaderSelectorListener listener);
public void start() throws IOException;
public void requeue() throws InterruptedException;
}Caching mechanisms for ZooKeeper paths to improve performance and reduce network overhead. Used in Flink for monitoring configuration changes and coordinator state.
public class NodeCache implements Closeable {
public NodeCache(CuratorFramework client, String path);
public NodeCache(CuratorFramework client, String path, boolean dataIsCompressed);
public void start() throws Exception;
public void start(boolean buildInitial) throws Exception;
public ChildData getCurrentData();
}
public class PathChildrenCache implements Closeable {
public PathChildrenCache(CuratorFramework client, String path, boolean cacheData);
public void start() throws Exception;
public void start(StartMode mode) throws Exception;
public List<ChildData> getCurrentData();
}Shared data structures for maintaining counters and values across distributed processes. Used in Flink for checkpoint ID coordination and configuration sharing.
public class SharedCount implements Closeable {
public SharedCount(CuratorFramework client, String path, int seedValue);
public void start() throws Exception;
public int getCount();
public boolean trySetCount(VersionedValue<Integer> previous, int newCount) throws Exception;
}
public class SharedValue implements Closeable {
public SharedValue(CuratorFramework client, String path, byte[] seedValue);
public void start() throws Exception;
public VersionedValue<byte[]> getValue() throws Exception;
public boolean trySetValue(VersionedValue<byte[]> previous, byte[] newValue) throws Exception;
}Provides locking mechanisms for coordinating access to shared resources across distributed processes. Available but less commonly used in typical Flink deployments.
public interface InterProcessLock {
void acquire() throws Exception;
boolean acquire(long time, TimeUnit unit) throws Exception;
void release() throws Exception;
}
public class InterProcessMutex implements InterProcessLock {
public InterProcessMutex(CuratorFramework client, String lockPath);
}// Core framework types
public interface CuratorFramework extends Closeable {
void start();
void close();
CuratorFramework.State getState();
void blockUntilConnected() throws InterruptedException;
}
// Cache data structures
public class ChildData {
public String getPath();
public Stat getStat();
public byte[] getData();
}
// Versioned value wrapper
public class VersionedValue<T> {
public T getValue();
public int getVersion();
}
// Connection and retry policies
public class ExponentialBackoffRetry implements RetryPolicy {
public ExponentialBackoffRetry(int baseSleepTimeMs, int maxRetries);
public ExponentialBackoffRetry(int baseSleepTimeMs, int maxRetries, int maxSleepMs);
}
// Listener interfaces
public interface LeaderLatchListener {
void isLeader();
void notLeader();
}
public interface NodeCacheListener {
void nodeChanged() throws Exception;
}
public interface PathChildrenCacheListener {
void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception;
}