@@ -45,17 +45,21 @@ public class WorkerProxy {
4545 private static final String OPTION_SERVICE_KEY_FILE = "service_key_file" ;
4646 private static final String OPTION_USE_PLAIN_TEXT_CHANNEL = "use_plain_text_channel" ;
4747 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" ;
4850
4951 public static int spannerPort = 0 ;
5052 public static int proxyPort = 0 ;
5153 public static String cert = "" ;
5254 public static String serviceKeyFile = "" ;
55+ public static double multiplexedSessionOperationsRatio = 0.0 ;
5356 public static boolean usePlainTextChannel = false ;
5457 public static boolean enableGrpcFaultInjector = false ;
5558
5659 public static CommandLine commandLine ;
5760
5861 private static final int MIN_PORT = 0 , MAX_PORT = 65535 ;
62+ private static final double MIN_RATIO = 0.0 , MAX_RATIO = 1.0 ;
5963
6064 public static void main (String [] args ) throws Exception {
6165 commandLine = buildOptions (args );
@@ -95,10 +99,30 @@ public static void main(String[] args) throws Exception {
9599 usePlainTextChannel = commandLine .hasOption (OPTION_USE_PLAIN_TEXT_CHANNEL );
96100 enableGrpcFaultInjector = commandLine .hasOption (OPTION_ENABLE_GRPC_FAULT_INJECTOR );
97101
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+
98121 Server server ;
99122 while (true ) {
100123 try {
101- CloudExecutorImpl cloudExecutorImpl = new CloudExecutorImpl (enableGrpcFaultInjector );
124+ CloudExecutorImpl cloudExecutorImpl =
125+ new CloudExecutorImpl (enableGrpcFaultInjector , multiplexedSessionOperationsRatio );
102126 HealthStatusManager healthStatusManager = new HealthStatusManager ();
103127 // Set up Cloud server.
104128 server =
@@ -139,6 +163,11 @@ private static CommandLine buildOptions(String[] args) {
139163 OPTION_ENABLE_GRPC_FAULT_INJECTOR ,
140164 false ,
141165 "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." );
142171
143172 CommandLineParser parser = new DefaultParser ();
144173 try {
0 commit comments