@@ -52,7 +52,7 @@ public class MongoDBStack extends CoreStack {
5252 " \" w\" :\" majority\" ," + //
5353 " \" retryWrites\" :\" true\" ," + //
5454 " \" retryReads\" :\" true\" ," + //
55- " \" maxPoolSize\" :10 ," + //
55+ " \" maxPoolSize\" :20 ," + //
5656 " \" compressors\" :\" zstd\" " + //
5757 "}" ;
5858
@@ -134,9 +134,6 @@ public static String getFullConnectionURL_primary(GenericConvertMap<String, Obje
134134 + "is highly recommended for replica clusters to ensure read after write consistency." );
135135 }
136136
137- // In the future we may want to support opt_map
138- // GenericConvertMap<String,Object> optMap = config.getGenericConvertStringMap("opt_map", "{}");
139-
140137 // Lets build the auth str
141138 String authStr = "" ;
142139 if (user != null && pass != null ) {
@@ -180,10 +177,10 @@ public static String getFullConnectionURL_secondary(GenericConvertMap<String, Ob
180177 String host = config .getString ("host" , "localhost" );
181178 int port = config .getInt ("port" , 27017 );
182179
183- // Hanlding of option string
180+ // Hanlding of option string, default sec_opt uses `secondaryPreferred`
184181 GenericConvertMap <String , Object > optMap = new GenericConvertHashMap <>();
185182 optMap .putAll (config .getGenericConvertStringMap ("opt" , defaultOptJson ));
186- optMap .putAll (config .getGenericConvertStringMap ("sec_opt" , "{}" ));
183+ optMap .putAll (config .getGenericConvertStringMap ("sec_opt" , "{ \" readPreference \" : \" secondaryPreferred \" }" ));
187184
188185 // The opt string overwrite
189186 String optStr = config .getString ("sec_opt_str" , mapToOptStr (optMap ));
@@ -204,13 +201,10 @@ public static String getFullConnectionURL_secondary(GenericConvertMap<String, Ob
204201 LOGGER
205202 .warning ("MongoDB is configured without readConcernLevel for the secondary connection, "
206203 + "this is alright for a single node, but `readConcernLevel=linearizable`"
207- + "or `readPreference=master &readConcernLevel=majority`"
204+ + "or `readPreference=secondaryPreferred &readConcernLevel=majority`"
208205 + "is highly recommended for replica clusters to ensure read after write consistency." );
209206 }
210207
211- // In the future we may want to support opt_map
212- // GenericConvertMap<String,Object> optMap = config.getGenericConvertStringMap("opt_map", "{}");
213-
214208 // Lets build the auth str
215209 String authStr = "" ;
216210 if (user != null && pass != null ) {
0 commit comments