8000 Feature/upgrade protobuf by sunxien · Pull Request #5460 · alibaba/canal · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Feature/upgrade protobuf #5460

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions client-adapter/clickhouse/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
2 changes: 2 additions & 0 deletions client-adapter/es6x/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
2 changes: 2 additions & 0 deletions client-adapter/es7x/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
2 changes: 2 additions & 0 deletions client-adapter/es8x/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
2 changes: 2 additions & 0 deletions client-adapter/hbase/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
2 changes: 2 additions & 0 deletions client-adapter/kudu/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
13 changes: 12 additions & 1 deletion client-adapter/launcher/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>

<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-shaded-client</artifactId>
Expand All @@ -79,6 +78,18 @@
<artifactId>clickhouse-jdbc</artifactId>
</dependency>

<!-- prometheus hotspot exporter -->
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_hotspot</artifactId>
<version>0.4.0</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_httpserver</artifactId>
<version>0.4.0</version>
</dependency>

<!-- outer adapter jar with dependencies-->
<dependency>
<groupId>com.alibaba.otter</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
@SpringBootApplication(exclude= { DataSourceAutoConfiguration.class})
public class CanalAdapterApplication {

public static void main(String[] args) {
// 支持rocketmq client 配置日志路径
System.setProperty("rocketmq.client.logUseSlf4j","true");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.alibaba.otter.canal.adapter.launcher.prometheus;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @author sunxien
* @date 2025/5/19
* @since 1.0.0-SNAPSHOT
*/
public class CanalAdapterExports {

private static final Logger logger = LoggerFactory.getLogger(CanalAdapterExports.class);

private CanalAdapterExports() {
}

private static class SingletonHolder {
private static final CanalAdapterExports SINGLETON = new CanalAdapterExports();
}

public static CanalAdapterExports instance() {
return SingletonHolder.SINGLETON;
}

public void initialize() {
// TODO
}

public void terminate() {
// TODO
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package com.alibaba.otter.canal.adapter.launcher.prometheus;

import io.prometheus.client.exporter.HTTPServer;
import io.prometheus.client.hotspot.DefaultExports;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
* @author sunxien
* @date 2025/5/19
* @since 1.0.0-SNAPSHOT
*/
@Component
public class PrometheusService implements InitializingBean, DisposableBean {

private static final Logger logger = LoggerFactory.getLogger(PrometheusService.class);

private final CanalAdapterExports adapterExports;
private volatile boolean running = false;
< 10000 /td>
/**
* <pre>
* Canal Server admin port: 11112
* Canal Server tcp port: 11111
* Canal Adapter metric port: 11113
* </pre>
*/
private int port = 11113;
private HTTPServer httpServer;

private PrometheusService() {
this.adapterExports = CanalAdapterExports.instance();
}

private static class SingletonHolder {
private static final PrometheusService SINGLETON = new PrometheusService();
}

public static PrometheusService getInstance() {
return SingletonHolder.SINGLETON;
}

@Override
public void afterPropertiesSet() throws Exception {
PrometheusService.getInstance().initialize();
}

@Override
public void destroy() throws Exception {
PrometheusService.getInstance().terminate();
}

public void initialize() {
try {
logger.info("Starting prometheus HTTPServer on port {}....", port);
// TODO 2.Https?
httpServer = new HTTPServer(port);
logger.info("Start prometheus HTTPServer on port {} success", port);
} catch (IOException e) {
logger.error("Unable to start prometheus HTTPServer on port {}.", port, e);
return;
}
try {
// JVM exports
DefaultExports.initialize();
// adapterExports.initialize();
this.running = true;
} catch (Throwable t) {
logger.error("Unable to initialize adapter exports. (Register the default Hotspot collectors)", t);
}
}

public void terminate() {
try {
this.running = false;
adapterExports.terminate();
if (httpServer != null) {
httpServer.stop();
logger.info("Stop prometheus HTTPServer on port {} success", port);
}
} catch (Throwable t) {
logger.error("Something happened while terminating prometheus HTTPServer.", t);
}
}

public boolean isRunning() {
return running;
}

public void setServerPort(int port) {
this.port = port;
}
}
2 changes: 2 additions & 0 deletions client-adapter/phoenix/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
2 changes: 2 additions & 0 deletions client-adapter/rdb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
2 changes: 2 additions & 0 deletions client-adapter/tablestore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public boolean equals(Object o) {

@Override
public String toString() {
return String.format("%s-%s-%s", domainId, serverId, sequence);
StringBuilder sb = new StringBuilder(16);
sb.append(domainId).append("-");
sb.append(serverId).append("-");
return sb.append(sequence).toString();
// return String.format("%s-%s-%s", domainId, serverId, sequence);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.regex.Pattern;

import com.alibaba.fastjson2.JSONWriter;
import com.alibaba.otter.canal.parse.driver.mysql.packets.server.FieldPacket;
import com.alibaba.polardbx.druid.sql.repository.Schema;
import org.apache.commons.beanutils.BeanUtils;
Expand Down Expand Up @@ -369,7 +371,7 @@ private boolean applySnapshotToDB(EntryPosition position, boolean init) {
snapshotDO.setBinlogOffest(position.getPosition());
snapshotDO.setBinlogMasterId(String.valueOf(position.getServerId()));
snapshotDO.setBinlogTimestamp(position.getTimestamp());
snapshotDO.setData(JSON.toJSONString(schemaDdls));
snapshotDO.setData(JSON.toJSONString(schemaDdls, JSONWriter.Feature.LargeObject));
try {
metaSnapshotDAO.insert(snapshotDO);
} catch (Throwable e) {
Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.6.1</version>
<!-- <version>3.6.1</version> -->
<version>4.31.0</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
Expand Down
Loading
0