Skip to content
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

[ISSUE #436]BrokerBasedLog supports initialization of compaction topic #437

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
73bc139
fixed null pointer exception #294
sunxiaojian Aug 31, 2022
8fa5457
Merge branch 'master' of github.com:sunxiaojian/rocketmq-connect
sunxiaojian Aug 31, 2022
312d33c
Merge branch 'apache:master' into master
sunxiaojian Sep 1, 2022
3278370
Merge branch 'apache:master' into master
sunxiaojian Sep 8, 2022
6b3b798
Merge branch 'apache:master' into master
sunxiaojian Sep 10, 2022
39b8eae
Fix invalid offset submitted by sinktask #310
sunxiaojian Sep 10, 2022
0918f10
Merge branch 'apache:master' into master
sunxiaojian Sep 11, 2022
2b94a7a
Merge branch 'apache:master' into master
sunxiaojian Sep 13, 2022
63f815d
Merge branch 'apache:master' into master
sunxiaojian Sep 26, 2022
c137fab
pull update
sunxiaojian Oct 12, 2022
19ad60c
Merge branch 'apache:master' into master
sunxiaojian Nov 4, 2022
bfd8e62
Merge branch 'apache:master' into master
sunxiaojian Nov 17, 2022
faf0fba
Merge branch 'apache:master' into master
sunxiaojian Dec 19, 2022
f6b65d2
Merge branch 'apache:master' into master
sunxiaojian Dec 27, 2022
507770d
Merge branch 'apache:master' into master
sunxiaojian Dec 29, 2022
1336681
Merge branch 'apache:master' into master
sunxiaojian Jan 6, 2023
910b7da
Merge branch 'apache:master' into master
sunxiaojian Feb 13, 2023
ab0ad85
Merge branch 'apache:master' into master
sunxiaojian Feb 24, 2023
6ffc39e
Merge branch 'apache:master' into master
sunxiaojian Mar 2, 2023
47f0aac
Adding the COMPACTION attribute is supported when creating a topic in…
sunxiaojian Mar 2, 2023
80b4d74
Merge branch 'master' into fixed-create-compaction-topic
sunxiaojian Mar 7, 2023
cc040b2
fixed
sunxiaojian Mar 7, 2023
f697554
Merge branch 'fixed-create-compaction-topic' of github.com:sunxiaojia…
sunxiaojian Mar 7, 2023
1f5080b
upgrade rocketmq client version to 5.1.0
sunxiaojian Mar 7, 2023
01d16c8
extend rocketmq-connect-common
sunxiaojian Mar 8, 2023
da77b22
update README.md
sunxiaojian Mar 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ rocketmq-connect-sample的主要作用是从源文件中读取数据发送到Roc
2. 64bit JDK 1.8+;
3. Maven 3.2.x或以上版本;
4. 启动 [RocketMQ](https://rocketmq.apache.org/docs/quick-start/);
> 支持 RocketMQ [5.1.0] 版本
5. 创建测试Topic
> sh ${ROCKETMQ_HOME}/bin/mqadmin updateTopic -t fileTopic -n localhost:9876 -c DefaultCluster -r 8 -w 8

Expand Down
2 changes: 1 addition & 1 deletion connectors/rocketmq-connect-activemq/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-openmessaging</artifactId>
<version>4.3.2</version>
<version>4.9.4</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
Expand Down
4 changes: 2 additions & 2 deletions connectors/rocketmq-connect-cassandra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<!-- Compiler settings properties -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<rocketmq.version>4.5.2</rocketmq.version>
<rocketmq.version>4.9.4</rocketmq.version>
</properties>

<build>
Expand Down Expand Up @@ -245,7 +245,7 @@
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-openmessaging</artifactId>
<version>4.3.2</version>
<version>4.9.4</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
Expand Down
8 changes: 6 additions & 2 deletions connectors/rocketmq-connect-debezium/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@
<debezium.version>1.7.2.Final</debezium.version>
<debezium.postgresql.version>42.3.3</debezium.postgresql.version>
<!--rocketmq version-->
<rocketmq.version>4.7.1</rocketmq.version>
<rocketmq-openmessaging.version>4.3.2</rocketmq-openmessaging.version>
<rocketmq.version>5.1.0</rocketmq.version>

<!--rocketmq connect version-->
<openmessaging-connector.version>0.1.4</openmessaging-connector.version>
Expand Down Expand Up @@ -327,6 +326,11 @@
<artifactId>logback-core</artifactId>
<version>1.2.9</version>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-connect-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
*/
package org.apache.rocketmq.connect.debezium;

import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.acl.common.AclClientRPCHook;
import org.apache.rocketmq.acl.common.SessionCredentials;
Expand All @@ -24,28 +29,22 @@
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.TopicConfig;
import org.apache.rocketmq.common.admin.TopicOffset;
import org.apache.rocketmq.common.admin.TopicStatsTable;
import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.protocol.body.ClusterInfo;
import org.apache.rocketmq.common.protocol.body.SubscriptionGroupWrapper;
import org.apache.rocketmq.common.protocol.route.BrokerData;
import org.apache.rocketmq.common.protocol.route.TopicRouteData;
import org.apache.rocketmq.common.subscription.SubscriptionGroupConfig;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.remoting.exception.RemotingException;
import org.apache.rocketmq.remoting.protocol.LanguageCode;
import org.apache.rocketmq.remoting.protocol.ResponseCode;
import org.apache.rocketmq.remoting.protocol.admin.TopicOffset;
import org.apache.rocketmq.remoting.protocol.admin.TopicStatsTable;
import org.apache.rocketmq.remoting.protocol.body.ClusterInfo;
import org.apache.rocketmq.remoting.protocol.body.SubscriptionGroupWrapper;
import org.apache.rocketmq.remoting.protocol.route.BrokerData;
import org.apache.rocketmq.remoting.protocol.route.TopicRouteData;
import org.apache.rocketmq.remoting.protocol.subscription.SubscriptionGroupConfig;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.CommandUtil;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;

/**
* Tools for creating RocketMq topic and group
*/
Expand Down Expand Up @@ -130,7 +129,7 @@ public static void createTopic(RocketMqConfig config, TopicConfig topicConfig) {
try {
defaultMQAdminExt = startMQAdminTool(config);
ClusterInfo clusterInfo = defaultMQAdminExt.examineBrokerClusterInfo();
HashMap<String, Set<String>> clusterAddrTable = clusterInfo.getClusterAddrTable();
Map<String, Set<String>> clusterAddrTable = clusterInfo.getClusterAddrTable();
Set<String> clusterNameSet = clusterAddrTable.keySet();
for (String clusterName : clusterNameSet) {
Set<String> masterSet = CommandUtil.fetchMasterAddrByClusterName(defaultMQAdminExt, clusterName);
Expand Down Expand Up @@ -201,7 +200,7 @@ public static String createSubGroup(RocketMqConfig connectConfig, String subGrou
SubscriptionGroupConfig initConfig = new SubscriptionGroupConfig();
initConfig.setGroupName(subGroup);
ClusterInfo clusterInfo = defaultMQAdminExt.examineBrokerClusterInfo();
HashMap<String, Set<String>> clusterAddrTable = clusterInfo.getClusterAddrTable();
Map<String, Set<String>> clusterAddrTable = clusterInfo.getClusterAddrTable();
Set<String> clusterNameSet = clusterAddrTable.keySet();
for (String clusterName : clusterNameSet) {
Set<String> masterSet = CommandUtil.fetchMasterAddrByClusterName(defaultMQAdminExt, clusterName);
Expand Down Expand Up @@ -231,9 +230,9 @@ public static Map<MessageQueue, TopicOffset> offsets(RocketMqConfig config, Stri
DefaultMQAdminExt adminClient = null;
try {
adminClient = RocketMqAdminUtil.startMQAdminTool(config);
TopicStatsTable topicStatsTable = adminClient.examineTopicStats(topic);
TopicStatsTable topicStatsTable = examineTopicStats(adminClient,topic);
return topicStatsTable.getOffsetTable();
} catch (MQClientException | MQBrokerException | RemotingException | InterruptedException e) {
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
if (adminClient != null) {
Expand All @@ -242,4 +241,59 @@ public static Map<MessageQueue, TopicOffset> offsets(RocketMqConfig config, Stri
}
}

/**
* Compatible with 4.9.4 and earlier
*
* @param adminClient
* @param topic
* @return
*/
private static TopicStatsTable examineTopicStats(DefaultMQAdminExt adminClient, String topic) {
try {
return adminClient.examineTopicStats(topic);
} catch (MQBrokerException e) {
// Compatible with 4.9.4 and earlier
if (e.getResponseCode() == ResponseCode.REQUEST_CODE_NOT_SUPPORTED) {
try {
return overrideExamineTopicStats(adminClient, topic);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
} else {
throw new RuntimeException(e);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}

/**
* Compatible with version 4.9.4
*
* @param adminClient
* @param topic
* @return
* @throws RemotingException
* @throws InterruptedException
* @throws MQClientException
* @throws MQBrokerException
*/
private static TopicStatsTable overrideExamineTopicStats(DefaultMQAdminExt adminClient,
String topic) throws RemotingException, InterruptedException, MQClientException, MQBrokerException {
TopicRouteData topicRouteData = adminClient.examineTopicRouteInfo(topic);
TopicStatsTable topicStatsTable = new TopicStatsTable();
for (BrokerData bd : topicRouteData.getBrokerDatas()) {
String addr = bd.selectBrokerAddr();
if (addr != null) {
TopicStatsTable tst = adminClient
.getDefaultMQAdminExtImpl()
.getMqClientInstance()
.getMQClientAPIImpl()
.getTopicStatsInfo(addr, topic, 5000);
topicStatsTable.getOffsetTable().putAll(tst.getOffsetTable());
}
}
return topicStatsTable;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
import org.apache.rocketmq.client.producer.SendCallback;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.TopicConfig;
import org.apache.rocketmq.common.admin.TopicOffset;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.connect.kafka.connect.adaptor.task.AbstractKafkaConnectSource;
import org.apache.rocketmq.remoting.exception.RemotingException;
import org.apache.rocketmq.remoting.protocol.admin.TopicOffset;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
4 changes: 2 additions & 2 deletions connectors/rocketmq-connect-deltalake/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<!-- Compiler settings properties -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<rocketmq.version>4.5.2</rocketmq.version>
<rocketmq.version>4.9.4</rocketmq.version>
<avro.version>1.10.2</avro.version>
<parquet.version>1.10.1</parquet.version>
<scala.version>2.12</scala.version>
Expand Down Expand Up @@ -231,7 +231,7 @@
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-openmessaging</artifactId>
<version>4.3.2</version>
<version>4.9.4</version>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion connectors/rocketmq-connect-hudi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ http://${runtime-ip}:${runtime-port}/connectors/${rocketmq-hudi-connector-name}/
* **spark-submit 启动任务**
将connect-runtime打包后通过spark-submit提交任务
```
nohup sh spark-submit --class org.apache.rocketmq.connect.runtime.DistributedConnectStartup --conf "spark.driver.extraJavaOptions=-Dlogback.configurationFile=logback.xml" --files /xxx/conf/connect.conf,/xxx/conf/log4j.properties --packages org.apache.hudi:hudi-spark3-bundle_2.12:0.8.0,org.apache.spark:spark-avro_2.12:3.0.1,org.apache.hudi:hudi-java-client:0.8.0,org.apache.parquet:parquet-avro:1.10.1,org.apache.avro:avro:1.10.2,com.alibaba:fastjson:1.2.51,org.reflections:reflections:0.9.11,org.apache.httpcomponents:httpclient:4.5.5,io.openmessaging:openmessaging-connector:0.1.1,commons-cli:commons-cli:1.1,org.apache.rocketmq:rocketmq-client:4.4.0,org.apache.rocketmq:rocketmq-tools:4.4.0,org.apache.rocketmq:rocketmq-remoting:4.4.0,org.apache.rocketmq:rocketmq-openmessaging:4.3.2,org.slf4j:slf4j-api:1.7.7,com.google.guava:guava:20.0,org.apache.hadoop:hadoop-common:3.3.1,org.reflections:reflections:0.9.12,org.apache.hive:hive-exec:2.3.7 --conf 'spark.executor.userClassPathFirst=true' --conf 'spark.driver.userClassPathFirst=true' --conf 'spark.serializer=org.apache.spark.serializer.KryoSerializer' /xxx/rocketmq/rocketmq-connect-runtime-0.0.1-SNAPSHOT.jar &
nohup sh spark-submit --class org.apache.rocketmq.connect.runtime.DistributedConnectStartup --conf "spark.driver.extraJavaOptions=-Dlogback.configurationFile=logback.xml" --files /xxx/conf/connect.conf,/xxx/conf/log4j.properties --packages org.apache.hudi:hudi-spark3-bundle_2.12:0.8.0,org.apache.spark:spark-avro_2.12:3.0.1,org.apache.hudi:hudi-java-client:0.8.0,org.apache.parquet:parquet-avro:1.10.1,org.apache.avro:avro:1.10.2,com.alibaba:fastjson:1.2.51,org.reflections:reflections:0.9.11,org.apache.httpcomponents:httpclient:4.5.5,io.openmessaging:openmessaging-connector:0.1.1,commons-cli:commons-cli:1.1,org.apache.rocketmq:rocketmq-client:4.4.0,org.apache.rocketmq:rocketmq-tools:4.4.0,org.apache.rocketmq:rocketmq-remoting:4.4.0,org.apache.rocketmq:rocketmq-openmessaging:4.9.4,org.slf4j:slf4j-api:1.7.7,com.google.guava:guava:20.0,org.apache.hadoop:hadoop-common:3.3.1,org.reflections:reflections:0.9.12,org.apache.hive:hive-exec:2.3.7 --conf 'spark.executor.userClassPathFirst=true' --conf 'spark.driver.userClassPathFirst=true' --conf 'spark.serializer=org.apache.spark.serializer.KryoSerializer' /xxx/rocketmq/rocketmq-connect-runtime-0.0.1-SNAPSHOT.jar &
```
后续操作参考rocketmq-connect-hudi启动步骤

Expand Down
4 changes: 2 additions & 2 deletions connectors/rocketmq-connect-hudi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<!-- Compiler settings properties -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<rocketmq.version>4.7.1</rocketmq.version>
<rocketmq.version>4.9.4</rocketmq.version>

<hudi.version>0.8.0</hudi.version>
<avro.version>1.10.2</avro.version>
Expand Down Expand Up @@ -231,7 +231,7 @@
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-openmessaging</artifactId>
<version>4.3.2</version>
<version>4.9.4</version>
</dependency>
<dependency>
<groupId>org.apache.hudi</groupId>
Expand Down
2 changes: 1 addition & 1 deletion connectors/rocketmq-connect-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<!-- Compiler settings properties -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<rocketmq.version>4.7.1</rocketmq.version>
<rocketmq.version>4.9.4</rocketmq.version>

<!--test jar-->
<junit.version>4.13.1</junit.version>
Expand Down
2 changes: 1 addition & 1 deletion connectors/rocketmq-connect-jms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-openmessaging</artifactId>
<version>4.3.2</version>
<version>4.9.4</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
Expand Down
2 changes: 1 addition & 1 deletion connectors/rocketmq-connect-kafka/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-openmessaging</artifactId>
<version>4.3.2</version>
<version>4.9.4</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
Expand Down
2 changes: 1 addition & 1 deletion connectors/rocketmq-connect-mongo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-openmessaging</artifactId>
<version>5.1.0</version>
<version>4.9.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
2 changes: 1 addition & 1 deletion connectors/rocketmq-connect-mqtt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<!-- Compiler settings properties -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<rocketmq.version>4.7.1</rocketmq.version>
<rocketmq.version>4.9.4</rocketmq.version>
</properties>

<build>
Expand Down
2 changes: 1 addition & 1 deletion connectors/rocketmq-connect-rabbitmq/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-openmessaging</artifactId>
<version>4.3.2</version>
<version>4.9.4</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
Expand Down
2 changes: 1 addition & 1 deletion connectors/rocketmq-connect-redis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<!-- Compiler settings properties -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<rocketmq.version>4.5.2</rocketmq.version>
<rocketmq.version>4.9.4</rocketmq.version>
</properties>

<build>
Expand Down
2 changes: 1 addition & 1 deletion connectors/rocketmq-replicator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
</build>

<properties>
<rocketmq.version>4.7.1</rocketmq.version>
<rocketmq.version>4.9.4</rocketmq.version>
<openmessaging.connector.version>0.1.3</openmessaging.connector.version>
<junit.version>4.13.1</junit.version>
<mockito.version>3.2.4</mockito.version>
Expand Down
5 changes: 5 additions & 0 deletions metric-exporter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>

<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
Expand All @@ -37,6 +38,10 @@
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-tools</artifactId>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-connect-common</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Loading