diff --git a/modules/dcache/pom.xml b/modules/dcache/pom.xml index 4ddcc4367d6..1e11d1a7aaa 100644 --- a/modules/dcache/pom.xml +++ b/modules/dcache/pom.xml @@ -326,7 +326,7 @@ org.mongodb - mongo-java-driver + mongodb-driver-sync diff --git a/modules/dcache/src/main/java/org/dcache/pool/repository/meta/mongo/MongoDbMetadataRepository.java b/modules/dcache/src/main/java/org/dcache/pool/repository/meta/mongo/MongoDbMetadataRepository.java index 424f0574b2f..75e414ae0ea 100644 --- a/modules/dcache/src/main/java/org/dcache/pool/repository/meta/mongo/MongoDbMetadataRepository.java +++ b/modules/dcache/src/main/java/org/dcache/pool/repository/meta/mongo/MongoDbMetadataRepository.java @@ -6,10 +6,11 @@ import static org.dcache.util.Exceptions.messageOrClassName; import com.google.common.base.Stopwatch; -import com.mongodb.MongoClient; -import com.mongodb.MongoClientOptions; -import com.mongodb.MongoClientURI; +import com.mongodb.ConnectionString; +import com.mongodb.MongoClientSettings; import com.mongodb.MongoException; +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoClients; import com.mongodb.client.MongoCollection; import com.mongodb.event.ServerClosedEvent; import com.mongodb.event.ServerDescriptionChangedEvent; @@ -130,14 +131,13 @@ public MongoDbMetadataRepository(FileStore fileStore, Path ignored, String poolN @Override public void init() throws CacheException { + MongoClientSettings settings = MongoClientSettings.builder() + .applicationName("dCache-" + Version.of(MongoDbMetadataRepository.class).getVersion()) + .applyToServerSettings(builder -> builder.addServerListener(this)) + .applyConnectionString(new ConnectionString(url)) + .build(); + mongo = MongoClients.create(settings); - MongoClientOptions.Builder optionBuilder = new MongoClientOptions.Builder() - .addServerListener(this) - .description(pool) - .applicationName( - "dCache-" + Version.of(MongoDbMetadataRepository.class).getVersion()); - - mongo = new MongoClient(new MongoClientURI(url, optionBuilder)); collection = mongo.getDatabase(dbName).getCollection(collectionName); } @@ -278,7 +278,7 @@ public long getTotalSpace() { @Override public String toString() { - return String.format("[data=%s;meta=%s]", fileStore, mongo.getConnectPoint()); + return String.format("[data=%s;meta=%s]", fileStore, url); } @Override diff --git a/pom.xml b/pom.xml index 0bab503e13c..add8cd1eb2d 100644 --- a/pom.xml +++ b/pom.xml @@ -851,8 +851,8 @@ org.mongodb - mongo-java-driver - 3.4.2 + mongodb-driver-sync + 4.11.1