or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

client-management.mdexception-handling.mdimmutable-state.mdindex.mdstate-querying.md

client-management.mddocs/

0

# Client Management

1

2

Core client functionality for connecting to Flink clusters, managing configuration, and handling client lifecycle operations.

3

4

## Capabilities

5

6

### Client Creation

7

8

Create a QueryableStateClient to connect to a Flink cluster's client proxy.

9

10

```java { .api }

11

public QueryableStateClient(String remoteHostname, int remotePort) throws UnknownHostException;

12

public QueryableStateClient(InetAddress remoteAddress, int remotePort);

13

```

14

15

**Parameters:**

16

- `remoteHostname` - Hostname of the client proxy to connect to (throws UnknownHostException if invalid)

17

- `remotePort` - Port of the client proxy (must be in range 0-65535)

18

- `remoteAddress` - InetAddress of the client proxy to connect to

19

20

**Usage Example:**

21

```java

22

// Connect using hostname

23

QueryableStateClient client = new QueryableStateClient("localhost", 9069);

24

25

// Connect using InetAddress

26

InetAddress address = InetAddress.getByName("192.168.1.100");

27

QueryableStateClient client = new QueryableStateClient(address, 9069);

28

```

29

30

### Configuration Management

31

32

Configure execution settings and classloader for serialization.

33

34

```java { .api }

35

public ExecutionConfig getExecutionConfig();

36

public ExecutionConfig setExecutionConfig(ExecutionConfig config);

37

public ClassLoader setUserClassLoader(ClassLoader userClassLoader);

38

```

39

40

**Returns:**

41

- `getExecutionConfig()` - Current ExecutionConfig or null if not set

42

- `setExecutionConfig()` - Previous ExecutionConfig or null if none was set

43

- `setUserClassLoader()` - Previous ClassLoader or null if none was set

44

45

**Usage Example:**

46

```java

47

QueryableStateClient client = new QueryableStateClient("localhost", 9069);

48

49

// Configure execution config

50

ExecutionConfig config = new ExecutionConfig();

51

config.enableObjectReuse(); // Example configuration

52

ExecutionConfig previous = client.setExecutionConfig(config);

53

54

// Set custom classloader for serialization

55

ClassLoader customClassLoader = Thread.currentThread().getContextClassLoader();

56

client.setUserClassLoader(customClassLoader);

57

```

58

59

### Lifecycle Management

60

61

Manage the client lifecycle with proper shutdown procedures.

62

63

```java { .api }

64

public CompletableFuture<?> shutdownAndHandle();

65

public void shutdownAndWait();

66

```

67

68

**Returns:**

69

- `shutdownAndHandle()` - CompletableFuture that completes when shutdown is finished

70

- `shutdownAndWait()` - void (blocks until shutdown completes)

71

72

**Behavior:**

73

- `shutdownAndHandle()` - Returns a future for asynchronous shutdown handling

74

- `shutdownAndWait()` - Blocks the calling thread until shutdown completes; logs warnings on exceptions

75

76

**Usage Example:**

77

```java

78

QueryableStateClient client = new QueryableStateClient("localhost", 9069);

79

80

// Perform queries...

81

82

// Asynchronous shutdown

83

client.shutdownAndHandle().thenRun(() -> {

84

System.out.println("Client shutdown completed");

85

}).exceptionally(throwable -> {

86

System.err.println("Shutdown failed: " + throwable.getMessage());

87

return null;

88

});

89

90

// Or synchronous shutdown

91

client.shutdownAndWait();

92

```

93

94

## Internal Components

95

96

The client internally manages:

97

- **Network Client**: Netty-based client for communication with the cluster

98

- **Message Serialization**: Handles KvStateRequest/KvStateResponse serialization

99

- **Statistics**: Optional request statistics tracking (disabled by default)

100

- **Remote Address**: Cached connection information for the client proxy

101

102

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.