0
# RPC Configuration
1
2
Configuration management for Pekko RPC services, providing comprehensive settings for timeouts, message sizes, serialization options, and debugging features.
3
4
## Capabilities
5
6
### PekkoRpcServiceConfiguration
7
8
Main configuration class that encapsulates all RPC service settings and provides factory methods for creating configurations from Flink configuration objects.
9
10
```java { .api }
11
/**
12
* Configuration for PekkoRpcService with settings for timeouts, message sizes, and debugging options.
13
*/
14
public class PekkoRpcServiceConfiguration {
15
16
/**
17
* Creates configuration from a Flink Configuration object.
18
* Extracts RPC-specific settings including timeouts, frame sizes, and debugging options.
19
*
20
* @param configuration Flink configuration object containing RPC settings
21
* @return PekkoRpcServiceConfiguration with settings extracted from configuration
22
*/
23
public static PekkoRpcServiceConfiguration fromConfiguration(Configuration configuration);
24
25
/**
26
* Creates default configuration with standard RPC settings.
27
* Uses default timeout values, frame sizes, and debugging options.
28
*
29
* @return PekkoRpcServiceConfiguration with default settings
30
*/
31
public static PekkoRpcServiceConfiguration defaultConfiguration();
32
33
/**
34
* Gets the underlying Flink configuration object.
35
*
36
* @return Configuration object containing all Flink settings
37
*/
38
public Configuration getConfiguration();
39
40
/**
41
* Gets the RPC ask timeout duration.
42
* This timeout applies to RPC calls that expect a response.
43
*
44
* @return Duration representing the ask timeout
45
*/
46
public Duration getTimeout();
47
48
/**
49
* Gets the maximum frame size for RPC messages.
50
* Messages larger than this size will be rejected.
51
*
52
* @return Maximum frame size in bytes
53
*/
54
public long getMaximumFramesize();
55
56
/**
57
* Checks if ask call stack capture is enabled.
58
* When enabled, provides better debugging information for RPC failures.
59
*
60
* @return true if ask call stack capture is enabled
61
*/
62
public boolean captureAskCallStack();
63
64
/**
65
* Checks if RPC invocation serialization is forced.
66
* When enabled, all RPC invocations are serialized even for local calls.
67
*
68
* @return true if RPC invocation serialization is forced
69
*/
70
public boolean isForceRpcInvocationSerialization();
71
}
72
```
73
74
**Usage Examples:**
75
76
```java
77
import org.apache.flink.configuration.Configuration;
78
import org.apache.flink.configuration.RpcOptions;
79
import org.apache.flink.runtime.rpc.pekko.PekkoRpcServiceConfiguration;
80
import java.time.Duration;
81
82
// Create configuration from Flink Configuration
83
Configuration flinkConfig = new Configuration();
84
flinkConfig.set(RpcOptions.ASK_TIMEOUT_DURATION, Duration.ofSeconds(30));
85
flinkConfig.set(RpcOptions.FRAMESIZE, "10MB");
86
flinkConfig.set(RpcOptions.CAPTURE_ASK_CALLSTACK, true);
87
88
PekkoRpcServiceConfiguration rpcConfig =
89
PekkoRpcServiceConfiguration.fromConfiguration(flinkConfig);
90
91
// Use default configuration for simple scenarios
92
PekkoRpcServiceConfiguration defaultConfig =
93
PekkoRpcServiceConfiguration.defaultConfiguration();
94
95
// Access configuration properties
96
Duration askTimeout = rpcConfig.getTimeout();
97
long maxFrameSize = rpcConfig.getMaximumFramesize();
98
boolean debugMode = rpcConfig.captureAskCallStack();
99
boolean forceSerialization = rpcConfig.isForceRpcInvocationSerialization();
100
101
// Log configuration details
102
System.out.println("RPC ask timeout: " + askTimeout);
103
System.out.println("Max frame size: " + maxFrameSize + " bytes");
104
System.out.println("Debug mode enabled: " + debugMode);
105
System.out.println("Force serialization: " + forceSerialization);
106
107
// Pass configuration to RPC service creation
108
// (This would typically be done internally by PekkoRpcServiceUtils)
109
```
110
111
### Configuration Options
112
113
The configuration system supports various RPC-related options from `RpcOptions`:
114
115
```java
116
// Timeout settings
117
RpcOptions.ASK_TIMEOUT_DURATION // Duration for RPC ask operations
118
RpcOptions.LOOKUP_TIMEOUT_DURATION // Duration for RPC endpoint lookups
119
120
// Message size limits
121
RpcOptions.FRAMESIZE // Maximum message frame size
122
123
// Debugging and development
124
RpcOptions.CAPTURE_ASK_CALLSTACK // Enable call stack capture for debugging
125
126
// Serialization behavior
127
RpcOptions.FORCE_RPC_INVOCATION_SERIALIZATION // Force serialization of all RPC calls
128
```
129
130
**Configuration Examples:**
131
132
```java
133
import org.apache.flink.configuration.Configuration;
134
import org.apache.flink.configuration.RpcOptions;
135
136
// Configure for production environment
137
Configuration prodConfig = new Configuration();
138
prodConfig.set(RpcOptions.ASK_TIMEOUT_DURATION, Duration.ofMinutes(5));
139
prodConfig.set(RpcOptions.FRAMESIZE, "50MB");
140
prodConfig.set(RpcOptions.CAPTURE_ASK_CALLSTACK, false); // Disable for performance
141
142
// Configure for development environment
143
Configuration devConfig = new Configuration();
144
devConfig.set(RpcOptions.ASK_TIMEOUT_DURATION, Duration.ofSeconds(10));
145
devConfig.set(RpcOptions.FRAMESIZE, "10MB");
146
devConfig.set(RpcOptions.CAPTURE_ASK_CALLSTACK, true); // Enable for debugging
147
devConfig.set(RpcOptions.FORCE_RPC_INVOCATION_SERIALIZATION, true); // Test serialization
148
149
// Configure for testing environment
150
Configuration testConfig = new Configuration();
151
testConfig.set(RpcOptions.ASK_TIMEOUT_DURATION, Duration.ofSeconds(1));
152
testConfig.set(RpcOptions.FRAMESIZE, "1MB");
153
testConfig.set(RpcOptions.CAPTURE_ASK_CALLSTACK, true);
154
```