@@ -45,17 +45,21 @@ public class WorkerProxy {
45
45
private static final String OPTION_SERVICE_KEY_FILE = "service_key_file" ;
46
46
private static final String OPTION_USE_PLAIN_TEXT_CHANNEL = "use_plain_text_channel" ;
47
47
private static final String OPTION_ENABLE_GRPC_FAULT_INJECTOR = "enable_grpc_fault_injector" ;
48
+ private static final String OPTION_MULTIPLEXED_SESSION_OPERATIONS_RATIO =
49
+ "multiplexed_session_operations_ratio" ;
48
50
49
51
public static int spannerPort = 0 ;
50
52
public static int proxyPort = 0 ;
51
53
public static String cert = "" ;
52
54
public static String serviceKeyFile = "" ;
55
+ public static double multiplexedSessionOperationsRatio = 0.0 ;
53
56
public static boolean usePlainTextChannel = false ;
54
57
public static boolean enableGrpcFaultInjector = false ;
55
58
56
59
public static CommandLine commandLine ;
57
60
58
61
private static final int MIN_PORT = 0 , MAX_PORT = 65535 ;
62
+ private static final double MIN_RATIO = 0.0 , MAX_RATIO = 1.0 ;
59
63
60
64
public static void main (String [] args ) throws Exception {
61
65
commandLine = buildOptions (args );
@@ -95,10 +99,30 @@ public static void main(String[] args) throws Exception {
95
99
usePlainTextChannel = commandLine .hasOption (OPTION_USE_PLAIN_TEXT_CHANNEL );
96
100
enableGrpcFaultInjector = commandLine .hasOption (OPTION_ENABLE_GRPC_FAULT_INJECTOR );
97
101
102
+ if (commandLine .hasOption (OPTION_MULTIPLEXED_SESSION_OPERATIONS_RATIO )) {
103
+ multiplexedSessionOperationsRatio =
104
+ Double .parseDouble (
105
+ commandLine .getOptionValue (OPTION_MULTIPLEXED_SESSION_OPERATIONS_RATIO ));
106
+ LOGGER .log (
107
+ Level .INFO ,
108
+ String .format (
109
+ "Multiplexed session ratio from commandline arg: \n %s" ,
110
+ multiplexedSessionOperationsRatio ));
111
+ if (multiplexedSessionOperationsRatio < MIN_RATIO
112
+ || multiplexedSessionOperationsRatio > MAX_RATIO ) {
113
+ throw new IllegalArgumentException (
114
+ "Spanner multiplexedSessionOperationsRatio must be between "
115
+ + MIN_RATIO
116
+ + " and "
117
+ + MAX_RATIO );
118
+ }
119
+ }
120
+
98
121
Server server ;
99
122
while (true ) {
100
123
try {
101
- CloudExecutorImpl cloudExecutorImpl = new CloudExecutorImpl (enableGrpcFaultInjector );
124
+ CloudExecutorImpl cloudExecutorImpl =
125
+ new CloudExecutorImpl (enableGrpcFaultInjector , multiplexedSessionOperationsRatio );
102
126
HealthStatusManager healthStatusManager = new HealthStatusManager ();
103
127
// Set up Cloud server.
104
128
server =
@@ -139,6 +163,11 @@ private static CommandLine buildOptions(String[] args) {
139
163
OPTION_ENABLE_GRPC_FAULT_INJECTOR ,
140
164
false ,
141
165
"Enable grpc fault injector in cloud client executor." );
166
+ options .addOption (
167
+ null ,
168
+ OPTION_MULTIPLEXED_SESSION_OPERATIONS_RATIO ,
169
+ true ,
170
+ "Ratio of operations to use multiplexed sessions." );
142
171
143
172
CommandLineParser parser = new DefaultParser ();
144
173
try {
0 commit comments