diff --git a/.gitignore b/.gitignore index 3f1a5d6b..90bd720f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ jtester.properties .idea/ *.iml .DS_Store +*.tar.gz +*.rpm diff --git a/README.md b/README.md index 456bd2db..86ef8755 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@
  1. canal QQ讨论群已经建立,群号:161559791 ,欢迎加入进行技术讨论。
  2. canal消费端项目开源: Otter(分布式数据库同步系统),地址:https://github.com/alibaba/otter
  3. +
  4. Canal已在阿里云推出商业化版本 数据传输服务DTS, 开通即用,免去部署维护的昂贵使用成本。DTS针对阿里云RDS、DRDS等产品进行了适配,解决了Binlog日志回收,主备切换、VPC网络切换等场景下的订阅高可用问题。同时,针对RDS进行了针对性的性能优化。出于稳定性、性能及成本的考虑,强烈推荐阿里云用户使用DTS产品。DTS产品使用文档
  5. +DTS支持阿里云RDS&DRDS的Binlog日志实时订阅,现推出首月免费体验,限时限量,立即体验>>>

背景

@@ -73,6 +75,14 @@ See the wiki page for : wiki文
  • 阿里巴巴去Oracle数据迁移同步工具(目标支持MySQL/DRDS):http://github.com/alibaba/yugong
  • +

    相关产品

    +
      +
    1. 阿里云分布式数据库DRDS
    2. +
    3. 阿里云数据传输服务DTS
    4. +
    5. 阿里云数据库备份服务DBS
    6. +
    7. 阿里云数据管理服务DMS
    8. +
    +

    问题反馈

    1. qq交流群: 161559791
    2. diff --git a/client/src/main/java/com/alibaba/otter/canal/client/CanalConnector.java b/client/src/main/java/com/alibaba/otter/canal/client/CanalConnector.java index 85177d98..8e52333d 100644 --- a/client/src/main/java/com/alibaba/otter/canal/client/CanalConnector.java +++ b/client/src/main/java/com/alibaba/otter/canal/client/CanalConnector.java @@ -152,6 +152,7 @@ public interface CanalConnector { /** * 中断的阻塞,用于优雅停止client + * * @throws CanalClientException */ void stopRunning() throws CanalClientException; diff --git a/client/src/main/java/com/alibaba/otter/canal/client/CanalConnectors.java b/client/src/main/java/com/alibaba/otter/canal/client/CanalConnectors.java index 391b21dc..c6fe83a0 100644 --- a/client/src/main/java/com/alibaba/otter/canal/client/CanalConnectors.java +++ b/client/src/main/java/com/alibaba/otter/canal/client/CanalConnectors.java @@ -29,7 +29,8 @@ public class CanalConnectors { public static CanalConnector newSingleConnector(SocketAddress address, String destination, String username, String password) { SimpleCanalConnector canalConnector = new SimpleCanalConnector(address, username, password, destination); - canalConnector.setSoTimeout(30 * 1000); + canalConnector.setSoTimeout(60 * 1000); + canalConnector.setIdleTimeout(60 * 60 * 1000); return canalConnector; } @@ -48,7 +49,8 @@ public class CanalConnectors { password, destination, new SimpleNodeAccessStrategy(addresses)); - canalConnector.setSoTimeout(30 * 1000); + canalConnector.setSoTimeout(60 * 1000); + canalConnector.setIdleTimeout(60 * 60 * 1000); return canalConnector; } @@ -67,7 +69,8 @@ public class CanalConnectors { password, destination, new ClusterNodeAccessStrategy(destination, ZkClientx.getZkClient(zkServers))); - canalConnector.setSoTimeout(30 * 1000); + canalConnector.setSoTimeout(60 * 1000); + canalConnector.setIdleTimeout(60 * 60 * 1000); return canalConnector; } } diff --git a/client/src/main/java/com/alibaba/otter/canal/client/impl/ClusterCanalConnector.java b/client/src/main/java/com/alibaba/otter/canal/client/impl/ClusterCanalConnector.java index 8446e948..7ec1781a 100644 --- a/client/src/main/java/com/alibaba/otter/canal/client/impl/ClusterCanalConnector.java +++ b/client/src/main/java/com/alibaba/otter/canal/client/impl/ClusterCanalConnector.java @@ -22,7 +22,8 @@ public class ClusterCanalConnector implements CanalConnector { private final Logger logger = LoggerFactory.getLogger(this.getClass()); private String username; private String password; - private int soTimeout = 10000; + private int soTimeout = 60000; + private int idleTimeout = 60 * 60 * 1000; private int retryTimes = 3; // 设置-1时可以subscribe阻塞等待时优雅停机 private int retryInterval = 5000; // 重试的时间间隔,默认5秒 private CanalNodeAccessStrategy accessStrategy; @@ -52,6 +53,7 @@ public class ClusterCanalConnector implements CanalConnector { }; currentConnector.setSoTimeout(soTimeout); + currentConnector.setIdleTimeout(idleTimeout); if (filter != null) { currentConnector.setFilter(filter); } @@ -110,10 +112,8 @@ public class ClusterCanalConnector implements CanalConnector { logger.info("block waiting interrupted by other thread."); return; } else { - logger.warn(String.format( - "something goes wrong when subscribing from server: %s", - currentConnector != null ? currentConnector.getAddress() : "null"), - t); + logger.warn(String.format("something goes wrong when subscribing from server: %s", + currentConnector != null ? currentConnector.getAddress() : "null"), t); times++; restart(); logger.info("restart the connector for next round retry."); @@ -184,7 +184,7 @@ public class ClusterCanalConnector implements CanalConnector { return msg; } catch (Throwable t) { logger.warn(String.format("something goes wrong when getWithoutAck data from server:%s", - currentConnector.getAddress()), t); + currentConnector != null ? currentConnector.getAddress() : "null"), t); times++; restart(); logger.info("restart the connector for next round retry."); @@ -201,7 +201,7 @@ public class ClusterCanalConnector implements CanalConnector { return msg; } catch (Throwable t) { logger.warn(String.format("something goes wrong when getWithoutAck data from server:%s", - currentConnector.getAddress()), t); + currentConnector != null ? currentConnector.getAddress() : "null"), t); times++; restart(); logger.info("restart the connector for next round retry."); @@ -218,7 +218,8 @@ public class ClusterCanalConnector implements CanalConnector { return; } catch (Throwable t) { logger.warn(String.format("something goes wrong when rollbacking data from server:%s", - currentConnector.getAddress()), t); + currentConnector != null ? currentConnector.getAddress() : "null"), + t); times++; restart(); logger.info("restart the connector for next round retry."); @@ -235,7 +236,8 @@ public class ClusterCanalConnector implements CanalConnector { return; } catch (Throwable t) { logger.warn(String.format("something goes wrong when rollbacking data from server:%s", - currentConnector.getAddress()), t); + currentConnector != null ? currentConnector.getAddress() : "null"), + t); times++; restart(); logger.info("restart the connector for next round retry."); @@ -253,7 +255,8 @@ public class ClusterCanalConnector implements CanalConnector { return; } catch (Throwable t) { logger.warn(String.format("something goes wrong when acking data from server:%s", - currentConnector.getAddress()), t); + currentConnector != null ? currentConnector.getAddress() : "null"), + t); times++; restart(); logger.info("restart the connector for next round retry."); @@ -300,6 +303,14 @@ public class ClusterCanalConnector implements CanalConnector { this.soTimeout = soTimeout; } + public int getIdleTimeout() { + return idleTimeout; + } + + public void setIdleTimeout(int idleTimeout) { + this.idleTimeout = idleTimeout; + } + public int getRetryTimes() { return retryTimes; } diff --git a/client/src/main/java/com/alibaba/otter/canal/client/impl/SimpleCanalConnector.java b/client/src/main/java/com/alibaba/otter/canal/client/impl/SimpleCanalConnector.java index 0b870c17..0f29794d 100644 --- a/client/src/main/java/com/alibaba/otter/canal/client/impl/SimpleCanalConnector.java +++ b/client/src/main/java/com/alibaba/otter/canal/client/impl/SimpleCanalConnector.java @@ -55,6 +55,7 @@ public class SimpleCanalConnector implements CanalConnector { private String username; private String password; private int soTimeout = 60000; // milliseconds + private int idleTimeout = 60 * 60 * 1000; // client和server之间的空闲链接超时的时间,默认为1小时 private String filter; // 记录上一次的filter提交值,便于自动重试时提交 private final ByteBuffer readHeader = ByteBuffer.allocate(4).order(ByteOrder.BIG_ENDIAN); @@ -70,23 +71,29 @@ public class SimpleCanalConnector implements CanalConnector { private volatile boolean connected = false; // 代表connected是否已正常执行,因为有HA,不代表在工作中 private boolean rollbackOnConnect = true; // 是否在connect链接成功后,自动执行rollback操作 private boolean rollbackOnDisConnect = false; // 是否在connect链接成功后,自动执行rollback操作 - + private boolean lazyParseEntry = false; // 是否自动化解析Entry对象,如果考虑最大化性能可以延后解析 // 读写数据分别使用不同的锁进行控制,减小锁粒度,读也需要排他锁,并发度容易造成数据包混乱,反序列化失败 private Object readDataLock = new Object(); private Object writeDataLock = new Object(); - private boolean running = false; + private volatile boolean running = false; public SimpleCanalConnector(SocketAddress address, String username, String password, String destination){ - this(address, username, password, destination, 60000); + this(address, username, password, destination, 60000, 60 * 60 * 1000); } public SimpleCanalConnector(SocketAddress address, String username, String password, String destination, int soTimeout){ + this(address, username, password, destination, soTimeout, 60 * 60 * 1000); + } + + public SimpleCanalConnector(SocketAddress address, String username, String password, String destination, + int soTimeout, int idleTimeout){ this.address = address; this.username = username; this.password = password; this.soTimeout = soTimeout; + this.idleTimeout = idleTimeout; this.clientIdentity = new ClientIdentity(destination, (short) 1001); } @@ -157,8 +164,8 @@ public class SimpleCanalConnector implements CanalConnector { ClientAuth ca = ClientAuth.newBuilder() .setUsername(username != null ? username : "") .setPassword(ByteString.copyFromUtf8(password != null ? password : "")) - .setNetReadTimeout(soTimeout) - .setNetWriteTimeout(soTimeout) + .setNetReadTimeout(idleTimeout) + .setNetWriteTimeout(idleTimeout) .build(); writeWithHeader(Packet.newBuilder() .setType(PacketType.CLIENTAUTHENTICATION) @@ -282,6 +289,9 @@ public class SimpleCanalConnector implements CanalConnector { public Message getWithoutAck(int batchSize, Long timeout, TimeUnit unit) throws CanalClientException { waitClientRunning(); + if (!running) { + return null; + } try { int size = (batchSize <= 0) ? 1000 : batchSize; long time = (timeout == null || timeout < 0) ? -1 : timeout; // -1代表不做timeout控制 @@ -309,7 +319,8 @@ public class SimpleCanalConnector implements CanalConnector { } private Message receiveMessages() throws IOException { - Packet p = Packet.parseFrom(readNextPacket()); + byte[] data = readNextPacket(); + Packet p = Packet.parseFrom(data); switch (p.getType()) { case MESSAGES: { if (!p.getCompression().equals(Compression.NONE)) { @@ -318,8 +329,13 @@ public class SimpleCanalConnector implements CanalConnector { Messages messages = Messages.parseFrom(p.getBody()); Message result = new Message(messages.getBatchId()); - for (ByteString byteString : messages.getMessagesList()) { - result.addEntry(Entry.parseFrom(byteString)); + if (lazyParseEntry) { + // byteString + result.setRawEntries(messages.getMessagesList()); + } else { + for (ByteString byteString : messages.getMessagesList()) { + result.addEntry(Entry.parseFrom(byteString)); + } } return result; } @@ -335,6 +351,9 @@ public class SimpleCanalConnector implements CanalConnector { public void ack(long batchId) throws CanalClientException { waitClientRunning(); + if (!running) { + return; + } ClientAck ca = ClientAck.newBuilder() .setDestination(clientIdentity.getDestination()) .setClientId(String.valueOf(clientIdentity.getClientId())) @@ -500,6 +519,14 @@ public class SimpleCanalConnector implements CanalConnector { this.soTimeout = soTimeout; } + public int getIdleTimeout() { + return idleTimeout; + } + + public void setIdleTimeout(int idleTimeout) { + this.idleTimeout = idleTimeout; + } + public void setZkClientx(ZkClientx zkClientx) { this.zkClientx = zkClientx; initClientRunningMonitor(this.clientIdentity); @@ -517,11 +544,19 @@ public class SimpleCanalConnector implements CanalConnector { this.filter = filter; } + public boolean isLazyParseEntry() { + return lazyParseEntry; + } + + public void setLazyParseEntry(boolean lazyParseEntry) { + this.lazyParseEntry = lazyParseEntry; + } + public void stopRunning() { if (running) { - running = false; //设置为非running状态 + running = false; // 设置为非running状态 if (!mutex.state()) { - mutex.set(true); //中断阻塞 + mutex.set(true); // 中断阻塞 } } } diff --git a/client/src/main/java/com/alibaba/otter/canal/client/impl/running/ClientRunningMonitor.java b/client/src/main/java/com/alibaba/otter/canal/client/impl/running/ClientRunningMonitor.java index 4c2a9f66..32202dc1 100644 --- a/client/src/main/java/com/alibaba/otter/canal/client/impl/running/ClientRunningMonitor.java +++ b/client/src/main/java/com/alibaba/otter/canal/client/impl/running/ClientRunningMonitor.java @@ -98,6 +98,10 @@ public class ClientRunningMonitor extends AbstractCanalLifeCycle { String path = ZookeeperPathUtils.getDestinationClientRunning(this.destination, clientData.getClientId()); zkClient.unsubscribeDataChanges(path, dataListener); releaseRunning(); // 尝试一下release + //Fix issue #697 + if (delayExector != null) { + delayExector.shutdown(); + } } // 改动记录: diff --git a/common/src/main/java/com/alibaba/otter/canal/common/utils/NamedThreadFactory.java b/common/src/main/java/com/alibaba/otter/canal/common/utils/NamedThreadFactory.java index 866664a1..eeb94c4a 100644 --- a/common/src/main/java/com/alibaba/otter/canal/common/utils/NamedThreadFactory.java +++ b/common/src/main/java/com/alibaba/otter/canal/common/utils/NamedThreadFactory.java @@ -23,6 +23,11 @@ public class NamedThreadFactory implements ThreadFactory { public void uncaughtException(Thread t, Throwable e) { + if (e instanceof InterruptedException + || (e.getCause() != null && e.getCause() instanceof InterruptedException)) { + return; + } + logger.error("from " + t.getName(), e); } }; diff --git a/common/src/main/java/com/alibaba/otter/canal/common/zookeeper/running/ServerRunningMonitor.java b/common/src/main/java/com/alibaba/otter/canal/common/zookeeper/running/ServerRunningMonitor.java index a0407c95..60a59946 100644 --- a/common/src/main/java/com/alibaba/otter/canal/common/zookeeper/running/ServerRunningMonitor.java +++ b/common/src/main/java/com/alibaba/otter/canal/common/zookeeper/running/ServerRunningMonitor.java @@ -4,7 +4,6 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import com.alibaba.otter.canal.common.CanalException; import org.I0Itec.zkclient.IZkDataListener; import org.I0Itec.zkclient.exception.ZkException; import org.I0Itec.zkclient.exception.ZkInterruptedException; diff --git a/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogContext.java b/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogContext.java index cac8c691..8d88d00d 100644 --- a/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogContext.java +++ b/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogContext.java @@ -58,7 +58,6 @@ public final class LogContext { public void reset() { formatDescription = FormatDescriptionLogEvent.FORMAT_DESCRIPTION_EVENT_5_x; - mapOfTable.clear(); } } diff --git a/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogDecoder.java b/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogDecoder.java index e1cb5555..bbb358b7 100644 --- a/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogDecoder.java +++ b/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogDecoder.java @@ -109,6 +109,8 @@ public final class LogDecoder { /* Decoding binary-log to event */ event = decode(buffer, header, context); if (event != null) { + // set logFileName + event.getHeader().setLogFileName(context.getLogPosition().getFileName()); event.setSemival(buffer.semival); } } catch (IOException e) { diff --git a/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/GtidLogEvent.java b/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/GtidLogEvent.java index 064f60bf..5c2678b5 100644 --- a/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/GtidLogEvent.java +++ b/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/GtidLogEvent.java @@ -17,10 +17,13 @@ public class GtidLogEvent extends LogEvent { public static final int ENCODED_FLAG_LENGTH = 1; // / Length of SID in event encoding public static final int ENCODED_SID_LENGTH = 16; + public static final int LOGICAL_TIMESTAMP_TYPE_CODE = 2; private boolean commitFlag; private UUID sid; private long gno; + private Long lastCommitted; + private Long sequenceNumber; public GtidLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){ super(header); @@ -40,6 +43,15 @@ public class GtidLogEvent extends LogEvent { gno = buffer.getLong64(); + // support gtid lastCommitted and sequenceNumber + // fix bug #776 + if (buffer.hasRemaining() && buffer.remaining() > 16 && buffer.getUint8() == LOGICAL_TIMESTAMP_TYPE_CODE) { + lastCommitted = buffer.getLong64(); + sequenceNumber = buffer.getLong64(); + } + + + // ignore gtid info read // sid.copy_from((uchar *)ptr_buffer); // ptr_buffer+= ENCODED_SID_LENGTH; @@ -62,4 +74,12 @@ public class GtidLogEvent extends LogEvent { public long getGno() { return gno; } + + public Long getLastCommitted() { + return lastCommitted; + } + + public Long getSequenceNumber() { + return sequenceNumber; + } } diff --git a/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/LogHeader.java b/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/LogHeader.java index c7c5429b..229693a2 100644 --- a/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/LogHeader.java +++ b/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/LogHeader.java @@ -115,6 +115,11 @@ public final class LogHeader { */ protected long crc; // ha_checksum + /** + * binlog fileName + */ + protected String logFileName; + /* for Start_event_v3 */ public LogHeader(final int type){ this.type = type; @@ -270,6 +275,14 @@ public final class LogHeader { return checksumAlg; } + public String getLogFileName() { + return logFileName; + } + + public void setLogFileName(String logFileName) { + this.logFileName = logFileName; + } + private void processCheckSum(LogBuffer buffer) { if (checksumAlg != LogEvent.BINLOG_CHECKSUM_ALG_OFF && checksumAlg != LogEvent.BINLOG_CHECKSUM_ALG_UNDEF) { crc = buffer.getUint32(eventLen - LogEvent.BINLOG_CHECKSUM_LEN); diff --git a/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/RowsLogBuffer.java b/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/RowsLogBuffer.java index 0727d8b6..fdfb3ebc 100644 --- a/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/RowsLogBuffer.java +++ b/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/RowsLogBuffer.java @@ -27,6 +27,7 @@ public final class RowsLogBuffer { public static final long DATETIMEF_INT_OFS = 0x8000000000L; public static final long TIMEF_INT_OFS = 0x800000L; public static final long TIMEF_OFS = 0x800000000000L; + private static char[] digits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; private final LogBuffer buffer; private final int columnLen; @@ -489,17 +490,18 @@ public final class RowsLogBuffer { // t % 100); StringBuilder builder = new StringBuilder(); - builder.append(formatNumber(d / 10000, 4)) - .append('-') - .append(formatNumber((d % 10000) / 100, 2)) - .append('-') - .append(formatNumber(d % 100, 2)) - .append(' ') - .append(formatNumber(t / 10000, 2)) - .append(':') - .append(formatNumber((t % 10000) / 100, 2)) - .append(':') - .append(formatNumber(t % 100, 2)); + builder.append(26); + appendNumber4(builder, d / 10000); + builder.append('-'); + appendNumber2(builder, (d % 10000) / 100); + builder.append('-'); + appendNumber2(builder, d % 100); + builder.append(' '); + appendNumber2(builder, t / 10000); + builder.append(':'); + appendNumber2(builder, (t % 10000) / 100); + builder.append(':'); + appendNumber2(builder, t % 100); value = builder.toString(); } javaType = Types.TIMESTAMP; @@ -562,18 +564,18 @@ public final class RowsLogBuffer { // (int) ((hms >> 6) % (1 << 6)), // (int) (hms % (1 << 6))); - StringBuilder builder = new StringBuilder(); - builder.append(formatNumber((int) (ym / 13), 4)) - .append('-') - .append(formatNumber((int) (ym % 13), 2)) - .append('-') - .append(formatNumber((int) (ymd % (1 << 5)), 2)) - .append(' ') - .append(formatNumber((int) (hms >> 12), 2)) - .append(':') - .append(formatNumber((int) ((hms >> 6) % (1 << 6)), 2)) - .append(':') - .append(formatNumber((int) (hms % (1 << 6)), 2)); + StringBuilder builder = new StringBuilder(26); + appendNumber4(builder, (int) (ym / 13)); + builder.append('-'); + appendNumber2(builder, (int) (ym % 13)); + builder.append('-'); + appendNumber2(builder, (int) (ymd % (1 << 5))); + builder.append(' '); + appendNumber2(builder, (int) (hms >> 12)); + builder.append(':'); + appendNumber2(builder, (int) ((hms >> 6) % (1 << 6))); + builder.append(':'); + appendNumber2(builder, (int) (hms % (1 << 6))); second = builder.toString(); } @@ -609,15 +611,15 @@ public final class RowsLogBuffer { // (u32 % 10000) / 100, // u32 % 100); - StringBuilder builder = new StringBuilder(); + StringBuilder builder = new StringBuilder(12); if (i32 < 0) { builder.append('-'); } - builder.append(formatNumber(u32 / 10000, 2)) - .append(':') - .append(formatNumber((u32 % 10000) / 100, 2)) - .append(':') - .append(formatNumber(u32 % 100, 2)); + appendNumber2(builder, u32 / 10000); + builder.append(':'); + appendNumber2(builder, (u32 % 10000) / 100); + builder.append(':'); + appendNumber2(builder, u32 % 100); value = builder.toString(); } javaType = Types.TIME; @@ -718,15 +720,15 @@ public final class RowsLogBuffer { // (int) ((intpart >> 6) % (1 << 6)), // (int) (intpart % (1 << 6))); - StringBuilder builder = new StringBuilder(); + StringBuilder builder = new StringBuilder(12); if (ltime < 0) { builder.append('-'); } - builder.append(formatNumber((int) ((intpart >> 12) % (1 << 10)), 2)) - .append(':') - .append(formatNumber((int) ((intpart >> 6) % (1 << 6)), 2)) - .append(':') - .append(formatNumber((int) (intpart % (1 << 6)), 2)); + appendNumber2(builder, (int) ((intpart >> 12) % (1 << 10))); + builder.append(':'); + appendNumber2(builder, (int) ((intpart >> 6) % (1 << 6))); + builder.append(':'); + appendNumber2(builder, (int) (intpart % (1 << 6))); second = builder.toString(); } @@ -770,12 +772,12 @@ public final class RowsLogBuffer { // value = String.format("%04d-%02d-%02d", i32 / (16 * 32), // i32 / 32 % 16, i32 % 32); - StringBuilder builder = new StringBuilder(); - builder.append(formatNumber(i32 / (16 * 32), 4)) - .append('-') - .append(formatNumber(i32 / 32 % 16, 2)) - .append('-') - .append(formatNumber(i32 % 32, 2)); + StringBuilder builder = new StringBuilder(12); + appendNumber4(builder, i32 / (16 * 32)); + builder.append('-'); + appendNumber2(builder, i32 / 32 % 16); + builder.append('-'); + appendNumber2(builder, i32 % 32); value = builder.toString(); } javaType = Types.DATE; @@ -1126,29 +1128,34 @@ public final class RowsLogBuffer { return sec.substring(0, meta); } - private String formatNumber(int d, int size) { - return leftPad(String.valueOf(d), size, '0'); + private void appendNumber4(StringBuilder builder, int d) { + if (d >= 1000) { + builder.append(digits[d / 1000]) + .append(digits[(d / 100) % 10]) + .append(digits[(d / 10) % 10]) + .append(digits[d % 10]); + } else if (d >= 100) { + builder.append('0'); + appendNumber3(builder, d); + } } - private String leftPad(String str, int size, char padChar) { - if (str == null) { - return null; + private void appendNumber3(StringBuilder builder, int d) { + if (d >= 100) { + builder.append(digits[d / 100]) + .append(digits[(d / 10) % 10]) + .append(digits[d % 10]); + } else { + builder.append('0'); + appendNumber2(builder, d); } - int pads = size - str.length(); - if (pads <= 0) { - return str; // returns original String when possible - } - return padding(pads, padChar).concat(str); } - private String padding(int repeat, char padChar) throws IndexOutOfBoundsException { - if (repeat < 0) { - throw new IndexOutOfBoundsException("Cannot pad a negative amount: " + repeat); + private void appendNumber2(StringBuilder builder, int d) { + if (d >= 10) { + builder.append(digits[(d / 10) % 10]).append(digits[d % 10]); + } else { + builder.append('0').append(digits[d]); } - final char[] buf = new char[repeat]; - for (int i = 0; i < buf.length; i++) { - buf[i] = padChar; - } - return new String(buf); } } diff --git a/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/RowsLogEvent.java b/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/RowsLogEvent.java index d27074b6..f2ce79b0 100644 --- a/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/RowsLogEvent.java +++ b/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/RowsLogEvent.java @@ -194,7 +194,7 @@ public abstract class RowsLogEvent extends LogEvent { } public final RowsLogBuffer getRowsBuf(String charsetName) { - return new RowsLogBuffer(rowsBuf.duplicate(), columnLen, charsetName); + return new RowsLogBuffer(rowsBuf, columnLen, charsetName); } public final int getFlags(final int flags) { diff --git a/dbsync/src/test/java/com/taobao/tddl/dbsync/FetcherPerformanceTest.java b/dbsync/src/test/java/com/taobao/tddl/dbsync/FetcherPerformanceTest.java new file mode 100644 index 00000000..f5af66e3 --- /dev/null +++ b/dbsync/src/test/java/com/taobao/tddl/dbsync/FetcherPerformanceTest.java @@ -0,0 +1,52 @@ +package com.taobao.tddl.dbsync; + +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.Statement; +import java.util.concurrent.atomic.AtomicLong; + +import com.taobao.tddl.dbsync.binlog.DirectLogFetcher; +import com.taobao.tddl.dbsync.binlog.LogEvent; + +public class FetcherPerformanceTest { + + public static void main(String args[]) { + DirectLogFetcher fetcher = new DirectLogFetcher(); + try { + Class.forName("com.mysql.jdbc.Driver"); + Connection connection = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306", + "root", + "hello"); + Statement statement = connection.createStatement(); + statement.execute("SET @master_binlog_checksum='@@global.binlog_checksum'"); + statement.execute("SET @mariadb_slave_capability='" + LogEvent.MARIA_SLAVE_CAPABILITY_MINE + "'"); + + fetcher.open(connection, "mysql-bin.000006", 120L, 2); + + AtomicLong sum = new AtomicLong(0); + long start = System.currentTimeMillis(); + long last = 0; + long end = 0; + + while (fetcher.fetch()) { + sum.incrementAndGet(); + long current = sum.get(); + if (current - last >= 100000) { + end = System.currentTimeMillis(); + long tps = ((current - last) * 1000) / (end - start); + System.out.println(" total : " + sum + " , cost : " + (end - start) + " , tps : " + tps); + last = current; + start = end; + } + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + fetcher.close(); + } catch (IOException e) { + } + } + } +} diff --git a/dbsync/src/test/java/com/taobao/tddl/dbsync/binlog/DirectLogFetcherTest.java b/dbsync/src/test/java/com/taobao/tddl/dbsync/binlog/DirectLogFetcherTest.java index 23a10f01..78d5b586 100644 --- a/dbsync/src/test/java/com/taobao/tddl/dbsync/binlog/DirectLogFetcherTest.java +++ b/dbsync/src/test/java/com/taobao/tddl/dbsync/binlog/DirectLogFetcherTest.java @@ -8,15 +8,6 @@ import java.sql.Statement; import org.junit.Assert; import org.junit.Test; -import com.taobao.tddl.dbsync.binlog.event.DeleteRowsLogEvent; -import com.taobao.tddl.dbsync.binlog.event.QueryLogEvent; -import com.taobao.tddl.dbsync.binlog.event.RotateLogEvent; -import com.taobao.tddl.dbsync.binlog.event.RowsQueryLogEvent; -import com.taobao.tddl.dbsync.binlog.event.UpdateRowsLogEvent; -import com.taobao.tddl.dbsync.binlog.event.WriteRowsLogEvent; -import com.taobao.tddl.dbsync.binlog.event.XidLogEvent; -import com.taobao.tddl.dbsync.binlog.event.mariadb.AnnotateRowsEvent; - public class DirectLogFetcherTest extends BaseLogFetcherTest { @Test @@ -24,56 +15,54 @@ public class DirectLogFetcherTest extends BaseLogFetcherTest { DirectLogFetcher fecther = new DirectLogFetcher(); try { Class.forName("com.mysql.jdbc.Driver"); - Connection connection = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306", "root", "hello"); + Connection connection = DriverManager.getConnection("jdbc:mysql://100.81.154.142:3306", "root", "hello"); Statement statement = connection.createStatement(); statement.execute("SET @master_binlog_checksum='@@global.binlog_checksum'"); statement.execute("SET @mariadb_slave_capability='" + LogEvent.MARIA_SLAVE_CAPABILITY_MINE + "'"); - fecther.open(connection, "mysql-bin.000001", 4L, 2); + fecther.open(connection, "mysql-bin.000006", 120L, 2); - LogDecoder decoder = new LogDecoder(LogEvent.UNKNOWN_EVENT, LogEvent.ENUM_END_EVENT); + LogDecoder decoder = new LogDecoder(LogEvent.UNKNOWN_EVENT, LogEvent.UNKNOWN_EVENT); LogContext context = new LogContext(); while (fecther.fetch()) { - LogEvent event = null; - event = decoder.decode(fecther, context); - - if (event == null) { - continue; - // throw new RuntimeException("parse failed"); - } - - int eventType = event.getHeader().getType(); - switch (eventType) { - case LogEvent.ROTATE_EVENT: - binlogFileName = ((RotateLogEvent) event).getFilename(); - break; - case LogEvent.WRITE_ROWS_EVENT_V1: - case LogEvent.WRITE_ROWS_EVENT: - parseRowsEvent((WriteRowsLogEvent) event); - break; - case LogEvent.UPDATE_ROWS_EVENT_V1: - case LogEvent.UPDATE_ROWS_EVENT: - parseRowsEvent((UpdateRowsLogEvent) event); - break; - case LogEvent.DELETE_ROWS_EVENT_V1: - case LogEvent.DELETE_ROWS_EVENT: - parseRowsEvent((DeleteRowsLogEvent) event); - break; - case LogEvent.QUERY_EVENT: - parseQueryEvent((QueryLogEvent) event); - break; - case LogEvent.ROWS_QUERY_LOG_EVENT: - parseRowsQueryEvent((RowsQueryLogEvent) event); - break; - case LogEvent.ANNOTATE_ROWS_EVENT: - parseAnnotateRowsEvent((AnnotateRowsEvent) event); - break; - case LogEvent.XID_EVENT: - parseXidEvent((XidLogEvent) event); - break; - default: - break; - } + decoder.decode(fecther, context); + continue; + // if (event == null) { + // continue; + // } + // + // int eventType = event.getHeader().getType(); + // switch (eventType) { + // case LogEvent.ROTATE_EVENT: + // binlogFileName = ((RotateLogEvent) event).getFilename(); + // break; + // case LogEvent.WRITE_ROWS_EVENT_V1: + // case LogEvent.WRITE_ROWS_EVENT: + // parseRowsEvent((WriteRowsLogEvent) event); + // break; + // case LogEvent.UPDATE_ROWS_EVENT_V1: + // case LogEvent.UPDATE_ROWS_EVENT: + // parseRowsEvent((UpdateRowsLogEvent) event); + // break; + // case LogEvent.DELETE_ROWS_EVENT_V1: + // case LogEvent.DELETE_ROWS_EVENT: + // parseRowsEvent((DeleteRowsLogEvent) event); + // break; + // case LogEvent.QUERY_EVENT: + // parseQueryEvent((QueryLogEvent) event); + // break; + // case LogEvent.ROWS_QUERY_LOG_EVENT: + // parseRowsQueryEvent((RowsQueryLogEvent) event); + // break; + // case LogEvent.ANNOTATE_ROWS_EVENT: + // parseAnnotateRowsEvent((AnnotateRowsEvent) event); + // break; + // case LogEvent.XID_EVENT: + // parseXidEvent((XidLogEvent) event); + // break; + // default: + // break; + // } } } catch (Exception e) { e.printStackTrace(); diff --git a/deployer/pom.xml b/deployer/pom.xml index 5fa2efc8..75f05805 100644 --- a/deployer/pom.xml +++ b/deployer/pom.xml @@ -16,6 +16,14 @@ canal.server ${project.version} + + + + + + + + diff --git a/deployer/src/main/bin/metrics_env.sh b/deployer/src/main/bin/metrics_env.sh new file mode 100644 index 00000000..1085eae2 --- /dev/null +++ b/deployer/src/main/bin/metrics_env.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# Additional line arg for current prometheus solution +case "`uname`" in +Linux) + bin_abs_path=$(readlink -f $(dirname $0)) + ;; +*) + bin_abs_path=`cd $(dirname $0); pwd` + ;; +esac +base=${bin_abs_path}/.. +if [ $(ls $base/lib/aspectjweaver*.jar | wc -l) -eq 1 ]; then + WEAVER=$(ls $base/lib/aspectjweaver*.jar) + METRICS_OPTS=" -javaagent:"${WEAVER}" " +fi diff --git a/deployer/src/main/bin/restart.sh b/deployer/src/main/bin/restart.sh new file mode 100644 index 00000000..63749ce5 --- /dev/null +++ b/deployer/src/main/bin/restart.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +sh stop.sh + +sh startup.sh diff --git a/deployer/src/main/bin/startup.sh b/deployer/src/main/bin/startup.sh index 5655c713..b87652c0 100644 --- a/deployer/src/main/bin/startup.sh +++ b/deployer/src/main/bin/startup.sh @@ -94,7 +94,12 @@ then echo LOG CONFIGURATION : $logback_configurationFile echo canal conf : $canal_conf echo CLASSPATH :$CLASSPATH - $JAVA $JAVA_OPTS $JAVA_DEBUG_OPT $CANAL_OPTS -classpath .:$CLASSPATH com.alibaba.otter.canal.deployer.CanalLauncher 1>>$base/logs/canal/canal.log 2>&1 & +# metrics support options +# if [ -x $base/bin/metrics_env.sh ]; then +# . $base/bin/metrics_env.sh +# echo METRICS_OPTS $METRICS_OPTS +# fi + $JAVA $JAVA_OPTS $METRICS_OPTS $JAVA_DEBUG_OPT $CANAL_OPTS -classpath .:$CLASSPATH com.alibaba.otter.canal.deployer.CanalLauncher 1>>$base/logs/canal/canal.log 2>&1 & echo $! > $base/bin/canal.pid echo "cd to $current_path for continue" diff --git a/deployer/src/main/java/com/alibaba/otter/canal/deployer/CanalConstants.java b/deployer/src/main/java/com/alibaba/otter/canal/deployer/CanalConstants.java index d68d5871..b328feb7 100644 --- a/deployer/src/main/java/com/alibaba/otter/canal/deployer/CanalConstants.java +++ b/deployer/src/main/java/com/alibaba/otter/canal/deployer/CanalConstants.java @@ -16,6 +16,7 @@ public class CanalConstants { public static final String CANAL_IP = ROOT + "." + "ip"; public static final String CANAL_PORT = ROOT + "." + "port"; public static final String CANAL_ZKSERVERS = ROOT + "." + "zkServers"; + public static final String CANAL_WITHOUT_NETTY = ROOT + "." + "withoutNetty"; public static final String CANAL_DESTINATIONS = ROOT + "." + "destinations"; public static final String CANAL_AUTO_SCAN = ROOT + "." + "auto.scan"; diff --git a/deployer/src/main/java/com/alibaba/otter/canal/deployer/CanalController.java b/deployer/src/main/java/com/alibaba/otter/canal/deployer/CanalController.java index 08c0744d..6b0fc934 100644 --- a/deployer/src/main/java/com/alibaba/otter/canal/deployer/CanalController.java +++ b/deployer/src/main/java/com/alibaba/otter/canal/deployer/CanalController.java @@ -34,6 +34,7 @@ import com.alibaba.otter.canal.instance.core.CanalInstanceGenerator; import com.alibaba.otter.canal.instance.manager.CanalConfigClient; import com.alibaba.otter.canal.instance.manager.ManagerCanalInstanceGenerator; import com.alibaba.otter.canal.instance.spring.SpringCanalInstanceGenerator; +import com.alibaba.otter.canal.parse.CanalEventParser; import com.alibaba.otter.canal.server.embedded.CanalServerWithEmbedded; import com.alibaba.otter.canal.server.exception.CanalServerException; import com.alibaba.otter.canal.server.netty.CanalServerWithNetty; @@ -43,7 +44,7 @@ import com.google.common.collect.MigrateMap; /** * canal调度控制器 - * + * * @author jianghang 2012-11-8 下午12:03:11 * @version 1.0.0 */ @@ -97,9 +98,12 @@ public class CanalController { port = Integer.valueOf(getProperty(properties, CanalConstants.CANAL_PORT)); embededCanalServer = CanalServerWithEmbedded.instance(); embededCanalServer.setCanalInstanceGenerator(instanceGenerator);// 设置自定义的instanceGenerator - canalServer = CanalServerWithNetty.instance(); - canalServer.setIp(ip); - canalServer.setPort(port); + String canalWithoutNetty = getProperty(properties, CanalConstants.CANAL_WITHOUT_NETTY); + if (canalWithoutNetty == null || "false".equals(canalWithoutNetty)) { + canalServer = CanalServerWithNetty.instance(); + canalServer.setIp(ip); + canalServer.setPort(port); + } // 处理下ip为空,默认使用hostIp暴露到zk中 if (StringUtils.isEmpty(ip)) { @@ -300,7 +304,7 @@ public class CanalController { return instanceGenerator.generate(destination); } else if (config.getMode().isSpring()) { SpringCanalInstanceGenerator instanceGenerator = new SpringCanalInstanceGenerator(); - synchronized (this) { + synchronized (CanalEventParser.class) { try { // 设置当前正在加载的通道,加载spring查找文件时会用到该变量 System.setProperty(CanalConstants.CANAL_DESTINATION_PROPERTY, destination); @@ -376,7 +380,18 @@ public class CanalController { } private String getProperty(Properties properties, String key) { - return StringUtils.trim(properties.getProperty(StringUtils.trim(key))); + key = StringUtils.trim(key); + String value = System.getProperty(key); + + if (value == null) { + value = System.getenv(key); + } + + if (value == null) { + value = properties.getProperty(key); + } + + return StringUtils.trim(value); } public void start() throws Throwable { @@ -431,11 +446,15 @@ public class CanalController { } // 启动网络接口 - canalServer.start(); + if (canalServer != null) { + canalServer.start(); + } } public void stop() throws Throwable { - canalServer.stop(); + if (canalServer != null) { + canalServer.stop(); + } if (autoScan) { for (InstanceConfigMonitor monitor : instanceConfigMonitors.values()) { @@ -454,7 +473,7 @@ public class CanalController { // 释放canal的工作节点 releaseCid(ZookeeperPathUtils.getCanalClusterNode(ip + ":" + port)); logger.info("## stop the canal server[{}:{}]", ip, port); - + if (zkclientx != null) { zkclientx.close(); } diff --git a/deployer/src/main/java/com/alibaba/otter/canal/deployer/CanalLauncher.java b/deployer/src/main/java/com/alibaba/otter/canal/deployer/CanalLauncher.java index e66a5a9b..828f49e2 100644 --- a/deployer/src/main/java/com/alibaba/otter/canal/deployer/CanalLauncher.java +++ b/deployer/src/main/java/com/alibaba/otter/canal/deployer/CanalLauncher.java @@ -59,6 +59,7 @@ public class CanalLauncher { private static void setGlobalUncaughtExceptionHandler() { Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override public void uncaughtException(Thread t, Throwable e) { logger.error("UnCaughtException", e); diff --git a/deployer/src/main/resources/canal.properties b/deployer/src/main/resources/canal.properties index f765e71b..2bff29ae 100644 --- a/deployer/src/main/resources/canal.properties +++ b/deployer/src/main/resources/canal.properties @@ -3,10 +3,11 @@ ################################################# canal.id= 1 canal.ip= -canal.port= 11111 +canal.port=11111 canal.zkServers= # flush data to zk canal.zookeeper.flush.period = 1000 +canal.withoutNetty = false # flush meta cursor/parse position to file canal.file.data.dir = ${canal.conf.dir} canal.file.flush.period = 1000 @@ -42,6 +43,7 @@ canal.instance.filter.query.dml = false canal.instance.filter.query.ddl = false canal.instance.filter.table.error = false canal.instance.filter.rows = false +canal.instance.filter.transaction.entry = false # binlog format/image check canal.instance.binlog.format = ROW,STATEMENT,MIXED @@ -50,6 +52,20 @@ canal.instance.binlog.image = FULL,MINIMAL,NOBLOB # binlog ddl isolation canal.instance.get.ddl.isolation = false +# parallel parser config +canal.instance.parser.parallel = true +## concurrent thread number, default 60% available processors, suggest not to exceed Runtime.getRuntime().availableProcessors() +#canal.instance.parser.parallelThreadSize = 16 +## disruptor ringbuffer size, must be power of 2 +canal.instance.parser.parallelBufferSize = 256 + +# table meta tsdb info +canal.instance.tsdb.enable=true +canal.instance.tsdb.dir=${canal.file.data.dir:../conf}/${canal.instance.destination:} +canal.instance.tsdb.url=jdbc:h2:${canal.instance.tsdb.dir}/h2;CACHE_SIZE=1000;MODE=MYSQL; +canal.instance.tsdb.dbUsername=canal +canal.instance.tsdb.dbPassword=canal + ################################################# ######### destinations ############# ################################################# diff --git a/deployer/src/main/resources/example/instance.properties b/deployer/src/main/resources/example/instance.properties index a3703b86..e0cf0064 100644 --- a/deployer/src/main/resources/example/instance.properties +++ b/deployer/src/main/resources/example/instance.properties @@ -1,11 +1,12 @@ ################################################# -## mysql serverId -canal.instance.mysql.slaveId=0 +## mysql serverId , v1.0.26+ will autoGen +# canal.instance.mysql.slaveId=0 + +# enable gtid use true/false +canal.instance.gtidon=false # position info canal.instance.master.address=127.0.0.1:3306 -# enable gtid use true/false -canal.instance.gtidon=false canal.instance.master.journal.name= canal.instance.master.position= canal.instance.master.timestamp= @@ -13,23 +14,21 @@ canal.instance.master.gtid= # table meta tsdb info canal.instance.tsdb.enable=true -canal.instance.tsdb.dir=${canal.file.data.dir:../conf}/${canal.instance.destination:} -canal.instance.tsdb.url=jdbc:h2:${canal.instance.tsdb.dir}/h2;CACHE_SIZE=1000;MODE=MYSQL; #canal.instance.tsdb.url=jdbc:mysql://127.0.0.1:3306/canal_tsdb -canal.instance.tsdb.dbUsername=canal -canal.instance.tsdb.dbPassword=canal - +#canal.instance.tsdb.dbUsername=canal +#canal.instance.tsdb.dbPassword=canal #canal.instance.standby.address = #canal.instance.standby.journal.name = #canal.instance.standby.position = #canal.instance.standby.timestamp = #canal.instance.standby.gtid= + # username/password canal.instance.dbUsername=canal canal.instance.dbPassword=canal -canal.instance.defaultDatabaseName=test canal.instance.connectionCharset=UTF-8 + # table regex canal.instance.filter.regex=.*\\..* # table black regex diff --git a/deployer/src/main/resources/logback.xml b/deployer/src/main/resources/logback.xml index 1b0f4103..f1c0e93b 100644 --- a/deployer/src/main/resources/logback.xml +++ b/deployer/src/main/resources/logback.xml @@ -70,9 +70,13 @@ - + + + + + diff --git a/deployer/src/main/resources/spring/default-instance.xml b/deployer/src/main/resources/spring/default-instance.xml index 93cb39af..6b455c83 100644 --- a/deployer/src/main/resources/spring/default-instance.xml +++ b/deployer/src/main/resources/spring/default-instance.xml @@ -81,6 +81,7 @@ + @@ -148,7 +149,7 @@ - + @@ -156,7 +157,7 @@ - + @@ -191,6 +192,11 @@ - + + + + + + diff --git a/deployer/src/main/resources/spring/file-instance.xml b/deployer/src/main/resources/spring/file-instance.xml index d8285dc1..377428a9 100644 --- a/deployer/src/main/resources/spring/file-instance.xml +++ b/deployer/src/main/resources/spring/file-instance.xml @@ -67,6 +67,7 @@ + @@ -133,7 +134,7 @@ - + @@ -141,7 +142,7 @@ - + @@ -176,6 +177,11 @@ - + + + + + + diff --git a/deployer/src/main/resources/spring/group-instance.xml b/deployer/src/main/resources/spring/group-instance.xml index e8c0dd0f..44f1ab3b 100644 --- a/deployer/src/main/resources/spring/group-instance.xml +++ b/deployer/src/main/resources/spring/group-instance.xml @@ -64,6 +64,7 @@ + @@ -130,7 +131,7 @@ - + @@ -138,7 +139,7 @@ - + @@ -166,6 +167,11 @@ + + + + + @@ -223,7 +229,7 @@ - + @@ -231,7 +237,7 @@ - + @@ -260,5 +266,10 @@ + + + + + diff --git a/deployer/src/main/resources/spring/local-instance.xml b/deployer/src/main/resources/spring/local-instance.xml index 5ac62df1..930ecb7b 100644 --- a/deployer/src/main/resources/spring/local-instance.xml +++ b/deployer/src/main/resources/spring/local-instance.xml @@ -67,6 +67,7 @@ + @@ -113,7 +114,7 @@ - + @@ -137,5 +138,10 @@ + + + + + \ No newline at end of file diff --git a/deployer/src/main/resources/spring/memory-instance.xml b/deployer/src/main/resources/spring/memory-instance.xml index ef8e4880..cd387b8f 100644 --- a/deployer/src/main/resources/spring/memory-instance.xml +++ b/deployer/src/main/resources/spring/memory-instance.xml @@ -64,6 +64,7 @@ + @@ -121,7 +122,7 @@ - + @@ -129,7 +130,7 @@ - + @@ -164,6 +165,11 @@ - + + + + + + diff --git a/deployer/src/main/resources/spring/tsdb/h2-tsdb.xml b/deployer/src/main/resources/spring/tsdb/h2-tsdb.xml index 6f8ba05d..beb61236 100644 --- a/deployer/src/main/resources/spring/tsdb/h2-tsdb.xml +++ b/deployer/src/main/resources/spring/tsdb/h2-tsdb.xml @@ -31,8 +31,8 @@ - - + + diff --git a/deployer/src/main/resources/spring/tsdb/mysql-tsdb.xml b/deployer/src/main/resources/spring/tsdb/mysql-tsdb.xml index 555eec44..58cab638 100644 --- a/deployer/src/main/resources/spring/tsdb/mysql-tsdb.xml +++ b/deployer/src/main/resources/spring/tsdb/mysql-tsdb.xml @@ -31,8 +31,8 @@ - - + + diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..e44796cb --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,67 @@ +FROM centos:centos6.7 + +MAINTAINER agapple (jianghang115@gmail.com) + +# install system +RUN \ + /bin/cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ + echo 'root:Hello1234' | chpasswd && \ + groupadd -r admin && useradd -g admin admin && \ + yum install -y man && \ + yum install -y dstat && \ + yum install -y unzip && \ + yum install -y nc && \ + yum install -y openssh-server && \ + yum install -y tar && \ + yum install -y which && \ + yum install -y wget && \ + yum install -y perl && \ + yum install -y file && \ + ssh-keygen -q -N "" -t dsa -f /etc/ssh/ssh_host_dsa_key && \ + ssh-keygen -q -N "" -t rsa -f /etc/ssh/ssh_host_rsa_key && \ + sed -ri 's/session required pam_loginuid.so/#session required pam_loginuid.so/g' /etc/pam.d/sshd && \ + sed -i -e 's/^#Port 22$/Port 2222/' /etc/ssh/sshd_config && \ + mkdir -p /root/.ssh && chown root.root /root && chmod 700 /root/.ssh && \ + yum install -y cronie && \ + sed -i '/session required pam_loginuid.so/d' /etc/pam.d/crond && \ + yum clean all && \ + true + +# install canal +COPY image/ /tmp/docker/ +COPY canal.deployer-*.tar.gz /home/admin/ +COPY jdk-8-linux-x64.rpm /tmp/ + +RUN \ + cp -R /tmp/docker/alidata /alidata && \ + chmod +x /alidata/bin/* && \ + mkdir -p /home/admin && \ + cp -R /tmp/docker/admin/* /home/admin/ && \ + /bin/cp -f alidata/bin/lark-wait /usr/bin/lark-wait && \ + + touch /var/lib/rpm/* && \ + yum -y install /tmp/jdk-8-linux-x64.rpm && \ + /bin/rm -f /tmp/jdk-8-linux-x64.rpm && \ + + echo "export JAVA_HOME=/usr/java/latest" >> /etc/profile && \ + echo "export PATH=\$JAVA_HOME/bin:\$PATH" >> /etc/profile && \ + /bin/mv /home/admin/bin/clean_log /etc/cron.d && \ + + mkdir -p /home/admin/canal-server && \ + tar -xzvf /home/admin/canal.deployer-*.tar.gz -C /home/admin/canal-server && \ + /bin/rm -f /home/admin/canal.deployer-*.tar.gz && \ + + mkdir -p home/admin/canal-server/logs && \ + chmod +x /home/admin/*.sh && \ + chmod +x /home/admin/bin/*.sh && \ + chown admin: -R /home/admin && \ + yum clean all && \ + true + +# 2222 sys , 8080 web , 8000 debug , 11111 canal +EXPOSE 2222 11111 8000 8080 + +WORKDIR /home/admin + +ENTRYPOINT [ "/alidata/bin/main.sh" ] +CMD [ "/home/admin/app.sh" ] \ No newline at end of file diff --git a/docker/build.sh b/docker/build.sh new file mode 100644 index 00000000..58424fb3 --- /dev/null +++ b/docker/build.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +current_path=`pwd` +case "`uname`" in + Darwin) + bin_abs_path=`cd $(dirname $0); pwd` + ;; + Linux) + bin_abs_path=$(readlink -f $(dirname $0)) + ;; + *) + bin_abs_path=`cd $(dirname $0); pwd` + ;; +esac +BASE=${bin_abs_path} + +if [ ! -f $BASE/jdk*.rpm ] ; then + DOWNLOAD_LINK="http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.tar.gz" + wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie" "$DOWNLOAD_LINK" -O $BASE/jdk-8-linux-x64.rpm +fi + +cd $BASE/../ && mvn clean package -Dmaven.test.skip -Denv=release && cd $current_path ; + +if [ "$1" == "kafka" ] ; then + cp $BASE/../target/canal-kafka-*.tar.gz $BASE/ + docker build --no-cache -t canal/canal-server $BASE/ +else + cp $BASE/../target/canal.deployer-*.tar.gz $BASE/ + docker build --no-cache -t canal/canal-server $BASE/ +fi diff --git a/docker/image/admin/app.sh b/docker/image/admin/app.sh new file mode 100755 index 00000000..254f7e48 --- /dev/null +++ b/docker/image/admin/app.sh @@ -0,0 +1,117 @@ +#!/bin/bash +set -e + +source /etc/profile +export JAVA_HOME=/usr/java/latest +export PATH=$JAVA_HOME/bin:$PATH +touch /tmp/start.log +chown admin: /tmp/start.log +chown -R admin: /home/admin/canal-server +host=`hostname -i` + +# waitterm +# wait TERM/INT signal. +# see: http://veithen.github.io/2014/11/16/sigterm-propagation.html +waitterm() { + local PID + # any process to block + tail -f /dev/null & + PID="$!" + # setup trap, could do nothing, or just kill the blocker + trap "kill -TERM ${PID}" TERM INT + # wait for signal, ignore wait exit code + wait "${PID}" || true + # clear trap + trap - TERM INT + # wait blocker, ignore blocker exit code + wait "${PID}" 2>/dev/null || true +} + +# waittermpid "${PIDFILE}". +# monitor process by pidfile && wait TERM/INT signal. +# if the process disappeared, return 1, means exit with ERROR. +# if TERM or INT signal received, return 0, means OK to exit. +waittermpid() { + local PIDFILE PID do_run error + PIDFILE="${1?}" + do_run=true + error=0 + trap "do_run=false" TERM INT + while "${do_run}" ; do + PID="$(cat "${PIDFILE}")" + if ! ps -p "${PID}" >/dev/null 2>&1 ; then + do_run=false + error=1 + else + sleep 1 + fi + done + trap - TERM INT + return "${error}" +} + + +function checkStart() { + local name=$1 + local cmd=$2 + local timeout=$3 + cost=5 + while [ $timeout -gt 0 ]; do + ST=`eval $cmd` + if [ "$ST" == "0" ]; then + sleep 1 + let timeout=timeout-1 + let cost=cost+1 + elif [ "$ST" == "" ]; then + sleep 1 + let timeout=timeout-1 + let cost=cost+1 + else + break + fi + done + echo "start $name successful" +} + + +function start_canal() { + echo "start canal ..." + serverPort=`perl -le 'print $ENV{"canal.port"}'` + if [ -z "$serverPort" ] ; then + serverPort=11111 + fi + + destination=`perl -le 'print $ENV{"canal.destinations"}'` + if [[ "$destination" =~ ',' ]]; then + echo "multi destination:$destination is not support" + exit 1; + else + mv /home/admin/canal-server/conf/example /home/admin/canal-server/conf/$destination + fi + su admin -c 'cd /home/admin/canal-server/bin/ && sh restart.sh 1>>/tmp/start.log 2>&1' + sleep 5 + #check start + checkStart "canal" "nc 127.0.0.1 $serverPort -w 1 -z | wc -l" 30 +} + +function stop_canal() { + echo "stop canal" + su admin -c 'cd /home/admin/canal-server/bin/ && sh stop.sh 1>>/tmp/start.log 2>&1' + echo "stop canal successful ..." +} + +echo "==> START ..." + +start_canal + +echo "==> START SUCCESSFUL ..." + +tail -f /dev/null & +# wait TERM signal +waitterm + +echo "==> STOP" + +stop_canal + +echo "==> STOP SUCCESSFUL ..." diff --git a/docker/image/admin/bin/clean_log b/docker/image/admin/bin/clean_log new file mode 100644 index 00000000..df183614 --- /dev/null +++ b/docker/image/admin/bin/clean_log @@ -0,0 +1,2 @@ +# cron clean log once per minute +*/2 * * * * admin /home/admin/bin/clean_log.sh >>/tmp/clean_log.log 2>&1 diff --git a/docker/image/admin/bin/clean_log.sh b/docker/image/admin/bin/clean_log.sh new file mode 100755 index 00000000..9d0a0bef --- /dev/null +++ b/docker/image/admin/bin/clean_log.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# Global Settings +PATH="$HOME/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin" +export PATH + +CUTOFF="85" +#获取磁盘使用率最高的分区 +USAGE=$(df -h|awk 'NR>1 {gsub(/%$/,"",$5);print $5 }'|sort -nr|head -1) +before=$USAGE + +baseClean(){ + #删除tmp目录15天前的文件。 + #更新文档时间戳 + if [ -d /tmp/hsperfdata_admin ] + then + touch /tmp/hsperfdata_admin + touch /tmp/hsperfdata_admin/* + fi + + find /tmp/ -type f -mtime +15 | xargs -t rm -rf >/dev/null 2>&1 + + + now=$(df -h|awk 'NR>1 {gsub(/%$/,"",$5);print $5 }'|sort -nr|head -1) + echo "before:$before; now:$now" +} + +CANAL_DIR="/home/admin/canal-server/logs" +if [[ -d $CANAL_DIR ]]; then + USAGE=$(df -h|awk 'NR>1 {gsub(/%$/,"",$5);print $5 }'|sort -nr|head -1) + if [[ $USAGE -ge 90 ]]; then + find $CANAL_DIR -type f -mtime +7 | xargs rm -rf {} + fi + USAGE=$(df -h|awk 'NR>1 {gsub(/%$/,"",$5);print $5 }'|sort -nr|head -1) + if [[ $USAGE -ge 80 ]]; then + find $CANAL_DIR -type f -mtime +3 | xargs rm -rf {} + fi + USAGE=$(df -h|awk 'NR>1 {gsub(/%$/,"",$5);print $5 }'|sort -nr|head -1) + if [[ $USAGE -ge 80 ]]; then + find $CANAL_DIR -type d -empty -mtime +3 | grep -v canal | xargs rm -rf {} + find $CANAL_DIR -type f -iname '*.tmp' | xargs rm -rf {} + fi + baseClean + exit 0 +fi \ No newline at end of file diff --git a/docker/image/admin/health.sh b/docker/image/admin/health.sh new file mode 100755 index 00000000..17a89740 --- /dev/null +++ b/docker/image/admin/health.sh @@ -0,0 +1,13 @@ +#!/bin/sh +CHECK_URL="http://127.0.0.1:8080/metrics" +CHECK_POINT="success" +CHECK_COUNT=`curl -s --connect-timeout 7 --max-time 7 $CHECK_URL | grep -c $CHECK_POINT` +if [ $CHECK_COUNT -eq 0 ]; then + echo "[FAILED]" + status=0 + error=1 +else + echo "[ OK ]" + status=1 + error=0 +fi \ No newline at end of file diff --git a/docker/image/alidata/bin/exec_rc_local.sh b/docker/image/alidata/bin/exec_rc_local.sh new file mode 100755 index 00000000..7cc8aa3f --- /dev/null +++ b/docker/image/alidata/bin/exec_rc_local.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +if [ "${SKIP_EXEC_RC_LOCAL}" = "YES" ] ; then + echo "skip /etc/rc.local: SKIP_EXEC_RC_LOCAL=${SKIP_EXEC_RC_LOCAL}" + exit +fi + +if [ "${DOCKER_DEPLOY_TYPE}" = "HOST" ] ; then + echo "skip /etc/rc.local: DOCKER_DEPLOY_TYPE=${DOCKER_DEPLOY_TYPE}" + exit +fi \ No newline at end of file diff --git a/docker/image/alidata/bin/lark-wait b/docker/image/alidata/bin/lark-wait new file mode 100755 index 00000000..db7be708 --- /dev/null +++ b/docker/image/alidata/bin/lark-wait @@ -0,0 +1,6 @@ +#!/bin/bash +set -e + +chown admin: -R /home/admin/ +source /alidata/lib/proc.sh +waitterm diff --git a/docker/image/alidata/bin/main.sh b/docker/image/alidata/bin/main.sh new file mode 100755 index 00000000..a57551a7 --- /dev/null +++ b/docker/image/alidata/bin/main.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +[ -n "${DOCKER_DEPLOY_TYPE}" ] || DOCKER_DEPLOY_TYPE="VM" +echo "DOCKER_DEPLOY_TYPE=${DOCKER_DEPLOY_TYPE}" + +# run init scripts +for e in $(ls /alidata/init/*) ; do + [ -x "${e}" ] || continue + echo "==> INIT $e" + $e + echo "==> EXIT CODE: $?" +done + +echo "==> INIT DEFAULT" +service sshd start +service crond start + +#echo "check hostname -i: `hostname -i`" +#hti_num=`hostname -i|awk '{print NF}'` +#if [ $hti_num -gt 1 ];then +# echo "hostname -i result error:`hostname -i`" +# exit 120 +#fi + +echo "==> INIT DONE" +echo "==> RUN ${*}" +exec "${@}" \ No newline at end of file diff --git a/docker/image/alidata/init/02init-sshd.sh b/docker/image/alidata/init/02init-sshd.sh new file mode 100755 index 00000000..118ee553 --- /dev/null +++ b/docker/image/alidata/init/02init-sshd.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# set port +if [ -z "${SSHD_PORT}" ] ; then + SSHD_PORT=22 + [ "${DOCKER_DEPLOY_TYPE}" = "HOST" ] && SSHD_PORT=2222 +fi + +sed -r -i '/^OPTIONS=/ d' /etc/sysconfig/sshd +echo 'OPTIONS="-p '"${SSHD_PORT}"'"' >> /etc/sysconfig/sshd + +# set admin ssh pulic key +if [ "${USE_ADMIN_PASSAGE}" = "YES" ] ; then + echo "set admin passage" + mkdir -p /home/admin/.ssh + chown admin:admin /home/admin/.ssh + chown admin:admin /home/admin/.ssh/authorized_keys + chmod 644 /home/admin/.ssh/authorized_keys +fi diff --git a/docker/image/alidata/init/fix-hosts.py b/docker/image/alidata/init/fix-hosts.py new file mode 100755 index 00000000..4ee8abb5 --- /dev/null +++ b/docker/image/alidata/init/fix-hosts.py @@ -0,0 +1,66 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +#****************************************************************# +# Create Date: 2017-01-06 17:58 +#***************************************************************# + +import socket +import shutil +from time import gmtime, strftime + +# get host_name +host_name = socket.gethostname() +tmp_file = "/tmp/.lark-fix-host.hosts" +host_file = "/etc/hosts" +bak_file_name = "/tmp/hosts-fix-bak.%s" % ( strftime("%Y-%m-%d_%H-%M-%S", gmtime()) ) + +# load /etc/hosts file context +FH = open(host_file,"r") +file_lines = [ i.rstrip() for i in FH.readlines()] +FH.close() +file_lines_reverse = file_lines[::-1] +new_lines = [] +bad_lines = [] +last_match_line = "" + +for line in file_lines_reverse: + if line.find(host_name) < 0: # 不匹配的行直接跳过 + new_lines.append(line + "\n") + continue + + cols = line.split() + new_cols = [] + if cols[0].startswith("#"): # 跳过已经注释掉的行 + new_lines.append(line + "\n") + continue + for col in cols: + if not col == host_name: # 跳过不匹配的列 + new_cols.append(col) + continue + + if cols[0] == "127.0.0.1": # 如果第一列是 127.0.0.1 就跳过匹配的列, 防止 hostname -i 返回 127.0.0.1 + continue + + # 如果已经发现过匹配的列, 就丢掉重复的列 + if not len(last_match_line) == 0: + continue + + new_cols.append(col) + last_match_line = line + + # 跳过 xx.xx.xx.xx hostname 这样的重复列 + if len(new_cols) == 1: + continue + + new_l = "%s\n" % " ".join(new_cols) + new_lines.append(new_l) + +# save tmp hosts + +FH2=file(tmp_file,"w+") +FH2.writelines( new_lines[::-1]) +FH2.close() + +# mv to /etc/hosts +shutil.copy(host_file, bak_file_name) +shutil.move(tmp_file, host_file) diff --git a/docker/image/alidata/lib/proc.sh b/docker/image/alidata/lib/proc.sh new file mode 100644 index 00000000..40ddff93 --- /dev/null +++ b/docker/image/alidata/lib/proc.sh @@ -0,0 +1,40 @@ +# waitterm +# wait TERM/INT signal. +# see: http://veithen.github.io/2014/11/16/sigterm-propagation.html +waitterm() { + local PID + # any process to block + tail -f /dev/null & + PID="$!" + # setup trap, could do nothing, or just kill the blocker + trap "kill -TERM ${PID}" TERM INT + # wait for signal, ignore wait exit code + wait "${PID}" || true + # clear trap + trap - TERM INT + # wait blocker, ignore blocker exit code + wait "${PID}" 2>/dev/null || true +} + +# waittermpid "${PIDFILE}". +# monitor process by pidfile && wait TERM/INT signal. +# if the process disappeared, return 1, means exit with ERROR. +# if TERM or INT signal received, return 0, means OK to exit. +waittermpid() { + local PIDFILE PID do_run error + PIDFILE="${1?}" + do_run=true + error=0 + trap "do_run=false" TERM INT + while "${do_run}" ; do + PID="$(cat "${PIDFILE}")" + if ! ps -p "${PID}" >/dev/null 2>&1 ; then + do_run=false + error=1 + else + sleep 1 + fi + done + trap - TERM INT + return "${error}" +} diff --git a/docker/run.sh b/docker/run.sh new file mode 100644 index 00000000..7c56e2ba --- /dev/null +++ b/docker/run.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +function usage() { + echo "Usage:" + echo " run.sh [CONFIG]" + echo "example:" + echo " run.sh -e canal.instance.master.address=127.0.0.1:3306 \\" + echo " -e canal.instance.dbUsername=canal \\" + echo " -e canal.instance.dbPassword=canal \\" + echo " -e canal.instance.connectionCharset=UTF-8 \\" + echo " -e canal.instance.tsdb.enable=true \\" + echo " -e canal.instance.gtidon=false \\" + echo " -e canal.instance.filter.regex=.*\\..* " + exit +} + +function check_port() { + local port=$1 + local TL=$(which telnet) + if [ -f $TL ]; then + data=`echo quit | telnet 127.0.0.1 $port| grep -ic connected` + echo $data + return + fi + + local NC=$(which nc) + if [ -f $NC ]; then + data=`nc -z -w 1 127.0.0.1 $port | grep -ic succeeded` + echo $data + return + fi + echo "0" + return +} + +function getMyIp() { + case "`uname`" in + Darwin) + myip=`echo "show State:/Network/Global/IPv4" | scutil | grep PrimaryInterface | awk '{print $3}' | xargs ifconfig | grep inet | grep -v inet6 | awk '{print $2}'` + ;; + *) + myip=`ip route get 1 | awk '{print $NF;exit}'` + ;; + esac + echo $myip +} + +NET_MODE="" +case "`uname`" in + Darwin) + bin_abs_path=`cd $(dirname $0); pwd` + ;; + Linux) + bin_abs_path=$(readlink -f $(dirname $0)) + NET_MODE="--net=host" + ;; + *) + NET_MODE="--net=host" + bin_abs_path=`cd $(dirname $0); pwd` + ;; +esac +BASE=${bin_abs_path} +if [ $# -eq 0 ]; then + usage +elif [ "$1" == "-h" ] ; then + usage +elif [ "$1" == "help" ] ; then + usage +fi + +DATA="$BASE/data" +mkdir -p $DATA +CONFIG=${@:1} +#VOLUMNS="-v $DATA:/home/admin/canal-server/logs" +PORTLIST="8000 8080 2222 11111" +PORTS="" +for PORT in $PORTLIST ; do + #exist=`check_port $PORT` + exist="0" + if [ "$exist" == "0" ]; then + PORTS="$PORTS -p $PORT:$PORT" + else + echo "port $PORT is used , pls check" + exit 1 + fi +done + +MEMORY="-m 4096m" +LOCALHOST=`getMyIp` +cmd="docker run -it -h $LOCALHOST $CONFIG --name=canal-server $VOLUMNS $NET_MODE $PORTS $MEMORY canal/canal-server" +echo $cmd +eval $cmd \ No newline at end of file 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 a8e6305a..0f01cbd5 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 @@ -32,7 +32,7 @@ public class MysqlConnector { private String password; private byte charsetNumber = 33; - private String defaultSchema = "retl"; + private String defaultSchema = "test"; private int soTimeout = 30 * 1000; private int connTimeout = 5 * 1000; private int receiveBufferSize = 16 * 1024; @@ -53,7 +53,7 @@ public class MysqlConnector { String addr = address.getHostString(); int port = address.getPort(); this.address = new InetSocketAddress(addr, port); - + this.username = username; this.password = password; } diff --git a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/GTIDSet.java b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/GTIDSet.java index 9b028fc2..39b7efeb 100644 --- a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/GTIDSet.java +++ b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/GTIDSet.java @@ -3,8 +3,7 @@ package com.alibaba.otter.canal.parse.driver.mysql.packets; import java.io.IOException; /** - * Created by hiwjd on 2018/4/23. - * hiwjd0@gmail.com + * Created by hiwjd on 2018/4/23. hiwjd0@gmail.com */ public interface GTIDSet { @@ -17,6 +16,7 @@ public interface GTIDSet { /** * 更新当前实例 + * * @param str * @throws Exception */ diff --git a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/MysqlGTIDSet.java b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/MysqlGTIDSet.java index 4428fb5a..35872370 100644 --- a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/MysqlGTIDSet.java +++ b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/MysqlGTIDSet.java @@ -1,14 +1,14 @@ package com.alibaba.otter.canal.parse.driver.mysql.packets; -import com.alibaba.otter.canal.parse.driver.mysql.utils.ByteHelper; - import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.util.*; +import java.util.HashMap; +import java.util.Map; + +import com.alibaba.otter.canal.parse.driver.mysql.utils.ByteHelper; /** - * Created by hiwjd on 2018/4/23. - * hiwjd0@gmail.com + * Created by hiwjd on 2018/4/23. hiwjd0@gmail.com */ public class MysqlGTIDSet implements GTIDSet { @@ -56,61 +56,26 @@ public class MysqlGTIDSet implements GTIDSet { } /** - * 解析如下格式的字符串为MysqlGTIDSet: - * - * 726757ad-4455-11e8-ae04-0242ac110002:1 => - * MysqlGTIDSet{ - * sets: { - * 726757ad-4455-11e8-ae04-0242ac110002: UUIDSet{ - * SID: 726757ad-4455-11e8-ae04-0242ac110002, - * intervals: [{start:1, stop:2}] - * } - * } - * } - * - * 726757ad-4455-11e8-ae04-0242ac110002:1-3 => - * MysqlGTIDSet{ - * sets: { - * 726757ad-4455-11e8-ae04-0242ac110002: UUIDSet{ - * SID: 726757ad-4455-11e8-ae04-0242ac110002, - * intervals: [{start:1, stop:4}] - * } - * } - * } - * - * 726757ad-4455-11e8-ae04-0242ac110002:1-3:4 => - * MysqlGTIDSet{ - * sets: { - * 726757ad-4455-11e8-ae04-0242ac110002: UUIDSet{ - * SID: 726757ad-4455-11e8-ae04-0242ac110002, - * intervals: [{start:1, stop:5}] - * } - * } - * } - * - * 726757ad-4455-11e8-ae04-0242ac110002:1-3:7-9 => - * MysqlGTIDSet{ - * sets: { - * 726757ad-4455-11e8-ae04-0242ac110002: UUIDSet{ - * SID: 726757ad-4455-11e8-ae04-0242ac110002, - * intervals: [{start:1, stop:4}, {start:7, stop: 10}] - * } - * } - * } - * - * 726757ad-4455-11e8-ae04-0242ac110002:1-3,726757ad-4455-11e8-ae04-0242ac110003:4 => - * MysqlGTIDSet{ - * sets: { - * 726757ad-4455-11e8-ae04-0242ac110002: UUIDSet{ - * SID: 726757ad-4455-11e8-ae04-0242ac110002, - * intervals: [{start:1, stop:4}] - * }, - * 726757ad-4455-11e8-ae04-0242ac110003: UUIDSet{ - * SID: 726757ad-4455-11e8-ae04-0242ac110002, - * intervals: [{start:4, stop:5}] - * } - * } - * } + * 解析如下格式的字符串为MysqlGTIDSet: 726757ad-4455-11e8-ae04-0242ac110002:1 => + * MysqlGTIDSet{ sets: { 726757ad-4455-11e8-ae04-0242ac110002: UUIDSet{ SID: + * 726757ad-4455-11e8-ae04-0242ac110002, intervals: [{start:1, stop:2}] } } + * } 726757ad-4455-11e8-ae04-0242ac110002:1-3 => MysqlGTIDSet{ sets: { + * 726757ad-4455-11e8-ae04-0242ac110002: UUIDSet{ SID: + * 726757ad-4455-11e8-ae04-0242ac110002, intervals: [{start:1, stop:4}] } } + * } 726757ad-4455-11e8-ae04-0242ac110002:1-3:4 => MysqlGTIDSet{ sets: { + * 726757ad-4455-11e8-ae04-0242ac110002: UUIDSet{ SID: + * 726757ad-4455-11e8-ae04-0242ac110002, intervals: [{start:1, stop:5}] } } + * } 726757ad-4455-11e8-ae04-0242ac110002:1-3:7-9 => MysqlGTIDSet{ sets: { + * 726757ad-4455-11e8-ae04-0242ac110002: UUIDSet{ SID: + * 726757ad-4455-11e8-ae04-0242ac110002, intervals: [{start:1, stop:4}, + * {start:7, stop: 10}] } } } + * 726757ad-4455-11e8-ae04-0242ac110002:1-3,726757 + * ad-4455-11e8-ae04-0242ac110003:4 => MysqlGTIDSet{ sets: { + * 726757ad-4455-11e8-ae04-0242ac110002: UUIDSet{ SID: + * 726757ad-4455-11e8-ae04-0242ac110002, intervals: [{start:1, stop:4}] }, + * 726757ad-4455-11e8-ae04-0242ac110003: UUIDSet{ SID: + * 726757ad-4455-11e8-ae04-0242ac110002, intervals: [{start:4, stop:5}] } } + * } * * @param gtidData * @return diff --git a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/UUIDSet.java b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/UUIDSet.java index 9a3354b4..5b2f9b30 100644 --- a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/UUIDSet.java +++ b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/UUIDSet.java @@ -1,7 +1,5 @@ package com.alibaba.otter.canal.parse.driver.mysql.packets; -import com.alibaba.otter.canal.parse.driver.mysql.utils.ByteHelper; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.ByteBuffer; @@ -10,13 +8,14 @@ import java.util.Collections; import java.util.List; import java.util.UUID; +import com.alibaba.otter.canal.parse.driver.mysql.utils.ByteHelper; + /** - * Created by hiwjd on 2018/4/23. - * hiwjd0@gmail.com + * Created by hiwjd on 2018/4/23. hiwjd0@gmail.com */ public class UUIDSet { - public UUID SID; + public UUID SID; public List intervals; public byte[] encode() throws IOException { @@ -54,6 +53,7 @@ public class UUIDSet { } public static class Interval implements Comparable { + public long start; public long stop; @@ -85,19 +85,15 @@ public class UUIDSet { } /** - * 解析如下格式字符串为UUIDSet: - * - * 726757ad-4455-11e8-ae04-0242ac110002:1 => - * UUIDSet{SID: 726757ad-4455-11e8-ae04-0242ac110002, intervals: [{start:1, stop:2}]} - * - * 726757ad-4455-11e8-ae04-0242ac110002:1-3 => - * UUIDSet{SID: 726757ad-4455-11e8-ae04-0242ac110002, intervals: [{start:1, stop:4}]} - * - * 726757ad-4455-11e8-ae04-0242ac110002:1-3:4 - * UUIDSet{SID: 726757ad-4455-11e8-ae04-0242ac110002, intervals: [{start:1, stop:5}]} - * - * 726757ad-4455-11e8-ae04-0242ac110002:1-3:7-9 - * UUIDSet{SID: 726757ad-4455-11e8-ae04-0242ac110002, intervals: [{start:1, stop:4}, {start:7, stop:10}]} + * 解析如下格式字符串为UUIDSet: 726757ad-4455-11e8-ae04-0242ac110002:1 => UUIDSet{SID: + * 726757ad-4455-11e8-ae04-0242ac110002, intervals: [{start:1, stop:2}]} + * 726757ad-4455-11e8-ae04-0242ac110002:1-3 => UUIDSet{SID: + * 726757ad-4455-11e8-ae04-0242ac110002, intervals: [{start:1, stop:4}]} + * 726757ad-4455-11e8-ae04-0242ac110002:1-3:4 UUIDSet{SID: + * 726757ad-4455-11e8-ae04-0242ac110002, intervals: [{start:1, stop:5}]} + * 726757ad-4455-11e8-ae04-0242ac110002:1-3:7-9 UUIDSet{SID: + * 726757ad-4455-11e8-ae04-0242ac110002, intervals: [{start:1, stop:4}, + * {start:7, stop:10}]} * * @param str * @return @@ -110,7 +106,7 @@ public class UUIDSet { } List intervals = new ArrayList(); - for (int i=1; i Interval{start:1, stop:2} - * 1-3 => Interval{start:1, stop:4} - * - * 注意!字符串格式表达时[n,m]是两侧都包含的,Interval表达时[n,m)右侧开 + * 解析如下格式字符串为Interval: 1 => Interval{start:1, stop:2} 1-3 => + * Interval{start:1, stop:4} 注意!字符串格式表达时[n,m]是两侧都包含的,Interval表达时[n,m)右侧开 * * @param str * @return @@ -173,8 +165,8 @@ public class UUIDSet { } /** - * 把{start,stop}连续的合并掉: - * [{start:1, stop:4},{start:4, stop:5}] => [{start:1, stop:5}] + * 把{start,stop}连续的合并掉: [{start:1, stop:4},{start:4, stop:5}] => [{start:1, + * stop:5}] * * @param intervals * @return @@ -183,11 +175,11 @@ public class UUIDSet { List combined = new ArrayList(); Collections.sort(intervals); int len = intervals.size(); - for (int i=0; i= intervals.get(j).start) { intervals.get(i).stop = intervals.get(j).stop; } else { diff --git a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/client/BinlogDumpGTIDCommandPacket.java b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/client/BinlogDumpGTIDCommandPacket.java index 36c274c3..ef9526b1 100644 --- a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/client/BinlogDumpGTIDCommandPacket.java +++ b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/client/BinlogDumpGTIDCommandPacket.java @@ -1,28 +1,26 @@ package com.alibaba.otter.canal.parse.driver.mysql.packets.client; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + import com.alibaba.otter.canal.parse.driver.mysql.packets.CommandPacket; import com.alibaba.otter.canal.parse.driver.mysql.packets.GTIDSet; import com.alibaba.otter.canal.parse.driver.mysql.utils.ByteHelper; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - /** - * Created by hiwjd on 2018/4/24. - * hiwjd0@gmail.com - * + * Created by hiwjd on 2018/4/24. hiwjd0@gmail.com * https://dev.mysql.com/doc/internals/en/com-binlog-dump-gtid.html */ public class BinlogDumpGTIDCommandPacket extends CommandPacket { - public static final int BINLOG_DUMP_NON_BLOCK = 0x01; + public static final int BINLOG_DUMP_NON_BLOCK = 0x01; public static final int BINLOG_THROUGH_POSITION = 0x02; - public static final int BINLOG_THROUGH_GTID = 0x04; + public static final int BINLOG_THROUGH_GTID = 0x04; - public long slaveServerId; - public GTIDSet gtidSet; + public long slaveServerId; + public GTIDSet gtidSet; - public BinlogDumpGTIDCommandPacket() { + public BinlogDumpGTIDCommandPacket(){ setCommand((byte) 0x1e); } @@ -51,15 +49,15 @@ public class BinlogDumpGTIDCommandPacket extends CommandPacket { // 6. [4] data-size ByteHelper.writeUnsignedIntLittleEndian(bs.length, out); // 7, [] data - // [8] n_sids // 文档写的是4个字节,其实是8个字节 - // for n_sids { - // [16] SID - // [8] n_intervals - // for n_intervals { - // [8] start (signed) - // [8] end (signed) - // } - // } + // [8] n_sids // 文档写的是4个字节,其实是8个字节 + // for n_sids { + // [16] SID + // [8] n_intervals + // for n_intervals { + // [8] start (signed) + // [8] end (signed) + // } + // } out.write(bs); // } diff --git a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/BioSocketChannel.java b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/BioSocketChannel.java index 4a272fd6..f746189e 100644 --- a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/BioSocketChannel.java +++ b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/BioSocketChannel.java @@ -1,5 +1,6 @@ package com.alibaba.otter.canal.parse.driver.mysql.socket; +import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -24,7 +25,7 @@ public class BioSocketChannel implements SocketChannel { BioSocketChannel(Socket socket) throws IOException{ this.socket = socket; - this.input = socket.getInputStream(); + this.input = new BufferedInputStream(socket.getInputStream(), 16384); this.output = socket.getOutputStream(); } @@ -93,6 +94,37 @@ public class BioSocketChannel implements SocketChannel { return data; } + @Override + public void read(byte[] data, int off, int len, int timeout) throws IOException { + InputStream input = this.input; + int accTimeout = 0; + if (input == null) { + throw new SocketException("Socket already closed."); + } + + int n = 0; + while (n < len && accTimeout < timeout) { + try { + int read = input.read(data, off + n, len - n); + if (read > -1) { + n += read; + } else { + throw new IOException("EOF encountered."); + } + } catch (SocketTimeoutException te) { + if (Thread.interrupted()) { + throw new ClosedByInterruptException(); + } + accTimeout += SO_TIMEOUT; + } + } + + if (n < len && accTimeout >= timeout) { + throw new SocketTimeoutException("Timeout occurred, failed to read " + len + " bytes in " + timeout + + " milliseconds."); + } + } + public boolean isConnected() { Socket socket = this.socket; if (socket != null) { 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 3af1d469..dcc17bad 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 @@ -11,8 +11,6 @@ public abstract class BioSocketChannelPool { public static BioSocketChannel open(SocketAddress address) throws Exception { Socket socket = new Socket(); - socket.setReceiveBufferSize(32 * 1024); - socket.setSendBufferSize(32 * 1024); socket.setSoTimeout(BioSocketChannel.SO_TIMEOUT); socket.setTcpNoDelay(true); socket.setKeepAlive(true); diff --git a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/NettySocketChannel.java b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/NettySocketChannel.java index 3ba9b104..782af21e 100644 --- a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/NettySocketChannel.java +++ b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/NettySocketChannel.java @@ -11,6 +11,7 @@ import io.netty.util.internal.SystemPropertyUtil; import java.io.IOException; import java.net.SocketAddress; +import org.apache.commons.lang.NotImplementedException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -202,6 +203,11 @@ public class NettySocketChannel implements SocketChannel { } while (true); } + @Override + public void read(byte[] data, int off, int len, int timeout) throws IOException { + throw new NotImplementedException(); + } + public boolean isConnected() { return channel != null ? true : false; } @@ -224,4 +230,5 @@ public class NettySocketChannel implements SocketChannel { } } + } diff --git a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/NettySocketChannelPool.java b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/NettySocketChannelPool.java index e97f6a4f..4a8ece1b 100644 --- a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/NettySocketChannelPool.java +++ b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/NettySocketChannelPool.java @@ -29,19 +29,18 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({ "rawtypes", "deprecation" }) public abstract class NettySocketChannelPool { - private static EventLoopGroup group = new NioEventLoopGroup(); // 非阻塞IO线程组 - private static Bootstrap boot = new Bootstrap(); // 主 + private static EventLoopGroup group = new NioEventLoopGroup(); // 非阻塞IO线程组 + private static Bootstrap boot = new Bootstrap(); // 主 private static Map chManager = new ConcurrentHashMap(); private static final Logger logger = LoggerFactory.getLogger(NettySocketChannelPool.class); static { boot.group(group) .channel(NioSocketChannel.class) - .option(ChannelOption.SO_RCVBUF, 32 * 1024) - .option(ChannelOption.SO_SNDBUF, 32 * 1024) .option(ChannelOption.TCP_NODELAY, true) // 如果是延时敏感型应用,建议关闭Nagle算法 .option(ChannelOption.SO_KEEPALIVE, true) + .option(ChannelOption.SO_REUSEADDR, true) .option(ChannelOption.RCVBUF_ALLOCATOR, AdaptiveRecvByteBufAllocator.DEFAULT) .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) // diff --git a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/SocketChannel.java b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/SocketChannel.java index 952fde53..67f967ab 100644 --- a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/SocketChannel.java +++ b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/SocketChannel.java @@ -15,6 +15,8 @@ public interface SocketChannel { public byte[] read(int readSize, int timeout) throws IOException; + public void read(byte[] data, int off, int len, int timeout) throws IOException; + public boolean isConnected(); public SocketAddress getRemoteSocketAddress(); diff --git a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/utils/ByteHelper.java b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/utils/ByteHelper.java index 04ba2685..471cd2bc 100644 --- a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/utils/ByteHelper.java +++ b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/utils/ByteHelper.java @@ -108,7 +108,7 @@ public abstract class ByteHelper { return out.toByteArray(); } - + public static void write8ByteUnsignedIntLittleEndian(long data, ByteArrayOutputStream out) { out.write((byte) (data & 0xFF)); out.write((byte) (data >>> 8)); @@ -119,7 +119,7 @@ public abstract class ByteHelper { out.write((byte) (data >>> 48)); out.write((byte) (data >>> 56)); } - + public static void writeUnsignedIntLittleEndian(long data, ByteArrayOutputStream out) { out.write((byte) (data & 0xFF)); out.write((byte) (data >>> 8)); diff --git a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/utils/PacketManager.java b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/utils/PacketManager.java index bdf01196..7841205c 100644 --- a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/utils/PacketManager.java +++ b/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/utils/PacketManager.java @@ -14,15 +14,15 @@ public abstract class PacketManager { } public static HeaderPacket readHeader(SocketChannel ch, int len, int timeout) throws IOException { - HeaderPacket header = new HeaderPacket(); - header.fromBytes(ch.read(len, timeout)); - return header; + HeaderPacket header = new HeaderPacket(); + header.fromBytes(ch.read(len, timeout)); + return header; } public static byte[] readBytes(SocketChannel ch, int len) throws IOException { return ch.read(len); } - + public static byte[] readBytes(SocketChannel ch, int len, int timeout) throws IOException { return ch.read(len, timeout); } diff --git a/driver/src/test/java/com/alibaba/otter/canal/parse/driver/mysql/MysqlGTIDSetTest.java b/driver/src/test/java/com/alibaba/otter/canal/parse/driver/mysql/MysqlGTIDSetTest.java index 4744168d..f423686d 100644 --- a/driver/src/test/java/com/alibaba/otter/canal/parse/driver/mysql/MysqlGTIDSetTest.java +++ b/driver/src/test/java/com/alibaba/otter/canal/parse/driver/mysql/MysqlGTIDSetTest.java @@ -1,17 +1,23 @@ package com.alibaba.otter.canal.parse.driver.mysql; +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.junit.Test; + import com.alibaba.otter.canal.parse.driver.mysql.packets.GTIDSet; import com.alibaba.otter.canal.parse.driver.mysql.packets.MysqlGTIDSet; import com.alibaba.otter.canal.parse.driver.mysql.packets.UUIDSet; -import org.junit.Test; -import static org.junit.Assert.*; - -import java.io.IOException; -import java.util.*; /** - * Created by hiwjd on 2018/4/25. - * hiwjd0@gmail.com + * Created by hiwjd on 2018/4/25. hiwjd0@gmail.com */ public class MysqlGTIDSetTest { @@ -20,14 +26,12 @@ public class MysqlGTIDSetTest { GTIDSet gtidSet = MysqlGTIDSet.parse("726757ad-4455-11e8-ae04-0242ac110002:1"); byte[] bytes = gtidSet.encode(); - byte[] expected = { - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x67, 0x57, (byte)0xad, - 0x44, 0x55, 0x11, (byte)0xe8, (byte)0xae, 0x04, 0x02, 0x42, (byte)0xac, 0x11, 0x00, 0x02, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + byte[] expected = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x67, 0x57, (byte) 0xad, 0x44, 0x55, + 0x11, (byte) 0xe8, (byte) 0xae, 0x04, 0x02, 0x42, (byte) 0xac, 0x11, 0x00, 0x02, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }; - for (int i=0; i cases = new HashMap(5); - cases.put( - "726757ad-4455-11e8-ae04-0242ac110002:1", - buildForTest(new Material("726757ad-4455-11e8-ae04-0242ac110002", 1, 2)) - ); - cases.put( - "726757ad-4455-11e8-ae04-0242ac110002:1-3", - buildForTest(new Material("726757ad-4455-11e8-ae04-0242ac110002", 1, 4)) - ); - cases.put( - "726757ad-4455-11e8-ae04-0242ac110002:1-3:4", - buildForTest(new Material("726757ad-4455-11e8-ae04-0242ac110002", 1, 5)) - ); - cases.put( - "726757ad-4455-11e8-ae04-0242ac110002:1-3:7-9", - buildForTest(new Material("726757ad-4455-11e8-ae04-0242ac110002", 1, 4, 7, 10)) - ); - cases.put( - "726757ad-4455-11e8-ae04-0242ac110002:1-3,726757ad-4455-11e8-ae04-0242ac110003:4", - buildForTest( - Arrays.asList( - new Material("726757ad-4455-11e8-ae04-0242ac110002", 1, 4), - new Material("726757ad-4455-11e8-ae04-0242ac110003", 4, 5) - ) - ) - ); + cases.put("726757ad-4455-11e8-ae04-0242ac110002:1", + buildForTest(new Material("726757ad-4455-11e8-ae04-0242ac110002", 1, 2))); + cases.put("726757ad-4455-11e8-ae04-0242ac110002:1-3", + buildForTest(new Material("726757ad-4455-11e8-ae04-0242ac110002", 1, 4))); + cases.put("726757ad-4455-11e8-ae04-0242ac110002:1-3:4", + buildForTest(new Material("726757ad-4455-11e8-ae04-0242ac110002", 1, 5))); + cases.put("726757ad-4455-11e8-ae04-0242ac110002:1-3:7-9", + buildForTest(new Material("726757ad-4455-11e8-ae04-0242ac110002", 1, 4, 7, 10))); + cases.put("726757ad-4455-11e8-ae04-0242ac110002:1-3,726757ad-4455-11e8-ae04-0242ac110003:4", + buildForTest(Arrays.asList(new Material("726757ad-4455-11e8-ae04-0242ac110002", 1, 4), + new Material("726757ad-4455-11e8-ae04-0242ac110003", 4, 5)))); for (Map.Entry entry : cases.entrySet()) { MysqlGTIDSet expected = entry.getValue(); @@ -71,7 +61,7 @@ public class MysqlGTIDSetTest { private static class Material { - public Material(String uuid, long start, long stop) { + public Material(String uuid, long start, long stop){ this.uuid = uuid; this.start = start; this.stop = stop; @@ -79,7 +69,7 @@ public class MysqlGTIDSetTest { this.stop1 = 0; } - public Material(String uuid, long start, long stop, long start1, long stop1) { + public Material(String uuid, long start, long stop, long start1, long stop1){ this.uuid = uuid; this.start = start; this.stop = stop; @@ -88,10 +78,10 @@ public class MysqlGTIDSetTest { } public String uuid; - public long start; - public long stop; - public long start1; - public long stop1; + public long start; + public long stop; + public long start1; + public long stop1; } private MysqlGTIDSet buildForTest(Material material) { diff --git a/driver/src/test/java/com/alibaba/otter/canal/parse/driver/mysql/UUIDSetTest.java b/driver/src/test/java/com/alibaba/otter/canal/parse/driver/mysql/UUIDSetTest.java index 4cdf10da..4ed025dc 100644 --- a/driver/src/test/java/com/alibaba/otter/canal/parse/driver/mysql/UUIDSetTest.java +++ b/driver/src/test/java/com/alibaba/otter/canal/parse/driver/mysql/UUIDSetTest.java @@ -1,16 +1,16 @@ package com.alibaba.otter.canal.parse.driver.mysql; -import com.alibaba.otter.canal.parse.driver.mysql.packets.UUIDSet; -import org.junit.Test; +import static org.junit.Assert.assertEquals; import java.util.HashMap; import java.util.Map; -import static org.junit.Assert.*; +import org.junit.Test; + +import com.alibaba.otter.canal.parse.driver.mysql.packets.UUIDSet; /** - * Created by hiwjd on 2018/4/26. - * hiwjd0@gmail.com + * Created by hiwjd on 2018/4/26. hiwjd0@gmail.com */ public class UUIDSetTest { diff --git a/example/pom.xml b/example/pom.xml index 1f60bc01..2897e821 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -21,6 +21,82 @@ canal.protocol ${project.version} + + com.alibaba + druid + + + mysql + mysql-connector-java + + + org.apache.ddlutils + ddlutils + 1.0 + + + commons-beanutils + commons-beanutils-core + + + commons-lang + commons-lang + + + commons-dbcp + commons-dbcp + + + commons-pool + commons-pool + + + commons-logging + commons-logging-api + + + dom4j + dom4j + + + stax + stax-api + + + commons-collections + commons-collections + + + commons-digester + commons-digester + + + commons-betwixt + commons-betwixt + + + + + org.apache.commons + commons-pool2 + 2.5.0 + + + commons-beanutils + commons-beanutils + 1.8.2 + + + org.apache.commons + commons-lang3 + 3.7 + + + commons-collections + commons-collections + 3.2 + + junit diff --git a/example/src/main/java/com/alibaba/otter/canal/example/AbstractCanalClientTest.java b/example/src/main/java/com/alibaba/otter/canal/example/AbstractCanalClientTest.java index 6b30b98b..d1ddd88e 100644 --- a/example/src/main/java/com/alibaba/otter/canal/example/AbstractCanalClientTest.java +++ b/example/src/main/java/com/alibaba/otter/canal/example/AbstractCanalClientTest.java @@ -3,6 +3,7 @@ package com.alibaba.otter.canal.example; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; +import java.util.concurrent.TimeUnit; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.SystemUtils; @@ -13,7 +14,6 @@ import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; import com.alibaba.otter.canal.client.CanalConnector; -import com.alibaba.otter.canal.client.impl.ClusterCanalConnector; import com.alibaba.otter.canal.protocol.CanalEntry.Column; import com.alibaba.otter.canal.protocol.CanalEntry.Entry; import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; @@ -38,7 +38,6 @@ public class AbstractCanalClientTest { protected static final String SEP = SystemUtils.LINE_SEPARATOR; protected static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; protected volatile boolean running = false; - private volatile boolean waiting = true; protected Thread.UncaughtExceptionHandler handler = new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { @@ -96,13 +95,8 @@ public class AbstractCanalClientTest { if (!running) { return; } + connector.stopRunning(); running = false; - if (waiting) { - if (connector instanceof ClusterCanalConnector) { - ((ClusterCanalConnector) connector).setRetryTimes(-1); - } - thread.interrupt(); - } if (thread != null) { try { thread.join(); @@ -121,7 +115,6 @@ public class AbstractCanalClientTest { MDC.put("destination", destination); connector.connect(); connector.subscribe(); - waiting = false; while (running) { Message message = connector.getWithoutAck(batchSize); // 获取指定数量的数据 long batchId = message.getId(); diff --git a/example/src/main/java/com/alibaba/otter/canal/example/SimpleCanalClientPermanceTest.java b/example/src/main/java/com/alibaba/otter/canal/example/SimpleCanalClientPermanceTest.java new file mode 100644 index 00000000..c58eb869 --- /dev/null +++ b/example/src/main/java/com/alibaba/otter/canal/example/SimpleCanalClientPermanceTest.java @@ -0,0 +1,68 @@ +package com.alibaba.otter.canal.example; +import java.net.InetSocketAddress; +import java.util.concurrent.ArrayBlockingQueue; + +import com.alibaba.otter.canal.client.CanalConnector; +import com.alibaba.otter.canal.client.CanalConnectors; +import com.alibaba.otter.canal.client.impl.SimpleCanalConnector; +import com.alibaba.otter.canal.protocol.Message; + +public class SimpleCanalClientPermanceTest { + + public static void main(String args[]) { + String destination = "example"; + String ip = "127.0.0.1"; + int batchSize = 1024; + int count = 0; + int sum = 0; + int perSum = 0; + long start = System.currentTimeMillis(); + long end = 0; + final ArrayBlockingQueue queue = new ArrayBlockingQueue(100); + try { + final CanalConnector connector = CanalConnectors.newSingleConnector(new InetSocketAddress(ip, 11111), + destination, + "", + ""); + + Thread ackThread = new Thread(new Runnable() { + + @Override + public void run() { + while (true) { + try { + long batchId = queue.take(); + connector.ack(batchId); + } catch (InterruptedException e) { + } + } + } + }); + ackThread.start(); + + ((SimpleCanalConnector) connector).setLazyParseEntry(true); + connector.connect(); + connector.subscribe(); + while (true) { + Message message = connector.getWithoutAck(batchSize); + long batchId = message.getId(); + int size = message.getRawEntries().size(); + sum += size; + perSum += size; + count++; + queue.add(batchId); + if (count % 10 == 0) { + end = System.currentTimeMillis(); + long tps = (perSum * 1000) / (end - start); + System.out.println(" total : " + sum + " , current : " + perSum + " , cost : " + (end - start) + + " , tps : " + tps); + start = end; + perSum = 0; + } + } + } catch (Throwable e) { + e.printStackTrace(); + } + } + +} diff --git a/example/src/main/java/com/alibaba/otter/canal/example/db/AbstractDbClient.java b/example/src/main/java/com/alibaba/otter/canal/example/db/AbstractDbClient.java new file mode 100644 index 00000000..ec998e55 --- /dev/null +++ b/example/src/main/java/com/alibaba/otter/canal/example/db/AbstractDbClient.java @@ -0,0 +1,144 @@ +package com.alibaba.otter.canal.example.db; + +import com.alibaba.otter.canal.protocol.CanalEntry; +import com.alibaba.otter.canal.protocol.Message; +import org.slf4j.MDC; + +import java.util.Date; +import java.util.List; + +public abstract class AbstractDbClient extends CanalConnectorClient { + + + public abstract void insert(CanalEntry.Header header, List afterColumns); + + public abstract void update(CanalEntry.Header header, List afterColumns); + + public abstract void delete(CanalEntry.Header header, List beforeColumns); + + + @Override + public synchronized void start() { + if (running) { + return; + } + super.start(); + } + + @Override + public synchronized void stop() { + if (!running) { + return; + } + super.stop(); + MDC.remove("destination"); + } + + @Override + protected void processMessage(Message message) { + long batchId = message.getId(); + //遍历每条消息 + for (CanalEntry.Entry entry : message.getEntries()) { + session(entry);//no exception + } + //ack all the time。 + connector.ack(batchId); + } + + private void session(CanalEntry.Entry entry) { + CanalEntry.EntryType entryType = entry.getEntryType(); + int times = 0; + boolean success = false; + while (!success) { + if (times > 0) { + /** + * 1:retry,重试,重试默认为3次,由retryTimes参数决定,如果重试次数达到阈值,则跳过,并且记录日志。 + * 2:ignore,直接忽略,不重试,记录日志。 + */ + if (exceptionStrategy == ExceptionStrategy.RETRY.code) { + if (times >= retryTimes) { + break; + } + } else { + break; + } + } + try { + switch (entryType) { + case TRANSACTIONBEGIN: + transactionBegin(entry); + break; + case TRANSACTIONEND: + transactionEnd(entry); + break; + case ROWDATA: + rowData(entry); + break; + default: + break; + } + success = true; + } catch (Exception e) { + times++; + logger.error("parse event has an error ,times: + " + times + ", data:" + entry.toString(), e); + } + + } + } + + private void rowData(CanalEntry.Entry entry) throws Exception { + CanalEntry.RowChange rowChange = CanalEntry.RowChange.parseFrom(entry.getStoreValue()); + CanalEntry.EventType eventType = rowChange.getEventType(); + CanalEntry.Header header = entry.getHeader(); + long executeTime = header.getExecuteTime(); + long delayTime = new Date().getTime() - executeTime; + String sql = rowChange.getSql(); + + try { + if (!isDML(eventType) || rowChange.getIsDdl()) { + processDDL(header, eventType, sql); + return; + } + //处理DML数据 + processDML(header, eventType, rowChange, sql); + } catch (Exception e) { + logger.error("process event error ,", e); + logger.error(rowFormat, + new Object[]{header.getLogfileName(), String.valueOf(header.getLogfileOffset()), + header.getSchemaName(), header.getTableName(), eventType, + String.valueOf(executeTime), String.valueOf(delayTime)}); + throw e;//重新抛出 + } + } + + /** + * 处理 dml 数据 + * + * @param header + * @param eventType + * @param rowChange + * @param sql + */ + protected void processDML(CanalEntry.Header header, CanalEntry.EventType eventType, CanalEntry.RowChange rowChange, String sql) { + for (CanalEntry.RowData rowData : rowChange.getRowDatasList()) { + switch (eventType) { + case DELETE: + delete(header, rowData.getBeforeColumnsList()); + break; + case INSERT: + insert(header, rowData.getAfterColumnsList()); + break; + case UPDATE: + update(header, rowData.getAfterColumnsList()); + break; + default: + whenOthers(header, sql); + } + } + } + +} + + + + diff --git a/example/src/main/java/com/alibaba/otter/canal/example/db/CanalConnectorClient.java b/example/src/main/java/com/alibaba/otter/canal/example/db/CanalConnectorClient.java new file mode 100644 index 00000000..844f60db --- /dev/null +++ b/example/src/main/java/com/alibaba/otter/canal/example/db/CanalConnectorClient.java @@ -0,0 +1,488 @@ +package com.alibaba.otter.canal.example.db; + +import com.alibaba.otter.canal.client.CanalConnector; +import com.alibaba.otter.canal.client.CanalConnectors; +import com.alibaba.otter.canal.common.AbstractCanalLifeCycle; +import com.alibaba.otter.canal.protocol.CanalEntry; +import com.alibaba.otter.canal.protocol.Message; +import org.apache.commons.lang.SystemUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.util.CollectionUtils; + +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +public abstract class CanalConnectorClient extends AbstractCanalLifeCycle implements InitializingBean { + + protected static final Logger logger = LoggerFactory.getLogger(CanalConnectorClient.class); + protected static final String SEP = SystemUtils.LINE_SEPARATOR; + protected static String contextFormat; + protected static String rowFormat; + protected static String transactionFormat; + protected static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; + + static { + StringBuilder sb = new StringBuilder(); + sb.append(SEP) + .append("-------------Batch-------------") + .append(SEP) + .append("* Batch Id: [{}] ,count : [{}] , Mem size : [{}] , Time : {}") + .append(SEP) + .append("* Start : [{}] ") + .append(SEP) + .append("* End : [{}] ") + .append(SEP) + .append("-------------------------------") + .append(SEP); + contextFormat = sb.toString(); + + sb = new StringBuilder(); + sb.append(SEP) + .append("+++++++++++++Row+++++++++++++>>>") + .append("binlog[{}:{}] , name[{},{}] , eventType : {} , executeTime : {} , delay : {}ms") + .append(SEP); + rowFormat = sb.toString(); + + sb = new StringBuilder(); + sb.append(SEP) + .append("===========Transaction {} : {}=======>>>") + .append("binlog[{}:{}] , executeTime : {} , delay : {}ms") + .append(SEP); + transactionFormat = sb.toString(); + } + + private String zkServers;//cluster + private String address;//single,ip:port + private String destination; + private String username; + private String password; + private int batchSize = 5 * 1024; + private String filter = "";//同canal filter,用于过滤database或者table的相关数据。 + protected boolean debug = false;//开启debug,会把每条消息的详情打印 + + //1:retry,重试,重试默认为3次,由retryTimes参数决定,如果重试次数达到阈值,则跳过,并且记录日志。 + //2:ignore,直接忽略,不重试,记录日志。 + protected int exceptionStrategy = 1; + protected int retryTimes = 3; + protected int waitingTime = 100;//当binlog没有数据时,主线程等待的时间,单位ms,大于0 + + + protected CanalConnector connector; + protected Thread thread; + + protected Thread.UncaughtExceptionHandler handler = new Thread.UncaughtExceptionHandler() { + + public void uncaughtException(Thread t, Throwable e) { + logger.error("process message has an error", e); + } + }; + + @Override + public void afterPropertiesSet() { + if (waitingTime <= 0) { + throw new IllegalArgumentException("waitingTime must be greater than 0"); + } + if (ExceptionStrategy.codeOf(exceptionStrategy) == null) { + throw new IllegalArgumentException("exceptionStrategy is not valid,1 or 2"); + } + start(); + } + + @Override + public void start() { + if (running) { + return; + } + super.start(); + initConnector(); + + thread = new Thread(new Runnable() { + + public void run() { + process(); + } + }); + + thread.setUncaughtExceptionHandler(handler); + thread.start(); + } + + @Override + public void stop() { + if (!running) { + return; + } + super.stop(); + quietlyStop(thread); + } + + protected void quietlyStop(Thread task) { + if (task != null) { + task.interrupt(); + try { + task.join(); + } catch (InterruptedException e) { + // ignore + } + } + } + + public void process() { + int times = 0; + while (running) { + try { + sleepWhenFailed(times); + //after block, should check the status of thread. + if (!running) { + break; + } + MDC.put("destination", destination); + connector.connect(); + connector.subscribe(filter); + connector.rollback(); + times = 0;//reset; + + while (running) { + // 获取指定数量的数据,不确认 + Message message = connector.getWithoutAck(batchSize); + + long batchId = message.getId(); + int size = message.getEntries().size(); + + if (batchId == -1 || size == 0) { + try { + Thread.sleep(waitingTime); + } catch (InterruptedException e) { + // + } + continue; + } + //logger + printBatch(message, batchId); + + processMessage(message); + + } + } catch (Exception e) { + logger.error("process error!", e); + if (times > 20) { + times = 0; + } + times++; + } finally { + connector.disconnect(); + MDC.remove("destination"); + } + } + } + + protected abstract void processMessage(Message message); + + + private void initConnector() { + if (zkServers != null && zkServers.length() > 0) { + connector = CanalConnectors.newClusterConnector(zkServers, destination, username, password); + } else if (address != null) { + String[] segments = address.split(":"); + SocketAddress socketAddress = new InetSocketAddress(segments[0], Integer.valueOf(segments[1])); + connector = CanalConnectors.newSingleConnector(socketAddress, destination, username, password); + } else { + throw new IllegalArgumentException("zkServers or address cant be null at same time,you should specify one of them!"); + } + + } + + /** + * 用于控制当连接异常时,重试的策略,我们不应该每次都是立即重试,否则将可能导致大量的错误,在空转时导致CPU过高的问题 + * sleep策略基于简单的累加 + * + * @param times + */ + private void sleepWhenFailed(int times) { + if (times <= 0) { + return; + } + try { + int sleepTime = 1000 + times * 100;//最大sleep 3s。 + Thread.sleep(sleepTime); + } catch (Exception ex) { + // + } + } + + /** + * 打印当前batch的摘要信息 + * + * @param message + * @param batchId + */ + protected void printBatch(Message message, long batchId) { + if (!debug) { + return; + } + List entries = message.getEntries(); + if (CollectionUtils.isEmpty(entries)) { + return; + } + + long memSize = 0; + for (CanalEntry.Entry entry : entries) { + memSize += entry.getHeader().getEventLength(); + } + int size = entries.size(); + String startPosition = buildPosition(entries.get(0)); + String endPosition = buildPosition(message.getEntries().get(size - 1)); + + SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT); + logger.info(contextFormat, new Object[]{batchId, size, memSize, format.format(new Date()), startPosition, endPosition}); + } + + protected String buildPosition(CanalEntry.Entry entry) { + CanalEntry.Header header = entry.getHeader(); + long time = header.getExecuteTime(); + Date date = new Date(time); + SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT); + StringBuilder sb = new StringBuilder(); + sb.append(header.getLogfileName()) + .append(":") + .append(header.getLogfileOffset()) + .append(":") + .append(header.getExecuteTime()) + .append("(") + .append(format.format(date)) + .append(")"); + return sb.toString(); + } + + /** + * default,only logging information + * + * @param entry + */ + protected void transactionBegin(CanalEntry.Entry entry) { + if (!debug) { + return; + } + try { + CanalEntry.TransactionBegin begin = CanalEntry.TransactionBegin.parseFrom(entry.getStoreValue()); + // 打印事务头信息,执行的线程id,事务耗时 + CanalEntry.Header header = entry.getHeader(); + long executeTime = header.getExecuteTime(); + long delayTime = new Date().getTime() - executeTime; + logger.info(transactionFormat, + new Object[]{"begin", begin.getTransactionId(), header.getLogfileName(), + String.valueOf(header.getLogfileOffset()), + String.valueOf(header.getExecuteTime()), String.valueOf(delayTime)}); + } catch (Exception e) { + logger.error("parse event has an error , data:" + entry.toString(), e); + } + } + + protected void transactionEnd(CanalEntry.Entry entry) { + if (!debug) { + return; + } + try { + CanalEntry.TransactionEnd end = CanalEntry.TransactionEnd.parseFrom(entry.getStoreValue()); + // 打印事务提交信息,事务id + CanalEntry.Header header = entry.getHeader(); + long executeTime = header.getExecuteTime(); + long delayTime = new Date().getTime() - executeTime; + + logger.info(transactionFormat, + new Object[]{"end", end.getTransactionId(), header.getLogfileName(), + String.valueOf(header.getLogfileOffset()), + String.valueOf(header.getExecuteTime()), String.valueOf(delayTime)}); + } catch (Exception e) { + logger.error("parse event has an error , data:" + entry.toString(), e); + } + } + + /** + * 判断事件类型为DML 数据 + * + * @param eventType + * @return + */ + protected boolean isDML(CanalEntry.EventType eventType) { + switch (eventType) { + case INSERT: + case UPDATE: + case DELETE: + return true; + default: + return false; + } + } + + /** + * 处理 DDL数据 + * + * @param header + * @param eventType + * @param sql + */ + + protected void processDDL(CanalEntry.Header header, CanalEntry.EventType eventType, String sql) { + if (!debug) { + return; + } + String table = header.getSchemaName() + "." + header.getTableName(); + //对于DDL,直接执行,因为没有行变更数据 + switch (eventType) { + case CREATE: + logger.warn("parse create table event, table: {}, sql: {}", table, sql); + return; + case ALTER: + logger.warn("parse alter table event, table: {}, sql: {}", table, sql); + return; + case TRUNCATE: + logger.warn("parse truncate table event, table: {}, sql: {}", table, sql); + return; + case ERASE: + case QUERY: + logger.warn("parse event : {}, sql: {} . ignored!", eventType.name(), sql); + return; + case RENAME: + logger.warn("parse rename table event, table: {}, sql: {}", table, sql); + return; + case CINDEX: + logger.warn("parse create index event, table: {}, sql: {}", table, sql); + return; + case DINDEX: + logger.warn("parse delete index event, table: {}, sql: {}", table, sql); + return; + default: + logger.warn("parse unknown event: {}, table: {}, sql: {}", new String[]{eventType.name(), table, sql}); + break; + } + } + + /** + * 强烈建议捕获异常,非上述已列出的其他操作,非核心 + * 除了“insert”、“update”、“delete”操作之外的,其他类型的操作. + * 默认实现为“无操作” + * + * @param header 可以从header中获得schema、table的名称 + * @param sql + */ + public void whenOthers(CanalEntry.Header header, String sql) { + String schema = header.getSchemaName(); + String table = header.getTableName(); + logger.error("ignore event,schema: {},table: {},SQL: {}", new String[]{schema, table, sql}); + } + + public enum ExceptionStrategy { + RETRY(1), IGNORE(2); + public int code; + + ExceptionStrategy(int code) { + this.code = code; + } + + public static ExceptionStrategy codeOf(Integer code) { + if (code != null) { + for (ExceptionStrategy e : ExceptionStrategy.values()) { + if (e.code == code) { + return e; + } + } + } + return null; + } + } + + public String getZkServers() { + return zkServers; + } + + public void setZkServers(String zkServers) { + this.zkServers = zkServers; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getDestination() { + return destination; + } + + public void setDestination(String destination) { + this.destination = destination; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public int getBatchSize() { + return batchSize; + } + + public void setBatchSize(int batchSize) { + this.batchSize = batchSize; + } + + public String getFilter() { + return filter; + } + + public void setFilter(String filter) { + this.filter = filter; + } + + public boolean isDebug() { + return debug; + } + + public void setDebug(boolean debug) { + this.debug = debug; + } + + public int getExceptionStrategy() { + return exceptionStrategy; + } + + public void setExceptionStrategy(int exceptionStrategy) { + this.exceptionStrategy = exceptionStrategy; + } + + public int getRetryTimes() { + return retryTimes; + } + + public void setRetryTimes(int retryTimes) { + this.retryTimes = retryTimes; + } + + public int getWaitingTime() { + return waitingTime; + } + + public void setWaitingTime(int waitingTime) { + this.waitingTime = waitingTime; + } +} diff --git a/example/src/main/java/com/alibaba/otter/canal/example/db/MysqlLoadLauncher.java b/example/src/main/java/com/alibaba/otter/canal/example/db/MysqlLoadLauncher.java new file mode 100644 index 00000000..b9936106 --- /dev/null +++ b/example/src/main/java/com/alibaba/otter/canal/example/db/MysqlLoadLauncher.java @@ -0,0 +1,35 @@ +package com.alibaba.otter.canal.example.db; + +import com.alibaba.otter.canal.example.db.mysql.MysqlClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class MysqlLoadLauncher { + private static final Logger logger = LoggerFactory.getLogger(MysqlLoadLauncher.class); + + public static void main(String[] args) { + try { + logger.info("## start the canal mysql client."); + final MysqlClient client = ServiceLocator.getMysqlClient(); + logger.info("## the canal consumer is running now ......"); + client.start(); + Runtime.getRuntime().addShutdownHook(new Thread() { + + public void run() { + try { + logger.info("## stop the canal consumer"); + client.stop(); + } catch (Throwable e) { + logger.warn("##something goes wrong when stopping canal consumer:\n{}", e); + } finally { + logger.info("## canal consumer is down."); + } + } + + }); + } catch (Throwable e) { + logger.error("## Something goes wrong when starting up the canal consumer:\n{}", e); + System.exit(0); + } + } +} diff --git a/example/src/main/java/com/alibaba/otter/canal/example/db/PropertyPlaceholderConfigurer.java b/example/src/main/java/com/alibaba/otter/canal/example/db/PropertyPlaceholderConfigurer.java new file mode 100644 index 00000000..65b4827c --- /dev/null +++ b/example/src/main/java/com/alibaba/otter/canal/example/db/PropertyPlaceholderConfigurer.java @@ -0,0 +1,169 @@ +package com.alibaba.otter.canal.example.db; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.context.ResourceLoaderAware; +import org.springframework.core.io.Resource; +import org.springframework.core.io.ResourceLoader; +import org.springframework.util.Assert; + +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +/** + * 扩展Spring的 + * {@linkplain org.springframework.beans.factory.config.PropertyPlaceholderConfigurer} + * ,增加默认值的功能。 例如:${placeholder:defaultValue},假如placeholder的值不存在,则默认取得 + * defaultValue。 + * + * @author jianghang 2013-1-24 下午03:37:56 + * @version 1.0.0 + */ +public class PropertyPlaceholderConfigurer extends org.springframework.beans.factory.config.PropertyPlaceholderConfigurer implements ResourceLoaderAware, InitializingBean { + + private static final String PLACEHOLDER_PREFIX = "${"; + private static final String PLACEHOLDER_SUFFIX = "}"; + private ResourceLoader loader; + private String[] locationNames; + + public PropertyPlaceholderConfigurer(){ + setIgnoreUnresolvablePlaceholders(true); + } + + public void setResourceLoader(ResourceLoader loader) { + this.loader = loader; + } + + public void setLocationNames(String[] locations) { + this.locationNames = locations; + } + + public void afterPropertiesSet() throws Exception { + Assert.notNull(loader, "no resourceLoader"); + + if (locationNames != null) { + for (int i = 0; i < locationNames.length; i++) { + locationNames[i] = resolveSystemPropertyPlaceholders(locationNames[i]); + } + } + + if (locationNames != null) { + List resources = new ArrayList(locationNames.length); + + for (String location : locationNames) { + location = trimToNull(location); + + if (location != null) { + resources.add(loader.getResource(location)); + } + } + + super.setLocations(resources.toArray(new Resource[resources.size()])); + } + } + + private String resolveSystemPropertyPlaceholders(String text) { + StringBuilder buf = new StringBuilder(text); + + for (int startIndex = buf.indexOf(PLACEHOLDER_PREFIX); startIndex >= 0;) { + int endIndex = buf.indexOf(PLACEHOLDER_SUFFIX, startIndex + PLACEHOLDER_PREFIX.length()); + + if (endIndex != -1) { + String placeholder = buf.substring(startIndex + PLACEHOLDER_PREFIX.length(), endIndex); + int nextIndex = endIndex + PLACEHOLDER_SUFFIX.length(); + + try { + String value = resolveSystemPropertyPlaceholder(placeholder); + + if (value != null) { + buf.replace(startIndex, endIndex + PLACEHOLDER_SUFFIX.length(), value); + nextIndex = startIndex + value.length(); + } else { + System.err.println("Could not resolve placeholder '" + + placeholder + + "' in [" + + text + + "] as system property: neither system property nor environment variable found"); + } + } catch (Throwable ex) { + System.err.println("Could not resolve placeholder '" + placeholder + "' in [" + text + + "] as system property: " + ex); + } + + startIndex = buf.indexOf(PLACEHOLDER_PREFIX, nextIndex); + } else { + startIndex = -1; + } + } + + return buf.toString(); + } + + private String resolveSystemPropertyPlaceholder(String placeholder) { + DefaultablePlaceholder dp = new DefaultablePlaceholder(placeholder); + String value = System.getProperty(dp.placeholder); + + if (value == null) { + value = System.getenv(dp.placeholder); + } + + if (value == null) { + value = dp.defaultValue; + } + + return value; + } + + @Override + protected String resolvePlaceholder(String placeholder, Properties props, int systemPropertiesMode) { + DefaultablePlaceholder dp = new DefaultablePlaceholder(placeholder); + String value = super.resolvePlaceholder(dp.placeholder, props, systemPropertiesMode); + + if (value == null) { + value = dp.defaultValue; + } + + return trimToEmpty(value); + } + + private static class DefaultablePlaceholder { + + private final String defaultValue; + private final String placeholder; + + public DefaultablePlaceholder(String placeholder){ + int commaIndex = placeholder.indexOf(":"); + String defaultValue = null; + + if (commaIndex >= 0) { + defaultValue = trimToEmpty(placeholder.substring(commaIndex + 1)); + placeholder = trimToEmpty(placeholder.substring(0, commaIndex)); + } + + this.placeholder = placeholder; + this.defaultValue = defaultValue; + } + } + + private String trimToNull(String str) { + if (str == null) { + return null; + } + + String result = str.trim(); + + if (result == null || result.length() == 0) { + return null; + } + + return result; + } + + public static String trimToEmpty(String str) { + if (str == null) { + return ""; + } + + return str.trim(); + } +} diff --git a/example/src/main/java/com/alibaba/otter/canal/example/db/ServiceLocator.java b/example/src/main/java/com/alibaba/otter/canal/example/db/ServiceLocator.java new file mode 100644 index 00000000..39ad4c62 --- /dev/null +++ b/example/src/main/java/com/alibaba/otter/canal/example/db/ServiceLocator.java @@ -0,0 +1,44 @@ +package com.alibaba.otter.canal.example.db; + +import com.alibaba.otter.canal.example.db.mysql.MysqlClient; +import org.springframework.beans.factory.DisposableBean; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.util.Assert; + +public class ServiceLocator implements DisposableBean { + + private static ApplicationContext applicationContext = null; + + static { + try { + applicationContext = new ClassPathXmlApplicationContext("classpath:client-spring.xml"); + } catch (RuntimeException e) { + throw e; + } + } + + private static T getBean(String name) { + assertContextInjected(); + return (T) applicationContext.getBean(name); + } + + + private static void clearHolder() { + ServiceLocator.applicationContext = null; + } + + @Override + public void destroy() throws Exception { + ServiceLocator.clearHolder(); + } + + private static void assertContextInjected() { + Assert.state(applicationContext != null, "ApplicationContext not set"); + } + + + public static MysqlClient getMysqlClient() { + return getBean("mysqlClient"); + } +} diff --git a/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/AbstractDbDialect.java b/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/AbstractDbDialect.java new file mode 100644 index 00000000..ec99b316 --- /dev/null +++ b/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/AbstractDbDialect.java @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2010-2101 Alibaba Group Holding Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.alibaba.otter.canal.example.db.dialect; + +import com.alibaba.otter.canal.example.db.utils.DdlUtils; +import com.google.common.base.Function; +import com.google.common.collect.MigrateMap; +import org.apache.commons.lang.exception.NestableRuntimeException; +import org.apache.ddlutils.model.Table; +import org.springframework.dao.DataAccessException; +import org.springframework.jdbc.core.ConnectionCallback; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; +import org.springframework.jdbc.support.lob.LobHandler; +import org.springframework.transaction.TransactionDefinition; +import org.springframework.transaction.support.TransactionTemplate; +import org.springframework.util.Assert; + +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +public abstract class AbstractDbDialect implements DbDialect { + + protected int databaseMajorVersion; + protected int databaseMinorVersion; + protected String databaseName; + protected JdbcTemplate jdbcTemplate; + protected TransactionTemplate transactionTemplate; + protected LobHandler lobHandler; + protected Map, Table> tables; + + public AbstractDbDialect(final JdbcTemplate jdbcTemplate, LobHandler lobHandler) { + this.jdbcTemplate = jdbcTemplate; + this.lobHandler = lobHandler; + // 初始化transction + this.transactionTemplate = new TransactionTemplate(); + transactionTemplate.setTransactionManager(new DataSourceTransactionManager(jdbcTemplate.getDataSource())); + transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); + + // 初始化一些数据 + jdbcTemplate.execute(new ConnectionCallback() { + + public Object doInConnection(Connection c) throws SQLException, DataAccessException { + DatabaseMetaData meta = c.getMetaData(); + databaseName = meta.getDatabaseProductName(); + databaseMajorVersion = meta.getDatabaseMajorVersion(); + databaseMinorVersion = meta.getDatabaseMinorVersion(); + + return null; + } + }); + + initTables(jdbcTemplate); + } + + public Table findTable(String schema, String table, boolean useCache) { + List key = Arrays.asList(schema, table); + if (useCache == false) { + tables.remove(key); + } + + return tables.get(key); + } + + public Table findTable(String schema, String table) { + return findTable(schema, table, true); + } + + public LobHandler getLobHandler() { + return lobHandler; + } + + public JdbcTemplate getJdbcTemplate() { + return jdbcTemplate; + } + + public TransactionTemplate getTransactionTemplate() { + return transactionTemplate; + } + + private void initTables(final JdbcTemplate jdbcTemplate) { + this.tables = MigrateMap.makeComputingMap(new Function, Table>() { + + public Table apply(List names) { + Assert.isTrue(names.size() == 2); + try { + Table table = DdlUtils.findTable(jdbcTemplate, names.get(0), names.get(0), names.get(1)); + if (table == null) { + throw new NestableRuntimeException("no found table [" + names.get(0) + "." + names.get(1) + + "] , pls check"); + } else { + return table; + } + } catch (Exception e) { + throw new NestableRuntimeException("find table [" + names.get(0) + "." + names.get(1) + "] error", + e); + } + } + }); + } + + +} diff --git a/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/AbstractSqlTemplate.java b/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/AbstractSqlTemplate.java new file mode 100644 index 00000000..fbbecabe --- /dev/null +++ b/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/AbstractSqlTemplate.java @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2010-2101 Alibaba Group Holding Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.alibaba.otter.canal.example.db.dialect; + +/** + * 默认的基于标准SQL实现的CRUD sql封装 + * + * @author jianghang 2011-10-27 下午01:37:00 + * @version 4.0.0 + */ +public abstract class AbstractSqlTemplate implements SqlTemplate { + + private static final String DOT = "."; + + public String getSelectSql(String schemaName, String tableName, String[] pkNames, String[] columnNames) { + StringBuilder sql = new StringBuilder("select "); + int size = columnNames.length; + for (int i = 0; i < size; i++) { + sql.append(appendEscape(columnNames[i])).append((i + 1 < size) ? " , " : ""); + } + + sql.append(" from ").append(getFullName(schemaName, tableName)).append(" where ( "); + appendColumnEquals(sql, pkNames, "and"); + sql.append(" ) "); + return sql.toString().intern();// 不使用intern,避免方法区内存消耗过多 + } + + public String getUpdateSql(String schemaName, String tableName, String[] pkNames, String[] columnNames) { + StringBuilder sql = new StringBuilder("update " + getFullName(schemaName, tableName) + " set "); + appendColumnEquals(sql, columnNames, ","); + sql.append(" where ("); + appendColumnEquals(sql, pkNames, "and"); + sql.append(")"); + return sql.toString().intern(); // 不使用intern,避免方法区内存消耗过多 + } + + public String getInsertSql(String schemaName, String tableName, String[] pkNames, String[] columnNames) { + StringBuilder sql = new StringBuilder("insert into " + getFullName(schemaName, tableName) + "("); + String[] allColumns = new String[pkNames.length + columnNames.length]; + System.arraycopy(columnNames, 0, allColumns, 0, columnNames.length); + System.arraycopy(pkNames, 0, allColumns, columnNames.length, pkNames.length); + + int size = allColumns.length; + for (int i = 0; i < size; i++) { + sql.append(appendEscape(allColumns[i])).append((i + 1 < size) ? "," : ""); + } + + sql.append(") values ("); + appendColumnQuestions(sql, allColumns); + sql.append(")"); + return sql.toString().intern();// intern优化,避免出现大量相同的字符串 + } + + public String getDeleteSql(String schemaName, String tableName, String[] pkNames) { + StringBuilder sql = new StringBuilder("delete from " + getFullName(schemaName, tableName) + " where "); + appendColumnEquals(sql, pkNames, "and"); + return sql.toString().intern();// intern优化,避免出现大量相同的字符串 + } + + protected String getFullName(String schemaName, String tableName) { + StringBuilder sb = new StringBuilder(); + if (schemaName != null) { + sb.append(appendEscape(schemaName)).append(DOT); + } + sb.append(appendEscape(tableName)); + return sb.toString().intern(); + } + + // ================ helper method ============ + + protected String appendEscape(String columnName) { + return columnName; + } + + protected void appendColumnQuestions(StringBuilder sql, String[] columns) { + int size = columns.length; + for (int i = 0; i < size; i++) { + sql.append("?").append((i + 1 < size) ? " , " : ""); + } + } + + protected void appendColumnEquals(StringBuilder sql, String[] columns, String separator) { + int size = columns.length; + for (int i = 0; i < size; i++) { + sql.append(" ").append(appendEscape(columns[i])).append(" = ").append("? "); + if (i != size - 1) { + sql.append(separator); + } + } + } +} diff --git a/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/DbDialect.java b/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/DbDialect.java new file mode 100644 index 00000000..060f476d --- /dev/null +++ b/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/DbDialect.java @@ -0,0 +1,20 @@ +package com.alibaba.otter.canal.example.db.dialect; + +import org.apache.ddlutils.model.Table; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.support.lob.LobHandler; +import org.springframework.transaction.support.TransactionTemplate; + +public interface DbDialect { + + LobHandler getLobHandler(); + + JdbcTemplate getJdbcTemplate(); + + TransactionTemplate getTransactionTemplate(); + + Table findTable(String schema, String table); + + Table findTable(String schema, String table, boolean useCache); + +} diff --git a/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/SqlTemplate.java b/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/SqlTemplate.java new file mode 100644 index 00000000..a90bd5ce --- /dev/null +++ b/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/SqlTemplate.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2010-2101 Alibaba Group Holding Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.alibaba.otter.canal.example.db.dialect; + +/** + * sql构造模板操作 + * + * @author jianghang 2011-10-27 下午01:31:15 + * @version 4.0.0 + */ +public interface SqlTemplate { + + public String getSelectSql(String schemaName, String tableName, String[] pkNames, String[] columnNames); + + public String getUpdateSql(String schemaName, String tableName, String[] pkNames, String[] columnNames); + + public String getDeleteSql(String schemaName, String tableName, String[] pkNames); + + public String getInsertSql(String schemaName, String tableName, String[] pkNames, String[] columnNames); + + /** + * 获取对应的mergeSql + */ + public String getMergeSql(String schemaName, String tableName, String[] pkNames, String[] columnNames, + String[] viewColumnNames, boolean updatePks); +} diff --git a/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/TableType.java b/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/TableType.java new file mode 100644 index 00000000..58cf662a --- /dev/null +++ b/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/TableType.java @@ -0,0 +1,93 @@ +package com.alibaba.otter.canal.example.db.dialect; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +/** + * An enumeration wrapper around JDBC table types. + */ +public enum TableType { + + /** + * Unknown + */ + unknown, + + /** + * System table + */ + system_table, + + /** + * Global temporary + */ + global_temporary, + + /** + * Local temporary + */ + local_temporary, + + /** + * Table + */ + table, + + /** + * View + */ + view, + + /** + * Alias + */ + alias, + + /** + * Synonym + */ + synonym,; + + /** + * Converts an array of table types to an array of their corresponding string values. + * + * @param tableTypes Array of table types + * @return Array of string table types + */ + public static String[] toStrings(final TableType[] tableTypes) { + if ((tableTypes == null) || (tableTypes.length == 0)) { + return new String[0]; + } + + final List tableTypeStrings = new ArrayList(tableTypes.length); + + for (final TableType tableType : tableTypes) { + if (tableType != null) { + tableTypeStrings.add(tableType.toString().toUpperCase(Locale.ENGLISH)); + } + } + + return tableTypeStrings.toArray(new String[tableTypeStrings.size()]); + } + + /** + * Converts an array of string table types to an array of their corresponding enumeration values. + * + * @param tableTypeStrings Array of string table types + * @return Array of table types + */ + public static TableType[] valueOf(final String[] tableTypeStrings) { + if ((tableTypeStrings == null) || (tableTypeStrings.length == 0)) { + return new TableType[0]; + } + + final List tableTypes = new ArrayList(tableTypeStrings.length); + + for (final String tableTypeString : tableTypeStrings) { + tableTypes.add(valueOf(tableTypeString.toLowerCase(Locale.ENGLISH))); + } + + return tableTypes.toArray(new TableType[tableTypes.size()]); + } +} diff --git a/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/mysql/MysqlDialect.java b/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/mysql/MysqlDialect.java new file mode 100644 index 00000000..7bdfe1df --- /dev/null +++ b/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/mysql/MysqlDialect.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2010-2101 Alibaba Group Holding Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.alibaba.otter.canal.example.db.dialect.mysql; + +import com.alibaba.otter.canal.example.db.dialect.AbstractDbDialect; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.support.lob.LobHandler; + +public class MysqlDialect extends AbstractDbDialect { + + public MysqlDialect(JdbcTemplate jdbcTemplate, LobHandler lobHandler) { + super(jdbcTemplate, lobHandler); + } + + public boolean isEmptyStringNulled() { + return false; + } +} diff --git a/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/mysql/MysqlSqlTemplate.java b/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/mysql/MysqlSqlTemplate.java new file mode 100644 index 00000000..0cf987ff --- /dev/null +++ b/example/src/main/java/com/alibaba/otter/canal/example/db/dialect/mysql/MysqlSqlTemplate.java @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2010-2101 Alibaba Group Holding Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.alibaba.otter.canal.example.db.dialect.mysql; + +import com.alibaba.otter.canal.example.db.dialect.AbstractSqlTemplate; + +/** + * mysql sql生成模板 + * + * @author jianghang 2011-10-27 下午01:41:20 + * @version 4.0.0 + */ +public class MysqlSqlTemplate extends AbstractSqlTemplate { + + private static final String ESCAPE = "`"; + + public String getMergeSql(String schemaName, String tableName, String[] pkNames, String[] columnNames, + String[] viewColumnNames, boolean includePks) { + StringBuilder sql = new StringBuilder("insert into " + getFullName(schemaName, tableName) + "("); + int size = columnNames.length; + for (int i = 0; i < size; i++) { + sql.append(appendEscape(columnNames[i])).append(" , "); + } + size = pkNames.length; + for (int i = 0; i < size; i++) { + sql.append(appendEscape(pkNames[i])).append((i + 1 < size) ? " , " : ""); + } + + sql.append(") values ("); + size = columnNames.length; + for (int i = 0; i < size; i++) { + sql.append("?").append(" , "); + } + size = pkNames.length; + for (int i = 0; i < size; i++) { + sql.append("?").append((i + 1 < size) ? " , " : ""); + } + sql.append(")"); + sql.append(" on duplicate key update "); + + size = columnNames.length; + for (int i = 0; i < size; i++) { + sql.append(appendEscape(columnNames[i])) + .append("=values(") + .append(appendEscape(columnNames[i])) + .append(")"); + if (includePks) { + sql.append(" , "); + } else { + sql.append((i + 1 < size) ? " , " : ""); + } + } + + if (includePks) { + // mysql merge sql匹配了uniqe / primary key时都会执行update,所以需要更新pk信息 + size = pkNames.length; + for (int i = 0; i < size; i++) { + sql.append(appendEscape(pkNames[i])).append("=values(").append(appendEscape(pkNames[i])).append(")"); + sql.append((i + 1 < size) ? " , " : ""); + } + } + + return sql.toString().intern();// intern优化,避免出现大量相同的字符串 + } + + protected String appendEscape(String columnName) { + return ESCAPE + columnName + ESCAPE; + } + +} \ No newline at end of file diff --git a/example/src/main/java/com/alibaba/otter/canal/example/db/mysql/AbstractMysqlClient.java b/example/src/main/java/com/alibaba/otter/canal/example/db/mysql/AbstractMysqlClient.java new file mode 100644 index 00000000..608b81e6 --- /dev/null +++ b/example/src/main/java/com/alibaba/otter/canal/example/db/mysql/AbstractMysqlClient.java @@ -0,0 +1,207 @@ +package com.alibaba.otter.canal.example.db.mysql; + +import com.alibaba.fastjson.JSON; +import com.alibaba.otter.canal.example.db.AbstractDbClient; +import com.alibaba.otter.canal.example.db.dialect.DbDialect; +import com.alibaba.otter.canal.example.db.dialect.mysql.MysqlDialect; +import com.alibaba.otter.canal.example.db.dialect.mysql.MysqlSqlTemplate; +import com.alibaba.otter.canal.example.db.dialect.SqlTemplate; +import com.alibaba.otter.canal.example.db.utils.SqlUtils; +import com.alibaba.otter.canal.protocol.CanalEntry; +import com.alibaba.otter.canal.protocol.exception.CanalClientException; +import org.apache.commons.lang.StringUtils; +import org.apache.ddlutils.model.Column; +import org.apache.ddlutils.model.Table; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.PreparedStatementSetter; +import org.springframework.jdbc.core.StatementCreatorUtils; +import org.springframework.jdbc.support.lob.DefaultLobHandler; +import org.springframework.jdbc.support.lob.LobCreator; +import org.springframework.transaction.TransactionStatus; +import org.springframework.transaction.support.TransactionCallback; + +import javax.sql.DataSource; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +public abstract class AbstractMysqlClient extends AbstractDbClient { + + private DataSource dataSource; + + private DbDialect dbDialect; + private SqlTemplate sqlTemplate; + + protected Integer execute(final CanalEntry.Header header, final List columns) { + final String sql = getSql(header, columns); + final LobCreator lobCreator = dbDialect.getLobHandler().getLobCreator(); + dbDialect.getTransactionTemplate().execute(new TransactionCallback() { + + public Object doInTransaction(TransactionStatus status) { + try { + JdbcTemplate template = dbDialect.getJdbcTemplate(); + int affect = template.update(sql, new PreparedStatementSetter() { + + public void setValues(PreparedStatement ps) throws SQLException { + doPreparedStatement(ps, dbDialect, lobCreator, header, columns); + } + }); + return affect; + } finally { + lobCreator.close(); + } + } + }); + return 0; + } + + private String getSql(CanalEntry.Header header, List columns) { + List pkNames = new ArrayList<>(); + List colNames = new ArrayList<>(); + for (CanalEntry.Column column : columns) { + if (column.getIsKey()) { + pkNames.add(column.getName()); + } else { + colNames.add(column.getName()); + } + } + String sql = ""; + CanalEntry.EventType eventType = header.getEventType(); + switch (eventType) { + case INSERT: + sql = sqlTemplate.getInsertSql(header.getSchemaName(), header.getTableName(), pkNames.toArray(new String[]{}), colNames.toArray(new String[]{})); + break; + case UPDATE: + sql = sqlTemplate.getUpdateSql(header.getSchemaName(), header.getTableName(), pkNames.toArray(new String[]{}), colNames.toArray(new String[]{})); + break; + case DELETE: + sql = sqlTemplate.getDeleteSql(header.getSchemaName(), header.getTableName(), pkNames.toArray(new String[]{})); + } + logger.info("Execute sql: {}", sql); + return sql; + } + + private void doPreparedStatement(PreparedStatement ps, DbDialect dbDialect, LobCreator lobCreator, + CanalEntry.Header header, List columns) throws SQLException { + + List rebuildColumns = new ArrayList<>(columns.size()); + + List keyColumns = new ArrayList<>(columns.size()); + List notKeyColumns = new ArrayList<>(columns.size()); + for (CanalEntry.Column column : columns) { + if (column.getIsKey()) { + keyColumns.add(column); + } else { + notKeyColumns.add(column); + } + } + CanalEntry.EventType eventType = header.getEventType(); + switch (eventType) { + case INSERT: + case UPDATE: + // insert/update语句对应的字段数序都是将主键排在后面 + rebuildColumns.addAll(notKeyColumns); + rebuildColumns.addAll(keyColumns); + break; + case DELETE: + rebuildColumns.addAll(keyColumns); + } + + // 获取一下当前字段名的数据是否必填 + Table table = dbDialect.findTable(header.getSchemaName(), header.getTableName()); + Map isRequiredMap = new HashMap(); + for (Column tableColumn : table.getColumns()) { + isRequiredMap.put(StringUtils.lowerCase(tableColumn.getName()), tableColumn.isRequired()); + } + + List values = new ArrayList<>(rebuildColumns.size()); + for (int i = 0; i < rebuildColumns.size(); i++) { + int paramIndex = i + 1; + CanalEntry.Column column = rebuildColumns.get(i); + int sqlType = column.getSqlType(); + + Boolean isRequired = isRequiredMap.get(StringUtils.lowerCase(column.getName())); + if (isRequired == null) { + // 清理一下目标库的表结构,二次检查一下 + table = dbDialect.findTable(header.getSchemaName(), header.getTableName()); + + isRequiredMap = new HashMap<>(); + for (Column tableColumn : table.getColumns()) { + isRequiredMap.put(StringUtils.lowerCase(tableColumn.getName()), tableColumn.isRequired()); + } + + isRequired = isRequiredMap.get(StringUtils.lowerCase(column.getName())); + if (isRequired == null) { + throw new CanalClientException(String.format("column name %s is not found in Table[%s]", + column.getName(), + table.toString())); + } + } + + Object param; + if (sqlType == Types.TIME || sqlType == Types.TIMESTAMP || sqlType == Types.DATE) { + // 解决mysql的0000-00-00 00:00:00问题,直接依赖mysql + // driver进行处理,如果转化为Timestamp会出错 + param = column.getValue(); + if (param instanceof String && StringUtils.isEmpty(String.valueOf(param))) { + param = null; + } + } else { + param = SqlUtils.stringToSqlValue(column.getValue(), + sqlType, + isRequired, + column.getIsNull()); + } + + try { + switch (sqlType) { + case Types.CLOB: + lobCreator.setClobAsString(ps, paramIndex, (String) param); + break; + case Types.BLOB: + lobCreator.setBlobAsBytes(ps, paramIndex, (byte[]) param); + break; + case Types.TIME: + case Types.TIMESTAMP: + case Types.DATE: + ps.setObject(paramIndex, param); + break; + case Types.BIT: + StatementCreatorUtils.setParameterValue(ps, paramIndex, Types.DECIMAL, null, param); + break; + default: + StatementCreatorUtils.setParameterValue(ps, paramIndex, sqlType, null, param); + break; + } + values.add(param); + } catch (SQLException ex) { + logger.error("## SetParam error , [sqltype={}, value={}]", + new Object[]{sqlType, param}); + throw ex; + } + } + logger.info("## sql values: {}", JSON.toJSONString(values)); + } + + @Override + public void afterPropertiesSet() { + JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); + DefaultLobHandler lobHandler = new DefaultLobHandler(); + lobHandler.setStreamAsLob(true); + dbDialect = new MysqlDialect(jdbcTemplate, lobHandler); + sqlTemplate = new MysqlSqlTemplate(); + } + + public DataSource getDataSource() { + return dataSource; + } + + public void setDataSource(DataSource dataSource) { + this.dataSource = dataSource; + } +} diff --git a/example/src/main/java/com/alibaba/otter/canal/example/db/mysql/MysqlClient.java b/example/src/main/java/com/alibaba/otter/canal/example/db/mysql/MysqlClient.java new file mode 100644 index 00000000..f16b6146 --- /dev/null +++ b/example/src/main/java/com/alibaba/otter/canal/example/db/mysql/MysqlClient.java @@ -0,0 +1,23 @@ +package com.alibaba.otter.canal.example.db.mysql; + +import com.alibaba.otter.canal.protocol.CanalEntry; + +import java.util.List; + +public class MysqlClient extends AbstractMysqlClient { + + @Override + public void insert(CanalEntry.Header header, List afterColumns) { + execute(header, afterColumns); + } + + @Override + public void update(CanalEntry.Header header, List afterColumns) { + execute(header, afterColumns); + } + + @Override + public void delete(CanalEntry.Header header, List beforeColumns) { + execute(header, beforeColumns); + } +} diff --git a/example/src/main/java/com/alibaba/otter/canal/example/db/utils/ByteArrayConverter.java b/example/src/main/java/com/alibaba/otter/canal/example/db/utils/ByteArrayConverter.java new file mode 100644 index 00000000..6bd33686 --- /dev/null +++ b/example/src/main/java/com/alibaba/otter/canal/example/db/utils/ByteArrayConverter.java @@ -0,0 +1,50 @@ +package com.alibaba.otter.canal.example.db.utils; + +import org.apache.commons.beanutils.ConversionException; +import org.apache.commons.beanutils.Converter; +import org.apache.commons.beanutils.converters.ArrayConverter; +import org.apache.commons.beanutils.converters.ByteConverter; + +public class ByteArrayConverter implements Converter { + + public static final Converter SQL_BYTES = new ByteArrayConverter(null); + private static final Converter converter = new ArrayConverter(byte[].class, new ByteConverter()); + + protected final Object defaultValue; + protected final boolean useDefault; + + public ByteArrayConverter() { + this.defaultValue = null; + this.useDefault = false; + } + + public ByteArrayConverter(Object defaultValue) { + this.defaultValue = defaultValue; + this.useDefault = true; + } + + public Object convert(Class type, Object value) { + if (value == null) { + if (useDefault) { + return (defaultValue); + } else { + throw new ConversionException("No value specified"); + } + } + + if (value instanceof byte[]) { + return (value); + } + + // BLOB类型,canal直接存储为String("ISO-8859-1") + if (value instanceof String) { + try { + return ((String) value).getBytes("ISO-8859-1"); + } catch (Exception e) { + throw new ConversionException(e); + } + } + + return converter.convert(type, value); // byteConvertor进行转化 + } +} diff --git a/example/src/main/java/com/alibaba/otter/canal/example/db/utils/DdlUtils.java b/example/src/main/java/com/alibaba/otter/canal/example/db/utils/DdlUtils.java new file mode 100644 index 00000000..7964b18d --- /dev/null +++ b/example/src/main/java/com/alibaba/otter/canal/example/db/utils/DdlUtils.java @@ -0,0 +1,326 @@ +package com.alibaba.otter.canal.example.db.utils; + +import com.alibaba.otter.canal.example.db.dialect.TableType; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.ddlutils.model.Column; +import org.apache.ddlutils.model.Table; +import org.apache.ddlutils.platform.DatabaseMetaDataWrapper; +import org.apache.ddlutils.platform.MetaDataColumnDescriptor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.dao.DataAccessException; +import org.springframework.jdbc.core.ConnectionCallback; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.support.JdbcUtils; + +import java.sql.*; +import java.util.*; + + +public class DdlUtils { + + private static final Logger logger = LoggerFactory.getLogger(DdlUtils.class); + private static TableType[] SUPPORTED_TABLE_TYPES = new TableType[]{TableType.view, TableType.table}; + private final static Map _defaultSizes = new HashMap(); + + static { + _defaultSizes.put(new Integer(1), "254"); + _defaultSizes.put(new Integer(12), "254"); + _defaultSizes.put(new Integer(-1), "254"); + _defaultSizes.put(new Integer(-2), "254"); + _defaultSizes.put(new Integer(-3), "254"); + _defaultSizes.put(new Integer(-4), "254"); + _defaultSizes.put(new Integer(4), "32"); + _defaultSizes.put(new Integer(-5), "64"); + _defaultSizes.put(new Integer(7), "7,0"); + _defaultSizes.put(new Integer(6), "15,0"); + _defaultSizes.put(new Integer(8), "15,0"); + _defaultSizes.put(new Integer(3), "15,15"); + _defaultSizes.put(new Integer(2), "15,15"); + } + + + public static Table findTable(final JdbcTemplate jdbcTemplate, final String catalogName, final String schemaName, + final String tableName) { + return (Table) jdbcTemplate.execute(new ConnectionCallback() { + + public Object doInConnection(Connection con) throws SQLException, DataAccessException { + Table table = null; + DatabaseMetaDataWrapper metaData = new DatabaseMetaDataWrapper(); + try { + + DatabaseMetaData databaseMetaData = con.getMetaData(); + + metaData.setMetaData(databaseMetaData); + metaData.setTableTypes(TableType.toStrings(SUPPORTED_TABLE_TYPES)); + metaData.setCatalog(catalogName); + metaData.setSchemaPattern(schemaName); + + String convertTableName = tableName; + if (databaseMetaData.storesUpperCaseIdentifiers()) { + metaData.setCatalog(catalogName.toUpperCase()); + metaData.setSchemaPattern(schemaName.toUpperCase()); + convertTableName = tableName.toUpperCase(); + } + if (databaseMetaData.storesLowerCaseIdentifiers()) { + metaData.setCatalog(catalogName.toLowerCase()); + metaData.setSchemaPattern(schemaName.toLowerCase()); + convertTableName = tableName.toLowerCase(); + } + + ResultSet tableData = null; + try { + tableData = metaData.getTables(convertTableName); + + while ((tableData != null) && tableData.next()) { + Map values = readColumns(tableData, initColumnsForTable()); + + table = readTable(metaData, values); + if (table.getName().equalsIgnoreCase(tableName)) { + break; + } + } + } finally { + JdbcUtils.closeResultSet(tableData); + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + makeAllColumnsPrimaryKeysIfNoPrimaryKeysFound(table); + return table; + } + }); + } + + /** + * Treat tables with no primary keys as a table with all primary keys. + */ + private static void makeAllColumnsPrimaryKeysIfNoPrimaryKeysFound(Table table) { + if ((table != null) && (table.getPrimaryKeyColumns() != null) && (table.getPrimaryKeyColumns().length == 0)) { + Column[] allCoumns = table.getColumns(); + + for (Column column : allCoumns) { + column.setPrimaryKey(true); + } + } + } + + private static Table readTable(DatabaseMetaDataWrapper metaData, Map values) throws SQLException { + String tableName = (String) values.get("TABLE_NAME"); + Table table = null; + + if ((tableName != null) && (tableName.length() > 0)) { + table = new Table(); + table.setName(tableName); + table.setType((String) values.get("TABLE_TYPE")); + table.setCatalog((String) values.get("TABLE_CAT")); + table.setSchema((String) values.get("TABLE_SCHEM")); + table.setDescription((String) values.get("REMARKS")); + table.addColumns(readColumns(metaData, tableName)); + + Collection primaryKeys = readPrimaryKeyNames(metaData, tableName); + + for (Object key : primaryKeys) { + Column col = table.findColumn((String) key, true); + + if (col != null) { + col.setPrimaryKey(true); + } else { + throw new NullPointerException(String.format("%s pk %s is null - %s %s", + tableName, + key, + ToStringBuilder.reflectionToString(metaData, ToStringStyle.SIMPLE_STYLE), + ToStringBuilder.reflectionToString(values, ToStringStyle.SIMPLE_STYLE))); + } + } + } + + return table; + } + + private static List initColumnsForTable() { + List result = new ArrayList(); + + result.add(new MetaDataColumnDescriptor("TABLE_NAME", Types.VARCHAR)); + result.add(new MetaDataColumnDescriptor("TABLE_TYPE", Types.VARCHAR, "UNKNOWN")); + result.add(new MetaDataColumnDescriptor("TABLE_CAT", Types.VARCHAR)); + result.add(new MetaDataColumnDescriptor("TABLE_SCHEM", Types.VARCHAR)); + result.add(new MetaDataColumnDescriptor("REMARKS", Types.VARCHAR)); + + return result; + } + + private static List initColumnsForColumn() { + List result = new ArrayList(); + + // As suggested by Alexandre Borgoltz, we're reading the COLUMN_DEF + // first because Oracle + // has problems otherwise (it seemingly requires a LONG column to be the + // first to be read) + // See also DDLUTILS-29 + result.add(new MetaDataColumnDescriptor("COLUMN_DEF", Types.VARCHAR)); + + // we're also reading the table name so that a model reader impl can + // filter manually + result.add(new MetaDataColumnDescriptor("TABLE_NAME", Types.VARCHAR)); + result.add(new MetaDataColumnDescriptor("COLUMN_NAME", Types.VARCHAR)); + result.add(new MetaDataColumnDescriptor("TYPE_NAME", Types.VARCHAR)); + result.add(new MetaDataColumnDescriptor("DATA_TYPE", Types.INTEGER, new Integer(Types.OTHER))); + result.add(new MetaDataColumnDescriptor("NUM_PREC_RADIX", Types.INTEGER, new Integer(10))); + result.add(new MetaDataColumnDescriptor("DECIMAL_DIGITS", Types.INTEGER, new Integer(0))); + result.add(new MetaDataColumnDescriptor("COLUMN_SIZE", Types.VARCHAR)); + result.add(new MetaDataColumnDescriptor("IS_NULLABLE", Types.VARCHAR, "YES")); + result.add(new MetaDataColumnDescriptor("REMARKS", Types.VARCHAR)); + + return result; + } + + private static List initColumnsForPK() { + List result = new ArrayList(); + + result.add(new MetaDataColumnDescriptor("COLUMN_NAME", Types.VARCHAR)); + + // we're also reading the table name so that a model reader impl can + // filter manually + result.add(new MetaDataColumnDescriptor("TABLE_NAME", Types.VARCHAR)); + + // the name of the primary key is currently only interesting to the pk + // index name resolution + result.add(new MetaDataColumnDescriptor("PK_NAME", Types.VARCHAR)); + + return result; + } + + private static List readColumns(DatabaseMetaDataWrapper metaData, String tableName) throws SQLException { + ResultSet columnData = null; + + try { + columnData = metaData.getColumns(tableName, null); + + List columns = new ArrayList(); + Map values; + + for (; columnData.next(); columns.add(readColumn(metaData, values))) { + Map tmp = readColumns(columnData, initColumnsForColumn()); + if (tableName.equalsIgnoreCase((String) tmp.get("TABLE_NAME"))) { + values = tmp; + } else { + break; + } + } + + return columns; + } finally { + JdbcUtils.closeResultSet(columnData); + } + } + + private static Column readColumn(DatabaseMetaDataWrapper metaData, Map values) throws SQLException { + Column column = new Column(); + + column.setName((String) values.get("COLUMN_NAME")); + column.setDefaultValue((String) values.get("COLUMN_DEF")); + column.setTypeCode(((Integer) values.get("DATA_TYPE")).intValue()); + + String typeName = (String) values.get("TYPE_NAME"); + // column.setType(typeName); + + if ((typeName != null) && typeName.startsWith("TIMESTAMP")) { + column.setTypeCode(Types.TIMESTAMP); + } + // modify 2013-09-25,处理下unsigned + if ((typeName != null) && StringUtils.containsIgnoreCase(typeName, "UNSIGNED")) { + // 如果为unsigned,往上调大一个量级,避免数据溢出 + switch (column.getTypeCode()) { + case Types.TINYINT: + column.setTypeCode(Types.SMALLINT); + break; + case Types.SMALLINT: + column.setTypeCode(Types.INTEGER); + break; + case Types.INTEGER: + column.setTypeCode(Types.BIGINT); + break; + case Types.BIGINT: + column.setTypeCode(Types.DECIMAL); + break; + default: + break; + } + } + + Integer precision = (Integer) values.get("NUM_PREC_RADIX"); + + if (precision != null) { + column.setPrecisionRadix(precision.intValue()); + } + + String size = (String) values.get("COLUMN_SIZE"); + + if (size == null) { + size = (String) _defaultSizes.get(new Integer(column.getTypeCode())); + } + + // we're setting the size after the precision and radix in case + // the database prefers to return them in the size value + column.setSize(size); + + int scale = 0; + Object dec_digits = values.get("DECIMAL_DIGITS"); + + if (dec_digits instanceof String) { + scale = (dec_digits == null) ? 0 : NumberUtils.toInt(dec_digits.toString()); + } else if (dec_digits instanceof Integer) { + scale = (dec_digits == null) ? 0 : (Integer) dec_digits; + } + + if (scale != 0) { + column.setScale(scale); + } + + column.setRequired("NO".equalsIgnoreCase(((String) values.get("IS_NULLABLE")).trim())); + column.setDescription((String) values.get("REMARKS")); + return column; + } + + private static Map readColumns(ResultSet resultSet, List columnDescriptors) + throws SQLException { + Map values = new HashMap(); + MetaDataColumnDescriptor descriptor; + + for (Iterator it = columnDescriptors.iterator(); it.hasNext(); values.put(descriptor.getName(), + descriptor.readColumn(resultSet))) { + descriptor = (MetaDataColumnDescriptor) it.next(); + } + + return values; + } + + private static Collection readPrimaryKeyNames(DatabaseMetaDataWrapper metaData, String tableName) + throws SQLException { + ResultSet pkData = null; + + try { + List pks = new ArrayList(); + Map values; + + for (pkData = metaData.getPrimaryKeys(tableName); pkData.next(); pks.add(readPrimaryKeyName(metaData, + values))) { + values = readColumns(pkData, initColumnsForPK()); + } + + return pks; + } finally { + JdbcUtils.closeResultSet(pkData); + } + } + + private static String readPrimaryKeyName(DatabaseMetaDataWrapper metaData, Map values) + throws SQLException { + return (String) values.get("COLUMN_NAME"); + } +} diff --git a/example/src/main/java/com/alibaba/otter/canal/example/db/utils/SqlTimestampConverter.java b/example/src/main/java/com/alibaba/otter/canal/example/db/utils/SqlTimestampConverter.java new file mode 100644 index 00000000..5743106d --- /dev/null +++ b/example/src/main/java/com/alibaba/otter/canal/example/db/utils/SqlTimestampConverter.java @@ -0,0 +1,140 @@ +package com.alibaba.otter.canal.example.db.utils; + +import org.apache.commons.beanutils.ConversionException; +import org.apache.commons.beanutils.Converter; +import org.apache.commons.lang.time.DateFormatUtils; + +import java.sql.Timestamp; +import java.text.ParseException; +import java.text.ParsePosition; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + +public class SqlTimestampConverter implements Converter { + + /** + * Field description + */ + public static final String[] DATE_FORMATS = new String[]{"yyyy-MM-dd", "HH:mm:ss", "yyyy-MM-dd HH:mm:ss", + "yyyy-MM-dd hh:mm:ss.fffffffff", "EEE MMM dd HH:mm:ss zzz yyyy", + DateFormatUtils.ISO_DATETIME_FORMAT.getPattern(), + DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern(), + DateFormatUtils.SMTP_DATETIME_FORMAT.getPattern(),}; + + public static final Converter SQL_TIMESTAMP = new SqlTimestampConverter(null); + + /** + * The default value specified to our Constructor, if any. + */ + private final Object defaultValue; + + /** + * Should we return the default value on conversion errors? + */ + private final boolean useDefault; + + /** + * Create a {@link Converter} that will throw a {@link ConversionException} if a conversion error occurs. + */ + public SqlTimestampConverter() { + this.defaultValue = null; + this.useDefault = false; + } + + /** + * Create a {@link Converter} that will return the specified default value if a conversion error occurs. + * + * @param defaultValue The default value to be returned + */ + public SqlTimestampConverter(Object defaultValue) { + this.defaultValue = defaultValue; + this.useDefault = true; + } + + /** + * Convert the specified input object into an output object of the specified type. + * + * @param type Data type to which this value should be converted + * @param value The input value to be converted + * @throws ConversionException if conversion cannot be performed successfully + */ + public Object convert(Class type, Object value) { + if (value == null) { + if (useDefault) { + return (defaultValue); + } else { + throw new ConversionException("No value specified"); + } + } + + if (value instanceof java.sql.Date && java.sql.Date.class.equals(type)) { + return value; + } else if (value instanceof java.sql.Time && java.sql.Time.class.equals(type)) { + return value; + } else if (value instanceof Timestamp && Timestamp.class.equals(type)) { + return value; + } else { + try { + if (java.sql.Date.class.equals(type)) { + return new java.sql.Date(convertTimestamp2TimeMillis(value.toString())); + } else if (java.sql.Time.class.equals(type)) { + return new java.sql.Time(convertTimestamp2TimeMillis(value.toString())); + } else if (Timestamp.class.equals(type)) { + return new Timestamp(convertTimestamp2TimeMillis(value.toString())); + } else { + return new Timestamp(convertTimestamp2TimeMillis(value.toString())); + } + } catch (Exception e) { + throw new ConversionException("Value format invalid: " + e.getMessage(), e); + } + } + + } + + private Long convertTimestamp2TimeMillis(String input) { + if (input == null) { + return null; + } + + try { + // 先处理Timestamp类型 + return Timestamp.valueOf(input).getTime(); + } catch (Exception nfe) { + try { + try { + return parseDate(input, DATE_FORMATS, Locale.ENGLISH).getTime(); + } catch (Exception err) { + return parseDate(input, DATE_FORMATS, Locale.getDefault()).getTime(); + } + } catch (Exception err) { + // 最后处理long time的情况 + return Long.parseLong(input); + } + } + } + + private Date parseDate(String str, String[] parsePatterns, Locale locale) throws ParseException { + if ((str == null) || (parsePatterns == null)) { + throw new IllegalArgumentException("Date and Patterns must not be null"); + } + + SimpleDateFormat parser = null; + ParsePosition pos = new ParsePosition(0); + + for (int i = 0; i < parsePatterns.length; i++) { + if (i == 0) { + parser = new SimpleDateFormat(parsePatterns[0], locale); + } else { + parser.applyPattern(parsePatterns[i]); + } + pos.setIndex(0); + Date date = parser.parse(str, pos); + if ((date != null) && (pos.getIndex() == str.length())) { + return date; + } + } + + throw new ParseException("Unable to parse the date: " + str, -1); + } +} diff --git a/example/src/main/java/com/alibaba/otter/canal/example/db/utils/SqlUtils.java b/example/src/main/java/com/alibaba/otter/canal/example/db/utils/SqlUtils.java new file mode 100644 index 00000000..565d5730 --- /dev/null +++ b/example/src/main/java/com/alibaba/otter/canal/example/db/utils/SqlUtils.java @@ -0,0 +1,315 @@ +package com.alibaba.otter.canal.example.db.utils; + +import org.apache.commons.beanutils.ConvertUtilsBean; +import org.apache.commons.lang.StringUtils; + +import java.io.UnsupportedEncodingException; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.sql.*; +import java.util.HashMap; +import java.util.Map; + +public class SqlUtils { + + public static final String REQUIRED_FIELD_NULL_SUBSTITUTE = " "; + public static final String SQLDATE_FORMAT = "yyyy-MM-dd"; + public static final String TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss"; + private static final Map> sqlTypeToJavaTypeMap = new HashMap>(); + private static final ConvertUtilsBean convertUtilsBean = new ConvertUtilsBean(); + + static { + // regist Converter + convertUtilsBean.register(SqlTimestampConverter.SQL_TIMESTAMP, Date.class); + convertUtilsBean.register(SqlTimestampConverter.SQL_TIMESTAMP, Time.class); + convertUtilsBean.register(SqlTimestampConverter.SQL_TIMESTAMP, Timestamp.class); + convertUtilsBean.register(ByteArrayConverter.SQL_BYTES, byte[].class); + + // bool + sqlTypeToJavaTypeMap.put(Types.BOOLEAN, Boolean.class); + + // int + sqlTypeToJavaTypeMap.put(Types.TINYINT, Integer.class); + sqlTypeToJavaTypeMap.put(Types.SMALLINT, Integer.class); + sqlTypeToJavaTypeMap.put(Types.INTEGER, Integer.class); + + // long + sqlTypeToJavaTypeMap.put(Types.BIGINT, Long.class); + // mysql bit最多64位,无符号 + sqlTypeToJavaTypeMap.put(Types.BIT, BigInteger.class); + + // decimal + sqlTypeToJavaTypeMap.put(Types.REAL, Float.class); + sqlTypeToJavaTypeMap.put(Types.FLOAT, Float.class); + sqlTypeToJavaTypeMap.put(Types.DOUBLE, Double.class); + sqlTypeToJavaTypeMap.put(Types.NUMERIC, BigDecimal.class); + sqlTypeToJavaTypeMap.put(Types.DECIMAL, BigDecimal.class); + + // date + sqlTypeToJavaTypeMap.put(Types.DATE, Date.class); + sqlTypeToJavaTypeMap.put(Types.TIME, Time.class); + sqlTypeToJavaTypeMap.put(Types.TIMESTAMP, Timestamp.class); + + // blob + sqlTypeToJavaTypeMap.put(Types.BLOB, byte[].class); + + // byte[] + sqlTypeToJavaTypeMap.put(Types.REF, byte[].class); + sqlTypeToJavaTypeMap.put(Types.OTHER, byte[].class); + sqlTypeToJavaTypeMap.put(Types.ARRAY, byte[].class); + sqlTypeToJavaTypeMap.put(Types.STRUCT, byte[].class); + sqlTypeToJavaTypeMap.put(Types.SQLXML, byte[].class); + sqlTypeToJavaTypeMap.put(Types.BINARY, byte[].class); + sqlTypeToJavaTypeMap.put(Types.DATALINK, byte[].class); + sqlTypeToJavaTypeMap.put(Types.DISTINCT, byte[].class); + sqlTypeToJavaTypeMap.put(Types.VARBINARY, byte[].class); + sqlTypeToJavaTypeMap.put(Types.JAVA_OBJECT, byte[].class); + sqlTypeToJavaTypeMap.put(Types.LONGVARBINARY, byte[].class); + + // String + sqlTypeToJavaTypeMap.put(Types.CHAR, String.class); + sqlTypeToJavaTypeMap.put(Types.VARCHAR, String.class); + sqlTypeToJavaTypeMap.put(Types.LONGVARCHAR, String.class); + sqlTypeToJavaTypeMap.put(Types.LONGNVARCHAR, String.class); + sqlTypeToJavaTypeMap.put(Types.NCHAR, String.class); + sqlTypeToJavaTypeMap.put(Types.NVARCHAR, String.class); + sqlTypeToJavaTypeMap.put(Types.NCLOB, String.class); + sqlTypeToJavaTypeMap.put(Types.CLOB, String.class); + } + + /** + * 将指定java.sql.Types的ResultSet value转换成相应的String + * + * @param rs + * @param index + * @param sqlType + * @return + * @throws SQLException + */ + public static String sqlValueToString(ResultSet rs, int index, int sqlType) throws SQLException { + Class requiredType = sqlTypeToJavaTypeMap.get(sqlType); + if (requiredType == null) { + throw new IllegalArgumentException("unknow java.sql.Types - " + sqlType); + } + + return getResultSetValue(rs, index, requiredType); + } + + /** + * sqlValueToString方法的逆向过程 + * + * @param value + * @param sqlType + * @param isTextRequired + * @param isEmptyStringNulled + * @return + */ + public static Object stringToSqlValue(String value, int sqlType, boolean isRequired, boolean isEmptyStringNulled) { + // 设置变量 + String sourceValue = value; + if (SqlUtils.isTextType(sqlType)) { + if ((sourceValue == null) || (StringUtils.isEmpty(sourceValue) && isEmptyStringNulled)) { + return isRequired ? REQUIRED_FIELD_NULL_SUBSTITUTE : null; + } else { + return sourceValue; + } + } else { + if (StringUtils.isEmpty(sourceValue)) { + return null; + } else { + Class requiredType = sqlTypeToJavaTypeMap.get(sqlType); + if (requiredType == null) { + throw new IllegalArgumentException("unknow java.sql.Types - " + sqlType); + } else if (requiredType.equals(String.class)) { + return sourceValue; + } else if (isNumeric(sqlType)) { + return convertUtilsBean.convert(sourceValue.trim(), requiredType); + } else { + return convertUtilsBean.convert(sourceValue, requiredType); + } + } + } + } + + public static String encoding(String source, int sqlType, String sourceEncoding, String targetEncoding) { + switch (sqlType) { + case Types.CHAR: + case Types.VARCHAR: + case Types.LONGVARCHAR: + case Types.NCHAR: + case Types.NVARCHAR: + case Types.LONGNVARCHAR: + case Types.CLOB: + case Types.NCLOB: + if (false == StringUtils.isEmpty(source)) { + String fromEncoding = StringUtils.isBlank(sourceEncoding) ? "UTF-8" : sourceEncoding; + String toEncoding = StringUtils.isBlank(targetEncoding) ? "UTF-8" : targetEncoding; + + // if (false == StringUtils.equalsIgnoreCase(fromEncoding, + // toEncoding)) { + try { + return new String(source.getBytes(fromEncoding), toEncoding); + } catch (UnsupportedEncodingException e) { + throw new IllegalArgumentException(e.getMessage(), e); + } + // } + } + } + + return source; + } + + /** + * Retrieve a JDBC column value from a ResultSet, using the specified value + * type. + *

      + * Uses the specifically typed ResultSet accessor methods, falling back to + * {@link #getResultSetValue(ResultSet, int)} for unknown types. + *

      + * Note that the returned value may not be assignable to the specified + * required type, in case of an unknown type. Calling code needs to deal + * with this case appropriately, e.g. throwing a corresponding exception. + * + * @param rs is the ResultSet holding the data + * @param index is the column index + * @param requiredType the required value type (may be null) + * @return the value object + * @throws SQLException if thrown by the JDBC API + */ + private static String getResultSetValue(ResultSet rs, int index, Class requiredType) throws SQLException { + if (requiredType == null) { + return getResultSetValue(rs, index); + } + + Object value = null; + boolean wasNullCheck = false; + + // Explicitly extract typed value, as far as possible. + if (String.class.equals(requiredType)) { + value = rs.getString(index); + } else if (boolean.class.equals(requiredType) || Boolean.class.equals(requiredType)) { + value = Boolean.valueOf(rs.getBoolean(index)); + wasNullCheck = true; + } else if (byte.class.equals(requiredType) || Byte.class.equals(requiredType)) { + value = new Byte(rs.getByte(index)); + wasNullCheck = true; + } else if (short.class.equals(requiredType) || Short.class.equals(requiredType)) { + value = new Short(rs.getShort(index)); + wasNullCheck = true; + } else if (int.class.equals(requiredType) || Integer.class.equals(requiredType)) { + value = new Long(rs.getLong(index)); + wasNullCheck = true; + } else if (long.class.equals(requiredType) || Long.class.equals(requiredType)) { + value = rs.getBigDecimal(index); + wasNullCheck = true; + } else if (float.class.equals(requiredType) || Float.class.equals(requiredType)) { + value = new Float(rs.getFloat(index)); + wasNullCheck = true; + } else if (double.class.equals(requiredType) || Double.class.equals(requiredType) + || Number.class.equals(requiredType)) { + value = new Double(rs.getDouble(index)); + wasNullCheck = true; + } else if (Time.class.equals(requiredType)) { + // try { + // value = rs.getTime(index); + // } catch (SQLException e) { + value = rs.getString(index);// 尝试拿为string对象,0000无法用Time表示 + // if (value == null && !rs.wasNull()) { + // value = "00:00:00"; // + // mysql设置了zeroDateTimeBehavior=convertToNull,出现0值时返回为null + // } + // } + } else if (Timestamp.class.equals(requiredType) || Date.class.equals(requiredType)) { + // try { + // value = convertTimestamp(rs.getTimestamp(index)); + // } catch (SQLException e) { + // 尝试拿为string对象,0000-00-00 00:00:00无法用Timestamp 表示 + value = rs.getString(index); + // if (value == null && !rs.wasNull()) { + // value = "0000:00:00 00:00:00"; // + // mysql设置了zeroDateTimeBehavior=convertToNull,出现0值时返回为null + // } + // } + } else if (BigDecimal.class.equals(requiredType)) { + value = rs.getBigDecimal(index); + } else if (BigInteger.class.equals(requiredType)) { + value = rs.getBigDecimal(index); + } else if (Blob.class.equals(requiredType)) { + value = rs.getBlob(index); + } else if (Clob.class.equals(requiredType)) { + value = rs.getClob(index); + } else if (byte[].class.equals(requiredType)) { + try { + byte[] bytes = rs.getBytes(index); + if (bytes == null) { + value = null; + } else { + value = new String(bytes, "ISO-8859-1");// 将binary转化为iso-8859-1的字符串 + } + } catch (UnsupportedEncodingException e) { + throw new SQLException(e); + } + } else { + // Some unknown type desired -> rely on getObject. + value = getResultSetValue(rs, index); + } + + // Perform was-null check if demanded (for results that the + // JDBC driver returns as primitives). + if (wasNullCheck && (value != null) && rs.wasNull()) { + value = null; + } + + return (value == null) ? null : convertUtilsBean.convert(value); + } + + /** + * Retrieve a JDBC column value from a ResultSet, using the most appropriate + * value type. The returned value should be a detached value object, not + * having any ties to the active ResultSet: in particular, it should not be + * a Blob or Clob object but rather a byte array respectively String + * representation. + *

      + * Uses the getObject(index) method, but includes additional + * "hacks" to get around Oracle 10g returning a non-standard object for its + * TIMESTAMP datatype and a java.sql.Date for DATE columns + * leaving out the time portion: These columns will explicitly be extracted + * as standard java.sql.Timestamp object. + * + * @param rs is the ResultSet holding the data + * @param index is the column index + * @return the value object + * @throws SQLException if thrown by the JDBC API + * @see Blob + * @see Clob + * @see Timestamp + */ + private static String getResultSetValue(ResultSet rs, int index) throws SQLException { + Object obj = rs.getObject(index); + return (obj == null) ? null : convertUtilsBean.convert(obj); + } + + // private static Object convertTimestamp(Timestamp timestamp) { + // return (timestamp == null) ? null : timestamp.getTime(); + // } + + /** + * Check whether the given SQL type is numeric. + */ + public static boolean isNumeric(int sqlType) { + return (Types.BIT == sqlType) || (Types.BIGINT == sqlType) || (Types.DECIMAL == sqlType) + || (Types.DOUBLE == sqlType) || (Types.FLOAT == sqlType) || (Types.INTEGER == sqlType) + || (Types.NUMERIC == sqlType) || (Types.REAL == sqlType) || (Types.SMALLINT == sqlType) + || (Types.TINYINT == sqlType); + } + + public static boolean isTextType(int sqlType) { + if (sqlType == Types.CHAR || sqlType == Types.VARCHAR || sqlType == Types.CLOB || sqlType == Types.LONGVARCHAR + || sqlType == Types.NCHAR || sqlType == Types.NVARCHAR || sqlType == Types.NCLOB + || sqlType == Types.LONGNVARCHAR) { + return true; + } else { + return false; + } + } +} diff --git a/example/src/main/resources/client-spring.xml b/example/src/main/resources/client-spring.xml new file mode 100644 index 00000000..29eba1af --- /dev/null +++ b/example/src/main/resources/client-spring.xml @@ -0,0 +1,53 @@ + + + + + + + + + classpath:client.properties + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/src/main/resources/client.properties b/example/src/main/resources/client.properties new file mode 100644 index 00000000..c5142912 --- /dev/null +++ b/example/src/main/resources/client.properties @@ -0,0 +1,16 @@ +# client 配置 +zk.servers=127.0.0.1:2181 +# 5 * 1024 +client.batch.size=5120 +client.debug=false +client.destination=example +client.username=canal +client.password=canal +client.exceptionstrategy=1 +client.retrytimes=3 +client.filter=.*\\..* + +# 同步目标: mysql 配置 +target.mysql.url=jdbc:mysql://127.0.0.1:4306 +target.mysql.username=root +target.mysql.password=123456 diff --git a/instance/manager/src/main/java/com/alibaba/otter/canal/instance/manager/CanalInstanceWithManager.java b/instance/manager/src/main/java/com/alibaba/otter/canal/instance/manager/CanalInstanceWithManager.java index f6cec13d..039a80b7 100644 --- a/instance/manager/src/main/java/com/alibaba/otter/canal/instance/manager/CanalInstanceWithManager.java +++ b/instance/manager/src/main/java/com/alibaba/otter/canal/instance/manager/CanalInstanceWithManager.java @@ -6,7 +6,11 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; + import com.alibaba.otter.canal.parse.inbound.mysql.tablemeta.HistoryTableMetaCache; + +import com.alibaba.otter.canal.meta.FileMixedMetaManager; + import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -21,13 +25,7 @@ import com.alibaba.otter.canal.filter.aviater.AviaterRegexFilter; import com.alibaba.otter.canal.instance.core.AbstractCanalInstance; import com.alibaba.otter.canal.instance.manager.model.Canal; import com.alibaba.otter.canal.instance.manager.model.CanalParameter; -import com.alibaba.otter.canal.instance.manager.model.CanalParameter.DataSourcing; -import com.alibaba.otter.canal.instance.manager.model.CanalParameter.HAMode; -import com.alibaba.otter.canal.instance.manager.model.CanalParameter.IndexMode; -import com.alibaba.otter.canal.instance.manager.model.CanalParameter.MetaMode; -import com.alibaba.otter.canal.instance.manager.model.CanalParameter.SourcingType; -import com.alibaba.otter.canal.instance.manager.model.CanalParameter.StorageMode; -import com.alibaba.otter.canal.instance.manager.model.CanalParameter.StorageScavengeMode; +import com.alibaba.otter.canal.instance.manager.model.CanalParameter.*; import com.alibaba.otter.canal.meta.MemoryMetaManager; import com.alibaba.otter.canal.meta.PeriodMixedMetaManager; import com.alibaba.otter.canal.meta.ZooKeeperMetaManager; @@ -38,12 +36,7 @@ import com.alibaba.otter.canal.parse.inbound.AbstractEventParser; import com.alibaba.otter.canal.parse.inbound.group.GroupEventParser; import com.alibaba.otter.canal.parse.inbound.mysql.LocalBinlogEventParser; import com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser; -import com.alibaba.otter.canal.parse.index.CanalLogPositionManager; -import com.alibaba.otter.canal.parse.index.FailbackLogPositionManager; -import com.alibaba.otter.canal.parse.index.MemoryLogPositionManager; -import com.alibaba.otter.canal.parse.index.MetaLogPositionManager; -import com.alibaba.otter.canal.parse.index.PeriodMixedLogPositionManager; -import com.alibaba.otter.canal.parse.index.ZooKeeperLogPositionManager; +import com.alibaba.otter.canal.parse.index.*; import com.alibaba.otter.canal.parse.support.AuthenticationInfo; import com.alibaba.otter.canal.protocol.position.EntryPosition; import com.alibaba.otter.canal.sink.entry.EntryEventSink; @@ -121,6 +114,11 @@ public class CanalInstanceWithManager extends AbstractCanalInstance { ZooKeeperMetaManager zooKeeperMetaManager = new ZooKeeperMetaManager(); zooKeeperMetaManager.setZkClientx(getZkclientx()); ((PeriodMixedMetaManager) metaManager).setZooKeeperMetaManager(zooKeeperMetaManager); + } else if (mode.isLocalFile()){ + FileMixedMetaManager fileMixedMetaManager = new FileMixedMetaManager(); + fileMixedMetaManager.setDataDir(parameters.getDataDir()); + fileMixedMetaManager.setPeriod(parameters.getMetaFileFlushPeriod()); + metaManager = fileMixedMetaManager; } else { throw new CanalException("unsupport MetaMode for " + mode); } diff --git a/instance/manager/src/main/java/com/alibaba/otter/canal/instance/manager/model/CanalParameter.java b/instance/manager/src/main/java/com/alibaba/otter/canal/instance/manager/model/CanalParameter.java index 94558590..d707c679 100644 --- a/instance/manager/src/main/java/com/alibaba/otter/canal/instance/manager/model/CanalParameter.java +++ b/instance/manager/src/main/java/com/alibaba/otter/canal/instance/manager/model/CanalParameter.java @@ -29,8 +29,10 @@ public class CanalParameter implements Serializable { private Long zkClusterId; // zk集群id,为管理方便 private List zkClusters; // zk集群地址 + private String dataDir = "../conf"; // 默认本地文件数据的目录默认是conf // meta相关参数 private MetaMode metaMode = MetaMode.MEMORY; // meta机制 + private Integer metaFileFlushPeriod = 1000; // meta刷新间隔 // storage存储 private Integer transactionSize = 1024; // 支持处理的transaction事务大小 @@ -247,7 +249,9 @@ public class CanalParameter implements Serializable { /** 文件存储模式 */ ZOOKEEPER, /** 混合模式,内存+文件 */ - MIXED; + MIXED, + /** 本地文件存储模式*/ + LOCAL_FILE; public boolean isMemory() { return this.equals(MetaMode.MEMORY); @@ -260,6 +264,10 @@ public class CanalParameter implements Serializable { public boolean isMixed() { return this.equals(MetaMode.MIXED); } + + public boolean isLocalFile(){ + return this.equals(MetaMode.LOCAL_FILE); + } } public static enum IndexMode { @@ -394,6 +402,22 @@ public class CanalParameter implements Serializable { return storageMode; } + public String getDataDir() { + return dataDir; + } + + public void setDataDir(String dataDir) { + this.dataDir = dataDir; + } + + public Integer getMetaFileFlushPeriod() { + return metaFileFlushPeriod; + } + + public void setMetaFileFlushPeriod(Integer metaFileFlushPeriod) { + this.metaFileFlushPeriod = metaFileFlushPeriod; + } + public void setStorageMode(StorageMode storageMode) { this.storageMode = storageMode; } diff --git a/kafka-client/pom.xml b/kafka-client/pom.xml new file mode 100644 index 00000000..d814be52 --- /dev/null +++ b/kafka-client/pom.xml @@ -0,0 +1,111 @@ + + + 4.0.0 + + canal + com.alibaba.otter + 1.0.26-SNAPSHOT + ../pom.xml + + com.alibaba.otter + canal.kafka.client + jar + canal kafka client module for otter ${project.version} + + + + + com.alibaba.otter + canal.protocol + ${project.version} + + + org.apache.kafka + kafka-clients + 0.9.0.1 + + + + + junit + junit + + + + + + dev + + true + + env + !javadoc + + + + + + javadoc + + + env + javadoc + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + + attach-javadocs + package + + jar + + + + + true + public + true +

      ${project.artifactId}-${project.version}
      +
      ${project.artifactId}-${project.version}
      + ${project.artifactId}-${project.version} + + https://github.com/alibaba/canal + + ${project.build.directory}/apidocs/apidocs/${project.version} + + + + org.apache.maven.plugins + maven-scm-publish-plugin + 1.0-beta-2 + + + attach-javadocs + package + + publish-scm + + + + + ${project.build.directory}/scmpublish + Publishing javadoc for ${project.artifactId}:${project.version} + ${project.build.directory}/apidocs + true + scm:git:git@github.com:alibaba/canal.git + gh-pages + + + + + + + \ No newline at end of file diff --git a/kafka-client/src/main/java/com/alibaba/otter/canal/kafka/client/KafkaCanalConnector.java b/kafka-client/src/main/java/com/alibaba/otter/canal/kafka/client/KafkaCanalConnector.java new file mode 100644 index 00000000..3e997e27 --- /dev/null +++ b/kafka-client/src/main/java/com/alibaba/otter/canal/kafka/client/KafkaCanalConnector.java @@ -0,0 +1,242 @@ +package com.alibaba.otter.canal.kafka.client; + +import com.alibaba.otter.canal.common.utils.AddressUtils; +import com.alibaba.otter.canal.common.utils.BooleanMutex; +import com.alibaba.otter.canal.common.zookeeper.ZkClientx; +import com.alibaba.otter.canal.kafka.client.running.ClientRunningData; +import com.alibaba.otter.canal.kafka.client.running.ClientRunningListener; +import com.alibaba.otter.canal.kafka.client.running.ClientRunningMonitor; +import com.alibaba.otter.canal.protocol.Message; +import com.alibaba.otter.canal.protocol.exception.CanalClientException; +import org.apache.kafka.clients.consumer.ConsumerRecords; +import org.apache.kafka.clients.consumer.KafkaConsumer; +import org.apache.kafka.common.TopicPartition; +import org.apache.kafka.common.serialization.StringDeserializer; + +import java.util.Collections; +import java.util.Properties; +import java.util.concurrent.TimeUnit; + +/** + * canal kafka 数据操作客户端 + * + * @author machengyuan @ 2018-6-12 + * @version 1.0.0 + */ +public class KafkaCanalConnector { + + private KafkaConsumer kafkaConsumer; + private String topic; + private Integer partition; + private Properties properties; + private ClientRunningMonitor runningMonitor; // 运行控制 + private ZkClientx zkClientx; + private BooleanMutex mutex = new BooleanMutex(false); + private volatile boolean connected = false; + private volatile boolean running = false; + + public KafkaCanalConnector(String zkServers, String servers, String topic, Integer partition, String groupId) { + this.topic = topic; + this.partition = partition; + + properties = new Properties(); + properties.put("bootstrap.servers", servers); + properties.put("group.id", groupId); + properties.put("enable.auto.commit", false); + properties.put("auto.commit.interval.ms", "1000"); + properties.put("auto.offset.reset", "latest"); //如果没有offset则从最后的offset开始读 + properties.put("request.timeout.ms", "40000"); // 必须大于session.timeout.ms的设置 + properties.put("session.timeout.ms", "30000"); // 默认为30秒 + properties.put("max.poll.records", "1"); // 所以一次只取一条数据 + properties.put("key.deserializer", StringDeserializer.class.getName()); + properties.put("value.deserializer", MessageDeserializer.class.getName()); + + if (zkServers != null) { + zkClientx = new ZkClientx(zkServers); + + ClientRunningData clientData = new ClientRunningData(); + clientData.setGroupId(groupId); + clientData.setAddress(AddressUtils.getHostIp()); + + runningMonitor = new ClientRunningMonitor(); + runningMonitor.setTopic(topic); + runningMonitor.setZkClient(zkClientx); + runningMonitor.setClientData(clientData); + runningMonitor.setListener(new ClientRunningListener() { + public void processActiveEnter() { + mutex.set(true); + } + + public void processActiveExit() { + mutex.set(false); + } + }); + } + + } + + /** + * 重新设置sessionTime + * + * @param timeout + * @param unit + */ + public void setSessionTimeout(Long timeout, TimeUnit unit) { + long t = unit.toMillis(timeout); + properties.put("request.timeout.ms", String.valueOf(t + 60000)); + properties.put("session.timeout.ms", String.valueOf(t)); + } + + /** + * 打开连接 + */ + public void connect() { + if (connected) { + return; + } + + if (runningMonitor != null) { + if (!runningMonitor.isStart()) { + runningMonitor.start(); + } + } + + connected = true; + + if (kafkaConsumer == null) { + kafkaConsumer = new KafkaConsumer(properties); + } + } + + /** + * 关闭链接 + */ + public void disconnnect() { + kafkaConsumer.close(); + + connected = false; + if (runningMonitor.isStart()) { + runningMonitor.stop(); + } + } + + private void waitClientRunning() { + try { + if (zkClientx != null) { + if (!connected) {// 未调用connect + throw new CanalClientException("should connect first"); + } + + running = true; + mutex.get();// 阻塞等待 + } else { + // 单机模式直接设置为running + running = true; + } + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new CanalClientException(e); + } + } + + public boolean checkValid() { + if (zkClientx != null) { + return mutex.state(); + } else { + return true;// 默认都放过 + } + } + + /** + * 订阅topic + */ + public void subscribe() { + waitClientRunning(); + if (!running) { + return; + } + + if (partition == null) { + kafkaConsumer.subscribe(Collections.singletonList(topic)); + } else { + TopicPartition topicPartition = new TopicPartition(topic, partition); + kafkaConsumer.assign(Collections.singletonList(topicPartition)); + } + } + + /** + * 取消订阅 + */ + public void unsubscribe() { + waitClientRunning(); + if (!running) { + return; + } + + kafkaConsumer.unsubscribe(); + } + + /** + * 获取数据,自动进行确认 + * + * @return + */ + public Message get() { + return get(100L, TimeUnit.MILLISECONDS); + } + + public Message get(Long timeout, TimeUnit unit) { + waitClientRunning(); + if (!running) { + return null; + } + + Message message = getWithoutAck(timeout, unit); + this.ack(); + return message; + } + + public Message getWithoutAck() { + return getWithoutAck(100L, TimeUnit.MILLISECONDS); + } + + /** + * 获取数据,不进行确认,等待处理完成手工确认 + * + * @return + */ + public Message getWithoutAck(Long timeout, TimeUnit unit) { + waitClientRunning(); + if (!running) { + return null; + } + + ConsumerRecords records = kafkaConsumer.poll(unit.toMillis(timeout)); // 基于配置,最多只能poll到一条数据 + + if (!records.isEmpty()) { + return records.iterator().next().value(); + } + return null; + } + + /** + * 提交offset,如果超过 session.timeout.ms 设置的时间没有ack则会抛出异常,ack失败 + */ + public void ack() { + waitClientRunning(); + if (!running) { + return; + } + + kafkaConsumer.commitSync(); + } + + public void stopRunning() { + if (running) { + running = false; // 设置为非running状态 + if (!mutex.state()) { + mutex.set(true); // 中断阻塞 + } + } + } +} diff --git a/kafka-client/src/main/java/com/alibaba/otter/canal/kafka/client/KafkaCanalConnectors.java b/kafka-client/src/main/java/com/alibaba/otter/canal/kafka/client/KafkaCanalConnectors.java new file mode 100644 index 00000000..1a2942ab --- /dev/null +++ b/kafka-client/src/main/java/com/alibaba/otter/canal/kafka/client/KafkaCanalConnectors.java @@ -0,0 +1,62 @@ +package com.alibaba.otter.canal.kafka.client; + +/** + * canal kafka connectors创建工具类 + * + * @author machengyuan @ 2018-6-12 + * @version 1.0.0 + */ +public class KafkaCanalConnectors { + + /** + * 创建kafka客户端链接,独立运行不注册zk信息 + * + * @param servers + * @param topic + * @param partition + * @param groupId + * @return + */ + public static KafkaCanalConnector newKafkaConnector(String servers, String topic, Integer partition, String groupId) { + return new KafkaCanalConnector(null, servers, topic, partition, groupId); + } + + /** + * 创建kafka客户端链接,独立运行不注册zk信息 + * + * @param servers + * @param topic + * @param groupId + * @return + */ + public static KafkaCanalConnector newKafkaConnector(String servers, String topic, String groupId) { + return new KafkaCanalConnector(null, servers, topic, null, groupId); + } + + /** + * 创建kafka客户端链接 + * + * @param zkServers + * @param servers + * @param topic + * @param partition + * @param groupId + * @return + */ + public static KafkaCanalConnector newKafkaConnector(String zkServers, String servers, String topic, Integer partition, String groupId) { + return new KafkaCanalConnector(zkServers, servers, topic, partition, groupId); + } + + /** + * 创建kafka客户端链接 + * + * @param zkServers + * @param servers + * @param topic + * @param groupId + * @return + */ + public static KafkaCanalConnector newKafkaConnector(String zkServers, String servers, String topic, String groupId) { + return new KafkaCanalConnector(zkServers, servers, topic, null, groupId); + } +} diff --git a/kafka-client/src/main/java/com/alibaba/otter/canal/kafka/client/MessageDeserializer.java b/kafka-client/src/main/java/com/alibaba/otter/canal/kafka/client/MessageDeserializer.java new file mode 100644 index 00000000..70f2fc06 --- /dev/null +++ b/kafka-client/src/main/java/com/alibaba/otter/canal/kafka/client/MessageDeserializer.java @@ -0,0 +1,64 @@ +package com.alibaba.otter.canal.kafka.client; + +import java.util.Map; + +import org.apache.kafka.common.serialization.Deserializer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.alibaba.otter.canal.protocol.CanalEntry; +import com.alibaba.otter.canal.protocol.CanalPacket; +import com.alibaba.otter.canal.protocol.Message; +import com.alibaba.otter.canal.protocol.exception.CanalClientException; +import com.google.protobuf.ByteString; + +/** + * Kafka Message类的反序列化 + * + * @author machengyuan @ 2018-6-12 + * @version 1.0.0 + */ +public class MessageDeserializer implements Deserializer { + + private static Logger logger = LoggerFactory.getLogger(MessageDeserializer.class); + + @Override + public void configure(Map configs, boolean isKey) { + } + + @Override + public Message deserialize(String topic, byte[] data) { + try { + if (data == null) { + return null; + } + else { + CanalPacket.Packet p = CanalPacket.Packet.parseFrom(data); + switch (p.getType()) { + case MESSAGES: { + if (!p.getCompression().equals(CanalPacket.Compression.NONE)) { + throw new CanalClientException("compression is not supported in this connector"); + } + + CanalPacket.Messages messages = CanalPacket.Messages.parseFrom(p.getBody()); + Message result = new Message(messages.getBatchId()); + for (ByteString byteString : messages.getMessagesList()) { + result.addEntry(CanalEntry.Entry.parseFrom(byteString)); + } + return result; + } + default: + break; + } + } + } catch (Exception e) { + logger.error("Error when deserializing byte[] to message "); + } + return null; + } + + @Override + public void close() { + // nothing to do + } +} diff --git a/kafka-client/src/main/java/com/alibaba/otter/canal/kafka/client/running/ClientRunningData.java b/kafka-client/src/main/java/com/alibaba/otter/canal/kafka/client/running/ClientRunningData.java new file mode 100644 index 00000000..7bbbabd7 --- /dev/null +++ b/kafka-client/src/main/java/com/alibaba/otter/canal/kafka/client/running/ClientRunningData.java @@ -0,0 +1,39 @@ +package com.alibaba.otter.canal.kafka.client.running; + +/** + * client running状态信息 + * + * @author machengyuan 2018-06-20 下午04:10:12 + * @version 1.0.0 + */ +public class ClientRunningData { + + private String groupId; + private String address; + private boolean active = true; + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public boolean isActive() { + return active; + } + + public void setActive(boolean active) { + this.active = active; + } + +} diff --git a/kafka-client/src/main/java/com/alibaba/otter/canal/kafka/client/running/ClientRunningListener.java b/kafka-client/src/main/java/com/alibaba/otter/canal/kafka/client/running/ClientRunningListener.java new file mode 100644 index 00000000..d49cf79f --- /dev/null +++ b/kafka-client/src/main/java/com/alibaba/otter/canal/kafka/client/running/ClientRunningListener.java @@ -0,0 +1,21 @@ +package com.alibaba.otter.canal.kafka.client.running; + +/** + * client running状态信息 + * + * @author machengyuan 2018-06-20 下午04:10:12 + * @version 1.0.0 + */ +public interface ClientRunningListener { + + /** + * 触发现在轮到自己做为active + */ + public void processActiveEnter(); + + /** + * 触发一下当前active模式失败 + */ + public void processActiveExit(); + +} diff --git a/kafka-client/src/main/java/com/alibaba/otter/canal/kafka/client/running/ClientRunningMonitor.java b/kafka-client/src/main/java/com/alibaba/otter/canal/kafka/client/running/ClientRunningMonitor.java new file mode 100644 index 00000000..0f61211e --- /dev/null +++ b/kafka-client/src/main/java/com/alibaba/otter/canal/kafka/client/running/ClientRunningMonitor.java @@ -0,0 +1,281 @@ +package com.alibaba.otter.canal.kafka.client.running; + +import java.text.MessageFormat; +import java.util.Random; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import org.I0Itec.zkclient.IZkDataListener; +import org.I0Itec.zkclient.exception.ZkException; +import org.I0Itec.zkclient.exception.ZkInterruptedException; +import org.I0Itec.zkclient.exception.ZkNoNodeException; +import org.I0Itec.zkclient.exception.ZkNodeExistsException; +import org.apache.zookeeper.CreateMode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; + +import com.alibaba.otter.canal.common.AbstractCanalLifeCycle; +import com.alibaba.otter.canal.common.utils.AddressUtils; +import com.alibaba.otter.canal.common.utils.BooleanMutex; +import com.alibaba.otter.canal.common.utils.JsonUtils; +import com.alibaba.otter.canal.common.zookeeper.ZkClientx; +import com.alibaba.otter.canal.common.zookeeper.ZookeeperPathUtils; +import com.alibaba.otter.canal.protocol.exception.CanalClientException; + + +/** + * kafka client running状态信息 + * + * @author machengyuan 2018-06-20 下午04:10:12 + * @version 1.0.0 + */ +public class ClientRunningMonitor extends AbstractCanalLifeCycle { + + private static final String TOPIC_ROOT_NODE = ZookeeperPathUtils.CANAL_ROOT_NODE + + ZookeeperPathUtils.ZOOKEEPER_SEPARATOR + "topics"; + + private static final String TOPIC_NODE = TOPIC_ROOT_NODE + ZookeeperPathUtils.ZOOKEEPER_SEPARATOR + + "{0}"; + + private static final String TOPIC_CLIENTID_NODE = TOPIC_NODE + ZookeeperPathUtils.ZOOKEEPER_SEPARATOR + + "{1}"; + + private static final String TOPIC_CLIENTID_RUNNING_NODE = TOPIC_CLIENTID_NODE + + ZookeeperPathUtils.ZOOKEEPER_SEPARATOR + + ZookeeperPathUtils.RUNNING_NODE; + + private static String getTopicClientRunning(String topic, String groupId) { + return MessageFormat.format(TOPIC_CLIENTID_RUNNING_NODE, topic, groupId); + } + + private static String getClientIdNodePath(String topic, String groupId) { + return MessageFormat.format(TOPIC_CLIENTID_NODE, topic, groupId); + } + + private static final Logger logger = LoggerFactory.getLogger(ClientRunningMonitor.class); + private ZkClientx zkClient; + private String topic; + private ClientRunningData clientData; + private IZkDataListener dataListener; + private BooleanMutex mutex = new BooleanMutex(false); + private volatile boolean release = false; + private volatile ClientRunningData activeData; + private ScheduledExecutorService delayExector = Executors.newScheduledThreadPool(1); + private ClientRunningListener listener; + private int delayTime = 5; + + private static Integer virtualPort; + + public ClientRunningMonitor(){ + if (virtualPort == null) { + Random rand = new Random(); + virtualPort = rand.nextInt(9000) + 1000; + } + + dataListener = new IZkDataListener() { + + public void handleDataChange(String dataPath, Object data) throws Exception { + MDC.put("kafkaTopic", topic); + ClientRunningData runningData = JsonUtils.unmarshalFromByte((byte[]) data, ClientRunningData.class); + if (!isMine(runningData.getAddress())) { + mutex.set(false); + } + + if (!runningData.isActive() && isMine(runningData.getAddress())) { // 说明出现了主动释放的操作,并且本机之前是active + release = true; + releaseRunning();// 彻底释放mainstem + } + + activeData = (ClientRunningData) runningData; + } + + public void handleDataDeleted(String dataPath) throws Exception { + MDC.put("kafkaTopic", topic); + + mutex.set(false); + // 触发一下退出,可能是人为干预的释放操作或者网络闪断引起的session expired timeout + processActiveExit(); + if (!release && activeData != null && isMine(activeData.getAddress())) { + // 如果上一次active的状态就是本机,则即时触发一下active抢占 + initRunning(); + } else { + // 否则就是等待delayTime,避免因网络瞬端或者zk异常,导致出现频繁的切换操作 + delayExector.schedule(new Runnable() { + + public void run() { + initRunning(); + } + }, delayTime, TimeUnit.SECONDS); + } + } + + }; + + } + + public void start() { + super.start(); + + String path = getTopicClientRunning(this.topic, clientData.getGroupId()); + + zkClient.subscribeDataChanges(path, dataListener); + initRunning(); + } + + public void stop() { + super.stop(); + String path = getTopicClientRunning(this.topic, clientData.getGroupId()); + zkClient.unsubscribeDataChanges(path, dataListener); + releaseRunning(); // 尝试一下release + // Fix issue #697 + if (delayExector != null) { + delayExector.shutdown(); + } + } + + // 改动记录: + // 1,在方法上加synchronized关键字,保证同步顺序执行; + // 2,判断Zk上已经存在的activeData是否是本机,是的话把mutex重置为true,否则会导致死锁 + // 3,增加异常处理,保证出现异常时,running节点能被删除,否则会导致死锁 + public synchronized void initRunning() { + if (!isStart()) { + return; + } + + String path = getTopicClientRunning(this.topic, clientData.getGroupId()); + // 序列化 + byte[] bytes = JsonUtils.marshalToByte(clientData); + try { + mutex.set(false); + zkClient.create(path, bytes, CreateMode.EPHEMERAL); + processActiveEnter();// 触发一下事件 + activeData = clientData; + mutex.set(true); + } catch (ZkNodeExistsException e) { + bytes = zkClient.readData(path, true); + if (bytes == null) {// 如果不存在节点,立即尝试一次 + initRunning(); + } else { + activeData = JsonUtils.unmarshalFromByte(bytes, ClientRunningData.class); + // 如果发现已经存在,判断一下是否自己,避免活锁 + if (activeData.getAddress().contains(":") && isMine(activeData.getAddress())) { + mutex.set(true); + } + } + } catch (ZkNoNodeException e) { + zkClient.createPersistent(getClientIdNodePath(this.topic, clientData.getGroupId()), true); // 尝试创建父节点 + initRunning(); + } catch (Throwable t) { + logger.error(MessageFormat.format("There is an error when execute initRunning method, with destination [{0}].", + topic), + t); + // 出现任何异常尝试release + releaseRunning(); + throw new CanalClientException("something goes wrong in initRunning method. ", t); + } + } + + /** + * 阻塞等待自己成为active,如果自己成为active,立马返回 + * + * @throws InterruptedException + */ + public void waitForActive() throws InterruptedException { + initRunning(); + mutex.get(); + } + + /** + * 检查当前的状态 + */ + public boolean check() { + String path = getTopicClientRunning(this.topic, clientData.getGroupId()); + // ZookeeperPathUtils.getDestinationClientRunning(this.destination, + // clientData.getClientId()); + try { + byte[] bytes = zkClient.readData(path); + ClientRunningData eventData = JsonUtils.unmarshalFromByte(bytes, ClientRunningData.class); + activeData = eventData;// 更新下为最新值 + // 检查下nid是否为自己 + boolean result = isMine(activeData.getAddress()); + if (!result) { + logger.warn("canal is running in [{}] , but not in [{}]", + activeData.getAddress(), + clientData.getAddress()); + } + return result; + } catch (ZkNoNodeException e) { + logger.warn("canal is not run any in node"); + return false; + } catch (ZkInterruptedException e) { + logger.warn("canal check is interrupt"); + Thread.interrupted();// 清除interrupt标记 + return check(); + } catch (ZkException e) { + logger.warn("canal check is failed"); + return false; + } + } + + public boolean releaseRunning() { + if (check()) { + String path = getTopicClientRunning(this.topic, clientData.getGroupId()); + zkClient.delete(path); + mutex.set(false); + processActiveExit(); + return true; + } + + return false; + } + + // ====================== helper method ====================== + + private boolean isMine(String address) { + return address.equals(clientData.getAddress()); + } + + private void processActiveEnter() { + if (listener != null) { + // 触发回调 + listener.processActiveEnter(); + this.clientData.setAddress(/* address */AddressUtils.getHostIp() + ":" + virtualPort); + + String path = getTopicClientRunning(this.topic, clientData.getGroupId()); + // 序列化 + byte[] bytes = JsonUtils.marshalToByte(clientData); + zkClient.writeData(path, bytes); + } + } + + private void processActiveExit() { + if (listener != null) { + listener.processActiveExit(); + } + } + + public void setListener(ClientRunningListener listener) { + this.listener = listener; + } + + // ===================== setter / getter ======================= + + public void setTopic(String topic) { + this.topic = topic; + } + + public void setClientData(ClientRunningData clientData) { + this.clientData = clientData; + } + + public void setDelayTime(int delayTime) { + this.delayTime = delayTime; + } + + public void setZkClient(ZkClientx zkClient) { + this.zkClient = zkClient; + } + +} diff --git a/kafka-client/src/test/java/com/alibaba/otter/canal/kafka/client/running/AbstractKafkaTest.java b/kafka-client/src/test/java/com/alibaba/otter/canal/kafka/client/running/AbstractKafkaTest.java new file mode 100644 index 00000000..22dda072 --- /dev/null +++ b/kafka-client/src/test/java/com/alibaba/otter/canal/kafka/client/running/AbstractKafkaTest.java @@ -0,0 +1,26 @@ +package com.alibaba.otter.canal.kafka.client.running; + +import org.junit.Assert; + +/** + * Kafka 测试基类 + * + * @author machengyuan @ 2018-6-12 + * @version 1.0.0 + */ +public abstract class AbstractKafkaTest { + + public static String topic = "example"; + public static Integer partition = null; + public static String groupId = "g4"; + public static String servers = "slave1:6667,slave2:6667,slave3:6667"; + public static String zkServers = "slave1:2181,slave2:2181,slave3:2181"; + + public void sleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + Assert.fail(e.getMessage()); + } + } +} diff --git a/kafka-client/src/test/java/com/alibaba/otter/canal/kafka/client/running/CanalKafkaClientExample.java b/kafka-client/src/test/java/com/alibaba/otter/canal/kafka/client/running/CanalKafkaClientExample.java new file mode 100644 index 00000000..f4a0afc5 --- /dev/null +++ b/kafka-client/src/test/java/com/alibaba/otter/canal/kafka/client/running/CanalKafkaClientExample.java @@ -0,0 +1,144 @@ +package com.alibaba.otter.canal.kafka.client.running; + +import java.util.concurrent.TimeUnit; + +import org.apache.kafka.common.errors.WakeupException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.Assert; + +import com.alibaba.otter.canal.kafka.client.KafkaCanalConnector; +import com.alibaba.otter.canal.kafka.client.KafkaCanalConnectors; +import com.alibaba.otter.canal.protocol.Message; + +/** + * Kafka client example + * + * @author machengyuan @ 2018-6-12 + * @version 1.0.0 + */ +public class CanalKafkaClientExample { + + protected final static Logger logger = LoggerFactory.getLogger(CanalKafkaClientExample.class); + + private KafkaCanalConnector connector; + + private static volatile boolean running = false; + + private Thread thread = null; + + private Thread.UncaughtExceptionHandler handler = new Thread.UncaughtExceptionHandler() { + + public void uncaughtException(Thread t, Throwable e) { + logger.error("parse events has an error", e); + } + }; + + public CanalKafkaClientExample(String zkServers, String servers, String topic, Integer partition, String groupId) { + connector = KafkaCanalConnectors.newKafkaConnector(zkServers, servers, topic, partition, groupId); + } + + public static void main(String[] args) { + try { + final CanalKafkaClientExample kafkaCanalClientExample = new CanalKafkaClientExample(AbstractKafkaTest.zkServers, + AbstractKafkaTest.servers, + AbstractKafkaTest.topic, + AbstractKafkaTest.partition, + AbstractKafkaTest.groupId); + logger.info("## start the kafka consumer: {}-{}", AbstractKafkaTest.topic, AbstractKafkaTest.groupId); + kafkaCanalClientExample.start(); + logger.info("## the canal kafka consumer is running now ......"); + Runtime.getRuntime().addShutdownHook(new Thread() { + + public void run() { + try { + logger.info("## stop the kafka consumer"); + kafkaCanalClientExample.stop(); + } catch (Throwable e) { + logger.warn("##something goes wrong when stopping kafka consumer:", e); + } finally { + logger.info("## kafka consumer is down."); + } + } + + }); + while (running) + ; + } catch (Throwable e) { + logger.error("## Something goes wrong when starting up the kafka consumer:", e); + System.exit(0); + } + } + + public void start() { + Assert.notNull(connector, "connector is null"); + thread = new Thread(new Runnable() { + + public void run() { + process(); + } + }); + thread.setUncaughtExceptionHandler(handler); + thread.start(); + running = true; + } + + public void stop() { + if (!running) { + return; + } + connector.stopRunning(); + running = false; + if (thread != null) { + try { + thread.join(); + } catch (InterruptedException e) { + // ignore + } + } + } + + private void process() { + while (!running) + ; + while (running) { + try { + connector.connect(); + connector.subscribe(); + while (running) { + try { + Message message = connector.getWithoutAck(1L, TimeUnit.SECONDS); // 获取message + if (message == null) { + continue; + } + long batchId = message.getId(); + int size = message.getEntries().size(); + if (batchId == -1 || size == 0) { + // try { + // Thread.sleep(1000); + // } catch (InterruptedException e) { + // } + } else { + // printSummary(message, batchId, size); + // printEntry(message.getEntries()); + logger.info(message.toString()); + } + + connector.ack(); // 提交确认 + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + } + + try { + connector.unsubscribe(); + } catch (WakeupException e) { + // No-op. Continue process + } + connector.disconnnect(); + } +} diff --git a/kafka-client/src/test/java/com/alibaba/otter/canal/kafka/client/running/KafkaClientRunningTest.java b/kafka-client/src/test/java/com/alibaba/otter/canal/kafka/client/running/KafkaClientRunningTest.java new file mode 100644 index 00000000..d8ff6d30 --- /dev/null +++ b/kafka-client/src/test/java/com/alibaba/otter/canal/kafka/client/running/KafkaClientRunningTest.java @@ -0,0 +1,62 @@ +package com.alibaba.otter.canal.kafka.client.running; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +import org.apache.kafka.common.errors.WakeupException; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.alibaba.otter.canal.kafka.client.KafkaCanalConnector; +import com.alibaba.otter.canal.kafka.client.KafkaCanalConnectors; +import com.alibaba.otter.canal.protocol.Message; + +/** + * Kafka consumer获取Message的测试例子 + * + * @author machengyuan @ 2018-6-12 + * @version 1.0.0 + */ +public class KafkaClientRunningTest extends AbstractKafkaTest { + + private Logger logger = LoggerFactory.getLogger(KafkaClientRunningTest.class); + + private boolean running = true; + + @Test + public void testKafkaConsumer() { + final ExecutorService executor = Executors.newFixedThreadPool(1); + + final KafkaCanalConnector connector = KafkaCanalConnectors.newKafkaConnector(servers, topic, partition, groupId); + + executor.submit(new Runnable() { + + @Override + public void run() { + connector.connect(); + connector.subscribe(); + while (running) { + try { + Message message = connector.getWithoutAck(3L, TimeUnit.SECONDS); + if (message != null) { + System.out.println(message); + } + connector.ack(); + } catch (WakeupException e) { + // ignore + } + } + connector.unsubscribe(); + connector.disconnnect(); + } + }); + + sleep(60000); + running = false; + executor.shutdown(); + logger.info("shutdown completed"); + } + +} diff --git a/kafka-client/src/test/resources/logback.xml b/kafka-client/src/test/resources/logback.xml new file mode 100644 index 00000000..81fa0712 --- /dev/null +++ b/kafka-client/src/test/resources/logback.xml @@ -0,0 +1,19 @@ + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{56} - %msg%n + + + + + + + + + + + + + \ No newline at end of file diff --git a/kafka/pom.xml b/kafka/pom.xml new file mode 100644 index 00000000..8d3b35d7 --- /dev/null +++ b/kafka/pom.xml @@ -0,0 +1,140 @@ + + + 4.0.0 + + canal + com.alibaba.otter + 1.0.26-SNAPSHOT + ../pom.xml + + com.alibaba.otter + canal.kafka + jar + canal kafka module for otter ${project.version} + + + com.alibaba.otter + canal.deployer + ${project.version} + + + + org.yaml + snakeyaml + 1.17 + + + + org.apache.kafka + kafka_2.11 + 0.9.0.1 + + + org.slf4j + slf4j-log4j12 + + + + + + + + + + maven-jar-plugin + + + true + + + **/logback.xml + **/canal.properties + **/spring/** + **/example/** + **/kafka.yml + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + 2.2.1 + + + assemble + + single + + package + + + + false + false + + + + + + + + dev + + true + + env + !release + + + + + + + maven-assembly-plugin + + + + ${basedir}/src/main/assembly/dev.xml + + canal + ${project.build.directory} + + + + + + + + + release + + + env + release + + + + + + + maven-assembly-plugin + + + + ${basedir}/src/main/assembly/release.xml + + + ${project.artifactId}-${project.version} + + ${project.parent.build.directory} + + + + + + + \ No newline at end of file diff --git a/kafka/src/main/assembly/dev.xml b/kafka/src/main/assembly/dev.xml new file mode 100644 index 00000000..2c3e3fff --- /dev/null +++ b/kafka/src/main/assembly/dev.xml @@ -0,0 +1,64 @@ + + dist + + dir + + false + + + . + / + + README* + + + + ./src/main/bin + bin + + **/* + + 0755 + + + ../deployer/src/main/conf + /conf + + **/* + + + + ../deployer/src/main/resources + /conf + + **/* + + + logback.xml + + + + ./src/main/resources + /conf + + **/* + + + + target + logs + + **/* + + + + + + lib + + junit:junit + + + + diff --git a/kafka/src/main/assembly/release.xml b/kafka/src/main/assembly/release.xml new file mode 100644 index 00000000..0b103620 --- /dev/null +++ b/kafka/src/main/assembly/release.xml @@ -0,0 +1,64 @@ + + dist + + tar.gz + + false + + + . + / + + README* + + + + ./src/main/bin + bin + + **/* + + 0755 + + + ../deployer/src/main/conf + /conf + + **/* + + + + ../deployer/src/main/resources + /conf + + **/* + + + logback.xml + + + + ./src/main/resources + /conf + + **/* + + + + target + logs + + **/* + + + + + + lib + + junit:junit + + + + diff --git a/kafka/src/main/bin/startup.bat b/kafka/src/main/bin/startup.bat new file mode 100755 index 00000000..429cc653 --- /dev/null +++ b/kafka/src/main/bin/startup.bat @@ -0,0 +1,25 @@ +@echo off +@if not "%ECHO%" == "" echo %ECHO% +@if "%OS%" == "Windows_NT" setlocal + +set ENV_PATH=.\ +if "%OS%" == "Windows_NT" set ENV_PATH=%~dp0% + +set conf_dir=%ENV_PATH%\..\conf +set canal_conf=%conf_dir%\canal.properties +set logback_configurationFile=%conf_dir%\logback.xml + +set CLASSPATH=%conf_dir% +set CLASSPATH=%conf_dir%\..\lib\*;%CLASSPATH% + +set JAVA_MEM_OPTS= -Xms128m -Xmx512m -XX:PermSize=128m +set JAVA_OPTS_EXT= -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dapplication.codeset=UTF-8 -Dfile.encoding=UTF-8 +set JAVA_DEBUG_OPT= -server -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=9099,server=y,suspend=n +set CANAL_OPTS= -DappName=otter-canal -Dlogback.configurationFile="%logback_configurationFile%" -Dcanal.conf="%canal_conf%" + +set JAVA_OPTS= %JAVA_MEM_OPTS% %JAVA_OPTS_EXT% %JAVA_DEBUG_OPT% %CANAL_OPTS% + +set CMD_STR= java %JAVA_OPTS% -classpath "%CLASSPATH%" java %JAVA_OPTS% -classpath "%CLASSPATH%" com.alibaba.otter.canal.kafka.CanalLauncher +echo start cmd : %CMD_STR% + +java %JAVA_OPTS% -classpath "%CLASSPATH%" com.alibaba.otter.canal.kafka.CanalLauncher \ No newline at end of file diff --git a/kafka/src/main/bin/startup.sh b/kafka/src/main/bin/startup.sh new file mode 100644 index 00000000..184c4b3f --- /dev/null +++ b/kafka/src/main/bin/startup.sh @@ -0,0 +1,104 @@ +#!/bin/bash + +current_path=`pwd` +case "`uname`" in + Linux) + bin_abs_path=$(readlink -f $(dirname $0)) + ;; + *) + bin_abs_path=`cd $(dirname $0); pwd` + ;; +esac +base=${bin_abs_path}/.. +canal_conf=$base/conf/canal.properties +logback_configurationFile=$base/conf/logback.xml +export LANG=en_US.UTF-8 +export BASE=$base + +if [ -f $base/bin/canal.pid ] ; then + echo "found canal.pid , Please run stop.sh first ,then startup.sh" 2>&2 + exit 1 +fi + +if [ ! -d $base/logs/canal ] ; then + mkdir -p $base/logs/canal +fi + +## set java path +if [ -z "$JAVA" ] ; then + JAVA=$(which java) +fi + +ALIBABA_JAVA="/usr/alibaba/java/bin/java" +TAOBAO_JAVA="/opt/taobao/java/bin/java" +if [ -z "$JAVA" ]; then + if [ -f $ALIBABA_JAVA ] ; then + JAVA=$ALIBABA_JAVA + elif [ -f $TAOBAO_JAVA ] ; then + JAVA=$TAOBAO_JAVA + else + echo "Cannot find a Java JDK. Please set either set JAVA or put java (>=1.5) in your PATH." 2>&2 + exit 1 + fi +fi + +case "$#" +in +0 ) + ;; +1 ) + var=$* + if [ -f $var ] ; then + canal_conf=$var + else + echo "THE PARAMETER IS NOT CORRECT.PLEASE CHECK AGAIN." + exit + fi;; +2 ) + var=$1 + if [ -f $var ] ; then + canal_conf=$var + else + if [ "$1" = "debug" ]; then + DEBUG_PORT=$2 + DEBUG_SUSPEND="n" + JAVA_DEBUG_OPT="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=$DEBUG_PORT,server=y,suspend=$DEBUG_SUSPEND" + fi + fi;; +* ) + echo "THE PARAMETERS MUST BE TWO OR LESS.PLEASE CHECK AGAIN." + exit;; +esac + +str=`file -L $JAVA | grep 64-bit` +if [ -n "$str" ]; then + JAVA_OPTS="-server -Xms2048m -Xmx3072m -Xmn1024m -XX:SurvivorRatio=2 -XX:PermSize=96m -XX:MaxPermSize=256m -Xss256k -XX:-UseAdaptiveSizePolicy -XX:MaxTenuringThreshold=15 -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError" +else + JAVA_OPTS="-server -Xms1024m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:MaxPermSize=128m " +fi + +JAVA_OPTS=" $JAVA_OPTS -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dfile.encoding=UTF-8" +CANAL_OPTS="-DappName=otter-canal -Dlogback.configurationFile=$logback_configurationFile -Dcanal.conf=$canal_conf" + +if [ -e $canal_conf -a -e $logback_configurationFile ] +then + + for i in $base/lib/*; + do CLASSPATH=$i:"$CLASSPATH"; + done + CLASSPATH="$base/conf:$CLASSPATH"; + + echo "cd to $bin_abs_path for workaround relative path" + cd $bin_abs_path + + echo LOG CONFIGURATION : $logback_configurationFile + echo canal conf : $canal_conf + echo CLASSPATH :$CLASSPATH + $JAVA $JAVA_OPTS $JAVA_DEBUG_OPT $CANAL_OPTS -classpath .:$CLASSPATH com.alibaba.otter.canal.kafka.CanalLauncher 1>>$base/logs/canal/canal.log 2>&1 & + echo $! > $base/bin/canal.pid + + echo "cd to $current_path for continue" + cd $current_path +else + echo "canal conf("$canal_conf") OR log configration file($logback_configurationFile) is not exist,please create then first!" +fi diff --git a/kafka/src/main/bin/stop.sh b/kafka/src/main/bin/stop.sh new file mode 100644 index 00000000..f398749c --- /dev/null +++ b/kafka/src/main/bin/stop.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +cygwin=false; +linux=false; +case "`uname`" in + CYGWIN*) + cygwin=true + ;; + Linux*) + linux=true + ;; +esac + +get_pid() { + STR=$1 + PID=$2 + if $cygwin; then + JAVA_CMD="$JAVA_HOME\bin\java" + JAVA_CMD=`cygpath --path --unix $JAVA_CMD` + JAVA_PID=`ps |grep $JAVA_CMD |awk '{print $1}'` + else + if $linux; then + if [ ! -z "$PID" ]; then + JAVA_PID=`ps -C java -f --width 1000|grep "$STR"|grep "$PID"|grep -v grep|awk '{print $2}'` + else + JAVA_PID=`ps -C java -f --width 1000|grep "$STR"|grep -v grep|awk '{print $2}'` + fi + else + if [ ! -z "$PID" ]; then + JAVA_PID=`ps aux |grep "$STR"|grep "$PID"|grep -v grep|awk '{print $2}'` + else + JAVA_PID=`ps aux |grep "$STR"|grep -v grep|awk '{print $2}'` + fi + fi + fi + echo $JAVA_PID; +} + +base=`dirname $0`/.. +pidfile=$base/bin/canal.pid +if [ ! -f "$pidfile" ];then + echo "canal is not running. exists" + exit +fi + +pid=`cat $pidfile` +if [ "$pid" == "" ] ; then + pid=`get_pid "appName=otter-canal"` +fi + +echo -e "`hostname`: stopping canal $pid ... " +kill $pid + +LOOPS=0 +while (true); +do + gpid=`get_pid "appName=otter-canal" "$pid"` + if [ "$gpid" == "" ] ; then + echo "Oook! cost:$LOOPS" + `rm $pidfile` + break; + fi + let LOOPS=LOOPS+1 + sleep 1 +done \ No newline at end of file diff --git a/kafka/src/main/java/com/alibaba/otter/canal/kafka/CanalLauncher.java b/kafka/src/main/java/com/alibaba/otter/canal/kafka/CanalLauncher.java new file mode 100644 index 00000000..3212733c --- /dev/null +++ b/kafka/src/main/java/com/alibaba/otter/canal/kafka/CanalLauncher.java @@ -0,0 +1,17 @@ +package com.alibaba.otter.canal.kafka; + +import com.alibaba.otter.canal.kafka.producer.CanalKafkaStarter; + +/** + * canal-kafka独立版本启动的入口类 + * + * @author machengyuan 2018-6-11 下午05:30:49 + * @version 1.0.0 + */ +public class CanalLauncher { + + public static void main(String[] args) { + CanalServerStarter.init(); + CanalKafkaStarter.init(); + } +} diff --git a/kafka/src/main/java/com/alibaba/otter/canal/kafka/CanalServerStarter.java b/kafka/src/main/java/com/alibaba/otter/canal/kafka/CanalServerStarter.java new file mode 100644 index 00000000..573f0eac --- /dev/null +++ b/kafka/src/main/java/com/alibaba/otter/canal/kafka/CanalServerStarter.java @@ -0,0 +1,78 @@ +package com.alibaba.otter.canal.kafka; + +import java.io.FileInputStream; +import java.util.Properties; + +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.alibaba.otter.canal.deployer.CanalController; + +/** + * canal server 启动类 + * + * @author machengyuan 2018-6-11 下午05:30:49 + * @version 1.0.0 + */ +public class CanalServerStarter { + + private static final String CLASSPATH_URL_PREFIX = "classpath:"; + private static final Logger logger = LoggerFactory.getLogger(CanalServerStarter.class); + private volatile static boolean running = false; + + public static void init() { + try { + logger.info("## set default uncaught exception handler"); + setGlobalUncaughtExceptionHandler(); + + logger.info("## load canal configurations"); + String conf = System.getProperty("canal.conf", "classpath:canal.properties"); + Properties properties = new Properties(); + if (conf.startsWith(CLASSPATH_URL_PREFIX)) { + conf = StringUtils.substringAfter(conf, CLASSPATH_URL_PREFIX); + properties.load(CanalLauncher.class.getClassLoader().getResourceAsStream(conf)); + } else { + properties.load(new FileInputStream(conf)); + } + + logger.info("## start the canal server."); + final CanalController controller = new CanalController(properties); + controller.start(); + running = true; + logger.info("## the canal server is running now ......"); + Runtime.getRuntime().addShutdownHook(new Thread() { + + public void run() { + try { + logger.info("## stop the canal server"); + running = false; + controller.stop(); + } catch (Throwable e) { + logger.warn("##something goes wrong when stopping canal Server:", e); + } finally { + logger.info("## canal server is down."); + } + } + + }); + } catch (Throwable e) { + logger.error("## Something goes wrong when starting up the canal Server:", e); + System.exit(0); + } + } + + public static boolean isRunning() { + return running; + } + + private static void setGlobalUncaughtExceptionHandler() { + Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + + @Override + public void uncaughtException(Thread t, Throwable e) { + logger.error("UnCaughtException", e); + } + }); + } +} diff --git a/kafka/src/main/java/com/alibaba/otter/canal/kafka/producer/CanalKafkaProducer.java b/kafka/src/main/java/com/alibaba/otter/canal/kafka/producer/CanalKafkaProducer.java new file mode 100644 index 00000000..4543aac1 --- /dev/null +++ b/kafka/src/main/java/com/alibaba/otter/canal/kafka/producer/CanalKafkaProducer.java @@ -0,0 +1,88 @@ +package com.alibaba.otter.canal.kafka.producer; + +import java.io.IOException; +import java.util.Properties; + +import org.apache.kafka.clients.producer.KafkaProducer; +import org.apache.kafka.clients.producer.Producer; +import org.apache.kafka.clients.producer.ProducerRecord; +import org.apache.kafka.common.serialization.StringSerializer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.alibaba.otter.canal.kafka.producer.KafkaProperties.Topic; +import com.alibaba.otter.canal.protocol.Message; + +/** + * kafka producer 主操作类 + * + * @author machengyuan 2018-6-11 下午05:30:49 + * @version 1.0.0 + */ +public class CanalKafkaProducer { + + private static final Logger logger = LoggerFactory.getLogger(CanalKafkaProducer.class); + + private Producer producer; + + public void init(KafkaProperties kafkaProperties) { + Properties properties = new Properties(); + properties.put("bootstrap.servers", kafkaProperties.getServers()); + properties.put("acks", "all"); + properties.put("retries", kafkaProperties.getRetries()); + properties.put("batch.size", kafkaProperties.getBatchSize()); + properties.put("linger.ms", kafkaProperties.getLingerMs()); + properties.put("buffer.memory", kafkaProperties.getBufferMemory()); + properties.put("key.serializer", StringSerializer.class.getName()); + properties.put("value.serializer", MessageSerializer.class.getName()); + producer = new KafkaProducer(properties); + } + + public void stop() { + try { + logger.info("## stop the kafka producer"); + producer.close(); + } catch (Throwable e) { + logger.warn("##something goes wrong when stopping kafka producer:", e); + } finally { + logger.info("## kafka producer is down."); + } + } + + public void send(Topic topic, Message message) throws IOException { + // set canal.instance.filter.transaction.entry = true + + // boolean valid = false; + // if (message != null) { + // if (message.isRaw() && !message.getRawEntries().isEmpty()) { + // for (ByteString byteString : message.getRawEntries()) { + // CanalEntry.Entry entry = CanalEntry.Entry.parseFrom(byteString); + // if (entry.getEntryType() != CanalEntry.EntryType.TRANSACTIONBEGIN + // && entry.getEntryType() != CanalEntry.EntryType.TRANSACTIONEND) { + // valid = true; + // break; + // } + // } + // } else if (!message.getEntries().isEmpty()){ + // for (CanalEntry.Entry entry : message.getEntries()) { + // if (entry.getEntryType() != CanalEntry.EntryType.TRANSACTIONBEGIN + // && entry.getEntryType() != CanalEntry.EntryType.TRANSACTIONEND) { + // valid = true; + // break; + // } + // } + // } + // } + // if (!valid) { + // return; + // } + ProducerRecord record; + if (topic.getPartition() != null) { + record = new ProducerRecord(topic.getTopic(), topic.getPartition(), null, message); + } else { + record = new ProducerRecord(topic.getTopic(), message); + } + producer.send(record); + logger.debug("send message to kafka topic: {} \n {}", topic.getTopic(), message.toString()); + } +} diff --git a/kafka/src/main/java/com/alibaba/otter/canal/kafka/producer/CanalKafkaStarter.java b/kafka/src/main/java/com/alibaba/otter/canal/kafka/producer/CanalKafkaStarter.java new file mode 100644 index 00000000..0eedfa7a --- /dev/null +++ b/kafka/src/main/java/com/alibaba/otter/canal/kafka/producer/CanalKafkaStarter.java @@ -0,0 +1,150 @@ +package com.alibaba.otter.canal.kafka.producer; + +import java.io.FileInputStream; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.yaml.snakeyaml.Yaml; + +import com.alibaba.otter.canal.kafka.CanalServerStarter; +import com.alibaba.otter.canal.kafka.producer.KafkaProperties.CanalDestination; +import com.alibaba.otter.canal.kafka.producer.KafkaProperties.Topic; +import com.alibaba.otter.canal.protocol.ClientIdentity; +import com.alibaba.otter.canal.protocol.Message; +import com.alibaba.otter.canal.server.embedded.CanalServerWithEmbedded; + +/** + * kafka 启动类 + * + * @author machengyuan 2018-6-11 下午05:30:49 + * @version 1.0.0 + */ +public class CanalKafkaStarter { + + private static final String CLASSPATH_URL_PREFIX = "classpath:"; + private static final Logger logger = LoggerFactory.getLogger(CanalKafkaStarter.class); + + private volatile static boolean running = false; + + private static ExecutorService executorService; + + private static CanalKafkaProducer canalKafkaProducer; + + private static KafkaProperties kafkaProperties; + + public static void init() { + try { + logger.info("## load kafka configurations"); + String conf = System.getProperty("kafka.conf", "classpath:kafka.yml"); + + if (conf.startsWith(CLASSPATH_URL_PREFIX)) { + conf = StringUtils.substringAfter(conf, CLASSPATH_URL_PREFIX); + kafkaProperties = new Yaml().loadAs(CanalKafkaStarter.class.getClassLoader().getResourceAsStream(conf), + KafkaProperties.class); + } else { + kafkaProperties = new Yaml().loadAs(new FileInputStream(conf), KafkaProperties.class); + } + + // 初始化 kafka producer + canalKafkaProducer = new CanalKafkaProducer(); + canalKafkaProducer.init(kafkaProperties); + // set filterTransactionEntry + if (kafkaProperties.isFilterTransactionEntry()) { + System.setProperty("canal.instance.filter.transaction.entry", "true"); + } + // 对应每个instance启动一个worker线程 + List destinations = kafkaProperties.getCanalDestinations(); + + executorService = Executors.newFixedThreadPool(destinations.size()); + + logger.info("## start the kafka workers."); + for (final CanalDestination destination : destinations) { + executorService.execute(new Runnable() { + + @Override + public void run() { + worker(destination); + } + }); + } + running = true; + logger.info("## the kafka workers is running now ......"); + Runtime.getRuntime().addShutdownHook(new Thread() { + + public void run() { + try { + logger.info("## stop the kafka workers"); + running = false; + executorService.shutdown(); + canalKafkaProducer.stop(); + } catch (Throwable e) { + logger.warn("##something goes wrong when stopping kafka workers:", e); + } finally { + logger.info("## canal kafka is down."); + } + } + + }); + + } catch (Throwable e) { + logger.error("## Something goes wrong when starting up the canal kafka workers:", e); + System.exit(0); + } + } + + private static void worker(CanalDestination destination) { + while (!running) + ; + while (!CanalServerStarter.isRunning()) + ; // 等待server启动完成 + logger.info("## start the canal consumer: {}.", destination.getCanalDestination()); + CanalServerWithEmbedded server = CanalServerWithEmbedded.instance(); + ClientIdentity clientIdentity = new ClientIdentity(destination.getCanalDestination(), (short) 1001, ""); + while (running) { + try { + if (!server.getCanalInstances().containsKey(clientIdentity.getDestination())) { + try { + Thread.sleep(3000); + } catch (InterruptedException e) { + // ignore + } + continue; + } + server.subscribe(clientIdentity); + logger.info("## the canal consumer {} is running now ......", destination.getCanalDestination()); + + while (running) { + Message message = server.getWithoutAck(clientIdentity, kafkaProperties.getCanalBatchSize()); // 获取指定数量的数据 + long batchId = message.getId(); + try { + int size = message.isRaw() ? message.getRawEntries().size() : message.getEntries().size(); + if (batchId != -1 && size != 0) { + if (!StringUtils.isEmpty(destination.getTopic())) { + Topic topic = new Topic(); + topic.setTopic(destination.getTopic()); + topic.setPartition(destination.getPartition()); + destination.getTopics().add(topic); + } + for (Topic topic : destination.getTopics()) { + canalKafkaProducer.send(topic, message); // 发送message到所有topic + } + } + + if (batchId != -1) { + server.ack(clientIdentity, batchId); // 提交确认 + } + } catch (Exception e) { + server.rollback(clientIdentity); + logger.error(e.getMessage(), e); + } + } + } catch (Exception e) { + logger.error("process error!", e); + } + } + } +} diff --git a/kafka/src/main/java/com/alibaba/otter/canal/kafka/producer/KafkaProperties.java b/kafka/src/main/java/com/alibaba/otter/canal/kafka/producer/KafkaProperties.java new file mode 100644 index 00000000..8e193aac --- /dev/null +++ b/kafka/src/main/java/com/alibaba/otter/canal/kafka/producer/KafkaProperties.java @@ -0,0 +1,170 @@ +package com.alibaba.otter.canal.kafka.producer; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * kafka 配置项 + * + * @author machengyuan 2018-6-11 下午05:30:49 + * @version 1.0.0 + */ +public class KafkaProperties { + + private String servers = "localhost:6667"; + private int retries = 0; + private int batchSize = 16384; + private int lingerMs = 1; + private long bufferMemory = 33554432L; + private boolean filterTransactionEntry = true; + private int canalBatchSize = 5; + + private List canalDestinations = new ArrayList(); + + public static class CanalDestination { + + private String canalDestination; + private String topic; + private Integer partition; + private Set topics = new HashSet(); + + public String getCanalDestination() { + return canalDestination; + } + + public void setCanalDestination(String canalDestination) { + this.canalDestination = canalDestination; + } + + public String getTopic() { + return topic; + } + + public void setTopic(String topic) { + this.topic = topic; + } + + public Integer getPartition() { + return partition; + } + + public void setPartition(Integer partition) { + this.partition = partition; + } + + public Set getTopics() { + return topics; + } + + public void setTopics(Set topics) { + this.topics = topics; + } + } + + public static class Topic { + + private String topic; + private Integer partition; + + public String getTopic() { + return topic; + } + + public void setTopic(String topic) { + this.topic = topic; + } + + public Integer getPartition() { + return partition; + } + + public void setPartition(Integer partition) { + this.partition = partition; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Topic topic1 = (Topic) o; + + if (topic != null ? !topic.equals(topic1.topic) : topic1.topic != null) return false; + return partition != null ? partition.equals(topic1.partition) : topic1.partition == null; + } + + @Override + public int hashCode() { + int result = topic != null ? topic.hashCode() : 0; + result = 31 * result + (partition != null ? partition.hashCode() : 0); + return result; + } + } + + public String getServers() { + return servers; + } + + public void setServers(String servers) { + this.servers = servers; + } + + public int getRetries() { + return retries; + } + + public void setRetries(int retries) { + this.retries = retries; + } + + public int getBatchSize() { + return batchSize; + } + + public void setBatchSize(int batchSize) { + this.batchSize = batchSize; + } + + public int getLingerMs() { + return lingerMs; + } + + public void setLingerMs(int lingerMs) { + this.lingerMs = lingerMs; + } + + public long getBufferMemory() { + return bufferMemory; + } + + public void setBufferMemory(long bufferMemory) { + this.bufferMemory = bufferMemory; + } + + public int getCanalBatchSize() { + return canalBatchSize; + } + + public void setCanalBatchSize(int canalBatchSize) { + this.canalBatchSize = canalBatchSize; + } + + public List getCanalDestinations() { + return canalDestinations; + } + + public void setCanalDestinations(List canalDestinations) { + this.canalDestinations = canalDestinations; + } + + public boolean isFilterTransactionEntry() { + return filterTransactionEntry; + } + + public void setFilterTransactionEntry(boolean filterTransactionEntry) { + this.filterTransactionEntry = filterTransactionEntry; + } + +} diff --git a/kafka/src/main/java/com/alibaba/otter/canal/kafka/producer/MessageSerializer.java b/kafka/src/main/java/com/alibaba/otter/canal/kafka/producer/MessageSerializer.java new file mode 100644 index 00000000..02336004 --- /dev/null +++ b/kafka/src/main/java/com/alibaba/otter/canal/kafka/producer/MessageSerializer.java @@ -0,0 +1,92 @@ +package com.alibaba.otter.canal.kafka.producer; + +import java.util.List; +import java.util.Map; + +import org.apache.kafka.common.errors.SerializationException; +import org.apache.kafka.common.serialization.Serializer; +import org.springframework.util.CollectionUtils; + +import com.alibaba.otter.canal.protocol.CanalEntry; +import com.alibaba.otter.canal.protocol.CanalPacket; +import com.alibaba.otter.canal.protocol.CanalPacket.PacketType; +import com.alibaba.otter.canal.protocol.Message; +import com.google.protobuf.ByteString; +import com.google.protobuf.CodedOutputStream; +import com.google.protobuf.WireFormat; + +/** + * Kafka Message类的序列化 + * + * @author machengyuan 2018-6-11 下午05:30:49 + * @version 1.0.0 + */ +public class MessageSerializer implements Serializer { + + @Override + public void configure(Map configs, boolean isKey) { + } + + @Override + public byte[] serialize(String topic, Message data) { + try { + if (data != null) { + if (data.getId() != -1) { + if (data.isRaw() && !CollectionUtils.isEmpty(data.getRawEntries())) { + // for performance + List rowEntries = data.getRawEntries(); + // message size + int messageSize = 0; + messageSize += com.google.protobuf.CodedOutputStream.computeInt64Size(1, data.getId()); + + int dataSize = 0; + for (int i = 0; i < rowEntries.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream.computeBytesSizeNoTag(rowEntries.get(i)); + } + messageSize += dataSize; + messageSize += 1 * rowEntries.size(); + // packet size + int size = 0; + size += com.google.protobuf.CodedOutputStream.computeEnumSize(3, + PacketType.MESSAGES.getNumber()); + size += com.google.protobuf.CodedOutputStream.computeTagSize(5) + + com.google.protobuf.CodedOutputStream.computeRawVarint32Size(messageSize) + + messageSize; + // build data + byte[] body = new byte[size]; + CodedOutputStream output = CodedOutputStream.newInstance(body); + output.writeEnum(3, PacketType.MESSAGES.getNumber()); + + output.writeTag(5, WireFormat.WIRETYPE_LENGTH_DELIMITED); + output.writeRawVarint32(messageSize); + // message + output.writeInt64(1, data.getId()); + for (int i = 0; i < rowEntries.size(); i++) { + output.writeBytes(2, rowEntries.get(i)); + } + output.checkNoSpaceLeft(); + return body; + } else if (!CollectionUtils.isEmpty(data.getEntries())) { + CanalPacket.Messages.Builder messageBuilder = CanalPacket.Messages.newBuilder(); + for (CanalEntry.Entry entry : data.getEntries()) { + messageBuilder.addMessages(entry.toByteString()); + } + + CanalPacket.Packet.Builder packetBuilder = CanalPacket.Packet.newBuilder(); + packetBuilder.setType(CanalPacket.PacketType.MESSAGES); + packetBuilder.setBody(messageBuilder.build().toByteString()); + return packetBuilder.build().toByteArray(); + } + } + } + } catch (Exception e) { + throw new SerializationException("Error when serializing message to byte[] "); + } + return null; + } + + @Override + public void close() { + // nothing to do + } +} diff --git a/kafka/src/main/resources/kafka.yml b/kafka/src/main/resources/kafka.yml new file mode 100644 index 00000000..d6ccc51a --- /dev/null +++ b/kafka/src/main/resources/kafka.yml @@ -0,0 +1,19 @@ +servers: slave1:6667,slave2:6667,slave3:6667 +retries: 0 +batchSize: 16384 +lingerMs: 1 +bufferMemory: 33554432 +# canal的批次大小,单位 k +canalBatchSize: 50 +filterTransactionEntry: true + +canalDestinations: + - canalDestination: example + topic: example + partition: + # 一个destination可以对应多个topic +# topics: +# - topics: example +# partition: + + diff --git a/kafka/src/main/resources/logback.xml b/kafka/src/main/resources/logback.xml new file mode 100644 index 00000000..34e7b1e5 --- /dev/null +++ b/kafka/src/main/resources/logback.xml @@ -0,0 +1,85 @@ + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{56} - %msg%n + + + + + + + destination + canal + + + + ../logs/${destination}/${destination}.log + + + ../logs/${destination}/%d{yyyy-MM-dd}/${destination}-%d{yyyy-MM-dd}-%i.log.gz + + + 512MB + + 60 + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{56} - %msg%n + + + + + + + + + destination + canal + + + + ../logs/${destination}/meta.log + + + ../logs/${destination}/%d{yyyy-MM-dd}/meta-%d{yyyy-MM-dd}-%i.log.gz + + + 32MB + + 60 + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} - %msg%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/parse/pom.xml b/parse/pom.xml index 5173ae82..994d06f0 100644 --- a/parse/pom.xml +++ b/parse/pom.xml @@ -73,6 +73,10 @@ org.apache.commons commons-compress + + com.lmax + disruptor + junit diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/AbstractEventParser.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/AbstractEventParser.java index d047c6be..7f7d39ac 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/AbstractEventParser.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/AbstractEventParser.java @@ -88,12 +88,19 @@ public abstract class AbstractEventParser extends AbstractCanalLifeCycle protected TimerTask heartBeatTimerTask; protected Throwable exception = null; - protected boolean isGTIDMode = false; // 是否是GTID模式 + protected boolean isGTIDMode = false; // 是否是GTID模式 + protected boolean parallel = true; // 是否开启并行解析模式 + protected Integer parallelThreadSize = Runtime.getRuntime() + .availableProcessors() * 60 / 100; // 60%的能力跑解析,剩余部分处理网络 + protected int parallelBufferSize = 256; // 必须为2的幂 + protected MultiStageCoprocessor multiStageCoprocessor; protected abstract BinlogParser buildParser(); protected abstract ErosaConnection buildErosaConnection(); + protected abstract MultiStageCoprocessor buildMultiStageCoprocessor(); + protected abstract EntryPosition findStartPosition(ErosaConnection connection) throws IOException; protected void preDump(ErosaConnection connection) { @@ -217,19 +224,39 @@ public abstract class AbstractEventParser extends AbstractCanalLifeCycle }; // 4. 开始dump数据 - // 判断所属instance是否启用GTID模式,是的话调用ErosaConnection中GTID对应方法dump数据 - if (isGTIDMode()) { - erosaConnection.dump(MysqlGTIDSet.parse(startPosition.getGtid()), sinkHandler); - } else { - if (StringUtils.isEmpty(startPosition.getJournalName()) && startPosition.getTimestamp() != null) { - erosaConnection.dump(startPosition.getTimestamp(), sinkHandler); + if (parallel) { + // build stage processor + multiStageCoprocessor = buildMultiStageCoprocessor(); + multiStageCoprocessor.start(); + + if (isGTIDMode()) { + // 判断所属instance是否启用GTID模式,是的话调用ErosaConnection中GTID对应方法dump数据 + erosaConnection.dump(MysqlGTIDSet.parse(startPosition.getGtid()), multiStageCoprocessor); } else { - erosaConnection.dump(startPosition.getJournalName(), + if (StringUtils.isEmpty(startPosition.getJournalName()) + && startPosition.getTimestamp() != null) { + erosaConnection.dump(startPosition.getTimestamp(), multiStageCoprocessor); + } else { + erosaConnection.dump(startPosition.getJournalName(), + startPosition.getPosition(), + multiStageCoprocessor); + } + } + } else { + if (isGTIDMode()) { + // 判断所属instance是否启用GTID模式,是的话调用ErosaConnection中GTID对应方法dump数据 + erosaConnection.dump(MysqlGTIDSet.parse(startPosition.getGtid()), sinkHandler); + } else { + if (StringUtils.isEmpty(startPosition.getJournalName()) + && startPosition.getTimestamp() != null) { + erosaConnection.dump(startPosition.getTimestamp(), sinkHandler); + } else { + erosaConnection.dump(startPosition.getJournalName(), startPosition.getPosition(), sinkHandler); + } } } - } catch (TableIdNotFoundException e) { exception = e; // 特殊处理TableIdNotFound异常,出现这样的异常,一种可能就是起始的position是一个事务当中,导致tablemap @@ -275,6 +302,14 @@ public abstract class AbstractEventParser extends AbstractCanalLifeCycle eventSink.interrupt(); transactionBuffer.reset();// 重置一下缓冲队列,重新记录数据 binlogParser.reset();// 重新置位 + if (multiStageCoprocessor != null) { + // 处理 RejectedExecutionException + try { + multiStageCoprocessor.reset(); + } catch (Throwable t) { + logger.debug("multi processor rejected:", t); + } + } if (running) { // sleep一段时间再进行重试 @@ -301,6 +336,11 @@ public abstract class AbstractEventParser extends AbstractCanalLifeCycle stopHeartBeat(); // 先停止心跳 parseThread.interrupt(); // 尝试中断 eventSink.interrupt(); + + if (multiStageCoprocessor != null && multiStageCoprocessor.isStart()) { + multiStageCoprocessor.stop(); + } + try { parseThread.join();// 等待其结束 } catch (InterruptedException e) { @@ -548,4 +588,31 @@ public abstract class AbstractEventParser extends AbstractCanalLifeCycle public void setIsGTIDMode(boolean isGTIDMode) { this.isGTIDMode = isGTIDMode; } + + public boolean isParallel() { + return parallel; + } + + public void setParallel(boolean parallel) { + this.parallel = parallel; + } + + public int getParallelThreadSize() { + return parallelThreadSize; + } + + public void setParallelThreadSize(Integer parallelThreadSize) { + if (parallelThreadSize != null) { + this.parallelThreadSize = parallelThreadSize; + } + } + + public Integer getParallelBufferSize() { + return parallelBufferSize; + } + + public void setParallelBufferSize(int parallelBufferSize) { + this.parallelBufferSize = parallelBufferSize; + } + } diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/ErosaConnection.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/ErosaConnection.java index 97ea3b15..6beb4a9e 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/ErosaConnection.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/ErosaConnection.java @@ -1,9 +1,9 @@ package com.alibaba.otter.canal.parse.inbound; -import com.alibaba.otter.canal.parse.driver.mysql.packets.GTIDSet; - import java.io.IOException; +import com.alibaba.otter.canal.parse.driver.mysql.packets.GTIDSet; + /** * 通用的Erosa的链接接口, 用于一般化处理mysql/oracle的解析过程 * @@ -28,12 +28,16 @@ public interface ErosaConnection { /** * 通过GTID同步binlog - * - * @param gtidSet - * @param func - * @throws IOException */ public void dump(GTIDSet gtidSet, SinkFunction func) throws IOException; + // ------------- + + public void dump(String binlogfilename, Long binlogPosition, MultiStageCoprocessor coprocessor) throws IOException; + + public void dump(long timestamp, MultiStageCoprocessor coprocessor) throws IOException; + + public void dump(GTIDSet gtidSet, MultiStageCoprocessor coprocessor) throws IOException; + ErosaConnection fork(); } diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/MultiStageCoprocessor.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/MultiStageCoprocessor.java new file mode 100644 index 00000000..96e063e9 --- /dev/null +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/MultiStageCoprocessor.java @@ -0,0 +1,29 @@ +package com.alibaba.otter.canal.parse.inbound; + +import com.alibaba.otter.canal.common.CanalLifeCycle; +import com.taobao.tddl.dbsync.binlog.LogBuffer; + +/** + * 针对解析器提供一个多阶段协同的处理 + * + *
      + * 1. 网络接收 (单线程)
      + * 2. 事件基本解析 (单线程,事件类型、DDL解析构造TableMeta、维护位点信息)
      + * 3. 事件深度解析 (多线程, DML事件数据的完整解析)
      + * 4. 投递到store (单线程)
      + * 
      + * + * @author agapple 2018年7月3日 下午4:54:17 + * @since 1.0.26 + */ +public interface MultiStageCoprocessor extends CanalLifeCycle { + + /** + * 网络数据投递 + */ + public boolean publish(LogBuffer buffer); + + public boolean publish(LogBuffer buffer, String binlogFileName); + + public void reset(); +} diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/AbstractMysqlEventParser.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/AbstractMysqlEventParser.java index 3b0e605d..c0d2f190 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/AbstractMysqlEventParser.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/AbstractMysqlEventParser.java @@ -7,10 +7,12 @@ import org.slf4j.LoggerFactory; import com.alibaba.otter.canal.filter.CanalEventFilter; import com.alibaba.otter.canal.filter.aviater.AviaterRegexFilter; +import com.alibaba.otter.canal.parse.CanalEventParser; import com.alibaba.otter.canal.parse.driver.mysql.packets.MysqlGTIDSet; import com.alibaba.otter.canal.parse.exception.CanalParseException; import com.alibaba.otter.canal.parse.inbound.AbstractEventParser; import com.alibaba.otter.canal.parse.inbound.BinlogParser; +import com.alibaba.otter.canal.parse.inbound.MultiStageCoprocessor; import com.alibaba.otter.canal.parse.inbound.mysql.dbsync.LogEventConvert; import com.alibaba.otter.canal.parse.inbound.mysql.tsdb.TableMetaTSDB; import com.alibaba.otter.canal.parse.inbound.mysql.tsdb.TableMetaTSDBBuilder; @@ -90,8 +92,16 @@ public abstract class AbstractMysqlEventParser extends AbstractEventParser { public void start() throws CanalParseException { if (enableTsdb) { if (tableMetaTSDB == null) { - // 初始化 - tableMetaTSDB = TableMetaTSDBBuilder.build(destination, tsdbSpringXml); + synchronized (CanalEventParser.class) { + try { + // 设置当前正在加载的通道,加载spring查找文件时会用到该变量 + System.setProperty("canal.instance.destination", destination); + // 初始化 + tableMetaTSDB = TableMetaTSDBBuilder.build(destination, tsdbSpringXml); + } finally { + System.setProperty("canal.instance.destination", ""); + } + } } } @@ -117,6 +127,14 @@ public abstract class AbstractMysqlEventParser extends AbstractEventParser { } } + protected MultiStageCoprocessor buildMultiStageCoprocessor() { + return new MysqlMultiStageCoprocessor(parallelBufferSize, + parallelThreadSize, + (LogEventConvert) binlogParser, + transactionBuffer, + destination); + } + // ============================ setter / getter ========================= public void setConnectionCharsetNumber(byte connectionCharsetNumber) { diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/LocalBinLogConnection.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/LocalBinLogConnection.java index 68086633..6c59465b 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/LocalBinLogConnection.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/LocalBinLogConnection.java @@ -4,16 +4,18 @@ import java.io.File; import java.io.IOException; import java.util.List; -import com.alibaba.otter.canal.parse.driver.mysql.packets.GTIDSet; import org.apache.commons.lang.NotImplementedException; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.alibaba.otter.canal.parse.driver.mysql.packets.GTIDSet; import com.alibaba.otter.canal.parse.inbound.ErosaConnection; +import com.alibaba.otter.canal.parse.inbound.MultiStageCoprocessor; import com.alibaba.otter.canal.parse.inbound.SinkFunction; import com.alibaba.otter.canal.parse.inbound.mysql.local.BinLogFileQueue; import com.taobao.tddl.dbsync.binlog.FileLogFetcher; +import com.taobao.tddl.dbsync.binlog.LogBuffer; import com.taobao.tddl.dbsync.binlog.LogContext; import com.taobao.tddl.dbsync.binlog.LogDecoder; import com.taobao.tddl.dbsync.binlog.LogEvent; @@ -207,6 +209,132 @@ public class LocalBinLogConnection implements ErosaConnection { throw new NotImplementedException(); } + @Override + public void dump(String binlogfilename, Long binlogPosition, MultiStageCoprocessor coprocessor) throws IOException { + File current = new File(directory, binlogfilename); + + FileLogFetcher fetcher = new FileLogFetcher(bufferSize); + try { + fetcher.open(current, binlogPosition); + while (running) { + boolean needContinue = true; + while (fetcher.fetch()) { + LogBuffer buffer = fetcher.duplicate(); + fetcher.consume(fetcher.limit()); + // set filename + if (!coprocessor.publish(buffer, binlogfilename)) { + needContinue = false; + break; + } + } + + if (needContinue) {// 读取下一个 + fetcher.close(); // 关闭上一个文件 + + File nextFile; + if (needWait) { + nextFile = binlogs.waitForNextFile(current); + } else { + nextFile = binlogs.getNextFile(current); + } + + if (nextFile == null) { + break; + } + + current = nextFile; + fetcher.open(current); + binlogfilename = nextFile.getName(); + } else { + break;// 跳出 + } + } + } catch (InterruptedException e) { + logger.warn("LocalBinLogConnection dump interrupted"); + } finally { + if (fetcher != null) { + fetcher.close(); + } + } + } + + @Override + public void dump(long timestampMills, MultiStageCoprocessor coprocessor) throws IOException { + List currentBinlogs = binlogs.currentBinlogs(); + File current = currentBinlogs.get(currentBinlogs.size() - 1); + long timestampSeconds = timestampMills / 1000; + + String binlogFilename = null; + long binlogFileOffset = 0; + + FileLogFetcher fetcher = new FileLogFetcher(bufferSize); + LogDecoder decoder = new LogDecoder(); + decoder.handle(LogEvent.FORMAT_DESCRIPTION_EVENT); + decoder.handle(LogEvent.QUERY_EVENT); + decoder.handle(LogEvent.XID_EVENT); + LogContext context = new LogContext(); + try { + fetcher.open(current); + context.setLogPosition(new LogPosition(current.getName())); + while (running) { + boolean needContinue = true; + String lastXidLogFilename = current.getName(); + long lastXidLogFileOffset = 0; + + binlogFilename = lastXidLogFilename; + binlogFileOffset = lastXidLogFileOffset; + while (fetcher.fetch()) { + LogEvent event = decoder.decode(fetcher, context); + if (event != null) { + if (event.getWhen() > timestampSeconds) { + break; + } + + needContinue = false; + if (LogEvent.QUERY_EVENT == event.getHeader().getType()) { + if (StringUtils.endsWithIgnoreCase(((QueryLogEvent) event).getQuery(), "BEGIN")) { + binlogFilename = lastXidLogFilename; + binlogFileOffset = lastXidLogFileOffset; + } else if (StringUtils.endsWithIgnoreCase(((QueryLogEvent) event).getQuery(), "COMMIT")) { + lastXidLogFilename = current.getName(); + lastXidLogFileOffset = event.getLogPos(); + } + } else if (LogEvent.XID_EVENT == event.getHeader().getType()) { + lastXidLogFilename = current.getName(); + lastXidLogFileOffset = event.getLogPos(); + } + } + } + + if (needContinue) {// 读取下一个 + fetcher.close(); // 关闭上一个文件 + + File nextFile = binlogs.getBefore(current); + if (nextFile == null) { + break; + } + + current = nextFile; + fetcher.open(current); + context.setLogPosition(new LogPosition(current.getName())); + } else { + break;// 跳出 + } + } + } finally { + if (fetcher != null) { + fetcher.close(); + } + } + + dump(binlogFilename, binlogFileOffset, coprocessor); + } + + @Override + public void dump(GTIDSet gtidSet, MultiStageCoprocessor coprocessor) throws IOException { + throw new NotImplementedException(); + } + public ErosaConnection fork() { LocalBinLogConnection connection = new LocalBinLogConnection(); diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlConnection.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlConnection.java index 4a3b7fb9..d01a210e 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlConnection.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlConnection.java @@ -8,8 +8,6 @@ import java.nio.charset.Charset; import java.util.List; import java.util.concurrent.TimeUnit; -import com.alibaba.otter.canal.parse.driver.mysql.packets.GTIDSet; -import com.alibaba.otter.canal.parse.driver.mysql.packets.client.BinlogDumpGTIDCommandPacket; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -17,8 +15,10 @@ import org.slf4j.LoggerFactory; import com.alibaba.otter.canal.parse.driver.mysql.MysqlConnector; import com.alibaba.otter.canal.parse.driver.mysql.MysqlQueryExecutor; import com.alibaba.otter.canal.parse.driver.mysql.MysqlUpdateExecutor; +import com.alibaba.otter.canal.parse.driver.mysql.packets.GTIDSet; import com.alibaba.otter.canal.parse.driver.mysql.packets.HeaderPacket; import com.alibaba.otter.canal.parse.driver.mysql.packets.client.BinlogDumpCommandPacket; +import com.alibaba.otter.canal.parse.driver.mysql.packets.client.BinlogDumpGTIDCommandPacket; import com.alibaba.otter.canal.parse.driver.mysql.packets.client.RegisterSlaveCommandPacket; import com.alibaba.otter.canal.parse.driver.mysql.packets.client.SemiAckCommandPacket; import com.alibaba.otter.canal.parse.driver.mysql.packets.server.ErrorPacket; @@ -26,9 +26,11 @@ import com.alibaba.otter.canal.parse.driver.mysql.packets.server.ResultSetPacket import com.alibaba.otter.canal.parse.driver.mysql.utils.PacketManager; import com.alibaba.otter.canal.parse.exception.CanalParseException; import com.alibaba.otter.canal.parse.inbound.ErosaConnection; +import com.alibaba.otter.canal.parse.inbound.MultiStageCoprocessor; import com.alibaba.otter.canal.parse.inbound.SinkFunction; import com.alibaba.otter.canal.parse.inbound.mysql.dbsync.DirectLogFetcher; import com.alibaba.otter.canal.parse.support.AuthenticationInfo; +import com.taobao.tddl.dbsync.binlog.LogBuffer; import com.taobao.tddl.dbsync.binlog.LogContext; import com.taobao.tddl.dbsync.binlog.LogDecoder; import com.taobao.tddl.dbsync.binlog.LogEvent; @@ -156,7 +158,7 @@ public class MysqlConnection implements ErosaConnection { } if (event.getSemival() == 1) { - sendSemiAck(context.getLogPosition().getFileName(), binlogPosition); + sendSemiAck(context.getLogPosition().getFileName(), context.getLogPosition().getPosition()); } } } @@ -167,20 +169,24 @@ public class MysqlConnection implements ErosaConnection { sendBinlogDumpGTID(gtidSet); DirectLogFetcher fetcher = new DirectLogFetcher(connector.getReceiveBufferSize()); - fetcher.start(connector.getChannel()); - LogDecoder decoder = new LogDecoder(LogEvent.UNKNOWN_EVENT, LogEvent.ENUM_END_EVENT); - LogContext context = new LogContext(); - while (fetcher.fetch()) { - LogEvent event = null; - event = decoder.decode(fetcher, context); + try { + fetcher.start(connector.getChannel()); + LogDecoder decoder = new LogDecoder(LogEvent.UNKNOWN_EVENT, LogEvent.ENUM_END_EVENT); + LogContext context = new LogContext(); + while (fetcher.fetch()) { + LogEvent event = null; + event = decoder.decode(fetcher, context); - if (event == null) { - throw new CanalParseException("parse failed"); - } + if (event == null) { + throw new CanalParseException("parse failed"); + } - if (!func.sink(event)) { - break; + if (!func.sink(event)) { + break; + } } + } finally { + fetcher.close(); } } @@ -188,6 +194,53 @@ public class MysqlConnection implements ErosaConnection { throw new NullPointerException("Not implement yet"); } + @Override + public void dump(String binlogfilename, Long binlogPosition, MultiStageCoprocessor coprocessor) throws IOException { + updateSettings(); + sendRegisterSlave(); + sendBinlogDump(binlogfilename, binlogPosition); + ((MysqlMultiStageCoprocessor) coprocessor).setConnection(this); + DirectLogFetcher fetcher = new DirectLogFetcher(connector.getReceiveBufferSize()); + try { + fetcher.start(connector.getChannel()); + while (fetcher.fetch()) { + LogBuffer buffer = fetcher.duplicate(); + fetcher.consume(fetcher.limit()); + if (!coprocessor.publish(buffer)) { + break; + } + } + } finally { + fetcher.close(); + } + } + + @Override + public void dump(long timestamp, MultiStageCoprocessor coprocessor) throws IOException { + throw new NullPointerException("Not implement yet"); + } + + @Override + public void dump(GTIDSet gtidSet, MultiStageCoprocessor coprocessor) throws IOException { + updateSettings(); + sendBinlogDumpGTID(gtidSet); + + ((MysqlMultiStageCoprocessor) coprocessor).setConnection(this); + DirectLogFetcher fetcher = new DirectLogFetcher(connector.getReceiveBufferSize()); + try { + fetcher.start(connector.getChannel()); + while (fetcher.fetch()) { + LogBuffer buffer = fetcher.duplicate(); + fetcher.consume(fetcher.limit()); + if (!coprocessor.publish(buffer)) { + break; + } + } + } finally { + fetcher.close(); + } + } + private void sendRegisterSlave() throws IOException { RegisterSlaveCommandPacket cmd = new RegisterSlaveCommandPacket(); cmd.reportHost = authInfo.getAddress().getAddress().getHostAddress(); @@ -233,7 +286,7 @@ public class MysqlConnection implements ErosaConnection { connector.setDumping(true); } - private void sendSemiAck(String binlogfilename, Long binlogPosition) throws IOException { + public void sendSemiAck(String binlogfilename, Long binlogPosition) throws IOException { SemiAckCommandPacket semiAckCmd = new SemiAckCommandPacket(); semiAckCmd.binlogFileName = binlogfilename; semiAckCmd.binlogPosition = binlogPosition; @@ -538,4 +591,5 @@ public class MysqlConnection implements ErosaConnection { public void setAuthInfo(AuthenticationInfo authInfo) { this.authInfo = authInfo; } + } diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlEventParser.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlEventParser.java index a30af259..aeb3b2ea 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlEventParser.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlEventParser.java @@ -653,6 +653,9 @@ public class MysqlEventParser extends AbstractMysqlEventParser implements CanalE throw new CanalParseException("command : 'show master status' has an error! pls check. you need (at least one of) the SUPER,REPLICATION CLIENT privilege(s) for this operation"); } EntryPosition endPosition = new EntryPosition(fields.get(0), Long.valueOf(fields.get(1))); + if (isGTIDMode && fields.size() > 4) { + endPosition.setGtid(fields.get(4)); + } return endPosition; } catch (IOException e) { throw new CanalParseException("command : 'show master status' has an error!", e); @@ -773,7 +776,7 @@ public class MysqlEventParser extends AbstractMysqlEventParser implements CanalE } if (StringUtils.equals(endPosition.getJournalName(), logfilename) - && endPosition.getPosition() < logfileoffset) { + && endPosition.getPosition() <= logfileoffset) { return false; } diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlMultiStageCoprocessor.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlMultiStageCoprocessor.java new file mode 100644 index 00000000..281a05f2 --- /dev/null +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlMultiStageCoprocessor.java @@ -0,0 +1,430 @@ +package com.alibaba.otter.canal.parse.inbound.mysql; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.locks.LockSupport; + +import org.apache.commons.lang.StringUtils; + +import com.alibaba.otter.canal.common.AbstractCanalLifeCycle; +import com.alibaba.otter.canal.common.utils.NamedThreadFactory; +import com.alibaba.otter.canal.parse.exception.CanalParseException; +import com.alibaba.otter.canal.parse.inbound.ErosaConnection; +import com.alibaba.otter.canal.parse.inbound.EventTransactionBuffer; +import com.alibaba.otter.canal.parse.inbound.MultiStageCoprocessor; +import com.alibaba.otter.canal.parse.inbound.TableMeta; +import com.alibaba.otter.canal.parse.inbound.mysql.dbsync.LogEventConvert; +import com.alibaba.otter.canal.protocol.CanalEntry; +import com.lmax.disruptor.BatchEventProcessor; +import com.lmax.disruptor.BlockingWaitStrategy; +import com.lmax.disruptor.EventFactory; +import com.lmax.disruptor.EventHandler; +import com.lmax.disruptor.ExceptionHandler; +import com.lmax.disruptor.InsufficientCapacityException; +import com.lmax.disruptor.LifecycleAware; +import com.lmax.disruptor.RingBuffer; +import com.lmax.disruptor.Sequence; +import com.lmax.disruptor.SequenceBarrier; +import com.lmax.disruptor.WorkHandler; +import com.lmax.disruptor.WorkerPool; +import com.taobao.tddl.dbsync.binlog.LogBuffer; +import com.taobao.tddl.dbsync.binlog.LogContext; +import com.taobao.tddl.dbsync.binlog.LogDecoder; +import com.taobao.tddl.dbsync.binlog.LogEvent; +import com.taobao.tddl.dbsync.binlog.LogPosition; +import com.taobao.tddl.dbsync.binlog.event.DeleteRowsLogEvent; +import com.taobao.tddl.dbsync.binlog.event.RowsLogEvent; +import com.taobao.tddl.dbsync.binlog.event.UpdateRowsLogEvent; +import com.taobao.tddl.dbsync.binlog.event.WriteRowsLogEvent; + +/** + * 针对解析器提供一个多阶段协同的处理 + * + *
      + * 1. 网络接收 (单线程)
      + * 2. 事件基本解析 (单线程,事件类型、DDL解析构造TableMeta、维护位点信息)
      + * 3. 事件深度解析 (多线程, DML事件数据的完整解析)
      + * 4. 投递到store (单线程)
      + * 
      + * + * @author agapple 2018年7月3日 下午4:54:17 + * @since 1.0.26 + */ +public class MysqlMultiStageCoprocessor extends AbstractCanalLifeCycle implements MultiStageCoprocessor { + + private LogEventConvert logEventConvert; + private EventTransactionBuffer transactionBuffer; + private ErosaConnection connection; + + private int parserThreadCount; + private int ringBufferSize; + private RingBuffer disruptorMsgBuffer; + private ExecutorService parserExecutor; + private ExecutorService stageExecutor; + private String destination; + private volatile CanalParseException exception; + + public MysqlMultiStageCoprocessor(int ringBufferSize, int parserThreadCount, LogEventConvert logEventConvert, + EventTransactionBuffer transactionBuffer, String destination){ + this.ringBufferSize = ringBufferSize; + this.parserThreadCount = parserThreadCount; + this.logEventConvert = logEventConvert; + this.transactionBuffer = transactionBuffer; + this.destination = destination; + } + + @Override + public void start() { + super.start(); + this.exception = null; + this.disruptorMsgBuffer = RingBuffer.createSingleProducer(new MessageEventFactory(), + ringBufferSize, + new BlockingWaitStrategy()); + + this.parserExecutor = Executors.newFixedThreadPool(parserThreadCount, + new NamedThreadFactory("MultiStageCoprocessor-Parser-" + destination)); + + this.stageExecutor = Executors.newFixedThreadPool(2, new NamedThreadFactory("MultiStageCoprocessor-other-" + + destination)); + SequenceBarrier sequenceBarrier = disruptorMsgBuffer.newBarrier(); + ExceptionHandler exceptionHandler = new SimpleFatalExceptionHandler(); + // stage 2 + BatchEventProcessor simpleParserStage = new BatchEventProcessor(disruptorMsgBuffer, + sequenceBarrier, + new SimpleParserStage()); + simpleParserStage.setExceptionHandler(exceptionHandler); + disruptorMsgBuffer.addGatingSequences(simpleParserStage.getSequence()); + + // stage 3 + SequenceBarrier dmlParserSequenceBarrier = disruptorMsgBuffer.newBarrier(simpleParserStage.getSequence()); + WorkHandler[] workHandlers = new DmlParserStage[parserThreadCount]; + for (int i = 0; i < parserThreadCount; i++) { + workHandlers[i] = new DmlParserStage(); + } + WorkerPool workerPool = new WorkerPool(disruptorMsgBuffer, + dmlParserSequenceBarrier, + exceptionHandler, + workHandlers); + Sequence[] sequence = workerPool.getWorkerSequences(); + disruptorMsgBuffer.addGatingSequences(sequence); + + // stage 4 + SequenceBarrier sinkSequenceBarrier = disruptorMsgBuffer.newBarrier(sequence); + BatchEventProcessor sinkStoreStage = new BatchEventProcessor(disruptorMsgBuffer, + sinkSequenceBarrier, + new SinkStoreStage()); + sinkStoreStage.setExceptionHandler(exceptionHandler); + disruptorMsgBuffer.addGatingSequences(sinkStoreStage.getSequence()); + + // start work + stageExecutor.submit(simpleParserStage); + stageExecutor.submit(sinkStoreStage); + workerPool.start(parserExecutor); + } + + @Override + public void stop() { + try { + parserExecutor.shutdownNow(); + } catch (Throwable e) { + // ignore + } + + try { + stageExecutor.shutdownNow(); + } catch (Throwable e) { + // ignore + } + super.stop(); + } + + /** + * 网络数据投递 + */ + public boolean publish(LogBuffer buffer) { + return publish(buffer, null); + } + + public boolean publish(LogBuffer buffer, String binlogFileName) { + if (!isStart()) { + if (exception != null) { + throw exception; + } + return false; + } + + /** + * 由于改为processor仅终止自身stage而不是stop,那么需要由incident标识coprocessor是否正常工作。 + * 让dump线程能够及时感知 + */ + if (exception != null) { + throw exception; + } + boolean interupted = false; + do { + try { + long next = disruptorMsgBuffer.tryNext(); + MessageEvent event = disruptorMsgBuffer.get(next); + event.setBuffer(buffer); + if (binlogFileName != null) { + event.setBinlogFileName(binlogFileName); + } + disruptorMsgBuffer.publish(next); + break; + } catch (InsufficientCapacityException e) { + // park + LockSupport.parkNanos(1L); + interupted = Thread.interrupted(); + } + } while (!interupted && isStart()); + return isStart(); + } + + @Override + public void reset() { + if (isStart()) { + stop(); + } + + start(); + } + + private class SimpleParserStage implements EventHandler, LifecycleAware { + + private LogDecoder decoder; + private LogContext context; + + public SimpleParserStage(){ + decoder = new LogDecoder(LogEvent.UNKNOWN_EVENT, LogEvent.ENUM_END_EVENT); + context = new LogContext(); + } + + public void onEvent(MessageEvent event, long sequence, boolean endOfBatch) throws Exception { + try { + LogBuffer buffer = event.getBuffer(); + if (StringUtils.isNotEmpty(event.getBinlogFileName()) + && !context.getLogPosition().getFileName().equals(event.getBinlogFileName())) { + // set roate binlog file name + context.setLogPosition(new LogPosition(event.getBinlogFileName(), context.getLogPosition() + .getPosition())); + } + + LogEvent logEvent = decoder.decode(buffer, context); + event.setEvent(logEvent); + + int eventType = logEvent.getHeader().getType(); + TableMeta tableMeta = null; + boolean needDmlParse = false; + switch (eventType) { + case LogEvent.WRITE_ROWS_EVENT_V1: + case LogEvent.WRITE_ROWS_EVENT: + tableMeta = logEventConvert.parseRowsEventForTableMeta((WriteRowsLogEvent) logEvent); + needDmlParse = true; + break; + case LogEvent.UPDATE_ROWS_EVENT_V1: + case LogEvent.UPDATE_ROWS_EVENT: + tableMeta = logEventConvert.parseRowsEventForTableMeta((UpdateRowsLogEvent) logEvent); + needDmlParse = true; + break; + case LogEvent.DELETE_ROWS_EVENT_V1: + case LogEvent.DELETE_ROWS_EVENT: + tableMeta = logEventConvert.parseRowsEventForTableMeta((DeleteRowsLogEvent) logEvent); + needDmlParse = true; + break; + case LogEvent.ROWS_QUERY_LOG_EVENT: + needDmlParse = true; + break; + default: + CanalEntry.Entry entry = logEventConvert.parse(event.getEvent(), false); + event.setEntry(entry); + } + + // 记录一下DML的表结构 + event.setNeedDmlParse(needDmlParse); + event.setTable(tableMeta); + } catch (Throwable e) { + exception = new CanalParseException(e); + throw exception; + } + } + + @Override + public void onStart() { + + } + + @Override + public void onShutdown() { + + } + } + + private class DmlParserStage implements WorkHandler, LifecycleAware { + + @Override + public void onEvent(MessageEvent event) throws Exception { + try { + if (event.isNeedDmlParse()) { + int eventType = event.getEvent().getHeader().getType(); + CanalEntry.Entry entry = null; + switch (eventType) { + case LogEvent.ROWS_QUERY_LOG_EVENT: + entry = logEventConvert.parse(event.getEvent(), false); + break; + default: + // 单独解析dml事件 + entry = logEventConvert.parseRowsEvent((RowsLogEvent) event.getEvent(), event.getTable()); + } + + event.setEntry(entry); + } + } catch (Throwable e) { + exception = new CanalParseException(e); + throw exception; + } + } + + @Override + public void onStart() { + + } + + @Override + public void onShutdown() { + + } + } + + private class SinkStoreStage implements EventHandler, LifecycleAware { + + public void onEvent(MessageEvent event, long sequence, boolean endOfBatch) throws Exception { + try { + if (event.getEntry() != null) { + transactionBuffer.add(event.getEntry()); + } + + LogEvent logEvent = event.getEvent(); + if (connection instanceof MysqlConnection && logEvent.getSemival() == 1) { + // semi ack回报 + ((MysqlConnection) connection).sendSemiAck(logEvent.getHeader().getLogFileName(), + logEvent.getHeader().getLogPos()); + } + + // clear for gc + event.setBuffer(null); + event.setBinlogFileName(null); + event.setEvent(null); + event.setTable(null); + event.setEntry(null); + event.setNeedDmlParse(false); + } catch (Throwable e) { + exception = new CanalParseException(e); + throw exception; + } + } + + @Override + public void onStart() { + + } + + @Override + public void onShutdown() { + + } + } + + class MessageEvent { + + private String binlogFileName; // for local binlog parse + private LogBuffer buffer; + private CanalEntry.Entry entry; + private boolean needDmlParse = false; + private TableMeta table; + private LogEvent event; + + public String getBinlogFileName() { + return binlogFileName; + } + + public void setBinlogFileName(String binlogFileName) { + this.binlogFileName = binlogFileName; + } + + public LogBuffer getBuffer() { + return buffer; + } + + public void setBuffer(LogBuffer buffer) { + this.buffer = buffer; + } + + public LogEvent getEvent() { + return event; + } + + public void setEvent(LogEvent event) { + this.event = event; + } + + public CanalEntry.Entry getEntry() { + return entry; + } + + public void setEntry(CanalEntry.Entry entry) { + this.entry = entry; + } + + public boolean isNeedDmlParse() { + return needDmlParse; + } + + public void setNeedDmlParse(boolean needDmlParse) { + this.needDmlParse = needDmlParse; + } + + public TableMeta getTable() { + return table; + } + + public void setTable(TableMeta table) { + this.table = table; + } + + } + + class SimpleFatalExceptionHandler implements ExceptionHandler { + + @Override + public void handleEventException(final Throwable ex, final long sequence, final Object event) { + } + + @Override + public void handleOnStartException(final Throwable ex) { + } + + @Override + public void handleOnShutdownException(final Throwable ex) { + } + } + + class MessageEventFactory implements EventFactory { + + public MessageEvent newInstance() { + return new MessageEvent(); + } + } + + public void setLogEventConvert(LogEventConvert logEventConvert) { + this.logEventConvert = logEventConvert; + } + + public void setTransactionBuffer(EventTransactionBuffer transactionBuffer) { + this.transactionBuffer = transactionBuffer; + } + + public void setConnection(ErosaConnection connection) { + this.connection = connection; + } + +} diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/dbsync/DirectLogFetcher.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/dbsync/DirectLogFetcher.java index 18803657..222d762a 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/dbsync/DirectLogFetcher.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/dbsync/DirectLogFetcher.java @@ -19,30 +19,30 @@ import com.taobao.tddl.dbsync.binlog.LogFetcher; */ public class DirectLogFetcher extends LogFetcher { - protected static final Logger logger = LoggerFactory.getLogger(DirectLogFetcher.class); + protected static final Logger logger = LoggerFactory.getLogger(DirectLogFetcher.class); // Master heartbeat interval - public static final int MASTER_HEARTBEAT_PERIOD_SECONDS = 15; + public static final int MASTER_HEARTBEAT_PERIOD_SECONDS = 15; // +10s 确保 timeout > heartbeat interval - private static final int READ_TIMEOUT_MILLISECONDS = (MASTER_HEARTBEAT_PERIOD_SECONDS + 10) * 1000; + private static final int READ_TIMEOUT_MILLISECONDS = (MASTER_HEARTBEAT_PERIOD_SECONDS + 10) * 1000; /** Command to dump binlog */ - public static final byte COM_BINLOG_DUMP = 18; + public static final byte COM_BINLOG_DUMP = 18; /** Packet header sizes */ - public static final int NET_HEADER_SIZE = 4; - public static final int SQLSTATE_LENGTH = 5; + public static final int NET_HEADER_SIZE = 4; + public static final int SQLSTATE_LENGTH = 5; /** Packet offsets */ - public static final int PACKET_LEN_OFFSET = 0; - public static final int PACKET_SEQ_OFFSET = 3; + public static final int PACKET_LEN_OFFSET = 0; + public static final int PACKET_SEQ_OFFSET = 3; /** Maximum packet length */ - public static final int MAX_PACKET_LENGTH = (256 * 256 * 256 - 1); + public static final int MAX_PACKET_LENGTH = (256 * 256 * 256 - 1); private SocketChannel channel; - private boolean issemi = false; + private boolean issemi = false; // private BufferedInputStream input; @@ -64,9 +64,6 @@ public class DirectLogFetcher extends LogFetcher { if ("1".equals(dbsemi)) { issemi = true; } - // 和mysql driver一样,提供buffer机制,提升读取binlog速度 - // this.input = new - // BufferedInputStream(channel.socket().getInputStream(), 16384); } /** @@ -171,10 +168,13 @@ public class DirectLogFetcher extends LogFetcher { private final boolean fetch0(final int off, final int len) throws IOException { ensureCapacity(off + len); - byte[] read = channel.read(len, READ_TIMEOUT_MILLISECONDS); - System.arraycopy(read, 0, this.buffer, off, len); + // byte[] read = channel.read(len, READ_TIMEOUT_MILLISECONDS); + // System.arraycopy(read, 0, this.buffer, off, len); - if (limit < off + len) limit = off + len; + channel.read(buffer, off, len, READ_TIMEOUT_MILLISECONDS); + if (limit < off + len) { + limit = off + len; + } return true; } diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/dbsync/LogEventConvert.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/dbsync/LogEventConvert.java index 67bb07b7..72369f07 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/dbsync/LogEventConvert.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/dbsync/LogEventConvert.java @@ -49,7 +49,6 @@ import com.taobao.tddl.dbsync.binlog.event.IntvarLogEvent; import com.taobao.tddl.dbsync.binlog.event.LogHeader; import com.taobao.tddl.dbsync.binlog.event.QueryLogEvent; import com.taobao.tddl.dbsync.binlog.event.RandLogEvent; -import com.taobao.tddl.dbsync.binlog.event.RotateLogEvent; import com.taobao.tddl.dbsync.binlog.event.RowsLogBuffer; import com.taobao.tddl.dbsync.binlog.event.RowsLogEvent; import com.taobao.tddl.dbsync.binlog.event.RowsQueryLogEvent; @@ -91,8 +90,10 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar private volatile AviaterRegexFilter nameFilter; // 运行时引用可能会有变化,比如规则发生变化时 private volatile AviaterRegexFilter nameBlackFilter; + private TableMetaCacheInterface tableMetaCache; private String binlogFileName = "mysql-bin.000001"; + private Charset charset = Charset.defaultCharset(); private boolean filterQueryDcl = false; private boolean filterQueryDml = false; @@ -122,9 +123,6 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar int eventType = logEvent.getHeader().getType(); switch (eventType) { - case LogEvent.ROTATE_EVENT: - binlogFileName = ((RotateLogEvent) logEvent).getFilename(); - break; case LogEvent.QUERY_EVENT: return parseQueryEvent((QueryLogEvent) logEvent, isSeek); case LogEvent.XID_EVENT: @@ -161,7 +159,6 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar public void reset() { // do nothing - binlogFileName = "mysql-bin.000001"; if (tableMetaCache != null) { tableMetaCache.clearTableMeta(); } @@ -176,8 +173,14 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar if (gtidSet != null) { gtidSet.update(value); } + if (logEvent.getLastCommitted() != null) { + builder.setKey("lastCommitted"); + builder.setValue(String.valueOf(logEvent.getLastCommitted())); + builder.setKey("sequenceNumber"); + builder.setValue(String.valueOf(logEvent.getSequenceNumber())); + } - Header header = createHeader("", logHeader, "", "", EventType.GTID); + Header header = createHeader(logHeader, "", "", EventType.GTID); return createEntry(header, EntryType.GTIDLOG, builder.build().toByteString()); } @@ -190,7 +193,7 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar beginBuilder.addProps(createSpecialPair(XA_TYPE, XA_START)); beginBuilder.addProps(createSpecialPair(XA_XID, getXaXid(queryString, XA_START))); TransactionBegin transactionBegin = beginBuilder.build(); - Header header = createHeader(binlogFileName, event.getHeader(), "", "", null); + Header header = createHeader(event.getHeader(), "", "", null); return createEntry(header, EntryType.TRANSACTIONBEGIN, transactionBegin.toByteString()); } else if (StringUtils.startsWithIgnoreCase(queryString, XA_END)) { // xa start use TransactionEnd @@ -199,11 +202,11 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar endBuilder.addProps(createSpecialPair(XA_TYPE, XA_END)); endBuilder.addProps(createSpecialPair(XA_XID, getXaXid(queryString, XA_END))); TransactionEnd transactionEnd = endBuilder.build(); - Header header = createHeader(binlogFileName, event.getHeader(), "", "", null); + Header header = createHeader(event.getHeader(), "", "", null); return createEntry(header, EntryType.TRANSACTIONEND, transactionEnd.toByteString()); } else if (StringUtils.startsWithIgnoreCase(queryString, XA_COMMIT)) { // xa commit - Header header = createHeader(binlogFileName, event.getHeader(), "", "", EventType.XACOMMIT); + Header header = createHeader(event.getHeader(), "", "", EventType.XACOMMIT); RowChange.Builder rowChangeBuider = RowChange.newBuilder(); rowChangeBuider.setSql(queryString); rowChangeBuider.addProps(createSpecialPair(XA_TYPE, XA_COMMIT)); @@ -212,7 +215,7 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar return createEntry(header, EntryType.ROWDATA, rowChangeBuider.build().toByteString()); } else if (StringUtils.startsWithIgnoreCase(queryString, XA_ROLLBACK)) { // xa rollback - Header header = createHeader(binlogFileName, event.getHeader(), "", "", EventType.XAROLLBACK); + Header header = createHeader(event.getHeader(), "", "", EventType.XAROLLBACK); RowChange.Builder rowChangeBuider = RowChange.newBuilder(); rowChangeBuider.setSql(queryString); rowChangeBuider.addProps(createSpecialPair(XA_TYPE, XA_ROLLBACK)); @@ -221,11 +224,11 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar return createEntry(header, EntryType.ROWDATA, rowChangeBuider.build().toByteString()); } else if (StringUtils.endsWithIgnoreCase(queryString, BEGIN)) { TransactionBegin transactionBegin = createTransactionBegin(event.getSessionId()); - Header header = createHeader(binlogFileName, event.getHeader(), "", "", null); + Header header = createHeader(event.getHeader(), "", "", null); return createEntry(header, EntryType.TRANSACTIONBEGIN, transactionBegin.toByteString()); } else if (StringUtils.endsWithIgnoreCase(queryString, COMMIT)) { TransactionEnd transactionEnd = createTransactionEnd(0L); // MyISAM可能不会有xid事件 - Header header = createHeader(binlogFileName, event.getHeader(), "", "", null); + Header header = createHeader(event.getHeader(), "", "", null); return createEntry(header, EntryType.TRANSACTIONEND, transactionEnd.toByteString()); } else { boolean notFilter = false; @@ -269,9 +272,10 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar tableMetaCache.apply(position, fulltbName, queryString, null); } - Header header = createHeader(binlogFileName, event.getHeader(), schemaName, tableName, type); + Header header = createHeader(event.getHeader(), schemaName, tableName, type); RowChange.Builder rowChangeBuider = RowChange.newBuilder(); - if (type != EventType.QUERY) { + if (type != EventType.QUERY && type != EventType.INSERT && type != EventType.UPDATE + && type != EventType.DELETE) { rowChangeBuider.setIsDdl(true); } rowChangeBuider.setSql(queryString); @@ -428,52 +432,78 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar private Entry parseXidEvent(XidLogEvent event) { TransactionEnd transactionEnd = createTransactionEnd(event.getXid()); - Header header = createHeader(binlogFileName, event.getHeader(), "", "", null); + Header header = createHeader(event.getHeader(), "", "", null); return createEntry(header, EntryType.TRANSACTIONEND, transactionEnd.toByteString()); } - private Entry parseRowsEvent(RowsLogEvent event) { + public TableMeta parseRowsEventForTableMeta(RowsLogEvent event) { + TableMapLogEvent table = event.getTable(); + if (table == null) { + // tableId对应的记录不存在 + throw new TableIdNotFoundException("not found tableId:" + event.getTableId()); + } + + boolean isHeartBeat = isAliSQLHeartBeat(table.getDbName(), table.getTableName()); + boolean isRDSHeartBeat = tableMetaCache.isOnRDS() && isRDSHeartBeat(table.getDbName(), table.getTableName()); + + String fullname = table.getDbName() + "." + table.getTableName(); + // check name filter + if (nameFilter != null && !nameFilter.filter(fullname)) { + return null; + } + if (nameBlackFilter != null && nameBlackFilter.filter(fullname)) { + return null; + } + + // if (isHeartBeat || isRDSHeartBeat) { + // // 忽略rds模式的mysql.ha_health_check心跳数据 + // return null; + // } + TableMeta tableMeta = null; + if (isRDSHeartBeat) { + // 处理rds模式的mysql.ha_health_check心跳数据 + // 主要RDS的心跳表基本无权限,需要mock一个tableMeta + FieldMeta idMeta = new FieldMeta("id", "bigint(20)", true, false, "0"); + FieldMeta typeMeta = new FieldMeta("type", "char(1)", false, true, "0"); + tableMeta = new TableMeta(table.getDbName(), table.getTableName(), Arrays.asList(idMeta, typeMeta)); + } else if (isHeartBeat) { + // 处理alisql模式的test.heartbeat心跳数据 + // 心跳表基本无权限,需要mock一个tableMeta + FieldMeta idMeta = new FieldMeta("id", "smallint(6)", false, true, null); + FieldMeta typeMeta = new FieldMeta("ts", "int(11)", true, false, null); + tableMeta = new TableMeta(table.getDbName(), table.getTableName(), Arrays.asList(idMeta, typeMeta)); + } + + EntryPosition position = createPosition(event.getHeader()); + if (tableMetaCache != null && tableMeta == null) {// 入错存在table meta + tableMeta = getTableMeta(table.getDbName(), table.getTableName(), true, position); + if (tableMeta == null) { + if (!filterTableError) { + throw new CanalParseException("not found [" + fullname + "] in db , pls check!"); + } + } + } + + return tableMeta; + } + + public Entry parseRowsEvent(RowsLogEvent event) { + return parseRowsEvent(event, null); + } + + public Entry parseRowsEvent(RowsLogEvent event, TableMeta tableMeta) { if (filterRows) { return null; } try { - TableMapLogEvent table = event.getTable(); - if (table == null) { - // tableId对应的记录不存在 - throw new TableIdNotFoundException("not found tableId:" + event.getTableId()); + if (tableMeta == null) { // 如果没有外部指定 + tableMeta = parseRowsEventForTableMeta(event); } - boolean isHeartBeat = isAliSQLHeartBeat(table.getDbName(), table.getTableName()); - boolean isRDSHeartBeat = tableMetaCache.isOnRDS() - && isRDSHeartBeat(table.getDbName(), table.getTableName()); - - String fullname = table.getDbName() + "." + table.getTableName(); - // check name filter - if (nameFilter != null && !nameFilter.filter(fullname)) { + if (tableMeta == null) { + // 拿不到表结构,执行忽略 return null; } - if (nameBlackFilter != null && nameBlackFilter.filter(fullname)) { - return null; - } - - // if (isHeartBeat || isRDSHeartBeat) { - // // 忽略rds模式的mysql.ha_health_check心跳数据 - // return null; - // } - TableMeta tableMeta = null; - if (isRDSHeartBeat) { - // 处理rds模式的mysql.ha_health_check心跳数据 - // 主要RDS的心跳表基本无权限,需要mock一个tableMeta - FieldMeta idMeta = new FieldMeta("id", "bigint(20)", true, false, "0"); - FieldMeta typeMeta = new FieldMeta("type", "char(1)", false, true, "0"); - tableMeta = new TableMeta(table.getDbName(), table.getTableName(), Arrays.asList(idMeta, typeMeta)); - } else if (isHeartBeat) { - // 处理alisql模式的test.heartbeat心跳数据 - // 心跳表基本无权限,需要mock一个tableMeta - FieldMeta idMeta = new FieldMeta("id", "smallint(6)", false, true, null); - FieldMeta typeMeta = new FieldMeta("type", "int(11)", true, false, null); - tableMeta = new TableMeta(table.getDbName(), table.getTableName(), Arrays.asList(idMeta, typeMeta)); - } EventType eventType = null; int type = event.getHeader().getType(); @@ -487,12 +517,6 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar throw new CanalParseException("unsupport event type :" + event.getHeader().getType()); } - Header header = createHeader(binlogFileName, - event.getHeader(), - table.getDbName(), - table.getTableName(), - eventType); - EntryPosition position = createPosition(event.getHeader()); RowChange.Builder rowChangeBuider = RowChange.newBuilder(); rowChangeBuider.setTableId(event.getTableId()); rowChangeBuider.setIsDdl(false); @@ -501,18 +525,9 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar RowsLogBuffer buffer = event.getRowsBuf(charset.name()); BitSet columns = event.getColumns(); BitSet changeColumns = event.getChangeColumns(); - boolean tableError = false; - if (tableMetaCache != null && tableMeta == null) {// 入错存在table meta - // cache - tableMeta = getTableMeta(table.getDbName(), table.getTableName(), true, position); - if (tableMeta == null) { - tableError = true; - if (!filterTableError) { - throw new CanalParseException("not found [" + fullname + "] in db , pls check!"); - } - } - } + boolean tableError = false; + int rowsCount = 0; while (buffer.nextOneRow(columns)) { // 处理row记录 RowData.Builder rowDataBuilder = RowData.newBuilder(); @@ -533,16 +548,20 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar tableError |= parseOneRow(rowDataBuilder, event, buffer, changeColumns, true, tableMeta); } + rowsCount ++; rowChangeBuider.addRowDatas(rowDataBuilder.build()); } + TableMapLogEvent table = event.getTable(); + Header header = createHeader(event.getHeader(), table.getDbName(), table.getTableName(), eventType, rowsCount); + RowChange rowChange = rowChangeBuider.build(); if (tableError) { Entry entry = createEntry(header, EntryType.ROWDATA, ByteString.EMPTY); logger.warn("table parser error : {}storeValue: {}", entry.toString(), rowChange.toString()); return null; } else { - Entry entry = createEntry(header, EntryType.ROWDATA, rowChangeBuider.build().toByteString()); + Entry entry = createEntry(header, EntryType.ROWDATA, rowChange.toByteString()); return entry; } } catch (Exception e) { @@ -551,7 +570,7 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar } private EntryPosition createPosition(LogHeader logHeader) { - return new EntryPosition(binlogFileName, + return new EntryPosition(logHeader.getLogFileName(), logHeader.getLogPos(), logHeader.getWhen() * 1000L, logHeader.getServerId()); // 记录到秒 @@ -638,11 +657,14 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar // fixed issue // https://github.com/alibaba/canal/issues/66,特殊处理binary/varbinary,不能做编码处理 boolean isBinary = false; + boolean isSingleBit = false; if (fieldMeta != null) { if (StringUtils.containsIgnoreCase(fieldMeta.getColumnType(), "VARBINARY")) { isBinary = true; } else if (StringUtils.containsIgnoreCase(fieldMeta.getColumnType(), "BINARY")) { isBinary = true; + } else if (StringUtils.containsIgnoreCase(fieldMeta.getColumnType(), "TINYINT(1)")) { + isSingleBit = true; } } buffer.nextValue(info.type, info.meta, isBinary); @@ -652,6 +674,9 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar } int javaType = buffer.getJavaType(); + if (isSingleBit && javaType == Types.TINYINT) { + javaType = Types.BIT; + } if (buffer.isNull()) { columnBuilder.setIsNull(true); } else { @@ -768,7 +793,7 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar } private Entry buildQueryEntry(String queryString, LogHeader logHeader, String tableName) { - Header header = createHeader(binlogFileName, logHeader, "", tableName, EventType.QUERY); + Header header = createHeader(logHeader, "", tableName, EventType.QUERY); RowChange.Builder rowChangeBuider = RowChange.newBuilder(); rowChangeBuider.setSql(queryString); rowChangeBuider.setEventType(EventType.QUERY); @@ -776,19 +801,23 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar } private Entry buildQueryEntry(String queryString, LogHeader logHeader) { - Header header = createHeader(binlogFileName, logHeader, "", "", EventType.QUERY); + Header header = createHeader(logHeader, "", "", EventType.QUERY); RowChange.Builder rowChangeBuider = RowChange.newBuilder(); rowChangeBuider.setSql(queryString); rowChangeBuider.setEventType(EventType.QUERY); return createEntry(header, EntryType.ROWDATA, rowChangeBuider.build().toByteString()); } - private Header createHeader(String binlogFile, LogHeader logHeader, String schemaName, String tableName, - EventType eventType) { + + private Header createHeader(LogHeader logHeader, String schemaName, String tableName, EventType eventType) { + return createHeader(logHeader, schemaName, tableName, eventType, -1); + } + + private Header createHeader(LogHeader logHeader, String schemaName, String tableName, EventType eventType, Integer rowsCount) { // header会做信息冗余,方便以后做检索或者过滤 Header.Builder headerBuilder = Header.newBuilder(); headerBuilder.setVersion(version); - headerBuilder.setLogfileName(binlogFile); + headerBuilder.setLogfileName(logHeader.getLogFileName()); headerBuilder.setLogfileOffset(logHeader.getLogPos() - logHeader.getEventLen()); headerBuilder.setServerId(logHeader.getServerId()); headerBuilder.setServerenCode(UTF_8);// 经过java输出后所有的编码为unicode @@ -809,6 +838,12 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar String gtid = gtidSet.toString(); headerBuilder.setGtid(gtid); } + + // add rowsCount suppport + if (rowsCount > 0) { + Pair pair = createSpecialPair("rowsCount", String.valueOf(rowsCount)); + headerBuilder.addProps(pair); + } return headerBuilder.build(); } 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 eda66921..d82e5eff 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,6 +4,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.apache.commons.lang.StringUtils; + import com.alibaba.fastsql.sql.SQLUtils; import com.alibaba.fastsql.sql.ast.SQLExpr; import com.alibaba.fastsql.sql.ast.SQLStatement; @@ -18,9 +20,11 @@ import com.alibaba.fastsql.sql.ast.statement.SQLAlterTableItem; import com.alibaba.fastsql.sql.ast.statement.SQLAlterTableRename; import com.alibaba.fastsql.sql.ast.statement.SQLAlterTableStatement; import com.alibaba.fastsql.sql.ast.statement.SQLConstraint; +import com.alibaba.fastsql.sql.ast.statement.SQLCreateDatabaseStatement; import com.alibaba.fastsql.sql.ast.statement.SQLCreateIndexStatement; import com.alibaba.fastsql.sql.ast.statement.SQLCreateTableStatement; import com.alibaba.fastsql.sql.ast.statement.SQLDeleteStatement; +import com.alibaba.fastsql.sql.ast.statement.SQLDropDatabaseStatement; import com.alibaba.fastsql.sql.ast.statement.SQLDropIndexStatement; import com.alibaba.fastsql.sql.ast.statement.SQLDropTableStatement; import com.alibaba.fastsql.sql.ast.statement.SQLExprTableSource; @@ -157,6 +161,17 @@ public class DruidDdlParser { processName(ddlResult, schmeaName, delete.getTableName(), false); ddlResult.setType(EventType.DELETE); ddlResults.add(ddlResult); + } else if (statement instanceof SQLCreateDatabaseStatement) { + DdlResult ddlResult = new DdlResult(); + ddlResult.setType(EventType.QUERY); + // 只设置schema + processName(ddlResult, schmeaName, null, false); + ddlResults.add(ddlResult); + } else if (statement instanceof SQLDropDatabaseStatement) { + DdlResult ddlResult = new DdlResult(); + ddlResult.setType(EventType.QUERY); + // 只设置schema + processName(ddlResult, schmeaName, null, false); } } @@ -165,6 +180,9 @@ public class DruidDdlParser { private static void processName(DdlResult ddlResult, String schema, SQLExpr sqlName, boolean isOri) { if (sqlName == null) { + if (StringUtils.isNotBlank(schema)) { + ddlResult.setSchemaName(schema); + } return; } diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/DatabaseTableMeta.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/DatabaseTableMeta.java index 585f1de9..bb2af45f 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/DatabaseTableMeta.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/DatabaseTableMeta.java @@ -70,7 +70,9 @@ public class DatabaseTableMeta implements TableMetaTSDB { @Override public Thread newThread(Runnable r) { - return new Thread(r, "[scheduler-table-meta-snapshot]"); + Thread thread = new Thread(r, "[scheduler-table-meta-snapshot]"); + thread.setDaemon(true); + return thread; } }); @@ -298,13 +300,24 @@ public class DatabaseTableMeta implements TableMetaTSDB { createDDL = packet.getFieldValues().get(1); tableMetaFromDB.setFields(TableMetaCache.parseTableMeta(schema, table, packet)); } - } catch (IOException e) { - if (e.getMessage().contains("errorNumber=1146")) { - logger.error("table not exist in db , pls check :" + getFullName(schema, table) + " , mem : " - + tableMetaFromMem); - return false; + } catch (Throwable e) { + try { + // retry for broke pipe, see: + // https://github.com/alibaba/canal/issues/724 + connection.reconnect(); + ResultSetPacket packet = connection.query("show create table " + getFullName(schema, table)); + if (packet.getFieldValues().size() > 1) { + createDDL = packet.getFieldValues().get(1); + tableMetaFromDB.setFields(TableMetaCache.parseTableMeta(schema, table, packet)); + } + } catch (IOException e1) { + if (e.getMessage().contains("errorNumber=1146")) { + logger.error("table not exist in db , pls check :" + getFullName(schema, table) + " , mem : " + + tableMetaFromMem); + return false; + } + throw new CanalParseException(e); } - throw new CanalParseException(e); } boolean result = compareTableMeta(tableMetaFromMem, tableMetaFromDB); 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 127df1c4..9a886336 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 @@ -94,7 +94,7 @@ public class MemoryTableMeta implements TableMetaTSDB { tableMeta = tableMetas.get(keys); if (tableMeta == null) { Schema schemaRep = repository.findSchema(schema); - if (schema == null) { + if (schemaRep == null) { return null; } SchemaObject data = schemaRep.findTable(table); diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/dao/MetaHistoryDO.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/dao/MetaHistoryDO.java index 6ac548f1..d81322d2 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/dao/MetaHistoryDO.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/dao/MetaHistoryDO.java @@ -87,7 +87,6 @@ public class MetaHistoryDO { this.useSchema = useSchema; } - public String getExtra() { return extra; } diff --git a/parse/src/test/java/com/alibaba/otter/canal/parse/MysqlBinlogDumpPerformanceTest.java b/parse/src/test/java/com/alibaba/otter/canal/parse/MysqlBinlogDumpPerformanceTest.java new file mode 100644 index 00000000..8ca9b044 --- /dev/null +++ b/parse/src/test/java/com/alibaba/otter/canal/parse/MysqlBinlogDumpPerformanceTest.java @@ -0,0 +1,89 @@ +package com.alibaba.otter.canal.parse; + +import java.net.InetSocketAddress; +import java.nio.charset.Charset; +import java.util.List; +import java.util.concurrent.atomic.AtomicLong; + +import com.alibaba.otter.canal.common.AbstractCanalLifeCycle; +import com.alibaba.otter.canal.parse.exception.CanalParseException; +import com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser; +import com.alibaba.otter.canal.parse.index.AbstractLogPositionManager; +import com.alibaba.otter.canal.parse.support.AuthenticationInfo; +import com.alibaba.otter.canal.protocol.CanalEntry; +import com.alibaba.otter.canal.protocol.position.EntryPosition; +import com.alibaba.otter.canal.protocol.position.LogPosition; +import com.alibaba.otter.canal.sink.CanalEventSink; +import com.alibaba.otter.canal.sink.exception.CanalSinkException; + +public class MysqlBinlogDumpPerformanceTest { + + public static void main(String args[]) { + final MysqlEventParser controller = new MysqlEventParser(); + final EntryPosition startPosition = new EntryPosition("mysql-bin.001699", 120L, 100L); + controller.setConnectionCharset(Charset.forName("UTF-8")); + controller.setSlaveId(3344L); + controller.setDetectingEnable(false); + controller.setFilterQueryDml(true); + controller.setMasterInfo(new AuthenticationInfo(new InetSocketAddress("127.0.0.1", 3328), "root", "hello")); + controller.setMasterPosition(startPosition); + controller.setEnableTsdb(false); + controller.setDestination("example"); + controller.setTsdbSpringXml("classpath:spring/tsdb/h2-tsdb.xml"); + // controller.setEventFilter(new AviaterRegexFilter("test\\..*")); + // controller.setEventBlackFilter(new + // AviaterRegexFilter("canal_tsdb\\..*")); + controller.setParallel(true); + controller.setParallelBufferSize(256); + controller.setParallelThreadSize(16); + controller.setIsGTIDMode(false); + final AtomicLong sum = new AtomicLong(0); + final AtomicLong last = new AtomicLong(0); + final AtomicLong start = new AtomicLong(System.currentTimeMillis()); + final AtomicLong end = new AtomicLong(0); + controller.setEventSink(new AbstractCanalEventSinkTest>() { + + public boolean sink(List entrys, InetSocketAddress remoteAddress, String destination) + throws CanalSinkException, + InterruptedException { + + sum.addAndGet(entrys.size()); + long current = sum.get(); + if (current - last.get() >= 100000) { + end.set(System.currentTimeMillis()); + long tps = ((current - last.get()) * 1000) / (end.get() - start.get()); + System.out.println(" total : " + sum + " , cost : " + (end.get() - start.get()) + " , tps : " + tps); + last.set(current); + start.set(end.get()); + } + return true; + } + + }); + controller.setLogPositionManager(new AbstractLogPositionManager() { + + @Override + public LogPosition getLatestIndexBy(String destination) { + return null; + } + + @Override + public void persistLogPosition(String destination, LogPosition logPosition) throws CanalParseException { + } + }); + + controller.start(); + + try { + Thread.sleep(100 * 1000 * 1000L); + } catch (InterruptedException e) { + } + controller.stop(); + } + + public static abstract class AbstractCanalEventSinkTest extends AbstractCanalLifeCycle implements CanalEventSink { + + public void interrupt() { + } + } +} diff --git a/parse/src/test/java/com/alibaba/otter/canal/parse/MysqlBinlogEventPerformanceTest.java b/parse/src/test/java/com/alibaba/otter/canal/parse/MysqlBinlogEventPerformanceTest.java new file mode 100644 index 00000000..e92fecb5 --- /dev/null +++ b/parse/src/test/java/com/alibaba/otter/canal/parse/MysqlBinlogEventPerformanceTest.java @@ -0,0 +1,82 @@ +package com.alibaba.otter.canal.parse; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.nio.charset.Charset; +import java.util.concurrent.atomic.AtomicLong; + +import com.alibaba.otter.canal.parse.driver.mysql.MysqlConnector; +import com.alibaba.otter.canal.parse.driver.mysql.MysqlUpdateExecutor; +import com.alibaba.otter.canal.parse.driver.mysql.packets.HeaderPacket; +import com.alibaba.otter.canal.parse.driver.mysql.packets.client.BinlogDumpCommandPacket; +import com.alibaba.otter.canal.parse.driver.mysql.utils.PacketManager; +import com.alibaba.otter.canal.parse.inbound.mysql.dbsync.DirectLogFetcher; +import com.taobao.tddl.dbsync.binlog.LogContext; +import com.taobao.tddl.dbsync.binlog.LogDecoder; +import com.taobao.tddl.dbsync.binlog.LogEvent; + +public class MysqlBinlogEventPerformanceTest { + + protected static Charset charset = Charset.forName("utf-8"); + + public static void main(String args[]) { + DirectLogFetcher fetcher = new DirectLogFetcher(); + try { + MysqlConnector connector = new MysqlConnector(new InetSocketAddress("127.0.0.1", 3306), "root", "hello"); + connector.connect(); + updateSettings(connector); + sendBinlogDump(connector, "mysql-bin.000006", 120L, 3); + fetcher.start(connector.getChannel()); + LogDecoder decoder = new LogDecoder(LogEvent.UNKNOWN_EVENT, LogEvent.ENUM_END_EVENT); + LogContext context = new LogContext(); + AtomicLong sum = new AtomicLong(0); + long start = System.currentTimeMillis(); + long last = 0; + long end = 0; + while (fetcher.fetch()) { + decoder.decode(fetcher, context); + sum.incrementAndGet(); + long current = sum.get(); + if (current - last >= 100000) { + end = System.currentTimeMillis(); + long tps = ((current - last) * 1000) / (end - start); + System.out.println(" total : " + sum + " , cost : " + (end - start) + " , tps : " + tps); + last = current; + start = end; + } + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + fetcher.close(); + } catch (IOException e) { + } + } + } + + private static void sendBinlogDump(MysqlConnector connector, String binlogfilename, Long binlogPosition, int slaveId) + throws IOException { + BinlogDumpCommandPacket binlogDumpCmd = new BinlogDumpCommandPacket(); + binlogDumpCmd.binlogFileName = binlogfilename; + binlogDumpCmd.binlogPosition = binlogPosition; + binlogDumpCmd.slaveServerId = slaveId; + byte[] cmdBody = binlogDumpCmd.toBytes(); + + HeaderPacket binlogDumpHeader = new HeaderPacket(); + binlogDumpHeader.setPacketBodyLength(cmdBody.length); + binlogDumpHeader.setPacketSequenceNumber((byte) 0x00); + PacketManager.writePkg(connector.getChannel(), binlogDumpHeader.toBytes(), cmdBody); + } + + private static void updateSettings(MysqlConnector connector) throws IOException { + update("set @master_binlog_checksum= '@@global.binlog_checksum'", connector); + update("SET @mariadb_slave_capability='" + LogEvent.MARIA_SLAVE_CAPABILITY_MINE + "'", connector); + } + + public static void update(String cmd, MysqlConnector connector) throws IOException { + MysqlUpdateExecutor exector = new MysqlUpdateExecutor(connector); + exector.update(cmd); + } + +} diff --git a/parse/src/test/java/com/alibaba/otter/canal/parse/MysqlBinlogParsePerformanceTest.java b/parse/src/test/java/com/alibaba/otter/canal/parse/MysqlBinlogParsePerformanceTest.java new file mode 100644 index 00000000..79b88375 --- /dev/null +++ b/parse/src/test/java/com/alibaba/otter/canal/parse/MysqlBinlogParsePerformanceTest.java @@ -0,0 +1,192 @@ +package com.alibaba.otter.canal.parse; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.InetSocketAddress; +import java.nio.charset.Charset; +import java.util.BitSet; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.atomic.AtomicLong; + +import com.alibaba.otter.canal.parse.driver.mysql.MysqlConnector; +import com.alibaba.otter.canal.parse.driver.mysql.MysqlUpdateExecutor; +import com.alibaba.otter.canal.parse.driver.mysql.packets.HeaderPacket; +import com.alibaba.otter.canal.parse.driver.mysql.packets.client.BinlogDumpCommandPacket; +import com.alibaba.otter.canal.parse.driver.mysql.utils.PacketManager; +import com.alibaba.otter.canal.parse.inbound.mysql.dbsync.DirectLogFetcher; +import com.taobao.tddl.dbsync.binlog.LogBuffer; +import com.taobao.tddl.dbsync.binlog.LogContext; +import com.taobao.tddl.dbsync.binlog.LogDecoder; +import com.taobao.tddl.dbsync.binlog.LogEvent; +import com.taobao.tddl.dbsync.binlog.event.DeleteRowsLogEvent; +import com.taobao.tddl.dbsync.binlog.event.RowsLogBuffer; +import com.taobao.tddl.dbsync.binlog.event.RowsLogEvent; +import com.taobao.tddl.dbsync.binlog.event.TableMapLogEvent; +import com.taobao.tddl.dbsync.binlog.event.TableMapLogEvent.ColumnInfo; +import com.taobao.tddl.dbsync.binlog.event.UpdateRowsLogEvent; +import com.taobao.tddl.dbsync.binlog.event.WriteRowsLogEvent; + +public class MysqlBinlogParsePerformanceTest { + + protected static Charset charset = Charset.forName("utf-8"); + + public static void main(String args[]) { + DirectLogFetcher fetcher = new DirectLogFetcher(); + try { + MysqlConnector connector = new MysqlConnector(new InetSocketAddress("127.0.0.1", 3306), "root", "hello"); + connector.connect(); + updateSettings(connector); + sendBinlogDump(connector, "mysql-bin.000006", 120L, 3); + fetcher.start(connector.getChannel()); + final BlockingQueue buffer = new ArrayBlockingQueue(1024); + Thread thread = new Thread(new Runnable() { + + @Override + public void run() { + try { + consumer(buffer); + } catch (IOException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }); + thread.start(); + + while (fetcher.fetch()) { + buffer.put(fetcher.duplicate()); + fetcher.consume(fetcher.limit()); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + fetcher.close(); + } catch (IOException e) { + } + } + } + + public static void consumer(BlockingQueue buffer) throws IOException, InterruptedException { + LogDecoder decoder = new LogDecoder(LogEvent.UNKNOWN_EVENT, LogEvent.ENUM_END_EVENT); + LogContext context = new LogContext(); + + AtomicLong sum = new AtomicLong(0); + long start = System.currentTimeMillis(); + long last = 0; + long end = 0; + while (true) { + LogEvent event = null; + event = decoder.decode(buffer.take(), context); + int eventType = event.getHeader().getType(); + switch (eventType) { + case LogEvent.ROTATE_EVENT: + break; + case LogEvent.WRITE_ROWS_EVENT_V1: + case LogEvent.WRITE_ROWS_EVENT: + parseRowsEvent((WriteRowsLogEvent) event, sum); + break; + case LogEvent.UPDATE_ROWS_EVENT_V1: + case LogEvent.UPDATE_ROWS_EVENT: + parseRowsEvent((UpdateRowsLogEvent) event, sum); + break; + case LogEvent.DELETE_ROWS_EVENT_V1: + case LogEvent.DELETE_ROWS_EVENT: + parseRowsEvent((DeleteRowsLogEvent) event, sum); + break; + case LogEvent.XID_EVENT: + sum.incrementAndGet(); + break; + case LogEvent.QUERY_EVENT: + sum.incrementAndGet(); + break; + default: + break; + } + + long current = sum.get(); + if (current - last >= 100000) { + end = System.currentTimeMillis(); + long tps = ((current - last) * 1000) / (end - start); + System.out.println(" total : " + sum + " , cost : " + (end - start) + " , tps : " + tps); + last = current; + start = end; + } + } + } + + private static void sendBinlogDump(MysqlConnector connector, String binlogfilename, Long binlogPosition, int slaveId) + throws IOException { + BinlogDumpCommandPacket binlogDumpCmd = new BinlogDumpCommandPacket(); + binlogDumpCmd.binlogFileName = binlogfilename; + binlogDumpCmd.binlogPosition = binlogPosition; + binlogDumpCmd.slaveServerId = slaveId; + byte[] cmdBody = binlogDumpCmd.toBytes(); + + HeaderPacket binlogDumpHeader = new HeaderPacket(); + binlogDumpHeader.setPacketBodyLength(cmdBody.length); + binlogDumpHeader.setPacketSequenceNumber((byte) 0x00); + PacketManager.writePkg(connector.getChannel(), binlogDumpHeader.toBytes(), cmdBody); + } + + private static void updateSettings(MysqlConnector connector) throws IOException { + update("set @master_binlog_checksum= '@@global.binlog_checksum'", connector); + update("SET @mariadb_slave_capability='" + LogEvent.MARIA_SLAVE_CAPABILITY_MINE + "'", connector); + } + + public static void update(String cmd, MysqlConnector connector) throws IOException { + MysqlUpdateExecutor exector = new MysqlUpdateExecutor(connector); + exector.update(cmd); + } + + public static void parseRowsEvent(RowsLogEvent event, AtomicLong sum) { + try { + RowsLogBuffer buffer = event.getRowsBuf(charset.name()); + BitSet columns = event.getColumns(); + BitSet changeColumns = event.getChangeColumns(); + while (buffer.nextOneRow(columns)) { + int type = event.getHeader().getType(); + if (LogEvent.WRITE_ROWS_EVENT_V1 == type || LogEvent.WRITE_ROWS_EVENT == type) { + parseOneRow(event, buffer, columns, true); + } else if (LogEvent.DELETE_ROWS_EVENT_V1 == type || LogEvent.DELETE_ROWS_EVENT == type) { + parseOneRow(event, buffer, columns, false); + } else { + parseOneRow(event, buffer, columns, false); + if (!buffer.nextOneRow(changeColumns)) { + break; + } + parseOneRow(event, buffer, changeColumns, true); + } + + sum.incrementAndGet(); + } + } catch (Exception e) { + throw new RuntimeException("parse row data failed.", e); + } + } + + public static void parseOneRow(RowsLogEvent event, RowsLogBuffer buffer, BitSet cols, boolean isAfter) + throws UnsupportedEncodingException { + TableMapLogEvent map = event.getTable(); + if (map == null) { + throw new RuntimeException("not found TableMap with tid=" + event.getTableId()); + } + + final int columnCnt = map.getColumnCnt(); + final ColumnInfo[] columnInfo = map.getColumnInfo(); + for (int i = 0; i < columnCnt; i++) { + if (!cols.get(i)) { + continue; + } + + ColumnInfo info = columnInfo[i]; + buffer.nextValue(info.type, info.meta); + if (buffer.isNull()) { + } else { + buffer.getValue(); + } + } + } +} diff --git a/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/group/DummyEventStore.java b/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/group/DummyEventStore.java index 24f7f551..c542e5c0 100644 --- a/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/group/DummyEventStore.java +++ b/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/group/DummyEventStore.java @@ -7,7 +7,6 @@ import java.util.Date; import java.util.List; import java.util.concurrent.TimeUnit; -import com.alibaba.otter.canal.protocol.CanalEntry; import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; import com.alibaba.otter.canal.protocol.position.Position; import com.alibaba.otter.canal.store.CanalEventStore; @@ -18,7 +17,7 @@ import com.alibaba.otter.canal.store.model.Events; public class DummyEventStore implements CanalEventStore { private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; - private static final String messgae = "{0} [{1}:{2}:{3}] {4} {5}.{6}"; + private static final String messgae = "{0} [{1}:{2}:{3}]"; public void ack(Position position) throws CanalStoreException { @@ -82,46 +81,40 @@ public class DummyEventStore implements CanalEventStore { public void put(List datas) throws InterruptedException, CanalStoreException { for (Event data : datas) { - CanalEntry.Header header = data.getEntry().getHeader(); - Date date = new Date(header.getExecuteTime()); + Date date = new Date(data.getExecuteTime()); SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT); - if (data.getEntry().getEntryType() == EntryType.TRANSACTIONBEGIN - || data.getEntry().getEntryType() == EntryType.TRANSACTIONEND) { + if (data.getEntryType() == EntryType.TRANSACTIONBEGIN || data.getEntryType() == EntryType.TRANSACTIONEND) { // System.out.println(MessageFormat.format(messgae, new Object[] // { Thread.currentThread().getName(), // header.getLogfilename(), header.getLogfileoffset(), // format.format(date), // data.getEntry().getEntryType(), "" })); - System.out.println(data.getEntry().getEntryType()); + System.out.println(data.getEntryType()); } else { System.out.println(MessageFormat.format(messgae, - new Object[] { Thread.currentThread().getName(), header.getLogfileName(), - String.valueOf(header.getLogfileOffset()), format.format(date), header.getEventType(), - header.getSchemaName(), header.getTableName() })); + new Object[] { Thread.currentThread().getName(), data.getJournalName(), + String.valueOf(data.getPosition()), format.format(date) })); } } } public boolean put(List datas, long timeout, TimeUnit unit) throws InterruptedException, CanalStoreException { for (Event data : datas) { - CanalEntry.Header header = data.getEntry().getHeader(); - Date date = new Date(header.getExecuteTime()); + Date date = new Date(data.getExecuteTime()); SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT); - if (data.getEntry().getEntryType() == EntryType.TRANSACTIONBEGIN - || data.getEntry().getEntryType() == EntryType.TRANSACTIONEND) { + if (data.getEntryType() == EntryType.TRANSACTIONBEGIN || data.getEntryType() == EntryType.TRANSACTIONEND) { // System.out.println(MessageFormat.format(messgae, new Object[] // { Thread.currentThread().getName(), // header.getLogfilename(), header.getLogfileoffset(), // format.format(date), // data.getEntry().getEntryType(), "" })); - System.out.println(data.getEntry().getEntryType()); + System.out.println(data.getEntryType()); } else { System.out.println(MessageFormat.format(messgae, - new Object[] { Thread.currentThread().getName(), header.getLogfileName(), - String.valueOf(header.getLogfileOffset()), format.format(date), header.getEventType(), - header.getSchemaName(), header.getTableName() })); + new Object[] { Thread.currentThread().getName(), data.getJournalName(), + String.valueOf(data.getPosition()), format.format(date) })); } } return true; @@ -131,23 +124,20 @@ public class DummyEventStore implements CanalEventStore { System.out.println("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); for (Event data : datas) { - CanalEntry.Header header = data.getEntry().getHeader(); - Date date = new Date(header.getExecuteTime()); + Date date = new Date(data.getExecuteTime()); SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT); - if (data.getEntry().getEntryType() == EntryType.TRANSACTIONBEGIN - || data.getEntry().getEntryType() == EntryType.TRANSACTIONEND) { + if (data.getEntryType() == EntryType.TRANSACTIONBEGIN || data.getEntryType() == EntryType.TRANSACTIONEND) { // System.out.println(MessageFormat.format(messgae, new Object[] // { Thread.currentThread().getName(), // header.getLogfilename(), header.getLogfileoffset(), // format.format(date), // data.getEntry().getEntryType(), "" })); - System.out.println(data.getEntry().getEntryType()); + System.out.println(data.getEntryType()); } else { System.out.println(MessageFormat.format(messgae, - new Object[] { Thread.currentThread().getName(), header.getLogfileName(), - String.valueOf(header.getLogfileOffset()), format.format(date), header.getEventType(), - header.getSchemaName(), header.getTableName() })); + new Object[] { Thread.currentThread().getName(), data.getJournalName(), + String.valueOf(data.getPosition()), format.format(date) })); } } diff --git a/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlDumpTest.java b/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlDumpTest.java index 6849c5b3..6c11c637 100644 --- a/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlDumpTest.java +++ b/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlDumpTest.java @@ -41,6 +41,9 @@ public class MysqlDumpTest { controller.setTsdbSpringXml("classpath:tsdb/h2-tsdb.xml"); controller.setEventFilter(new AviaterRegexFilter("test\\..*")); controller.setEventBlackFilter(new AviaterRegexFilter("canal_tsdb\\..*")); + controller.setParallel(true); + controller.setParallelBufferSize(256); + controller.setParallelThreadSize(2); controller.setIsGTIDMode(false); controller.setEventSink(new AbstractCanalEventSinkTest>() { diff --git a/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/FastsqlSchemaTest.java b/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/FastsqlSchemaTest.java new file mode 100644 index 00000000..c7e25607 --- /dev/null +++ b/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/FastsqlSchemaTest.java @@ -0,0 +1,30 @@ +package com.alibaba.otter.canal.parse.inbound.mysql.tsdb; + +import java.io.FileNotFoundException; +import java.io.IOException; + +import org.junit.Test; + +import com.alibaba.fastsql.sql.repository.SchemaObject; +import com.alibaba.fastsql.sql.repository.SchemaRepository; +import com.alibaba.fastsql.util.JdbcConstants; + +/** + * @author agapple 2018年6月7日 下午5:36:13 + * @since 3.1.9 + */ +public class FastsqlSchemaTest { + + @Test + public void testSimple() throws FileNotFoundException, IOException { + SchemaRepository repository = new SchemaRepository(JdbcConstants.MYSQL); + String sql = "create table yushitai_test.card_record ( id bigint auto_increment) auto_increment=256 " + + "; alter table yushitai_test.card_record add column customization_id bigint unsigned NOT NULL COMMENT 'TEST' ;" + + "; rename table yushitai_test.card_record to yushitai_test._card_record_del;"; + repository.console(sql); + + repository.setDefaultSchema("yushitai_test"); + SchemaObject table = repository.findTable("_card_record_del"); + System.out.println(table.getStatement().toString()); + } +} diff --git a/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/MemoryTableMeta_DDL_Test.java b/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/MemoryTableMeta_DDL_Test.java new file mode 100644 index 00000000..e3005b62 --- /dev/null +++ b/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/MemoryTableMeta_DDL_Test.java @@ -0,0 +1,40 @@ +package com.alibaba.otter.canal.parse.inbound.mysql.tsdb; + +import java.io.File; +import java.io.FileInputStream; +import java.net.URL; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import com.alibaba.otter.canal.parse.inbound.TableMeta; + +/** + * @author agapple 2017年8月1日 下午7:15:54 + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { "/tsdb/mysql-tsdb.xml" }) +public class MemoryTableMeta_DDL_Test { + + @Test + public void test1() throws Throwable { + MemoryTableMeta memoryTableMeta = new MemoryTableMeta(); + URL url = Thread.currentThread().getContextClassLoader().getResource("dummy.txt"); + File dummyFile = new File(url.getFile()); + File create = new File(dummyFile.getParent() + "/ddl", "ddl_test1.sql"); + String sql = StringUtils.join(IOUtils.readLines(new FileInputStream(create)), "\n"); + memoryTableMeta.apply(null, "test", sql, null); + + TableMeta meta = memoryTableMeta.find("yushitai_test", "card_record"); + System.out.println(meta); + Assert.assertNotNull(meta.getFieldMetaByName("customization_id")); + + meta = memoryTableMeta.find("yushitai_test", "_card_record_gho"); + Assert.assertNull(meta); + } +} diff --git a/parse/src/test/resources/ddl/ddl_test1.sql b/parse/src/test/resources/ddl/ddl_test1.sql new file mode 100644 index 00000000..a708fdac --- /dev/null +++ b/parse/src/test/resources/ddl/ddl_test1.sql @@ -0,0 +1,21 @@ +create table yushitai_test.card_record ( +id bigint auto_increment, +last_update timestamp not null DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, +hint varchar(64) charset ascii not null, +value varchar(255) charset ascii not null, +primary key(id), +unique key hint_uidx(hint) +) auto_increment=256 ; + +DROP TABLE IF EXISTS _card_record_gho /* generated by server */ ; +DROP TABLE IF EXISTS _card_record_del /* generated by server */ ; + +create /* gh-ost */ table yushitai_test._card_record_gho like yushitai_test.card_record ; +alter /* gh-ost */ table yushitai_test._card_record_gho add column customization_id bigint unsigned NOT NULL COMMENT 'TEST' ; + +create /* gh-ost */ table yushitai_test._card_record_del ( +id int auto_increment primary key +) engine=InnoDB comment='ghost-cut-over-sentry' ; + +DROP TABLE IF EXISTS _card_record_del /* generated by server */ ; +rename /* gh-ost */ table yushitai_test.card_record to yushitai_test._card_record_del, yushitai_test._card_record_gho to yushitai_test.card_record; \ No newline at end of file diff --git a/pom.xml b/pom.xml index e9c2623b..56ac821a 100644 --- a/pom.xml +++ b/pom.xml @@ -66,16 +66,6 @@ false - - alibaba - http://code.alibabatech.com/mvn/releases/ - - true - - - false - - sonatype sonatype @@ -106,8 +96,8 @@ true true - 1.6 - 1.6 + 1.7 + 1.7 UTF-8 3.2.9.RELEASE @@ -127,6 +117,9 @@ client deployer example + kafka + kafka-client + prometheus @@ -254,13 +247,18 @@ com.alibaba.fastsql fastsql - 2.0.0_preview_186 + 2.0.0_preview_540 com.alibaba druid 1.1.9 + + com.lmax + disruptor + 3.4.2 + ch.qos.logback @@ -334,7 +332,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.2 + 3.8.0 ${java_source_version} ${java_target_version} diff --git a/prometheus/pom.xml b/prometheus/pom.xml new file mode 100644 index 00000000..16cf8acf --- /dev/null +++ b/prometheus/pom.xml @@ -0,0 +1,67 @@ + + + + canal + com.alibaba.otter + 1.0.26-SNAPSHOT + + 4.0.0 + + com.alibaba.otter + canal.prometheus + 1.0.26-SNAPSHOT + canal prometheus module for otter ${project.version} + + + + org.aspectj + aspectjrt + 1.8.9 + + + org.aspectj + aspectjweaver + 1.8.9 + + + org.jctools + jctools-core + 2.1.2 + + + io.prometheus + simpleclient + 0.4.0 + + + io.prometheus + simpleclient_hotspot + 0.4.0 + + + io.prometheus + simpleclient_httpserver + 0.4.0 + + + io.prometheus + simpleclient_pushgateway + 0.4.0 + + + com.alibaba.otter + canal.instance.core + ${project.version} + provided + + + com.alibaba.otter + canal.server + ${project.version} + provided + + + + diff --git a/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/CanalInstanceExports.java b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/CanalInstanceExports.java new file mode 100644 index 00000000..8acf40b8 --- /dev/null +++ b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/CanalInstanceExports.java @@ -0,0 +1,98 @@ +package com.alibaba.otter.canal.prometheus; + +import com.alibaba.otter.canal.instance.core.CanalInstance; +import com.alibaba.otter.canal.prometheus.impl.InstanceMetaCollector; +import com.alibaba.otter.canal.prometheus.impl.MemoryStoreCollector; +import com.alibaba.otter.canal.prometheus.impl.PrometheusCanalEventDownStreamHandler; +import com.alibaba.otter.canal.sink.CanalEventSink; +import com.alibaba.otter.canal.sink.entry.EntryEventSink; +import com.alibaba.otter.canal.store.CanalStoreException; +import io.prometheus.client.Collector; +import io.prometheus.client.CollectorRegistry; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Collections; +import java.util.List; + +/** + * @author Chuanyi Li + */ +public class CanalInstanceExports { + + private static final Logger logger = LoggerFactory.getLogger(CanalInstanceExports.class); + + public static final String[] labels = {"destination"}; + + public static final List labelList = Collections.singletonList(labels[0]); + + private final String destination; + + private Collector storeCollector; + + private Collector delayCollector; + + private Collector metaCollector; + + private CanalInstanceExports(CanalInstance instance) { + this.destination = instance.getDestination(); + initDelayGauge(instance); + initStoreCollector(instance); + initMetaCollector(instance); + } + + + + static CanalInstanceExports forInstance(CanalInstance instance) { + return new CanalInstanceExports(instance); + } + + void register() { + if (delayCollector != null) { + delayCollector.register(); + } + if (storeCollector != null) { + storeCollector.register(); + } + if (metaCollector != null) { + metaCollector.register(); + } + } + + void unregister() { + if (delayCollector != null) { + CollectorRegistry.defaultRegistry.unregister(delayCollector); + } + if (storeCollector != null) { + CollectorRegistry.defaultRegistry.unregister(storeCollector); + } + if (metaCollector != null) { + CollectorRegistry.defaultRegistry.unregister(metaCollector); + } + } + + private void initDelayGauge(CanalInstance instance) { + CanalEventSink sink = instance.getEventSink(); + if (sink instanceof EntryEventSink) { + EntryEventSink entryEventSink = (EntryEventSink) sink; + // TODO ensure not to add handler again + PrometheusCanalEventDownStreamHandler handler = new PrometheusCanalEventDownStreamHandler(destination); + entryEventSink.addHandler(handler); + delayCollector = handler.getCollector(); + } else { + logger.warn("This impl register metrics for only EntryEventSink, skip."); + } + } + + private void initStoreCollector(CanalInstance instance) { + try { + storeCollector = new MemoryStoreCollector(instance.getEventStore(), destination); + } catch (CanalStoreException cse) { + logger.warn("Failed to register metrics for destination {}.", destination, cse); + } + } + + private void initMetaCollector(CanalInstance instance) { + metaCollector = new InstanceMetaCollector(instance); + } +} diff --git a/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/CanalServerExports.java b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/CanalServerExports.java new file mode 100644 index 00000000..8eef79ba --- /dev/null +++ b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/CanalServerExports.java @@ -0,0 +1,21 @@ +package com.alibaba.otter.canal.prometheus; + +import com.alibaba.otter.canal.prometheus.impl.InboundThroughputAspect; +import com.alibaba.otter.canal.prometheus.impl.OutboundThroughputAspect; + +/** + * @author Chuanyi Li + */ +public class CanalServerExports { + + private static boolean initialized = false; + + public static synchronized void initialize() { + if (!initialized) { + InboundThroughputAspect.getCollector().register(); + OutboundThroughputAspect.getCollector().register(); + initialized = true; + } + } + +} diff --git a/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/PrometheusProvider.java b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/PrometheusProvider.java new file mode 100644 index 00000000..12b8675f --- /dev/null +++ b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/PrometheusProvider.java @@ -0,0 +1,15 @@ +package com.alibaba.otter.canal.prometheus; + +import com.alibaba.otter.canal.spi.CanalMetricsProvider; +import com.alibaba.otter.canal.spi.CanalMetricsService; + +/** + * @author Chuanyi Li + */ +public class PrometheusProvider implements CanalMetricsProvider { + + @Override + public CanalMetricsService getService() { + return PrometheusService.getInstance(); + } +} diff --git a/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/PrometheusService.java b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/PrometheusService.java new file mode 100644 index 00000000..c7942235 --- /dev/null +++ b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/PrometheusService.java @@ -0,0 +1,110 @@ +package com.alibaba.otter.canal.prometheus; + +import com.alibaba.otter.canal.instance.core.CanalInstance; +import com.alibaba.otter.canal.spi.CanalMetricsService; +import io.prometheus.client.exporter.HTTPServer; +import io.prometheus.client.hotspot.DefaultExports; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * @author Chuanyi Li + */ +public class PrometheusService implements CanalMetricsService { + + private static final Logger logger = LoggerFactory.getLogger(PrometheusService.class); + + private final Map exports = new ConcurrentHashMap(); + + private volatile boolean running = false; + + private HTTPServer server; + + private PrometheusService() { + } + + private static class SingletonHolder { + private static final PrometheusService SINGLETON = new PrometheusService(); + } + + public static PrometheusService getInstance() { + return SingletonHolder.SINGLETON; + } + + @Override + public void initialize() { + try { + //TODO 1.Configurable port + //TODO 2.Https + server = new HTTPServer(11112); + } catch (IOException e) { + logger.warn("Unable to start prometheus HTTPServer.", e); + return; + } + try { + // JVM exports + DefaultExports.initialize(); + // Canal server level exports + CanalServerExports.initialize(); + } catch (Throwable t) { + logger.warn("Unable to initialize server exports.", t); + } + + running = true; + } + + @Override + public void terminate() { + running = false; + // Normally, service should be terminated at canal shutdown. + // No need to unregister instance exports explicitly. + // But for the sake of safety, unregister them. + for (CanalInstanceExports ie : exports.values()) { + ie.unregister(); + } + if (server != null) { + server.stop(); + } + } + + @Override + public boolean isRunning() { + return running; + } + + @Override + public void register(CanalInstance instance) { + if (instance.isStart()) { + logger.warn("Cannot register metrics for destination {} that is running.", instance.getDestination()); + return; + } + try { + CanalInstanceExports export = CanalInstanceExports.forInstance(instance); + export.register(); + exports.put(instance.getDestination(), export); + } catch (Throwable t) { + logger.warn("Unable to register instance exports for {}.", instance.getDestination(), t); + } + logger.info("Register metrics for destination {}.", instance.getDestination()); + } + + @Override + public void unregister(CanalInstance instance) { + if (instance.isStart()) { + logger.warn("Try unregister metrics after destination {} is stopped.", instance.getDestination()); + } + try { + CanalInstanceExports export = exports.remove(instance.getDestination()); + if (export != null) { + export.unregister(); + } + } catch (Throwable t) { + logger.warn("Unable to unregister instance exports for {}.", instance.getDestination(), t); + } + logger.info("Unregister metrics for destination {}.", instance.getDestination()); + } +} diff --git a/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/InboundThroughputAspect.java b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/InboundThroughputAspect.java new file mode 100644 index 00000000..eabc256c --- /dev/null +++ b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/InboundThroughputAspect.java @@ -0,0 +1,79 @@ +package com.alibaba.otter.canal.prometheus.impl; + +import io.prometheus.client.Collector; +import io.prometheus.client.CounterMetricFamily; +import org.aspectj.lang.annotation.After; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.jctools.maps.ConcurrentAutoTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Chuanyi Li + */ +@Aspect +public class InboundThroughputAspect { + + private static final Logger logger = LoggerFactory.getLogger(InboundThroughputAspect.class); + + /** + * Support highly scalable counters + * @see ConcurrentAutoTable + */ + private static final ConcurrentAutoTable total = new ConcurrentAutoTable(); + + private static final Collector collector = new InboundThroughputCollector(); + + public static Collector getCollector() { + return collector; + } + + @Pointcut("call(byte[] com.alibaba.otter.canal.parse.driver.mysql.socket.SocketChannel.read(..))") + public void read() {} + + @Pointcut("call(void com.alibaba.otter.canal.parse.driver.mysql.socket.SocketChannel.read(..)) ") + public void readBytes() {} + + //nested read, just eliminate them. + @Pointcut("withincode(* com.alibaba.otter.canal.parse.driver.mysql.socket.SocketChannel.read(..))") + public void nestedCall() {} + + @After("read() && !nestedCall() && args(len, ..)") + public void recordRead(int len) { + accumulateBytes(len); + } + + @After("readBytes() && !nestedCall() && args(.., len, timeout)") + public void recordReadBytes(int len, int timeout) { + accumulateBytes(len); + } + + private void accumulateBytes(int count) { + try { + total.add(count); + } catch (Throwable t) { + //Catch every Throwable, rather than break the business logic. + logger.warn("Error while accumulate inbound bytes.", t); + } + } + + public static class InboundThroughputCollector extends Collector { + + private InboundThroughputCollector() {} + + @Override + public List collect() { + List mfs = new ArrayList(); + CounterMetricFamily bytes = new CounterMetricFamily("canal_net_inbound_bytes", + "Total socket inbound bytes of canal server.", + total.get()); + mfs.add(bytes); + return mfs; + } + } + +} diff --git a/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/InstanceMetaCollector.java b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/InstanceMetaCollector.java new file mode 100644 index 00000000..5562b8fd --- /dev/null +++ b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/InstanceMetaCollector.java @@ -0,0 +1,64 @@ +package com.alibaba.otter.canal.prometheus.impl; + +import com.alibaba.otter.canal.instance.core.CanalInstance; +import com.alibaba.otter.canal.instance.spring.CanalInstanceWithSpring; +import com.alibaba.otter.canal.meta.CanalMetaManager; +import com.alibaba.otter.canal.prometheus.CanalInstanceExports; +import com.alibaba.otter.canal.protocol.ClientIdentity; +import io.prometheus.client.Collector; +import io.prometheus.client.GaugeMetricFamily; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * @author Chuanyi Li + */ +public class InstanceMetaCollector extends Collector { + + private static final List InfoLabel = Arrays.asList("destination", "mode"); + + private CanalMetaManager metaManager; + + private final String destination; + + private final String mode; + + private final String subsHelp; + + public InstanceMetaCollector(CanalInstance instance) { + if (instance == null) { + throw new IllegalArgumentException("CanalInstance must not be null."); + } + if (instance instanceof CanalInstanceWithSpring) { + mode = "spring"; + } else { + mode = "manager"; + } + this.metaManager = instance.getMetaManager(); + this.destination = instance.getDestination(); + this.subsHelp = "Subscriptions of canal instance " + destination; + } + + @Override + public List collect() { + List mfs = new ArrayList(); + GaugeMetricFamily instanceInfo = new GaugeMetricFamily( + "canal_instance", + "Canal instance", + InfoLabel); + instanceInfo.addMetric(Arrays.asList(destination, mode), 1); + mfs.add(instanceInfo); + if (metaManager.isStart()) { + // client id = hardcode 1001, 目前没有意义 + List subs = metaManager.listAllSubscribeInfo(destination); + GaugeMetricFamily subscriptions = new GaugeMetricFamily( + "canal_instance_subscription", + subsHelp, CanalInstanceExports.labelList); + subscriptions.addMetric(Arrays.asList(destination), subs.size()); + mfs.add(subscriptions); + } + return mfs; + } +} diff --git a/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/MemoryStoreCollector.java b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/MemoryStoreCollector.java new file mode 100644 index 00000000..79fdca4a --- /dev/null +++ b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/MemoryStoreCollector.java @@ -0,0 +1,75 @@ +package com.alibaba.otter.canal.prometheus.impl; + +import com.alibaba.otter.canal.prometheus.CanalInstanceExports; +import com.alibaba.otter.canal.store.CanalEventStore; +import com.alibaba.otter.canal.store.CanalStoreException; +import com.alibaba.otter.canal.store.memory.MemoryEventStoreWithBuffer; +import io.prometheus.client.Collector; +import io.prometheus.client.CounterMetricFamily; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.atomic.AtomicLong; + +/** + * @author Chuanyi Li + */ +public class MemoryStoreCollector extends Collector { + + private static final Class clazz = MemoryEventStoreWithBuffer.class; + + private final String destination; + + private final AtomicLong putSequence; + + private final AtomicLong ackSequence; + + private final String putHelp; + + private final String ackHelp; + + public MemoryStoreCollector(CanalEventStore store, String destination) { + this.destination = destination; + if (!(store instanceof MemoryEventStoreWithBuffer)) { + throw new IllegalArgumentException("EventStore must be MemoryEventStoreWithBuffer"); + } + MemoryEventStoreWithBuffer ms = (MemoryEventStoreWithBuffer) store; + putSequence = getDeclaredValue(ms, "putSequence"); + ackSequence = getDeclaredValue(ms, "ackSequence"); + putHelp = "Produced sequence of canal instance " + destination; + ackHelp = "Consumed sequence of canal instance " + destination; + } + + @Override + public List collect() { + List mfs = new ArrayList(); + CounterMetricFamily put = new CounterMetricFamily("canal_instance_store_produce_seq", + putHelp, Arrays.asList(CanalInstanceExports.labels)); + put.addMetric(Collections.singletonList(destination), putSequence.doubleValue()); + mfs.add(put); + CounterMetricFamily ack = new CounterMetricFamily("canal_instance_store_consume_seq", + ackHelp, Arrays.asList(CanalInstanceExports.labels)); + ack.addMetric(Collections.singletonList(destination), ackSequence.doubleValue()); + mfs.add(ack); + return mfs; + } + + @SuppressWarnings("unchecked") + private static T getDeclaredValue(MemoryEventStoreWithBuffer store, String name) { + T value; + try { + Field putField = clazz.getDeclaredField(name); + putField.setAccessible(true); + value = (T) putField.get(store); + } catch (NoSuchFieldException e) { + throw new CanalStoreException(e); + } catch (IllegalAccessException e) { + throw new CanalStoreException(e); + } + return value; + } + +} diff --git a/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/OutboundThroughputAspect.java b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/OutboundThroughputAspect.java new file mode 100644 index 00000000..60dd808d --- /dev/null +++ b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/OutboundThroughputAspect.java @@ -0,0 +1,80 @@ +package com.alibaba.otter.canal.prometheus.impl; + +import io.prometheus.client.Collector; +import io.prometheus.client.CounterMetricFamily; +import org.aspectj.lang.annotation.After; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.jboss.netty.channel.Channel; +import org.jctools.maps.ConcurrentAutoTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; + +import static com.alibaba.otter.canal.server.netty.NettyUtils.HEADER_LENGTH; + +/** + * @author Chuanyi Li + */ +@Aspect +public class OutboundThroughputAspect { + private static final Logger logger = LoggerFactory.getLogger(OutboundThroughputAspect.class); + + /** + * Support highly scalable counters + * @see ConcurrentAutoTable + */ + private static final ConcurrentAutoTable total = new ConcurrentAutoTable(); + + private static final Collector collector = new OutboundThroughputCollector(); + + public static Collector getCollector() { + return collector; + } + + @Pointcut("call(* com.alibaba.otter.canal.server.netty.NettyUtils.write(..))") + public void write() {} + + //nested read, just eliminate them. + @Pointcut("withincode(* com.alibaba.otter.canal.server.netty.NettyUtils.write(..))") + public void nestedCall() {} + + @After("write() && !nestedCall() && args(ch, bytes, ..)") + public void recordWriteBytes(Channel ch, byte[] bytes) { + if (bytes != null) { + accumulateBytes(HEADER_LENGTH + bytes.length); + } + } + + @After("write() && !nestedCall() && args(ch, buf, ..)") + public void recordWriteBuffer(Channel ch, ByteBuffer buf) { + if (buf != null) { + total.add(HEADER_LENGTH + buf.limit()); + } + } + private void accumulateBytes(int count) { + try { + total.add(count); + } catch (Throwable t) { + //Catch every Throwable, rather than break the business logic. + logger.warn("Error while accumulate inbound bytes.", t); + } + } + + public static class OutboundThroughputCollector extends Collector { + + private OutboundThroughputCollector() {} + + @Override public List collect() { + List mfs = new ArrayList(); + CounterMetricFamily bytes = new CounterMetricFamily("canal_net_outbound_bytes", + "Total socket outbound bytes of canal server.", + total.get()); + mfs.add(bytes); + return mfs; + } + } +} diff --git a/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/PrometheusCanalEventDownStreamHandler.java b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/PrometheusCanalEventDownStreamHandler.java new file mode 100644 index 00000000..c55a7eac --- /dev/null +++ b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/PrometheusCanalEventDownStreamHandler.java @@ -0,0 +1,73 @@ +package com.alibaba.otter.canal.prometheus.impl; + +import com.alibaba.otter.canal.prometheus.CanalInstanceExports; +import com.alibaba.otter.canal.sink.AbstractCanalEventDownStreamHandler; +import com.alibaba.otter.canal.store.model.Event; +import io.prometheus.client.Collector; +import io.prometheus.client.GaugeMetricFamily; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * @author Chuanyi Li + */ +public class PrometheusCanalEventDownStreamHandler extends AbstractCanalEventDownStreamHandler> { + + private final Collector collector; + + private long latestExecuteTime = 0L; + + private static final String DELAY_NAME = "canal_instance_traffic_delay"; + + private final String delayHelpName; + + private final List labelValues; + + public PrometheusCanalEventDownStreamHandler(final String destination) { + this.delayHelpName = "Traffic delay of canal instance " + destination + " in seconds."; + this.labelValues = Collections.singletonList(destination); + collector = new Collector() { + @Override + public List collect() { + List mfs = new ArrayList(); + long now = System.currentTimeMillis(); + GaugeMetricFamily delay = new GaugeMetricFamily( + DELAY_NAME, + delayHelpName, + CanalInstanceExports.labelList); + double d = 0.0; + if (latestExecuteTime > 0) { + d = now - latestExecuteTime; + } + d = d > 0.0 ? (d / 1000) : 0.0; + delay.addMetric(labelValues, d); + mfs.add(delay); + return mfs; + } + }; + } + + @Override + public List before(List events) { + // TODO utilize MySQL master heartbeat packet to refresh delay if always no more events coming + // see: https://dev.mysql.com/worklog/task/?id=342 + // heartbeats are sent by the master only if there is no + // more unsent events in the actual binlog file for a period longer that + // master_heartbeat_period. + if (events != null && !events.isEmpty()) { + Event last = events.get(events.size() - 1); + long ts = last.getExecuteTime(); + if (ts > latestExecuteTime) { + latestExecuteTime = ts; + } + } + return events; + } + + public Collector getCollector() { + return this.collector; + } + +} diff --git a/prometheus/src/main/resources/META-INF/aop.xml b/prometheus/src/main/resources/META-INF/aop.xml new file mode 100644 index 00000000..8bd31d0c --- /dev/null +++ b/prometheus/src/main/resources/META-INF/aop.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/prometheus/src/main/resources/META-INF/services/com.alibaba.otter.canal.spi.CanalMetricsProvider b/prometheus/src/main/resources/META-INF/services/com.alibaba.otter.canal.spi.CanalMetricsProvider new file mode 100644 index 00000000..9adbf8d1 --- /dev/null +++ b/prometheus/src/main/resources/META-INF/services/com.alibaba.otter.canal.spi.CanalMetricsProvider @@ -0,0 +1 @@ +com.alibaba.otter.canal.prometheus.PrometheusProvider diff --git a/protocol/src/main/java/com/alibaba/otter/canal/protocol/CanalEntry.java b/protocol/src/main/java/com/alibaba/otter/canal/protocol/CanalEntry.java index d802f54e..1a0979db 100644 --- a/protocol/src/main/java/com/alibaba/otter/canal/protocol/CanalEntry.java +++ b/protocol/src/main/java/com/alibaba/otter/canal/protocol/CanalEntry.java @@ -4,11 +4,13 @@ package com.alibaba.otter.canal.protocol; public final class CanalEntry { - private CanalEntry() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - + + private CanalEntry(){ + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + } + /** * Protobuf enum {@code com.alibaba.otter.canal.protocol.EntryType} * @@ -16,20 +18,19 @@ public final class CanalEntry { * *打散后的事件类型,主要用于标识事务的开始,变更数据,结束* * */ - public enum EntryType - implements com.google.protobuf.ProtocolMessageEnum { - /** - * TRANSACTIONBEGIN = 1; - */ - TRANSACTIONBEGIN(0, 1), - /** - * ROWDATA = 2; - */ - ROWDATA(1, 2), - /** - * TRANSACTIONEND = 3; - */ - TRANSACTIONEND(2, 3), + public enum EntryType implements com.google.protobuf.ProtocolMessageEnum { + /** + * TRANSACTIONBEGIN = 1; + */ + TRANSACTIONBEGIN(0, 1), + /** + * ROWDATA = 2; + */ + ROWDATA(1, 2), + /** + * TRANSACTIONEND = 3; + */ + TRANSACTIONEND(2, 3), /** * HEARTBEAT = 4; * @@ -37,25 +38,24 @@ public final class CanalEntry { * * 心跳类型,内部使用,外部暂不可见,可忽略 * * */ - HEARTBEAT(3, 4), - /** - * GTIDLOG = 5; - */ - GTIDLOG(4, 5), - ; + HEARTBEAT(3, 4), + /** + * GTIDLOG = 5; + */ + GTIDLOG(4, 5), ; - /** - * TRANSACTIONBEGIN = 1; - */ - public static final int TRANSACTIONBEGIN_VALUE = 1; - /** - * ROWDATA = 2; - */ - public static final int ROWDATA_VALUE = 2; - /** - * TRANSACTIONEND = 3; - */ - public static final int TRANSACTIONEND_VALUE = 3; + /** + * TRANSACTIONBEGIN = 1; + */ + public static final int TRANSACTIONBEGIN_VALUE = 1; + /** + * ROWDATA = 2; + */ + public static final int ROWDATA_VALUE = 2; + /** + * TRANSACTIONEND = 3; + */ + public static final int TRANSACTIONEND_VALUE = 3; /** * HEARTBEAT = 4; * @@ -63,72 +63,75 @@ public final class CanalEntry { * * 心跳类型,内部使用,外部暂不可见,可忽略 * * */ - public static final int HEARTBEAT_VALUE = 4; - /** - * GTIDLOG = 5; - */ - public static final int GTIDLOG_VALUE = 5; + public static final int HEARTBEAT_VALUE = 4; + /** + * GTIDLOG = 5; + */ + public static final int GTIDLOG_VALUE = 5; + public final int getNumber() { + return value; + } - public final int getNumber() { return value; } - - public static EntryType valueOf(int value) { - switch (value) { - case 1: return TRANSACTIONBEGIN; - case 2: return ROWDATA; - case 3: return TRANSACTIONEND; - case 4: return HEARTBEAT; - case 5: return GTIDLOG; - default: return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; - } - private static com.google.protobuf.Internal.EnumLiteMap - internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public EntryType findValueByNumber(int number) { - return EntryType.valueOf(number); + public static EntryType valueOf(int value) { + switch (value) { + case 1: + return TRANSACTIONBEGIN; + case 2: + return ROWDATA; + case 3: + return TRANSACTIONEND; + case 4: + return HEARTBEAT; + case 5: + return GTIDLOG; + default: + return null; } - }; + } - public final com.google.protobuf.Descriptors.EnumValueDescriptor - getValueDescriptor() { - return getDescriptor().getValues().get(index); + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static com.google.protobuf.Internal.EnumLiteMap internalValueMap = new com.google.protobuf.Internal.EnumLiteMap() { + + public EntryType findValueByNumber(int number) { + return EntryType.valueOf(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + return getDescriptor().getValues().get(index); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.alibaba.otter.canal.protocol.CanalEntry.getDescriptor().getEnumTypes().get(0); + } + + private static final EntryType[] VALUES = values(); + + public static EntryType valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + return VALUES[desc.getIndex()]; + } + + private final int index; + private final int value; + + private EntryType(int index, int value){ + this.index = index; + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:com.alibaba.otter.canal.protocol.EntryType) } - public final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptorForType() { - return getDescriptor(); - } - public static final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptor() { - return com.alibaba.otter.canal.protocol.CanalEntry.getDescriptor().getEnumTypes().get(0); - } - - private static final EntryType[] VALUES = values(); - - public static EntryType valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException( - "EnumValueDescriptor is not for this type."); - } - return VALUES[desc.getIndex()]; - } - - private final int index; - private final int value; - - private EntryType(int index, int value) { - this.index = index; - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:com.alibaba.otter.canal.protocol.EntryType) - } /** * Protobuf enum {@code com.alibaba.otter.canal.protocol.EventType} @@ -137,226 +140,238 @@ public final class CanalEntry { * * 事件类型 * * */ - public enum EventType - implements com.google.protobuf.ProtocolMessageEnum { - /** - * INSERT = 1; - */ - INSERT(0, 1), - /** - * UPDATE = 2; - */ - UPDATE(1, 2), - /** - * DELETE = 3; - */ - DELETE(2, 3), - /** - * CREATE = 4; - */ - CREATE(3, 4), - /** - * ALTER = 5; - */ - ALTER(4, 5), - /** - * ERASE = 6; - */ - ERASE(5, 6), - /** - * QUERY = 7; - */ - QUERY(6, 7), - /** - * TRUNCATE = 8; - */ - TRUNCATE(7, 8), - /** - * RENAME = 9; - */ - RENAME(8, 9), - /** - * CINDEX = 10; - * - *
      -     **CREATE INDEX*
      -     * 
      - */ - CINDEX(9, 10), - /** - * DINDEX = 11; - */ - DINDEX(10, 11), - /** - * GTID = 12; - */ - GTID(11, 12), - /** - * XASTART = 13; - * - *
      -     ** XA *
      -     * 
      - */ - XASTART(12, 13), - /** - * XAEND = 14; - */ - XAEND(13, 14), - /** - * XACOMMIT = 15; - */ - XACOMMIT(14, 15), - /** - * XAROLLBACK = 16; - */ - XAROLLBACK(15, 16), - ; + public enum EventType implements com.google.protobuf.ProtocolMessageEnum { + /** + * INSERT = 1; + */ + INSERT(0, 1), + /** + * UPDATE = 2; + */ + UPDATE(1, 2), + /** + * DELETE = 3; + */ + DELETE(2, 3), + /** + * CREATE = 4; + */ + CREATE(3, 4), + /** + * ALTER = 5; + */ + ALTER(4, 5), + /** + * ERASE = 6; + */ + ERASE(5, 6), + /** + * QUERY = 7; + */ + QUERY(6, 7), + /** + * TRUNCATE = 8; + */ + TRUNCATE(7, 8), + /** + * RENAME = 9; + */ + RENAME(8, 9), + /** + * CINDEX = 10; + * + *
      +         * *CREATE INDEX*
      +         * 
      + */ + CINDEX(9, 10), + /** + * DINDEX = 11; + */ + DINDEX(10, 11), + /** + * GTID = 12; + */ + GTID(11, 12), + /** + * XASTART = 13; + * + *
      +         * * XA *
      +         * 
      + */ + XASTART(12, 13), + /** + * XAEND = 14; + */ + XAEND(13, 14), + /** + * XACOMMIT = 15; + */ + XACOMMIT(14, 15), + /** + * XAROLLBACK = 16; + */ + XAROLLBACK(15, 16), ; - /** - * INSERT = 1; - */ - public static final int INSERT_VALUE = 1; - /** - * UPDATE = 2; - */ - public static final int UPDATE_VALUE = 2; - /** - * DELETE = 3; - */ - public static final int DELETE_VALUE = 3; - /** - * CREATE = 4; - */ - public static final int CREATE_VALUE = 4; - /** - * ALTER = 5; - */ - public static final int ALTER_VALUE = 5; - /** - * ERASE = 6; - */ - public static final int ERASE_VALUE = 6; - /** - * QUERY = 7; - */ - public static final int QUERY_VALUE = 7; - /** - * TRUNCATE = 8; - */ - public static final int TRUNCATE_VALUE = 8; - /** - * RENAME = 9; - */ - public static final int RENAME_VALUE = 9; - /** - * CINDEX = 10; - * - *
      -     **CREATE INDEX*
      -     * 
      - */ - public static final int CINDEX_VALUE = 10; - /** - * DINDEX = 11; - */ - public static final int DINDEX_VALUE = 11; - /** - * GTID = 12; - */ - public static final int GTID_VALUE = 12; - /** - * XASTART = 13; - * - *
      -     ** XA *
      -     * 
      - */ - public static final int XASTART_VALUE = 13; - /** - * XAEND = 14; - */ - public static final int XAEND_VALUE = 14; - /** - * XACOMMIT = 15; - */ - public static final int XACOMMIT_VALUE = 15; - /** - * XAROLLBACK = 16; - */ - public static final int XAROLLBACK_VALUE = 16; + /** + * INSERT = 1; + */ + public static final int INSERT_VALUE = 1; + /** + * UPDATE = 2; + */ + public static final int UPDATE_VALUE = 2; + /** + * DELETE = 3; + */ + public static final int DELETE_VALUE = 3; + /** + * CREATE = 4; + */ + public static final int CREATE_VALUE = 4; + /** + * ALTER = 5; + */ + public static final int ALTER_VALUE = 5; + /** + * ERASE = 6; + */ + public static final int ERASE_VALUE = 6; + /** + * QUERY = 7; + */ + public static final int QUERY_VALUE = 7; + /** + * TRUNCATE = 8; + */ + public static final int TRUNCATE_VALUE = 8; + /** + * RENAME = 9; + */ + public static final int RENAME_VALUE = 9; + /** + * CINDEX = 10; + * + *
      +         * *CREATE INDEX*
      +         * 
      + */ + public static final int CINDEX_VALUE = 10; + /** + * DINDEX = 11; + */ + public static final int DINDEX_VALUE = 11; + /** + * GTID = 12; + */ + public static final int GTID_VALUE = 12; + /** + * XASTART = 13; + * + *
      +         * * XA *
      +         * 
      + */ + public static final int XASTART_VALUE = 13; + /** + * XAEND = 14; + */ + public static final int XAEND_VALUE = 14; + /** + * XACOMMIT = 15; + */ + public static final int XACOMMIT_VALUE = 15; + /** + * XAROLLBACK = 16; + */ + public static final int XAROLLBACK_VALUE = 16; + public final int getNumber() { + return value; + } - public final int getNumber() { return value; } - - public static EventType valueOf(int value) { - switch (value) { - case 1: return INSERT; - case 2: return UPDATE; - case 3: return DELETE; - case 4: return CREATE; - case 5: return ALTER; - case 6: return ERASE; - case 7: return QUERY; - case 8: return TRUNCATE; - case 9: return RENAME; - case 10: return CINDEX; - case 11: return DINDEX; - case 12: return GTID; - case 13: return XASTART; - case 14: return XAEND; - case 15: return XACOMMIT; - case 16: return XAROLLBACK; - default: return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; - } - private static com.google.protobuf.Internal.EnumLiteMap - internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public EventType findValueByNumber(int number) { - return EventType.valueOf(number); + public static EventType valueOf(int value) { + switch (value) { + case 1: + return INSERT; + case 2: + return UPDATE; + case 3: + return DELETE; + case 4: + return CREATE; + case 5: + return ALTER; + case 6: + return ERASE; + case 7: + return QUERY; + case 8: + return TRUNCATE; + case 9: + return RENAME; + case 10: + return CINDEX; + case 11: + return DINDEX; + case 12: + return GTID; + case 13: + return XASTART; + case 14: + return XAEND; + case 15: + return XACOMMIT; + case 16: + return XAROLLBACK; + default: + return null; } - }; + } - public final com.google.protobuf.Descriptors.EnumValueDescriptor - getValueDescriptor() { - return getDescriptor().getValues().get(index); + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static com.google.protobuf.Internal.EnumLiteMap internalValueMap = new com.google.protobuf.Internal.EnumLiteMap() { + + public EventType findValueByNumber(int number) { + return EventType.valueOf(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + return getDescriptor().getValues().get(index); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.alibaba.otter.canal.protocol.CanalEntry.getDescriptor().getEnumTypes().get(1); + } + + private static final EventType[] VALUES = values(); + + public static EventType valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + return VALUES[desc.getIndex()]; + } + + private final int index; + private final int value; + + private EventType(int index, int value){ + this.index = index; + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:com.alibaba.otter.canal.protocol.EventType) } - public final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptorForType() { - return getDescriptor(); - } - public static final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptor() { - return com.alibaba.otter.canal.protocol.CanalEntry.getDescriptor().getEnumTypes().get(1); - } - - private static final EventType[] VALUES = values(); - - public static EventType valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException( - "EnumValueDescriptor is not for this type."); - } - return VALUES[desc.getIndex()]; - } - - private final int index; - private final int value; - - private EventType(int index, int value) { - this.index = index; - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:com.alibaba.otter.canal.protocol.EventType) - } /** * Protobuf enum {@code com.alibaba.otter.canal.protocol.Type} @@ -365,97 +380,96 @@ public final class CanalEntry { * *数据库类型* * */ - public enum Type - implements com.google.protobuf.ProtocolMessageEnum { - /** - * ORACLE = 1; - */ - ORACLE(0, 1), - /** - * MYSQL = 2; - */ - MYSQL(1, 2), - /** - * PGSQL = 3; - */ - PGSQL(2, 3), - ; + public enum Type implements com.google.protobuf.ProtocolMessageEnum { + /** + * ORACLE = 1; + */ + ORACLE(0, 1), + /** + * MYSQL = 2; + */ + MYSQL(1, 2), + /** + * PGSQL = 3; + */ + PGSQL(2, 3), ; - /** - * ORACLE = 1; - */ - public static final int ORACLE_VALUE = 1; - /** - * MYSQL = 2; - */ - public static final int MYSQL_VALUE = 2; - /** - * PGSQL = 3; - */ - public static final int PGSQL_VALUE = 3; + /** + * ORACLE = 1; + */ + public static final int ORACLE_VALUE = 1; + /** + * MYSQL = 2; + */ + public static final int MYSQL_VALUE = 2; + /** + * PGSQL = 3; + */ + public static final int PGSQL_VALUE = 3; + public final int getNumber() { + return value; + } - public final int getNumber() { return value; } - - public static Type valueOf(int value) { - switch (value) { - case 1: return ORACLE; - case 2: return MYSQL; - case 3: return PGSQL; - default: return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; - } - private static com.google.protobuf.Internal.EnumLiteMap - internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public Type findValueByNumber(int number) { - return Type.valueOf(number); + public static Type valueOf(int value) { + switch (value) { + case 1: + return ORACLE; + case 2: + return MYSQL; + case 3: + return PGSQL; + default: + return null; } - }; + } - public final com.google.protobuf.Descriptors.EnumValueDescriptor - getValueDescriptor() { - return getDescriptor().getValues().get(index); - } - public final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptorForType() { - return getDescriptor(); - } - public static final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptor() { - return com.alibaba.otter.canal.protocol.CanalEntry.getDescriptor().getEnumTypes().get(2); + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static com.google.protobuf.Internal.EnumLiteMap internalValueMap = new com.google.protobuf.Internal.EnumLiteMap() { + + public Type findValueByNumber(int number) { + return Type.valueOf(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + return getDescriptor().getValues().get(index); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.alibaba.otter.canal.protocol.CanalEntry.getDescriptor().getEnumTypes().get(2); + } + + private static final Type[] VALUES = values(); + + public static Type valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + return VALUES[desc.getIndex()]; + } + + private final int index; + private final int value; + + private Type(int index, int value){ + this.index = index; + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:com.alibaba.otter.canal.protocol.Type) } - private static final Type[] VALUES = values(); - - public static Type valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException( - "EnumValueDescriptor is not for this type."); - } - return VALUES[desc.getIndex()]; - } - - private final int index; - private final int value; - - private Type(int index, int value) { - this.index = index; - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:com.alibaba.otter.canal.protocol.Type) - } - - public interface EntryOrBuilder extends - // @@protoc_insertion_point(interface_extends:com.alibaba.otter.canal.protocol.Entry) - com.google.protobuf.MessageOrBuilder { + public interface EntryOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.alibaba.otter.canal.protocol.Entry) + com.google.protobuf.MessageOrBuilder { /** * optional .com.alibaba.otter.canal.protocol.Header header = 1; @@ -464,8 +478,8 @@ public final class CanalEntry { * *协议头部信息* * */ - boolean hasHeader(); - + boolean hasHeader(); + /** * optional .com.alibaba.otter.canal.protocol.Header header = 1; * @@ -473,8 +487,8 @@ public final class CanalEntry { * *协议头部信息* * */ - com.alibaba.otter.canal.protocol.CanalEntry.Header getHeader(); - + com.alibaba.otter.canal.protocol.CanalEntry.Header getHeader(); + /** * optional .com.alibaba.otter.canal.protocol.Header header = 1; * @@ -482,7 +496,7 @@ public final class CanalEntry { * *协议头部信息* * */ - com.alibaba.otter.canal.protocol.CanalEntry.HeaderOrBuilder getHeaderOrBuilder(); + com.alibaba.otter.canal.protocol.CanalEntry.HeaderOrBuilder getHeaderOrBuilder(); /** * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; @@ -491,8 +505,8 @@ public final class CanalEntry { * *打散后的事件类型* * */ - boolean hasEntryType(); - + boolean hasEntryType(); + /** * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; * @@ -500,7 +514,7 @@ public final class CanalEntry { * *打散后的事件类型* * */ - com.alibaba.otter.canal.protocol.CanalEntry.EntryType getEntryType(); + com.alibaba.otter.canal.protocol.CanalEntry.EntryType getEntryType(); /** * optional bytes storeValue = 3; @@ -509,8 +523,8 @@ public final class CanalEntry { * *传输的二进制数组* * */ - boolean hasStoreValue(); - + boolean hasStoreValue(); + /** * optional bytes storeValue = 3; * @@ -518,9 +532,9 @@ public final class CanalEntry { * *传输的二进制数组* * */ - com.google.protobuf.ByteString getStoreValue(); - } - + com.google.protobuf.ByteString getStoreValue(); + } + /** * Protobuf type {@code com.alibaba.otter.canal.protocol.Entry} * @@ -531,127 +545,126 @@ public final class CanalEntry { *************************************************************** * */ - public static final class Entry extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:com.alibaba.otter.canal.protocol.Entry) - EntryOrBuilder { - // Use Entry.newBuilder() to construct. - private Entry(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private Entry(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + public static final class Entry extends com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:com.alibaba.otter.canal.protocol.Entry) + EntryOrBuilder { - private static final Entry defaultInstance; - public static Entry getDefaultInstance() { - return defaultInstance; - } - - public Entry getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private Entry( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - com.alibaba.otter.canal.protocol.CanalEntry.Header.Builder subBuilder = null; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - subBuilder = header_.toBuilder(); - } - header_ = input.readMessage(com.alibaba.otter.canal.protocol.CanalEntry.Header.PARSER, extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(header_); - header_ = subBuilder.buildPartial(); - } - bitField0_ |= 0x00000001; - break; - } - case 16: { - int rawValue = input.readEnum(); - com.alibaba.otter.canal.protocol.CanalEntry.EntryType value = com.alibaba.otter.canal.protocol.CanalEntry.EntryType.valueOf(rawValue); - if (value == null) { - unknownFields.mergeVarintField(2, rawValue); - } else { - bitField0_ |= 0x00000002; - entryType_ = value; - } - break; - } - case 26: { - bitField0_ |= 0x00000004; - storeValue_ = input.readBytes(); - break; - } - } + // Use Entry.newBuilder() to construct. + private Entry(com.google.protobuf.GeneratedMessage.Builder builder){ + super(builder); + this.unknownFields = builder.getUnknownFields(); } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Entry_descriptor; - } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Entry_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.alibaba.otter.canal.protocol.CanalEntry.Entry.class, com.alibaba.otter.canal.protocol.CanalEntry.Entry.Builder.class); - } + private Entry(boolean noInit){ + this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public Entry parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Entry(input, extensionRegistry); - } - }; + private static final Entry defaultInstance; - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } + public static Entry getDefaultInstance() { + return defaultInstance; + } + + public Entry getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private Entry(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException{ + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + com.alibaba.otter.canal.protocol.CanalEntry.Header.Builder subBuilder = null; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + subBuilder = header_.toBuilder(); + } + header_ = input.readMessage(com.alibaba.otter.canal.protocol.CanalEntry.Header.PARSER, + extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(header_); + header_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000001; + break; + } + case 16: { + int rawValue = input.readEnum(); + com.alibaba.otter.canal.protocol.CanalEntry.EntryType value = com.alibaba.otter.canal.protocol.CanalEntry.EntryType.valueOf(rawValue); + if (value == null) { + unknownFields.mergeVarintField(2, rawValue); + } else { + bitField0_ |= 0x00000002; + entryType_ = value; + } + break; + } + case 26: { + bitField0_ |= 0x00000004; + storeValue_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Entry_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Entry_fieldAccessorTable.ensureFieldAccessorsInitialized(com.alibaba.otter.canal.protocol.CanalEntry.Entry.class, + com.alibaba.otter.canal.protocol.CanalEntry.Entry.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + + public Entry parsePartialFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Entry(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + public static final int HEADER_FIELD_NUMBER = 1; + private com.alibaba.otter.canal.protocol.CanalEntry.Header header_; - private int bitField0_; - public static final int HEADER_FIELD_NUMBER = 1; - private com.alibaba.otter.canal.protocol.CanalEntry.Header header_; - /** * optional .com.alibaba.otter.canal.protocol.Header header = 1; * @@ -659,10 +672,10 @@ public final class CanalEntry { * *协议头部信息* * */ - public boolean hasHeader() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - + public boolean hasHeader() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** * optional .com.alibaba.otter.canal.protocol.Header header = 1; * @@ -670,10 +683,10 @@ public final class CanalEntry { * *协议头部信息* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.Header getHeader() { - return header_; - } - + public com.alibaba.otter.canal.protocol.CanalEntry.Header getHeader() { + return header_; + } + /** * optional .com.alibaba.otter.canal.protocol.Header header = 1; * @@ -681,13 +694,13 @@ public final class CanalEntry { * *协议头部信息* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.HeaderOrBuilder getHeaderOrBuilder() { - return header_; - } + public com.alibaba.otter.canal.protocol.CanalEntry.HeaderOrBuilder getHeaderOrBuilder() { + return header_; + } + + public static final int ENTRYTYPE_FIELD_NUMBER = 2; + private com.alibaba.otter.canal.protocol.CanalEntry.EntryType entryType_; - public static final int ENTRYTYPE_FIELD_NUMBER = 2; - private com.alibaba.otter.canal.protocol.CanalEntry.EntryType entryType_; - /** * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; * @@ -695,10 +708,10 @@ public final class CanalEntry { * *打散后的事件类型* * */ - public boolean hasEntryType() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - + public boolean hasEntryType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; * @@ -706,13 +719,13 @@ public final class CanalEntry { * *打散后的事件类型* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.EntryType getEntryType() { - return entryType_; - } + public com.alibaba.otter.canal.protocol.CanalEntry.EntryType getEntryType() { + return entryType_; + } + + public static final int STOREVALUE_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString storeValue_; - public static final int STOREVALUE_FIELD_NUMBER = 3; - private com.google.protobuf.ByteString storeValue_; - /** * optional bytes storeValue = 3; * @@ -720,10 +733,10 @@ public final class CanalEntry { * *传输的二进制数组* * */ - public boolean hasStoreValue() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - + public boolean hasStoreValue() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** * optional bytes storeValue = 3; * @@ -731,137 +744,146 @@ public final class CanalEntry { * *传输的二进制数组* * */ - public com.google.protobuf.ByteString getStoreValue() { - return storeValue_; - } + public com.google.protobuf.ByteString getStoreValue() { + return storeValue_; + } - private void initFields() { - header_ = com.alibaba.otter.canal.protocol.CanalEntry.Header.getDefaultInstance(); - entryType_ = com.alibaba.otter.canal.protocol.CanalEntry.EntryType.ROWDATA; - storeValue_ = com.google.protobuf.ByteString.EMPTY; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; + private void initFields() { + header_ = com.alibaba.otter.canal.protocol.CanalEntry.Header.getDefaultInstance(); + entryType_ = com.alibaba.otter.canal.protocol.CanalEntry.EntryType.ROWDATA; + storeValue_ = com.google.protobuf.ByteString.EMPTY; + } - memoizedIsInitialized = 1; - return true; - } + private byte memoizedIsInitialized = -1; - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeMessage(1, header_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeEnum(2, entryType_.getNumber()); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeBytes(3, storeValue_); - } - getUnknownFields().writeTo(output); - } + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; + memoizedIsInitialized = 1; + return true; + } - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, header_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeEnumSize(2, entryType_.getNumber()); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(3, storeValue_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeMessage(1, header_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeEnum(2, entryType_.getNumber()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeBytes(3, storeValue_); + } + getUnknownFields().writeTo(output); + } - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } + private int memoizedSerializedSize = -1; - public static com.alibaba.otter.canal.protocol.CanalEntry.Entry parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Entry parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Entry parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Entry parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Entry parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Entry parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Entry parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Entry parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Entry parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Entry parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(com.alibaba.otter.canal.protocol.CanalEntry.Entry prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, header_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(2, entryType_.getNumber()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(3, storeValue_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + + @java.lang.Override + protected java.lang.Object writeReplace() throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Entry parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Entry parseFrom(com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Entry parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Entry parseFrom(byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Entry parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Entry parseFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Entry parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Entry parseDelimitedFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Entry parseFrom(com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Entry parseFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { + return Builder.create(); + } + + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder(com.alibaba.otter.canal.protocol.CanalEntry.Entry prototype) { + return newBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return newBuilder(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** * Protobuf type {@code com.alibaba.otter.canal.protocol.Entry} * @@ -872,153 +894,150 @@ public final class CanalEntry { *************************************************************** * */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements // @@protoc_insertion_point(builder_implements:com.alibaba.otter.canal.protocol.Entry) com.alibaba.otter.canal.protocol.CanalEntry.EntryOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Entry_descriptor; - } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Entry_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.alibaba.otter.canal.protocol.CanalEntry.Entry.class, com.alibaba.otter.canal.protocol.CanalEntry.Entry.Builder.class); - } + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Entry_descriptor; + } - // Construct using com.alibaba.otter.canal.protocol.CanalEntry.Entry.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Entry_fieldAccessorTable.ensureFieldAccessorsInitialized(com.alibaba.otter.canal.protocol.CanalEntry.Entry.class, + com.alibaba.otter.canal.protocol.CanalEntry.Entry.Builder.class); + } - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getHeaderFieldBuilder(); - } - } - private static Builder create() { - return new Builder(); - } + // Construct using + // com.alibaba.otter.canal.protocol.CanalEntry.Entry.newBuilder() + private Builder(){ + maybeForceBuilderInitialization(); + } - public Builder clear() { - super.clear(); - if (headerBuilder_ == null) { - header_ = com.alibaba.otter.canal.protocol.CanalEntry.Header.getDefaultInstance(); - } else { - headerBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000001); - entryType_ = com.alibaba.otter.canal.protocol.CanalEntry.EntryType.ROWDATA; - bitField0_ = (bitField0_ & ~0x00000002); - storeValue_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000004); - return this; - } + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent){ + super(parent); + maybeForceBuilderInitialization(); + } - public Builder clone() { - return create().mergeFrom(buildPartial()); - } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getHeaderFieldBuilder(); + } + } - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Entry_descriptor; - } + private static Builder create() { + return new Builder(); + } - public com.alibaba.otter.canal.protocol.CanalEntry.Entry getDefaultInstanceForType() { - return com.alibaba.otter.canal.protocol.CanalEntry.Entry.getDefaultInstance(); - } + public Builder clear() { + super.clear(); + if (headerBuilder_ == null) { + header_ = com.alibaba.otter.canal.protocol.CanalEntry.Header.getDefaultInstance(); + } else { + headerBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + entryType_ = com.alibaba.otter.canal.protocol.CanalEntry.EntryType.ROWDATA; + bitField0_ = (bitField0_ & ~0x00000002); + storeValue_ = com.google.protobuf.ByteString.EMPTY; + bitField0_ = (bitField0_ & ~0x00000004); + return this; + } - public com.alibaba.otter.canal.protocol.CanalEntry.Entry build() { - com.alibaba.otter.canal.protocol.CanalEntry.Entry result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } + public Builder clone() { + return create().mergeFrom(buildPartial()); + } - public com.alibaba.otter.canal.protocol.CanalEntry.Entry buildPartial() { - com.alibaba.otter.canal.protocol.CanalEntry.Entry result = new com.alibaba.otter.canal.protocol.CanalEntry.Entry(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - if (headerBuilder_ == null) { - result.header_ = header_; - } else { - result.header_ = headerBuilder_.build(); - } - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.entryType_ = entryType_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000004; - } - result.storeValue_ = storeValue_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Entry_descriptor; + } - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.alibaba.otter.canal.protocol.CanalEntry.Entry) { - return mergeFrom((com.alibaba.otter.canal.protocol.CanalEntry.Entry)other); - } else { - super.mergeFrom(other); - return this; - } - } + public com.alibaba.otter.canal.protocol.CanalEntry.Entry getDefaultInstanceForType() { + return com.alibaba.otter.canal.protocol.CanalEntry.Entry.getDefaultInstance(); + } - public Builder mergeFrom(com.alibaba.otter.canal.protocol.CanalEntry.Entry other) { - if (other == com.alibaba.otter.canal.protocol.CanalEntry.Entry.getDefaultInstance()) return this; - if (other.hasHeader()) { - mergeHeader(other.getHeader()); - } - if (other.hasEntryType()) { - setEntryType(other.getEntryType()); - } - if (other.hasStoreValue()) { - setStoreValue(other.getStoreValue()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } + public com.alibaba.otter.canal.protocol.CanalEntry.Entry build() { + com.alibaba.otter.canal.protocol.CanalEntry.Entry result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } - public final boolean isInitialized() { - return true; - } + public com.alibaba.otter.canal.protocol.CanalEntry.Entry buildPartial() { + com.alibaba.otter.canal.protocol.CanalEntry.Entry result = new com.alibaba.otter.canal.protocol.CanalEntry.Entry(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + if (headerBuilder_ == null) { + result.header_ = header_; + } else { + result.header_ = headerBuilder_.build(); + } + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.entryType_ = entryType_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + result.storeValue_ = storeValue_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.alibaba.otter.canal.protocol.CanalEntry.Entry parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.alibaba.otter.canal.protocol.CanalEntry.Entry) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.alibaba.otter.canal.protocol.CanalEntry.Entry) { + return mergeFrom((com.alibaba.otter.canal.protocol.CanalEntry.Entry) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.alibaba.otter.canal.protocol.CanalEntry.Entry other) { + if (other == com.alibaba.otter.canal.protocol.CanalEntry.Entry.getDefaultInstance()) return this; + if (other.hasHeader()) { + mergeHeader(other.getHeader()); + } + if (other.hasEntryType()) { + setEntryType(other.getEntryType()); + } + if (other.hasStoreValue()) { + setStoreValue(other.getStoreValue()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.alibaba.otter.canal.protocol.CanalEntry.Entry parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.alibaba.otter.canal.protocol.CanalEntry.Entry) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private com.alibaba.otter.canal.protocol.CanalEntry.Header header_ = com.alibaba.otter.canal.protocol.CanalEntry.Header.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder headerBuilder_; - private com.alibaba.otter.canal.protocol.CanalEntry.Header header_ = com.alibaba.otter.canal.protocol.CanalEntry.Header.getDefaultInstance(); - private com.google.protobuf.SingleFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Header, com.alibaba.otter.canal.protocol.CanalEntry.Header.Builder, com.alibaba.otter.canal.protocol.CanalEntry.HeaderOrBuilder> headerBuilder_; - /** * optional .com.alibaba.otter.canal.protocol.Header header = 1; * @@ -1026,10 +1045,10 @@ public final class CanalEntry { * *协议头部信息* * */ - public boolean hasHeader() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - + public boolean hasHeader() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** * optional .com.alibaba.otter.canal.protocol.Header header = 1; * @@ -1037,14 +1056,14 @@ public final class CanalEntry { * *协议头部信息* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.Header getHeader() { - if (headerBuilder_ == null) { - return header_; - } else { - return headerBuilder_.getMessage(); - } - } - + public com.alibaba.otter.canal.protocol.CanalEntry.Header getHeader() { + if (headerBuilder_ == null) { + return header_; + } else { + return headerBuilder_.getMessage(); + } + } + /** * optional .com.alibaba.otter.canal.protocol.Header header = 1; * @@ -1052,20 +1071,20 @@ public final class CanalEntry { * *协议头部信息* * */ - public Builder setHeader(com.alibaba.otter.canal.protocol.CanalEntry.Header value) { - if (headerBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - header_ = value; - onChanged(); - } else { - headerBuilder_.setMessage(value); - } - bitField0_ |= 0x00000001; - return this; - } - + public Builder setHeader(com.alibaba.otter.canal.protocol.CanalEntry.Header value) { + if (headerBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + header_ = value; + onChanged(); + } else { + headerBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + return this; + } + /** * optional .com.alibaba.otter.canal.protocol.Header header = 1; * @@ -1073,18 +1092,17 @@ public final class CanalEntry { * *协议头部信息* * */ - public Builder setHeader( - com.alibaba.otter.canal.protocol.CanalEntry.Header.Builder builderForValue) { - if (headerBuilder_ == null) { - header_ = builderForValue.build(); - onChanged(); - } else { - headerBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00000001; - return this; - } - + public Builder setHeader(com.alibaba.otter.canal.protocol.CanalEntry.Header.Builder builderForValue) { + if (headerBuilder_ == null) { + header_ = builderForValue.build(); + onChanged(); + } else { + headerBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + return this; + } + /** * optional .com.alibaba.otter.canal.protocol.Header header = 1; * @@ -1092,23 +1110,24 @@ public final class CanalEntry { * *协议头部信息* * */ - public Builder mergeHeader(com.alibaba.otter.canal.protocol.CanalEntry.Header value) { - if (headerBuilder_ == null) { - if (((bitField0_ & 0x00000001) == 0x00000001) && - header_ != com.alibaba.otter.canal.protocol.CanalEntry.Header.getDefaultInstance()) { - header_ = - com.alibaba.otter.canal.protocol.CanalEntry.Header.newBuilder(header_).mergeFrom(value).buildPartial(); - } else { - header_ = value; - } - onChanged(); - } else { - headerBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00000001; - return this; - } - + public Builder mergeHeader(com.alibaba.otter.canal.protocol.CanalEntry.Header value) { + if (headerBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001) + && header_ != com.alibaba.otter.canal.protocol.CanalEntry.Header.getDefaultInstance()) { + header_ = com.alibaba.otter.canal.protocol.CanalEntry.Header.newBuilder(header_) + .mergeFrom(value) + .buildPartial(); + } else { + header_ = value; + } + onChanged(); + } else { + headerBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000001; + return this; + } + /** * optional .com.alibaba.otter.canal.protocol.Header header = 1; * @@ -1116,17 +1135,17 @@ public final class CanalEntry { * *协议头部信息* * */ - public Builder clearHeader() { - if (headerBuilder_ == null) { - header_ = com.alibaba.otter.canal.protocol.CanalEntry.Header.getDefaultInstance(); - onChanged(); - } else { - headerBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000001); - return this; - } - + public Builder clearHeader() { + if (headerBuilder_ == null) { + header_ = com.alibaba.otter.canal.protocol.CanalEntry.Header.getDefaultInstance(); + onChanged(); + } else { + headerBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + /** * optional .com.alibaba.otter.canal.protocol.Header header = 1; * @@ -1134,12 +1153,12 @@ public final class CanalEntry { * *协议头部信息* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.Header.Builder getHeaderBuilder() { - bitField0_ |= 0x00000001; - onChanged(); - return getHeaderFieldBuilder().getBuilder(); - } - + public com.alibaba.otter.canal.protocol.CanalEntry.Header.Builder getHeaderBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getHeaderFieldBuilder().getBuilder(); + } + /** * optional .com.alibaba.otter.canal.protocol.Header header = 1; * @@ -1147,14 +1166,14 @@ public final class CanalEntry { * *协议头部信息* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.HeaderOrBuilder getHeaderOrBuilder() { - if (headerBuilder_ != null) { - return headerBuilder_.getMessageOrBuilder(); - } else { - return header_; - } - } - + public com.alibaba.otter.canal.protocol.CanalEntry.HeaderOrBuilder getHeaderOrBuilder() { + if (headerBuilder_ != null) { + return headerBuilder_.getMessageOrBuilder(); + } else { + return header_; + } + } + /** * optional .com.alibaba.otter.canal.protocol.Header header = 1; * @@ -1162,22 +1181,18 @@ public final class CanalEntry { * *协议头部信息* * */ - private com.google.protobuf.SingleFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Header, com.alibaba.otter.canal.protocol.CanalEntry.Header.Builder, com.alibaba.otter.canal.protocol.CanalEntry.HeaderOrBuilder> - getHeaderFieldBuilder() { - if (headerBuilder_ == null) { - headerBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Header, com.alibaba.otter.canal.protocol.CanalEntry.Header.Builder, com.alibaba.otter.canal.protocol.CanalEntry.HeaderOrBuilder>( - getHeader(), - getParentForChildren(), - isClean()); - header_ = null; - } - return headerBuilder_; - } + private com.google.protobuf.SingleFieldBuilder getHeaderFieldBuilder() { + if (headerBuilder_ == null) { + headerBuilder_ = new com.google.protobuf.SingleFieldBuilder(getHeader(), + getParentForChildren(), + isClean()); + header_ = null; + } + return headerBuilder_; + } + + private com.alibaba.otter.canal.protocol.CanalEntry.EntryType entryType_ = com.alibaba.otter.canal.protocol.CanalEntry.EntryType.ROWDATA; - private com.alibaba.otter.canal.protocol.CanalEntry.EntryType entryType_ = com.alibaba.otter.canal.protocol.CanalEntry.EntryType.ROWDATA; - /** * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; * @@ -1185,10 +1200,10 @@ public final class CanalEntry { * *打散后的事件类型* * */ - public boolean hasEntryType() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - + public boolean hasEntryType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; * @@ -1196,10 +1211,10 @@ public final class CanalEntry { * *打散后的事件类型* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.EntryType getEntryType() { - return entryType_; - } - + public com.alibaba.otter.canal.protocol.CanalEntry.EntryType getEntryType() { + return entryType_; + } + /** * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; * @@ -1207,99 +1222,99 @@ public final class CanalEntry { * *打散后的事件类型* * */ - public Builder setEntryType(com.alibaba.otter.canal.protocol.CanalEntry.EntryType value) { - if (value == null) { - throw new NullPointerException(); + public Builder setEntryType(com.alibaba.otter.canal.protocol.CanalEntry.EntryType value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + entryType_ = value; + onChanged(); + return this; + } + + /** + * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; + * + *
      +             * *打散后的事件类型*
      +             * 
      + */ + public Builder clearEntryType() { + bitField0_ = (bitField0_ & ~0x00000002); + entryType_ = com.alibaba.otter.canal.protocol.CanalEntry.EntryType.ROWDATA; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString storeValue_ = com.google.protobuf.ByteString.EMPTY; + + /** + * optional bytes storeValue = 3; + * + *
      +             * *传输的二进制数组*
      +             * 
      + */ + public boolean hasStoreValue() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + + /** + * optional bytes storeValue = 3; + * + *
      +             * *传输的二进制数组*
      +             * 
      + */ + public com.google.protobuf.ByteString getStoreValue() { + return storeValue_; + } + + /** + * optional bytes storeValue = 3; + * + *
      +             * *传输的二进制数组*
      +             * 
      + */ + public Builder setStoreValue(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + storeValue_ = value; + onChanged(); + return this; + } + + /** + * optional bytes storeValue = 3; + * + *
      +             * *传输的二进制数组*
      +             * 
      + */ + public Builder clearStoreValue() { + bitField0_ = (bitField0_ & ~0x00000004); + storeValue_ = getDefaultInstance().getStoreValue(); + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.Entry) } - bitField0_ |= 0x00000002; - entryType_ = value; - onChanged(); - return this; - } - - /** - * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; - * - *
      -             * *打散后的事件类型*
      -             * 
      - */ - public Builder clearEntryType() { - bitField0_ = (bitField0_ & ~0x00000002); - entryType_ = com.alibaba.otter.canal.protocol.CanalEntry.EntryType.ROWDATA; - onChanged(); - return this; - } - private com.google.protobuf.ByteString storeValue_ = com.google.protobuf.ByteString.EMPTY; - - /** - * optional bytes storeValue = 3; - * - *
      -             * *传输的二进制数组*
      -             * 
      - */ - public boolean hasStoreValue() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - - /** - * optional bytes storeValue = 3; - * - *
      -             * *传输的二进制数组*
      -             * 
      - */ - public com.google.protobuf.ByteString getStoreValue() { - return storeValue_; - } - - /** - * optional bytes storeValue = 3; - * - *
      -             * *传输的二进制数组*
      -             * 
      - */ - public Builder setStoreValue(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000004; - storeValue_ = value; - onChanged(); - return this; - } - - /** - * optional bytes storeValue = 3; - * - *
      -             * *传输的二进制数组*
      -             * 
      - */ - public Builder clearStoreValue() { - bitField0_ = (bitField0_ & ~0x00000004); - storeValue_ = getDefaultInstance().getStoreValue(); - onChanged(); - return this; - } + static { + defaultInstance = new Entry(true); + defaultInstance.initFields(); + } - // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.Entry) + // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.Entry) } - static { - defaultInstance = new Entry(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.Entry) - } - - public interface HeaderOrBuilder extends - // @@protoc_insertion_point(interface_extends:com.alibaba.otter.canal.protocol.Header) - com.google.protobuf.MessageOrBuilder { + public interface HeaderOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.alibaba.otter.canal.protocol.Header) + com.google.protobuf.MessageOrBuilder { /** * optional int32 version = 1 [default = 1]; @@ -1308,8 +1323,8 @@ public final class CanalEntry { * *协议的版本号* * */ - boolean hasVersion(); - + boolean hasVersion(); + /** * optional int32 version = 1 [default = 1]; * @@ -1317,7 +1332,7 @@ public final class CanalEntry { * *协议的版本号* * */ - int getVersion(); + int getVersion(); /** * optional string logfileName = 2; @@ -1326,8 +1341,8 @@ public final class CanalEntry { * *binlog/redolog 文件名* * */ - boolean hasLogfileName(); - + boolean hasLogfileName(); + /** * optional string logfileName = 2; * @@ -1335,8 +1350,8 @@ public final class CanalEntry { * *binlog/redolog 文件名* * */ - java.lang.String getLogfileName(); - + java.lang.String getLogfileName(); + /** * optional string logfileName = 2; * @@ -1344,8 +1359,7 @@ public final class CanalEntry { * *binlog/redolog 文件名* * */ - com.google.protobuf.ByteString - getLogfileNameBytes(); + com.google.protobuf.ByteString getLogfileNameBytes(); /** * optional int64 logfileOffset = 3; @@ -1354,8 +1368,8 @@ public final class CanalEntry { * *binlog/redolog 文件的偏移位置* * */ - boolean hasLogfileOffset(); - + boolean hasLogfileOffset(); + /** * optional int64 logfileOffset = 3; * @@ -1363,7 +1377,7 @@ public final class CanalEntry { * *binlog/redolog 文件的偏移位置* * */ - long getLogfileOffset(); + long getLogfileOffset(); /** * optional int64 serverId = 4; @@ -1372,8 +1386,8 @@ public final class CanalEntry { * *服务端serverId* * */ - boolean hasServerId(); - + boolean hasServerId(); + /** * optional int64 serverId = 4; * @@ -1381,7 +1395,7 @@ public final class CanalEntry { * *服务端serverId* * */ - long getServerId(); + long getServerId(); /** * optional string serverenCode = 5; @@ -1390,8 +1404,8 @@ public final class CanalEntry { * * 变更数据的编码 * * */ - boolean hasServerenCode(); - + boolean hasServerenCode(); + /** * optional string serverenCode = 5; * @@ -1399,8 +1413,8 @@ public final class CanalEntry { * * 变更数据的编码 * * */ - java.lang.String getServerenCode(); - + java.lang.String getServerenCode(); + /** * optional string serverenCode = 5; * @@ -1408,8 +1422,7 @@ public final class CanalEntry { * * 变更数据的编码 * * */ - com.google.protobuf.ByteString - getServerenCodeBytes(); + com.google.protobuf.ByteString getServerenCodeBytes(); /** * optional int64 executeTime = 6; @@ -1418,8 +1431,8 @@ public final class CanalEntry { * *变更数据的执行时间 * * */ - boolean hasExecuteTime(); - + boolean hasExecuteTime(); + /** * optional int64 executeTime = 6; * @@ -1427,7 +1440,7 @@ public final class CanalEntry { * *变更数据的执行时间 * * */ - long getExecuteTime(); + long getExecuteTime(); /** * optional .com.alibaba.otter.canal.protocol.Type sourceType = 7 [default = MYSQL]; @@ -1436,8 +1449,8 @@ public final class CanalEntry { * * 变更数据的来源* * */ - boolean hasSourceType(); - + boolean hasSourceType(); + /** * optional .com.alibaba.otter.canal.protocol.Type sourceType = 7 [default = MYSQL]; * @@ -1445,7 +1458,7 @@ public final class CanalEntry { * * 变更数据的来源* * */ - com.alibaba.otter.canal.protocol.CanalEntry.Type getSourceType(); + com.alibaba.otter.canal.protocol.CanalEntry.Type getSourceType(); /** * optional string schemaName = 8; @@ -1454,8 +1467,8 @@ public final class CanalEntry { * * 变更数据的schemaname* * */ - boolean hasSchemaName(); - + boolean hasSchemaName(); + /** * optional string schemaName = 8; * @@ -1463,8 +1476,8 @@ public final class CanalEntry { * * 变更数据的schemaname* * */ - java.lang.String getSchemaName(); - + java.lang.String getSchemaName(); + /** * optional string schemaName = 8; * @@ -1472,8 +1485,7 @@ public final class CanalEntry { * * 变更数据的schemaname* * */ - com.google.protobuf.ByteString - getSchemaNameBytes(); + com.google.protobuf.ByteString getSchemaNameBytes(); /** * optional string tableName = 9; @@ -1482,8 +1494,8 @@ public final class CanalEntry { * *变更数据的tablename* * */ - boolean hasTableName(); - + boolean hasTableName(); + /** * optional string tableName = 9; * @@ -1491,8 +1503,8 @@ public final class CanalEntry { * *变更数据的tablename* * */ - java.lang.String getTableName(); - + java.lang.String getTableName(); + /** * optional string tableName = 9; * @@ -1500,8 +1512,7 @@ public final class CanalEntry { * *变更数据的tablename* * */ - com.google.protobuf.ByteString - getTableNameBytes(); + com.google.protobuf.ByteString getTableNameBytes(); /** * optional int64 eventLength = 10; @@ -1510,8 +1521,8 @@ public final class CanalEntry { * *每个event的长度* * */ - boolean hasEventLength(); - + boolean hasEventLength(); + /** * optional int64 eventLength = 10; * @@ -1519,7 +1530,7 @@ public final class CanalEntry { * *每个event的长度* * */ - long getEventLength(); + long getEventLength(); /** * optional .com.alibaba.otter.canal.protocol.EventType eventType = 11 [default = UPDATE]; @@ -1528,8 +1539,8 @@ public final class CanalEntry { * *数据变更类型* * */ - boolean hasEventType(); - + boolean hasEventType(); + /** * optional .com.alibaba.otter.canal.protocol.EventType eventType = 11 [default = UPDATE]; * @@ -1537,7 +1548,7 @@ public final class CanalEntry { * *数据变更类型* * */ - com.alibaba.otter.canal.protocol.CanalEntry.EventType getEventType(); + com.alibaba.otter.canal.protocol.CanalEntry.EventType getEventType(); /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; @@ -1546,9 +1557,8 @@ public final class CanalEntry { * *预留扩展* * */ - java.util.List - getPropsList(); - + java.util.List getPropsList(); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; * @@ -1556,8 +1566,8 @@ public final class CanalEntry { * *预留扩展* * */ - com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index); - + com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; * @@ -1565,8 +1575,8 @@ public final class CanalEntry { * *预留扩展* * */ - int getPropsCount(); - + int getPropsCount(); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; * @@ -1574,9 +1584,8 @@ public final class CanalEntry { * *预留扩展* * */ - java.util.List - getPropsOrBuilderList(); - + java.util.List getPropsOrBuilderList(); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; * @@ -1584,8 +1593,7 @@ public final class CanalEntry { * *预留扩展* * */ - com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder( - int index); + com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index); /** * optional string gtid = 13; @@ -1594,8 +1602,8 @@ public final class CanalEntry { * *当前事务的gitd* * */ - boolean hasGtid(); - + boolean hasGtid(); + /** * optional string gtid = 13; * @@ -1603,8 +1611,8 @@ public final class CanalEntry { * *当前事务的gitd* * */ - java.lang.String getGtid(); - + java.lang.String getGtid(); + /** * optional string gtid = 13; * @@ -1612,1195 +1620,1168 @@ public final class CanalEntry { * *当前事务的gitd* * */ - com.google.protobuf.ByteString - getGtidBytes(); - } - /** - * Protobuf type {@code com.alibaba.otter.canal.protocol.Header} - * - *
      -   **message Header*
      -   * 
      - */ - public static final class Header extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:com.alibaba.otter.canal.protocol.Header) - HeaderOrBuilder { - // Use Header.newBuilder() to construct. - private Header(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private Header(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final Header defaultInstance; - public static Header getDefaultInstance() { - return defaultInstance; + com.google.protobuf.ByteString getGtidBytes(); } - public Header getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private Header( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - bitField0_ |= 0x00000001; - version_ = input.readInt32(); - break; - } - case 18: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000002; - logfileName_ = bs; - break; - } - case 24: { - bitField0_ |= 0x00000004; - logfileOffset_ = input.readInt64(); - break; - } - case 32: { - bitField0_ |= 0x00000008; - serverId_ = input.readInt64(); - break; - } - case 42: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000010; - serverenCode_ = bs; - break; - } - case 48: { - bitField0_ |= 0x00000020; - executeTime_ = input.readInt64(); - break; - } - case 56: { - int rawValue = input.readEnum(); - com.alibaba.otter.canal.protocol.CanalEntry.Type value = com.alibaba.otter.canal.protocol.CanalEntry.Type.valueOf(rawValue); - if (value == null) { - unknownFields.mergeVarintField(7, rawValue); - } else { - bitField0_ |= 0x00000040; - sourceType_ = value; - } - break; - } - case 66: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000080; - schemaName_ = bs; - break; - } - case 74: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000100; - tableName_ = bs; - break; - } - case 80: { - bitField0_ |= 0x00000200; - eventLength_ = input.readInt64(); - break; - } - case 88: { - int rawValue = input.readEnum(); - com.alibaba.otter.canal.protocol.CanalEntry.EventType value = com.alibaba.otter.canal.protocol.CanalEntry.EventType.valueOf(rawValue); - if (value == null) { - unknownFields.mergeVarintField(11, rawValue); - } else { - bitField0_ |= 0x00000400; - eventType_ = value; - } - break; - } - case 98: { - if (!((mutable_bitField0_ & 0x00000800) == 0x00000800)) { - props_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000800; - } - props_.add(input.readMessage(com.alibaba.otter.canal.protocol.CanalEntry.Pair.PARSER, extensionRegistry)); - break; - } - case 106: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000800; - gtid_ = bs; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000800) == 0x00000800)) { - props_ = java.util.Collections.unmodifiableList(props_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Header_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Header_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.alibaba.otter.canal.protocol.CanalEntry.Header.class, com.alibaba.otter.canal.protocol.CanalEntry.Header.Builder.class); - } - - public static com.google.protobuf.Parser
      PARSER = - new com.google.protobuf.AbstractParser
      () { - public Header parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Header(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser
      getParserForType() { - return PARSER; - } - - private int bitField0_; - public static final int VERSION_FIELD_NUMBER = 1; - private int version_; - - /** - * optional int32 version = 1 [default = 1]; - * - *
      -         * *协议的版本号*
      -         * 
      - */ - public boolean hasVersion() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - - /** - * optional int32 version = 1 [default = 1]; - * - *
      -         * *协议的版本号*
      -         * 
      - */ - public int getVersion() { - return version_; - } - - public static final int LOGFILENAME_FIELD_NUMBER = 2; - private java.lang.Object logfileName_; - - /** - * optional string logfileName = 2; - * - *
      -         * *binlog/redolog 文件名*
      -         * 
      - */ - public boolean hasLogfileName() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - - /** - * optional string logfileName = 2; - * - *
      -         * *binlog/redolog 文件名*
      -         * 
      - */ - public java.lang.String getLogfileName() { - java.lang.Object ref = logfileName_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - logfileName_ = s; - } - return s; - } - } - - /** - * optional string logfileName = 2; - * - *
      -         * *binlog/redolog 文件名*
      -         * 
      - */ - public com.google.protobuf.ByteString - getLogfileNameBytes() { - java.lang.Object ref = logfileName_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - logfileName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int LOGFILEOFFSET_FIELD_NUMBER = 3; - private long logfileOffset_; - - /** - * optional int64 logfileOffset = 3; - * - *
      -         * *binlog/redolog 文件的偏移位置*
      -         * 
      - */ - public boolean hasLogfileOffset() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - - /** - * optional int64 logfileOffset = 3; - * - *
      -         * *binlog/redolog 文件的偏移位置*
      -         * 
      - */ - public long getLogfileOffset() { - return logfileOffset_; - } - - public static final int SERVERID_FIELD_NUMBER = 4; - private long serverId_; - - /** - * optional int64 serverId = 4; - * - *
      -         * *服务端serverId*
      -         * 
      - */ - public boolean hasServerId() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - - /** - * optional int64 serverId = 4; - * - *
      -         * *服务端serverId*
      -         * 
      - */ - public long getServerId() { - return serverId_; - } - - public static final int SERVERENCODE_FIELD_NUMBER = 5; - private java.lang.Object serverenCode_; - - /** - * optional string serverenCode = 5; - * - *
      -         * * 变更数据的编码 *
      -         * 
      - */ - public boolean hasServerenCode() { - return ((bitField0_ & 0x00000010) == 0x00000010); - } - - /** - * optional string serverenCode = 5; - * - *
      -         * * 变更数据的编码 *
      -         * 
      - */ - public java.lang.String getServerenCode() { - java.lang.Object ref = serverenCode_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - serverenCode_ = s; - } - return s; - } - } - - /** - * optional string serverenCode = 5; - * - *
      -         * * 变更数据的编码 *
      -         * 
      - */ - public com.google.protobuf.ByteString - getServerenCodeBytes() { - java.lang.Object ref = serverenCode_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - serverenCode_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int EXECUTETIME_FIELD_NUMBER = 6; - private long executeTime_; - - /** - * optional int64 executeTime = 6; - * - *
      -         * *变更数据的执行时间 *
      -         * 
      - */ - public boolean hasExecuteTime() { - return ((bitField0_ & 0x00000020) == 0x00000020); - } - - /** - * optional int64 executeTime = 6; - * - *
      -         * *变更数据的执行时间 *
      -         * 
      - */ - public long getExecuteTime() { - return executeTime_; - } - - public static final int SOURCETYPE_FIELD_NUMBER = 7; - private com.alibaba.otter.canal.protocol.CanalEntry.Type sourceType_; - - /** - * optional .com.alibaba.otter.canal.protocol.Type sourceType = 7 [default = MYSQL]; - * - *
      -         * * 变更数据的来源*
      -         * 
      - */ - public boolean hasSourceType() { - return ((bitField0_ & 0x00000040) == 0x00000040); - } - - /** - * optional .com.alibaba.otter.canal.protocol.Type sourceType = 7 [default = MYSQL]; - * - *
      -         * * 变更数据的来源*
      -         * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Type getSourceType() { - return sourceType_; - } - - public static final int SCHEMANAME_FIELD_NUMBER = 8; - private java.lang.Object schemaName_; - - /** - * optional string schemaName = 8; - * - *
      -         * * 变更数据的schemaname*
      -         * 
      - */ - public boolean hasSchemaName() { - return ((bitField0_ & 0x00000080) == 0x00000080); - } - - /** - * optional string schemaName = 8; - * - *
      -         * * 变更数据的schemaname*
      -         * 
      - */ - public java.lang.String getSchemaName() { - java.lang.Object ref = schemaName_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - schemaName_ = s; - } - return s; - } - } - - /** - * optional string schemaName = 8; - * - *
      -         * * 变更数据的schemaname*
      -         * 
      - */ - public com.google.protobuf.ByteString - getSchemaNameBytes() { - java.lang.Object ref = schemaName_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - schemaName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int TABLENAME_FIELD_NUMBER = 9; - private java.lang.Object tableName_; - - /** - * optional string tableName = 9; - * - *
      -         * *变更数据的tablename*
      -         * 
      - */ - public boolean hasTableName() { - return ((bitField0_ & 0x00000100) == 0x00000100); - } - - /** - * optional string tableName = 9; - * - *
      -         * *变更数据的tablename*
      -         * 
      - */ - public java.lang.String getTableName() { - java.lang.Object ref = tableName_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - tableName_ = s; - } - return s; - } - } - - /** - * optional string tableName = 9; - * - *
      -         * *变更数据的tablename*
      -         * 
      - */ - public com.google.protobuf.ByteString - getTableNameBytes() { - java.lang.Object ref = tableName_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - tableName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int EVENTLENGTH_FIELD_NUMBER = 10; - private long eventLength_; - - /** - * optional int64 eventLength = 10; - * - *
      -         * *每个event的长度*
      -         * 
      - */ - public boolean hasEventLength() { - return ((bitField0_ & 0x00000200) == 0x00000200); - } - - /** - * optional int64 eventLength = 10; - * - *
      -         * *每个event的长度*
      -         * 
      - */ - public long getEventLength() { - return eventLength_; - } - - public static final int EVENTTYPE_FIELD_NUMBER = 11; - private com.alibaba.otter.canal.protocol.CanalEntry.EventType eventType_; - - /** - * optional .com.alibaba.otter.canal.protocol.EventType eventType = 11 [default = UPDATE]; - * - *
      -         * *数据变更类型*
      -         * 
      - */ - public boolean hasEventType() { - return ((bitField0_ & 0x00000400) == 0x00000400); - } - - /** - * optional .com.alibaba.otter.canal.protocol.EventType eventType = 11 [default = UPDATE]; - * - *
      -         * *数据变更类型*
      -         * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.EventType getEventType() { - return eventType_; - } - - public static final int PROPS_FIELD_NUMBER = 12; - private java.util.List props_; - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -         * *预留扩展*
      -         * 
      - */ - public java.util.List getPropsList() { - return props_; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -         * *预留扩展*
      -         * 
      - */ - public java.util.List - getPropsOrBuilderList() { - return props_; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -         * *预留扩展*
      -         * 
      - */ - public int getPropsCount() { - return props_.size(); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -         * *预留扩展*
      -         * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { - return props_.get(index); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -         * *预留扩展*
      -         * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder( - int index) { - return props_.get(index); - } - - public static final int GTID_FIELD_NUMBER = 13; - private java.lang.Object gtid_; - - /** - * optional string gtid = 13; - * - *
      -         * *当前事务的gitd*
      -         * 
      - */ - public boolean hasGtid() { - return ((bitField0_ & 0x00000800) == 0x00000800); - } - - /** - * optional string gtid = 13; - * - *
      -         * *当前事务的gitd*
      -         * 
      - */ - public java.lang.String getGtid() { - java.lang.Object ref = gtid_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - gtid_ = s; - } - return s; - } - } - - /** - * optional string gtid = 13; - * - *
      -         * *当前事务的gitd*
      -         * 
      - */ - public com.google.protobuf.ByteString - getGtidBytes() { - java.lang.Object ref = gtid_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - gtid_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private void initFields() { - version_ = 1; - logfileName_ = ""; - logfileOffset_ = 0L; - serverId_ = 0L; - serverenCode_ = ""; - executeTime_ = 0L; - sourceType_ = com.alibaba.otter.canal.protocol.CanalEntry.Type.MYSQL; - schemaName_ = ""; - tableName_ = ""; - eventLength_ = 0L; - eventType_ = com.alibaba.otter.canal.protocol.CanalEntry.EventType.UPDATE; - props_ = java.util.Collections.emptyList(); - gtid_ = ""; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeInt32(1, version_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeBytes(2, getLogfileNameBytes()); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeInt64(3, logfileOffset_); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - output.writeInt64(4, serverId_); - } - if (((bitField0_ & 0x00000010) == 0x00000010)) { - output.writeBytes(5, getServerenCodeBytes()); - } - if (((bitField0_ & 0x00000020) == 0x00000020)) { - output.writeInt64(6, executeTime_); - } - if (((bitField0_ & 0x00000040) == 0x00000040)) { - output.writeEnum(7, sourceType_.getNumber()); - } - if (((bitField0_ & 0x00000080) == 0x00000080)) { - output.writeBytes(8, getSchemaNameBytes()); - } - if (((bitField0_ & 0x00000100) == 0x00000100)) { - output.writeBytes(9, getTableNameBytes()); - } - if (((bitField0_ & 0x00000200) == 0x00000200)) { - output.writeInt64(10, eventLength_); - } - if (((bitField0_ & 0x00000400) == 0x00000400)) { - output.writeEnum(11, eventType_.getNumber()); - } - for (int i = 0; i < props_.size(); i++) { - output.writeMessage(12, props_.get(i)); - } - if (((bitField0_ & 0x00000800) == 0x00000800)) { - output.writeBytes(13, getGtidBytes()); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(1, version_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, getLogfileNameBytes()); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(3, logfileOffset_); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(4, serverId_); - } - if (((bitField0_ & 0x00000010) == 0x00000010)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(5, getServerenCodeBytes()); - } - if (((bitField0_ & 0x00000020) == 0x00000020)) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(6, executeTime_); - } - if (((bitField0_ & 0x00000040) == 0x00000040)) { - size += com.google.protobuf.CodedOutputStream - .computeEnumSize(7, sourceType_.getNumber()); - } - if (((bitField0_ & 0x00000080) == 0x00000080)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(8, getSchemaNameBytes()); - } - if (((bitField0_ & 0x00000100) == 0x00000100)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(9, getTableNameBytes()); - } - if (((bitField0_ & 0x00000200) == 0x00000200)) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(10, eventLength_); - } - if (((bitField0_ & 0x00000400) == 0x00000400)) { - size += com.google.protobuf.CodedOutputStream - .computeEnumSize(11, eventType_.getNumber()); - } - for (int i = 0; i < props_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(12, props_.get(i)); - } - if (((bitField0_ & 0x00000800) == 0x00000800)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(13, getGtidBytes()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static com.alibaba.otter.canal.protocol.CanalEntry.Header parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Header parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Header parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Header parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Header parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Header parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Header parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Header parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Header parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Header parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(com.alibaba.otter.canal.protocol.CanalEntry.Header prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } /** * Protobuf type {@code com.alibaba.otter.canal.protocol.Header} * *
      -     **message Header*
      +     * *message Header*
            * 
      */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements + public static final class Header extends com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:com.alibaba.otter.canal.protocol.Header) + HeaderOrBuilder { + + // Use Header.newBuilder() to construct. + private Header(com.google.protobuf.GeneratedMessage.Builder builder){ + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + + private Header(boolean noInit){ + this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + + private static final Header defaultInstance; + + public static Header getDefaultInstance() { + return defaultInstance; + } + + public Header getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private Header(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException{ + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + bitField0_ |= 0x00000001; + version_ = input.readInt32(); + break; + } + case 18: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000002; + logfileName_ = bs; + break; + } + case 24: { + bitField0_ |= 0x00000004; + logfileOffset_ = input.readInt64(); + break; + } + case 32: { + bitField0_ |= 0x00000008; + serverId_ = input.readInt64(); + break; + } + case 42: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000010; + serverenCode_ = bs; + break; + } + case 48: { + bitField0_ |= 0x00000020; + executeTime_ = input.readInt64(); + break; + } + case 56: { + int rawValue = input.readEnum(); + com.alibaba.otter.canal.protocol.CanalEntry.Type value = com.alibaba.otter.canal.protocol.CanalEntry.Type.valueOf(rawValue); + if (value == null) { + unknownFields.mergeVarintField(7, rawValue); + } else { + bitField0_ |= 0x00000040; + sourceType_ = value; + } + break; + } + case 66: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000080; + schemaName_ = bs; + break; + } + case 74: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000100; + tableName_ = bs; + break; + } + case 80: { + bitField0_ |= 0x00000200; + eventLength_ = input.readInt64(); + break; + } + case 88: { + int rawValue = input.readEnum(); + com.alibaba.otter.canal.protocol.CanalEntry.EventType value = com.alibaba.otter.canal.protocol.CanalEntry.EventType.valueOf(rawValue); + if (value == null) { + unknownFields.mergeVarintField(11, rawValue); + } else { + bitField0_ |= 0x00000400; + eventType_ = value; + } + break; + } + case 98: { + if (!((mutable_bitField0_ & 0x00000800) == 0x00000800)) { + props_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000800; + } + props_.add(input.readMessage(com.alibaba.otter.canal.protocol.CanalEntry.Pair.PARSER, + extensionRegistry)); + break; + } + case 106: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000800; + gtid_ = bs; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e.getMessage()).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000800) == 0x00000800)) { + props_ = java.util.Collections.unmodifiableList(props_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Header_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Header_fieldAccessorTable.ensureFieldAccessorsInitialized(com.alibaba.otter.canal.protocol.CanalEntry.Header.class, + com.alibaba.otter.canal.protocol.CanalEntry.Header.Builder.class); + } + + public static com.google.protobuf.Parser
      PARSER = new com.google.protobuf.AbstractParser
      () { + + public Header parsePartialFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Header(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser
      getParserForType() { + return PARSER; + } + + private int bitField0_; + public static final int VERSION_FIELD_NUMBER = 1; + private int version_; + + /** + * optional int32 version = 1 [default = 1]; + * + *
      +         * *协议的版本号*
      +         * 
      + */ + public boolean hasVersion() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + + /** + * optional int32 version = 1 [default = 1]; + * + *
      +         * *协议的版本号*
      +         * 
      + */ + public int getVersion() { + return version_; + } + + public static final int LOGFILENAME_FIELD_NUMBER = 2; + private java.lang.Object logfileName_; + + /** + * optional string logfileName = 2; + * + *
      +         * *binlog/redolog 文件名*
      +         * 
      + */ + public boolean hasLogfileName() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + + /** + * optional string logfileName = 2; + * + *
      +         * *binlog/redolog 文件名*
      +         * 
      + */ + public java.lang.String getLogfileName() { + java.lang.Object ref = logfileName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + logfileName_ = s; + } + return s; + } + } + + /** + * optional string logfileName = 2; + * + *
      +         * *binlog/redolog 文件名*
      +         * 
      + */ + public com.google.protobuf.ByteString getLogfileNameBytes() { + java.lang.Object ref = logfileName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + logfileName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int LOGFILEOFFSET_FIELD_NUMBER = 3; + private long logfileOffset_; + + /** + * optional int64 logfileOffset = 3; + * + *
      +         * *binlog/redolog 文件的偏移位置*
      +         * 
      + */ + public boolean hasLogfileOffset() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + + /** + * optional int64 logfileOffset = 3; + * + *
      +         * *binlog/redolog 文件的偏移位置*
      +         * 
      + */ + public long getLogfileOffset() { + return logfileOffset_; + } + + public static final int SERVERID_FIELD_NUMBER = 4; + private long serverId_; + + /** + * optional int64 serverId = 4; + * + *
      +         * *服务端serverId*
      +         * 
      + */ + public boolean hasServerId() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + + /** + * optional int64 serverId = 4; + * + *
      +         * *服务端serverId*
      +         * 
      + */ + public long getServerId() { + return serverId_; + } + + public static final int SERVERENCODE_FIELD_NUMBER = 5; + private java.lang.Object serverenCode_; + + /** + * optional string serverenCode = 5; + * + *
      +         * * 变更数据的编码 *
      +         * 
      + */ + public boolean hasServerenCode() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + + /** + * optional string serverenCode = 5; + * + *
      +         * * 变更数据的编码 *
      +         * 
      + */ + public java.lang.String getServerenCode() { + java.lang.Object ref = serverenCode_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + serverenCode_ = s; + } + return s; + } + } + + /** + * optional string serverenCode = 5; + * + *
      +         * * 变更数据的编码 *
      +         * 
      + */ + public com.google.protobuf.ByteString getServerenCodeBytes() { + java.lang.Object ref = serverenCode_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + serverenCode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int EXECUTETIME_FIELD_NUMBER = 6; + private long executeTime_; + + /** + * optional int64 executeTime = 6; + * + *
      +         * *变更数据的执行时间 *
      +         * 
      + */ + public boolean hasExecuteTime() { + return ((bitField0_ & 0x00000020) == 0x00000020); + } + + /** + * optional int64 executeTime = 6; + * + *
      +         * *变更数据的执行时间 *
      +         * 
      + */ + public long getExecuteTime() { + return executeTime_; + } + + public static final int SOURCETYPE_FIELD_NUMBER = 7; + private com.alibaba.otter.canal.protocol.CanalEntry.Type sourceType_; + + /** + * optional .com.alibaba.otter.canal.protocol.Type sourceType = 7 [default = MYSQL]; + * + *
      +         * * 变更数据的来源*
      +         * 
      + */ + public boolean hasSourceType() { + return ((bitField0_ & 0x00000040) == 0x00000040); + } + + /** + * optional .com.alibaba.otter.canal.protocol.Type sourceType = 7 [default = MYSQL]; + * + *
      +         * * 变更数据的来源*
      +         * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Type getSourceType() { + return sourceType_; + } + + public static final int SCHEMANAME_FIELD_NUMBER = 8; + private java.lang.Object schemaName_; + + /** + * optional string schemaName = 8; + * + *
      +         * * 变更数据的schemaname*
      +         * 
      + */ + public boolean hasSchemaName() { + return ((bitField0_ & 0x00000080) == 0x00000080); + } + + /** + * optional string schemaName = 8; + * + *
      +         * * 变更数据的schemaname*
      +         * 
      + */ + public java.lang.String getSchemaName() { + java.lang.Object ref = schemaName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + schemaName_ = s; + } + return s; + } + } + + /** + * optional string schemaName = 8; + * + *
      +         * * 变更数据的schemaname*
      +         * 
      + */ + public com.google.protobuf.ByteString getSchemaNameBytes() { + java.lang.Object ref = schemaName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + schemaName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TABLENAME_FIELD_NUMBER = 9; + private java.lang.Object tableName_; + + /** + * optional string tableName = 9; + * + *
      +         * *变更数据的tablename*
      +         * 
      + */ + public boolean hasTableName() { + return ((bitField0_ & 0x00000100) == 0x00000100); + } + + /** + * optional string tableName = 9; + * + *
      +         * *变更数据的tablename*
      +         * 
      + */ + public java.lang.String getTableName() { + java.lang.Object ref = tableName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + tableName_ = s; + } + return s; + } + } + + /** + * optional string tableName = 9; + * + *
      +         * *变更数据的tablename*
      +         * 
      + */ + public com.google.protobuf.ByteString getTableNameBytes() { + java.lang.Object ref = tableName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + tableName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int EVENTLENGTH_FIELD_NUMBER = 10; + private long eventLength_; + + /** + * optional int64 eventLength = 10; + * + *
      +         * *每个event的长度*
      +         * 
      + */ + public boolean hasEventLength() { + return ((bitField0_ & 0x00000200) == 0x00000200); + } + + /** + * optional int64 eventLength = 10; + * + *
      +         * *每个event的长度*
      +         * 
      + */ + public long getEventLength() { + return eventLength_; + } + + public static final int EVENTTYPE_FIELD_NUMBER = 11; + private com.alibaba.otter.canal.protocol.CanalEntry.EventType eventType_; + + /** + * optional .com.alibaba.otter.canal.protocol.EventType eventType = 11 [default = UPDATE]; + * + *
      +         * *数据变更类型*
      +         * 
      + */ + public boolean hasEventType() { + return ((bitField0_ & 0x00000400) == 0x00000400); + } + + /** + * optional .com.alibaba.otter.canal.protocol.EventType eventType = 11 [default = UPDATE]; + * + *
      +         * *数据变更类型*
      +         * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.EventType getEventType() { + return eventType_; + } + + public static final int PROPS_FIELD_NUMBER = 12; + private java.util.List props_; + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public java.util.List getPropsList() { + return props_; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public java.util.List getPropsOrBuilderList() { + return props_; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public int getPropsCount() { + return props_.size(); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { + return props_.get(index); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index) { + return props_.get(index); + } + + public static final int GTID_FIELD_NUMBER = 13; + private java.lang.Object gtid_; + + /** + * optional string gtid = 13; + * + *
      +         * *当前事务的gitd*
      +         * 
      + */ + public boolean hasGtid() { + return ((bitField0_ & 0x00000800) == 0x00000800); + } + + /** + * optional string gtid = 13; + * + *
      +         * *当前事务的gitd*
      +         * 
      + */ + public java.lang.String getGtid() { + java.lang.Object ref = gtid_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + gtid_ = s; + } + return s; + } + } + + /** + * optional string gtid = 13; + * + *
      +         * *当前事务的gitd*
      +         * 
      + */ + public com.google.protobuf.ByteString getGtidBytes() { + java.lang.Object ref = gtid_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + gtid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private void initFields() { + version_ = 1; + logfileName_ = ""; + logfileOffset_ = 0L; + serverId_ = 0L; + serverenCode_ = ""; + executeTime_ = 0L; + sourceType_ = com.alibaba.otter.canal.protocol.CanalEntry.Type.MYSQL; + schemaName_ = ""; + tableName_ = ""; + eventLength_ = 0L; + eventType_ = com.alibaba.otter.canal.protocol.CanalEntry.EventType.UPDATE; + props_ = java.util.Collections.emptyList(); + gtid_ = ""; + } + + private byte memoizedIsInitialized = -1; + + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeInt32(1, version_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBytes(2, getLogfileNameBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeInt64(3, logfileOffset_); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + output.writeInt64(4, serverId_); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + output.writeBytes(5, getServerenCodeBytes()); + } + if (((bitField0_ & 0x00000020) == 0x00000020)) { + output.writeInt64(6, executeTime_); + } + if (((bitField0_ & 0x00000040) == 0x00000040)) { + output.writeEnum(7, sourceType_.getNumber()); + } + if (((bitField0_ & 0x00000080) == 0x00000080)) { + output.writeBytes(8, getSchemaNameBytes()); + } + if (((bitField0_ & 0x00000100) == 0x00000100)) { + output.writeBytes(9, getTableNameBytes()); + } + if (((bitField0_ & 0x00000200) == 0x00000200)) { + output.writeInt64(10, eventLength_); + } + if (((bitField0_ & 0x00000400) == 0x00000400)) { + output.writeEnum(11, eventType_.getNumber()); + } + for (int i = 0; i < props_.size(); i++) { + output.writeMessage(12, props_.get(i)); + } + if (((bitField0_ & 0x00000800) == 0x00000800)) { + output.writeBytes(13, getGtidBytes()); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(1, version_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(2, getLogfileNameBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(3, logfileOffset_); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(4, serverId_); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(5, getServerenCodeBytes()); + } + if (((bitField0_ & 0x00000020) == 0x00000020)) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(6, executeTime_); + } + if (((bitField0_ & 0x00000040) == 0x00000040)) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(7, sourceType_.getNumber()); + } + if (((bitField0_ & 0x00000080) == 0x00000080)) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(8, getSchemaNameBytes()); + } + if (((bitField0_ & 0x00000100) == 0x00000100)) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(9, getTableNameBytes()); + } + if (((bitField0_ & 0x00000200) == 0x00000200)) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(10, eventLength_); + } + if (((bitField0_ & 0x00000400) == 0x00000400)) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(11, eventType_.getNumber()); + } + for (int i = 0; i < props_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(12, props_.get(i)); + } + if (((bitField0_ & 0x00000800) == 0x00000800)) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(13, getGtidBytes()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + + @java.lang.Override + protected java.lang.Object writeReplace() throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Header parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Header parseFrom(com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Header parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Header parseFrom(byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Header parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Header parseFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Header parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Header parseDelimitedFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Header parseFrom(com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Header parseFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { + return Builder.create(); + } + + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder(com.alibaba.otter.canal.protocol.CanalEntry.Header prototype) { + return newBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return newBuilder(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * Protobuf type {@code com.alibaba.otter.canal.protocol.Header} + * + *
      +         * *message Header*
      +         * 
      + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements // @@protoc_insertion_point(builder_implements:com.alibaba.otter.canal.protocol.Header) com.alibaba.otter.canal.protocol.CanalEntry.HeaderOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Header_descriptor; - } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Header_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.alibaba.otter.canal.protocol.CanalEntry.Header.class, com.alibaba.otter.canal.protocol.CanalEntry.Header.Builder.class); - } - - // Construct using com.alibaba.otter.canal.protocol.CanalEntry.Header.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getPropsFieldBuilder(); - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - version_ = 1; - bitField0_ = (bitField0_ & ~0x00000001); - logfileName_ = ""; - bitField0_ = (bitField0_ & ~0x00000002); - logfileOffset_ = 0L; - bitField0_ = (bitField0_ & ~0x00000004); - serverId_ = 0L; - bitField0_ = (bitField0_ & ~0x00000008); - serverenCode_ = ""; - bitField0_ = (bitField0_ & ~0x00000010); - executeTime_ = 0L; - bitField0_ = (bitField0_ & ~0x00000020); - sourceType_ = com.alibaba.otter.canal.protocol.CanalEntry.Type.MYSQL; - bitField0_ = (bitField0_ & ~0x00000040); - schemaName_ = ""; - bitField0_ = (bitField0_ & ~0x00000080); - tableName_ = ""; - bitField0_ = (bitField0_ & ~0x00000100); - eventLength_ = 0L; - bitField0_ = (bitField0_ & ~0x00000200); - eventType_ = com.alibaba.otter.canal.protocol.CanalEntry.EventType.UPDATE; - bitField0_ = (bitField0_ & ~0x00000400); - if (propsBuilder_ == null) { - props_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000800); - } else { - propsBuilder_.clear(); - } - gtid_ = ""; - bitField0_ = (bitField0_ & ~0x00001000); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Header_descriptor; - } - - public com.alibaba.otter.canal.protocol.CanalEntry.Header getDefaultInstanceForType() { - return com.alibaba.otter.canal.protocol.CanalEntry.Header.getDefaultInstance(); - } - - public com.alibaba.otter.canal.protocol.CanalEntry.Header build() { - com.alibaba.otter.canal.protocol.CanalEntry.Header result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.alibaba.otter.canal.protocol.CanalEntry.Header buildPartial() { - com.alibaba.otter.canal.protocol.CanalEntry.Header result = new com.alibaba.otter.canal.protocol.CanalEntry.Header(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.version_ = version_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.logfileName_ = logfileName_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000004; - } - result.logfileOffset_ = logfileOffset_; - if (((from_bitField0_ & 0x00000008) == 0x00000008)) { - to_bitField0_ |= 0x00000008; - } - result.serverId_ = serverId_; - if (((from_bitField0_ & 0x00000010) == 0x00000010)) { - to_bitField0_ |= 0x00000010; - } - result.serverenCode_ = serverenCode_; - if (((from_bitField0_ & 0x00000020) == 0x00000020)) { - to_bitField0_ |= 0x00000020; - } - result.executeTime_ = executeTime_; - if (((from_bitField0_ & 0x00000040) == 0x00000040)) { - to_bitField0_ |= 0x00000040; - } - result.sourceType_ = sourceType_; - if (((from_bitField0_ & 0x00000080) == 0x00000080)) { - to_bitField0_ |= 0x00000080; - } - result.schemaName_ = schemaName_; - if (((from_bitField0_ & 0x00000100) == 0x00000100)) { - to_bitField0_ |= 0x00000100; - } - result.tableName_ = tableName_; - if (((from_bitField0_ & 0x00000200) == 0x00000200)) { - to_bitField0_ |= 0x00000200; - } - result.eventLength_ = eventLength_; - if (((from_bitField0_ & 0x00000400) == 0x00000400)) { - to_bitField0_ |= 0x00000400; - } - result.eventType_ = eventType_; - if (propsBuilder_ == null) { - if (((bitField0_ & 0x00000800) == 0x00000800)) { - props_ = java.util.Collections.unmodifiableList(props_); - bitField0_ = (bitField0_ & ~0x00000800); - } - result.props_ = props_; - } else { - result.props_ = propsBuilder_.build(); - } - if (((from_bitField0_ & 0x00001000) == 0x00001000)) { - to_bitField0_ |= 0x00000800; - } - result.gtid_ = gtid_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.alibaba.otter.canal.protocol.CanalEntry.Header) { - return mergeFrom((com.alibaba.otter.canal.protocol.CanalEntry.Header)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.alibaba.otter.canal.protocol.CanalEntry.Header other) { - if (other == com.alibaba.otter.canal.protocol.CanalEntry.Header.getDefaultInstance()) return this; - if (other.hasVersion()) { - setVersion(other.getVersion()); - } - if (other.hasLogfileName()) { - bitField0_ |= 0x00000002; - logfileName_ = other.logfileName_; - onChanged(); - } - if (other.hasLogfileOffset()) { - setLogfileOffset(other.getLogfileOffset()); - } - if (other.hasServerId()) { - setServerId(other.getServerId()); - } - if (other.hasServerenCode()) { - bitField0_ |= 0x00000010; - serverenCode_ = other.serverenCode_; - onChanged(); - } - if (other.hasExecuteTime()) { - setExecuteTime(other.getExecuteTime()); - } - if (other.hasSourceType()) { - setSourceType(other.getSourceType()); - } - if (other.hasSchemaName()) { - bitField0_ |= 0x00000080; - schemaName_ = other.schemaName_; - onChanged(); - } - if (other.hasTableName()) { - bitField0_ |= 0x00000100; - tableName_ = other.tableName_; - onChanged(); - } - if (other.hasEventLength()) { - setEventLength(other.getEventLength()); - } - if (other.hasEventType()) { - setEventType(other.getEventType()); - } - if (propsBuilder_ == null) { - if (!other.props_.isEmpty()) { - if (props_.isEmpty()) { - props_ = other.props_; - bitField0_ = (bitField0_ & ~0x00000800); - } else { - ensurePropsIsMutable(); - props_.addAll(other.props_); + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Header_descriptor; } - onChanged(); - } - } else { - if (!other.props_.isEmpty()) { - if (propsBuilder_.isEmpty()) { - propsBuilder_.dispose(); - propsBuilder_ = null; - props_ = other.props_; - bitField0_ = (bitField0_ & ~0x00000800); - propsBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getPropsFieldBuilder() : null; - } else { - propsBuilder_.addAllMessages(other.props_); + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Header_fieldAccessorTable.ensureFieldAccessorsInitialized(com.alibaba.otter.canal.protocol.CanalEntry.Header.class, + com.alibaba.otter.canal.protocol.CanalEntry.Header.Builder.class); } - } - } - if (other.hasGtid()) { - bitField0_ |= 0x00001000; - gtid_ = other.gtid_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - public final boolean isInitialized() { - return true; - } + // Construct using + // com.alibaba.otter.canal.protocol.CanalEntry.Header.newBuilder() + private Builder(){ + maybeForceBuilderInitialization(); + } - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.alibaba.otter.canal.protocol.CanalEntry.Header parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.alibaba.otter.canal.protocol.CanalEntry.Header) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent){ + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getPropsFieldBuilder(); + } + } + + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + version_ = 1; + bitField0_ = (bitField0_ & ~0x00000001); + logfileName_ = ""; + bitField0_ = (bitField0_ & ~0x00000002); + logfileOffset_ = 0L; + bitField0_ = (bitField0_ & ~0x00000004); + serverId_ = 0L; + bitField0_ = (bitField0_ & ~0x00000008); + serverenCode_ = ""; + bitField0_ = (bitField0_ & ~0x00000010); + executeTime_ = 0L; + bitField0_ = (bitField0_ & ~0x00000020); + sourceType_ = com.alibaba.otter.canal.protocol.CanalEntry.Type.MYSQL; + bitField0_ = (bitField0_ & ~0x00000040); + schemaName_ = ""; + bitField0_ = (bitField0_ & ~0x00000080); + tableName_ = ""; + bitField0_ = (bitField0_ & ~0x00000100); + eventLength_ = 0L; + bitField0_ = (bitField0_ & ~0x00000200); + eventType_ = com.alibaba.otter.canal.protocol.CanalEntry.EventType.UPDATE; + bitField0_ = (bitField0_ & ~0x00000400); + if (propsBuilder_ == null) { + props_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000800); + } else { + propsBuilder_.clear(); + } + gtid_ = ""; + bitField0_ = (bitField0_ & ~0x00001000); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Header_descriptor; + } + + public com.alibaba.otter.canal.protocol.CanalEntry.Header getDefaultInstanceForType() { + return com.alibaba.otter.canal.protocol.CanalEntry.Header.getDefaultInstance(); + } + + public com.alibaba.otter.canal.protocol.CanalEntry.Header build() { + com.alibaba.otter.canal.protocol.CanalEntry.Header result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.alibaba.otter.canal.protocol.CanalEntry.Header buildPartial() { + com.alibaba.otter.canal.protocol.CanalEntry.Header result = new com.alibaba.otter.canal.protocol.CanalEntry.Header(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.version_ = version_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.logfileName_ = logfileName_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + result.logfileOffset_ = logfileOffset_; + if (((from_bitField0_ & 0x00000008) == 0x00000008)) { + to_bitField0_ |= 0x00000008; + } + result.serverId_ = serverId_; + if (((from_bitField0_ & 0x00000010) == 0x00000010)) { + to_bitField0_ |= 0x00000010; + } + result.serverenCode_ = serverenCode_; + if (((from_bitField0_ & 0x00000020) == 0x00000020)) { + to_bitField0_ |= 0x00000020; + } + result.executeTime_ = executeTime_; + if (((from_bitField0_ & 0x00000040) == 0x00000040)) { + to_bitField0_ |= 0x00000040; + } + result.sourceType_ = sourceType_; + if (((from_bitField0_ & 0x00000080) == 0x00000080)) { + to_bitField0_ |= 0x00000080; + } + result.schemaName_ = schemaName_; + if (((from_bitField0_ & 0x00000100) == 0x00000100)) { + to_bitField0_ |= 0x00000100; + } + result.tableName_ = tableName_; + if (((from_bitField0_ & 0x00000200) == 0x00000200)) { + to_bitField0_ |= 0x00000200; + } + result.eventLength_ = eventLength_; + if (((from_bitField0_ & 0x00000400) == 0x00000400)) { + to_bitField0_ |= 0x00000400; + } + result.eventType_ = eventType_; + if (propsBuilder_ == null) { + if (((bitField0_ & 0x00000800) == 0x00000800)) { + props_ = java.util.Collections.unmodifiableList(props_); + bitField0_ = (bitField0_ & ~0x00000800); + } + result.props_ = props_; + } else { + result.props_ = propsBuilder_.build(); + } + if (((from_bitField0_ & 0x00001000) == 0x00001000)) { + to_bitField0_ |= 0x00000800; + } + result.gtid_ = gtid_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.alibaba.otter.canal.protocol.CanalEntry.Header) { + return mergeFrom((com.alibaba.otter.canal.protocol.CanalEntry.Header) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.alibaba.otter.canal.protocol.CanalEntry.Header other) { + if (other == com.alibaba.otter.canal.protocol.CanalEntry.Header.getDefaultInstance()) return this; + if (other.hasVersion()) { + setVersion(other.getVersion()); + } + if (other.hasLogfileName()) { + bitField0_ |= 0x00000002; + logfileName_ = other.logfileName_; + onChanged(); + } + if (other.hasLogfileOffset()) { + setLogfileOffset(other.getLogfileOffset()); + } + if (other.hasServerId()) { + setServerId(other.getServerId()); + } + if (other.hasServerenCode()) { + bitField0_ |= 0x00000010; + serverenCode_ = other.serverenCode_; + onChanged(); + } + if (other.hasExecuteTime()) { + setExecuteTime(other.getExecuteTime()); + } + if (other.hasSourceType()) { + setSourceType(other.getSourceType()); + } + if (other.hasSchemaName()) { + bitField0_ |= 0x00000080; + schemaName_ = other.schemaName_; + onChanged(); + } + if (other.hasTableName()) { + bitField0_ |= 0x00000100; + tableName_ = other.tableName_; + onChanged(); + } + if (other.hasEventLength()) { + setEventLength(other.getEventLength()); + } + if (other.hasEventType()) { + setEventType(other.getEventType()); + } + if (propsBuilder_ == null) { + if (!other.props_.isEmpty()) { + if (props_.isEmpty()) { + props_ = other.props_; + bitField0_ = (bitField0_ & ~0x00000800); + } else { + ensurePropsIsMutable(); + props_.addAll(other.props_); + } + onChanged(); + } + } else { + if (!other.props_.isEmpty()) { + if (propsBuilder_.isEmpty()) { + propsBuilder_.dispose(); + propsBuilder_ = null; + props_ = other.props_; + bitField0_ = (bitField0_ & ~0x00000800); + propsBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getPropsFieldBuilder() : null; + } else { + propsBuilder_.addAllMessages(other.props_); + } + } + } + if (other.hasGtid()) { + bitField0_ |= 0x00001000; + gtid_ = other.gtid_; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.alibaba.otter.canal.protocol.CanalEntry.Header parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.alibaba.otter.canal.protocol.CanalEntry.Header) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private int version_ = 1; - private int version_ = 1; - /** * optional int32 version = 1 [default = 1]; * @@ -2808,10 +2789,10 @@ public final class CanalEntry { * *协议的版本号* * */ - public boolean hasVersion() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - + public boolean hasVersion() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** * optional int32 version = 1 [default = 1]; * @@ -2819,10 +2800,10 @@ public final class CanalEntry { * *协议的版本号* * */ - public int getVersion() { - return version_; - } - + public int getVersion() { + return version_; + } + /** * optional int32 version = 1 [default = 1]; * @@ -2830,13 +2811,13 @@ public final class CanalEntry { * *协议的版本号* * */ - public Builder setVersion(int value) { - bitField0_ |= 0x00000001; - version_ = value; - onChanged(); - return this; - } - + public Builder setVersion(int value) { + bitField0_ |= 0x00000001; + version_ = value; + onChanged(); + return this; + } + /** * optional int32 version = 1 [default = 1]; * @@ -2844,15 +2825,15 @@ public final class CanalEntry { * *协议的版本号* * */ - public Builder clearVersion() { - bitField0_ = (bitField0_ & ~0x00000001); - version_ = 1; - onChanged(); - return this; - } + public Builder clearVersion() { + bitField0_ = (bitField0_ & ~0x00000001); + version_ = 1; + onChanged(); + return this; + } - private java.lang.Object logfileName_ = ""; - + private java.lang.Object logfileName_ = ""; + /** * optional string logfileName = 2; * @@ -2860,10 +2841,10 @@ public final class CanalEntry { * *binlog/redolog 文件名* * */ - public boolean hasLogfileName() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - + public boolean hasLogfileName() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** * optional string logfileName = 2; * @@ -2871,21 +2852,20 @@ public final class CanalEntry { * *binlog/redolog 文件名* * */ - public java.lang.String getLogfileName() { - java.lang.Object ref = logfileName_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - logfileName_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - + public java.lang.String getLogfileName() { + java.lang.Object ref = logfileName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + logfileName_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** * optional string logfileName = 2; * @@ -2893,20 +2873,17 @@ public final class CanalEntry { * *binlog/redolog 文件名* * */ - public com.google.protobuf.ByteString - getLogfileNameBytes() { - java.lang.Object ref = logfileName_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - logfileName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - + public com.google.protobuf.ByteString getLogfileNameBytes() { + java.lang.Object ref = logfileName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + logfileName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** * optional string logfileName = 2; * @@ -2914,17 +2891,16 @@ public final class CanalEntry { * *binlog/redolog 文件名* * */ - public Builder setLogfileName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - logfileName_ = value; - onChanged(); - return this; - } - + public Builder setLogfileName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + logfileName_ = value; + onChanged(); + return this; + } + /** * optional string logfileName = 2; * @@ -2932,13 +2908,13 @@ public final class CanalEntry { * *binlog/redolog 文件名* * */ - public Builder clearLogfileName() { - bitField0_ = (bitField0_ & ~0x00000002); - logfileName_ = getDefaultInstance().getLogfileName(); - onChanged(); - return this; - } - + public Builder clearLogfileName() { + bitField0_ = (bitField0_ & ~0x00000002); + logfileName_ = getDefaultInstance().getLogfileName(); + onChanged(); + return this; + } + /** * optional string logfileName = 2; * @@ -2946,19 +2922,18 @@ public final class CanalEntry { * *binlog/redolog 文件名* * */ - public Builder setLogfileNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - logfileName_ = value; - onChanged(); - return this; - } + public Builder setLogfileNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + logfileName_ = value; + onChanged(); + return this; + } + + private long logfileOffset_; - private long logfileOffset_ ; - /** * optional int64 logfileOffset = 3; * @@ -2966,10 +2941,10 @@ public final class CanalEntry { * *binlog/redolog 文件的偏移位置* * */ - public boolean hasLogfileOffset() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - + public boolean hasLogfileOffset() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** * optional int64 logfileOffset = 3; * @@ -2977,10 +2952,10 @@ public final class CanalEntry { * *binlog/redolog 文件的偏移位置* * */ - public long getLogfileOffset() { - return logfileOffset_; - } - + public long getLogfileOffset() { + return logfileOffset_; + } + /** * optional int64 logfileOffset = 3; * @@ -2988,13 +2963,13 @@ public final class CanalEntry { * *binlog/redolog 文件的偏移位置* * */ - public Builder setLogfileOffset(long value) { - bitField0_ |= 0x00000004; - logfileOffset_ = value; - onChanged(); - return this; - } - + public Builder setLogfileOffset(long value) { + bitField0_ |= 0x00000004; + logfileOffset_ = value; + onChanged(); + return this; + } + /** * optional int64 logfileOffset = 3; * @@ -3002,15 +2977,15 @@ public final class CanalEntry { * *binlog/redolog 文件的偏移位置* * */ - public Builder clearLogfileOffset() { - bitField0_ = (bitField0_ & ~0x00000004); - logfileOffset_ = 0L; - onChanged(); - return this; - } + public Builder clearLogfileOffset() { + bitField0_ = (bitField0_ & ~0x00000004); + logfileOffset_ = 0L; + onChanged(); + return this; + } + + private long serverId_; - private long serverId_ ; - /** * optional int64 serverId = 4; * @@ -3018,10 +2993,10 @@ public final class CanalEntry { * *服务端serverId* * */ - public boolean hasServerId() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - + public boolean hasServerId() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** * optional int64 serverId = 4; * @@ -3029,10 +3004,10 @@ public final class CanalEntry { * *服务端serverId* * */ - public long getServerId() { - return serverId_; - } - + public long getServerId() { + return serverId_; + } + /** * optional int64 serverId = 4; * @@ -3040,13 +3015,13 @@ public final class CanalEntry { * *服务端serverId* * */ - public Builder setServerId(long value) { - bitField0_ |= 0x00000008; - serverId_ = value; - onChanged(); - return this; - } - + public Builder setServerId(long value) { + bitField0_ |= 0x00000008; + serverId_ = value; + onChanged(); + return this; + } + /** * optional int64 serverId = 4; * @@ -3054,15 +3029,15 @@ public final class CanalEntry { * *服务端serverId* * */ - public Builder clearServerId() { - bitField0_ = (bitField0_ & ~0x00000008); - serverId_ = 0L; - onChanged(); - return this; - } + public Builder clearServerId() { + bitField0_ = (bitField0_ & ~0x00000008); + serverId_ = 0L; + onChanged(); + return this; + } - private java.lang.Object serverenCode_ = ""; - + private java.lang.Object serverenCode_ = ""; + /** * optional string serverenCode = 5; * @@ -3070,10 +3045,10 @@ public final class CanalEntry { * * 变更数据的编码 * * */ - public boolean hasServerenCode() { - return ((bitField0_ & 0x00000010) == 0x00000010); - } - + public boolean hasServerenCode() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** * optional string serverenCode = 5; * @@ -3081,21 +3056,20 @@ public final class CanalEntry { * * 变更数据的编码 * * */ - public java.lang.String getServerenCode() { - java.lang.Object ref = serverenCode_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - serverenCode_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - + public java.lang.String getServerenCode() { + java.lang.Object ref = serverenCode_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + serverenCode_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** * optional string serverenCode = 5; * @@ -3103,20 +3077,17 @@ public final class CanalEntry { * * 变更数据的编码 * * */ - public com.google.protobuf.ByteString - getServerenCodeBytes() { - java.lang.Object ref = serverenCode_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - serverenCode_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - + public com.google.protobuf.ByteString getServerenCodeBytes() { + java.lang.Object ref = serverenCode_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + serverenCode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** * optional string serverenCode = 5; * @@ -3124,17 +3095,16 @@ public final class CanalEntry { * * 变更数据的编码 * * */ - public Builder setServerenCode( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000010; - serverenCode_ = value; - onChanged(); - return this; - } - + public Builder setServerenCode(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000010; + serverenCode_ = value; + onChanged(); + return this; + } + /** * optional string serverenCode = 5; * @@ -3142,13 +3112,13 @@ public final class CanalEntry { * * 变更数据的编码 * * */ - public Builder clearServerenCode() { - bitField0_ = (bitField0_ & ~0x00000010); - serverenCode_ = getDefaultInstance().getServerenCode(); - onChanged(); - return this; - } - + public Builder clearServerenCode() { + bitField0_ = (bitField0_ & ~0x00000010); + serverenCode_ = getDefaultInstance().getServerenCode(); + onChanged(); + return this; + } + /** * optional string serverenCode = 5; * @@ -3156,19 +3126,18 @@ public final class CanalEntry { * * 变更数据的编码 * * */ - public Builder setServerenCodeBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000010; - serverenCode_ = value; - onChanged(); - return this; - } + public Builder setServerenCodeBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000010; + serverenCode_ = value; + onChanged(); + return this; + } + + private long executeTime_; - private long executeTime_ ; - /** * optional int64 executeTime = 6; * @@ -3176,10 +3145,10 @@ public final class CanalEntry { * *变更数据的执行时间 * * */ - public boolean hasExecuteTime() { - return ((bitField0_ & 0x00000020) == 0x00000020); - } - + public boolean hasExecuteTime() { + return ((bitField0_ & 0x00000020) == 0x00000020); + } + /** * optional int64 executeTime = 6; * @@ -3187,10 +3156,10 @@ public final class CanalEntry { * *变更数据的执行时间 * * */ - public long getExecuteTime() { - return executeTime_; - } - + public long getExecuteTime() { + return executeTime_; + } + /** * optional int64 executeTime = 6; * @@ -3198,13 +3167,13 @@ public final class CanalEntry { * *变更数据的执行时间 * * */ - public Builder setExecuteTime(long value) { - bitField0_ |= 0x00000020; - executeTime_ = value; - onChanged(); - return this; - } - + public Builder setExecuteTime(long value) { + bitField0_ |= 0x00000020; + executeTime_ = value; + onChanged(); + return this; + } + /** * optional int64 executeTime = 6; * @@ -3212,15 +3181,15 @@ public final class CanalEntry { * *变更数据的执行时间 * * */ - public Builder clearExecuteTime() { - bitField0_ = (bitField0_ & ~0x00000020); - executeTime_ = 0L; - onChanged(); - return this; - } + public Builder clearExecuteTime() { + bitField0_ = (bitField0_ & ~0x00000020); + executeTime_ = 0L; + onChanged(); + return this; + } + + private com.alibaba.otter.canal.protocol.CanalEntry.Type sourceType_ = com.alibaba.otter.canal.protocol.CanalEntry.Type.MYSQL; - private com.alibaba.otter.canal.protocol.CanalEntry.Type sourceType_ = com.alibaba.otter.canal.protocol.CanalEntry.Type.MYSQL; - /** * optional .com.alibaba.otter.canal.protocol.Type sourceType = 7 [default = MYSQL]; * @@ -3228,10 +3197,10 @@ public final class CanalEntry { * * 变更数据的来源* * */ - public boolean hasSourceType() { - return ((bitField0_ & 0x00000040) == 0x00000040); - } - + public boolean hasSourceType() { + return ((bitField0_ & 0x00000040) == 0x00000040); + } + /** * optional .com.alibaba.otter.canal.protocol.Type sourceType = 7 [default = MYSQL]; * @@ -3239,10 +3208,10 @@ public final class CanalEntry { * * 变更数据的来源* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.Type getSourceType() { - return sourceType_; - } - + public com.alibaba.otter.canal.protocol.CanalEntry.Type getSourceType() { + return sourceType_; + } + /** * optional .com.alibaba.otter.canal.protocol.Type sourceType = 7 [default = MYSQL]; * @@ -3250,16 +3219,16 @@ public final class CanalEntry { * * 变更数据的来源* * */ - public Builder setSourceType(com.alibaba.otter.canal.protocol.CanalEntry.Type value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000040; - sourceType_ = value; - onChanged(); - return this; - } - + public Builder setSourceType(com.alibaba.otter.canal.protocol.CanalEntry.Type value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000040; + sourceType_ = value; + onChanged(); + return this; + } + /** * optional .com.alibaba.otter.canal.protocol.Type sourceType = 7 [default = MYSQL]; * @@ -3267,154 +3236,147 @@ public final class CanalEntry { * * 变更数据的来源* * */ - public Builder clearSourceType() { - bitField0_ = (bitField0_ & ~0x00000040); - sourceType_ = com.alibaba.otter.canal.protocol.CanalEntry.Type.MYSQL; - onChanged(); - return this; - } + public Builder clearSourceType() { + bitField0_ = (bitField0_ & ~0x00000040); + sourceType_ = com.alibaba.otter.canal.protocol.CanalEntry.Type.MYSQL; + onChanged(); + return this; + } - private java.lang.Object schemaName_ = ""; - - /** - * optional string schemaName = 8; - * - *
      -             * * 变更数据的schemaname*
      -             * 
      - */ - public boolean hasSchemaName() { - return ((bitField0_ & 0x00000080) == 0x00000080); - } - - /** - * optional string schemaName = 8; - * - *
      -             * * 变更数据的schemaname*
      -             * 
      - */ - public java.lang.String getSchemaName() { - java.lang.Object ref = schemaName_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - schemaName_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * optional string schemaName = 8; - * - *
      -             * * 变更数据的schemaname*
      -             * 
      - */ - public com.google.protobuf.ByteString - getSchemaNameBytes() { - java.lang.Object ref = schemaName_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - schemaName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * optional string schemaName = 8; - * - *
      -             * * 变更数据的schemaname*
      -             * 
      - */ - public Builder setSchemaName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000080; - schemaName_ = value; - onChanged(); - return this; - } - - /** - * optional string schemaName = 8; - * - *
      -             * * 变更数据的schemaname*
      -             * 
      - */ - public Builder clearSchemaName() { - bitField0_ = (bitField0_ & ~0x00000080); - schemaName_ = getDefaultInstance().getSchemaName(); - onChanged(); - return this; - } - - /** - * optional string schemaName = 8; - * - *
      -             * * 变更数据的schemaname*
      -             * 
      - */ - public Builder setSchemaNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000080; - schemaName_ = value; - onChanged(); - return this; - } + private java.lang.Object schemaName_ = ""; - private java.lang.Object tableName_ = ""; - /** - * optional string tableName = 9; + * optional string schemaName = 8; * *
      -             * *变更数据的tablename*
      +             * * 变更数据的schemaname*
                    * 
      */ - public boolean hasTableName() { - return ((bitField0_ & 0x00000100) == 0x00000100); - } - + public boolean hasSchemaName() { + return ((bitField0_ & 0x00000080) == 0x00000080); + } + /** + * optional string schemaName = 8; + * + *
      +             * * 变更数据的schemaname*
      +             * 
      + */ + public java.lang.String getSchemaName() { + java.lang.Object ref = schemaName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + schemaName_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * optional string schemaName = 8; + * + *
      +             * * 变更数据的schemaname*
      +             * 
      + */ + public com.google.protobuf.ByteString getSchemaNameBytes() { + java.lang.Object ref = schemaName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + schemaName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * optional string schemaName = 8; + * + *
      +             * * 变更数据的schemaname*
      +             * 
      + */ + public Builder setSchemaName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000080; + schemaName_ = value; + onChanged(); + return this; + } + + /** + * optional string schemaName = 8; + * + *
      +             * * 变更数据的schemaname*
      +             * 
      + */ + public Builder clearSchemaName() { + bitField0_ = (bitField0_ & ~0x00000080); + schemaName_ = getDefaultInstance().getSchemaName(); + onChanged(); + return this; + } + + /** + * optional string schemaName = 8; + * + *
      +             * * 变更数据的schemaname*
      +             * 
      + */ + public Builder setSchemaNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000080; + schemaName_ = value; + onChanged(); + return this; + } + + private java.lang.Object tableName_ = ""; + + /** + * optional string tableName = 9; + * + *
      +             * *变更数据的tablename*
      +             * 
      + */ + public boolean hasTableName() { + return ((bitField0_ & 0x00000100) == 0x00000100); + } + + /** * optional string tableName = 9; * *
                    * *变更数据的tablename*
                    * 
      */ - public java.lang.String getTableName() { - java.lang.Object ref = tableName_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - tableName_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - + public java.lang.String getTableName() { + java.lang.Object ref = tableName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + tableName_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** * optional string tableName = 9; * @@ -3422,20 +3384,17 @@ public final class CanalEntry { * *变更数据的tablename* * */ - public com.google.protobuf.ByteString - getTableNameBytes() { - java.lang.Object ref = tableName_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - tableName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - + public com.google.protobuf.ByteString getTableNameBytes() { + java.lang.Object ref = tableName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + tableName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** * optional string tableName = 9; * @@ -3443,17 +3402,16 @@ public final class CanalEntry { * *变更数据的tablename* * */ - public Builder setTableName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000100; - tableName_ = value; - onChanged(); - return this; - } - + public Builder setTableName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000100; + tableName_ = value; + onChanged(); + return this; + } + /** * optional string tableName = 9; * @@ -3461,13 +3419,13 @@ public final class CanalEntry { * *变更数据的tablename* * */ - public Builder clearTableName() { - bitField0_ = (bitField0_ & ~0x00000100); - tableName_ = getDefaultInstance().getTableName(); - onChanged(); - return this; - } - + public Builder clearTableName() { + bitField0_ = (bitField0_ & ~0x00000100); + tableName_ = getDefaultInstance().getTableName(); + onChanged(); + return this; + } + /** * optional string tableName = 9; * @@ -3475,19 +3433,18 @@ public final class CanalEntry { * *变更数据的tablename* * */ - public Builder setTableNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000100; - tableName_ = value; - onChanged(); - return this; - } + public Builder setTableNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000100; + tableName_ = value; + onChanged(); + return this; + } + + private long eventLength_; - private long eventLength_ ; - /** * optional int64 eventLength = 10; * @@ -3495,10 +3452,10 @@ public final class CanalEntry { * *每个event的长度* * */ - public boolean hasEventLength() { - return ((bitField0_ & 0x00000200) == 0x00000200); - } - + public boolean hasEventLength() { + return ((bitField0_ & 0x00000200) == 0x00000200); + } + /** * optional int64 eventLength = 10; * @@ -3506,10 +3463,10 @@ public final class CanalEntry { * *每个event的长度* * */ - public long getEventLength() { - return eventLength_; - } - + public long getEventLength() { + return eventLength_; + } + /** * optional int64 eventLength = 10; * @@ -3517,13 +3474,13 @@ public final class CanalEntry { * *每个event的长度* * */ - public Builder setEventLength(long value) { - bitField0_ |= 0x00000200; - eventLength_ = value; - onChanged(); - return this; - } - + public Builder setEventLength(long value) { + bitField0_ |= 0x00000200; + eventLength_ = value; + onChanged(); + return this; + } + /** * optional int64 eventLength = 10; * @@ -3531,15 +3488,15 @@ public final class CanalEntry { * *每个event的长度* * */ - public Builder clearEventLength() { - bitField0_ = (bitField0_ & ~0x00000200); - eventLength_ = 0L; - onChanged(); - return this; - } + public Builder clearEventLength() { + bitField0_ = (bitField0_ & ~0x00000200); + eventLength_ = 0L; + onChanged(); + return this; + } + + private com.alibaba.otter.canal.protocol.CanalEntry.EventType eventType_ = com.alibaba.otter.canal.protocol.CanalEntry.EventType.UPDATE; - private com.alibaba.otter.canal.protocol.CanalEntry.EventType eventType_ = com.alibaba.otter.canal.protocol.CanalEntry.EventType.UPDATE; - /** * optional .com.alibaba.otter.canal.protocol.EventType eventType = 11 [default = UPDATE]; * @@ -3547,10 +3504,10 @@ public final class CanalEntry { * *数据变更类型* * */ - public boolean hasEventType() { - return ((bitField0_ & 0x00000400) == 0x00000400); - } - + public boolean hasEventType() { + return ((bitField0_ & 0x00000400) == 0x00000400); + } + /** * optional .com.alibaba.otter.canal.protocol.EventType eventType = 11 [default = UPDATE]; * @@ -3558,10 +3515,10 @@ public final class CanalEntry { * *数据变更类型* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.EventType getEventType() { - return eventType_; - } - + public com.alibaba.otter.canal.protocol.CanalEntry.EventType getEventType() { + return eventType_; + } + /** * optional .com.alibaba.otter.canal.protocol.EventType eventType = 11 [default = UPDATE]; * @@ -3569,16 +3526,16 @@ public final class CanalEntry { * *数据变更类型* * */ - public Builder setEventType(com.alibaba.otter.canal.protocol.CanalEntry.EventType value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000400; - eventType_ = value; - onChanged(); - return this; - } - + public Builder setEventType(com.alibaba.otter.canal.protocol.CanalEntry.EventType value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000400; + eventType_ = value; + onChanged(); + return this; + } + /** * optional .com.alibaba.otter.canal.protocol.EventType eventType = 11 [default = UPDATE]; * @@ -3586,24 +3543,23 @@ public final class CanalEntry { * *数据变更类型* * */ - public Builder clearEventType() { - bitField0_ = (bitField0_ & ~0x00000400); - eventType_ = com.alibaba.otter.canal.protocol.CanalEntry.EventType.UPDATE; - onChanged(); - return this; - } + public Builder clearEventType() { + bitField0_ = (bitField0_ & ~0x00000400); + eventType_ = com.alibaba.otter.canal.protocol.CanalEntry.EventType.UPDATE; + onChanged(); + return this; + } - private java.util.List props_ = - java.util.Collections.emptyList(); - private void ensurePropsIsMutable() { - if (!((bitField0_ & 0x00000800) == 0x00000800)) { - props_ = new java.util.ArrayList(props_); - bitField0_ |= 0x00000800; - } - } + private java.util.List props_ = java.util.Collections.emptyList(); - private com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Pair, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder, com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder> propsBuilder_; + private void ensurePropsIsMutable() { + if (!((bitField0_ & 0x00000800) == 0x00000800)) { + props_ = new java.util.ArrayList(props_); + bitField0_ |= 0x00000800; + } + } + + private com.google.protobuf.RepeatedFieldBuilder propsBuilder_; /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; @@ -3612,436 +3568,415 @@ public final class CanalEntry { * *预留扩展* * */ - public java.util.List getPropsList() { - if (propsBuilder_ == null) { - return java.util.Collections.unmodifiableList(props_); - } else { - return propsBuilder_.getMessageList(); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public int getPropsCount() { - if (propsBuilder_ == null) { - return props_.size(); - } else { - return propsBuilder_.getCount(); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { - if (propsBuilder_ == null) { - return props_.get(index); - } else { - return propsBuilder_.getMessage(index); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder setProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { - if (propsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePropsIsMutable(); - props_.set(index, value); - onChanged(); - } else { - propsBuilder_.setMessage(index, value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder setProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.set(index, builderForValue.build()); - onChanged(); - } else { - propsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder addProps(com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { - if (propsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePropsIsMutable(); - props_.add(value); - onChanged(); - } else { - propsBuilder_.addMessage(value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder addProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { - if (propsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePropsIsMutable(); - props_.add(index, value); - onChanged(); - } else { - propsBuilder_.addMessage(index, value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder addProps( - com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.add(builderForValue.build()); - onChanged(); - } else { - propsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder addProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.add(index, builderForValue.build()); - onChanged(); - } else { - propsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder addAllProps( - java.lang.Iterable values) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, props_); - onChanged(); - } else { - propsBuilder_.addAllMessages(values); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder clearProps() { - if (propsBuilder_ == null) { - props_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000800); - onChanged(); - } else { - propsBuilder_.clear(); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder removeProps(int index) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.remove(index); - onChanged(); - } else { - propsBuilder_.remove(index); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder getPropsBuilder( - int index) { - return getPropsFieldBuilder().getBuilder(index); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder( - int index) { - if (propsBuilder_ == null) { - return props_.get(index); } else { - return propsBuilder_.getMessageOrBuilder(index); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public java.util.List - getPropsOrBuilderList() { - if (propsBuilder_ != null) { - return propsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(props_); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder() { - return getPropsFieldBuilder().addBuilder( - com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder( - int index) { - return getPropsFieldBuilder().addBuilder( - index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public java.util.List - getPropsBuilderList() { - return getPropsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Pair, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder, com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder> - getPropsFieldBuilder() { - if (propsBuilder_ == null) { - propsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Pair, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder, com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder>( - props_, - ((bitField0_ & 0x00000800) == 0x00000800), - getParentForChildren(), - isClean()); - props_ = null; - } - return propsBuilder_; - } + public java.util.List getPropsList() { + if (propsBuilder_ == null) { + return java.util.Collections.unmodifiableList(props_); + } else { + return propsBuilder_.getMessageList(); + } + } - private java.lang.Object gtid_ = ""; - /** - * optional string gtid = 13; + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; * *
      -             * *当前事务的gitd*
      +             * *预留扩展*
                    * 
      */ - public boolean hasGtid() { - return ((bitField0_ & 0x00001000) == 0x00001000); - } - - /** - * optional string gtid = 13; - * - *
      -             * *当前事务的gitd*
      -             * 
      - */ - public java.lang.String getGtid() { - java.lang.Object ref = gtid_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - gtid_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * optional string gtid = 13; - * - *
      -             * *当前事务的gitd*
      -             * 
      - */ - public com.google.protobuf.ByteString - getGtidBytes() { - java.lang.Object ref = gtid_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - gtid_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * optional string gtid = 13; - * - *
      -             * *当前事务的gitd*
      -             * 
      - */ - public Builder setGtid( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00001000; - gtid_ = value; - onChanged(); - return this; - } - - /** - * optional string gtid = 13; - * - *
      -             * *当前事务的gitd*
      -             * 
      - */ - public Builder clearGtid() { - bitField0_ = (bitField0_ & ~0x00001000); - gtid_ = getDefaultInstance().getGtid(); - onChanged(); - return this; - } - - /** - * optional string gtid = 13; - * - *
      -             * *当前事务的gitd*
      -             * 
      - */ - public Builder setGtidBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00001000; - gtid_ = value; - onChanged(); - return this; - } + public int getPropsCount() { + if (propsBuilder_ == null) { + return props_.size(); + } else { + return propsBuilder_.getCount(); + } + } - // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.Header) + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { + if (propsBuilder_ == null) { + return props_.get(index); + } else { + return propsBuilder_.getMessage(index); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder setProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { + if (propsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropsIsMutable(); + props_.set(index, value); + onChanged(); + } else { + propsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder setProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.set(index, builderForValue.build()); + onChanged(); + } else { + propsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder addProps(com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { + if (propsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropsIsMutable(); + props_.add(value); + onChanged(); + } else { + propsBuilder_.addMessage(value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder addProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { + if (propsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropsIsMutable(); + props_.add(index, value); + onChanged(); + } else { + propsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder addProps(com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.add(builderForValue.build()); + onChanged(); + } else { + propsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder addProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.add(index, builderForValue.build()); + onChanged(); + } else { + propsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder addAllProps(java.lang.Iterable values) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, props_); + onChanged(); + } else { + propsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder clearProps() { + if (propsBuilder_ == null) { + props_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000800); + onChanged(); + } else { + propsBuilder_.clear(); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder removeProps(int index) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.remove(index); + onChanged(); + } else { + propsBuilder_.remove(index); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder getPropsBuilder(int index) { + return getPropsFieldBuilder().getBuilder(index); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index) { + if (propsBuilder_ == null) { + return props_.get(index); + } else { + return propsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public java.util.List getPropsOrBuilderList() { + if (propsBuilder_ != null) { + return propsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(props_); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder() { + return getPropsFieldBuilder().addBuilder(com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder(int index) { + return getPropsFieldBuilder().addBuilder(index, + com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public java.util.List getPropsBuilderList() { + return getPropsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder getPropsFieldBuilder() { + if (propsBuilder_ == null) { + propsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder(props_, + ((bitField0_ & 0x00000800) == 0x00000800), + getParentForChildren(), + isClean()); + props_ = null; + } + return propsBuilder_; + } + + private java.lang.Object gtid_ = ""; + + /** + * optional string gtid = 13; + * + *
      +             * *当前事务的gitd*
      +             * 
      + */ + public boolean hasGtid() { + return ((bitField0_ & 0x00001000) == 0x00001000); + } + + /** + * optional string gtid = 13; + * + *
      +             * *当前事务的gitd*
      +             * 
      + */ + public java.lang.String getGtid() { + java.lang.Object ref = gtid_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + gtid_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * optional string gtid = 13; + * + *
      +             * *当前事务的gitd*
      +             * 
      + */ + public com.google.protobuf.ByteString getGtidBytes() { + java.lang.Object ref = gtid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + gtid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * optional string gtid = 13; + * + *
      +             * *当前事务的gitd*
      +             * 
      + */ + public Builder setGtid(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00001000; + gtid_ = value; + onChanged(); + return this; + } + + /** + * optional string gtid = 13; + * + *
      +             * *当前事务的gitd*
      +             * 
      + */ + public Builder clearGtid() { + bitField0_ = (bitField0_ & ~0x00001000); + gtid_ = getDefaultInstance().getGtid(); + onChanged(); + return this; + } + + /** + * optional string gtid = 13; + * + *
      +             * *当前事务的gitd*
      +             * 
      + */ + public Builder setGtidBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00001000; + gtid_ = value; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.Header) + } + + static { + defaultInstance = new Header(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.Header) } - static { - defaultInstance = new Header(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.Header) - } - - public interface ColumnOrBuilder extends - // @@protoc_insertion_point(interface_extends:com.alibaba.otter.canal.protocol.Column) - com.google.protobuf.MessageOrBuilder { + public interface ColumnOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.alibaba.otter.canal.protocol.Column) + com.google.protobuf.MessageOrBuilder { /** * optional int32 index = 1; @@ -4050,8 +3985,8 @@ public final class CanalEntry { * *字段下标* * */ - boolean hasIndex(); - + boolean hasIndex(); + /** * optional int32 index = 1; * @@ -4059,7 +3994,7 @@ public final class CanalEntry { * *字段下标* * */ - int getIndex(); + int getIndex(); /** * optional int32 sqlType = 2; @@ -4068,8 +4003,8 @@ public final class CanalEntry { * *字段java中类型* * */ - boolean hasSqlType(); - + boolean hasSqlType(); + /** * optional int32 sqlType = 2; * @@ -4077,7 +4012,7 @@ public final class CanalEntry { * *字段java中类型* * */ - int getSqlType(); + int getSqlType(); /** * optional string name = 3; @@ -4086,8 +4021,8 @@ public final class CanalEntry { * *字段名称(忽略大小写),在mysql中是没有的* * */ - boolean hasName(); - + boolean hasName(); + /** * optional string name = 3; * @@ -4095,8 +4030,8 @@ public final class CanalEntry { * *字段名称(忽略大小写),在mysql中是没有的* * */ - java.lang.String getName(); - + java.lang.String getName(); + /** * optional string name = 3; * @@ -4104,8 +4039,7 @@ public final class CanalEntry { * *字段名称(忽略大小写),在mysql中是没有的* * */ - com.google.protobuf.ByteString - getNameBytes(); + com.google.protobuf.ByteString getNameBytes(); /** * optional bool isKey = 4; @@ -4114,8 +4048,8 @@ public final class CanalEntry { * *是否是主键* * */ - boolean hasIsKey(); - + boolean hasIsKey(); + /** * optional bool isKey = 4; * @@ -4123,7 +4057,7 @@ public final class CanalEntry { * *是否是主键* * */ - boolean getIsKey(); + boolean getIsKey(); /** * optional bool updated = 5; @@ -4132,8 +4066,8 @@ public final class CanalEntry { * *如果EventType=UPDATE,用于标识这个字段值是否有修改* * */ - boolean hasUpdated(); - + boolean hasUpdated(); + /** * optional bool updated = 5; * @@ -4141,7 +4075,7 @@ public final class CanalEntry { * *如果EventType=UPDATE,用于标识这个字段值是否有修改* * */ - boolean getUpdated(); + boolean getUpdated(); /** * optional bool isNull = 6 [default = false]; @@ -4150,8 +4084,8 @@ public final class CanalEntry { * * 标识是否为空 * * */ - boolean hasIsNull(); - + boolean hasIsNull(); + /** * optional bool isNull = 6 [default = false]; * @@ -4159,7 +4093,7 @@ public final class CanalEntry { * * 标识是否为空 * * */ - boolean getIsNull(); + boolean getIsNull(); /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; @@ -4168,9 +4102,8 @@ public final class CanalEntry { * *预留扩展* * */ - java.util.List - getPropsList(); - + java.util.List getPropsList(); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; * @@ -4178,8 +4111,8 @@ public final class CanalEntry { * *预留扩展* * */ - com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index); - + com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; * @@ -4187,8 +4120,8 @@ public final class CanalEntry { * *预留扩展* * */ - int getPropsCount(); - + int getPropsCount(); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; * @@ -4196,9 +4129,8 @@ public final class CanalEntry { * *预留扩展* * */ - java.util.List - getPropsOrBuilderList(); - + java.util.List getPropsOrBuilderList(); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; * @@ -4206,8 +4138,7 @@ public final class CanalEntry { * *预留扩展* * */ - com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder( - int index); + com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index); /** * optional string value = 8; @@ -4216,8 +4147,8 @@ public final class CanalEntry { * * 字段值,timestamp,Datetime是一个时间格式的文本 * * */ - boolean hasValue(); - + boolean hasValue(); + /** * optional string value = 8; * @@ -4225,8 +4156,8 @@ public final class CanalEntry { * * 字段值,timestamp,Datetime是一个时间格式的文本 * * */ - java.lang.String getValue(); - + java.lang.String getValue(); + /** * optional string value = 8; * @@ -4234,8 +4165,7 @@ public final class CanalEntry { * * 字段值,timestamp,Datetime是一个时间格式的文本 * * */ - com.google.protobuf.ByteString - getValueBytes(); + com.google.protobuf.ByteString getValueBytes(); /** * optional int32 length = 9; @@ -4244,8 +4174,8 @@ public final class CanalEntry { * * 对应数据对象原始长度 * * */ - boolean hasLength(); - + boolean hasLength(); + /** * optional int32 length = 9; * @@ -4253,7 +4183,7 @@ public final class CanalEntry { * * 对应数据对象原始长度 * * */ - int getLength(); + int getLength(); /** * optional string mysqlType = 10; @@ -4262,8 +4192,8 @@ public final class CanalEntry { * *字段mysql类型* * */ - boolean hasMysqlType(); - + boolean hasMysqlType(); + /** * optional string mysqlType = 10; * @@ -4271,8 +4201,8 @@ public final class CanalEntry { * *字段mysql类型* * */ - java.lang.String getMysqlType(); - + java.lang.String getMysqlType(); + /** * optional string mysqlType = 10; * @@ -4280,10 +4210,9 @@ public final class CanalEntry { * *字段mysql类型* * */ - com.google.protobuf.ByteString - getMysqlTypeBytes(); - } - + com.google.protobuf.ByteString getMysqlTypeBytes(); + } + /** * Protobuf type {@code com.alibaba.otter.canal.protocol.Column} * @@ -4291,157 +4220,156 @@ public final class CanalEntry { * *每个字段的数据结构* * */ - public static final class Column extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:com.alibaba.otter.canal.protocol.Column) - ColumnOrBuilder { - // Use Column.newBuilder() to construct. - private Column(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private Column(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + public static final class Column extends com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:com.alibaba.otter.canal.protocol.Column) + ColumnOrBuilder { - private static final Column defaultInstance; - public static Column getDefaultInstance() { - return defaultInstance; - } - - public Column getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private Column( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - bitField0_ |= 0x00000001; - index_ = input.readInt32(); - break; - } - case 16: { - bitField0_ |= 0x00000002; - sqlType_ = input.readInt32(); - break; - } - case 26: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000004; - name_ = bs; - break; - } - case 32: { - bitField0_ |= 0x00000008; - isKey_ = input.readBool(); - break; - } - case 40: { - bitField0_ |= 0x00000010; - updated_ = input.readBool(); - break; - } - case 48: { - bitField0_ |= 0x00000020; - isNull_ = input.readBool(); - break; - } - case 58: { - if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) { - props_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000040; - } - props_.add(input.readMessage(com.alibaba.otter.canal.protocol.CanalEntry.Pair.PARSER, extensionRegistry)); - break; - } - case 66: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000040; - value_ = bs; - break; - } - case 72: { - bitField0_ |= 0x00000080; - length_ = input.readInt32(); - break; - } - case 82: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000100; - mysqlType_ = bs; - break; - } - } + // Use Column.newBuilder() to construct. + private Column(com.google.protobuf.GeneratedMessage.Builder builder){ + super(builder); + this.unknownFields = builder.getUnknownFields(); } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000040) == 0x00000040)) { - props_ = java.util.Collections.unmodifiableList(props_); + + private Column(boolean noInit){ + this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Column_descriptor; - } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Column_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.alibaba.otter.canal.protocol.CanalEntry.Column.class, com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder.class); - } + private static final Column defaultInstance; - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public Column parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Column(input, extensionRegistry); - } - }; + public static Column getDefaultInstance() { + return defaultInstance; + } - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } + public Column getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private Column(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException{ + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + bitField0_ |= 0x00000001; + index_ = input.readInt32(); + break; + } + case 16: { + bitField0_ |= 0x00000002; + sqlType_ = input.readInt32(); + break; + } + case 26: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000004; + name_ = bs; + break; + } + case 32: { + bitField0_ |= 0x00000008; + isKey_ = input.readBool(); + break; + } + case 40: { + bitField0_ |= 0x00000010; + updated_ = input.readBool(); + break; + } + case 48: { + bitField0_ |= 0x00000020; + isNull_ = input.readBool(); + break; + } + case 58: { + if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) { + props_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000040; + } + props_.add(input.readMessage(com.alibaba.otter.canal.protocol.CanalEntry.Pair.PARSER, + extensionRegistry)); + break; + } + case 66: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000040; + value_ = bs; + break; + } + case 72: { + bitField0_ |= 0x00000080; + length_ = input.readInt32(); + break; + } + case 82: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000100; + mysqlType_ = bs; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e.getMessage()).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000040) == 0x00000040)) { + props_ = java.util.Collections.unmodifiableList(props_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Column_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Column_fieldAccessorTable.ensureFieldAccessorsInitialized(com.alibaba.otter.canal.protocol.CanalEntry.Column.class, + com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + + public Column parsePartialFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Column(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + public static final int INDEX_FIELD_NUMBER = 1; + private int index_; - private int bitField0_; - public static final int INDEX_FIELD_NUMBER = 1; - private int index_; - /** * optional int32 index = 1; * @@ -4449,10 +4377,10 @@ public final class CanalEntry { * *字段下标* * */ - public boolean hasIndex() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - + public boolean hasIndex() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** * optional int32 index = 1; * @@ -4460,13 +4388,13 @@ public final class CanalEntry { * *字段下标* * */ - public int getIndex() { - return index_; - } + public int getIndex() { + return index_; + } + + public static final int SQLTYPE_FIELD_NUMBER = 2; + private int sqlType_; - public static final int SQLTYPE_FIELD_NUMBER = 2; - private int sqlType_; - /** * optional int32 sqlType = 2; * @@ -4474,10 +4402,10 @@ public final class CanalEntry { * *字段java中类型* * */ - public boolean hasSqlType() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - + public boolean hasSqlType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** * optional int32 sqlType = 2; * @@ -4485,46 +4413,13 @@ public final class CanalEntry { * *字段java中类型* * */ - public int getSqlType() { - return sqlType_; - } - - public static final int NAME_FIELD_NUMBER = 3; - private java.lang.Object name_; - - /** - * optional string name = 3; - * - *
      -         * *字段名称(忽略大小写),在mysql中是没有的*
      -         * 
      - */ - public boolean hasName() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - - /** - * optional string name = 3; - * - *
      -         * *字段名称(忽略大小写),在mysql中是没有的*
      -         * 
      - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - name_ = s; + public int getSqlType() { + return sqlType_; } - return s; - } - } - + + public static final int NAME_FIELD_NUMBER = 3; + private java.lang.Object name_; + /** * optional string name = 3; * @@ -4532,23 +4427,52 @@ public final class CanalEntry { * *字段名称(忽略大小写),在mysql中是没有的* * */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } + public boolean hasName() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + + /** + * optional string name = 3; + * + *
      +         * *字段名称(忽略大小写),在mysql中是没有的*
      +         * 
      + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + name_ = s; + } + return s; + } + } + + /** + * optional string name = 3; + * + *
      +         * *字段名称(忽略大小写),在mysql中是没有的*
      +         * 
      + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ISKEY_FIELD_NUMBER = 4; + private boolean isKey_; - public static final int ISKEY_FIELD_NUMBER = 4; - private boolean isKey_; - /** * optional bool isKey = 4; * @@ -4556,10 +4480,10 @@ public final class CanalEntry { * *是否是主键* * */ - public boolean hasIsKey() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - + public boolean hasIsKey() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** * optional bool isKey = 4; * @@ -4567,13 +4491,13 @@ public final class CanalEntry { * *是否是主键* * */ - public boolean getIsKey() { - return isKey_; - } + public boolean getIsKey() { + return isKey_; + } + + public static final int UPDATED_FIELD_NUMBER = 5; + private boolean updated_; - public static final int UPDATED_FIELD_NUMBER = 5; - private boolean updated_; - /** * optional bool updated = 5; * @@ -4581,10 +4505,10 @@ public final class CanalEntry { * *如果EventType=UPDATE,用于标识这个字段值是否有修改* * */ - public boolean hasUpdated() { - return ((bitField0_ & 0x00000010) == 0x00000010); - } - + public boolean hasUpdated() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** * optional bool updated = 5; * @@ -4592,13 +4516,13 @@ public final class CanalEntry { * *如果EventType=UPDATE,用于标识这个字段值是否有修改* * */ - public boolean getUpdated() { - return updated_; - } + public boolean getUpdated() { + return updated_; + } + + public static final int ISNULL_FIELD_NUMBER = 6; + private boolean isNull_; - public static final int ISNULL_FIELD_NUMBER = 6; - private boolean isNull_; - /** * optional bool isNull = 6 [default = false]; * @@ -4606,10 +4530,10 @@ public final class CanalEntry { * * 标识是否为空 * * */ - public boolean hasIsNull() { - return ((bitField0_ & 0x00000020) == 0x00000020); - } - + public boolean hasIsNull() { + return ((bitField0_ & 0x00000020) == 0x00000020); + } + /** * optional bool isNull = 6 [default = false]; * @@ -4617,106 +4541,71 @@ public final class CanalEntry { * * 标识是否为空 * * */ - public boolean getIsNull() { - return isNull_; - } - - public static final int PROPS_FIELD_NUMBER = 7; - private java.util.List props_; - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -         * *预留扩展*
      -         * 
      - */ - public java.util.List getPropsList() { - return props_; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -         * *预留扩展*
      -         * 
      - */ - public java.util.List - getPropsOrBuilderList() { - return props_; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -         * *预留扩展*
      -         * 
      - */ - public int getPropsCount() { - return props_.size(); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -         * *预留扩展*
      -         * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { - return props_.get(index); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -         * *预留扩展*
      -         * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder( - int index) { - return props_.get(index); - } - - public static final int VALUE_FIELD_NUMBER = 8; - private java.lang.Object value_; - - /** - * optional string value = 8; - * - *
      -         * * 字段值,timestamp,Datetime是一个时间格式的文本 *
      -         * 
      - */ - public boolean hasValue() { - return ((bitField0_ & 0x00000040) == 0x00000040); - } - - /** - * optional string value = 8; - * - *
      -         * * 字段值,timestamp,Datetime是一个时间格式的文本 *
      -         * 
      - */ - public java.lang.String getValue() { - java.lang.Object ref = value_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - value_ = s; + public boolean getIsNull() { + return isNull_; } - return s; - } - } - + + public static final int PROPS_FIELD_NUMBER = 7; + private java.util.List props_; + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public java.util.List getPropsList() { + return props_; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public java.util.List getPropsOrBuilderList() { + return props_; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public int getPropsCount() { + return props_.size(); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { + return props_.get(index); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index) { + return props_.get(index); + } + + public static final int VALUE_FIELD_NUMBER = 8; + private java.lang.Object value_; + /** * optional string value = 8; * @@ -4724,23 +4613,52 @@ public final class CanalEntry { * * 字段值,timestamp,Datetime是一个时间格式的文本 * * */ - public com.google.protobuf.ByteString - getValueBytes() { - java.lang.Object ref = value_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - value_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } + public boolean hasValue() { + return ((bitField0_ & 0x00000040) == 0x00000040); + } + + /** + * optional string value = 8; + * + *
      +         * * 字段值,timestamp,Datetime是一个时间格式的文本 *
      +         * 
      + */ + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + value_ = s; + } + return s; + } + } + + /** + * optional string value = 8; + * + *
      +         * * 字段值,timestamp,Datetime是一个时间格式的文本 *
      +         * 
      + */ + public com.google.protobuf.ByteString getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int LENGTH_FIELD_NUMBER = 9; + private int length_; - public static final int LENGTH_FIELD_NUMBER = 9; - private int length_; - /** * optional int32 length = 9; * @@ -4748,10 +4666,10 @@ public final class CanalEntry { * * 对应数据对象原始长度 * * */ - public boolean hasLength() { - return ((bitField0_ & 0x00000080) == 0x00000080); - } - + public boolean hasLength() { + return ((bitField0_ & 0x00000080) == 0x00000080); + } + /** * optional int32 length = 9; * @@ -4759,46 +4677,13 @@ public final class CanalEntry { * * 对应数据对象原始长度 * * */ - public int getLength() { - return length_; - } - - public static final int MYSQLTYPE_FIELD_NUMBER = 10; - private java.lang.Object mysqlType_; - - /** - * optional string mysqlType = 10; - * - *
      -         * *字段mysql类型*
      -         * 
      - */ - public boolean hasMysqlType() { - return ((bitField0_ & 0x00000100) == 0x00000100); - } - - /** - * optional string mysqlType = 10; - * - *
      -         * *字段mysql类型*
      -         * 
      - */ - public java.lang.String getMysqlType() { - java.lang.Object ref = mysqlType_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - mysqlType_ = s; + public int getLength() { + return length_; } - return s; - } - } - + + public static final int MYSQLTYPE_FIELD_NUMBER = 10; + private java.lang.Object mysqlType_; + /** * optional string mysqlType = 10; * @@ -4806,203 +4691,234 @@ public final class CanalEntry { * *字段mysql类型* * */ - public com.google.protobuf.ByteString - getMysqlTypeBytes() { - java.lang.Object ref = mysqlType_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - mysqlType_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } + public boolean hasMysqlType() { + return ((bitField0_ & 0x00000100) == 0x00000100); + } - private void initFields() { - index_ = 0; - sqlType_ = 0; - name_ = ""; - isKey_ = false; - updated_ = false; - isNull_ = false; - props_ = java.util.Collections.emptyList(); - value_ = ""; - length_ = 0; - mysqlType_ = ""; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; + /** + * optional string mysqlType = 10; + * + *
      +         * *字段mysql类型*
      +         * 
      + */ + public java.lang.String getMysqlType() { + java.lang.Object ref = mysqlType_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + mysqlType_ = s; + } + return s; + } + } - memoizedIsInitialized = 1; - return true; - } + /** + * optional string mysqlType = 10; + * + *
      +         * *字段mysql类型*
      +         * 
      + */ + public com.google.protobuf.ByteString getMysqlTypeBytes() { + java.lang.Object ref = mysqlType_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + mysqlType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeInt32(1, index_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeInt32(2, sqlType_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeBytes(3, getNameBytes()); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - output.writeBool(4, isKey_); - } - if (((bitField0_ & 0x00000010) == 0x00000010)) { - output.writeBool(5, updated_); - } - if (((bitField0_ & 0x00000020) == 0x00000020)) { - output.writeBool(6, isNull_); - } - for (int i = 0; i < props_.size(); i++) { - output.writeMessage(7, props_.get(i)); - } - if (((bitField0_ & 0x00000040) == 0x00000040)) { - output.writeBytes(8, getValueBytes()); - } - if (((bitField0_ & 0x00000080) == 0x00000080)) { - output.writeInt32(9, length_); - } - if (((bitField0_ & 0x00000100) == 0x00000100)) { - output.writeBytes(10, getMysqlTypeBytes()); - } - getUnknownFields().writeTo(output); - } + private void initFields() { + index_ = 0; + sqlType_ = 0; + name_ = ""; + isKey_ = false; + updated_ = false; + isNull_ = false; + props_ = java.util.Collections.emptyList(); + value_ = ""; + length_ = 0; + mysqlType_ = ""; + } - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; + private byte memoizedIsInitialized = -1; - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(1, index_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(2, sqlType_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(3, getNameBytes()); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - size += com.google.protobuf.CodedOutputStream - .computeBoolSize(4, isKey_); - } - if (((bitField0_ & 0x00000010) == 0x00000010)) { - size += com.google.protobuf.CodedOutputStream - .computeBoolSize(5, updated_); - } - if (((bitField0_ & 0x00000020) == 0x00000020)) { - size += com.google.protobuf.CodedOutputStream - .computeBoolSize(6, isNull_); - } - for (int i = 0; i < props_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(7, props_.get(i)); - } - if (((bitField0_ & 0x00000040) == 0x00000040)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(8, getValueBytes()); - } - if (((bitField0_ & 0x00000080) == 0x00000080)) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(9, length_); - } - if (((bitField0_ & 0x00000100) == 0x00000100)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(10, getMysqlTypeBytes()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } + memoizedIsInitialized = 1; + return true; + } - public static com.alibaba.otter.canal.protocol.CanalEntry.Column parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Column parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Column parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Column parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Column parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Column parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Column parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Column parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Column parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Column parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeInt32(1, index_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeInt32(2, sqlType_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeBytes(3, getNameBytes()); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + output.writeBool(4, isKey_); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + output.writeBool(5, updated_); + } + if (((bitField0_ & 0x00000020) == 0x00000020)) { + output.writeBool(6, isNull_); + } + for (int i = 0; i < props_.size(); i++) { + output.writeMessage(7, props_.get(i)); + } + if (((bitField0_ & 0x00000040) == 0x00000040)) { + output.writeBytes(8, getValueBytes()); + } + if (((bitField0_ & 0x00000080) == 0x00000080)) { + output.writeInt32(9, length_); + } + if (((bitField0_ & 0x00000100) == 0x00000100)) { + output.writeBytes(10, getMysqlTypeBytes()); + } + getUnknownFields().writeTo(output); + } - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(com.alibaba.otter.canal.protocol.CanalEntry.Column prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } + private int memoizedSerializedSize = -1; + + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(1, index_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(2, sqlType_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(3, getNameBytes()); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(4, isKey_); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(5, updated_); + } + if (((bitField0_ & 0x00000020) == 0x00000020)) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(6, isNull_); + } + for (int i = 0; i < props_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(7, props_.get(i)); + } + if (((bitField0_ & 0x00000040) == 0x00000040)) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(8, getValueBytes()); + } + if (((bitField0_ & 0x00000080) == 0x00000080)) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(9, length_); + } + if (((bitField0_ & 0x00000100) == 0x00000100)) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(10, getMysqlTypeBytes()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + + @java.lang.Override + protected java.lang.Object writeReplace() throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Column parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Column parseFrom(com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Column parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Column parseFrom(byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Column parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Column parseFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Column parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Column parseDelimitedFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Column parseFrom(com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Column parseFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { + return Builder.create(); + } + + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder(com.alibaba.otter.canal.protocol.CanalEntry.Column prototype) { + return newBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return newBuilder(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** * Protobuf type {@code com.alibaba.otter.canal.protocol.Column} * @@ -5010,244 +4926,240 @@ public final class CanalEntry { * *每个字段的数据结构* * */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements // @@protoc_insertion_point(builder_implements:com.alibaba.otter.canal.protocol.Column) com.alibaba.otter.canal.protocol.CanalEntry.ColumnOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Column_descriptor; - } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Column_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.alibaba.otter.canal.protocol.CanalEntry.Column.class, com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder.class); - } - - // Construct using com.alibaba.otter.canal.protocol.CanalEntry.Column.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getPropsFieldBuilder(); - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - index_ = 0; - bitField0_ = (bitField0_ & ~0x00000001); - sqlType_ = 0; - bitField0_ = (bitField0_ & ~0x00000002); - name_ = ""; - bitField0_ = (bitField0_ & ~0x00000004); - isKey_ = false; - bitField0_ = (bitField0_ & ~0x00000008); - updated_ = false; - bitField0_ = (bitField0_ & ~0x00000010); - isNull_ = false; - bitField0_ = (bitField0_ & ~0x00000020); - if (propsBuilder_ == null) { - props_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000040); - } else { - propsBuilder_.clear(); - } - value_ = ""; - bitField0_ = (bitField0_ & ~0x00000080); - length_ = 0; - bitField0_ = (bitField0_ & ~0x00000100); - mysqlType_ = ""; - bitField0_ = (bitField0_ & ~0x00000200); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Column_descriptor; - } - - public com.alibaba.otter.canal.protocol.CanalEntry.Column getDefaultInstanceForType() { - return com.alibaba.otter.canal.protocol.CanalEntry.Column.getDefaultInstance(); - } - - public com.alibaba.otter.canal.protocol.CanalEntry.Column build() { - com.alibaba.otter.canal.protocol.CanalEntry.Column result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.alibaba.otter.canal.protocol.CanalEntry.Column buildPartial() { - com.alibaba.otter.canal.protocol.CanalEntry.Column result = new com.alibaba.otter.canal.protocol.CanalEntry.Column(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.index_ = index_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.sqlType_ = sqlType_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000004; - } - result.name_ = name_; - if (((from_bitField0_ & 0x00000008) == 0x00000008)) { - to_bitField0_ |= 0x00000008; - } - result.isKey_ = isKey_; - if (((from_bitField0_ & 0x00000010) == 0x00000010)) { - to_bitField0_ |= 0x00000010; - } - result.updated_ = updated_; - if (((from_bitField0_ & 0x00000020) == 0x00000020)) { - to_bitField0_ |= 0x00000020; - } - result.isNull_ = isNull_; - if (propsBuilder_ == null) { - if (((bitField0_ & 0x00000040) == 0x00000040)) { - props_ = java.util.Collections.unmodifiableList(props_); - bitField0_ = (bitField0_ & ~0x00000040); - } - result.props_ = props_; - } else { - result.props_ = propsBuilder_.build(); - } - if (((from_bitField0_ & 0x00000080) == 0x00000080)) { - to_bitField0_ |= 0x00000040; - } - result.value_ = value_; - if (((from_bitField0_ & 0x00000100) == 0x00000100)) { - to_bitField0_ |= 0x00000080; - } - result.length_ = length_; - if (((from_bitField0_ & 0x00000200) == 0x00000200)) { - to_bitField0_ |= 0x00000100; - } - result.mysqlType_ = mysqlType_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.alibaba.otter.canal.protocol.CanalEntry.Column) { - return mergeFrom((com.alibaba.otter.canal.protocol.CanalEntry.Column)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.alibaba.otter.canal.protocol.CanalEntry.Column other) { - if (other == com.alibaba.otter.canal.protocol.CanalEntry.Column.getDefaultInstance()) return this; - if (other.hasIndex()) { - setIndex(other.getIndex()); - } - if (other.hasSqlType()) { - setSqlType(other.getSqlType()); - } - if (other.hasName()) { - bitField0_ |= 0x00000004; - name_ = other.name_; - onChanged(); - } - if (other.hasIsKey()) { - setIsKey(other.getIsKey()); - } - if (other.hasUpdated()) { - setUpdated(other.getUpdated()); - } - if (other.hasIsNull()) { - setIsNull(other.getIsNull()); - } - if (propsBuilder_ == null) { - if (!other.props_.isEmpty()) { - if (props_.isEmpty()) { - props_ = other.props_; - bitField0_ = (bitField0_ & ~0x00000040); - } else { - ensurePropsIsMutable(); - props_.addAll(other.props_); + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Column_descriptor; } - onChanged(); - } - } else { - if (!other.props_.isEmpty()) { - if (propsBuilder_.isEmpty()) { - propsBuilder_.dispose(); - propsBuilder_ = null; - props_ = other.props_; - bitField0_ = (bitField0_ & ~0x00000040); - propsBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getPropsFieldBuilder() : null; - } else { - propsBuilder_.addAllMessages(other.props_); + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Column_fieldAccessorTable.ensureFieldAccessorsInitialized(com.alibaba.otter.canal.protocol.CanalEntry.Column.class, + com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder.class); } - } - } - if (other.hasValue()) { - bitField0_ |= 0x00000080; - value_ = other.value_; - onChanged(); - } - if (other.hasLength()) { - setLength(other.getLength()); - } - if (other.hasMysqlType()) { - bitField0_ |= 0x00000200; - mysqlType_ = other.mysqlType_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - public final boolean isInitialized() { - return true; - } + // Construct using + // com.alibaba.otter.canal.protocol.CanalEntry.Column.newBuilder() + private Builder(){ + maybeForceBuilderInitialization(); + } - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.alibaba.otter.canal.protocol.CanalEntry.Column parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.alibaba.otter.canal.protocol.CanalEntry.Column) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent){ + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getPropsFieldBuilder(); + } + } + + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + index_ = 0; + bitField0_ = (bitField0_ & ~0x00000001); + sqlType_ = 0; + bitField0_ = (bitField0_ & ~0x00000002); + name_ = ""; + bitField0_ = (bitField0_ & ~0x00000004); + isKey_ = false; + bitField0_ = (bitField0_ & ~0x00000008); + updated_ = false; + bitField0_ = (bitField0_ & ~0x00000010); + isNull_ = false; + bitField0_ = (bitField0_ & ~0x00000020); + if (propsBuilder_ == null) { + props_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000040); + } else { + propsBuilder_.clear(); + } + value_ = ""; + bitField0_ = (bitField0_ & ~0x00000080); + length_ = 0; + bitField0_ = (bitField0_ & ~0x00000100); + mysqlType_ = ""; + bitField0_ = (bitField0_ & ~0x00000200); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Column_descriptor; + } + + public com.alibaba.otter.canal.protocol.CanalEntry.Column getDefaultInstanceForType() { + return com.alibaba.otter.canal.protocol.CanalEntry.Column.getDefaultInstance(); + } + + public com.alibaba.otter.canal.protocol.CanalEntry.Column build() { + com.alibaba.otter.canal.protocol.CanalEntry.Column result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.alibaba.otter.canal.protocol.CanalEntry.Column buildPartial() { + com.alibaba.otter.canal.protocol.CanalEntry.Column result = new com.alibaba.otter.canal.protocol.CanalEntry.Column(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.index_ = index_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.sqlType_ = sqlType_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + result.name_ = name_; + if (((from_bitField0_ & 0x00000008) == 0x00000008)) { + to_bitField0_ |= 0x00000008; + } + result.isKey_ = isKey_; + if (((from_bitField0_ & 0x00000010) == 0x00000010)) { + to_bitField0_ |= 0x00000010; + } + result.updated_ = updated_; + if (((from_bitField0_ & 0x00000020) == 0x00000020)) { + to_bitField0_ |= 0x00000020; + } + result.isNull_ = isNull_; + if (propsBuilder_ == null) { + if (((bitField0_ & 0x00000040) == 0x00000040)) { + props_ = java.util.Collections.unmodifiableList(props_); + bitField0_ = (bitField0_ & ~0x00000040); + } + result.props_ = props_; + } else { + result.props_ = propsBuilder_.build(); + } + if (((from_bitField0_ & 0x00000080) == 0x00000080)) { + to_bitField0_ |= 0x00000040; + } + result.value_ = value_; + if (((from_bitField0_ & 0x00000100) == 0x00000100)) { + to_bitField0_ |= 0x00000080; + } + result.length_ = length_; + if (((from_bitField0_ & 0x00000200) == 0x00000200)) { + to_bitField0_ |= 0x00000100; + } + result.mysqlType_ = mysqlType_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.alibaba.otter.canal.protocol.CanalEntry.Column) { + return mergeFrom((com.alibaba.otter.canal.protocol.CanalEntry.Column) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.alibaba.otter.canal.protocol.CanalEntry.Column other) { + if (other == com.alibaba.otter.canal.protocol.CanalEntry.Column.getDefaultInstance()) return this; + if (other.hasIndex()) { + setIndex(other.getIndex()); + } + if (other.hasSqlType()) { + setSqlType(other.getSqlType()); + } + if (other.hasName()) { + bitField0_ |= 0x00000004; + name_ = other.name_; + onChanged(); + } + if (other.hasIsKey()) { + setIsKey(other.getIsKey()); + } + if (other.hasUpdated()) { + setUpdated(other.getUpdated()); + } + if (other.hasIsNull()) { + setIsNull(other.getIsNull()); + } + if (propsBuilder_ == null) { + if (!other.props_.isEmpty()) { + if (props_.isEmpty()) { + props_ = other.props_; + bitField0_ = (bitField0_ & ~0x00000040); + } else { + ensurePropsIsMutable(); + props_.addAll(other.props_); + } + onChanged(); + } + } else { + if (!other.props_.isEmpty()) { + if (propsBuilder_.isEmpty()) { + propsBuilder_.dispose(); + propsBuilder_ = null; + props_ = other.props_; + bitField0_ = (bitField0_ & ~0x00000040); + propsBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getPropsFieldBuilder() : null; + } else { + propsBuilder_.addAllMessages(other.props_); + } + } + } + if (other.hasValue()) { + bitField0_ |= 0x00000080; + value_ = other.value_; + onChanged(); + } + if (other.hasLength()) { + setLength(other.getLength()); + } + if (other.hasMysqlType()) { + bitField0_ |= 0x00000200; + mysqlType_ = other.mysqlType_; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.alibaba.otter.canal.protocol.CanalEntry.Column parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.alibaba.otter.canal.protocol.CanalEntry.Column) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private int index_; - private int index_ ; - /** * optional int32 index = 1; * @@ -5255,10 +5167,10 @@ public final class CanalEntry { * *字段下标* * */ - public boolean hasIndex() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - + public boolean hasIndex() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** * optional int32 index = 1; * @@ -5266,10 +5178,10 @@ public final class CanalEntry { * *字段下标* * */ - public int getIndex() { - return index_; - } - + public int getIndex() { + return index_; + } + /** * optional int32 index = 1; * @@ -5277,13 +5189,13 @@ public final class CanalEntry { * *字段下标* * */ - public Builder setIndex(int value) { - bitField0_ |= 0x00000001; - index_ = value; - onChanged(); - return this; - } - + public Builder setIndex(int value) { + bitField0_ |= 0x00000001; + index_ = value; + onChanged(); + return this; + } + /** * optional int32 index = 1; * @@ -5291,15 +5203,15 @@ public final class CanalEntry { * *字段下标* * */ - public Builder clearIndex() { - bitField0_ = (bitField0_ & ~0x00000001); - index_ = 0; - onChanged(); - return this; - } + public Builder clearIndex() { + bitField0_ = (bitField0_ & ~0x00000001); + index_ = 0; + onChanged(); + return this; + } + + private int sqlType_; - private int sqlType_ ; - /** * optional int32 sqlType = 2; * @@ -5307,10 +5219,10 @@ public final class CanalEntry { * *字段java中类型* * */ - public boolean hasSqlType() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - + public boolean hasSqlType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** * optional int32 sqlType = 2; * @@ -5318,10 +5230,10 @@ public final class CanalEntry { * *字段java中类型* * */ - public int getSqlType() { - return sqlType_; - } - + public int getSqlType() { + return sqlType_; + } + /** * optional int32 sqlType = 2; * @@ -5329,13 +5241,13 @@ public final class CanalEntry { * *字段java中类型* * */ - public Builder setSqlType(int value) { - bitField0_ |= 0x00000002; - sqlType_ = value; - onChanged(); - return this; - } - + public Builder setSqlType(int value) { + bitField0_ |= 0x00000002; + sqlType_ = value; + onChanged(); + return this; + } + /** * optional int32 sqlType = 2; * @@ -5343,15 +5255,15 @@ public final class CanalEntry { * *字段java中类型* * */ - public Builder clearSqlType() { - bitField0_ = (bitField0_ & ~0x00000002); - sqlType_ = 0; - onChanged(); - return this; - } + public Builder clearSqlType() { + bitField0_ = (bitField0_ & ~0x00000002); + sqlType_ = 0; + onChanged(); + return this; + } - private java.lang.Object name_ = ""; - + private java.lang.Object name_ = ""; + /** * optional string name = 3; * @@ -5359,10 +5271,10 @@ public final class CanalEntry { * *字段名称(忽略大小写),在mysql中是没有的* * */ - public boolean hasName() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - + public boolean hasName() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** * optional string name = 3; * @@ -5370,21 +5282,20 @@ public final class CanalEntry { * *字段名称(忽略大小写),在mysql中是没有的* * */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - name_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + name_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** * optional string name = 3; * @@ -5392,20 +5303,17 @@ public final class CanalEntry { * *字段名称(忽略大小写),在mysql中是没有的* * */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** * optional string name = 3; * @@ -5413,17 +5321,16 @@ public final class CanalEntry { * *字段名称(忽略大小写),在mysql中是没有的* * */ - public Builder setName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000004; - name_ = value; - onChanged(); - return this; - } - + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + name_ = value; + onChanged(); + return this; + } + /** * optional string name = 3; * @@ -5431,13 +5338,13 @@ public final class CanalEntry { * *字段名称(忽略大小写),在mysql中是没有的* * */ - public Builder clearName() { - bitField0_ = (bitField0_ & ~0x00000004); - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - + public Builder clearName() { + bitField0_ = (bitField0_ & ~0x00000004); + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** * optional string name = 3; * @@ -5445,19 +5352,18 @@ public final class CanalEntry { * *字段名称(忽略大小写),在mysql中是没有的* * */ - public Builder setNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000004; - name_ = value; - onChanged(); - return this; - } + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + name_ = value; + onChanged(); + return this; + } + + private boolean isKey_; - private boolean isKey_ ; - /** * optional bool isKey = 4; * @@ -5465,10 +5371,10 @@ public final class CanalEntry { * *是否是主键* * */ - public boolean hasIsKey() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - + public boolean hasIsKey() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** * optional bool isKey = 4; * @@ -5476,10 +5382,10 @@ public final class CanalEntry { * *是否是主键* * */ - public boolean getIsKey() { - return isKey_; - } - + public boolean getIsKey() { + return isKey_; + } + /** * optional bool isKey = 4; * @@ -5487,13 +5393,13 @@ public final class CanalEntry { * *是否是主键* * */ - public Builder setIsKey(boolean value) { - bitField0_ |= 0x00000008; - isKey_ = value; - onChanged(); - return this; - } - + public Builder setIsKey(boolean value) { + bitField0_ |= 0x00000008; + isKey_ = value; + onChanged(); + return this; + } + /** * optional bool isKey = 4; * @@ -5501,15 +5407,15 @@ public final class CanalEntry { * *是否是主键* * */ - public Builder clearIsKey() { - bitField0_ = (bitField0_ & ~0x00000008); - isKey_ = false; - onChanged(); - return this; - } + public Builder clearIsKey() { + bitField0_ = (bitField0_ & ~0x00000008); + isKey_ = false; + onChanged(); + return this; + } + + private boolean updated_; - private boolean updated_ ; - /** * optional bool updated = 5; * @@ -5517,10 +5423,10 @@ public final class CanalEntry { * *如果EventType=UPDATE,用于标识这个字段值是否有修改* * */ - public boolean hasUpdated() { - return ((bitField0_ & 0x00000010) == 0x00000010); - } - + public boolean hasUpdated() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** * optional bool updated = 5; * @@ -5528,10 +5434,10 @@ public final class CanalEntry { * *如果EventType=UPDATE,用于标识这个字段值是否有修改* * */ - public boolean getUpdated() { - return updated_; - } - + public boolean getUpdated() { + return updated_; + } + /** * optional bool updated = 5; * @@ -5539,13 +5445,13 @@ public final class CanalEntry { * *如果EventType=UPDATE,用于标识这个字段值是否有修改* * */ - public Builder setUpdated(boolean value) { - bitField0_ |= 0x00000010; - updated_ = value; - onChanged(); - return this; - } - + public Builder setUpdated(boolean value) { + bitField0_ |= 0x00000010; + updated_ = value; + onChanged(); + return this; + } + /** * optional bool updated = 5; * @@ -5553,15 +5459,15 @@ public final class CanalEntry { * *如果EventType=UPDATE,用于标识这个字段值是否有修改* * */ - public Builder clearUpdated() { - bitField0_ = (bitField0_ & ~0x00000010); - updated_ = false; - onChanged(); - return this; - } + public Builder clearUpdated() { + bitField0_ = (bitField0_ & ~0x00000010); + updated_ = false; + onChanged(); + return this; + } + + private boolean isNull_; - private boolean isNull_ ; - /** * optional bool isNull = 6 [default = false]; * @@ -5569,10 +5475,10 @@ public final class CanalEntry { * * 标识是否为空 * * */ - public boolean hasIsNull() { - return ((bitField0_ & 0x00000020) == 0x00000020); - } - + public boolean hasIsNull() { + return ((bitField0_ & 0x00000020) == 0x00000020); + } + /** * optional bool isNull = 6 [default = false]; * @@ -5580,10 +5486,10 @@ public final class CanalEntry { * * 标识是否为空 * * */ - public boolean getIsNull() { - return isNull_; - } - + public boolean getIsNull() { + return isNull_; + } + /** * optional bool isNull = 6 [default = false]; * @@ -5591,13 +5497,13 @@ public final class CanalEntry { * * 标识是否为空 * * */ - public Builder setIsNull(boolean value) { - bitField0_ |= 0x00000020; - isNull_ = value; - onChanged(); - return this; - } - + public Builder setIsNull(boolean value) { + bitField0_ |= 0x00000020; + isNull_ = value; + onChanged(); + return this; + } + /** * optional bool isNull = 6 [default = false]; * @@ -5605,24 +5511,23 @@ public final class CanalEntry { * * 标识是否为空 * * */ - public Builder clearIsNull() { - bitField0_ = (bitField0_ & ~0x00000020); - isNull_ = false; - onChanged(); - return this; - } + public Builder clearIsNull() { + bitField0_ = (bitField0_ & ~0x00000020); + isNull_ = false; + onChanged(); + return this; + } - private java.util.List props_ = - java.util.Collections.emptyList(); - private void ensurePropsIsMutable() { - if (!((bitField0_ & 0x00000040) == 0x00000040)) { - props_ = new java.util.ArrayList(props_); - bitField0_ |= 0x00000040; - } - } + private java.util.List props_ = java.util.Collections.emptyList(); - private com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Pair, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder, com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder> propsBuilder_; + private void ensurePropsIsMutable() { + if (!((bitField0_ & 0x00000040) == 0x00000040)) { + props_ = new java.util.ArrayList(props_); + bitField0_ |= 0x00000040; + } + } + + private com.google.protobuf.RepeatedFieldBuilder propsBuilder_; /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; @@ -5631,351 +5536,335 @@ public final class CanalEntry { * *预留扩展* * */ - public java.util.List getPropsList() { - if (propsBuilder_ == null) { - return java.util.Collections.unmodifiableList(props_); - } else { - return propsBuilder_.getMessageList(); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public int getPropsCount() { - if (propsBuilder_ == null) { - return props_.size(); - } else { - return propsBuilder_.getCount(); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { - if (propsBuilder_ == null) { - return props_.get(index); - } else { - return propsBuilder_.getMessage(index); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder setProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { - if (propsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePropsIsMutable(); - props_.set(index, value); - onChanged(); - } else { - propsBuilder_.setMessage(index, value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder setProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.set(index, builderForValue.build()); - onChanged(); - } else { - propsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder addProps(com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { - if (propsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePropsIsMutable(); - props_.add(value); - onChanged(); - } else { - propsBuilder_.addMessage(value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder addProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { - if (propsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePropsIsMutable(); - props_.add(index, value); - onChanged(); - } else { - propsBuilder_.addMessage(index, value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder addProps( - com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.add(builderForValue.build()); - onChanged(); - } else { - propsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder addProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.add(index, builderForValue.build()); - onChanged(); - } else { - propsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder addAllProps( - java.lang.Iterable values) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, props_); - onChanged(); - } else { - propsBuilder_.addAllMessages(values); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder clearProps() { - if (propsBuilder_ == null) { - props_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000040); - onChanged(); - } else { - propsBuilder_.clear(); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder removeProps(int index) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.remove(index); - onChanged(); - } else { - propsBuilder_.remove(index); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder getPropsBuilder( - int index) { - return getPropsFieldBuilder().getBuilder(index); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder( - int index) { - if (propsBuilder_ == null) { - return props_.get(index); } else { - return propsBuilder_.getMessageOrBuilder(index); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public java.util.List - getPropsOrBuilderList() { - if (propsBuilder_ != null) { - return propsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(props_); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder() { - return getPropsFieldBuilder().addBuilder( - com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder( - int index) { - return getPropsFieldBuilder().addBuilder( - index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public java.util.List - getPropsBuilderList() { - return getPropsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Pair, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder, com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder> - getPropsFieldBuilder() { - if (propsBuilder_ == null) { - propsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Pair, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder, com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder>( - props_, - ((bitField0_ & 0x00000040) == 0x00000040), - getParentForChildren(), - isClean()); - props_ = null; - } - return propsBuilder_; - } + public java.util.List getPropsList() { + if (propsBuilder_ == null) { + return java.util.Collections.unmodifiableList(props_); + } else { + return propsBuilder_.getMessageList(); + } + } - private java.lang.Object value_ = ""; - /** - * optional string value = 8; + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; * *
      -             * * 字段值,timestamp,Datetime是一个时间格式的文本 *
      +             * *预留扩展*
                    * 
      */ - public boolean hasValue() { - return ((bitField0_ & 0x00000080) == 0x00000080); - } - + public int getPropsCount() { + if (propsBuilder_ == null) { + return props_.size(); + } else { + return propsBuilder_.getCount(); + } + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { + if (propsBuilder_ == null) { + return props_.get(index); + } else { + return propsBuilder_.getMessage(index); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder setProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { + if (propsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropsIsMutable(); + props_.set(index, value); + onChanged(); + } else { + propsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder setProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.set(index, builderForValue.build()); + onChanged(); + } else { + propsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder addProps(com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { + if (propsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropsIsMutable(); + props_.add(value); + onChanged(); + } else { + propsBuilder_.addMessage(value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder addProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { + if (propsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropsIsMutable(); + props_.add(index, value); + onChanged(); + } else { + propsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder addProps(com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.add(builderForValue.build()); + onChanged(); + } else { + propsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder addProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.add(index, builderForValue.build()); + onChanged(); + } else { + propsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder addAllProps(java.lang.Iterable values) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, props_); + onChanged(); + } else { + propsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder clearProps() { + if (propsBuilder_ == null) { + props_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000040); + onChanged(); + } else { + propsBuilder_.clear(); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder removeProps(int index) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.remove(index); + onChanged(); + } else { + propsBuilder_.remove(index); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder getPropsBuilder(int index) { + return getPropsFieldBuilder().getBuilder(index); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index) { + if (propsBuilder_ == null) { + return props_.get(index); + } else { + return propsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public java.util.List getPropsOrBuilderList() { + if (propsBuilder_ != null) { + return propsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(props_); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder() { + return getPropsFieldBuilder().addBuilder(com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder(int index) { + return getPropsFieldBuilder().addBuilder(index, + com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public java.util.List getPropsBuilderList() { + return getPropsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder getPropsFieldBuilder() { + if (propsBuilder_ == null) { + propsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder(props_, + ((bitField0_ & 0x00000040) == 0x00000040), + getParentForChildren(), + isClean()); + props_ = null; + } + return propsBuilder_; + } + + private java.lang.Object value_ = ""; + + /** + * optional string value = 8; + * + *
      +             * * 字段值,timestamp,Datetime是一个时间格式的文本 *
      +             * 
      + */ + public boolean hasValue() { + return ((bitField0_ & 0x00000080) == 0x00000080); + } + + /** * optional string value = 8; * *
                    * * 字段值,timestamp,Datetime是一个时间格式的文本 *
                    * 
      */ - public java.lang.String getValue() { - java.lang.Object ref = value_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - value_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + value_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** * optional string value = 8; * @@ -5983,20 +5872,17 @@ public final class CanalEntry { * * 字段值,timestamp,Datetime是一个时间格式的文本 * * */ - public com.google.protobuf.ByteString - getValueBytes() { - java.lang.Object ref = value_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - value_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - + public com.google.protobuf.ByteString getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** * optional string value = 8; * @@ -6004,17 +5890,16 @@ public final class CanalEntry { * * 字段值,timestamp,Datetime是一个时间格式的文本 * * */ - public Builder setValue( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000080; - value_ = value; - onChanged(); - return this; - } - + public Builder setValue(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000080; + value_ = value; + onChanged(); + return this; + } + /** * optional string value = 8; * @@ -6022,13 +5907,13 @@ public final class CanalEntry { * * 字段值,timestamp,Datetime是一个时间格式的文本 * * */ - public Builder clearValue() { - bitField0_ = (bitField0_ & ~0x00000080); - value_ = getDefaultInstance().getValue(); - onChanged(); - return this; - } - + public Builder clearValue() { + bitField0_ = (bitField0_ & ~0x00000080); + value_ = getDefaultInstance().getValue(); + onChanged(); + return this; + } + /** * optional string value = 8; * @@ -6036,19 +5921,18 @@ public final class CanalEntry { * * 字段值,timestamp,Datetime是一个时间格式的文本 * * */ - public Builder setValueBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000080; - value_ = value; - onChanged(); - return this; - } + public Builder setValueBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000080; + value_ = value; + onChanged(); + return this; + } + + private int length_; - private int length_ ; - /** * optional int32 length = 9; * @@ -6056,10 +5940,10 @@ public final class CanalEntry { * * 对应数据对象原始长度 * * */ - public boolean hasLength() { - return ((bitField0_ & 0x00000100) == 0x00000100); - } - + public boolean hasLength() { + return ((bitField0_ & 0x00000100) == 0x00000100); + } + /** * optional int32 length = 9; * @@ -6067,10 +5951,10 @@ public final class CanalEntry { * * 对应数据对象原始长度 * * */ - public int getLength() { - return length_; - } - + public int getLength() { + return length_; + } + /** * optional int32 length = 9; * @@ -6078,13 +5962,13 @@ public final class CanalEntry { * * 对应数据对象原始长度 * * */ - public Builder setLength(int value) { - bitField0_ |= 0x00000100; - length_ = value; - onChanged(); - return this; - } - + public Builder setLength(int value) { + bitField0_ |= 0x00000100; + length_ = value; + onChanged(); + return this; + } + /** * optional int32 length = 9; * @@ -6092,405 +5976,128 @@ public final class CanalEntry { * * 对应数据对象原始长度 * * */ - public Builder clearLength() { - bitField0_ = (bitField0_ & ~0x00000100); - length_ = 0; - onChanged(); - return this; - } - - private java.lang.Object mysqlType_ = ""; - - /** - * optional string mysqlType = 10; - * - *
      -             * *字段mysql类型*
      -             * 
      - */ - public boolean hasMysqlType() { - return ((bitField0_ & 0x00000200) == 0x00000200); - } - - /** - * optional string mysqlType = 10; - * - *
      -             * *字段mysql类型*
      -             * 
      - */ - public java.lang.String getMysqlType() { - java.lang.Object ref = mysqlType_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - mysqlType_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * optional string mysqlType = 10; - * - *
      -             * *字段mysql类型*
      -             * 
      - */ - public com.google.protobuf.ByteString - getMysqlTypeBytes() { - java.lang.Object ref = mysqlType_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - mysqlType_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * optional string mysqlType = 10; - * - *
      -             * *字段mysql类型*
      -             * 
      - */ - public Builder setMysqlType( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000200; - mysqlType_ = value; - onChanged(); - return this; - } - - /** - * optional string mysqlType = 10; - * - *
      -             * *字段mysql类型*
      -             * 
      - */ - public Builder clearMysqlType() { - bitField0_ = (bitField0_ & ~0x00000200); - mysqlType_ = getDefaultInstance().getMysqlType(); - onChanged(); - return this; - } - - /** - * optional string mysqlType = 10; - * - *
      -             * *字段mysql类型*
      -             * 
      - */ - public Builder setMysqlTypeBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000200; - mysqlType_ = value; - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.Column) - } - - static { - defaultInstance = new Column(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.Column) - } - - public interface RowDataOrBuilder extends - // @@protoc_insertion_point(interface_extends:com.alibaba.otter.canal.protocol.RowData) - com.google.protobuf.MessageOrBuilder { - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -         * * 字段信息,增量数据(修改前,删除前) *
      -         * 
      - */ - java.util.List - getBeforeColumnsList(); - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -         * * 字段信息,增量数据(修改前,删除前) *
      -         * 
      - */ - com.alibaba.otter.canal.protocol.CanalEntry.Column getBeforeColumns(int index); - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -         * * 字段信息,增量数据(修改前,删除前) *
      -         * 
      - */ - int getBeforeColumnsCount(); - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -         * * 字段信息,增量数据(修改前,删除前) *
      -         * 
      - */ - java.util.List - getBeforeColumnsOrBuilderList(); - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -         * * 字段信息,增量数据(修改前,删除前) *
      -         * 
      - */ - com.alibaba.otter.canal.protocol.CanalEntry.ColumnOrBuilder getBeforeColumnsOrBuilder( - int index); - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -         * * 字段信息,增量数据(修改后,新增后)  *
      -         * 
      - */ - java.util.List - getAfterColumnsList(); - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -         * * 字段信息,增量数据(修改后,新增后)  *
      -         * 
      - */ - com.alibaba.otter.canal.protocol.CanalEntry.Column getAfterColumns(int index); - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -         * * 字段信息,增量数据(修改后,新增后)  *
      -         * 
      - */ - int getAfterColumnsCount(); - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -         * * 字段信息,增量数据(修改后,新增后)  *
      -         * 
      - */ - java.util.List - getAfterColumnsOrBuilderList(); - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -         * * 字段信息,增量数据(修改后,新增后)  *
      -         * 
      - */ - com.alibaba.otter.canal.protocol.CanalEntry.ColumnOrBuilder getAfterColumnsOrBuilder( - int index); - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -         * *预留扩展*
      -         * 
      - */ - java.util.List - getPropsList(); - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -         * *预留扩展*
      -         * 
      - */ - com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index); - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -         * *预留扩展*
      -         * 
      - */ - int getPropsCount(); - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -         * *预留扩展*
      -         * 
      - */ - java.util.List - getPropsOrBuilderList(); - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -         * *预留扩展*
      -         * 
      - */ - com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder( - int index); - } - /** - * Protobuf type {@code com.alibaba.otter.canal.protocol.RowData} - */ - public static final class RowData extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:com.alibaba.otter.canal.protocol.RowData) - RowDataOrBuilder { - // Use RowData.newBuilder() to construct. - private RowData(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private RowData(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final RowData defaultInstance; - public static RowData getDefaultInstance() { - return defaultInstance; - } - - public RowData getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private RowData( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; + public Builder clearLength() { + bitField0_ = (bitField0_ & ~0x00000100); + length_ = 0; + onChanged(); + return this; } - case 10: { - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - beforeColumns_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000001; - } - beforeColumns_.add(input.readMessage(com.alibaba.otter.canal.protocol.CanalEntry.Column.PARSER, extensionRegistry)); - break; + + private java.lang.Object mysqlType_ = ""; + + /** + * optional string mysqlType = 10; + * + *
      +             * *字段mysql类型*
      +             * 
      + */ + public boolean hasMysqlType() { + return ((bitField0_ & 0x00000200) == 0x00000200); } - case 18: { - if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - afterColumns_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000002; - } - afterColumns_.add(input.readMessage(com.alibaba.otter.canal.protocol.CanalEntry.Column.PARSER, extensionRegistry)); - break; + + /** + * optional string mysqlType = 10; + * + *
      +             * *字段mysql类型*
      +             * 
      + */ + public java.lang.String getMysqlType() { + java.lang.Object ref = mysqlType_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + mysqlType_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } } - case 26: { - if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - props_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000004; - } - props_.add(input.readMessage(com.alibaba.otter.canal.protocol.CanalEntry.Pair.PARSER, extensionRegistry)); - break; + + /** + * optional string mysqlType = 10; + * + *
      +             * *字段mysql类型*
      +             * 
      + */ + public com.google.protobuf.ByteString getMysqlTypeBytes() { + java.lang.Object ref = mysqlType_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + mysqlType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } - } + + /** + * optional string mysqlType = 10; + * + *
      +             * *字段mysql类型*
      +             * 
      + */ + public Builder setMysqlType(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000200; + mysqlType_ = value; + onChanged(); + return this; + } + + /** + * optional string mysqlType = 10; + * + *
      +             * *字段mysql类型*
      +             * 
      + */ + public Builder clearMysqlType() { + bitField0_ = (bitField0_ & ~0x00000200); + mysqlType_ = getDefaultInstance().getMysqlType(); + onChanged(); + return this; + } + + /** + * optional string mysqlType = 10; + * + *
      +             * *字段mysql类型*
      +             * 
      + */ + public Builder setMysqlTypeBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000200; + mysqlType_ = value; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.Column) } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - beforeColumns_ = java.util.Collections.unmodifiableList(beforeColumns_); + + static { + defaultInstance = new Column(true); + defaultInstance.initFields(); } - if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - afterColumns_ = java.util.Collections.unmodifiableList(afterColumns_); - } - if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - props_ = java.util.Collections.unmodifiableList(props_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowData_descriptor; + + // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.Column) } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowData_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.alibaba.otter.canal.protocol.CanalEntry.RowData.class, com.alibaba.otter.canal.protocol.CanalEntry.RowData.Builder.class); - } + public interface RowDataOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.alibaba.otter.canal.protocol.RowData) + com.google.protobuf.MessageOrBuilder { - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public RowData parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new RowData(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public static final int BEFORECOLUMNS_FIELD_NUMBER = 1; - private java.util.List beforeColumns_; - /** * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; * @@ -6498,10 +6105,8 @@ public final class CanalEntry { * * 字段信息,增量数据(修改前,删除前) * * */ - public java.util.List getBeforeColumnsList() { - return beforeColumns_; - } - + java.util.List getBeforeColumnsList(); + /** * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; * @@ -6509,11 +6114,8 @@ public final class CanalEntry { * * 字段信息,增量数据(修改前,删除前) * * */ - public java.util.List - getBeforeColumnsOrBuilderList() { - return beforeColumns_; - } - + com.alibaba.otter.canal.protocol.CanalEntry.Column getBeforeColumns(int index); + /** * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; * @@ -6521,10 +6123,8 @@ public final class CanalEntry { * * 字段信息,增量数据(修改前,删除前) * * */ - public int getBeforeColumnsCount() { - return beforeColumns_.size(); - } - + int getBeforeColumnsCount(); + /** * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; * @@ -6532,10 +6132,8 @@ public final class CanalEntry { * * 字段信息,增量数据(修改前,删除前) * * */ - public com.alibaba.otter.canal.protocol.CanalEntry.Column getBeforeColumns(int index) { - return beforeColumns_.get(index); - } - + java.util.List getBeforeColumnsOrBuilderList(); + /** * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; * @@ -6543,14 +6141,8 @@ public final class CanalEntry { * * 字段信息,增量数据(修改前,删除前) * * */ - public com.alibaba.otter.canal.protocol.CanalEntry.ColumnOrBuilder getBeforeColumnsOrBuilder( - int index) { - return beforeColumns_.get(index); - } + com.alibaba.otter.canal.protocol.CanalEntry.ColumnOrBuilder getBeforeColumnsOrBuilder(int index); - public static final int AFTERCOLUMNS_FIELD_NUMBER = 2; - private java.util.List afterColumns_; - /** * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; * @@ -6558,10 +6150,8 @@ public final class CanalEntry { * * 字段信息,增量数据(修改后,新增后) * * */ - public java.util.List getAfterColumnsList() { - return afterColumns_; - } - + java.util.List getAfterColumnsList(); + /** * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; * @@ -6569,11 +6159,8 @@ public final class CanalEntry { * * 字段信息,增量数据(修改后,新增后) * * */ - public java.util.List - getAfterColumnsOrBuilderList() { - return afterColumns_; - } - + com.alibaba.otter.canal.protocol.CanalEntry.Column getAfterColumns(int index); + /** * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; * @@ -6581,10 +6168,8 @@ public final class CanalEntry { * * 字段信息,增量数据(修改后,新增后) * * */ - public int getAfterColumnsCount() { - return afterColumns_.size(); - } - + int getAfterColumnsCount(); + /** * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; * @@ -6592,10 +6177,8 @@ public final class CanalEntry { * * 字段信息,增量数据(修改后,新增后) * * */ - public com.alibaba.otter.canal.protocol.CanalEntry.Column getAfterColumns(int index) { - return afterColumns_.get(index); - } - + java.util.List getAfterColumnsOrBuilderList(); + /** * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; * @@ -6603,14 +6186,8 @@ public final class CanalEntry { * * 字段信息,增量数据(修改后,新增后) * * */ - public com.alibaba.otter.canal.protocol.CanalEntry.ColumnOrBuilder getAfterColumnsOrBuilder( - int index) { - return afterColumns_.get(index); - } + com.alibaba.otter.canal.protocol.CanalEntry.ColumnOrBuilder getAfterColumnsOrBuilder(int index); - public static final int PROPS_FIELD_NUMBER = 3; - private java.util.List props_; - /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -6618,10 +6195,8 @@ public final class CanalEntry { * *预留扩展* * */ - public java.util.List getPropsList() { - return props_; - } - + java.util.List getPropsList(); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -6629,11 +6204,8 @@ public final class CanalEntry { * *预留扩展* * */ - public java.util.List - getPropsOrBuilderList() { - return props_; - } - + com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -6641,10 +6213,8 @@ public final class CanalEntry { * *预留扩展* * */ - public int getPropsCount() { - return props_.size(); - } - + int getPropsCount(); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -6652,10 +6222,8 @@ public final class CanalEntry { * *预留扩展* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { - return props_.get(index); - } - + java.util.List getPropsOrBuilderList(); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -6663,382 +6231,680 @@ public final class CanalEntry { * *预留扩展* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder( - int index) { - return props_.get(index); + com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index); } - private void initFields() { - beforeColumns_ = java.util.Collections.emptyList(); - afterColumns_ = java.util.Collections.emptyList(); - props_ = java.util.Collections.emptyList(); - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - for (int i = 0; i < beforeColumns_.size(); i++) { - output.writeMessage(1, beforeColumns_.get(i)); - } - for (int i = 0; i < afterColumns_.size(); i++) { - output.writeMessage(2, afterColumns_.get(i)); - } - for (int i = 0; i < props_.size(); i++) { - output.writeMessage(3, props_.get(i)); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < beforeColumns_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, beforeColumns_.get(i)); - } - for (int i = 0; i < afterColumns_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(2, afterColumns_.get(i)); - } - for (int i = 0; i < props_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, props_.get(i)); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static com.alibaba.otter.canal.protocol.CanalEntry.RowData parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.RowData parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.RowData parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.RowData parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.RowData parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.RowData parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.RowData parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.RowData parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.RowData parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.RowData parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(com.alibaba.otter.canal.protocol.CanalEntry.RowData prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } /** * Protobuf type {@code com.alibaba.otter.canal.protocol.RowData} */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements + public static final class RowData extends com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:com.alibaba.otter.canal.protocol.RowData) + RowDataOrBuilder { + + // Use RowData.newBuilder() to construct. + private RowData(com.google.protobuf.GeneratedMessage.Builder builder){ + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + + private RowData(boolean noInit){ + this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + + private static final RowData defaultInstance; + + public static RowData getDefaultInstance() { + return defaultInstance; + } + + public RowData getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private RowData(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException{ + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + beforeColumns_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + beforeColumns_.add(input.readMessage(com.alibaba.otter.canal.protocol.CanalEntry.Column.PARSER, + extensionRegistry)); + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + afterColumns_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + afterColumns_.add(input.readMessage(com.alibaba.otter.canal.protocol.CanalEntry.Column.PARSER, + extensionRegistry)); + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + props_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + props_.add(input.readMessage(com.alibaba.otter.canal.protocol.CanalEntry.Pair.PARSER, + extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e.getMessage()).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + beforeColumns_ = java.util.Collections.unmodifiableList(beforeColumns_); + } + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + afterColumns_ = java.util.Collections.unmodifiableList(afterColumns_); + } + if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + props_ = java.util.Collections.unmodifiableList(props_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowData_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowData_fieldAccessorTable.ensureFieldAccessorsInitialized(com.alibaba.otter.canal.protocol.CanalEntry.RowData.class, + com.alibaba.otter.canal.protocol.CanalEntry.RowData.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + + public RowData parsePartialFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new RowData(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public static final int BEFORECOLUMNS_FIELD_NUMBER = 1; + private java.util.List beforeColumns_; + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +         * * 字段信息,增量数据(修改前,删除前) *
      +         * 
      + */ + public java.util.List getBeforeColumnsList() { + return beforeColumns_; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +         * * 字段信息,增量数据(修改前,删除前) *
      +         * 
      + */ + public java.util.List getBeforeColumnsOrBuilderList() { + return beforeColumns_; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +         * * 字段信息,增量数据(修改前,删除前) *
      +         * 
      + */ + public int getBeforeColumnsCount() { + return beforeColumns_.size(); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +         * * 字段信息,增量数据(修改前,删除前) *
      +         * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Column getBeforeColumns(int index) { + return beforeColumns_.get(index); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +         * * 字段信息,增量数据(修改前,删除前) *
      +         * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.ColumnOrBuilder getBeforeColumnsOrBuilder(int index) { + return beforeColumns_.get(index); + } + + public static final int AFTERCOLUMNS_FIELD_NUMBER = 2; + private java.util.List afterColumns_; + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +         * * 字段信息,增量数据(修改后,新增后)  *
      +         * 
      + */ + public java.util.List getAfterColumnsList() { + return afterColumns_; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +         * * 字段信息,增量数据(修改后,新增后)  *
      +         * 
      + */ + public java.util.List getAfterColumnsOrBuilderList() { + return afterColumns_; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +         * * 字段信息,增量数据(修改后,新增后)  *
      +         * 
      + */ + public int getAfterColumnsCount() { + return afterColumns_.size(); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +         * * 字段信息,增量数据(修改后,新增后)  *
      +         * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Column getAfterColumns(int index) { + return afterColumns_.get(index); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +         * * 字段信息,增量数据(修改后,新增后)  *
      +         * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.ColumnOrBuilder getAfterColumnsOrBuilder(int index) { + return afterColumns_.get(index); + } + + public static final int PROPS_FIELD_NUMBER = 3; + private java.util.List props_; + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public java.util.List getPropsList() { + return props_; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public java.util.List getPropsOrBuilderList() { + return props_; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public int getPropsCount() { + return props_.size(); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { + return props_.get(index); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index) { + return props_.get(index); + } + + private void initFields() { + beforeColumns_ = java.util.Collections.emptyList(); + afterColumns_ = java.util.Collections.emptyList(); + props_ = java.util.Collections.emptyList(); + } + + private byte memoizedIsInitialized = -1; + + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getSerializedSize(); + for (int i = 0; i < beforeColumns_.size(); i++) { + output.writeMessage(1, beforeColumns_.get(i)); + } + for (int i = 0; i < afterColumns_.size(); i++) { + output.writeMessage(2, afterColumns_.get(i)); + } + for (int i = 0; i < props_.size(); i++) { + output.writeMessage(3, props_.get(i)); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < beforeColumns_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, beforeColumns_.get(i)); + } + for (int i = 0; i < afterColumns_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, afterColumns_.get(i)); + } + for (int i = 0; i < props_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, props_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + + @java.lang.Override + protected java.lang.Object writeReplace() throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.RowData parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.RowData parseFrom(com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.RowData parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.RowData parseFrom(byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.RowData parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.RowData parseFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.RowData parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.RowData parseDelimitedFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.RowData parseFrom(com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.RowData parseFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { + return Builder.create(); + } + + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder(com.alibaba.otter.canal.protocol.CanalEntry.RowData prototype) { + return newBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return newBuilder(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * Protobuf type {@code com.alibaba.otter.canal.protocol.RowData} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements // @@protoc_insertion_point(builder_implements:com.alibaba.otter.canal.protocol.RowData) com.alibaba.otter.canal.protocol.CanalEntry.RowDataOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowData_descriptor; - } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowData_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.alibaba.otter.canal.protocol.CanalEntry.RowData.class, com.alibaba.otter.canal.protocol.CanalEntry.RowData.Builder.class); - } - - // Construct using com.alibaba.otter.canal.protocol.CanalEntry.RowData.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getBeforeColumnsFieldBuilder(); - getAfterColumnsFieldBuilder(); - getPropsFieldBuilder(); - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - if (beforeColumnsBuilder_ == null) { - beforeColumns_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - } else { - beforeColumnsBuilder_.clear(); - } - if (afterColumnsBuilder_ == null) { - afterColumns_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); - } else { - afterColumnsBuilder_.clear(); - } - if (propsBuilder_ == null) { - props_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - } else { - propsBuilder_.clear(); - } - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowData_descriptor; - } - - public com.alibaba.otter.canal.protocol.CanalEntry.RowData getDefaultInstanceForType() { - return com.alibaba.otter.canal.protocol.CanalEntry.RowData.getDefaultInstance(); - } - - public com.alibaba.otter.canal.protocol.CanalEntry.RowData build() { - com.alibaba.otter.canal.protocol.CanalEntry.RowData result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.alibaba.otter.canal.protocol.CanalEntry.RowData buildPartial() { - com.alibaba.otter.canal.protocol.CanalEntry.RowData result = new com.alibaba.otter.canal.protocol.CanalEntry.RowData(this); - int from_bitField0_ = bitField0_; - if (beforeColumnsBuilder_ == null) { - if (((bitField0_ & 0x00000001) == 0x00000001)) { - beforeColumns_ = java.util.Collections.unmodifiableList(beforeColumns_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.beforeColumns_ = beforeColumns_; - } else { - result.beforeColumns_ = beforeColumnsBuilder_.build(); - } - if (afterColumnsBuilder_ == null) { - if (((bitField0_ & 0x00000002) == 0x00000002)) { - afterColumns_ = java.util.Collections.unmodifiableList(afterColumns_); - bitField0_ = (bitField0_ & ~0x00000002); - } - result.afterColumns_ = afterColumns_; - } else { - result.afterColumns_ = afterColumnsBuilder_.build(); - } - if (propsBuilder_ == null) { - if (((bitField0_ & 0x00000004) == 0x00000004)) { - props_ = java.util.Collections.unmodifiableList(props_); - bitField0_ = (bitField0_ & ~0x00000004); - } - result.props_ = props_; - } else { - result.props_ = propsBuilder_.build(); - } - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.alibaba.otter.canal.protocol.CanalEntry.RowData) { - return mergeFrom((com.alibaba.otter.canal.protocol.CanalEntry.RowData)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.alibaba.otter.canal.protocol.CanalEntry.RowData other) { - if (other == com.alibaba.otter.canal.protocol.CanalEntry.RowData.getDefaultInstance()) return this; - if (beforeColumnsBuilder_ == null) { - if (!other.beforeColumns_.isEmpty()) { - if (beforeColumns_.isEmpty()) { - beforeColumns_ = other.beforeColumns_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureBeforeColumnsIsMutable(); - beforeColumns_.addAll(other.beforeColumns_); + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowData_descriptor; } - onChanged(); - } - } else { - if (!other.beforeColumns_.isEmpty()) { - if (beforeColumnsBuilder_.isEmpty()) { - beforeColumnsBuilder_.dispose(); - beforeColumnsBuilder_ = null; - beforeColumns_ = other.beforeColumns_; - bitField0_ = (bitField0_ & ~0x00000001); - beforeColumnsBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getBeforeColumnsFieldBuilder() : null; - } else { - beforeColumnsBuilder_.addAllMessages(other.beforeColumns_); + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowData_fieldAccessorTable.ensureFieldAccessorsInitialized(com.alibaba.otter.canal.protocol.CanalEntry.RowData.class, + com.alibaba.otter.canal.protocol.CanalEntry.RowData.Builder.class); } - } - } - if (afterColumnsBuilder_ == null) { - if (!other.afterColumns_.isEmpty()) { - if (afterColumns_.isEmpty()) { - afterColumns_ = other.afterColumns_; - bitField0_ = (bitField0_ & ~0x00000002); - } else { - ensureAfterColumnsIsMutable(); - afterColumns_.addAll(other.afterColumns_); + + // Construct using + // com.alibaba.otter.canal.protocol.CanalEntry.RowData.newBuilder() + private Builder(){ + maybeForceBuilderInitialization(); } - onChanged(); - } - } else { - if (!other.afterColumns_.isEmpty()) { - if (afterColumnsBuilder_.isEmpty()) { - afterColumnsBuilder_.dispose(); - afterColumnsBuilder_ = null; - afterColumns_ = other.afterColumns_; - bitField0_ = (bitField0_ & ~0x00000002); - afterColumnsBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getAfterColumnsFieldBuilder() : null; - } else { - afterColumnsBuilder_.addAllMessages(other.afterColumns_); + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent){ + super(parent); + maybeForceBuilderInitialization(); } - } - } - if (propsBuilder_ == null) { - if (!other.props_.isEmpty()) { - if (props_.isEmpty()) { - props_ = other.props_; - bitField0_ = (bitField0_ & ~0x00000004); - } else { - ensurePropsIsMutable(); - props_.addAll(other.props_); + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getBeforeColumnsFieldBuilder(); + getAfterColumnsFieldBuilder(); + getPropsFieldBuilder(); + } } - onChanged(); - } - } else { - if (!other.props_.isEmpty()) { - if (propsBuilder_.isEmpty()) { - propsBuilder_.dispose(); - propsBuilder_ = null; - props_ = other.props_; - bitField0_ = (bitField0_ & ~0x00000004); - propsBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getPropsFieldBuilder() : null; - } else { - propsBuilder_.addAllMessages(other.props_); + + private static Builder create() { + return new Builder(); } - } - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - public final boolean isInitialized() { - return true; - } + public Builder clear() { + super.clear(); + if (beforeColumnsBuilder_ == null) { + beforeColumns_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + beforeColumnsBuilder_.clear(); + } + if (afterColumnsBuilder_ == null) { + afterColumns_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + } else { + afterColumnsBuilder_.clear(); + } + if (propsBuilder_ == null) { + props_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + } else { + propsBuilder_.clear(); + } + return this; + } - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.alibaba.otter.canal.protocol.CanalEntry.RowData parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.alibaba.otter.canal.protocol.CanalEntry.RowData) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; + public Builder clone() { + return create().mergeFrom(buildPartial()); + } - private java.util.List beforeColumns_ = - java.util.Collections.emptyList(); - private void ensureBeforeColumnsIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - beforeColumns_ = new java.util.ArrayList(beforeColumns_); - bitField0_ |= 0x00000001; - } - } + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowData_descriptor; + } - private com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Column, com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder, com.alibaba.otter.canal.protocol.CanalEntry.ColumnOrBuilder> beforeColumnsBuilder_; + public com.alibaba.otter.canal.protocol.CanalEntry.RowData getDefaultInstanceForType() { + return com.alibaba.otter.canal.protocol.CanalEntry.RowData.getDefaultInstance(); + } + + public com.alibaba.otter.canal.protocol.CanalEntry.RowData build() { + com.alibaba.otter.canal.protocol.CanalEntry.RowData result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.alibaba.otter.canal.protocol.CanalEntry.RowData buildPartial() { + com.alibaba.otter.canal.protocol.CanalEntry.RowData result = new com.alibaba.otter.canal.protocol.CanalEntry.RowData(this); + int from_bitField0_ = bitField0_; + if (beforeColumnsBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + beforeColumns_ = java.util.Collections.unmodifiableList(beforeColumns_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.beforeColumns_ = beforeColumns_; + } else { + result.beforeColumns_ = beforeColumnsBuilder_.build(); + } + if (afterColumnsBuilder_ == null) { + if (((bitField0_ & 0x00000002) == 0x00000002)) { + afterColumns_ = java.util.Collections.unmodifiableList(afterColumns_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.afterColumns_ = afterColumns_; + } else { + result.afterColumns_ = afterColumnsBuilder_.build(); + } + if (propsBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004)) { + props_ = java.util.Collections.unmodifiableList(props_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.props_ = props_; + } else { + result.props_ = propsBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.alibaba.otter.canal.protocol.CanalEntry.RowData) { + return mergeFrom((com.alibaba.otter.canal.protocol.CanalEntry.RowData) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.alibaba.otter.canal.protocol.CanalEntry.RowData other) { + if (other == com.alibaba.otter.canal.protocol.CanalEntry.RowData.getDefaultInstance()) return this; + if (beforeColumnsBuilder_ == null) { + if (!other.beforeColumns_.isEmpty()) { + if (beforeColumns_.isEmpty()) { + beforeColumns_ = other.beforeColumns_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureBeforeColumnsIsMutable(); + beforeColumns_.addAll(other.beforeColumns_); + } + onChanged(); + } + } else { + if (!other.beforeColumns_.isEmpty()) { + if (beforeColumnsBuilder_.isEmpty()) { + beforeColumnsBuilder_.dispose(); + beforeColumnsBuilder_ = null; + beforeColumns_ = other.beforeColumns_; + bitField0_ = (bitField0_ & ~0x00000001); + beforeColumnsBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getBeforeColumnsFieldBuilder() : null; + } else { + beforeColumnsBuilder_.addAllMessages(other.beforeColumns_); + } + } + } + if (afterColumnsBuilder_ == null) { + if (!other.afterColumns_.isEmpty()) { + if (afterColumns_.isEmpty()) { + afterColumns_ = other.afterColumns_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureAfterColumnsIsMutable(); + afterColumns_.addAll(other.afterColumns_); + } + onChanged(); + } + } else { + if (!other.afterColumns_.isEmpty()) { + if (afterColumnsBuilder_.isEmpty()) { + afterColumnsBuilder_.dispose(); + afterColumnsBuilder_ = null; + afterColumns_ = other.afterColumns_; + bitField0_ = (bitField0_ & ~0x00000002); + afterColumnsBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getAfterColumnsFieldBuilder() : null; + } else { + afterColumnsBuilder_.addAllMessages(other.afterColumns_); + } + } + } + if (propsBuilder_ == null) { + if (!other.props_.isEmpty()) { + if (props_.isEmpty()) { + props_ = other.props_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensurePropsIsMutable(); + props_.addAll(other.props_); + } + onChanged(); + } + } else { + if (!other.props_.isEmpty()) { + if (propsBuilder_.isEmpty()) { + propsBuilder_.dispose(); + propsBuilder_ = null; + props_ = other.props_; + bitField0_ = (bitField0_ & ~0x00000004); + propsBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getPropsFieldBuilder() : null; + } else { + propsBuilder_.addAllMessages(other.props_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.alibaba.otter.canal.protocol.CanalEntry.RowData parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.alibaba.otter.canal.protocol.CanalEntry.RowData) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private java.util.List beforeColumns_ = java.util.Collections.emptyList(); + + private void ensureBeforeColumnsIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + beforeColumns_ = new java.util.ArrayList(beforeColumns_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder beforeColumnsBuilder_; /** * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; @@ -7047,327 +6913,313 @@ public final class CanalEntry { * * 字段信息,增量数据(修改前,删除前) * * */ - public java.util.List getBeforeColumnsList() { - if (beforeColumnsBuilder_ == null) { - return java.util.Collections.unmodifiableList(beforeColumns_); - } else { - return beforeColumnsBuilder_.getMessageList(); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -             * * 字段信息,增量数据(修改前,删除前) *
      -             * 
      - */ - public int getBeforeColumnsCount() { - if (beforeColumnsBuilder_ == null) { - return beforeColumns_.size(); - } else { - return beforeColumnsBuilder_.getCount(); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -             * * 字段信息,增量数据(修改前,删除前) *
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Column getBeforeColumns(int index) { - if (beforeColumnsBuilder_ == null) { - return beforeColumns_.get(index); - } else { - return beforeColumnsBuilder_.getMessage(index); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -             * * 字段信息,增量数据(修改前,删除前) *
      -             * 
      - */ - public Builder setBeforeColumns( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Column value) { - if (beforeColumnsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureBeforeColumnsIsMutable(); - beforeColumns_.set(index, value); - onChanged(); - } else { - beforeColumnsBuilder_.setMessage(index, value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -             * * 字段信息,增量数据(修改前,删除前) *
      -             * 
      - */ - public Builder setBeforeColumns( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder builderForValue) { - if (beforeColumnsBuilder_ == null) { - ensureBeforeColumnsIsMutable(); - beforeColumns_.set(index, builderForValue.build()); - onChanged(); - } else { - beforeColumnsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -             * * 字段信息,增量数据(修改前,删除前) *
      -             * 
      - */ - public Builder addBeforeColumns(com.alibaba.otter.canal.protocol.CanalEntry.Column value) { - if (beforeColumnsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureBeforeColumnsIsMutable(); - beforeColumns_.add(value); - onChanged(); - } else { - beforeColumnsBuilder_.addMessage(value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -             * * 字段信息,增量数据(修改前,删除前) *
      -             * 
      - */ - public Builder addBeforeColumns( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Column value) { - if (beforeColumnsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureBeforeColumnsIsMutable(); - beforeColumns_.add(index, value); - onChanged(); - } else { - beforeColumnsBuilder_.addMessage(index, value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -             * * 字段信息,增量数据(修改前,删除前) *
      -             * 
      - */ - public Builder addBeforeColumns( - com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder builderForValue) { - if (beforeColumnsBuilder_ == null) { - ensureBeforeColumnsIsMutable(); - beforeColumns_.add(builderForValue.build()); - onChanged(); - } else { - beforeColumnsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -             * * 字段信息,增量数据(修改前,删除前) *
      -             * 
      - */ - public Builder addBeforeColumns( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder builderForValue) { - if (beforeColumnsBuilder_ == null) { - ensureBeforeColumnsIsMutable(); - beforeColumns_.add(index, builderForValue.build()); - onChanged(); - } else { - beforeColumnsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -             * * 字段信息,增量数据(修改前,删除前) *
      -             * 
      - */ - public Builder addAllBeforeColumns( - java.lang.Iterable values) { - if (beforeColumnsBuilder_ == null) { - ensureBeforeColumnsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, beforeColumns_); - onChanged(); - } else { - beforeColumnsBuilder_.addAllMessages(values); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -             * * 字段信息,增量数据(修改前,删除前) *
      -             * 
      - */ - public Builder clearBeforeColumns() { - if (beforeColumnsBuilder_ == null) { - beforeColumns_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - beforeColumnsBuilder_.clear(); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -             * * 字段信息,增量数据(修改前,删除前) *
      -             * 
      - */ - public Builder removeBeforeColumns(int index) { - if (beforeColumnsBuilder_ == null) { - ensureBeforeColumnsIsMutable(); - beforeColumns_.remove(index); - onChanged(); - } else { - beforeColumnsBuilder_.remove(index); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -             * * 字段信息,增量数据(修改前,删除前) *
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder getBeforeColumnsBuilder( - int index) { - return getBeforeColumnsFieldBuilder().getBuilder(index); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -             * * 字段信息,增量数据(修改前,删除前) *
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.ColumnOrBuilder getBeforeColumnsOrBuilder( - int index) { - if (beforeColumnsBuilder_ == null) { - return beforeColumns_.get(index); } else { - return beforeColumnsBuilder_.getMessageOrBuilder(index); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -             * * 字段信息,增量数据(修改前,删除前) *
      -             * 
      - */ - public java.util.List - getBeforeColumnsOrBuilderList() { - if (beforeColumnsBuilder_ != null) { - return beforeColumnsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(beforeColumns_); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -             * * 字段信息,增量数据(修改前,删除前) *
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder addBeforeColumnsBuilder() { - return getBeforeColumnsFieldBuilder().addBuilder( - com.alibaba.otter.canal.protocol.CanalEntry.Column.getDefaultInstance()); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -             * * 字段信息,增量数据(修改前,删除前) *
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder addBeforeColumnsBuilder( - int index) { - return getBeforeColumnsFieldBuilder().addBuilder( - index, com.alibaba.otter.canal.protocol.CanalEntry.Column.getDefaultInstance()); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; - * - *
      -             * * 字段信息,增量数据(修改前,删除前) *
      -             * 
      - */ - public java.util.List - getBeforeColumnsBuilderList() { - return getBeforeColumnsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Column, com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder, com.alibaba.otter.canal.protocol.CanalEntry.ColumnOrBuilder> - getBeforeColumnsFieldBuilder() { - if (beforeColumnsBuilder_ == null) { - beforeColumnsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Column, com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder, com.alibaba.otter.canal.protocol.CanalEntry.ColumnOrBuilder>( - beforeColumns_, - ((bitField0_ & 0x00000001) == 0x00000001), - getParentForChildren(), - isClean()); - beforeColumns_ = null; - } - return beforeColumnsBuilder_; - } + public java.util.List getBeforeColumnsList() { + if (beforeColumnsBuilder_ == null) { + return java.util.Collections.unmodifiableList(beforeColumns_); + } else { + return beforeColumnsBuilder_.getMessageList(); + } + } - private java.util.List afterColumns_ = - java.util.Collections.emptyList(); - private void ensureAfterColumnsIsMutable() { - if (!((bitField0_ & 0x00000002) == 0x00000002)) { - afterColumns_ = new java.util.ArrayList(afterColumns_); - bitField0_ |= 0x00000002; - } - } + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +             * * 字段信息,增量数据(修改前,删除前) *
      +             * 
      + */ + public int getBeforeColumnsCount() { + if (beforeColumnsBuilder_ == null) { + return beforeColumns_.size(); + } else { + return beforeColumnsBuilder_.getCount(); + } + } - private com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Column, com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder, com.alibaba.otter.canal.protocol.CanalEntry.ColumnOrBuilder> afterColumnsBuilder_; + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +             * * 字段信息,增量数据(修改前,删除前) *
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Column getBeforeColumns(int index) { + if (beforeColumnsBuilder_ == null) { + return beforeColumns_.get(index); + } else { + return beforeColumnsBuilder_.getMessage(index); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +             * * 字段信息,增量数据(修改前,删除前) *
      +             * 
      + */ + public Builder setBeforeColumns(int index, com.alibaba.otter.canal.protocol.CanalEntry.Column value) { + if (beforeColumnsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBeforeColumnsIsMutable(); + beforeColumns_.set(index, value); + onChanged(); + } else { + beforeColumnsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +             * * 字段信息,增量数据(修改前,删除前) *
      +             * 
      + */ + public Builder setBeforeColumns(int index, + com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder builderForValue) { + if (beforeColumnsBuilder_ == null) { + ensureBeforeColumnsIsMutable(); + beforeColumns_.set(index, builderForValue.build()); + onChanged(); + } else { + beforeColumnsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +             * * 字段信息,增量数据(修改前,删除前) *
      +             * 
      + */ + public Builder addBeforeColumns(com.alibaba.otter.canal.protocol.CanalEntry.Column value) { + if (beforeColumnsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBeforeColumnsIsMutable(); + beforeColumns_.add(value); + onChanged(); + } else { + beforeColumnsBuilder_.addMessage(value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +             * * 字段信息,增量数据(修改前,删除前) *
      +             * 
      + */ + public Builder addBeforeColumns(int index, com.alibaba.otter.canal.protocol.CanalEntry.Column value) { + if (beforeColumnsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBeforeColumnsIsMutable(); + beforeColumns_.add(index, value); + onChanged(); + } else { + beforeColumnsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +             * * 字段信息,增量数据(修改前,删除前) *
      +             * 
      + */ + public Builder addBeforeColumns(com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder builderForValue) { + if (beforeColumnsBuilder_ == null) { + ensureBeforeColumnsIsMutable(); + beforeColumns_.add(builderForValue.build()); + onChanged(); + } else { + beforeColumnsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +             * * 字段信息,增量数据(修改前,删除前) *
      +             * 
      + */ + public Builder addBeforeColumns(int index, + com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder builderForValue) { + if (beforeColumnsBuilder_ == null) { + ensureBeforeColumnsIsMutable(); + beforeColumns_.add(index, builderForValue.build()); + onChanged(); + } else { + beforeColumnsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +             * * 字段信息,增量数据(修改前,删除前) *
      +             * 
      + */ + public Builder addAllBeforeColumns(java.lang.Iterable values) { + if (beforeColumnsBuilder_ == null) { + ensureBeforeColumnsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, beforeColumns_); + onChanged(); + } else { + beforeColumnsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +             * * 字段信息,增量数据(修改前,删除前) *
      +             * 
      + */ + public Builder clearBeforeColumns() { + if (beforeColumnsBuilder_ == null) { + beforeColumns_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + beforeColumnsBuilder_.clear(); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +             * * 字段信息,增量数据(修改前,删除前) *
      +             * 
      + */ + public Builder removeBeforeColumns(int index) { + if (beforeColumnsBuilder_ == null) { + ensureBeforeColumnsIsMutable(); + beforeColumns_.remove(index); + onChanged(); + } else { + beforeColumnsBuilder_.remove(index); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +             * * 字段信息,增量数据(修改前,删除前) *
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder getBeforeColumnsBuilder(int index) { + return getBeforeColumnsFieldBuilder().getBuilder(index); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +             * * 字段信息,增量数据(修改前,删除前) *
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.ColumnOrBuilder getBeforeColumnsOrBuilder(int index) { + if (beforeColumnsBuilder_ == null) { + return beforeColumns_.get(index); + } else { + return beforeColumnsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +             * * 字段信息,增量数据(修改前,删除前) *
      +             * 
      + */ + public java.util.List getBeforeColumnsOrBuilderList() { + if (beforeColumnsBuilder_ != null) { + return beforeColumnsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(beforeColumns_); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +             * * 字段信息,增量数据(修改前,删除前) *
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder addBeforeColumnsBuilder() { + return getBeforeColumnsFieldBuilder().addBuilder(com.alibaba.otter.canal.protocol.CanalEntry.Column.getDefaultInstance()); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +             * * 字段信息,增量数据(修改前,删除前) *
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder addBeforeColumnsBuilder(int index) { + return getBeforeColumnsFieldBuilder().addBuilder(index, + com.alibaba.otter.canal.protocol.CanalEntry.Column.getDefaultInstance()); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
      +             * * 字段信息,增量数据(修改前,删除前) *
      +             * 
      + */ + public java.util.List getBeforeColumnsBuilderList() { + return getBeforeColumnsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder getBeforeColumnsFieldBuilder() { + if (beforeColumnsBuilder_ == null) { + beforeColumnsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder(beforeColumns_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + beforeColumns_ = null; + } + return beforeColumnsBuilder_; + } + + private java.util.List afterColumns_ = java.util.Collections.emptyList(); + + private void ensureAfterColumnsIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + afterColumns_ = new java.util.ArrayList(afterColumns_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilder afterColumnsBuilder_; /** * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; @@ -7376,327 +7228,313 @@ public final class CanalEntry { * * 字段信息,增量数据(修改后,新增后) * * */ - public java.util.List getAfterColumnsList() { - if (afterColumnsBuilder_ == null) { - return java.util.Collections.unmodifiableList(afterColumns_); - } else { - return afterColumnsBuilder_.getMessageList(); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -             * * 字段信息,增量数据(修改后,新增后)  *
      -             * 
      - */ - public int getAfterColumnsCount() { - if (afterColumnsBuilder_ == null) { - return afterColumns_.size(); - } else { - return afterColumnsBuilder_.getCount(); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -             * * 字段信息,增量数据(修改后,新增后)  *
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Column getAfterColumns(int index) { - if (afterColumnsBuilder_ == null) { - return afterColumns_.get(index); - } else { - return afterColumnsBuilder_.getMessage(index); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -             * * 字段信息,增量数据(修改后,新增后)  *
      -             * 
      - */ - public Builder setAfterColumns( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Column value) { - if (afterColumnsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureAfterColumnsIsMutable(); - afterColumns_.set(index, value); - onChanged(); - } else { - afterColumnsBuilder_.setMessage(index, value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -             * * 字段信息,增量数据(修改后,新增后)  *
      -             * 
      - */ - public Builder setAfterColumns( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder builderForValue) { - if (afterColumnsBuilder_ == null) { - ensureAfterColumnsIsMutable(); - afterColumns_.set(index, builderForValue.build()); - onChanged(); - } else { - afterColumnsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -             * * 字段信息,增量数据(修改后,新增后)  *
      -             * 
      - */ - public Builder addAfterColumns(com.alibaba.otter.canal.protocol.CanalEntry.Column value) { - if (afterColumnsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureAfterColumnsIsMutable(); - afterColumns_.add(value); - onChanged(); - } else { - afterColumnsBuilder_.addMessage(value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -             * * 字段信息,增量数据(修改后,新增后)  *
      -             * 
      - */ - public Builder addAfterColumns( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Column value) { - if (afterColumnsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureAfterColumnsIsMutable(); - afterColumns_.add(index, value); - onChanged(); - } else { - afterColumnsBuilder_.addMessage(index, value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -             * * 字段信息,增量数据(修改后,新增后)  *
      -             * 
      - */ - public Builder addAfterColumns( - com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder builderForValue) { - if (afterColumnsBuilder_ == null) { - ensureAfterColumnsIsMutable(); - afterColumns_.add(builderForValue.build()); - onChanged(); - } else { - afterColumnsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -             * * 字段信息,增量数据(修改后,新增后)  *
      -             * 
      - */ - public Builder addAfterColumns( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder builderForValue) { - if (afterColumnsBuilder_ == null) { - ensureAfterColumnsIsMutable(); - afterColumns_.add(index, builderForValue.build()); - onChanged(); - } else { - afterColumnsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -             * * 字段信息,增量数据(修改后,新增后)  *
      -             * 
      - */ - public Builder addAllAfterColumns( - java.lang.Iterable values) { - if (afterColumnsBuilder_ == null) { - ensureAfterColumnsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, afterColumns_); - onChanged(); - } else { - afterColumnsBuilder_.addAllMessages(values); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -             * * 字段信息,增量数据(修改后,新增后)  *
      -             * 
      - */ - public Builder clearAfterColumns() { - if (afterColumnsBuilder_ == null) { - afterColumns_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - } else { - afterColumnsBuilder_.clear(); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -             * * 字段信息,增量数据(修改后,新增后)  *
      -             * 
      - */ - public Builder removeAfterColumns(int index) { - if (afterColumnsBuilder_ == null) { - ensureAfterColumnsIsMutable(); - afterColumns_.remove(index); - onChanged(); - } else { - afterColumnsBuilder_.remove(index); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -             * * 字段信息,增量数据(修改后,新增后)  *
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder getAfterColumnsBuilder( - int index) { - return getAfterColumnsFieldBuilder().getBuilder(index); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -             * * 字段信息,增量数据(修改后,新增后)  *
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.ColumnOrBuilder getAfterColumnsOrBuilder( - int index) { - if (afterColumnsBuilder_ == null) { - return afterColumns_.get(index); } else { - return afterColumnsBuilder_.getMessageOrBuilder(index); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -             * * 字段信息,增量数据(修改后,新增后)  *
      -             * 
      - */ - public java.util.List - getAfterColumnsOrBuilderList() { - if (afterColumnsBuilder_ != null) { - return afterColumnsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(afterColumns_); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -             * * 字段信息,增量数据(修改后,新增后)  *
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder addAfterColumnsBuilder() { - return getAfterColumnsFieldBuilder().addBuilder( - com.alibaba.otter.canal.protocol.CanalEntry.Column.getDefaultInstance()); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -             * * 字段信息,增量数据(修改后,新增后)  *
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder addAfterColumnsBuilder( - int index) { - return getAfterColumnsFieldBuilder().addBuilder( - index, com.alibaba.otter.canal.protocol.CanalEntry.Column.getDefaultInstance()); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; - * - *
      -             * * 字段信息,增量数据(修改后,新增后)  *
      -             * 
      - */ - public java.util.List - getAfterColumnsBuilderList() { - return getAfterColumnsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Column, com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder, com.alibaba.otter.canal.protocol.CanalEntry.ColumnOrBuilder> - getAfterColumnsFieldBuilder() { - if (afterColumnsBuilder_ == null) { - afterColumnsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Column, com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder, com.alibaba.otter.canal.protocol.CanalEntry.ColumnOrBuilder>( - afterColumns_, - ((bitField0_ & 0x00000002) == 0x00000002), - getParentForChildren(), - isClean()); - afterColumns_ = null; - } - return afterColumnsBuilder_; - } + public java.util.List getAfterColumnsList() { + if (afterColumnsBuilder_ == null) { + return java.util.Collections.unmodifiableList(afterColumns_); + } else { + return afterColumnsBuilder_.getMessageList(); + } + } - private java.util.List props_ = - java.util.Collections.emptyList(); - private void ensurePropsIsMutable() { - if (!((bitField0_ & 0x00000004) == 0x00000004)) { - props_ = new java.util.ArrayList(props_); - bitField0_ |= 0x00000004; - } - } + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +             * * 字段信息,增量数据(修改后,新增后)  *
      +             * 
      + */ + public int getAfterColumnsCount() { + if (afterColumnsBuilder_ == null) { + return afterColumns_.size(); + } else { + return afterColumnsBuilder_.getCount(); + } + } - private com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Pair, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder, com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder> propsBuilder_; + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +             * * 字段信息,增量数据(修改后,新增后)  *
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Column getAfterColumns(int index) { + if (afterColumnsBuilder_ == null) { + return afterColumns_.get(index); + } else { + return afterColumnsBuilder_.getMessage(index); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +             * * 字段信息,增量数据(修改后,新增后)  *
      +             * 
      + */ + public Builder setAfterColumns(int index, com.alibaba.otter.canal.protocol.CanalEntry.Column value) { + if (afterColumnsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAfterColumnsIsMutable(); + afterColumns_.set(index, value); + onChanged(); + } else { + afterColumnsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +             * * 字段信息,增量数据(修改后,新增后)  *
      +             * 
      + */ + public Builder setAfterColumns(int index, + com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder builderForValue) { + if (afterColumnsBuilder_ == null) { + ensureAfterColumnsIsMutable(); + afterColumns_.set(index, builderForValue.build()); + onChanged(); + } else { + afterColumnsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +             * * 字段信息,增量数据(修改后,新增后)  *
      +             * 
      + */ + public Builder addAfterColumns(com.alibaba.otter.canal.protocol.CanalEntry.Column value) { + if (afterColumnsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAfterColumnsIsMutable(); + afterColumns_.add(value); + onChanged(); + } else { + afterColumnsBuilder_.addMessage(value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +             * * 字段信息,增量数据(修改后,新增后)  *
      +             * 
      + */ + public Builder addAfterColumns(int index, com.alibaba.otter.canal.protocol.CanalEntry.Column value) { + if (afterColumnsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAfterColumnsIsMutable(); + afterColumns_.add(index, value); + onChanged(); + } else { + afterColumnsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +             * * 字段信息,增量数据(修改后,新增后)  *
      +             * 
      + */ + public Builder addAfterColumns(com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder builderForValue) { + if (afterColumnsBuilder_ == null) { + ensureAfterColumnsIsMutable(); + afterColumns_.add(builderForValue.build()); + onChanged(); + } else { + afterColumnsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +             * * 字段信息,增量数据(修改后,新增后)  *
      +             * 
      + */ + public Builder addAfterColumns(int index, + com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder builderForValue) { + if (afterColumnsBuilder_ == null) { + ensureAfterColumnsIsMutable(); + afterColumns_.add(index, builderForValue.build()); + onChanged(); + } else { + afterColumnsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +             * * 字段信息,增量数据(修改后,新增后)  *
      +             * 
      + */ + public Builder addAllAfterColumns(java.lang.Iterable values) { + if (afterColumnsBuilder_ == null) { + ensureAfterColumnsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, afterColumns_); + onChanged(); + } else { + afterColumnsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +             * * 字段信息,增量数据(修改后,新增后)  *
      +             * 
      + */ + public Builder clearAfterColumns() { + if (afterColumnsBuilder_ == null) { + afterColumns_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + afterColumnsBuilder_.clear(); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +             * * 字段信息,增量数据(修改后,新增后)  *
      +             * 
      + */ + public Builder removeAfterColumns(int index) { + if (afterColumnsBuilder_ == null) { + ensureAfterColumnsIsMutable(); + afterColumns_.remove(index); + onChanged(); + } else { + afterColumnsBuilder_.remove(index); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +             * * 字段信息,增量数据(修改后,新增后)  *
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder getAfterColumnsBuilder(int index) { + return getAfterColumnsFieldBuilder().getBuilder(index); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +             * * 字段信息,增量数据(修改后,新增后)  *
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.ColumnOrBuilder getAfterColumnsOrBuilder(int index) { + if (afterColumnsBuilder_ == null) { + return afterColumns_.get(index); + } else { + return afterColumnsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +             * * 字段信息,增量数据(修改后,新增后)  *
      +             * 
      + */ + public java.util.List getAfterColumnsOrBuilderList() { + if (afterColumnsBuilder_ != null) { + return afterColumnsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(afterColumns_); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +             * * 字段信息,增量数据(修改后,新增后)  *
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder addAfterColumnsBuilder() { + return getAfterColumnsFieldBuilder().addBuilder(com.alibaba.otter.canal.protocol.CanalEntry.Column.getDefaultInstance()); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +             * * 字段信息,增量数据(修改后,新增后)  *
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Column.Builder addAfterColumnsBuilder(int index) { + return getAfterColumnsFieldBuilder().addBuilder(index, + com.alibaba.otter.canal.protocol.CanalEntry.Column.getDefaultInstance()); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
      +             * * 字段信息,增量数据(修改后,新增后)  *
      +             * 
      + */ + public java.util.List getAfterColumnsBuilderList() { + return getAfterColumnsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder getAfterColumnsFieldBuilder() { + if (afterColumnsBuilder_ == null) { + afterColumnsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder(afterColumns_, + ((bitField0_ & 0x00000002) == 0x00000002), + getParentForChildren(), + isClean()); + afterColumns_ = null; + } + return afterColumnsBuilder_; + } + + private java.util.List props_ = java.util.Collections.emptyList(); + + private void ensurePropsIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + props_ = new java.util.ArrayList(props_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilder propsBuilder_; /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; @@ -7705,330 +7543,315 @@ public final class CanalEntry { * *预留扩展* * */ - public java.util.List getPropsList() { - if (propsBuilder_ == null) { - return java.util.Collections.unmodifiableList(props_); - } else { - return propsBuilder_.getMessageList(); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public int getPropsCount() { - if (propsBuilder_ == null) { - return props_.size(); - } else { - return propsBuilder_.getCount(); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { - if (propsBuilder_ == null) { - return props_.get(index); - } else { - return propsBuilder_.getMessage(index); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder setProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { - if (propsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePropsIsMutable(); - props_.set(index, value); - onChanged(); - } else { - propsBuilder_.setMessage(index, value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder setProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.set(index, builderForValue.build()); - onChanged(); - } else { - propsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder addProps(com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { - if (propsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePropsIsMutable(); - props_.add(value); - onChanged(); - } else { - propsBuilder_.addMessage(value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder addProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { - if (propsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePropsIsMutable(); - props_.add(index, value); - onChanged(); - } else { - propsBuilder_.addMessage(index, value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder addProps( - com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.add(builderForValue.build()); - onChanged(); - } else { - propsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder addProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.add(index, builderForValue.build()); - onChanged(); - } else { - propsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder addAllProps( - java.lang.Iterable values) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, props_); - onChanged(); - } else { - propsBuilder_.addAllMessages(values); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder clearProps() { - if (propsBuilder_ == null) { - props_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - onChanged(); - } else { - propsBuilder_.clear(); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder removeProps(int index) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.remove(index); - onChanged(); - } else { - propsBuilder_.remove(index); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder getPropsBuilder( - int index) { - return getPropsFieldBuilder().getBuilder(index); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder( - int index) { - if (propsBuilder_ == null) { - return props_.get(index); } else { - return propsBuilder_.getMessageOrBuilder(index); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public java.util.List - getPropsOrBuilderList() { - if (propsBuilder_ != null) { - return propsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(props_); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder() { - return getPropsFieldBuilder().addBuilder( - com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder( - int index) { - return getPropsFieldBuilder().addBuilder( - index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public java.util.List - getPropsBuilderList() { - return getPropsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Pair, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder, com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder> - getPropsFieldBuilder() { - if (propsBuilder_ == null) { - propsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Pair, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder, com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder>( - props_, - ((bitField0_ & 0x00000004) == 0x00000004), - getParentForChildren(), - isClean()); - props_ = null; - } - return propsBuilder_; - } + public java.util.List getPropsList() { + if (propsBuilder_ == null) { + return java.util.Collections.unmodifiableList(props_); + } else { + return propsBuilder_.getMessageList(); + } + } - // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.RowData) + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public int getPropsCount() { + if (propsBuilder_ == null) { + return props_.size(); + } else { + return propsBuilder_.getCount(); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { + if (propsBuilder_ == null) { + return props_.get(index); + } else { + return propsBuilder_.getMessage(index); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder setProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { + if (propsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropsIsMutable(); + props_.set(index, value); + onChanged(); + } else { + propsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder setProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.set(index, builderForValue.build()); + onChanged(); + } else { + propsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder addProps(com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { + if (propsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropsIsMutable(); + props_.add(value); + onChanged(); + } else { + propsBuilder_.addMessage(value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder addProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { + if (propsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropsIsMutable(); + props_.add(index, value); + onChanged(); + } else { + propsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder addProps(com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.add(builderForValue.build()); + onChanged(); + } else { + propsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder addProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.add(index, builderForValue.build()); + onChanged(); + } else { + propsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder addAllProps(java.lang.Iterable values) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, props_); + onChanged(); + } else { + propsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder clearProps() { + if (propsBuilder_ == null) { + props_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + propsBuilder_.clear(); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder removeProps(int index) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.remove(index); + onChanged(); + } else { + propsBuilder_.remove(index); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder getPropsBuilder(int index) { + return getPropsFieldBuilder().getBuilder(index); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index) { + if (propsBuilder_ == null) { + return props_.get(index); + } else { + return propsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public java.util.List getPropsOrBuilderList() { + if (propsBuilder_ != null) { + return propsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(props_); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder() { + return getPropsFieldBuilder().addBuilder(com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder(int index) { + return getPropsFieldBuilder().addBuilder(index, + com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public java.util.List getPropsBuilderList() { + return getPropsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder getPropsFieldBuilder() { + if (propsBuilder_ == null) { + propsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder(props_, + ((bitField0_ & 0x00000004) == 0x00000004), + getParentForChildren(), + isClean()); + props_ = null; + } + return propsBuilder_; + } + + // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.RowData) + } + + static { + defaultInstance = new RowData(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.RowData) } - static { - defaultInstance = new RowData(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.RowData) - } - - public interface RowChangeOrBuilder extends - // @@protoc_insertion_point(interface_extends:com.alibaba.otter.canal.protocol.RowChange) - com.google.protobuf.MessageOrBuilder { + public interface RowChangeOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.alibaba.otter.canal.protocol.RowChange) + com.google.protobuf.MessageOrBuilder { /** * optional int64 tableId = 1; @@ -8037,8 +7860,8 @@ public final class CanalEntry { * *tableId,由数据库产生* * */ - boolean hasTableId(); - + boolean hasTableId(); + /** * optional int64 tableId = 1; * @@ -8046,7 +7869,7 @@ public final class CanalEntry { * *tableId,由数据库产生* * */ - long getTableId(); + long getTableId(); /** * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; @@ -8055,8 +7878,8 @@ public final class CanalEntry { * *数据变更类型* * */ - boolean hasEventType(); - + boolean hasEventType(); + /** * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; * @@ -8064,7 +7887,7 @@ public final class CanalEntry { * *数据变更类型* * */ - com.alibaba.otter.canal.protocol.CanalEntry.EventType getEventType(); + com.alibaba.otter.canal.protocol.CanalEntry.EventType getEventType(); /** * optional bool isDdl = 10 [default = false]; @@ -8073,8 +7896,8 @@ public final class CanalEntry { * * 标识是否是ddl语句 * * */ - boolean hasIsDdl(); - + boolean hasIsDdl(); + /** * optional bool isDdl = 10 [default = false]; * @@ -8082,7 +7905,7 @@ public final class CanalEntry { * * 标识是否是ddl语句 * * */ - boolean getIsDdl(); + boolean getIsDdl(); /** * optional string sql = 11; @@ -8091,8 +7914,8 @@ public final class CanalEntry { * * ddl/query的sql语句 * * */ - boolean hasSql(); - + boolean hasSql(); + /** * optional string sql = 11; * @@ -8100,8 +7923,8 @@ public final class CanalEntry { * * ddl/query的sql语句 * * */ - java.lang.String getSql(); - + java.lang.String getSql(); + /** * optional string sql = 11; * @@ -8109,8 +7932,7 @@ public final class CanalEntry { * * ddl/query的sql语句 * * */ - com.google.protobuf.ByteString - getSqlBytes(); + com.google.protobuf.ByteString getSqlBytes(); /** * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; @@ -8119,9 +7941,8 @@ public final class CanalEntry { * * 一次数据库变更可能存在多行 * * */ - java.util.List - getRowDatasList(); - + java.util.List getRowDatasList(); + /** * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; * @@ -8129,8 +7950,8 @@ public final class CanalEntry { * * 一次数据库变更可能存在多行 * * */ - com.alibaba.otter.canal.protocol.CanalEntry.RowData getRowDatas(int index); - + com.alibaba.otter.canal.protocol.CanalEntry.RowData getRowDatas(int index); + /** * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; * @@ -8138,8 +7959,8 @@ public final class CanalEntry { * * 一次数据库变更可能存在多行 * * */ - int getRowDatasCount(); - + int getRowDatasCount(); + /** * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; * @@ -8147,9 +7968,8 @@ public final class CanalEntry { * * 一次数据库变更可能存在多行 * * */ - java.util.List - getRowDatasOrBuilderList(); - + java.util.List getRowDatasOrBuilderList(); + /** * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; * @@ -8157,8 +7977,7 @@ public final class CanalEntry { * * 一次数据库变更可能存在多行 * * */ - com.alibaba.otter.canal.protocol.CanalEntry.RowDataOrBuilder getRowDatasOrBuilder( - int index); + com.alibaba.otter.canal.protocol.CanalEntry.RowDataOrBuilder getRowDatasOrBuilder(int index); /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; @@ -8167,9 +7986,8 @@ public final class CanalEntry { * *预留扩展* * */ - java.util.List - getPropsList(); - + java.util.List getPropsList(); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -8177,8 +7995,8 @@ public final class CanalEntry { * *预留扩展* * */ - com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index); - + com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -8186,8 +8004,8 @@ public final class CanalEntry { * *预留扩展* * */ - int getPropsCount(); - + int getPropsCount(); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -8195,9 +8013,8 @@ public final class CanalEntry { * *预留扩展* * */ - java.util.List - getPropsOrBuilderList(); - + java.util.List getPropsOrBuilderList(); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -8205,8 +8022,7 @@ public final class CanalEntry { * *预留扩展* * */ - com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder( - int index); + com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index); /** * optional string ddlSchemaName = 14; @@ -8215,8 +8031,8 @@ public final class CanalEntry { * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName * * */ - boolean hasDdlSchemaName(); - + boolean hasDdlSchemaName(); + /** * optional string ddlSchemaName = 14; * @@ -8224,8 +8040,8 @@ public final class CanalEntry { * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName * * */ - java.lang.String getDdlSchemaName(); - + java.lang.String getDdlSchemaName(); + /** * optional string ddlSchemaName = 14; * @@ -8233,10 +8049,9 @@ public final class CanalEntry { * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName * * */ - com.google.protobuf.ByteString - getDdlSchemaNameBytes(); - } - + com.google.protobuf.ByteString getDdlSchemaNameBytes(); + } + /** * Protobuf type {@code com.alibaba.otter.canal.protocol.RowChange} * @@ -8244,153 +8059,154 @@ public final class CanalEntry { * *message row 每行变更数据的数据结构* * */ - public static final class RowChange extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:com.alibaba.otter.canal.protocol.RowChange) - RowChangeOrBuilder { - // Use RowChange.newBuilder() to construct. - private RowChange(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private RowChange(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + public static final class RowChange extends com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:com.alibaba.otter.canal.protocol.RowChange) + RowChangeOrBuilder { - private static final RowChange defaultInstance; - public static RowChange getDefaultInstance() { - return defaultInstance; - } - - public RowChange getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private RowChange( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - bitField0_ |= 0x00000001; - tableId_ = input.readInt64(); - break; - } - case 16: { - int rawValue = input.readEnum(); - com.alibaba.otter.canal.protocol.CanalEntry.EventType value = com.alibaba.otter.canal.protocol.CanalEntry.EventType.valueOf(rawValue); - if (value == null) { - unknownFields.mergeVarintField(2, rawValue); - } else { - bitField0_ |= 0x00000002; - eventType_ = value; - } - break; - } - case 80: { - bitField0_ |= 0x00000004; - isDdl_ = input.readBool(); - break; - } - case 90: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000008; - sql_ = bs; - break; - } - case 98: { - if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { - rowDatas_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000010; - } - rowDatas_.add(input.readMessage(com.alibaba.otter.canal.protocol.CanalEntry.RowData.PARSER, extensionRegistry)); - break; - } - case 106: { - if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { - props_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000020; - } - props_.add(input.readMessage(com.alibaba.otter.canal.protocol.CanalEntry.Pair.PARSER, extensionRegistry)); - break; - } - case 114: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000010; - ddlSchemaName_ = bs; - break; - } - } + // Use RowChange.newBuilder() to construct. + private RowChange(com.google.protobuf.GeneratedMessage.Builder builder){ + super(builder); + this.unknownFields = builder.getUnknownFields(); } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { - rowDatas_ = java.util.Collections.unmodifiableList(rowDatas_); + + private RowChange(boolean noInit){ + this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) { - props_ = java.util.Collections.unmodifiableList(props_); + + private static final RowChange defaultInstance; + + public static RowChange getDefaultInstance() { + return defaultInstance; } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowChange_descriptor; - } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowChange_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.alibaba.otter.canal.protocol.CanalEntry.RowChange.class, com.alibaba.otter.canal.protocol.CanalEntry.RowChange.Builder.class); - } + public RowChange getDefaultInstanceForType() { + return defaultInstance; + } - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public RowChange parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new RowChange(input, extensionRegistry); - } - }; + private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private RowChange(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException{ + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + bitField0_ |= 0x00000001; + tableId_ = input.readInt64(); + break; + } + case 16: { + int rawValue = input.readEnum(); + com.alibaba.otter.canal.protocol.CanalEntry.EventType value = com.alibaba.otter.canal.protocol.CanalEntry.EventType.valueOf(rawValue); + if (value == null) { + unknownFields.mergeVarintField(2, rawValue); + } else { + bitField0_ |= 0x00000002; + eventType_ = value; + } + break; + } + case 80: { + bitField0_ |= 0x00000004; + isDdl_ = input.readBool(); + break; + } + case 90: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000008; + sql_ = bs; + break; + } + case 98: { + if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + rowDatas_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000010; + } + rowDatas_.add(input.readMessage(com.alibaba.otter.canal.protocol.CanalEntry.RowData.PARSER, + extensionRegistry)); + break; + } + case 106: { + if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + props_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000020; + } + props_.add(input.readMessage(com.alibaba.otter.canal.protocol.CanalEntry.Pair.PARSER, + extensionRegistry)); + break; + } + case 114: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000010; + ddlSchemaName_ = bs; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e.getMessage()).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + rowDatas_ = java.util.Collections.unmodifiableList(rowDatas_); + } + if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + props_ = java.util.Collections.unmodifiableList(props_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowChange_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowChange_fieldAccessorTable.ensureFieldAccessorsInitialized(com.alibaba.otter.canal.protocol.CanalEntry.RowChange.class, + com.alibaba.otter.canal.protocol.CanalEntry.RowChange.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + + public RowChange parsePartialFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new RowChange(input, + extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + public static final int TABLEID_FIELD_NUMBER = 1; + private long tableId_; - private int bitField0_; - public static final int TABLEID_FIELD_NUMBER = 1; - private long tableId_; - /** * optional int64 tableId = 1; * @@ -8398,10 +8214,10 @@ public final class CanalEntry { * *tableId,由数据库产生* * */ - public boolean hasTableId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - + public boolean hasTableId() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** * optional int64 tableId = 1; * @@ -8409,13 +8225,13 @@ public final class CanalEntry { * *tableId,由数据库产生* * */ - public long getTableId() { - return tableId_; - } + public long getTableId() { + return tableId_; + } + + public static final int EVENTTYPE_FIELD_NUMBER = 2; + private com.alibaba.otter.canal.protocol.CanalEntry.EventType eventType_; - public static final int EVENTTYPE_FIELD_NUMBER = 2; - private com.alibaba.otter.canal.protocol.CanalEntry.EventType eventType_; - /** * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; * @@ -8423,10 +8239,10 @@ public final class CanalEntry { * *数据变更类型* * */ - public boolean hasEventType() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - + public boolean hasEventType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; * @@ -8434,13 +8250,13 @@ public final class CanalEntry { * *数据变更类型* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.EventType getEventType() { - return eventType_; - } + public com.alibaba.otter.canal.protocol.CanalEntry.EventType getEventType() { + return eventType_; + } + + public static final int ISDDL_FIELD_NUMBER = 10; + private boolean isDdl_; - public static final int ISDDL_FIELD_NUMBER = 10; - private boolean isDdl_; - /** * optional bool isDdl = 10 [default = false]; * @@ -8448,10 +8264,10 @@ public final class CanalEntry { * * 标识是否是ddl语句 * * */ - public boolean hasIsDdl() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - + public boolean hasIsDdl() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** * optional bool isDdl = 10 [default = false]; * @@ -8459,46 +8275,13 @@ public final class CanalEntry { * * 标识是否是ddl语句 * * */ - public boolean getIsDdl() { - return isDdl_; - } - - public static final int SQL_FIELD_NUMBER = 11; - private java.lang.Object sql_; - - /** - * optional string sql = 11; - * - *
      -         * * ddl/query的sql语句  *
      -         * 
      - */ - public boolean hasSql() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - - /** - * optional string sql = 11; - * - *
      -         * * ddl/query的sql语句  *
      -         * 
      - */ - public java.lang.String getSql() { - java.lang.Object ref = sql_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - sql_ = s; + public boolean getIsDdl() { + return isDdl_; } - return s; - } - } - + + public static final int SQL_FIELD_NUMBER = 11; + private java.lang.Object sql_; + /** * optional string sql = 11; * @@ -8506,176 +8289,168 @@ public final class CanalEntry { * * ddl/query的sql语句 * * */ - public com.google.protobuf.ByteString - getSqlBytes() { - java.lang.Object ref = sql_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - sql_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int ROWDATAS_FIELD_NUMBER = 12; - private java.util.List rowDatas_; - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -         * * 一次数据库变更可能存在多行  *
      -         * 
      - */ - public java.util.List getRowDatasList() { - return rowDatas_; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -         * * 一次数据库变更可能存在多行  *
      -         * 
      - */ - public java.util.List - getRowDatasOrBuilderList() { - return rowDatas_; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -         * * 一次数据库变更可能存在多行  *
      -         * 
      - */ - public int getRowDatasCount() { - return rowDatas_.size(); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -         * * 一次数据库变更可能存在多行  *
      -         * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.RowData getRowDatas(int index) { - return rowDatas_.get(index); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -         * * 一次数据库变更可能存在多行  *
      -         * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.RowDataOrBuilder getRowDatasOrBuilder( - int index) { - return rowDatas_.get(index); - } - - public static final int PROPS_FIELD_NUMBER = 13; - private java.util.List props_; - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; - * - *
      -         * *预留扩展*
      -         * 
      - */ - public java.util.List getPropsList() { - return props_; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; - * - *
      -         * *预留扩展*
      -         * 
      - */ - public java.util.List - getPropsOrBuilderList() { - return props_; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; - * - *
      -         * *预留扩展*
      -         * 
      - */ - public int getPropsCount() { - return props_.size(); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; - * - *
      -         * *预留扩展*
      -         * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { - return props_.get(index); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; - * - *
      -         * *预留扩展*
      -         * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder( - int index) { - return props_.get(index); - } - - public static final int DDLSCHEMANAME_FIELD_NUMBER = 14; - private java.lang.Object ddlSchemaName_; - - /** - * optional string ddlSchemaName = 14; - * - *
      -         * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
      -         * 
      - */ - public boolean hasDdlSchemaName() { - return ((bitField0_ & 0x00000010) == 0x00000010); - } - - /** - * optional string ddlSchemaName = 14; - * - *
      -         * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
      -         * 
      - */ - public java.lang.String getDdlSchemaName() { - java.lang.Object ref = ddlSchemaName_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - ddlSchemaName_ = s; + public boolean hasSql() { + return ((bitField0_ & 0x00000008) == 0x00000008); } - return s; - } - } - + + /** + * optional string sql = 11; + * + *
      +         * * ddl/query的sql语句  *
      +         * 
      + */ + public java.lang.String getSql() { + java.lang.Object ref = sql_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + sql_ = s; + } + return s; + } + } + + /** + * optional string sql = 11; + * + *
      +         * * ddl/query的sql语句  *
      +         * 
      + */ + public com.google.protobuf.ByteString getSqlBytes() { + java.lang.Object ref = sql_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + sql_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ROWDATAS_FIELD_NUMBER = 12; + private java.util.List rowDatas_; + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +         * * 一次数据库变更可能存在多行  *
      +         * 
      + */ + public java.util.List getRowDatasList() { + return rowDatas_; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +         * * 一次数据库变更可能存在多行  *
      +         * 
      + */ + public java.util.List getRowDatasOrBuilderList() { + return rowDatas_; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +         * * 一次数据库变更可能存在多行  *
      +         * 
      + */ + public int getRowDatasCount() { + return rowDatas_.size(); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +         * * 一次数据库变更可能存在多行  *
      +         * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.RowData getRowDatas(int index) { + return rowDatas_.get(index); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +         * * 一次数据库变更可能存在多行  *
      +         * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.RowDataOrBuilder getRowDatasOrBuilder(int index) { + return rowDatas_.get(index); + } + + public static final int PROPS_FIELD_NUMBER = 13; + private java.util.List props_; + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public java.util.List getPropsList() { + return props_; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public java.util.List getPropsOrBuilderList() { + return props_; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public int getPropsCount() { + return props_.size(); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { + return props_.get(index); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index) { + return props_.get(index); + } + + public static final int DDLSCHEMANAME_FIELD_NUMBER = 14; + private java.lang.Object ddlSchemaName_; + /** * optional string ddlSchemaName = 14; * @@ -8683,179 +8458,213 @@ public final class CanalEntry { * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName * * */ - public com.google.protobuf.ByteString - getDdlSchemaNameBytes() { - java.lang.Object ref = ddlSchemaName_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - ddlSchemaName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } + public boolean hasDdlSchemaName() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } - private void initFields() { - tableId_ = 0L; - eventType_ = com.alibaba.otter.canal.protocol.CanalEntry.EventType.UPDATE; - isDdl_ = false; - sql_ = ""; - rowDatas_ = java.util.Collections.emptyList(); - props_ = java.util.Collections.emptyList(); - ddlSchemaName_ = ""; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; + /** + * optional string ddlSchemaName = 14; + * + *
      +         * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
      +         * 
      + */ + public java.lang.String getDdlSchemaName() { + java.lang.Object ref = ddlSchemaName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + ddlSchemaName_ = s; + } + return s; + } + } - memoizedIsInitialized = 1; - return true; - } + /** + * optional string ddlSchemaName = 14; + * + *
      +         * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
      +         * 
      + */ + public com.google.protobuf.ByteString getDdlSchemaNameBytes() { + java.lang.Object ref = ddlSchemaName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + ddlSchemaName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeInt64(1, tableId_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeEnum(2, eventType_.getNumber()); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeBool(10, isDdl_); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - output.writeBytes(11, getSqlBytes()); - } - for (int i = 0; i < rowDatas_.size(); i++) { - output.writeMessage(12, rowDatas_.get(i)); - } - for (int i = 0; i < props_.size(); i++) { - output.writeMessage(13, props_.get(i)); - } - if (((bitField0_ & 0x00000010) == 0x00000010)) { - output.writeBytes(14, getDdlSchemaNameBytes()); - } - getUnknownFields().writeTo(output); - } + private void initFields() { + tableId_ = 0L; + eventType_ = com.alibaba.otter.canal.protocol.CanalEntry.EventType.UPDATE; + isDdl_ = false; + sql_ = ""; + rowDatas_ = java.util.Collections.emptyList(); + props_ = java.util.Collections.emptyList(); + ddlSchemaName_ = ""; + } - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; + private byte memoizedIsInitialized = -1; - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(1, tableId_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeEnumSize(2, eventType_.getNumber()); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeBoolSize(10, isDdl_); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(11, getSqlBytes()); - } - for (int i = 0; i < rowDatas_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(12, rowDatas_.get(i)); - } - for (int i = 0; i < props_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(13, props_.get(i)); - } - if (((bitField0_ & 0x00000010) == 0x00000010)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(14, getDdlSchemaNameBytes()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } + memoizedIsInitialized = 1; + return true; + } - public static com.alibaba.otter.canal.protocol.CanalEntry.RowChange parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.RowChange parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.RowChange parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.RowChange parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.RowChange parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.RowChange parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.RowChange parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.RowChange parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.RowChange parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.RowChange parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeInt64(1, tableId_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeEnum(2, eventType_.getNumber()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeBool(10, isDdl_); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + output.writeBytes(11, getSqlBytes()); + } + for (int i = 0; i < rowDatas_.size(); i++) { + output.writeMessage(12, rowDatas_.get(i)); + } + for (int i = 0; i < props_.size(); i++) { + output.writeMessage(13, props_.get(i)); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + output.writeBytes(14, getDdlSchemaNameBytes()); + } + getUnknownFields().writeTo(output); + } - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(com.alibaba.otter.canal.protocol.CanalEntry.RowChange prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } + private int memoizedSerializedSize = -1; + + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(1, tableId_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(2, eventType_.getNumber()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(10, isDdl_); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(11, getSqlBytes()); + } + for (int i = 0; i < rowDatas_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(12, rowDatas_.get(i)); + } + for (int i = 0; i < props_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(13, props_.get(i)); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(14, getDdlSchemaNameBytes()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + + @java.lang.Override + protected java.lang.Object writeReplace() throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.RowChange parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.RowChange parseFrom(com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.RowChange parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.RowChange parseFrom(byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.RowChange parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.RowChange parseFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.RowChange parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.RowChange parseDelimitedFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.RowChange parseFrom(com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.RowChange parseFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { + return Builder.create(); + } + + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder(com.alibaba.otter.canal.protocol.CanalEntry.RowChange prototype) { + return newBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return newBuilder(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** * Protobuf type {@code com.alibaba.otter.canal.protocol.RowChange} * @@ -8863,248 +8672,242 @@ public final class CanalEntry { * *message row 每行变更数据的数据结构* * */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements // @@protoc_insertion_point(builder_implements:com.alibaba.otter.canal.protocol.RowChange) com.alibaba.otter.canal.protocol.CanalEntry.RowChangeOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowChange_descriptor; - } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowChange_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.alibaba.otter.canal.protocol.CanalEntry.RowChange.class, com.alibaba.otter.canal.protocol.CanalEntry.RowChange.Builder.class); - } - - // Construct using com.alibaba.otter.canal.protocol.CanalEntry.RowChange.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getRowDatasFieldBuilder(); - getPropsFieldBuilder(); - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - tableId_ = 0L; - bitField0_ = (bitField0_ & ~0x00000001); - eventType_ = com.alibaba.otter.canal.protocol.CanalEntry.EventType.UPDATE; - bitField0_ = (bitField0_ & ~0x00000002); - isDdl_ = false; - bitField0_ = (bitField0_ & ~0x00000004); - sql_ = ""; - bitField0_ = (bitField0_ & ~0x00000008); - if (rowDatasBuilder_ == null) { - rowDatas_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); - } else { - rowDatasBuilder_.clear(); - } - if (propsBuilder_ == null) { - props_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000020); - } else { - propsBuilder_.clear(); - } - ddlSchemaName_ = ""; - bitField0_ = (bitField0_ & ~0x00000040); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowChange_descriptor; - } - - public com.alibaba.otter.canal.protocol.CanalEntry.RowChange getDefaultInstanceForType() { - return com.alibaba.otter.canal.protocol.CanalEntry.RowChange.getDefaultInstance(); - } - - public com.alibaba.otter.canal.protocol.CanalEntry.RowChange build() { - com.alibaba.otter.canal.protocol.CanalEntry.RowChange result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.alibaba.otter.canal.protocol.CanalEntry.RowChange buildPartial() { - com.alibaba.otter.canal.protocol.CanalEntry.RowChange result = new com.alibaba.otter.canal.protocol.CanalEntry.RowChange(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.tableId_ = tableId_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.eventType_ = eventType_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000004; - } - result.isDdl_ = isDdl_; - if (((from_bitField0_ & 0x00000008) == 0x00000008)) { - to_bitField0_ |= 0x00000008; - } - result.sql_ = sql_; - if (rowDatasBuilder_ == null) { - if (((bitField0_ & 0x00000010) == 0x00000010)) { - rowDatas_ = java.util.Collections.unmodifiableList(rowDatas_); - bitField0_ = (bitField0_ & ~0x00000010); - } - result.rowDatas_ = rowDatas_; - } else { - result.rowDatas_ = rowDatasBuilder_.build(); - } - if (propsBuilder_ == null) { - if (((bitField0_ & 0x00000020) == 0x00000020)) { - props_ = java.util.Collections.unmodifiableList(props_); - bitField0_ = (bitField0_ & ~0x00000020); - } - result.props_ = props_; - } else { - result.props_ = propsBuilder_.build(); - } - if (((from_bitField0_ & 0x00000040) == 0x00000040)) { - to_bitField0_ |= 0x00000010; - } - result.ddlSchemaName_ = ddlSchemaName_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.alibaba.otter.canal.protocol.CanalEntry.RowChange) { - return mergeFrom((com.alibaba.otter.canal.protocol.CanalEntry.RowChange)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.alibaba.otter.canal.protocol.CanalEntry.RowChange other) { - if (other == com.alibaba.otter.canal.protocol.CanalEntry.RowChange.getDefaultInstance()) return this; - if (other.hasTableId()) { - setTableId(other.getTableId()); - } - if (other.hasEventType()) { - setEventType(other.getEventType()); - } - if (other.hasIsDdl()) { - setIsDdl(other.getIsDdl()); - } - if (other.hasSql()) { - bitField0_ |= 0x00000008; - sql_ = other.sql_; - onChanged(); - } - if (rowDatasBuilder_ == null) { - if (!other.rowDatas_.isEmpty()) { - if (rowDatas_.isEmpty()) { - rowDatas_ = other.rowDatas_; - bitField0_ = (bitField0_ & ~0x00000010); - } else { - ensureRowDatasIsMutable(); - rowDatas_.addAll(other.rowDatas_); + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowChange_descriptor; } - onChanged(); - } - } else { - if (!other.rowDatas_.isEmpty()) { - if (rowDatasBuilder_.isEmpty()) { - rowDatasBuilder_.dispose(); - rowDatasBuilder_ = null; - rowDatas_ = other.rowDatas_; - bitField0_ = (bitField0_ & ~0x00000010); - rowDatasBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getRowDatasFieldBuilder() : null; - } else { - rowDatasBuilder_.addAllMessages(other.rowDatas_); - } - } - } - if (propsBuilder_ == null) { - if (!other.props_.isEmpty()) { - if (props_.isEmpty()) { - props_ = other.props_; - bitField0_ = (bitField0_ & ~0x00000020); - } else { - ensurePropsIsMutable(); - props_.addAll(other.props_); - } - onChanged(); - } - } else { - if (!other.props_.isEmpty()) { - if (propsBuilder_.isEmpty()) { - propsBuilder_.dispose(); - propsBuilder_ = null; - props_ = other.props_; - bitField0_ = (bitField0_ & ~0x00000020); - propsBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getPropsFieldBuilder() : null; - } else { - propsBuilder_.addAllMessages(other.props_); - } - } - } - if (other.hasDdlSchemaName()) { - bitField0_ |= 0x00000040; - ddlSchemaName_ = other.ddlSchemaName_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - public final boolean isInitialized() { - return true; - } + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowChange_fieldAccessorTable.ensureFieldAccessorsInitialized(com.alibaba.otter.canal.protocol.CanalEntry.RowChange.class, + com.alibaba.otter.canal.protocol.CanalEntry.RowChange.Builder.class); + } - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.alibaba.otter.canal.protocol.CanalEntry.RowChange parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.alibaba.otter.canal.protocol.CanalEntry.RowChange) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; + // Construct using + // com.alibaba.otter.canal.protocol.CanalEntry.RowChange.newBuilder() + private Builder(){ + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent){ + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getRowDatasFieldBuilder(); + getPropsFieldBuilder(); + } + } + + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + tableId_ = 0L; + bitField0_ = (bitField0_ & ~0x00000001); + eventType_ = com.alibaba.otter.canal.protocol.CanalEntry.EventType.UPDATE; + bitField0_ = (bitField0_ & ~0x00000002); + isDdl_ = false; + bitField0_ = (bitField0_ & ~0x00000004); + sql_ = ""; + bitField0_ = (bitField0_ & ~0x00000008); + if (rowDatasBuilder_ == null) { + rowDatas_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + } else { + rowDatasBuilder_.clear(); + } + if (propsBuilder_ == null) { + props_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + } else { + propsBuilder_.clear(); + } + ddlSchemaName_ = ""; + bitField0_ = (bitField0_ & ~0x00000040); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowChange_descriptor; + } + + public com.alibaba.otter.canal.protocol.CanalEntry.RowChange getDefaultInstanceForType() { + return com.alibaba.otter.canal.protocol.CanalEntry.RowChange.getDefaultInstance(); + } + + public com.alibaba.otter.canal.protocol.CanalEntry.RowChange build() { + com.alibaba.otter.canal.protocol.CanalEntry.RowChange result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.alibaba.otter.canal.protocol.CanalEntry.RowChange buildPartial() { + com.alibaba.otter.canal.protocol.CanalEntry.RowChange result = new com.alibaba.otter.canal.protocol.CanalEntry.RowChange(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.tableId_ = tableId_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.eventType_ = eventType_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + result.isDdl_ = isDdl_; + if (((from_bitField0_ & 0x00000008) == 0x00000008)) { + to_bitField0_ |= 0x00000008; + } + result.sql_ = sql_; + if (rowDatasBuilder_ == null) { + if (((bitField0_ & 0x00000010) == 0x00000010)) { + rowDatas_ = java.util.Collections.unmodifiableList(rowDatas_); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.rowDatas_ = rowDatas_; + } else { + result.rowDatas_ = rowDatasBuilder_.build(); + } + if (propsBuilder_ == null) { + if (((bitField0_ & 0x00000020) == 0x00000020)) { + props_ = java.util.Collections.unmodifiableList(props_); + bitField0_ = (bitField0_ & ~0x00000020); + } + result.props_ = props_; + } else { + result.props_ = propsBuilder_.build(); + } + if (((from_bitField0_ & 0x00000040) == 0x00000040)) { + to_bitField0_ |= 0x00000010; + } + result.ddlSchemaName_ = ddlSchemaName_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.alibaba.otter.canal.protocol.CanalEntry.RowChange) { + return mergeFrom((com.alibaba.otter.canal.protocol.CanalEntry.RowChange) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.alibaba.otter.canal.protocol.CanalEntry.RowChange other) { + if (other == com.alibaba.otter.canal.protocol.CanalEntry.RowChange.getDefaultInstance()) return this; + if (other.hasTableId()) { + setTableId(other.getTableId()); + } + if (other.hasEventType()) { + setEventType(other.getEventType()); + } + if (other.hasIsDdl()) { + setIsDdl(other.getIsDdl()); + } + if (other.hasSql()) { + bitField0_ |= 0x00000008; + sql_ = other.sql_; + onChanged(); + } + if (rowDatasBuilder_ == null) { + if (!other.rowDatas_.isEmpty()) { + if (rowDatas_.isEmpty()) { + rowDatas_ = other.rowDatas_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensureRowDatasIsMutable(); + rowDatas_.addAll(other.rowDatas_); + } + onChanged(); + } + } else { + if (!other.rowDatas_.isEmpty()) { + if (rowDatasBuilder_.isEmpty()) { + rowDatasBuilder_.dispose(); + rowDatasBuilder_ = null; + rowDatas_ = other.rowDatas_; + bitField0_ = (bitField0_ & ~0x00000010); + rowDatasBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getRowDatasFieldBuilder() : null; + } else { + rowDatasBuilder_.addAllMessages(other.rowDatas_); + } + } + } + if (propsBuilder_ == null) { + if (!other.props_.isEmpty()) { + if (props_.isEmpty()) { + props_ = other.props_; + bitField0_ = (bitField0_ & ~0x00000020); + } else { + ensurePropsIsMutable(); + props_.addAll(other.props_); + } + onChanged(); + } + } else { + if (!other.props_.isEmpty()) { + if (propsBuilder_.isEmpty()) { + propsBuilder_.dispose(); + propsBuilder_ = null; + props_ = other.props_; + bitField0_ = (bitField0_ & ~0x00000020); + propsBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getPropsFieldBuilder() : null; + } else { + propsBuilder_.addAllMessages(other.props_); + } + } + } + if (other.hasDdlSchemaName()) { + bitField0_ |= 0x00000040; + ddlSchemaName_ = other.ddlSchemaName_; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.alibaba.otter.canal.protocol.CanalEntry.RowChange parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.alibaba.otter.canal.protocol.CanalEntry.RowChange) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private long tableId_; - private long tableId_ ; - /** * optional int64 tableId = 1; * @@ -9112,10 +8915,10 @@ public final class CanalEntry { * *tableId,由数据库产生* * */ - public boolean hasTableId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - + public boolean hasTableId() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** * optional int64 tableId = 1; * @@ -9123,10 +8926,10 @@ public final class CanalEntry { * *tableId,由数据库产生* * */ - public long getTableId() { - return tableId_; - } - + public long getTableId() { + return tableId_; + } + /** * optional int64 tableId = 1; * @@ -9134,13 +8937,13 @@ public final class CanalEntry { * *tableId,由数据库产生* * */ - public Builder setTableId(long value) { - bitField0_ |= 0x00000001; - tableId_ = value; - onChanged(); - return this; - } - + public Builder setTableId(long value) { + bitField0_ |= 0x00000001; + tableId_ = value; + onChanged(); + return this; + } + /** * optional int64 tableId = 1; * @@ -9148,15 +8951,15 @@ public final class CanalEntry { * *tableId,由数据库产生* * */ - public Builder clearTableId() { - bitField0_ = (bitField0_ & ~0x00000001); - tableId_ = 0L; - onChanged(); - return this; - } + public Builder clearTableId() { + bitField0_ = (bitField0_ & ~0x00000001); + tableId_ = 0L; + onChanged(); + return this; + } + + private com.alibaba.otter.canal.protocol.CanalEntry.EventType eventType_ = com.alibaba.otter.canal.protocol.CanalEntry.EventType.UPDATE; - private com.alibaba.otter.canal.protocol.CanalEntry.EventType eventType_ = com.alibaba.otter.canal.protocol.CanalEntry.EventType.UPDATE; - /** * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; * @@ -9164,10 +8967,10 @@ public final class CanalEntry { * *数据变更类型* * */ - public boolean hasEventType() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - + public boolean hasEventType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; * @@ -9175,10 +8978,10 @@ public final class CanalEntry { * *数据变更类型* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.EventType getEventType() { - return eventType_; - } - + public com.alibaba.otter.canal.protocol.CanalEntry.EventType getEventType() { + return eventType_; + } + /** * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; * @@ -9186,16 +8989,16 @@ public final class CanalEntry { * *数据变更类型* * */ - public Builder setEventType(com.alibaba.otter.canal.protocol.CanalEntry.EventType value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - eventType_ = value; - onChanged(); - return this; - } - + public Builder setEventType(com.alibaba.otter.canal.protocol.CanalEntry.EventType value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + eventType_ = value; + onChanged(); + return this; + } + /** * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; * @@ -9203,15 +9006,15 @@ public final class CanalEntry { * *数据变更类型* * */ - public Builder clearEventType() { - bitField0_ = (bitField0_ & ~0x00000002); - eventType_ = com.alibaba.otter.canal.protocol.CanalEntry.EventType.UPDATE; - onChanged(); - return this; - } + public Builder clearEventType() { + bitField0_ = (bitField0_ & ~0x00000002); + eventType_ = com.alibaba.otter.canal.protocol.CanalEntry.EventType.UPDATE; + onChanged(); + return this; + } + + private boolean isDdl_; - private boolean isDdl_ ; - /** * optional bool isDdl = 10 [default = false]; * @@ -9219,10 +9022,10 @@ public final class CanalEntry { * * 标识是否是ddl语句 * * */ - public boolean hasIsDdl() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - + public boolean hasIsDdl() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** * optional bool isDdl = 10 [default = false]; * @@ -9230,10 +9033,10 @@ public final class CanalEntry { * * 标识是否是ddl语句 * * */ - public boolean getIsDdl() { - return isDdl_; - } - + public boolean getIsDdl() { + return isDdl_; + } + /** * optional bool isDdl = 10 [default = false]; * @@ -9241,13 +9044,13 @@ public final class CanalEntry { * * 标识是否是ddl语句 * * */ - public Builder setIsDdl(boolean value) { - bitField0_ |= 0x00000004; - isDdl_ = value; - onChanged(); - return this; - } - + public Builder setIsDdl(boolean value) { + bitField0_ |= 0x00000004; + isDdl_ = value; + onChanged(); + return this; + } + /** * optional bool isDdl = 10 [default = false]; * @@ -9255,15 +9058,15 @@ public final class CanalEntry { * * 标识是否是ddl语句 * * */ - public Builder clearIsDdl() { - bitField0_ = (bitField0_ & ~0x00000004); - isDdl_ = false; - onChanged(); - return this; - } + public Builder clearIsDdl() { + bitField0_ = (bitField0_ & ~0x00000004); + isDdl_ = false; + onChanged(); + return this; + } + + private java.lang.Object sql_ = ""; - private java.lang.Object sql_ = ""; - /** * optional string sql = 11; * @@ -9271,10 +9074,10 @@ public final class CanalEntry { * * ddl/query的sql语句 * * */ - public boolean hasSql() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - + public boolean hasSql() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** * optional string sql = 11; * @@ -9282,21 +9085,20 @@ public final class CanalEntry { * * ddl/query的sql语句 * * */ - public java.lang.String getSql() { - java.lang.Object ref = sql_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - sql_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - + public java.lang.String getSql() { + java.lang.Object ref = sql_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + sql_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** * optional string sql = 11; * @@ -9304,20 +9106,17 @@ public final class CanalEntry { * * ddl/query的sql语句 * * */ - public com.google.protobuf.ByteString - getSqlBytes() { - java.lang.Object ref = sql_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - sql_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - + public com.google.protobuf.ByteString getSqlBytes() { + java.lang.Object ref = sql_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + sql_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** * optional string sql = 11; * @@ -9325,17 +9124,16 @@ public final class CanalEntry { * * ddl/query的sql语句 * * */ - public Builder setSql( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000008; - sql_ = value; - onChanged(); - return this; - } - + public Builder setSql(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000008; + sql_ = value; + onChanged(); + return this; + } + /** * optional string sql = 11; * @@ -9343,13 +9141,13 @@ public final class CanalEntry { * * ddl/query的sql语句 * * */ - public Builder clearSql() { - bitField0_ = (bitField0_ & ~0x00000008); - sql_ = getDefaultInstance().getSql(); - onChanged(); - return this; - } - + public Builder clearSql() { + bitField0_ = (bitField0_ & ~0x00000008); + sql_ = getDefaultInstance().getSql(); + onChanged(); + return this; + } + /** * optional string sql = 11; * @@ -9357,28 +9155,26 @@ public final class CanalEntry { * * ddl/query的sql语句 * * */ - public Builder setSqlBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000008; - sql_ = value; - onChanged(); - return this; - } + public Builder setSqlBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000008; + sql_ = value; + onChanged(); + return this; + } - private java.util.List rowDatas_ = - java.util.Collections.emptyList(); - private void ensureRowDatasIsMutable() { - if (!((bitField0_ & 0x00000010) == 0x00000010)) { - rowDatas_ = new java.util.ArrayList(rowDatas_); - bitField0_ |= 0x00000010; - } - } + private java.util.List rowDatas_ = java.util.Collections.emptyList(); - private com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.RowData, com.alibaba.otter.canal.protocol.CanalEntry.RowData.Builder, com.alibaba.otter.canal.protocol.CanalEntry.RowDataOrBuilder> rowDatasBuilder_; + private void ensureRowDatasIsMutable() { + if (!((bitField0_ & 0x00000010) == 0x00000010)) { + rowDatas_ = new java.util.ArrayList(rowDatas_); + bitField0_ |= 0x00000010; + } + } + + private com.google.protobuf.RepeatedFieldBuilder rowDatasBuilder_; /** * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; @@ -9387,327 +9183,313 @@ public final class CanalEntry { * * 一次数据库变更可能存在多行 * * */ - public java.util.List getRowDatasList() { - if (rowDatasBuilder_ == null) { - return java.util.Collections.unmodifiableList(rowDatas_); - } else { - return rowDatasBuilder_.getMessageList(); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -             * * 一次数据库变更可能存在多行  *
      -             * 
      - */ - public int getRowDatasCount() { - if (rowDatasBuilder_ == null) { - return rowDatas_.size(); - } else { - return rowDatasBuilder_.getCount(); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -             * * 一次数据库变更可能存在多行  *
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.RowData getRowDatas(int index) { - if (rowDatasBuilder_ == null) { - return rowDatas_.get(index); - } else { - return rowDatasBuilder_.getMessage(index); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -             * * 一次数据库变更可能存在多行  *
      -             * 
      - */ - public Builder setRowDatas( - int index, com.alibaba.otter.canal.protocol.CanalEntry.RowData value) { - if (rowDatasBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureRowDatasIsMutable(); - rowDatas_.set(index, value); - onChanged(); - } else { - rowDatasBuilder_.setMessage(index, value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -             * * 一次数据库变更可能存在多行  *
      -             * 
      - */ - public Builder setRowDatas( - int index, com.alibaba.otter.canal.protocol.CanalEntry.RowData.Builder builderForValue) { - if (rowDatasBuilder_ == null) { - ensureRowDatasIsMutable(); - rowDatas_.set(index, builderForValue.build()); - onChanged(); - } else { - rowDatasBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -             * * 一次数据库变更可能存在多行  *
      -             * 
      - */ - public Builder addRowDatas(com.alibaba.otter.canal.protocol.CanalEntry.RowData value) { - if (rowDatasBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureRowDatasIsMutable(); - rowDatas_.add(value); - onChanged(); - } else { - rowDatasBuilder_.addMessage(value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -             * * 一次数据库变更可能存在多行  *
      -             * 
      - */ - public Builder addRowDatas( - int index, com.alibaba.otter.canal.protocol.CanalEntry.RowData value) { - if (rowDatasBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureRowDatasIsMutable(); - rowDatas_.add(index, value); - onChanged(); - } else { - rowDatasBuilder_.addMessage(index, value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -             * * 一次数据库变更可能存在多行  *
      -             * 
      - */ - public Builder addRowDatas( - com.alibaba.otter.canal.protocol.CanalEntry.RowData.Builder builderForValue) { - if (rowDatasBuilder_ == null) { - ensureRowDatasIsMutable(); - rowDatas_.add(builderForValue.build()); - onChanged(); - } else { - rowDatasBuilder_.addMessage(builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -             * * 一次数据库变更可能存在多行  *
      -             * 
      - */ - public Builder addRowDatas( - int index, com.alibaba.otter.canal.protocol.CanalEntry.RowData.Builder builderForValue) { - if (rowDatasBuilder_ == null) { - ensureRowDatasIsMutable(); - rowDatas_.add(index, builderForValue.build()); - onChanged(); - } else { - rowDatasBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -             * * 一次数据库变更可能存在多行  *
      -             * 
      - */ - public Builder addAllRowDatas( - java.lang.Iterable values) { - if (rowDatasBuilder_ == null) { - ensureRowDatasIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, rowDatas_); - onChanged(); - } else { - rowDatasBuilder_.addAllMessages(values); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -             * * 一次数据库变更可能存在多行  *
      -             * 
      - */ - public Builder clearRowDatas() { - if (rowDatasBuilder_ == null) { - rowDatas_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); - onChanged(); - } else { - rowDatasBuilder_.clear(); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -             * * 一次数据库变更可能存在多行  *
      -             * 
      - */ - public Builder removeRowDatas(int index) { - if (rowDatasBuilder_ == null) { - ensureRowDatasIsMutable(); - rowDatas_.remove(index); - onChanged(); - } else { - rowDatasBuilder_.remove(index); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -             * * 一次数据库变更可能存在多行  *
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.RowData.Builder getRowDatasBuilder( - int index) { - return getRowDatasFieldBuilder().getBuilder(index); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -             * * 一次数据库变更可能存在多行  *
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.RowDataOrBuilder getRowDatasOrBuilder( - int index) { - if (rowDatasBuilder_ == null) { - return rowDatas_.get(index); } else { - return rowDatasBuilder_.getMessageOrBuilder(index); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -             * * 一次数据库变更可能存在多行  *
      -             * 
      - */ - public java.util.List - getRowDatasOrBuilderList() { - if (rowDatasBuilder_ != null) { - return rowDatasBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(rowDatas_); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -             * * 一次数据库变更可能存在多行  *
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.RowData.Builder addRowDatasBuilder() { - return getRowDatasFieldBuilder().addBuilder( - com.alibaba.otter.canal.protocol.CanalEntry.RowData.getDefaultInstance()); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -             * * 一次数据库变更可能存在多行  *
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.RowData.Builder addRowDatasBuilder( - int index) { - return getRowDatasFieldBuilder().addBuilder( - index, com.alibaba.otter.canal.protocol.CanalEntry.RowData.getDefaultInstance()); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
      -             * * 一次数据库变更可能存在多行  *
      -             * 
      - */ - public java.util.List - getRowDatasBuilderList() { - return getRowDatasFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.RowData, com.alibaba.otter.canal.protocol.CanalEntry.RowData.Builder, com.alibaba.otter.canal.protocol.CanalEntry.RowDataOrBuilder> - getRowDatasFieldBuilder() { - if (rowDatasBuilder_ == null) { - rowDatasBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.RowData, com.alibaba.otter.canal.protocol.CanalEntry.RowData.Builder, com.alibaba.otter.canal.protocol.CanalEntry.RowDataOrBuilder>( - rowDatas_, - ((bitField0_ & 0x00000010) == 0x00000010), - getParentForChildren(), - isClean()); - rowDatas_ = null; - } - return rowDatasBuilder_; - } + public java.util.List getRowDatasList() { + if (rowDatasBuilder_ == null) { + return java.util.Collections.unmodifiableList(rowDatas_); + } else { + return rowDatasBuilder_.getMessageList(); + } + } - private java.util.List props_ = - java.util.Collections.emptyList(); - private void ensurePropsIsMutable() { - if (!((bitField0_ & 0x00000020) == 0x00000020)) { - props_ = new java.util.ArrayList(props_); - bitField0_ |= 0x00000020; - } - } + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +             * * 一次数据库变更可能存在多行  *
      +             * 
      + */ + public int getRowDatasCount() { + if (rowDatasBuilder_ == null) { + return rowDatas_.size(); + } else { + return rowDatasBuilder_.getCount(); + } + } - private com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Pair, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder, com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder> propsBuilder_; + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +             * * 一次数据库变更可能存在多行  *
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.RowData getRowDatas(int index) { + if (rowDatasBuilder_ == null) { + return rowDatas_.get(index); + } else { + return rowDatasBuilder_.getMessage(index); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +             * * 一次数据库变更可能存在多行  *
      +             * 
      + */ + public Builder setRowDatas(int index, com.alibaba.otter.canal.protocol.CanalEntry.RowData value) { + if (rowDatasBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRowDatasIsMutable(); + rowDatas_.set(index, value); + onChanged(); + } else { + rowDatasBuilder_.setMessage(index, value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +             * * 一次数据库变更可能存在多行  *
      +             * 
      + */ + public Builder setRowDatas(int index, + com.alibaba.otter.canal.protocol.CanalEntry.RowData.Builder builderForValue) { + if (rowDatasBuilder_ == null) { + ensureRowDatasIsMutable(); + rowDatas_.set(index, builderForValue.build()); + onChanged(); + } else { + rowDatasBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +             * * 一次数据库变更可能存在多行  *
      +             * 
      + */ + public Builder addRowDatas(com.alibaba.otter.canal.protocol.CanalEntry.RowData value) { + if (rowDatasBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRowDatasIsMutable(); + rowDatas_.add(value); + onChanged(); + } else { + rowDatasBuilder_.addMessage(value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +             * * 一次数据库变更可能存在多行  *
      +             * 
      + */ + public Builder addRowDatas(int index, com.alibaba.otter.canal.protocol.CanalEntry.RowData value) { + if (rowDatasBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRowDatasIsMutable(); + rowDatas_.add(index, value); + onChanged(); + } else { + rowDatasBuilder_.addMessage(index, value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +             * * 一次数据库变更可能存在多行  *
      +             * 
      + */ + public Builder addRowDatas(com.alibaba.otter.canal.protocol.CanalEntry.RowData.Builder builderForValue) { + if (rowDatasBuilder_ == null) { + ensureRowDatasIsMutable(); + rowDatas_.add(builderForValue.build()); + onChanged(); + } else { + rowDatasBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +             * * 一次数据库变更可能存在多行  *
      +             * 
      + */ + public Builder addRowDatas(int index, + com.alibaba.otter.canal.protocol.CanalEntry.RowData.Builder builderForValue) { + if (rowDatasBuilder_ == null) { + ensureRowDatasIsMutable(); + rowDatas_.add(index, builderForValue.build()); + onChanged(); + } else { + rowDatasBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +             * * 一次数据库变更可能存在多行  *
      +             * 
      + */ + public Builder addAllRowDatas(java.lang.Iterable values) { + if (rowDatasBuilder_ == null) { + ensureRowDatasIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, rowDatas_); + onChanged(); + } else { + rowDatasBuilder_.addAllMessages(values); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +             * * 一次数据库变更可能存在多行  *
      +             * 
      + */ + public Builder clearRowDatas() { + if (rowDatasBuilder_ == null) { + rowDatas_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + } else { + rowDatasBuilder_.clear(); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +             * * 一次数据库变更可能存在多行  *
      +             * 
      + */ + public Builder removeRowDatas(int index) { + if (rowDatasBuilder_ == null) { + ensureRowDatasIsMutable(); + rowDatas_.remove(index); + onChanged(); + } else { + rowDatasBuilder_.remove(index); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +             * * 一次数据库变更可能存在多行  *
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.RowData.Builder getRowDatasBuilder(int index) { + return getRowDatasFieldBuilder().getBuilder(index); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +             * * 一次数据库变更可能存在多行  *
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.RowDataOrBuilder getRowDatasOrBuilder(int index) { + if (rowDatasBuilder_ == null) { + return rowDatas_.get(index); + } else { + return rowDatasBuilder_.getMessageOrBuilder(index); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +             * * 一次数据库变更可能存在多行  *
      +             * 
      + */ + public java.util.List getRowDatasOrBuilderList() { + if (rowDatasBuilder_ != null) { + return rowDatasBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(rowDatas_); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +             * * 一次数据库变更可能存在多行  *
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.RowData.Builder addRowDatasBuilder() { + return getRowDatasFieldBuilder().addBuilder(com.alibaba.otter.canal.protocol.CanalEntry.RowData.getDefaultInstance()); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +             * * 一次数据库变更可能存在多行  *
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.RowData.Builder addRowDatasBuilder(int index) { + return getRowDatasFieldBuilder().addBuilder(index, + com.alibaba.otter.canal.protocol.CanalEntry.RowData.getDefaultInstance()); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
      +             * * 一次数据库变更可能存在多行  *
      +             * 
      + */ + public java.util.List getRowDatasBuilderList() { + return getRowDatasFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder getRowDatasFieldBuilder() { + if (rowDatasBuilder_ == null) { + rowDatasBuilder_ = new com.google.protobuf.RepeatedFieldBuilder(rowDatas_, + ((bitField0_ & 0x00000010) == 0x00000010), + getParentForChildren(), + isClean()); + rowDatas_ = null; + } + return rowDatasBuilder_; + } + + private java.util.List props_ = java.util.Collections.emptyList(); + + private void ensurePropsIsMutable() { + if (!((bitField0_ & 0x00000020) == 0x00000020)) { + props_ = new java.util.ArrayList(props_); + bitField0_ |= 0x00000020; + } + } + + private com.google.protobuf.RepeatedFieldBuilder propsBuilder_; /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; @@ -9716,14 +9498,14 @@ public final class CanalEntry { * *预留扩展* * */ - public java.util.List getPropsList() { - if (propsBuilder_ == null) { - return java.util.Collections.unmodifiableList(props_); - } else { - return propsBuilder_.getMessageList(); - } - } - + public java.util.List getPropsList() { + if (propsBuilder_ == null) { + return java.util.Collections.unmodifiableList(props_); + } else { + return propsBuilder_.getMessageList(); + } + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -9731,14 +9513,14 @@ public final class CanalEntry { * *预留扩展* * */ - public int getPropsCount() { - if (propsBuilder_ == null) { - return props_.size(); - } else { - return propsBuilder_.getCount(); - } - } - + public int getPropsCount() { + if (propsBuilder_ == null) { + return props_.size(); + } else { + return propsBuilder_.getCount(); + } + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -9746,14 +9528,14 @@ public final class CanalEntry { * *预留扩展* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { - if (propsBuilder_ == null) { - return props_.get(index); - } else { - return propsBuilder_.getMessage(index); - } - } - + public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { + if (propsBuilder_ == null) { + return props_.get(index); + } else { + return propsBuilder_.getMessage(index); + } + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -9761,21 +9543,20 @@ public final class CanalEntry { * *预留扩展* * */ - public Builder setProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { - if (propsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePropsIsMutable(); - props_.set(index, value); - onChanged(); - } else { - propsBuilder_.setMessage(index, value); - } - return this; - } - + public Builder setProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { + if (propsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropsIsMutable(); + props_.set(index, value); + onChanged(); + } else { + propsBuilder_.setMessage(index, value); + } + return this; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -9783,18 +9564,17 @@ public final class CanalEntry { * *预留扩展* * */ - public Builder setProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.set(index, builderForValue.build()); - onChanged(); - } else { - propsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - + public Builder setProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.set(index, builderForValue.build()); + onChanged(); + } else { + propsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -9802,20 +9582,20 @@ public final class CanalEntry { * *预留扩展* * */ - public Builder addProps(com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { - if (propsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePropsIsMutable(); - props_.add(value); - onChanged(); - } else { - propsBuilder_.addMessage(value); - } - return this; - } - + public Builder addProps(com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { + if (propsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropsIsMutable(); + props_.add(value); + onChanged(); + } else { + propsBuilder_.addMessage(value); + } + return this; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -9823,21 +9603,20 @@ public final class CanalEntry { * *预留扩展* * */ - public Builder addProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { - if (propsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePropsIsMutable(); - props_.add(index, value); - onChanged(); - } else { - propsBuilder_.addMessage(index, value); - } - return this; - } - + public Builder addProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { + if (propsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropsIsMutable(); + props_.add(index, value); + onChanged(); + } else { + propsBuilder_.addMessage(index, value); + } + return this; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -9845,18 +9624,17 @@ public final class CanalEntry { * *预留扩展* * */ - public Builder addProps( - com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.add(builderForValue.build()); - onChanged(); - } else { - propsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - + public Builder addProps(com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.add(builderForValue.build()); + onChanged(); + } else { + propsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -9864,18 +9642,17 @@ public final class CanalEntry { * *预留扩展* * */ - public Builder addProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.add(index, builderForValue.build()); - onChanged(); - } else { - propsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - + public Builder addProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.add(index, builderForValue.build()); + onChanged(); + } else { + propsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -9883,19 +9660,17 @@ public final class CanalEntry { * *预留扩展* * */ - public Builder addAllProps( - java.lang.Iterable values) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, props_); - onChanged(); - } else { - propsBuilder_.addAllMessages(values); - } - return this; - } - + public Builder addAllProps(java.lang.Iterable values) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, props_); + onChanged(); + } else { + propsBuilder_.addAllMessages(values); + } + return this; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -9903,17 +9678,17 @@ public final class CanalEntry { * *预留扩展* * */ - public Builder clearProps() { - if (propsBuilder_ == null) { - props_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000020); - onChanged(); - } else { - propsBuilder_.clear(); - } - return this; - } - + public Builder clearProps() { + if (propsBuilder_ == null) { + props_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + onChanged(); + } else { + propsBuilder_.clear(); + } + return this; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -9921,17 +9696,17 @@ public final class CanalEntry { * *预留扩展* * */ - public Builder removeProps(int index) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.remove(index); - onChanged(); - } else { - propsBuilder_.remove(index); - } - return this; - } - + public Builder removeProps(int index) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.remove(index); + onChanged(); + } else { + propsBuilder_.remove(index); + } + return this; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -9939,11 +9714,10 @@ public final class CanalEntry { * *预留扩展* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder getPropsBuilder( - int index) { - return getPropsFieldBuilder().getBuilder(index); - } - + public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder getPropsBuilder(int index) { + return getPropsFieldBuilder().getBuilder(index); + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -9951,14 +9725,14 @@ public final class CanalEntry { * *预留扩展* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder( - int index) { - if (propsBuilder_ == null) { - return props_.get(index); } else { - return propsBuilder_.getMessageOrBuilder(index); - } - } - + public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index) { + if (propsBuilder_ == null) { + return props_.get(index); + } else { + return propsBuilder_.getMessageOrBuilder(index); + } + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -9966,15 +9740,14 @@ public final class CanalEntry { * *预留扩展* * */ - public java.util.List - getPropsOrBuilderList() { - if (propsBuilder_ != null) { - return propsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(props_); - } - } - + public java.util.List getPropsOrBuilderList() { + if (propsBuilder_ != null) { + return propsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(props_); + } + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -9982,11 +9755,10 @@ public final class CanalEntry { * *预留扩展* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder() { - return getPropsFieldBuilder().addBuilder( - com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); - } - + public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder() { + return getPropsFieldBuilder().addBuilder(com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -9994,12 +9766,11 @@ public final class CanalEntry { * *预留扩展* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder( - int index) { - return getPropsFieldBuilder().addBuilder( - index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); - } - + public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder(int index) { + return getPropsFieldBuilder().addBuilder(index, + com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; * @@ -10007,27 +9778,23 @@ public final class CanalEntry { * *预留扩展* * */ - public java.util.List - getPropsBuilderList() { - return getPropsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Pair, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder, com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder> - getPropsFieldBuilder() { - if (propsBuilder_ == null) { - propsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Pair, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder, com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder>( - props_, - ((bitField0_ & 0x00000020) == 0x00000020), - getParentForChildren(), - isClean()); - props_ = null; - } - return propsBuilder_; - } + public java.util.List getPropsBuilderList() { + return getPropsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder getPropsFieldBuilder() { + if (propsBuilder_ == null) { + propsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder(props_, + ((bitField0_ & 0x00000020) == 0x00000020), + getParentForChildren(), + isClean()); + props_ = null; + } + return propsBuilder_; + } + + private java.lang.Object ddlSchemaName_ = ""; - private java.lang.Object ddlSchemaName_ = ""; - /** * optional string ddlSchemaName = 14; * @@ -10035,117 +9802,111 @@ public final class CanalEntry { * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName * * */ - public boolean hasDdlSchemaName() { - return ((bitField0_ & 0x00000040) == 0x00000040); - } - - /** - * optional string ddlSchemaName = 14; - * - *
      -             * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
      -             * 
      - */ - public java.lang.String getDdlSchemaName() { - java.lang.Object ref = ddlSchemaName_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - ddlSchemaName_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * optional string ddlSchemaName = 14; - * - *
      -             * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
      -             * 
      - */ - public com.google.protobuf.ByteString - getDdlSchemaNameBytes() { - java.lang.Object ref = ddlSchemaName_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - ddlSchemaName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * optional string ddlSchemaName = 14; - * - *
      -             * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
      -             * 
      - */ - public Builder setDdlSchemaName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000040; - ddlSchemaName_ = value; - onChanged(); - return this; - } - - /** - * optional string ddlSchemaName = 14; - * - *
      -             * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
      -             * 
      - */ - public Builder clearDdlSchemaName() { - bitField0_ = (bitField0_ & ~0x00000040); - ddlSchemaName_ = getDefaultInstance().getDdlSchemaName(); - onChanged(); - return this; - } - - /** - * optional string ddlSchemaName = 14; - * - *
      -             * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
      -             * 
      - */ - public Builder setDdlSchemaNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000040; - ddlSchemaName_ = value; - onChanged(); - return this; - } + public boolean hasDdlSchemaName() { + return ((bitField0_ & 0x00000040) == 0x00000040); + } - // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.RowChange) + /** + * optional string ddlSchemaName = 14; + * + *
      +             * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
      +             * 
      + */ + public java.lang.String getDdlSchemaName() { + java.lang.Object ref = ddlSchemaName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + ddlSchemaName_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * optional string ddlSchemaName = 14; + * + *
      +             * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
      +             * 
      + */ + public com.google.protobuf.ByteString getDdlSchemaNameBytes() { + java.lang.Object ref = ddlSchemaName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + ddlSchemaName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * optional string ddlSchemaName = 14; + * + *
      +             * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
      +             * 
      + */ + public Builder setDdlSchemaName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000040; + ddlSchemaName_ = value; + onChanged(); + return this; + } + + /** + * optional string ddlSchemaName = 14; + * + *
      +             * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
      +             * 
      + */ + public Builder clearDdlSchemaName() { + bitField0_ = (bitField0_ & ~0x00000040); + ddlSchemaName_ = getDefaultInstance().getDdlSchemaName(); + onChanged(); + return this; + } + + /** + * optional string ddlSchemaName = 14; + * + *
      +             * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
      +             * 
      + */ + public Builder setDdlSchemaNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000040; + ddlSchemaName_ = value; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.RowChange) + } + + static { + defaultInstance = new RowChange(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.RowChange) } - static { - defaultInstance = new RowChange(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.RowChange) - } - - public interface TransactionBeginOrBuilder extends - // @@protoc_insertion_point(interface_extends:com.alibaba.otter.canal.protocol.TransactionBegin) - com.google.protobuf.MessageOrBuilder { + public interface TransactionBeginOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.alibaba.otter.canal.protocol.TransactionBegin) + com.google.protobuf.MessageOrBuilder { /** * optional int64 executeTime = 1; @@ -10154,8 +9915,8 @@ public final class CanalEntry { * *已废弃,请使用header里的executeTime* * */ - boolean hasExecuteTime(); - + boolean hasExecuteTime(); + /** * optional int64 executeTime = 1; * @@ -10163,7 +9924,7 @@ public final class CanalEntry { * *已废弃,请使用header里的executeTime* * */ - long getExecuteTime(); + long getExecuteTime(); /** * optional string transactionId = 2; @@ -10172,8 +9933,8 @@ public final class CanalEntry { * *已废弃,Begin里不提供事务id* * */ - boolean hasTransactionId(); - + boolean hasTransactionId(); + /** * optional string transactionId = 2; * @@ -10181,8 +9942,8 @@ public final class CanalEntry { * *已废弃,Begin里不提供事务id* * */ - java.lang.String getTransactionId(); - + java.lang.String getTransactionId(); + /** * optional string transactionId = 2; * @@ -10190,8 +9951,7 @@ public final class CanalEntry { * *已废弃,Begin里不提供事务id* * */ - com.google.protobuf.ByteString - getTransactionIdBytes(); + com.google.protobuf.ByteString getTransactionIdBytes(); /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; @@ -10200,9 +9960,8 @@ public final class CanalEntry { * *预留扩展* * */ - java.util.List - getPropsList(); - + java.util.List getPropsList(); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -10210,8 +9969,8 @@ public final class CanalEntry { * *预留扩展* * */ - com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index); - + com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -10219,8 +9978,8 @@ public final class CanalEntry { * *预留扩展* * */ - int getPropsCount(); - + int getPropsCount(); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -10228,9 +9987,8 @@ public final class CanalEntry { * *预留扩展* * */ - java.util.List - getPropsOrBuilderList(); - + java.util.List getPropsOrBuilderList(); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -10238,8 +9996,7 @@ public final class CanalEntry { * *预留扩展* * */ - com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder( - int index); + com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index); /** * optional int64 threadId = 4; @@ -10248,8 +10005,8 @@ public final class CanalEntry { * *执行的thread Id* * */ - boolean hasThreadId(); - + boolean hasThreadId(); + /** * optional int64 threadId = 4; * @@ -10257,9 +10014,9 @@ public final class CanalEntry { * *执行的thread Id* * */ - long getThreadId(); - } - + long getThreadId(); + } + /** * Protobuf type {@code com.alibaba.otter.canal.protocol.TransactionBegin} * @@ -10267,125 +10024,125 @@ public final class CanalEntry { * *开始事务的一些信息* * */ - public static final class TransactionBegin extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:com.alibaba.otter.canal.protocol.TransactionBegin) - TransactionBeginOrBuilder { - // Use TransactionBegin.newBuilder() to construct. - private TransactionBegin(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private TransactionBegin(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + public static final class TransactionBegin extends com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:com.alibaba.otter.canal.protocol.TransactionBegin) + TransactionBeginOrBuilder { - private static final TransactionBegin defaultInstance; - public static TransactionBegin getDefaultInstance() { - return defaultInstance; - } - - public TransactionBegin getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private TransactionBegin( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - bitField0_ |= 0x00000001; - executeTime_ = input.readInt64(); - break; - } - case 18: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000002; - transactionId_ = bs; - break; - } - case 26: { - if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - props_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000004; - } - props_.add(input.readMessage(com.alibaba.otter.canal.protocol.CanalEntry.Pair.PARSER, extensionRegistry)); - break; - } - case 32: { - bitField0_ |= 0x00000004; - threadId_ = input.readInt64(); - break; - } - } + // Use TransactionBegin.newBuilder() to construct. + private TransactionBegin(com.google.protobuf.GeneratedMessage.Builder builder){ + super(builder); + this.unknownFields = builder.getUnknownFields(); } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - props_ = java.util.Collections.unmodifiableList(props_); + + private TransactionBegin(boolean noInit){ + this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_descriptor; - } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin.class, com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin.Builder.class); - } + private static final TransactionBegin defaultInstance; - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public TransactionBegin parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new TransactionBegin(input, extensionRegistry); - } - }; + public static TransactionBegin getDefaultInstance() { + return defaultInstance; + } - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } + public TransactionBegin getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private TransactionBegin(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException{ + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + bitField0_ |= 0x00000001; + executeTime_ = input.readInt64(); + break; + } + case 18: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000002; + transactionId_ = bs; + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + props_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + props_.add(input.readMessage(com.alibaba.otter.canal.protocol.CanalEntry.Pair.PARSER, + extensionRegistry)); + break; + } + case 32: { + bitField0_ |= 0x00000004; + threadId_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e.getMessage()).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + props_ = java.util.Collections.unmodifiableList(props_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_fieldAccessorTable.ensureFieldAccessorsInitialized(com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin.class, + com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + + public TransactionBegin parsePartialFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TransactionBegin(input, + extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + public static final int EXECUTETIME_FIELD_NUMBER = 1; + private long executeTime_; - private int bitField0_; - public static final int EXECUTETIME_FIELD_NUMBER = 1; - private long executeTime_; - /** * optional int64 executeTime = 1; * @@ -10393,10 +10150,10 @@ public final class CanalEntry { * *已废弃,请使用header里的executeTime* * */ - public boolean hasExecuteTime() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - + public boolean hasExecuteTime() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** * optional int64 executeTime = 1; * @@ -10404,46 +10161,13 @@ public final class CanalEntry { * *已废弃,请使用header里的executeTime* * */ - public long getExecuteTime() { - return executeTime_; - } - - public static final int TRANSACTIONID_FIELD_NUMBER = 2; - private java.lang.Object transactionId_; - - /** - * optional string transactionId = 2; - * - *
      -         * *已废弃,Begin里不提供事务id*
      -         * 
      - */ - public boolean hasTransactionId() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - - /** - * optional string transactionId = 2; - * - *
      -         * *已废弃,Begin里不提供事务id*
      -         * 
      - */ - public java.lang.String getTransactionId() { - java.lang.Object ref = transactionId_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - transactionId_ = s; + public long getExecuteTime() { + return executeTime_; } - return s; - } - } - + + public static final int TRANSACTIONID_FIELD_NUMBER = 2; + private java.lang.Object transactionId_; + /** * optional string transactionId = 2; * @@ -10451,46 +10175,74 @@ public final class CanalEntry { * *已废弃,Begin里不提供事务id* * */ - public com.google.protobuf.ByteString - getTransactionIdBytes() { - java.lang.Object ref = transactionId_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - transactionId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } + public boolean hasTransactionId() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } - public static final int PROPS_FIELD_NUMBER = 3; - private java.util.List props_; - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * optional string transactionId = 2; * *
      -         * *预留扩展*
      +         * *已废弃,Begin里不提供事务id*
                * 
      */ - public java.util.List getPropsList() { - return props_; - } - + public java.lang.String getTransactionId() { + java.lang.Object ref = transactionId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + transactionId_ = s; + } + return s; + } + } + /** + * optional string transactionId = 2; + * + *
      +         * *已废弃,Begin里不提供事务id*
      +         * 
      + */ + public com.google.protobuf.ByteString getTransactionIdBytes() { + java.lang.Object ref = transactionId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + transactionId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PROPS_FIELD_NUMBER = 3; + private java.util.List props_; + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +         * *预留扩展*
      +         * 
      + */ + public java.util.List getPropsList() { + return props_; + } + + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * *
                * *预留扩展*
                * 
      */ - public java.util.List - getPropsOrBuilderList() { - return props_; - } - + public java.util.List getPropsOrBuilderList() { + return props_; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -10498,10 +10250,10 @@ public final class CanalEntry { * *预留扩展* * */ - public int getPropsCount() { - return props_.size(); - } - + public int getPropsCount() { + return props_.size(); + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -10509,10 +10261,10 @@ public final class CanalEntry { * *预留扩展* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { - return props_.get(index); - } - + public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { + return props_.get(index); + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -10520,14 +10272,13 @@ public final class CanalEntry { * *预留扩展* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder( - int index) { - return props_.get(index); - } + public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index) { + return props_.get(index); + } + + public static final int THREADID_FIELD_NUMBER = 4; + private long threadId_; - public static final int THREADID_FIELD_NUMBER = 4; - private long threadId_; - /** * optional int64 threadId = 4; * @@ -10535,10 +10286,10 @@ public final class CanalEntry { * *执行的thread Id* * */ - public boolean hasThreadId() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - + public boolean hasThreadId() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** * optional int64 threadId = 4; * @@ -10546,145 +10297,153 @@ public final class CanalEntry { * *执行的thread Id* * */ - public long getThreadId() { - return threadId_; - } + public long getThreadId() { + return threadId_; + } - private void initFields() { - executeTime_ = 0L; - transactionId_ = ""; - props_ = java.util.Collections.emptyList(); - threadId_ = 0L; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; + private void initFields() { + executeTime_ = 0L; + transactionId_ = ""; + props_ = java.util.Collections.emptyList(); + threadId_ = 0L; + } - memoizedIsInitialized = 1; - return true; - } + private byte memoizedIsInitialized = -1; - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeInt64(1, executeTime_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeBytes(2, getTransactionIdBytes()); - } - for (int i = 0; i < props_.size(); i++) { - output.writeMessage(3, props_.get(i)); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeInt64(4, threadId_); - } - getUnknownFields().writeTo(output); - } + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; + memoizedIsInitialized = 1; + return true; + } - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(1, executeTime_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, getTransactionIdBytes()); - } - for (int i = 0; i < props_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, props_.get(i)); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(4, threadId_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeInt64(1, executeTime_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBytes(2, getTransactionIdBytes()); + } + for (int i = 0; i < props_.size(); i++) { + output.writeMessage(3, props_.get(i)); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeInt64(4, threadId_); + } + getUnknownFields().writeTo(output); + } - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } + private int memoizedSerializedSize = -1; - public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(1, executeTime_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(2, getTransactionIdBytes()); + } + for (int i = 0; i < props_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, props_.get(i)); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(4, threadId_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + + @java.lang.Override + protected java.lang.Object writeReplace() throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parseFrom(com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parseFrom(byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parseFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parseDelimitedFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parseFrom(com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parseFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { + return Builder.create(); + } + + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder(com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin prototype) { + return newBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return newBuilder(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** * Protobuf type * {@code com.alibaba.otter.canal.protocol.TransactionBegin} @@ -10693,186 +10452,182 @@ public final class CanalEntry { * *开始事务的一些信息* * */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements // @@protoc_insertion_point(builder_implements:com.alibaba.otter.canal.protocol.TransactionBegin) com.alibaba.otter.canal.protocol.CanalEntry.TransactionBeginOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_descriptor; - } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin.class, com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin.Builder.class); - } - - // Construct using com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getPropsFieldBuilder(); - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - executeTime_ = 0L; - bitField0_ = (bitField0_ & ~0x00000001); - transactionId_ = ""; - bitField0_ = (bitField0_ & ~0x00000002); - if (propsBuilder_ == null) { - props_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - } else { - propsBuilder_.clear(); - } - threadId_ = 0L; - bitField0_ = (bitField0_ & ~0x00000008); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_descriptor; - } - - public com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin getDefaultInstanceForType() { - return com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin.getDefaultInstance(); - } - - public com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin build() { - com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin buildPartial() { - com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin result = new com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.executeTime_ = executeTime_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.transactionId_ = transactionId_; - if (propsBuilder_ == null) { - if (((bitField0_ & 0x00000004) == 0x00000004)) { - props_ = java.util.Collections.unmodifiableList(props_); - bitField0_ = (bitField0_ & ~0x00000004); - } - result.props_ = props_; - } else { - result.props_ = propsBuilder_.build(); - } - if (((from_bitField0_ & 0x00000008) == 0x00000008)) { - to_bitField0_ |= 0x00000004; - } - result.threadId_ = threadId_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin) { - return mergeFrom((com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin other) { - if (other == com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin.getDefaultInstance()) return this; - if (other.hasExecuteTime()) { - setExecuteTime(other.getExecuteTime()); - } - if (other.hasTransactionId()) { - bitField0_ |= 0x00000002; - transactionId_ = other.transactionId_; - onChanged(); - } - if (propsBuilder_ == null) { - if (!other.props_.isEmpty()) { - if (props_.isEmpty()) { - props_ = other.props_; - bitField0_ = (bitField0_ & ~0x00000004); - } else { - ensurePropsIsMutable(); - props_.addAll(other.props_); + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_descriptor; } - onChanged(); - } - } else { - if (!other.props_.isEmpty()) { - if (propsBuilder_.isEmpty()) { - propsBuilder_.dispose(); - propsBuilder_ = null; - props_ = other.props_; - bitField0_ = (bitField0_ & ~0x00000004); - propsBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getPropsFieldBuilder() : null; - } else { - propsBuilder_.addAllMessages(other.props_); + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_fieldAccessorTable.ensureFieldAccessorsInitialized(com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin.class, + com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin.Builder.class); } - } - } - if (other.hasThreadId()) { - setThreadId(other.getThreadId()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - public final boolean isInitialized() { - return true; - } + // Construct using + // com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin.newBuilder() + private Builder(){ + maybeForceBuilderInitialization(); + } - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent){ + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getPropsFieldBuilder(); + } + } + + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + executeTime_ = 0L; + bitField0_ = (bitField0_ & ~0x00000001); + transactionId_ = ""; + bitField0_ = (bitField0_ & ~0x00000002); + if (propsBuilder_ == null) { + props_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + } else { + propsBuilder_.clear(); + } + threadId_ = 0L; + bitField0_ = (bitField0_ & ~0x00000008); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_descriptor; + } + + public com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin getDefaultInstanceForType() { + return com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin.getDefaultInstance(); + } + + public com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin build() { + com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin buildPartial() { + com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin result = new com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.executeTime_ = executeTime_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.transactionId_ = transactionId_; + if (propsBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004)) { + props_ = java.util.Collections.unmodifiableList(props_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.props_ = props_; + } else { + result.props_ = propsBuilder_.build(); + } + if (((from_bitField0_ & 0x00000008) == 0x00000008)) { + to_bitField0_ |= 0x00000004; + } + result.threadId_ = threadId_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin) { + return mergeFrom((com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin other) { + if (other == com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin.getDefaultInstance()) return this; + if (other.hasExecuteTime()) { + setExecuteTime(other.getExecuteTime()); + } + if (other.hasTransactionId()) { + bitField0_ |= 0x00000002; + transactionId_ = other.transactionId_; + onChanged(); + } + if (propsBuilder_ == null) { + if (!other.props_.isEmpty()) { + if (props_.isEmpty()) { + props_ = other.props_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensurePropsIsMutable(); + props_.addAll(other.props_); + } + onChanged(); + } + } else { + if (!other.props_.isEmpty()) { + if (propsBuilder_.isEmpty()) { + propsBuilder_.dispose(); + propsBuilder_ = null; + props_ = other.props_; + bitField0_ = (bitField0_ & ~0x00000004); + propsBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getPropsFieldBuilder() : null; + } else { + propsBuilder_.addAllMessages(other.props_); + } + } + } + if (other.hasThreadId()) { + setThreadId(other.getThreadId()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private long executeTime_; - private long executeTime_ ; - /** * optional int64 executeTime = 1; * @@ -10880,10 +10635,10 @@ public final class CanalEntry { * *已废弃,请使用header里的executeTime* * */ - public boolean hasExecuteTime() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - + public boolean hasExecuteTime() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** * optional int64 executeTime = 1; * @@ -10891,10 +10646,10 @@ public final class CanalEntry { * *已废弃,请使用header里的executeTime* * */ - public long getExecuteTime() { - return executeTime_; - } - + public long getExecuteTime() { + return executeTime_; + } + /** * optional int64 executeTime = 1; * @@ -10902,13 +10657,13 @@ public final class CanalEntry { * *已废弃,请使用header里的executeTime* * */ - public Builder setExecuteTime(long value) { - bitField0_ |= 0x00000001; - executeTime_ = value; - onChanged(); - return this; - } - + public Builder setExecuteTime(long value) { + bitField0_ |= 0x00000001; + executeTime_ = value; + onChanged(); + return this; + } + /** * optional int64 executeTime = 1; * @@ -10916,130 +10671,123 @@ public final class CanalEntry { * *已废弃,请使用header里的executeTime* * */ - public Builder clearExecuteTime() { - bitField0_ = (bitField0_ & ~0x00000001); - executeTime_ = 0L; - onChanged(); - return this; - } + public Builder clearExecuteTime() { + bitField0_ = (bitField0_ & ~0x00000001); + executeTime_ = 0L; + onChanged(); + return this; + } - private java.lang.Object transactionId_ = ""; - - /** - * optional string transactionId = 2; - * - *
      -             * *已废弃,Begin里不提供事务id*
      -             * 
      - */ - public boolean hasTransactionId() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - - /** - * optional string transactionId = 2; - * - *
      -             * *已废弃,Begin里不提供事务id*
      -             * 
      - */ - public java.lang.String getTransactionId() { - java.lang.Object ref = transactionId_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - transactionId_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * optional string transactionId = 2; - * - *
      -             * *已废弃,Begin里不提供事务id*
      -             * 
      - */ - public com.google.protobuf.ByteString - getTransactionIdBytes() { - java.lang.Object ref = transactionId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - transactionId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * optional string transactionId = 2; - * - *
      -             * *已废弃,Begin里不提供事务id*
      -             * 
      - */ - public Builder setTransactionId( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - transactionId_ = value; - onChanged(); - return this; - } - - /** - * optional string transactionId = 2; - * - *
      -             * *已废弃,Begin里不提供事务id*
      -             * 
      - */ - public Builder clearTransactionId() { - bitField0_ = (bitField0_ & ~0x00000002); - transactionId_ = getDefaultInstance().getTransactionId(); - onChanged(); - return this; - } - - /** - * optional string transactionId = 2; - * - *
      -             * *已废弃,Begin里不提供事务id*
      -             * 
      - */ - public Builder setTransactionIdBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - transactionId_ = value; - onChanged(); - return this; - } + private java.lang.Object transactionId_ = ""; - private java.util.List props_ = - java.util.Collections.emptyList(); - private void ensurePropsIsMutable() { - if (!((bitField0_ & 0x00000004) == 0x00000004)) { - props_ = new java.util.ArrayList(props_); - bitField0_ |= 0x00000004; - } - } + /** + * optional string transactionId = 2; + * + *
      +             * *已废弃,Begin里不提供事务id*
      +             * 
      + */ + public boolean hasTransactionId() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } - private com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Pair, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder, com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder> propsBuilder_; + /** + * optional string transactionId = 2; + * + *
      +             * *已废弃,Begin里不提供事务id*
      +             * 
      + */ + public java.lang.String getTransactionId() { + java.lang.Object ref = transactionId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + transactionId_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * optional string transactionId = 2; + * + *
      +             * *已废弃,Begin里不提供事务id*
      +             * 
      + */ + public com.google.protobuf.ByteString getTransactionIdBytes() { + java.lang.Object ref = transactionId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + transactionId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * optional string transactionId = 2; + * + *
      +             * *已废弃,Begin里不提供事务id*
      +             * 
      + */ + public Builder setTransactionId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + transactionId_ = value; + onChanged(); + return this; + } + + /** + * optional string transactionId = 2; + * + *
      +             * *已废弃,Begin里不提供事务id*
      +             * 
      + */ + public Builder clearTransactionId() { + bitField0_ = (bitField0_ & ~0x00000002); + transactionId_ = getDefaultInstance().getTransactionId(); + onChanged(); + return this; + } + + /** + * optional string transactionId = 2; + * + *
      +             * *已废弃,Begin里不提供事务id*
      +             * 
      + */ + public Builder setTransactionIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + transactionId_ = value; + onChanged(); + return this; + } + + private java.util.List props_ = java.util.Collections.emptyList(); + + private void ensurePropsIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + props_ = new java.util.ArrayList(props_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilder propsBuilder_; /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; @@ -11048,14 +10796,14 @@ public final class CanalEntry { * *预留扩展* * */ - public java.util.List getPropsList() { - if (propsBuilder_ == null) { - return java.util.Collections.unmodifiableList(props_); - } else { - return propsBuilder_.getMessageList(); - } - } - + public java.util.List getPropsList() { + if (propsBuilder_ == null) { + return java.util.Collections.unmodifiableList(props_); + } else { + return propsBuilder_.getMessageList(); + } + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11063,14 +10811,14 @@ public final class CanalEntry { * *预留扩展* * */ - public int getPropsCount() { - if (propsBuilder_ == null) { - return props_.size(); - } else { - return propsBuilder_.getCount(); - } - } - + public int getPropsCount() { + if (propsBuilder_ == null) { + return props_.size(); + } else { + return propsBuilder_.getCount(); + } + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11078,14 +10826,14 @@ public final class CanalEntry { * *预留扩展* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { - if (propsBuilder_ == null) { - return props_.get(index); - } else { - return propsBuilder_.getMessage(index); - } - } - + public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { + if (propsBuilder_ == null) { + return props_.get(index); + } else { + return propsBuilder_.getMessage(index); + } + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11093,21 +10841,20 @@ public final class CanalEntry { * *预留扩展* * */ - public Builder setProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { - if (propsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePropsIsMutable(); - props_.set(index, value); - onChanged(); - } else { - propsBuilder_.setMessage(index, value); - } - return this; - } - + public Builder setProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { + if (propsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropsIsMutable(); + props_.set(index, value); + onChanged(); + } else { + propsBuilder_.setMessage(index, value); + } + return this; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11115,18 +10862,17 @@ public final class CanalEntry { * *预留扩展* * */ - public Builder setProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.set(index, builderForValue.build()); - onChanged(); - } else { - propsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - + public Builder setProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.set(index, builderForValue.build()); + onChanged(); + } else { + propsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11134,20 +10880,20 @@ public final class CanalEntry { * *预留扩展* * */ - public Builder addProps(com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { - if (propsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePropsIsMutable(); - props_.add(value); - onChanged(); - } else { - propsBuilder_.addMessage(value); - } - return this; - } - + public Builder addProps(com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { + if (propsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropsIsMutable(); + props_.add(value); + onChanged(); + } else { + propsBuilder_.addMessage(value); + } + return this; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11155,21 +10901,20 @@ public final class CanalEntry { * *预留扩展* * */ - public Builder addProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { - if (propsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePropsIsMutable(); - props_.add(index, value); - onChanged(); - } else { - propsBuilder_.addMessage(index, value); - } - return this; - } - + public Builder addProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { + if (propsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropsIsMutable(); + props_.add(index, value); + onChanged(); + } else { + propsBuilder_.addMessage(index, value); + } + return this; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11177,18 +10922,17 @@ public final class CanalEntry { * *预留扩展* * */ - public Builder addProps( - com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.add(builderForValue.build()); - onChanged(); - } else { - propsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - + public Builder addProps(com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.add(builderForValue.build()); + onChanged(); + } else { + propsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11196,18 +10940,17 @@ public final class CanalEntry { * *预留扩展* * */ - public Builder addProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.add(index, builderForValue.build()); - onChanged(); - } else { - propsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - + public Builder addProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.add(index, builderForValue.build()); + onChanged(); + } else { + propsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11215,19 +10958,17 @@ public final class CanalEntry { * *预留扩展* * */ - public Builder addAllProps( - java.lang.Iterable values) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, props_); - onChanged(); - } else { - propsBuilder_.addAllMessages(values); - } - return this; - } - + public Builder addAllProps(java.lang.Iterable values) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, props_); + onChanged(); + } else { + propsBuilder_.addAllMessages(values); + } + return this; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11235,17 +10976,17 @@ public final class CanalEntry { * *预留扩展* * */ - public Builder clearProps() { - if (propsBuilder_ == null) { - props_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - onChanged(); - } else { - propsBuilder_.clear(); - } - return this; - } - + public Builder clearProps() { + if (propsBuilder_ == null) { + props_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + propsBuilder_.clear(); + } + return this; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11253,17 +10994,17 @@ public final class CanalEntry { * *预留扩展* * */ - public Builder removeProps(int index) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.remove(index); - onChanged(); - } else { - propsBuilder_.remove(index); - } - return this; - } - + public Builder removeProps(int index) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.remove(index); + onChanged(); + } else { + propsBuilder_.remove(index); + } + return this; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11271,11 +11012,10 @@ public final class CanalEntry { * *预留扩展* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder getPropsBuilder( - int index) { - return getPropsFieldBuilder().getBuilder(index); - } - + public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder getPropsBuilder(int index) { + return getPropsFieldBuilder().getBuilder(index); + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11283,14 +11023,14 @@ public final class CanalEntry { * *预留扩展* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder( - int index) { - if (propsBuilder_ == null) { - return props_.get(index); } else { - return propsBuilder_.getMessageOrBuilder(index); - } - } - + public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index) { + if (propsBuilder_ == null) { + return props_.get(index); + } else { + return propsBuilder_.getMessageOrBuilder(index); + } + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11298,15 +11038,14 @@ public final class CanalEntry { * *预留扩展* * */ - public java.util.List - getPropsOrBuilderList() { - if (propsBuilder_ != null) { - return propsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(props_); - } - } - + public java.util.List getPropsOrBuilderList() { + if (propsBuilder_ != null) { + return propsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(props_); + } + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11314,11 +11053,10 @@ public final class CanalEntry { * *预留扩展* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder() { - return getPropsFieldBuilder().addBuilder( - com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); - } - + public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder() { + return getPropsFieldBuilder().addBuilder(com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11326,12 +11064,11 @@ public final class CanalEntry { * *预留扩展* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder( - int index) { - return getPropsFieldBuilder().addBuilder( - index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); - } - + public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder(int index) { + return getPropsFieldBuilder().addBuilder(index, + com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11339,27 +11076,23 @@ public final class CanalEntry { * *预留扩展* * */ - public java.util.List - getPropsBuilderList() { - return getPropsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Pair, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder, com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder> - getPropsFieldBuilder() { - if (propsBuilder_ == null) { - propsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Pair, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder, com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder>( - props_, - ((bitField0_ & 0x00000004) == 0x00000004), - getParentForChildren(), - isClean()); - props_ = null; - } - return propsBuilder_; - } + public java.util.List getPropsBuilderList() { + return getPropsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder getPropsFieldBuilder() { + if (propsBuilder_ == null) { + propsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder(props_, + ((bitField0_ & 0x00000004) == 0x00000004), + getParentForChildren(), + isClean()); + props_ = null; + } + return propsBuilder_; + } + + private long threadId_; - private long threadId_ ; - /** * optional int64 threadId = 4; * @@ -11367,63 +11100,63 @@ public final class CanalEntry { * *执行的thread Id* * */ - public boolean hasThreadId() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - - /** - * optional int64 threadId = 4; - * - *
      -             * *执行的thread Id*
      -             * 
      - */ - public long getThreadId() { - return threadId_; - } - - /** - * optional int64 threadId = 4; - * - *
      -             * *执行的thread Id*
      -             * 
      - */ - public Builder setThreadId(long value) { - bitField0_ |= 0x00000008; - threadId_ = value; - onChanged(); - return this; - } - - /** - * optional int64 threadId = 4; - * - *
      -             * *执行的thread Id*
      -             * 
      - */ - public Builder clearThreadId() { - bitField0_ = (bitField0_ & ~0x00000008); - threadId_ = 0L; - onChanged(); - return this; - } + public boolean hasThreadId() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } - // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.TransactionBegin) + /** + * optional int64 threadId = 4; + * + *
      +             * *执行的thread Id*
      +             * 
      + */ + public long getThreadId() { + return threadId_; + } + + /** + * optional int64 threadId = 4; + * + *
      +             * *执行的thread Id*
      +             * 
      + */ + public Builder setThreadId(long value) { + bitField0_ |= 0x00000008; + threadId_ = value; + onChanged(); + return this; + } + + /** + * optional int64 threadId = 4; + * + *
      +             * *执行的thread Id*
      +             * 
      + */ + public Builder clearThreadId() { + bitField0_ = (bitField0_ & ~0x00000008); + threadId_ = 0L; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.TransactionBegin) + } + + static { + defaultInstance = new TransactionBegin(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.TransactionBegin) } - static { - defaultInstance = new TransactionBegin(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.TransactionBegin) - } - - public interface TransactionEndOrBuilder extends - // @@protoc_insertion_point(interface_extends:com.alibaba.otter.canal.protocol.TransactionEnd) - com.google.protobuf.MessageOrBuilder { + public interface TransactionEndOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.alibaba.otter.canal.protocol.TransactionEnd) + com.google.protobuf.MessageOrBuilder { /** * optional int64 executeTime = 1; @@ -11432,8 +11165,8 @@ public final class CanalEntry { * *已废弃,请使用header里的executeTime* * */ - boolean hasExecuteTime(); - + boolean hasExecuteTime(); + /** * optional int64 executeTime = 1; * @@ -11441,7 +11174,7 @@ public final class CanalEntry { * *已废弃,请使用header里的executeTime* * */ - long getExecuteTime(); + long getExecuteTime(); /** * optional string transactionId = 2; @@ -11450,8 +11183,8 @@ public final class CanalEntry { * *事务号* * */ - boolean hasTransactionId(); - + boolean hasTransactionId(); + /** * optional string transactionId = 2; * @@ -11459,8 +11192,8 @@ public final class CanalEntry { * *事务号* * */ - java.lang.String getTransactionId(); - + java.lang.String getTransactionId(); + /** * optional string transactionId = 2; * @@ -11468,8 +11201,7 @@ public final class CanalEntry { * *事务号* * */ - com.google.protobuf.ByteString - getTransactionIdBytes(); + com.google.protobuf.ByteString getTransactionIdBytes(); /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; @@ -11478,9 +11210,8 @@ public final class CanalEntry { * *预留扩展* * */ - java.util.List - getPropsList(); - + java.util.List getPropsList(); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11488,8 +11219,8 @@ public final class CanalEntry { * *预留扩展* * */ - com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index); - + com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11497,8 +11228,8 @@ public final class CanalEntry { * *预留扩展* * */ - int getPropsCount(); - + int getPropsCount(); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11506,9 +11237,8 @@ public final class CanalEntry { * *预留扩展* * */ - java.util.List - getPropsOrBuilderList(); - + java.util.List getPropsOrBuilderList(); + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11516,10 +11246,9 @@ public final class CanalEntry { * *预留扩展* * */ - com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder( - int index); - } - + com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index); + } + /** * Protobuf type {@code com.alibaba.otter.canal.protocol.TransactionEnd} * @@ -11527,120 +11256,120 @@ public final class CanalEntry { * *结束事务的一些信息* * */ - public static final class TransactionEnd extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:com.alibaba.otter.canal.protocol.TransactionEnd) - TransactionEndOrBuilder { - // Use TransactionEnd.newBuilder() to construct. - private TransactionEnd(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private TransactionEnd(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + public static final class TransactionEnd extends com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:com.alibaba.otter.canal.protocol.TransactionEnd) + TransactionEndOrBuilder { - private static final TransactionEnd defaultInstance; - public static TransactionEnd getDefaultInstance() { - return defaultInstance; - } - - public TransactionEnd getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private TransactionEnd( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - bitField0_ |= 0x00000001; - executeTime_ = input.readInt64(); - break; - } - case 18: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000002; - transactionId_ = bs; - break; - } - case 26: { - if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - props_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000004; - } - props_.add(input.readMessage(com.alibaba.otter.canal.protocol.CanalEntry.Pair.PARSER, extensionRegistry)); - break; - } - } + // Use TransactionEnd.newBuilder() to construct. + private TransactionEnd(com.google.protobuf.GeneratedMessage.Builder builder){ + super(builder); + this.unknownFields = builder.getUnknownFields(); } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - props_ = java.util.Collections.unmodifiableList(props_); + + private TransactionEnd(boolean noInit){ + this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_descriptor; - } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd.class, com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd.Builder.class); - } + private static final TransactionEnd defaultInstance; - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public TransactionEnd parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new TransactionEnd(input, extensionRegistry); - } - }; + public static TransactionEnd getDefaultInstance() { + return defaultInstance; + } - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } + public TransactionEnd getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private TransactionEnd(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException{ + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + bitField0_ |= 0x00000001; + executeTime_ = input.readInt64(); + break; + } + case 18: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000002; + transactionId_ = bs; + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + props_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + props_.add(input.readMessage(com.alibaba.otter.canal.protocol.CanalEntry.Pair.PARSER, + extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e.getMessage()).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + props_ = java.util.Collections.unmodifiableList(props_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_fieldAccessorTable.ensureFieldAccessorsInitialized(com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd.class, + com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + + public TransactionEnd parsePartialFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TransactionEnd(input, + extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + public static final int EXECUTETIME_FIELD_NUMBER = 1; + private long executeTime_; - private int bitField0_; - public static final int EXECUTETIME_FIELD_NUMBER = 1; - private long executeTime_; - /** * optional int64 executeTime = 1; * @@ -11648,10 +11377,10 @@ public final class CanalEntry { * *已废弃,请使用header里的executeTime* * */ - public boolean hasExecuteTime() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - + public boolean hasExecuteTime() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** * optional int64 executeTime = 1; * @@ -11659,46 +11388,13 @@ public final class CanalEntry { * *已废弃,请使用header里的executeTime* * */ - public long getExecuteTime() { - return executeTime_; - } - - public static final int TRANSACTIONID_FIELD_NUMBER = 2; - private java.lang.Object transactionId_; - - /** - * optional string transactionId = 2; - * - *
      -         * *事务号*
      -         * 
      - */ - public boolean hasTransactionId() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - - /** - * optional string transactionId = 2; - * - *
      -         * *事务号*
      -         * 
      - */ - public java.lang.String getTransactionId() { - java.lang.Object ref = transactionId_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - transactionId_ = s; + public long getExecuteTime() { + return executeTime_; } - return s; - } - } - + + public static final int TRANSACTIONID_FIELD_NUMBER = 2; + private java.lang.Object transactionId_; + /** * optional string transactionId = 2; * @@ -11706,23 +11402,52 @@ public final class CanalEntry { * *事务号* * */ - public com.google.protobuf.ByteString - getTransactionIdBytes() { - java.lang.Object ref = transactionId_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - transactionId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } + public boolean hasTransactionId() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + + /** + * optional string transactionId = 2; + * + *
      +         * *事务号*
      +         * 
      + */ + public java.lang.String getTransactionId() { + java.lang.Object ref = transactionId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + transactionId_ = s; + } + return s; + } + } + + /** + * optional string transactionId = 2; + * + *
      +         * *事务号*
      +         * 
      + */ + public com.google.protobuf.ByteString getTransactionIdBytes() { + java.lang.Object ref = transactionId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + transactionId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PROPS_FIELD_NUMBER = 3; + private java.util.List props_; - public static final int PROPS_FIELD_NUMBER = 3; - private java.util.List props_; - /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11730,10 +11455,10 @@ public final class CanalEntry { * *预留扩展* * */ - public java.util.List getPropsList() { - return props_; - } - + public java.util.List getPropsList() { + return props_; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11741,11 +11466,10 @@ public final class CanalEntry { * *预留扩展* * */ - public java.util.List - getPropsOrBuilderList() { - return props_; - } - + public java.util.List getPropsOrBuilderList() { + return props_; + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11753,10 +11477,10 @@ public final class CanalEntry { * *预留扩展* * */ - public int getPropsCount() { - return props_.size(); - } - + public int getPropsCount() { + return props_.size(); + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11764,10 +11488,10 @@ public final class CanalEntry { * *预留扩展* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { - return props_.get(index); - } - + public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { + return props_.get(index); + } + /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; * @@ -11775,138 +11499,146 @@ public final class CanalEntry { * *预留扩展* * */ - public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder( - int index) { - return props_.get(index); - } + public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index) { + return props_.get(index); + } - private void initFields() { - executeTime_ = 0L; - transactionId_ = ""; - props_ = java.util.Collections.emptyList(); - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; + private void initFields() { + executeTime_ = 0L; + transactionId_ = ""; + props_ = java.util.Collections.emptyList(); + } - memoizedIsInitialized = 1; - return true; - } + private byte memoizedIsInitialized = -1; - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeInt64(1, executeTime_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeBytes(2, getTransactionIdBytes()); - } - for (int i = 0; i < props_.size(); i++) { - output.writeMessage(3, props_.get(i)); - } - getUnknownFields().writeTo(output); - } + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; + memoizedIsInitialized = 1; + return true; + } - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(1, executeTime_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, getTransactionIdBytes()); - } - for (int i = 0; i < props_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, props_.get(i)); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeInt64(1, executeTime_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBytes(2, getTransactionIdBytes()); + } + for (int i = 0; i < props_.size(); i++) { + output.writeMessage(3, props_.get(i)); + } + getUnknownFields().writeTo(output); + } - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } + private int memoizedSerializedSize = -1; - public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(1, executeTime_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(2, getTransactionIdBytes()); + } + for (int i = 0; i < props_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, props_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + + @java.lang.Override + protected java.lang.Object writeReplace() throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parseFrom(com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parseFrom(byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parseFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parseDelimitedFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parseFrom(com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parseFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { + return Builder.create(); + } + + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder(com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd prototype) { + return newBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return newBuilder(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** * Protobuf type {@code com.alibaba.otter.canal.protocol.TransactionEnd} * @@ -11914,177 +11646,173 @@ public final class CanalEntry { * *结束事务的一些信息* * */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements // @@protoc_insertion_point(builder_implements:com.alibaba.otter.canal.protocol.TransactionEnd) com.alibaba.otter.canal.protocol.CanalEntry.TransactionEndOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_descriptor; - } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd.class, com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd.Builder.class); - } - - // Construct using com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getPropsFieldBuilder(); - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - executeTime_ = 0L; - bitField0_ = (bitField0_ & ~0x00000001); - transactionId_ = ""; - bitField0_ = (bitField0_ & ~0x00000002); - if (propsBuilder_ == null) { - props_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - } else { - propsBuilder_.clear(); - } - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_descriptor; - } - - public com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd getDefaultInstanceForType() { - return com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd.getDefaultInstance(); - } - - public com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd build() { - com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd buildPartial() { - com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd result = new com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.executeTime_ = executeTime_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.transactionId_ = transactionId_; - if (propsBuilder_ == null) { - if (((bitField0_ & 0x00000004) == 0x00000004)) { - props_ = java.util.Collections.unmodifiableList(props_); - bitField0_ = (bitField0_ & ~0x00000004); - } - result.props_ = props_; - } else { - result.props_ = propsBuilder_.build(); - } - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd) { - return mergeFrom((com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd other) { - if (other == com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd.getDefaultInstance()) return this; - if (other.hasExecuteTime()) { - setExecuteTime(other.getExecuteTime()); - } - if (other.hasTransactionId()) { - bitField0_ |= 0x00000002; - transactionId_ = other.transactionId_; - onChanged(); - } - if (propsBuilder_ == null) { - if (!other.props_.isEmpty()) { - if (props_.isEmpty()) { - props_ = other.props_; - bitField0_ = (bitField0_ & ~0x00000004); - } else { - ensurePropsIsMutable(); - props_.addAll(other.props_); + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_descriptor; } - onChanged(); - } - } else { - if (!other.props_.isEmpty()) { - if (propsBuilder_.isEmpty()) { - propsBuilder_.dispose(); - propsBuilder_ = null; - props_ = other.props_; - bitField0_ = (bitField0_ & ~0x00000004); - propsBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getPropsFieldBuilder() : null; - } else { - propsBuilder_.addAllMessages(other.props_); + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_fieldAccessorTable.ensureFieldAccessorsInitialized(com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd.class, + com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd.Builder.class); } - } - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - public final boolean isInitialized() { - return true; - } + // Construct using + // com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd.newBuilder() + private Builder(){ + maybeForceBuilderInitialization(); + } - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent){ + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getPropsFieldBuilder(); + } + } + + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + executeTime_ = 0L; + bitField0_ = (bitField0_ & ~0x00000001); + transactionId_ = ""; + bitField0_ = (bitField0_ & ~0x00000002); + if (propsBuilder_ == null) { + props_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + } else { + propsBuilder_.clear(); + } + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_descriptor; + } + + public com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd getDefaultInstanceForType() { + return com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd.getDefaultInstance(); + } + + public com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd build() { + com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd buildPartial() { + com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd result = new com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.executeTime_ = executeTime_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.transactionId_ = transactionId_; + if (propsBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004)) { + props_ = java.util.Collections.unmodifiableList(props_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.props_ = props_; + } else { + result.props_ = propsBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd) { + return mergeFrom((com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd other) { + if (other == com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd.getDefaultInstance()) return this; + if (other.hasExecuteTime()) { + setExecuteTime(other.getExecuteTime()); + } + if (other.hasTransactionId()) { + bitField0_ |= 0x00000002; + transactionId_ = other.transactionId_; + onChanged(); + } + if (propsBuilder_ == null) { + if (!other.props_.isEmpty()) { + if (props_.isEmpty()) { + props_ = other.props_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensurePropsIsMutable(); + props_.addAll(other.props_); + } + onChanged(); + } + } else { + if (!other.props_.isEmpty()) { + if (propsBuilder_.isEmpty()) { + propsBuilder_.dispose(); + propsBuilder_ = null; + props_ = other.props_; + bitField0_ = (bitField0_ & ~0x00000004); + propsBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getPropsFieldBuilder() : null; + } else { + propsBuilder_.addAllMessages(other.props_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private long executeTime_; - private long executeTime_ ; - /** * optional int64 executeTime = 1; * @@ -12092,10 +11820,10 @@ public final class CanalEntry { * *已废弃,请使用header里的executeTime* * */ - public boolean hasExecuteTime() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - + public boolean hasExecuteTime() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** * optional int64 executeTime = 1; * @@ -12103,10 +11831,10 @@ public final class CanalEntry { * *已废弃,请使用header里的executeTime* * */ - public long getExecuteTime() { - return executeTime_; - } - + public long getExecuteTime() { + return executeTime_; + } + /** * optional int64 executeTime = 1; * @@ -12114,13 +11842,13 @@ public final class CanalEntry { * *已废弃,请使用header里的executeTime* * */ - public Builder setExecuteTime(long value) { - bitField0_ |= 0x00000001; - executeTime_ = value; - onChanged(); - return this; - } - + public Builder setExecuteTime(long value) { + bitField0_ |= 0x00000001; + executeTime_ = value; + onChanged(); + return this; + } + /** * optional int64 executeTime = 1; * @@ -12128,130 +11856,123 @@ public final class CanalEntry { * *已废弃,请使用header里的executeTime* * */ - public Builder clearExecuteTime() { - bitField0_ = (bitField0_ & ~0x00000001); - executeTime_ = 0L; - onChanged(); - return this; - } + public Builder clearExecuteTime() { + bitField0_ = (bitField0_ & ~0x00000001); + executeTime_ = 0L; + onChanged(); + return this; + } - private java.lang.Object transactionId_ = ""; - - /** - * optional string transactionId = 2; - * - *
      -             * *事务号*
      -             * 
      - */ - public boolean hasTransactionId() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - - /** - * optional string transactionId = 2; - * - *
      -             * *事务号*
      -             * 
      - */ - public java.lang.String getTransactionId() { - java.lang.Object ref = transactionId_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - transactionId_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * optional string transactionId = 2; - * - *
      -             * *事务号*
      -             * 
      - */ - public com.google.protobuf.ByteString - getTransactionIdBytes() { - java.lang.Object ref = transactionId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - transactionId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * optional string transactionId = 2; - * - *
      -             * *事务号*
      -             * 
      - */ - public Builder setTransactionId( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - transactionId_ = value; - onChanged(); - return this; - } - - /** - * optional string transactionId = 2; - * - *
      -             * *事务号*
      -             * 
      - */ - public Builder clearTransactionId() { - bitField0_ = (bitField0_ & ~0x00000002); - transactionId_ = getDefaultInstance().getTransactionId(); - onChanged(); - return this; - } - - /** - * optional string transactionId = 2; - * - *
      -             * *事务号*
      -             * 
      - */ - public Builder setTransactionIdBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - transactionId_ = value; - onChanged(); - return this; - } + private java.lang.Object transactionId_ = ""; - private java.util.List props_ = - java.util.Collections.emptyList(); - private void ensurePropsIsMutable() { - if (!((bitField0_ & 0x00000004) == 0x00000004)) { - props_ = new java.util.ArrayList(props_); - bitField0_ |= 0x00000004; - } - } + /** + * optional string transactionId = 2; + * + *
      +             * *事务号*
      +             * 
      + */ + public boolean hasTransactionId() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } - private com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Pair, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder, com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder> propsBuilder_; + /** + * optional string transactionId = 2; + * + *
      +             * *事务号*
      +             * 
      + */ + public java.lang.String getTransactionId() { + java.lang.Object ref = transactionId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + transactionId_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * optional string transactionId = 2; + * + *
      +             * *事务号*
      +             * 
      + */ + public com.google.protobuf.ByteString getTransactionIdBytes() { + java.lang.Object ref = transactionId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + transactionId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * optional string transactionId = 2; + * + *
      +             * *事务号*
      +             * 
      + */ + public Builder setTransactionId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + transactionId_ = value; + onChanged(); + return this; + } + + /** + * optional string transactionId = 2; + * + *
      +             * *事务号*
      +             * 
      + */ + public Builder clearTransactionId() { + bitField0_ = (bitField0_ & ~0x00000002); + transactionId_ = getDefaultInstance().getTransactionId(); + onChanged(); + return this; + } + + /** + * optional string transactionId = 2; + * + *
      +             * *事务号*
      +             * 
      + */ + public Builder setTransactionIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + transactionId_ = value; + onChanged(); + return this; + } + + private java.util.List props_ = java.util.Collections.emptyList(); + + private void ensurePropsIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + props_ = new java.util.ArrayList(props_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilder propsBuilder_; /** * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; @@ -12260,360 +11981,347 @@ public final class CanalEntry { * *预留扩展* * */ - public java.util.List getPropsList() { - if (propsBuilder_ == null) { - return java.util.Collections.unmodifiableList(props_); - } else { - return propsBuilder_.getMessageList(); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public int getPropsCount() { - if (propsBuilder_ == null) { - return props_.size(); - } else { - return propsBuilder_.getCount(); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { - if (propsBuilder_ == null) { - return props_.get(index); - } else { - return propsBuilder_.getMessage(index); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder setProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { - if (propsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePropsIsMutable(); - props_.set(index, value); - onChanged(); - } else { - propsBuilder_.setMessage(index, value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder setProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.set(index, builderForValue.build()); - onChanged(); - } else { - propsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder addProps(com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { - if (propsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePropsIsMutable(); - props_.add(value); - onChanged(); - } else { - propsBuilder_.addMessage(value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder addProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { - if (propsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePropsIsMutable(); - props_.add(index, value); - onChanged(); - } else { - propsBuilder_.addMessage(index, value); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder addProps( - com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.add(builderForValue.build()); - onChanged(); - } else { - propsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder addProps( - int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.add(index, builderForValue.build()); - onChanged(); - } else { - propsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder addAllProps( - java.lang.Iterable values) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, props_); - onChanged(); - } else { - propsBuilder_.addAllMessages(values); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder clearProps() { - if (propsBuilder_ == null) { - props_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - onChanged(); - } else { - propsBuilder_.clear(); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public Builder removeProps(int index) { - if (propsBuilder_ == null) { - ensurePropsIsMutable(); - props_.remove(index); - onChanged(); - } else { - propsBuilder_.remove(index); - } - return this; - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder getPropsBuilder( - int index) { - return getPropsFieldBuilder().getBuilder(index); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder( - int index) { - if (propsBuilder_ == null) { - return props_.get(index); } else { - return propsBuilder_.getMessageOrBuilder(index); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public java.util.List - getPropsOrBuilderList() { - if (propsBuilder_ != null) { - return propsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(props_); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder() { - return getPropsFieldBuilder().addBuilder( - com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder( - int index) { - return getPropsFieldBuilder().addBuilder( - index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; - * - *
      -             * *预留扩展*
      -             * 
      - */ - public java.util.List - getPropsBuilderList() { - return getPropsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Pair, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder, com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder> - getPropsFieldBuilder() { - if (propsBuilder_ == null) { - propsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.alibaba.otter.canal.protocol.CanalEntry.Pair, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder, com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder>( - props_, - ((bitField0_ & 0x00000004) == 0x00000004), - getParentForChildren(), - isClean()); - props_ = null; - } - return propsBuilder_; - } + public java.util.List getPropsList() { + if (propsBuilder_ == null) { + return java.util.Collections.unmodifiableList(props_); + } else { + return propsBuilder_.getMessageList(); + } + } - // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.TransactionEnd) + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public int getPropsCount() { + if (propsBuilder_ == null) { + return props_.size(); + } else { + return propsBuilder_.getCount(); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index) { + if (propsBuilder_ == null) { + return props_.get(index); + } else { + return propsBuilder_.getMessage(index); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder setProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { + if (propsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropsIsMutable(); + props_.set(index, value); + onChanged(); + } else { + propsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder setProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.set(index, builderForValue.build()); + onChanged(); + } else { + propsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder addProps(com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { + if (propsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropsIsMutable(); + props_.add(value); + onChanged(); + } else { + propsBuilder_.addMessage(value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder addProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair value) { + if (propsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropsIsMutable(); + props_.add(index, value); + onChanged(); + } else { + propsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder addProps(com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.add(builderForValue.build()); + onChanged(); + } else { + propsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder addProps(int index, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder builderForValue) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.add(index, builderForValue.build()); + onChanged(); + } else { + propsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder addAllProps(java.lang.Iterable values) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, props_); + onChanged(); + } else { + propsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder clearProps() { + if (propsBuilder_ == null) { + props_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + propsBuilder_.clear(); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public Builder removeProps(int index) { + if (propsBuilder_ == null) { + ensurePropsIsMutable(); + props_.remove(index); + onChanged(); + } else { + propsBuilder_.remove(index); + } + return this; + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder getPropsBuilder(int index) { + return getPropsFieldBuilder().getBuilder(index); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index) { + if (propsBuilder_ == null) { + return props_.get(index); + } else { + return propsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public java.util.List getPropsOrBuilderList() { + if (propsBuilder_ != null) { + return propsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(props_); + } + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder() { + return getPropsFieldBuilder().addBuilder(com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder addPropsBuilder(int index) { + return getPropsFieldBuilder().addBuilder(index, + com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()); + } + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
      +             * *预留扩展*
      +             * 
      + */ + public java.util.List getPropsBuilderList() { + return getPropsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder getPropsFieldBuilder() { + if (propsBuilder_ == null) { + propsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder(props_, + ((bitField0_ & 0x00000004) == 0x00000004), + getParentForChildren(), + isClean()); + props_ = null; + } + return propsBuilder_; + } + + // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.TransactionEnd) + } + + static { + defaultInstance = new TransactionEnd(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.TransactionEnd) } - static { - defaultInstance = new TransactionEnd(true); - defaultInstance.initFields(); + public interface PairOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.alibaba.otter.canal.protocol.Pair) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string key = 1; + */ + boolean hasKey(); + + /** + * optional string key = 1; + */ + java.lang.String getKey(); + + /** + * optional string key = 1; + */ + com.google.protobuf.ByteString getKeyBytes(); + + /** + * optional string value = 2; + */ + boolean hasValue(); + + /** + * optional string value = 2; + */ + java.lang.String getValue(); + + /** + * optional string value = 2; + */ + com.google.protobuf.ByteString getValueBytes(); } - // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.TransactionEnd) - } - - public interface PairOrBuilder extends - // @@protoc_insertion_point(interface_extends:com.alibaba.otter.canal.protocol.Pair) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string key = 1; - */ - boolean hasKey(); - /** - * optional string key = 1; - */ - java.lang.String getKey(); - /** - * optional string key = 1; - */ - com.google.protobuf.ByteString - getKeyBytes(); - - /** - * optional string value = 2; - */ - boolean hasValue(); - /** - * optional string value = 2; - */ - java.lang.String getValue(); - /** - * optional string value = 2; - */ - com.google.protobuf.ByteString - getValueBytes(); - } - /** * Protobuf type {@code com.alibaba.otter.canal.protocol.Pair} * @@ -12621,310 +12329,316 @@ public final class CanalEntry { * *预留扩展* * */ - public static final class Pair extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:com.alibaba.otter.canal.protocol.Pair) - PairOrBuilder { - // Use Pair.newBuilder() to construct. - private Pair(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private Pair(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + public static final class Pair extends com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:com.alibaba.otter.canal.protocol.Pair) + PairOrBuilder { - private static final Pair defaultInstance; - public static Pair getDefaultInstance() { - return defaultInstance; - } - - public Pair getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private Pair( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000001; - key_ = bs; - break; - } - case 18: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000002; - value_ = bs; - break; - } - } + // Use Pair.newBuilder() to construct. + private Pair(com.google.protobuf.GeneratedMessage.Builder builder){ + super(builder); + this.unknownFields = builder.getUnknownFields(); } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Pair_descriptor; - } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Pair_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.alibaba.otter.canal.protocol.CanalEntry.Pair.class, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public Pair parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Pair(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - private int bitField0_; - public static final int KEY_FIELD_NUMBER = 1; - private java.lang.Object key_; - /** - * optional string key = 1; - */ - public boolean hasKey() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional string key = 1; - */ - public java.lang.String getKey() { - java.lang.Object ref = key_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - key_ = s; + private Pair(boolean noInit){ + this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - return s; - } - } - /** - * optional string key = 1; - */ - public com.google.protobuf.ByteString - getKeyBytes() { - java.lang.Object ref = key_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - key_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - public static final int VALUE_FIELD_NUMBER = 2; - private java.lang.Object value_; - /** - * optional string value = 2; - */ - public boolean hasValue() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional string value = 2; - */ - public java.lang.String getValue() { - java.lang.Object ref = value_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - value_ = s; + private static final Pair defaultInstance; + + public static Pair getDefaultInstance() { + return defaultInstance; } - return s; - } - } - /** - * optional string value = 2; - */ - public com.google.protobuf.ByteString - getValueBytes() { - java.lang.Object ref = value_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - value_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - private void initFields() { - key_ = ""; - value_ = ""; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; + public Pair getDefaultInstanceForType() { + return defaultInstance; + } - memoizedIsInitialized = 1; - return true; - } + private final com.google.protobuf.UnknownFieldSet unknownFields; - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeBytes(1, getKeyBytes()); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeBytes(2, getValueBytes()); - } - getUnknownFields().writeTo(output); - } + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; + private Pair(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException{ + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000001; + key_ = bs; + break; + } + case 18: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000002; + value_ = bs; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(1, getKeyBytes()); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, getValueBytes()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Pair_descriptor; + } - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Pair_fieldAccessorTable.ensureFieldAccessorsInitialized(com.alibaba.otter.canal.protocol.CanalEntry.Pair.class, + com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder.class); + } - public static com.alibaba.otter.canal.protocol.CanalEntry.Pair parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Pair parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Pair parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Pair parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Pair parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Pair parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Pair parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Pair parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Pair parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.alibaba.otter.canal.protocol.CanalEntry.Pair parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } + public static com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(com.alibaba.otter.canal.protocol.CanalEntry.Pair prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } + public Pair parsePartialFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Pair(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + public static final int KEY_FIELD_NUMBER = 1; + private java.lang.Object key_; + + /** + * optional string key = 1; + */ + public boolean hasKey() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + + /** + * optional string key = 1; + */ + public java.lang.String getKey() { + java.lang.Object ref = key_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + key_ = s; + } + return s; + } + } + + /** + * optional string key = 1; + */ + public com.google.protobuf.ByteString getKeyBytes() { + java.lang.Object ref = key_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + key_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int VALUE_FIELD_NUMBER = 2; + private java.lang.Object value_; + + /** + * optional string value = 2; + */ + public boolean hasValue() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + + /** + * optional string value = 2; + */ + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + value_ = s; + } + return s; + } + } + + /** + * optional string value = 2; + */ + public com.google.protobuf.ByteString getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private void initFields() { + key_ = ""; + value_ = ""; + } + + private byte memoizedIsInitialized = -1; + + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getKeyBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBytes(2, getValueBytes()); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(1, getKeyBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(2, getValueBytes()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + + @java.lang.Override + protected java.lang.Object writeReplace() throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Pair parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Pair parseFrom(com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Pair parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Pair parseFrom(byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Pair parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Pair parseFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Pair parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Pair parseDelimitedFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Pair parseFrom(com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + + public static com.alibaba.otter.canal.protocol.CanalEntry.Pair parseFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { + return Builder.create(); + } + + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder(com.alibaba.otter.canal.protocol.CanalEntry.Pair prototype) { + return newBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return newBuilder(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** * Protobuf type {@code com.alibaba.otter.canal.protocol.Pair} * @@ -12932,459 +12646,409 @@ public final class CanalEntry { * *预留扩展* * */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements // @@protoc_insertion_point(builder_implements:com.alibaba.otter.canal.protocol.Pair) com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Pair_descriptor; - } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Pair_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.alibaba.otter.canal.protocol.CanalEntry.Pair.class, com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder.class); - } + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Pair_descriptor; + } - // Construct using com.alibaba.otter.canal.protocol.CanalEntry.Pair.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Pair_fieldAccessorTable.ensureFieldAccessorsInitialized(com.alibaba.otter.canal.protocol.CanalEntry.Pair.class, + com.alibaba.otter.canal.protocol.CanalEntry.Pair.Builder.class); + } - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + // Construct using + // com.alibaba.otter.canal.protocol.CanalEntry.Pair.newBuilder() + private Builder(){ + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent){ + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + key_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + value_ = ""; + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Pair_descriptor; + } + + public com.alibaba.otter.canal.protocol.CanalEntry.Pair getDefaultInstanceForType() { + return com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance(); + } + + public com.alibaba.otter.canal.protocol.CanalEntry.Pair build() { + com.alibaba.otter.canal.protocol.CanalEntry.Pair result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.alibaba.otter.canal.protocol.CanalEntry.Pair buildPartial() { + com.alibaba.otter.canal.protocol.CanalEntry.Pair result = new com.alibaba.otter.canal.protocol.CanalEntry.Pair(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.key_ = key_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.value_ = value_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.alibaba.otter.canal.protocol.CanalEntry.Pair) { + return mergeFrom((com.alibaba.otter.canal.protocol.CanalEntry.Pair) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.alibaba.otter.canal.protocol.CanalEntry.Pair other) { + if (other == com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()) return this; + if (other.hasKey()) { + bitField0_ |= 0x00000001; + key_ = other.key_; + onChanged(); + } + if (other.hasValue()) { + bitField0_ |= 0x00000002; + value_ = other.value_; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.alibaba.otter.canal.protocol.CanalEntry.Pair parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.alibaba.otter.canal.protocol.CanalEntry.Pair) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private java.lang.Object key_ = ""; + + /** + * optional string key = 1; + */ + public boolean hasKey() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + + /** + * optional string key = 1; + */ + public java.lang.String getKey() { + java.lang.Object ref = key_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + key_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * optional string key = 1; + */ + public com.google.protobuf.ByteString getKeyBytes() { + java.lang.Object ref = key_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + key_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * optional string key = 1; + */ + public Builder setKey(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + key_ = value; + onChanged(); + return this; + } + + /** + * optional string key = 1; + */ + public Builder clearKey() { + bitField0_ = (bitField0_ & ~0x00000001); + key_ = getDefaultInstance().getKey(); + onChanged(); + return this; + } + + /** + * optional string key = 1; + */ + public Builder setKeyBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + key_ = value; + onChanged(); + return this; + } + + private java.lang.Object value_ = ""; + + /** + * optional string value = 2; + */ + public boolean hasValue() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + + /** + * optional string value = 2; + */ + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + value_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * optional string value = 2; + */ + public com.google.protobuf.ByteString getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * optional string value = 2; + */ + public Builder setValue(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + value_ = value; + onChanged(); + return this; + } + + /** + * optional string value = 2; + */ + public Builder clearValue() { + bitField0_ = (bitField0_ & ~0x00000002); + value_ = getDefaultInstance().getValue(); + onChanged(); + return this; + } + + /** + * optional string value = 2; + */ + public Builder setValueBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + value_ = value; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.Pair) } - } - private static Builder create() { - return new Builder(); - } - public Builder clear() { - super.clear(); - key_ = ""; - bitField0_ = (bitField0_ & ~0x00000001); - value_ = ""; - bitField0_ = (bitField0_ & ~0x00000002); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.alibaba.otter.canal.protocol.CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Pair_descriptor; - } - - public com.alibaba.otter.canal.protocol.CanalEntry.Pair getDefaultInstanceForType() { - return com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance(); - } - - public com.alibaba.otter.canal.protocol.CanalEntry.Pair build() { - com.alibaba.otter.canal.protocol.CanalEntry.Pair result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); + static { + defaultInstance = new Pair(true); + defaultInstance.initFields(); } - return result; - } - public com.alibaba.otter.canal.protocol.CanalEntry.Pair buildPartial() { - com.alibaba.otter.canal.protocol.CanalEntry.Pair result = new com.alibaba.otter.canal.protocol.CanalEntry.Pair(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.key_ = key_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.value_ = value_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.alibaba.otter.canal.protocol.CanalEntry.Pair) { - return mergeFrom((com.alibaba.otter.canal.protocol.CanalEntry.Pair)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.alibaba.otter.canal.protocol.CanalEntry.Pair other) { - if (other == com.alibaba.otter.canal.protocol.CanalEntry.Pair.getDefaultInstance()) return this; - if (other.hasKey()) { - bitField0_ |= 0x00000001; - key_ = other.key_; - onChanged(); - } - if (other.hasValue()) { - bitField0_ |= 0x00000002; - value_ = other.value_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.alibaba.otter.canal.protocol.CanalEntry.Pair parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.alibaba.otter.canal.protocol.CanalEntry.Pair) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.lang.Object key_ = ""; - /** - * optional string key = 1; - */ - public boolean hasKey() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional string key = 1; - */ - public java.lang.String getKey() { - java.lang.Object ref = key_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - key_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string key = 1; - */ - public com.google.protobuf.ByteString - getKeyBytes() { - java.lang.Object ref = key_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - key_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string key = 1; - */ - public Builder setKey( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - key_ = value; - onChanged(); - return this; - } - /** - * optional string key = 1; - */ - public Builder clearKey() { - bitField0_ = (bitField0_ & ~0x00000001); - key_ = getDefaultInstance().getKey(); - onChanged(); - return this; - } - /** - * optional string key = 1; - */ - public Builder setKeyBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - key_ = value; - onChanged(); - return this; - } - - private java.lang.Object value_ = ""; - /** - * optional string value = 2; - */ - public boolean hasValue() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional string value = 2; - */ - public java.lang.String getValue() { - java.lang.Object ref = value_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - value_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string value = 2; - */ - public com.google.protobuf.ByteString - getValueBytes() { - java.lang.Object ref = value_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - value_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string value = 2; - */ - public Builder setValue( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - value_ = value; - onChanged(); - return this; - } - /** - * optional string value = 2; - */ - public Builder clearValue() { - bitField0_ = (bitField0_ & ~0x00000002); - value_ = getDefaultInstance().getValue(); - onChanged(); - return this; - } - /** - * optional string value = 2; - */ - public Builder setValueBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - value_ = value; - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.Pair) + // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.Pair) } + private static final com.google.protobuf.Descriptors.Descriptor internal_static_com_alibaba_otter_canal_protocol_Entry_descriptor; + private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_com_alibaba_otter_canal_protocol_Entry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor internal_static_com_alibaba_otter_canal_protocol_Header_descriptor; + private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_com_alibaba_otter_canal_protocol_Header_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor internal_static_com_alibaba_otter_canal_protocol_Column_descriptor; + private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_com_alibaba_otter_canal_protocol_Column_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor internal_static_com_alibaba_otter_canal_protocol_RowData_descriptor; + private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_com_alibaba_otter_canal_protocol_RowData_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor internal_static_com_alibaba_otter_canal_protocol_RowChange_descriptor; + private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_com_alibaba_otter_canal_protocol_RowChange_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_descriptor; + private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_descriptor; + private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor internal_static_com_alibaba_otter_canal_protocol_Pair_descriptor; + private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_com_alibaba_otter_canal_protocol_Pair_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; static { - defaultInstance = new Pair(true); - defaultInstance.initFields(); + java.lang.String[] descriptorData = { + "\n\023EntryProtocol.proto\022 com.alibaba.otter" + + ".canal.protocol\"\236\001\n\005Entry\0228\n\006header\030\001 \001(" + + "\0132(.com.alibaba.otter.canal.protocol.Hea" + + "der\022G\n\tentryType\030\002 \001(\0162+.com.alibaba.ott" + + "er.canal.protocol.EntryType:\007ROWDATA\022\022\n\n" + + "storeValue\030\003 \001(\014\"\221\003\n\006Header\022\022\n\007version\030\001" + + " \001(\005:\0011\022\023\n\013logfileName\030\002 \001(\t\022\025\n\rlogfileO" + + "ffset\030\003 \001(\003\022\020\n\010serverId\030\004 \001(\003\022\024\n\014servere" + + "nCode\030\005 \001(\t\022\023\n\013executeTime\030\006 \001(\003\022A\n\nsour" + + "ceType\030\007 \001(\0162&.com.alibaba.otter.canal.p", + "rotocol.Type:\005MYSQL\022\022\n\nschemaName\030\010 \001(\t\022" + + "\021\n\ttableName\030\t \001(\t\022\023\n\013eventLength\030\n \001(\003\022" + + "F\n\teventType\030\013 \001(\0162+.com.alibaba.otter.c" + + "anal.protocol.EventType:\006UPDATE\0225\n\005props" + + "\030\014 \003(\0132&.com.alibaba.otter.canal.protoco" + + "l.Pair\022\014\n\004gtid\030\r \001(\t\"\326\001\n\006Column\022\r\n\005index" + + "\030\001 \001(\005\022\017\n\007sqlType\030\002 \001(\005\022\014\n\004name\030\003 \001(\t\022\r\n" + + "\005isKey\030\004 \001(\010\022\017\n\007updated\030\005 \001(\010\022\025\n\006isNull\030" + + "\006 \001(\010:\005false\0225\n\005props\030\007 \003(\0132&.com.alibab" + + "a.otter.canal.protocol.Pair\022\r\n\005value\030\010 \001", + "(\t\022\016\n\006length\030\t \001(\005\022\021\n\tmysqlType\030\n \001(\t\"\301\001" + + "\n\007RowData\022?\n\rbeforeColumns\030\001 \003(\0132(.com.a" + + "libaba.otter.canal.protocol.Column\022>\n\014af" + + "terColumns\030\002 \003(\0132(.com.alibaba.otter.can" + + "al.protocol.Column\0225\n\005props\030\003 \003(\0132&.com." + + "alibaba.otter.canal.protocol.Pair\"\222\002\n\tRo" + + "wChange\022\017\n\007tableId\030\001 \001(\003\022F\n\teventType\030\002 " + + "\001(\0162+.com.alibaba.otter.canal.protocol.E" + + "ventType:\006UPDATE\022\024\n\005isDdl\030\n \001(\010:\005false\022\013" + + "\n\003sql\030\013 \001(\t\022;\n\010rowDatas\030\014 \003(\0132).com.alib", + "aba.otter.canal.protocol.RowData\0225\n\005prop" + "s\030\r \003(\0132&.com.alibaba.otter.canal.protoc" + + "ol.Pair\022\025\n\rddlSchemaName\030\016 \001(\t\"\207\001\n\020Trans" + + "actionBegin\022\023\n\013executeTime\030\001 \001(\003\022\025\n\rtran" + + "sactionId\030\002 \001(\t\0225\n\005props\030\003 \003(\0132&.com.ali" + + "baba.otter.canal.protocol.Pair\022\020\n\010thread" + + "Id\030\004 \001(\003\"s\n\016TransactionEnd\022\023\n\013executeTim" + + "e\030\001 \001(\003\022\025\n\rtransactionId\030\002 \001(\t\0225\n\005props\030" + + "\003 \003(\0132&.com.alibaba.otter.canal.protocol" + + ".Pair\"\"\n\004Pair\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(", + "\t*^\n\tEntryType\022\024\n\020TRANSACTIONBEGIN\020\001\022\013\n\007" + + "ROWDATA\020\002\022\022\n\016TRANSACTIONEND\020\003\022\r\n\tHEARTBE" + + "AT\020\004\022\013\n\007GTIDLOG\020\005*\316\001\n\tEventType\022\n\n\006INSER" + + "T\020\001\022\n\n\006UPDATE\020\002\022\n\n\006DELETE\020\003\022\n\n\006CREATE\020\004\022" + + "\t\n\005ALTER\020\005\022\t\n\005ERASE\020\006\022\t\n\005QUERY\020\007\022\014\n\010TRUN" + + "CATE\020\010\022\n\n\006RENAME\020\t\022\n\n\006CINDEX\020\n\022\n\n\006DINDEX" + + "\020\013\022\010\n\004GTID\020\014\022\013\n\007XASTART\020\r\022\t\n\005XAEND\020\016\022\014\n\010" + + "XACOMMIT\020\017\022\016\n\nXAROLLBACK\020\020*(\n\004Type\022\n\n\006OR" + + "ACLE\020\001\022\t\n\005MYSQL\020\002\022\t\n\005PGSQL\020\003B0\n com.alib" + + "aba.otter.canal.protocolB\nCanalEntryH\001" }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + + public com.google.protobuf.ExtensionRegistry assignDescriptors(com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] {}, + assigner); + internal_static_com_alibaba_otter_canal_protocol_Entry_descriptor = getDescriptor().getMessageTypes().get(0); + internal_static_com_alibaba_otter_canal_protocol_Entry_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable(internal_static_com_alibaba_otter_canal_protocol_Entry_descriptor, + new java.lang.String[] { "Header", "EntryType", "StoreValue", }); + internal_static_com_alibaba_otter_canal_protocol_Header_descriptor = getDescriptor().getMessageTypes().get(1); + internal_static_com_alibaba_otter_canal_protocol_Header_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable(internal_static_com_alibaba_otter_canal_protocol_Header_descriptor, + new java.lang.String[] { "Version", "LogfileName", "LogfileOffset", "ServerId", "ServerenCode", + "ExecuteTime", "SourceType", "SchemaName", "TableName", "EventLength", "EventType", "Props", "Gtid", }); + internal_static_com_alibaba_otter_canal_protocol_Column_descriptor = getDescriptor().getMessageTypes().get(2); + internal_static_com_alibaba_otter_canal_protocol_Column_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable(internal_static_com_alibaba_otter_canal_protocol_Column_descriptor, + new java.lang.String[] { "Index", "SqlType", "Name", "IsKey", "Updated", "IsNull", "Props", "Value", + "Length", "MysqlType", }); + internal_static_com_alibaba_otter_canal_protocol_RowData_descriptor = getDescriptor().getMessageTypes().get(3); + internal_static_com_alibaba_otter_canal_protocol_RowData_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable(internal_static_com_alibaba_otter_canal_protocol_RowData_descriptor, + new java.lang.String[] { "BeforeColumns", "AfterColumns", "Props", }); + internal_static_com_alibaba_otter_canal_protocol_RowChange_descriptor = getDescriptor().getMessageTypes() + .get(4); + internal_static_com_alibaba_otter_canal_protocol_RowChange_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable(internal_static_com_alibaba_otter_canal_protocol_RowChange_descriptor, + new java.lang.String[] { "TableId", "EventType", "IsDdl", "Sql", "RowDatas", "Props", "DdlSchemaName", }); + internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_descriptor = getDescriptor().getMessageTypes() + .get(5); + internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable(internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_descriptor, + new java.lang.String[] { "ExecuteTime", "TransactionId", "Props", "ThreadId", }); + internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_descriptor = getDescriptor().getMessageTypes() + .get(6); + internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable(internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_descriptor, + new java.lang.String[] { "ExecuteTime", "TransactionId", "Props", }); + internal_static_com_alibaba_otter_canal_protocol_Pair_descriptor = getDescriptor().getMessageTypes().get(7); + internal_static_com_alibaba_otter_canal_protocol_Pair_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable(internal_static_com_alibaba_otter_canal_protocol_Pair_descriptor, + new java.lang.String[] { "Key", "Value", }); } - // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.Pair) - } - - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_alibaba_otter_canal_protocol_Entry_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_com_alibaba_otter_canal_protocol_Entry_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_alibaba_otter_canal_protocol_Header_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_com_alibaba_otter_canal_protocol_Header_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_alibaba_otter_canal_protocol_Column_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_com_alibaba_otter_canal_protocol_Column_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_alibaba_otter_canal_protocol_RowData_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_com_alibaba_otter_canal_protocol_RowData_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_alibaba_otter_canal_protocol_RowChange_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_com_alibaba_otter_canal_protocol_RowChange_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_alibaba_otter_canal_protocol_Pair_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_com_alibaba_otter_canal_protocol_Pair_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\023EntryProtocol.proto\022 com.alibaba.otter" + - ".canal.protocol\"\236\001\n\005Entry\0228\n\006header\030\001 \001(" + - "\0132(.com.alibaba.otter.canal.protocol.Hea" + - "der\022G\n\tentryType\030\002 \001(\0162+.com.alibaba.ott" + - "er.canal.protocol.EntryType:\007ROWDATA\022\022\n\n" + - "storeValue\030\003 \001(\014\"\221\003\n\006Header\022\022\n\007version\030\001" + - " \001(\005:\0011\022\023\n\013logfileName\030\002 \001(\t\022\025\n\rlogfileO" + - "ffset\030\003 \001(\003\022\020\n\010serverId\030\004 \001(\003\022\024\n\014servere" + - "nCode\030\005 \001(\t\022\023\n\013executeTime\030\006 \001(\003\022A\n\nsour" + - "ceType\030\007 \001(\0162&.com.alibaba.otter.canal.p", - "rotocol.Type:\005MYSQL\022\022\n\nschemaName\030\010 \001(\t\022" + - "\021\n\ttableName\030\t \001(\t\022\023\n\013eventLength\030\n \001(\003\022" + - "F\n\teventType\030\013 \001(\0162+.com.alibaba.otter.c" + - "anal.protocol.EventType:\006UPDATE\0225\n\005props" + - "\030\014 \003(\0132&.com.alibaba.otter.canal.protoco" + - "l.Pair\022\014\n\004gtid\030\r \001(\t\"\326\001\n\006Column\022\r\n\005index" + - "\030\001 \001(\005\022\017\n\007sqlType\030\002 \001(\005\022\014\n\004name\030\003 \001(\t\022\r\n" + - "\005isKey\030\004 \001(\010\022\017\n\007updated\030\005 \001(\010\022\025\n\006isNull\030" + - "\006 \001(\010:\005false\0225\n\005props\030\007 \003(\0132&.com.alibab" + - "a.otter.canal.protocol.Pair\022\r\n\005value\030\010 \001", - "(\t\022\016\n\006length\030\t \001(\005\022\021\n\tmysqlType\030\n \001(\t\"\301\001" + - "\n\007RowData\022?\n\rbeforeColumns\030\001 \003(\0132(.com.a" + - "libaba.otter.canal.protocol.Column\022>\n\014af" + - "terColumns\030\002 \003(\0132(.com.alibaba.otter.can" + - "al.protocol.Column\0225\n\005props\030\003 \003(\0132&.com." + - "alibaba.otter.canal.protocol.Pair\"\222\002\n\tRo" + - "wChange\022\017\n\007tableId\030\001 \001(\003\022F\n\teventType\030\002 " + - "\001(\0162+.com.alibaba.otter.canal.protocol.E" + - "ventType:\006UPDATE\022\024\n\005isDdl\030\n \001(\010:\005false\022\013" + - "\n\003sql\030\013 \001(\t\022;\n\010rowDatas\030\014 \003(\0132).com.alib", - "aba.otter.canal.protocol.RowData\0225\n\005prop" + - "s\030\r \003(\0132&.com.alibaba.otter.canal.protoc" + - "ol.Pair\022\025\n\rddlSchemaName\030\016 \001(\t\"\207\001\n\020Trans" + - "actionBegin\022\023\n\013executeTime\030\001 \001(\003\022\025\n\rtran" + - "sactionId\030\002 \001(\t\0225\n\005props\030\003 \003(\0132&.com.ali" + - "baba.otter.canal.protocol.Pair\022\020\n\010thread" + - "Id\030\004 \001(\003\"s\n\016TransactionEnd\022\023\n\013executeTim" + - "e\030\001 \001(\003\022\025\n\rtransactionId\030\002 \001(\t\0225\n\005props\030" + - "\003 \003(\0132&.com.alibaba.otter.canal.protocol" + - ".Pair\"\"\n\004Pair\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(", - "\t*^\n\tEntryType\022\024\n\020TRANSACTIONBEGIN\020\001\022\013\n\007" + - "ROWDATA\020\002\022\022\n\016TRANSACTIONEND\020\003\022\r\n\tHEARTBE" + - "AT\020\004\022\013\n\007GTIDLOG\020\005*\316\001\n\tEventType\022\n\n\006INSER" + - "T\020\001\022\n\n\006UPDATE\020\002\022\n\n\006DELETE\020\003\022\n\n\006CREATE\020\004\022" + - "\t\n\005ALTER\020\005\022\t\n\005ERASE\020\006\022\t\n\005QUERY\020\007\022\014\n\010TRUN" + - "CATE\020\010\022\n\n\006RENAME\020\t\022\n\n\006CINDEX\020\n\022\n\n\006DINDEX" + - "\020\013\022\010\n\004GTID\020\014\022\013\n\007XASTART\020\r\022\t\n\005XAEND\020\016\022\014\n\010" + - "XACOMMIT\020\017\022\016\n\nXAROLLBACK\020\020*(\n\004Type\022\n\n\006OR" + - "ACLE\020\001\022\t\n\005MYSQL\020\002\022\t\n\005PGSQL\020\003B0\n com.alib" + - "aba.otter.canal.protocolB\nCanalEntryH\001" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - internal_static_com_alibaba_otter_canal_protocol_Entry_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_com_alibaba_otter_canal_protocol_Entry_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_com_alibaba_otter_canal_protocol_Entry_descriptor, - new java.lang.String[] { "Header", "EntryType", "StoreValue", }); - internal_static_com_alibaba_otter_canal_protocol_Header_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_com_alibaba_otter_canal_protocol_Header_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_com_alibaba_otter_canal_protocol_Header_descriptor, - new java.lang.String[] { "Version", "LogfileName", "LogfileOffset", "ServerId", "ServerenCode", "ExecuteTime", "SourceType", "SchemaName", "TableName", "EventLength", "EventType", "Props", "Gtid", }); - internal_static_com_alibaba_otter_canal_protocol_Column_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_com_alibaba_otter_canal_protocol_Column_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_com_alibaba_otter_canal_protocol_Column_descriptor, - new java.lang.String[] { "Index", "SqlType", "Name", "IsKey", "Updated", "IsNull", "Props", "Value", "Length", "MysqlType", }); - internal_static_com_alibaba_otter_canal_protocol_RowData_descriptor = - getDescriptor().getMessageTypes().get(3); - internal_static_com_alibaba_otter_canal_protocol_RowData_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_com_alibaba_otter_canal_protocol_RowData_descriptor, - new java.lang.String[] { "BeforeColumns", "AfterColumns", "Props", }); - internal_static_com_alibaba_otter_canal_protocol_RowChange_descriptor = - getDescriptor().getMessageTypes().get(4); - internal_static_com_alibaba_otter_canal_protocol_RowChange_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_com_alibaba_otter_canal_protocol_RowChange_descriptor, - new java.lang.String[] { "TableId", "EventType", "IsDdl", "Sql", "RowDatas", "Props", "DdlSchemaName", }); - internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_descriptor = - getDescriptor().getMessageTypes().get(5); - internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_descriptor, - new java.lang.String[] { "ExecuteTime", "TransactionId", "Props", "ThreadId", }); - internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_descriptor = - getDescriptor().getMessageTypes().get(6); - internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_descriptor, - new java.lang.String[] { "ExecuteTime", "TransactionId", "Props", }); - internal_static_com_alibaba_otter_canal_protocol_Pair_descriptor = - getDescriptor().getMessageTypes().get(7); - internal_static_com_alibaba_otter_canal_protocol_Pair_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_com_alibaba_otter_canal_protocol_Pair_descriptor, - new java.lang.String[] { "Key", "Value", }); - } - - // @@protoc_insertion_point(outer_class_scope) -} \ No newline at end of file + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/protocol/src/main/java/com/alibaba/otter/canal/protocol/Message.java b/protocol/src/main/java/com/alibaba/otter/canal/protocol/Message.java index 984766e2..35adf15d 100644 --- a/protocol/src/main/java/com/alibaba/otter/canal/protocol/Message.java +++ b/protocol/src/main/java/com/alibaba/otter/canal/protocol/Message.java @@ -8,6 +8,7 @@ import org.apache.commons.lang.builder.ToStringBuilder; import com.alibaba.otter.canal.common.utils.CanalToStringStyle; import com.alibaba.otter.canal.protocol.CanalEntry.Entry; +import com.google.protobuf.ByteString; /** * @author zebin.xuzb @ 2012-6-19 @@ -18,11 +19,26 @@ public class Message implements Serializable { private static final long serialVersionUID = 1234034768477580009L; private long id; + @Deprecated private List entries = new ArrayList(); + // row data for performance, see: + // https://github.com/alibaba/canal/issues/726 + private boolean raw = true; + private List rawEntries = new ArrayList(); public Message(long id, List entries){ this.id = id; this.entries = entries == null ? new ArrayList() : entries; + this.raw = false; + } + + public Message(long id, boolean raw, List entries){ + this.id = id; + if (raw) { + this.rawEntries = entries == null ? new ArrayList() : entries; + } else { + this.entries = entries == null ? new ArrayList() : entries; + } } public Message(long id){ @@ -49,6 +65,26 @@ public class Message implements Serializable { this.entries.add(entry); } + public void setRawEntries(List rawEntries) { + this.rawEntries = rawEntries; + } + + public void addRawEntry(ByteString rawEntry) { + this.rawEntries.add(rawEntry); + } + + public List getRawEntries() { + return rawEntries; + } + + public boolean isRaw() { + return raw; + } + + public void setRaw(boolean raw) { + this.raw = raw; + } + public String toString() { return ToStringBuilder.reflectionToString(this, CanalToStringStyle.DEFAULT_STYLE); } diff --git a/protocol/src/main/java/com/alibaba/otter/canal/protocol/position/EntryPosition.java b/protocol/src/main/java/com/alibaba/otter/canal/protocol/position/EntryPosition.java index a830e636..33887b0c 100644 --- a/protocol/src/main/java/com/alibaba/otter/canal/protocol/position/EntryPosition.java +++ b/protocol/src/main/java/com/alibaba/otter/canal/protocol/position/EntryPosition.java @@ -1,6 +1,5 @@ package com.alibaba.otter.canal.protocol.position; - /** * 数据库对象的唯一标示 * diff --git a/server/src/main/java/com/alibaba/otter/canal/server/embedded/CanalServerWithEmbedded.java b/server/src/main/java/com/alibaba/otter/canal/server/embedded/CanalServerWithEmbedded.java index 1b6bd448..ccf21020 100644 --- a/server/src/main/java/com/alibaba/otter/canal/server/embedded/CanalServerWithEmbedded.java +++ b/server/src/main/java/com/alibaba/otter/canal/server/embedded/CanalServerWithEmbedded.java @@ -1,11 +1,11 @@ package com.alibaba.otter.canal.server.embedded; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.TimeUnit; +import com.alibaba.otter.canal.spi.CanalMetricsProvider; +import com.alibaba.otter.canal.spi.CanalMetricsService; +import com.alibaba.otter.canal.spi.NopCanalMetricsService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; @@ -14,7 +14,6 @@ import org.springframework.util.CollectionUtils; import com.alibaba.otter.canal.common.AbstractCanalLifeCycle; import com.alibaba.otter.canal.instance.core.CanalInstance; import com.alibaba.otter.canal.instance.core.CanalInstanceGenerator; -import com.alibaba.otter.canal.protocol.CanalEntry.Entry; import com.alibaba.otter.canal.protocol.ClientIdentity; import com.alibaba.otter.canal.protocol.Message; import com.alibaba.otter.canal.protocol.position.LogPosition; @@ -30,20 +29,22 @@ import com.google.common.base.Function; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.MigrateMap; +import com.google.protobuf.ByteString; /** * 嵌入式版本实现 - * + * * @author jianghang 2012-7-12 下午01:34:00 * @author zebin.xuzb * @version 1.0.0 */ public class CanalServerWithEmbedded extends AbstractCanalLifeCycle implements CanalServer, CanalService { - private static final Logger logger = LoggerFactory.getLogger(CanalServerWithEmbedded.class); + private static final Logger logger = LoggerFactory.getLogger(CanalServerWithEmbedded.class); private Map canalInstances; // private Map lastRollbackPostions; private CanalInstanceGenerator canalInstanceGenerator; + private CanalMetricsService metrics = NopCanalMetricsService.NOP; private static class SingletonHolder { @@ -61,7 +62,9 @@ public class CanalServerWithEmbedded extends AbstractCanalLifeCycle implements C public void start() { if (!isStart()) { super.start(); - + // 如果存在provider,则启动metrics service + loadCanalMetrics(); + metrics.initialize(); canalInstances = MigrateMap.makeComputingMap(new Function() { public CanalInstance apply(String destination) { @@ -92,6 +95,7 @@ public class CanalServerWithEmbedded extends AbstractCanalLifeCycle implements C logger.error(String.format("stop CanalInstance[%s] has an error", entry.getKey()), e); } } + metrics.terminate(); } public void start(final String destination) { @@ -99,6 +103,9 @@ public class CanalServerWithEmbedded extends AbstractCanalLifeCycle implements C if (!canalInstance.isStart()) { try { MDC.put("destination", destination); + if (metrics.isRunning()) { + metrics.register(canalInstance); + } canalInstance.start(); logger.info("start CanalInstances[{}] successfully", destination); } finally { @@ -114,6 +121,9 @@ public class CanalServerWithEmbedded extends AbstractCanalLifeCycle implements C try { MDC.put("destination", destination); canalInstance.stop(); + if (metrics.isRunning()) { + metrics.unregister(canalInstance); + } logger.info("stop CanalInstances[{}] successfully", destination); } finally { MDC.remove("destination"); @@ -176,7 +186,7 @@ public class CanalServerWithEmbedded extends AbstractCanalLifeCycle implements C /** * 获取数据 - * + * *
            * 注意: meta获取和数据的获取需要保证顺序性,优先拿到meta的,一定也会是优先拿到数据,所以需要加同步. (不能出现先拿到meta,拿到第二批数据,这样就会导致数据顺序性出现问题)
            * 
      @@ -188,14 +198,14 @@ public class CanalServerWithEmbedded extends AbstractCanalLifeCycle implements C /** * 获取数据,可以指定超时时间. - * + * *
            * 几种case:
            * a. 如果timeout为null,则采用tryGet方式,即时获取
            * b. 如果timeout不为null
            *    1. timeout为0,则采用get阻塞方式,获取数据,不设置超时,直到有足够的batchSize数据才返回
            *    2. timeout不为0,则采用get+timeout方式,获取数据,超时还没有batchSize足够的数据,有多少返回多少
      -     * 
      +     *
            * 注意: meta获取和数据的获取需要保证顺序性,优先拿到meta的,一定也会是优先拿到数据,所以需要加同步. (不能出现先拿到meta,拿到第二批数据,这样就会导致数据顺序性出现问题)
            * 
      */ @@ -221,28 +231,29 @@ public class CanalServerWithEmbedded extends AbstractCanalLifeCycle implements C if (CollectionUtils.isEmpty(events.getEvents())) { logger.debug("get successfully, clientId:{} batchSize:{} but result is null", - clientIdentity.getClientId(), batchSize); - return new Message(-1, new ArrayList()); // 返回空包,避免生成batchId,浪费性能 + clientIdentity.getClientId(), + batchSize); + return new Message(-1, true, new ArrayList()); // 返回空包,避免生成batchId,浪费性能 } else { // 记录到流式信息 Long batchId = canalInstance.getMetaManager().addBatch(clientIdentity, events.getPositionRange()); - List entrys = Lists.transform(events.getEvents(), new Function() { + List entrys = Lists.transform(events.getEvents(), new Function() { - public Entry apply(Event input) { - return input.getEntry(); + public ByteString apply(Event input) { + return input.getRawEntry(); } }); if (logger.isInfoEnabled()) { logger.info("get successfully, clientId:{} batchSize:{} real size is {} and result is [batchId:{} , position:{}]", - clientIdentity.getClientId(), - batchSize, - entrys.size(), - batchId, - events.getPositionRange()); + clientIdentity.getClientId(), + batchSize, + entrys.size(), + batchId, + events.getPositionRange()); } // 直接提交ack ack(clientIdentity, batchId); - return new Message(batchId, entrys); + return new Message(batchId, true, entrys); } } } @@ -250,7 +261,7 @@ public class CanalServerWithEmbedded extends AbstractCanalLifeCycle implements C /** * 不指定 position 获取事件。canal 会记住此 client 最新的 position。
      * 如果是第一次 fetch,则会从 canal 中保存的最老一条数据开始输出。 - * + * *
            * 注意: meta获取和数据的获取需要保证顺序性,优先拿到meta的,一定也会是优先拿到数据,所以需要加同步. (不能出现先拿到meta,拿到第二批数据,这样就会导致数据顺序性出现问题)
            * 
      @@ -263,14 +274,14 @@ public class CanalServerWithEmbedded extends AbstractCanalLifeCycle implements C /** * 不指定 position 获取事件。canal 会记住此 client 最新的 position。
      * 如果是第一次 fetch,则会从 canal 中保存的最老一条数据开始输出。 - * + * *
            * 几种case:
            * a. 如果timeout为null,则采用tryGet方式,即时获取
            * b. 如果timeout不为null
            *    1. timeout为0,则采用get阻塞方式,获取数据,不设置超时,直到有足够的batchSize数据才返回
            *    2. timeout不为0,则采用get+timeout方式,获取数据,超时还没有batchSize足够的数据,有多少返回多少
      -     *    
      +     *
            * 注意: meta获取和数据的获取需要保证顺序性,优先拿到meta的,一定也会是优先拿到数据,所以需要加同步. (不能出现先拿到meta,拿到第二批数据,这样就会导致数据顺序性出现问题)
            * 
      */ @@ -299,26 +310,27 @@ public class CanalServerWithEmbedded extends AbstractCanalLifeCycle implements C if (CollectionUtils.isEmpty(events.getEvents())) { logger.debug("getWithoutAck successfully, clientId:{} batchSize:{} but result is null", - clientIdentity.getClientId(), batchSize); - return new Message(-1, new ArrayList()); // 返回空包,避免生成batchId,浪费性能 + clientIdentity.getClientId(), + batchSize); + return new Message(-1, true, new ArrayList()); // 返回空包,避免生成batchId,浪费性能 } else { // 记录到流式信息 Long batchId = canalInstance.getMetaManager().addBatch(clientIdentity, events.getPositionRange()); - List entrys = Lists.transform(events.getEvents(), new Function() { + List entrys = Lists.transform(events.getEvents(), new Function() { - public Entry apply(Event input) { - return input.getEntry(); + public ByteString apply(Event input) { + return input.getRawEntry(); } }); if (logger.isInfoEnabled()) { logger.info("getWithoutAck successfully, clientId:{} batchSize:{} real size is {} and result is [batchId:{} , position:{}]", - clientIdentity.getClientId(), - batchSize, - entrys.size(), - batchId, - events.getPositionRange()); + clientIdentity.getClientId(), + batchSize, + entrys.size(), + batchId, + events.getPositionRange()); } - return new Message(batchId, entrys); + return new Message(batchId, true, entrys); } } @@ -340,7 +352,7 @@ public class CanalServerWithEmbedded extends AbstractCanalLifeCycle implements C /** * 进行 batch id 的确认。确认之后,小于等于此 batchId 的 Message 都会被确认。 - * + * *
            * 注意:进行反馈时必须按照batchId的顺序进行ack(需有客户端保证)
            * 
      @@ -381,9 +393,9 @@ public class CanalServerWithEmbedded extends AbstractCanalLifeCycle implements C canalInstance.getMetaManager().updateCursor(clientIdentity, positionRanges.getAck()); if (logger.isInfoEnabled()) { logger.info("ack successfully, clientId:{} batchId:{} position:{}", - clientIdentity.getClientId(), - batchId, - positionRanges); + clientIdentity.getClientId(), + batchId, + positionRanges); } } @@ -490,6 +502,27 @@ public class CanalServerWithEmbedded extends AbstractCanalLifeCycle implements C } } + private void loadCanalMetrics() { + ServiceLoader providers = ServiceLoader.load(CanalMetricsProvider.class); + List list = new ArrayList(); + for (CanalMetricsProvider provider : providers) { + list.add(provider); + } + if (!list.isEmpty()) { + // 发现provider, 进行初始化 + if (list.size() > 1) { + logger.warn("Found more than one CanalMetricsProvider, use the first one."); + //报告冲突 + for (CanalMetricsProvider p : list) { + logger.warn("Found CanalMetricsProvider: {}.", p.getClass().getName()); + } + } + //默认使用第一个 + CanalMetricsProvider provider = list.get(0); + this.metrics = provider.getService(); + } + } + // ========= setter ========== public void setCanalInstanceGenerator(CanalInstanceGenerator canalInstanceGenerator) { diff --git a/server/src/main/java/com/alibaba/otter/canal/server/netty/NettyUtils.java b/server/src/main/java/com/alibaba/otter/canal/server/netty/NettyUtils.java index 531c817f..20532400 100644 --- a/server/src/main/java/com/alibaba/otter/canal/server/netty/NettyUtils.java +++ b/server/src/main/java/com/alibaba/otter/canal/server/netty/NettyUtils.java @@ -2,8 +2,12 @@ package com.alibaba.otter.canal.server.netty; import java.nio.ByteBuffer; import java.nio.ByteOrder; +import java.util.ArrayList; +import java.util.List; +import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; +import org.jboss.netty.buffer.CompositeChannelBuffer; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelFutureListener; import org.jboss.netty.channel.Channels; @@ -19,9 +23,23 @@ import com.alibaba.otter.canal.protocol.CanalPacket.Packet; public class NettyUtils { private static final Logger logger = LoggerFactory.getLogger(NettyUtils.class); - private static int HEADER_LENGTH = 4; + public static int HEADER_LENGTH = 4; public static Timer hashedWheelTimer = new HashedWheelTimer(); + public static void write(Channel channel, ByteBuffer body, ChannelFutureListener channelFutureListner) { + byte[] header = ByteBuffer.allocate(HEADER_LENGTH).order(ByteOrder.BIG_ENDIAN).putInt(body.limit()).array(); + List components = new ArrayList(2); + components.add(ChannelBuffers.wrappedBuffer(ByteOrder.BIG_ENDIAN, header)); + components.add(ChannelBuffers.wrappedBuffer(body)); + + if (channelFutureListner == null) { + Channels.write(channel, new CompositeChannelBuffer(ByteOrder.BIG_ENDIAN, components)); + } else { + Channels.write(channel, new CompositeChannelBuffer(ByteOrder.BIG_ENDIAN, components)) + .addListener(channelFutureListner); + } + } + public static void write(Channel channel, byte[] body, ChannelFutureListener channelFutureListner) { byte[] header = ByteBuffer.allocate(HEADER_LENGTH).order(ByteOrder.BIG_ENDIAN).putInt(body.length).array(); if (channelFutureListner == null) { diff --git a/server/src/main/java/com/alibaba/otter/canal/server/netty/handler/ClientAuthenticationHandler.java b/server/src/main/java/com/alibaba/otter/canal/server/netty/handler/ClientAuthenticationHandler.java index eaa6b636..60398ea7 100644 --- a/server/src/main/java/com/alibaba/otter/canal/server/netty/handler/ClientAuthenticationHandler.java +++ b/server/src/main/java/com/alibaba/otter/canal/server/netty/handler/ClientAuthenticationHandler.java @@ -34,7 +34,7 @@ public class ClientAuthenticationHandler extends SimpleChannelHandler { private static final Logger logger = LoggerFactory.getLogger(ClientAuthenticationHandler.class); private final int SUPPORTED_VERSION = 3; - private final int defaultSubscriptorDisconnectIdleTimeout = 5 * 60 * 1000; + private final int defaultSubscriptorDisconnectIdleTimeout = 60 * 60 * 1000; private CanalServerWithEmbedded embeddedServer; public ClientAuthenticationHandler(){ diff --git a/server/src/main/java/com/alibaba/otter/canal/server/netty/handler/SessionHandler.java b/server/src/main/java/com/alibaba/otter/canal/server/netty/handler/SessionHandler.java index 3eda5a0d..11bba043 100644 --- a/server/src/main/java/com/alibaba/otter/canal/server/netty/handler/SessionHandler.java +++ b/server/src/main/java/com/alibaba/otter/canal/server/netty/handler/SessionHandler.java @@ -33,13 +33,10 @@ import com.alibaba.otter.canal.protocol.ClientIdentity; import com.alibaba.otter.canal.protocol.Message; import com.alibaba.otter.canal.server.embedded.CanalServerWithEmbedded; import com.alibaba.otter.canal.server.netty.NettyUtils; +import com.google.protobuf.ByteString; +import com.google.protobuf.CodedOutputStream; +import com.google.protobuf.WireFormat; -/** - * 处理具体的客户端请求 - * - * @author jianghang 2012-10-24 下午02:21:13 - * @version 1.0.0 - */ public class SessionHandler extends SimpleChannelHandler { private static final Logger logger = LoggerFactory.getLogger(SessionHandler.class); @@ -76,7 +73,7 @@ public class SessionHandler extends SimpleChannelHandler { } embeddedServer.subscribe(clientIdentity); - ctx.setAttachment(clientIdentity);// 设置状态数据 + // ctx.setAttachment(clientIdentity);// 设置状态数据 NettyUtils.ack(ctx.getChannel(), null); } else { NettyUtils.error(401, @@ -130,18 +127,74 @@ public class SessionHandler extends SimpleChannelHandler { } // } - Packet.Builder packetBuilder = CanalPacket.Packet.newBuilder(); - packetBuilder.setType(PacketType.MESSAGES); + if (message.getId() != -1 && message.isRaw()) { + List rowEntries = message.getRawEntries(); + // message size + int messageSize = 0; + messageSize += com.google.protobuf.CodedOutputStream.computeInt64Size(1, message.getId()); - Messages.Builder messageBuilder = CanalPacket.Messages.newBuilder(); - messageBuilder.setBatchId(message.getId()); - if (message.getId() != -1 && !CollectionUtils.isEmpty(message.getEntries())) { - for (Entry entry : message.getEntries()) { - messageBuilder.addMessages(entry.toByteString()); + int dataSize = 0; + for (int i = 0; i < rowEntries.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream.computeBytesSizeNoTag(rowEntries.get(i)); } + messageSize += dataSize; + messageSize += 1 * rowEntries.size(); + // packet size + int size = 0; + size += com.google.protobuf.CodedOutputStream.computeEnumSize(3, + PacketType.MESSAGES.getNumber()); + size += com.google.protobuf.CodedOutputStream.computeTagSize(5) + + com.google.protobuf.CodedOutputStream.computeRawVarint32Size(messageSize) + + messageSize; + // recyle bytes + // ByteBuffer byteBuffer = (ByteBuffer) + // ctx.getAttachment(); + // if (byteBuffer != null && size <= + // byteBuffer.capacity()) { + // byteBuffer.clear(); + // } else { + // byteBuffer = + // ByteBuffer.allocate(size).order(ByteOrder.BIG_ENDIAN); + // ctx.setAttachment(byteBuffer); + // } + // CodedOutputStream output = + // CodedOutputStream.newInstance(byteBuffer); + byte[] body = new byte[size]; + CodedOutputStream output = CodedOutputStream.newInstance(body); + output.writeEnum(3, PacketType.MESSAGES.getNumber()); + + output.writeTag(5, WireFormat.WIRETYPE_LENGTH_DELIMITED); + output.writeRawVarint32(messageSize); + // message + output.writeInt64(1, message.getId()); + for (int i = 0; i < rowEntries.size(); i++) { + output.writeBytes(2, rowEntries.get(i)); + } + output.checkNoSpaceLeft(); + NettyUtils.write(ctx.getChannel(), body, null); + + // output.flush(); + // byteBuffer.flip(); + // NettyUtils.write(ctx.getChannel(), byteBuffer, + // null); + } else { + Packet.Builder packetBuilder = CanalPacket.Packet.newBuilder(); + packetBuilder.setType(PacketType.MESSAGES); + + Messages.Builder messageBuilder = CanalPacket.Messages.newBuilder(); + messageBuilder.setBatchId(message.getId()); + if (message.getId() != -1) { + if (message.isRaw() && !CollectionUtils.isEmpty(message.getRawEntries())) { + messageBuilder.addAllMessages(message.getRawEntries()); + } else if (!CollectionUtils.isEmpty(message.getEntries())) { + for (Entry entry : message.getEntries()) { + messageBuilder.addMessages(entry.toByteString()); + } + } + } + packetBuilder.setBody(messageBuilder.build().toByteString()); + NettyUtils.write(ctx.getChannel(), packetBuilder.build().toByteArray(), null);// 输出数据 } - packetBuilder.setBody(messageBuilder.build().toByteString()); - NettyUtils.write(ctx.getChannel(), packetBuilder.build().toByteArray(), null);// 输出数据 } else { NettyUtils.error(401, MessageFormatter.format("destination or clientId is null", get.toString()).getMessage(), diff --git a/server/src/main/java/com/alibaba/otter/canal/spi/CanalMetricsProvider.java b/server/src/main/java/com/alibaba/otter/canal/spi/CanalMetricsProvider.java new file mode 100644 index 00000000..ad0ceddf --- /dev/null +++ b/server/src/main/java/com/alibaba/otter/canal/spi/CanalMetricsProvider.java @@ -0,0 +1,24 @@ +package com.alibaba.otter.canal.spi; + +/** + * Use java service provider mechanism to provide {@link CanalMetricsService}. + *
      + * Example:
      + * {@code
      + *     ServiceLoader providers = ServiceLoader.load(CanalMetricsProvider.class);
      + *     List list = new ArrayList();
      + *     for (CanalMetricsProvider provider : providers) {
      + *         list.add(provider);
      + *     }
      + * }
      + * 
      + * @author Chuanyi Li + */ +public interface CanalMetricsProvider { + + /** + * @return Impl of {@link CanalMetricsService} + */ + CanalMetricsService getService(); + +} diff --git a/server/src/main/java/com/alibaba/otter/canal/spi/CanalMetricsService.java b/server/src/main/java/com/alibaba/otter/canal/spi/CanalMetricsService.java new file mode 100644 index 00000000..6d823be8 --- /dev/null +++ b/server/src/main/java/com/alibaba/otter/canal/spi/CanalMetricsService.java @@ -0,0 +1,42 @@ +package com.alibaba.otter.canal.spi; + +import com.alibaba.otter.canal.instance.core.CanalInstance; + +/** + * Canal server/instance metrics for export. + * + * Designed to be created by service provider. + * + * @see CanalMetricsProvider + * @author Chuanyi Li + */ +public interface CanalMetricsService { + + /** + * Initialization on canal server startup. + */ + void initialize(); + + /** + * Clean-up at canal server stop phase. + */ + void terminate(); + + /** + * @return {@code true} if the metrics service is running, otherwise {@code false}. + */ + boolean isRunning(); + + /** + * Register instance level metrics for specified instance. + * @param instance {@link CanalInstance} + */ + void register(CanalInstance instance); + + /** + * Unregister instance level metrics for specified instance. + * @param instance {@link CanalInstance} + */ + void unregister(CanalInstance instance); + +} diff --git a/server/src/main/java/com/alibaba/otter/canal/spi/NopCanalMetricsService.java b/server/src/main/java/com/alibaba/otter/canal/spi/NopCanalMetricsService.java new file mode 100644 index 00000000..0d6ad088 --- /dev/null +++ b/server/src/main/java/com/alibaba/otter/canal/spi/NopCanalMetricsService.java @@ -0,0 +1,38 @@ +package com.alibaba.otter.canal.spi; + +import com.alibaba.otter.canal.instance.core.CanalInstance; + +/** + * @author Chuanyi Li + */ +public class NopCanalMetricsService implements CanalMetricsService { + + public static final NopCanalMetricsService NOP = new NopCanalMetricsService(); + + private NopCanalMetricsService() {} + + @Override + public void initialize() { + + } + + @Override + public void terminate() { + + } + + @Override + public boolean isRunning() { + return false; + } + + @Override + public void register(CanalInstance instance) { + + } + + @Override + public void unregister(CanalInstance instance) { + + } +} diff --git a/server/src/test/java/com/alibaba/otter/canal/server/CanalServerWithEmbedded_FileModeTest.java b/server/src/test/java/com/alibaba/otter/canal/server/CanalServerWithEmbedded_FileModeTest.java new file mode 100644 index 00000000..e986b6ff --- /dev/null +++ b/server/src/test/java/com/alibaba/otter/canal/server/CanalServerWithEmbedded_FileModeTest.java @@ -0,0 +1,53 @@ +package com.alibaba.otter.canal.server; + +import java.net.InetSocketAddress; +import java.util.Arrays; + +import com.alibaba.otter.canal.instance.manager.model.Canal; +import com.alibaba.otter.canal.instance.manager.model.CanalParameter; +import com.alibaba.otter.canal.instance.manager.model.CanalParameter.*; + +public class CanalServerWithEmbedded_FileModeTest extends BaseCanalServerWithEmbededTest { + + protected Canal buildCanal() { + Canal canal = new Canal(); + canal.setId(1L); + canal.setName(DESTINATION); + canal.setDesc("my standalone server test "); + + CanalParameter parameter = new CanalParameter(); + + parameter.setMetaMode(MetaMode.LOCAL_FILE); + parameter.setDataDir("./conf"); + parameter.setMetaFileFlushPeriod(1000); + parameter.setHaMode(HAMode.HEARTBEAT); + parameter.setIndexMode(IndexMode.MEMORY_META_FAILBACK); + + parameter.setStorageMode(StorageMode.MEMORY); + parameter.setMemoryStorageBufferSize(32 * 1024); + + parameter.setSourcingType(SourcingType.MYSQL); + parameter.setDbAddresses(Arrays.asList(new InetSocketAddress(MYSQL_ADDRESS, 3306), + new InetSocketAddress(MYSQL_ADDRESS, 3306))); + parameter.setDbUsername(USERNAME); + parameter.setDbPassword(PASSWORD); + parameter.setPositions(Arrays.asList("{\"journalName\":\"mysql-bin.000001\",\"position\":332L,\"timestamp\":\"1505998863000\"}", + "{\"journalName\":\"mysql-bin.000001\",\"position\":332L,\"timestamp\":\"1505998863000\"}")); + + parameter.setSlaveId(1234L); + + parameter.setDefaultConnectionTimeoutInSeconds(30); + parameter.setConnectionCharset("UTF-8"); + parameter.setConnectionCharsetNumber((byte) 33); + parameter.setReceiveBufferSize(8 * 1024); + parameter.setSendBufferSize(8 * 1024); + + parameter.setDetectingEnable(false); + parameter.setDetectingIntervalInSeconds(10); + parameter.setDetectingRetryTimes(3); + parameter.setDetectingSQL(DETECTING_SQL); + + canal.setCanalParameter(parameter); + return canal; + } +} \ No newline at end of file diff --git a/server/src/test/java/com/alibaba/otter/canal/server/ProtocolTest.java b/server/src/test/java/com/alibaba/otter/canal/server/ProtocolTest.java new file mode 100644 index 00000000..cb078ddf --- /dev/null +++ b/server/src/test/java/com/alibaba/otter/canal/server/ProtocolTest.java @@ -0,0 +1,92 @@ +package com.alibaba.otter.canal.server; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +import org.junit.Test; + +import com.alibaba.otter.canal.protocol.CanalEntry.Entry; +import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; +import com.alibaba.otter.canal.protocol.CanalEntry.Header; +import com.alibaba.otter.canal.protocol.CanalPacket.Compression; +import com.alibaba.otter.canal.protocol.CanalPacket.Messages; +import com.alibaba.otter.canal.protocol.CanalPacket.Packet; +import com.alibaba.otter.canal.protocol.CanalPacket.PacketType; +import com.alibaba.otter.canal.protocol.Message; +import com.alibaba.otter.canal.protocol.exception.CanalClientException; +import com.google.protobuf.ByteString; +import com.google.protobuf.CodedOutputStream; +import com.google.protobuf.WireFormat; + +public class ProtocolTest { + + @Test + public void testSimple() throws IOException { + Header.Builder headerBuilder = Header.newBuilder(); + headerBuilder.setLogfileName("mysql-bin.000001"); + headerBuilder.setLogfileOffset(1024); + headerBuilder.setExecuteTime(1024); + Entry.Builder entryBuilder = Entry.newBuilder(); + entryBuilder.setHeader(headerBuilder.build()); + entryBuilder.setEntryType(EntryType.ROWDATA); + Entry entry = entryBuilder.build(); + Message message = new Message(3, true, Arrays.asList(entry.toByteString())); + + byte[] body = buildData(message); + Packet packet = Packet.parseFrom(body); + switch (packet.getType()) { + case MESSAGES: { + if (!packet.getCompression().equals(Compression.NONE)) { + throw new CanalClientException("compression is not supported in this connector"); + } + + Messages messages = Messages.parseFrom(packet.getBody()); + Message result = new Message(messages.getBatchId()); + for (ByteString byteString : messages.getMessagesList()) { + result.addEntry(Entry.parseFrom(byteString)); + } + + System.out.println(result); + break; + } + default: { + throw new CanalClientException("unexpected packet type: " + packet.getType()); + } + } + } + + private byte[] buildData(Message message) throws IOException { + List rowEntries = message.getRawEntries(); + // message size + int messageSize = 0; + messageSize += com.google.protobuf.CodedOutputStream.computeInt64Size(1, message.getId()); + + int dataSize = 0; + for (int i = 0; i < rowEntries.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream.computeBytesSizeNoTag(rowEntries.get(i)); + } + messageSize += dataSize; + messageSize += 1 * rowEntries.size(); + // packet size + int size = 0; + size += com.google.protobuf.CodedOutputStream.computeEnumSize(3, PacketType.MESSAGES.getNumber()); + size += com.google.protobuf.CodedOutputStream.computeTagSize(5) + + com.google.protobuf.CodedOutputStream.computeRawVarint32Size(messageSize) + messageSize; + // TODO recyle bytes[] + byte[] body = new byte[size]; + CodedOutputStream output = CodedOutputStream.newInstance(body); + output.writeEnum(3, PacketType.MESSAGES.getNumber()); + + output.writeTag(5, WireFormat.WIRETYPE_LENGTH_DELIMITED); + output.writeRawVarint32(messageSize); + // message + output.writeInt64(1, message.getId()); + for (int i = 0; i < rowEntries.size(); i++) { + output.writeBytes(2, rowEntries.get(i)); + } + output.checkNoSpaceLeft(); + + return body; + } +} diff --git a/sink/src/main/java/com/alibaba/otter/canal/sink/entry/EntryEventSink.java b/sink/src/main/java/com/alibaba/otter/canal/sink/entry/EntryEventSink.java index bfb4b771..6511e6ba 100644 --- a/sink/src/main/java/com/alibaba/otter/canal/sink/entry/EntryEventSink.java +++ b/sink/src/main/java/com/alibaba/otter/canal/sink/entry/EntryEventSink.java @@ -92,11 +92,11 @@ public class EntryEventSink extends AbstractCanalEventSink events = new ArrayList(); for (CanalEntry.Entry entry : entrys) { - Event event = new Event(new LogIdentity(remoteAddress, -1L), entry); - if (!doFilter(event)) { + if (!doFilter(entry)) { continue; } + Event event = new Event(new LogIdentity(remoteAddress, -1L), entry); events.add(event); hasRowData |= (entry.getEntryType() == EntryType.ROWDATA); hasHeartBeat |= (entry.getEntryType() == EntryType.HEARTBEAT); @@ -111,7 +111,7 @@ public class EntryEventSink extends AbstractCanalEventSink emptyTransactionInterval || lastEmptyTransactionCount.incrementAndGet() > emptyTransctionThresold) { @@ -126,15 +126,15 @@ public class EntryEventSink extends AbstractCanalEventSink before(List events) { boolean existHeartBeat = false; for (Event event : events) { - if (event.getEntry().getEntryType() == EntryType.HEARTBEAT) { + if (event.getEntryType() == EntryType.HEARTBEAT) { existHeartBeat = true; } } @@ -29,7 +29,7 @@ public class HeartBeatEntryEventHandler extends AbstractCanalEventDownStreamHand // 目前heartbeat和其他事件是分离的,保险一点还是做一下检查处理 List result = new ArrayList(); for (Event event : events) { - if (event.getEntry().getEntryType() != EntryType.HEARTBEAT) { + if (event.getEntryType() != EntryType.HEARTBEAT) { result.add(event); } } diff --git a/sink/src/main/java/com/alibaba/otter/canal/sink/entry/group/TimelineBarrier.java b/sink/src/main/java/com/alibaba/otter/canal/sink/entry/group/TimelineBarrier.java index be9edfa0..24f457b7 100644 --- a/sink/src/main/java/com/alibaba/otter/canal/sink/entry/group/TimelineBarrier.java +++ b/sink/src/main/java/com/alibaba/otter/canal/sink/entry/group/TimelineBarrier.java @@ -139,7 +139,7 @@ public class TimelineBarrier implements GroupBarrier { } private Long getTimestamp(Event event) { - return event.getEntry().getHeader().getExecuteTime(); + return event.getExecuteTime(); } } diff --git a/sink/src/main/java/com/alibaba/otter/canal/sink/entry/group/TimelineTransactionBarrier.java b/sink/src/main/java/com/alibaba/otter/canal/sink/entry/group/TimelineTransactionBarrier.java index 5f6c42b3..59bf8fd7 100644 --- a/sink/src/main/java/com/alibaba/otter/canal/sink/entry/group/TimelineTransactionBarrier.java +++ b/sink/src/main/java/com/alibaba/otter/canal/sink/entry/group/TimelineTransactionBarrier.java @@ -60,11 +60,11 @@ public class TimelineTransactionBarrier extends TimelineBarrier { } public void clear(Event event) { - super.clear(event); + super.clear(event); - //应该先判断2,再判断是否是事务尾,因为事务尾也可以导致txState的状态为2 - //如果先判断事务尾,那么2的状态可能永远没机会被修改了,系统出现死锁 - //CanalSinkException被注释的代码是不是可以放开??我们内部使用的时候已经放开了,从代码逻辑的分析上以及实践效果来看,应该抛异常 + // 应该先判断2,再判断是否是事务尾,因为事务尾也可以导致txState的状态为2 + // 如果先判断事务尾,那么2的状态可能永远没机会被修改了,系统出现死锁 + // CanalSinkException被注释的代码是不是可以放开??我们内部使用的时候已经放开了,从代码逻辑的分析上以及实践效果来看,应该抛异常 if (txState.intValue() == 2) {// 非事务中 boolean result = txState.compareAndSet(2, 0); if (result == false) { @@ -92,7 +92,7 @@ public class TimelineTransactionBarrier extends TimelineBarrier { return true; // 事务允许通过 } } else if (txState.compareAndSet(0, 2)) { // 非事务保护中 - //当基于zk-cursor启动的时候,拿到的第一个Event是TransactionEnd + // 当基于zk-cursor启动的时候,拿到的第一个Event是TransactionEnd return true; // DDL/DCL/TransactionEnd允许通过 } } @@ -113,11 +113,11 @@ public class TimelineTransactionBarrier extends TimelineBarrier { } private boolean isTransactionBegin(Event event) { - return event.getEntry().getEntryType() == EntryType.TRANSACTIONBEGIN; + return event.getEntryType() == EntryType.TRANSACTIONBEGIN; } private boolean isTransactionEnd(Event event) { - return event.getEntry().getEntryType() == EntryType.TRANSACTIONEND; + return event.getEntryType() == EntryType.TRANSACTIONEND; } } diff --git a/sink/src/test/java/com/alibaba/otter/canal/sink/stub/DummyEventStore.java b/sink/src/test/java/com/alibaba/otter/canal/sink/stub/DummyEventStore.java index 8a52bb05..7f786ef2 100644 --- a/sink/src/test/java/com/alibaba/otter/canal/sink/stub/DummyEventStore.java +++ b/sink/src/test/java/com/alibaba/otter/canal/sink/stub/DummyEventStore.java @@ -60,33 +60,33 @@ public class DummyEventStore implements CanalEventStore { } public void put(Event data) throws InterruptedException, CanalStoreException { - System.out.println("time:" + data.getEntry().getHeader().getExecuteTime()); + System.out.println("time:" + data.getExecuteTime()); } public boolean put(Event data, long timeout, TimeUnit unit) throws InterruptedException, CanalStoreException { - System.out.println("time:" + data.getEntry().getHeader().getExecuteTime()); + System.out.println("time:" + data.getExecuteTime()); return true; } public boolean tryPut(Event data) throws CanalStoreException { - System.out.println("time:" + data.getEntry().getHeader().getExecuteTime()); + System.out.println("time:" + data.getExecuteTime()); return true; } public void put(List datas) throws InterruptedException, CanalStoreException { Event data = datas.get(0); - System.out.println("time:" + data.getEntry().getHeader().getExecuteTime()); + System.out.println("time:" + data.getExecuteTime()); } public boolean put(List datas, long timeout, TimeUnit unit) throws InterruptedException, CanalStoreException { Event data = datas.get(0); - System.out.println("time:" + data.getEntry().getHeader().getExecuteTime()); + System.out.println("time:" + data.getExecuteTime()); return true; } public boolean tryPut(List datas) throws CanalStoreException { Event data = datas.get(0); - System.out.println("time:" + data.getEntry().getHeader().getExecuteTime()); + System.out.println("time:" + data.getExecuteTime()); return true; } diff --git a/store/src/main/java/com/alibaba/otter/canal/store/helper/CanalEventUtils.java b/store/src/main/java/com/alibaba/otter/canal/store/helper/CanalEventUtils.java index ac858446..4fdbfcba 100644 --- a/store/src/main/java/com/alibaba/otter/canal/store/helper/CanalEventUtils.java +++ b/store/src/main/java/com/alibaba/otter/canal/store/helper/CanalEventUtils.java @@ -2,7 +2,6 @@ package com.alibaba.otter.canal.store.helper; import org.apache.commons.lang.StringUtils; -import com.alibaba.otter.canal.protocol.CanalEntry; import com.alibaba.otter.canal.protocol.position.EntryPosition; import com.alibaba.otter.canal.protocol.position.LogPosition; import com.alibaba.otter.canal.store.model.Event; @@ -48,14 +47,13 @@ public class CanalEventUtils { */ public static LogPosition createPosition(Event event) { EntryPosition position = new EntryPosition(); - position.setJournalName(event.getEntry().getHeader().getLogfileName()); - position.setPosition(event.getEntry().getHeader().getLogfileOffset()); - position.setTimestamp(event.getEntry().getHeader().getExecuteTime()); + position.setJournalName(event.getJournalName()); + position.setPosition(event.getPosition()); + position.setTimestamp(event.getExecuteTime()); // add serverId at 2016-06-28 - position.setServerId(event.getEntry().getHeader().getServerId()); - + position.setServerId(event.getServerId()); // add gtid - position.setGtid(event.getEntry().getHeader().getGtid()); + position.setGtid(event.getGtid()); LogPosition logPosition = new LogPosition(); logPosition.setPostion(position); @@ -68,9 +66,9 @@ public class CanalEventUtils { */ public static LogPosition createPosition(Event event, boolean included) { EntryPosition position = new EntryPosition(); - position.setJournalName(event.getEntry().getHeader().getLogfileName()); - position.setPosition(event.getEntry().getHeader().getLogfileOffset()); - position.setTimestamp(event.getEntry().getHeader().getExecuteTime()); + position.setJournalName(event.getJournalName()); + position.setPosition(event.getPosition()); + position.setTimestamp(event.getExecuteTime()); position.setIncluded(included); LogPosition logPosition = new LogPosition(); @@ -84,13 +82,14 @@ public class CanalEventUtils { */ public static boolean checkPosition(Event event, LogPosition logPosition) { EntryPosition position = logPosition.getPostion(); - CanalEntry.Entry entry = event.getEntry(); - boolean result = position.getTimestamp().equals(entry.getHeader().getExecuteTime()); + boolean result = position.getTimestamp().equals(event.getExecuteTime()); boolean exactely = (StringUtils.isBlank(position.getJournalName()) && position.getPosition() == null); if (!exactely) {// 精确匹配 - result &= StringUtils.equals(entry.getHeader().getLogfileName(), position.getJournalName()); - result &= position.getPosition().equals(entry.getHeader().getLogfileOffset()); + result &= position.getPosition().equals(event.getPosition()); + if (result) {// short path + result &= StringUtils.equals(event.getJournalName(), position.getJournalName()); + } } return result; diff --git a/store/src/main/java/com/alibaba/otter/canal/store/memory/MemoryEventStoreWithBuffer.java b/store/src/main/java/com/alibaba/otter/canal/store/memory/MemoryEventStoreWithBuffer.java index 99995a8f..075d1524 100644 --- a/store/src/main/java/com/alibaba/otter/canal/store/memory/MemoryEventStoreWithBuffer.java +++ b/store/src/main/java/com/alibaba/otter/canal/store/memory/MemoryEventStoreWithBuffer.java @@ -278,7 +278,7 @@ public class MemoryEventStoreWithBuffer extends AbstractCanalStoreScavenge imple // 提取数据并返回 for (; next <= end; next++) { Event event = entries[getIndex(next)]; - if (ddlIsolation && isDdl(event.getEntry().getHeader().getEventType())) { + if (ddlIsolation && isDdl(event.getEventType())) { // 如果是ddl隔离,直接返回 if (entrys.size() == 0) { entrys.add(event);// 如果没有DML事件,加入当前的DDL事件 @@ -297,7 +297,7 @@ public class MemoryEventStoreWithBuffer extends AbstractCanalStoreScavenge imple for (; memsize <= maxMemSize && next <= maxAbleSequence; next++) { // 永远保证可以取出第一条的记录,避免死锁 Event event = entries[getIndex(next)]; - if (ddlIsolation && isDdl(event.getEntry().getHeader().getEventType())) { + if (ddlIsolation && isDdl(event.getEventType())) { // 如果是ddl隔离,直接返回 if (entrys.size() == 0) { entrys.add(event);// 如果没有DML事件,加入当前的DDL事件 @@ -325,9 +325,8 @@ public class MemoryEventStoreWithBuffer extends AbstractCanalStoreScavenge imple for (int i = entrys.size() - 1; i >= 0; i--) { Event event = entrys.get(i); - if (CanalEntry.EntryType.TRANSACTIONBEGIN == event.getEntry().getEntryType() - || CanalEntry.EntryType.TRANSACTIONEND == event.getEntry().getEntryType() - || isDdl(event.getEntry().getHeader().getEventType())) { + if (CanalEntry.EntryType.TRANSACTIONBEGIN == event.getEntryType() + || CanalEntry.EntryType.TRANSACTIONEND == event.getEntryType() || isDdl(event.getEventType())) { // 将事务头/尾设置可被为ack的点 range.setAck(CanalEventUtils.createPosition(event)); break; @@ -532,7 +531,7 @@ public class MemoryEventStoreWithBuffer extends AbstractCanalStoreScavenge imple private long calculateSize(Event event) { // 直接返回binlog中的事件大小 - return event.getEntry().getHeader().getEventLength(); + return event.getRawLength(); } private int getIndex(long sequcnce) { diff --git a/store/src/main/java/com/alibaba/otter/canal/store/model/Event.java b/store/src/main/java/com/alibaba/otter/canal/store/model/Event.java index c31d37f3..07e9fead 100644 --- a/store/src/main/java/com/alibaba/otter/canal/store/model/Event.java +++ b/store/src/main/java/com/alibaba/otter/canal/store/model/Event.java @@ -6,7 +6,10 @@ import org.apache.commons.lang.builder.ToStringBuilder; import com.alibaba.otter.canal.common.utils.CanalToStringStyle; import com.alibaba.otter.canal.protocol.CanalEntry; +import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; +import com.alibaba.otter.canal.protocol.CanalEntry.EventType; import com.alibaba.otter.canal.protocol.position.LogIdentity; +import com.google.protobuf.ByteString; /** * store存储数据对象 @@ -18,14 +21,32 @@ public class Event implements Serializable { private static final long serialVersionUID = 1333330351758762739L; private LogIdentity logIdentity; // 记录数据产生的来源 - private CanalEntry.Entry entry; + private ByteString rawEntry; + + private long executeTime; + private EntryType entryType; + private String journalName; + private long position; + private long serverId; + private EventType eventType; + private String gtid; + private long rawLength; public Event(){ } public Event(LogIdentity logIdentity, CanalEntry.Entry entry){ this.logIdentity = logIdentity; - this.entry = entry; + this.entryType = entry.getEntryType(); + this.executeTime = entry.getHeader().getExecuteTime(); + this.journalName = entry.getHeader().getLogfileName(); + this.position = entry.getHeader().getLogfileOffset(); + this.serverId = entry.getHeader().getServerId(); + this.gtid = entry.getHeader().getGtid(); + this.eventType = entry.getHeader().getEventType(); + // build raw + this.rawEntry = entry.toByteString(); + this.rawLength = rawEntry.size(); } public LogIdentity getLogIdentity() { @@ -36,12 +57,76 @@ public class Event implements Serializable { this.logIdentity = logIdentity; } - public CanalEntry.Entry getEntry() { - return entry; + public ByteString getRawEntry() { + return rawEntry; } - public void setEntry(CanalEntry.Entry entry) { - this.entry = entry; + public void setRawEntry(ByteString rawEntry) { + this.rawEntry = rawEntry; + } + + public long getExecuteTime() { + return executeTime; + } + + public void setExecuteTime(long executeTime) { + this.executeTime = executeTime; + } + + public EntryType getEntryType() { + return entryType; + } + + public void setEntryType(EntryType entryType) { + this.entryType = entryType; + } + + public String getJournalName() { + return journalName; + } + + public void setJournalName(String journalName) { + this.journalName = journalName; + } + + public long getPosition() { + return position; + } + + public void setPosition(long position) { + this.position = position; + } + + public long getServerId() { + return serverId; + } + + public void setServerId(long serverId) { + this.serverId = serverId; + } + + public String getGtid() { + return gtid; + } + + public void setGtid(String gtid) { + this.gtid = gtid; + } + + public long getRawLength() { + return rawLength; + } + + public void setRawLength(long rawLength) { + this.rawLength = rawLength; + } + + public EventType getEventType() { + return eventType; + } + + public void setEventType(EventType eventType) { + this.eventType = eventType; } public String toString() { diff --git a/store/src/test/java/com/alibaba/otter/cancel/store/memory/buffer/MemoryEventStoreMultiThreadTest.java b/store/src/test/java/com/alibaba/otter/cancel/store/memory/buffer/MemoryEventStoreMultiThreadTest.java index 4209e4f1..9aa216f6 100644 --- a/store/src/test/java/com/alibaba/otter/cancel/store/memory/buffer/MemoryEventStoreMultiThreadTest.java +++ b/store/src/test/java/com/alibaba/otter/cancel/store/memory/buffer/MemoryEventStoreMultiThreadTest.java @@ -161,13 +161,12 @@ public class MemoryEventStoreMultiThreadTest extends MemoryEventStoreBase { first = entrys.getPositionRange().getEnd(); for (Event event : entrys.getEvents()) { - this.result.add(event.getEntry().getHeader().getLogfileOffset()); + this.result.add(event.getPosition()); } emptyCount = 0; - System.out.println("offest : " - + entrys.getEvents().get(0).getEntry().getHeader().getLogfileOffset() - + " , count :" + entrys.getEvents().size()); + System.out.println("offest : " + entrys.getEvents().get(0).getPosition() + " , count :" + + entrys.getEvents().size()); ackCount++; if (ackCount == 1) { eventStore.cleanUntil(entrys.getPositionRange().getEnd());