mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
fixed code template and format
This commit is contained in:
@@ -14,15 +14,17 @@ import com.alibaba.otter.canal.common.utils.CanalToStringStyle;
|
||||
* </pre>
|
||||
*
|
||||
* <br>
|
||||
* The Packet Header will not be shown in the descriptions of packets that follow this section. Think of it as always
|
||||
* there. But logically, it "precedes the packet" rather than "is included in the packet".<br>
|
||||
* The Packet Header will not be shown in the descriptions of packets that
|
||||
* follow this section. Think of it as always there. But logically, it
|
||||
* "precedes the packet" rather than "is included in the packet".<br>
|
||||
*
|
||||
* @author fujohnwang
|
||||
*/
|
||||
public class HeaderPacket implements IPacket {
|
||||
|
||||
/**
|
||||
* this field indicates the packet length that follows the header, with header packet's 4 bytes excluded.
|
||||
* this field indicates the packet length that follows the header, with
|
||||
* header packet's 4 bytes excluded.
|
||||
*/
|
||||
private int packetBodyLength;
|
||||
private byte packetSequenceNumber;
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.io.IOException;
|
||||
* @see 1.0
|
||||
*/
|
||||
public interface IPacket {
|
||||
|
||||
/**
|
||||
* un-marshal raw bytes into {@link IPacket} state for application usage.<br>
|
||||
*
|
||||
|
||||
@@ -56,24 +56,24 @@ public class FieldPacket extends PacketWithHeaderPacket {
|
||||
this.name = reader.readLengthCodedString(data);
|
||||
this.originalName = reader.readLengthCodedString(data);
|
||||
index = reader.getIndex();
|
||||
//
|
||||
//
|
||||
index++;
|
||||
//
|
||||
//
|
||||
this.character = ByteHelper.readUnsignedShortLittleEndian(data, index);
|
||||
index += 2;
|
||||
//
|
||||
this.length = ByteHelper.readUnsignedIntLittleEndian(data, index);
|
||||
index += 4;
|
||||
//
|
||||
//
|
||||
this.type = data[index];
|
||||
index++;
|
||||
//
|
||||
//
|
||||
this.flags = ByteHelper.readUnsignedShortLittleEndian(data, index);
|
||||
index += 2;
|
||||
//
|
||||
//
|
||||
this.decimals = data[index];
|
||||
index++;
|
||||
//
|
||||
//
|
||||
if (index < data.length) {
|
||||
reader.setIndex(index);
|
||||
this.definition = reader.readLengthCodedString(data);
|
||||
|
||||
@@ -75,7 +75,8 @@ public class HandshakeInitializationPacket extends PacketWithHeaderPacket {
|
||||
// 8. bypass filtered bytes
|
||||
index += 13;
|
||||
// 9. read rest of scramble_buff
|
||||
this.restOfScrambleBuff = ByteHelper.readFixedLengthBytes(data, index, 12); // 虽然Handshake Initialization
|
||||
this.restOfScrambleBuff = ByteHelper.readFixedLengthBytes(data, index, 12); // 虽然Handshake
|
||||
// Initialization
|
||||
// Packet规定最后13个byte是剩下的scrumble,
|
||||
// 但实际上最后一个字节是0, 不应该包含在scrumble中.
|
||||
// end read
|
||||
|
||||
@@ -23,7 +23,7 @@ public abstract class ByteHelper {
|
||||
out.write(str.getBytes());
|
||||
out.write(MSC.NULL_TERMINATED_STRING_DELIMITER);
|
||||
}
|
||||
|
||||
|
||||
public static void writeNullTerminated(byte[] data, ByteArrayOutputStream out) throws IOException {
|
||||
out.write(data);
|
||||
out.write(MSC.NULL_TERMINATED_STRING_DELIMITER);
|
||||
|
||||
@@ -26,7 +26,7 @@ public class LengthCodedStringReader {
|
||||
|
||||
try {
|
||||
return new String(ArrayUtils.subarray(data, getIndex(), (int) (getIndex() + length)),
|
||||
encoding == null ? CODE_PAGE_1252 : encoding);
|
||||
encoding == null ? CODE_PAGE_1252 : encoding);
|
||||
} finally {
|
||||
setIndex((int) (getIndex() + length));
|
||||
}
|
||||
|
||||
@@ -30,8 +30,10 @@ public abstract class PacketManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Since We r using blocking IO, so we will just write once and assert the length to simplify the read operation.<br>
|
||||
* If the block write doesn't work as we expected, we will change this implementation as per the result.
|
||||
* Since We r using blocking IO, so we will just write once and assert the
|
||||
* length to simplify the read operation.<br>
|
||||
* If the block write doesn't work as we expected, we will change this
|
||||
* implementation as per the result.
|
||||
*
|
||||
* @param ch
|
||||
* @param len
|
||||
|
||||
Reference in New Issue
Block a user