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/client/pom.xml b/client/pom.xml index c736b141..038f2a9f 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -3,7 +3,7 @@ com.alibaba.otter canal - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT ../pom.xml com.alibaba.otter diff --git a/common/pom.xml b/common/pom.xml index 9c57c560..afa3372c 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -3,7 +3,7 @@ com.alibaba.otter canal - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT ../pom.xml canal.common diff --git a/dbsync/pom.xml b/dbsync/pom.xml index 1f274e82..17ec6c30 100644 --- a/dbsync/pom.xml +++ b/dbsync/pom.xml @@ -3,7 +3,7 @@ com.alibaba.otter canal - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT ../pom.xml com.alibaba.otter diff --git a/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/FileLogFetcher.java b/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/FileLogFetcher.java index 0d586cd4..cdb1f685 100644 --- a/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/FileLogFetcher.java +++ b/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/FileLogFetcher.java @@ -168,7 +168,9 @@ public final class FileLogFetcher extends LogFetcher { * @see com.taobao.tddl.dbsync.binlog.LogFetcher#close() */ public void close() throws IOException { - if (fin != null) fin.close(); + if (fin != null) { + fin.close(); + } fin = null; } 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 fdfb3ebc..bc0f3dde 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 @@ -490,7 +490,6 @@ public final class RowsLogBuffer { // t % 100); StringBuilder builder = new StringBuilder(); - builder.append(26); appendNumber4(builder, d / 10000); builder.append('-'); appendNumber2(builder, (d % 10000) / 100); @@ -615,7 +614,13 @@ public final class RowsLogBuffer { if (i32 < 0) { builder.append('-'); } - appendNumber2(builder, u32 / 10000); + + int d = u32 / 10000; + if (d > 100) { + builder.append(String.valueOf(d)); + } else { + appendNumber2(builder, d); + } builder.append(':'); appendNumber2(builder, (u32 % 10000) / 100); builder.append(':'); @@ -724,7 +729,13 @@ public final class RowsLogBuffer { if (ltime < 0) { builder.append('-'); } - appendNumber2(builder, (int) ((intpart >> 12) % (1 << 10))); + + int d = (int) ((intpart >> 12) % (1 << 10)); + if (d > 100) { + builder.append(String.valueOf(d)); + } else { + appendNumber2(builder, d); + } builder.append(':'); appendNumber2(builder, (int) ((intpart >> 6) % (1 << 6))); builder.append(':'); @@ -1134,7 +1145,7 @@ public final class RowsLogBuffer { .append(digits[(d / 100) % 10]) .append(digits[(d / 10) % 10]) .append(digits[d % 10]); - } else if (d >= 100) { + } else { builder.append('0'); appendNumber3(builder, d); } @@ -1142,9 +1153,7 @@ public final class RowsLogBuffer { private void appendNumber3(StringBuilder builder, int d) { if (d >= 100) { - builder.append(digits[d / 100]) - .append(digits[(d / 10) % 10]) - .append(digits[d % 10]); + builder.append(digits[d / 100]).append(digits[(d / 10) % 10]).append(digits[d % 10]); } else { builder.append('0'); appendNumber2(builder, d); diff --git a/deployer/pom.xml b/deployer/pom.xml index 75f05805..2de1ce1e 100644 --- a/deployer/pom.xml +++ b/deployer/pom.xml @@ -3,7 +3,7 @@ com.alibaba.otter canal - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT ../pom.xml com.alibaba.otter @@ -18,12 +18,12 @@ - - - - - - + + com.alibaba.otter + canal.prometheus + ${project.version} + runtime + diff --git a/deployer/src/main/bin/metrics_env.sh b/deployer/src/main/bin/metrics_env.sh deleted file mode 100644 index 1085eae2..00000000 --- a/deployer/src/main/bin/metrics_env.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/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/startup.sh b/deployer/src/main/bin/startup.sh index b87652c0..5655c713 100644 --- a/deployer/src/main/bin/startup.sh +++ b/deployer/src/main/bin/startup.sh @@ -94,12 +94,7 @@ then echo LOG CONFIGURATION : $logback_configurationFile echo canal conf : $canal_conf echo CLASSPATH :$CLASSPATH -# 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 & + $JAVA $JAVA_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/CanalController.java b/deployer/src/main/java/com/alibaba/otter/canal/deployer/CanalController.java index 88f6e9a3..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; @@ -303,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); @@ -379,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 { diff --git a/deployer/src/main/resources/canal.properties b/deployer/src/main/resources/canal.properties index 23ec03a1..9083477d 100644 --- a/deployer/src/main/resources/canal.properties +++ b/deployer/src/main/resources/canal.properties @@ -3,7 +3,7 @@ ################################################# canal.id= 1 canal.ip= -canal.port= 11111 +canal.port=11111 canal.zkServers= # flush data to zk canal.zookeeper.flush.period = 1000 @@ -43,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 @@ -58,6 +59,17 @@ canal.instance.parser.parallel = true ## 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 + +# rds oss binlog account +canal.instance.rds.accesskey = +canal.instance.rds.secretkey = + ################################################# ######### destinations ############# ################################################# @@ -74,7 +86,6 @@ canal.instance.tsdb.spring.xml=classpath:spring/tsdb/h2-tsdb.xml canal.instance.global.mode = spring canal.instance.global.lazy = false #canal.instance.global.manager.address = 127.0.0.1:1099 -#canal.instance.global.spring.xml = classpath:spring/local-instance.xml #canal.instance.global.spring.xml = classpath:spring/memory-instance.xml canal.instance.global.spring.xml = classpath:spring/file-instance.xml #canal.instance.global.spring.xml = classpath:spring/default-instance.xml diff --git a/deployer/src/main/resources/example/instance.properties b/deployer/src/main/resources/example/instance.properties index a3703b86..f72b65fe 100644 --- a/deployer/src/main/resources/example/instance.properties +++ b/deployer/src/main/resources/example/instance.properties @@ -1,35 +1,39 @@ ################################################# -## 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= canal.instance.master.gtid= +# rds oss binlog +canal.instance.rds.accesskey= +canal.instance.rds.secretkey= +canal.instance.rds.instanceId= + # table meta tsdb info canal.instance.tsdb.enable=true -canal.instance.tsdb.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/example/rds_instance.properties b/deployer/src/main/resources/example/rds_instance.properties deleted file mode 100644 index f04b3832..00000000 --- a/deployer/src/main/resources/example/rds_instance.properties +++ /dev/null @@ -1,32 +0,0 @@ -################################################# -# rds openapi binlog -canal.instance.rds.open.url=https://rds.aliyuncs.com/ -canal.instance.rds.open.accesskey= -canal.instance.rds.open.secretkey= -canal.instance.rds.instanceId= -canal.instance.rds.startTime= -canal.instance.rds.endTime= - -# local binlog dir -canal.instance.parser.directory=${canal.file.data.dir:../conf}/${canal.instance.destination:}/binlog -# position info -canal.instance.master.address=127.0.0.1:3306 - -# 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 - -# 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=test\\..* -# table black regex -canal.instance.filter.black.regex= -################################################# \ No newline at end of file diff --git a/deployer/src/main/resources/spring/base-instance.xml b/deployer/src/main/resources/spring/base-instance.xml new file mode 100644 index 00000000..e6c500b5 --- /dev/null +++ b/deployer/src/main/resources/spring/base-instance.xml @@ -0,0 +1,39 @@ + + + + + + + + + + classpath:canal.properties + classpath:${canal.instance.destination:}/instance.properties + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/deployer/src/main/resources/spring/default-instance.xml b/deployer/src/main/resources/spring/default-instance.xml index c4465df1..07b9109d 100644 --- a/deployer/src/main/resources/spring/default-instance.xml +++ b/deployer/src/main/resources/spring/default-instance.xml @@ -10,26 +10,7 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd" default-autowire="byName"> - - - - - - - classpath:canal.properties - classpath:${canal.instance.destination:}/instance.properties - - - - - - - - - - - - + @@ -81,9 +62,10 @@ + - + @@ -148,7 +130,7 @@ - + @@ -156,7 +138,7 @@ - + diff --git a/deployer/src/main/resources/spring/file-instance.xml b/deployer/src/main/resources/spring/file-instance.xml index 340a8158..58dd32c9 100644 --- a/deployer/src/main/resources/spring/file-instance.xml +++ b/deployer/src/main/resources/spring/file-instance.xml @@ -10,26 +10,7 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd" default-autowire="byName"> - - - - - - - classpath:canal.properties - classpath:${canal.instance.destination:}/instance.properties - - - - - - - - - - - - + @@ -67,9 +48,10 @@ + - + @@ -133,7 +115,7 @@ - + @@ -141,7 +123,7 @@ - + diff --git a/deployer/src/main/resources/spring/group-instance.xml b/deployer/src/main/resources/spring/group-instance.xml index 60d069dc..47d3ba33 100644 --- a/deployer/src/main/resources/spring/group-instance.xml +++ b/deployer/src/main/resources/spring/group-instance.xml @@ -10,26 +10,7 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd" default-autowire="byName"> - - - - - - - classpath:canal.properties - classpath:${canal.instance.destination:}/instance.properties - - - - - - - - - - - - + @@ -64,6 +45,7 @@ + @@ -75,7 +57,7 @@ - + @@ -130,7 +112,7 @@ - + @@ -138,7 +120,7 @@ - + @@ -173,7 +155,7 @@ - + @@ -228,7 +210,7 @@ - + @@ -236,7 +218,7 @@ - + diff --git a/deployer/src/main/resources/spring/local-instance.xml b/deployer/src/main/resources/spring/local-instance.xml deleted file mode 100644 index 0b2f96aa..00000000 --- a/deployer/src/main/resources/spring/local-instance.xml +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - - - - - classpath:canal.properties - classpath:${canal.instance.destination:}/instance.properties - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ 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 8fec8918..428454db 100644 --- a/deployer/src/main/resources/spring/memory-instance.xml +++ b/deployer/src/main/resources/spring/memory-instance.xml @@ -10,26 +10,7 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd" default-autowire="byName"> - - - - - - - classpath:canal.properties - classpath:${canal.instance.destination:}/instance.properties - - - - - - - - - - - - + @@ -64,9 +45,10 @@ + - + @@ -121,7 +103,7 @@ - + @@ -129,7 +111,7 @@ - + diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..311ac0b5 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,33 @@ +FROM canal/osbase:v1 + +MAINTAINER agapple (jianghang115@gmail.com) + +# install canal +COPY image/ /tmp/docker/ +COPY canal.deployer-*.tar.gz /home/admin/ + +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 && \ + + 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" ] diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile new file mode 100644 index 00000000..010b97e0 --- /dev/null +++ b/docker/base/Dockerfile @@ -0,0 +1,41 @@ +FROM centos:centos6.10 + +MAINTAINER agapple (jianghang115@gmail.com) + +env DOWNLOAD_LINK="http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.rpm" +# 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 && \ + true + +RUN \ + touch /var/lib/rpm/* && \ + wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie" "$DOWNLOAD_LINK" -O /tmp/jdk-8-linux-x64.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 && \ + yum clean all && \ + true + +CMD ["/bin/bash"] diff --git a/docker/build.sh b/docker/build.sh new file mode 100644 index 00000000..6b42e3a4 --- /dev/null +++ b/docker/build.sh @@ -0,0 +1,29 @@ +#!/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 [ "$1" == "base" ] ; then + docker build --no-cache -t canal/osbase $BASE/base +else + rm -rf $BASE/canal.*.tar.gz ; + 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 +fi diff --git a/docker/image/admin/app.sh b/docker/image/admin/app.sh new file mode 100755 index 00000000..66928ac3 --- /dev/null +++ b/docker/image/admin/app.sh @@ -0,0 +1,119 @@ +#!/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 + if [ "$destination" != "" ] && [ "$destination" != "example" ] ; then + mv /home/admin/canal-server/conf/example /home/admin/canal-server/conf/$destination + fi + 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..c48e6d9d --- /dev/null +++ b/docker/image/admin/health.sh @@ -0,0 +1,18 @@ +#!/bin/sh +metrics_port=`perl -le 'print $ENV{"canal.metrics.pull.port"}'` +if [ "$metrics_port" == "" ]; then + metrics_port="11112" +fi + +CHECK_URL="http://127.0.0.1:$metrics_port/metrics" +CHECK_POINT="canal" +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..3d5f7659 --- /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/pom.xml b/driver/pom.xml index edd24e57..648e64cc 100644 --- a/driver/pom.xml +++ b/driver/pom.xml @@ -3,7 +3,7 @@ com.alibaba.otter canal - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT ../pom.xml com.alibaba.otter 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 29b96852..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; diff --git a/example/pom.xml b/example/pom.xml index 1f60bc01..4f13d017 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -3,7 +3,7 @@ com.alibaba.otter canal - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT ../pom.xml com.alibaba.otter @@ -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 d1ddd88e..599b5da7 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 @@ -1,9 +1,9 @@ package com.alibaba.otter.canal.example; +import java.io.UnsupportedEncodingException; 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; @@ -254,7 +254,17 @@ public class AbstractCanalClientTest { protected void printColumn(List columns) { for (Column column : columns) { StringBuilder builder = new StringBuilder(); - builder.append(column.getName() + " : " + column.getValue()); + try { + if (StringUtils.containsIgnoreCase(column.getMysqlType(), "BLOB") + || StringUtils.containsIgnoreCase(column.getMysqlType(), "BINARY")) { + // get value bytes + builder.append(column.getName() + " : " + + new String(column.getValue().getBytes("ISO-8859-1"), "UTF-8")); + } else { + builder.append(column.getName() + " : " + column.getValue()); + } + } catch (UnsupportedEncodingException e) { + } builder.append(" type=" + column.getMysqlType()); if (column.getUpdated()) { builder.append(" update=" + column.getUpdated()); 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/filter/pom.xml b/filter/pom.xml index 30b53e28..f662f5ea 100644 --- a/filter/pom.xml +++ b/filter/pom.xml @@ -3,7 +3,7 @@ com.alibaba.otter canal - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT ../pom.xml com.alibaba.otter diff --git a/instance/core/pom.xml b/instance/core/pom.xml index cbfab2fd..e3812d4e 100644 --- a/instance/core/pom.xml +++ b/instance/core/pom.xml @@ -3,7 +3,7 @@ com.alibaba.otter canal - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT ../../pom.xml canal.instance.core diff --git a/instance/manager/pom.xml b/instance/manager/pom.xml index 10f01e43..79340bd0 100644 --- a/instance/manager/pom.xml +++ b/instance/manager/pom.xml @@ -3,7 +3,7 @@ com.alibaba.otter canal - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT ../../pom.xml com.alibaba.otter 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 bca5ba13..778a40aa 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,6 +6,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import com.alibaba.otter.canal.meta.FileMixedMetaManager; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,6 +28,7 @@ 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.meta.FileMixedMetaManager; import com.alibaba.otter.canal.meta.MemoryMetaManager; import com.alibaba.otter.canal.meta.PeriodMixedMetaManager; import com.alibaba.otter.canal.meta.ZooKeeperMetaManager; @@ -37,12 +39,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; @@ -120,6 +117,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 16c929ca..40df1485 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 @@ -28,8 +28,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事务大小 @@ -91,6 +93,10 @@ public class CanalParameter implements Serializable { private Boolean filterTableError = Boolean.FALSE; // 是否忽略表解析异常 private String blackFilter = null; // 匹配黑名单,忽略解析 + private Boolean tsdbEnable = Boolean.FALSE; // 是否开启tableMetaTSDB + private String tsdbJdbcUrl; + private String tsdbJdbcUserName; + private String tsdbJdbcPassword; // ================================== 兼容字段处理 private InetSocketAddress masterAddress; // 主库信息 private String masterUsername; // 帐号 @@ -243,7 +249,9 @@ public class CanalParameter implements Serializable { /** 文件存储模式 */ ZOOKEEPER, /** 混合模式,内存+文件 */ - MIXED; + MIXED, + /** 本地文件存储模式 */ + LOCAL_FILE; public boolean isMemory() { return this.equals(MetaMode.MEMORY); @@ -256,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 { @@ -390,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; } @@ -859,6 +887,38 @@ public class CanalParameter implements Serializable { this.blackFilter = blackFilter; } + public Boolean getTsdbEnable() { + return tsdbEnable; + } + + public void setTsdbEnable(Boolean tsdbEnable) { + this.tsdbEnable = tsdbEnable; + } + + public String getTsdbJdbcUrl() { + return tsdbJdbcUrl; + } + + public void setTsdbJdbcUrl(String tsdbJdbcUrl) { + this.tsdbJdbcUrl = tsdbJdbcUrl; + } + + public String getTsdbJdbcUserName() { + return tsdbJdbcUserName; + } + + public void setTsdbJdbcUserName(String tsdbJdbcUserName) { + this.tsdbJdbcUserName = tsdbJdbcUserName; + } + + public String getTsdbJdbcPassword() { + return tsdbJdbcPassword; + } + + public void setTsdbJdbcPassword(String tsdbJdbcPassword) { + this.tsdbJdbcPassword = tsdbJdbcPassword; + } + public String toString() { return ToStringBuilder.reflectionToString(this, CanalToStringStyle.DEFAULT_STYLE); } diff --git a/instance/pom.xml b/instance/pom.xml index aeec17cb..f45baee1 100644 --- a/instance/pom.xml +++ b/instance/pom.xml @@ -3,7 +3,7 @@ com.alibaba.otter canal - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT ../pom.xml com.alibaba.otter diff --git a/instance/spring/pom.xml b/instance/spring/pom.xml index 6a8f172a..116dee77 100644 --- a/instance/spring/pom.xml +++ b/instance/spring/pom.xml @@ -3,7 +3,7 @@ com.alibaba.otter canal - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT ../../pom.xml com.alibaba.otter diff --git a/kafka-client/pom.xml b/kafka-client/pom.xml index d814be52..5444af5d 100644 --- a/kafka-client/pom.xml +++ b/kafka-client/pom.xml @@ -6,7 +6,7 @@ canal com.alibaba.otter - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT ../pom.xml com.alibaba.otter @@ -108,4 +108,4 @@ - \ No newline at end of file + 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 index 1cb3daba..70f2fc06 100644 --- 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 @@ -29,7 +29,9 @@ public class MessageDeserializer implements Deserializer { @Override public Message deserialize(String topic, byte[] data) { try { - if (data == null) return null; + if (data == null) { + return null; + } else { CanalPacket.Packet p = CanalPacket.Packet.parseFrom(data); switch (p.getType()) { 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 index 3eab85ed..7bbbabd7 100644 --- 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 @@ -8,8 +8,8 @@ package com.alibaba.otter.canal.kafka.client.running; */ public class ClientRunningData { - private String groupId; - private String address; + private String groupId; + private String address; private boolean active = true; public String getGroupId() { 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 index 3bdbfe6e..0f61211e 100644 --- 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 @@ -1,12 +1,11 @@ package com.alibaba.otter.canal.kafka.client.running; -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; +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; @@ -17,11 +16,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; -import java.text.MessageFormat; -import java.util.Random; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; +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状态信息 @@ -31,13 +33,18 @@ import java.util.concurrent.TimeUnit; */ 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_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_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_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 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); @@ -47,21 +54,21 @@ public class ClientRunningMonitor extends AbstractCanalLifeCycle { 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 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 ScheduledExecutorService delayExector = Executors.newScheduledThreadPool(1); + private ClientRunningListener listener; + private int delayTime = 5; - private static Integer virtualPort; + private static Integer virtualPort; - public ClientRunningMonitor() { + public ClientRunningMonitor(){ if (virtualPort == null) { Random rand = new Random(); virtualPort = rand.nextInt(9000) + 1000; @@ -108,7 +115,6 @@ public class ClientRunningMonitor extends AbstractCanalLifeCycle { } - public void start() { super.start(); @@ -123,7 +129,7 @@ public class ClientRunningMonitor extends AbstractCanalLifeCycle { String path = getTopicClientRunning(this.topic, clientData.getGroupId()); zkClient.unsubscribeDataChanges(path, dataListener); releaseRunning(); // 尝试一下release - //Fix issue #697 + // Fix issue #697 if (delayExector != null) { delayExector.shutdown(); } @@ -159,13 +165,12 @@ public class ClientRunningMonitor extends AbstractCanalLifeCycle { } } } catch (ZkNoNodeException e) { - zkClient.createPersistent(getClientIdNodePath(this.topic, clientData.getGroupId()), - true); // 尝试创建父节点 + 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); + topic), + t); // 出现任何异常尝试release releaseRunning(); throw new CanalClientException("something goes wrong in initRunning method. ", t); @@ -187,7 +192,8 @@ public class ClientRunningMonitor extends AbstractCanalLifeCycle { */ public boolean check() { String path = getTopicClientRunning(this.topic, clientData.getGroupId()); - //ZookeeperPathUtils.getDestinationClientRunning(this.destination, clientData.getClientId()); + // ZookeeperPathUtils.getDestinationClientRunning(this.destination, + // clientData.getClientId()); try { byte[] bytes = zkClient.readData(path); ClientRunningData eventData = JsonUtils.unmarshalFromByte(bytes, ClientRunningData.class); @@ -196,8 +202,8 @@ public class ClientRunningMonitor extends AbstractCanalLifeCycle { boolean result = isMine(activeData.getAddress()); if (!result) { logger.warn("canal is running in [{}] , but not in [{}]", - activeData.getAddress(), - clientData.getAddress()); + activeData.getAddress(), + clientData.getAddress()); } return result; } catch (ZkNoNodeException e) { @@ -235,7 +241,7 @@ public class ClientRunningMonitor extends AbstractCanalLifeCycle { if (listener != null) { // 触发回调 listener.processActiveEnter(); - this.clientData.setAddress(/*address*/AddressUtils.getHostIp() + ":" + virtualPort); + this.clientData.setAddress(/* address */AddressUtils.getHostIp() + ":" + virtualPort); String path = getTopicClientRunning(this.topic, clientData.getGroupId()); // 序列化 diff --git a/kafka/pom.xml b/kafka/pom.xml index 8d3b35d7..d46a2d03 100644 --- a/kafka/pom.xml +++ b/kafka/pom.xml @@ -6,7 +6,7 @@ canal com.alibaba.otter - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT ../pom.xml com.alibaba.otter @@ -137,4 +137,4 @@ - \ No newline at end of file + 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 index e0b2d1d8..573f0eac 100644 --- a/kafka/src/main/java/com/alibaba/otter/canal/kafka/CanalServerStarter.java +++ b/kafka/src/main/java/com/alibaba/otter/canal/kafka/CanalServerStarter.java @@ -17,9 +17,9 @@ import com.alibaba.otter.canal.deployer.CanalController; */ 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; + 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 { 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 index 3318a89e..4543aac1 100644 --- 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 @@ -3,7 +3,6 @@ package com.alibaba.otter.canal.kafka.producer; import java.io.IOException; import java.util.Properties; -import com.google.protobuf.ByteString; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.Producer; import org.apache.kafka.clients.producer.ProducerRecord; @@ -12,7 +11,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.alibaba.otter.canal.kafka.producer.KafkaProperties.Topic; -import com.alibaba.otter.canal.protocol.CanalEntry; import com.alibaba.otter.canal.protocol.Message; /** @@ -52,31 +50,32 @@ public class CanalKafkaProducer { } public void send(Topic topic, Message message) throws IOException { - 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; - } + // 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); 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 index 0ff018c2..0eedfa7a 100644 --- 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 @@ -52,7 +52,10 @@ public class CanalKafkaStarter { // 初始化 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(); @@ -118,7 +121,7 @@ public class CanalKafkaStarter { Message message = server.getWithoutAck(clientIdentity, kafkaProperties.getCanalBatchSize()); // 获取指定数量的数据 long batchId = message.getId(); try { - int size = message.getEntries().size(); + int size = message.isRaw() ? message.getRawEntries().size() : message.getEntries().size(); if (batchId != -1 && size != 0) { if (!StringUtils.isEmpty(destination.getTopic())) { Topic topic = new Topic(); 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 index 0b346137..8e193aac 100644 --- 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 @@ -13,15 +13,15 @@ import java.util.Set; */ 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 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 int canalBatchSize = 5; - - private List canalDestinations = new ArrayList(); + private List canalDestinations = new ArrayList(); public static class CanalDestination { @@ -158,4 +158,13 @@ public class KafkaProperties { 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 index 17fca117..02336004 100644 --- 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 @@ -1,13 +1,19 @@ package com.alibaba.otter.canal.kafka.producer; -import com.alibaba.otter.canal.protocol.CanalEntry; -import com.alibaba.otter.canal.protocol.CanalPacket; -import com.alibaba.otter.canal.protocol.Message; +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 java.util.Map; +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类的序列化 @@ -25,20 +31,53 @@ public class MessageSerializer implements Serializer { public byte[] serialize(String topic, Message data) { try { if (data != null) { - CanalPacket.Messages.Builder messageBuilder = CanalPacket.Messages.newBuilder(); if (data.getId() != -1) { if (data.isRaw() && !CollectionUtils.isEmpty(data.getRawEntries())) { - messageBuilder.addAllMessages(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(); } } - 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[] "); diff --git a/kafka/src/main/resources/kafka.yml b/kafka/src/main/resources/kafka.yml index ab214319..d6ccc51a 100644 --- a/kafka/src/main/resources/kafka.yml +++ b/kafka/src/main/resources/kafka.yml @@ -5,6 +5,7 @@ lingerMs: 1 bufferMemory: 33554432 # canal的批次大小,单位 k canalBatchSize: 50 +filterTransactionEntry: true canalDestinations: - canalDestination: example diff --git a/meta/pom.xml b/meta/pom.xml index 6192d92d..93c4ad7b 100644 --- a/meta/pom.xml +++ b/meta/pom.xml @@ -3,7 +3,7 @@ com.alibaba.otter canal - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT ../pom.xml com.alibaba.otter diff --git a/parse/pom.xml b/parse/pom.xml index 994d06f0..fb93fc99 100644 --- a/parse/pom.xml +++ b/parse/pom.xml @@ -3,7 +3,7 @@ com.alibaba.otter canal - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT ../pom.xml canal.parse diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/exception/PositionNotFoundException.java b/parse/src/main/java/com/alibaba/otter/canal/parse/exception/PositionNotFoundException.java new file mode 100644 index 00000000..d5552a9f --- /dev/null +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/exception/PositionNotFoundException.java @@ -0,0 +1,30 @@ +package com.alibaba.otter.canal.parse.exception; + +/** + * @author chengjin.lyf on 2018/7/20 下午2:54 + * @since 1.0.25 + */ +public class PositionNotFoundException extends CanalParseException { + + private static final long serialVersionUID = -7382448928116244017L; + + public PositionNotFoundException(String errorCode) { + super(errorCode); + } + + public PositionNotFoundException(String errorCode, Throwable cause) { + super(errorCode, cause); + } + + public PositionNotFoundException(String errorCode, String errorDesc) { + super(errorCode, errorDesc); + } + + public PositionNotFoundException(String errorCode, String errorDesc, Throwable cause) { + super(errorCode, errorDesc, cause); + } + + public PositionNotFoundException(Throwable cause) { + super(cause); + } +} diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/exception/ServerIdNotMatchException.java b/parse/src/main/java/com/alibaba/otter/canal/parse/exception/ServerIdNotMatchException.java new file mode 100644 index 00000000..05baee02 --- /dev/null +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/exception/ServerIdNotMatchException.java @@ -0,0 +1,32 @@ +package com.alibaba.otter.canal.parse.exception; + +import com.alibaba.otter.canal.common.CanalException; + +/** + * @author chengjin.lyf on 2018/8/8 下午1:07 + * @since 1.0.25 + */ +public class ServerIdNotMatchException extends CanalException{ + + private static final long serialVersionUID = -6124989280379293953L; + + public ServerIdNotMatchException(String errorCode) { + super(errorCode); + } + + public ServerIdNotMatchException(String errorCode, Throwable cause) { + super(errorCode, cause); + } + + public ServerIdNotMatchException(String errorCode, String errorDesc) { + super(errorCode, errorDesc); + } + + public ServerIdNotMatchException(String errorCode, String errorDesc, Throwable cause) { + super(errorCode, errorDesc, cause); + } + + public ServerIdNotMatchException(Throwable cause) { + super(cause); + } +} 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 7f7d39ac..fcae1317 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 @@ -21,6 +21,7 @@ import com.alibaba.otter.canal.filter.CanalEventFilter; 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.exception.PositionNotFoundException; import com.alibaba.otter.canal.parse.exception.TableIdNotFoundException; import com.alibaba.otter.canal.parse.inbound.EventTransactionBuffer.TransactionFlushCallback; import com.alibaba.otter.canal.parse.index.CanalLogPositionManager; @@ -94,6 +95,8 @@ public abstract class AbstractEventParser extends AbstractCanalLifeCycle .availableProcessors() * 60 / 100; // 60%的能力跑解析,剩余部分处理网络 protected int parallelBufferSize = 256; // 必须为2的幂 protected MultiStageCoprocessor multiStageCoprocessor; + protected ParserExceptionHandler parserExceptionHandler; + protected long serverId; protected abstract BinlogParser buildParser(); @@ -170,11 +173,16 @@ public abstract class AbstractEventParser extends AbstractCanalLifeCycle preDump(erosaConnection); erosaConnection.connect();// 链接 + + long queryServerId = erosaConnection.queryServerId(); + if (queryServerId != 0) { + serverId = queryServerId; + } // 4. 获取最后的位置信息 EntryPosition position = findStartPosition(erosaConnection); final EntryPosition startPosition = position; if (startPosition == null) { - throw new CanalParseException("can't find start position for " + destination); + throw new PositionNotFoundException("can't find start position for " + destination); } if (!processTableMeta(startPosition)) { @@ -277,6 +285,9 @@ public abstract class AbstractEventParser extends AbstractCanalLifeCycle runningInfo.getAddress().toString()), e); sendAlarm(destination, ExceptionUtils.getFullStackTrace(e)); } + if (parserExceptionHandler != null) { + parserExceptionHandler.handle(e); + } } finally { // 重新置为中断状态 Thread.interrupted(); @@ -426,7 +437,7 @@ public abstract class AbstractEventParser extends AbstractCanalLifeCycle return logPosition; } - protected void processSinkError(Throwable e, LogPosition lastPosition, String startBinlogFile, long startPosition) { + protected void processSinkError(Throwable e, LogPosition lastPosition, String startBinlogFile, Long startPosition) { if (lastPosition != null) { logger.warn(String.format("ERROR ## parse this event has an error , last position : [%s]", lastPosition.getPostion()), @@ -615,4 +626,20 @@ public abstract class AbstractEventParser extends AbstractCanalLifeCycle this.parallelBufferSize = parallelBufferSize; } + public ParserExceptionHandler getParserExceptionHandler() { + return parserExceptionHandler; + } + + public void setParserExceptionHandler(ParserExceptionHandler parserExceptionHandler) { + this.parserExceptionHandler = parserExceptionHandler; + } + + public long getServerId() { + return serverId; + } + + public void setServerId(long serverId) { + this.serverId = serverId; + } + } 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 6beb4a9e..5355e2e1 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 @@ -40,4 +40,6 @@ public interface ErosaConnection { public void dump(GTIDSet gtidSet, MultiStageCoprocessor coprocessor) throws IOException; ErosaConnection fork(); + + public long queryServerId() throws IOException; } diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/EventTransactionBuffer.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/EventTransactionBuffer.java index c3c7150f..8034d078 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/EventTransactionBuffer.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/EventTransactionBuffer.java @@ -80,6 +80,11 @@ public class EventTransactionBuffer extends AbstractCanalLifeCycle { flush(); } break; + case HEARTBEAT: + // master过来的heartbeat,说明binlog已经读完了,是idle状态 + put(entry); + flush(); + break; default: break; } 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 index 96e063e9..4ab68e39 100644 --- 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 @@ -2,6 +2,7 @@ package com.alibaba.otter.canal.parse.inbound; import com.alibaba.otter.canal.common.CanalLifeCycle; import com.taobao.tddl.dbsync.binlog.LogBuffer; +import com.taobao.tddl.dbsync.binlog.LogEvent; /** * 针对解析器提供一个多阶段协同的处理 @@ -23,7 +24,7 @@ public interface MultiStageCoprocessor extends CanalLifeCycle { */ public boolean publish(LogBuffer buffer); - public boolean publish(LogBuffer buffer, String binlogFileName); + public boolean publish(LogEvent event); public void reset(); } diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/ParserExceptionHandler.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/ParserExceptionHandler.java new file mode 100644 index 00000000..d0face01 --- /dev/null +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/ParserExceptionHandler.java @@ -0,0 +1,9 @@ +package com.alibaba.otter.canal.parse.inbound; + +/** + * @author chengjin.lyf on 2018/7/20 下午3:55 + * @since 1.0.25 + */ +public interface ParserExceptionHandler { + void handle(Throwable e); +} 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 8188cf83..941f5ebc 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 @@ -1,39 +1,45 @@ package com.alibaba.otter.canal.parse.inbound.mysql; import java.nio.charset.Charset; +import java.util.concurrent.atomic.AtomicLong; import org.slf4j.Logger; 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.DefaultTableMetaTSDBFactory; import com.alibaba.otter.canal.parse.inbound.mysql.tsdb.TableMetaTSDB; -import com.alibaba.otter.canal.parse.inbound.mysql.tsdb.TableMetaTSDBBuilder; +import com.alibaba.otter.canal.parse.inbound.mysql.tsdb.TableMetaTSDBFactory; import com.alibaba.otter.canal.protocol.position.EntryPosition; public abstract class AbstractMysqlEventParser extends AbstractEventParser { - protected final Logger logger = LoggerFactory.getLogger(this.getClass()); - protected static final long BINLOG_START_OFFEST = 4L; + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + protected static final long BINLOG_START_OFFEST = 4L; + + protected TableMetaTSDBFactory tableMetaTSDBFactory = new DefaultTableMetaTSDBFactory(); + protected boolean enableTsdb = false; + protected String tsdbSpringXml; + protected TableMetaTSDB tableMetaTSDB; - protected boolean enableTsdb = false; - protected String tsdbSpringXml; - protected TableMetaTSDB tableMetaTSDB; // 编码信息 - protected byte connectionCharsetNumber = (byte) 33; - protected Charset connectionCharset = Charset.forName("UTF-8"); - protected boolean filterQueryDcl = false; - protected boolean filterQueryDml = false; - protected boolean filterQueryDdl = false; - protected boolean filterRows = false; - protected boolean filterTableError = false; - protected boolean useDruidDdlFilter = true; + protected byte connectionCharsetNumber = (byte) 33; + protected Charset connectionCharset = Charset.forName("UTF-8"); + protected boolean filterQueryDcl = false; + protected boolean filterQueryDml = false; + protected boolean filterQueryDdl = false; + protected boolean filterRows = false; + protected boolean filterTableError = false; + protected boolean useDruidDdlFilter = true; + private final AtomicLong eventsPublishBlockingTime = new AtomicLong(0L); protected BinlogParser buildParser() { LogEventConvert convert = new LogEventConvert(); @@ -91,8 +97,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 = tableMetaTSDBFactory.build(destination, tsdbSpringXml); + } finally { + System.setProperty("canal.instance.destination", ""); + } + } } } @@ -101,7 +115,7 @@ public abstract class AbstractMysqlEventParser extends AbstractEventParser { public void stop() throws CanalParseException { if (enableTsdb) { - TableMetaTSDBBuilder.destory(destination); + tableMetaTSDBFactory.destory(destination); tableMetaTSDB = null; } @@ -119,11 +133,13 @@ public abstract class AbstractMysqlEventParser extends AbstractEventParser { } protected MultiStageCoprocessor buildMultiStageCoprocessor() { - return new MysqlMultiStageCoprocessor(parallelBufferSize, + MysqlMultiStageCoprocessor mysqlMultiStageCoprocessor = new MysqlMultiStageCoprocessor(parallelBufferSize, parallelThreadSize, (LogEventConvert) binlogParser, transactionBuffer, destination); + mysqlMultiStageCoprocessor.setEventsPublishBlockingTime(eventsPublishBlockingTime); + return mysqlMultiStageCoprocessor; } // ============================ setter / getter ========================= @@ -173,7 +189,7 @@ public abstract class AbstractMysqlEventParser extends AbstractEventParser { if (this.enableTsdb) { if (tableMetaTSDB == null) { // 初始化 - tableMetaTSDB = TableMetaTSDBBuilder.build(destination, tsdbSpringXml); + tableMetaTSDB = tableMetaTSDBFactory.build(destination, tsdbSpringXml); } } } @@ -183,9 +199,17 @@ public abstract class AbstractMysqlEventParser extends AbstractEventParser { if (this.enableTsdb) { if (tableMetaTSDB == null) { // 初始化 - tableMetaTSDB = TableMetaTSDBBuilder.build(destination, tsdbSpringXml); + tableMetaTSDB = tableMetaTSDBFactory.build(destination, tsdbSpringXml); } } } + public void setTableMetaTSDBFactory(TableMetaTSDBFactory tableMetaTSDBFactory) { + this.tableMetaTSDBFactory = tableMetaTSDBFactory; + } + + public AtomicLong getEventsPublishBlockingTime() { + return this.eventsPublishBlockingTime; + } + } 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 6c59465b..5cf5bb9d 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 @@ -10,18 +10,18 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.alibaba.otter.canal.parse.driver.mysql.packets.GTIDSet; +import com.alibaba.otter.canal.parse.exception.CanalParseException; +import com.alibaba.otter.canal.parse.exception.ServerIdNotMatchException; 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; import com.taobao.tddl.dbsync.binlog.LogPosition; import com.taobao.tddl.dbsync.binlog.event.QueryLogEvent; -import com.taobao.tddl.dbsync.binlog.event.RotateLogEvent; /** * local bin log connection (not real connection) @@ -36,6 +36,8 @@ public class LocalBinLogConnection implements ErosaConnection { private String directory; private int bufferSize = 16 * 1024; private boolean running = false; + private long serverId; + private FileParserListener parserListener; public LocalBinLogConnection(){ } @@ -88,14 +90,14 @@ public class LocalBinLogConnection implements ErosaConnection { while (running) { boolean needContinue = true; LogEvent event = null; - // 处理一下binlog文件名 - event = new RotateLogEvent(context.getLogPosition().getFileName(), 4); - func.sink(event); while (fetcher.fetch()) { event = decoder.decode(fetcher, context); if (event == null) { continue; } + if (serverId != 0 && event.getServerId() != serverId) { + throw new ServerIdNotMatchException("unexpected serverId " + serverId + " in binlog file !"); + } if (!func.sink(event)) { needContinue = false; @@ -103,8 +105,9 @@ public class LocalBinLogConnection implements ErosaConnection { } } + fetcher.close(); // 关闭上一个文件 + parserFinish(current.getName()); if (needContinue) {// 读取下一个 - fetcher.close(); // 关闭上一个文件 File nextFile; if (needWait) { @@ -160,6 +163,10 @@ public class LocalBinLogConnection implements ErosaConnection { while (fetcher.fetch()) { LogEvent event = decoder.decode(fetcher, context); if (event != null) { + if (serverId != 0 && event.getServerId() != serverId) { + throw new ServerIdNotMatchException("unexpected serverId " + serverId + " in binlog file !"); + } + if (event.getWhen() > timestampSeconds) { break; } @@ -176,6 +183,9 @@ public class LocalBinLogConnection implements ErosaConnection { } else if (LogEvent.XID_EVENT == event.getHeader().getType()) { lastXidLogFilename = current.getName(); lastXidLogFileOffset = event.getLogPos(); + } else if (LogEvent.FORMAT_DESCRIPTION_EVENT == event.getHeader().getType()) { + lastXidLogFilename = current.getName(); + lastXidLogFileOffset = event.getLogPos(); } } } @@ -212,25 +222,37 @@ public class LocalBinLogConnection implements ErosaConnection { @Override public void dump(String binlogfilename, Long binlogPosition, MultiStageCoprocessor coprocessor) throws IOException { File current = new File(directory, binlogfilename); + if (!current.exists()) { + throw new CanalParseException("binlog:" + binlogfilename + " is not found"); + } FileLogFetcher fetcher = new FileLogFetcher(bufferSize); + LogDecoder decoder = new LogDecoder(LogEvent.UNKNOWN_EVENT, LogEvent.ENUM_END_EVENT); + LogContext context = new LogContext(); try { fetcher.open(current, binlogPosition); + context.setLogPosition(new LogPosition(binlogfilename, binlogPosition)); while (running) { boolean needContinue = true; + LogEvent event = null; while (fetcher.fetch()) { - LogBuffer buffer = fetcher.duplicate(); - fetcher.consume(fetcher.limit()); - // set filename - if (!coprocessor.publish(buffer, binlogfilename)) { + event = decoder.decode(fetcher, context); + if (event == null) { + continue; + } + if (serverId != 0 && event.getServerId() != serverId) { + throw new ServerIdNotMatchException("unexpected serverId " + serverId + " in binlog file !"); + } + + if (!coprocessor.publish(event)) { needContinue = false; break; } } + fetcher.close(); // 关闭上一个文件 + parserFinish(binlogfilename); if (needContinue) {// 读取下一个 - fetcher.close(); // 关闭上一个文件 - File nextFile; if (needWait) { nextFile = binlogs.waitForNextFile(current); @@ -258,6 +280,12 @@ public class LocalBinLogConnection implements ErosaConnection { } } + private void parserFinish(String fileName) { + if (parserListener != null) { + parserListener.onFinish(fileName); + } + } + @Override public void dump(long timestampMills, MultiStageCoprocessor coprocessor) throws IOException { List currentBinlogs = binlogs.currentBinlogs(); @@ -286,6 +314,10 @@ public class LocalBinLogConnection implements ErosaConnection { while (fetcher.fetch()) { LogEvent event = decoder.decode(fetcher, context); if (event != null) { + if (serverId != 0 && event.getServerId() != serverId) { + throw new ServerIdNotMatchException("unexpected serverId " + serverId + " in binlog file !"); + } + if (event.getWhen() > timestampSeconds) { break; } @@ -302,6 +334,9 @@ public class LocalBinLogConnection implements ErosaConnection { } else if (LogEvent.XID_EVENT == event.getHeader().getType()) { lastXidLogFilename = current.getName(); lastXidLogFileOffset = event.getLogPos(); + } else if (LogEvent.FORMAT_DESCRIPTION_EVENT == event.getHeader().getType()) { + lastXidLogFilename = current.getName(); + lastXidLogFileOffset = event.getLogPos(); } } } @@ -344,6 +379,11 @@ public class LocalBinLogConnection implements ErosaConnection { return connection; } + @Override + public long queryServerId() { + return 0; + } + public boolean isNeedWait() { return needWait; } @@ -368,4 +408,21 @@ public class LocalBinLogConnection implements ErosaConnection { this.bufferSize = bufferSize; } + public long getServerId() { + return serverId; + } + + public void setServerId(long serverId) { + this.serverId = serverId; + } + + public void setParserListener(FileParserListener parserListener) { + this.parserListener = parserListener; + } + + public interface FileParserListener { + + void onFinish(String fileName); + } + } 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 d01a210e..eb3c0e31 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 @@ -7,8 +7,10 @@ import java.net.InetSocketAddress; import java.nio.charset.Charset; import java.util.List; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.math.NumberUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,6 +51,8 @@ public class MysqlConnection implements ErosaConnection { private AuthenticationInfo authInfo; protected int connTimeout = 5 * 1000; // 5秒 protected int soTimeout = 60 * 60 * 1000; // 1小时 + // dump binlog bytes, 暂不包括meta与TSDB + private AtomicLong receivedBinlogBytes; public MysqlConnection(){ } @@ -124,6 +128,7 @@ public class MysqlConnection implements ErosaConnection { decoder.handle(LogEvent.XID_EVENT); LogContext context = new LogContext(); while (fetcher.fetch()) { + accumulateReceivedBytes(fetcher.limit()); LogEvent event = null; event = decoder.decode(fetcher, context); @@ -146,6 +151,7 @@ public class MysqlConnection implements ErosaConnection { LogDecoder decoder = new LogDecoder(LogEvent.UNKNOWN_EVENT, LogEvent.ENUM_END_EVENT); LogContext context = new LogContext(); while (fetcher.fetch()) { + accumulateReceivedBytes(fetcher.limit()); LogEvent event = null; event = decoder.decode(fetcher, context); @@ -174,6 +180,7 @@ public class MysqlConnection implements ErosaConnection { LogDecoder decoder = new LogDecoder(LogEvent.UNKNOWN_EVENT, LogEvent.ENUM_END_EVENT); LogContext context = new LogContext(); while (fetcher.fetch()) { + accumulateReceivedBytes(fetcher.limit()); LogEvent event = null; event = decoder.decode(fetcher, context); @@ -204,6 +211,7 @@ public class MysqlConnection implements ErosaConnection { try { fetcher.start(connector.getChannel()); while (fetcher.fetch()) { + accumulateReceivedBytes(fetcher.limit()); LogBuffer buffer = fetcher.duplicate(); fetcher.consume(fetcher.limit()); if (!coprocessor.publish(buffer)) { @@ -230,6 +238,7 @@ public class MysqlConnection implements ErosaConnection { try { fetcher.start(connector.getChannel()); while (fetcher.fetch()) { + accumulateReceivedBytes(fetcher.limit()); LogBuffer buffer = fetcher.duplicate(); fetcher.consume(fetcher.limit()); if (!coprocessor.publish(buffer)) { @@ -324,6 +333,16 @@ public class MysqlConnection implements ErosaConnection { return connection; } + @Override + public long queryServerId() throws IOException { + ResultSetPacket resultSetPacket = query("show variables like 'server_id'"); + List fieldValues = resultSetPacket.getFieldValues(); + if (fieldValues == null || fieldValues.size() != 2) { + return 0; + } + return NumberUtils.toLong(fieldValues.get(1)); + } + // ====================== help method ==================== /** @@ -334,7 +353,6 @@ public class MysqlConnection implements ErosaConnection { *

  • net_read_timeout
  • * * - * @param channel * @throws IOException */ private void updateSettings() throws IOException { @@ -453,6 +471,12 @@ public class MysqlConnection implements ErosaConnection { } } + private void accumulateReceivedBytes(long x) { + if (receivedBinlogBytes != null) { + receivedBinlogBytes.addAndGet(x); + } + } + public static enum BinlogFormat { STATEMENT("STATEMENT"), ROW("ROW"), MIXED("MIXED"); @@ -592,4 +616,8 @@ public class MysqlConnection implements ErosaConnection { this.authInfo = authInfo; } + public void setReceivedBinlogBytes(AtomicLong receivedBinlogBytes) { + this.receivedBinlogBytes = receivedBinlogBytes; + } + } 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 6c2b9d4d..b585d9ab 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 @@ -47,30 +47,32 @@ import com.taobao.tddl.dbsync.binlog.LogEvent; */ public class MysqlEventParser extends AbstractMysqlEventParser implements CanalEventParser, CanalHASwitchable { - private CanalHAController haController = null; + private CanalHAController haController = null; - private int defaultConnectionTimeoutInSeconds = 30; // sotimeout - private int receiveBufferSize = 64 * 1024; - private int sendBufferSize = 64 * 1024; + private int defaultConnectionTimeoutInSeconds = 30; // sotimeout + private int receiveBufferSize = 64 * 1024; + private int sendBufferSize = 64 * 1024; // 数据库信息 - private AuthenticationInfo masterInfo; // 主库 - private AuthenticationInfo standbyInfo; // 备库 + protected AuthenticationInfo masterInfo; // 主库 + protected AuthenticationInfo standbyInfo; // 备库 // binlog信息 - private EntryPosition masterPosition; - private EntryPosition standbyPosition; - private long slaveId; // 链接到mysql的slave + protected EntryPosition masterPosition; + protected EntryPosition standbyPosition; + private long slaveId; // 链接到mysql的slave // 心跳检查信息 - private String detectingSQL; // 心跳sql - private MysqlConnection metaConnection; // 查询meta信息的链接 - private TableMetaCache tableMetaCache; // 对应meta - // cache - private int fallbackIntervalInSeconds = 60; // 切换回退时间 - private BinlogFormat[] supportBinlogFormats; // 支持的binlogFormat,如果设置会执行强校验 - private BinlogImage[] supportBinlogImages; // 支持的binlogImage,如果设置会执行强校验 + private String detectingSQL; // 心跳sql + private MysqlConnection metaConnection; // 查询meta信息的链接 + private TableMetaCache tableMetaCache; // 对应meta + private int fallbackIntervalInSeconds = 60; // 切换回退时间 + private BinlogFormat[] supportBinlogFormats; // 支持的binlogFormat,如果设置会执行强校验 + private BinlogImage[] supportBinlogImages; // 支持的binlogImage,如果设置会执行强校验 // update by yishun.chen,特殊异常处理参数 - private int dumpErrorCount = 0; // binlogDump失败异常计数 - private int dumpErrorCountThreshold = 2; // binlogDump失败异常计数阀值 + private int dumpErrorCount = 0; // binlogDump失败异常计数 + private int dumpErrorCountThreshold = 2; // binlogDump失败异常计数阀值 + + // instance received binlog bytes + private final AtomicLong receivedBinlogBytes = new AtomicLong(0L); protected ErosaConnection buildErosaConnection() { return buildMysqlConnection(this.runningInfo); @@ -314,6 +316,7 @@ public class MysqlEventParser extends AbstractMysqlEventParser implements CanalE connection.getConnector().setSendBufferSize(sendBufferSize); connection.getConnector().setSoTimeout(defaultConnectionTimeoutInSeconds * 1000); connection.setCharset(connectionCharset); + connection.setReceivedBinlogBytes(receivedBinlogBytes); // 随机生成slaveId if (this.slaveId <= 0) { this.slaveId = generateUniqueServerId(); @@ -512,7 +515,7 @@ public class MysqlEventParser extends AbstractMysqlEventParser implements CanalE private Long findTransactionBeginPosition(ErosaConnection mysqlConnection, final EntryPosition entryPosition) throws IOException { // 针对开始的第一条为非Begin记录,需要从该binlog扫描 - final AtomicLong preTransactionStartPosition = new AtomicLong(0L); + final java.util.concurrent.atomic.AtomicLong preTransactionStartPosition = new java.util.concurrent.atomic.AtomicLong(0L); mysqlConnection.reconnect(); mysqlConnection.seek(entryPosition.getJournalName(), 4L, new SinkFunction() { @@ -643,6 +646,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); @@ -750,16 +756,9 @@ public class MysqlEventParser extends AbstractMysqlEventParser implements CanalE Long logposTimestamp = entry.getHeader().getExecuteTime(); Long serverId = entry.getHeader().getServerId(); - if (CanalEntry.EntryType.TRANSACTIONBEGIN.equals(entry.getEntryType()) - || CanalEntry.EntryType.TRANSACTIONEND.equals(entry.getEntryType())) { - if (logger.isDebugEnabled()) { - logger.debug("compare exit condition:{},{},{}, startTimestamp={}...", new Object[] { - logfilename, logfileoffset, logposTimestamp, startTimestamp }); - } - // 事务头和尾寻找第一条记录时间戳,如果最小的一条记录都不满足条件,可直接退出 - if (logposTimestamp >= startTimestamp) { - return false; - } + // 如果最小的一条记录都不满足条件,可直接退出 + if (logposTimestamp >= startTimestamp) { + return false; } if (StringUtils.equals(endPosition.getJournalName(), logfilename) @@ -908,4 +907,8 @@ public class MysqlEventParser extends AbstractMysqlEventParser implements CanalE this.dumpErrorCountThreshold = dumpErrorCountThreshold; } + public AtomicLong getReceivedBinlogBytes() { + return this.receivedBinlogBytes; + } + } 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 index 281a05f2..63b0f0eb 100644 --- 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 @@ -2,10 +2,9 @@ package com.alibaba.otter.canal.parse.inbound.mysql; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicLong; 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; @@ -31,7 +30,6 @@ 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; @@ -52,6 +50,7 @@ import com.taobao.tddl.dbsync.binlog.event.WriteRowsLogEvent; */ public class MysqlMultiStageCoprocessor extends AbstractCanalLifeCycle implements MultiStageCoprocessor { + private static final int maxFullTimes = 10; private LogEventConvert logEventConvert; private EventTransactionBuffer transactionBuffer; private ErosaConnection connection; @@ -63,6 +62,7 @@ public class MysqlMultiStageCoprocessor extends AbstractCanalLifeCycle implement private ExecutorService stageExecutor; private String destination; private volatile CanalParseException exception; + private AtomicLong eventsPublishBlockingTime; public MysqlMultiStageCoprocessor(int ringBufferSize, int parserThreadCount, LogEventConvert logEventConvert, EventTransactionBuffer transactionBuffer, String destination){ @@ -138,14 +138,18 @@ public class MysqlMultiStageCoprocessor extends AbstractCanalLifeCycle implement super.stop(); } + public boolean publish(LogBuffer buffer) { + return this.publish(buffer, null); + } + /** * 网络数据投递 */ - public boolean publish(LogBuffer buffer) { - return publish(buffer, null); + public boolean publish(LogEvent event) { + return this.publish(null, event); } - public boolean publish(LogBuffer buffer, String binlogFileName) { + private boolean publish(LogBuffer buffer, LogEvent event) { if (!isStart()) { if (exception != null) { throw exception; @@ -161,25 +165,51 @@ public class MysqlMultiStageCoprocessor extends AbstractCanalLifeCycle implement throw exception; } boolean interupted = false; + long blockingStart = 0L; + int fullTimes = 0; do { try { long next = disruptorMsgBuffer.tryNext(); - MessageEvent event = disruptorMsgBuffer.get(next); - event.setBuffer(buffer); - if (binlogFileName != null) { - event.setBinlogFileName(binlogFileName); + MessageEvent data = disruptorMsgBuffer.get(next); + if (buffer != null) { + data.setBuffer(buffer); + } else { + data.setEvent(event); } disruptorMsgBuffer.publish(next); + if (fullTimes > 0) { + eventsPublishBlockingTime.addAndGet(System.nanoTime() - blockingStart); + } break; } catch (InsufficientCapacityException e) { + if (fullTimes == 0) { + blockingStart = System.nanoTime(); + } // park - LockSupport.parkNanos(1L); + // LockSupport.parkNanos(1L); + applyWait(++fullTimes); interupted = Thread.interrupted(); + if (fullTimes % 1000 == 0) { + long nextStart = System.nanoTime(); + eventsPublishBlockingTime.addAndGet(nextStart - blockingStart); + blockingStart = nextStart; + } } } while (!interupted && isStart()); return isStart(); } + // 处理无数据的情况,避免空循环挂死 + private void applyWait(int fullTimes) { + int newFullTimes = fullTimes > maxFullTimes ? maxFullTimes : fullTimes; + if (fullTimes <= 3) { // 3次以内 + Thread.yield(); + } else { // 超过3次,最多只sleep 1ms + LockSupport.parkNanos(100 * 1000L * newFullTimes); + } + + } + @Override public void reset() { if (isStart()) { @@ -201,17 +231,13 @@ public class MysqlMultiStageCoprocessor extends AbstractCanalLifeCycle implement 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 = event.getEvent(); + if (logEvent == null) { + LogBuffer buffer = event.getBuffer(); + logEvent = decoder.decode(buffer, context); + event.setEvent(logEvent); } - LogEvent logEvent = decoder.decode(buffer, context); - event.setEvent(logEvent); - int eventType = logEvent.getHeader().getType(); TableMeta tableMeta = null; boolean needDmlParse = false; @@ -312,7 +338,6 @@ public class MysqlMultiStageCoprocessor extends AbstractCanalLifeCycle implement // clear for gc event.setBuffer(null); - event.setBinlogFileName(null); event.setEvent(null); event.setTable(null); event.setEntry(null); @@ -336,21 +361,12 @@ public class MysqlMultiStageCoprocessor extends AbstractCanalLifeCycle implement 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; } @@ -427,4 +443,8 @@ public class MysqlMultiStageCoprocessor extends AbstractCanalLifeCycle implement this.connection = connection; } + public void setEventsPublishBlockingTime(AtomicLong eventsPublishBlockingTime) { + this.eventsPublishBlockingTime = eventsPublishBlockingTime; + } + } 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 09af808f..e161e34e 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 @@ -42,6 +42,7 @@ import com.google.protobuf.ByteString; import com.taobao.tddl.dbsync.binlog.LogEvent; import com.taobao.tddl.dbsync.binlog.event.DeleteRowsLogEvent; import com.taobao.tddl.dbsync.binlog.event.GtidLogEvent; +import com.taobao.tddl.dbsync.binlog.event.HeartbeatLogEvent; import com.taobao.tddl.dbsync.binlog.event.IntvarLogEvent; import com.taobao.tddl.dbsync.binlog.event.LogHeader; import com.taobao.tddl.dbsync.binlog.event.QueryLogEvent; @@ -144,6 +145,8 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar return parseRandLogEvent((RandLogEvent) logEvent); case LogEvent.GTID_LOG_EVENT: return parseGTIDLogEvent((GtidLogEvent) logEvent); + case LogEvent.HEARTBEAT_LOG_EVENT: + return parseHeartbeatLogEvent((HeartbeatLogEvent) logEvent); default: break; } @@ -158,6 +161,15 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar } } + private Entry parseHeartbeatLogEvent(HeartbeatLogEvent logEvent) { + Header.Builder headerBuilder = Header.newBuilder(); + headerBuilder.setEventType(EventType.MHEARTBEAT); + Entry.Builder entryBuilder = Entry.newBuilder(); + entryBuilder.setHeader(headerBuilder.build()); + entryBuilder.setEntryType(EntryType.HEARTBEAT); + return entryBuilder.build(); + } + private Entry parseGTIDLogEvent(GtidLogEvent logEvent) { LogHeader logHeader = logEvent.getHeader(); String value = logEvent.getSid().toString() + ":" + logEvent.getGno(); @@ -541,12 +553,16 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar tableError |= parseOneRow(rowDataBuilder, event, buffer, changeColumns, true, tableMeta); } - rowsCount ++; + rowsCount++; rowChangeBuider.addRowDatas(rowDataBuilder.build()); } TableMapLogEvent table = event.getTable(); - Header header = createHeader(event.getHeader(), table.getDbName(), table.getTableName(), eventType, rowsCount); + Header header = createHeader(event.getHeader(), + table.getDbName(), + table.getTableName(), + eventType, + rowsCount); RowChange rowChange = rowChangeBuider.build(); if (tableError) { @@ -755,6 +771,8 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar } else { // byte数组,直接使用iso-8859-1保留对应编码,浪费内存 columnBuilder.setValue(new String((byte[]) value, ISO_8859_1)); + // columnBuilder.setValueBytes(ByteString.copyFrom((byte[]) + // value)); javaType = Types.BLOB; } break; @@ -801,12 +819,12 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar return createEntry(header, EntryType.ROWDATA, rowChangeBuider.build().toByteString()); } - 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) { + private Header createHeader(LogHeader logHeader, String schemaName, String tableName, EventType eventType, + Integer rowsCount) { // header会做信息冗余,方便以后做检索或者过滤 Header.Builder headerBuilder = Header.newBuilder(); headerBuilder.setVersion(version); @@ -869,11 +887,14 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar private TableMeta getTableMeta(String dbName, String tbName, boolean useCache, EntryPosition position) { try { return tableMetaCache.getTableMeta(dbName, tbName, useCache, position); - } catch (Exception e) { + } catch (Throwable e) { String message = ExceptionUtils.getRootCauseMessage(e); if (filterTableError) { if (StringUtils.contains(message, "errorNumber=1146") && StringUtils.contains(message, "doesn't exist")) { return null; + } else if (StringUtils.contains(message, "errorNumber=1142") + && StringUtils.contains(message, "command denied")) { + return null; } } @@ -960,5 +981,4 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar public void setGtidSet(GTIDSet gtidSet) { this.gtidSet = gtidSet; } - } diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/local/BinLogFileQueue.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/local/BinLogFileQueue.java index 224852cc..eb227303 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/local/BinLogFileQueue.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/local/BinLogFileQueue.java @@ -25,13 +25,14 @@ import com.alibaba.otter.canal.parse.exception.CanalParseException; */ public class BinLogFileQueue { - private String baseName = "mysql-bin."; - private List binlogs = new ArrayList(); - private File directory; - private ReentrantLock lock = new ReentrantLock(); - private Condition nextCondition = lock.newCondition(); - private Timer timer = new Timer(true); - private long reloadInterval = 10 * 1000L; // 10秒 + private String baseName = "mysql-bin."; + private List binlogs = new ArrayList(); + private File directory; + private ReentrantLock lock = new ReentrantLock(); + private Condition nextCondition = lock.newCondition(); + private Timer timer = new Timer(true); + private long reloadInterval = 10 * 1000L; // 10秒 + private CanalParseException exception = null; public BinLogFileQueue(String directory){ this(new File(directory)); @@ -52,9 +53,24 @@ public class BinLogFileQueue { timer.scheduleAtFixedRate(new TimerTask() { public void run() { - List files = listBinlogFiles(); - for (File file : files) { - offer(file); + try { + // File errorFile = new File(BinLogFileQueue.this.directory, + // errorFileName); + // if (errorFile.isFile() && errorFile.exists()) { + // String text = StringUtils.join(IOUtils.readLines(new + // FileInputStream(errorFile)), "\n"); + // exception = new CanalParseException(text); + // } + List files = listBinlogFiles(); + for (File file : files) { + offer(file); + } + } catch (Throwable e) { + exception = new CanalParseException(e); + } + + if (exception != null) { + offer(null); } } }, reloadInterval, reloadInterval); @@ -69,6 +85,10 @@ public class BinLogFileQueue { public File getNextFile(File pre) { try { lock.lockInterruptibly(); + if (exception != null) { + throw exception; + } + if (binlogs.size() == 0) { return null; } else { @@ -94,6 +114,10 @@ public class BinLogFileQueue { public File getBefore(File file) { try { lock.lockInterruptibly(); + if (exception != null) { + throw exception; + } + if (binlogs.size() == 0) { return null; } else { @@ -130,6 +154,9 @@ public class BinLogFileQueue { nextCondition.await();// 等待新文件 } + if (exception != null) { + throw exception; + } if (pre == null) {// 第一次 return binlogs.get(0); } else { @@ -170,13 +197,16 @@ public class BinLogFileQueue { private boolean offer(File file) { try { lock.lockInterruptibly(); - if (!binlogs.contains(file)) { - binlogs.add(file); - nextCondition.signalAll();// 唤醒 - return true; - } else { - return false; + if (file != null) { + if (!binlogs.contains(file)) { + binlogs.add(file); + nextCondition.signalAll();// 唤醒 + return true; + } } + + nextCondition.signalAll();// 唤醒 + return false; } catch (InterruptedException e) { Thread.currentThread().interrupt(); return false; diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/BinlogDownloadQueue.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/BinlogDownloadQueue.java new file mode 100644 index 00000000..e132514b --- /dev/null +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/BinlogDownloadQueue.java @@ -0,0 +1,339 @@ +package com.alibaba.otter.canal.parse.inbound.mysql.rds; + +import io.netty.handler.codec.http.HttpResponseStatus; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.util.Collections; +import java.util.Comparator; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.LockSupport; + +import javax.net.ssl.SSLContext; + +import org.apache.commons.compress.archivers.tar.TarArchiveEntry; +import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.http.HttpResponse; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.config.RegistryBuilder; +import org.apache.http.conn.socket.ConnectionSocketFactory; +import org.apache.http.conn.socket.PlainConnectionSocketFactory; +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.apache.http.ssl.SSLContextBuilder; +import org.apache.http.ssl.TrustStrategy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.alibaba.otter.canal.parse.inbound.mysql.rds.data.BinlogFile; + +/** + * @author chengjin.lyf on 2018/8/7 下午3:10 + * @since 1.0.25 + */ +public class BinlogDownloadQueue { + + private static final Logger logger = LoggerFactory.getLogger(BinlogDownloadQueue.class); + private static final int TIMEOUT = 10000; + + private LinkedBlockingQueue downloadQueue = new LinkedBlockingQueue(); + private LinkedBlockingQueue taskQueue = new LinkedBlockingQueue(); + private LinkedList binlogList; + private final int batchFileSize; + private Thread downloadThread; + public boolean running = true; + private final String destDir; + private String hostId; + private int currentSize; + private String lastDownload; + + public BinlogDownloadQueue(List downloadQueue, int batchFileSize, String destDir) throws IOException{ + this.binlogList = new LinkedList(downloadQueue); + this.batchFileSize = batchFileSize; + this.destDir = destDir; + this.currentSize = 0; + prepareBinlogList(); + cleanDir(); + } + + private void prepareBinlogList() { + for (BinlogFile binlog : this.binlogList) { + String fileName = StringUtils.substringBetween(binlog.getDownloadLink(), "mysql-bin.", "?"); + binlog.setFileName(fileName); + } + Collections.sort(this.binlogList, new Comparator() { + + @Override + public int compare(BinlogFile o1, BinlogFile o2) { + return o1.getFileName().compareTo(o2.getFileName()); + } + }); + } + + public void cleanDir() throws IOException { + File destDirFile = new File(destDir); + FileUtils.forceMkdir(destDirFile); + FileUtils.cleanDirectory(destDirFile); + } + + public void silenceDownload() { + if (downloadThread != null) { + return; + } + downloadThread = new Thread(new DownloadThread(), "download-" + destDir); + downloadThread.setDaemon(true); + downloadThread.start(); + } + + public BinlogFile tryOne() throws Throwable { + BinlogFile binlogFile = binlogList.poll(); + download(binlogFile); + hostId = binlogFile.getHostInstanceID(); + this.currentSize++; + return binlogFile; + } + + public void notifyNotMatch() { + this.currentSize--; + filter(hostId); + } + + private void filter(String hostInstanceId) { + Iterator it = binlogList.iterator(); + while (it.hasNext()) { + BinlogFile bf = it.next(); + if (bf.getHostInstanceID().equalsIgnoreCase(hostInstanceId)) { + it.remove(); + } else { + hostId = bf.getHostInstanceID(); + } + } + } + + public boolean isLastFile(String fileName) { + String needCompareName = lastDownload; + if (StringUtils.isNotEmpty(needCompareName) && StringUtils.endsWith(needCompareName, "tar")) { + needCompareName = needCompareName.substring(0, needCompareName.indexOf(".")); + } + return fileName.equalsIgnoreCase(needCompareName) && binlogList.isEmpty(); + } + + public void prepare() throws InterruptedException { + for (int i = this.currentSize; i < batchFileSize && !binlogList.isEmpty(); i++) { + BinlogFile binlogFile = null; + while (!binlogList.isEmpty()) { + binlogFile = binlogList.poll(); + if (!binlogFile.getHostInstanceID().equalsIgnoreCase(hostId)) { + continue; + } + break; + } + if (binlogFile == null) { + break; + } + this.downloadQueue.put(binlogFile); + this.lastDownload = "mysql-bin." + binlogFile.getFileName(); + this.currentSize++; + } + } + + public void downOne() { + this.currentSize--; + } + + public void release() { + running = false; + this.currentSize = 0; + binlogList.clear(); + downloadQueue.clear(); + } + + private void download(BinlogFile binlogFile) throws Throwable { + String downloadLink = binlogFile.getDownloadLink(); + String fileName = binlogFile.getFileName(); + + downloadLink = downloadLink.trim(); + CloseableHttpClient httpClient = null; + if (downloadLink.startsWith("https")) { + HttpClientBuilder builder = HttpClientBuilder.create(); + builder.setMaxConnPerRoute(50); + builder.setMaxConnTotal(100); + // 创建支持忽略证书的https + final SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() { + + @Override + public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { + return true; + } + }).build(); + + httpClient = HttpClientBuilder.create() + .setSSLContext(sslContext) + .setConnectionManager(new PoolingHttpClientConnectionManager(RegistryBuilder. create() + .register("http", PlainConnectionSocketFactory.INSTANCE) + .register("https", new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE)) + .build())) + .build(); + } else { + httpClient = HttpClientBuilder.create().setMaxConnPerRoute(50).setMaxConnTotal(100).build(); + } + + HttpGet httpGet = new HttpGet(downloadLink); + RequestConfig requestConfig = RequestConfig.custom() + .setConnectTimeout(TIMEOUT) + .setConnectionRequestTimeout(TIMEOUT) + .setSocketTimeout(TIMEOUT) + .build(); + httpGet.setConfig(requestConfig); + HttpResponse response = httpClient.execute(httpGet); + int statusCode = response.getStatusLine().getStatusCode(); + if (statusCode != HttpResponseStatus.OK.code()) { + throw new RuntimeException("download failed , url:" + downloadLink + " , statusCode:" + statusCode); + } + saveFile(new File(destDir), "mysql-bin." + fileName, response); + } + + private static void saveFile(File parentFile, String fileName, HttpResponse response) throws IOException { + InputStream is = response.getEntity().getContent(); + long totalSize = Long.parseLong(response.getFirstHeader("Content-Length").getValue()); + if (response.getFirstHeader("Content-Disposition") != null) { + fileName = response.getFirstHeader("Content-Disposition").getValue(); + fileName = StringUtils.substringAfter(fileName, "filename="); + } + boolean isTar = StringUtils.endsWith(fileName, ".tar"); + FileUtils.forceMkdir(parentFile); + FileOutputStream fos = null; + try { + if (isTar) { + TarArchiveInputStream tais = new TarArchiveInputStream(is); + TarArchiveEntry tarArchiveEntry = null; + while ((tarArchiveEntry = tais.getNextTarEntry()) != null) { + String name = tarArchiveEntry.getName(); + File tarFile = new File(parentFile, name + ".tmp"); + logger.info("start to download file " + tarFile.getName()); + if (tarFile.exists()) { + tarFile.delete(); + } + BufferedOutputStream bos = null; + try { + bos = new BufferedOutputStream(new FileOutputStream(tarFile)); + int read = -1; + byte[] buffer = new byte[1024]; + while ((read = tais.read(buffer)) != -1) { + bos.write(buffer, 0, read); + } + logger.info("download file " + tarFile.getName() + " end!"); + tarFile.renameTo(new File(parentFile, name)); + } finally { + IOUtils.closeQuietly(bos); + } + } + tais.close(); + } else { + File file = new File(parentFile, fileName + ".tmp"); + if (file.exists()) { + file.delete(); + } + + if (!file.isFile()) { + file.createNewFile(); + } + try { + fos = new FileOutputStream(file); + byte[] buffer = new byte[1024]; + int len; + long copySize = 0; + long nextPrintProgress = 0; + logger.info("start to download file " + file.getName()); + while ((len = is.read(buffer)) != -1) { + fos.write(buffer, 0, len); + copySize += len; + long progress = copySize * 100 / totalSize; + if (progress >= nextPrintProgress) { + logger.info("download " + file.getName() + " progress : " + progress + + "% , download size : " + copySize + ", total size : " + totalSize); + nextPrintProgress += 10; + } + } + logger.info("download file " + file.getName() + " end!"); + fos.flush(); + } finally { + IOUtils.closeQuietly(fos); + } + file.renameTo(new File(parentFile, fileName)); + } + } finally { + IOUtils.closeQuietly(fos); + } + } + + public void execute(Runnable runnable) throws InterruptedException { + taskQueue.put(runnable); + } + + private class DownloadThread implements Runnable { + + @Override + public void run() { + while (running) { + BinlogFile binlogFile = null; + try { + binlogFile = downloadQueue.poll(5000, TimeUnit.MILLISECONDS); + if (binlogFile != null) { + int retry = 1; + while (true) { + try { + download(binlogFile); + break; + } catch (Throwable e) { + if (retry % 10 == 0) { + retry = retry + 1; + try { + logger.warn("download failed + " + binlogFile.toString() + "], retry : " + + retry, e); + // File errorFile = new File(destDir, + // "error.txt"); + // FileWriter writer = new + // FileWriter(errorFile); + // writer.write(ExceptionUtils.getFullStackTrace(e)); + // writer.flush(); + // IOUtils.closeQuietly(writer); + LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(100 * retry)); + } catch (Throwable e1) { + logger.error("write error failed", e1); + } + } else { + retry = retry + 1; + } + } + } + } + + Runnable runnable = taskQueue.poll(5000, TimeUnit.MILLISECONDS); + if (runnable != null) { + runnable.run(); + } + } catch (Throwable e) { + logger.error("task process failed", e); + } + } + + } + } +} diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/HttpHelper.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/HttpHelper.java index 7b641ade..9ed865fe 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/HttpHelper.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/HttpHelper.java @@ -155,6 +155,7 @@ public class HttpHelper { .register("https", new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE)) .build())) .build(); + // ---------------- 创建支持https 的client成功--------- URI uri = new URIBuilder(url).build(); diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/RdsBinlogEventParserProxy.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/RdsBinlogEventParserProxy.java new file mode 100644 index 00000000..3c38ed0c --- /dev/null +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/RdsBinlogEventParserProxy.java @@ -0,0 +1,166 @@ +package com.alibaba.otter.canal.parse.inbound.mysql.rds; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; + +import org.apache.commons.lang.StringUtils; + +import com.alibaba.otter.canal.parse.exception.PositionNotFoundException; +import com.alibaba.otter.canal.parse.inbound.ParserExceptionHandler; +import com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser; + +/** + * aliyun rds的binlog parser支持 + * + *
    + * 注意点:aliyun的binlog会有定期清理并备份到oss上, 这里实现了一份自动下载oss+rds binlog的机制
    + * 
    + * + * @author chengjin.lyf on 2018/7/20 上午10:52 + * @since 1.0.25 + */ +public class RdsBinlogEventParserProxy extends MysqlEventParser { + + private String rdsOpenApiUrl = "https://rds.aliyuncs.com/"; // openapi地址 + private String accesskey; // 云账号的ak + private String secretkey; // 云账号sk + private String instanceId; // rds实例id + private String directory; // binlog目录 + private int batchFileSize = 4; // 最多下载的binlog文件数量 + + private RdsLocalBinlogEventParser rdsLocalBinlogEventParser = new RdsLocalBinlogEventParser(); + private ExecutorService executorService = Executors.newSingleThreadExecutor(new ThreadFactory() { + + @Override + public Thread newThread(Runnable r) { + Thread t = new Thread(r, + "rds-binlog-daemon-thread"); + t.setDaemon(true); + return t; + } + }); + + @Override + public void start() { + if (StringUtils.isNotEmpty(accesskey) && StringUtils.isNotEmpty(secretkey) + && StringUtils.isNotEmpty(instanceId)) { + final ParserExceptionHandler targetHandler = this.getParserExceptionHandler(); + if (directory == null) { + directory = System.getProperty("java.io.tmpdir", "/tmp") + "/" + destination; + } + rdsLocalBinlogEventParser.setLogPositionManager(this.getLogPositionManager()); + rdsLocalBinlogEventParser.setDestination(destination); + rdsLocalBinlogEventParser.setAlarmHandler(this.getAlarmHandler()); + rdsLocalBinlogEventParser.setConnectionCharset(this.connectionCharset); + rdsLocalBinlogEventParser.setConnectionCharsetNumber(this.connectionCharsetNumber); + rdsLocalBinlogEventParser.setEnableTsdb(this.enableTsdb); + rdsLocalBinlogEventParser.setEventBlackFilter(this.eventBlackFilter); + rdsLocalBinlogEventParser.setFilterQueryDcl(this.filterQueryDcl); + rdsLocalBinlogEventParser.setFilterQueryDdl(this.filterQueryDdl); + rdsLocalBinlogEventParser.setFilterQueryDml(this.filterQueryDml); + rdsLocalBinlogEventParser.setFilterRows(this.filterRows); + rdsLocalBinlogEventParser.setFilterTableError(this.filterTableError); + // rdsLocalBinlogEventParser.setIsGTIDMode(this.isGTIDMode); + rdsLocalBinlogEventParser.setMasterInfo(this.masterInfo); + rdsLocalBinlogEventParser.setEventFilter(this.eventFilter); + rdsLocalBinlogEventParser.setMasterPosition(this.masterPosition); + rdsLocalBinlogEventParser.setTransactionSize(this.transactionSize); + rdsLocalBinlogEventParser.setUrl(this.rdsOpenApiUrl); + rdsLocalBinlogEventParser.setAccesskey(this.accesskey); + rdsLocalBinlogEventParser.setSecretkey(this.secretkey); + rdsLocalBinlogEventParser.setInstanceId(this.instanceId); + rdsLocalBinlogEventParser.setEventSink(eventSink); + rdsLocalBinlogEventParser.setDirectory(directory); + rdsLocalBinlogEventParser.setBatchFileSize(batchFileSize); + rdsLocalBinlogEventParser.setParallel(this.parallel); + rdsLocalBinlogEventParser.setParallelBufferSize(this.parallelBufferSize); + rdsLocalBinlogEventParser.setParallelThreadSize(this.parallelThreadSize); + rdsLocalBinlogEventParser.setFinishListener(new RdsLocalBinlogEventParser.ParseFinishListener() { + + @Override + public void onFinish() { + executorService.execute(new Runnable() { + + @Override + public void run() { + rdsLocalBinlogEventParser.stop(); + RdsBinlogEventParserProxy.this.start(); + } + }); + + } + }); + this.setParserExceptionHandler(new ParserExceptionHandler() { + + @Override + public void handle(Throwable e) { + handleMysqlParserException(e); + if (targetHandler != null) { + targetHandler.handle(e); + } + } + }); + } + + super.start(); + } + + private void handleMysqlParserException(Throwable throwable) { + if (throwable instanceof PositionNotFoundException) { + logger.info("remove rds not found position, try download rds binlog!"); + executorService.execute(new Runnable() { + + @Override + public void run() { + try { + logger.info("stop mysql parser!"); + RdsBinlogEventParserProxy rdsBinlogEventParserProxy = RdsBinlogEventParserProxy.this; + long serverId = rdsBinlogEventParserProxy.getServerId(); + rdsLocalBinlogEventParser.setServerId(serverId); + rdsBinlogEventParserProxy.stop(); + logger.info("start rds mysql binlog parser!"); + rdsLocalBinlogEventParser.start(); + } catch (Throwable e) { + logger.info("handle exception failed", e); + } + } + }); + } + } + + @Override + public void stop() { + super.stop(); + } + + @Override + public boolean isStart() { + return super.isStart(); + } + + public void setRdsOpenApiUrl(String rdsOpenApiUrl) { + this.rdsOpenApiUrl = rdsOpenApiUrl; + } + + public void setAccesskey(String accesskey) { + this.accesskey = accesskey; + } + + public void setSecretkey(String secretkey) { + this.secretkey = secretkey; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public void setDirectory(String directory) { + this.directory = directory; + } + + public void setBatchFileSize(int batchFileSize) { + this.batchFileSize = batchFileSize; + } + +} diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/RdsBinlogOpenApi.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/RdsBinlogOpenApi.java index eb638739..2e79c536 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/RdsBinlogOpenApi.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/RdsBinlogOpenApi.java @@ -1,46 +1,21 @@ package com.alibaba.otter.canal.parse.inbound.mysql.rds; -import io.netty.handler.codec.http.HttpResponseStatus; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.text.SimpleDateFormat; +import java.net.URI; +import java.net.URISyntaxException; import java.util.Collections; import java.util.Date; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import java.util.TimeZone; -import java.util.TreeMap; -import java.util.UUID; -import javax.crypto.Mac; -import javax.crypto.SecretKey; -import javax.crypto.spec.SecretKeySpec; - -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.compress.archivers.tar.TarArchiveEntry; -import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; -import org.apache.http.HttpResponse; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; +import com.alibaba.otter.canal.parse.inbound.mysql.rds.data.BinlogFile; +import com.alibaba.otter.canal.parse.inbound.mysql.rds.data.DescribeBinlogFileResult; +import com.alibaba.otter.canal.parse.inbound.mysql.rds.data.RdsBackupPolicy; +import com.alibaba.otter.canal.parse.inbound.mysql.rds.data.RdsItem; +import com.alibaba.otter.canal.parse.inbound.mysql.rds.request.DescribeBackupPolicyRequest; +import com.alibaba.otter.canal.parse.inbound.mysql.rds.request.DescribeBinlogFilesRequest; /** * @author agapple 2017年10月14日 下午1:53:52 @@ -48,287 +23,78 @@ import com.alibaba.fastjson.JSONObject; */ public class RdsBinlogOpenApi { - protected static final Logger logger = LoggerFactory.getLogger(RdsBinlogOpenApi.class); - private static final String ISO8601_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; - private static final int TIMEOUT = 10000; - private static final String ENCODING = "UTF-8"; - private static final String MAC_NAME = "HmacSHA1"; - private static final String API_VERSION = "2014-08-15"; - private static final String SIGNATURE_VERSION = "1.0"; + protected static final Logger logger = LoggerFactory.getLogger(RdsBinlogOpenApi.class); - public static void downloadBinlogFiles(String url, String ak, String sk, String dbInstanceId, Date startTime, - Date endTime, File destDir) throws Throwable { - int pageSize = 100; - int pageNumber = 0; - int pageRecordCount = 1; - String hostInstanceID = null; - while (pageRecordCount > 0 && pageRecordCount <= pageSize) { - pageNumber += 1; - String result = describeBinlogFiles(url, ak, sk, dbInstanceId, startTime, endTime, pageSize, pageNumber); - JSONObject jsobObj = JSON.parseObject(result); - pageRecordCount = jsobObj.getInteger("PageRecordCount"); - - if (pageRecordCount > 0) { - FileUtils.forceMkdir(destDir); - File hostIdFile = new File(destDir, "hostId"); - if (hostIdFile.exists()) { - List lines = IOUtils.readLines(new FileInputStream(hostIdFile)); - hostInstanceID = StringUtils.join(lines, "\n"); - } - - String itemStr = jsobObj.getString("Items"); - JSONObject binLogFileObj = JSONObject.parseObject(itemStr); - JSONArray items = binLogFileObj.getJSONArray("BinLogFile"); - if (items == null || items.isEmpty()) { - continue; - } - for (int i = 0; i < items.size(); i++) { - JSONObject item = (JSONObject) items.get(i); - String oneHostInstanceID = item.getString("HostInstanceID"); - if (hostInstanceID == null) { - hostInstanceID = oneHostInstanceID; - FileOutputStream hostIdFileOut = null; - try { - hostIdFileOut = new FileOutputStream(hostIdFile); - hostIdFileOut.write(oneHostInstanceID.getBytes()); - hostIdFileOut.flush(); - } finally { - IOUtils.closeQuietly(hostIdFileOut); - } - } - - if (hostInstanceID.equals(oneHostInstanceID)) { // 只选择一个host下载 - String downloadLink = item.getString("DownloadLink"); - String fileName = StringUtils.substringBetween(downloadLink, "mysql-bin.", ".tar"); - if (StringUtils.isNotEmpty(fileName)) { - File currentFile = new File(destDir, "mysql-bin." + fileName); - if (currentFile.isFile() && currentFile.exists()) { - // 检查一下文件是否存在,存在就就没必要下载了 - continue; - } - } - - HttpGet httpGet = new HttpGet(downloadLink); - CloseableHttpClient httpClient = HttpClientBuilder.create() - .setMaxConnPerRoute(50) - .setMaxConnTotal(100) - .build(); - RequestConfig requestConfig = RequestConfig.custom() - .setConnectTimeout(TIMEOUT) - .setConnectionRequestTimeout(TIMEOUT) - .setSocketTimeout(TIMEOUT) - .build(); - httpGet.setConfig(requestConfig); - HttpResponse response = httpClient.execute(httpGet); - int statusCode = response.getStatusLine().getStatusCode(); - if (statusCode != HttpResponseStatus.OK.code()) { - throw new RuntimeException("download failed , url:" + downloadLink + " , statusCode:" - + statusCode); - } - saveFile(destDir, response); - } - } + public static List listBinlogFiles(String url, String ak, String sk, String dbInstanceId, + Date startTime, Date endTime) { + DescribeBinlogFilesRequest request = new DescribeBinlogFilesRequest(); + if (StringUtils.isNotEmpty(url)) { + try { + URI uri = new URI(url); + request.setEndPoint(uri.getHost()); + } catch (URISyntaxException e) { + logger.error("resolve url host failed, will use default rds endpoint!"); } } - } - - private static void saveFile(File parentFile, HttpResponse response) throws IOException { - InputStream is = response.getEntity().getContent(); - long totalSize = Long.parseLong(response.getFirstHeader("Content-Length").getValue()); - String fileName = response.getFirstHeader("Content-Disposition").getValue(); - fileName = StringUtils.substringAfter(fileName, "filename="); - boolean isTar = StringUtils.endsWith(fileName, ".tar"); - FileUtils.forceMkdir(parentFile); - FileOutputStream fos = null; - try { - if (isTar) { - TarArchiveInputStream tais = new TarArchiveInputStream(is); - TarArchiveEntry tarArchiveEntry = null; - while ((tarArchiveEntry = tais.getNextTarEntry()) != null) { - String name = tarArchiveEntry.getName(); - File tarFile = new File(parentFile, name); - logger.info("start to download file " + tarFile.getName()); - BufferedOutputStream bos = null; - try { - bos = new BufferedOutputStream(new FileOutputStream(tarFile)); - int read = -1; - byte[] buffer = new byte[1024]; - while ((read = tais.read(buffer)) != -1) { - bos.write(buffer, 0, read); - } - logger.info("download file " + tarFile.getName() + " end!"); - } finally { - IOUtils.closeQuietly(bos); - } - } - tais.close(); - } else { - File file = new File(parentFile, fileName); - if (!file.isFile()) { - file.createNewFile(); + request.setStartDate(startTime); + request.setEndDate(endTime); + request.setPageNumber(1); + request.setPageSize(100); + request.setRdsInstanceId(dbInstanceId); + request.setAccessKeyId(ak); + request.setAccessKeySecret(sk); + DescribeBinlogFileResult result = null; + int retryTime = 3; + while (true) { + try { + result = request.doAction(); + break; + } catch (Exception e) { + if (retryTime-- <= 0) { + throw new RuntimeException(e); } try { - fos = new FileOutputStream(file); - byte[] buffer = new byte[1024]; - int len; - long copySize = 0; - long nextPrintProgress = 0; - logger.info("start to download file " + file.getName()); - while ((len = is.read(buffer)) != -1) { - fos.write(buffer, 0, len); - copySize += len; - long progress = copySize * 100 / totalSize; - if (progress >= nextPrintProgress) { - logger.info("download " + file.getName() + " progress : " + progress - + "% , download size : " + copySize + ", total size : " + totalSize); - nextPrintProgress += 10; - } - } - logger.info("download file " + file.getName() + " end!"); - fos.flush(); - } finally { - IOUtils.closeQuietly(fos); + Thread.sleep(100L); + } catch (InterruptedException e1) { } } - } finally { - IOUtils.closeQuietly(fos); } - } - - public static String describeBinlogFiles(String url, String ak, String sk, String dbInstanceId, Date startTime, - Date endTime, int pageSize, int pageNumber) throws Exception { - Map paramMap = new HashMap(); - paramMap.put("Action", "DescribeBinlogFiles"); - paramMap.put("DBInstanceId", dbInstanceId); // rds实例id - paramMap.put("StartTime", formatIso8601Date(startTime)); - paramMap.put("EndTime", formatIso8601Date(endTime)); - paramMap.put("PageSize", String.valueOf(pageSize)); - paramMap.put("PageNumber", String.valueOf(pageNumber)); - return doRequest(url, paramMap, ak, sk); - } - - private static String doRequest(String domin, Map param, String ak, String sk) throws Exception { - param.put("AccessKeyId", ak); - param.put("SignatureMethod", "HMAC-SHA1"); - param.put("SignatureVersion", SIGNATURE_VERSION); - param.put("Version", API_VERSION); - param.put("SignatureNonce", UUID.randomUUID().toString()); - param.put("Format", "JSON"); - param.put("Timestamp", formatIso8601Date(new Date())); - String signStr = generate("POST", param, sk); - param.put("Signature", signStr); - String request = concatQueryString(param); - String url = domin + "?" + request; - String result = HttpHelper.post(url, null, Collections.EMPTY_MAP, TIMEOUT); - return result; - } - - public static String concatQueryString(Map parameters) throws UnsupportedEncodingException { - if (null == parameters) { - return null; + if (result == null) { + return Collections.EMPTY_LIST; } - StringBuilder urlBuilder = new StringBuilder(""); - for (Map.Entry entry : parameters.entrySet()) { - String key = entry.getKey(); - String val = entry.getValue(); - urlBuilder.append(encode(key)); - if (val != null) { - urlBuilder.append("=").append(encode(val)); + RdsItem rdsItem = result.getItems(); + if (rdsItem != null) { + return rdsItem.getBinLogFile(); + } + return Collections.EMPTY_LIST; + } + + public static RdsBackupPolicy queryBinlogBackupPolicy(String url, String ak, String sk, String dbInstanceId) { + DescribeBackupPolicyRequest request = new DescribeBackupPolicyRequest(); + if (StringUtils.isNotEmpty(url)) { + try { + URI uri = new URI(url); + request.setEndPoint(uri.getHost()); + } catch (URISyntaxException e) { + logger.error("resolve url host failed, will use default rds endpoint!"); } - urlBuilder.append("&"); } - int strIndex = urlBuilder.length(); - if (parameters.size() > 0) { - urlBuilder.deleteCharAt(strIndex - 1); - } - return urlBuilder.toString(); - } - - public static String encode(String value) throws UnsupportedEncodingException { - return URLEncoder.encode(value, "UTF-8"); - } - - private static String formatIso8601Date(Date date) { - SimpleDateFormat df = new SimpleDateFormat(ISO8601_DATE_FORMAT); - df.setTimeZone(TimeZone.getTimeZone("GMT")); - return df.format(date); - } - - /** - * 使用 HMAC-SHA1 签名方法对对encryptText进行签名 - * - * @param encryptText 被签名的字符串 - * @param encryptKey 密钥 - * @return - * @throws Exception - */ - public static byte[] HmacSHA1Encrypt(String encryptText, String encryptKey) throws Exception { - byte[] data = encryptKey.getBytes(ENCODING); - // 根据给定的字节数组构造一个密钥,第二参数指定一个密钥算法的名称 - SecretKey secretKey = new SecretKeySpec(data, MAC_NAME); - // 生成一个指定 Mac 算法 的 Mac 对象 - Mac mac = Mac.getInstance(MAC_NAME); - // 用给定密钥初始化 Mac 对象 - mac.init(secretKey); - - byte[] text = encryptText.getBytes(ENCODING); - // 完成 Mac 操作 - return mac.doFinal(text); - } - - private static String base64(byte input[]) throws UnsupportedEncodingException { - return new String(Base64.encodeBase64(input), ENCODING); - } - - /** 对参数名称和参数值进行URL编码 **/ - public static String generate(String method, Map parameter, String accessKeySecret) - throws Exception { - String signString = generateSignString(method, parameter); - byte[] signBytes = HmacSHA1Encrypt(signString, accessKeySecret + "&"); - String signature = base64(signBytes); - if ("POST".equals(method)) { - return signature; - } - return URLEncoder.encode(signature, "UTF-8"); - } - - private static String generateQueryString(TreeMap treeMap) { - StringBuilder canonicalizedQueryString = new StringBuilder(); - boolean first = true; - for (String key : treeMap.navigableKeySet()) { - String value = treeMap.get(key); - if (!first) { - canonicalizedQueryString.append("&"); + request.setRdsInstanceId(dbInstanceId); + request.setAccessKeyId(ak); + request.setAccessKeySecret(sk); + int retryTime = 3; + while (true) { + try { + return request.doAction(); + } catch (Exception e) { + if (retryTime-- <= 0) { + throw new RuntimeException(e); + } + try { + Thread.sleep(100L); + } catch (InterruptedException e1) { + } } - first = false; - canonicalizedQueryString.append(percentEncode(key)).append("=").append(percentEncode(value)); } - return canonicalizedQueryString.toString(); - } - - public static String generateSignString(String httpMethod, Map parameter) throws IOException { - TreeMap sortParameter = new TreeMap(); - sortParameter.putAll(parameter); - String canonicalizedQueryString = generateQueryString(sortParameter); - if (null == httpMethod) { - throw new RuntimeException("httpMethod can not be empty"); - } - /** 构造待签名的字符串* */ - StringBuilder stringToSign = new StringBuilder(); - stringToSign.append(httpMethod).append("&"); - stringToSign.append(percentEncode("/")).append("&"); - stringToSign.append(percentEncode(canonicalizedQueryString)); - return stringToSign.toString(); - } - - public static String percentEncode(String value) { - try { - return value == null ? null : URLEncoder.encode(value, ENCODING) - .replaceAll("\\+", "%20") - .replaceAll("\\*", "%2A") - .replaceAll("%7E", "~"); - } catch (Exception e) { - } - return ""; } } diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/RdsLocalBinlogEventParser.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/RdsLocalBinlogEventParser.java index 68be38e5..aac14d99 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/RdsLocalBinlogEventParser.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/RdsLocalBinlogEventParser.java @@ -2,14 +2,23 @@ package com.alibaba.otter.canal.parse.inbound.mysql.rds; import java.io.File; import java.util.Date; +import java.util.List; import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.math.NumberUtils; import org.springframework.util.Assert; import com.alibaba.otter.canal.parse.CanalEventParser; import com.alibaba.otter.canal.parse.exception.CanalParseException; +import com.alibaba.otter.canal.parse.exception.PositionNotFoundException; +import com.alibaba.otter.canal.parse.exception.ServerIdNotMatchException; +import com.alibaba.otter.canal.parse.inbound.ErosaConnection; +import com.alibaba.otter.canal.parse.inbound.ParserExceptionHandler; +import com.alibaba.otter.canal.parse.inbound.mysql.LocalBinLogConnection; import com.alibaba.otter.canal.parse.inbound.mysql.LocalBinlogEventParser; +import com.alibaba.otter.canal.parse.inbound.mysql.rds.data.BinlogFile; import com.alibaba.otter.canal.protocol.position.EntryPosition; +import com.alibaba.otter.canal.protocol.position.LogPosition; /** * 基于rds binlog备份文件的复制 @@ -17,47 +26,104 @@ import com.alibaba.otter.canal.protocol.position.EntryPosition; * @author agapple 2017年10月15日 下午1:27:36 * @since 1.0.25 */ -public class RdsLocalBinlogEventParser extends LocalBinlogEventParser implements CanalEventParser { +public class RdsLocalBinlogEventParser extends LocalBinlogEventParser implements CanalEventParser, LocalBinLogConnection.FileParserListener { - private String url = "https://rds.aliyuncs.com/"; // openapi地址 - private String accesskey; // 云账号的ak - private String secretkey; // 云账号sk - private String instanceId; // rds实例id - private Long startTime; - private Long endTime; + private String url; // openapi地址 + private String accesskey; // 云账号的ak + private String secretkey; // 云账号sk + private String instanceId; // rds实例id + private Long startTime; + private Long endTime; + private BinlogDownloadQueue binlogDownloadQueue; + private ParseFinishListener finishListener; + private int batchFileSize; public RdsLocalBinlogEventParser(){ } public void start() throws CanalParseException { try { - Assert.notNull(startTime); Assert.notNull(accesskey); Assert.notNull(secretkey); Assert.notNull(instanceId); Assert.notNull(url); + Assert.notNull(directory); + if (endTime == null) { endTime = System.currentTimeMillis(); } - RdsBinlogOpenApi.downloadBinlogFiles(url, + EntryPosition entryPosition = findStartPosition(null); + if (entryPosition == null) { + throw new PositionNotFoundException("position not found!"); + } + long startTimeInMill = entryPosition.getTimestamp(); + startTime = startTimeInMill; + List binlogFiles = RdsBinlogOpenApi.listBinlogFiles(url, accesskey, secretkey, instanceId, new Date(startTime), - new Date(endTime), - new File(directory)); - - // 更新一下时间戳 - masterPosition = new EntryPosition(startTime); + new Date(endTime)); + binlogDownloadQueue = new BinlogDownloadQueue(binlogFiles, batchFileSize, directory); + binlogDownloadQueue.silenceDownload(); + needWait = true; + // try to download one file,use to test server id + binlogDownloadQueue.tryOne(); } catch (Throwable e) { logger.error("download binlog failed", e); throw new CanalParseException(e); } + setParserExceptionHandler(new ParserExceptionHandler() { + @Override + public void handle(Throwable e) { + handleMysqlParserException(e); + } + }); super.start(); } + private void handleMysqlParserException(Throwable throwable) { + if (throwable instanceof ServerIdNotMatchException) { + logger.error("server id not match, try download another rds binlog!"); + binlogDownloadQueue.notifyNotMatch(); + try { + binlogDownloadQueue.cleanDir(); + binlogDownloadQueue.tryOne(); + binlogDownloadQueue.prepare(); + } catch (Throwable e) { + throw new RuntimeException(e); + } + + try { + binlogDownloadQueue.execute(new Runnable() { + + @Override + public void run() { + RdsLocalBinlogEventParser.super.stop(); + RdsLocalBinlogEventParser.super.start(); + } + }); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + + } + } + + @Override + protected ErosaConnection buildErosaConnection() { + ErosaConnection connection = super.buildErosaConnection(); + if (connection instanceof LocalBinLogConnection) { + LocalBinLogConnection localBinLogConnection = (LocalBinLogConnection) connection; + localBinLogConnection.setNeedWait(true); + localBinLogConnection.setServerId(serverId); + localBinLogConnection.setParserListener(this); + } + return connection; + } + public String getUrl() { return url; } @@ -68,44 +134,87 @@ public class RdsLocalBinlogEventParser extends LocalBinlogEventParser implements } } - public String getAccesskey() { - return accesskey; - } - public void setAccesskey(String accesskey) { this.accesskey = accesskey; } - public String getSecretkey() { - return secretkey; - } - public void setSecretkey(String secretkey) { this.secretkey = secretkey; } - public String getInstanceId() { - return instanceId; - } - public void setInstanceId(String instanceId) { this.instanceId = instanceId; } - public Long getStartTime() { - return startTime; - } - public void setStartTime(Long startTime) { this.startTime = startTime; } - public Long getEndTime() { - return endTime; - } - public void setEndTime(Long endTime) { this.endTime = endTime; } + @Override + public void onFinish(String fileName) { + try { + binlogDownloadQueue.downOne(); + File needDeleteFile = new File(directory + File.separator + fileName); + if (needDeleteFile.exists()) { + needDeleteFile.delete(); + } + // 处理下logManager位点问题 + LogPosition logPosition = logPositionManager.getLatestIndexBy(destination); + Long timestamp = 0L; + if (logPosition != null && logPosition.getPostion() != null) { + timestamp = logPosition.getPostion().getTimestamp(); + EntryPosition position = logPosition.getPostion(); + LogPosition newLogPosition = new LogPosition(); + String journalName = position.getJournalName(); + int sepIdx = journalName.indexOf("."); + String fileIndex = journalName.substring(sepIdx + 1); + int index = NumberUtils.toInt(fileIndex) + 1; + String newJournalName = journalName.substring(0, sepIdx) + "." + + StringUtils.leftPad(String.valueOf(index), fileIndex.length(), "0"); + newLogPosition.setPostion(new EntryPosition(newJournalName, + 4L, + position.getTimestamp(), + position.getServerId())); + newLogPosition.setIdentity(logPosition.getIdentity()); + logPositionManager.persistLogPosition(destination, newLogPosition); + } + + if (binlogDownloadQueue.isLastFile(fileName)) { + logger.warn("last file : " + fileName + " , timestamp : " + timestamp + + " , all file parse complete, switch to mysql parser!"); + finishListener.onFinish(); + return; + } else { + logger.warn("parse local binlog file : " + fileName + " , timestamp : " + timestamp + + " , try the next binlog !"); + } + binlogDownloadQueue.prepare(); + } catch (Exception e) { + logger.error("prepare download binlog file failed!", e); + throw new RuntimeException(e); + } + } + + @Override + public void stop() { + this.binlogDownloadQueue.release(); + super.stop(); + } + + public void setFinishListener(ParseFinishListener finishListener) { + this.finishListener = finishListener; + } + + public interface ParseFinishListener { + + void onFinish(); + } + + public void setBatchFileSize(int batchFileSize) { + this.batchFileSize = batchFileSize; + } } diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/data/BinlogFile.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/data/BinlogFile.java new file mode 100644 index 00000000..bee87521 --- /dev/null +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/data/BinlogFile.java @@ -0,0 +1,80 @@ +package com.alibaba.otter.canal.parse.inbound.mysql.rds.data; + +/** + * @author chengjin.lyf on 2018/8/7 下午2:26 + * @since 1.0.25 + */ +public class BinlogFile { + + private Long FileSize; + private String LogBeginTime; + private String LogEndTime; + private String DownloadLink; + private String HostInstanceID; + private String LinkExpiredTime; + private String fileName; + + public Long getFileSize() { + return FileSize; + } + + public void setFileSize(Long fileSize) { + FileSize = fileSize; + } + + public String getLogBeginTime() { + return LogBeginTime; + } + + public void setLogBeginTime(String logBeginTime) { + LogBeginTime = logBeginTime; + } + + public String getLogEndTime() { + return LogEndTime; + } + + public void setLogEndTime(String logEndTime) { + LogEndTime = logEndTime; + } + + public String getDownloadLink() { + return DownloadLink; + } + + public void setDownloadLink(String downloadLink) { + DownloadLink = downloadLink; + } + + public String getHostInstanceID() { + return HostInstanceID; + } + + public void setHostInstanceID(String hostInstanceID) { + HostInstanceID = hostInstanceID; + } + + public String getLinkExpiredTime() { + return LinkExpiredTime; + } + + public void setLinkExpiredTime(String linkExpiredTime) { + LinkExpiredTime = linkExpiredTime; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + @Override + public String toString() { + return "BinlogFile [FileSize=" + FileSize + ", LogBeginTime=" + LogBeginTime + ", LogEndTime=" + LogEndTime + + ", DownloadLink=" + DownloadLink + ", HostInstanceID=" + HostInstanceID + ", LinkExpiredTime=" + + LinkExpiredTime + ", fileName=" + fileName + "]"; + } + +} diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/data/DescribeBinlogFileResult.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/data/DescribeBinlogFileResult.java new file mode 100644 index 00000000..d5b6820d --- /dev/null +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/data/DescribeBinlogFileResult.java @@ -0,0 +1,63 @@ +package com.alibaba.otter.canal.parse.inbound.mysql.rds.data; + +/** + * @author chengjin.lyf on 2018/8/7 下午2:26 + * @since 1.0.25 + */ +public class DescribeBinlogFileResult { + + private RdsItem Items; + private long PageNumber; + private long TotalRecordCount; + private long TotalFileSize; + private String RequestId; + private long PageRecordCount; + + public RdsItem getItems() { + return Items; + } + + public void setItems(RdsItem items) { + Items = items; + } + + public long getPageNumber() { + return PageNumber; + } + + public void setPageNumber(long pageNumber) { + PageNumber = pageNumber; + } + + public long getTotalRecordCount() { + return TotalRecordCount; + } + + public void setTotalRecordCount(long totalRecordCount) { + TotalRecordCount = totalRecordCount; + } + + public long getTotalFileSize() { + return TotalFileSize; + } + + public void setTotalFileSize(long totalFileSize) { + TotalFileSize = totalFileSize; + } + + public String getRequestId() { + return RequestId; + } + + public void setRequestId(String requestId) { + RequestId = requestId; + } + + public long getPageRecordCount() { + return PageRecordCount; + } + + public void setPageRecordCount(long pageRecordCount) { + PageRecordCount = pageRecordCount; + } +} diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/data/RdsBackupPolicy.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/data/RdsBackupPolicy.java new file mode 100644 index 00000000..e007671a --- /dev/null +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/data/RdsBackupPolicy.java @@ -0,0 +1,78 @@ +package com.alibaba.otter.canal.parse.inbound.mysql.rds.data; + +/** + * @author chengjin.lyf on 2018/8/7 下午2:26 + * @since 1.0.25 + */ +public class RdsBackupPolicy { + + /** + * 数据备份保留天数(7到730天)。 + */ + private String BackupRetentionPeriod; + /** + * 数据备份时间,格式:HH:mmZ- HH:mm Z。 + */ + private String PreferredBackupTime; + /** + * 数据备份周期。Monday:周一;Tuesday:周二;Wednesday:周三;Thursday:周四;Friday:周五;Saturday: + * 周六;Sunday:周日。 + */ + private String PreferredBackupPeriod; + /** + * 日志备份状态。Enable:开启;Disabled:关闭。 + */ + private boolean BackupLog; + /** + * 日志备份保留天数(7到730天)。 + */ + private int LogBackupRetentionPeriod; + + public String getBackupRetentionPeriod() { + return BackupRetentionPeriod; + } + + public void setBackupRetentionPeriod(String backupRetentionPeriod) { + BackupRetentionPeriod = backupRetentionPeriod; + } + + public String getPreferredBackupTime() { + return PreferredBackupTime; + } + + public void setPreferredBackupTime(String preferredBackupTime) { + PreferredBackupTime = preferredBackupTime; + } + + public String getPreferredBackupPeriod() { + return PreferredBackupPeriod; + } + + public void setPreferredBackupPeriod(String preferredBackupPeriod) { + PreferredBackupPeriod = preferredBackupPeriod; + } + + public boolean isBackupLog() { + return BackupLog; + } + + public void setBackupLog(boolean backupLog) { + BackupLog = backupLog; + } + + public int getLogBackupRetentionPeriod() { + return LogBackupRetentionPeriod; + } + + public void setLogBackupRetentionPeriod(int logBackupRetentionPeriod) { + LogBackupRetentionPeriod = logBackupRetentionPeriod; + } + + @Override + public String toString() { + return "RdsBackupPolicy [BackupRetentionPeriod=" + BackupRetentionPeriod + ", PreferredBackupTime=" + + PreferredBackupTime + ", PreferredBackupPeriod=" + PreferredBackupPeriod + ", BackupLog=" + BackupLog + + ", LogBackupRetentionPeriod=" + LogBackupRetentionPeriod + "]"; + } + +} diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/data/RdsItem.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/data/RdsItem.java new file mode 100644 index 00000000..81c484e3 --- /dev/null +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/data/RdsItem.java @@ -0,0 +1,26 @@ +package com.alibaba.otter.canal.parse.inbound.mysql.rds.data; + +import java.util.List; + +/** + * @author chengjin.lyf on 2018/8/7 下午2:26 + * @since 1.0.25 + */ +public class RdsItem { + + private List BinLogFile; + + public List getBinLogFile() { + return BinLogFile; + } + + public void setBinLogFile(List binLogFile) { + BinLogFile = binLogFile; + } + + @Override + public String toString() { + return "RdsItem [BinLogFile=" + BinLogFile + "]"; + } + +} diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/request/AbstractRequest.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/request/AbstractRequest.java new file mode 100644 index 00000000..f43523b5 --- /dev/null +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/request/AbstractRequest.java @@ -0,0 +1,251 @@ +package com.alibaba.otter.canal.parse.inbound.mysql.rds.request; + +import io.netty.handler.codec.http.HttpResponseStatus; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Map; +import java.util.TimeZone; +import java.util.TreeMap; +import java.util.UUID; +import java.util.concurrent.TimeUnit; + +import javax.crypto.Mac; +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; +import javax.net.ssl.SSLContext; + +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang.StringUtils; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.config.Registry; +import org.apache.http.config.RegistryBuilder; +import org.apache.http.conn.HttpClientConnectionManager; +import org.apache.http.conn.socket.PlainConnectionSocketFactory; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.TrustStrategy; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.apache.http.ssl.SSLContexts; +import org.apache.http.util.EntityUtils; + +/** + * @author chengjin.lyf on 2018/8/7 下午2:26 + * @since 1.0.25 + */ +public abstract class AbstractRequest { + + /** + * 要求的编码格式 + */ + private static final String ENCODING = "UTF-8"; + /** + * 要求的sign签名算法 + */ + private static final String MAC_NAME = "HmacSHA1"; + + private String accessKeyId; + + private String accessKeySecret; + + /** + * api 版本 + */ + private String version; + + private String endPoint = "rds.aliyuncs.com"; + + private String protocol = "http"; + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + private int timeout = (int) TimeUnit.MINUTES.toMillis(1); + + private Map treeMap = new TreeMap(); + + public void putQueryString(String name, String value) { + if (StringUtils.isBlank(name) || StringUtils.isBlank(value)) { + return; + } + treeMap.put(name, value); + } + + public void setVersion(String version) { + this.version = version; + } + + public void setEndPoint(String endPoint) { + this.endPoint = endPoint; + } + + public void setAccessKeyId(String accessKeyId) { + this.accessKeyId = accessKeyId; + } + + public void setAccessKeySecret(String accessKeySecret) { + this.accessKeySecret = accessKeySecret; + } + + /** + * 使用 HMAC-SHA1 签名方法对对encryptText进行签名 + * + * @param encryptText 被签名的字符串 + * @param encryptKey 密钥 + * @return + * @throws Exception + */ + private byte[] HmacSHA1Encrypt(String encryptText, String encryptKey) throws Exception { + byte[] data = encryptKey.getBytes(ENCODING); + // 根据给定的字节数组构造一个密钥,第二参数指定一个密钥算法的名称 + SecretKey secretKey = new SecretKeySpec(data, MAC_NAME); + // 生成一个指定 Mac 算法 的 Mac 对象 + Mac mac = Mac.getInstance(MAC_NAME); + // 用给定密钥初始化 Mac 对象 + mac.init(secretKey); + + byte[] text = encryptText.getBytes(ENCODING); + // 完成 Mac 操作 + return mac.doFinal(text); + } + + private String base64(byte input[]) throws UnsupportedEncodingException { + return new String(Base64.encodeBase64(input), ENCODING); + } + + private String concatQueryString(Map parameters) throws UnsupportedEncodingException { + if (null == parameters) { + return null; + } + StringBuilder urlBuilder = new StringBuilder(""); + for (Map.Entry entry : parameters.entrySet()) { + String key = entry.getKey(); + String val = entry.getValue(); + urlBuilder.append(encode(key)); + if (val != null) { + urlBuilder.append("=").append(encode(val)); + } + urlBuilder.append("&"); + } + int strIndex = urlBuilder.length(); + if (parameters.size() > 0) { + urlBuilder.deleteCharAt(strIndex - 1); + } + return urlBuilder.toString(); + } + + private String encode(String value) throws UnsupportedEncodingException { + return URLEncoder.encode(value, "UTF-8"); + } + + private String makeSignature(TreeMap paramMap) throws Exception { + String cqs = concatQueryString(paramMap); + cqs = encode(cqs); + cqs = cqs.replaceAll("\\+", "%20"); + cqs = cqs.replaceAll("\\*", "%2A"); + cqs = cqs.replaceAll("%7E", "~"); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("GET").append("&").append(encode("/")).append("&").append(cqs); + return base64(HmacSHA1Encrypt(stringBuilder.toString(), accessKeySecret + "&")); + } + + public final String formatUTCTZ(Date date) { + SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd'T'HH:mm:ss'Z'"); + sdf.setTimeZone(TimeZone.getTimeZone("UTC")); + return sdf.format(date); + } + + private void fillCommonParam(Map p) { + p.put("Format", "JSON"); + p.put("Version", version); + p.put("AccessKeyId", accessKeyId); + p.put("SignatureMethod", "HMAC-SHA1"); // 此处不能用变量 MAC_NAME + p.put("Timestamp", formatUTCTZ(new Date())); + p.put("SignatureVersion", "1.0"); + p.put("SignatureNonce", UUID.randomUUID().toString()); + } + + private String makeRequestString(Map param) throws Exception { + fillCommonParam(param); + String sign = makeSignature(new TreeMap(param)); + StringBuilder builder = new StringBuilder(); + for (Map.Entry entry : param.entrySet()) { + builder.append(encode(entry.getKey())).append("=").append(encode(entry.getValue())).append("&"); + } + builder.append("Signature").append("=").append(sign); + return builder.toString(); + } + + /** + * 执行http请求 + * + * @param getMethod + * @return + * @throws IOException + */ + @SuppressWarnings("deprecation") + private final HttpResponse executeHttpRequest(HttpGet getMethod, String host) throws Exception { + SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, new TrustStrategy() { + + @Override + public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { + return true; + } + }).build(); + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, + new String[] { "TLSv1" }, + null, + SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); + Registry registry = RegistryBuilder.create() + .register("http", PlainConnectionSocketFactory.INSTANCE) + .register("https", sslsf) + .build(); + HttpClientConnectionManager httpClientConnectionManager = new PoolingHttpClientConnectionManager(registry); + CloseableHttpClient httpClient = HttpClientBuilder.create() + .setMaxConnPerRoute(50) + .setMaxConnTotal(100) + .setConnectionManager(httpClientConnectionManager) + .build(); + RequestConfig requestConfig = RequestConfig.custom() + .setConnectTimeout(timeout) + .setConnectionRequestTimeout(timeout) + .setSocketTimeout(timeout) + .build(); + getMethod.setConfig(requestConfig); + HttpResponse response = httpClient.execute(getMethod); + int statusCode = response.getStatusLine().getStatusCode(); + if (statusCode != HttpResponseStatus.OK.code() && statusCode != HttpResponseStatus.PARTIAL_CONTENT.code()) { + String result = EntityUtils.toString(response.getEntity()); + throw new RuntimeException("return error !" + response.getStatusLine().getReasonPhrase() + ", " + result); + } + return response; + } + + protected abstract T processResult(HttpResponse response) throws Exception; + + protected void processBefore() { + + } + + public final T doAction() throws Exception { + processBefore(); + String requestStr = makeRequestString(treeMap); + HttpGet httpGet = new HttpGet(protocol + "://" + endPoint + "?" + requestStr); + HttpResponse response = executeHttpRequest(httpGet, endPoint); + if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { + String result = EntityUtils.toString(response.getEntity()); + throw new RuntimeException("http request failed! " + result); + } + return processResult(response); + } +} diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/request/DescribeBackupPolicyRequest.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/request/DescribeBackupPolicyRequest.java new file mode 100644 index 00000000..cf51961a --- /dev/null +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/request/DescribeBackupPolicyRequest.java @@ -0,0 +1,40 @@ +package com.alibaba.otter.canal.parse.inbound.mysql.rds.request; + +import org.apache.http.HttpResponse; +import org.apache.http.util.EntityUtils; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.otter.canal.parse.inbound.mysql.rds.data.RdsBackupPolicy; + +/** + * rds 备份策略查询 + * + * @author chengjin.lyf on 2018/8/7 下午3:41 + * @since 1.0.25 + */ +public class DescribeBackupPolicyRequest extends AbstractRequest { + + public DescribeBackupPolicyRequest(){ + setVersion("2014-08-15"); + putQueryString("Action", "DescribeBackupPolicy"); + + } + + public void setRdsInstanceId(String rdsInstanceId) { + putQueryString("DBInstanceId", rdsInstanceId); + } + + @Override + protected RdsBackupPolicy processResult(HttpResponse response) throws Exception { + String result = EntityUtils.toString(response.getEntity()); + JSONObject jsonObj = JSON.parseObject(result); + RdsBackupPolicy policy = new RdsBackupPolicy(); + policy.setBackupRetentionPeriod(jsonObj.getString("BackupRetentionPeriod")); + policy.setBackupLog(jsonObj.getString("BackupLog").equalsIgnoreCase("Enable")); + policy.setLogBackupRetentionPeriod(jsonObj.getIntValue("LogBackupRetentionPeriod")); + policy.setPreferredBackupPeriod(jsonObj.getString("PreferredBackupPeriod")); + policy.setPreferredBackupTime(jsonObj.getString("PreferredBackupTime")); + return policy; + } +} diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/request/DescribeBinlogFilesRequest.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/request/DescribeBinlogFilesRequest.java new file mode 100644 index 00000000..8aa90569 --- /dev/null +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/request/DescribeBinlogFilesRequest.java @@ -0,0 +1,55 @@ +package com.alibaba.otter.canal.parse.inbound.mysql.rds.request; + +import java.util.Date; + +import org.apache.http.HttpResponse; +import org.apache.http.util.EntityUtils; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.alibaba.otter.canal.parse.inbound.mysql.rds.data.DescribeBinlogFileResult; + +/** + * @author chengjin.lyf on 2018/8/7 下午3:41 + * @since 1.0.25 + */ +public class DescribeBinlogFilesRequest extends AbstractRequest { + + public DescribeBinlogFilesRequest(){ + setVersion("2014-08-15"); + putQueryString("Action", "DescribeBinlogFiles"); + } + + public void setRdsInstanceId(String rdsInstanceId) { + putQueryString("DBInstanceId", rdsInstanceId); + } + + public void setPageSize(int pageSize) { + putQueryString("PageSize", String.valueOf(pageSize)); + } + + public void setPageNumber(int pageNumber) { + putQueryString("PageNumber", String.valueOf(pageNumber)); + } + + public void setStartDate(Date startDate) { + putQueryString("StartTime", formatUTCTZ(startDate)); + } + + public void setEndDate(Date endDate) { + putQueryString("EndTime", formatUTCTZ(endDate)); + } + + public void setResourceOwnerId(Long resourceOwnerId) { + putQueryString("ResourceOwnerId", String.valueOf(resourceOwnerId)); + } + + @Override + protected DescribeBinlogFileResult processResult(HttpResponse response) throws Exception { + String result = EntityUtils.toString(response.getEntity()); + DescribeBinlogFileResult describeBinlogFileResult = JSONObject.parseObject(result, + new TypeReference() { + }); + return describeBinlogFileResult; + } +} diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/DefaultTableMetaTSDBFactory.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/DefaultTableMetaTSDBFactory.java new file mode 100644 index 00000000..00e2744b --- /dev/null +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/DefaultTableMetaTSDBFactory.java @@ -0,0 +1,19 @@ +package com.alibaba.otter.canal.parse.inbound.mysql.tsdb; + +/** + * @author agapple 2017年10月11日 下午8:45:40 + * @since 1.0.25 + */ +public class DefaultTableMetaTSDBFactory implements TableMetaTSDBFactory { + + /** + * 代理一下tableMetaTSDB的获取,使用隔离的spring定义 + */ + public TableMetaTSDB build(String destination, String springXml) { + return TableMetaTSDBBuilder.build(destination, springXml); + } + + public void destory(String destination) { + TableMetaTSDBBuilder.destory(destination); + } +} 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 9a886336..904b55a9 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 @@ -68,7 +68,8 @@ public class MemoryTableMeta implements TableMetaTSDB { try { // druid暂时flush privileges语法解析有问题 - if (!StringUtils.startsWithIgnoreCase(StringUtils.trim(ddl), "flush")) { + if (!StringUtils.startsWithIgnoreCase(StringUtils.trim(ddl), "flush") + && !StringUtils.startsWithIgnoreCase(StringUtils.trim(ddl), "grant")) { repository.console(ddl); } } catch (Throwable e) { diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/TableMetaTSDBBuilder.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/TableMetaTSDBBuilder.java index 8e37ef71..107e1013 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/TableMetaTSDBBuilder.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/TableMetaTSDBBuilder.java @@ -10,12 +10,15 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; import com.google.common.collect.Maps; /** - * @author agapple 2017年10月11日 下午8:45:40 + * tableMeta构造器 + * + * @author agapple 2018年8月8日 上午11:01:08 * @since 1.0.25 */ + public class TableMetaTSDBBuilder { - protected final static Logger logger = LoggerFactory.getLogger(TableMetaTSDBBuilder.class); + protected final static Logger logger = LoggerFactory.getLogger(DefaultTableMetaTSDBFactory.class); private static ConcurrentMap contexts = Maps.newConcurrentMap(); /** diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/TableMetaTSDBFactory.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/TableMetaTSDBFactory.java new file mode 100644 index 00000000..950645a8 --- /dev/null +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/TableMetaTSDBFactory.java @@ -0,0 +1,18 @@ +package com.alibaba.otter.canal.parse.inbound.mysql.tsdb; + +/** + * tableMeta构造器,允许重载实现 + * + * @author agapple 2018年8月8日 上午11:01:08 + * @since 1.0.26 + */ + +public interface TableMetaTSDBFactory { + + /** + * 代理一下tableMetaTSDB的获取,使用隔离的spring定义 + */ + public TableMetaTSDB build(String destination, String springXml); + + public void destory(String destination); +} diff --git a/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/mysql/RdsBinlogEventParserProxyTest.java b/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/mysql/RdsBinlogEventParserProxyTest.java new file mode 100644 index 00000000..546ee58c --- /dev/null +++ b/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/mysql/RdsBinlogEventParserProxyTest.java @@ -0,0 +1,119 @@ +package com.alibaba.otter.canal.parse.inbound.mysql; + +import java.net.InetSocketAddress; +import java.util.Calendar; +import java.util.List; +import java.util.concurrent.atomic.AtomicLong; + +import org.junit.Assert; +import org.junit.Test; + +import com.alibaba.otter.canal.filter.aviater.AviaterRegexFilter; +import com.alibaba.otter.canal.parse.helper.TimeoutChecker; +import com.alibaba.otter.canal.parse.inbound.mysql.rds.RdsBinlogEventParserProxy; +import com.alibaba.otter.canal.parse.index.AbstractLogPositionManager; +import com.alibaba.otter.canal.parse.stub.AbstractCanalEventSinkTest; +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.exception.CanalSinkException; + +/** + * @author chengjin.lyf on 2018/7/21 下午5:24 + * @since 1.0.25 + */ +public class RdsBinlogEventParserProxyTest { + + private static final String DETECTING_SQL = "insert into retl.xdual values(1,now()) on duplicate key update x=now()"; + private static final String MYSQL_ADDRESS = ""; + private static final String USERNAME = ""; + private static final String PASSWORD = ""; + public static final String DBNAME = ""; + public static final String TBNAME = ""; + public static final String DDL = ""; + + @Test + public void test_timestamp() throws InterruptedException { + final TimeoutChecker timeoutChecker = new TimeoutChecker(3000 * 1000); + final AtomicLong entryCount = new AtomicLong(0); + final EntryPosition entryPosition = new EntryPosition(); + + final RdsBinlogEventParserProxy controller = new RdsBinlogEventParserProxy(); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.HOUR_OF_DAY, -24 * 4); + final EntryPosition defaultPosition = buildPosition(null, null, calendar.getTimeInMillis()); + controller.setSlaveId(3344L); + controller.setDetectingEnable(false); + controller.setDetectingSQL(DETECTING_SQL); + controller.setMasterInfo(buildAuthentication()); + controller.setMasterPosition(defaultPosition); + controller.setInstanceId(""); + controller.setAccesskey(""); + controller.setSecretkey(""); + controller.setDirectory("/tmp/binlog"); + controller.setEventBlackFilter(new AviaterRegexFilter("mysql\\.*")); + controller.setFilterTableError(true); + controller.setBatchFileSize(4); + controller.setEventSink(new AbstractCanalEventSinkTest>() { + + @Override + public boolean sink(List entrys, InetSocketAddress remoteAddress, String destination) + throws CanalSinkException { + for (CanalEntry.Entry entry : entrys) { + if (entry.getEntryType() != CanalEntry.EntryType.HEARTBEAT) { + entryCount.incrementAndGet(); + + String logfilename = entry.getHeader().getLogfileName(); + long logfileoffset = entry.getHeader().getLogfileOffset(); + long executeTime = entry.getHeader().getExecuteTime(); + + entryPosition.setJournalName(logfilename); + entryPosition.setPosition(logfileoffset); + entryPosition.setTimestamp(executeTime); + break; + } + } + return true; + } + }); + + controller.setLogPositionManager(new AbstractLogPositionManager() { + + private LogPosition logPosition; + + public void persistLogPosition(String destination, LogPosition logPosition) { + this.logPosition = logPosition; + } + + public LogPosition getLatestIndexBy(String destination) { + return logPosition; + } + }); + + controller.start(); + timeoutChecker.waitForIdle(); + + if (controller.isStart()) { + controller.stop(); + } + + // check + Assert.assertTrue(entryCount.get() > 0); + + // 对比第一条数据和起始的position相同 + Assert.assertEquals(entryPosition.getJournalName(), "mysql-bin.000001"); + Assert.assertTrue(entryPosition.getPosition() <= 6163L); + Assert.assertTrue(entryPosition.getTimestamp() <= defaultPosition.getTimestamp()); + } + + // ======================== helper method ======================= + + private EntryPosition buildPosition(String binlogFile, Long offest, Long timestamp) { + return new EntryPosition(binlogFile, offest, timestamp); + } + + private AuthenticationInfo buildAuthentication() { + return new AuthenticationInfo(new InetSocketAddress(MYSQL_ADDRESS, 3306), USERNAME, PASSWORD); + } +} diff --git a/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/mysql/RdsBinlogOpenApiTest.java b/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/mysql/RdsBinlogOpenApiTest.java index 596847ae..25a14284 100644 --- a/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/mysql/RdsBinlogOpenApiTest.java +++ b/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/mysql/RdsBinlogOpenApiTest.java @@ -1,11 +1,14 @@ package com.alibaba.otter.canal.parse.inbound.mysql; -import java.io.File; import java.util.Date; +import java.util.List; import org.apache.commons.lang.time.DateUtils; +import org.junit.Test; import com.alibaba.otter.canal.parse.inbound.mysql.rds.RdsBinlogOpenApi; +import com.alibaba.otter.canal.parse.inbound.mysql.rds.data.BinlogFile; +import com.alibaba.otter.canal.parse.inbound.mysql.rds.data.RdsBackupPolicy; /** * @author agapple 2017年10月15日 下午2:14:34 @@ -13,15 +16,19 @@ import com.alibaba.otter.canal.parse.inbound.mysql.rds.RdsBinlogOpenApi; */ public class RdsBinlogOpenApiTest { + @Test public void testSimple() throws Throwable { - Date startTime = DateUtils.parseDate("2017-10-13 20:56:58", new String[] { "yyyy-MM-dd HH:mm:ss" }); - Date endTime = DateUtils.parseDate("2017-10-14 02:57:59", new String[] { "yyyy-MM-dd HH:mm:ss" }); - RdsBinlogOpenApi.downloadBinlogFiles("https://rds.aliyuncs.com/", - "", - "", - "rm-bp180v4mfjnm157es", - startTime, - endTime, - new File("/tmp/binlog/")); + Date startTime = DateUtils.parseDate("2018-08-10 12:00:00", new String[] { "yyyy-MM-dd HH:mm:ss" }); + Date endTime = DateUtils.parseDate("2018-08-11 12:00:00", new String[] { "yyyy-MM-dd HH:mm:ss" }); + String url = "https://rds.aliyuncs.com/"; + String ak = ""; + String sk = ""; + String dbInstanceId = ""; + + RdsBackupPolicy backupPolicy = RdsBinlogOpenApi.queryBinlogBackupPolicy(url, ak, sk, dbInstanceId); + System.out.println(backupPolicy); + + List binlogFiles = RdsBinlogOpenApi.listBinlogFiles(url, ak, sk, dbInstanceId, startTime, endTime); + System.out.println(binlogFiles); } } diff --git a/pom.xml b/pom.xml index 9a14868b..3101aca6 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ canal pom canal module for otter ${project.version} - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT https://github.com/alibaba/canal org.sonatype.oss @@ -96,8 +96,8 @@ true true - 1.6 - 1.6 + 1.7 + 1.7 UTF-8 3.2.9.RELEASE @@ -247,7 +247,7 @@ com.alibaba.fastsql fastsql - 2.0.0_preview_520 + 2.0.0_preview_540 com.alibaba @@ -332,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 index 16cf8acf..7d192834 100644 --- a/prometheus/pom.xml +++ b/prometheus/pom.xml @@ -5,26 +5,15 @@ canal com.alibaba.otter - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT 4.0.0 com.alibaba.otter canal.prometheus - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT canal prometheus module for otter ${project.version} - - - org.aspectj - aspectjrt - 1.8.9 - - - org.aspectj - aspectjweaver - 1.8.9 - org.jctools jctools-core 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 index 8acf40b8..6f50214c 100644 --- a/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/CanalInstanceExports.java +++ b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/CanalInstanceExports.java @@ -1,12 +1,7 @@ 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 com.alibaba.otter.canal.prometheus.impl.*; import io.prometheus.client.Collector; import io.prometheus.client.CollectorRegistry; import org.slf4j.Logger; @@ -20,79 +15,71 @@ import java.util.List; */ public class CanalInstanceExports { - private static final Logger logger = LoggerFactory.getLogger(CanalInstanceExports.class); + private static final Logger logger = LoggerFactory.getLogger(CanalInstanceExports.class); + public static final String DEST = "destination"; + public static final String[] DEST_LABELS = {DEST}; + public static final List DEST_LABELS_LIST = Collections.singletonList(DEST); + private final Collector storeCollector; + private final Collector entryCollector; + private final Collector metaCollector; + private final Collector sinkCollector; + private final Collector parserCollector; - 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); + private CanalInstanceExports() { + this.storeCollector = StoreCollector.instance(); + this.entryCollector = EntryCollector.instance(); + this.metaCollector = MetaCollector.instance(); + this.sinkCollector = SinkCollector.instance(); + this.parserCollector = ParserCollector.instance(); } - - - static CanalInstanceExports forInstance(CanalInstance instance) { - return new CanalInstanceExports(instance); + private static class SingletonHolder { + private static final CanalInstanceExports SINGLETON = new CanalInstanceExports(); } - void register() { - if (delayCollector != null) { - delayCollector.register(); - } - if (storeCollector != null) { - storeCollector.register(); - } - if (metaCollector != null) { - metaCollector.register(); - } + public static CanalInstanceExports instance() { + return SingletonHolder.SINGLETON; } - void unregister() { - if (delayCollector != null) { - CollectorRegistry.defaultRegistry.unregister(delayCollector); - } - if (storeCollector != null) { - CollectorRegistry.defaultRegistry.unregister(storeCollector); - } - if (metaCollector != null) { - CollectorRegistry.defaultRegistry.unregister(metaCollector); - } + public void initialize() { + storeCollector.register(); + entryCollector.register(); + metaCollector.register(); + sinkCollector.register(); + parserCollector.register(); } - 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."); - } + public void terminate() { + CollectorRegistry.defaultRegistry.unregister(storeCollector); + CollectorRegistry.defaultRegistry.unregister(entryCollector); + CollectorRegistry.defaultRegistry.unregister(metaCollector); + CollectorRegistry.defaultRegistry.unregister(sinkCollector); + CollectorRegistry.defaultRegistry.unregister(parserCollector); } - 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); - } + void register(CanalInstance instance) { + requiredInstanceRegistry(storeCollector).register(instance); + requiredInstanceRegistry(entryCollector).register(instance); + requiredInstanceRegistry(metaCollector).register(instance); + requiredInstanceRegistry(sinkCollector).register(instance); + requiredInstanceRegistry(parserCollector).register(instance); + logger.info("Successfully register metrics for instance {}.", instance.getDestination()); } - private void initMetaCollector(CanalInstance instance) { - metaCollector = new InstanceMetaCollector(instance); + void unregister(CanalInstance instance) { + requiredInstanceRegistry(storeCollector).unregister(instance); + requiredInstanceRegistry(entryCollector).unregister(instance); + requiredInstanceRegistry(metaCollector).unregister(instance); + requiredInstanceRegistry(sinkCollector).unregister(instance); + requiredInstanceRegistry(parserCollector).unregister(instance); + logger.info("Successfully unregister metrics for instance {}.", instance.getDestination()); } + + private InstanceRegistry requiredInstanceRegistry(Collector collector) { + if (!(collector instanceof InstanceRegistry)) { + throw new IllegalArgumentException("Canal prometheus collector need to implement InstanceRegistry."); + } + return (InstanceRegistry) collector; + } + } 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 deleted file mode 100644 index 8eef79ba..00000000 --- a/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/CanalServerExports.java +++ /dev/null @@ -1,21 +0,0 @@ -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/InstanceRegistry.java b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/InstanceRegistry.java new file mode 100644 index 00000000..e320efc4 --- /dev/null +++ b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/InstanceRegistry.java @@ -0,0 +1,14 @@ +package com.alibaba.otter.canal.prometheus; + +import com.alibaba.otter.canal.instance.core.CanalInstance; + +/** + * @author Chuanyi Li + */ +public interface InstanceRegistry { + + void register(CanalInstance instance); + + void unregister(CanalInstance instance); + +} 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 index c7942235..485f6728 100644 --- a/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/PrometheusService.java +++ b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/PrometheusService.java @@ -1,6 +1,8 @@ package com.alibaba.otter.canal.prometheus; import com.alibaba.otter.canal.instance.core.CanalInstance; +import com.alibaba.otter.canal.prometheus.impl.PrometheusClientInstanceProfiler; +import com.alibaba.otter.canal.server.netty.ClientInstanceProfiler; import com.alibaba.otter.canal.spi.CanalMetricsService; import io.prometheus.client.exporter.HTTPServer; import io.prometheus.client.hotspot.DefaultExports; @@ -8,23 +10,24 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; + +import static com.alibaba.otter.canal.server.netty.CanalServerWithNettyProfiler.NOP; +import static com.alibaba.otter.canal.server.netty.CanalServerWithNettyProfiler.profiler; /** * @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 static final Logger logger = LoggerFactory.getLogger(PrometheusService.class); + private final CanalInstanceExports instanceExports; + private volatile boolean running = false; + private HTTPServer server; + private final ClientInstanceProfiler clientProfiler; private PrometheusService() { + this.instanceExports = CanalInstanceExports.instance(); + this.clientProfiler = PrometheusClientInstanceProfiler.instance(); } private static class SingletonHolder { @@ -48,8 +51,11 @@ public class PrometheusService implements CanalMetricsService { try { // JVM exports DefaultExports.initialize(); - // Canal server level exports - CanalServerExports.initialize(); + instanceExports.initialize(); + if (!clientProfiler.isStart()) { + clientProfiler.start(); + } + profiler().setInstanceProfiler(clientProfiler); } catch (Throwable t) { logger.warn("Unable to initialize server exports.", t); } @@ -60,14 +66,17 @@ public class PrometheusService implements CanalMetricsService { @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(); + try { + instanceExports.terminate(); + if (clientProfiler.isStart()) { + clientProfiler.stop(); + } + profiler().setInstanceProfiler(NOP); + if (server != null) { + server.stop(); + } + } catch (Throwable t) { + logger.warn("Something happened while terminating.", t); } } @@ -83,9 +92,7 @@ public class PrometheusService implements CanalMetricsService { return; } try { - CanalInstanceExports export = CanalInstanceExports.forInstance(instance); - export.register(); - exports.put(instance.getDestination(), export); + instanceExports.register(instance); } catch (Throwable t) { logger.warn("Unable to register instance exports for {}.", instance.getDestination(), t); } @@ -98,13 +105,11 @@ public class PrometheusService implements CanalMetricsService { logger.warn("Try unregister metrics after destination {} is stopped.", instance.getDestination()); } try { - CanalInstanceExports export = exports.remove(instance.getDestination()); - if (export != null) { - export.unregister(); - } + instanceExports.unregister(instance); } 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/EntryCollector.java b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/EntryCollector.java new file mode 100644 index 00000000..e434bd58 --- /dev/null +++ b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/EntryCollector.java @@ -0,0 +1,153 @@ +package com.alibaba.otter.canal.prometheus.impl; + +import com.alibaba.otter.canal.instance.core.CanalInstance; +import com.alibaba.otter.canal.prometheus.InstanceRegistry; +import com.alibaba.otter.canal.sink.CanalEventDownStreamHandler; +import com.alibaba.otter.canal.sink.CanalEventSink; +import com.alibaba.otter.canal.sink.entry.EntryEventSink; +import com.google.common.base.Preconditions; +import io.prometheus.client.Collector; +import io.prometheus.client.Counter; +import io.prometheus.client.CounterMetricFamily; +import io.prometheus.client.GaugeMetricFamily; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicLong; + +import static com.alibaba.otter.canal.prometheus.CanalInstanceExports.DEST_LABELS_LIST; + +/** + * @author Chuanyi Li + */ +public class EntryCollector extends Collector implements InstanceRegistry { + + private static final Logger logger = LoggerFactory.getLogger(SinkCollector.class); + private static final String DELAY = "canal_instance_traffic_delay"; + private static final String TRANSACTION = "canal_instance_transactions"; + private static final String ROW_EVENTS = "canal_instance_row_events"; + private static final String ROWS_COUNTER = "canal_instance_rows_counter"; + private static final String DELAY_HELP = "Traffic delay of canal instance in milliseconds"; + private static final String TRANSACTION_HELP = "Transactions counter of canal instance"; + private static final String ROW_EVENTS_HELP = "Rowdata events counter of canal instance"; + private static final String ROWS_COUNTER_HELP = "Rows counter of canal instance"; + private final ConcurrentMap instances = new ConcurrentHashMap(); + + private EntryCollector() {} + + private static class SingletonHolder { + private static final EntryCollector SINGLETON = new EntryCollector(); + } + + public static EntryCollector instance() { + return SingletonHolder.SINGLETON; + } + + @Override + public List collect() { + List mfs = new ArrayList(); + GaugeMetricFamily delay = new GaugeMetricFamily(DELAY, + DELAY_HELP, DEST_LABELS_LIST); + CounterMetricFamily transactions = new CounterMetricFamily(TRANSACTION, + TRANSACTION_HELP, DEST_LABELS_LIST); + CounterMetricFamily rowEvents = new CounterMetricFamily(ROW_EVENTS, + ROW_EVENTS_HELP, DEST_LABELS_LIST); + CounterMetricFamily rowsCounter = new CounterMetricFamily(ROWS_COUNTER, + ROWS_COUNTER_HELP, DEST_LABELS_LIST); + for (EntryMetricsHolder emh : instances.values()) { + long now = System.currentTimeMillis(); + long latest = emh.latestExecTime.get(); + if (now >= latest) { + delay.addMetric(emh.destLabelValues, (now - latest)); + } + transactions.addMetric(emh.destLabelValues, emh.transactionCounter.doubleValue()); + rowEvents.addMetric(emh.destLabelValues, emh.rowEventCounter.doubleValue()); + rowsCounter.addMetric(emh.destLabelValues, emh.rowsCounter.doubleValue()); + } + mfs.add(delay); + mfs.add(transactions); + mfs.add(rowEvents); + mfs.add(rowsCounter); + return mfs; + } + + @Override + public void register(CanalInstance instance) { + final String destination = instance.getDestination(); + EntryMetricsHolder holder = new EntryMetricsHolder(); + holder.destLabelValues = Collections.singletonList(destination); + CanalEventSink sink = instance.getEventSink(); + if (!(sink instanceof EntryEventSink)) { + throw new IllegalArgumentException("CanalEventSink must be EntryEventSink"); + } + EntryEventSink entrySink = (EntryEventSink) sink; + PrometheusCanalEventDownStreamHandler handler = assembleHandler(entrySink); + holder.latestExecTime = handler.getLatestExecuteTime(); + holder.transactionCounter = handler.getTransactionCounter(); + holder.rowEventCounter = handler.getRowEventCounter(); + holder.rowsCounter = handler.getRowsCounter(); + Preconditions.checkNotNull(holder.latestExecTime); + Preconditions.checkNotNull(holder.transactionCounter); + Preconditions.checkNotNull(holder.rowEventCounter); + Preconditions.checkNotNull(holder.rowsCounter); + EntryMetricsHolder old = instances.put(destination, holder); + if (old != null) { + logger.warn("Remove stale EntryCollector for instance {}.", destination); + } + } + + @Override + public void unregister(CanalInstance instance) { + final String destination = instance.getDestination(); + CanalEventSink sink = instance.getEventSink(); + if (!(sink instanceof EntryEventSink)) { + throw new IllegalArgumentException("CanalEventSink must be EntryEventSink"); + } + unloadHandler((EntryEventSink) sink); + instances.remove(destination); + } + + private PrometheusCanalEventDownStreamHandler assembleHandler(EntryEventSink entrySink) { + PrometheusCanalEventDownStreamHandler ph = new PrometheusCanalEventDownStreamHandler(); + List handlers = entrySink.getHandlers(); + for (CanalEventDownStreamHandler handler : handlers) { + if (handler instanceof PrometheusCanalEventDownStreamHandler) { + throw new IllegalStateException("PrometheusCanalEventDownStreamHandler already exists in handlers."); + } + } + entrySink.addHandler(ph, 0); + return ph; + } + + private void unloadHandler(EntryEventSink entrySink) { + List handlers = entrySink.getHandlers(); + int i = 0; + for (; i < handlers.size(); i++) { + if (handlers.get(i) instanceof PrometheusCanalEventDownStreamHandler) { + break; + } + } + entrySink.removeHandler(i); + // Ensure no PrometheusCanalEventDownStreamHandler + handlers = entrySink.getHandlers(); + for (CanalEventDownStreamHandler handler : handlers) { + if (handler instanceof PrometheusCanalEventDownStreamHandler) { + throw new IllegalStateException("Multiple prometheusCanalEventDownStreamHandler exists in handlers."); + } + } + } + + private class EntryMetricsHolder { + private AtomicLong latestExecTime; + private AtomicLong transactionCounter; + private AtomicLong rowEventCounter; + private AtomicLong rowsCounter; + private List destLabelValues; + } + +} 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 deleted file mode 100644 index eabc256c..00000000 --- a/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/InboundThroughputAspect.java +++ /dev/null @@ -1,79 +0,0 @@ -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 deleted file mode 100644 index 5562b8fd..00000000 --- a/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/InstanceMetaCollector.java +++ /dev/null @@ -1,64 +0,0 @@ -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 deleted file mode 100644 index 79fdca4a..00000000 --- a/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/MemoryStoreCollector.java +++ /dev/null @@ -1,75 +0,0 @@ -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/MetaCollector.java b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/MetaCollector.java new file mode 100644 index 00000000..e51e8e29 --- /dev/null +++ b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/MetaCollector.java @@ -0,0 +1,91 @@ +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.InstanceRegistry; +import com.alibaba.otter.canal.protocol.ClientIdentity; +import com.google.common.base.Preconditions; +import io.prometheus.client.Collector; +import io.prometheus.client.GaugeMetricFamily; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import static com.alibaba.otter.canal.prometheus.CanalInstanceExports.DEST_LABELS_LIST; + +/** + * @author Chuanyi Li + */ +public class MetaCollector extends Collector implements InstanceRegistry { + + private static final List INFO_LABELS_LIST = Arrays.asList("destination", "mode"); + private static final Logger logger = LoggerFactory.getLogger(MetaCollector.class); + private static final String INSTANCE = "canal_instance"; + private static final String INSTANCE_HELP = "Canal instance"; + private static final String SUBSCRIPTION = "canal_instance_subscriptions"; + private static final String SUBSCRIPTION_HELP = "Canal instance subscriptions"; + private final ConcurrentMap instances = new ConcurrentHashMap(); + + private MetaCollector() {} + + private static class SingletonHolder { + private static final MetaCollector SINGLETON = new MetaCollector(); + } + + public static MetaCollector instance() { + return SingletonHolder.SINGLETON; + } + + @Override + public List collect() { + List mfs = new ArrayList(); + GaugeMetricFamily instanceInfo = new GaugeMetricFamily(INSTANCE, + INSTANCE_HELP, INFO_LABELS_LIST); + GaugeMetricFamily subsInfo = new GaugeMetricFamily(SUBSCRIPTION, + SUBSCRIPTION_HELP, DEST_LABELS_LIST); + for (Map.Entry nme : instances.entrySet()) { + final String destination = nme.getKey(); + final MetaMetricsHolder nmh = nme.getValue(); + instanceInfo.addMetric(nmh.infoLabelValues, 1); + List subs = nmh.metaManager.listAllSubscribeInfo(destination); + int count = subs == null ? 0 : subs.size(); + subsInfo.addMetric(nmh.destLabelValues, count); + } + mfs.add(instanceInfo); + mfs.add(subsInfo); + return mfs; + } + + @Override + public void register(CanalInstance instance) { + final String destination = instance.getDestination(); + MetaMetricsHolder holder = new MetaMetricsHolder(); + String mode = (instance instanceof CanalInstanceWithSpring) ? "spring" : "manager"; + holder.infoLabelValues = Arrays.asList(destination, mode); + holder.destLabelValues = Collections.singletonList(destination); + holder.metaManager = instance.getMetaManager(); + Preconditions.checkNotNull(holder.metaManager); + MetaMetricsHolder old = instances.put(destination, holder); + if (old != null) { + logger.warn("Remove stale MetaCollector for instance {}.", destination); + } + } + + @Override + public void unregister(CanalInstance instance) { + final String destination = instance.getDestination(); + instances.remove(destination); + } + + private class MetaMetricsHolder { + private List infoLabelValues; + private List destLabelValues; + private CanalMetaManager metaManager; + } + + +} 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 deleted file mode 100644 index 60dd808d..00000000 --- a/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/OutboundThroughputAspect.java +++ /dev/null @@ -1,80 +0,0 @@ -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/ParserCollector.java b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/ParserCollector.java new file mode 100644 index 00000000..73102795 --- /dev/null +++ b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/ParserCollector.java @@ -0,0 +1,116 @@ +package com.alibaba.otter.canal.prometheus.impl; + +import com.alibaba.otter.canal.instance.core.CanalInstance; +import com.alibaba.otter.canal.parse.CanalEventParser; +import com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser; +import com.alibaba.otter.canal.prometheus.InstanceRegistry; +import com.google.common.base.Preconditions; +import io.prometheus.client.Collector; +import io.prometheus.client.CounterMetricFamily; +import io.prometheus.client.GaugeMetricFamily; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicLong; + +import static com.alibaba.otter.canal.prometheus.CanalInstanceExports.DEST; +import static com.alibaba.otter.canal.prometheus.CanalInstanceExports.DEST_LABELS_LIST; +import static java.util.concurrent.TimeUnit.NANOSECONDS; + +/** + * @author Chuanyi Li + */ +public class ParserCollector extends Collector implements InstanceRegistry { + + private static final Logger logger = LoggerFactory.getLogger(ParserCollector.class); + private static final long NANO_PER_MILLI = 1000 * 1000L; + private static final String PUBLISH_BLOCKING = "canal_instance_publish_blocking_time"; + private static final String RECEIVED_BINLOG = "canal_instance_received_binlog_bytes"; + private static final String PARSER_MODE = "canal_instance_parser_mode"; + private static final String MODE_LABEL = "parallel"; + private static final String PUBLISH_BLOCKING_HELP = "Publish blocking time of dump thread in milliseconds"; + private static final String RECEIVED_BINLOG_HELP = "Received binlog bytes"; + private static final String MODE_HELP = "Parser mode(parallel/serial) of instance"; + private final List modeLabels = Arrays.asList(DEST, MODE_LABEL); + private final ConcurrentMap instances = new ConcurrentHashMap(); + + private ParserCollector() {} + + private static class SingletonHolder { + private static final ParserCollector SINGLETON = new ParserCollector(); + } + + public static ParserCollector instance() { + return SingletonHolder.SINGLETON; + } + + @Override + public List collect() { + List mfs = new ArrayList(); + boolean hasParallel = false; + CounterMetricFamily bytesCounter = new CounterMetricFamily(RECEIVED_BINLOG, + RECEIVED_BINLOG_HELP, DEST_LABELS_LIST); + GaugeMetricFamily modeGauge = new GaugeMetricFamily(PARSER_MODE, + MODE_HELP, modeLabels); + CounterMetricFamily blockingCounter = new CounterMetricFamily(PUBLISH_BLOCKING, + PUBLISH_BLOCKING_HELP, DEST_LABELS_LIST); + for (ParserMetricsHolder emh : instances.values()) { + if (emh.isParallel) { + blockingCounter.addMetric(emh.destLabelValues, (emh.eventsPublishBlockingTime.doubleValue() / NANO_PER_MILLI)); + hasParallel = true; + } + modeGauge.addMetric(emh.modeLabelValues, 1); + bytesCounter.addMetric(emh.destLabelValues, emh.receivedBinlogBytes.doubleValue()); + + } + mfs.add(bytesCounter); + mfs.add(modeGauge); + if (hasParallel) { + mfs.add(blockingCounter); + } + return mfs; + } + + @Override + public void register(CanalInstance instance) { + final String destination = instance.getDestination(); + ParserMetricsHolder holder = new ParserMetricsHolder(); + CanalEventParser parser = instance.getEventParser(); + if (!(parser instanceof MysqlEventParser)) { + throw new IllegalArgumentException("CanalEventParser must be MysqlEventParser"); + } + MysqlEventParser mysqlParser = (MysqlEventParser) parser; + holder.destLabelValues = Collections.singletonList(destination); + holder.modeLabelValues = Arrays.asList(destination, Boolean.toString(mysqlParser.isParallel())); + holder.eventsPublishBlockingTime = mysqlParser.getEventsPublishBlockingTime(); + holder.receivedBinlogBytes = mysqlParser.getReceivedBinlogBytes(); + holder.isParallel = mysqlParser.isParallel(); + Preconditions.checkNotNull(holder.eventsPublishBlockingTime); + Preconditions.checkNotNull(holder.receivedBinlogBytes); + ParserMetricsHolder old = instances.put(destination, holder); + if (old != null) { + logger.warn("Remove stale ParserCollector for instance {}.", destination); + } + } + + @Override + public void unregister(CanalInstance instance) { + final String destination = instance.getDestination(); + instances.remove(destination); + } + + private class ParserMetricsHolder { + private List destLabelValues; + private List modeLabelValues; + private AtomicLong receivedBinlogBytes; + private AtomicLong eventsPublishBlockingTime; + private boolean isParallel; + } + +} 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 index c55a7eac..f81033a4 100644 --- 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 @@ -1,73 +1,90 @@ package com.alibaba.otter.canal.prometheus.impl; -import com.alibaba.otter.canal.prometheus.CanalInstanceExports; +import com.alibaba.otter.canal.protocol.CanalEntry; +import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; 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; +import java.util.concurrent.atomic.AtomicLong; /** * @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; - } - }; - } + private final AtomicLong latestExecuteTime = new AtomicLong(0L); + private final AtomicLong transactionCounter = new AtomicLong(0L); + private final AtomicLong rowEventCounter = new AtomicLong(0L); + private final AtomicLong rowsCounter = new AtomicLong(0L); @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. + long localExecTime = 0L; if (events != null && !events.isEmpty()) { - Event last = events.get(events.size() - 1); - long ts = last.getExecuteTime(); - if (ts > latestExecuteTime) { - latestExecuteTime = ts; + for (Event e : events) { + EntryType type = e.getEntryType(); + if (type == null) continue; + switch (type) { + case TRANSACTIONBEGIN: { + long exec = e.getExecuteTime(); + if (exec > 0) localExecTime = exec; + break; + } + case ROWDATA: { + long exec = e.getExecuteTime(); + if (exec > 0) localExecTime = exec; + rowEventCounter.incrementAndGet(); + rowsCounter.addAndGet(e.getRowsCount()); + break; + } + case TRANSACTIONEND: { + long exec = e.getExecuteTime(); + if (exec > 0) localExecTime = exec; + transactionCounter.incrementAndGet(); + break; + } + case HEARTBEAT: + CanalEntry.EventType eventType = e.getEventType(); + if (eventType == CanalEntry.EventType.MHEARTBEAT) { + localExecTime = System.currentTimeMillis(); + } + break; + default: + break; + } + } + if (localExecTime > 0) { + latestExecuteTime.lazySet(localExecTime); } } return events; } - public Collector getCollector() { - return this.collector; + @Override + public void start() { + + super.start(); } + @Override + public void stop() { + super.stop(); + } + + public AtomicLong getLatestExecuteTime() { + return latestExecuteTime; + } + + public AtomicLong getTransactionCounter() { + return transactionCounter; + } + + public AtomicLong getRowsCounter() { + return rowsCounter; + } + + public AtomicLong getRowEventCounter() { + return rowEventCounter; + } } diff --git a/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/PrometheusClientInstanceProfiler.java b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/PrometheusClientInstanceProfiler.java new file mode 100644 index 00000000..da16f2db --- /dev/null +++ b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/PrometheusClientInstanceProfiler.java @@ -0,0 +1,138 @@ +package com.alibaba.otter.canal.prometheus.impl; + +import com.alibaba.otter.canal.protocol.CanalPacket.PacketType; +import com.alibaba.otter.canal.server.netty.ClientInstanceProfiler; +import com.alibaba.otter.canal.server.netty.listener.ChannelFutureAggregator.ClientRequestResult; +import io.prometheus.client.CollectorRegistry; +import io.prometheus.client.Counter; +import io.prometheus.client.Histogram; + +import static com.alibaba.otter.canal.prometheus.CanalInstanceExports.DEST; +import static com.alibaba.otter.canal.prometheus.CanalInstanceExports.DEST_LABELS; + +/** + * @author Chuanyi Li + */ +public class PrometheusClientInstanceProfiler implements ClientInstanceProfiler { + + private static final long NANO_PER_MILLI = 1000 * 1000L; + private static final String PACKET_TYPE = "canal_instance_client_packets"; + private static final String OUTBOUND_BYTES = "canal_instance_client_bytes"; + private static final String EMPTY_BATCHES = "canal_instance_client_empty_batches"; + private static final String ERRORS = "canal_instance_client_request_error"; + private static final String LATENCY = "canal_instance_client_request_latency"; + private final Counter outboundCounter; + private final Counter packetsCounter; + private final Counter emptyBatchesCounter; + private final Counter errorsCounter; + private final Histogram responseLatency; + private volatile boolean running = false; + + private static class SingletonHolder { + private static final PrometheusClientInstanceProfiler SINGLETON = new PrometheusClientInstanceProfiler(); + } + + public static PrometheusClientInstanceProfiler instance() { + return SingletonHolder.SINGLETON; + } + + private PrometheusClientInstanceProfiler() { + this.outboundCounter = Counter.build() + .labelNames(DEST_LABELS) + .name(OUTBOUND_BYTES) + .help("Total bytes sent to client.") + .create(); + this.packetsCounter = Counter.build() + .labelNames(new String[]{DEST, "packetType"}) + .name(PACKET_TYPE) + .help("Total packets sent to client.") + .create(); + this.emptyBatchesCounter = Counter.build() + .labelNames(DEST_LABELS) + .name(EMPTY_BATCHES) + .help("Total empty batches sent to client.") + .create(); + this.errorsCounter = Counter.build() + .labelNames(new String[]{DEST, "errorCode"}) + .name(ERRORS) + .help("Total client request errors.") + .create(); + this.responseLatency = Histogram.build() + .labelNames(DEST_LABELS) + .name(LATENCY) + .help("Client request latency.") + // buckets in milliseconds + .buckets(2.5, 10.0, 25.0, 100.0) + .create(); + } + + @Override + public void profiling(ClientRequestResult result) { + String destination = result.getDestination(); + PacketType type = result.getType(); + outboundCounter.labels(destination).inc(result.getAmount()); + packetsCounter.labels(destination, type.name()).inc(); + short errorCode = result.getErrorCode(); + if (errorCode > 0) { + errorsCounter.labels(destination, Short.toString(errorCode)).inc(); + } + long latency = result.getLatency(); + responseLatency.labels(destination).observe(((double) latency) / NANO_PER_MILLI); + switch (type) { + case GET: + boolean empty = result.getEmpty(); + if (empty) { + emptyBatchesCounter.labels(destination).inc(); + } + break; + // reserve for others + default: + break; + } + } + + @Override + public void start() { + if (outboundCounter != null) { + outboundCounter.register(); + } + if (packetsCounter != null) { + packetsCounter.register(); + } + if (emptyBatchesCounter != null) { + emptyBatchesCounter.register(); + } + if (errorsCounter != null) { + errorsCounter.register(); + } + if (responseLatency != null) { + responseLatency.register(); + } + running = true; + } + + @Override + public void stop() { + running = false; + if (outboundCounter != null) { + CollectorRegistry.defaultRegistry.unregister(outboundCounter); + } + if (packetsCounter != null) { + CollectorRegistry.defaultRegistry.unregister(packetsCounter); + } + if (emptyBatchesCounter != null) { + CollectorRegistry.defaultRegistry.unregister(emptyBatchesCounter); + } + if (errorsCounter != null) { + CollectorRegistry.defaultRegistry.unregister(errorsCounter); + } + if (responseLatency != null) { + CollectorRegistry.defaultRegistry.unregister(responseLatency); + } + } + + @Override + public boolean isStart() { + return running; + } +} diff --git a/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/SinkCollector.java b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/SinkCollector.java new file mode 100644 index 00000000..61dc4d64 --- /dev/null +++ b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/SinkCollector.java @@ -0,0 +1,84 @@ +package com.alibaba.otter.canal.prometheus.impl; + +import com.alibaba.otter.canal.instance.core.CanalInstance; +import com.alibaba.otter.canal.prometheus.InstanceRegistry; +import com.alibaba.otter.canal.sink.CanalEventSink; +import com.alibaba.otter.canal.sink.entry.EntryEventSink; +import com.google.common.base.Preconditions; +import io.prometheus.client.Collector; +import io.prometheus.client.CounterMetricFamily; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicLong; + +import static com.alibaba.otter.canal.prometheus.CanalInstanceExports.DEST_LABELS_LIST; +import static java.util.concurrent.TimeUnit.NANOSECONDS; + +/** + * @author Chuanyi Li + */ +public class SinkCollector extends Collector implements InstanceRegistry { + + private static final Logger logger = LoggerFactory.getLogger(SinkCollector.class); + private static final long NANO_PER_MILLI = 1000 * 1000L; + private static final String SINK_BLOCKING_TIME = "canal_instance_sink_blocking_time"; + private static final String SINK_BLOCK_TIME_HELP = "Total sink blocking time in milliseconds"; + private final ConcurrentMap instances = new ConcurrentHashMap(); + + private SinkCollector() {} + + private static class SingletonHolder { + private static final SinkCollector SINGLETON = new SinkCollector(); + } + + public static SinkCollector instance() { + return SingletonHolder.SINGLETON; + } + + @Override + public List collect() { + List mfs = new ArrayList(); + CounterMetricFamily blockingCounter = new CounterMetricFamily(SINK_BLOCKING_TIME, + SINK_BLOCK_TIME_HELP, DEST_LABELS_LIST); + for (SinkMetricsHolder smh : instances.values()) { + blockingCounter.addMetric(smh.destLabelValues, (smh.eventsSinkBlockingTime.doubleValue() / NANO_PER_MILLI)); + } + mfs.add(blockingCounter); + return mfs; + } + + @Override + public void register(CanalInstance instance) { + final String destination = instance.getDestination(); + SinkMetricsHolder holder = new SinkMetricsHolder(); + holder.destLabelValues = Collections.singletonList(destination); + CanalEventSink sink = instance.getEventSink(); + if (!(sink instanceof EntryEventSink)) { + throw new IllegalArgumentException("CanalEventSink must be EntryEventSink"); + } + EntryEventSink entrySink = (EntryEventSink) sink; + holder.eventsSinkBlockingTime = entrySink.getEventsSinkBlockingTime(); + Preconditions.checkNotNull(holder.eventsSinkBlockingTime); + SinkMetricsHolder old = instances.put(destination, holder); + if (old != null) { + logger.warn("Remote stale SinkCollector for instance {}.", destination); + } + } + + @Override + public void unregister(CanalInstance instance) { + final String destination = instance.getDestination(); + instances.remove(destination); + } + + private class SinkMetricsHolder { + private AtomicLong eventsSinkBlockingTime; + private List destLabelValues; + } +} diff --git a/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/StoreCollector.java b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/StoreCollector.java new file mode 100644 index 00000000..3be87c3e --- /dev/null +++ b/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/StoreCollector.java @@ -0,0 +1,134 @@ +package com.alibaba.otter.canal.prometheus.impl; + +import com.alibaba.otter.canal.instance.core.CanalInstance; +import com.alibaba.otter.canal.prometheus.InstanceRegistry; +import com.alibaba.otter.canal.store.CanalEventStore; +import com.alibaba.otter.canal.store.memory.MemoryEventStoreWithBuffer; +import com.alibaba.otter.canal.store.model.BatchMode; +import com.google.common.base.Preconditions; +import io.prometheus.client.Collector; +import io.prometheus.client.CounterMetricFamily; +import io.prometheus.client.GaugeMetricFamily; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicLong; + +import static com.alibaba.otter.canal.prometheus.CanalInstanceExports.DEST; +import static com.alibaba.otter.canal.prometheus.CanalInstanceExports.DEST_LABELS_LIST; + +/** + * @author Chuanyi Li + */ +public class StoreCollector extends Collector implements InstanceRegistry { + + private static final Logger logger = LoggerFactory.getLogger(SinkCollector.class); + private static final String PRODUCE = "canal_instance_store_produce_seq"; + private static final String CONSUME = "canal_instance_store_consume_seq"; + private static final String STORE = "canal_instance_store"; + private static final String PRODUCE_MEM = "canal_instance_store_produce_mem"; + private static final String CONSUME_MEM = "canal_instance_store_consume_mem"; + private static final String PRODUCE_HELP = "Produced events counter of canal instance"; + private static final String CONSUME_HELP = "Consumed events counter of canal instance"; + private static final String STORE_HELP = "Canal instance info"; + private static final String PRODUCE_MEM_HELP = "Produced mem bytes of canal instance"; + private static final String CONSUME_MEM_HELP = "Consumed mem bytes of canal instance"; + private final ConcurrentMap instances = new ConcurrentHashMap(); + private final List storeLabelsList = Arrays.asList(DEST, "batchMode"); + + private StoreCollector() {} + + private static class SingletonHolder { + private static final StoreCollector SINGLETON = new StoreCollector(); + } + + public static StoreCollector instance() { + return SingletonHolder.SINGLETON; + } + + @Override + public List collect() { + List mfs = new ArrayList(); + CounterMetricFamily put = new CounterMetricFamily(PRODUCE, + PRODUCE_HELP, DEST_LABELS_LIST); + CounterMetricFamily ack = new CounterMetricFamily(CONSUME, + CONSUME_HELP, DEST_LABELS_LIST); + GaugeMetricFamily store = new GaugeMetricFamily(STORE, + STORE_HELP, storeLabelsList); + CounterMetricFamily putMem = new CounterMetricFamily(PRODUCE_MEM, + PRODUCE_MEM_HELP, DEST_LABELS_LIST); + CounterMetricFamily ackMem = new CounterMetricFamily(CONSUME_MEM, + CONSUME_MEM_HELP, DEST_LABELS_LIST); + boolean hasMem = false; + for (StoreMetricsHolder smh : instances.values()) { + final boolean isMem = smh.batchMode.isMemSize(); + put.addMetric(smh.destLabelValues, smh.putSeq.doubleValue()); + ack.addMetric(smh.destLabelValues, smh.ackSeq.doubleValue()); + store.addMetric(smh.storeLabelValues, 1); + if (isMem) { + hasMem = true; + putMem.addMetric(smh.destLabelValues, smh.putMemSize.doubleValue()); + ackMem.addMetric(smh.destLabelValues, smh.ackMemSize.doubleValue()); + } + } + mfs.add(put); + mfs.add(ack); + mfs.add(store); + if (hasMem) { + mfs.add(putMem); + mfs.add(ackMem); + } + return mfs; + } + + @Override + public void register(CanalInstance instance) { + final String destination = instance.getDestination(); + StoreMetricsHolder holder = new StoreMetricsHolder(); + CanalEventStore store = instance.getEventStore(); + if (!(store instanceof MemoryEventStoreWithBuffer)) { + throw new IllegalArgumentException("EventStore must be MemoryEventStoreWithBuffer"); + } + MemoryEventStoreWithBuffer memStore = (MemoryEventStoreWithBuffer) store; + holder.batchMode = memStore.getBatchMode(); + holder.putSeq = memStore.getPutSequence(); + holder.ackSeq = memStore.getAckSequence(); + holder.destLabelValues = Collections.singletonList(destination); + holder.storeLabelValues = Arrays.asList(destination, memStore.getBatchMode().name()); + Preconditions.checkNotNull(holder.batchMode); + Preconditions.checkNotNull(holder.putSeq); + Preconditions.checkNotNull(holder.ackSeq); + if (holder.batchMode.isMemSize()) { + holder.putMemSize = memStore.getPutMemSize(); + holder.ackMemSize = memStore.getAckMemSize(); + Preconditions.checkNotNull(holder.putMemSize); + Preconditions.checkNotNull(holder.ackMemSize); + } + StoreMetricsHolder old = instances.putIfAbsent(destination, holder); + if (old != null) { + logger.warn("Remote stale StoreCollector for instance {}.", destination); + } + } + + @Override + public void unregister(CanalInstance instance) { + final String destination = instance.getDestination(); + instances.remove(destination); + } + + private class StoreMetricsHolder { + private AtomicLong putSeq; + private AtomicLong ackSeq; + private BatchMode batchMode; + private AtomicLong putMemSize; + private AtomicLong ackMemSize; + private List destLabelValues; + private List storeLabelValues; + } +} diff --git a/prometheus/src/main/resources/META-INF/aop.xml b/prometheus/src/main/resources/META-INF/aop.xml deleted file mode 100644 index 8bd31d0c..00000000 --- a/prometheus/src/main/resources/META-INF/aop.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/protocol/pom.xml b/protocol/pom.xml index ec7c7867..94715d15 100644 --- a/protocol/pom.xml +++ b/protocol/pom.xml @@ -3,7 +3,7 @@ com.alibaba.otter canal - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT ../pom.xml com.alibaba.otter 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 1a0979db..051d8bf6 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,13051 +4,12836 @@ 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} + * + *
    +   **打散后的事件类型,主要用于标识事务的开始,变更数据,结束*
    +   * 
    + */ + public enum EntryType + implements com.google.protobuf.ProtocolMessageEnum { /** - * Protobuf enum {@code com.alibaba.otter.canal.protocol.EntryType} + * TRANSACTIONBEGIN = 1; + */ + TRANSACTIONBEGIN(0, 1), + /** + * ROWDATA = 2; + */ + ROWDATA(1, 2), + /** + * TRANSACTIONEND = 3; + */ + TRANSACTIONEND(2, 3), + /** + * HEARTBEAT = 4; * *
    -     * *打散后的事件类型,主要用于标识事务的开始,变更数据,结束*
    +     ** 心跳类型,内部使用,外部暂不可见,可忽略 *
          * 
    */ - 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; - * - *
    -         * * 心跳类型,内部使用,外部暂不可见,可忽略 *
    -         * 
    - */ - 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; - /** - * HEARTBEAT = 4; - * - *
    -         * * 心跳类型,内部使用,外部暂不可见,可忽略 *
    -         * 
    - */ - public static final int HEARTBEAT_VALUE = 4; - /** - * GTIDLOG = 5; - */ - public static final int GTIDLOG_VALUE = 5; - - 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 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) - } + HEARTBEAT(3, 4), + /** + * GTIDLOG = 5; + */ + GTIDLOG(4, 5), + ; /** - * Protobuf enum {@code com.alibaba.otter.canal.protocol.EventType} + * 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; * *
    -     * * 事件类型 *
    +     ** 心跳类型,内部使用,外部暂不可见,可忽略 *
          * 
    */ - 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 static final int HEARTBEAT_VALUE = 4; + /** + * GTIDLOG = 5; + */ + public static final int GTIDLOG_VALUE = 5; - /** - * 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 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 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 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 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 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} + * + *
    +   ** 事件类型 *
    +   * 
    + */ + 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), + /** + * XACOMMIT = 13; + * + *
    +     ** XA *
    +     * 
    + */ + XACOMMIT(12, 13), + /** + * XAROLLBACK = 14; + */ + XAROLLBACK(13, 14), + /** + * MHEARTBEAT = 15; + * + *
    +     ** MASTER HEARTBEAT *
    +     * 
    + */ + MHEARTBEAT(14, 15), + ; + /** - * Protobuf enum {@code com.alibaba.otter.canal.protocol.Type} + * 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 enum Type implements com.google.protobuf.ProtocolMessageEnum { - /** - * ORACLE = 1; - */ - ORACLE(0, 1), - /** - * MYSQL = 2; - */ - MYSQL(1, 2), - /** - * PGSQL = 3; - */ - PGSQL(2, 3), ; + 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; + /** + * XACOMMIT = 13; + * + *
    +     ** XA *
    +     * 
    + */ + public static final int XACOMMIT_VALUE = 13; + /** + * XAROLLBACK = 14; + */ + public static final int XAROLLBACK_VALUE = 14; + /** + * MHEARTBEAT = 15; + * + *
    +     ** MASTER HEARTBEAT *
    +     * 
    + */ + public static final int MHEARTBEAT_VALUE = 15; - /** - * 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 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) + 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 XACOMMIT; + case 14: return XAROLLBACK; + case 15: return MHEARTBEAT; + default: return null; + } } - public interface EntryOrBuilder extends - // @@protoc_insertion_point(interface_extends:com.alibaba.otter.canal.protocol.Entry) - com.google.protobuf.MessageOrBuilder { + 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); + } + }; - /** - * optional .com.alibaba.otter.canal.protocol.Header header = 1; - * - *
    -         * *协议头部信息*
    -         * 
    - */ - boolean hasHeader(); - - /** - * optional .com.alibaba.otter.canal.protocol.Header header = 1; - * - *
    -         * *协议头部信息*
    -         * 
    - */ - com.alibaba.otter.canal.protocol.CanalEntry.Header getHeader(); - - /** - * optional .com.alibaba.otter.canal.protocol.Header header = 1; - * - *
    -         * *协议头部信息*
    -         * 
    - */ - com.alibaba.otter.canal.protocol.CanalEntry.HeaderOrBuilder getHeaderOrBuilder(); - - /** - * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; - * - *
    -         * *打散后的事件类型*
    -         * 
    - */ - boolean hasEntryType(); - - /** - * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; - * - *
    -         * *打散后的事件类型*
    -         * 
    - */ - com.alibaba.otter.canal.protocol.CanalEntry.EntryType getEntryType(); - - /** - * optional bytes storeValue = 3; - * - *
    -         * *传输的二进制数组*
    -         * 
    - */ - boolean hasStoreValue(); - - /** - * optional bytes storeValue = 3; - * - *
    -         * *传输的二进制数组*
    -         * 
    - */ - com.google.protobuf.ByteString getStoreValue(); + 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 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 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} + * + *
    +   **数据库类型*
    +   * 
    + */ + 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; + + + 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 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 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 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 { + + /** + * optional .com.alibaba.otter.canal.protocol.Header header = 1; + * + *
    +     **协议头部信息*
    +     * 
    + */ + boolean hasHeader(); + /** + * optional .com.alibaba.otter.canal.protocol.Header header = 1; + * + *
    +     **协议头部信息*
    +     * 
    + */ + Header getHeader(); + /** + * optional .com.alibaba.otter.canal.protocol.Header header = 1; + * + *
    +     **协议头部信息*
    +     * 
    + */ + HeaderOrBuilder getHeaderOrBuilder(); + + /** + * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; + * + *
    +     **打散后的事件类型*
    +     * 
    + */ + boolean hasEntryType(); + /** + * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; + * + *
    +     **打散后的事件类型*
    +     * 
    + */ + EntryType getEntryType(); + + /** + * optional bytes storeValue = 3; + * + *
    +     **传输的二进制数组*
    +     * 
    + */ + boolean hasStoreValue(); + /** + * optional bytes storeValue = 3; + * + *
    +     **传输的二进制数组*
    +     * 
    + */ + com.google.protobuf.ByteString getStoreValue(); + } + /** + * Protobuf type {@code com.alibaba.otter.canal.protocol.Entry} + * + *
    +   ****************************************************************
    +   * message model
    +   *如果要在Enum中新增类型,确保以前的类型的下标值不变.
    +   ***************************************************************
    +   * 
    + */ + 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(); } + + private static final Entry defaultInstance; + public static Entry getDefaultInstance() { + return defaultInstance; + } + + public Entry getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @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: { + Header.Builder subBuilder = null; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + subBuilder = header_.toBuilder(); + } + header_ = input.readMessage(Header.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(header_); + header_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000001; + break; + } + case 16: { + int rawValue = input.readEnum(); + EntryType value = 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 CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Entry_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Entry_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Entry.class, 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); + } + }; + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + public static final int HEADER_FIELD_NUMBER = 1; + private Header header_; + /** + * optional .com.alibaba.otter.canal.protocol.Header header = 1; + * + *
    +     **协议头部信息*
    +     * 
    + */ + public boolean hasHeader() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional .com.alibaba.otter.canal.protocol.Header header = 1; + * + *
    +     **协议头部信息*
    +     * 
    + */ + public Header getHeader() { + return header_; + } + /** + * optional .com.alibaba.otter.canal.protocol.Header header = 1; + * + *
    +     **协议头部信息*
    +     * 
    + */ + public HeaderOrBuilder getHeaderOrBuilder() { + return header_; + } + + public static final int ENTRYTYPE_FIELD_NUMBER = 2; + private EntryType entryType_; + /** + * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; + * + *
    +     **打散后的事件类型*
    +     * 
    + */ + public boolean hasEntryType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; + * + *
    +     **打散后的事件类型*
    +     * 
    + */ + public EntryType getEntryType() { + return entryType_; + } + + public static final int STOREVALUE_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString storeValue_; + /** + * optional bytes storeValue = 3; + * + *
    +     **传输的二进制数组*
    +     * 
    + */ + public boolean hasStoreValue() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional bytes storeValue = 3; + * + *
    +     **传输的二进制数组*
    +     * 
    + */ + public com.google.protobuf.ByteString getStoreValue() { + return storeValue_; + } + + private void initFields() { + header_ = Header.getDefaultInstance(); + entryType_ = 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; + + memoizedIsInitialized = 1; + return true; + } + + 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 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 + .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; + @Override + protected Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static Entry parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Entry parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Entry parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Entry parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Entry parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static Entry parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static Entry parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static Entry parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static Entry parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static 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(Entry prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } /** * Protobuf type {@code com.alibaba.otter.canal.protocol.Entry} * *
          ****************************************************************
    -     *  message model
    -     * 如果要在Enum中新增类型,确保以前的类型的下标值不变.
    +     * message model
    +     *如果要在Enum中新增类型,确保以前的类型的下标值不变.
          ***************************************************************
          * 
    */ - 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(); - } - - 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; - } - } - } - } 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_; - - /** - * optional .com.alibaba.otter.canal.protocol.Header header = 1; - * - *
    -         * *协议头部信息*
    -         * 
    - */ - public boolean hasHeader() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - - /** - * optional .com.alibaba.otter.canal.protocol.Header header = 1; - * - *
    -         * *协议头部信息*
    -         * 
    - */ - public com.alibaba.otter.canal.protocol.CanalEntry.Header getHeader() { - return header_; - } - - /** - * optional .com.alibaba.otter.canal.protocol.Header header = 1; - * - *
    -         * *协议头部信息*
    -         * 
    - */ - 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_; - - /** - * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; - * - *
    -         * *打散后的事件类型*
    -         * 
    - */ - public boolean hasEntryType() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - - /** - * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; - * - *
    -         * *打散后的事件类型*
    -         * 
    - */ - 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_; - - /** - * optional bytes storeValue = 3; - * - *
    -         * *传输的二进制数组*
    -         * 
    - */ - public boolean hasStoreValue() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - - /** - * optional bytes storeValue = 3; - * - *
    -         * *传输的二进制数组*
    -         * 
    - */ - 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; - - memoizedIsInitialized = 1; - return true; - } - - 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 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.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; - } - - /** - * Protobuf type {@code com.alibaba.otter.canal.protocol.Entry} - * - *
    -         ****************************************************************
    -         *  message model
    -         * 如果要在Enum中新增类型,确保以前的类型的下标值不变.
    -         ***************************************************************
    -         * 
    - */ - 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 { + EntryOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Entry_descriptor; + } - 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 FieldAccessorTable + internalGetFieldAccessorTable() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Entry_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Entry.class, Builder.class); + } - 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); - } + // Construct using com.alibaba.otter.canal.protocol.CanalEntry.Entry.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } - // Construct using - // com.alibaba.otter.canal.protocol.CanalEntry.Entry.newBuilder() - private Builder(){ - maybeForceBuilderInitialization(); - } - - 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(); - } - - 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 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_Entry_descriptor; - } - - public com.alibaba.otter.canal.protocol.CanalEntry.Entry getDefaultInstanceForType() { - return com.alibaba.otter.canal.protocol.CanalEntry.Entry.getDefaultInstance(); - } - - 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 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.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_; - - /** - * optional .com.alibaba.otter.canal.protocol.Header header = 1; - * - *
    -             * *协议头部信息*
    -             * 
    - */ - public boolean hasHeader() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - - /** - * optional .com.alibaba.otter.canal.protocol.Header header = 1; - * - *
    -             * *协议头部信息*
    -             * 
    - */ - 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; - * - *
    -             * *协议头部信息*
    -             * 
    - */ - 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; - * - *
    -             * *协议头部信息*
    -             * 
    - */ - 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; - * - *
    -             * *协议头部信息*
    -             * 
    - */ - 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; - * - *
    -             * *协议头部信息*
    -             * 
    - */ - 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; - * - *
    -             * *协议头部信息*
    -             * 
    - */ - 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; - * - *
    -             * *协议头部信息*
    -             * 
    - */ - 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; - * - *
    -             * *协议头部信息*
    -             * 
    - */ - 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; - - /** - * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; - * - *
    -             * *打散后的事件类型*
    -             * 
    - */ - public boolean hasEntryType() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - - /** - * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; - * - *
    -             * *打散后的事件类型*
    -             * 
    - */ - public com.alibaba.otter.canal.protocol.CanalEntry.EntryType getEntryType() { - return entryType_; - } - - /** - * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; - * - *
    -             * *打散后的事件类型*
    -             * 
    - */ - 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) + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getHeaderFieldBuilder(); } + } + private static Builder create() { + return new Builder(); + } - static { - defaultInstance = new Entry(true); - defaultInstance.initFields(); + public Builder clear() { + super.clear(); + if (headerBuilder_ == null) { + header_ = Header.getDefaultInstance(); + } else { + headerBuilder_.clear(); } + bitField0_ = (bitField0_ & ~0x00000001); + entryType_ = EntryType.ROWDATA; + bitField0_ = (bitField0_ & ~0x00000002); + storeValue_ = com.google.protobuf.ByteString.EMPTY; + bitField0_ = (bitField0_ & ~0x00000004); + return this; + } - // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.Entry) + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Entry_descriptor; + } + + public Entry getDefaultInstanceForType() { + return Entry.getDefaultInstance(); + } + + public Entry build() { + Entry result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public Entry buildPartial() { + Entry result = new 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.Message other) { + if (other instanceof Entry) { + return mergeFrom((Entry)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(Entry other) { + if (other == 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 { + Entry parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (Entry) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private Header header_ = Header.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + Header, Header.Builder, HeaderOrBuilder> headerBuilder_; + /** + * optional .com.alibaba.otter.canal.protocol.Header header = 1; + * + *
    +       **协议头部信息*
    +       * 
    + */ + public boolean hasHeader() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional .com.alibaba.otter.canal.protocol.Header header = 1; + * + *
    +       **协议头部信息*
    +       * 
    + */ + public Header getHeader() { + if (headerBuilder_ == null) { + return header_; + } else { + return headerBuilder_.getMessage(); + } + } + /** + * optional .com.alibaba.otter.canal.protocol.Header header = 1; + * + *
    +       **协议头部信息*
    +       * 
    + */ + public Builder setHeader(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; + * + *
    +       **协议头部信息*
    +       * 
    + */ + public Builder setHeader( + 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; + * + *
    +       **协议头部信息*
    +       * 
    + */ + public Builder mergeHeader(Header value) { + if (headerBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001) && + header_ != Header.getDefaultInstance()) { + header_ = + 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; + * + *
    +       **协议头部信息*
    +       * 
    + */ + public Builder clearHeader() { + if (headerBuilder_ == null) { + header_ = Header.getDefaultInstance(); + onChanged(); + } else { + headerBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + /** + * optional .com.alibaba.otter.canal.protocol.Header header = 1; + * + *
    +       **协议头部信息*
    +       * 
    + */ + public Header.Builder getHeaderBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getHeaderFieldBuilder().getBuilder(); + } + /** + * optional .com.alibaba.otter.canal.protocol.Header header = 1; + * + *
    +       **协议头部信息*
    +       * 
    + */ + public HeaderOrBuilder getHeaderOrBuilder() { + if (headerBuilder_ != null) { + return headerBuilder_.getMessageOrBuilder(); + } else { + return header_; + } + } + /** + * optional .com.alibaba.otter.canal.protocol.Header header = 1; + * + *
    +       **协议头部信息*
    +       * 
    + */ + private com.google.protobuf.SingleFieldBuilder< + Header, Header.Builder, HeaderOrBuilder> + getHeaderFieldBuilder() { + if (headerBuilder_ == null) { + headerBuilder_ = new com.google.protobuf.SingleFieldBuilder< + Header, Header.Builder, HeaderOrBuilder>( + getHeader(), + getParentForChildren(), + isClean()); + header_ = null; + } + return headerBuilder_; + } + + private EntryType entryType_ = EntryType.ROWDATA; + /** + * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; + * + *
    +       **打散后的事件类型*
    +       * 
    + */ + public boolean hasEntryType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; + * + *
    +       **打散后的事件类型*
    +       * 
    + */ + public EntryType getEntryType() { + return entryType_; + } + /** + * optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = ROWDATA]; + * + *
    +       **打散后的事件类型*
    +       * 
    + */ + public Builder setEntryType(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_ = 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) } - 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]; - * - *
    -         * *协议的版本号*
    -         * 
    - */ - boolean hasVersion(); - - /** - * optional int32 version = 1 [default = 1]; - * - *
    -         * *协议的版本号*
    -         * 
    - */ - int getVersion(); - - /** - * optional string logfileName = 2; - * - *
    -         * *binlog/redolog 文件名*
    -         * 
    - */ - boolean hasLogfileName(); - - /** - * optional string logfileName = 2; - * - *
    -         * *binlog/redolog 文件名*
    -         * 
    - */ - java.lang.String getLogfileName(); - - /** - * optional string logfileName = 2; - * - *
    -         * *binlog/redolog 文件名*
    -         * 
    - */ - com.google.protobuf.ByteString getLogfileNameBytes(); - - /** - * optional int64 logfileOffset = 3; - * - *
    -         * *binlog/redolog 文件的偏移位置*
    -         * 
    - */ - boolean hasLogfileOffset(); - - /** - * optional int64 logfileOffset = 3; - * - *
    -         * *binlog/redolog 文件的偏移位置*
    -         * 
    - */ - long getLogfileOffset(); - - /** - * optional int64 serverId = 4; - * - *
    -         * *服务端serverId*
    -         * 
    - */ - boolean hasServerId(); - - /** - * optional int64 serverId = 4; - * - *
    -         * *服务端serverId*
    -         * 
    - */ - long getServerId(); - - /** - * optional string serverenCode = 5; - * - *
    -         * * 变更数据的编码 *
    -         * 
    - */ - boolean hasServerenCode(); - - /** - * optional string serverenCode = 5; - * - *
    -         * * 变更数据的编码 *
    -         * 
    - */ - java.lang.String getServerenCode(); - - /** - * optional string serverenCode = 5; - * - *
    -         * * 变更数据的编码 *
    -         * 
    - */ - com.google.protobuf.ByteString getServerenCodeBytes(); - - /** - * optional int64 executeTime = 6; - * - *
    -         * *变更数据的执行时间 *
    -         * 
    - */ - boolean hasExecuteTime(); - - /** - * optional int64 executeTime = 6; - * - *
    -         * *变更数据的执行时间 *
    -         * 
    - */ - long getExecuteTime(); - - /** - * optional .com.alibaba.otter.canal.protocol.Type sourceType = 7 [default = MYSQL]; - * - *
    -         * * 变更数据的来源*
    -         * 
    - */ - boolean hasSourceType(); - - /** - * optional .com.alibaba.otter.canal.protocol.Type sourceType = 7 [default = MYSQL]; - * - *
    -         * * 变更数据的来源*
    -         * 
    - */ - com.alibaba.otter.canal.protocol.CanalEntry.Type getSourceType(); - - /** - * optional string schemaName = 8; - * - *
    -         * * 变更数据的schemaname*
    -         * 
    - */ - boolean hasSchemaName(); - - /** - * optional string schemaName = 8; - * - *
    -         * * 变更数据的schemaname*
    -         * 
    - */ - java.lang.String getSchemaName(); - - /** - * optional string schemaName = 8; - * - *
    -         * * 变更数据的schemaname*
    -         * 
    - */ - com.google.protobuf.ByteString getSchemaNameBytes(); - - /** - * optional string tableName = 9; - * - *
    -         * *变更数据的tablename*
    -         * 
    - */ - boolean hasTableName(); - - /** - * optional string tableName = 9; - * - *
    -         * *变更数据的tablename*
    -         * 
    - */ - java.lang.String getTableName(); - - /** - * optional string tableName = 9; - * - *
    -         * *变更数据的tablename*
    -         * 
    - */ - com.google.protobuf.ByteString getTableNameBytes(); - - /** - * optional int64 eventLength = 10; - * - *
    -         * *每个event的长度*
    -         * 
    - */ - boolean hasEventLength(); - - /** - * optional int64 eventLength = 10; - * - *
    -         * *每个event的长度*
    -         * 
    - */ - long getEventLength(); - - /** - * optional .com.alibaba.otter.canal.protocol.EventType eventType = 11 [default = UPDATE]; - * - *
    -         * *数据变更类型*
    -         * 
    - */ - boolean hasEventType(); - - /** - * optional .com.alibaba.otter.canal.protocol.EventType eventType = 11 [default = UPDATE]; - * - *
    -         * *数据变更类型*
    -         * 
    - */ - com.alibaba.otter.canal.protocol.CanalEntry.EventType getEventType(); - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
    -         * *预留扩展*
    -         * 
    - */ - java.util.List getPropsList(); - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
    -         * *预留扩展*
    -         * 
    - */ - com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index); - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
    -         * *预留扩展*
    -         * 
    - */ - int getPropsCount(); - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
    -         * *预留扩展*
    -         * 
    - */ - java.util.List getPropsOrBuilderList(); - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
    -         * *预留扩展*
    -         * 
    - */ - com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index); - - /** - * optional string gtid = 13; - * - *
    -         * *当前事务的gitd*
    -         * 
    - */ - boolean hasGtid(); - - /** - * optional string gtid = 13; - * - *
    -         * *当前事务的gitd*
    -         * 
    - */ - java.lang.String getGtid(); - - /** - * optional string gtid = 13; - * - *
    -         * *当前事务的gitd*
    -         * 
    - */ - com.google.protobuf.ByteString getGtidBytes(); + 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 { + + /** + * optional int32 version = 1 [default = 1]; + * + *
    +     **协议的版本号*
    +     * 
    + */ + boolean hasVersion(); + /** + * optional int32 version = 1 [default = 1]; + * + *
    +     **协议的版本号*
    +     * 
    + */ + int getVersion(); + + /** + * optional string logfileName = 2; + * + *
    +     **binlog/redolog 文件名*
    +     * 
    + */ + boolean hasLogfileName(); + /** + * optional string logfileName = 2; + * + *
    +     **binlog/redolog 文件名*
    +     * 
    + */ + String getLogfileName(); + /** + * optional string logfileName = 2; + * + *
    +     **binlog/redolog 文件名*
    +     * 
    + */ + com.google.protobuf.ByteString + getLogfileNameBytes(); + + /** + * optional int64 logfileOffset = 3; + * + *
    +     **binlog/redolog 文件的偏移位置*
    +     * 
    + */ + boolean hasLogfileOffset(); + /** + * optional int64 logfileOffset = 3; + * + *
    +     **binlog/redolog 文件的偏移位置*
    +     * 
    + */ + long getLogfileOffset(); + + /** + * optional int64 serverId = 4; + * + *
    +     **服务端serverId*
    +     * 
    + */ + boolean hasServerId(); + /** + * optional int64 serverId = 4; + * + *
    +     **服务端serverId*
    +     * 
    + */ + long getServerId(); + + /** + * optional string serverenCode = 5; + * + *
    +     ** 变更数据的编码 *
    +     * 
    + */ + boolean hasServerenCode(); + /** + * optional string serverenCode = 5; + * + *
    +     ** 变更数据的编码 *
    +     * 
    + */ + String getServerenCode(); + /** + * optional string serverenCode = 5; + * + *
    +     ** 变更数据的编码 *
    +     * 
    + */ + com.google.protobuf.ByteString + getServerenCodeBytes(); + + /** + * optional int64 executeTime = 6; + * + *
    +     **变更数据的执行时间 *
    +     * 
    + */ + boolean hasExecuteTime(); + /** + * optional int64 executeTime = 6; + * + *
    +     **变更数据的执行时间 *
    +     * 
    + */ + long getExecuteTime(); + + /** + * optional .com.alibaba.otter.canal.protocol.Type sourceType = 7 [default = MYSQL]; + * + *
    +     ** 变更数据的来源*
    +     * 
    + */ + boolean hasSourceType(); + /** + * optional .com.alibaba.otter.canal.protocol.Type sourceType = 7 [default = MYSQL]; + * + *
    +     ** 变更数据的来源*
    +     * 
    + */ + Type getSourceType(); + + /** + * optional string schemaName = 8; + * + *
    +     ** 变更数据的schemaname*
    +     * 
    + */ + boolean hasSchemaName(); + /** + * optional string schemaName = 8; + * + *
    +     ** 变更数据的schemaname*
    +     * 
    + */ + String getSchemaName(); + /** + * optional string schemaName = 8; + * + *
    +     ** 变更数据的schemaname*
    +     * 
    + */ + com.google.protobuf.ByteString + getSchemaNameBytes(); + + /** + * optional string tableName = 9; + * + *
    +     **变更数据的tablename*
    +     * 
    + */ + boolean hasTableName(); + /** + * optional string tableName = 9; + * + *
    +     **变更数据的tablename*
    +     * 
    + */ + String getTableName(); + /** + * optional string tableName = 9; + * + *
    +     **变更数据的tablename*
    +     * 
    + */ + com.google.protobuf.ByteString + getTableNameBytes(); + + /** + * optional int64 eventLength = 10; + * + *
    +     **每个event的长度*
    +     * 
    + */ + boolean hasEventLength(); + /** + * optional int64 eventLength = 10; + * + *
    +     **每个event的长度*
    +     * 
    + */ + long getEventLength(); + + /** + * optional .com.alibaba.otter.canal.protocol.EventType eventType = 11 [default = UPDATE]; + * + *
    +     **数据变更类型*
    +     * 
    + */ + boolean hasEventType(); + /** + * optional .com.alibaba.otter.canal.protocol.EventType eventType = 11 [default = UPDATE]; + * + *
    +     **数据变更类型*
    +     * 
    + */ + EventType getEventType(); + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
    +     **预留扩展*
    +     * 
    + */ + java.util.List + getPropsList(); + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
    +     **预留扩展*
    +     * 
    + */ + Pair getProps(int index); + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
    +     **预留扩展*
    +     * 
    + */ + int getPropsCount(); + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
    +     **预留扩展*
    +     * 
    + */ + java.util.List + getPropsOrBuilderList(); + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
    +     **预留扩展*
    +     * 
    + */ + PairOrBuilder getPropsOrBuilder(int index); + + /** + * optional string gtid = 13; + * + *
    +     **当前事务的gitd*
    +     * 
    + */ + boolean hasGtid(); + /** + * optional string gtid = 13; + * + *
    +     **当前事务的gitd*
    +     * 
    + */ + String getGtid(); + /** + * optional string gtid = 13; + * + *
    +     **当前事务的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; + } + + public Header getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @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(); + Type value = 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(); + EventType value = 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(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 CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Header_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Header_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Header.class, 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); + } + }; + + @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 Object logfileName_; + /** + * optional string logfileName = 2; + * + *
    +     **binlog/redolog 文件名*
    +     * 
    + */ + public boolean hasLogfileName() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional string logfileName = 2; + * + *
    +     **binlog/redolog 文件名*
    +     * 
    + */ + public String getLogfileName() { + Object ref = logfileName_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + logfileName_ = s; + } + return s; + } + } + /** + * optional string logfileName = 2; + * + *
    +     **binlog/redolog 文件名*
    +     * 
    + */ + public com.google.protobuf.ByteString + getLogfileNameBytes() { + Object ref = logfileName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (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 Object serverenCode_; + /** + * optional string serverenCode = 5; + * + *
    +     ** 变更数据的编码 *
    +     * 
    + */ + public boolean hasServerenCode() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** + * optional string serverenCode = 5; + * + *
    +     ** 变更数据的编码 *
    +     * 
    + */ + public String getServerenCode() { + Object ref = serverenCode_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + serverenCode_ = s; + } + return s; + } + } + /** + * optional string serverenCode = 5; + * + *
    +     ** 变更数据的编码 *
    +     * 
    + */ + public com.google.protobuf.ByteString + getServerenCodeBytes() { + Object ref = serverenCode_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (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 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 Type getSourceType() { + return sourceType_; + } + + public static final int SCHEMANAME_FIELD_NUMBER = 8; + private Object schemaName_; + /** + * optional string schemaName = 8; + * + *
    +     ** 变更数据的schemaname*
    +     * 
    + */ + public boolean hasSchemaName() { + return ((bitField0_ & 0x00000080) == 0x00000080); + } + /** + * optional string schemaName = 8; + * + *
    +     ** 变更数据的schemaname*
    +     * 
    + */ + public String getSchemaName() { + Object ref = schemaName_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + schemaName_ = s; + } + return s; + } + } + /** + * optional string schemaName = 8; + * + *
    +     ** 变更数据的schemaname*
    +     * 
    + */ + public com.google.protobuf.ByteString + getSchemaNameBytes() { + Object ref = schemaName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + schemaName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TABLENAME_FIELD_NUMBER = 9; + private Object tableName_; + /** + * optional string tableName = 9; + * + *
    +     **变更数据的tablename*
    +     * 
    + */ + public boolean hasTableName() { + return ((bitField0_ & 0x00000100) == 0x00000100); + } + /** + * optional string tableName = 9; + * + *
    +     **变更数据的tablename*
    +     * 
    + */ + public String getTableName() { + Object ref = tableName_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + tableName_ = s; + } + return s; + } + } + /** + * optional string tableName = 9; + * + *
    +     **变更数据的tablename*
    +     * 
    + */ + public com.google.protobuf.ByteString + getTableNameBytes() { + Object ref = tableName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (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 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 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 Pair getProps(int index) { + return props_.get(index); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
    +     **预留扩展*
    +     * 
    + */ + public PairOrBuilder getPropsOrBuilder( + int index) { + return props_.get(index); + } + + public static final int GTID_FIELD_NUMBER = 13; + private Object gtid_; + /** + * optional string gtid = 13; + * + *
    +     **当前事务的gitd*
    +     * 
    + */ + public boolean hasGtid() { + return ((bitField0_ & 0x00000800) == 0x00000800); + } + /** + * optional string gtid = 13; + * + *
    +     **当前事务的gitd*
    +     * 
    + */ + public String getGtid() { + Object ref = gtid_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + gtid_ = s; + } + return s; + } + } + /** + * optional string gtid = 13; + * + *
    +     **当前事务的gitd*
    +     * 
    + */ + public com.google.protobuf.ByteString + getGtidBytes() { + Object ref = gtid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (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_ = Type.MYSQL; + schemaName_ = ""; + tableName_ = ""; + eventLength_ = 0L; + eventType_ = 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; + @Override + protected Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static Header parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Header parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Header parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Header parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Header parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static Header parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static Header parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static Header parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static Header parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static 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(Header prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @Override + protected Builder newBuilderForType( + 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 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 + 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_); - } - 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; - - /** - * optional int32 version = 1 [default = 1]; - * - *
    -             * *协议的版本号*
    -             * 
    - */ - public boolean hasVersion() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - - /** - * optional int32 version = 1 [default = 1]; - * - *
    -             * *协议的版本号*
    -             * 
    - */ - public int getVersion() { - return version_; - } - - /** - * optional int32 version = 1 [default = 1]; - * - *
    -             * *协议的版本号*
    -             * 
    - */ - public Builder setVersion(int value) { - bitField0_ |= 0x00000001; - version_ = value; - onChanged(); - return this; - } - - /** - * optional int32 version = 1 [default = 1]; - * - *
    -             * *协议的版本号*
    -             * 
    - */ - public Builder clearVersion() { - bitField0_ = (bitField0_ & ~0x00000001); - version_ = 1; - onChanged(); - return this; - } - - 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)) { - 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; - * - *
    -             * *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; - } - } - - /** - * optional string logfileName = 2; - * - *
    -             * *binlog/redolog 文件名*
    -             * 
    - */ - public Builder setLogfileName(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - logfileName_ = value; - onChanged(); - return this; - } - - /** - * optional string logfileName = 2; - * - *
    -             * *binlog/redolog 文件名*
    -             * 
    - */ - public Builder clearLogfileName() { - bitField0_ = (bitField0_ & ~0x00000002); - logfileName_ = getDefaultInstance().getLogfileName(); - onChanged(); - return this; - } - - /** - * optional string logfileName = 2; - * - *
    -             * *binlog/redolog 文件名*
    -             * 
    - */ - public Builder setLogfileNameBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - logfileName_ = value; - onChanged(); - return this; - } - - 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_; - } - - /** - * optional int64 logfileOffset = 3; - * - *
    -             * *binlog/redolog 文件的偏移位置*
    -             * 
    - */ - public Builder setLogfileOffset(long value) { - bitField0_ |= 0x00000004; - logfileOffset_ = value; - onChanged(); - return this; - } - - /** - * optional int64 logfileOffset = 3; - * - *
    -             * *binlog/redolog 文件的偏移位置*
    -             * 
    - */ - public Builder clearLogfileOffset() { - bitField0_ = (bitField0_ & ~0x00000004); - logfileOffset_ = 0L; - onChanged(); - return this; - } - - 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_; - } - - /** - * optional int64 serverId = 4; - * - *
    -             * *服务端serverId*
    -             * 
    - */ - public Builder setServerId(long value) { - bitField0_ |= 0x00000008; - serverId_ = value; - onChanged(); - return this; - } - - /** - * optional int64 serverId = 4; - * - *
    -             * *服务端serverId*
    -             * 
    - */ - public Builder clearServerId() { - bitField0_ = (bitField0_ & ~0x00000008); - serverId_ = 0L; - onChanged(); - return this; - } - - 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)) { - 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; - * - *
    -             * * 变更数据的编码 *
    -             * 
    - */ - 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; - * - *
    -             * * 变更数据的编码 *
    -             * 
    - */ - public Builder setServerenCode(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000010; - serverenCode_ = value; - onChanged(); - return this; - } - - /** - * optional string serverenCode = 5; - * - *
    -             * * 变更数据的编码 *
    -             * 
    - */ - public Builder clearServerenCode() { - bitField0_ = (bitField0_ & ~0x00000010); - serverenCode_ = getDefaultInstance().getServerenCode(); - onChanged(); - return this; - } - - /** - * optional string serverenCode = 5; - * - *
    -             * * 变更数据的编码 *
    -             * 
    - */ - public Builder setServerenCodeBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000010; - serverenCode_ = value; - onChanged(); - return this; - } - - private long executeTime_; - - /** - * optional int64 executeTime = 6; - * - *
    -             * *变更数据的执行时间 *
    -             * 
    - */ - public boolean hasExecuteTime() { - return ((bitField0_ & 0x00000020) == 0x00000020); - } - - /** - * optional int64 executeTime = 6; - * - *
    -             * *变更数据的执行时间 *
    -             * 
    - */ - public long getExecuteTime() { - return executeTime_; - } - - /** - * optional int64 executeTime = 6; - * - *
    -             * *变更数据的执行时间 *
    -             * 
    - */ - public Builder setExecuteTime(long value) { - bitField0_ |= 0x00000020; - executeTime_ = value; - onChanged(); - return this; - } - - /** - * optional int64 executeTime = 6; - * - *
    -             * *变更数据的执行时间 *
    -             * 
    - */ - 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; - - /** - * 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_; - } - - /** - * optional .com.alibaba.otter.canal.protocol.Type sourceType = 7 [default = MYSQL]; - * - *
    -             * * 变更数据的来源*
    -             * 
    - */ - 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]; - * - *
    -             * * 变更数据的来源*
    -             * 
    - */ - 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 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; - } - } - - /** - * optional string tableName = 9; - * - *
    -             * *变更数据的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; - } - } - - /** - * optional string tableName = 9; - * - *
    -             * *变更数据的tablename*
    -             * 
    - */ - public Builder setTableName(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000100; - tableName_ = value; - onChanged(); - return this; - } - - /** - * optional string tableName = 9; - * - *
    -             * *变更数据的tablename*
    -             * 
    - */ - public Builder clearTableName() { - bitField0_ = (bitField0_ & ~0x00000100); - tableName_ = getDefaultInstance().getTableName(); - onChanged(); - return this; - } - - /** - * optional string tableName = 9; - * - *
    -             * *变更数据的tablename*
    -             * 
    - */ - public Builder setTableNameBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000100; - tableName_ = value; - onChanged(); - return this; - } - - 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_; - } - - /** - * optional int64 eventLength = 10; - * - *
    -             * *每个event的长度*
    -             * 
    - */ - public Builder setEventLength(long value) { - bitField0_ |= 0x00000200; - eventLength_ = value; - onChanged(); - return this; - } - - /** - * optional int64 eventLength = 10; - * - *
    -             * *每个event的长度*
    -             * 
    - */ - 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; - - /** - * 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_; - } - - /** - * optional .com.alibaba.otter.canal.protocol.EventType eventType = 11 [default = UPDATE]; - * - *
    -             * *数据变更类型*
    -             * 
    - */ - 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]; - * - *
    -             * *数据变更类型*
    -             * 
    - */ - 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 com.google.protobuf.RepeatedFieldBuilder propsBuilder_; - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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 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) + HeaderOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Header_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Header_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Header.class, Builder.class); + } + + // Construct using com.alibaba.otter.canal.protocol.CanalEntry.Header.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getPropsFieldBuilder(); } + } + private static Builder create() { + return new Builder(); + } - static { - defaultInstance = new Header(true); - defaultInstance.initFields(); + 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_ = Type.MYSQL; + bitField0_ = (bitField0_ & ~0x00000040); + schemaName_ = ""; + bitField0_ = (bitField0_ & ~0x00000080); + tableName_ = ""; + bitField0_ = (bitField0_ & ~0x00000100); + eventLength_ = 0L; + bitField0_ = (bitField0_ & ~0x00000200); + eventType_ = 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; + } - // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.Header) + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Header_descriptor; + } + + public Header getDefaultInstanceForType() { + return Header.getDefaultInstance(); + } + + public Header build() { + Header result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public Header buildPartial() { + Header result = new 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 Header) { + return mergeFrom((Header)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(Header other) { + if (other == 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 { + Header parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (Header) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private int version_ = 1; + /** + * optional int32 version = 1 [default = 1]; + * + *
    +       **协议的版本号*
    +       * 
    + */ + public boolean hasVersion() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional int32 version = 1 [default = 1]; + * + *
    +       **协议的版本号*
    +       * 
    + */ + public int getVersion() { + return version_; + } + /** + * optional int32 version = 1 [default = 1]; + * + *
    +       **协议的版本号*
    +       * 
    + */ + public Builder setVersion(int value) { + bitField0_ |= 0x00000001; + version_ = value; + onChanged(); + return this; + } + /** + * optional int32 version = 1 [default = 1]; + * + *
    +       **协议的版本号*
    +       * 
    + */ + public Builder clearVersion() { + bitField0_ = (bitField0_ & ~0x00000001); + version_ = 1; + onChanged(); + return this; + } + + private Object logfileName_ = ""; + /** + * optional string logfileName = 2; + * + *
    +       **binlog/redolog 文件名*
    +       * 
    + */ + public boolean hasLogfileName() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional string logfileName = 2; + * + *
    +       **binlog/redolog 文件名*
    +       * 
    + */ + public String getLogfileName() { + Object ref = logfileName_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + logfileName_ = s; + } + return s; + } else { + return (String) ref; + } + } + /** + * optional string logfileName = 2; + * + *
    +       **binlog/redolog 文件名*
    +       * 
    + */ + public com.google.protobuf.ByteString + getLogfileNameBytes() { + Object ref = logfileName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + logfileName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string logfileName = 2; + * + *
    +       **binlog/redolog 文件名*
    +       * 
    + */ + public Builder setLogfileName( + String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + logfileName_ = value; + onChanged(); + return this; + } + /** + * optional string logfileName = 2; + * + *
    +       **binlog/redolog 文件名*
    +       * 
    + */ + public Builder clearLogfileName() { + bitField0_ = (bitField0_ & ~0x00000002); + logfileName_ = getDefaultInstance().getLogfileName(); + onChanged(); + return this; + } + /** + * optional string logfileName = 2; + * + *
    +       **binlog/redolog 文件名*
    +       * 
    + */ + public Builder setLogfileNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + logfileName_ = value; + onChanged(); + return this; + } + + 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_; + } + /** + * optional int64 logfileOffset = 3; + * + *
    +       **binlog/redolog 文件的偏移位置*
    +       * 
    + */ + public Builder setLogfileOffset(long value) { + bitField0_ |= 0x00000004; + logfileOffset_ = value; + onChanged(); + return this; + } + /** + * optional int64 logfileOffset = 3; + * + *
    +       **binlog/redolog 文件的偏移位置*
    +       * 
    + */ + public Builder clearLogfileOffset() { + bitField0_ = (bitField0_ & ~0x00000004); + logfileOffset_ = 0L; + onChanged(); + return this; + } + + 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_; + } + /** + * optional int64 serverId = 4; + * + *
    +       **服务端serverId*
    +       * 
    + */ + public Builder setServerId(long value) { + bitField0_ |= 0x00000008; + serverId_ = value; + onChanged(); + return this; + } + /** + * optional int64 serverId = 4; + * + *
    +       **服务端serverId*
    +       * 
    + */ + public Builder clearServerId() { + bitField0_ = (bitField0_ & ~0x00000008); + serverId_ = 0L; + onChanged(); + return this; + } + + private Object serverenCode_ = ""; + /** + * optional string serverenCode = 5; + * + *
    +       ** 变更数据的编码 *
    +       * 
    + */ + public boolean hasServerenCode() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** + * optional string serverenCode = 5; + * + *
    +       ** 变更数据的编码 *
    +       * 
    + */ + public String getServerenCode() { + Object ref = serverenCode_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + serverenCode_ = s; + } + return s; + } else { + return (String) ref; + } + } + /** + * optional string serverenCode = 5; + * + *
    +       ** 变更数据的编码 *
    +       * 
    + */ + public com.google.protobuf.ByteString + getServerenCodeBytes() { + Object ref = serverenCode_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + serverenCode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string serverenCode = 5; + * + *
    +       ** 变更数据的编码 *
    +       * 
    + */ + public Builder setServerenCode( + String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000010; + serverenCode_ = value; + onChanged(); + return this; + } + /** + * optional string serverenCode = 5; + * + *
    +       ** 变更数据的编码 *
    +       * 
    + */ + public Builder clearServerenCode() { + bitField0_ = (bitField0_ & ~0x00000010); + serverenCode_ = getDefaultInstance().getServerenCode(); + onChanged(); + return this; + } + /** + * optional string serverenCode = 5; + * + *
    +       ** 变更数据的编码 *
    +       * 
    + */ + public Builder setServerenCodeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000010; + serverenCode_ = value; + onChanged(); + return this; + } + + private long executeTime_ ; + /** + * optional int64 executeTime = 6; + * + *
    +       **变更数据的执行时间 *
    +       * 
    + */ + public boolean hasExecuteTime() { + return ((bitField0_ & 0x00000020) == 0x00000020); + } + /** + * optional int64 executeTime = 6; + * + *
    +       **变更数据的执行时间 *
    +       * 
    + */ + public long getExecuteTime() { + return executeTime_; + } + /** + * optional int64 executeTime = 6; + * + *
    +       **变更数据的执行时间 *
    +       * 
    + */ + public Builder setExecuteTime(long value) { + bitField0_ |= 0x00000020; + executeTime_ = value; + onChanged(); + return this; + } + /** + * optional int64 executeTime = 6; + * + *
    +       **变更数据的执行时间 *
    +       * 
    + */ + public Builder clearExecuteTime() { + bitField0_ = (bitField0_ & ~0x00000020); + executeTime_ = 0L; + onChanged(); + return this; + } + + private Type sourceType_ = Type.MYSQL; + /** + * 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 Type getSourceType() { + return sourceType_; + } + /** + * optional .com.alibaba.otter.canal.protocol.Type sourceType = 7 [default = MYSQL]; + * + *
    +       ** 变更数据的来源*
    +       * 
    + */ + public Builder setSourceType(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]; + * + *
    +       ** 变更数据的来源*
    +       * 
    + */ + public Builder clearSourceType() { + bitField0_ = (bitField0_ & ~0x00000040); + sourceType_ = Type.MYSQL; + onChanged(); + return this; + } + + private Object schemaName_ = ""; + /** + * optional string schemaName = 8; + * + *
    +       ** 变更数据的schemaname*
    +       * 
    + */ + public boolean hasSchemaName() { + return ((bitField0_ & 0x00000080) == 0x00000080); + } + /** + * optional string schemaName = 8; + * + *
    +       ** 变更数据的schemaname*
    +       * 
    + */ + public String getSchemaName() { + Object ref = schemaName_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + schemaName_ = s; + } + return s; + } else { + return (String) ref; + } + } + /** + * optional string schemaName = 8; + * + *
    +       ** 变更数据的schemaname*
    +       * 
    + */ + public com.google.protobuf.ByteString + getSchemaNameBytes() { + Object ref = schemaName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + schemaName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string schemaName = 8; + * + *
    +       ** 变更数据的schemaname*
    +       * 
    + */ + public Builder setSchemaName( + 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 Object tableName_ = ""; + /** + * optional string tableName = 9; + * + *
    +       **变更数据的tablename*
    +       * 
    + */ + public boolean hasTableName() { + return ((bitField0_ & 0x00000100) == 0x00000100); + } + /** + * optional string tableName = 9; + * + *
    +       **变更数据的tablename*
    +       * 
    + */ + public String getTableName() { + Object ref = tableName_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + tableName_ = s; + } + return s; + } else { + return (String) ref; + } + } + /** + * optional string tableName = 9; + * + *
    +       **变更数据的tablename*
    +       * 
    + */ + public com.google.protobuf.ByteString + getTableNameBytes() { + Object ref = tableName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + tableName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string tableName = 9; + * + *
    +       **变更数据的tablename*
    +       * 
    + */ + public Builder setTableName( + String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000100; + tableName_ = value; + onChanged(); + return this; + } + /** + * optional string tableName = 9; + * + *
    +       **变更数据的tablename*
    +       * 
    + */ + public Builder clearTableName() { + bitField0_ = (bitField0_ & ~0x00000100); + tableName_ = getDefaultInstance().getTableName(); + onChanged(); + return this; + } + /** + * optional string tableName = 9; + * + *
    +       **变更数据的tablename*
    +       * 
    + */ + public Builder setTableNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000100; + tableName_ = value; + onChanged(); + return this; + } + + 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_; + } + /** + * optional int64 eventLength = 10; + * + *
    +       **每个event的长度*
    +       * 
    + */ + public Builder setEventLength(long value) { + bitField0_ |= 0x00000200; + eventLength_ = value; + onChanged(); + return this; + } + /** + * optional int64 eventLength = 10; + * + *
    +       **每个event的长度*
    +       * 
    + */ + public Builder clearEventLength() { + bitField0_ = (bitField0_ & ~0x00000200); + eventLength_ = 0L; + onChanged(); + return this; + } + + private EventType eventType_ = EventType.UPDATE; + /** + * 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 EventType getEventType() { + return eventType_; + } + /** + * optional .com.alibaba.otter.canal.protocol.EventType eventType = 11 [default = UPDATE]; + * + *
    +       **数据变更类型*
    +       * 
    + */ + public Builder setEventType(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]; + * + *
    +       **数据变更类型*
    +       * 
    + */ + public Builder clearEventType() { + bitField0_ = (bitField0_ & ~0x00000400); + eventType_ = 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 com.google.protobuf.RepeatedFieldBuilder< + Pair, Pair.Builder, PairOrBuilder> propsBuilder_; + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
    +       **预留扩展*
    +       * 
    + */ + 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 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, 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, 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(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, 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( + 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, 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( + 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 Pair.Builder getPropsBuilder( + int index) { + return getPropsFieldBuilder().getBuilder(index); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
    +       **预留扩展*
    +       * 
    + */ + public 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 Pair.Builder addPropsBuilder() { + return getPropsFieldBuilder().addBuilder( + Pair.getDefaultInstance()); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
    +       **预留扩展*
    +       * 
    + */ + public Pair.Builder addPropsBuilder( + int index) { + return getPropsFieldBuilder().addBuilder( + index, Pair.getDefaultInstance()); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 12; + * + *
    +       **预留扩展*
    +       * 
    + */ + public java.util.List + getPropsBuilderList() { + return getPropsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + Pair, Pair.Builder, PairOrBuilder> + getPropsFieldBuilder() { + if (propsBuilder_ == null) { + propsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + Pair, Pair.Builder, PairOrBuilder>( + props_, + ((bitField0_ & 0x00000800) == 0x00000800), + getParentForChildren(), + isClean()); + props_ = null; + } + return propsBuilder_; + } + + private Object gtid_ = ""; + /** + * optional string gtid = 13; + * + *
    +       **当前事务的gitd*
    +       * 
    + */ + public boolean hasGtid() { + return ((bitField0_ & 0x00001000) == 0x00001000); + } + /** + * optional string gtid = 13; + * + *
    +       **当前事务的gitd*
    +       * 
    + */ + public String getGtid() { + Object ref = gtid_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + gtid_ = s; + } + return s; + } else { + return (String) ref; + } + } + /** + * optional string gtid = 13; + * + *
    +       **当前事务的gitd*
    +       * 
    + */ + public com.google.protobuf.ByteString + getGtidBytes() { + Object ref = gtid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + gtid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string gtid = 13; + * + *
    +       **当前事务的gitd*
    +       * 
    + */ + public Builder setGtid( + 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) } - public interface ColumnOrBuilder extends - // @@protoc_insertion_point(interface_extends:com.alibaba.otter.canal.protocol.Column) - com.google.protobuf.MessageOrBuilder { - - /** - * optional int32 index = 1; - * - *
    -         * *字段下标*
    -         * 
    - */ - boolean hasIndex(); - - /** - * optional int32 index = 1; - * - *
    -         * *字段下标*
    -         * 
    - */ - int getIndex(); - - /** - * optional int32 sqlType = 2; - * - *
    -         * *字段java中类型*
    -         * 
    - */ - boolean hasSqlType(); - - /** - * optional int32 sqlType = 2; - * - *
    -         * *字段java中类型*
    -         * 
    - */ - int getSqlType(); - - /** - * optional string name = 3; - * - *
    -         * *字段名称(忽略大小写),在mysql中是没有的*
    -         * 
    - */ - boolean hasName(); - - /** - * optional string name = 3; - * - *
    -         * *字段名称(忽略大小写),在mysql中是没有的*
    -         * 
    - */ - java.lang.String getName(); - - /** - * optional string name = 3; - * - *
    -         * *字段名称(忽略大小写),在mysql中是没有的*
    -         * 
    - */ - com.google.protobuf.ByteString getNameBytes(); - - /** - * optional bool isKey = 4; - * - *
    -         * *是否是主键*
    -         * 
    - */ - boolean hasIsKey(); - - /** - * optional bool isKey = 4; - * - *
    -         * *是否是主键*
    -         * 
    - */ - boolean getIsKey(); - - /** - * optional bool updated = 5; - * - *
    -         * *如果EventType=UPDATE,用于标识这个字段值是否有修改*
    -         * 
    - */ - boolean hasUpdated(); - - /** - * optional bool updated = 5; - * - *
    -         * *如果EventType=UPDATE,用于标识这个字段值是否有修改*
    -         * 
    - */ - boolean getUpdated(); - - /** - * optional bool isNull = 6 [default = false]; - * - *
    -         * * 标识是否为空  *
    -         * 
    - */ - boolean hasIsNull(); - - /** - * optional bool isNull = 6 [default = false]; - * - *
    -         * * 标识是否为空  *
    -         * 
    - */ - boolean getIsNull(); - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
    -         * *预留扩展*
    -         * 
    - */ - java.util.List getPropsList(); - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
    -         * *预留扩展*
    -         * 
    - */ - com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index); - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
    -         * *预留扩展*
    -         * 
    - */ - int getPropsCount(); - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
    -         * *预留扩展*
    -         * 
    - */ - java.util.List getPropsOrBuilderList(); - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
    -         * *预留扩展*
    -         * 
    - */ - com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index); - - /** - * optional string value = 8; - * - *
    -         * * 字段值,timestamp,Datetime是一个时间格式的文本 *
    -         * 
    - */ - boolean hasValue(); - - /** - * optional string value = 8; - * - *
    -         * * 字段值,timestamp,Datetime是一个时间格式的文本 *
    -         * 
    - */ - java.lang.String getValue(); - - /** - * optional string value = 8; - * - *
    -         * * 字段值,timestamp,Datetime是一个时间格式的文本 *
    -         * 
    - */ - com.google.protobuf.ByteString getValueBytes(); - - /** - * optional int32 length = 9; - * - *
    -         * * 对应数据对象原始长度 *
    -         * 
    - */ - boolean hasLength(); - - /** - * optional int32 length = 9; - * - *
    -         * * 对应数据对象原始长度 *
    -         * 
    - */ - int getLength(); - - /** - * optional string mysqlType = 10; - * - *
    -         * *字段mysql类型*
    -         * 
    - */ - boolean hasMysqlType(); - - /** - * optional string mysqlType = 10; - * - *
    -         * *字段mysql类型*
    -         * 
    - */ - java.lang.String getMysqlType(); - - /** - * optional string mysqlType = 10; - * - *
    -         * *字段mysql类型*
    -         * 
    - */ - com.google.protobuf.ByteString getMysqlTypeBytes(); + 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 { + + /** + * optional int32 index = 1; + * + *
    +     **字段下标*
    +     * 
    + */ + boolean hasIndex(); + /** + * optional int32 index = 1; + * + *
    +     **字段下标*
    +     * 
    + */ + int getIndex(); + + /** + * optional int32 sqlType = 2; + * + *
    +     **字段java中类型*
    +     * 
    + */ + boolean hasSqlType(); + /** + * optional int32 sqlType = 2; + * + *
    +     **字段java中类型*
    +     * 
    + */ + int getSqlType(); + + /** + * optional string name = 3; + * + *
    +     **字段名称(忽略大小写),在mysql中是没有的*
    +     * 
    + */ + boolean hasName(); + /** + * optional string name = 3; + * + *
    +     **字段名称(忽略大小写),在mysql中是没有的*
    +     * 
    + */ + String getName(); + /** + * optional string name = 3; + * + *
    +     **字段名称(忽略大小写),在mysql中是没有的*
    +     * 
    + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * optional bool isKey = 4; + * + *
    +     **是否是主键*
    +     * 
    + */ + boolean hasIsKey(); + /** + * optional bool isKey = 4; + * + *
    +     **是否是主键*
    +     * 
    + */ + boolean getIsKey(); + + /** + * optional bool updated = 5; + * + *
    +     **如果EventType=UPDATE,用于标识这个字段值是否有修改*
    +     * 
    + */ + boolean hasUpdated(); + /** + * optional bool updated = 5; + * + *
    +     **如果EventType=UPDATE,用于标识这个字段值是否有修改*
    +     * 
    + */ + boolean getUpdated(); + + /** + * optional bool isNull = 6 [default = false]; + * + *
    +     ** 标识是否为空  *
    +     * 
    + */ + boolean hasIsNull(); + /** + * optional bool isNull = 6 [default = false]; + * + *
    +     ** 标识是否为空  *
    +     * 
    + */ + boolean getIsNull(); + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
    +     **预留扩展*
    +     * 
    + */ + java.util.List + getPropsList(); + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
    +     **预留扩展*
    +     * 
    + */ + Pair getProps(int index); + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
    +     **预留扩展*
    +     * 
    + */ + int getPropsCount(); + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
    +     **预留扩展*
    +     * 
    + */ + java.util.List + getPropsOrBuilderList(); + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
    +     **预留扩展*
    +     * 
    + */ + PairOrBuilder getPropsOrBuilder(int index); + + /** + * optional string value = 8; + * + *
    +     ** 字段值,timestamp,Datetime是一个时间格式的文本 *
    +     * 
    + */ + boolean hasValue(); + /** + * optional string value = 8; + * + *
    +     ** 字段值,timestamp,Datetime是一个时间格式的文本 *
    +     * 
    + */ + String getValue(); + /** + * optional string value = 8; + * + *
    +     ** 字段值,timestamp,Datetime是一个时间格式的文本 *
    +     * 
    + */ + com.google.protobuf.ByteString + getValueBytes(); + + /** + * optional int32 length = 9; + * + *
    +     ** 对应数据对象原始长度 *
    +     * 
    + */ + boolean hasLength(); + /** + * optional int32 length = 9; + * + *
    +     ** 对应数据对象原始长度 *
    +     * 
    + */ + int getLength(); + + /** + * optional string mysqlType = 10; + * + *
    +     **字段mysql类型*
    +     * 
    + */ + boolean hasMysqlType(); + /** + * optional string mysqlType = 10; + * + *
    +     **字段mysql类型*
    +     * 
    + */ + String getMysqlType(); + /** + * optional string mysqlType = 10; + * + *
    +     **字段mysql类型*
    +     * 
    + */ + com.google.protobuf.ByteString + getMysqlTypeBytes(); + } + /** + * Protobuf type {@code com.alibaba.otter.canal.protocol.Column} + * + *
    +   **每个字段的数据结构*
    +   * 
    + */ + 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(); } + + private static final Column defaultInstance; + public static Column getDefaultInstance() { + return defaultInstance; + } + + public Column getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @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(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 CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Column_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Column_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Column.class, 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); + } + }; + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + public static final int INDEX_FIELD_NUMBER = 1; + private int index_; + /** + * optional int32 index = 1; + * + *
    +     **字段下标*
    +     * 
    + */ + public boolean hasIndex() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional int32 index = 1; + * + *
    +     **字段下标*
    +     * 
    + */ + public int getIndex() { + return index_; + } + + public static final int SQLTYPE_FIELD_NUMBER = 2; + private int sqlType_; + /** + * optional int32 sqlType = 2; + * + *
    +     **字段java中类型*
    +     * 
    + */ + public boolean hasSqlType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional int32 sqlType = 2; + * + *
    +     **字段java中类型*
    +     * 
    + */ + public int getSqlType() { + return sqlType_; + } + + public static final int NAME_FIELD_NUMBER = 3; + private Object name_; + /** + * optional string name = 3; + * + *
    +     **字段名称(忽略大小写),在mysql中是没有的*
    +     * 
    + */ + public boolean hasName() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional string name = 3; + * + *
    +     **字段名称(忽略大小写),在mysql中是没有的*
    +     * 
    + */ + public String getName() { + Object ref = name_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + name_ = s; + } + return s; + } + } + /** + * optional string name = 3; + * + *
    +     **字段名称(忽略大小写),在mysql中是没有的*
    +     * 
    + */ + public com.google.protobuf.ByteString + getNameBytes() { + Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ISKEY_FIELD_NUMBER = 4; + private boolean isKey_; + /** + * optional bool isKey = 4; + * + *
    +     **是否是主键*
    +     * 
    + */ + public boolean hasIsKey() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * optional bool isKey = 4; + * + *
    +     **是否是主键*
    +     * 
    + */ + public boolean getIsKey() { + return isKey_; + } + + public static final int UPDATED_FIELD_NUMBER = 5; + private boolean updated_; + /** + * optional bool updated = 5; + * + *
    +     **如果EventType=UPDATE,用于标识这个字段值是否有修改*
    +     * 
    + */ + public boolean hasUpdated() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** + * optional bool updated = 5; + * + *
    +     **如果EventType=UPDATE,用于标识这个字段值是否有修改*
    +     * 
    + */ + public boolean getUpdated() { + return updated_; + } + + public static final int ISNULL_FIELD_NUMBER = 6; + private boolean isNull_; + /** + * optional bool isNull = 6 [default = false]; + * + *
    +     ** 标识是否为空  *
    +     * 
    + */ + public boolean hasIsNull() { + return ((bitField0_ & 0x00000020) == 0x00000020); + } + /** + * optional bool isNull = 6 [default = false]; + * + *
    +     ** 标识是否为空  *
    +     * 
    + */ + 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 Pair getProps(int index) { + return props_.get(index); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
    +     **预留扩展*
    +     * 
    + */ + public PairOrBuilder getPropsOrBuilder( + int index) { + return props_.get(index); + } + + public static final int VALUE_FIELD_NUMBER = 8; + private Object value_; + /** + * optional string value = 8; + * + *
    +     ** 字段值,timestamp,Datetime是一个时间格式的文本 *
    +     * 
    + */ + public boolean hasValue() { + return ((bitField0_ & 0x00000040) == 0x00000040); + } + /** + * optional string value = 8; + * + *
    +     ** 字段值,timestamp,Datetime是一个时间格式的文本 *
    +     * 
    + */ + public String getValue() { + Object ref = value_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + value_ = s; + } + return s; + } + } + /** + * optional string value = 8; + * + *
    +     ** 字段值,timestamp,Datetime是一个时间格式的文本 *
    +     * 
    + */ + public com.google.protobuf.ByteString + getValueBytes() { + Object ref = value_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int LENGTH_FIELD_NUMBER = 9; + private int length_; + /** + * optional int32 length = 9; + * + *
    +     ** 对应数据对象原始长度 *
    +     * 
    + */ + public boolean hasLength() { + return ((bitField0_ & 0x00000080) == 0x00000080); + } + /** + * optional int32 length = 9; + * + *
    +     ** 对应数据对象原始长度 *
    +     * 
    + */ + public int getLength() { + return length_; + } + + public static final int MYSQLTYPE_FIELD_NUMBER = 10; + private Object mysqlType_; + /** + * optional string mysqlType = 10; + * + *
    +     **字段mysql类型*
    +     * 
    + */ + public boolean hasMysqlType() { + return ((bitField0_ & 0x00000100) == 0x00000100); + } + /** + * optional string mysqlType = 10; + * + *
    +     **字段mysql类型*
    +     * 
    + */ + public String getMysqlType() { + Object ref = mysqlType_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + mysqlType_ = s; + } + return s; + } + } + /** + * optional string mysqlType = 10; + * + *
    +     **字段mysql类型*
    +     * 
    + */ + public com.google.protobuf.ByteString + getMysqlTypeBytes() { + Object ref = mysqlType_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + mysqlType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + 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; + + memoizedIsInitialized = 1; + return true; + } + + 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 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; + @Override + protected Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static Column parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Column parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Column parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Column parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Column parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static Column parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static Column parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static Column parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static Column parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static 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(Column prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } /** * Protobuf type {@code com.alibaba.otter.canal.protocol.Column} * *
    -     * *每个字段的数据结构*
    +     **每个字段的数据结构*
          * 
    */ - 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(); - } - - 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; - } - } - } - } 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_; - - /** - * optional int32 index = 1; - * - *
    -         * *字段下标*
    -         * 
    - */ - public boolean hasIndex() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - - /** - * optional int32 index = 1; - * - *
    -         * *字段下标*
    -         * 
    - */ - public int getIndex() { - return index_; - } - - public static final int SQLTYPE_FIELD_NUMBER = 2; - private int sqlType_; - - /** - * optional int32 sqlType = 2; - * - *
    -         * *字段java中类型*
    -         * 
    - */ - public boolean hasSqlType() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - - /** - * optional int32 sqlType = 2; - * - *
    -         * *字段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; - } - 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_; - - /** - * optional bool isKey = 4; - * - *
    -         * *是否是主键*
    -         * 
    - */ - public boolean hasIsKey() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - - /** - * optional bool isKey = 4; - * - *
    -         * *是否是主键*
    -         * 
    - */ - public boolean getIsKey() { - return isKey_; - } - - public static final int UPDATED_FIELD_NUMBER = 5; - private boolean updated_; - - /** - * optional bool updated = 5; - * - *
    -         * *如果EventType=UPDATE,用于标识这个字段值是否有修改*
    -         * 
    - */ - public boolean hasUpdated() { - return ((bitField0_ & 0x00000010) == 0x00000010); - } - - /** - * optional bool updated = 5; - * - *
    -         * *如果EventType=UPDATE,用于标识这个字段值是否有修改*
    -         * 
    - */ - public boolean getUpdated() { - return updated_; - } - - public static final int ISNULL_FIELD_NUMBER = 6; - private boolean isNull_; - - /** - * optional bool isNull = 6 [default = false]; - * - *
    -         * * 标识是否为空  *
    -         * 
    - */ - public boolean hasIsNull() { - return ((bitField0_ & 0x00000020) == 0x00000020); - } - - /** - * optional bool isNull = 6 [default = false]; - * - *
    -         * * 标识是否为空  *
    -         * 
    - */ - 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; - } - 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_; - - /** - * optional int32 length = 9; - * - *
    -         * * 对应数据对象原始长度 *
    -         * 
    - */ - public boolean hasLength() { - return ((bitField0_ & 0x00000080) == 0x00000080); - } - - /** - * optional int32 length = 9; - * - *
    -         * * 对应数据对象原始长度 *
    -         * 
    - */ - 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; - } - return s; - } - } - - /** - * 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; - } - } - - 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; - - memoizedIsInitialized = 1; - return true; - } - - 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 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; - } - - /** - * Protobuf type {@code com.alibaba.otter.canal.protocol.Column} - * - *
    -         * *每个字段的数据结构*
    -         * 
    - */ - 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_); - } - 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_; - - /** - * optional int32 index = 1; - * - *
    -             * *字段下标*
    -             * 
    - */ - public boolean hasIndex() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - - /** - * optional int32 index = 1; - * - *
    -             * *字段下标*
    -             * 
    - */ - public int getIndex() { - return index_; - } - - /** - * optional int32 index = 1; - * - *
    -             * *字段下标*
    -             * 
    - */ - public Builder setIndex(int value) { - bitField0_ |= 0x00000001; - index_ = value; - onChanged(); - return this; - } - - /** - * optional int32 index = 1; - * - *
    -             * *字段下标*
    -             * 
    - */ - public Builder clearIndex() { - bitField0_ = (bitField0_ & ~0x00000001); - index_ = 0; - onChanged(); - return this; - } - - private int sqlType_; - - /** - * optional int32 sqlType = 2; - * - *
    -             * *字段java中类型*
    -             * 
    - */ - public boolean hasSqlType() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - - /** - * optional int32 sqlType = 2; - * - *
    -             * *字段java中类型*
    -             * 
    - */ - public int getSqlType() { - return sqlType_; - } - - /** - * optional int32 sqlType = 2; - * - *
    -             * *字段java中类型*
    -             * 
    - */ - public Builder setSqlType(int value) { - bitField0_ |= 0x00000002; - sqlType_ = value; - onChanged(); - return this; - } - - /** - * optional int32 sqlType = 2; - * - *
    -             * *字段java中类型*
    -             * 
    - */ - public Builder clearSqlType() { - bitField0_ = (bitField0_ & ~0x00000002); - sqlType_ = 0; - onChanged(); - return this; - } - - 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)) { - 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; - * - *
    -             * *字段名称(忽略大小写),在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; - } - } - - /** - * optional string name = 3; - * - *
    -             * *字段名称(忽略大小写),在mysql中是没有的*
    -             * 
    - */ - public Builder setName(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000004; - name_ = value; - onChanged(); - return this; - } - - /** - * optional string name = 3; - * - *
    -             * *字段名称(忽略大小写),在mysql中是没有的*
    -             * 
    - */ - public Builder clearName() { - bitField0_ = (bitField0_ & ~0x00000004); - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - - /** - * optional string name = 3; - * - *
    -             * *字段名称(忽略大小写),在mysql中是没有的*
    -             * 
    - */ - public Builder setNameBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000004; - name_ = value; - onChanged(); - return this; - } - - private boolean isKey_; - - /** - * optional bool isKey = 4; - * - *
    -             * *是否是主键*
    -             * 
    - */ - public boolean hasIsKey() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - - /** - * optional bool isKey = 4; - * - *
    -             * *是否是主键*
    -             * 
    - */ - public boolean getIsKey() { - return isKey_; - } - - /** - * optional bool isKey = 4; - * - *
    -             * *是否是主键*
    -             * 
    - */ - public Builder setIsKey(boolean value) { - bitField0_ |= 0x00000008; - isKey_ = value; - onChanged(); - return this; - } - - /** - * optional bool isKey = 4; - * - *
    -             * *是否是主键*
    -             * 
    - */ - public Builder clearIsKey() { - bitField0_ = (bitField0_ & ~0x00000008); - isKey_ = false; - onChanged(); - return this; - } - - private boolean updated_; - - /** - * optional bool updated = 5; - * - *
    -             * *如果EventType=UPDATE,用于标识这个字段值是否有修改*
    -             * 
    - */ - public boolean hasUpdated() { - return ((bitField0_ & 0x00000010) == 0x00000010); - } - - /** - * optional bool updated = 5; - * - *
    -             * *如果EventType=UPDATE,用于标识这个字段值是否有修改*
    -             * 
    - */ - public boolean getUpdated() { - return updated_; - } - - /** - * optional bool updated = 5; - * - *
    -             * *如果EventType=UPDATE,用于标识这个字段值是否有修改*
    -             * 
    - */ - public Builder setUpdated(boolean value) { - bitField0_ |= 0x00000010; - updated_ = value; - onChanged(); - return this; - } - - /** - * optional bool updated = 5; - * - *
    -             * *如果EventType=UPDATE,用于标识这个字段值是否有修改*
    -             * 
    - */ - public Builder clearUpdated() { - bitField0_ = (bitField0_ & ~0x00000010); - updated_ = false; - onChanged(); - return this; - } - - private boolean isNull_; - - /** - * optional bool isNull = 6 [default = false]; - * - *
    -             * * 标识是否为空  *
    -             * 
    - */ - public boolean hasIsNull() { - return ((bitField0_ & 0x00000020) == 0x00000020); - } - - /** - * optional bool isNull = 6 [default = false]; - * - *
    -             * * 标识是否为空  *
    -             * 
    - */ - public boolean getIsNull() { - return isNull_; - } - - /** - * optional bool isNull = 6 [default = false]; - * - *
    -             * * 标识是否为空  *
    -             * 
    - */ - public Builder setIsNull(boolean value) { - bitField0_ |= 0x00000020; - isNull_ = value; - onChanged(); - return this; - } - - /** - * optional bool isNull = 6 [default = false]; - * - *
    -             * * 标识是否为空  *
    -             * 
    - */ - 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 com.google.protobuf.RepeatedFieldBuilder propsBuilder_; - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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 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; - } - } - - /** - * optional string value = 8; - * - *
    -             * * 字段值,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; - } - } - - /** - * optional string value = 8; - * - *
    -             * * 字段值,timestamp,Datetime是一个时间格式的文本 *
    -             * 
    - */ - public Builder setValue(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000080; - value_ = value; - onChanged(); - return this; - } - - /** - * optional string value = 8; - * - *
    -             * * 字段值,timestamp,Datetime是一个时间格式的文本 *
    -             * 
    - */ - public Builder clearValue() { - bitField0_ = (bitField0_ & ~0x00000080); - value_ = getDefaultInstance().getValue(); - onChanged(); - return this; - } - - /** - * optional string value = 8; - * - *
    -             * * 字段值,timestamp,Datetime是一个时间格式的文本 *
    -             * 
    - */ - public Builder setValueBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000080; - value_ = value; - onChanged(); - return this; - } - - private int length_; - - /** - * optional int32 length = 9; - * - *
    -             * * 对应数据对象原始长度 *
    -             * 
    - */ - public boolean hasLength() { - return ((bitField0_ & 0x00000100) == 0x00000100); - } - - /** - * optional int32 length = 9; - * - *
    -             * * 对应数据对象原始长度 *
    -             * 
    - */ - public int getLength() { - return length_; - } - - /** - * optional int32 length = 9; - * - *
    -             * * 对应数据对象原始长度 *
    -             * 
    - */ - public Builder setLength(int value) { - bitField0_ |= 0x00000100; - length_ = value; - onChanged(); - return this; - } - - /** - * optional int32 length = 9; - * - *
    -             * * 对应数据对象原始长度 *
    -             * 
    - */ - 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) + ColumnOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Column_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Column_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Column.class, Builder.class); + } + + // Construct using com.alibaba.otter.canal.protocol.CanalEntry.Column.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getPropsFieldBuilder(); } + } + private static Builder create() { + return new Builder(); + } - static { - defaultInstance = new Column(true); - defaultInstance.initFields(); + 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; + } - // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.Column) + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Column_descriptor; + } + + public Column getDefaultInstanceForType() { + return Column.getDefaultInstance(); + } + + public Column build() { + Column result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public Column buildPartial() { + Column result = new 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 Column) { + return mergeFrom((Column)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(Column other) { + if (other == 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 { + Column parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (Column) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private int index_ ; + /** + * optional int32 index = 1; + * + *
    +       **字段下标*
    +       * 
    + */ + public boolean hasIndex() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional int32 index = 1; + * + *
    +       **字段下标*
    +       * 
    + */ + public int getIndex() { + return index_; + } + /** + * optional int32 index = 1; + * + *
    +       **字段下标*
    +       * 
    + */ + public Builder setIndex(int value) { + bitField0_ |= 0x00000001; + index_ = value; + onChanged(); + return this; + } + /** + * optional int32 index = 1; + * + *
    +       **字段下标*
    +       * 
    + */ + public Builder clearIndex() { + bitField0_ = (bitField0_ & ~0x00000001); + index_ = 0; + onChanged(); + return this; + } + + private int sqlType_ ; + /** + * optional int32 sqlType = 2; + * + *
    +       **字段java中类型*
    +       * 
    + */ + public boolean hasSqlType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional int32 sqlType = 2; + * + *
    +       **字段java中类型*
    +       * 
    + */ + public int getSqlType() { + return sqlType_; + } + /** + * optional int32 sqlType = 2; + * + *
    +       **字段java中类型*
    +       * 
    + */ + public Builder setSqlType(int value) { + bitField0_ |= 0x00000002; + sqlType_ = value; + onChanged(); + return this; + } + /** + * optional int32 sqlType = 2; + * + *
    +       **字段java中类型*
    +       * 
    + */ + public Builder clearSqlType() { + bitField0_ = (bitField0_ & ~0x00000002); + sqlType_ = 0; + onChanged(); + return this; + } + + private Object name_ = ""; + /** + * optional string name = 3; + * + *
    +       **字段名称(忽略大小写),在mysql中是没有的*
    +       * 
    + */ + public boolean hasName() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional string name = 3; + * + *
    +       **字段名称(忽略大小写),在mysql中是没有的*
    +       * 
    + */ + public String getName() { + Object ref = name_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + name_ = s; + } + return s; + } else { + return (String) ref; + } + } + /** + * optional string name = 3; + * + *
    +       **字段名称(忽略大小写),在mysql中是没有的*
    +       * 
    + */ + public com.google.protobuf.ByteString + getNameBytes() { + Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string name = 3; + * + *
    +       **字段名称(忽略大小写),在mysql中是没有的*
    +       * 
    + */ + public Builder setName( + String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + name_ = value; + onChanged(); + return this; + } + /** + * optional string name = 3; + * + *
    +       **字段名称(忽略大小写),在mysql中是没有的*
    +       * 
    + */ + public Builder clearName() { + bitField0_ = (bitField0_ & ~0x00000004); + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * optional string name = 3; + * + *
    +       **字段名称(忽略大小写),在mysql中是没有的*
    +       * 
    + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + name_ = value; + onChanged(); + return this; + } + + private boolean isKey_ ; + /** + * optional bool isKey = 4; + * + *
    +       **是否是主键*
    +       * 
    + */ + public boolean hasIsKey() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * optional bool isKey = 4; + * + *
    +       **是否是主键*
    +       * 
    + */ + public boolean getIsKey() { + return isKey_; + } + /** + * optional bool isKey = 4; + * + *
    +       **是否是主键*
    +       * 
    + */ + public Builder setIsKey(boolean value) { + bitField0_ |= 0x00000008; + isKey_ = value; + onChanged(); + return this; + } + /** + * optional bool isKey = 4; + * + *
    +       **是否是主键*
    +       * 
    + */ + public Builder clearIsKey() { + bitField0_ = (bitField0_ & ~0x00000008); + isKey_ = false; + onChanged(); + return this; + } + + private boolean updated_ ; + /** + * optional bool updated = 5; + * + *
    +       **如果EventType=UPDATE,用于标识这个字段值是否有修改*
    +       * 
    + */ + public boolean hasUpdated() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** + * optional bool updated = 5; + * + *
    +       **如果EventType=UPDATE,用于标识这个字段值是否有修改*
    +       * 
    + */ + public boolean getUpdated() { + return updated_; + } + /** + * optional bool updated = 5; + * + *
    +       **如果EventType=UPDATE,用于标识这个字段值是否有修改*
    +       * 
    + */ + public Builder setUpdated(boolean value) { + bitField0_ |= 0x00000010; + updated_ = value; + onChanged(); + return this; + } + /** + * optional bool updated = 5; + * + *
    +       **如果EventType=UPDATE,用于标识这个字段值是否有修改*
    +       * 
    + */ + public Builder clearUpdated() { + bitField0_ = (bitField0_ & ~0x00000010); + updated_ = false; + onChanged(); + return this; + } + + private boolean isNull_ ; + /** + * optional bool isNull = 6 [default = false]; + * + *
    +       ** 标识是否为空  *
    +       * 
    + */ + public boolean hasIsNull() { + return ((bitField0_ & 0x00000020) == 0x00000020); + } + /** + * optional bool isNull = 6 [default = false]; + * + *
    +       ** 标识是否为空  *
    +       * 
    + */ + public boolean getIsNull() { + return isNull_; + } + /** + * optional bool isNull = 6 [default = false]; + * + *
    +       ** 标识是否为空  *
    +       * 
    + */ + public Builder setIsNull(boolean value) { + bitField0_ |= 0x00000020; + isNull_ = value; + onChanged(); + return this; + } + /** + * optional bool isNull = 6 [default = false]; + * + *
    +       ** 标识是否为空  *
    +       * 
    + */ + 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 com.google.protobuf.RepeatedFieldBuilder< + Pair, Pair.Builder, PairOrBuilder> propsBuilder_; + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
    +       **预留扩展*
    +       * 
    + */ + 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 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, 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, 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(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, 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( + 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, 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( + 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 Pair.Builder getPropsBuilder( + int index) { + return getPropsFieldBuilder().getBuilder(index); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
    +       **预留扩展*
    +       * 
    + */ + public 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 Pair.Builder addPropsBuilder() { + return getPropsFieldBuilder().addBuilder( + Pair.getDefaultInstance()); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
    +       **预留扩展*
    +       * 
    + */ + public Pair.Builder addPropsBuilder( + int index) { + return getPropsFieldBuilder().addBuilder( + index, Pair.getDefaultInstance()); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 7; + * + *
    +       **预留扩展*
    +       * 
    + */ + public java.util.List + getPropsBuilderList() { + return getPropsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + Pair, Pair.Builder, PairOrBuilder> + getPropsFieldBuilder() { + if (propsBuilder_ == null) { + propsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + Pair, Pair.Builder, PairOrBuilder>( + props_, + ((bitField0_ & 0x00000040) == 0x00000040), + getParentForChildren(), + isClean()); + props_ = null; + } + return propsBuilder_; + } + + private Object value_ = ""; + /** + * optional string value = 8; + * + *
    +       ** 字段值,timestamp,Datetime是一个时间格式的文本 *
    +       * 
    + */ + public boolean hasValue() { + return ((bitField0_ & 0x00000080) == 0x00000080); + } + /** + * optional string value = 8; + * + *
    +       ** 字段值,timestamp,Datetime是一个时间格式的文本 *
    +       * 
    + */ + public String getValue() { + Object ref = value_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + value_ = s; + } + return s; + } else { + return (String) ref; + } + } + /** + * optional string value = 8; + * + *
    +       ** 字段值,timestamp,Datetime是一个时间格式的文本 *
    +       * 
    + */ + public com.google.protobuf.ByteString + getValueBytes() { + Object ref = value_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string value = 8; + * + *
    +       ** 字段值,timestamp,Datetime是一个时间格式的文本 *
    +       * 
    + */ + public Builder setValue( + String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000080; + value_ = value; + onChanged(); + return this; + } + /** + * optional string value = 8; + * + *
    +       ** 字段值,timestamp,Datetime是一个时间格式的文本 *
    +       * 
    + */ + public Builder clearValue() { + bitField0_ = (bitField0_ & ~0x00000080); + value_ = getDefaultInstance().getValue(); + onChanged(); + return this; + } + /** + * optional string value = 8; + * + *
    +       ** 字段值,timestamp,Datetime是一个时间格式的文本 *
    +       * 
    + */ + public Builder setValueBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000080; + value_ = value; + onChanged(); + return this; + } + + private int length_ ; + /** + * optional int32 length = 9; + * + *
    +       ** 对应数据对象原始长度 *
    +       * 
    + */ + public boolean hasLength() { + return ((bitField0_ & 0x00000100) == 0x00000100); + } + /** + * optional int32 length = 9; + * + *
    +       ** 对应数据对象原始长度 *
    +       * 
    + */ + public int getLength() { + return length_; + } + /** + * optional int32 length = 9; + * + *
    +       ** 对应数据对象原始长度 *
    +       * 
    + */ + public Builder setLength(int value) { + bitField0_ |= 0x00000100; + length_ = value; + onChanged(); + return this; + } + /** + * optional int32 length = 9; + * + *
    +       ** 对应数据对象原始长度 *
    +       * 
    + */ + public Builder clearLength() { + bitField0_ = (bitField0_ & ~0x00000100); + length_ = 0; + onChanged(); + return this; + } + + private Object mysqlType_ = ""; + /** + * optional string mysqlType = 10; + * + *
    +       **字段mysql类型*
    +       * 
    + */ + public boolean hasMysqlType() { + return ((bitField0_ & 0x00000200) == 0x00000200); + } + /** + * optional string mysqlType = 10; + * + *
    +       **字段mysql类型*
    +       * 
    + */ + public String getMysqlType() { + Object ref = mysqlType_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + mysqlType_ = s; + } + return s; + } else { + return (String) ref; + } + } + /** + * optional string mysqlType = 10; + * + *
    +       **字段mysql类型*
    +       * 
    + */ + public com.google.protobuf.ByteString + getMysqlTypeBytes() { + Object ref = mysqlType_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + mysqlType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string mysqlType = 10; + * + *
    +       **字段mysql类型*
    +       * 
    + */ + public Builder setMysqlType( + 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) } - 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); + 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; + * + *
    +     ** 字段信息,增量数据(修改前,删除前) *
    +     * 
    + */ + 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; + * + *
    +     ** 字段信息,增量数据(修改前,删除前) *
    +     * 
    + */ + 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; + * + *
    +     ** 字段信息,增量数据(修改后,新增后)  *
    +     * 
    + */ + 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; + * + *
    +     ** 字段信息,增量数据(修改后,新增后)  *
    +     * 
    + */ + 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; + * + *
    +     **预留扩展*
    +     * 
    + */ + 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; + * + *
    +     **预留扩展*
    +     * 
    + */ + 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; + @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(Column.PARSER, extensionRegistry)); + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + afterColumns_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + afterColumns_.add(input.readMessage(Column.PARSER, extensionRegistry)); + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + props_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + props_.add(input.readMessage(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 CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowData_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowData_fieldAccessorTable + .ensureFieldAccessorsInitialized( + RowData.class, 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); + } + }; + + @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 Column getBeforeColumns(int index) { + return beforeColumns_.get(index); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
    +     ** 字段信息,增量数据(修改前,删除前) *
    +     * 
    + */ + public 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 Column getAfterColumns(int index) { + return afterColumns_.get(index); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
    +     ** 字段信息,增量数据(修改后,新增后)  *
    +     * 
    + */ + public 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 Pair getProps(int index) { + return props_.get(index); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
    +     **预留扩展*
    +     * 
    + */ + public 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; + @Override + protected Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static RowData parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static RowData parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static RowData parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static RowData parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static RowData parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static RowData parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static RowData parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static RowData parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static RowData parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static 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(RowData prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } /** * 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; - } - 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 + 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_); - } - 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; - * - *
    -             * * 字段信息,增量数据(修改前,删除前) *
    -             * 
    - */ - 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 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; - * - *
    -             * * 字段信息,增量数据(修改后,新增后)  *
    -             * 
    - */ - 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 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; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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 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) + RowDataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowData_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowData_fieldAccessorTable + .ensureFieldAccessorsInitialized( + RowData.class, Builder.class); + } + + // Construct using com.alibaba.otter.canal.protocol.CanalEntry.RowData.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getBeforeColumnsFieldBuilder(); + getAfterColumnsFieldBuilder(); + getPropsFieldBuilder(); } + } + private static Builder create() { + return new Builder(); + } - static { - defaultInstance = new RowData(true); - defaultInstance.initFields(); + 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; + } - // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.RowData) + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowData_descriptor; + } + + public RowData getDefaultInstanceForType() { + return RowData.getDefaultInstance(); + } + + public RowData build() { + RowData result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public RowData buildPartial() { + RowData result = new 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 RowData) { + return mergeFrom((RowData)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(RowData other) { + if (other == 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 { + RowData parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (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< + Column, Column.Builder, ColumnOrBuilder> beforeColumnsBuilder_; + + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
    +       ** 字段信息,增量数据(修改前,删除前) *
    +       * 
    + */ + 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 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, 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, 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(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, 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( + 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, 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( + 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 Column.Builder getBeforeColumnsBuilder( + int index) { + return getBeforeColumnsFieldBuilder().getBuilder(index); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
    +       ** 字段信息,增量数据(修改前,删除前) *
    +       * 
    + */ + public 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 Column.Builder addBeforeColumnsBuilder() { + return getBeforeColumnsFieldBuilder().addBuilder( + Column.getDefaultInstance()); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
    +       ** 字段信息,增量数据(修改前,删除前) *
    +       * 
    + */ + public Column.Builder addBeforeColumnsBuilder( + int index) { + return getBeforeColumnsFieldBuilder().addBuilder( + index, Column.getDefaultInstance()); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Column beforeColumns = 1; + * + *
    +       ** 字段信息,增量数据(修改前,删除前) *
    +       * 
    + */ + public java.util.List + getBeforeColumnsBuilderList() { + return getBeforeColumnsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + Column, Column.Builder, ColumnOrBuilder> + getBeforeColumnsFieldBuilder() { + if (beforeColumnsBuilder_ == null) { + beforeColumnsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + Column, Column.Builder, ColumnOrBuilder>( + 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< + Column, Column.Builder, ColumnOrBuilder> afterColumnsBuilder_; + + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
    +       ** 字段信息,增量数据(修改后,新增后)  *
    +       * 
    + */ + 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 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, 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, 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(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, 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( + 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, 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( + 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 Column.Builder getAfterColumnsBuilder( + int index) { + return getAfterColumnsFieldBuilder().getBuilder(index); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
    +       ** 字段信息,增量数据(修改后,新增后)  *
    +       * 
    + */ + public 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 Column.Builder addAfterColumnsBuilder() { + return getAfterColumnsFieldBuilder().addBuilder( + Column.getDefaultInstance()); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
    +       ** 字段信息,增量数据(修改后,新增后)  *
    +       * 
    + */ + public Column.Builder addAfterColumnsBuilder( + int index) { + return getAfterColumnsFieldBuilder().addBuilder( + index, Column.getDefaultInstance()); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Column afterColumns = 2; + * + *
    +       ** 字段信息,增量数据(修改后,新增后)  *
    +       * 
    + */ + public java.util.List + getAfterColumnsBuilderList() { + return getAfterColumnsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + Column, Column.Builder, ColumnOrBuilder> + getAfterColumnsFieldBuilder() { + if (afterColumnsBuilder_ == null) { + afterColumnsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + Column, Column.Builder, ColumnOrBuilder>( + 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< + Pair, Pair.Builder, PairOrBuilder> propsBuilder_; + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
    +       **预留扩展*
    +       * 
    + */ + 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 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, 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, 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(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, 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( + 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, 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( + 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 Pair.Builder getPropsBuilder( + int index) { + return getPropsFieldBuilder().getBuilder(index); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
    +       **预留扩展*
    +       * 
    + */ + public 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 Pair.Builder addPropsBuilder() { + return getPropsFieldBuilder().addBuilder( + Pair.getDefaultInstance()); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
    +       **预留扩展*
    +       * 
    + */ + public Pair.Builder addPropsBuilder( + int index) { + return getPropsFieldBuilder().addBuilder( + index, Pair.getDefaultInstance()); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
    +       **预留扩展*
    +       * 
    + */ + public java.util.List + getPropsBuilderList() { + return getPropsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + Pair, Pair.Builder, PairOrBuilder> + getPropsFieldBuilder() { + if (propsBuilder_ == null) { + propsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + Pair, Pair.Builder, PairOrBuilder>( + props_, + ((bitField0_ & 0x00000004) == 0x00000004), + getParentForChildren(), + isClean()); + props_ = null; + } + return propsBuilder_; + } + + // @@protoc_insertion_point(builder_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 { - - /** - * optional int64 tableId = 1; - * - *
    -         * *tableId,由数据库产生*
    -         * 
    - */ - boolean hasTableId(); - - /** - * optional int64 tableId = 1; - * - *
    -         * *tableId,由数据库产生*
    -         * 
    - */ - long getTableId(); - - /** - * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; - * - *
    -         * *数据变更类型*
    -         * 
    - */ - boolean hasEventType(); - - /** - * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; - * - *
    -         * *数据变更类型*
    -         * 
    - */ - com.alibaba.otter.canal.protocol.CanalEntry.EventType getEventType(); - - /** - * optional bool isDdl = 10 [default = false]; - * - *
    -         * * 标识是否是ddl语句  *
    -         * 
    - */ - boolean hasIsDdl(); - - /** - * optional bool isDdl = 10 [default = false]; - * - *
    -         * * 标识是否是ddl语句  *
    -         * 
    - */ - boolean getIsDdl(); - - /** - * optional string sql = 11; - * - *
    -         * * ddl/query的sql语句  *
    -         * 
    - */ - boolean hasSql(); - - /** - * optional string sql = 11; - * - *
    -         * * ddl/query的sql语句  *
    -         * 
    - */ - java.lang.String getSql(); - - /** - * optional string sql = 11; - * - *
    -         * * ddl/query的sql语句  *
    -         * 
    - */ - com.google.protobuf.ByteString getSqlBytes(); - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
    -         * * 一次数据库变更可能存在多行  *
    -         * 
    - */ - java.util.List getRowDatasList(); - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
    -         * * 一次数据库变更可能存在多行  *
    -         * 
    - */ - com.alibaba.otter.canal.protocol.CanalEntry.RowData getRowDatas(int index); - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
    -         * * 一次数据库变更可能存在多行  *
    -         * 
    - */ - int getRowDatasCount(); - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
    -         * * 一次数据库变更可能存在多行  *
    -         * 
    - */ - java.util.List getRowDatasOrBuilderList(); - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
    -         * * 一次数据库变更可能存在多行  *
    -         * 
    - */ - com.alibaba.otter.canal.protocol.CanalEntry.RowDataOrBuilder getRowDatasOrBuilder(int index); - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; - * - *
    -         * *预留扩展*
    -         * 
    - */ - java.util.List getPropsList(); - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; - * - *
    -         * *预留扩展*
    -         * 
    - */ - com.alibaba.otter.canal.protocol.CanalEntry.Pair getProps(int index); - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; - * - *
    -         * *预留扩展*
    -         * 
    - */ - int getPropsCount(); - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; - * - *
    -         * *预留扩展*
    -         * 
    - */ - java.util.List getPropsOrBuilderList(); - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; - * - *
    -         * *预留扩展*
    -         * 
    - */ - com.alibaba.otter.canal.protocol.CanalEntry.PairOrBuilder getPropsOrBuilder(int index); - - /** - * optional string ddlSchemaName = 14; - * - *
    -         * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
    -         * 
    - */ - boolean hasDdlSchemaName(); - - /** - * optional string ddlSchemaName = 14; - * - *
    -         * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
    -         * 
    - */ - java.lang.String getDdlSchemaName(); - - /** - * optional string ddlSchemaName = 14; - * - *
    -         * * ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
    -         * 
    - */ - com.google.protobuf.ByteString getDdlSchemaNameBytes(); + 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 { + + /** + * optional int64 tableId = 1; + * + *
    +     **tableId,由数据库产生*
    +     * 
    + */ + boolean hasTableId(); + /** + * optional int64 tableId = 1; + * + *
    +     **tableId,由数据库产生*
    +     * 
    + */ + long getTableId(); + + /** + * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; + * + *
    +     **数据变更类型*
    +     * 
    + */ + boolean hasEventType(); + /** + * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; + * + *
    +     **数据变更类型*
    +     * 
    + */ + EventType getEventType(); + + /** + * optional bool isDdl = 10 [default = false]; + * + *
    +     ** 标识是否是ddl语句  *
    +     * 
    + */ + boolean hasIsDdl(); + /** + * optional bool isDdl = 10 [default = false]; + * + *
    +     ** 标识是否是ddl语句  *
    +     * 
    + */ + boolean getIsDdl(); + + /** + * optional string sql = 11; + * + *
    +     ** ddl/query的sql语句  *
    +     * 
    + */ + boolean hasSql(); + /** + * optional string sql = 11; + * + *
    +     ** ddl/query的sql语句  *
    +     * 
    + */ + String getSql(); + /** + * optional string sql = 11; + * + *
    +     ** ddl/query的sql语句  *
    +     * 
    + */ + com.google.protobuf.ByteString + getSqlBytes(); + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
    +     ** 一次数据库变更可能存在多行  *
    +     * 
    + */ + java.util.List + getRowDatasList(); + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
    +     ** 一次数据库变更可能存在多行  *
    +     * 
    + */ + RowData getRowDatas(int index); + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
    +     ** 一次数据库变更可能存在多行  *
    +     * 
    + */ + int getRowDatasCount(); + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
    +     ** 一次数据库变更可能存在多行  *
    +     * 
    + */ + java.util.List + getRowDatasOrBuilderList(); + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
    +     ** 一次数据库变更可能存在多行  *
    +     * 
    + */ + RowDataOrBuilder getRowDatasOrBuilder(int index); + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; + * + *
    +     **预留扩展*
    +     * 
    + */ + java.util.List + getPropsList(); + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; + * + *
    +     **预留扩展*
    +     * 
    + */ + Pair getProps(int index); + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; + * + *
    +     **预留扩展*
    +     * 
    + */ + int getPropsCount(); + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; + * + *
    +     **预留扩展*
    +     * 
    + */ + java.util.List + getPropsOrBuilderList(); + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; + * + *
    +     **预留扩展*
    +     * 
    + */ + PairOrBuilder getPropsOrBuilder(int index); + + /** + * optional string ddlSchemaName = 14; + * + *
    +     ** ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
    +     * 
    + */ + boolean hasDdlSchemaName(); + /** + * optional string ddlSchemaName = 14; + * + *
    +     ** ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
    +     * 
    + */ + String getDdlSchemaName(); + /** + * optional string ddlSchemaName = 14; + * + *
    +     ** ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
    +     * 
    + */ + com.google.protobuf.ByteString + getDdlSchemaNameBytes(); + } + /** + * Protobuf type {@code com.alibaba.otter.canal.protocol.RowChange} + * + *
    +   **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(); } + + private static final RowChange defaultInstance; + public static RowChange getDefaultInstance() { + return defaultInstance; + } + + public RowChange getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @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(); + EventType value = 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(RowData.PARSER, extensionRegistry)); + break; + } + case 106: { + if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + props_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000020; + } + props_.add(input.readMessage(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 CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowChange_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowChange_fieldAccessorTable + .ensureFieldAccessorsInitialized( + RowChange.class, 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); + } + }; + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + public static final int TABLEID_FIELD_NUMBER = 1; + private long tableId_; + /** + * optional int64 tableId = 1; + * + *
    +     **tableId,由数据库产生*
    +     * 
    + */ + public boolean hasTableId() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional int64 tableId = 1; + * + *
    +     **tableId,由数据库产生*
    +     * 
    + */ + public long getTableId() { + return tableId_; + } + + public static final int EVENTTYPE_FIELD_NUMBER = 2; + private EventType eventType_; + /** + * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; + * + *
    +     **数据变更类型*
    +     * 
    + */ + public boolean hasEventType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; + * + *
    +     **数据变更类型*
    +     * 
    + */ + public EventType getEventType() { + return eventType_; + } + + public static final int ISDDL_FIELD_NUMBER = 10; + private boolean isDdl_; + /** + * optional bool isDdl = 10 [default = false]; + * + *
    +     ** 标识是否是ddl语句  *
    +     * 
    + */ + public boolean hasIsDdl() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional bool isDdl = 10 [default = false]; + * + *
    +     ** 标识是否是ddl语句  *
    +     * 
    + */ + public boolean getIsDdl() { + return isDdl_; + } + + public static final int SQL_FIELD_NUMBER = 11; + private Object sql_; + /** + * optional string sql = 11; + * + *
    +     ** ddl/query的sql语句  *
    +     * 
    + */ + public boolean hasSql() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * optional string sql = 11; + * + *
    +     ** ddl/query的sql语句  *
    +     * 
    + */ + public String getSql() { + Object ref = sql_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + sql_ = s; + } + return s; + } + } + /** + * optional string sql = 11; + * + *
    +     ** ddl/query的sql语句  *
    +     * 
    + */ + public com.google.protobuf.ByteString + getSqlBytes() { + Object ref = sql_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (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 RowData getRowDatas(int index) { + return rowDatas_.get(index); + } + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
    +     ** 一次数据库变更可能存在多行  *
    +     * 
    + */ + public 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 Pair getProps(int index) { + return props_.get(index); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; + * + *
    +     **预留扩展*
    +     * 
    + */ + public PairOrBuilder getPropsOrBuilder( + int index) { + return props_.get(index); + } + + public static final int DDLSCHEMANAME_FIELD_NUMBER = 14; + private 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 String getDdlSchemaName() { + Object ref = ddlSchemaName_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + ddlSchemaName_ = s; + } + return s; + } + } + /** + * optional string ddlSchemaName = 14; + * + *
    +     ** ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
    +     * 
    + */ + public com.google.protobuf.ByteString + getDdlSchemaNameBytes() { + Object ref = ddlSchemaName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + ddlSchemaName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private void initFields() { + tableId_ = 0L; + eventType_ = 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; + + memoizedIsInitialized = 1; + return true; + } + + 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 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; + @Override + protected Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static RowChange parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static RowChange parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static RowChange parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static RowChange parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static RowChange parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static RowChange parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static RowChange parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static RowChange parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static RowChange parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static 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(RowChange prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } /** * Protobuf type {@code com.alibaba.otter.canal.protocol.RowChange} * *
    -     * *message row 每行变更数据的数据结构*
    +     **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(); - } - - 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; - } - } - } - } 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_; - - /** - * optional int64 tableId = 1; - * - *
    -         * *tableId,由数据库产生*
    -         * 
    - */ - public boolean hasTableId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - - /** - * optional int64 tableId = 1; - * - *
    -         * *tableId,由数据库产生*
    -         * 
    - */ - public long getTableId() { - return tableId_; - } - - 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]; - * - *
    -         * *数据变更类型*
    -         * 
    - */ - public boolean hasEventType() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - - /** - * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; - * - *
    -         * *数据变更类型*
    -         * 
    - */ - public com.alibaba.otter.canal.protocol.CanalEntry.EventType getEventType() { - return eventType_; - } - - public static final int ISDDL_FIELD_NUMBER = 10; - private boolean isDdl_; - - /** - * optional bool isDdl = 10 [default = false]; - * - *
    -         * * 标识是否是ddl语句  *
    -         * 
    - */ - public boolean hasIsDdl() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - - /** - * optional bool isDdl = 10 [default = false]; - * - *
    -         * * 标识是否是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; - } - 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; - * - *
    -         * * 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; - } - return s; - } - } - - /** - * 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; - } - } - - 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; - - memoizedIsInitialized = 1; - return true; - } - - 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 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; - } - - /** - * Protobuf type {@code com.alibaba.otter.canal.protocol.RowChange} - * - *
    -         * *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_); - } - 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_; - - /** - * optional int64 tableId = 1; - * - *
    -             * *tableId,由数据库产生*
    -             * 
    - */ - public boolean hasTableId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - - /** - * optional int64 tableId = 1; - * - *
    -             * *tableId,由数据库产生*
    -             * 
    - */ - public long getTableId() { - return tableId_; - } - - /** - * optional int64 tableId = 1; - * - *
    -             * *tableId,由数据库产生*
    -             * 
    - */ - public Builder setTableId(long value) { - bitField0_ |= 0x00000001; - tableId_ = value; - onChanged(); - return this; - } - - /** - * optional int64 tableId = 1; - * - *
    -             * *tableId,由数据库产生*
    -             * 
    - */ - 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; - - /** - * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; - * - *
    -             * *数据变更类型*
    -             * 
    - */ - public boolean hasEventType() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - - /** - * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; - * - *
    -             * *数据变更类型*
    -             * 
    - */ - public com.alibaba.otter.canal.protocol.CanalEntry.EventType getEventType() { - return eventType_; - } - - /** - * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; - * - *
    -             * *数据变更类型*
    -             * 
    - */ - 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]; - * - *
    -             * *数据变更类型*
    -             * 
    - */ - public Builder clearEventType() { - bitField0_ = (bitField0_ & ~0x00000002); - eventType_ = com.alibaba.otter.canal.protocol.CanalEntry.EventType.UPDATE; - onChanged(); - return this; - } - - private boolean isDdl_; - - /** - * optional bool isDdl = 10 [default = false]; - * - *
    -             * * 标识是否是ddl语句  *
    -             * 
    - */ - public boolean hasIsDdl() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - - /** - * optional bool isDdl = 10 [default = false]; - * - *
    -             * * 标识是否是ddl语句  *
    -             * 
    - */ - public boolean getIsDdl() { - return isDdl_; - } - - /** - * optional bool isDdl = 10 [default = false]; - * - *
    -             * * 标识是否是ddl语句  *
    -             * 
    - */ - public Builder setIsDdl(boolean value) { - bitField0_ |= 0x00000004; - isDdl_ = value; - onChanged(); - return this; - } - - /** - * optional bool isDdl = 10 [default = false]; - * - *
    -             * * 标识是否是ddl语句  *
    -             * 
    - */ - public Builder clearIsDdl() { - bitField0_ = (bitField0_ & ~0x00000004); - isDdl_ = false; - onChanged(); - return this; - } - - 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)) { - 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; - * - *
    -             * * 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; - } - } - - /** - * optional string sql = 11; - * - *
    -             * * ddl/query的sql语句  *
    -             * 
    - */ - public Builder setSql(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000008; - sql_ = value; - onChanged(); - return this; - } - - /** - * optional string sql = 11; - * - *
    -             * * ddl/query的sql语句  *
    -             * 
    - */ - public Builder clearSql() { - bitField0_ = (bitField0_ & ~0x00000008); - sql_ = getDefaultInstance().getSql(); - onChanged(); - return this; - } - - /** - * optional string sql = 11; - * - *
    -             * * ddl/query的sql语句  *
    -             * 
    - */ - 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 com.google.protobuf.RepeatedFieldBuilder rowDatasBuilder_; - - /** - * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; - * - *
    -             * * 一次数据库变更可能存在多行  *
    -             * 
    - */ - 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 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; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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; - * - *
    -             * *预留扩展*
    -             * 
    - */ - public int getPropsCount() { - if (propsBuilder_ == null) { - return props_.size(); - } else { - return propsBuilder_.getCount(); - } - } - - /** - * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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_ = ""; - - /** - * optional string ddlSchemaName = 14; - * - *
    -             * * 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; - } - - // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.RowChange) + RowChangeOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowChange_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowChange_fieldAccessorTable + .ensureFieldAccessorsInitialized( + RowChange.class, Builder.class); + } + + // Construct using com.alibaba.otter.canal.protocol.CanalEntry.RowChange.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getRowDatasFieldBuilder(); + getPropsFieldBuilder(); } + } + private static Builder create() { + return new Builder(); + } - static { - defaultInstance = new RowChange(true); - defaultInstance.initFields(); + public Builder clear() { + super.clear(); + tableId_ = 0L; + bitField0_ = (bitField0_ & ~0x00000001); + eventType_ = 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; + } - // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.RowChange) + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_RowChange_descriptor; + } + + public RowChange getDefaultInstanceForType() { + return RowChange.getDefaultInstance(); + } + + public RowChange build() { + RowChange result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public RowChange buildPartial() { + RowChange result = new 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 RowChange) { + return mergeFrom((RowChange)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(RowChange other) { + if (other == 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 { + RowChange parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (RowChange) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private long tableId_ ; + /** + * optional int64 tableId = 1; + * + *
    +       **tableId,由数据库产生*
    +       * 
    + */ + public boolean hasTableId() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional int64 tableId = 1; + * + *
    +       **tableId,由数据库产生*
    +       * 
    + */ + public long getTableId() { + return tableId_; + } + /** + * optional int64 tableId = 1; + * + *
    +       **tableId,由数据库产生*
    +       * 
    + */ + public Builder setTableId(long value) { + bitField0_ |= 0x00000001; + tableId_ = value; + onChanged(); + return this; + } + /** + * optional int64 tableId = 1; + * + *
    +       **tableId,由数据库产生*
    +       * 
    + */ + public Builder clearTableId() { + bitField0_ = (bitField0_ & ~0x00000001); + tableId_ = 0L; + onChanged(); + return this; + } + + private EventType eventType_ = EventType.UPDATE; + /** + * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; + * + *
    +       **数据变更类型*
    +       * 
    + */ + public boolean hasEventType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; + * + *
    +       **数据变更类型*
    +       * 
    + */ + public EventType getEventType() { + return eventType_; + } + /** + * optional .com.alibaba.otter.canal.protocol.EventType eventType = 2 [default = UPDATE]; + * + *
    +       **数据变更类型*
    +       * 
    + */ + public Builder setEventType(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]; + * + *
    +       **数据变更类型*
    +       * 
    + */ + public Builder clearEventType() { + bitField0_ = (bitField0_ & ~0x00000002); + eventType_ = EventType.UPDATE; + onChanged(); + return this; + } + + private boolean isDdl_ ; + /** + * optional bool isDdl = 10 [default = false]; + * + *
    +       ** 标识是否是ddl语句  *
    +       * 
    + */ + public boolean hasIsDdl() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional bool isDdl = 10 [default = false]; + * + *
    +       ** 标识是否是ddl语句  *
    +       * 
    + */ + public boolean getIsDdl() { + return isDdl_; + } + /** + * optional bool isDdl = 10 [default = false]; + * + *
    +       ** 标识是否是ddl语句  *
    +       * 
    + */ + public Builder setIsDdl(boolean value) { + bitField0_ |= 0x00000004; + isDdl_ = value; + onChanged(); + return this; + } + /** + * optional bool isDdl = 10 [default = false]; + * + *
    +       ** 标识是否是ddl语句  *
    +       * 
    + */ + public Builder clearIsDdl() { + bitField0_ = (bitField0_ & ~0x00000004); + isDdl_ = false; + onChanged(); + return this; + } + + private Object sql_ = ""; + /** + * optional string sql = 11; + * + *
    +       ** ddl/query的sql语句  *
    +       * 
    + */ + public boolean hasSql() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * optional string sql = 11; + * + *
    +       ** ddl/query的sql语句  *
    +       * 
    + */ + public String getSql() { + Object ref = sql_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + sql_ = s; + } + return s; + } else { + return (String) ref; + } + } + /** + * optional string sql = 11; + * + *
    +       ** ddl/query的sql语句  *
    +       * 
    + */ + public com.google.protobuf.ByteString + getSqlBytes() { + Object ref = sql_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + sql_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string sql = 11; + * + *
    +       ** ddl/query的sql语句  *
    +       * 
    + */ + public Builder setSql( + String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000008; + sql_ = value; + onChanged(); + return this; + } + /** + * optional string sql = 11; + * + *
    +       ** ddl/query的sql语句  *
    +       * 
    + */ + public Builder clearSql() { + bitField0_ = (bitField0_ & ~0x00000008); + sql_ = getDefaultInstance().getSql(); + onChanged(); + return this; + } + /** + * optional string sql = 11; + * + *
    +       ** ddl/query的sql语句  *
    +       * 
    + */ + 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 com.google.protobuf.RepeatedFieldBuilder< + RowData, RowData.Builder, RowDataOrBuilder> rowDatasBuilder_; + + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
    +       ** 一次数据库变更可能存在多行  *
    +       * 
    + */ + 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 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, 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, 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(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, 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( + 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, 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( + 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 RowData.Builder getRowDatasBuilder( + int index) { + return getRowDatasFieldBuilder().getBuilder(index); + } + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
    +       ** 一次数据库变更可能存在多行  *
    +       * 
    + */ + public 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 RowData.Builder addRowDatasBuilder() { + return getRowDatasFieldBuilder().addBuilder( + RowData.getDefaultInstance()); + } + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
    +       ** 一次数据库变更可能存在多行  *
    +       * 
    + */ + public RowData.Builder addRowDatasBuilder( + int index) { + return getRowDatasFieldBuilder().addBuilder( + index, RowData.getDefaultInstance()); + } + /** + * repeated .com.alibaba.otter.canal.protocol.RowData rowDatas = 12; + * + *
    +       ** 一次数据库变更可能存在多行  *
    +       * 
    + */ + public java.util.List + getRowDatasBuilderList() { + return getRowDatasFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + RowData, RowData.Builder, RowDataOrBuilder> + getRowDatasFieldBuilder() { + if (rowDatasBuilder_ == null) { + rowDatasBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + RowData, RowData.Builder, RowDataOrBuilder>( + 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< + Pair, Pair.Builder, PairOrBuilder> propsBuilder_; + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; + * + *
    +       **预留扩展*
    +       * 
    + */ + 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; + * + *
    +       **预留扩展*
    +       * 
    + */ + public int getPropsCount() { + if (propsBuilder_ == null) { + return props_.size(); + } else { + return propsBuilder_.getCount(); + } + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; + * + *
    +       **预留扩展*
    +       * 
    + */ + public 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; + * + *
    +       **预留扩展*
    +       * 
    + */ + public Builder setProps( + int index, 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; + * + *
    +       **预留扩展*
    +       * 
    + */ + public Builder setProps( + int index, 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; + * + *
    +       **预留扩展*
    +       * 
    + */ + public Builder addProps(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; + * + *
    +       **预留扩展*
    +       * 
    + */ + public Builder addProps( + int index, 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; + * + *
    +       **预留扩展*
    +       * 
    + */ + public Builder addProps( + 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; + * + *
    +       **预留扩展*
    +       * 
    + */ + public Builder addProps( + int index, 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; + * + *
    +       **预留扩展*
    +       * 
    + */ + public Builder addAllProps( + 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; + * + *
    +       **预留扩展*
    +       * 
    + */ + 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; + * + *
    +       **预留扩展*
    +       * 
    + */ + 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; + * + *
    +       **预留扩展*
    +       * 
    + */ + public Pair.Builder getPropsBuilder( + int index) { + return getPropsFieldBuilder().getBuilder(index); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; + * + *
    +       **预留扩展*
    +       * 
    + */ + public 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; + * + *
    +       **预留扩展*
    +       * 
    + */ + 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; + * + *
    +       **预留扩展*
    +       * 
    + */ + public Pair.Builder addPropsBuilder() { + return getPropsFieldBuilder().addBuilder( + Pair.getDefaultInstance()); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; + * + *
    +       **预留扩展*
    +       * 
    + */ + public Pair.Builder addPropsBuilder( + int index) { + return getPropsFieldBuilder().addBuilder( + index, Pair.getDefaultInstance()); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 13; + * + *
    +       **预留扩展*
    +       * 
    + */ + public java.util.List + getPropsBuilderList() { + return getPropsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + Pair, Pair.Builder, PairOrBuilder> + getPropsFieldBuilder() { + if (propsBuilder_ == null) { + propsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + Pair, Pair.Builder, PairOrBuilder>( + props_, + ((bitField0_ & 0x00000020) == 0x00000020), + getParentForChildren(), + isClean()); + props_ = null; + } + return propsBuilder_; + } + + private Object ddlSchemaName_ = ""; + /** + * optional string ddlSchemaName = 14; + * + *
    +       ** ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
    +       * 
    + */ + public boolean hasDdlSchemaName() { + return ((bitField0_ & 0x00000040) == 0x00000040); + } + /** + * optional string ddlSchemaName = 14; + * + *
    +       ** ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
    +       * 
    + */ + public String getDdlSchemaName() { + Object ref = ddlSchemaName_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + ddlSchemaName_ = s; + } + return s; + } else { + return (String) ref; + } + } + /** + * optional string ddlSchemaName = 14; + * + *
    +       ** ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  *
    +       * 
    + */ + public com.google.protobuf.ByteString + getDdlSchemaNameBytes() { + Object ref = ddlSchemaName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (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( + 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) } - public interface TransactionBeginOrBuilder extends - // @@protoc_insertion_point(interface_extends:com.alibaba.otter.canal.protocol.TransactionBegin) - com.google.protobuf.MessageOrBuilder { - - /** - * optional int64 executeTime = 1; - * - *
    -         * *已废弃,请使用header里的executeTime*
    -         * 
    - */ - boolean hasExecuteTime(); - - /** - * optional int64 executeTime = 1; - * - *
    -         * *已废弃,请使用header里的executeTime*
    -         * 
    - */ - long getExecuteTime(); - - /** - * optional string transactionId = 2; - * - *
    -         * *已废弃,Begin里不提供事务id*
    -         * 
    - */ - boolean hasTransactionId(); - - /** - * optional string transactionId = 2; - * - *
    -         * *已废弃,Begin里不提供事务id*
    -         * 
    - */ - java.lang.String getTransactionId(); - - /** - * optional string transactionId = 2; - * - *
    -         * *已废弃,Begin里不提供事务id*
    -         * 
    - */ - com.google.protobuf.ByteString getTransactionIdBytes(); - - /** - * 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); - - /** - * optional int64 threadId = 4; - * - *
    -         * *执行的thread Id*
    -         * 
    - */ - boolean hasThreadId(); - - /** - * optional int64 threadId = 4; - * - *
    -         * *执行的thread Id*
    -         * 
    - */ - long getThreadId(); + 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 { + + /** + * optional int64 executeTime = 1; + * + *
    +     **已废弃,请使用header里的executeTime*
    +     * 
    + */ + boolean hasExecuteTime(); + /** + * optional int64 executeTime = 1; + * + *
    +     **已废弃,请使用header里的executeTime*
    +     * 
    + */ + long getExecuteTime(); + + /** + * optional string transactionId = 2; + * + *
    +     **已废弃,Begin里不提供事务id*
    +     * 
    + */ + boolean hasTransactionId(); + /** + * optional string transactionId = 2; + * + *
    +     **已废弃,Begin里不提供事务id*
    +     * 
    + */ + String getTransactionId(); + /** + * optional string transactionId = 2; + * + *
    +     **已废弃,Begin里不提供事务id*
    +     * 
    + */ + com.google.protobuf.ByteString + getTransactionIdBytes(); + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
    +     **预留扩展*
    +     * 
    + */ + java.util.List + getPropsList(); + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
    +     **预留扩展*
    +     * 
    + */ + 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; + * + *
    +     **预留扩展*
    +     * 
    + */ + PairOrBuilder getPropsOrBuilder(int index); + + /** + * optional int64 threadId = 4; + * + *
    +     **执行的thread Id*
    +     * 
    + */ + boolean hasThreadId(); + /** + * optional int64 threadId = 4; + * + *
    +     **执行的thread Id*
    +     * 
    + */ + long getThreadId(); + } + /** + * Protobuf type {@code com.alibaba.otter.canal.protocol.TransactionBegin} + * + *
    +   **开始事务的一些信息*
    +   * 
    + */ + 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(); } + + private static final TransactionBegin defaultInstance; + public static TransactionBegin getDefaultInstance() { + return defaultInstance; + } + + public TransactionBegin getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @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(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 CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_fieldAccessorTable + .ensureFieldAccessorsInitialized( + TransactionBegin.class, 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); + } + }; + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + public static final int EXECUTETIME_FIELD_NUMBER = 1; + private long executeTime_; + /** + * optional int64 executeTime = 1; + * + *
    +     **已废弃,请使用header里的executeTime*
    +     * 
    + */ + public boolean hasExecuteTime() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional int64 executeTime = 1; + * + *
    +     **已废弃,请使用header里的executeTime*
    +     * 
    + */ + public long getExecuteTime() { + return executeTime_; + } + + public static final int TRANSACTIONID_FIELD_NUMBER = 2; + private Object transactionId_; + /** + * optional string transactionId = 2; + * + *
    +     **已废弃,Begin里不提供事务id*
    +     * 
    + */ + public boolean hasTransactionId() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional string transactionId = 2; + * + *
    +     **已废弃,Begin里不提供事务id*
    +     * 
    + */ + public String getTransactionId() { + Object ref = transactionId_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + transactionId_ = s; + } + return s; + } + } + /** + * optional string transactionId = 2; + * + *
    +     **已废弃,Begin里不提供事务id*
    +     * 
    + */ + public com.google.protobuf.ByteString + getTransactionIdBytes() { + Object ref = transactionId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (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_; + } + /** + * 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 Pair getProps(int index) { + return props_.get(index); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
    +     **预留扩展*
    +     * 
    + */ + public PairOrBuilder getPropsOrBuilder( + int index) { + return props_.get(index); + } + + public static final int THREADID_FIELD_NUMBER = 4; + private long threadId_; + /** + * optional int64 threadId = 4; + * + *
    +     **执行的thread Id*
    +     * 
    + */ + public boolean hasThreadId() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional int64 threadId = 4; + * + *
    +     **执行的thread Id*
    +     * 
    + */ + 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; + + memoizedIsInitialized = 1; + return true; + } + + 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 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, 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; + @Override + protected Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static TransactionBegin parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static TransactionBegin parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static TransactionBegin parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static TransactionBegin parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static TransactionBegin parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static TransactionBegin parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static TransactionBegin parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static TransactionBegin parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static TransactionBegin parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static 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(TransactionBegin prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } /** * Protobuf type {@code com.alibaba.otter.canal.protocol.TransactionBegin} * *
    -     * *开始事务的一些信息*
    +     **开始事务的一些信息*
          * 
    */ - 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(); - } - - 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; - } - } - } - } 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_; - - /** - * optional int64 executeTime = 1; - * - *
    -         * *已废弃,请使用header里的executeTime*
    -         * 
    - */ - public boolean hasExecuteTime() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - - /** - * optional int64 executeTime = 1; - * - *
    -         * *已废弃,请使用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; - } - 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_; - } - - /** - * 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); - } - - public static final int THREADID_FIELD_NUMBER = 4; - private long threadId_; - - /** - * optional int64 threadId = 4; - * - *
    -         * *执行的thread Id*
    -         * 
    - */ - public boolean hasThreadId() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - - /** - * optional int64 threadId = 4; - * - *
    -         * *执行的thread Id*
    -         * 
    - */ - 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; - - memoizedIsInitialized = 1; - return true; - } - - 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 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, 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; - } - - /** - * Protobuf type - * {@code com.alibaba.otter.canal.protocol.TransactionBegin} - * - *
    -         * *开始事务的一些信息*
    -         * 
    - */ - 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 { + TransactionBeginOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_descriptor; + } - 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 FieldAccessorTable + internalGetFieldAccessorTable() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_fieldAccessorTable + .ensureFieldAccessorsInitialized( + TransactionBegin.class, Builder.class); + } - 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(); + } - // 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_); - } - 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_; - - /** - * optional int64 executeTime = 1; - * - *
    -             * *已废弃,请使用header里的executeTime*
    -             * 
    - */ - public boolean hasExecuteTime() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - - /** - * optional int64 executeTime = 1; - * - *
    -             * *已废弃,请使用header里的executeTime*
    -             * 
    - */ - public long getExecuteTime() { - return executeTime_; - } - - /** - * optional int64 executeTime = 1; - * - *
    -             * *已废弃,请使用header里的executeTime*
    -             * 
    - */ - public Builder setExecuteTime(long value) { - bitField0_ |= 0x00000001; - executeTime_ = value; - onChanged(); - return this; - } - - /** - * optional int64 executeTime = 1; - * - *
    -             * *已废弃,请使用header里的executeTime*
    -             * 
    - */ - 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.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; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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 getPropsFieldBuilder() { - if (propsBuilder_ == null) { - propsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder(props_, - ((bitField0_ & 0x00000004) == 0x00000004), - getParentForChildren(), - isClean()); - props_ = null; - } - return propsBuilder_; - } - - private long threadId_; - - /** - * optional int64 threadId = 4; - * - *
    -             * *执行的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; - } - - // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.TransactionBegin) + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getPropsFieldBuilder(); } + } + private static Builder create() { + return new Builder(); + } - static { - defaultInstance = new TransactionBegin(true); - defaultInstance.initFields(); + 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; + } - // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.TransactionBegin) + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionBegin_descriptor; + } + + public TransactionBegin getDefaultInstanceForType() { + return TransactionBegin.getDefaultInstance(); + } + + public TransactionBegin build() { + TransactionBegin result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public TransactionBegin buildPartial() { + TransactionBegin result = new 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 TransactionBegin) { + return mergeFrom((TransactionBegin)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(TransactionBegin other) { + if (other == 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 { + TransactionBegin parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (TransactionBegin) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private long executeTime_ ; + /** + * optional int64 executeTime = 1; + * + *
    +       **已废弃,请使用header里的executeTime*
    +       * 
    + */ + public boolean hasExecuteTime() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional int64 executeTime = 1; + * + *
    +       **已废弃,请使用header里的executeTime*
    +       * 
    + */ + public long getExecuteTime() { + return executeTime_; + } + /** + * optional int64 executeTime = 1; + * + *
    +       **已废弃,请使用header里的executeTime*
    +       * 
    + */ + public Builder setExecuteTime(long value) { + bitField0_ |= 0x00000001; + executeTime_ = value; + onChanged(); + return this; + } + /** + * optional int64 executeTime = 1; + * + *
    +       **已废弃,请使用header里的executeTime*
    +       * 
    + */ + public Builder clearExecuteTime() { + bitField0_ = (bitField0_ & ~0x00000001); + executeTime_ = 0L; + onChanged(); + return this; + } + + private Object transactionId_ = ""; + /** + * optional string transactionId = 2; + * + *
    +       **已废弃,Begin里不提供事务id*
    +       * 
    + */ + public boolean hasTransactionId() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional string transactionId = 2; + * + *
    +       **已废弃,Begin里不提供事务id*
    +       * 
    + */ + public String getTransactionId() { + Object ref = transactionId_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + transactionId_ = s; + } + return s; + } else { + return (String) ref; + } + } + /** + * optional string transactionId = 2; + * + *
    +       **已废弃,Begin里不提供事务id*
    +       * 
    + */ + public com.google.protobuf.ByteString + getTransactionIdBytes() { + Object ref = transactionId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + transactionId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string transactionId = 2; + * + *
    +       **已废弃,Begin里不提供事务id*
    +       * 
    + */ + public Builder setTransactionId( + 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< + Pair, Pair.Builder, PairOrBuilder> propsBuilder_; + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
    +       **预留扩展*
    +       * 
    + */ + 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 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, 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, 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(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, 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( + 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, 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( + 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 Pair.Builder getPropsBuilder( + int index) { + return getPropsFieldBuilder().getBuilder(index); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
    +       **预留扩展*
    +       * 
    + */ + public 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 Pair.Builder addPropsBuilder() { + return getPropsFieldBuilder().addBuilder( + Pair.getDefaultInstance()); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
    +       **预留扩展*
    +       * 
    + */ + public Pair.Builder addPropsBuilder( + int index) { + return getPropsFieldBuilder().addBuilder( + index, Pair.getDefaultInstance()); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
    +       **预留扩展*
    +       * 
    + */ + public java.util.List + getPropsBuilderList() { + return getPropsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + Pair, Pair.Builder, PairOrBuilder> + getPropsFieldBuilder() { + if (propsBuilder_ == null) { + propsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + Pair, Pair.Builder, PairOrBuilder>( + props_, + ((bitField0_ & 0x00000004) == 0x00000004), + getParentForChildren(), + isClean()); + props_ = null; + } + return propsBuilder_; + } + + private long threadId_ ; + /** + * optional int64 threadId = 4; + * + *
    +       **执行的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; + } + + // @@protoc_insertion_point(builder_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 { - - /** - * optional int64 executeTime = 1; - * - *
    -         * *已废弃,请使用header里的executeTime*
    -         * 
    - */ - boolean hasExecuteTime(); - - /** - * optional int64 executeTime = 1; - * - *
    -         * *已废弃,请使用header里的executeTime*
    -         * 
    - */ - long getExecuteTime(); - - /** - * optional string transactionId = 2; - * - *
    -         * *事务号*
    -         * 
    - */ - boolean hasTransactionId(); - - /** - * optional string transactionId = 2; - * - *
    -         * *事务号*
    -         * 
    - */ - java.lang.String getTransactionId(); - - /** - * optional string transactionId = 2; - * - *
    -         * *事务号*
    -         * 
    - */ - com.google.protobuf.ByteString getTransactionIdBytes(); - - /** - * 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); + 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 { + + /** + * optional int64 executeTime = 1; + * + *
    +     **已废弃,请使用header里的executeTime*
    +     * 
    + */ + boolean hasExecuteTime(); + /** + * optional int64 executeTime = 1; + * + *
    +     **已废弃,请使用header里的executeTime*
    +     * 
    + */ + long getExecuteTime(); + + /** + * optional string transactionId = 2; + * + *
    +     **事务号*
    +     * 
    + */ + boolean hasTransactionId(); + /** + * optional string transactionId = 2; + * + *
    +     **事务号*
    +     * 
    + */ + String getTransactionId(); + /** + * optional string transactionId = 2; + * + *
    +     **事务号*
    +     * 
    + */ + com.google.protobuf.ByteString + getTransactionIdBytes(); + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
    +     **预留扩展*
    +     * 
    + */ + java.util.List + getPropsList(); + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
    +     **预留扩展*
    +     * 
    + */ + 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; + * + *
    +     **预留扩展*
    +     * 
    + */ + PairOrBuilder getPropsOrBuilder(int index); + } + /** + * Protobuf type {@code com.alibaba.otter.canal.protocol.TransactionEnd} + * + *
    +   **结束事务的一些信息*
    +   * 
    + */ + 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(); } + + private static final TransactionEnd defaultInstance; + public static TransactionEnd getDefaultInstance() { + return defaultInstance; + } + + public TransactionEnd getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @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(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 CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_fieldAccessorTable + .ensureFieldAccessorsInitialized( + TransactionEnd.class, 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); + } + }; + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + public static final int EXECUTETIME_FIELD_NUMBER = 1; + private long executeTime_; + /** + * optional int64 executeTime = 1; + * + *
    +     **已废弃,请使用header里的executeTime*
    +     * 
    + */ + public boolean hasExecuteTime() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional int64 executeTime = 1; + * + *
    +     **已废弃,请使用header里的executeTime*
    +     * 
    + */ + public long getExecuteTime() { + return executeTime_; + } + + public static final int TRANSACTIONID_FIELD_NUMBER = 2; + private Object transactionId_; + /** + * optional string transactionId = 2; + * + *
    +     **事务号*
    +     * 
    + */ + public boolean hasTransactionId() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional string transactionId = 2; + * + *
    +     **事务号*
    +     * 
    + */ + public String getTransactionId() { + Object ref = transactionId_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + transactionId_ = s; + } + return s; + } + } + /** + * optional string transactionId = 2; + * + *
    +     **事务号*
    +     * 
    + */ + public com.google.protobuf.ByteString + getTransactionIdBytes() { + Object ref = transactionId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (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_; + } + /** + * 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 Pair getProps(int index) { + return props_.get(index); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
    +     **预留扩展*
    +     * 
    + */ + public 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; + + memoizedIsInitialized = 1; + return true; + } + + 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 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, 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; + @Override + protected Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static TransactionEnd parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static TransactionEnd parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static TransactionEnd parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static TransactionEnd parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static TransactionEnd parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static TransactionEnd parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static TransactionEnd parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static TransactionEnd parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static TransactionEnd parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static 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(TransactionEnd prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } /** * Protobuf type {@code com.alibaba.otter.canal.protocol.TransactionEnd} * *
    -     * *结束事务的一些信息*
    +     **结束事务的一些信息*
          * 
    */ - 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(); - } - - 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; - } - } - } - } 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_; - - /** - * optional int64 executeTime = 1; - * - *
    -         * *已废弃,请使用header里的executeTime*
    -         * 
    - */ - public boolean hasExecuteTime() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - - /** - * optional int64 executeTime = 1; - * - *
    -         * *已废弃,请使用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; - } - 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_; - - /** - * 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() { - 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; - - memoizedIsInitialized = 1; - return true; - } - - 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 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, 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; - } - - /** - * Protobuf type {@code com.alibaba.otter.canal.protocol.TransactionEnd} - * - *
    -         * *结束事务的一些信息*
    -         * 
    - */ - 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 { + TransactionEndOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_descriptor; + } - 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 FieldAccessorTable + internalGetFieldAccessorTable() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_fieldAccessorTable + .ensureFieldAccessorsInitialized( + TransactionEnd.class, Builder.class); + } - 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(); + } - // 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_); - } - 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_; - - /** - * optional int64 executeTime = 1; - * - *
    -             * *已废弃,请使用header里的executeTime*
    -             * 
    - */ - public boolean hasExecuteTime() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - - /** - * optional int64 executeTime = 1; - * - *
    -             * *已废弃,请使用header里的executeTime*
    -             * 
    - */ - public long getExecuteTime() { - return executeTime_; - } - - /** - * optional int64 executeTime = 1; - * - *
    -             * *已废弃,请使用header里的executeTime*
    -             * 
    - */ - public Builder setExecuteTime(long value) { - bitField0_ |= 0x00000001; - executeTime_ = value; - onChanged(); - return this; - } - - /** - * optional int64 executeTime = 1; - * - *
    -             * *已废弃,请使用header里的executeTime*
    -             * 
    - */ - 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.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; - * - *
    -             * *预留扩展*
    -             * 
    - */ - 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 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) + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getPropsFieldBuilder(); } + } + private static Builder create() { + return new Builder(); + } - static { - defaultInstance = new TransactionEnd(true); - defaultInstance.initFields(); + 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; + } - // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.TransactionEnd) + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_TransactionEnd_descriptor; + } + + public TransactionEnd getDefaultInstanceForType() { + return TransactionEnd.getDefaultInstance(); + } + + public TransactionEnd build() { + TransactionEnd result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public TransactionEnd buildPartial() { + TransactionEnd result = new 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 TransactionEnd) { + return mergeFrom((TransactionEnd)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(TransactionEnd other) { + if (other == 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 { + TransactionEnd parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (TransactionEnd) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private long executeTime_ ; + /** + * optional int64 executeTime = 1; + * + *
    +       **已废弃,请使用header里的executeTime*
    +       * 
    + */ + public boolean hasExecuteTime() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional int64 executeTime = 1; + * + *
    +       **已废弃,请使用header里的executeTime*
    +       * 
    + */ + public long getExecuteTime() { + return executeTime_; + } + /** + * optional int64 executeTime = 1; + * + *
    +       **已废弃,请使用header里的executeTime*
    +       * 
    + */ + public Builder setExecuteTime(long value) { + bitField0_ |= 0x00000001; + executeTime_ = value; + onChanged(); + return this; + } + /** + * optional int64 executeTime = 1; + * + *
    +       **已废弃,请使用header里的executeTime*
    +       * 
    + */ + public Builder clearExecuteTime() { + bitField0_ = (bitField0_ & ~0x00000001); + executeTime_ = 0L; + onChanged(); + return this; + } + + private Object transactionId_ = ""; + /** + * optional string transactionId = 2; + * + *
    +       **事务号*
    +       * 
    + */ + public boolean hasTransactionId() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional string transactionId = 2; + * + *
    +       **事务号*
    +       * 
    + */ + public String getTransactionId() { + Object ref = transactionId_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + transactionId_ = s; + } + return s; + } else { + return (String) ref; + } + } + /** + * optional string transactionId = 2; + * + *
    +       **事务号*
    +       * 
    + */ + public com.google.protobuf.ByteString + getTransactionIdBytes() { + Object ref = transactionId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + transactionId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string transactionId = 2; + * + *
    +       **事务号*
    +       * 
    + */ + public Builder setTransactionId( + 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< + Pair, Pair.Builder, PairOrBuilder> propsBuilder_; + + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
    +       **预留扩展*
    +       * 
    + */ + 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 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, 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, 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(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, 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( + 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, 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( + 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 Pair.Builder getPropsBuilder( + int index) { + return getPropsFieldBuilder().getBuilder(index); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
    +       **预留扩展*
    +       * 
    + */ + public 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 Pair.Builder addPropsBuilder() { + return getPropsFieldBuilder().addBuilder( + Pair.getDefaultInstance()); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
    +       **预留扩展*
    +       * 
    + */ + public Pair.Builder addPropsBuilder( + int index) { + return getPropsFieldBuilder().addBuilder( + index, Pair.getDefaultInstance()); + } + /** + * repeated .com.alibaba.otter.canal.protocol.Pair props = 3; + * + *
    +       **预留扩展*
    +       * 
    + */ + public java.util.List + getPropsBuilderList() { + return getPropsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + Pair, Pair.Builder, PairOrBuilder> + getPropsFieldBuilder() { + if (propsBuilder_ == null) { + propsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + Pair, Pair.Builder, PairOrBuilder>( + props_, + ((bitField0_ & 0x00000004) == 0x00000004), + getParentForChildren(), + isClean()); + props_ = null; + } + return propsBuilder_; + } + + // @@protoc_insertion_point(builder_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(); + static { + defaultInstance = new TransactionEnd(true); + defaultInstance.initFields(); } + // @@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; + */ + String getKey(); + /** + * optional string key = 1; + */ + com.google.protobuf.ByteString + getKeyBytes(); + + /** + * optional string value = 2; + */ + boolean hasValue(); + /** + * optional string value = 2; + */ + String getValue(); + /** + * optional string value = 2; + */ + com.google.protobuf.ByteString + getValueBytes(); + } + /** + * Protobuf type {@code com.alibaba.otter.canal.protocol.Pair} + * + *
    +   **预留扩展*
    +   * 
    + */ + 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(); } + + private static final Pair defaultInstance; + public static Pair getDefaultInstance() { + return defaultInstance; + } + + public Pair getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @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; + } + } + } + } 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 CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Pair_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Pair_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Pair.class, 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); + } + }; + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + public static final int KEY_FIELD_NUMBER = 1; + private Object key_; + /** + * optional string key = 1; + */ + public boolean hasKey() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional string key = 1; + */ + public String getKey() { + Object ref = key_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + key_ = s; + } + return s; + } + } + /** + * optional string key = 1; + */ + public com.google.protobuf.ByteString + getKeyBytes() { + Object ref = key_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + key_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int VALUE_FIELD_NUMBER = 2; + private Object value_; + /** + * optional string value = 2; + */ + public boolean hasValue() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional string value = 2; + */ + public String getValue() { + Object ref = value_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + value_ = s; + } + return s; + } + } + /** + * optional string value = 2; + */ + public com.google.protobuf.ByteString + getValueBytes() { + Object ref = value_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (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; + @Override + protected Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static Pair parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Pair parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Pair parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Pair parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Pair parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static Pair parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static Pair parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static Pair parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static Pair parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static 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(Pair prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } /** * Protobuf type {@code com.alibaba.otter.canal.protocol.Pair} * *
    -     * *预留扩展*
    +     **预留扩展*
          * 
    */ - 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(); - } - - 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; - } - } - } - } 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; - } - 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; - } - - /** - * Protobuf type {@code com.alibaba.otter.canal.protocol.Pair} - * - *
    -         * *预留扩展*
    -         * 
    - */ - 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 { + PairOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Pair_descriptor; + } - 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 FieldAccessorTable + internalGetFieldAccessorTable() { + return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Pair_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Pair.class, Builder.class); + } - 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); - } + // Construct using com.alibaba.otter.canal.protocol.CanalEntry.Pair.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } - // 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 Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { } + } + private static Builder create() { + return new Builder(); + } - static { - defaultInstance = new Pair(true); - defaultInstance.initFields(); + 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 CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Pair_descriptor; + } + + public Pair getDefaultInstanceForType() { + return Pair.getDefaultInstance(); + } + + public Pair build() { + Pair result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); } + return result; + } - // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.Pair) + public Pair buildPartial() { + Pair result = new 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 Pair) { + return mergeFrom((Pair)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(Pair other) { + if (other == 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 { + Pair parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (Pair) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private Object key_ = ""; + /** + * optional string key = 1; + */ + public boolean hasKey() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional string key = 1; + */ + public String getKey() { + Object ref = key_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + key_ = s; + } + return s; + } else { + return (String) ref; + } + } + /** + * optional string key = 1; + */ + public com.google.protobuf.ByteString + getKeyBytes() { + Object ref = key_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + key_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string key = 1; + */ + public Builder setKey( + 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 Object value_ = ""; + /** + * optional string value = 2; + */ + public boolean hasValue() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional string value = 2; + */ + public String getValue() { + Object ref = value_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + value_ = s; + } + return s; + } else { + return (String) ref; + } + } + /** + * optional string value = 2; + */ + public com.google.protobuf.ByteString + getValueBytes() { + Object ref = value_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string value = 2; + */ + public Builder setValue( + 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 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", }); + defaultInstance = new Pair(true); + defaultInstance.initFields(); } - // @@protoc_insertion_point(outer_class_scope) + // @@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 { + 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*\306\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\014\n\010XACOMMIT\020\r\022\016\n\nXAROLLBACK" + + "\020\016\022\016\n\nMHEARTBEAT\020\017*(\n\004Type\022\n\n\006ORACLE\020\001\022\t" + + "\n\005MYSQL\020\002\022\t\n\005PGSQL\020\003B0\n com.alibaba.otte" + + "r.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 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 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 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 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 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 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 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 String[] { "Key", "Value", }); + } + + // @@protoc_insertion_point(outer_class_scope) } diff --git a/protocol/src/main/java/com/alibaba/otter/canal/protocol/EntryProtocol.proto b/protocol/src/main/java/com/alibaba/otter/canal/protocol/EntryProtocol.proto index b6d2ae76..526db41f 100644 --- a/protocol/src/main/java/com/alibaba/otter/canal/protocol/EntryProtocol.proto +++ b/protocol/src/main/java/com/alibaba/otter/canal/protocol/EntryProtocol.proto @@ -194,6 +194,8 @@ enum EventType { /** XA **/ XACOMMIT = 13; XAROLLBACK = 14; + /** MASTER HEARTBEAT **/ + MHEARTBEAT = 15; } /**数据库类型**/ @@ -201,4 +203,4 @@ enum Type { ORACLE = 1; MYSQL = 2; PGSQL = 3; -} \ No newline at end of file +} diff --git a/server/pom.xml b/server/pom.xml index 1d243981..b7f83d56 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -3,7 +3,7 @@ com.alibaba.otter canal - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT ../pom.xml canal.server diff --git a/server/src/main/java/com/alibaba/otter/canal/server/netty/CanalServerWithNettyProfiler.java b/server/src/main/java/com/alibaba/otter/canal/server/netty/CanalServerWithNettyProfiler.java new file mode 100644 index 00000000..cca3fa6b --- /dev/null +++ b/server/src/main/java/com/alibaba/otter/canal/server/netty/CanalServerWithNettyProfiler.java @@ -0,0 +1,39 @@ +package com.alibaba.otter.canal.server.netty; + +import com.alibaba.otter.canal.common.AbstractCanalLifeCycle; +import com.alibaba.otter.canal.server.netty.listener.ChannelFutureAggregator.ClientRequestResult; + +/** + * @author Chuanyi Li + */ +public class CanalServerWithNettyProfiler { + + public static final ClientInstanceProfiler NOP = new DefaultClientInstanceProfiler(); + private ClientInstanceProfiler instanceProfiler; + + private static class SingletonHolder { + private static CanalServerWithNettyProfiler SINGLETON = new CanalServerWithNettyProfiler(); + } + + private CanalServerWithNettyProfiler() { + this.instanceProfiler = NOP; + } + + public static CanalServerWithNettyProfiler profiler() { + return SingletonHolder.SINGLETON; + } + + public void profiling(ClientRequestResult result) { + instanceProfiler.profiling(result); + } + + public void setInstanceProfiler(ClientInstanceProfiler instanceProfiler) { + this.instanceProfiler = instanceProfiler; + } + + private static class DefaultClientInstanceProfiler extends AbstractCanalLifeCycle implements ClientInstanceProfiler { + @Override + public void profiling(ClientRequestResult result) {} + } + +} diff --git a/server/src/main/java/com/alibaba/otter/canal/server/netty/ClientInstanceProfiler.java b/server/src/main/java/com/alibaba/otter/canal/server/netty/ClientInstanceProfiler.java new file mode 100644 index 00000000..2ffbd46e --- /dev/null +++ b/server/src/main/java/com/alibaba/otter/canal/server/netty/ClientInstanceProfiler.java @@ -0,0 +1,13 @@ +package com.alibaba.otter.canal.server.netty; + +import com.alibaba.otter.canal.common.CanalLifeCycle; +import com.alibaba.otter.canal.server.netty.listener.ChannelFutureAggregator.ClientRequestResult; + +/** + * @author Chuanyi Li + */ +public interface ClientInstanceProfiler extends CanalLifeCycle { + + void profiling(ClientRequestResult result); + +} 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 20532400..43ecbe67 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 @@ -74,4 +74,20 @@ public class NettyUtils { .toByteArray(), channelFutureListener); } + + public static byte[] ackPacket() { + return Packet.newBuilder() + .setType(CanalPacket.PacketType.ACK) + .setBody(Ack.newBuilder().build().toByteString()) + .build() + .toByteArray(); + } + + public static byte[] errorPacket(int errorCode, String errorMessage) { + return Packet.newBuilder() + .setType(CanalPacket.PacketType.ACK) + .setBody(Ack.newBuilder().setErrorCode(errorCode).setErrorMessage(errorMessage).build().toByteString()) + .build() + .toByteArray(); + } } 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 60398ea7..597d692a 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 @@ -73,7 +73,7 @@ public class ClientAuthenticationHandler extends SimpleChannelHandler { MDC.remove("destination"); } } - + // 鉴权一次性,暂不统计 NettyUtils.ack(ctx.getChannel(), new ChannelFutureListener() { public void operationComplete(ChannelFuture future) throws Exception { 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 11bba043..a98e7b8b 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 @@ -3,6 +3,7 @@ package com.alibaba.otter.canal.server.netty.handler; import java.util.List; import java.util.concurrent.TimeUnit; +import com.alibaba.otter.canal.server.netty.listener.ChannelFutureAggregator; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.exception.ExceptionUtils; import org.jboss.netty.buffer.ChannelBuffer; @@ -51,6 +52,7 @@ public class SessionHandler extends SimpleChannelHandler { public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { logger.info("message receives in session handler..."); + long start = System.nanoTime(); ChannelBuffer buffer = (ChannelBuffer) e.getMessage(); Packet packet = Packet.parseFrom(buffer.readBytes(buffer.readableBytes()).array()); ClientIdentity clientIdentity = null; @@ -74,12 +76,13 @@ public class SessionHandler extends SimpleChannelHandler { embeddedServer.subscribe(clientIdentity); // ctx.setAttachment(clientIdentity);// 设置状态数据 - NettyUtils.ack(ctx.getChannel(), null); + byte[] ackBytes = NettyUtils.ackPacket(); + NettyUtils.write(ctx.getChannel(), ackBytes, new ChannelFutureAggregator(sub.getDestination(), + sub, packet.getType(), ackBytes.length, System.nanoTime() - start)); } else { - NettyUtils.error(401, - MessageFormatter.format("destination or clientId is null", sub.toString()).getMessage(), - ctx.getChannel(), - null); + byte[] errorBytes = NettyUtils.errorPacket(401, MessageFormatter.format("destination or clientId is null", sub.toString()).getMessage()); + NettyUtils.write(ctx.getChannel(), errorBytes ,new ChannelFutureAggregator(sub.getDestination(), + sub, packet.getType(), errorBytes.length, System.nanoTime() - start, (short) 401)); } break; case UNSUBSCRIPTION: @@ -91,12 +94,13 @@ public class SessionHandler extends SimpleChannelHandler { MDC.put("destination", clientIdentity.getDestination()); embeddedServer.unsubscribe(clientIdentity); stopCanalInstanceIfNecessary(clientIdentity);// 尝试关闭 - NettyUtils.ack(ctx.getChannel(), null); + byte[] ackBytes = NettyUtils.ackPacket(); + NettyUtils.write(ctx.getChannel(), ackBytes, new ChannelFutureAggregator(unsub.getDestination(), + unsub, packet.getType(), ackBytes.length, System.nanoTime() - start)); } else { - NettyUtils.error(401, - MessageFormatter.format("destination or clientId is null", unsub.toString()).getMessage(), - ctx.getChannel(), - null); + byte[] errorBytes = NettyUtils.errorPacket(401, MessageFormatter.format("destination or clientId is null", unsub.toString()).getMessage()); + NettyUtils.write(ctx.getChannel(), errorBytes, new ChannelFutureAggregator(unsub.getDestination(), + unsub, packet.getType(), errorBytes.length, System.nanoTime() - start, (short) 401)); } break; case GET: @@ -171,7 +175,8 @@ public class SessionHandler extends SimpleChannelHandler { output.writeBytes(2, rowEntries.get(i)); } output.checkNoSpaceLeft(); - NettyUtils.write(ctx.getChannel(), body, null); + NettyUtils.write(ctx.getChannel(), body, new ChannelFutureAggregator(get.getDestination(), + get, packet.getType(), body.length, System.nanoTime() - start, message.getId() == -1)); // output.flush(); // byteBuffer.flip(); @@ -192,14 +197,14 @@ public class SessionHandler extends SimpleChannelHandler { } } } - packetBuilder.setBody(messageBuilder.build().toByteString()); - NettyUtils.write(ctx.getChannel(), packetBuilder.build().toByteArray(), null);// 输出数据 + byte[] body = packetBuilder.setBody(messageBuilder.build().toByteString()).build().toByteArray(); + NettyUtils.write(ctx.getChannel(), body, new ChannelFutureAggregator(get.getDestination(), + get, packet.getType(), body.length, System.nanoTime() - start, message.getId() == -1));// 输出数据 } } else { - NettyUtils.error(401, - MessageFormatter.format("destination or clientId is null", get.toString()).getMessage(), - ctx.getChannel(), - null); + byte[] errorBytes = NettyUtils.errorPacket(401, MessageFormatter.format("destination or clientId is null", get.toString()).getMessage()); + NettyUtils.write(ctx.getChannel(), errorBytes, new ChannelFutureAggregator(get.getDestination(), + get, packet.getType(), errorBytes.length, System.nanoTime() - start, (short) 401)); } break; case CLIENTACK: @@ -207,10 +212,9 @@ public class SessionHandler extends SimpleChannelHandler { MDC.put("destination", ack.getDestination()); if (StringUtils.isNotEmpty(ack.getDestination()) && StringUtils.isNotEmpty(ack.getClientId())) { if (ack.getBatchId() == 0L) { - NettyUtils.error(402, - MessageFormatter.format("batchId should assign value", ack.toString()).getMessage(), - ctx.getChannel(), - null); + byte[] errorBytes = NettyUtils.errorPacket(402, MessageFormatter.format("batchId should assign value", ack.toString()).getMessage()); + NettyUtils.write(ctx.getChannel(), errorBytes, new ChannelFutureAggregator(ack.getDestination(), + ack, packet.getType(), errorBytes.length, System.nanoTime() - start, (short) 402)); } else if (ack.getBatchId() == -1L) { // -1代表上一次get没有数据,直接忽略之 // donothing } else { @@ -218,10 +222,9 @@ public class SessionHandler extends SimpleChannelHandler { embeddedServer.ack(clientIdentity, ack.getBatchId()); } } else { - NettyUtils.error(401, - MessageFormatter.format("destination or clientId is null", ack.toString()).getMessage(), - ctx.getChannel(), - null); + byte[] errorBytes = NettyUtils.errorPacket(401, MessageFormatter.format("destination or clientId is null", ack.toString()).getMessage()); + NettyUtils.write(ctx.getChannel(), errorBytes, new ChannelFutureAggregator(ack.getDestination(), + ack, packet.getType(), errorBytes.length, System.nanoTime() - start, (short) 401)); } break; case CLIENTROLLBACK: @@ -237,25 +240,23 @@ public class SessionHandler extends SimpleChannelHandler { embeddedServer.rollback(clientIdentity, rollback.getBatchId()); // 只回滚单个批次 } } else { - NettyUtils.error(401, - MessageFormatter.format("destination or clientId is null", rollback.toString()) - .getMessage(), - ctx.getChannel(), - null); + byte[] errorBytes = NettyUtils.errorPacket(401, MessageFormatter.format("destination or clientId is null", rollback.toString()).getMessage()); + NettyUtils.write(ctx.getChannel(), errorBytes, new ChannelFutureAggregator(rollback.getDestination(), + rollback, packet.getType(), errorBytes.length, System.nanoTime() - start, (short) 401)); } break; default: - NettyUtils.error(400, MessageFormatter.format("packet type={} is NOT supported!", packet.getType()) - .getMessage(), ctx.getChannel(), null); + byte[] errorBytes = NettyUtils.errorPacket(400, MessageFormatter.format("packet type={} is NOT supported!", packet.getType()).getMessage()); + NettyUtils.write(ctx.getChannel(), errorBytes, new ChannelFutureAggregator(ctx.getChannel().getRemoteAddress().toString(), + null, packet.getType(), errorBytes.length, System.nanoTime() - start, (short) 400)); break; } } catch (Throwable exception) { - NettyUtils.error(400, - MessageFormatter.format("something goes wrong with channel:{}, exception={}", + byte[] errorBytes = NettyUtils.errorPacket(400, MessageFormatter.format("something goes wrong with channel:{}, exception={}", ctx.getChannel(), - ExceptionUtils.getStackTrace(exception)).getMessage(), - ctx.getChannel(), - null); + ExceptionUtils.getStackTrace(exception)).getMessage()); + NettyUtils.write(ctx.getChannel(), errorBytes, new ChannelFutureAggregator(ctx.getChannel().getRemoteAddress().toString(), + null, packet.getType(), errorBytes.length, System.nanoTime() - start, (short) 400)); } finally { MDC.remove("destination"); } diff --git a/server/src/main/java/com/alibaba/otter/canal/server/netty/listener/ChannelFutureAggregator.java b/server/src/main/java/com/alibaba/otter/canal/server/netty/listener/ChannelFutureAggregator.java new file mode 100644 index 00000000..b962b9a0 --- /dev/null +++ b/server/src/main/java/com/alibaba/otter/canal/server/netty/listener/ChannelFutureAggregator.java @@ -0,0 +1,179 @@ +package com.alibaba.otter.canal.server.netty.listener; + +import com.alibaba.otter.canal.protocol.CanalPacket; +import com.google.common.base.Preconditions; +import com.google.protobuf.GeneratedMessage; +import org.jboss.netty.channel.ChannelFuture; +import org.jboss.netty.channel.ChannelFutureListener; + +import static com.alibaba.otter.canal.server.netty.CanalServerWithNettyProfiler.profiler; + +/** + * @author Chuanyi Li + */ +public class ChannelFutureAggregator implements ChannelFutureListener { + + private ClientRequestResult result; + + public ChannelFutureAggregator(String destination, GeneratedMessage request, CanalPacket.PacketType type, int amount, long latency, boolean empty) { + this(destination, request, type, amount, latency, empty, (short) 0); + } + + public ChannelFutureAggregator(String destination, GeneratedMessage request, CanalPacket.PacketType type, int amount, long latency) { + this(destination, request, type, amount, latency, false, (short) 0); + } + + public ChannelFutureAggregator(String destination, GeneratedMessage request, CanalPacket.PacketType type, int amount, long latency, short errorCode) { + this(destination, request, type, amount, latency, false, errorCode); + } + + private ChannelFutureAggregator(String destination, GeneratedMessage request, CanalPacket.PacketType type, int amount, long latency, boolean empty, short errorCode) { + this.result = new ClientRequestResult.Builder() + .destination(destination) + .type(type) + .request(request) + .amount(amount) + .latency(latency) + .errorCode(errorCode) + .empty(empty) + .build(); + } + + @Override + public void operationComplete(ChannelFuture future) { + // profiling after I/O operation + if (future.getCause() != null) { + result.channelError = future.getCause(); + } + profiler().profiling(result); + } + + /** + * Client request result pojo + */ + public static class ClientRequestResult { + + private String destination; + private CanalPacket.PacketType type; + private GeneratedMessage request; + private int amount; + private long latency; + private short errorCode; + private boolean empty; + private Throwable channelError; + + private ClientRequestResult() {} + + private ClientRequestResult(Builder builder) { + this.destination = Preconditions.checkNotNull(builder.destination); + this.type = Preconditions.checkNotNull(builder.type); + this.request = builder.request; + this.amount = builder.amount; + this.latency = builder.latency; + this.errorCode = builder.errorCode; + this.empty = builder.empty; + this.channelError = builder.channelError; + } + + // auto-generated + public static class Builder { + + private String destination; + private CanalPacket.PacketType type; + private GeneratedMessage request; + private int amount; + private long latency; + private short errorCode; + private boolean empty; + private Throwable channelError; + + Builder destination(String destination) { + this.destination = destination; + return this; + } + + Builder type(CanalPacket.PacketType type) { + this.type = type; + return this; + } + + Builder request(GeneratedMessage request) { + this.request = request; + return this; + } + + Builder amount(int amount) { + this.amount = amount; + return this; + } + + Builder latency(long latency) { + this.latency = latency; + return this; + } + + Builder errorCode(short errorCode) { + this.errorCode = errorCode; + return this; + } + + Builder empty(boolean empty) { + this.empty = empty; + return this; + } + + public Builder channelError(Throwable channelError) { + this.channelError = channelError; + return this; + } + + public Builder fromPrototype(ClientRequestResult prototype) { + destination = prototype.destination; + type = prototype.type; + request = prototype.request; + amount = prototype.amount; + latency = prototype.latency; + errorCode = prototype.errorCode; + empty = prototype.empty; + channelError = prototype.channelError; + return this; + } + + ClientRequestResult build() { + return new ClientRequestResult(this); + } + } + // getters + public String getDestination() { + return destination; + } + + public CanalPacket.PacketType getType() { + return type; + } + + public GeneratedMessage getRequest() { + return request; + } + + public int getAmount() { + return amount; + } + + public long getLatency() { + return latency; + } + + public short getErrorCode() { + return errorCode; + } + + public boolean getEmpty() { + return empty; + } + + public Throwable getChannelError() { + return channelError; + } + } +} 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/sink/pom.xml b/sink/pom.xml index 4ed7e04f..9f136d35 100644 --- a/sink/pom.xml +++ b/sink/pom.xml @@ -3,7 +3,7 @@ com.alibaba.otter canal - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT ../pom.xml com.alibaba.otter 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 6511e6ba..7afde6b6 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 @@ -39,6 +39,7 @@ public class EntryEventSink extends AbstractCanalEventSink> handler : getHandlers()) { events = handler.before(events); } - + long blockingStart = 0L; int fullTimes = 0; do { if (eventStore.tryPut(events)) { + if (fullTimes > 0) { + eventsSinkBlockingTime.addAndGet(System.nanoTime() - blockingStart); + } for (CanalEventDownStreamHandler> handler : getHandlers()) { events = handler.after(events); } return true; } else { + if (fullTimes == 0) { + blockingStart = System.nanoTime(); + } applyWait(++fullTimes); + if (fullTimes % 100 == 0) { + long nextStart = System.nanoTime(); + eventsSinkBlockingTime.addAndGet(nextStart - blockingStart); + blockingStart = nextStart; + } } for (CanalEventDownStreamHandler> handler : getHandlers()) { @@ -202,4 +214,8 @@ public class EntryEventSink extends AbstractCanalEventSink com.alibaba.otter canal - 1.0.26-SNAPSHOT + 1.1.0-SNAPSHOT ../pom.xml com.alibaba.otter 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 075d1524..00ba2e71 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 @@ -562,4 +562,23 @@ public class MemoryEventStoreWithBuffer extends AbstractCanalStoreScavenge imple this.ddlIsolation = ddlIsolation; } + public AtomicLong getPutSequence() { + return putSequence; + } + + public AtomicLong getAckSequence() { + return ackSequence; + } + + public AtomicLong getPutMemSize() { + return putMemSize; + } + + public AtomicLong getAckMemSize() { + return ackMemSize; + } + + public BatchMode getBatchMode() { + return batchMode; + } } 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 07e9fead..3fed5251 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 @@ -1,6 +1,7 @@ package com.alibaba.otter.canal.store.model; import java.io.Serializable; +import java.util.List; import org.apache.commons.lang.builder.ToStringBuilder; @@ -31,6 +32,7 @@ public class Event implements Serializable { private EventType eventType; private String gtid; private long rawLength; + private int rowsCount; public Event(){ } @@ -47,6 +49,17 @@ public class Event implements Serializable { // build raw this.rawEntry = entry.toByteString(); this.rawLength = rawEntry.size(); + if (entryType == EntryType.ROWDATA) { + List props = entry.getHeader().getPropsList(); + if (props != null) { + for (CanalEntry.Pair p : props) { + if ("rowsCount".equals(p.getKey())) { + rowsCount = Integer.parseInt(p.getValue()); + break; + } + } + } + } } public LogIdentity getLogIdentity() { @@ -129,7 +142,16 @@ public class Event implements Serializable { this.eventType = eventType; } + public int getRowsCount() { + return rowsCount; + } + + public void setRowsCount(int rowsCount) { + this.rowsCount = rowsCount; + } + public String toString() { return ToStringBuilder.reflectionToString(this, CanalToStringStyle.DEFAULT_STYLE); } + }