Skip to content

Commit

Permalink
Merge pull request #21 from prdoyle/bump-mongo
Browse files Browse the repository at this point in the history
MongoDB v7 and Java client driver v5
  • Loading branch information
prdoyle authored Aug 19, 2024
2 parents 8896fbe + 1a151d9 commit 1e775e7
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 6 deletions.
4 changes: 3 additions & 1 deletion bosk-mongo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ compileTestJava {

dependencies {
api project(":bosk-core")
api 'org.mongodb:mongodb-driver-sync:4.1.2'
api 'org.mongodb:mongodb-driver-sync:5.1.2'
implementation 'com.github.spotbugs:spotbugs-annotations:4.8.6' // To stop warnings about When from MongoDB driver


// Allows us to annotate status objects so they're handy to serialize with jackson
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.17.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
import com.mongodb.client.DistinctIterable;
import com.mongodb.client.FindIterable;
import com.mongodb.client.ListIndexesIterable;
import com.mongodb.client.ListSearchIndexesIterable;
import com.mongodb.client.MapReduceIterable;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.model.BulkWriteOptions;
import com.mongodb.client.model.CountOptions;
import com.mongodb.client.model.CreateIndexOptions;
import com.mongodb.client.model.DeleteOptions;
import com.mongodb.client.model.DropCollectionOptions;
import com.mongodb.client.model.DropIndexOptions;
import com.mongodb.client.model.EstimatedDocumentCountOptions;
import com.mongodb.client.model.FindOneAndDeleteOptions;
Expand All @@ -32,6 +34,7 @@
import com.mongodb.client.model.InsertOneOptions;
import com.mongodb.client.model.RenameCollectionOptions;
import com.mongodb.client.model.ReplaceOptions;
import com.mongodb.client.model.SearchIndexModel;
import com.mongodb.client.model.UpdateOptions;
import com.mongodb.client.model.WriteModel;
import com.mongodb.client.result.DeleteResult;
Expand Down Expand Up @@ -377,18 +380,22 @@ public <TResult> ChangeStreamIterable<TResult> watch(ClientSession clientSession
return this.downstream.watch(clientSession, pipeline, resultClass);
}

@SuppressWarnings("deprecation")
public MapReduceIterable<TDocument> mapReduce(String mapFunction, String reduceFunction) {
return this.downstream.mapReduce(currentSession(), mapFunction, reduceFunction);
}

@SuppressWarnings("deprecation")
public <TResult> MapReduceIterable<TResult> mapReduce(String mapFunction, String reduceFunction, Class<TResult> resultClass) {
return this.downstream.mapReduce(currentSession(), mapFunction, reduceFunction, resultClass);
}

@SuppressWarnings("deprecation")
public MapReduceIterable<TDocument> mapReduce(ClientSession clientSession, String mapFunction, String reduceFunction) {
return this.downstream.mapReduce(clientSession, mapFunction, reduceFunction);
}

@SuppressWarnings("deprecation")
public <TResult> MapReduceIterable<TResult> mapReduce(ClientSession clientSession, String mapFunction, String reduceFunction, Class<TResult> resultClass) {
return this.downstream.mapReduce(clientSession, mapFunction, reduceFunction, resultClass);
}
Expand Down Expand Up @@ -625,6 +632,51 @@ public void drop(ClientSession clientSession) {
this.downstream.drop(clientSession);
}

@Override
public void drop(DropCollectionOptions dropCollectionOptions) {
this.downstream.drop(dropCollectionOptions);
}

@Override
public void drop(ClientSession clientSession, DropCollectionOptions dropCollectionOptions) {
this.downstream.drop(clientSession, dropCollectionOptions);
}

@Override
public String createSearchIndex(String indexName, Bson definition) {
return downstream.createSearchIndex(indexName, definition);
}

@Override
public String createSearchIndex(Bson definition) {
return downstream.createSearchIndex(definition);
}

@Override
public List<String> createSearchIndexes(List<SearchIndexModel> searchIndexModels) {
return downstream.createSearchIndexes(searchIndexModels);
}

@Override
public void updateSearchIndex(String indexName, Bson definition) {
downstream.updateSearchIndex(indexName, definition);
}

@Override
public void dropSearchIndex(String indexName) {
downstream.dropSearchIndex(indexName);
}

@Override
public ListSearchIndexesIterable<Document> listSearchIndexes() {
return downstream.listSearchIndexes();
}

@Override
public <TResult> ListSearchIndexesIterable<TResult> listSearchIndexes(Class<TResult> tResultClass) {
return downstream.listSearchIndexes(tResultClass);
}

public String createIndex(Bson keys) {
return this.downstream.createIndex(currentSession(), keys);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ static ChangeStreamDocument<BsonDocument> event(BsonDocument lsid, long txnNumbe
.append("coll", new BsonString("collection"))
.append("db", new BsonString("database"));
return new ChangeStreamDocument<>(
OperationType.OTHER,
OperationType.OTHER.getValue(),
new BsonDocument("_id", new BsonString("resumeToken")),
ns, ns,
null, null, null, null,
null, null, null, null, null,
new BsonInt64(txnNumber),
lsid
);
lsid,
null, null, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ public void close() {
}

private static GenericContainer<?> mongoContainer() {
// For some reason, creating a MongoDBContainer makes the Hanoi test WAY slower, like 100x
GenericContainer<?> result = new GenericContainer<>(
new ImageFromDockerfile().withDockerfileFromBuilder(builder -> builder
.from("mongo:4.4")
.from("mongo:7.0")
.run("echo \"rs.initiate()\" > /docker-entrypoint-initdb.d/rs-initiate.js")
.cmd("mongod", "--replSet", "rsLonesome", "--port", "27017", "--bind_ip_all")
.build()))
Expand Down

0 comments on commit 1e775e7

Please sign in to comment.