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

Added support for reindexing of dataExpiration #2211

Merged
merged 6 commits into from
Feb 16, 2023

Conversation

Madhu1029
Copy link
Contributor

Fixes issue #2160
Now, we can change dataExpiration value in agent.conf file to get it reflected in database.

@Madhu1029
Copy link
Contributor Author

Hi @fgalan ,

If PR seems ok, please merge the PR.
Thanks

Comment on lines 127 to 128
} catch (Exception e) {
LOGGER.warn("Error in collection " + collectionName + " creating index ex=" + e.getMessage());
Copy link
Member

Choose a reason for hiding this comment

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

Should the try/catch be removed (given that createIndex() will deal with the exception internally)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 1458daf

Copy link
Member

Choose a reason for hiding this comment

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

It seems the try/catch block is still there... or maybe I'm missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, will remove try/catch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in b6045a0

Comment on lines 204 to 206
} catch (Exception e) {
LOGGER.warn("Error in collection " + collectionName + " creating index ex=" + e.getMessage());
} // try catch
Copy link
Member

Choose a reason for hiding this comment

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

Should the try/catch be removed (given that createIndex() will deal with the exception internally)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 1458daf

Copy link
Member

Choose a reason for hiding this comment

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

It seems the try/catch block is still there... or maybe I'm missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, will remove try/catch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in b6045a0

* @param options
* @throws Exception
*/
public void createIndex(MongoDatabase db, String collectionName, BasicDBObject keys,
Copy link
Member

Choose a reason for hiding this comment

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

Is throws MongoException correct?

Given you capture the exception with the try/catch block, I would say that createIndex() is not able to throw any Exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 1458daf

[cygnus-common][cygnus-twitter][cygnus-ngsi][cygnus-ngsi-ld] Upgrade log4j from v1 (1.2.17) to v2 (2.17.2) series (#1592)
[cygnus-ngsi] OracleSQL ngsi sink added (for OracleS 11g and 12c) (#2195)
[cygnus-ngsi] Removes "_" in schema name for DM -schema family (#2201)
[cygnus-common] Added support for reindexing of dataExpiration (#2160)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
[cygnus-common] Added support for reindexing of dataExpiration (#2160)
[cygnus-common] Added support for reindexing of dataExpiration (#2160, partially)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in ffafa96

@Madhu1029
Copy link
Contributor Author

Hi @fgalan ,

Thanks for your support.
I have updated all the 4 suggestions.

} catch (Exception e) {
LOGGER.warn("Error in collection " + collectionName + " creating index ex=" + e.getMessage());
} // try catch
try {
if (dataExpiration != 0) {
keys = new BasicDBObject().append("recvTime", 1);
options = new IndexOptions().name("cyg_raw_exp").expireAfter(dataExpiration, TimeUnit.SECONDS);
db.getCollection(collectionName).createIndex(keys, options);
createIndex(db, collectionName, keys, options);
Copy link
Member

Choose a reason for hiding this comment

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

Should the try/catch be removed (given that createIndex() will deal with the exception internally)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, will remove try/catch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in b6045a0

Copy link
Member

@fgalan fgalan left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants