From b8028db9534e5f7e195c263817accd2cc98cffe9 Mon Sep 17 00:00:00 2001 From: Kanthi Subramanian Date: Mon, 4 Mar 2024 10:08:14 -0500 Subject: [PATCH] Added logic to receive input from user and populate local configuration --- .../debezium/embedded/InteractiveMode.java | 103 ++++++++++++++++++ .../debezium/embedded/PopulateYaml.java | 7 ++ .../SinkConnectorInteractiveConfig.java | 61 +++++++++++ 3 files changed, 171 insertions(+) create mode 100644 sink-connector-lightweight/src/main/java/com/altinity/clickhouse/debezium/embedded/InteractiveMode.java create mode 100644 sink-connector-lightweight/src/main/java/com/altinity/clickhouse/debezium/embedded/PopulateYaml.java create mode 100644 sink-connector-lightweight/src/main/java/com/altinity/clickhouse/debezium/embedded/SinkConnectorInteractiveConfig.java diff --git a/sink-connector-lightweight/src/main/java/com/altinity/clickhouse/debezium/embedded/InteractiveMode.java b/sink-connector-lightweight/src/main/java/com/altinity/clickhouse/debezium/embedded/InteractiveMode.java new file mode 100644 index 000000000..a2b843ef9 --- /dev/null +++ b/sink-connector-lightweight/src/main/java/com/altinity/clickhouse/debezium/embedded/InteractiveMode.java @@ -0,0 +1,103 @@ +package com.altinity.clickhouse.debezium.embedded; + +import java.util.Scanner; + +public class InteractiveMode { + // Prompt to the user to enter if its MySQL or PostgreSQL + public static String getDatabaseType() { + System.out.println("Enter the database type (mysql/postgres): "); + return new Scanner(System.in).nextLine(); + } + // Prompt to the user to enter the MySQL database host + public static String getDatabaseHost() { + System.out.println("Enter the database host: "); + return new Scanner(System.in).nextLine(); + } + // Prompt to the user to enter the MySQL database port + public static String getDatabasePort() { + System.out.println("Enter the database port: "); + return new Scanner(System.in).nextLine(); + } + + // Prompt to the user to enter the MySQL database name + public static String getDatabaseName() { + System.out.println("Enter the database name: "); + return new Scanner(System.in).nextLine(); + } + // Prompt to the user to enter the MySQL database user + public static String getDatabaseUser() { + System.out.println("Enter the database user: "); + return new Scanner(System.in).nextLine(); + } + // Prompt to the user to enter the MySQL database password + public static String getDatabasePassword() { + System.out.println("Enter the database password: "); + return new Scanner(System.in).nextLine(); + } + // Prompt the user to enter the tables to be replicated + public static String getTables() { + System.out.println("Enter the tables to be replicated: "); + return new Scanner(System.in).nextLine(); + } + + //Prompt the user to check if replication should transfer all existing data + // or only the changes from the time of the replication start + public static String getInitialSync() { + System.out.println("Do you want to replicate all existing data? (yes/no): "); + return new Scanner(System.in).nextLine(); + } + + //Prompt the user to enter the ClickHouse host + public static String getClickHouseHost() { + System.out.println("Enter the ClickHouse host: "); + return new Scanner(System.in).nextLine(); + } + + //Prompt the user to enter the ClickHouse port + public static String getClickHousePort() { + System.out.println("Enter the ClickHouse port: "); + return new Scanner(System.in).nextLine(); + } + + //Prompt the user to enter the ClickHouse user + public static String getClickHouseUser() { + System.out.println("Enter the ClickHouse user: "); + return new Scanner(System.in).nextLine(); + } + + //Prompt the user to enter the ClickHouse password + public static String getClickHousePassword() { + System.out.println("Enter the ClickHouse password: "); + return new Scanner(System.in).nextLine(); + } + + //Prompt the user to enter the ClickHouse database + public static String getClickHouseDatabase() { + System.out.println("Enter the ClickHouse database: "); + return new Scanner(System.in).nextLine(); + } + + // Call all the scanner and populate the class + public static void populate() { + + // Create the new Config class. + // Change Config to SinkConnectorInteractiveConfig + SinkConnectorInteractiveConfig Config = new SinkConnectorInteractiveConfig(); + + Config.setDatabaseType(getDatabaseType()); + Config.setDatabaseHost(getDatabaseHost()); + Config.setDatabasePort(getDatabasePort()); + Config.setDatabaseName(getDatabaseName()); + Config.setDatabaseUser(getDatabaseUser()); + Config.setDatabasePassword(getDatabasePassword()); + Config.setTables(getTables()); + Config.setInitialSync(getInitialSync()); + Config.setClickHouseHost(getClickHouseHost()); + Config.setClickHousePort(getClickHousePort()); + Config.setClickHouseUser(getClickHouseUser()); + Config.setClickHousePassword(getClickHousePassword()); + Config.setClickHouseDatabase(getClickHouseDatabase()); + } + + +} diff --git a/sink-connector-lightweight/src/main/java/com/altinity/clickhouse/debezium/embedded/PopulateYaml.java b/sink-connector-lightweight/src/main/java/com/altinity/clickhouse/debezium/embedded/PopulateYaml.java new file mode 100644 index 000000000..4e6a08d10 --- /dev/null +++ b/sink-connector-lightweight/src/main/java/com/altinity/clickhouse/debezium/embedded/PopulateYaml.java @@ -0,0 +1,7 @@ +package com.altinity.clickhouse.debezium.embedded; + +public class PopulateYaml { + // Class that takes SinkConnectorInteractiveConfig and populates the yaml file + // using snake yaml + +} diff --git a/sink-connector-lightweight/src/main/java/com/altinity/clickhouse/debezium/embedded/SinkConnectorInteractiveConfig.java b/sink-connector-lightweight/src/main/java/com/altinity/clickhouse/debezium/embedded/SinkConnectorInteractiveConfig.java new file mode 100644 index 000000000..69209e73c --- /dev/null +++ b/sink-connector-lightweight/src/main/java/com/altinity/clickhouse/debezium/embedded/SinkConnectorInteractiveConfig.java @@ -0,0 +1,61 @@ +package com.altinity.clickhouse.debezium.embedded; + +import lombok.Getter; +import lombok.Setter; + +public class SinkConnectorInteractiveConfig { + // Store all the configuration from user + @Getter + @Setter + private String databaseType; + + @Getter + @Setter + private String databaseHost; + + @Getter + @Setter + private String databasePort; + + @Getter + @Setter + private String databaseName; + + @Getter + @Setter + private String databaseUser; + + @Getter + @Setter + private String databasePassword; + + @Getter + @Setter + private String tables; + + @Getter + @Setter + private String initialSync; + + @Getter + @Setter + private String clickHouseHost; + + @Getter + @Setter + private String clickHousePort; + + @Getter + @Setter + private String clickHouseUser; + + + @Getter + @Setter + private String clickHousePassword; + + @Getter + @Setter + private String clickHouseDatabase; + +}