mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
Merge branch 'master' into master
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>com.alibaba.otter</groupId>
|
||||
<artifactId>canal</artifactId>
|
||||
<version>1.0.24-SNAPSHOT</version>
|
||||
<version>1.0.25-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<groupId>com.alibaba.otter</groupId>
|
||||
|
||||
@@ -65,8 +65,10 @@ public class MysqlConnector {
|
||||
public void connect() throws IOException {
|
||||
if (connected.compareAndSet(false, true)) {
|
||||
try {
|
||||
channel = SocketChannelPool.open(address);
|
||||
channel = SocketChannel.open();
|
||||
configChannel(channel);
|
||||
logger.info("connect MysqlConnection to {}...", address);
|
||||
channel.connect(address);
|
||||
negotiate(channel);
|
||||
} catch (Exception e) {
|
||||
disconnect();
|
||||
|
||||
@@ -24,9 +24,9 @@ public class MysqlQueryExecutor {
|
||||
|
||||
private SocketChannel channel;
|
||||
|
||||
public MysqlQueryExecutor(MysqlConnector connector){
|
||||
public MysqlQueryExecutor(MysqlConnector connector) throws IOException{
|
||||
if (!connector.isConnected()) {
|
||||
throw new RuntimeException("should execute connector.connect() first");
|
||||
throw new IOException("should execute connector.connect() first");
|
||||
}
|
||||
|
||||
this.channel = connector.getChannel();
|
||||
@@ -88,7 +88,7 @@ public class MysqlQueryExecutor {
|
||||
for (RowDataPacket r : rowData) {
|
||||
resultSet.getFieldValues().addAll(r.getColumns());
|
||||
}
|
||||
resultSet.setSourceAddress(channel.getRemoteSocketAddress());
|
||||
resultSet.setSourceAddress(channel.socket().getRemoteSocketAddress());
|
||||
|
||||
return resultSet;
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ public class MysqlUpdateExecutor {
|
||||
|
||||
private MysqlConnector connector;
|
||||
|
||||
public MysqlUpdateExecutor(MysqlConnector connector){
|
||||
public MysqlUpdateExecutor(MysqlConnector connector) throws IOException{
|
||||
if (!connector.isConnected()) {
|
||||
throw new RuntimeException("should execute connector.connect() first");
|
||||
throw new IOException("should execute connector.connect() first");
|
||||
}
|
||||
|
||||
this.connector = connector;
|
||||
|
||||
@@ -74,7 +74,7 @@ public class FieldPacket extends PacketWithHeaderPacket {
|
||||
this.decimals = data[index];
|
||||
index++;
|
||||
//
|
||||
index += 2;//skip filter
|
||||
index += 2;// skip filter
|
||||
//
|
||||
if (index < data.length) {
|
||||
reader.setIndex(index);
|
||||
|
||||
@@ -9,9 +9,9 @@ import java.io.IOException;
|
||||
import java.net.SocketAddress;
|
||||
|
||||
/**
|
||||
* 封装netty的通信channel和数据接收缓存,实现读、写、连接校验的功能。 2016-12-28
|
||||
*
|
||||
* @author luoyaogui
|
||||
* 封装netty的通信channel和数据接收缓存,实现读、写、连接校验的功能。
|
||||
* 2016-12-28
|
||||
*/
|
||||
public class SocketChannel {
|
||||
private Channel channel = null;
|
||||
|
||||
@@ -20,12 +20,11 @@ import java.io.IOException;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author luoyaogui
|
||||
* 实现channel的管理(监听连接、读数据、回收)
|
||||
* 2016-12-28
|
||||
* @author luoyaogui 实现channel的管理(监听连接、读数据、回收) 2016-12-28
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@SuppressWarnings({ "rawtypes", "deprecation" })
|
||||
public abstract class SocketChannelPool {
|
||||
|
||||
private static EventLoopGroup group = new NioEventLoopGroup();//非阻塞IO线程组
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.alibaba.otter.canal.parse.driver.mysql.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.alibaba.otter.canal.parse.driver.mysql.packets.HeaderPacket;
|
||||
import com.alibaba.otter.canal.parse.driver.mysql.socket.SocketChannel;
|
||||
|
||||
public abstract class PacketManager {
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.alibaba.otter.canal.parse.driver.mysql.packets.server.ResultSetPacket;
|
||||
|
||||
Reference in New Issue
Block a user