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

[mongodb] Plan2: Match multiple database and collection names using a regular expression in MongoDB. #940

Merged
merged 4 commits into from
Mar 15, 2022

Conversation

Jiabao-Sun
Copy link
Contributor

Match multiple database and collection names using a regular expression in MongoDB.
Support regex filter by databaseList and collectionList.

@Jiabao-Sun Jiabao-Sun force-pushed the mongodb-namespace-filter-plan2 branch 2 times, most recently from 7d7b93a to f9a9a84 Compare March 14, 2022 09:42
@Jiabao-Sun Jiabao-Sun force-pushed the mongodb-namespace-filter-plan2 branch from f9a9a84 to b6429e0 Compare March 14, 2022 10:38
@@ -226,4 +256,103 @@ private boolean isCopying() {
throw new IllegalStateException("Cannot access isCopying field of SourceTask", e);
}
}

private void init(Map<String, String> props) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private void init(Map<String, String> props) {
private void initCapturedCollections(MongoClient mongoClient, Map<String, String> props) {

and then we can put this method to CollectionDiscoveryUtils

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


/** match single database and multiple collections: collection = ^db0\.coll_b\d?$ . */
@Test
public void testMatchSingleDatabaseAndMultipleCollections() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public void testMatchSingleDatabaseAndMultipleCollections() throws Exception {
public void testMatchSingleQualifiedCollectionPattern() throws 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


/** match single database and multiple collections: database = db0 collection = .*coll_b\d? . */
@Test
public void testMatchSingleDatabaseAndMultipleCollections1() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public void testMatchSingleDatabaseAndMultipleCollections1() throws Exception {
public void testMatchSingleDatabaseWithCollectionPattern() throws 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

Comment on lines 321 to 337
### MongoDB Namespaces Filters

The config option `copy.existing.namespace.regex` is a regular expression that matches the namespaces from which to copy data.<br>

In the following example, matches namespaces `db0.coll0` and `db1.coll1` to snapshot.

```
'copy.existing.namespace.regex' = '^(db0\\.coll0|db1\\.coll1)$'
```

The config option `namespace.regex` is a regular expression that matches the namespaces from which to watch for changes.<br>

In the following example, matches namespaces `db0.coll0` and `db1.coll1` to watch.

```
'namespace.regex' = '^(db0\\.coll0|db1\\.coll1)$'
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need this document?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I missed it here.

@Jiabao-Sun Jiabao-Sun force-pushed the mongodb-namespace-filter-plan2 branch from 603f474 to c851129 Compare March 14, 2022 15:36
Copy link
Contributor

@leonardBang leonardBang left a comment

Choose a reason for hiding this comment

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

Thanks @Jiabao-Sun for the update, LGTM.
Please feel free to merge once the CI passed.

@Jiabao-Sun Jiabao-Sun merged commit 473e36b into apache:master Mar 15, 2022
@Jiabao-Sun
Copy link
Contributor Author

Thanks @leonardBang , @bobby-richard.
Merged into master.

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.

None yet

3 participants