Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/remove mongo create collection non capped case #2164

Merged
merged 4 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- [cygnus-common][MongoBackendImpl] Remove unneded mongo create collection in non capped case (#2161)
- [cygnus-ngsi][MongoSink][STHSink] Do not attemp to database in each insertion (#2156, #2019 reopened)
- [cygnus-common][CKANBackendImpl] allow empty result as resource_view_list (#2150)
- [cygnus-ngsi] Upgrade Dockerfile base image from centos8.4.2105 to Debian 11.2-slim
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public MongoBackendImpl(String mongoHosts, String mongoUsername, String mongoPas
/**
* Creates a collection for STH Comet, given its name, if not exists in the given database. Time-based limits are set,
* if possible.
* Note that different from the homonym createCollection method in this class, this one doesn't do an explicit collection
* creation operation in the DB, given that the creation of the indexes will automatically create the collection
* @param dbName
* @param collectionName
* @param dataExpiration
Expand All @@ -96,18 +98,6 @@ public void createCollection(String dbName, String collectionName, long dataExpi
LOGGER.debug("Creating Mongo collection=" + collectionName + " at database=" + dbName);
MongoDatabase db = getDatabase(dbName);

// create the collection
try {
db.createCollection(collectionName);
} catch (MongoException e) {
ErrorCategory errorCategory = ErrorCategory.fromErrorCode( e.getCode() );
if (errorCategory == ErrorCategory.fromErrorCode(48)){
LOGGER.debug("Collection already exists, nothing to create");
} else {
throw e;
} // if else
} // try catch

// check STH indexes documentation at https://github.com/telefonicaid/fiware-sth-comet/blob/master/doc/manuals/db_indexes.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could add this to the JavaDoc of this method:

Note that different from the homonym createCollection method in this class, this one doesn't do an explicit collection creation operation in the DB, given that the creation of the indexes will automatically create the collection

as reminder for the future

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 09057b1

BasicDBObject keys;
IndexOptions options;
Expand Down