Java client library for accessing queryable state in Apache Flink streaming applications through a network-based query interface.
—
Core client functionality for connecting to Flink clusters, managing configuration, and handling client lifecycle operations.
Create a QueryableStateClient to connect to a Flink cluster's client proxy.
public QueryableStateClient(String remoteHostname, int remotePort) throws UnknownHostException;
public QueryableStateClient(InetAddress remoteAddress, int remotePort);Parameters:
remoteHostname - Hostname of the client proxy to connect to (throws UnknownHostException if invalid)remotePort - Port of the client proxy (must be in range 0-65535)remoteAddress - InetAddress of the client proxy to connect toUsage Example:
// Connect using hostname
QueryableStateClient client = new QueryableStateClient("localhost", 9069);
// Connect using InetAddress
InetAddress address = InetAddress.getByName("192.168.1.100");
QueryableStateClient client = new QueryableStateClient(address, 9069);Configure execution settings and classloader for serialization.
public ExecutionConfig getExecutionConfig();
public ExecutionConfig setExecutionConfig(ExecutionConfig config);
public ClassLoader setUserClassLoader(ClassLoader userClassLoader);Returns:
getExecutionConfig() - Current ExecutionConfig or null if not setsetExecutionConfig() - Previous ExecutionConfig or null if none was setsetUserClassLoader() - Previous ClassLoader or null if none was setUsage Example:
QueryableStateClient client = new QueryableStateClient("localhost", 9069);
// Configure execution config
ExecutionConfig config = new ExecutionConfig();
config.enableObjectReuse(); // Example configuration
ExecutionConfig previous = client.setExecutionConfig(config);
// Set custom classloader for serialization
ClassLoader customClassLoader = Thread.currentThread().getContextClassLoader();
client.setUserClassLoader(customClassLoader);Manage the client lifecycle with proper shutdown procedures.
public CompletableFuture<?> shutdownAndHandle();
public void shutdownAndWait();Returns:
shutdownAndHandle() - CompletableFuture that completes when shutdown is finishedshutdownAndWait() - void (blocks until shutdown completes)Behavior:
shutdownAndHandle() - Returns a future for asynchronous shutdown handlingshutdownAndWait() - Blocks the calling thread until shutdown completes; logs warnings on exceptionsUsage Example:
QueryableStateClient client = new QueryableStateClient("localhost", 9069);
// Perform queries...
// Asynchronous shutdown
client.shutdownAndHandle().thenRun(() -> {
System.out.println("Client shutdown completed");
}).exceptionally(throwable -> {
System.err.println("Shutdown failed: " + throwable.getMessage());
return null;
});
// Or synchronous shutdown
client.shutdownAndWait();The client internally manages:
The client proxy serves as the entry point to the Flink cluster, forwarding requests to the JobManager for location resolution and to TaskManagers for actual state queries.
Install with Tessl CLI
npx tessl i tessl/maven-org-apache-flink--flink-queryable-state-client-java