-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Hai Yan <[email protected]>
- Loading branch information
Showing
26 changed files
with
535 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...main/java/org/opensearch/dataprepper/plugins/source/rds/datatype/postgres/ColumnType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...source/src/main/java/org/opensearch/dataprepper/plugins/source/rds/model/MessageType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.source.rds.model; | ||
|
||
public enum MessageType { | ||
BEGIN('B'), | ||
RELATION('R'), | ||
INSERT('I'), | ||
UPDATE('U'), | ||
DELETE('D'), | ||
COMMIT('C'); | ||
|
||
private final char value; | ||
|
||
MessageType(char value) { | ||
this.value = value; | ||
} | ||
|
||
public char getValue() { | ||
return value; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...src/main/java/org/opensearch/dataprepper/plugins/source/rds/schema/ConnectionManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.source.rds.schema; | ||
|
||
import java.sql.Connection; | ||
import java.sql.SQLException; | ||
|
||
/** | ||
* Interface for managing connections to a database. | ||
*/ | ||
public interface ConnectionManager { | ||
|
||
Connection getConnection() throws SQLException; | ||
} |
50 changes: 50 additions & 0 deletions
50
...n/java/org/opensearch/dataprepper/plugins/source/rds/schema/ConnectionManagerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.source.rds.schema; | ||
|
||
import org.opensearch.dataprepper.plugins.source.rds.RdsSourceConfig; | ||
import org.opensearch.dataprepper.plugins.source.rds.configuration.EngineType; | ||
import org.opensearch.dataprepper.plugins.source.rds.model.DbMetadata; | ||
|
||
import java.util.List; | ||
|
||
public class ConnectionManagerFactory { | ||
private final RdsSourceConfig sourceConfig; | ||
private final DbMetadata dbMetadata; | ||
|
||
public ConnectionManagerFactory(final RdsSourceConfig sourceConfig, final DbMetadata dbMetadata) { | ||
this.sourceConfig = sourceConfig; | ||
this.dbMetadata = dbMetadata; | ||
} | ||
|
||
public ConnectionManager getConnectionManager() { | ||
if (sourceConfig.getEngine() == EngineType.MYSQL) { | ||
return new MySqlConnectionManager( | ||
dbMetadata.getEndpoint(), | ||
dbMetadata.getPort(), | ||
sourceConfig.getAuthenticationConfig().getUsername(), | ||
sourceConfig.getAuthenticationConfig().getPassword(), | ||
sourceConfig.isTlsEnabled()); | ||
} | ||
|
||
return new PostgresConnectionManager( | ||
dbMetadata.getEndpoint(), | ||
dbMetadata.getPort(), | ||
sourceConfig.getAuthenticationConfig().getUsername(), | ||
sourceConfig.getAuthenticationConfig().getPassword(), | ||
sourceConfig.isTlsEnabled(), | ||
getDatabaseName(sourceConfig.getTableNames())); | ||
} | ||
|
||
private String getDatabaseName(List<String> tableNames) { | ||
return tableNames.get(0).split("\\.")[0]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.