From 1a00be1aad23c990375e53cd58187e784b95c37a Mon Sep 17 00:00:00 2001 From: "jianghang.loujh" Date: Wed, 11 Sep 2024 15:38:20 +0800 Subject: [PATCH] fixed format --- .../resources/example/instance.properties | 12 ++++--- .../parse/driver/mysql/MysqlConnector.java | 3 +- .../mysql/socket/BioSocketChannelPool.java | 6 ++-- .../mysql/socket/SocketChannelPool.java | 3 +- .../parse/inbound/mysql/ddl/DdlResult.java | 7 ++-- .../inbound/mysql/ddl/DruidDdlParser.java | 29 +++------------- .../inbound/mysql/tsdb/MemoryTableMeta.java | 33 +++++++------------ 7 files changed, 30 insertions(+), 63 deletions(-) diff --git a/deployer/src/main/resources/example/instance.properties b/deployer/src/main/resources/example/instance.properties index 74f637bf55..b602970a31 100644 --- a/deployer/src/main/resources/example/instance.properties +++ b/deployer/src/main/resources/example/instance.properties @@ -5,6 +5,11 @@ # enable gtid use true/false canal.instance.gtidon=false +# rds oss binlog +canal.instance.rds.accesskey= +canal.instance.rds.secretkey= +canal.instance.rds.instanceId= + # position info canal.instance.master.address=127.0.0.1:3306 canal.instance.master.journal.name= @@ -13,6 +18,8 @@ canal.instance.master.timestamp= canal.instance.master.gtid= # ssl +#canal.instance.master.sslMode=DISABLED +#canal.instance.master.tlsVersions= #canal.instance.master.trustCertificateKeyStoreType= #canal.instance.master.trustCertificateKeyStoreUrl= #canal.instance.master.trustCertificateKeyStorePassword= @@ -20,11 +27,6 @@ canal.instance.master.gtid= #canal.instance.master.clientCertificateKeyStoreUrl= #canal.instance.master.clientCertificateKeyStorePassword= -# rds oss binlog -canal.instance.rds.accesskey= -canal.instance.rds.secretkey= -canal.instance.rds.instanceId= - # table meta tsdb info canal.instance.tsdb.enable=true #canal.instance.tsdb.url=jdbc:mysql://127.0.0.1:3306/canal_tsdb diff --git a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/MysqlConnector.java b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/MysqlConnector.java index f505f6a007..c6aeb6f262 100644 --- a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/MysqlConnector.java +++ b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/MysqlConnector.java @@ -107,8 +107,7 @@ private void printSslStatus() { sslVersion, sslCipher); } catch (Exception e) { - logger.info("Can't show SSL status, server may not standard MySQL server: {}", e.toString()); - logger.debug("show SSL status exception", e); + logger.warn("Can't show SSL status, server may not standard MySQL server", e); } } diff --git a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/BioSocketChannelPool.java b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/BioSocketChannelPool.java index f3a65cae5f..40c087d49a 100644 --- a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/BioSocketChannelPool.java +++ b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/BioSocketChannelPool.java @@ -147,8 +147,7 @@ private static SSLContext getSSLContext(String clientCertificateKeyStoreUrl, Str ksIS.close(); } catch (IOException e) { // can't close input stream, but keystore can be properly initialized so we - // shouldn't throw - // this exception + // shouldn't throw this exception } } } @@ -194,8 +193,7 @@ private static SSLContext getSSLContext(String clientCertificateKeyStoreUrl, Str trustStoreIS.close(); } catch (IOException e) { // can't close input stream, but keystore can be properly initialized so we - // shouldn't throw this - // exception + // shouldn't throw this exception } } } diff --git a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/SocketChannelPool.java b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/SocketChannelPool.java index c2eaa11824..4d7dbde23b 100644 --- a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/SocketChannelPool.java +++ b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/SocketChannelPool.java @@ -29,10 +29,9 @@ public static SocketChannel open(SocketAddress address) throws Exception { public static SocketChannel connectSsl(SocketChannel channel, SslInfo sslInfo) throws IOException { SslMode sslMode = sslInfo.getSslMode(); - String type = chooseSocketChannel(); if ("netty".equalsIgnoreCase(type)) { - throw new UnsupportedOperationException("canal.socketChannel netty not support ssl mode: " + sslMode); + throw new UnsupportedOperationException("canal socketChannel netty not support ssl mode: " + sslMode); } else { SocketAddress remoteSocketAddress = channel.getRemoteSocketAddress(); try { diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/ddl/DdlResult.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/ddl/DdlResult.java index 889b359adf..4e771b0f5d 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/ddl/DdlResult.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/ddl/DdlResult.java @@ -10,8 +10,8 @@ public class DdlResult { private String schemaName; private String tableName; - private String oriSchemaName; // rename ddl中的源表 - private String oriTableName; // rename ddl中的目标表 + private String oriSchemaName; // rename ddl中的源表 + private String oriTableName; // rename ddl中的目标表 private EventType type; private DdlResult renameTableResult; // 多个rename table的存储 @@ -102,7 +102,8 @@ public String toString() { DdlResult ddlResult = this; StringBuilder sb = new StringBuilder(); do { - sb.append(String.format("DdlResult [schemaName=%s , tableName=%s , oriSchemaName=%s , oriTableName=%s , type=%s ];", + sb.append(String.format( + "DdlResult [schemaName=%s , tableName=%s , oriSchemaName=%s , oriTableName=%s , type=%s ];", ddlResult.schemaName, ddlResult.tableName, ddlResult.oriSchemaName, diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/ddl/DruidDdlParser.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/ddl/DruidDdlParser.java index ec0eae29cc..ddf39db26a 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/ddl/DruidDdlParser.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/ddl/DruidDdlParser.java @@ -4,39 +4,18 @@ import java.util.Arrays; import java.util.List; +import org.apache.commons.lang.StringUtils; + +import com.alibaba.otter.canal.protocol.CanalEntry.EventType; import com.alibaba.polardbx.druid.sql.SQLUtils; import com.alibaba.polardbx.druid.sql.ast.SQLExpr; import com.alibaba.polardbx.druid.sql.ast.SQLStatement; import com.alibaba.polardbx.druid.sql.ast.expr.SQLIdentifierExpr; import com.alibaba.polardbx.druid.sql.ast.expr.SQLPropertyExpr; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableAddConstraint; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableAddIndex; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableDropConstraint; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableDropIndex; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableDropKey; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableItem; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableRename; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableStatement; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLConstraint; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLCreateDatabaseStatement; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLCreateIndexStatement; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLCreateTableStatement; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLDeleteStatement; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLDropDatabaseStatement; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLDropIndexStatement; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLDropTableStatement; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLExprTableSource; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLInsertStatement; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLTableSource; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLTruncateStatement; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLUnique; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLUpdateStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.*; import com.alibaba.polardbx.druid.sql.dialect.mysql.ast.statement.MySqlRenameTableStatement; import com.alibaba.polardbx.druid.sql.parser.ParserException; import com.alibaba.polardbx.druid.util.JdbcConstants; -import org.apache.commons.lang.StringUtils; - -import com.alibaba.otter.canal.protocol.CanalEntry.EventType; /** * @author agapple 2017年7月27日 下午4:05:34 diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/MemoryTableMeta.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/MemoryTableMeta.java index c40f4a73f5..5617586f0d 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/MemoryTableMeta.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/MemoryTableMeta.java @@ -3,26 +3,22 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.alibaba.otter.canal.parse.inbound.TableMeta; +import com.alibaba.otter.canal.parse.inbound.TableMeta.FieldMeta; +import com.alibaba.otter.canal.parse.inbound.mysql.ddl.DruidDdlParser; +import com.alibaba.otter.canal.protocol.position.EntryPosition; import com.alibaba.polardbx.druid.DbType; import com.alibaba.polardbx.druid.sql.SQLUtils; import com.alibaba.polardbx.druid.sql.ast.SQLDataType; import com.alibaba.polardbx.druid.sql.ast.SQLDataTypeImpl; import com.alibaba.polardbx.druid.sql.ast.SQLExpr; import com.alibaba.polardbx.druid.sql.ast.SQLStatement; -import com.alibaba.polardbx.druid.sql.ast.expr.SQLCharExpr; -import com.alibaba.polardbx.druid.sql.ast.expr.SQLIdentifierExpr; -import com.alibaba.polardbx.druid.sql.ast.expr.SQLMethodInvokeExpr; -import com.alibaba.polardbx.druid.sql.ast.expr.SQLNullExpr; -import com.alibaba.polardbx.druid.sql.ast.expr.SQLPropertyExpr; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLColumnConstraint; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLColumnDefinition; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLColumnPrimaryKey; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLColumnUniqueKey; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLCreateTableStatement; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLNotNullConstraint; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLNullConstraint; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLSelectOrderByItem; -import com.alibaba.polardbx.druid.sql.ast.statement.SQLTableElement; +import com.alibaba.polardbx.druid.sql.ast.expr.*; +import com.alibaba.polardbx.druid.sql.ast.statement.*; import com.alibaba.polardbx.druid.sql.dialect.mysql.ast.MySqlPrimaryKey; import com.alibaba.polardbx.druid.sql.dialect.mysql.ast.MySqlUnique; import com.alibaba.polardbx.druid.sql.dialect.mysql.ast.expr.MySqlOrderingExpr; @@ -32,13 +28,6 @@ import com.alibaba.polardbx.druid.sql.visitor.SQLASTOutputVisitor; import com.alibaba.polardbx.druid.sql.visitor.VisitorFeature; import com.alibaba.polardbx.druid.util.JdbcConstants; -import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import com.alibaba.otter.canal.parse.inbound.TableMeta; -import com.alibaba.otter.canal.parse.inbound.TableMeta.FieldMeta; -import com.alibaba.otter.canal.parse.inbound.mysql.ddl.DruidDdlParser; -import com.alibaba.otter.canal.protocol.position.EntryPosition; /** * 基于DDL维护的内存表结构 @@ -50,7 +39,7 @@ public class MemoryTableMeta implements TableMetaTSDB { private Logger logger = LoggerFactory.getLogger(MemoryTableMeta.class); private Map, TableMeta> tableMetas = new ConcurrentHashMap<>(); - private SchemaRepository repository; + private SchemaRepository repository; public MemoryTableMeta(){ repository = new SchemaRepository(JdbcConstants.MYSQL);