使用netty重构socketChannel(jdk内置),修改了PacketManager实现,以及其他相关引用的类。

This commit is contained in:
luoyaogui
2017-01-03 14:18:58 +08:00
parent f6cf88a6bd
commit 5c11c71783
10 changed files with 221 additions and 66 deletions

View File

@@ -139,8 +139,8 @@ public class MysqlConnection implements ErosaConnection {
HeaderPacket binlogDumpHeader = new HeaderPacket();
binlogDumpHeader.setPacketBodyLength(cmdBody.length);
binlogDumpHeader.setPacketSequenceNumber((byte) 0x00);
PacketManager.write(connector.getChannel(), new ByteBuffer[] { ByteBuffer.wrap(binlogDumpHeader.toBytes()),
ByteBuffer.wrap(cmdBody) });
PacketManager.write(connector.getChannel(), binlogDumpHeader.toBytes(),
cmdBody);
connector.setDumping(true);
}

View File

@@ -5,11 +5,11 @@ import java.io.InterruptedIOException;
import java.net.SocketTimeoutException;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedByInterruptException;
import java.nio.channels.SocketChannel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.otter.canal.parse.driver.mysql.socket.SocketChannel;
import com.taobao.tddl.dbsync.binlog.LogFetcher;
/**
@@ -156,7 +156,7 @@ public class DirectLogFetcher extends LogFetcher {
throw new IOException("Unexpected End Stream");
}
}
// for (int count, n = 0; n < len; n += count) {
// if (0 > (count = input.read(buffer, off + n, len - n))) {
// // Reached end of input stream

View File

@@ -94,7 +94,6 @@ public class DirectLogFetcherTest {
HeaderPacket binlogDumpHeader = new HeaderPacket();
binlogDumpHeader.setPacketBodyLength(cmdBody.length);
binlogDumpHeader.setPacketSequenceNumber((byte) 0x00);
PacketManager.write(connector.getChannel(), new ByteBuffer[] { ByteBuffer.wrap(binlogDumpHeader.toBytes()),
ByteBuffer.wrap(cmdBody) });
PacketManager.write(connector.getChannel(), binlogDumpHeader.toBytes(),cmdBody);
}
}