-
Notifications
You must be signed in to change notification settings - Fork 594
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
feat(cdc): Add MongoDB CDC Source #14966
Changes from all commits
7399c7c
6a5bbb9
fd4aa01
3798597
d62252c
b4709b6
cc777ae
e4782a5
8e73db3
d170224
8433b84
6fab333
17af015
1fc3a52
ef7ca65
bcabf96
45398f9
5c7420f
5987352
a3f3f54
f53cf2a
3955ee2
71f6f9d
6ec7be3
89f1911
5388f6c
7ed6661
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2024 RisingWave Labs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.risingwave.connector.source.common; | ||
|
||
import com.mongodb.client.MongoClient; | ||
import com.mongodb.client.MongoClients; | ||
import java.util.Map; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class MongoDbValidator extends DatabaseValidator { | ||
private static final Logger LOG = LoggerFactory.getLogger(MongoDbValidator.class); | ||
|
||
String mongodbUrl; | ||
|
||
public MongoDbValidator(Map<String, String> userProps) { | ||
this.mongodbUrl = userProps.get("mongodb.url"); | ||
} | ||
|
||
@Override | ||
public void validateDbConfig() { | ||
// check connectivity | ||
try (MongoClient mongoClient = MongoClients.create(mongodbUrl)) { | ||
var desc = mongoClient.getClusterDescription(); | ||
LOG.info("test connectivity: MongoDB cluster description: {}", desc); | ||
} | ||
} | ||
|
||
@Override | ||
void validateUserPrivilege() { | ||
// TODO: check user privilege | ||
// https://debezium.io/documentation/reference/stable/connectors/mongodb.html#setting-up-mongodb | ||
// You must also have a MongoDB user that has the appropriate roles to read the admin | ||
// database where the oplog can be read. Additionally, the user must also be able to read | ||
// the config database in the configuration server of a sharded cluster and must have | ||
// listDatabases privilege action. When change streams are used (the default) the user also | ||
// must have cluster-wide privilege actions find and changeStream. | ||
} | ||
|
||
@Override | ||
void validateTable() { | ||
// do nothing since MongoDB is schemaless | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,12 +47,14 @@ public static CdcEngineRunner newCdcEngineRunner( | |
config.getResolvedDebeziumProps(), | ||
(success, message, error) -> { | ||
if (!success) { | ||
responseObserver.onError(error); | ||
LOG.error( | ||
"engine#{} terminated with error. message: {}", | ||
sourceId, | ||
message, | ||
error); | ||
if (error != null) { | ||
responseObserver.onError(error); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any motivation for this change? In what situation will it failed with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For defensive of nullptr and match the implementation of the following |
||
} else { | ||
LOG.info("engine#{} stopped normally. {}", sourceId, message); | ||
responseObserver.onCompleted(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# configs for postgres conneoctor | ||
connector.class=io.debezium.connector.mongodb.MongoDbConnector | ||
# default snapshot mode to initial | ||
snapshot.mode=${debezium.snapshot.mode:-initial} | ||
mongodb.connection.string=${mongodb.url} | ||
collection.include.list=${collection.name} | ||
# default heartbeat interval 5 mins | ||
heartbeat.interval.ms=${debezium.heartbeat.interval.ms:-300000} | ||
neverchanje marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# TODO: set this field in the code | ||
name=${collection.name} | ||
provide.transaction.metadata=${transactional:-false} | ||
# update event messages include the full document | ||
capture.mode=${debezium.capture.mode:-change_streams_update_full} | ||
# disable tombstones event | ||
tombstones.on.delete=${debezium.tombstones.on.delete:-false} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please also add some auth related options and try to test with a vendor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
username and password can be provided via the connection string (
mongodb.url
) if needed.