Joscorbe commented on code in PR #295:
URL: https://github.com/apache/jackrabbit-oak/pull/295#discussion_r959871713


##########
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/MongoConnection.java:
##########
@@ -142,41 +153,53 @@ public void close() {
      *
      * @return builder with default options set
      */
-    public static MongoClientOptions.Builder getDefaultBuilder() {
-        return new MongoClientOptions.Builder()
-                .description("MongoConnection for Oak DocumentMK")
-                .maxWaitTime(DEFAULT_MAX_WAIT_TIME)
-                .heartbeatFrequency(DEFAULT_HEARTBEAT_FREQUENCY_MS)
-                .threadsAllowedToBlockForConnectionMultiplier(100);
+    public static MongoClientSettings.Builder getDefaultBuilder() {
+        return MongoClientSettings.builder()
+                .applicationName("Oak DocumentMK")
+                .applyToConnectionPoolSettings(builder -> {
+                    builder.maxWaitTime(DEFAULT_MAX_WAIT_TIME, 
TimeUnit.MILLISECONDS);
+                })
+                .applyToServerSettings(builder -> {
+                    builder.heartbeatFrequency(DEFAULT_HEARTBEAT_FREQUENCY_MS, 
TimeUnit.MILLISECONDS);
+                })
+                .applyToClusterSettings(builder -> {
+                    builder.addClusterListener(new MongoClusterListener());
+                });
     }
 
-    public static String toString(MongoClientOptions opts) {
+    public static String toString(MongoClientSettings opts) {
         return Objects.toStringHelper(opts)
-                .add("connectionsPerHost", opts.getConnectionsPerHost())
-                .add("connectTimeout", opts.getConnectTimeout())
-                .add("socketTimeout", opts.getSocketTimeout())
-                .add("socketKeepAlive", opts.isSocketKeepAlive())
-                .add("maxWaitTime", opts.getMaxWaitTime())
-                .add("heartbeatFrequency", opts.getHeartbeatFrequency())
-                .add("threadsAllowedToBlockForConnectionMultiplier",
-                        opts.getThreadsAllowedToBlockForConnectionMultiplier())
+                .add("connectionsPerHost", 
opts.getConnectionPoolSettings().getMaxSize())
+                .add("connectTimeout", 
opts.getSocketSettings().getConnectTimeout(TimeUnit.MILLISECONDS))
+                .add("socketTimeout", 
opts.getSocketSettings().getReadTimeout(TimeUnit.MILLISECONDS))
+                .add("maxWaitTime", 
opts.getConnectionPoolSettings().getMaxWaitTime(TimeUnit.MILLISECONDS))
+                .add("heartbeatFrequency", 
opts.getServerSettings().getHeartbeatFrequency(TimeUnit.MILLISECONDS))
                 .add("readPreference", opts.getReadPreference().getName())
                 .add("writeConcern", opts.getWriteConcern())
                 .toString();
     }
 
+    public static String toString(ConnectionString connectionString) {
+        return Objects.toStringHelper(connectionString)
+                .add("connectionsPerHost", connectionString.getMaxConnecting())
+                .add("connectTimeout", connectionString.getConnectTimeout())
+                .add("socketTimeout", connectionString.getSocketTimeout())
+                .add("maxWaitTime", connectionString.getMaxWaitTime())
+                .add("heartbeatFrequency", 
connectionString.getHeartbeatFrequency())
+                .add("readPreference", connectionString.getReadPreference())
+                .add("writeConcern", connectionString.getWriteConcern())
+                .toString();
+    }
+
     /**
      * Returns {@code true} if the given {@code uri} has a write concern set.
      * @param uri the URI to check.
      * @return {@code true} if the URI has a write concern set, {@code false}
      *      otherwise.
      */
     public static boolean hasWriteConcern(@NotNull String uri) {
-        MongoClientOptions.Builder builder = MongoClientOptions.builder();
-        builder.writeConcern(WC_UNKNOWN);
-        WriteConcern wc = new MongoClientURI(checkNotNull(uri), builder)
-                .getOptions().getWriteConcern();
-        return !WC_UNKNOWN.equals(wc);
+        WriteConcern wc = new 
ConnectionString(checkNotNull(uri)).getWriteConcern();
+        return wc != null && !WC_UNKNOWN.equals(wc);

Review Comment:
   WriteConcern can be null now



##########
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/MongoConnection.java:
##########
@@ -186,9 +209,8 @@ public static boolean hasWriteConcern(@NotNull String uri) {
      *      otherwise.
      */
     public static boolean hasReadConcern(@NotNull String uri) {
-        ReadConcern rc = new MongoClientURI(checkNotNull(uri))
-                .getOptions().getReadConcern();
-        return readConcernLevel(rc) != null;
+        ReadConcern rc = new 
ConnectionString(checkNotNull(uri)).getReadConcern();
+        return rc != null && readConcernLevel(rc) != null;

Review Comment:
   ReadConcern can be null now



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to