Skip to content

Commit d294abf

Browse files
committed
[CDCSDK] [#9019] CDC SDK Client API and Java Console Subscriber
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
1 parent 67c4c92 commit d294abf

File tree

84 files changed

+8454
-498
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+8454
-498
lines changed

java/yb-cdc/pom.xml

+43-3
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,17 @@
2828
<dependency>
2929
<groupId>org.apache.kafka</groupId>
3030
<artifactId>kafka-clients</artifactId>
31-
<version>2.8.1</version>
31+
<version>2.3.0</version>
3232
</dependency>
3333
<dependency>
3434
<groupId>org.apache.avro</groupId>
3535
<artifactId>avro</artifactId>
36-
<version>1.10.2</version>
36+
<version>1.9.0</version>
3737
</dependency>
3838
<dependency>
3939
<groupId>commons-io</groupId>
4040
<artifactId>commons-io</artifactId>
41+
<version>2.5</version>
4142
</dependency>
4243
<dependency>
4344
<groupId>org.yb</groupId>
@@ -69,10 +70,12 @@
6970
<dependency>
7071
<groupId>commons-cli</groupId>
7172
<artifactId>commons-cli</artifactId>
73+
<version>1.2</version>
7274
</dependency>
7375
<dependency>
7476
<groupId>commons-codec</groupId>
7577
<artifactId>commons-codec</artifactId>
78+
<version>1.10</version>
7679
</dependency>
7780
<dependency>
7881
<groupId>org.apache.commons</groupId>
@@ -83,6 +86,33 @@
8386
<artifactId>gson</artifactId>
8487
<version>2.8.0</version>
8588
</dependency>
89+
<dependency>
90+
<groupId>org.postgresql</groupId>
91+
<artifactId>postgresql</artifactId>
92+
<version>42.2.23</version>
93+
</dependency>
94+
<dependency>
95+
<groupId>org.mybatis</groupId>
96+
<artifactId>mybatis</artifactId>
97+
<version>3.4.5</version>
98+
</dependency>
99+
<!-- dependency for YCQL driver -->
100+
<dependency>
101+
<groupId>com.yugabyte</groupId>
102+
<artifactId>java-driver-core</artifactId>
103+
<version>4.6.0-yb-6</version>
104+
</dependency>
105+
<!-- dependency for smart jdbc driver yugabyte -->
106+
<dependency>
107+
<groupId>com.yugabyte</groupId>
108+
<artifactId>jdbc-yugabytedb</artifactId>
109+
<version>42.3.0-beta.1</version>
110+
</dependency>
111+
<dependency>
112+
<groupId>${junit.groupId}</groupId>
113+
<artifactId>junit</artifactId>
114+
<scope>test</scope>
115+
</dependency>
86116
</dependencies>
87117

88118
<build>
@@ -114,6 +144,7 @@
114144
<plugin>
115145
<groupId>org.apache.maven.plugins</groupId>
116146
<artifactId>maven-dependency-plugin</artifactId>
147+
<version>3.2.0</version>
117148
<executions>
118149
<execution>
119150
<id>copy-dependencies</id>
@@ -134,13 +165,14 @@
134165
<plugin>
135166
<groupId>org.apache.maven.plugins</groupId>
136167
<artifactId>maven-assembly-plugin</artifactId>
168+
<version>3.3.0</version>
137169
<configuration>
138170
<finalName>yb-cdc-connector</finalName>
139171
<appendAssemblyId>false</appendAssemblyId>
140172
<archive>
141173
<manifest>
142174
<addClasspath>true</addClasspath>
143-
<mainClass>org.yb.cdc.Main</mainClass>
175+
<mainClass>org.yb.cdc.CDCConsoleSubscriber</mainClass>
144176
</manifest>
145177
</archive>
146178
<descriptorRefs>
@@ -166,6 +198,14 @@
166198
<preparationGoals>clean verify</preparationGoals>
167199
</configuration>
168200
</plugin>
201+
<plugin>
202+
<artifactId>maven-surefire-plugin</artifactId>
203+
<version>2.22.1</version>
204+
</plugin>
205+
<plugin>
206+
<artifactId>maven-jar-plugin</artifactId>
207+
<version>3.0.2</version>
208+
</plugin>
169209
</plugins>
170210
</build>
171211
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright (c) YugaByte, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4+
// in compliance with the License. You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software distributed under the License
9+
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10+
// or implied. See the License for the specific language governing permissions and limitations
11+
// under the License.
12+
//
13+
14+
package org.yb.cdc;
15+
16+
import org.apache.log4j.*;
17+
18+
public class CDCConsoleSubscriber {
19+
private static final Logger LOG = Logger.getLogger(CDCConsoleSubscriber.class);
20+
21+
private ConcurrentLogConnector connector;
22+
23+
public CDCConsoleSubscriber(CmdLineOpts cmdLineOpts, OutputClient opClient) throws Exception {
24+
connector = new ConcurrentLogConnector(cmdLineOpts, opClient);
25+
}
26+
27+
public void run() {
28+
try {
29+
connector.run();
30+
} catch (Exception e) {
31+
e.printStackTrace();
32+
LOG.error("Application ran into an error: ", e);
33+
System.exit(0);
34+
}
35+
}
36+
37+
public void close() {
38+
try {
39+
connector.close();
40+
} catch (Exception e) {
41+
System.exit(0);
42+
}
43+
}
44+
45+
public static void main(String[] args) throws Exception {
46+
LOG.info("Starting CDC Console Connector...");
47+
48+
CmdLineOpts configuration = CmdLineOpts.createFromArgs(args);
49+
try {
50+
CDCConsoleSubscriber subscriber = new CDCConsoleSubscriber(configuration, new LogClient());
51+
subscriber.run();
52+
}
53+
catch (Exception e) {
54+
e.printStackTrace();
55+
System.exit(1);
56+
}
57+
}
58+
}

0 commit comments

Comments
 (0)