Skip to content

Commit

Permalink
[CDCSDK] [#9019] CDC SDK Client API and Java Console Subscriber
Browse files Browse the repository at this point in the history
Summary:

Github Master Ticket: #9019
Design DocumentL https://docs.google.com/document/d/1_xZqU5UgzCu1W--kci3ajU7_iYXXHMQvudmybDI-Xsk/edit
Functional Spec: https://docs.google.com/document/u/2/d/1nHuzHQ-qYVPbKi2dqo_drzSXMq00h7w5oi0JDf0GD1U/edit#heading=h.jmqfs7jgvvg8

This is the client-side change that exposes some APIs to be consumed by CDC consumers. Currently, these APIs are not public and are to be consumed by our Debezium connector. For testing purposes, we have written a console subscriber for testing purposes.

Test Plan:
Unit tests in java for APIs and CDC behavior.
We have done some long-running testing with applications.
We have also run the YB-sample apps and enabled CDC on the table. Verified that all the events are received.

Reviewers: nicolas, bogdan, ybase, ashetkar, nkumar, nikhil, rahuldesirazu

Reviewed By: rahuldesirazu

Subscribers: vkushwaha, srangavajjula

Differential Revision: https://phabricator.dev.yugabyte.com/D13836
  • Loading branch information
suranjan committed Mar 4, 2022
1 parent 67c4c92 commit d294abf
Show file tree
Hide file tree
Showing 84 changed files with 8,454 additions and 498 deletions.
46 changes: 43 additions & 3 deletions java/yb-cdc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>2.8.1</version>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<version>1.10.2</version>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.yb</groupId>
Expand Down Expand Up @@ -69,10 +70,12 @@
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand All @@ -83,6 +86,33 @@
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.23</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.5</version>
</dependency>
<!-- dependency for YCQL driver -->
<dependency>
<groupId>com.yugabyte</groupId>
<artifactId>java-driver-core</artifactId>
<version>4.6.0-yb-6</version>
</dependency>
<!-- dependency for smart jdbc driver yugabyte -->
<dependency>
<groupId>com.yugabyte</groupId>
<artifactId>jdbc-yugabytedb</artifactId>
<version>42.3.0-beta.1</version>
</dependency>
<dependency>
<groupId>${junit.groupId}</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -114,6 +144,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>copy-dependencies</id>
Expand All @@ -134,13 +165,14 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<finalName>yb-cdc-connector</finalName>
<appendAssemblyId>false</appendAssemblyId>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>org.yb.cdc.Main</mainClass>
<mainClass>org.yb.cdc.CDCConsoleSubscriber</mainClass>
</manifest>
</archive>
<descriptorRefs>
Expand All @@ -166,6 +198,14 @@
<preparationGoals>clean verify</preparationGoals>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
</plugins>
</build>
</project>
58 changes: 58 additions & 0 deletions java/yb-cdc/src/main/java/org/yb/cdc/CDCConsoleSubscriber.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright (c) YugaByte, Inc.
//
// 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 org.yb.cdc;

import org.apache.log4j.*;

public class CDCConsoleSubscriber {
private static final Logger LOG = Logger.getLogger(CDCConsoleSubscriber.class);

private ConcurrentLogConnector connector;

public CDCConsoleSubscriber(CmdLineOpts cmdLineOpts, OutputClient opClient) throws Exception {
connector = new ConcurrentLogConnector(cmdLineOpts, opClient);
}

public void run() {
try {
connector.run();
} catch (Exception e) {
e.printStackTrace();
LOG.error("Application ran into an error: ", e);
System.exit(0);
}
}

public void close() {
try {
connector.close();
} catch (Exception e) {
System.exit(0);
}
}

public static void main(String[] args) throws Exception {
LOG.info("Starting CDC Console Connector...");

CmdLineOpts configuration = CmdLineOpts.createFromArgs(args);
try {
CDCConsoleSubscriber subscriber = new CDCConsoleSubscriber(configuration, new LogClient());
subscriber.run();
}
catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
}
Loading

0 comments on commit d294abf

Please sign in to comment.