code format & fine-tune

This commit is contained in:
jianghang.loujh
2024-10-14 16:44:59 +08:00
parent 2a7a507987
commit b391188baf
5 changed files with 21 additions and 25 deletions

View File

@@ -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=
@@ -12,7 +17,12 @@ canal.instance.master.position=
canal.instance.master.timestamp=
canal.instance.master.gtid=
# multi stream for polardbx
canal.instance.multi.stream.on=false
# ssl
#canal.instance.master.sslMode=DISABLED
#canal.instance.master.tlsVersions=
#canal.instance.master.trustCertificateKeyStoreType=
#canal.instance.master.trustCertificateKeyStoreUrl=
#canal.instance.master.trustCertificateKeyStorePassword=
@@ -20,11 +30,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
@@ -64,7 +69,4 @@ canal.mq.partition=0
#canal.mq.partitionsNum=3
#canal.mq.dynamicTopicPartitionNum=test.*:4,mycanal:6
#canal.mq.partitionHash=test.table:id^name,.*\\..*
#
# multi stream for polardbx
canal.instance.multi.stream.on=false
#################################################

View File

@@ -107,8 +107,7 @@ public class MysqlConnector {
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);
}
}

View File

@@ -147,8 +147,7 @@ public abstract class BioSocketChannelPool {
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 @@ public abstract class BioSocketChannelPool {
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
}
}
}

View File

@@ -29,10 +29,9 @@ public abstract class SocketChannelPool {
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 {

View File

@@ -46,8 +46,7 @@ import com.taobao.tddl.dbsync.binlog.LogEvent;
public class MysqlEventParser extends AbstractMysqlEventParser implements CanalEventParser, CanalHASwitchable {
private CanalHAController haController = null;
private int defaultConnectionTimeoutInSeconds = 30; // sotimeout
private int defaultConnectionTimeoutInSeconds = 30;
private int receiveBufferSize = 64 * 1024;
private int sendBufferSize = 64 * 1024;
// 数据库信息
@@ -69,10 +68,8 @@ public class MysqlEventParser extends AbstractMysqlEventParser implements CanalE
private int dumpErrorCount = 0; // binlogDump失败异常计数
private int dumpErrorCountThreshold = 2; // binlogDump失败异常计数阀值
private boolean rdsOssMode = false;
private boolean autoResetLatestPosMode = false; // true:
// binlog被删除之后,自动按最新的数据订阅
private boolean multiStreamEnable;//support for polardbx binlog-x
private boolean autoResetLatestPosMode = false; // binlog被删除之后,自动按最新的数据订阅
private boolean multiStreamEnable; // support for polardbx binlog-x
protected ErosaConnection buildErosaConnection() {
return buildMysqlConnection(this.runningInfo);
@@ -255,7 +252,6 @@ public class MysqlEventParser extends AbstractMysqlEventParser implements CanalE
reconnect = true;
logger.warn("connect failed by ", e);
}
}
public MysqlConnection getMysqlConnection() {
@@ -706,8 +702,10 @@ public class MysqlEventParser extends AbstractMysqlEventParser implements CanalE
*/
private EntryPosition findStartPosition(MysqlConnection mysqlConnection) {
try {
String showSql = multiStreamEnable ?
"show binlog events with " + destination + " limit 1" : "show binlog events limit 1";
String showSql = "show binlog events limit 1";
if (multiStreamEnable) {
showSql = "show binlog events with " + destination + " limit 1";
}
ResultSetPacket packet = mysqlConnection.query(showSql);
List<String> fields = packet.getFieldValues();
if (CollectionUtils.isEmpty(fields)) {