From 1433cec39b72173010d8c0b5ab81d793f4f30244 Mon Sep 17 00:00:00 2001 From: lubiao Date: Wed, 30 Mar 2022 20:49:17 +0800 Subject: [PATCH] 5.4.13 release --- README.md | 4 +- docker/admin/app.sh | 5 +- docker/bin/cdc_log_cleaner.sh | 38 +- docs/zh_CN/README.md | 4 +- polardbx-cdc-assemble/assembly.xml | 8 + polardbx-cdc-assemble/bin/process-check.sh | 37 +- polardbx-cdc-assemble/bin/start_rpl.sh | 125 + polardbx-cdc-assemble/bin/stop_rpl.sh | 37 + polardbx-cdc-assemble/pom.xml | 39 +- .../src/main/resources/logback.xml | 51 + .../src/main/resources/rpl-logback.xml | 265 ++ polardbx-cdc-canal/pom.xml | 4 +- .../polardbx/binlog/canal/CanalBootstrap.java | 15 +- .../canal/DefaultBinlogFileSizeFetcher.java | 50 + .../binlog/canal/IBinlogFileSizeFetcher.java | 14 + .../canal/binlog/LocalBinlogParser.java | 5 + .../binlog/canal/binlog/LogContext.java | 10 - .../binlog/canal/binlog/LogDecoder.java | 55 +- .../canal/binlog/dbms/DBMSRowChange.java | 4 + .../canal/binlog/event/RotateLogEvent.java | 6 + .../canal/binlog/event/RowsLogBuffer.java | 9 +- .../canal/core/AbstractEventParser.java | 16 + .../canal/core/BinlogEventProcessor.java | 8 +- .../binlog/canal/core/MysqlEventParser.java | 10 +- .../binlog/canal/core/ddl/TableMetaCache.java | 1 - .../canal/core/ddl/parser/DruidDdlParser.java | 7 + .../canal/core/ddl/tsdb/MemoryTableMeta.java | 153 +- .../canal/core/ddl/tsdb/TableMetaTSDB.java | 12 +- .../canal/core/dump/MysqlConnection.java | 20 +- .../core/handle/DefaultBinlogEventHandle.java | 8 +- .../core/handle/SearchTsoEventHandle.java | 205 +- .../canal/core/model/ServerCharactorSet.java | 8 + .../binlog/canal/system/SystemDB.java | 6 +- polardbx-cdc-common/pom.xml | 2 +- .../src/main/filters/dev.properties | 9 +- .../src/main/filters/release.properties | 9 +- .../aliyun/polardbx/binlog/CommonUtils.java | 7 + .../aliyun/polardbx/binlog/ConfigKeys.java | 68 + .../daemon/pipeline/CommandPipeline.java | 8 + ...nlogLogicMetaHistoryDynamicSqlSupport.java | 73 +- .../dao/BinlogLogicMetaHistoryMapper.java | 329 +- .../binlog/dao/PolarxCNodeInfoMapper.java | 304 ++ .../binlog/dao/RplDdlDynamicSqlSupport.java | 99 + .../polardbx/binlog/dao/RplDdlMapper.java | 261 ++ .../dao/RplServiceDynamicSqlSupport.java | 87 + .../polardbx/binlog/dao/RplServiceMapper.java | 245 ++ .../dao/RplStateMachineDynamicSqlSupport.java | 105 + .../binlog/dao/RplStateMachineMapper.java | 269 ++ .../RplTablePositionDynamicSqlSupport.java | 87 + .../binlog/dao/RplTablePositionMapper.java | 245 ++ .../binlog/dao/RplTaskDynamicSqlSupport.java | 153 + .../polardbx/binlog/dao/RplTaskMapper.java | 335 ++ .../SemiSnapshotInfoDynamicSqlSupport.java | 52 + .../binlog/dao/SemiSnapshotInfoMapper.java | 227 + .../domain/po/BinlogLogicMetaHistory.java | 125 +- .../binlog/domain/po/PolarxCNodeInfo.java | 239 ++ .../polardbx/binlog/domain/po/RplDdl.java | 205 + .../polardbx/binlog/domain/po/RplService.java | 171 + .../binlog/domain/po/RplStateMachine.java | 222 + .../binlog/domain/po/RplTablePosition.java | 171 + .../polardbx/binlog/domain/po/RplTask.java | 360 ++ .../binlog/domain/po/SemiSnapshotInfo.java | 102 + .../aliyun/polardbx/binlog/util/HexUtil.java | 446 ++ .../polardbx/binlog/util/LoopRetry.java | 128 + .../aliyun/polardbx/binlog/util/WgetCmd.java | 40 +- .../polardbx/binlog/util/WgetContext.java | 130 + .../src/main/resources/config.properties | 17 + .../src/main/resources/generatorConfig.xml | 19 + .../polardbx/binlog/CommonUtilsTest.java | 2 +- polardbx-cdc-daemon/pom.xml | 12 +- .../daemon/cluster/TopologyService.java | 2 +- .../service/BinlogBootstrapService.java | 9 + .../rest/resources/SystemControlResource.java | 1 + .../binlog/daemon/schedule/RplLeaderJob.java | 58 + .../binlog/daemon/schedule/RplWorkerJob.java | 51 + polardbx-cdc-dumper/pom.xml | 8 +- .../polardbx/binlog/dumper/CdcServer.java | 53 +- .../dump/logfile/BinlogEventReader.java | 3 + .../dumper/dump/logfile/BinlogFile.java | 64 +- .../dump/logfile/BinlogRecorderListener.java | 4 +- .../dumper/dump/logfile/LogFileGenerator.java | 67 +- .../dumper/dump/logfile/LogFileManager.java | 3 + .../dumper/dump/util/EventGenerator.java | 21 +- .../dumper/dump/util/TableIdManager.java | 112 + polardbx-cdc-format/pom.xml | 4 +- .../binlog/format/QueryEventBuilder.java | 1 - .../binlog/format/RowEventBuilder.java | 31 +- .../binlog/format/TableMapEventBuilder.java | 6 +- .../format/utils/CharsetConversion.java | 5 + .../format/utils/CharsetConversionTest.java | 38 + polardbx-cdc-meta/pom.xml | 12 +- .../binlog/cdc/meta/ConsistencyChecker.java | 286 ++ .../meta/CreateDropTableWithExistFilter.java | 51 + .../binlog/cdc/meta/ICdcTableMeta.java | 20 + .../binlog/cdc/meta/LogicTableMeta.java | 2 +- .../polardbx/binlog/cdc/meta/MetaType.java | 25 + .../cdc/meta/PolarDbXLogicTableMeta.java | 364 +- .../cdc/meta/PolarDbXStorageTableMeta.java | 272 +- .../cdc/meta/PolarDbXTableMetaManager.java | 655 ++- .../polardbx/binlog/cdc/meta/Printer.java | 75 + .../binlog/cdc/meta/RollbackMode.java | 44 + .../binlog/cdc/meta/domain/DDLRecord.java | 10 +- .../cdc/topology/LogicMetaTopology.java | 2 +- .../binlog/cdc/topology/TopologyManager.java | 13 + .../cdc/topology/vo/TopologyRecord.java | 2 +- .../db/migration/V17__Semi_Snapshot.sql | 9 + .../V18__Binlog_Logic_Meta_History.sql | 20 + .../db/migration/V19__Modify_Import_Meta.sql | 31 + .../meta/PolarDbXTableMetaManagerTest.java | 42 +- polardbx-cdc-monitor/pom.xml | 2 +- .../polardbx/binlog/monitor/MonitorType.java | 8 + polardbx-cdc-protocol/pom.xml | 6 +- .../polardbx/binlog/protocol/DumpReply.java | 1456 +++---- .../binlog/protocol/DumpReplyOrBuilder.java | 67 +- .../polardbx/binlog/protocol/DumpRequest.java | 1039 +++-- .../binlog/protocol/DumpRequestOrBuilder.java | 42 +- .../polardbx/binlog/protocol/MessageType.java | 359 +- .../polardbx/binlog/protocol/TxnBegin.java | 1713 ++++---- .../binlog/protocol/TxnBeginOrBuilder.java | 87 +- .../polardbx/binlog/protocol/TxnData.java | 1455 +++---- .../binlog/protocol/TxnDataOrBuilder.java | 67 +- .../polardbx/binlog/protocol/TxnEnd.java | 770 ++-- .../binlog/protocol/TxnEndOrBuilder.java | 17 - .../polardbx/binlog/protocol/TxnItem.java | 2089 +++++---- .../binlog/protocol/TxnItemOrBuilder.java | 187 +- .../binlog/protocol/TxnMergedToken.java | 1790 ++++---- .../protocol/TxnMergedTokenOrBuilder.java | 119 +- .../polardbx/binlog/protocol/TxnMessage.java | 2411 +++++------ .../binlog/protocol/TxnMessageOrBuilder.java | 176 +- .../binlog/protocol/TxnServiceGrpc.java | 454 +- .../polardbx/binlog/protocol/TxnStream.java | 365 +- .../polardbx/binlog/protocol/TxnTag.java | 1712 ++++---- .../binlog/protocol/TxnTagOrBuilder.java | 87 +- .../polardbx/binlog/protocol/TxnToken.java | 3762 +++++++++-------- .../binlog/protocol/TxnTokenOrBuilder.java | 403 +- .../polardbx/binlog/protocol/TxnType.java | 437 +- .../aliyun/polardbx/rpc/cdc/BinaryLog.java | 1166 +++-- .../polardbx/rpc/cdc/BinaryLogOrBuilder.java | 53 +- .../aliyun/polardbx/rpc/cdc/BinlogEvent.java | 1952 ++++----- .../rpc/cdc/BinlogEventOrBuilder.java | 135 +- .../polardbx/rpc/cdc/CdcServiceGrpc.java | 1401 +++--- .../polardbx/rpc/cdc/ChangeMasterRequest.java | 557 +++ .../rpc/cdc/ChangeMasterRequestOrBuilder.java | 21 + .../cdc/ChangeReplicationFilterRequest.java | 557 +++ ...angeReplicationFilterRequestOrBuilder.java | 21 + .../aliyun/polardbx/rpc/cdc/DumpRequest.java | 1166 +++-- .../rpc/cdc/DumpRequestOrBuilder.java | 53 +- .../aliyun/polardbx/rpc/cdc/DumpStream.java | 890 ++-- .../polardbx/rpc/cdc/DumpStreamOrBuilder.java | 28 +- .../aliyun/polardbx/rpc/cdc/DumperServer.java | 363 +- .../aliyun/polardbx/rpc/cdc/MasterStatus.java | 1972 ++++----- .../rpc/cdc/MasterStatusOrBuilder.java | 136 +- .../com/aliyun/polardbx/rpc/cdc/Request.java | 1036 +++-- .../polardbx/rpc/cdc/RequestOrBuilder.java | 42 +- .../polardbx/rpc/cdc/ResetSlaveRequest.java | 557 +++ .../rpc/cdc/ResetSlaveRequestOrBuilder.java | 21 + .../polardbx/rpc/cdc/RplCommandResponse.java | 629 +++ .../rpc/cdc/RplCommandResponseOrBuilder.java | 27 + .../rpc/cdc/ShowBinlogEventsRequest.java | 1432 +++---- .../cdc/ShowBinlogEventsRequestOrBuilder.java | 81 +- .../rpc/cdc/ShowSlaveStatusRequest.java | 557 +++ .../cdc/ShowSlaveStatusRequestOrBuilder.java | 21 + .../rpc/cdc/ShowSlaveStatusResponse.java | 557 +++ .../cdc/ShowSlaveStatusResponseOrBuilder.java | 21 + .../polardbx/rpc/cdc/StartSlaveRequest.java | 557 +++ .../rpc/cdc/StartSlaveRequestOrBuilder.java | 21 + .../polardbx/rpc/cdc/StopSlaveRequest.java | 557 +++ .../rpc/cdc/StopSlaveRequestOrBuilder.java | 21 + .../src/main/proto/DumperServer.proto | 47 + .../src/main/proto/TxnStream.proto | 32 +- polardbx-cdc-rpl/README.md | 87 + polardbx-cdc-rpl/assembly.xml | 41 + polardbx-cdc-rpl/bin/tool.sh | 116 + polardbx-cdc-rpl/pom.xml | 121 + .../aliyun/polardbx/rpl/RplTaskEngine.java | 69 + .../aliyun/polardbx/rpl/RplTaskRunner.java | 234 + .../polardbx/rpl/applier/ApplyHelper.java | 638 +++ .../polardbx/rpl/applier/BaseApplier.java | 71 + .../polardbx/rpl/applier/DdlHelper.java | 191 + .../polardbx/rpl/applier/DdlSqlContext.java | 37 + .../polardbx/rpl/applier/FlowLimiter.java | 28 + .../polardbx/rpl/applier/MergeApplier.java | 225 + .../rpl/applier/MergeDmlSqlContext.java | 38 + .../rpl/applier/MergeTransactionApplier.java | 325 ++ .../polardbx/rpl/applier/MysqlApplier.java | 369 ++ .../aliyun/polardbx/rpl/applier/RowKey.java | 99 + .../polardbx/rpl/applier/SplitApplier.java | 155 + .../rpl/applier/SplitTransactionApplier.java | 109 + .../polardbx/rpl/applier/SqlContext.java | 41 + .../rpl/applier/StatisticCounter.java | 75 + .../polardbx/rpl/applier/StatisticUnit.java | 41 + .../rpl/applier/StatisticalProxy.java | 371 ++ .../polardbx/rpl/applier/TPSLimiter.java | 97 + .../polardbx/rpl/applier/Transaction.java | 52 + .../rpl/applier/TransactionApplier.java | 100 + .../rpl/applier/TransactionBatch.java | 41 + .../polardbx/rpl/common/CalendarUtil.java | 663 +++ .../polardbx/rpl/common/CommonUtil.java | 156 + .../polardbx/rpl/common/DataCompareUtil.java | 295 ++ .../polardbx/rpl/common/DataSourceUtil.java | 475 +++ .../polardbx/rpl/common/DateParseUtil.java | 629 +++ .../rpl/common/DruidDataSourceWrapper.java | 409 ++ .../polardbx/rpl/common/HostManager.java | 53 + .../aliyun/polardbx/rpl/common/LogUtil.java | 187 + .../rpl/common/NamedThreadFactory.java | 44 + .../polardbx/rpl/common/PasswordUtil.java | 50 + .../polardbx/rpl/common/ResultCode.java | 42 + .../polardbx/rpl/common/RplConstants.java | 229 + .../polardbx/rpl/common/StringUtils2.java | 140 + .../rpl/common/TaskBasedDiscriminator.java | 85 + .../polardbx/rpl/common/TaskContext.java | 73 + .../polardbx/rpl/common/ThreadPoolUtil.java | 55 + .../rpl/common/fsmutil/AbstractFSM.java | 78 + .../rpl/common/fsmutil/FSMAction.java | 48 + .../rpl/common/fsmutil/FSMManager.java | 54 + .../polardbx/rpl/common/fsmutil/FSMState.java | 88 + .../rpl/common/fsmutil/FSMTransition.java | 57 + .../common/fsmutil/FSMTriggeredAction.java | 28 + .../rpl/common/fsmutil/ReplicaFSM.java | 50 + .../rpl/common/fsmutil/ServiceDetail.java | 30 + .../rpl/common/fsmutil/TaskDetail.java | 37 + .../polardbx/rpl/dbmeta/ColumnInfo.java | 42 + .../polardbx/rpl/dbmeta/ColumnValue.java | 54 + .../polardbx/rpl/dbmeta/DbMetaCache.java | 142 + .../polardbx/rpl/dbmeta/DbMetaManager.java | 369 ++ .../polardbx/rpl/dbmeta/KeyColumnInfo.java | 42 + .../aliyun/polardbx/rpl/dbmeta/TableInfo.java | 45 + .../polardbx/rpl/extractor/BaseExtractor.java | 62 + .../rpl/extractor/CanalBinlogExtractor.java | 286 ++ .../rpl/extractor/LogEventConvert.java | 772 ++++ .../rpl/extractor/NoTsoMysqlEventParser.java | 703 +++ .../cdc/DefaultCdcExtractHandler.java | 118 + .../rpl/extractor/cdc/EventParser.java | 33 + .../cdc/buffer/StreamObserverBuffer.java | 188 + .../rpl/extractor/cdc/buffer/StreamPipe.java | 48 + .../rpl/extractor/full/ExtractorUtil.java | 113 + .../rpl/extractor/full/RowChangeBuilder.java | 568 +++ .../rpl/extractor/full/RowChangeHelper.java | 363 ++ .../polardbx/rpl/filter/BaseFilter.java | 72 + .../polardbx/rpl/filter/ReplicateFilter.java | 286 ++ .../polardbx/rpl/pipeline/BasePipeline.java | 54 + .../polardbx/rpl/pipeline/MessageEvent.java | 49 + .../rpl/pipeline/MessageEventFactory.java | 32 + .../polardbx/rpl/pipeline/SerialPipeline.java | 515 +++ .../polardbx/rpl/taskmeta/ApplierConfig.java | 38 + .../polardbx/rpl/taskmeta/ApplierType.java | 78 + .../rpl/taskmeta/DbTaskMetaManager.java | 450 ++ .../polardbx/rpl/taskmeta/DdlState.java | 55 + .../rpl/taskmeta/ExtractorConfig.java | 33 + .../polardbx/rpl/taskmeta/ExtractorType.java | 47 + .../polardbx/rpl/taskmeta/FSMMetaManager.java | 522 +++ .../polardbx/rpl/taskmeta/FilterType.java | 50 + .../polardbx/rpl/taskmeta/HostInfo.java | 52 + .../polardbx/rpl/taskmeta/HostType.java | 49 + .../polardbx/rpl/taskmeta/PipelineConfig.java | 35 + .../polardbx/rpl/taskmeta/ReplicateMeta.java | 47 + .../rpl/taskmeta/RplServiceManager.java | 506 +++ .../polardbx/rpl/taskmeta/ServiceStatus.java | 71 + .../polardbx/rpl/taskmeta/ServiceType.java | 61 + .../rpl/taskmeta/StateMachineStatus.java | 53 + .../rpl/taskmeta/StateMachineType.java | 53 + .../polardbx/rpl/taskmeta/TaskStatus.java | 55 + .../com/aliyun/polardbx/rpl/TestBase.java | 497 +++ .../polardbx/rpl/applier/DdlHelperTest.java | 85 + .../rpl/applier/MergeApplierTest.java | 117 + .../rpl/dbmeta/DbMetaManagerTest.java | 54 + .../rpl/filter/ReplicateFilterTest.java | 700 +++ .../aliyun/polardbx/rpl/task/CharsetTest.java | 213 + .../polardbx/rpl/task/CharsetWriteTest.java | 245 ++ .../aliyun/polardbx/rpl/task/DdlE2ETest.java | 1619 +++++++ .../aliyun/polardbx/rpl/task/DmlE2ETest.java | 459 ++ .../aliyun/polardbx/rpl/task/DmlPerfTest.java | 153 + .../polardbx/rpl/task/PrimaryKeyTest.java | 321 ++ .../polardbx/rpl/task/TransactionTest.java | 161 + .../polardbx/rpl/task/TransferTest.java | 109 + .../src/test/resources/logback.xml | 224 + polardbx-cdc-storage/pom.xml | 2 +- .../polardbx/binlog/storage/TxnBuffer.java | 33 +- .../binlog/storage/TxnBufferItem.java | 8 + .../polardbx/binlog/storage/TxnItemRef.java | 36 +- .../polardbx/binlog/storage/TxnKey.java | 17 +- .../binlog/storage/TxnBufferTest.java | 8 +- polardbx-cdc-task/pom.xml | 2 +- .../aliyun/polardbx/binlog/TaskEngine.java | 5 +- .../binlog/extractor/BinlogExtractor.java | 11 +- .../DefaultOutputMergeSourceHandler.java | 8 +- .../binlog/extractor/RpcExtractor.java | 4 +- .../extractor/filter/EventAcceptFilter.java | 18 +- .../filter/RebuildEventLogFilter.java | 223 +- .../filter/TransactionBufferEventFilter.java | 7 +- .../filter/rebuild/DDLConverter.java | 8 +- .../filter/rebuild/ITableMetaDelegate.java | 2 + .../filter/rebuild/RowsLogEventRebuilder.java | 2 +- .../filter/rebuild/TableMetaDelegate.java | 26 +- .../binlog/extractor/log/Transaction.java | 60 +- .../polardbx/binlog/merge/LogEventMerger.java | 41 +- .../stress/FromRpcServerStressSimulator.java | 2 +- .../FromTransmitterStressSimulator.java | 2 +- .../binlog/transmit/LogEventTransmitter.java | 9 +- .../binlog/extractor/DDLConverterTest.java | 29 + .../extractor/LocalBinlogExtractorTest.java | 2 +- .../extractor/LocalBinlogFileReaderTest.java | 72 + .../extractor/MemoryEventLogBuffer.java | 23 + .../extractor/MockTableMetaDelegate.java | 6 + .../binlog/extractor/TraceExtractTest.java | 13 + .../filter/RebuildEventLogFilterTest.java | 63 + .../binlog/merge/LogEventMergerTest.java | 2 +- .../src/test/resources/logback.xml | 1 + polardbx-cdc-transfer/pom.xml | 2 +- .../aliyun/polardbx/binlog/transfer/Bank.java | 4 +- .../aliyun/polardbx/binlog/transfer/Main.java | 30 +- pom.xml | 5 +- 312 files changed, 49737 insertions(+), 17888 deletions(-) create mode 100644 polardbx-cdc-assemble/bin/start_rpl.sh create mode 100644 polardbx-cdc-assemble/bin/stop_rpl.sh create mode 100644 polardbx-cdc-assemble/src/main/resources/rpl-logback.xml create mode 100644 polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/DefaultBinlogFileSizeFetcher.java create mode 100644 polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/IBinlogFileSizeFetcher.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/PolarxCNodeInfoMapper.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplDdlDynamicSqlSupport.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplDdlMapper.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplServiceDynamicSqlSupport.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplServiceMapper.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplStateMachineDynamicSqlSupport.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplStateMachineMapper.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplTablePositionDynamicSqlSupport.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplTablePositionMapper.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplTaskDynamicSqlSupport.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplTaskMapper.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/SemiSnapshotInfoDynamicSqlSupport.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/SemiSnapshotInfoMapper.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/PolarxCNodeInfo.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/RplDdl.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/RplService.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/RplStateMachine.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/RplTablePosition.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/RplTask.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/SemiSnapshotInfo.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/util/HexUtil.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/util/LoopRetry.java create mode 100644 polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/util/WgetContext.java create mode 100644 polardbx-cdc-daemon/src/main/java/com/aliyun/polardbx/binlog/daemon/schedule/RplLeaderJob.java create mode 100644 polardbx-cdc-daemon/src/main/java/com/aliyun/polardbx/binlog/daemon/schedule/RplWorkerJob.java create mode 100644 polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/util/TableIdManager.java create mode 100644 polardbx-cdc-format/src/test/java/com/aliyun/com/polardbx/binlog/format/utils/CharsetConversionTest.java create mode 100644 polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/ConsistencyChecker.java create mode 100644 polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/CreateDropTableWithExistFilter.java create mode 100644 polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/ICdcTableMeta.java create mode 100644 polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/MetaType.java create mode 100644 polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/Printer.java create mode 100644 polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/RollbackMode.java create mode 100644 polardbx-cdc-meta/src/main/resources/db/migration/V17__Semi_Snapshot.sql create mode 100644 polardbx-cdc-meta/src/main/resources/db/migration/V18__Binlog_Logic_Meta_History.sql create mode 100644 polardbx-cdc-meta/src/main/resources/db/migration/V19__Modify_Import_Meta.sql create mode 100644 polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ChangeMasterRequest.java create mode 100644 polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ChangeMasterRequestOrBuilder.java create mode 100644 polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ChangeReplicationFilterRequest.java create mode 100644 polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ChangeReplicationFilterRequestOrBuilder.java create mode 100644 polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ResetSlaveRequest.java create mode 100644 polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ResetSlaveRequestOrBuilder.java create mode 100644 polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/RplCommandResponse.java create mode 100644 polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/RplCommandResponseOrBuilder.java create mode 100644 polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowSlaveStatusRequest.java create mode 100644 polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowSlaveStatusRequestOrBuilder.java create mode 100644 polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowSlaveStatusResponse.java create mode 100644 polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowSlaveStatusResponseOrBuilder.java create mode 100644 polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/StartSlaveRequest.java create mode 100644 polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/StartSlaveRequestOrBuilder.java create mode 100644 polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/StopSlaveRequest.java create mode 100644 polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/StopSlaveRequestOrBuilder.java create mode 100644 polardbx-cdc-rpl/README.md create mode 100644 polardbx-cdc-rpl/assembly.xml create mode 100755 polardbx-cdc-rpl/bin/tool.sh create mode 100644 polardbx-cdc-rpl/pom.xml create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/RplTaskEngine.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/RplTaskRunner.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/ApplyHelper.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/BaseApplier.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/DdlHelper.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/DdlSqlContext.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/FlowLimiter.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/MergeApplier.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/MergeDmlSqlContext.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/MergeTransactionApplier.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/MysqlApplier.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/RowKey.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/SplitApplier.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/SplitTransactionApplier.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/SqlContext.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/StatisticCounter.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/StatisticUnit.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/StatisticalProxy.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/TPSLimiter.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/Transaction.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/TransactionApplier.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/TransactionBatch.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/CalendarUtil.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/CommonUtil.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/DataCompareUtil.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/DataSourceUtil.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/DateParseUtil.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/DruidDataSourceWrapper.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/HostManager.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/LogUtil.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/NamedThreadFactory.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/PasswordUtil.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/ResultCode.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/RplConstants.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/StringUtils2.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/TaskBasedDiscriminator.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/TaskContext.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/ThreadPoolUtil.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/AbstractFSM.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/FSMAction.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/FSMManager.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/FSMState.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/FSMTransition.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/FSMTriggeredAction.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/ReplicaFSM.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/ServiceDetail.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/TaskDetail.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/ColumnInfo.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/ColumnValue.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/DbMetaCache.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/DbMetaManager.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/KeyColumnInfo.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/TableInfo.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/BaseExtractor.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/CanalBinlogExtractor.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/LogEventConvert.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/NoTsoMysqlEventParser.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/cdc/DefaultCdcExtractHandler.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/cdc/EventParser.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/cdc/buffer/StreamObserverBuffer.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/cdc/buffer/StreamPipe.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/full/ExtractorUtil.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/full/RowChangeBuilder.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/full/RowChangeHelper.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/filter/BaseFilter.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/filter/ReplicateFilter.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/pipeline/BasePipeline.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/pipeline/MessageEvent.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/pipeline/MessageEventFactory.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/pipeline/SerialPipeline.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ApplierConfig.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ApplierType.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/DbTaskMetaManager.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/DdlState.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ExtractorConfig.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ExtractorType.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/FSMMetaManager.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/FilterType.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/HostInfo.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/HostType.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/PipelineConfig.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ReplicateMeta.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/RplServiceManager.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ServiceStatus.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ServiceType.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/StateMachineStatus.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/StateMachineType.java create mode 100644 polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/TaskStatus.java create mode 100644 polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/TestBase.java create mode 100644 polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/applier/DdlHelperTest.java create mode 100644 polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/applier/MergeApplierTest.java create mode 100644 polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/dbmeta/DbMetaManagerTest.java create mode 100644 polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/filter/ReplicateFilterTest.java create mode 100644 polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/CharsetTest.java create mode 100644 polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/CharsetWriteTest.java create mode 100644 polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/DdlE2ETest.java create mode 100644 polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/DmlE2ETest.java create mode 100644 polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/DmlPerfTest.java create mode 100644 polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/PrimaryKeyTest.java create mode 100644 polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/TransactionTest.java create mode 100644 polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/TransferTest.java create mode 100644 polardbx-cdc-rpl/src/test/resources/logback.xml create mode 100644 polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/LocalBinlogFileReaderTest.java create mode 100644 polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/MemoryEventLogBuffer.java create mode 100644 polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/filter/RebuildEventLogFilterTest.java diff --git a/README.md b/README.md index b70ba012..16b0ff73 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,9 @@ See [Quick Start](https://github.com/ApsaraDB/galaxysql#to-quick-start-with-pola PolarDB-X is fully compatible with MySQL binary log related commands, such as `SHOW BINARY LOGS`, `SHOW BINLOG EVENTS`, etc. All commands can be found in the [official MySQL documentation](https://dev.mysql.com/doc/refman/8.0/en/binary-log-formats.html). -3. PolarDB-X as MySQL Slave (WIP) +3. PolarDB-X as MySQL Slave -PolarDB-X supports MySQL `CHANGE MASTER TO` command, you can use PolarDB-X as MySQL slave, refer to MySQL [official document](https://dev.mysql.com/doc/refman/8.0/en/change-master-to.html) for command details. +PolarDB-X supports MySQL Replica related commands, such as `CHANGE MASTER TO`,`START/STOP/RESET SLAVE`,`SHOW SLAVE STATUS`, etc. you can use PolarDB-X as MySQL slave, refer to [Replica Reference Manual](https://github.com/ApsaraDB/galaxycdc/tree/main/polardbx-cdc-rpl/README.md) for command details. See [more docs](https://github.com/ApsaraDB/galaxysql#quick-start) about PolarDB-X. diff --git a/docker/admin/app.sh b/docker/admin/app.sh index 0e4004c2..8a77330f 100644 --- a/docker/admin/app.sh +++ b/docker/admin/app.sh @@ -6,6 +6,9 @@ function start_app() { sh /home/admin/bin/jdk8.sh chmod 755 /home/admin/polardbx-binlog.standalone/bin/* sudo -E su admin -c 'sh /home/admin/polardbx-binlog.standalone/bin/daemon.sh start' + if [ -f "/home/admin/drds-worker/bin/globalSchedule.sh" ]; then + sh /home/admin/drds-worker/bin/globalSchedule.sh + fi } function stop_app() { @@ -25,8 +28,8 @@ function config_env() { if [ ! -f "/home/admin/env/env.properties" ]; then touch /home/admin/env/env.properties + echo "ins_ip=$(hostname -i)" >> /home/admin/env/env.properties fi - echo "ins_ip=$(hostname -i)" >> /home/admin/env/env.properties chown -R admin:admin /home/admin/. } diff --git a/docker/bin/cdc_log_cleaner.sh b/docker/bin/cdc_log_cleaner.sh index 7005dc7c..b2bf462b 100644 --- a/docker/bin/cdc_log_cleaner.sh +++ b/docker/bin/cdc_log_cleaner.sh @@ -130,7 +130,7 @@ clean_log() { print "dir[$clean_log_path] removed!" $2 sudo rm -rvf $clean_log_path else - if [[ ${clean_log_path: -6} == ".hprof" ]] || [[ "$clean_log_path" == *"gc.log-20"* ]] || [[ "$clean_log_path" == *"console.log-20"* ]]; then + if [[ ${clean_log_path: -6} == ".hprof" ]] || [[ "$clean_log_path" == *"gc.log-20"* ]] || [[ "$clean_log_path" == *"console.log-20"* ]] || [[ ${clean_log_path: -4} == ".tmp" ]]; then sudo rm -fv $clean_log_path elif [[ ${clean_log_path: -4} == ".pid" ]]; then print "skip the ${clean_log_path} file" @@ -168,6 +168,9 @@ do process_path="$cdc_log_path/polardbx-binlog" clean_process_log $process_path $clean_level + process_path_2="$cdc_log_path/polardbx-rpl" + clean_db_log $process_path_2 $clean_level + else print "clean finish! current usage[$use GB] `date`====================" exit @@ -186,3 +189,36 @@ sudo find /var/log/ -type f -size +500M -exec cp /dev/null {} \; #use=`df -h $cdc_log_path|sed '1d'|awk '{print $5+0}'` get_dir_size print "clean finish! current useage $use GB `date`====================" + + +########################### binlog-rpl log 清理 ############################# +# 删除超过 30 天未更新过的文件和文件夹 +day=30 +maxGb=30 +folder=/home/admin/logs/polardbx-rpl + +# -path 排除 folder 本身 +find $folder -path "$folder" -type d -mtime +$day -exec rm -rf {} \; +find $folder -type f -mtime +$day -exec rm -rf {} \; +# statistic.log, position.log, commit.log,gc.log 总是保存 30 天,因为每个文件大小比较固定,每天约 5M + +while [ $day -ge 1 ] +do +day=`expr $day - 1` +rpl_log_size=`du -sb $folder | awk '{print $1}'` +rpl_log_size_g=`expr $rpl_log_size / 1024 / 1024 / 1024` +echo "rpl log size: " $rpl_log_size_g GB + +if [ $rpl_log_size_g -ge $maxGb ];then + # 如果还是很大,删除所有已经归档的 default.*.gz 和 meta.*.gz 文件 + echo remove $day day .gz log files + find $folder -type f -mtime +$day -name 'default.*.gz' -exec ls -Shl {} +; + find $folder -type f -mtime +$day -name 'meta.*.gz' -exec ls -Shl {} +; + + find $folder -type f -mtime +$day -name 'default.*.gz' -exec rm -rf {} \; + find $folder -type f -mtime +$day -name 'meta.*.gz' -exec rm -rf {} \; +else + echo break + break +fi +done diff --git a/docs/zh_CN/README.md b/docs/zh_CN/README.md index 07f4336a..d406460e 100644 --- a/docs/zh_CN/README.md +++ b/docs/zh_CN/README.md @@ -19,9 +19,9 @@ GalaxyCDC 组件内置于 PolarDB-X 实例中,提供完全兼容 MySQL Binary PolarDB-X 完全兼容 MySQL Binlog 相关指令,例如 `SHOW BINARY LOGS`,`SHOW BINLOG EVENTS` 等,全部相关命令可参考 [MySQL 官方文档](https://dev.mysql.com/doc/refman/8.0/en/binary-log-formats.html) 。 -3. 将 PolarDB-X 作为 MySQL 的备库(开发中) +3. 将 PolarDB-X 作为 MySQL 的备库 -PolarDB-X 支持 MySQL `CHANGE MASTER TO` 命令,可将 PolarDB-X 直接作为 MySQL 的备库,命令详细说明请参考 [MySQL 官方文档](https://dev.mysql.com/doc/refman/8.0/en/change-master-to.html) 。 +PolarDB-X 支持 MySQL Replica 相关指令,例如 `CHANGE MASTER TO`,`START/STOP/RESET SLAVE`,`SHOW SLAVE STATUS` 等,可将 PolarDB-X 直接作为 MySQL 的备库,命令详细说明请参考 [MySQL 官方文档](https://dev.mysql.com/doc/refman/8.0/en/change-master-to.html) 。 可在 [PolarDB-X 介绍页](https://github.com/ApsaraDB/galaxysql#quick-start) 查看更多文档。 diff --git a/polardbx-cdc-assemble/assembly.xml b/polardbx-cdc-assemble/assembly.xml index 98c8d867..48dee5a9 100644 --- a/polardbx-cdc-assemble/assembly.xml +++ b/polardbx-cdc-assemble/assembly.xml @@ -22,6 +22,10 @@ target/classes/logback.xml polardbx-binlog.standalone/conf + + target/classes/rpl-logback.xml + polardbx-binlog.standalone/conf + ../polardbx-cdc-common/target/classes/config.properties polardbx-binlog.standalone/conf @@ -30,6 +34,10 @@ ../polardbx-cdc-common/target/classes/metrics.txt polardbx-binlog.standalone/conf + + target/classes/git.properties + polardbx-binlog.standalone/conf + diff --git a/polardbx-cdc-assemble/bin/process-check.sh b/polardbx-cdc-assemble/bin/process-check.sh index b5e5f009..919a021c 100644 --- a/polardbx-cdc-assemble/bin/process-check.sh +++ b/polardbx-cdc-assemble/bin/process-check.sh @@ -1,5 +1,40 @@ #!/usr/bin/env bash +PATH="/opt/taobao/java/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin" +# This file is used by cron table +WORKER_BIN=/home/admin/polardbx-binlog.standalone/bin +needStart=0; +PID_FILE="daemon.pid"; +executeShell="daemon.sh"; -sh /home/admin/polardbx-binlog.standalone/bin/check-deamon.sh \ No newline at end of file +if [ ! -f "$WORKER_BIN"/${PID_FILE} ];then + echo "${PID_FILE} not exist" + needStart=1; +else + pid=`cat $WORKER_BIN/${PID_FILE}` + echo "current ${PID_FILE} value : $pid"; + if [ -z "$pid" ]; then + echo "${PID_FILE} exist, but pid is empty" + needStart=1; + else + runningPid=`jps | grep "$pid" | awk '{print $1}'`; + echo "Running pid: $runningPid" + if [ "$pid" != "$runningPid" ]; then + echo "pid not empty, but process not exist" + needStart=1; + fi + fi +fi + +runningCount=`jps | grep DaemonBootStrap | wc -l` +echo "Running ${PID_FILE} count: $runningCount" +if [ "$runningCount" -gt 1 ];then + echo "Running ${PID_FILE} count more than 1"; + needStart=1; +fi + +if [ "$needStart" -eq 1 ];then + echo "Retarting ${PID_FILE}"; + sh $WORKER_BIN/${executeShell} restart > /dev/null 2>&1 & +fi \ No newline at end of file diff --git a/polardbx-cdc-assemble/bin/start_rpl.sh b/polardbx-cdc-assemble/bin/start_rpl.sh new file mode 100644 index 00000000..22eb694b --- /dev/null +++ b/polardbx-cdc-assemble/bin/start_rpl.sh @@ -0,0 +1,125 @@ +#!/bin/bash + +### ====================================================================== ### +## ## +## Polardbx-rpl Task Startup Script ## +## ## +### ====================================================================== ### +### 2020-08-08 by chengjin +### make some different + +TASK_ID=$1 +TASK_NAME=$2 +MEMORY=3072 +PERM_MEMORY=256 +BASE_HOME=$HOME/polardbx-binlog.standalone +LOG_DIR=$HOME/logs/polardbx-rpl/$TASK_NAME + +#get param from 16th to end +JVM_PARAMS="" + +usage() { + echo "please set startup Args String" + exit 1 +} + +if [ $# -lt 1 ]; then + usage +fi + +if [ $(whoami) == "root" ]; then + echo DO NOT use root user to launch me. + exit 1 +fi + +export LD_LIBRARY_PATH=${BASE_HOME}/lib:${LD_LIBRARY_PATH} +export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK +export LANG=zh_CN.GB18030 + +if [ -f ${HOME}/bin/jdk8.sh ]; then + sudo sh ${HOME}/bin/jdk8.sh +fi + +logback_configurationFile=${BASE_HOME}/conf/rpl-logback.xml + +JAVA_OPTS="${JAVA_OPTS} -server -Xms${MEMORY}m -Xmx${MEMORY}m -Xss1m -Djute.maxbuffer=10240000 -DtaskId=$TASK_ID -Dlogback.configurationFile=$logback_configurationFile" +if [[ ! "$JVM_PARAMS" =~ "PermSize" ]]; then + JAVA_OPTS="${JAVA_OPTS} -XX:PermSize=${PERM_MEMORY}m -XX:MaxPermSize=${PERM_MEMORY}m" +fi +#JAVA_OPTS="${JAVA_OPTS} -XX:NewSize=128m -XX:MaxNewSize=256m" +JAVA_OPTS="${JAVA_OPTS} -XX:+UseParallelGC" +JAVA_OPTS="${JAVA_OPTS} -XX:-UseAdaptiveSizePolicy -XX:SurvivorRatio=2 -XX:NewRatio=1 -XX:ParallelGCThreads=6" +JAVA_OPTS="${JAVA_OPTS} -XX:-OmitStackTraceInFastThrow" + +JAVA_OPTS="${JAVA_OPTS} -Djava.net.preferIPv4Stack=true" +JAVA_OPTS="${JAVA_OPTS} -XX:+PrintGCDetails" +JAVA_OPTS="${JAVA_OPTS} -XX:+PrintGCDateStamps" +JAVA_OPTS="${JAVA_OPTS} -XX:+DisableExplicitGC" +JAVA_OPTS="${JAVA_OPTS} -Xloggc:${LOG_DIR}/gc.log" +JAVA_OPTS="${JAVA_OPTS} -Dmemory=${MEMORY}" +JAVA_OPTS="${JAVA_OPTS} -Djava.util.prefs.systemRoot=${HOME}/.java -Djava.util.prefs.userRoot=${HOME}/.java/.userPrefs -Dfile.encoding=UTF-8" +JAVA_OPTS="${JAVA_OPTS} -Ddaemon.home.dir=${BASE_HOME}" + +if [ -f /home/admin/env.properties ]; then + for line in `cat /home/admin/env.properties` + do + JAVA_OPTS="${JAVA_OPTS} -D$line" + done +fi + +if [ ! -d ${HOME}/.java ]; then + mkdir -p "${HOME}/.java" +fi + +if [ ! -d ${HOME}/.java/.userPrefs ]; then + mkdir -p "${HOME}/.java/.userPrefs" +fi + +if [ ! -d ${HOME}/.java/.systemPrefs ]; then + mkdir -p "${HOME}/.java/.systemPrefs" +fi + +JAVA_OPTS="${JAVA_OPTS} -XX:+HeapDumpOnOutOfMemoryError" +JAVA_OPTS="${JAVA_OPTS} ${JVM_PARAMS}" + +## set java path +TAOBAO_JAVA="/opt/taobao/java/bin/java" +ALIBABA_JAVA="/usr/alibaba/java/bin/java" +if [ -f $TAOBAO_JAVA ]; then + JAVA=$TAOBAO_JAVA +elif [ -f $ALIBABA_JAVA ]; then + JAVA=$ALIBABA_JAVA +else + JAVA=$(which java) + if [ ! -f $JAVA ]; then + echo "Cannot find a Java JDK. Please set either set JAVA or put java (>=1.7) in your PATH." 2>&2 + exit 1 + fi +fi + +#BUILDER IN classpath +CLASSPATH="${BASE_HOME}/conf"; + +if [ -f ${HOME}/env/env.properties ]; then + CORES=$(sed '/^cpu_cores=/!d;s/.*=//' ${HOME}/env/env.properties) + if [ -n "$CORES" ]; then + JAVA_OPTS="${JAVA_OPTS} -XX:ActiveProcessorCount=$CORES" + fi + CLASSPATH="${HOME}/env:$CLASSPATH" +fi + +for jar in $(ls ${BASE_HOME}/lib/*.jar); do + CLASSPATH="${CLASSPATH}:""${jar}" +done + +if [ ! -d ${LOG_DIR} ]; then + mkdir -p ${LOG_DIR} +fi +defaultLog=${LOG_DIR}/default.log + +#change user.dir to /home/admin +cd $HOME + +#Start Java Process +echo "$(date +"%Y-%m-%d-%H:%M:%S.%N") ${JAVA} ${JAVA_OPTS} -classpath ${CLASSPATH}:. com.aliyun.polardbx.rpl.RplTaskEngine "taskId=${TASK_ID}"" >>$defaultLog +${JAVA} ${JAVA_OPTS} -classpath ${CLASSPATH}:. com.aliyun.polardbx.rpl.RplTaskEngine "taskId=${TASK_ID} taskName=${TASK_NAME}" 1>>$defaultLog 2>&1 & diff --git a/polardbx-cdc-assemble/bin/stop_rpl.sh b/polardbx-cdc-assemble/bin/stop_rpl.sh new file mode 100644 index 00000000..0a57ed75 --- /dev/null +++ b/polardbx-cdc-assemble/bin/stop_rpl.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +### ====================================================================== ### +## ## +## Polardbx-rpl Task Stop Script ## +## ## +### ====================================================================== ### + +TASK_ID=$1 + +BASE_HOME="/home/admin/polardbx-binlog.standalone" + +usage() { + echo "please set stop Args taskId" + exit 1 +} + +if [ $# -lt 1 ]; then + usage +fi + +if [ $(whoami) == "root" ]; then + echo DO NOT use root user to launch me. + exit 1 +fi + + +runningCount=`ps -ef | grep RplTaskEngine | grep taskId=${TASK_ID} | wc -l` +echo "taskId: ${TASK_ID} running count: $runningCount" + +if [ "$runningCount" -ge 1 ];then + echo "taskId: ${TASK_ID} already running, kill all and restart" + for pid in `ps -ef | grep RplTaskEngine | grep taskId=${TASK_ID} | awk '{print $2}'` ; do kill -9 $pid ; done +else + echo "no pid for $TASK_ID to stop." +fi + diff --git a/polardbx-cdc-assemble/pom.xml b/polardbx-cdc-assemble/pom.xml index 5799f7af..81ff64e5 100644 --- a/polardbx-cdc-assemble/pom.xml +++ b/polardbx-cdc-assemble/pom.xml @@ -5,7 +5,7 @@ polardbx-cdc com.aliyun.polardbx - 5.4.12-SNAPSHOT + 5.4.13-SNAPSHOT 4.0.0 polardbx-cdc-assemble @@ -42,6 +42,43 @@ polardbx-binlog + + pl.project13.maven + git-commit-id-plugin + 4.0.5 + + + + revision + + + + + false + yyyy-MM-dd HH:mm:ssZ + true + ${project.build.outputDirectory}/git.properties + + + + + false + + false + + 7 + + -dirty + + false + + + + maven-jar-plugin diff --git a/polardbx-cdc-assemble/src/main/resources/logback.xml b/polardbx-cdc-assemble/src/main/resources/logback.xml index e34fd851..9345a04d 100644 --- a/polardbx-cdc-assemble/src/main/resources/logback.xml +++ b/polardbx-cdc-assemble/src/main/resources/logback.xml @@ -76,6 +76,49 @@ + + ${HOME}/logs/polardbx-binlog/${taskName}/duplicateTransaction.log + true + + ${HOME}/logs/polardbx-binlog/${taskName}/%d{yyyy-MM-dd}/duplicateTransaction.%i.log.gz + + + 200MB + + 5 + + + + + + UTF-8 + + + + + ${HOME}/logs/polardbx-binlog/${taskName}/traceid-disorder.log + true + + ${HOME}/logs/polardbx-binlog/${taskName}/%d{yyyy-MM-dd}/traceid-disorder.%i.log.gz + + + 200MB + + 5 + + + + + + UTF-8 + + @@ -148,6 +191,10 @@ + + + + @@ -164,6 +211,10 @@ + + + + diff --git a/polardbx-cdc-assemble/src/main/resources/rpl-logback.xml b/polardbx-cdc-assemble/src/main/resources/rpl-logback.xml new file mode 100644 index 00000000..b144a446 --- /dev/null +++ b/polardbx-cdc-assemble/src/main/resources/rpl-logback.xml @@ -0,0 +1,265 @@ + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{36}) %X{C} - %msg%n + + + + + + + taskName + default + + + + ${HOME}/logs/polardbx-rpl/${taskName}/default.log + true + + + ${HOME}/logs/polardbx-rpl/${taskName}/%d{yyyy-MM-dd}/default.%i.log.gz + + + 200MB + + 14 + + + + + + UTF-8 + + + + + + + ${HOME}/logs/polardbx-rpl/meta.log + true + + ${HOME}/logs/polardbx-rpl/%d{yyyy-MM-dd}/meta.%i.log.gz + + 200MB + + 14 + + + + + + UTF-8 + + + + + ${HOME}/logs/polardbx-rpl/rpl.log + true + + ${HOME}/logs/polardbx-rpl/%d{yyyy-MM-dd}/rpl.%i.log.gz + + 200MB + + 14 + + + + + + UTF-8 + + + + + + taskName + default + + + + ${HOME}/logs/polardbx-rpl/${taskName}/commit.log + true + + + ${HOME}/logs/polardbx-rpl/${taskName}/%d{yyyy-MM-dd}/commit.%i.log.gz + + + 200MB + + 14 + + + + + + UTF-8 + + + + + + + + taskName + default + + + + ${HOME}/logs/polardbx-rpl/${taskName}/check.log + true + + + + + UTF-8 + + + + + + + + taskName + default + + + + ${HOME}/logs/polardbx-rpl/${taskName}/task.log + true + + + + + UTF-8 + + + + + + + + taskName + default + + + + ${HOME}/logs/polardbx-rpl/${taskName}/position.log + true + + + ${HOME}/logs/polardbx-rpl/${taskName}/%d{yyyy-MM-dd}/position.%i.log.gz + + + 200MB + + 14 + + + + + + UTF-8 + + + + + + + + taskName + default + + + + ${HOME}/logs/polardbx-rpl/${taskName}/statistic.log + true + + + ${HOME}/logs/polardbx-rpl/${taskName}/%d{yyyy-MM-dd}/statistic.%i.log.gz + + + 200MB + + 14 + + + + + + UTF-8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/polardbx-cdc-canal/pom.xml b/polardbx-cdc-canal/pom.xml index bf763cc1..0fcb9b81 100644 --- a/polardbx-cdc-canal/pom.xml +++ b/polardbx-cdc-canal/pom.xml @@ -5,7 +5,7 @@ polardbx-cdc com.aliyun.polardbx - 5.4.12-SNAPSHOT + 5.4.13-SNAPSHOT 4.0.0 polardbx-cdc-canal @@ -19,7 +19,7 @@ com.aliyun.polardbx polardbx-cdc-common - 5.4.12-SNAPSHOT + 5.4.13-SNAPSHOT compile diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/CanalBootstrap.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/CanalBootstrap.java index 0a82b143..e08eedca 100644 --- a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/CanalBootstrap.java +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/CanalBootstrap.java @@ -123,13 +123,13 @@ private void consumeMysql(ErosaConnection connection, String requestTso) throws realTso = CommonUtils.getTsoTimestamp(requestTso); } logger.info("dump mysql with start tso " + realTso); - BinlogPosition position = searchPosition(connection, realTso); + BinlogPosition position = searchPosition(connection, requestTso, realTso); if (position != null) { consume(connection, position, requestTso); return; } logger.warn("can not find " + requestTso + " in [" + mySqlInfo.getStartPosition() + "," + mySqlInfo - .getEndPosition() + "] try backup store!"); + .getEndPosition() + "] try oss!"); consumeFromBackup(requestTso); } @@ -161,17 +161,18 @@ private void consume(ErosaConnection connection, BinlogPosition startPosition, S } } - private BinlogPosition searchPosition(ErosaConnection connection, long requestTso) throws Exception { - logger.info("search position by tso : " + requestTso); + private BinlogPosition searchPosition(ErosaConnection connection, String requestTso, long searchTso) + throws Exception { + logger.info("search position by tso : " + searchTso); long startCmdTSO = -1; if (StringUtils.isNotBlank(this.startCmdTSO)) { startCmdTSO = CommonUtils.getTsoTimestamp(this.startCmdTSO); } SearchTsoEventHandle searchTsoEventHandle = - new SearchTsoEventHandle(requestTso, authenticationInfo, startCmdTSO); + new SearchTsoEventHandle(authenticationInfo, requestTso, searchTso, startCmdTSO); processor.setHandle(searchTsoEventHandle); connection.connect(); - BinlogPosition endPosition = connection.findEndPosition(requestTso); + BinlogPosition endPosition = connection.findEndPosition(searchTso); String searchFile = endPosition.getFileName(); while (true) { searchTsoEventHandle.reset(); @@ -181,7 +182,7 @@ private BinlogPosition searchPosition(ErosaConnection connection, long requestTs //找不到这个文件,直接break break; } - logger.info("start search " + requestTso + " in " + searchFile); + logger.info("start search " + searchTso + " in " + searchFile); searchTsoEventHandle.setCurrentFile(searchFile); searchTsoEventHandle .setEndPosition(new BinlogPosition(searchFile, binlogFileSize, -1, -1)); diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/DefaultBinlogFileSizeFetcher.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/DefaultBinlogFileSizeFetcher.java new file mode 100644 index 00000000..0c52e0d6 --- /dev/null +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/DefaultBinlogFileSizeFetcher.java @@ -0,0 +1,50 @@ +package com.aliyun.polardbx.binlog.canal; + +import com.aliyun.polardbx.binlog.DynamicApplicationConfig; +import com.aliyun.polardbx.binlog.canal.core.dump.ErosaConnection; +import com.aliyun.polardbx.binlog.canal.core.dump.MysqlConnection; +import com.aliyun.polardbx.binlog.error.PolardbxException; + +import java.io.IOException; + +import static com.aliyun.polardbx.binlog.ConfigKeys.DAEMON_TSO_HEARTBEAT_INTERVAL; + +/** + * Created by ziyang.lb + **/ +public class DefaultBinlogFileSizeFetcher implements IBinlogFileSizeFetcher { + private final ErosaConnection connection; + + public DefaultBinlogFileSizeFetcher(ErosaConnection connection) { + if (connection instanceof MysqlConnection) { + this.connection = connection.fork(); + } /*else if (connection instanceof OssConnection) { + this.connection = connection; + }*/ else { + throw new PolardbxException("invalid connection type " + connection.getClass()); + } + } + + @Override + public long fetch(String fileName) throws IOException { + sleep(); + if (connection instanceof MysqlConnection) { + try { + connection.connect(); + return connection.binlogFileSize(fileName); + } finally { + connection.disconnect(); + } + } else { + return connection.binlogFileSize(fileName); + } + } + + private void sleep() { + try { + int tsoHeartBeatInterval = DynamicApplicationConfig.getInt(DAEMON_TSO_HEARTBEAT_INTERVAL); + Thread.sleep(Math.min(tsoHeartBeatInterval * 5, 2000)); + } catch (InterruptedException e) { + } + } +} diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/IBinlogFileSizeFetcher.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/IBinlogFileSizeFetcher.java new file mode 100644 index 00000000..7307d5f4 --- /dev/null +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/IBinlogFileSizeFetcher.java @@ -0,0 +1,14 @@ +package com.aliyun.polardbx.binlog.canal; + +import java.io.IOException; + +/** + * Binlog文件大小查询器 + * Created by ziyang.lb + */ +public interface IBinlogFileSizeFetcher { + /** + * 获取指定binlog文件的文件大小 + */ + long fetch(String fileName) throws IOException; +} diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/LocalBinlogParser.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/LocalBinlogParser.java index 128d2edc..0ac6fcbc 100644 --- a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/LocalBinlogParser.java +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/LocalBinlogParser.java @@ -25,6 +25,7 @@ import com.aliyun.polardbx.binlog.canal.core.dump.SinkResult; import com.aliyun.polardbx.binlog.canal.core.model.AuthenticationInfo; import com.aliyun.polardbx.binlog.canal.core.model.BinlogPosition; +import com.aliyun.polardbx.binlog.canal.core.model.ServerCharactorSet; import com.aliyun.polardbx.binlog.canal.exception.TableIdNotFoundException; import java.io.IOException; @@ -59,6 +60,9 @@ public void dump(SinkFunction sinkFunction) throws IOException, TableIdNotFoundE decoder.handle(LogEvent.ROWS_QUERY_LOG_EVENT); decoder.handle(LogEvent.XA_PREPARE_LOG_EVENT); LogContext context = new LogContext(); + context.setServerCharactorSet( + ServerCharactorSet.builder().characterSetServer("utf8mb4").characterSetClient("utf8mb4") + .characterSetConnection("utf8mb4").characterSetDatabase("utf8mb4").build()); LogPosition logPosition = new LogPosition(binlogfilename, 0); context.setLogPosition(logPosition); while (fetcher.fetch()) { @@ -121,6 +125,7 @@ public void start(AuthenticationInfo master, BinlogPosition startPosition) { try { head.doNext(event); } catch (Exception e) { + System.out.println("fatal error at position " + logPosition); e.printStackTrace(); return false; } diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/LogContext.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/LogContext.java index 2c0822f5..3e586c8e 100644 --- a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/LogContext.java +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/LogContext.java @@ -36,8 +36,6 @@ public final class LogContext { private LogPosition logPosition; - private long serverId; - private ServerCharactorSet serverCharactorSet; public LogContext() { @@ -89,12 +87,4 @@ public void reset() { mapOfTable.clear(); } - - public long getServerId() { - return serverId; - } - - public void setServerId(long serverId) { - this.serverId = serverId; - } } diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/LogDecoder.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/LogDecoder.java index 832abe85..7df9fae0 100644 --- a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/LogDecoder.java +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/LogDecoder.java @@ -17,7 +17,7 @@ package com.aliyun.polardbx.binlog.canal.binlog; -import com.aliyun.polardbx.binlog.canal.LogEventUtil; +import com.aliyun.polardbx.binlog.canal.IBinlogFileSizeFetcher; import com.aliyun.polardbx.binlog.canal.binlog.event.AppendBlockLogEvent; import com.aliyun.polardbx.binlog.canal.binlog.event.BeginLoadQueryLogEvent; import com.aliyun.polardbx.binlog.canal.binlog.event.CreateFileLogEvent; @@ -57,6 +57,7 @@ import com.aliyun.polardbx.binlog.canal.binlog.event.mariadb.MariaGtidLogEvent; import com.aliyun.polardbx.binlog.canal.binlog.event.mariadb.StartEncryptionLogEvent; import com.aliyun.polardbx.binlog.canal.core.model.ServerCharactorSet; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -90,6 +91,8 @@ public final class LogDecoder { protected final BitSet handleSet = new BitSet(LogEvent.ENUM_END_EVENT); + protected IBinlogFileSizeFetcher binlogFileSizeFetcher; + public LogDecoder() { } @@ -102,7 +105,7 @@ public LogDecoder(final int fromIndex, final int toIndex) { * * @return UknownLogEvent if event type is unknown or skipped. */ - public static LogEvent decode(LogBuffer buffer, LogHeader header, LogContext context) throws IOException { + public LogEvent decode(LogBuffer buffer, LogHeader header, LogContext context) throws IOException { FormatDescriptionLogEvent descriptionEvent = context.getFormatDescription(); LogPosition logPosition = context.getLogPosition(); @@ -156,9 +159,6 @@ public static LogEvent decode(LogBuffer buffer, LogHeader header, LogContext con /* updating position in context */ logPosition.position = header.getLogPos(); event.fillTable(context); - if (context.getServerId() != 0L) { - event.setServerId(context.getServerId()); - } return event; } case LogEvent.UPDATE_ROWS_EVENT_V1: { @@ -166,9 +166,6 @@ public static LogEvent decode(LogBuffer buffer, LogHeader header, LogContext con /* updating position in context */ logPosition.position = header.getLogPos(); event.fillTable(context); - if (context.getServerId() != 0L) { - event.setServerId(context.getServerId()); - } return event; } case LogEvent.DELETE_ROWS_EVENT_V1: { @@ -176,13 +173,11 @@ public static LogEvent decode(LogBuffer buffer, LogHeader header, LogContext con /* updating position in context */ logPosition.position = header.getLogPos(); event.fillTable(context); - if (context.getServerId() != 0L) { - event.setServerId(context.getServerId()); - } return event; } case LogEvent.ROTATE_EVENT: { RotateLogEvent event = new RotateLogEvent(header, buffer, descriptionEvent); + event = tryFixRotateEvent(event, logPosition); /* updating position in context */ logPosition = new LogPosition(event.getFilename(), event.getPosition()); context.setLogPosition(logPosition); @@ -323,7 +318,6 @@ public static LogEvent decode(LogBuffer buffer, LogHeader header, LogContext con RowsQueryLogEvent event = new RowsQueryLogEvent(header, buffer, descriptionEvent); /* updating position in context */ logPosition.position = header.getLogPos(); - context.setServerId(LogEventUtil.getServerIdFromRowQuery(event)); return event; } case LogEvent.WRITE_ROWS_EVENT: { @@ -331,9 +325,6 @@ public static LogEvent decode(LogBuffer buffer, LogHeader header, LogContext con /* updating position in context */ logPosition.position = header.getLogPos(); event.fillTable(context); - if (context.getServerId() != 0L) { - event.setServerId(context.getServerId()); - } return event; } case LogEvent.UPDATE_ROWS_EVENT: { @@ -341,9 +332,6 @@ public static LogEvent decode(LogBuffer buffer, LogHeader header, LogContext con /* updating position in context */ logPosition.position = header.getLogPos(); event.fillTable(context); - if (context.getServerId() != 0L) { - event.setServerId(context.getServerId()); - } return event; } case LogEvent.DELETE_ROWS_EVENT: { @@ -351,9 +339,6 @@ public static LogEvent decode(LogBuffer buffer, LogHeader header, LogContext con /* updating position in context */ logPosition.position = header.getLogPos(); event.fillTable(context); - if (context.getServerId() != 0L) { - event.setServerId(context.getServerId()); - } return event; } case LogEvent.GTID_LOG_EVENT: @@ -501,4 +486,32 @@ public LogEvent decode(LogBuffer buffer, LogContext context) throws IOException return null; } + private RotateLogEvent tryFixRotateEvent(RotateLogEvent event, LogPosition logPosition) throws IOException { + if (binlogFileSizeFetcher != null && logPosition != null && StringUtils.isNotBlank(logPosition.getFileName()) + && !StringUtils.equals(logPosition.getFileName(), event.getFilename())) { + /* + xdb存在bug,可能会在binlog文件中的某个位置记录RotateEvent,这里做一下兼容性处理,判断rotate event是否出现在文件中 + 当收到rotate event时,判断logPosition是否已经到达文件的末尾,如果logPosition.getPosition() + length(rotateEvent)之和 + 小于binlog文件的size,则说明rotate event是出现在binlog文件中。但有一个例外情况,logPosition中的position字段虽然是long型, + 但在binlog文件中LogHeader实际能记录的最大值是uint32(最大值对应4G),即logPosition的position字段的值的最大上限是uint32, + 当出现超大事务时(如20G的大事务),logPosition.getPosition() + length(rotateEvent)之和肯定是小于binlog文件的size的,所以, + 此中情况下,就不简单的判定rotate event是出现在binlog文件中间位置了。xdb中,可以对max_binlog_size参数设置的最大值为1073741824(1G), + 只有出现大事务的情况下,才会导致binlog文件的大小超过max_binlog_size,所以rotate event出现在binlog文件的中间位置只会发生在小于 + max_binlog_size的位置,因此可以得出结论,当logPosition的position字段的值触达uint32阈值后,出现的rotate event一定是正常的rotate event + */ + long fileSize = binlogFileSizeFetcher.fetch(logPosition.getFileName()); + long length = logPosition.getPosition() + event.getEventLen(); + if (length < fileSize && length < Integer.MAX_VALUE) { + RotateLogEvent newEvent = new RotateLogEvent(event.getHeader(), logPosition.getFileName(), length); + logger.warn("receive a invalid rotate event, will fix it, the event info before fix is :" + event.info() + + " ,the event info after fix is :" + newEvent.info()); + return newEvent; + } + } + return event; + } + + public void setBinlogFileSizeFetcher(IBinlogFileSizeFetcher binlogFileSizeFetcher) { + this.binlogFileSizeFetcher = binlogFileSizeFetcher; + } } diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/dbms/DBMSRowChange.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/dbms/DBMSRowChange.java index aa7e6541..ba4c7a4c 100644 --- a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/dbms/DBMSRowChange.java +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/dbms/DBMSRowChange.java @@ -17,6 +17,8 @@ package com.aliyun.polardbx.binlog.canal.binlog.dbms; +import lombok.extern.slf4j.Slf4j; + import java.io.Serializable; import java.util.ArrayList; import java.util.BitSet; @@ -28,6 +30,7 @@ * @author Changyuan.lh * @version 1.0 */ +@Slf4j public abstract class DBMSRowChange extends DBMSEvent { private static final long serialVersionUID = -5725119493653542602L; @@ -152,6 +155,7 @@ public int getColumnIndex(String columnName) { if (column != null) { return column.getColumnIndex(); } + log.error("columnName: {} not found, columnSet: {}.", columnName, columnSet); return -1; } diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/event/RotateLogEvent.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/event/RotateLogEvent.java index dbf8fc63..f287f04b 100644 --- a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/event/RotateLogEvent.java +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/event/RotateLogEvent.java @@ -126,6 +126,12 @@ public RotateLogEvent(String filename, final long position) { this.position = position; } + public RotateLogEvent(LogHeader logHeader, String filename, long position) { + super(logHeader); + this.filename = filename; + this.position = position; + } + public final String getFilename() { return filename; } diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/event/RowsLogBuffer.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/event/RowsLogBuffer.java index 4e7d926a..61cf99dd 100644 --- a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/event/RowsLogBuffer.java +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/binlog/event/RowsLogBuffer.java @@ -301,6 +301,7 @@ final Serializable fetchValue(int type, final int meta, boolean isBinary, LogBuf case LogEvent.MYSQL_TYPE_SET: case LogEvent.MYSQL_TYPE_ENUM: case LogEvent.MYSQL_TYPE_STRING: + case LogEvent.MYSQL_TYPE_VAR_STRING: type = byte0; len = byte1; break; @@ -435,7 +436,7 @@ final Serializable fetchValue(int type, final int meta, boolean isBinary, LogBuf // value = bit; // } javaType = Types.BIT; - length = nbits; + length = len; break; } case LogEvent.MYSQL_TYPE_TIMESTAMP: { @@ -964,8 +965,7 @@ final Serializable fetchValue(int type, final int meta, boolean isBinary, LogBuf } break; } - case LogEvent.MYSQL_TYPE_VARCHAR: - case LogEvent.MYSQL_TYPE_VAR_STRING: { + case LogEvent.MYSQL_TYPE_VARCHAR: { /* * Except for the data length calculation, MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VAR_STRING and * MYSQL_TYPE_STRING are handled the same way. @@ -993,7 +993,8 @@ final Serializable fetchValue(int type, final int meta, boolean isBinary, LogBuf length = len; break; } - case LogEvent.MYSQL_TYPE_STRING: { + case LogEvent.MYSQL_TYPE_STRING: + case LogEvent.MYSQL_TYPE_VAR_STRING: { if (len < 256) { len = buffer.getUint8(); } else { diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/AbstractEventParser.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/AbstractEventParser.java index 6e861169..6ec6da87 100644 --- a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/AbstractEventParser.java +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/AbstractEventParser.java @@ -96,6 +96,17 @@ public void uncaughtException(Thread t, Throwable e) { protected abstract BinlogPosition findStartPosition(ErosaConnection connection, BinlogPosition position) throws IOException; + public BinlogPosition findStartPositionOnceBeforeStart(ErosaConnection connection, BinlogPosition position) + throws IOException { + if (running) { + return null; + } + running = true; + BinlogPosition returnPos = findStartPosition(connection, position); + running = false; + return returnPos; + } + protected void preDump(ErosaConnection connection) { } @@ -396,6 +407,10 @@ public void setPolarxInstanceId(String polarxInstanceId) { this.polarxInstanceId = polarxInstanceId; } + public void setNeedTransactionPosition(boolean value) { + this.needTransactionPosition.set(value); + } + private class DefaultTailEventFilter implements LogEventFilter { @Override @@ -423,5 +438,6 @@ public void onStop() { public void onStartConsume(HandlerContext context) { } + } } diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/BinlogEventProcessor.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/BinlogEventProcessor.java index ae79cc5f..367701c3 100644 --- a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/BinlogEventProcessor.java +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/BinlogEventProcessor.java @@ -17,6 +17,8 @@ package com.aliyun.polardbx.binlog.canal.core; +import com.aliyun.polardbx.binlog.canal.DefaultBinlogFileSizeFetcher; +import com.aliyun.polardbx.binlog.canal.IBinlogFileSizeFetcher; import com.aliyun.polardbx.binlog.canal.binlog.LogContext; import com.aliyun.polardbx.binlog.canal.binlog.LogDecoder; import com.aliyun.polardbx.binlog.canal.binlog.LogEvent; @@ -37,7 +39,7 @@ public class BinlogEventProcessor { private LogFetcher fetcher; private String binlogFileName; private ServerCharactorSet serverCharactorSet; - + private IBinlogFileSizeFetcher binlogFileSizeFetcher; private boolean run; public void setHandle(EventHandle handle) { @@ -54,12 +56,14 @@ public void init(ErosaConnection connection, String binlogFileName, long positio this.fetcher = connection.providerFetcher(binlogFileName, position, search); this.binlogFileName = binlogFileName; this.serverCharactorSet = serverCharactorSet; + this.binlogFileSizeFetcher = new DefaultBinlogFileSizeFetcher(connection); } public void start() throws Exception { run = true; handle.onStart(); LogDecoder decoder = new LogDecoder(LogEvent.UNKNOWN_EVENT, LogEvent.ENUM_END_EVENT); + decoder.setBinlogFileSizeFetcher(binlogFileSizeFetcher); LogContext context = new LogContext(); LogFetcher buffer = fetcher; LogPosition logPosition = new LogPosition(binlogFileName, 0); @@ -74,7 +78,7 @@ public void start() throws Exception { } handle.handle(event, context.getLogPosition()); if (handle.interrupt()) { - logger.error(" handler interrupt"); + logger.warn(" handler interrupt"); break; } } diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/MysqlEventParser.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/MysqlEventParser.java index c29d571b..76213e4d 100644 --- a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/MysqlEventParser.java +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/MysqlEventParser.java @@ -54,7 +54,7 @@ public class MysqlEventParser extends AbstractMysqlEventParser implements Binlog private static final Logger logger = LoggerFactory.getLogger(MysqlEventParser.class); private MysqlConnection metaConnection; // 查询meta信息的链接 - private int fallbackIntervalInSeconds = 60; // 切换回退时间 + public int fallbackIntervalInSeconds = 60; // 切换回退时间 private BinlogFormat[] supportBinlogFormats; // 支持的binlogFormat,如果设置会执行强校验 @@ -62,9 +62,9 @@ public class MysqlEventParser extends AbstractMysqlEventParser implements Binlog // 支持的binlogImage,如果设置会执行强校验 // update by yishun.chen,特殊异常处理参数 - private int dumpErrorCount = 0; // binlogDump失败异常计数 - private int dumpTimeoutCount = 0; - private int dumpErrorCountThreshold = 2; // binlogDump失败异常计数阀值 + public int dumpErrorCount = 0; // binlogDump失败异常计数 + public int dumpTimeoutCount = 0; + public int dumpErrorCountThreshold = 2; // binlogDump失败异常计数阀值 public MysqlEventParser() { supportBinlogFormats = new BinlogFormat[] {BinlogFormat.ROW}; @@ -77,7 +77,7 @@ protected ErosaConnection buildErosaConnection() { } @Override - protected void preDump(ErosaConnection connection) { + public void preDump(ErosaConnection connection) { if (!(connection instanceof MysqlConnection)) { throw new CanalParseException("Unsupported connection type : " + connection.getClass().getSimpleName()); } diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/ddl/TableMetaCache.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/ddl/TableMetaCache.java index 5a0fa3c3..b9e037a3 100644 --- a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/ddl/TableMetaCache.java +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/ddl/TableMetaCache.java @@ -51,7 +51,6 @@ public TableMetaCache(MysqlConnection connection) { this.connection = connection; this.memoryTableMeta = new MemoryTableMeta(logger); } - public TableMeta getTableMeta(String schema, String table) throws Throwable { TableMeta tableMeta = memoryTableMeta.find(schema, table); if (tableMeta == null) { diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/ddl/parser/DruidDdlParser.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/ddl/parser/DruidDdlParser.java index 270b2a43..ccfe4d02 100644 --- a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/ddl/parser/DruidDdlParser.java +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/ddl/parser/DruidDdlParser.java @@ -58,6 +58,7 @@ * @author agapple 2017年7月27日 下午4:05:34 * @since 3.2.5 */ + public class DruidDdlParser { public static List parse(String queryString, String schmeaName) { @@ -82,6 +83,12 @@ public static List parse(String queryString, String schmeaName) { ddlResults.add(ddlResult); } else if (statement instanceof SQLAlterTableStatement) { SQLAlterTableStatement alterTable = (SQLAlterTableStatement) statement; + if (alterTable.getTableOptions().size() > 0) { + DdlResult ddlResult = new DdlResult(); + processName(ddlResult, schmeaName, alterTable.getName(), false); + ddlResult.setType(DBMSAction.ALTER); + ddlResults.add(ddlResult); + } for (SQLAlterTableItem item : alterTable.getItems()) { if (item instanceof SQLAlterTableRename) { DdlResult ddlResult = new DdlResult(); diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/ddl/tsdb/MemoryTableMeta.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/ddl/tsdb/MemoryTableMeta.java index db60de60..d04cd019 100644 --- a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/ddl/tsdb/MemoryTableMeta.java +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/ddl/tsdb/MemoryTableMeta.java @@ -17,9 +17,13 @@ package com.aliyun.polardbx.binlog.canal.core.ddl.tsdb; +import com.alibaba.polardbx.druid.DbType; +import com.alibaba.polardbx.druid.sql.SQLUtils; import com.alibaba.polardbx.druid.sql.ast.SQLDataType; import com.alibaba.polardbx.druid.sql.ast.SQLDataTypeImpl; import com.alibaba.polardbx.druid.sql.ast.SQLExpr; +import com.alibaba.polardbx.druid.sql.ast.SQLIndex; +import com.alibaba.polardbx.druid.sql.ast.SQLName; import com.alibaba.polardbx.druid.sql.ast.SQLStatement; import com.alibaba.polardbx.druid.sql.ast.expr.SQLCharExpr; import com.alibaba.polardbx.druid.sql.ast.expr.SQLIdentifierExpr; @@ -32,7 +36,12 @@ import com.alibaba.polardbx.druid.sql.ast.statement.SQLColumnDefinition; import com.alibaba.polardbx.druid.sql.ast.statement.SQLColumnPrimaryKey; import com.alibaba.polardbx.druid.sql.ast.statement.SQLColumnUniqueKey; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLConstraint; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLCreateIndexStatement; import com.alibaba.polardbx.druid.sql.ast.statement.SQLCreateTableStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLDropDatabaseStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLDropTableStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLExprTableSource; import com.alibaba.polardbx.druid.sql.ast.statement.SQLNotNullConstraint; import com.alibaba.polardbx.druid.sql.ast.statement.SQLNullConstraint; import com.alibaba.polardbx.druid.sql.ast.statement.SQLSelectOrderByItem; @@ -41,9 +50,13 @@ import com.alibaba.polardbx.druid.sql.dialect.mysql.ast.MySqlUnique; import com.alibaba.polardbx.druid.sql.dialect.mysql.ast.expr.MySqlOrderingExpr; import com.alibaba.polardbx.druid.sql.dialect.mysql.ast.statement.MySqlCreateTableStatement; +import com.alibaba.polardbx.druid.sql.dialect.mysql.ast.statement.MySqlRenameTableStatement; +import com.alibaba.polardbx.druid.sql.parser.SQLParserUtils; +import com.alibaba.polardbx.druid.sql.parser.SQLStatementParser; import com.alibaba.polardbx.druid.sql.repository.Schema; import com.alibaba.polardbx.druid.sql.repository.SchemaObject; import com.alibaba.polardbx.druid.sql.repository.SchemaRepository; +import com.alibaba.polardbx.druid.util.FnvHash; import com.alibaba.polardbx.druid.util.JdbcConstants; import com.aliyun.polardbx.binlog.canal.core.ddl.TableMeta; import com.aliyun.polardbx.binlog.canal.core.ddl.TableMeta.FieldMeta; @@ -53,10 +66,14 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; +import java.lang.reflect.Field; import java.util.Arrays; +import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; /** @@ -88,13 +105,16 @@ public void destory() { @Override public boolean apply(BinlogPosition position, String schema, String ddl, String extra) { + if (StringUtils.isBlank(ddl)) { + return true; + } + tableMetas.clear(); synchronized (this) { if (StringUtils.isNotEmpty(schema)) { repository.setDefaultSchema(schema); } - // fastsql 已升级,不再需要 - //ddl = ddl.replaceAll("ALGORITHM = inplace", ""); + try { // druid暂时flush privileges语法解析有问题 if (!StringUtils.startsWithIgnoreCase(StringUtils.trim(ddl), "flush") @@ -102,6 +122,7 @@ public boolean apply(BinlogPosition position, String schema, String ddl, String && !StringUtils.startsWithIgnoreCase(StringUtils.trim(ddl), "create user") && !StringUtils.startsWithIgnoreCase(StringUtils.trim(ddl), "drop user")) { repository.console(ddl, FastSQLConstant.FEATURES); + tryRemoveSchema(position, ddl, schema); } } catch (Throwable e) { logger.warn("parse failed : " + ddl, e); @@ -156,6 +177,7 @@ public boolean rollback(BinlogPosition position) { throw new RuntimeException("not support for memory"); } + @Override public Map snapshot() { Map schemaDdls = new HashMap(); for (Schema schema : repository.getSchemas()) { @@ -320,6 +342,133 @@ private String getSqlName(SQLExpr sqlName) { } } + public boolean isSchemaExists(String schema) { + Schema schemaRep = repository.findSchema(schema); + return schemaRep != null; + } + + public Set findIndexes(String schema, String table) { + Set result = new HashSet<>(); + + Schema schemaRep = repository.findSchema(schema); + if (schemaRep == null) { + return result; + } + + SchemaObject data = schemaRep.findTable(table); + if (data == null) { + return result; + } + + SQLStatement statement = data.getStatement(); + if (statement == null) { + return result; + } + + if (statement instanceof SQLCreateTableStatement) { + SQLCreateTableStatement sqlCreateTableStatement = (SQLCreateTableStatement) statement; + sqlCreateTableStatement.getTableElementList().forEach(e -> { + if (e instanceof SQLConstraint && e instanceof SQLIndex) { + SQLConstraint sqlConstraint = (SQLConstraint) e; + if (sqlConstraint.getName() != null) { + result.add(SQLUtils.normalize(sqlConstraint.getName().getSimpleName())); + } + } + }); + } + + Collection objects = schemaRep.getIndexes(); + if (objects != null) { + objects.forEach(o -> { + if (o.getStatement() instanceof SQLCreateIndexStatement) { + SQLCreateIndexStatement createIndexStatement = (SQLCreateIndexStatement) o.getStatement(); + String indexTable = SQLUtils.normalize(createIndexStatement.getTableName()); + if (StringUtils.equalsIgnoreCase(indexTable, table)) { + SQLName sqlName = createIndexStatement.getIndexDefinition().getName(); + if (sqlName != null) { + result.add(SQLUtils.normalize(sqlName.getSimpleName())); + } + } + } + }); + } + + return result; + } + + private void tryRemoveSchema(BinlogPosition position, String ddlSql, String schema) throws IllegalAccessException { + SQLStatementParser parser = + SQLParserUtils.createSQLStatementParser(ddlSql, DbType.mysql, FastSQLConstant.FEATURES); + SQLStatement stmt = parser.parseStatementList().get(0); + + if (stmt instanceof SQLDropDatabaseStatement) { + Class clazz = SchemaRepository.class; + Field[] fields = clazz.getDeclaredFields(); + for (Field field : fields) { + String name = field.getName(); + if ("schemas".equalsIgnoreCase(name)) { + field.setAccessible(true); + Map schemas = (Map) field.get(repository); + schemas.remove(schema); + logger.warn("schema is removed from schema repository, tso {}, schema {}, ddlSql {}.", + position == null ? "" : position.getRtso(), schema, ddlSql); + break; + } + } + repository.setDefaultSchema((Schema) null); + } + } + + @Deprecated + private void tryRemoveTable(BinlogPosition position, String ddlSql, String schema) throws IllegalAccessException { + SQLStatementParser parser = + SQLParserUtils.createSQLStatementParser(ddlSql, DbType.mysql, FastSQLConstant.FEATURES); + SQLStatement stmt = parser.parseStatementList().get(0); + + // SchemaRepository的acceptDropTable、renameTable方法,在对带反引号的表进行处理时有问题,导致执行完drop sql后,table信息并未从objects中移除 + // 这里进行一下补偿操作,待bug修复后,可以移除,issue id:39638018 + if (stmt instanceof SQLDropTableStatement) { + SQLDropTableStatement dropStmt = (SQLDropTableStatement) stmt; + for (SQLExprTableSource tableSource : dropStmt.getTableSources()) { + String table = tableSource.getTableName(true); + doRemove(position == null ? "" : position.getRtso(), schema, table, ddlSql); + } + } else if (stmt instanceof MySqlRenameTableStatement) { + MySqlRenameTableStatement renameTableStatement = (MySqlRenameTableStatement) stmt; + for (MySqlRenameTableStatement.Item item : renameTableStatement.getItems()) { + String tableNameFrom = SQLUtils.normalize(item.getName().getSimpleName()); + doRemove(position == null ? "" : position.getRtso(), schema, tableNameFrom, ddlSql); + } + } + } + + private void doRemove(String tso, String schema, String table, String ddlSql) throws IllegalAccessException { + Schema schemaRep = repository.findSchema(schema); + if (schemaRep == null) { + return; + } + SchemaObject data = schemaRep.findTable(table); + if (data == null) { + return; + } + + Class clazz = schemaRep.getClass(); + Field[] fields = clazz.getDeclaredFields(); + for (Field field : fields) { + String name = field.getName(); + if ("objects".equalsIgnoreCase(name)) { + field.setAccessible(true); + Map objects = (Map) field.get(schemaRep); + long nameHashCode64 = FnvHash.hashCode64(table); + objects.remove(nameHashCode64); + logger.warn("table is removed from schema repository, tso {}, schema {},tableName {} ddl sql {}.", + tso, schema, table, ddlSql); + break; + } + } + + } + public SchemaRepository getRepository() { return repository; } diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/ddl/tsdb/TableMetaTSDB.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/ddl/tsdb/TableMetaTSDB.java index f7fd02d4..95a626ce 100644 --- a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/ddl/tsdb/TableMetaTSDB.java +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/ddl/tsdb/TableMetaTSDB.java @@ -33,31 +33,31 @@ public interface TableMetaTSDB { /** * 初始化 */ - public boolean init(String destination); + boolean init(String destination); /** * 销毁资源 */ - public void destory(); + void destory(); /** * 获取当前的表结构 */ - public TableMeta find(String schema, String table); + TableMeta find(String schema, String table); /** * 添加ddl到时间序列库中 */ - public boolean apply(BinlogPosition position, String schema, String ddl, String extra); + boolean apply(BinlogPosition position, String schema, String ddl, String extra); /** * 回滚到指定位点的表结构 */ - public boolean rollback(BinlogPosition position); + boolean rollback(BinlogPosition position); /** * 生成快照内容 */ - public Map snapshot(); + Map snapshot(); } diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/dump/MysqlConnection.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/dump/MysqlConnection.java index 930086e3..7fe18b35 100644 --- a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/dump/MysqlConnection.java +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/dump/MysqlConnection.java @@ -77,6 +77,10 @@ public MysqlConnection(AuthenticationInfo authInfo) { this.authInfo = authInfo; } + public MysqlConnection(Connection conn) { + this.conn = conn; + } + @Override public void connect() throws IOException { Properties info = new Properties(); @@ -133,6 +137,7 @@ public void seek(String binlogfilename, Long binlogPosition, SinkFunction func) decoder.handle(LogEvent.WRITE_ROWS_EVENT_V1); decoder.handle(LogEvent.WRITE_ROWS_EVENT); decoder.handle(LogEvent.TABLE_MAP_EVENT); + decoder.handle(LogEvent.ROWS_QUERY_LOG_EVENT); LogContext context = new LogContext(); context.setServerCharactorSet(getDefaultDatabaseCharset()); LogPosition logPosition = new LogPosition(binlogfilename, binlogPosition); @@ -315,6 +320,9 @@ public String process(ResultSet rs) throws SQLException { while (rs.next()) { String variableName = rs.getString(1); String charset = rs.getString(2); + if (StringUtils.equals("utf8mb3", charset)) { + charset = "utf8"; + } logger.info(variableName + " : " + charset); if ("character_set_client".equalsIgnoreCase(variableName)) { set.setCharacterSetClient(charset); @@ -402,16 +410,18 @@ public T query(String sql, ProcessJdbcResult processor) { rs = stmt.executeQuery(sql); return processor.process(rs); } catch (SQLException e) { - logger.error("SQLException: original sql: {}, actual statement:{}", sql, stmt); + logger.error("SQLException: original sql: {}, actual statement:{}, exception:{}", sql, stmt, e); throw new SQLExecuteException(e); } finally { - if (stmt != null) { - try { + try { + if (rs != null) { rs.close(); + } + if (stmt != null) { stmt.close(); - } catch (SQLException e) { - // ignore } + } catch (SQLException e) { + // ignore } } } diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/handle/DefaultBinlogEventHandle.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/handle/DefaultBinlogEventHandle.java index 92872405..848c355e 100644 --- a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/handle/DefaultBinlogEventHandle.java +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/handle/DefaultBinlogEventHandle.java @@ -112,7 +112,13 @@ public void handle(LogEvent event, LogPosition logPosition) { head.setRuntimeContext(runtimeContext); head.doNext(event); } catch (Throwable e) { - throw new CanalParseException(e); // 继续抛出异常,让上层统一感知 + if (logPosition != null) { + String message = String.format("meet fatal error when consume binlog at position %s:%s", + logPosition.getFileName(), logPosition.getPosition()); + throw new CanalParseException(message, e); + } else { + throw new CanalParseException(e); + } } } diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/handle/SearchTsoEventHandle.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/handle/SearchTsoEventHandle.java index 53bf4b45..ae3f8436 100644 --- a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/handle/SearchTsoEventHandle.java +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/handle/SearchTsoEventHandle.java @@ -17,6 +17,14 @@ package com.aliyun.polardbx.binlog.canal.core.handle; +import com.alibaba.polardbx.druid.DbType; +import com.alibaba.polardbx.druid.sql.SQLUtils; +import com.alibaba.polardbx.druid.sql.ast.SQLStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLCreateDatabaseStatement; +import com.alibaba.polardbx.druid.sql.parser.SQLParserUtils; +import com.alibaba.polardbx.druid.sql.parser.SQLStatementParser; +import com.aliyun.polardbx.binlog.DynamicApplicationConfig; +import com.aliyun.polardbx.binlog.SpringContextHolder; import com.aliyun.polardbx.binlog.canal.LogEventUtil; import com.aliyun.polardbx.binlog.canal.binlog.LogEvent; import com.aliyun.polardbx.binlog.canal.binlog.LogPosition; @@ -26,36 +34,64 @@ import com.aliyun.polardbx.binlog.canal.core.model.AuthenticationInfo; import com.aliyun.polardbx.binlog.canal.core.model.BinlogPosition; import com.aliyun.polardbx.binlog.canal.core.model.TranPosition; +import com.aliyun.polardbx.binlog.canal.exception.CanalParseException; +import com.aliyun.polardbx.binlog.dao.BinlogPolarxCommandMapper; +import com.aliyun.polardbx.binlog.dao.StorageHistoryInfoMapper; +import com.aliyun.polardbx.binlog.domain.po.BinlogPolarxCommand; +import com.aliyun.polardbx.binlog.domain.po.StorageHistoryInfo; import com.aliyun.polardbx.binlog.error.PolardbxException; +import com.aliyun.polardbx.binlog.util.FastSQLConstant; import com.google.common.collect.Maps; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.jdbc.core.JdbcTemplate; +import java.util.List; import java.util.Map; +import java.util.Optional; + +import static com.aliyun.polardbx.binlog.ConfigKeys.POLARX_INST_ID; +import static com.aliyun.polardbx.binlog.canal.system.SystemDB.LOGIC_SCHEMA; +import static com.aliyun.polardbx.binlog.dao.BinlogPolarxCommandDynamicSqlSupport.cmdId; +import static com.aliyun.polardbx.binlog.dao.StorageHistoryInfoDynamicSqlSupport.tso; +import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo; public class SearchTsoEventHandle implements EventHandle { private static final Logger logger = LoggerFactory.getLogger(SearchTsoEventHandle.class); + private final String requestTso; private final long searchTSO; private final Map tranPositionMap = Maps.newHashMap(); private final AuthenticationInfo authenticationInfo; + private final long minTso; + private final boolean isRequestTso4MarkStorageChange; + private final boolean isRequestTso4MarkStorageAdd; + + //need reset variables private BinlogPosition returnBinlogPosition; private BinlogPosition endPosition; private String currentFile; private long totalSize; private long logPos = 4; - private long lastPrintTimestamp = System.currentTimeMillis(); private TranPosition currentTransaction; private TranPosition commandTransaction; private boolean interrupt = false; private long lastTso = -1; - private long minTso; private long lastGcn = -1L; + private boolean isReceivedCreateCdcPhyDbEvent; - public SearchTsoEventHandle(long searchTSO, AuthenticationInfo authenticationInfo, long minTso) { - this.searchTSO = searchTSO; + //no need reset variables + private BinlogPosition firstTsoPositionAfterCreateCdcPhyEvent; + private long lastPrintTimestamp = System.currentTimeMillis(); + + public SearchTsoEventHandle(AuthenticationInfo authenticationInfo, String requestTso, long searchTSO, long minTso) { this.authenticationInfo = authenticationInfo; + this.requestTso = requestTso; + this.searchTSO = searchTSO; this.minTso = minTso; + this.isRequestTso4MarkStorageChange = checkRequestTsoMark4StorageChange(); + this.isRequestTso4MarkStorageAdd = checkRequestTsoMark4StorageAdd(); } @Override @@ -81,24 +117,41 @@ public void setEndPosition(BinlogPosition endPosition) { this.totalSize = endPosition.getPosition(); } - public void setTotalSize(long totalSize) { - this.totalSize = totalSize; - } - public void setCurrentFile(String currentFile) { this.currentFile = currentFile; } + //每次调用onStart之前需执行一下reset public void reset() { lastGcn = -1; lastTso = -1; tranPositionMap.clear(); logPos = 4; + totalSize = 0; + currentTransaction = null; + commandTransaction = null; + returnBinlogPosition = null; + endPosition = null; + isReceivedCreateCdcPhyDbEvent = false; interrupt = false; } @Override public void handle(LogEvent event, LogPosition logPosition) { + try { + search(event, logPosition); + } catch (Throwable t) { + if (logPosition != null) { + String message = String.format("meet fatal error when search tso at position %s:%s", + logPosition.getFileName(), logPosition.getPosition()); + throw new CanalParseException(message, t); + } else { + throw new CanalParseException(t); + } + } + } + + private void search(LogEvent event, LogPosition logPosition) { if (LogEventUtil.isStart(event)) { onStart(event, logPosition); } else if (LogEventUtil.isPrepare(event)) { @@ -120,10 +173,7 @@ public void handle(LogEvent event, LogPosition logPosition) { this.commandTransaction = currentTransaction; } } else { - //DN8.0 V2版本ddl也有记录tso,需要进行重置 - if (event.getHeader().getType() == LogEvent.QUERY_EVENT) { - lastGcn = -1L; - } + onDdl(event, logPosition); } } @@ -133,14 +183,22 @@ public void handle(LogEvent event, LogPosition logPosition) { if (returnBinlogPosition != null) { interrupt = true; - logger.info("returnBinlogPosition is found, stop searching. position info is {}:{}", - returnBinlogPosition.getFileName(), returnBinlogPosition.getFilePattern()); + logger.info("returnBinlogPosition is found, stop searching. position info is {}:{}:{}", + returnBinlogPosition.getFileName(), returnBinlogPosition.getPosition(), + returnBinlogPosition.getRtso()); return; } - logPos = event.getLogPos(); + logPos = event.getLogPos(); if (logPos >= endPosition.getPosition() || !logPosition.getFileName() .equalsIgnoreCase(endPosition.getFileName())) { + if (isRequestTso4MarkStorageAdd && isReceivedCreateCdcPhyDbEvent + && firstTsoPositionAfterCreateCdcPhyEvent != null) { + returnBinlogPosition = firstTsoPositionAfterCreateCdcPhyEvent; + logger.info("the add storage command for request tso [{}] is lost in this storage, " + + "the firstTsoPositionAfterCreateCdcPhyEvent is in the different binlog file with createCdcPhyEvent" + + ", will use it ,and its log Position is : {} ", requestTso, returnBinlogPosition); + } lastTso = -1L; interrupt = true; logger.warn("reach end logPosition:" + logPosition + ", endPos : " + endPosition + " , logPos:" + logPos); @@ -151,6 +209,9 @@ public void handle(LogEvent event, LogPosition logPosition) { private boolean checkCommitSequence(long sequence) { lastTso = sequence; + if (justDetectStorageAddCommandNotFound()) { + return false; + } if (searchTSO > 0 && lastTso > searchTSO && isCmdTxnNullOrCompleted()) { interrupt = true; logger.info("search tso " + searchTSO + " is less than last tso " + lastTso + ", stop searching."); @@ -212,16 +273,28 @@ private void onCommit(LogEvent event, LogPosition logPosition) { } else { tranPosition = currentTransaction; } + if (tranPosition != null) { tranPosition.setEnd(buildPosition(event, logPosition)); tranPosition.setTso(lastTso); if (minTso > 0 && lastTso < minTso) { return; } + if (justDetectStorageAddCommandNotFound()) { + processStorageAddCommandNotFound(tranPosition); + return; + } + if (justDetectStorageChangeCommandHasFound()) { + logger.info("found storage change command transaction for request tso " + requestTso); + returnBinlogPosition = commandTransaction.getPosition(); + return; + } if (returnBinlogPosition == null && lastTso > 0 && lastTso < searchTSO) { + logger.info("found returnBinlogPosition which is less than request tso : " + requestTso); returnBinlogPosition = tranPosition.getPosition(); } if (searchTSO == -1 && tranPosition.isCdcStartCmd()) { + logger.info("found returnBinlogPosition which is start command."); returnBinlogPosition = tranPosition.getPosition(); } } @@ -246,6 +319,108 @@ private void onGcn(LogEvent event) { lastGcn = gcnLogEvent.getGcn(); } + private void onDdl(LogEvent event, LogPosition logPosition) { + //DN8.0 V2版本ddl也有记录tso,需要进行重置 + if (event.getHeader().getType() == LogEvent.QUERY_EVENT) { + lastGcn = -1L; + + if (isRequestTso4MarkStorageAdd) { + QueryLogEvent queryLogEvent = (QueryLogEvent) event; + String ddlSql = queryLogEvent.getQuery(); + try { + SQLStatementParser parser = + SQLParserUtils.createSQLStatementParser(ddlSql, DbType.mysql, FastSQLConstant.FEATURES); + List statementList = parser.parseStatementList(); + SQLStatement statement = statementList.get(0); + + if (statement instanceof SQLCreateDatabaseStatement) { + SQLCreateDatabaseStatement createDatabaseStatement = (SQLCreateDatabaseStatement) statement; + String databaseName1 = SQLUtils.normalize(createDatabaseStatement.getDatabaseName()); + String databaseName2 = getCdcPhyDbNameByStorageInstId(); + if (StringUtils.equalsIgnoreCase(databaseName1, databaseName2)) { + isReceivedCreateCdcPhyDbEvent = true; + logger.info("receive create sql for cdc physical database, sql content is : " + ddlSql); + } + } + } catch (Throwable t) { + logger.warn("try parse ddlSql failed : " + ddlSql); + } + } + } + } + + private boolean checkRequestTsoMark4StorageChange() { + if (StringUtils.isNotBlank(requestTso)) { + StorageHistoryInfoMapper storageHistoryMapper = + SpringContextHolder.getObject(StorageHistoryInfoMapper.class); + Optional optional = + storageHistoryMapper.selectOne(s -> s.where(tso, isEqualTo(requestTso))); + if (optional.isPresent()) { + logger.warn("request tso is a tso for marking storage change, " + requestTso); + return true; + } + } + return false; + } + + private boolean checkRequestTsoMark4StorageAdd() { + if (StringUtils.isNotBlank(requestTso)) { + StorageHistoryInfoMapper storageHistoryMapper = + SpringContextHolder.getObject(StorageHistoryInfoMapper.class); + Optional optional1 = + storageHistoryMapper.selectOne(s -> s.where(tso, isEqualTo(requestTso))); + + if (optional1.isPresent()) { + BinlogPolarxCommandMapper commandMapper = + SpringContextHolder.getObject(BinlogPolarxCommandMapper.class); + Optional optional2 = + commandMapper.selectOne(c -> c.where(cmdId, isEqualTo(optional1.get().getInstructionId()))); + if (optional2.isPresent() && StringUtils.equals("ADD_STORAGE", optional2.get().getCmdType())) { + logger.warn("request tso is a tso for marking storage add, " + requestTso); + return true; + } + } + } + return false; + } + + private String getCdcPhyDbNameByStorageInstId() { + JdbcTemplate jdbcTemplate = SpringContextHolder.getObject("metaJdbcTemplate"); + List list = jdbcTemplate.queryForList(String.format( + "select g.phy_db_name from db_group_info g,group_detail_info d where " + + "d.group_name = g.group_name and d.inst_id = '%s' and d.storage_inst_id = '%s' and d.db_name = '%s'", + DynamicApplicationConfig.getString(POLARX_INST_ID), authenticationInfo.getStorageInstId(), LOGIC_SCHEMA), + String.class); + return list.isEmpty() ? "" : list.get(0); + } + + // 早期的CN内核,CdcManager在处理ScaleOut时有并发问题,可能会出现新增的DN节点上缺失Storage打标信息的情况,此处做容错处理 + // 如果searchTso是打标操作对应的Tso,假如没有找到小于searchTso的tso,则从大于等于searchTso的第一个tso开始消费 + private boolean justDetectStorageAddCommandNotFound() { + return isRequestTso4MarkStorageAdd && lastTso >= searchTSO && (commandTransaction == null || !commandTransaction + .isStorageChangeCmd() || (commandTransaction.isStorageChangeCmd() && commandTransaction.isComplete() + && commandTransaction.getTso() != searchTSO)); + } + + private boolean justDetectStorageChangeCommandHasFound() { + return isRequestTso4MarkStorageChange && commandTransaction != null && commandTransaction.isStorageChangeCmd() + && commandTransaction.isComplete() && commandTransaction.getTso() == searchTSO; + } + + private void processStorageAddCommandNotFound(TranPosition tranPosition) { + firstTsoPositionAfterCreateCdcPhyEvent = tranPosition.getPosition(); + if (isReceivedCreateCdcPhyDbEvent) { + returnBinlogPosition = tranPosition.getPosition(); + logger.info("the add storage command for request tso [{}] is lost in this storage," + + " the firstTsoPositionAfterCreateCdcPhyEvent is in the same binlog file with createCdcPhyEvent," + + " will use it, and its log Position is {} ", requestTso, returnBinlogPosition); + } else { + logger.info("the add storage command for request tso [{}] is not found in this file [{}], with lastTso [{}]" + + " ,stop searching.", requestTso, currentFile, lastTso); + interrupt = true; + } + } + private void printProcess(long logPos, String fileName) { long now = System.currentTimeMillis(); if (now - lastPrintTimestamp > 5000L) { diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/model/ServerCharactorSet.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/model/ServerCharactorSet.java index 8b4a913a..e9b44f50 100644 --- a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/model/ServerCharactorSet.java +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/core/model/ServerCharactorSet.java @@ -17,9 +17,17 @@ package com.aliyun.polardbx.binlog.canal.core.model; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; import lombok.ToString; @ToString +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Data public class ServerCharactorSet { private String characterSetClient; diff --git a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/system/SystemDB.java b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/system/SystemDB.java index d11d3bff..cccffa04 100644 --- a/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/system/SystemDB.java +++ b/polardbx-cdc-canal/src/main/java/com/aliyun/polardbx/binlog/canal/system/SystemDB.java @@ -17,6 +17,7 @@ package com.aliyun.polardbx.binlog.canal.system; +import com.alibaba.polardbx.druid.sql.SQLUtils; import com.aliyun.polardbx.binlog.canal.binlog.BinlogParser; import com.aliyun.polardbx.binlog.canal.binlog.event.TableMapLogEvent; import com.aliyun.polardbx.binlog.canal.binlog.event.WriteRowsLogEvent; @@ -30,6 +31,8 @@ public class SystemDB { + public static final String DDL_RECORD_FIELD_DDL_ID = "ID"; + public static final String DDL_RECORD_FIELD_JOB_ID = "JOB_ID"; public static final String DDL_RECORD_FIELD_SQL_KIND = "SQL_KIND"; public static final String DDL_RECORD_FIELD_DDL_SQL = "DDL_SQL"; public static final String DDL_RECORD_FIELD_SCHEMA_NAME = "SCHEMA_NAME"; @@ -60,6 +63,7 @@ public class SystemDB { * DRDS隐藏主键 */ public static final String DRDS_IMPLICIT_ID = "_drds_implicit_id_"; + public static final String AUTO_LOCAL_INDEX_PREFIX = "_local_"; private static final SystemDB instance = new SystemDB(); private final TableMeta ddlTableMeta; @@ -116,7 +120,7 @@ private SystemDB() { } public static boolean isDrdsImplicitId(String colName) { - return DRDS_IMPLICIT_ID.equalsIgnoreCase(colName); + return DRDS_IMPLICIT_ID.equalsIgnoreCase(SQLUtils.normalize(colName)); } public static SystemDB getInstance() { diff --git a/polardbx-cdc-common/pom.xml b/polardbx-cdc-common/pom.xml index e1b21ac2..b80ca21c 100644 --- a/polardbx-cdc-common/pom.xml +++ b/polardbx-cdc-common/pom.xml @@ -6,7 +6,7 @@ com.aliyun.polardbx polardbx-cdc - 5.4.12-SNAPSHOT + 5.4.13-SNAPSHOT polardbx-cdc-common http://maven.apache.org diff --git a/polardbx-cdc-common/src/main/filters/dev.properties b/polardbx-cdc-common/src/main/filters/dev.properties index 1fecff79..7f857c20 100644 --- a/polardbx-cdc-common/src/main/filters/dev.properties +++ b/polardbx-cdc-common/src/main/filters/dev.properties @@ -45,6 +45,7 @@ maven.polarx_password=123456 maven.binlog.dir.path=${user.home}/binlog/ maven.binlog.file.size=1048576 maven.binlog.file.seek.bufferSize=16 +maven.binlog.write.supportRowsQueryLog=true # # Daemon和拓扑相关的配置 # @@ -61,4 +62,10 @@ maven.topology.task.heartbeat.interval.ms=1000 maven.topology.resource.useRatio=0.9 maven.topology.resource.dumper.weight=2 maven.topology.resource.task.weight=3 - +# +# Meta相关 +# +maven.meta.checkConsistencyAfterEachApply=true +maven.meta.rollback.mode=SNAPSHOT_SEMI +maven.meta.semiSnapshot.holdingTime=360 +maven.meta.semiSnapshot.holdingTime.checkInterval=60 diff --git a/polardbx-cdc-common/src/main/filters/release.properties b/polardbx-cdc-common/src/main/filters/release.properties index 94b26ebd..e8a96bfd 100644 --- a/polardbx-cdc-common/src/main/filters/release.properties +++ b/polardbx-cdc-common/src/main/filters/release.properties @@ -45,6 +45,7 @@ maven.polarx_password= maven.binlog.dir.path=/home/admin/binlog/ maven.binlog.file.size=524288000 maven.binlog.file.seek.bufferSize=8 +maven.binlog.write.supportRowsQueryLog=true # # Daemon和拓扑相关的配置 # @@ -61,4 +62,10 @@ maven.topology.task.heartbeat.interval.ms=1000 maven.topology.resource.useRatio=0.7 maven.topology.resource.dumper.weight=2 maven.topology.resource.task.weight=3 - +# +# Meta相关 +# +maven.meta.checkConsistencyAfterEachApply=false +maven.meta.rollback.mode=SNAPSHOT_SEMI +maven.meta.semiSnapshot.holdingTime=360 +maven.meta.semiSnapshot.holdingTime.checkInterval=60 diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/CommonUtils.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/CommonUtils.java index 7933bd35..f01f8d6a 100644 --- a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/CommonUtils.java +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/CommonUtils.java @@ -24,6 +24,9 @@ import java.net.InetAddress; import java.net.NetworkInterface; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.Enumeration; import java.util.Objects; import java.util.Random; @@ -239,4 +242,8 @@ public static MarkInfo getCommand(String rowLogsQuery) { return new MarkInfo(rowLogsQuery); } + public static Date parse(String date, String pattern) throws ParseException { + SimpleDateFormat sdf = new SimpleDateFormat(pattern); + return sdf.parse(date); + } } diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/ConfigKeys.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/ConfigKeys.java index 16c56e63..e7f80624 100644 --- a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/ConfigKeys.java +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/ConfigKeys.java @@ -99,6 +99,10 @@ public abstract class ConfigKeys { * 密码配置是否使用密文,默认false */ public static final String USE_ENCRYPTED_PASSWORD = "useEncryptedPassword"; + /** + * 显示指定DN的ip,特殊情况下使用 + */ + public static final String ASSIGNED_DN_IP = "assignedDnIp"; //****************************************************************************************************************** //********************************************逻辑Binlog目录&文件&上传下载等相关配置************************************** @@ -119,6 +123,10 @@ public abstract class ConfigKeys { * 写binlog文件时是否进入dryrun模式 */ public static final String BINLOG_WRITE_DRYRUN = "binlog.write.dryrun"; + /** + * 写binlog文件时是否支持记录RowQueryLogEvent + */ + public static final String BINLOG_WRITE_SUPPORT_ROWS_QUERY_LOG = "binlog.write.supportRowsQueryLog"; /** * 逻辑binlog写缓冲区的大小,单位字节,建议为2的倍数 */ @@ -135,6 +143,10 @@ public abstract class ConfigKeys { * 心跳刷盘频率,默认30秒 */ public static final String HEARTBEAT_FLUSH_INTERVAL = "binlog.write.heartbeatFlushInterval"; + /** + * tableId的初始值 + */ + public static final String BINLOG_WRITE_TABLE_ID_BASE_VALUE = "binlog.write.tableId.baseValue"; //****************************************************************************************************************** //***************************************************Task运行时相关的配置********************************************** //****************************************************************************************************************** @@ -178,6 +190,19 @@ public abstract class ConfigKeys { * transmitter是否开启dry run,默认false */ public static final String TASK_TRANSMITTER_DRYRUN = "task.transmitter.dryRun"; + /** + * 是否支持binlog中显示隐藏主键 + */ + public static final String TASK_DRDS_HIDDEN_PK_SUPPORT = "task.support.drdsHiddenPk"; + /** + * 是否忽略TraceId乱序,默认false + */ + public static final String TASK_TRACEID_DISORDER_IGNORE = "task.traceid.disorder.ignore"; + + /** + * 忽略buffer key重复异常 + */ + public static final String TASK_EXCEPTION_SKIP_DUPLICATE_BUFFER_KEY = "task.skip.exception.bufferKey.duplicate"; //****************************************************************************************************************** //***********************************************Daemon和调度相关参数************************************************* @@ -314,6 +339,49 @@ public abstract class ConfigKeys { * 是否优先使用HistoryTable中的记录构建Repository,修复数据场景使用 */ public static final String META_USE_HISTORY_TABLE_FIRST = "meta.useHistoryTableFirst"; + /** + * Rollback时,元数据的构建方式 + */ + public static final String META_ROLLBACK_MODE = "meta.rollback.mode"; + /** + * 查询不到物理表元数据时,支持instant create的rollback mode + */ + public static final String META_ROLLBACK_MODE_SUPPORT_INSTANT_CREATE_TABLE = + "meta.rollback.mode.supportInstantCreatTable"; + /** + * 每次执行完逻辑DDL后,是否对该DDL对应的表的元数据信息进行一致性检查 + */ + public static final String META_CHECK_CONSISTENCY_AFTER_EACH_APPLY = "meta.checkConsistencyAfterEachApply"; + /** + * 每次执行完apply后是否打印当前表的汇总信息 + */ + public static final String META_PRINT_SUMMARY_AFTER_APPLY_SWITCH = "meta.printSummaryAfterApply.switch"; + /** + * 每次执行完apply后,需要打印表汇总信息的表清单,支持正则表达式 + */ + public static final String META_PRINT_SUMMARY_AFTER_APPLY_TABLES = "meta.printSummaryAfterApply.tables"; + /** + * 每次执行完apply后是否打印当前表的详细信息 + */ + public static final String META_PRINT_DETAIL_AFTER_APPLY_SWITCH = "meta.printDetailAfterApply.switch"; + /** + * 每次执行完apply后,需要打印表汇总信息的表清单,支持正则表达式 + */ + public static final String META_PRINT_DETAIL_AFTER_APPLY_TABLES = "meta.printDetailAfterApply.tables"; + /** + * SemiSnapshot的保存时间,超过该时间的snapshot会被移除,单位:小时 + */ + public static final String META_SEMI_SNAPSHOT_HOLDING_TIME = "meta.semiSnapshot.holdingTime"; + /** + * 检查SemiSnapshot的holdingtime的时间间隔,单位:分钟 + */ + public static final String META_SEMI_SNAPSHOT_HOLDING_TIME_CHECK_INTERVAL = + "meta.semiSnapshot.holdingTime.checkInterval"; + /** + * 对deltaChangeMap中全量进行一致性检测的周期,单位:秒 + */ + public static final String META_SEMI_SNAPSHOT_DELTA_CHANGE_CHECK_INTERVAL = + "meta.semiSnapshot.deltaChange.checkInterval"; //****************************************************************************************************************** //*********************************Binlog_System_Config表中有,但config文件中没有的一些配置****************************** diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/daemon/pipeline/CommandPipeline.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/daemon/pipeline/CommandPipeline.java index bc81c32b..62f1f714 100644 --- a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/daemon/pipeline/CommandPipeline.java +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/daemon/pipeline/CommandPipeline.java @@ -72,6 +72,14 @@ public void restartTask(String taskName, int mem) throws Exception { startTask(taskName); } + public void startRplTask(long taskId, String taskName) throws Exception { + execCommand(new String[] {"bash", "-c", "sh $HOME/polardbx-binlog.standalone/bin/start_rpl.sh " + taskId + " " + taskName}, 1000); + } + + public void stopRplTask(long taskId) throws Exception { + execCommand(new String[] {"bash", "-c", "sh $HOME/polardbx-binlog.standalone/bin/stop_rpl.sh " + taskId}, 1000); + } + public CommandResult execCommand(String[] commands, long timeout) throws Exception { CommandResult result = new CommandResult(); ShellCommandExecutor shexc = new ShellCommandExecutor(commands, diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/BinlogLogicMetaHistoryDynamicSqlSupport.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/BinlogLogicMetaHistoryDynamicSqlSupport.java index e434326c..691edaea 100644 --- a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/BinlogLogicMetaHistoryDynamicSqlSupport.java +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/BinlogLogicMetaHistoryDynamicSqlSupport.java @@ -1,80 +1,55 @@ -/* - * - * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.dao; -import org.mybatis.dynamic.sql.SqlColumn; -import org.mybatis.dynamic.sql.SqlTable; - -import javax.annotation.Generated; import java.sql.JDBCType; import java.util.Date; +import javax.annotation.Generated; +import org.mybatis.dynamic.sql.SqlColumn; +import org.mybatis.dynamic.sql.SqlTable; public final class BinlogLogicMetaHistoryDynamicSqlSupport { - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.173+08:00", - comments = "Source Table: binlog_logic_meta_history") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.184+08:00", comments="Source Table: binlog_logic_meta_history") public static final BinlogLogicMetaHistory binlogLogicMetaHistory = new BinlogLogicMetaHistory(); - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.174+08:00", - comments = "Source field: binlog_logic_meta_history.id") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.185+08:00", comments="Source field: binlog_logic_meta_history.id") public static final SqlColumn id = binlogLogicMetaHistory.id; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.174+08:00", - comments = "Source field: binlog_logic_meta_history.gmt_created") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.185+08:00", comments="Source field: binlog_logic_meta_history.gmt_created") public static final SqlColumn gmtCreated = binlogLogicMetaHistory.gmtCreated; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.174+08:00", - comments = "Source field: binlog_logic_meta_history.gmt_modified") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.185+08:00", comments="Source field: binlog_logic_meta_history.gmt_modified") public static final SqlColumn gmtModified = binlogLogicMetaHistory.gmtModified; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.174+08:00", - comments = "Source field: binlog_logic_meta_history.tso") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.185+08:00", comments="Source field: binlog_logic_meta_history.tso") public static final SqlColumn tso = binlogLogicMetaHistory.tso; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.174+08:00", - comments = "Source field: binlog_logic_meta_history.db_name") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.185+08:00", comments="Source field: binlog_logic_meta_history.db_name") public static final SqlColumn dbName = binlogLogicMetaHistory.dbName; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.174+08:00", - comments = "Source field: binlog_logic_meta_history.table_name") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.186+08:00", comments="Source field: binlog_logic_meta_history.table_name") public static final SqlColumn tableName = binlogLogicMetaHistory.tableName; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.174+08:00", - comments = "Source field: binlog_logic_meta_history.sql_kind") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.186+08:00", comments="Source field: binlog_logic_meta_history.sql_kind") public static final SqlColumn sqlKind = binlogLogicMetaHistory.sqlKind; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.174+08:00", - comments = "Source field: binlog_logic_meta_history.type") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.186+08:00", comments="Source field: binlog_logic_meta_history.type") public static final SqlColumn type = binlogLogicMetaHistory.type; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.174+08:00", - comments = "Source field: binlog_logic_meta_history.ddl") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.186+08:00", comments="Source field: binlog_logic_meta_history.ddl_record_id") + public static final SqlColumn ddlRecordId = binlogLogicMetaHistory.ddlRecordId; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.186+08:00", comments="Source field: binlog_logic_meta_history.ddl_job_id") + public static final SqlColumn ddlJobId = binlogLogicMetaHistory.ddlJobId; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.186+08:00", comments="Source field: binlog_logic_meta_history.ddl") public static final SqlColumn ddl = binlogLogicMetaHistory.ddl; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.174+08:00", - comments = "Source field: binlog_logic_meta_history.topology") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.186+08:00", comments="Source field: binlog_logic_meta_history.topology") public static final SqlColumn topology = binlogLogicMetaHistory.topology; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.174+08:00", - comments = "Source field: binlog_logic_meta_history.ext_info") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.186+08:00", comments="Source field: binlog_logic_meta_history.ext_info") public static final SqlColumn extInfo = binlogLogicMetaHistory.extInfo; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.174+08:00", - comments = "Source Table: binlog_logic_meta_history") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.185+08:00", comments="Source Table: binlog_logic_meta_history") public static final class BinlogLogicMetaHistory extends SqlTable { public final SqlColumn id = column("id", JDBCType.INTEGER); @@ -92,6 +67,10 @@ public static final class BinlogLogicMetaHistory extends SqlTable { public final SqlColumn type = column("type", JDBCType.TINYINT); + public final SqlColumn ddlRecordId = column("ddl_record_id", JDBCType.BIGINT); + + public final SqlColumn ddlJobId = column("ddl_job_id", JDBCType.BIGINT); + public final SqlColumn ddl = column("ddl", JDBCType.LONGVARCHAR); public final SqlColumn topology = column("topology", JDBCType.LONGVARCHAR); diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/BinlogLogicMetaHistoryMapper.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/BinlogLogicMetaHistoryMapper.java index 6b05e69f..b0609940 100644 --- a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/BinlogLogicMetaHistoryMapper.java +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/BinlogLogicMetaHistoryMapper.java @@ -1,23 +1,14 @@ -/* - * - * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.dao; +import static com.aliyun.polardbx.binlog.dao.BinlogLogicMetaHistoryDynamicSqlSupport.*; +import static org.mybatis.dynamic.sql.SqlBuilder.*; + import com.aliyun.polardbx.binlog.domain.po.BinlogLogicMetaHistory; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Optional; +import javax.annotation.Generated; import org.apache.ibatis.annotations.Arg; import org.apache.ibatis.annotations.ConstructorArgs; import org.apache.ibatis.annotations.DeleteProvider; @@ -41,265 +32,239 @@ import org.mybatis.dynamic.sql.util.SqlProviderAdapter; import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils; -import javax.annotation.Generated; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Optional; - -import static com.aliyun.polardbx.binlog.dao.BinlogLogicMetaHistoryDynamicSqlSupport.binlogLogicMetaHistory; -import static com.aliyun.polardbx.binlog.dao.BinlogLogicMetaHistoryDynamicSqlSupport.dbName; -import static com.aliyun.polardbx.binlog.dao.BinlogLogicMetaHistoryDynamicSqlSupport.ddl; -import static com.aliyun.polardbx.binlog.dao.BinlogLogicMetaHistoryDynamicSqlSupport.extInfo; -import static com.aliyun.polardbx.binlog.dao.BinlogLogicMetaHistoryDynamicSqlSupport.gmtCreated; -import static com.aliyun.polardbx.binlog.dao.BinlogLogicMetaHistoryDynamicSqlSupport.gmtModified; -import static com.aliyun.polardbx.binlog.dao.BinlogLogicMetaHistoryDynamicSqlSupport.id; -import static com.aliyun.polardbx.binlog.dao.BinlogLogicMetaHistoryDynamicSqlSupport.sqlKind; -import static com.aliyun.polardbx.binlog.dao.BinlogLogicMetaHistoryDynamicSqlSupport.tableName; -import static com.aliyun.polardbx.binlog.dao.BinlogLogicMetaHistoryDynamicSqlSupport.topology; -import static com.aliyun.polardbx.binlog.dao.BinlogLogicMetaHistoryDynamicSqlSupport.tso; -import static com.aliyun.polardbx.binlog.dao.BinlogLogicMetaHistoryDynamicSqlSupport.type; -import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo; - @Mapper public interface BinlogLogicMetaHistoryMapper { - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.182+08:00", - comments = "Source Table: binlog_logic_meta_history") - BasicColumn[] selectList = BasicColumn - .columnList(id, gmtCreated, gmtModified, tso, dbName, tableName, sqlKind, type, ddl, topology, extInfo); + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.197+08:00", comments="Source Table: binlog_logic_meta_history") + BasicColumn[] selectList = BasicColumn.columnList(id, gmtCreated, gmtModified, tso, dbName, tableName, sqlKind, type, ddlRecordId, ddlJobId, ddl, topology, extInfo); - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.175+08:00", - comments = "Source Table: binlog_logic_meta_history") - @SelectProvider(type = SqlProviderAdapter.class, method = "select") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.187+08:00", comments="Source Table: binlog_logic_meta_history") + @SelectProvider(type=SqlProviderAdapter.class, method="select") long count(SelectStatementProvider selectStatement); - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.176+08:00", - comments = "Source Table: binlog_logic_meta_history") - @DeleteProvider(type = SqlProviderAdapter.class, method = "delete") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.188+08:00", comments="Source Table: binlog_logic_meta_history") + @DeleteProvider(type=SqlProviderAdapter.class, method="delete") int delete(DeleteStatementProvider deleteStatement); - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.176+08:00", - comments = "Source Table: binlog_logic_meta_history") - @InsertProvider(type = SqlProviderAdapter.class, method = "insert") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.188+08:00", comments="Source Table: binlog_logic_meta_history") + @InsertProvider(type=SqlProviderAdapter.class, method="insert") int insert(InsertStatementProvider insertStatement); - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.176+08:00", - comments = "Source Table: binlog_logic_meta_history") - @InsertProvider(type = SqlProviderAdapter.class, method = "insertMultiple") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.189+08:00", comments="Source Table: binlog_logic_meta_history") + @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple") int insertMultiple(MultiRowInsertStatementProvider multipleInsertStatement); - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.178+08:00", - comments = "Source Table: binlog_logic_meta_history") - @SelectProvider(type = SqlProviderAdapter.class, method = "select") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.19+08:00", comments="Source Table: binlog_logic_meta_history") + @SelectProvider(type=SqlProviderAdapter.class, method="select") @ConstructorArgs({ - @Arg(column = "id", javaType = Integer.class, jdbcType = JdbcType.INTEGER, id = true), - @Arg(column = "gmt_created", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), - @Arg(column = "gmt_modified", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), - @Arg(column = "tso", javaType = String.class, jdbcType = JdbcType.VARCHAR), - @Arg(column = "db_name", javaType = String.class, jdbcType = JdbcType.VARCHAR), - @Arg(column = "table_name", javaType = String.class, jdbcType = JdbcType.VARCHAR), - @Arg(column = "sql_kind", javaType = String.class, jdbcType = JdbcType.VARCHAR), - @Arg(column = "type", javaType = Byte.class, jdbcType = JdbcType.TINYINT), - @Arg(column = "ddl", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR), - @Arg(column = "topology", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR), - @Arg(column = "ext_info", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR) + @Arg(column="id", javaType=Integer.class, jdbcType=JdbcType.INTEGER, id=true), + @Arg(column="gmt_created", javaType=Date.class, jdbcType=JdbcType.TIMESTAMP), + @Arg(column="gmt_modified", javaType=Date.class, jdbcType=JdbcType.TIMESTAMP), + @Arg(column="tso", javaType=String.class, jdbcType=JdbcType.VARCHAR), + @Arg(column="db_name", javaType=String.class, jdbcType=JdbcType.VARCHAR), + @Arg(column="table_name", javaType=String.class, jdbcType=JdbcType.VARCHAR), + @Arg(column="sql_kind", javaType=String.class, jdbcType=JdbcType.VARCHAR), + @Arg(column="type", javaType=Byte.class, jdbcType=JdbcType.TINYINT), + @Arg(column="ddl_record_id", javaType=Long.class, jdbcType=JdbcType.BIGINT), + @Arg(column="ddl_job_id", javaType=Long.class, jdbcType=JdbcType.BIGINT), + @Arg(column="ddl", javaType=String.class, jdbcType=JdbcType.LONGVARCHAR), + @Arg(column="topology", javaType=String.class, jdbcType=JdbcType.LONGVARCHAR), + @Arg(column="ext_info", javaType=String.class, jdbcType=JdbcType.LONGVARCHAR) }) Optional selectOne(SelectStatementProvider selectStatement); - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.179+08:00", - comments = "Source Table: binlog_logic_meta_history") - @SelectProvider(type = SqlProviderAdapter.class, method = "select") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.191+08:00", comments="Source Table: binlog_logic_meta_history") + @SelectProvider(type=SqlProviderAdapter.class, method="select") @ConstructorArgs({ - @Arg(column = "id", javaType = Integer.class, jdbcType = JdbcType.INTEGER, id = true), - @Arg(column = "gmt_created", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), - @Arg(column = "gmt_modified", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), - @Arg(column = "tso", javaType = String.class, jdbcType = JdbcType.VARCHAR), - @Arg(column = "db_name", javaType = String.class, jdbcType = JdbcType.VARCHAR), - @Arg(column = "table_name", javaType = String.class, jdbcType = JdbcType.VARCHAR), - @Arg(column = "sql_kind", javaType = String.class, jdbcType = JdbcType.VARCHAR), - @Arg(column = "type", javaType = Byte.class, jdbcType = JdbcType.TINYINT), - @Arg(column = "ddl", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR), - @Arg(column = "topology", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR), - @Arg(column = "ext_info", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR) + @Arg(column="id", javaType=Integer.class, jdbcType=JdbcType.INTEGER, id=true), + @Arg(column="gmt_created", javaType=Date.class, jdbcType=JdbcType.TIMESTAMP), + @Arg(column="gmt_modified", javaType=Date.class, jdbcType=JdbcType.TIMESTAMP), + @Arg(column="tso", javaType=String.class, jdbcType=JdbcType.VARCHAR), + @Arg(column="db_name", javaType=String.class, jdbcType=JdbcType.VARCHAR), + @Arg(column="table_name", javaType=String.class, jdbcType=JdbcType.VARCHAR), + @Arg(column="sql_kind", javaType=String.class, jdbcType=JdbcType.VARCHAR), + @Arg(column="type", javaType=Byte.class, jdbcType=JdbcType.TINYINT), + @Arg(column="ddl_record_id", javaType=Long.class, jdbcType=JdbcType.BIGINT), + @Arg(column="ddl_job_id", javaType=Long.class, jdbcType=JdbcType.BIGINT), + @Arg(column="ddl", javaType=String.class, jdbcType=JdbcType.LONGVARCHAR), + @Arg(column="topology", javaType=String.class, jdbcType=JdbcType.LONGVARCHAR), + @Arg(column="ext_info", javaType=String.class, jdbcType=JdbcType.LONGVARCHAR) }) List selectMany(SelectStatementProvider selectStatement); - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.179+08:00", - comments = "Source Table: binlog_logic_meta_history") - @UpdateProvider(type = SqlProviderAdapter.class, method = "update") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.192+08:00", comments="Source Table: binlog_logic_meta_history") + @UpdateProvider(type=SqlProviderAdapter.class, method="update") int update(UpdateStatementProvider updateStatement); - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.179+08:00", - comments = "Source Table: binlog_logic_meta_history") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.192+08:00", comments="Source Table: binlog_logic_meta_history") default long count(CountDSLCompleter completer) { return MyBatis3Utils.countFrom(this::count, binlogLogicMetaHistory, completer); } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.18+08:00", - comments = "Source Table: binlog_logic_meta_history") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.193+08:00", comments="Source Table: binlog_logic_meta_history") default int delete(DeleteDSLCompleter completer) { return MyBatis3Utils.deleteFrom(this::delete, binlogLogicMetaHistory, completer); } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.18+08:00", - comments = "Source Table: binlog_logic_meta_history") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.193+08:00", comments="Source Table: binlog_logic_meta_history") default int deleteByPrimaryKey(Integer id_) { - return delete(c -> + return delete(c -> c.where(id, isEqualTo(id_)) ); } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.18+08:00", - comments = "Source Table: binlog_logic_meta_history") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.193+08:00", comments="Source Table: binlog_logic_meta_history") default int insert(BinlogLogicMetaHistory record) { return MyBatis3Utils.insert(this::insert, record, binlogLogicMetaHistory, c -> c.map(id).toProperty("id") - .map(gmtCreated).toProperty("gmtCreated") - .map(gmtModified).toProperty("gmtModified") - .map(tso).toProperty("tso") - .map(dbName).toProperty("dbName") - .map(tableName).toProperty("tableName") - .map(sqlKind).toProperty("sqlKind") - .map(type).toProperty("type") - .map(ddl).toProperty("ddl") - .map(topology).toProperty("topology") - .map(extInfo).toProperty("extInfo") + .map(gmtCreated).toProperty("gmtCreated") + .map(gmtModified).toProperty("gmtModified") + .map(tso).toProperty("tso") + .map(dbName).toProperty("dbName") + .map(tableName).toProperty("tableName") + .map(sqlKind).toProperty("sqlKind") + .map(type).toProperty("type") + .map(ddlRecordId).toProperty("ddlRecordId") + .map(ddlJobId).toProperty("ddlJobId") + .map(ddl).toProperty("ddl") + .map(topology).toProperty("topology") + .map(extInfo).toProperty("extInfo") ); } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.181+08:00", - comments = "Source Table: binlog_logic_meta_history") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.195+08:00", comments="Source Table: binlog_logic_meta_history") default int insertMultiple(Collection records) { return MyBatis3Utils.insertMultiple(this::insertMultiple, records, binlogLogicMetaHistory, c -> c.map(id).toProperty("id") - .map(gmtCreated).toProperty("gmtCreated") - .map(gmtModified).toProperty("gmtModified") - .map(tso).toProperty("tso") - .map(dbName).toProperty("dbName") - .map(tableName).toProperty("tableName") - .map(sqlKind).toProperty("sqlKind") - .map(type).toProperty("type") - .map(ddl).toProperty("ddl") - .map(topology).toProperty("topology") - .map(extInfo).toProperty("extInfo") + .map(gmtCreated).toProperty("gmtCreated") + .map(gmtModified).toProperty("gmtModified") + .map(tso).toProperty("tso") + .map(dbName).toProperty("dbName") + .map(tableName).toProperty("tableName") + .map(sqlKind).toProperty("sqlKind") + .map(type).toProperty("type") + .map(ddlRecordId).toProperty("ddlRecordId") + .map(ddlJobId).toProperty("ddlJobId") + .map(ddl).toProperty("ddl") + .map(topology).toProperty("topology") + .map(extInfo).toProperty("extInfo") ); } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.182+08:00", - comments = "Source Table: binlog_logic_meta_history") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.196+08:00", comments="Source Table: binlog_logic_meta_history") default int insertSelective(BinlogLogicMetaHistory record) { return MyBatis3Utils.insert(this::insert, record, binlogLogicMetaHistory, c -> c.map(id).toPropertyWhenPresent("id", record::getId) - .map(gmtCreated).toPropertyWhenPresent("gmtCreated", record::getGmtCreated) - .map(gmtModified).toPropertyWhenPresent("gmtModified", record::getGmtModified) - .map(tso).toPropertyWhenPresent("tso", record::getTso) - .map(dbName).toPropertyWhenPresent("dbName", record::getDbName) - .map(tableName).toPropertyWhenPresent("tableName", record::getTableName) - .map(sqlKind).toPropertyWhenPresent("sqlKind", record::getSqlKind) - .map(type).toPropertyWhenPresent("type", record::getType) - .map(ddl).toPropertyWhenPresent("ddl", record::getDdl) - .map(topology).toPropertyWhenPresent("topology", record::getTopology) - .map(extInfo).toPropertyWhenPresent("extInfo", record::getExtInfo) + .map(gmtCreated).toPropertyWhenPresent("gmtCreated", record::getGmtCreated) + .map(gmtModified).toPropertyWhenPresent("gmtModified", record::getGmtModified) + .map(tso).toPropertyWhenPresent("tso", record::getTso) + .map(dbName).toPropertyWhenPresent("dbName", record::getDbName) + .map(tableName).toPropertyWhenPresent("tableName", record::getTableName) + .map(sqlKind).toPropertyWhenPresent("sqlKind", record::getSqlKind) + .map(type).toPropertyWhenPresent("type", record::getType) + .map(ddlRecordId).toPropertyWhenPresent("ddlRecordId", record::getDdlRecordId) + .map(ddlJobId).toPropertyWhenPresent("ddlJobId", record::getDdlJobId) + .map(ddl).toPropertyWhenPresent("ddl", record::getDdl) + .map(topology).toPropertyWhenPresent("topology", record::getTopology) + .map(extInfo).toPropertyWhenPresent("extInfo", record::getExtInfo) ); } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.183+08:00", - comments = "Source Table: binlog_logic_meta_history") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.198+08:00", comments="Source Table: binlog_logic_meta_history") default Optional selectOne(SelectDSLCompleter completer) { return MyBatis3Utils.selectOne(this::selectOne, selectList, binlogLogicMetaHistory, completer); } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.183+08:00", - comments = "Source Table: binlog_logic_meta_history") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.198+08:00", comments="Source Table: binlog_logic_meta_history") default List select(SelectDSLCompleter completer) { return MyBatis3Utils.selectList(this::selectMany, selectList, binlogLogicMetaHistory, completer); } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.184+08:00", - comments = "Source Table: binlog_logic_meta_history") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.199+08:00", comments="Source Table: binlog_logic_meta_history") default List selectDistinct(SelectDSLCompleter completer) { return MyBatis3Utils.selectDistinct(this::selectMany, selectList, binlogLogicMetaHistory, completer); } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.184+08:00", - comments = "Source Table: binlog_logic_meta_history") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.199+08:00", comments="Source Table: binlog_logic_meta_history") default Optional selectByPrimaryKey(Integer id_) { return selectOne(c -> c.where(id, isEqualTo(id_)) ); } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.184+08:00", - comments = "Source Table: binlog_logic_meta_history") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.2+08:00", comments="Source Table: binlog_logic_meta_history") default int update(UpdateDSLCompleter completer) { return MyBatis3Utils.update(this::update, binlogLogicMetaHistory, completer); } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.184+08:00", - comments = "Source Table: binlog_logic_meta_history") + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.2+08:00", comments="Source Table: binlog_logic_meta_history") static UpdateDSL updateAllColumns(BinlogLogicMetaHistory record, UpdateDSL dsl) { return dsl.set(id).equalTo(record::getId) - .set(gmtCreated).equalTo(record::getGmtCreated) - .set(gmtModified).equalTo(record::getGmtModified) - .set(tso).equalTo(record::getTso) - .set(dbName).equalTo(record::getDbName) - .set(tableName).equalTo(record::getTableName) - .set(sqlKind).equalTo(record::getSqlKind) - .set(type).equalTo(record::getType) - .set(ddl).equalTo(record::getDdl) - .set(topology).equalTo(record::getTopology) - .set(extInfo).equalTo(record::getExtInfo); - } - - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.185+08:00", - comments = "Source Table: binlog_logic_meta_history") - static UpdateDSL updateSelectiveColumns(BinlogLogicMetaHistory record, UpdateDSL dsl) { - return dsl.set(id).equalToWhenPresent(record::getId) - .set(gmtCreated).equalToWhenPresent(record::getGmtCreated) - .set(gmtModified).equalToWhenPresent(record::getGmtModified) - .set(tso).equalToWhenPresent(record::getTso) - .set(dbName).equalToWhenPresent(record::getDbName) - .set(tableName).equalToWhenPresent(record::getTableName) - .set(sqlKind).equalToWhenPresent(record::getSqlKind) - .set(type).equalToWhenPresent(record::getType) - .set(ddl).equalToWhenPresent(record::getDdl) - .set(topology).equalToWhenPresent(record::getTopology) - .set(extInfo).equalToWhenPresent(record::getExtInfo); - } - - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.185+08:00", - comments = "Source Table: binlog_logic_meta_history") - default int updateByPrimaryKey(BinlogLogicMetaHistory record) { - return update(c -> - c.set(gmtCreated).equalTo(record::getGmtCreated) + .set(gmtCreated).equalTo(record::getGmtCreated) .set(gmtModified).equalTo(record::getGmtModified) .set(tso).equalTo(record::getTso) .set(dbName).equalTo(record::getDbName) .set(tableName).equalTo(record::getTableName) .set(sqlKind).equalTo(record::getSqlKind) .set(type).equalTo(record::getType) + .set(ddlRecordId).equalTo(record::getDdlRecordId) + .set(ddlJobId).equalTo(record::getDdlJobId) .set(ddl).equalTo(record::getDdl) .set(topology).equalTo(record::getTopology) - .set(extInfo).equalTo(record::getExtInfo) - .where(id, isEqualTo(record::getId)) - ); + .set(extInfo).equalTo(record::getExtInfo); } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.185+08:00", - comments = "Source Table: binlog_logic_meta_history") - default int updateByPrimaryKeySelective(BinlogLogicMetaHistory record) { - return update(c -> - c.set(gmtCreated).equalToWhenPresent(record::getGmtCreated) + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.201+08:00", comments="Source Table: binlog_logic_meta_history") + static UpdateDSL updateSelectiveColumns(BinlogLogicMetaHistory record, UpdateDSL dsl) { + return dsl.set(id).equalToWhenPresent(record::getId) + .set(gmtCreated).equalToWhenPresent(record::getGmtCreated) .set(gmtModified).equalToWhenPresent(record::getGmtModified) .set(tso).equalToWhenPresent(record::getTso) .set(dbName).equalToWhenPresent(record::getDbName) .set(tableName).equalToWhenPresent(record::getTableName) .set(sqlKind).equalToWhenPresent(record::getSqlKind) .set(type).equalToWhenPresent(record::getType) + .set(ddlRecordId).equalToWhenPresent(record::getDdlRecordId) + .set(ddlJobId).equalToWhenPresent(record::getDdlJobId) .set(ddl).equalToWhenPresent(record::getDdl) .set(topology).equalToWhenPresent(record::getTopology) - .set(extInfo).equalToWhenPresent(record::getExtInfo) - .where(id, isEqualTo(record::getId)) + .set(extInfo).equalToWhenPresent(record::getExtInfo); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.201+08:00", comments="Source Table: binlog_logic_meta_history") + default int updateByPrimaryKey(BinlogLogicMetaHistory record) { + return update(c -> + c.set(gmtCreated).equalTo(record::getGmtCreated) + .set(gmtModified).equalTo(record::getGmtModified) + .set(tso).equalTo(record::getTso) + .set(dbName).equalTo(record::getDbName) + .set(tableName).equalTo(record::getTableName) + .set(sqlKind).equalTo(record::getSqlKind) + .set(type).equalTo(record::getType) + .set(ddlRecordId).equalTo(record::getDdlRecordId) + .set(ddlJobId).equalTo(record::getDdlJobId) + .set(ddl).equalTo(record::getDdl) + .set(topology).equalTo(record::getTopology) + .set(extInfo).equalTo(record::getExtInfo) + .where(id, isEqualTo(record::getId)) + ); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-03-10T17:59:36.202+08:00", comments="Source Table: binlog_logic_meta_history") + default int updateByPrimaryKeySelective(BinlogLogicMetaHistory record) { + return update(c -> + c.set(gmtCreated).equalToWhenPresent(record::getGmtCreated) + .set(gmtModified).equalToWhenPresent(record::getGmtModified) + .set(tso).equalToWhenPresent(record::getTso) + .set(dbName).equalToWhenPresent(record::getDbName) + .set(tableName).equalToWhenPresent(record::getTableName) + .set(sqlKind).equalToWhenPresent(record::getSqlKind) + .set(type).equalToWhenPresent(record::getType) + .set(ddlRecordId).equalToWhenPresent(record::getDdlRecordId) + .set(ddlJobId).equalToWhenPresent(record::getDdlJobId) + .set(ddl).equalToWhenPresent(record::getDdl) + .set(topology).equalToWhenPresent(record::getTopology) + .set(extInfo).equalToWhenPresent(record::getExtInfo) + .where(id, isEqualTo(record::getId)) ); } } \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/PolarxCNodeInfoMapper.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/PolarxCNodeInfoMapper.java new file mode 100644 index 00000000..d2a081cc --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/PolarxCNodeInfoMapper.java @@ -0,0 +1,304 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.dao; + +import static com.aliyun.polardbx.binlog.dao.PolarxCNodeInfoDynamicSqlSupport.*; +import static org.mybatis.dynamic.sql.SqlBuilder.*; + +import com.aliyun.polardbx.binlog.domain.po.PolarxCNodeInfo; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Optional; +import javax.annotation.Generated; + +import org.apache.ibatis.annotations.Arg; +import org.apache.ibatis.annotations.ConstructorArgs; +import org.apache.ibatis.annotations.DeleteProvider; +import org.apache.ibatis.annotations.InsertProvider; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.SelectProvider; +import org.apache.ibatis.annotations.UpdateProvider; +import org.apache.ibatis.type.JdbcType; +import org.mybatis.dynamic.sql.BasicColumn; +import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter; +import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider; +import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider; +import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider; +import org.mybatis.dynamic.sql.select.CountDSLCompleter; +import org.mybatis.dynamic.sql.select.SelectDSLCompleter; +import org.mybatis.dynamic.sql.select.render.SelectStatementProvider; +import org.mybatis.dynamic.sql.update.UpdateDSL; +import org.mybatis.dynamic.sql.update.UpdateDSLCompleter; +import org.mybatis.dynamic.sql.update.UpdateModel; +import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider; +import org.mybatis.dynamic.sql.util.SqlProviderAdapter; +import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils; + +@Mapper +public interface PolarxCNodeInfoMapper { + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.095+08:00", + comments = "Source Table: node_info") + BasicColumn[] selectList = BasicColumn + .columnList(id, cluster, instId, nodeid, version, ip, port, rpcPort, role, status, gmtCreated, gmtModified); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.081+08:00", + comments = "Source Table: node_info") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + long count(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.084+08:00", + comments = "Source Table: node_info") + @DeleteProvider(type = SqlProviderAdapter.class, method = "delete") + int delete(DeleteStatementProvider deleteStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.085+08:00", + comments = "Source Table: node_info") + @InsertProvider(type = SqlProviderAdapter.class, method = "insert") + int insert(InsertStatementProvider insertStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.085+08:00", + comments = "Source Table: node_info") + @InsertProvider(type = SqlProviderAdapter.class, method = "insertMultiple") + int insertMultiple(MultiRowInsertStatementProvider multipleInsertStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.086+08:00", + comments = "Source Table: node_info") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + @ConstructorArgs({ + @Arg(column = "id", javaType = Long.class, jdbcType = JdbcType.BIGINT, id = true), + @Arg(column = "cluster", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "inst_id", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "nodeid", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "version", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "ip", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "port", javaType = Integer.class, jdbcType = JdbcType.INTEGER), + @Arg(column = "rpc_port", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "role", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "status", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "gmt_created", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "gmt_modified", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP) + }) + Optional selectOne(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.088+08:00", + comments = "Source Table: node_info") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + @ConstructorArgs({ + @Arg(column = "id", javaType = Long.class, jdbcType = JdbcType.BIGINT, id = true), + @Arg(column = "cluster", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "inst_id", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "nodeid", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "version", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "ip", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "port", javaType = Integer.class, jdbcType = JdbcType.INTEGER), + @Arg(column = "rpc_port", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "role", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "status", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "gmt_created", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "gmt_modified", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP) + }) + List selectMany(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.089+08:00", + comments = "Source Table: node_info") + @UpdateProvider(type = SqlProviderAdapter.class, method = "update") + int update(UpdateStatementProvider updateStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.089+08:00", + comments = "Source Table: node_info") + default long count(CountDSLCompleter completer) { + return MyBatis3Utils.countFrom(this::count, polarxCNodeInfo, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.09+08:00", + comments = "Source Table: node_info") + default int delete(DeleteDSLCompleter completer) { + return MyBatis3Utils.deleteFrom(this::delete, polarxCNodeInfo, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.091+08:00", + comments = "Source Table: node_info") + default int deleteByPrimaryKey(Long id_) { + return delete(c -> + c.where(id, isEqualTo(id_)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.091+08:00", + comments = "Source Table: node_info") + default int insert(PolarxCNodeInfo record) { + return MyBatis3Utils.insert(this::insert, record, polarxCNodeInfo, c -> + c.map(id).toProperty("id") + .map(cluster).toProperty("cluster") + .map(instId).toProperty("instId") + .map(nodeid).toProperty("nodeid") + .map(version).toProperty("version") + .map(ip).toProperty("ip") + .map(port).toProperty("port") + .map(rpcPort).toProperty("rpcPort") + .map(role).toProperty("role") + .map(status).toProperty("status") + .map(gmtCreated).toProperty("gmtCreated") + .map(gmtModified).toProperty("gmtModified") + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.093+08:00", + comments = "Source Table: node_info") + default int insertMultiple(Collection records) { + return MyBatis3Utils.insertMultiple(this::insertMultiple, records, polarxCNodeInfo, c -> + c.map(id).toProperty("id") + .map(cluster).toProperty("cluster") + .map(instId).toProperty("instId") + .map(nodeid).toProperty("nodeid") + .map(version).toProperty("version") + .map(ip).toProperty("ip") + .map(port).toProperty("port") + .map(rpcPort).toProperty("rpcPort") + .map(role).toProperty("role") + .map(status).toProperty("status") + .map(gmtCreated).toProperty("gmtCreated") + .map(gmtModified).toProperty("gmtModified") + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.094+08:00", + comments = "Source Table: node_info") + default int insertSelective(PolarxCNodeInfo record) { + return MyBatis3Utils.insert(this::insert, record, polarxCNodeInfo, c -> + c.map(id).toPropertyWhenPresent("id", record::getId) + .map(cluster).toPropertyWhenPresent("cluster", record::getCluster) + .map(instId).toPropertyWhenPresent("instId", record::getInstId) + .map(nodeid).toPropertyWhenPresent("nodeid", record::getNodeid) + .map(version).toPropertyWhenPresent("version", record::getVersion) + .map(ip).toPropertyWhenPresent("ip", record::getIp) + .map(port).toPropertyWhenPresent("port", record::getPort) + .map(rpcPort).toPropertyWhenPresent("rpcPort", record::getRpcPort) + .map(role).toPropertyWhenPresent("role", record::getRole) + .map(status).toPropertyWhenPresent("status", record::getStatus) + .map(gmtCreated).toPropertyWhenPresent("gmtCreated", record::getGmtCreated) + .map(gmtModified).toPropertyWhenPresent("gmtModified", record::getGmtModified) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.097+08:00", + comments = "Source Table: node_info") + default Optional selectOne(SelectDSLCompleter completer) { + return MyBatis3Utils.selectOne(this::selectOne, selectList, polarxCNodeInfo, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.098+08:00", + comments = "Source Table: node_info") + default List select(SelectDSLCompleter completer) { + return MyBatis3Utils.selectList(this::selectMany, selectList, polarxCNodeInfo, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.099+08:00", + comments = "Source Table: node_info") + default List selectDistinct(SelectDSLCompleter completer) { + return MyBatis3Utils.selectDistinct(this::selectMany, selectList, polarxCNodeInfo, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.099+08:00", + comments = "Source Table: node_info") + default Optional selectByPrimaryKey(Long id_) { + return selectOne(c -> + c.where(id, isEqualTo(id_)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.1+08:00", + comments = "Source Table: node_info") + default int update(UpdateDSLCompleter completer) { + return MyBatis3Utils.update(this::update, polarxCNodeInfo, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.101+08:00", + comments = "Source Table: node_info") + static UpdateDSL updateAllColumns(PolarxCNodeInfo record, UpdateDSL dsl) { + return dsl.set(id).equalTo(record::getId) + .set(cluster).equalTo(record::getCluster) + .set(instId).equalTo(record::getInstId) + .set(nodeid).equalTo(record::getNodeid) + .set(version).equalTo(record::getVersion) + .set(ip).equalTo(record::getIp) + .set(port).equalTo(record::getPort) + .set(rpcPort).equalTo(record::getRpcPort) + .set(role).equalTo(record::getRole) + .set(status).equalTo(record::getStatus) + .set(gmtCreated).equalTo(record::getGmtCreated) + .set(gmtModified).equalTo(record::getGmtModified); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.101+08:00", + comments = "Source Table: node_info") + static UpdateDSL updateSelectiveColumns(PolarxCNodeInfo record, UpdateDSL dsl) { + return dsl.set(id).equalToWhenPresent(record::getId) + .set(cluster).equalToWhenPresent(record::getCluster) + .set(instId).equalToWhenPresent(record::getInstId) + .set(nodeid).equalToWhenPresent(record::getNodeid) + .set(version).equalToWhenPresent(record::getVersion) + .set(ip).equalToWhenPresent(record::getIp) + .set(port).equalToWhenPresent(record::getPort) + .set(rpcPort).equalToWhenPresent(record::getRpcPort) + .set(role).equalToWhenPresent(record::getRole) + .set(status).equalToWhenPresent(record::getStatus) + .set(gmtCreated).equalToWhenPresent(record::getGmtCreated) + .set(gmtModified).equalToWhenPresent(record::getGmtModified); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.102+08:00", + comments = "Source Table: node_info") + default int updateByPrimaryKey(PolarxCNodeInfo record) { + return update(c -> + c.set(cluster).equalTo(record::getCluster) + .set(instId).equalTo(record::getInstId) + .set(nodeid).equalTo(record::getNodeid) + .set(version).equalTo(record::getVersion) + .set(ip).equalTo(record::getIp) + .set(port).equalTo(record::getPort) + .set(rpcPort).equalTo(record::getRpcPort) + .set(role).equalTo(record::getRole) + .set(status).equalTo(record::getStatus) + .set(gmtCreated).equalTo(record::getGmtCreated) + .set(gmtModified).equalTo(record::getGmtModified) + .where(id, isEqualTo(record::getId)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.103+08:00", + comments = "Source Table: node_info") + default int updateByPrimaryKeySelective(PolarxCNodeInfo record) { + return update(c -> + c.set(cluster).equalToWhenPresent(record::getCluster) + .set(instId).equalToWhenPresent(record::getInstId) + .set(nodeid).equalToWhenPresent(record::getNodeid) + .set(version).equalToWhenPresent(record::getVersion) + .set(ip).equalToWhenPresent(record::getIp) + .set(port).equalToWhenPresent(record::getPort) + .set(rpcPort).equalToWhenPresent(record::getRpcPort) + .set(role).equalToWhenPresent(record::getRole) + .set(status).equalToWhenPresent(record::getStatus) + .set(gmtCreated).equalToWhenPresent(record::getGmtCreated) + .set(gmtModified).equalToWhenPresent(record::getGmtModified) + .where(id, isEqualTo(record::getId)) + ); + } +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplDdlDynamicSqlSupport.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplDdlDynamicSqlSupport.java new file mode 100644 index 00000000..bd80b003 --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplDdlDynamicSqlSupport.java @@ -0,0 +1,99 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.dao; + +import java.sql.JDBCType; +import java.util.Date; +import javax.annotation.Generated; + +import org.mybatis.dynamic.sql.SqlColumn; +import org.mybatis.dynamic.sql.SqlTable; + +public final class RplDdlDynamicSqlSupport { + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.762+08:00", + comments = "Source Table: rpl_ddl") + public static final RplDdl rplDdl = new RplDdl(); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.763+08:00", + comments = "Source field: rpl_ddl.id") + public static final SqlColumn id = rplDdl.id; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.763+08:00", + comments = "Source field: rpl_ddl.gmt_created") + public static final SqlColumn gmtCreated = rplDdl.gmtCreated; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.763+08:00", + comments = "Source field: rpl_ddl.gmt_modified") + public static final SqlColumn gmtModified = rplDdl.gmtModified; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.763+08:00", + comments = "Source field: rpl_ddl.state_machine_id") + public static final SqlColumn stateMachineId = rplDdl.stateMachineId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.763+08:00", + comments = "Source field: rpl_ddl.service_id") + public static final SqlColumn serviceId = rplDdl.serviceId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.763+08:00", + comments = "Source field: rpl_ddl.task_id") + public static final SqlColumn taskId = rplDdl.taskId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.763+08:00", + comments = "Source field: rpl_ddl.ddl_tso") + public static final SqlColumn ddlTso = rplDdl.ddlTso; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.763+08:00", + comments = "Source field: rpl_ddl.job_id") + public static final SqlColumn jobId = rplDdl.jobId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.763+08:00", + comments = "Source field: rpl_ddl.state") + public static final SqlColumn state = rplDdl.state; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.763+08:00", + comments = "Source field: rpl_ddl.ddl_stmt") + public static final SqlColumn ddlStmt = rplDdl.ddlStmt; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.762+08:00", + comments = "Source Table: rpl_ddl") + public static final class RplDdl extends SqlTable { + public final SqlColumn id = column("id", JDBCType.BIGINT); + + public final SqlColumn gmtCreated = column("gmt_created", JDBCType.TIMESTAMP); + + public final SqlColumn gmtModified = column("gmt_modified", JDBCType.TIMESTAMP); + + public final SqlColumn stateMachineId = column("state_machine_id", JDBCType.BIGINT); + + public final SqlColumn serviceId = column("service_id", JDBCType.BIGINT); + + public final SqlColumn taskId = column("task_id", JDBCType.BIGINT); + + public final SqlColumn ddlTso = column("ddl_tso", JDBCType.VARCHAR); + + public final SqlColumn jobId = column("job_id", JDBCType.BIGINT); + + public final SqlColumn state = column("state", JDBCType.INTEGER); + + public final SqlColumn ddlStmt = column("ddl_stmt", JDBCType.LONGVARCHAR); + + public RplDdl() { + super("rpl_ddl"); + } + } +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplDdlMapper.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplDdlMapper.java new file mode 100644 index 00000000..f636f0f4 --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplDdlMapper.java @@ -0,0 +1,261 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.dao; + +import static com.aliyun.polardbx.binlog.dao.RplDdlDynamicSqlSupport.*; +import static org.mybatis.dynamic.sql.SqlBuilder.*; + +import com.aliyun.polardbx.binlog.domain.po.RplDdl; + +import java.util.Date; +import java.util.List; +import java.util.Optional; +import javax.annotation.Generated; + +import org.apache.ibatis.annotations.Arg; +import org.apache.ibatis.annotations.ConstructorArgs; +import org.apache.ibatis.annotations.DeleteProvider; +import org.apache.ibatis.annotations.InsertProvider; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.SelectKey; +import org.apache.ibatis.annotations.SelectProvider; +import org.apache.ibatis.annotations.UpdateProvider; +import org.apache.ibatis.type.JdbcType; +import org.mybatis.dynamic.sql.BasicColumn; +import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter; +import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider; +import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider; +import org.mybatis.dynamic.sql.select.CountDSLCompleter; +import org.mybatis.dynamic.sql.select.SelectDSLCompleter; +import org.mybatis.dynamic.sql.select.render.SelectStatementProvider; +import org.mybatis.dynamic.sql.update.UpdateDSL; +import org.mybatis.dynamic.sql.update.UpdateDSLCompleter; +import org.mybatis.dynamic.sql.update.UpdateModel; +import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider; +import org.mybatis.dynamic.sql.util.SqlProviderAdapter; +import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils; + +@Mapper +public interface RplDdlMapper { + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.767+08:00", + comments = "Source Table: rpl_ddl") + BasicColumn[] selectList = BasicColumn + .columnList(id, gmtCreated, gmtModified, stateMachineId, serviceId, taskId, ddlTso, jobId, state, ddlStmt); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.764+08:00", + comments = "Source Table: rpl_ddl") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + long count(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.764+08:00", + comments = "Source Table: rpl_ddl") + @DeleteProvider(type = SqlProviderAdapter.class, method = "delete") + int delete(DeleteStatementProvider deleteStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.764+08:00", + comments = "Source Table: rpl_ddl") + @InsertProvider(type = SqlProviderAdapter.class, method = "insert") + @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "record.id", before = false, + resultType = Long.class) + int insert(InsertStatementProvider insertStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.764+08:00", + comments = "Source Table: rpl_ddl") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + @ConstructorArgs({ + @Arg(column = "id", javaType = Long.class, jdbcType = JdbcType.BIGINT, id = true), + @Arg(column = "gmt_created", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "gmt_modified", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "state_machine_id", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "service_id", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "task_id", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "ddl_tso", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "job_id", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "state", javaType = Integer.class, jdbcType = JdbcType.INTEGER), + @Arg(column = "ddl_stmt", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR) + }) + Optional selectOne(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.765+08:00", + comments = "Source Table: rpl_ddl") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + @ConstructorArgs({ + @Arg(column = "id", javaType = Long.class, jdbcType = JdbcType.BIGINT, id = true), + @Arg(column = "gmt_created", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "gmt_modified", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "state_machine_id", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "service_id", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "task_id", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "ddl_tso", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "job_id", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "state", javaType = Integer.class, jdbcType = JdbcType.INTEGER), + @Arg(column = "ddl_stmt", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR) + }) + List selectMany(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.765+08:00", + comments = "Source Table: rpl_ddl") + @UpdateProvider(type = SqlProviderAdapter.class, method = "update") + int update(UpdateStatementProvider updateStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.766+08:00", + comments = "Source Table: rpl_ddl") + default long count(CountDSLCompleter completer) { + return MyBatis3Utils.countFrom(this::count, rplDdl, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.766+08:00", + comments = "Source Table: rpl_ddl") + default int delete(DeleteDSLCompleter completer) { + return MyBatis3Utils.deleteFrom(this::delete, rplDdl, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.766+08:00", + comments = "Source Table: rpl_ddl") + default int deleteByPrimaryKey(Long id_) { + return delete(c -> + c.where(id, isEqualTo(id_)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.766+08:00", + comments = "Source Table: rpl_ddl") + default int insert(RplDdl record) { + return MyBatis3Utils.insert(this::insert, record, rplDdl, c -> + c.map(gmtCreated).toProperty("gmtCreated") + .map(gmtModified).toProperty("gmtModified") + .map(stateMachineId).toProperty("stateMachineId") + .map(serviceId).toProperty("serviceId") + .map(taskId).toProperty("taskId") + .map(ddlTso).toProperty("ddlTso") + .map(jobId).toProperty("jobId") + .map(state).toProperty("state") + .map(ddlStmt).toProperty("ddlStmt") + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.766+08:00", + comments = "Source Table: rpl_ddl") + default int insertSelective(RplDdl record) { + return MyBatis3Utils.insert(this::insert, record, rplDdl, c -> + c.map(gmtCreated).toPropertyWhenPresent("gmtCreated", record::getGmtCreated) + .map(gmtModified).toPropertyWhenPresent("gmtModified", record::getGmtModified) + .map(stateMachineId).toPropertyWhenPresent("stateMachineId", record::getStateMachineId) + .map(serviceId).toPropertyWhenPresent("serviceId", record::getServiceId) + .map(taskId).toPropertyWhenPresent("taskId", record::getTaskId) + .map(ddlTso).toPropertyWhenPresent("ddlTso", record::getDdlTso) + .map(jobId).toPropertyWhenPresent("jobId", record::getJobId) + .map(state).toPropertyWhenPresent("state", record::getState) + .map(ddlStmt).toPropertyWhenPresent("ddlStmt", record::getDdlStmt) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.767+08:00", + comments = "Source Table: rpl_ddl") + default Optional selectOne(SelectDSLCompleter completer) { + return MyBatis3Utils.selectOne(this::selectOne, selectList, rplDdl, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.767+08:00", + comments = "Source Table: rpl_ddl") + default List select(SelectDSLCompleter completer) { + return MyBatis3Utils.selectList(this::selectMany, selectList, rplDdl, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.767+08:00", + comments = "Source Table: rpl_ddl") + default List selectDistinct(SelectDSLCompleter completer) { + return MyBatis3Utils.selectDistinct(this::selectMany, selectList, rplDdl, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.767+08:00", + comments = "Source Table: rpl_ddl") + default Optional selectByPrimaryKey(Long id_) { + return selectOne(c -> + c.where(id, isEqualTo(id_)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.768+08:00", + comments = "Source Table: rpl_ddl") + default int update(UpdateDSLCompleter completer) { + return MyBatis3Utils.update(this::update, rplDdl, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.768+08:00", + comments = "Source Table: rpl_ddl") + static UpdateDSL updateAllColumns(RplDdl record, UpdateDSL dsl) { + return dsl.set(gmtCreated).equalTo(record::getGmtCreated) + .set(gmtModified).equalTo(record::getGmtModified) + .set(stateMachineId).equalTo(record::getStateMachineId) + .set(serviceId).equalTo(record::getServiceId) + .set(taskId).equalTo(record::getTaskId) + .set(ddlTso).equalTo(record::getDdlTso) + .set(jobId).equalTo(record::getJobId) + .set(state).equalTo(record::getState) + .set(ddlStmt).equalTo(record::getDdlStmt); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.768+08:00", + comments = "Source Table: rpl_ddl") + static UpdateDSL updateSelectiveColumns(RplDdl record, UpdateDSL dsl) { + return dsl.set(gmtCreated).equalToWhenPresent(record::getGmtCreated) + .set(gmtModified).equalToWhenPresent(record::getGmtModified) + .set(stateMachineId).equalToWhenPresent(record::getStateMachineId) + .set(serviceId).equalToWhenPresent(record::getServiceId) + .set(taskId).equalToWhenPresent(record::getTaskId) + .set(ddlTso).equalToWhenPresent(record::getDdlTso) + .set(jobId).equalToWhenPresent(record::getJobId) + .set(state).equalToWhenPresent(record::getState) + .set(ddlStmt).equalToWhenPresent(record::getDdlStmt); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.768+08:00", + comments = "Source Table: rpl_ddl") + default int updateByPrimaryKey(RplDdl record) { + return update(c -> + c.set(gmtCreated).equalTo(record::getGmtCreated) + .set(gmtModified).equalTo(record::getGmtModified) + .set(stateMachineId).equalTo(record::getStateMachineId) + .set(serviceId).equalTo(record::getServiceId) + .set(taskId).equalTo(record::getTaskId) + .set(ddlTso).equalTo(record::getDdlTso) + .set(jobId).equalTo(record::getJobId) + .set(state).equalTo(record::getState) + .set(ddlStmt).equalTo(record::getDdlStmt) + .where(id, isEqualTo(record::getId)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.768+08:00", + comments = "Source Table: rpl_ddl") + default int updateByPrimaryKeySelective(RplDdl record) { + return update(c -> + c.set(gmtCreated).equalToWhenPresent(record::getGmtCreated) + .set(gmtModified).equalToWhenPresent(record::getGmtModified) + .set(stateMachineId).equalToWhenPresent(record::getStateMachineId) + .set(serviceId).equalToWhenPresent(record::getServiceId) + .set(taskId).equalToWhenPresent(record::getTaskId) + .set(ddlTso).equalToWhenPresent(record::getDdlTso) + .set(jobId).equalToWhenPresent(record::getJobId) + .set(state).equalToWhenPresent(record::getState) + .set(ddlStmt).equalToWhenPresent(record::getDdlStmt) + .where(id, isEqualTo(record::getId)) + ); + } +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplServiceDynamicSqlSupport.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplServiceDynamicSqlSupport.java new file mode 100644 index 00000000..9ded8dd3 --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplServiceDynamicSqlSupport.java @@ -0,0 +1,87 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.dao; + +import java.sql.JDBCType; +import java.util.Date; +import javax.annotation.Generated; + +import org.mybatis.dynamic.sql.SqlColumn; +import org.mybatis.dynamic.sql.SqlTable; + +public final class RplServiceDynamicSqlSupport { + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.863+08:00", + comments = "Source Table: rpl_service") + public static final RplService rplService = new RplService(); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.863+08:00", + comments = "Source field: rpl_service.id") + public static final SqlColumn id = rplService.id; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.864+08:00", + comments = "Source field: rpl_service.gmt_created") + public static final SqlColumn gmtCreated = rplService.gmtCreated; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.864+08:00", + comments = "Source field: rpl_service.gmt_modified") + public static final SqlColumn gmtModified = rplService.gmtModified; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.864+08:00", + comments = "Source field: rpl_service.state_machine_id") + public static final SqlColumn stateMachineId = rplService.stateMachineId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.864+08:00", + comments = "Source field: rpl_service.service_type") + public static final SqlColumn serviceType = rplService.serviceType; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.864+08:00", + comments = "Source field: rpl_service.state_list") + public static final SqlColumn stateList = rplService.stateList; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.864+08:00", + comments = "Source field: rpl_service.channel") + public static final SqlColumn channel = rplService.channel; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.864+08:00", + comments = "Source field: rpl_service.status") + public static final SqlColumn status = rplService.status; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.863+08:00", + comments = "Source Table: rpl_service") + public static final class RplService extends SqlTable { + public final SqlColumn id = column("id", JDBCType.BIGINT); + + public final SqlColumn gmtCreated = column("gmt_created", JDBCType.TIMESTAMP); + + public final SqlColumn gmtModified = column("gmt_modified", JDBCType.TIMESTAMP); + + public final SqlColumn stateMachineId = column("state_machine_id", JDBCType.BIGINT); + + public final SqlColumn serviceType = column("service_type", JDBCType.INTEGER); + + public final SqlColumn stateList = column("state_list", JDBCType.VARCHAR); + + public final SqlColumn channel = column("channel", JDBCType.VARCHAR); + + public final SqlColumn status = column("status", JDBCType.INTEGER); + + public RplService() { + super("rpl_service"); + } + } +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplServiceMapper.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplServiceMapper.java new file mode 100644 index 00000000..043015db --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplServiceMapper.java @@ -0,0 +1,245 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.dao; + +import static com.aliyun.polardbx.binlog.dao.RplServiceDynamicSqlSupport.*; +import static org.mybatis.dynamic.sql.SqlBuilder.*; + +import com.aliyun.polardbx.binlog.domain.po.RplService; + +import java.util.Date; +import java.util.List; +import java.util.Optional; +import javax.annotation.Generated; + +import org.apache.ibatis.annotations.Arg; +import org.apache.ibatis.annotations.ConstructorArgs; +import org.apache.ibatis.annotations.DeleteProvider; +import org.apache.ibatis.annotations.InsertProvider; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.SelectKey; +import org.apache.ibatis.annotations.SelectProvider; +import org.apache.ibatis.annotations.UpdateProvider; +import org.apache.ibatis.type.JdbcType; +import org.mybatis.dynamic.sql.BasicColumn; +import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter; +import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider; +import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider; +import org.mybatis.dynamic.sql.select.CountDSLCompleter; +import org.mybatis.dynamic.sql.select.SelectDSLCompleter; +import org.mybatis.dynamic.sql.select.render.SelectStatementProvider; +import org.mybatis.dynamic.sql.update.UpdateDSL; +import org.mybatis.dynamic.sql.update.UpdateDSLCompleter; +import org.mybatis.dynamic.sql.update.UpdateModel; +import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider; +import org.mybatis.dynamic.sql.util.SqlProviderAdapter; +import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils; + +@Mapper +public interface RplServiceMapper { + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.095+08:00", + comments = "Source Table: rpl_service") + BasicColumn[] selectList = + BasicColumn.columnList(id, gmtCreated, gmtModified, stateMachineId, serviceType, stateList, channel, status); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.078+08:00", + comments = "Source Table: rpl_service") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + long count(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.079+08:00", + comments = "Source Table: rpl_service") + @DeleteProvider(type = SqlProviderAdapter.class, method = "delete") + int delete(DeleteStatementProvider deleteStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.08+08:00", + comments = "Source Table: rpl_service") + @InsertProvider(type = SqlProviderAdapter.class, method = "insert") + @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "record.id", before = false, + resultType = Long.class) + int insert(InsertStatementProvider insertStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.083+08:00", + comments = "Source Table: rpl_service") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + @ConstructorArgs({ + @Arg(column = "id", javaType = Long.class, jdbcType = JdbcType.BIGINT, id = true), + @Arg(column = "gmt_created", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "gmt_modified", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "state_machine_id", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "service_type", javaType = Integer.class, jdbcType = JdbcType.INTEGER), + @Arg(column = "state_list", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "channel", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "status", javaType = Integer.class, jdbcType = JdbcType.INTEGER) + }) + Optional selectOne(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.087+08:00", + comments = "Source Table: rpl_service") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + @ConstructorArgs({ + @Arg(column = "id", javaType = Long.class, jdbcType = JdbcType.BIGINT, id = true), + @Arg(column = "gmt_created", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "gmt_modified", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "state_machine_id", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "service_type", javaType = Integer.class, jdbcType = JdbcType.INTEGER), + @Arg(column = "state_list", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "channel", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "status", javaType = Integer.class, jdbcType = JdbcType.INTEGER) + }) + List selectMany(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.087+08:00", + comments = "Source Table: rpl_service") + @UpdateProvider(type = SqlProviderAdapter.class, method = "update") + int update(UpdateStatementProvider updateStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.087+08:00", + comments = "Source Table: rpl_service") + default long count(CountDSLCompleter completer) { + return MyBatis3Utils.countFrom(this::count, rplService, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.088+08:00", + comments = "Source Table: rpl_service") + default int delete(DeleteDSLCompleter completer) { + return MyBatis3Utils.deleteFrom(this::delete, rplService, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.088+08:00", + comments = "Source Table: rpl_service") + default int deleteByPrimaryKey(Long id_) { + return delete(c -> + c.where(id, isEqualTo(id_)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.089+08:00", + comments = "Source Table: rpl_service") + default int insert(RplService record) { + return MyBatis3Utils.insert(this::insert, record, rplService, c -> + c.map(gmtCreated).toProperty("gmtCreated") + .map(gmtModified).toProperty("gmtModified") + .map(stateMachineId).toProperty("stateMachineId") + .map(serviceType).toProperty("serviceType") + .map(stateList).toProperty("stateList") + .map(channel).toProperty("channel") + .map(status).toProperty("status") + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.091+08:00", + comments = "Source Table: rpl_service") + default int insertSelective(RplService record) { + return MyBatis3Utils.insert(this::insert, record, rplService, c -> + c.map(gmtCreated).toPropertyWhenPresent("gmtCreated", record::getGmtCreated) + .map(gmtModified).toPropertyWhenPresent("gmtModified", record::getGmtModified) + .map(stateMachineId).toPropertyWhenPresent("stateMachineId", record::getStateMachineId) + .map(serviceType).toPropertyWhenPresent("serviceType", record::getServiceType) + .map(stateList).toPropertyWhenPresent("stateList", record::getStateList) + .map(channel).toPropertyWhenPresent("channel", record::getChannel) + .map(status).toPropertyWhenPresent("status", record::getStatus) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.097+08:00", + comments = "Source Table: rpl_service") + default Optional selectOne(SelectDSLCompleter completer) { + return MyBatis3Utils.selectOne(this::selectOne, selectList, rplService, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.099+08:00", + comments = "Source Table: rpl_service") + default List select(SelectDSLCompleter completer) { + return MyBatis3Utils.selectList(this::selectMany, selectList, rplService, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.099+08:00", + comments = "Source Table: rpl_service") + default List selectDistinct(SelectDSLCompleter completer) { + return MyBatis3Utils.selectDistinct(this::selectMany, selectList, rplService, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.099+08:00", + comments = "Source Table: rpl_service") + default Optional selectByPrimaryKey(Long id_) { + return selectOne(c -> + c.where(id, isEqualTo(id_)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.1+08:00", + comments = "Source Table: rpl_service") + default int update(UpdateDSLCompleter completer) { + return MyBatis3Utils.update(this::update, rplService, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.101+08:00", + comments = "Source Table: rpl_service") + static UpdateDSL updateAllColumns(RplService record, UpdateDSL dsl) { + return dsl.set(gmtCreated).equalTo(record::getGmtCreated) + .set(gmtModified).equalTo(record::getGmtModified) + .set(stateMachineId).equalTo(record::getStateMachineId) + .set(serviceType).equalTo(record::getServiceType) + .set(stateList).equalTo(record::getStateList) + .set(channel).equalTo(record::getChannel) + .set(status).equalTo(record::getStatus); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.102+08:00", + comments = "Source Table: rpl_service") + static UpdateDSL updateSelectiveColumns(RplService record, UpdateDSL dsl) { + return dsl.set(gmtCreated).equalToWhenPresent(record::getGmtCreated) + .set(gmtModified).equalToWhenPresent(record::getGmtModified) + .set(stateMachineId).equalToWhenPresent(record::getStateMachineId) + .set(serviceType).equalToWhenPresent(record::getServiceType) + .set(stateList).equalToWhenPresent(record::getStateList) + .set(channel).equalToWhenPresent(record::getChannel) + .set(status).equalToWhenPresent(record::getStatus); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.103+08:00", + comments = "Source Table: rpl_service") + default int updateByPrimaryKey(RplService record) { + return update(c -> + c.set(gmtCreated).equalTo(record::getGmtCreated) + .set(gmtModified).equalTo(record::getGmtModified) + .set(stateMachineId).equalTo(record::getStateMachineId) + .set(serviceType).equalTo(record::getServiceType) + .set(stateList).equalTo(record::getStateList) + .set(channel).equalTo(record::getChannel) + .set(status).equalTo(record::getStatus) + .where(id, isEqualTo(record::getId)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-31T15:00:57.106+08:00", + comments = "Source Table: rpl_service") + default int updateByPrimaryKeySelective(RplService record) { + return update(c -> + c.set(gmtCreated).equalToWhenPresent(record::getGmtCreated) + .set(gmtModified).equalToWhenPresent(record::getGmtModified) + .set(stateMachineId).equalToWhenPresent(record::getStateMachineId) + .set(serviceType).equalToWhenPresent(record::getServiceType) + .set(stateList).equalToWhenPresent(record::getStateList) + .set(channel).equalToWhenPresent(record::getChannel) + .set(status).equalToWhenPresent(record::getStatus) + .where(id, isEqualTo(record::getId)) + ); + } +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplStateMachineDynamicSqlSupport.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplStateMachineDynamicSqlSupport.java new file mode 100644 index 00000000..b49ae1fe --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplStateMachineDynamicSqlSupport.java @@ -0,0 +1,105 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.dao; + +import java.sql.JDBCType; +import java.util.Date; +import javax.annotation.Generated; + +import org.mybatis.dynamic.sql.SqlColumn; +import org.mybatis.dynamic.sql.SqlTable; + +public final class RplStateMachineDynamicSqlSupport { + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.724+08:00", + comments = "Source Table: rpl_state_machine") + public static final RplStateMachine rplStateMachine = new RplStateMachine(); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.729+08:00", + comments = "Source field: rpl_state_machine.id") + public static final SqlColumn id = rplStateMachine.id; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.73+08:00", + comments = "Source field: rpl_state_machine.gmt_created") + public static final SqlColumn gmtCreated = rplStateMachine.gmtCreated; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.73+08:00", + comments = "Source field: rpl_state_machine.gmt_modified") + public static final SqlColumn gmtModified = rplStateMachine.gmtModified; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.73+08:00", + comments = "Source field: rpl_state_machine.type") + public static final SqlColumn type = rplStateMachine.type; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.73+08:00", + comments = "Source field: rpl_state_machine.class_name") + public static final SqlColumn className = rplStateMachine.className; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.73+08:00", + comments = "Source field: rpl_state_machine.channel") + public static final SqlColumn channel = rplStateMachine.channel; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.73+08:00", + comments = "Source field: rpl_state_machine.status") + public static final SqlColumn status = rplStateMachine.status; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.73+08:00", + comments = "Source field: rpl_state_machine.state") + public static final SqlColumn state = rplStateMachine.state; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.73+08:00", + comments = "Source field: rpl_state_machine.cluster_id") + public static final SqlColumn clusterId = rplStateMachine.clusterId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.73+08:00", + comments = "Source field: rpl_state_machine.config") + public static final SqlColumn config = rplStateMachine.config; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.73+08:00", + comments = "Source field: rpl_state_machine.context") + public static final SqlColumn context = rplStateMachine.context; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.728+08:00", + comments = "Source Table: rpl_state_machine") + public static final class RplStateMachine extends SqlTable { + public final SqlColumn id = column("id", JDBCType.BIGINT); + + public final SqlColumn gmtCreated = column("gmt_created", JDBCType.TIMESTAMP); + + public final SqlColumn gmtModified = column("gmt_modified", JDBCType.TIMESTAMP); + + public final SqlColumn type = column("type", JDBCType.INTEGER); + + public final SqlColumn className = column("class_name", JDBCType.VARCHAR); + + public final SqlColumn channel = column("channel", JDBCType.VARCHAR); + + public final SqlColumn status = column("status", JDBCType.INTEGER); + + public final SqlColumn state = column("state", JDBCType.INTEGER); + + public final SqlColumn clusterId = column("cluster_id", JDBCType.VARCHAR); + + public final SqlColumn config = column("config", JDBCType.LONGVARCHAR); + + public final SqlColumn context = column("context", JDBCType.LONGVARCHAR); + + public RplStateMachine() { + super("rpl_state_machine"); + } + } +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplStateMachineMapper.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplStateMachineMapper.java new file mode 100644 index 00000000..4a0c68a5 --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplStateMachineMapper.java @@ -0,0 +1,269 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.dao; + +import static com.aliyun.polardbx.binlog.dao.RplStateMachineDynamicSqlSupport.*; +import static org.mybatis.dynamic.sql.SqlBuilder.*; + +import com.aliyun.polardbx.binlog.domain.po.RplStateMachine; + +import java.util.Date; +import java.util.List; +import java.util.Optional; +import javax.annotation.Generated; + +import org.apache.ibatis.annotations.Arg; +import org.apache.ibatis.annotations.ConstructorArgs; +import org.apache.ibatis.annotations.DeleteProvider; +import org.apache.ibatis.annotations.InsertProvider; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.SelectKey; +import org.apache.ibatis.annotations.SelectProvider; +import org.apache.ibatis.annotations.UpdateProvider; +import org.apache.ibatis.type.JdbcType; +import org.mybatis.dynamic.sql.BasicColumn; +import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter; +import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider; +import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider; +import org.mybatis.dynamic.sql.select.CountDSLCompleter; +import org.mybatis.dynamic.sql.select.SelectDSLCompleter; +import org.mybatis.dynamic.sql.select.render.SelectStatementProvider; +import org.mybatis.dynamic.sql.update.UpdateDSL; +import org.mybatis.dynamic.sql.update.UpdateDSLCompleter; +import org.mybatis.dynamic.sql.update.UpdateModel; +import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider; +import org.mybatis.dynamic.sql.util.SqlProviderAdapter; +import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils; + +@Mapper +public interface RplStateMachineMapper { + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.747+08:00", + comments = "Source Table: rpl_state_machine") + BasicColumn[] selectList = BasicColumn + .columnList(id, gmtCreated, gmtModified, type, className, channel, status, state, clusterId, config, context); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.731+08:00", + comments = "Source Table: rpl_state_machine") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + long count(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.731+08:00", + comments = "Source Table: rpl_state_machine") + @DeleteProvider(type = SqlProviderAdapter.class, method = "delete") + int delete(DeleteStatementProvider deleteStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.733+08:00", + comments = "Source Table: rpl_state_machine") + @InsertProvider(type = SqlProviderAdapter.class, method = "insert") + @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "record.id", before = false, + resultType = Long.class) + int insert(InsertStatementProvider insertStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.74+08:00", + comments = "Source Table: rpl_state_machine") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + @ConstructorArgs({ + @Arg(column = "id", javaType = Long.class, jdbcType = JdbcType.BIGINT, id = true), + @Arg(column = "gmt_created", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "gmt_modified", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "type", javaType = Integer.class, jdbcType = JdbcType.INTEGER), + @Arg(column = "class_name", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "channel", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "status", javaType = Integer.class, jdbcType = JdbcType.INTEGER), + @Arg(column = "state", javaType = Integer.class, jdbcType = JdbcType.INTEGER), + @Arg(column = "cluster_id", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "config", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR), + @Arg(column = "context", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR) + }) + Optional selectOne(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.741+08:00", + comments = "Source Table: rpl_state_machine") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + @ConstructorArgs({ + @Arg(column = "id", javaType = Long.class, jdbcType = JdbcType.BIGINT, id = true), + @Arg(column = "gmt_created", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "gmt_modified", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "type", javaType = Integer.class, jdbcType = JdbcType.INTEGER), + @Arg(column = "class_name", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "channel", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "status", javaType = Integer.class, jdbcType = JdbcType.INTEGER), + @Arg(column = "state", javaType = Integer.class, jdbcType = JdbcType.INTEGER), + @Arg(column = "cluster_id", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "config", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR), + @Arg(column = "context", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR) + }) + List selectMany(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.742+08:00", + comments = "Source Table: rpl_state_machine") + @UpdateProvider(type = SqlProviderAdapter.class, method = "update") + int update(UpdateStatementProvider updateStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.742+08:00", + comments = "Source Table: rpl_state_machine") + default long count(CountDSLCompleter completer) { + return MyBatis3Utils.countFrom(this::count, rplStateMachine, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.742+08:00", + comments = "Source Table: rpl_state_machine") + default int delete(DeleteDSLCompleter completer) { + return MyBatis3Utils.deleteFrom(this::delete, rplStateMachine, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.743+08:00", + comments = "Source Table: rpl_state_machine") + default int deleteByPrimaryKey(Long id_) { + return delete(c -> + c.where(id, isEqualTo(id_)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.743+08:00", + comments = "Source Table: rpl_state_machine") + default int insert(RplStateMachine record) { + return MyBatis3Utils.insert(this::insert, record, rplStateMachine, c -> + c.map(gmtCreated).toProperty("gmtCreated") + .map(gmtModified).toProperty("gmtModified") + .map(type).toProperty("type") + .map(className).toProperty("className") + .map(channel).toProperty("channel") + .map(status).toProperty("status") + .map(state).toProperty("state") + .map(clusterId).toProperty("clusterId") + .map(config).toProperty("config") + .map(context).toProperty("context") + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.745+08:00", + comments = "Source Table: rpl_state_machine") + default int insertSelective(RplStateMachine record) { + return MyBatis3Utils.insert(this::insert, record, rplStateMachine, c -> + c.map(gmtCreated).toPropertyWhenPresent("gmtCreated", record::getGmtCreated) + .map(gmtModified).toPropertyWhenPresent("gmtModified", record::getGmtModified) + .map(type).toPropertyWhenPresent("type", record::getType) + .map(className).toPropertyWhenPresent("className", record::getClassName) + .map(channel).toPropertyWhenPresent("channel", record::getChannel) + .map(status).toPropertyWhenPresent("status", record::getStatus) + .map(state).toPropertyWhenPresent("state", record::getState) + .map(clusterId).toPropertyWhenPresent("clusterId", record::getClusterId) + .map(config).toPropertyWhenPresent("config", record::getConfig) + .map(context).toPropertyWhenPresent("context", record::getContext) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.748+08:00", + comments = "Source Table: rpl_state_machine") + default Optional selectOne(SelectDSLCompleter completer) { + return MyBatis3Utils.selectOne(this::selectOne, selectList, rplStateMachine, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.748+08:00", + comments = "Source Table: rpl_state_machine") + default List select(SelectDSLCompleter completer) { + return MyBatis3Utils.selectList(this::selectMany, selectList, rplStateMachine, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.749+08:00", + comments = "Source Table: rpl_state_machine") + default List selectDistinct(SelectDSLCompleter completer) { + return MyBatis3Utils.selectDistinct(this::selectMany, selectList, rplStateMachine, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.749+08:00", + comments = "Source Table: rpl_state_machine") + default Optional selectByPrimaryKey(Long id_) { + return selectOne(c -> + c.where(id, isEqualTo(id_)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.749+08:00", + comments = "Source Table: rpl_state_machine") + default int update(UpdateDSLCompleter completer) { + return MyBatis3Utils.update(this::update, rplStateMachine, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.75+08:00", + comments = "Source Table: rpl_state_machine") + static UpdateDSL updateAllColumns(RplStateMachine record, UpdateDSL dsl) { + return dsl.set(gmtCreated).equalTo(record::getGmtCreated) + .set(gmtModified).equalTo(record::getGmtModified) + .set(type).equalTo(record::getType) + .set(className).equalTo(record::getClassName) + .set(channel).equalTo(record::getChannel) + .set(status).equalTo(record::getStatus) + .set(state).equalTo(record::getState) + .set(clusterId).equalTo(record::getClusterId) + .set(config).equalTo(record::getConfig) + .set(context).equalTo(record::getContext); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.75+08:00", + comments = "Source Table: rpl_state_machine") + static UpdateDSL updateSelectiveColumns(RplStateMachine record, UpdateDSL dsl) { + return dsl.set(gmtCreated).equalToWhenPresent(record::getGmtCreated) + .set(gmtModified).equalToWhenPresent(record::getGmtModified) + .set(type).equalToWhenPresent(record::getType) + .set(className).equalToWhenPresent(record::getClassName) + .set(channel).equalToWhenPresent(record::getChannel) + .set(status).equalToWhenPresent(record::getStatus) + .set(state).equalToWhenPresent(record::getState) + .set(clusterId).equalToWhenPresent(record::getClusterId) + .set(config).equalToWhenPresent(record::getConfig) + .set(context).equalToWhenPresent(record::getContext); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.751+08:00", + comments = "Source Table: rpl_state_machine") + default int updateByPrimaryKey(RplStateMachine record) { + return update(c -> + c.set(gmtCreated).equalTo(record::getGmtCreated) + .set(gmtModified).equalTo(record::getGmtModified) + .set(type).equalTo(record::getType) + .set(className).equalTo(record::getClassName) + .set(channel).equalTo(record::getChannel) + .set(status).equalTo(record::getStatus) + .set(state).equalTo(record::getState) + .set(clusterId).equalTo(record::getClusterId) + .set(config).equalTo(record::getConfig) + .set(context).equalTo(record::getContext) + .where(id, isEqualTo(record::getId)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.753+08:00", + comments = "Source Table: rpl_state_machine") + default int updateByPrimaryKeySelective(RplStateMachine record) { + return update(c -> + c.set(gmtCreated).equalToWhenPresent(record::getGmtCreated) + .set(gmtModified).equalToWhenPresent(record::getGmtModified) + .set(type).equalToWhenPresent(record::getType) + .set(className).equalToWhenPresent(record::getClassName) + .set(channel).equalToWhenPresent(record::getChannel) + .set(status).equalToWhenPresent(record::getStatus) + .set(state).equalToWhenPresent(record::getState) + .set(clusterId).equalToWhenPresent(record::getClusterId) + .set(config).equalToWhenPresent(record::getConfig) + .set(context).equalToWhenPresent(record::getContext) + .where(id, isEqualTo(record::getId)) + ); + } +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplTablePositionDynamicSqlSupport.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplTablePositionDynamicSqlSupport.java new file mode 100644 index 00000000..5c8cda1b --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplTablePositionDynamicSqlSupport.java @@ -0,0 +1,87 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.dao; + +import java.sql.JDBCType; +import java.util.Date; +import javax.annotation.Generated; + +import org.mybatis.dynamic.sql.SqlColumn; +import org.mybatis.dynamic.sql.SqlTable; + +public final class RplTablePositionDynamicSqlSupport { + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.922+08:00", + comments = "Source Table: rpl_table_position") + public static final RplTablePosition rplTablePosition = new RplTablePosition(); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.922+08:00", + comments = "Source field: rpl_table_position.id") + public static final SqlColumn id = rplTablePosition.id; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.922+08:00", + comments = "Source field: rpl_table_position.gmt_created") + public static final SqlColumn gmtCreated = rplTablePosition.gmtCreated; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.923+08:00", + comments = "Source field: rpl_table_position.gmt_modified") + public static final SqlColumn gmtModified = rplTablePosition.gmtModified; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.923+08:00", + comments = "Source field: rpl_table_position.state_machine_id") + public static final SqlColumn stateMachineId = rplTablePosition.stateMachineId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.924+08:00", + comments = "Source field: rpl_table_position.service_id") + public static final SqlColumn serviceId = rplTablePosition.serviceId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.925+08:00", + comments = "Source field: rpl_table_position.task_id") + public static final SqlColumn taskId = rplTablePosition.taskId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.925+08:00", + comments = "Source field: rpl_table_position.full_table_name") + public static final SqlColumn fullTableName = rplTablePosition.fullTableName; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.925+08:00", + comments = "Source field: rpl_table_position.position") + public static final SqlColumn position = rplTablePosition.position; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.922+08:00", + comments = "Source Table: rpl_table_position") + public static final class RplTablePosition extends SqlTable { + public final SqlColumn id = column("id", JDBCType.BIGINT); + + public final SqlColumn gmtCreated = column("gmt_created", JDBCType.TIMESTAMP); + + public final SqlColumn gmtModified = column("gmt_modified", JDBCType.TIMESTAMP); + + public final SqlColumn stateMachineId = column("state_machine_id", JDBCType.BIGINT); + + public final SqlColumn serviceId = column("service_id", JDBCType.BIGINT); + + public final SqlColumn taskId = column("task_id", JDBCType.BIGINT); + + public final SqlColumn fullTableName = column("full_table_name", JDBCType.VARCHAR); + + public final SqlColumn position = column("position", JDBCType.VARCHAR); + + public RplTablePosition() { + super("rpl_table_position"); + } + } +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplTablePositionMapper.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplTablePositionMapper.java new file mode 100644 index 00000000..68059069 --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplTablePositionMapper.java @@ -0,0 +1,245 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.dao; + +import static com.aliyun.polardbx.binlog.dao.RplTablePositionDynamicSqlSupport.*; +import static org.mybatis.dynamic.sql.SqlBuilder.*; + +import com.aliyun.polardbx.binlog.domain.po.RplTablePosition; + +import java.util.Date; +import java.util.List; +import java.util.Optional; +import javax.annotation.Generated; + +import org.apache.ibatis.annotations.Arg; +import org.apache.ibatis.annotations.ConstructorArgs; +import org.apache.ibatis.annotations.DeleteProvider; +import org.apache.ibatis.annotations.InsertProvider; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.SelectKey; +import org.apache.ibatis.annotations.SelectProvider; +import org.apache.ibatis.annotations.UpdateProvider; +import org.apache.ibatis.type.JdbcType; +import org.mybatis.dynamic.sql.BasicColumn; +import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter; +import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider; +import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider; +import org.mybatis.dynamic.sql.select.CountDSLCompleter; +import org.mybatis.dynamic.sql.select.SelectDSLCompleter; +import org.mybatis.dynamic.sql.select.render.SelectStatementProvider; +import org.mybatis.dynamic.sql.update.UpdateDSL; +import org.mybatis.dynamic.sql.update.UpdateDSLCompleter; +import org.mybatis.dynamic.sql.update.UpdateModel; +import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider; +import org.mybatis.dynamic.sql.util.SqlProviderAdapter; +import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils; + +@Mapper +public interface RplTablePositionMapper { + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.931+08:00", + comments = "Source Table: rpl_table_position") + BasicColumn[] selectList = + BasicColumn.columnList(id, gmtCreated, gmtModified, stateMachineId, serviceId, taskId, fullTableName, position); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.925+08:00", + comments = "Source Table: rpl_table_position") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + long count(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.925+08:00", + comments = "Source Table: rpl_table_position") + @DeleteProvider(type = SqlProviderAdapter.class, method = "delete") + int delete(DeleteStatementProvider deleteStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.925+08:00", + comments = "Source Table: rpl_table_position") + @InsertProvider(type = SqlProviderAdapter.class, method = "insert") + @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "record.id", before = false, + resultType = Long.class) + int insert(InsertStatementProvider insertStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.928+08:00", + comments = "Source Table: rpl_table_position") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + @ConstructorArgs({ + @Arg(column = "id", javaType = Long.class, jdbcType = JdbcType.BIGINT, id = true), + @Arg(column = "gmt_created", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "gmt_modified", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "state_machine_id", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "service_id", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "task_id", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "full_table_name", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "position", javaType = String.class, jdbcType = JdbcType.VARCHAR) + }) + Optional selectOne(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.929+08:00", + comments = "Source Table: rpl_table_position") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + @ConstructorArgs({ + @Arg(column = "id", javaType = Long.class, jdbcType = JdbcType.BIGINT, id = true), + @Arg(column = "gmt_created", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "gmt_modified", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "state_machine_id", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "service_id", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "task_id", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "full_table_name", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "position", javaType = String.class, jdbcType = JdbcType.VARCHAR) + }) + List selectMany(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.93+08:00", + comments = "Source Table: rpl_table_position") + @UpdateProvider(type = SqlProviderAdapter.class, method = "update") + int update(UpdateStatementProvider updateStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.93+08:00", + comments = "Source Table: rpl_table_position") + default long count(CountDSLCompleter completer) { + return MyBatis3Utils.countFrom(this::count, rplTablePosition, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.93+08:00", + comments = "Source Table: rpl_table_position") + default int delete(DeleteDSLCompleter completer) { + return MyBatis3Utils.deleteFrom(this::delete, rplTablePosition, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.93+08:00", + comments = "Source Table: rpl_table_position") + default int deleteByPrimaryKey(Long id_) { + return delete(c -> + c.where(id, isEqualTo(id_)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.93+08:00", + comments = "Source Table: rpl_table_position") + default int insert(RplTablePosition record) { + return MyBatis3Utils.insert(this::insert, record, rplTablePosition, c -> + c.map(gmtCreated).toProperty("gmtCreated") + .map(gmtModified).toProperty("gmtModified") + .map(stateMachineId).toProperty("stateMachineId") + .map(serviceId).toProperty("serviceId") + .map(taskId).toProperty("taskId") + .map(fullTableName).toProperty("fullTableName") + .map(position).toProperty("position") + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.93+08:00", + comments = "Source Table: rpl_table_position") + default int insertSelective(RplTablePosition record) { + return MyBatis3Utils.insert(this::insert, record, rplTablePosition, c -> + c.map(gmtCreated).toPropertyWhenPresent("gmtCreated", record::getGmtCreated) + .map(gmtModified).toPropertyWhenPresent("gmtModified", record::getGmtModified) + .map(stateMachineId).toPropertyWhenPresent("stateMachineId", record::getStateMachineId) + .map(serviceId).toPropertyWhenPresent("serviceId", record::getServiceId) + .map(taskId).toPropertyWhenPresent("taskId", record::getTaskId) + .map(fullTableName).toPropertyWhenPresent("fullTableName", record::getFullTableName) + .map(position).toPropertyWhenPresent("position", record::getPosition) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.931+08:00", + comments = "Source Table: rpl_table_position") + default Optional selectOne(SelectDSLCompleter completer) { + return MyBatis3Utils.selectOne(this::selectOne, selectList, rplTablePosition, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.933+08:00", + comments = "Source Table: rpl_table_position") + default List select(SelectDSLCompleter completer) { + return MyBatis3Utils.selectList(this::selectMany, selectList, rplTablePosition, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.933+08:00", + comments = "Source Table: rpl_table_position") + default List selectDistinct(SelectDSLCompleter completer) { + return MyBatis3Utils.selectDistinct(this::selectMany, selectList, rplTablePosition, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.934+08:00", + comments = "Source Table: rpl_table_position") + default Optional selectByPrimaryKey(Long id_) { + return selectOne(c -> + c.where(id, isEqualTo(id_)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.934+08:00", + comments = "Source Table: rpl_table_position") + default int update(UpdateDSLCompleter completer) { + return MyBatis3Utils.update(this::update, rplTablePosition, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.934+08:00", + comments = "Source Table: rpl_table_position") + static UpdateDSL updateAllColumns(RplTablePosition record, UpdateDSL dsl) { + return dsl.set(gmtCreated).equalTo(record::getGmtCreated) + .set(gmtModified).equalTo(record::getGmtModified) + .set(stateMachineId).equalTo(record::getStateMachineId) + .set(serviceId).equalTo(record::getServiceId) + .set(taskId).equalTo(record::getTaskId) + .set(fullTableName).equalTo(record::getFullTableName) + .set(position).equalTo(record::getPosition); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.934+08:00", + comments = "Source Table: rpl_table_position") + static UpdateDSL updateSelectiveColumns(RplTablePosition record, UpdateDSL dsl) { + return dsl.set(gmtCreated).equalToWhenPresent(record::getGmtCreated) + .set(gmtModified).equalToWhenPresent(record::getGmtModified) + .set(stateMachineId).equalToWhenPresent(record::getStateMachineId) + .set(serviceId).equalToWhenPresent(record::getServiceId) + .set(taskId).equalToWhenPresent(record::getTaskId) + .set(fullTableName).equalToWhenPresent(record::getFullTableName) + .set(position).equalToWhenPresent(record::getPosition); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.934+08:00", + comments = "Source Table: rpl_table_position") + default int updateByPrimaryKey(RplTablePosition record) { + return update(c -> + c.set(gmtCreated).equalTo(record::getGmtCreated) + .set(gmtModified).equalTo(record::getGmtModified) + .set(stateMachineId).equalTo(record::getStateMachineId) + .set(serviceId).equalTo(record::getServiceId) + .set(taskId).equalTo(record::getTaskId) + .set(fullTableName).equalTo(record::getFullTableName) + .set(position).equalTo(record::getPosition) + .where(id, isEqualTo(record::getId)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.935+08:00", + comments = "Source Table: rpl_table_position") + default int updateByPrimaryKeySelective(RplTablePosition record) { + return update(c -> + c.set(gmtCreated).equalToWhenPresent(record::getGmtCreated) + .set(gmtModified).equalToWhenPresent(record::getGmtModified) + .set(stateMachineId).equalToWhenPresent(record::getStateMachineId) + .set(serviceId).equalToWhenPresent(record::getServiceId) + .set(taskId).equalToWhenPresent(record::getTaskId) + .set(fullTableName).equalToWhenPresent(record::getFullTableName) + .set(position).equalToWhenPresent(record::getPosition) + .where(id, isEqualTo(record::getId)) + ); + } +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplTaskDynamicSqlSupport.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplTaskDynamicSqlSupport.java new file mode 100644 index 00000000..480198a9 --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplTaskDynamicSqlSupport.java @@ -0,0 +1,153 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.dao; + +import java.sql.JDBCType; +import java.util.Date; +import javax.annotation.Generated; + +import org.mybatis.dynamic.sql.SqlColumn; +import org.mybatis.dynamic.sql.SqlTable; + +public final class RplTaskDynamicSqlSupport { + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.191+08:00", + comments = "Source Table: rpl_task") + public static final RplTask rplTask = new RplTask(); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.197+08:00", + comments = "Source field: rpl_task.id") + public static final SqlColumn id = rplTask.id; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.198+08:00", + comments = "Source field: rpl_task.gmt_created") + public static final SqlColumn gmtCreated = rplTask.gmtCreated; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.198+08:00", + comments = "Source field: rpl_task.gmt_modified") + public static final SqlColumn gmtModified = rplTask.gmtModified; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.198+08:00", + comments = "Source field: rpl_task.gmt_heartbeat") + public static final SqlColumn gmtHeartbeat = rplTask.gmtHeartbeat; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.198+08:00", + comments = "Source field: rpl_task.status") + public static final SqlColumn status = rplTask.status; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.198+08:00", + comments = "Source field: rpl_task.service_id") + public static final SqlColumn serviceId = rplTask.serviceId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.198+08:00", + comments = "Source field: rpl_task.state_machine_id") + public static final SqlColumn stateMachineId = rplTask.stateMachineId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.198+08:00", + comments = "Source field: rpl_task.type") + public static final SqlColumn type = rplTask.type; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.198+08:00", + comments = "Source field: rpl_task.master_host") + public static final SqlColumn masterHost = rplTask.masterHost; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.198+08:00", + comments = "Source field: rpl_task.master_port") + public static final SqlColumn masterPort = rplTask.masterPort; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.198+08:00", + comments = "Source field: rpl_task.position") + public static final SqlColumn position = rplTask.position; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.198+08:00", + comments = "Source field: rpl_task.worker") + public static final SqlColumn worker = rplTask.worker; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.198+08:00", + comments = "Source field: rpl_task.cluster_id") + public static final SqlColumn clusterId = rplTask.clusterId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.198+08:00", + comments = "Source field: rpl_task.extractor_config") + public static final SqlColumn extractorConfig = rplTask.extractorConfig; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.198+08:00", + comments = "Source field: rpl_task.pipeline_config") + public static final SqlColumn pipelineConfig = rplTask.pipelineConfig; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.199+08:00", + comments = "Source field: rpl_task.applier_config") + public static final SqlColumn applierConfig = rplTask.applierConfig; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.199+08:00", + comments = "Source field: rpl_task.last_error") + public static final SqlColumn lastError = rplTask.lastError; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.199+08:00", + comments = "Source field: rpl_task.statistic") + public static final SqlColumn statistic = rplTask.statistic; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.199+08:00", + comments = "Source field: rpl_task.extra") + public static final SqlColumn extra = rplTask.extra; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.197+08:00", + comments = "Source Table: rpl_task") + public static final class RplTask extends SqlTable { + public final SqlColumn id = column("id", JDBCType.BIGINT); + + public final SqlColumn gmtCreated = column("gmt_created", JDBCType.TIMESTAMP); + + public final SqlColumn gmtModified = column("gmt_modified", JDBCType.TIMESTAMP); + + public final SqlColumn gmtHeartbeat = column("gmt_heartbeat", JDBCType.TIMESTAMP); + + public final SqlColumn status = column("status", JDBCType.INTEGER); + + public final SqlColumn serviceId = column("service_id", JDBCType.BIGINT); + + public final SqlColumn stateMachineId = column("state_machine_id", JDBCType.BIGINT); + + public final SqlColumn type = column("type", JDBCType.INTEGER); + + public final SqlColumn masterHost = column("master_host", JDBCType.VARCHAR); + + public final SqlColumn masterPort = column("master_port", JDBCType.INTEGER); + + public final SqlColumn position = column("position", JDBCType.VARCHAR); + + public final SqlColumn worker = column("worker", JDBCType.VARCHAR); + + public final SqlColumn clusterId = column("cluster_id", JDBCType.VARCHAR); + + public final SqlColumn extractorConfig = column("extractor_config", JDBCType.LONGVARCHAR); + + public final SqlColumn pipelineConfig = column("pipeline_config", JDBCType.LONGVARCHAR); + + public final SqlColumn applierConfig = column("applier_config", JDBCType.LONGVARCHAR); + + public final SqlColumn lastError = column("last_error", JDBCType.LONGVARCHAR); + + public final SqlColumn statistic = column("statistic", JDBCType.LONGVARCHAR); + + public final SqlColumn extra = column("extra", JDBCType.LONGVARCHAR); + + public RplTask() { + super("rpl_task"); + } + } +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplTaskMapper.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplTaskMapper.java new file mode 100644 index 00000000..39380d71 --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/RplTaskMapper.java @@ -0,0 +1,335 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.dao; + +import static com.aliyun.polardbx.binlog.dao.RplTaskDynamicSqlSupport.*; +import static org.mybatis.dynamic.sql.SqlBuilder.*; + +import com.aliyun.polardbx.binlog.domain.po.RplTask; + +import java.util.Date; +import java.util.List; +import java.util.Optional; +import javax.annotation.Generated; + +import org.apache.ibatis.annotations.Arg; +import org.apache.ibatis.annotations.ConstructorArgs; +import org.apache.ibatis.annotations.DeleteProvider; +import org.apache.ibatis.annotations.InsertProvider; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.SelectKey; +import org.apache.ibatis.annotations.SelectProvider; +import org.apache.ibatis.annotations.UpdateProvider; +import org.apache.ibatis.type.JdbcType; +import org.mybatis.dynamic.sql.BasicColumn; +import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter; +import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider; +import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider; +import org.mybatis.dynamic.sql.select.CountDSLCompleter; +import org.mybatis.dynamic.sql.select.SelectDSLCompleter; +import org.mybatis.dynamic.sql.select.render.SelectStatementProvider; +import org.mybatis.dynamic.sql.update.UpdateDSL; +import org.mybatis.dynamic.sql.update.UpdateDSLCompleter; +import org.mybatis.dynamic.sql.update.UpdateModel; +import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider; +import org.mybatis.dynamic.sql.util.SqlProviderAdapter; +import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils; + +@Mapper +public interface RplTaskMapper { + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.213+08:00", + comments = "Source Table: rpl_task") + BasicColumn[] selectList = BasicColumn + .columnList(id, gmtCreated, gmtModified, gmtHeartbeat, status, serviceId, stateMachineId, type, masterHost, + masterPort, position, worker, clusterId, extractorConfig, pipelineConfig, applierConfig, lastError, + statistic, extra); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.2+08:00", + comments = "Source Table: rpl_task") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + long count(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.201+08:00", + comments = "Source Table: rpl_task") + @DeleteProvider(type = SqlProviderAdapter.class, method = "delete") + int delete(DeleteStatementProvider deleteStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.202+08:00", + comments = "Source Table: rpl_task") + @InsertProvider(type = SqlProviderAdapter.class, method = "insert") + @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "record.id", before = false, + resultType = Long.class) + int insert(InsertStatementProvider insertStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.207+08:00", + comments = "Source Table: rpl_task") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + @ConstructorArgs({ + @Arg(column = "id", javaType = Long.class, jdbcType = JdbcType.BIGINT, id = true), + @Arg(column = "gmt_created", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "gmt_modified", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "gmt_heartbeat", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "status", javaType = Integer.class, jdbcType = JdbcType.INTEGER), + @Arg(column = "service_id", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "state_machine_id", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "type", javaType = Integer.class, jdbcType = JdbcType.INTEGER), + @Arg(column = "master_host", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "master_port", javaType = Integer.class, jdbcType = JdbcType.INTEGER), + @Arg(column = "position", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "worker", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "cluster_id", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "extractor_config", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR), + @Arg(column = "pipeline_config", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR), + @Arg(column = "applier_config", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR), + @Arg(column = "last_error", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR), + @Arg(column = "statistic", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR), + @Arg(column = "extra", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR) + }) + Optional selectOne(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.207+08:00", + comments = "Source Table: rpl_task") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + @ConstructorArgs({ + @Arg(column = "id", javaType = Long.class, jdbcType = JdbcType.BIGINT, id = true), + @Arg(column = "gmt_created", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "gmt_modified", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "gmt_heartbeat", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "status", javaType = Integer.class, jdbcType = JdbcType.INTEGER), + @Arg(column = "service_id", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "state_machine_id", javaType = Long.class, jdbcType = JdbcType.BIGINT), + @Arg(column = "type", javaType = Integer.class, jdbcType = JdbcType.INTEGER), + @Arg(column = "master_host", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "master_port", javaType = Integer.class, jdbcType = JdbcType.INTEGER), + @Arg(column = "position", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "worker", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "cluster_id", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "extractor_config", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR), + @Arg(column = "pipeline_config", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR), + @Arg(column = "applier_config", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR), + @Arg(column = "last_error", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR), + @Arg(column = "statistic", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR), + @Arg(column = "extra", javaType = String.class, jdbcType = JdbcType.LONGVARCHAR) + }) + List selectMany(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.208+08:00", + comments = "Source Table: rpl_task") + @UpdateProvider(type = SqlProviderAdapter.class, method = "update") + int update(UpdateStatementProvider updateStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.209+08:00", + comments = "Source Table: rpl_task") + default long count(CountDSLCompleter completer) { + return MyBatis3Utils.countFrom(this::count, rplTask, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.209+08:00", + comments = "Source Table: rpl_task") + default int delete(DeleteDSLCompleter completer) { + return MyBatis3Utils.deleteFrom(this::delete, rplTask, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.209+08:00", + comments = "Source Table: rpl_task") + default int deleteByPrimaryKey(Long id_) { + return delete(c -> + c.where(id, isEqualTo(id_)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.21+08:00", + comments = "Source Table: rpl_task") + default int insert(RplTask record) { + return MyBatis3Utils.insert(this::insert, record, rplTask, c -> + c.map(gmtCreated).toProperty("gmtCreated") + .map(gmtModified).toProperty("gmtModified") + .map(gmtHeartbeat).toProperty("gmtHeartbeat") + .map(status).toProperty("status") + .map(serviceId).toProperty("serviceId") + .map(stateMachineId).toProperty("stateMachineId") + .map(type).toProperty("type") + .map(masterHost).toProperty("masterHost") + .map(masterPort).toProperty("masterPort") + .map(position).toProperty("position") + .map(worker).toProperty("worker") + .map(clusterId).toProperty("clusterId") + .map(extractorConfig).toProperty("extractorConfig") + .map(pipelineConfig).toProperty("pipelineConfig") + .map(applierConfig).toProperty("applierConfig") + .map(lastError).toProperty("lastError") + .map(statistic).toProperty("statistic") + .map(extra).toProperty("extra") + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.211+08:00", + comments = "Source Table: rpl_task") + default int insertSelective(RplTask record) { + return MyBatis3Utils.insert(this::insert, record, rplTask, c -> + c.map(gmtCreated).toPropertyWhenPresent("gmtCreated", record::getGmtCreated) + .map(gmtModified).toPropertyWhenPresent("gmtModified", record::getGmtModified) + .map(gmtHeartbeat).toPropertyWhenPresent("gmtHeartbeat", record::getGmtHeartbeat) + .map(status).toPropertyWhenPresent("status", record::getStatus) + .map(serviceId).toPropertyWhenPresent("serviceId", record::getServiceId) + .map(stateMachineId).toPropertyWhenPresent("stateMachineId", record::getStateMachineId) + .map(type).toPropertyWhenPresent("type", record::getType) + .map(masterHost).toPropertyWhenPresent("masterHost", record::getMasterHost) + .map(masterPort).toPropertyWhenPresent("masterPort", record::getMasterPort) + .map(position).toPropertyWhenPresent("position", record::getPosition) + .map(worker).toPropertyWhenPresent("worker", record::getWorker) + .map(clusterId).toPropertyWhenPresent("clusterId", record::getClusterId) + .map(extractorConfig).toPropertyWhenPresent("extractorConfig", record::getExtractorConfig) + .map(pipelineConfig).toPropertyWhenPresent("pipelineConfig", record::getPipelineConfig) + .map(applierConfig).toPropertyWhenPresent("applierConfig", record::getApplierConfig) + .map(lastError).toPropertyWhenPresent("lastError", record::getLastError) + .map(statistic).toPropertyWhenPresent("statistic", record::getStatistic) + .map(extra).toPropertyWhenPresent("extra", record::getExtra) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.213+08:00", + comments = "Source Table: rpl_task") + default Optional selectOne(SelectDSLCompleter completer) { + return MyBatis3Utils.selectOne(this::selectOne, selectList, rplTask, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.214+08:00", + comments = "Source Table: rpl_task") + default List select(SelectDSLCompleter completer) { + return MyBatis3Utils.selectList(this::selectMany, selectList, rplTask, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.214+08:00", + comments = "Source Table: rpl_task") + default List selectDistinct(SelectDSLCompleter completer) { + return MyBatis3Utils.selectDistinct(this::selectMany, selectList, rplTask, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.215+08:00", + comments = "Source Table: rpl_task") + default Optional selectByPrimaryKey(Long id_) { + return selectOne(c -> + c.where(id, isEqualTo(id_)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.215+08:00", + comments = "Source Table: rpl_task") + default int update(UpdateDSLCompleter completer) { + return MyBatis3Utils.update(this::update, rplTask, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.215+08:00", + comments = "Source Table: rpl_task") + static UpdateDSL updateAllColumns(RplTask record, UpdateDSL dsl) { + return dsl.set(gmtCreated).equalTo(record::getGmtCreated) + .set(gmtModified).equalTo(record::getGmtModified) + .set(gmtHeartbeat).equalTo(record::getGmtHeartbeat) + .set(status).equalTo(record::getStatus) + .set(serviceId).equalTo(record::getServiceId) + .set(stateMachineId).equalTo(record::getStateMachineId) + .set(type).equalTo(record::getType) + .set(masterHost).equalTo(record::getMasterHost) + .set(masterPort).equalTo(record::getMasterPort) + .set(position).equalTo(record::getPosition) + .set(worker).equalTo(record::getWorker) + .set(clusterId).equalTo(record::getClusterId) + .set(extractorConfig).equalTo(record::getExtractorConfig) + .set(pipelineConfig).equalTo(record::getPipelineConfig) + .set(applierConfig).equalTo(record::getApplierConfig) + .set(lastError).equalTo(record::getLastError) + .set(statistic).equalTo(record::getStatistic) + .set(extra).equalTo(record::getExtra); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.216+08:00", + comments = "Source Table: rpl_task") + static UpdateDSL updateSelectiveColumns(RplTask record, UpdateDSL dsl) { + return dsl.set(gmtCreated).equalToWhenPresent(record::getGmtCreated) + .set(gmtModified).equalToWhenPresent(record::getGmtModified) + .set(gmtHeartbeat).equalToWhenPresent(record::getGmtHeartbeat) + .set(status).equalToWhenPresent(record::getStatus) + .set(serviceId).equalToWhenPresent(record::getServiceId) + .set(stateMachineId).equalToWhenPresent(record::getStateMachineId) + .set(type).equalToWhenPresent(record::getType) + .set(masterHost).equalToWhenPresent(record::getMasterHost) + .set(masterPort).equalToWhenPresent(record::getMasterPort) + .set(position).equalToWhenPresent(record::getPosition) + .set(worker).equalToWhenPresent(record::getWorker) + .set(clusterId).equalToWhenPresent(record::getClusterId) + .set(extractorConfig).equalToWhenPresent(record::getExtractorConfig) + .set(pipelineConfig).equalToWhenPresent(record::getPipelineConfig) + .set(applierConfig).equalToWhenPresent(record::getApplierConfig) + .set(lastError).equalToWhenPresent(record::getLastError) + .set(statistic).equalToWhenPresent(record::getStatistic) + .set(extra).equalToWhenPresent(record::getExtra); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.217+08:00", + comments = "Source Table: rpl_task") + default int updateByPrimaryKey(RplTask record) { + return update(c -> + c.set(gmtCreated).equalTo(record::getGmtCreated) + .set(gmtModified).equalTo(record::getGmtModified) + .set(gmtHeartbeat).equalTo(record::getGmtHeartbeat) + .set(status).equalTo(record::getStatus) + .set(serviceId).equalTo(record::getServiceId) + .set(stateMachineId).equalTo(record::getStateMachineId) + .set(type).equalTo(record::getType) + .set(masterHost).equalTo(record::getMasterHost) + .set(masterPort).equalTo(record::getMasterPort) + .set(position).equalTo(record::getPosition) + .set(worker).equalTo(record::getWorker) + .set(clusterId).equalTo(record::getClusterId) + .set(extractorConfig).equalTo(record::getExtractorConfig) + .set(pipelineConfig).equalTo(record::getPipelineConfig) + .set(applierConfig).equalTo(record::getApplierConfig) + .set(lastError).equalTo(record::getLastError) + .set(statistic).equalTo(record::getStatistic) + .set(extra).equalTo(record::getExtra) + .where(id, isEqualTo(record::getId)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.218+08:00", + comments = "Source Table: rpl_task") + default int updateByPrimaryKeySelective(RplTask record) { + return update(c -> + c.set(gmtCreated).equalToWhenPresent(record::getGmtCreated) + .set(gmtModified).equalToWhenPresent(record::getGmtModified) + .set(gmtHeartbeat).equalToWhenPresent(record::getGmtHeartbeat) + .set(status).equalToWhenPresent(record::getStatus) + .set(serviceId).equalToWhenPresent(record::getServiceId) + .set(stateMachineId).equalToWhenPresent(record::getStateMachineId) + .set(type).equalToWhenPresent(record::getType) + .set(masterHost).equalToWhenPresent(record::getMasterHost) + .set(masterPort).equalToWhenPresent(record::getMasterPort) + .set(position).equalToWhenPresent(record::getPosition) + .set(worker).equalToWhenPresent(record::getWorker) + .set(clusterId).equalToWhenPresent(record::getClusterId) + .set(extractorConfig).equalToWhenPresent(record::getExtractorConfig) + .set(pipelineConfig).equalToWhenPresent(record::getPipelineConfig) + .set(applierConfig).equalToWhenPresent(record::getApplierConfig) + .set(lastError).equalToWhenPresent(record::getLastError) + .set(statistic).equalToWhenPresent(record::getStatistic) + .set(extra).equalToWhenPresent(record::getExtra) + .where(id, isEqualTo(record::getId)) + ); + } +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/SemiSnapshotInfoDynamicSqlSupport.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/SemiSnapshotInfoDynamicSqlSupport.java new file mode 100644 index 00000000..ceb8e997 --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/SemiSnapshotInfoDynamicSqlSupport.java @@ -0,0 +1,52 @@ +package com.aliyun.polardbx.binlog.dao; + +import org.mybatis.dynamic.sql.SqlColumn; +import org.mybatis.dynamic.sql.SqlTable; + +import javax.annotation.Generated; +import java.sql.JDBCType; +import java.util.Date; + +public final class SemiSnapshotInfoDynamicSqlSupport { + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.124+08:00", + comments = "Source Table: binlog_semi_snapshot") + public static final SemiSnapshotInfo semiSnapshotInfo = new SemiSnapshotInfo(); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.124+08:00", + comments = "Source field: binlog_semi_snapshot.id") + public static final SqlColumn id = semiSnapshotInfo.id; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.124+08:00", + comments = "Source field: binlog_semi_snapshot.gmt_created") + public static final SqlColumn gmtCreated = semiSnapshotInfo.gmtCreated; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.124+08:00", + comments = "Source field: binlog_semi_snapshot.gmt_modified") + public static final SqlColumn gmtModified = semiSnapshotInfo.gmtModified; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.125+08:00", + comments = "Source field: binlog_semi_snapshot.tso") + public static final SqlColumn tso = semiSnapshotInfo.tso; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.125+08:00", + comments = "Source field: binlog_semi_snapshot.storage_inst_id") + public static final SqlColumn storageInstId = semiSnapshotInfo.storageInstId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.124+08:00", + comments = "Source Table: binlog_semi_snapshot") + public static final class SemiSnapshotInfo extends SqlTable { + public final SqlColumn id = column("id", JDBCType.BIGINT); + + public final SqlColumn gmtCreated = column("gmt_created", JDBCType.TIMESTAMP); + + public final SqlColumn gmtModified = column("gmt_modified", JDBCType.TIMESTAMP); + + public final SqlColumn tso = column("tso", JDBCType.VARCHAR); + + public final SqlColumn storageInstId = column("storage_inst_id", JDBCType.VARCHAR); + + public SemiSnapshotInfo() { + super("binlog_semi_snapshot"); + } + } +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/SemiSnapshotInfoMapper.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/SemiSnapshotInfoMapper.java new file mode 100644 index 00000000..d59741fc --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/dao/SemiSnapshotInfoMapper.java @@ -0,0 +1,227 @@ +package com.aliyun.polardbx.binlog.dao; + +import com.aliyun.polardbx.binlog.domain.po.SemiSnapshotInfo; +import org.apache.ibatis.annotations.Arg; +import org.apache.ibatis.annotations.ConstructorArgs; +import org.apache.ibatis.annotations.DeleteProvider; +import org.apache.ibatis.annotations.InsertProvider; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.SelectProvider; +import org.apache.ibatis.annotations.UpdateProvider; +import org.apache.ibatis.type.JdbcType; +import org.mybatis.dynamic.sql.BasicColumn; +import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter; +import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider; +import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider; +import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider; +import org.mybatis.dynamic.sql.select.CountDSLCompleter; +import org.mybatis.dynamic.sql.select.SelectDSLCompleter; +import org.mybatis.dynamic.sql.select.render.SelectStatementProvider; +import org.mybatis.dynamic.sql.update.UpdateDSL; +import org.mybatis.dynamic.sql.update.UpdateDSLCompleter; +import org.mybatis.dynamic.sql.update.UpdateModel; +import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider; +import org.mybatis.dynamic.sql.util.SqlProviderAdapter; +import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils; + +import javax.annotation.Generated; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Optional; + +import static com.aliyun.polardbx.binlog.dao.SemiSnapshotInfoDynamicSqlSupport.gmtCreated; +import static com.aliyun.polardbx.binlog.dao.SemiSnapshotInfoDynamicSqlSupport.gmtModified; +import static com.aliyun.polardbx.binlog.dao.SemiSnapshotInfoDynamicSqlSupport.id; +import static com.aliyun.polardbx.binlog.dao.SemiSnapshotInfoDynamicSqlSupport.semiSnapshotInfo; +import static com.aliyun.polardbx.binlog.dao.SemiSnapshotInfoDynamicSqlSupport.storageInstId; +import static com.aliyun.polardbx.binlog.dao.SemiSnapshotInfoDynamicSqlSupport.tso; +import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo; + +@Mapper +public interface SemiSnapshotInfoMapper { + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.135+08:00", + comments = "Source Table: binlog_semi_snapshot") + BasicColumn[] selectList = BasicColumn.columnList(id, gmtCreated, gmtModified, tso, storageInstId); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.125+08:00", + comments = "Source Table: binlog_semi_snapshot") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + long count(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.126+08:00", + comments = "Source Table: binlog_semi_snapshot") + @DeleteProvider(type = SqlProviderAdapter.class, method = "delete") + int delete(DeleteStatementProvider deleteStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.126+08:00", + comments = "Source Table: binlog_semi_snapshot") + @InsertProvider(type = SqlProviderAdapter.class, method = "insert") + int insert(InsertStatementProvider insertStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.127+08:00", + comments = "Source Table: binlog_semi_snapshot") + @InsertProvider(type = SqlProviderAdapter.class, method = "insertMultiple") + int insertMultiple(MultiRowInsertStatementProvider multipleInsertStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.127+08:00", + comments = "Source Table: binlog_semi_snapshot") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + @ConstructorArgs({ + @Arg(column = "id", javaType = Long.class, jdbcType = JdbcType.BIGINT, id = true), + @Arg(column = "gmt_created", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "gmt_modified", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "tso", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "storage_inst_id", javaType = String.class, jdbcType = JdbcType.VARCHAR) + }) + Optional selectOne(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.129+08:00", + comments = "Source Table: binlog_semi_snapshot") + @SelectProvider(type = SqlProviderAdapter.class, method = "select") + @ConstructorArgs({ + @Arg(column = "id", javaType = Long.class, jdbcType = JdbcType.BIGINT, id = true), + @Arg(column = "gmt_created", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "gmt_modified", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Arg(column = "tso", javaType = String.class, jdbcType = JdbcType.VARCHAR), + @Arg(column = "storage_inst_id", javaType = String.class, jdbcType = JdbcType.VARCHAR) + }) + List selectMany(SelectStatementProvider selectStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.129+08:00", + comments = "Source Table: binlog_semi_snapshot") + @UpdateProvider(type = SqlProviderAdapter.class, method = "update") + int update(UpdateStatementProvider updateStatement); + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.13+08:00", + comments = "Source Table: binlog_semi_snapshot") + default long count(CountDSLCompleter completer) { + return MyBatis3Utils.countFrom(this::count, semiSnapshotInfo, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.13+08:00", + comments = "Source Table: binlog_semi_snapshot") + default int delete(DeleteDSLCompleter completer) { + return MyBatis3Utils.deleteFrom(this::delete, semiSnapshotInfo, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.131+08:00", + comments = "Source Table: binlog_semi_snapshot") + default int deleteByPrimaryKey(Long id_) { + return delete(c -> + c.where(id, isEqualTo(id_)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.131+08:00", + comments = "Source Table: binlog_semi_snapshot") + default int insert(SemiSnapshotInfo record) { + return MyBatis3Utils.insert(this::insert, record, semiSnapshotInfo, c -> + c.map(id).toProperty("id") + .map(gmtCreated).toProperty("gmtCreated") + .map(gmtModified).toProperty("gmtModified") + .map(tso).toProperty("tso") + .map(storageInstId).toProperty("storageInstId") + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.133+08:00", + comments = "Source Table: binlog_semi_snapshot") + default int insertMultiple(Collection records) { + return MyBatis3Utils.insertMultiple(this::insertMultiple, records, semiSnapshotInfo, c -> + c.map(id).toProperty("id") + .map(gmtCreated).toProperty("gmtCreated") + .map(gmtModified).toProperty("gmtModified") + .map(tso).toProperty("tso") + .map(storageInstId).toProperty("storageInstId") + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.134+08:00", + comments = "Source Table: binlog_semi_snapshot") + default int insertSelective(SemiSnapshotInfo record) { + return MyBatis3Utils.insert(this::insert, record, semiSnapshotInfo, c -> + c.map(id).toPropertyWhenPresent("id", record::getId) + .map(gmtCreated).toPropertyWhenPresent("gmtCreated", record::getGmtCreated) + .map(gmtModified).toPropertyWhenPresent("gmtModified", record::getGmtModified) + .map(tso).toPropertyWhenPresent("tso", record::getTso) + .map(storageInstId).toPropertyWhenPresent("storageInstId", record::getStorageInstId) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.136+08:00", + comments = "Source Table: binlog_semi_snapshot") + default Optional selectOne(SelectDSLCompleter completer) { + return MyBatis3Utils.selectOne(this::selectOne, selectList, semiSnapshotInfo, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.137+08:00", + comments = "Source Table: binlog_semi_snapshot") + default List select(SelectDSLCompleter completer) { + return MyBatis3Utils.selectList(this::selectMany, selectList, semiSnapshotInfo, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.138+08:00", + comments = "Source Table: binlog_semi_snapshot") + default List selectDistinct(SelectDSLCompleter completer) { + return MyBatis3Utils.selectDistinct(this::selectMany, selectList, semiSnapshotInfo, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.138+08:00", + comments = "Source Table: binlog_semi_snapshot") + default Optional selectByPrimaryKey(Long id_) { + return selectOne(c -> + c.where(id, isEqualTo(id_)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.139+08:00", + comments = "Source Table: binlog_semi_snapshot") + default int update(UpdateDSLCompleter completer) { + return MyBatis3Utils.update(this::update, semiSnapshotInfo, completer); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.139+08:00", + comments = "Source Table: binlog_semi_snapshot") + static UpdateDSL updateAllColumns(SemiSnapshotInfo record, UpdateDSL dsl) { + return dsl.set(id).equalTo(record::getId) + .set(gmtCreated).equalTo(record::getGmtCreated) + .set(gmtModified).equalTo(record::getGmtModified) + .set(tso).equalTo(record::getTso) + .set(storageInstId).equalTo(record::getStorageInstId); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.14+08:00", + comments = "Source Table: binlog_semi_snapshot") + static UpdateDSL updateSelectiveColumns(SemiSnapshotInfo record, UpdateDSL dsl) { + return dsl.set(id).equalToWhenPresent(record::getId) + .set(gmtCreated).equalToWhenPresent(record::getGmtCreated) + .set(gmtModified).equalToWhenPresent(record::getGmtModified) + .set(tso).equalToWhenPresent(record::getTso) + .set(storageInstId).equalToWhenPresent(record::getStorageInstId); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.141+08:00", + comments = "Source Table: binlog_semi_snapshot") + default int updateByPrimaryKey(SemiSnapshotInfo record) { + return update(c -> + c.set(gmtCreated).equalTo(record::getGmtCreated) + .set(gmtModified).equalTo(record::getGmtModified) + .set(tso).equalTo(record::getTso) + .set(storageInstId).equalTo(record::getStorageInstId) + .where(id, isEqualTo(record::getId)) + ); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.141+08:00", + comments = "Source Table: binlog_semi_snapshot") + default int updateByPrimaryKeySelective(SemiSnapshotInfo record) { + return update(c -> + c.set(gmtCreated).equalToWhenPresent(record::getGmtCreated) + .set(gmtModified).equalToWhenPresent(record::getGmtModified) + .set(tso).equalToWhenPresent(record::getTso) + .set(storageInstId).equalToWhenPresent(record::getStorageInstId) + .where(id, isEqualTo(record::getId)) + ); + } +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/BinlogLogicMetaHistory.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/BinlogLogicMetaHistory.java index b71c1af5..c7685acd 100644 --- a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/BinlogLogicMetaHistory.java +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/BinlogLogicMetaHistory.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.domain.po; import lombok.Builder; @@ -24,55 +7,63 @@ @Builder public class BinlogLogicMetaHistory { - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.169+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.178+08:00", comments = "Source field: binlog_logic_meta_history.id") private Integer id; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.169+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.178+08:00", comments = "Source field: binlog_logic_meta_history.gmt_created") private Date gmtCreated; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.169+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.179+08:00", comments = "Source field: binlog_logic_meta_history.gmt_modified") private Date gmtModified; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.179+08:00", comments = "Source field: binlog_logic_meta_history.tso") private String tso; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.179+08:00", comments = "Source field: binlog_logic_meta_history.db_name") private String dbName; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.179+08:00", comments = "Source field: binlog_logic_meta_history.table_name") private String tableName; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.179+08:00", comments = "Source field: binlog_logic_meta_history.sql_kind") private String sqlKind; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.18+08:00", comments = "Source field: binlog_logic_meta_history.type") private Byte type; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.18+08:00", + comments = "Source field: binlog_logic_meta_history.ddl_record_id") + private Long ddlRecordId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.18+08:00", + comments = "Source field: binlog_logic_meta_history.ddl_job_id") + private Long ddlJobId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.18+08:00", comments = "Source field: binlog_logic_meta_history.ddl") private String ddl; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.18+08:00", comments = "Source field: binlog_logic_meta_history.topology") private String topology; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.171+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.18+08:00", comments = "Source field: binlog_logic_meta_history.ext_info") private String extInfo; - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.166+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.174+08:00", comments = "Source Table: binlog_logic_meta_history") public BinlogLogicMetaHistory(Integer id, Date gmtCreated, Date gmtModified, String tso, String dbName, - String tableName, String sqlKind, Byte type, String ddl, String topology, - String extInfo) { + String tableName, String sqlKind, Byte type, Long ddlRecordId, Long ddlJobId, + String ddl, String topology, String extInfo) { this.id = id; this.gmtCreated = gmtCreated; this.gmtModified = gmtModified; @@ -81,144 +72,170 @@ public BinlogLogicMetaHistory(Integer id, Date gmtCreated, Date gmtModified, Str this.tableName = tableName; this.sqlKind = sqlKind; this.type = type; + this.ddlRecordId = ddlRecordId; + this.ddlJobId = ddlJobId; this.ddl = ddl; this.topology = topology; this.extInfo = extInfo; } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.168+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.177+08:00", comments = "Source Table: binlog_logic_meta_history") public BinlogLogicMetaHistory() { super(); } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.169+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.178+08:00", comments = "Source field: binlog_logic_meta_history.id") public Integer getId() { return id; } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.169+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.178+08:00", comments = "Source field: binlog_logic_meta_history.id") public void setId(Integer id) { this.id = id; } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.169+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.178+08:00", comments = "Source field: binlog_logic_meta_history.gmt_created") public Date getGmtCreated() { return gmtCreated; } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.169+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.179+08:00", comments = "Source field: binlog_logic_meta_history.gmt_created") public void setGmtCreated(Date gmtCreated) { this.gmtCreated = gmtCreated; } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.169+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.179+08:00", comments = "Source field: binlog_logic_meta_history.gmt_modified") public Date getGmtModified() { return gmtModified; } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.179+08:00", comments = "Source field: binlog_logic_meta_history.gmt_modified") public void setGmtModified(Date gmtModified) { this.gmtModified = gmtModified; } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.179+08:00", comments = "Source field: binlog_logic_meta_history.tso") public String getTso() { return tso; } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.179+08:00", comments = "Source field: binlog_logic_meta_history.tso") public void setTso(String tso) { this.tso = tso == null ? null : tso.trim(); } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.179+08:00", comments = "Source field: binlog_logic_meta_history.db_name") public String getDbName() { return dbName; } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.179+08:00", comments = "Source field: binlog_logic_meta_history.db_name") public void setDbName(String dbName) { this.dbName = dbName == null ? null : dbName.trim(); } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.179+08:00", comments = "Source field: binlog_logic_meta_history.table_name") public String getTableName() { return tableName; } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.179+08:00", comments = "Source field: binlog_logic_meta_history.table_name") public void setTableName(String tableName) { this.tableName = tableName == null ? null : tableName.trim(); } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.179+08:00", comments = "Source field: binlog_logic_meta_history.sql_kind") public String getSqlKind() { return sqlKind; } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.18+08:00", comments = "Source field: binlog_logic_meta_history.sql_kind") public void setSqlKind(String sqlKind) { this.sqlKind = sqlKind == null ? null : sqlKind.trim(); } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.18+08:00", comments = "Source field: binlog_logic_meta_history.type") public Byte getType() { return type; } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.18+08:00", comments = "Source field: binlog_logic_meta_history.type") public void setType(Byte type) { this.type = type; } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.18+08:00", + comments = "Source field: binlog_logic_meta_history.ddl_record_id") + public Long getDdlRecordId() { + return ddlRecordId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.18+08:00", + comments = "Source field: binlog_logic_meta_history.ddl_record_id") + public void setDdlRecordId(Long ddlRecordId) { + this.ddlRecordId = ddlRecordId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.18+08:00", + comments = "Source field: binlog_logic_meta_history.ddl_job_id") + public Long getDdlJobId() { + return ddlJobId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.18+08:00", + comments = "Source field: binlog_logic_meta_history.ddl_job_id") + public void setDdlJobId(Long ddlJobId) { + this.ddlJobId = ddlJobId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.18+08:00", comments = "Source field: binlog_logic_meta_history.ddl") public String getDdl() { return ddl; } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.18+08:00", comments = "Source field: binlog_logic_meta_history.ddl") public void setDdl(String ddl) { this.ddl = ddl == null ? null : ddl.trim(); } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.18+08:00", comments = "Source field: binlog_logic_meta_history.topology") public String getTopology() { return topology; } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.17+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.18+08:00", comments = "Source field: binlog_logic_meta_history.topology") public void setTopology(String topology) { this.topology = topology == null ? null : topology.trim(); } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.171+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.18+08:00", comments = "Source field: binlog_logic_meta_history.ext_info") public String getExtInfo() { return extInfo; } - @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-03T16:05:49.171+08:00", + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-03-10T17:59:36.181+08:00", comments = "Source field: binlog_logic_meta_history.ext_info") public void setExtInfo(String extInfo) { this.extInfo = extInfo == null ? null : extInfo.trim(); diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/PolarxCNodeInfo.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/PolarxCNodeInfo.java new file mode 100644 index 00000000..32af576d --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/PolarxCNodeInfo.java @@ -0,0 +1,239 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.domain.po; + +import java.util.Date; +import javax.annotation.Generated; + +public class PolarxCNodeInfo { + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.069+08:00", + comments = "Source field: node_info.id") + private Long id; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.069+08:00", + comments = "Source field: node_info.cluster") + private String cluster; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.07+08:00", + comments = "Source field: node_info.inst_id") + private String instId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.07+08:00", + comments = "Source field: node_info.nodeid") + private String nodeid; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.07+08:00", + comments = "Source field: node_info.version") + private String version; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.07+08:00", + comments = "Source field: node_info.ip") + private String ip; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.071+08:00", + comments = "Source field: node_info.port") + private Integer port; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.071+08:00", + comments = "Source field: node_info.rpc_port") + private Long rpcPort; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.071+08:00", + comments = "Source field: node_info.role") + private Long role; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.071+08:00", + comments = "Source field: node_info.status") + private Long status; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.072+08:00", + comments = "Source field: node_info.gmt_created") + private Date gmtCreated; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.072+08:00", + comments = "Source field: node_info.gmt_modified") + private Date gmtModified; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.064+08:00", + comments = "Source Table: node_info") + public PolarxCNodeInfo(Long id, String cluster, String instId, String nodeid, String version, String ip, + Integer port, Long rpcPort, Long role, Long status, Date gmtCreated, Date gmtModified) { + this.id = id; + this.cluster = cluster; + this.instId = instId; + this.nodeid = nodeid; + this.version = version; + this.ip = ip; + this.port = port; + this.rpcPort = rpcPort; + this.role = role; + this.status = status; + this.gmtCreated = gmtCreated; + this.gmtModified = gmtModified; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.068+08:00", + comments = "Source Table: node_info") + public PolarxCNodeInfo() { + super(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.069+08:00", + comments = "Source field: node_info.id") + public Long getId() { + return id; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.069+08:00", + comments = "Source field: node_info.id") + public void setId(Long id) { + this.id = id; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.069+08:00", + comments = "Source field: node_info.cluster") + public String getCluster() { + return cluster; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.07+08:00", + comments = "Source field: node_info.cluster") + public void setCluster(String cluster) { + this.cluster = cluster == null ? null : cluster.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.07+08:00", + comments = "Source field: node_info.inst_id") + public String getInstId() { + return instId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.07+08:00", + comments = "Source field: node_info.inst_id") + public void setInstId(String instId) { + this.instId = instId == null ? null : instId.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.07+08:00", + comments = "Source field: node_info.nodeid") + public String getNodeid() { + return nodeid; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.07+08:00", + comments = "Source field: node_info.nodeid") + public void setNodeid(String nodeid) { + this.nodeid = nodeid == null ? null : nodeid.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.07+08:00", + comments = "Source field: node_info.version") + public String getVersion() { + return version; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.07+08:00", + comments = "Source field: node_info.version") + public void setVersion(String version) { + this.version = version == null ? null : version.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.07+08:00", + comments = "Source field: node_info.ip") + public String getIp() { + return ip; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.071+08:00", + comments = "Source field: node_info.ip") + public void setIp(String ip) { + this.ip = ip == null ? null : ip.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.071+08:00", + comments = "Source field: node_info.port") + public Integer getPort() { + return port; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.071+08:00", + comments = "Source field: node_info.port") + public void setPort(Integer port) { + this.port = port; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.071+08:00", + comments = "Source field: node_info.rpc_port") + public Long getRpcPort() { + return rpcPort; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.071+08:00", + comments = "Source field: node_info.rpc_port") + public void setRpcPort(Long rpcPort) { + this.rpcPort = rpcPort; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.071+08:00", + comments = "Source field: node_info.role") + public Long getRole() { + return role; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.071+08:00", + comments = "Source field: node_info.role") + public void setRole(Long role) { + this.role = role; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.072+08:00", + comments = "Source field: node_info.status") + public Long getStatus() { + return status; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.072+08:00", + comments = "Source field: node_info.status") + public void setStatus(Long status) { + this.status = status; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.072+08:00", + comments = "Source field: node_info.gmt_created") + public Date getGmtCreated() { + return gmtCreated; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.072+08:00", + comments = "Source field: node_info.gmt_created") + public void setGmtCreated(Date gmtCreated) { + this.gmtCreated = gmtCreated; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.072+08:00", + comments = "Source field: node_info.gmt_modified") + public Date getGmtModified() { + return gmtModified; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-04-19T14:22:59.072+08:00", + comments = "Source field: node_info.gmt_modified") + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/RplDdl.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/RplDdl.java new file mode 100644 index 00000000..361087f1 --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/RplDdl.java @@ -0,0 +1,205 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.domain.po; + +import java.util.Date; +import javax.annotation.Generated; + +public class RplDdl { + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.759+08:00", + comments = "Source field: rpl_ddl.id") + private Long id; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.759+08:00", + comments = "Source field: rpl_ddl.gmt_created") + private Date gmtCreated; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.759+08:00", + comments = "Source field: rpl_ddl.gmt_modified") + private Date gmtModified; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.759+08:00", + comments = "Source field: rpl_ddl.state_machine_id") + private Long stateMachineId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.759+08:00", + comments = "Source field: rpl_ddl.service_id") + private Long serviceId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.759+08:00", + comments = "Source field: rpl_ddl.task_id") + private Long taskId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.76+08:00", + comments = "Source field: rpl_ddl.ddl_tso") + private String ddlTso; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.76+08:00", + comments = "Source field: rpl_ddl.job_id") + private Long jobId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.761+08:00", + comments = "Source field: rpl_ddl.state") + private Integer state; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.761+08:00", + comments = "Source field: rpl_ddl.ddl_stmt") + private String ddlStmt; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.758+08:00", + comments = "Source Table: rpl_ddl") + public RplDdl(Long id, Date gmtCreated, Date gmtModified, Long stateMachineId, Long serviceId, Long taskId, + String ddlTso, Long jobId, Integer state, String ddlStmt) { + this.id = id; + this.gmtCreated = gmtCreated; + this.gmtModified = gmtModified; + this.stateMachineId = stateMachineId; + this.serviceId = serviceId; + this.taskId = taskId; + this.ddlTso = ddlTso; + this.jobId = jobId; + this.state = state; + this.ddlStmt = ddlStmt; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.759+08:00", + comments = "Source Table: rpl_ddl") + public RplDdl() { + super(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.759+08:00", + comments = "Source field: rpl_ddl.id") + public Long getId() { + return id; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.759+08:00", + comments = "Source field: rpl_ddl.id") + public void setId(Long id) { + this.id = id; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.759+08:00", + comments = "Source field: rpl_ddl.gmt_created") + public Date getGmtCreated() { + return gmtCreated; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.759+08:00", + comments = "Source field: rpl_ddl.gmt_created") + public void setGmtCreated(Date gmtCreated) { + this.gmtCreated = gmtCreated; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.759+08:00", + comments = "Source field: rpl_ddl.gmt_modified") + public Date getGmtModified() { + return gmtModified; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.759+08:00", + comments = "Source field: rpl_ddl.gmt_modified") + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.759+08:00", + comments = "Source field: rpl_ddl.state_machine_id") + public Long getStateMachineId() { + return stateMachineId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.759+08:00", + comments = "Source field: rpl_ddl.state_machine_id") + public void setStateMachineId(Long stateMachineId) { + this.stateMachineId = stateMachineId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.759+08:00", + comments = "Source field: rpl_ddl.service_id") + public Long getServiceId() { + return serviceId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.759+08:00", + comments = "Source field: rpl_ddl.service_id") + public void setServiceId(Long serviceId) { + this.serviceId = serviceId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.76+08:00", + comments = "Source field: rpl_ddl.task_id") + public Long getTaskId() { + return taskId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.76+08:00", + comments = "Source field: rpl_ddl.task_id") + public void setTaskId(Long taskId) { + this.taskId = taskId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.76+08:00", + comments = "Source field: rpl_ddl.ddl_tso") + public String getDdlTso() { + return ddlTso; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.76+08:00", + comments = "Source field: rpl_ddl.ddl_tso") + public void setDdlTso(String ddlTso) { + this.ddlTso = ddlTso == null ? null : ddlTso.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.76+08:00", + comments = "Source field: rpl_ddl.job_id") + public Long getJobId() { + return jobId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.761+08:00", + comments = "Source field: rpl_ddl.job_id") + public void setJobId(Long jobId) { + this.jobId = jobId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.761+08:00", + comments = "Source field: rpl_ddl.state") + public Integer getState() { + return state; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.761+08:00", + comments = "Source field: rpl_ddl.state") + public void setState(Integer state) { + this.state = state; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.761+08:00", + comments = "Source field: rpl_ddl.ddl_stmt") + public String getDdlStmt() { + return ddlStmt; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.761+08:00", + comments = "Source field: rpl_ddl.ddl_stmt") + public void setDdlStmt(String ddlStmt) { + this.ddlStmt = ddlStmt == null ? null : ddlStmt.trim(); + } +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/RplService.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/RplService.java new file mode 100644 index 00000000..f1d9424e --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/RplService.java @@ -0,0 +1,171 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.domain.po; + +import java.util.Date; +import javax.annotation.Generated; + +public class RplService { + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.856+08:00", + comments = "Source field: rpl_service.id") + private Long id; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.857+08:00", + comments = "Source field: rpl_service.gmt_created") + private Date gmtCreated; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.857+08:00", + comments = "Source field: rpl_service.gmt_modified") + private Date gmtModified; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.858+08:00", + comments = "Source field: rpl_service.state_machine_id") + private Long stateMachineId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.858+08:00", + comments = "Source field: rpl_service.service_type") + private Integer serviceType; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.858+08:00", + comments = "Source field: rpl_service.state_list") + private String stateList; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.858+08:00", + comments = "Source field: rpl_service.channel") + private String channel; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.858+08:00", + comments = "Source field: rpl_service.status") + private Integer status; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.853+08:00", + comments = "Source Table: rpl_service") + public RplService(Long id, Date gmtCreated, Date gmtModified, Long stateMachineId, Integer serviceType, + String stateList, String channel, Integer status) { + this.id = id; + this.gmtCreated = gmtCreated; + this.gmtModified = gmtModified; + this.stateMachineId = stateMachineId; + this.serviceType = serviceType; + this.stateList = stateList; + this.channel = channel; + this.status = status; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.856+08:00", + comments = "Source Table: rpl_service") + public RplService() { + super(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.857+08:00", + comments = "Source field: rpl_service.id") + public Long getId() { + return id; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.857+08:00", + comments = "Source field: rpl_service.id") + public void setId(Long id) { + this.id = id; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.857+08:00", + comments = "Source field: rpl_service.gmt_created") + public Date getGmtCreated() { + return gmtCreated; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.857+08:00", + comments = "Source field: rpl_service.gmt_created") + public void setGmtCreated(Date gmtCreated) { + this.gmtCreated = gmtCreated; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.857+08:00", + comments = "Source field: rpl_service.gmt_modified") + public Date getGmtModified() { + return gmtModified; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.857+08:00", + comments = "Source field: rpl_service.gmt_modified") + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.858+08:00", + comments = "Source field: rpl_service.state_machine_id") + public Long getStateMachineId() { + return stateMachineId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.858+08:00", + comments = "Source field: rpl_service.state_machine_id") + public void setStateMachineId(Long stateMachineId) { + this.stateMachineId = stateMachineId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.858+08:00", + comments = "Source field: rpl_service.service_type") + public Integer getServiceType() { + return serviceType; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.858+08:00", + comments = "Source field: rpl_service.service_type") + public void setServiceType(Integer serviceType) { + this.serviceType = serviceType; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.858+08:00", + comments = "Source field: rpl_service.state_list") + public String getStateList() { + return stateList; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.858+08:00", + comments = "Source field: rpl_service.state_list") + public void setStateList(String stateList) { + this.stateList = stateList == null ? null : stateList.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.858+08:00", + comments = "Source field: rpl_service.channel") + public String getChannel() { + return channel; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.858+08:00", + comments = "Source field: rpl_service.channel") + public void setChannel(String channel) { + this.channel = channel == null ? null : channel.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.858+08:00", + comments = "Source field: rpl_service.status") + public Integer getStatus() { + return status; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-09-18T17:45:40.858+08:00", + comments = "Source field: rpl_service.status") + public void setStatus(Integer status) { + this.status = status; + } +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/RplStateMachine.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/RplStateMachine.java new file mode 100644 index 00000000..e125e604 --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/RplStateMachine.java @@ -0,0 +1,222 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.domain.po; + +import java.util.Date; +import javax.annotation.Generated; + +public class RplStateMachine { + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.715+08:00", + comments = "Source field: rpl_state_machine.id") + private Long id; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.717+08:00", + comments = "Source field: rpl_state_machine.gmt_created") + private Date gmtCreated; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.717+08:00", + comments = "Source field: rpl_state_machine.gmt_modified") + private Date gmtModified; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.717+08:00", + comments = "Source field: rpl_state_machine.type") + private Integer type; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.717+08:00", + comments = "Source field: rpl_state_machine.class_name") + private String className; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.717+08:00", + comments = "Source field: rpl_state_machine.channel") + private String channel; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.718+08:00", + comments = "Source field: rpl_state_machine.status") + private Integer status; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.718+08:00", + comments = "Source field: rpl_state_machine.state") + private Integer state; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.718+08:00", + comments = "Source field: rpl_state_machine.cluster_id") + private String clusterId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.718+08:00", + comments = "Source field: rpl_state_machine.config") + private String config; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.718+08:00", + comments = "Source field: rpl_state_machine.context") + private String context; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.705+08:00", + comments = "Source Table: rpl_state_machine") + public RplStateMachine(Long id, Date gmtCreated, Date gmtModified, Integer type, String className, String channel, + Integer status, Integer state, String clusterId, String config, String context) { + this.id = id; + this.gmtCreated = gmtCreated; + this.gmtModified = gmtModified; + this.type = type; + this.className = className; + this.channel = channel; + this.status = status; + this.state = state; + this.clusterId = clusterId; + this.config = config; + this.context = context; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.715+08:00", + comments = "Source Table: rpl_state_machine") + public RplStateMachine() { + super(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.717+08:00", + comments = "Source field: rpl_state_machine.id") + public Long getId() { + return id; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.717+08:00", + comments = "Source field: rpl_state_machine.id") + public void setId(Long id) { + this.id = id; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.717+08:00", + comments = "Source field: rpl_state_machine.gmt_created") + public Date getGmtCreated() { + return gmtCreated; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.717+08:00", + comments = "Source field: rpl_state_machine.gmt_created") + public void setGmtCreated(Date gmtCreated) { + this.gmtCreated = gmtCreated; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.717+08:00", + comments = "Source field: rpl_state_machine.gmt_modified") + public Date getGmtModified() { + return gmtModified; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.717+08:00", + comments = "Source field: rpl_state_machine.gmt_modified") + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.717+08:00", + comments = "Source field: rpl_state_machine.type") + public Integer getType() { + return type; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.717+08:00", + comments = "Source field: rpl_state_machine.type") + public void setType(Integer type) { + this.type = type; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.717+08:00", + comments = "Source field: rpl_state_machine.class_name") + public String getClassName() { + return className; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.717+08:00", + comments = "Source field: rpl_state_machine.class_name") + public void setClassName(String className) { + this.className = className == null ? null : className.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.717+08:00", + comments = "Source field: rpl_state_machine.channel") + public String getChannel() { + return channel; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.718+08:00", + comments = "Source field: rpl_state_machine.channel") + public void setChannel(String channel) { + this.channel = channel == null ? null : channel.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.718+08:00", + comments = "Source field: rpl_state_machine.status") + public Integer getStatus() { + return status; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.718+08:00", + comments = "Source field: rpl_state_machine.status") + public void setStatus(Integer status) { + this.status = status; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.718+08:00", + comments = "Source field: rpl_state_machine.state") + public Integer getState() { + return state; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.718+08:00", + comments = "Source field: rpl_state_machine.state") + public void setState(Integer state) { + this.state = state; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.718+08:00", + comments = "Source field: rpl_state_machine.cluster_id") + public String getClusterId() { + return clusterId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.718+08:00", + comments = "Source field: rpl_state_machine.cluster_id") + public void setClusterId(String clusterId) { + this.clusterId = clusterId == null ? null : clusterId.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.718+08:00", + comments = "Source field: rpl_state_machine.config") + public String getConfig() { + return config; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.718+08:00", + comments = "Source field: rpl_state_machine.config") + public void setConfig(String config) { + this.config = config == null ? null : config.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.718+08:00", + comments = "Source field: rpl_state_machine.context") + public String getContext() { + return context; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-12-01T14:20:15.719+08:00", + comments = "Source field: rpl_state_machine.context") + public void setContext(String context) { + this.context = context == null ? null : context.trim(); + } +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/RplTablePosition.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/RplTablePosition.java new file mode 100644 index 00000000..34f43c35 --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/RplTablePosition.java @@ -0,0 +1,171 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.domain.po; + +import java.util.Date; +import javax.annotation.Generated; + +public class RplTablePosition { + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.918+08:00", + comments = "Source field: rpl_table_position.id") + private Long id; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.92+08:00", + comments = "Source field: rpl_table_position.gmt_created") + private Date gmtCreated; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.92+08:00", + comments = "Source field: rpl_table_position.gmt_modified") + private Date gmtModified; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.92+08:00", + comments = "Source field: rpl_table_position.state_machine_id") + private Long stateMachineId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.92+08:00", + comments = "Source field: rpl_table_position.service_id") + private Long serviceId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.92+08:00", + comments = "Source field: rpl_table_position.task_id") + private Long taskId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.92+08:00", + comments = "Source field: rpl_table_position.full_table_name") + private String fullTableName; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.921+08:00", + comments = "Source field: rpl_table_position.position") + private String position; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.918+08:00", + comments = "Source Table: rpl_table_position") + public RplTablePosition(Long id, Date gmtCreated, Date gmtModified, Long stateMachineId, Long serviceId, + Long taskId, String fullTableName, String position) { + this.id = id; + this.gmtCreated = gmtCreated; + this.gmtModified = gmtModified; + this.stateMachineId = stateMachineId; + this.serviceId = serviceId; + this.taskId = taskId; + this.fullTableName = fullTableName; + this.position = position; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.918+08:00", + comments = "Source Table: rpl_table_position") + public RplTablePosition() { + super(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.92+08:00", + comments = "Source field: rpl_table_position.id") + public Long getId() { + return id; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.92+08:00", + comments = "Source field: rpl_table_position.id") + public void setId(Long id) { + this.id = id; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.92+08:00", + comments = "Source field: rpl_table_position.gmt_created") + public Date getGmtCreated() { + return gmtCreated; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.92+08:00", + comments = "Source field: rpl_table_position.gmt_created") + public void setGmtCreated(Date gmtCreated) { + this.gmtCreated = gmtCreated; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.92+08:00", + comments = "Source field: rpl_table_position.gmt_modified") + public Date getGmtModified() { + return gmtModified; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.92+08:00", + comments = "Source field: rpl_table_position.gmt_modified") + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.92+08:00", + comments = "Source field: rpl_table_position.state_machine_id") + public Long getStateMachineId() { + return stateMachineId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.92+08:00", + comments = "Source field: rpl_table_position.state_machine_id") + public void setStateMachineId(Long stateMachineId) { + this.stateMachineId = stateMachineId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.92+08:00", + comments = "Source field: rpl_table_position.service_id") + public Long getServiceId() { + return serviceId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.92+08:00", + comments = "Source field: rpl_table_position.service_id") + public void setServiceId(Long serviceId) { + this.serviceId = serviceId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.92+08:00", + comments = "Source field: rpl_table_position.task_id") + public Long getTaskId() { + return taskId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.92+08:00", + comments = "Source field: rpl_table_position.task_id") + public void setTaskId(Long taskId) { + this.taskId = taskId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.92+08:00", + comments = "Source field: rpl_table_position.full_table_name") + public String getFullTableName() { + return fullTableName; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.921+08:00", + comments = "Source field: rpl_table_position.full_table_name") + public void setFullTableName(String fullTableName) { + this.fullTableName = fullTableName == null ? null : fullTableName.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.921+08:00", + comments = "Source field: rpl_table_position.position") + public String getPosition() { + return position; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-08-19T17:32:16.921+08:00", + comments = "Source field: rpl_table_position.position") + public void setPosition(String position) { + this.position = position == null ? null : position.trim(); + } +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/RplTask.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/RplTask.java new file mode 100644 index 00000000..30e90efd --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/RplTask.java @@ -0,0 +1,360 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.domain.po; + +import java.util.Date; +import javax.annotation.Generated; + +public class RplTask { + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.18+08:00", + comments = "Source field: rpl_task.id") + private Long id; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.182+08:00", + comments = "Source field: rpl_task.gmt_created") + private Date gmtCreated; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.182+08:00", + comments = "Source field: rpl_task.gmt_modified") + private Date gmtModified; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.182+08:00", + comments = "Source field: rpl_task.gmt_heartbeat") + private Date gmtHeartbeat; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.182+08:00", + comments = "Source field: rpl_task.status") + private Integer status; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.182+08:00", + comments = "Source field: rpl_task.service_id") + private Long serviceId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.183+08:00", + comments = "Source field: rpl_task.state_machine_id") + private Long stateMachineId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.183+08:00", + comments = "Source field: rpl_task.type") + private Integer type; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.183+08:00", + comments = "Source field: rpl_task.master_host") + private String masterHost; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.184+08:00", + comments = "Source field: rpl_task.master_port") + private Integer masterPort; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.184+08:00", + comments = "Source field: rpl_task.position") + private String position; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.184+08:00", + comments = "Source field: rpl_task.worker") + private String worker; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.184+08:00", + comments = "Source field: rpl_task.cluster_id") + private String clusterId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.185+08:00", + comments = "Source field: rpl_task.extractor_config") + private String extractorConfig; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.185+08:00", + comments = "Source field: rpl_task.pipeline_config") + private String pipelineConfig; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.185+08:00", + comments = "Source field: rpl_task.applier_config") + private String applierConfig; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.186+08:00", + comments = "Source field: rpl_task.last_error") + private String lastError; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.186+08:00", + comments = "Source field: rpl_task.statistic") + private String statistic; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.186+08:00", + comments = "Source field: rpl_task.extra") + private String extra; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.171+08:00", + comments = "Source Table: rpl_task") + public RplTask(Long id, Date gmtCreated, Date gmtModified, Date gmtHeartbeat, Integer status, Long serviceId, + Long stateMachineId, Integer type, String masterHost, Integer masterPort, String position, + String worker, String clusterId, String extractorConfig, String pipelineConfig, String applierConfig, + String lastError, String statistic, String extra) { + this.id = id; + this.gmtCreated = gmtCreated; + this.gmtModified = gmtModified; + this.gmtHeartbeat = gmtHeartbeat; + this.status = status; + this.serviceId = serviceId; + this.stateMachineId = stateMachineId; + this.type = type; + this.masterHost = masterHost; + this.masterPort = masterPort; + this.position = position; + this.worker = worker; + this.clusterId = clusterId; + this.extractorConfig = extractorConfig; + this.pipelineConfig = pipelineConfig; + this.applierConfig = applierConfig; + this.lastError = lastError; + this.statistic = statistic; + this.extra = extra; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.18+08:00", + comments = "Source Table: rpl_task") + public RplTask() { + super(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.182+08:00", + comments = "Source field: rpl_task.id") + public Long getId() { + return id; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.182+08:00", + comments = "Source field: rpl_task.id") + public void setId(Long id) { + this.id = id; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.182+08:00", + comments = "Source field: rpl_task.gmt_created") + public Date getGmtCreated() { + return gmtCreated; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.182+08:00", + comments = "Source field: rpl_task.gmt_created") + public void setGmtCreated(Date gmtCreated) { + this.gmtCreated = gmtCreated; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.182+08:00", + comments = "Source field: rpl_task.gmt_modified") + public Date getGmtModified() { + return gmtModified; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.182+08:00", + comments = "Source field: rpl_task.gmt_modified") + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.182+08:00", + comments = "Source field: rpl_task.gmt_heartbeat") + public Date getGmtHeartbeat() { + return gmtHeartbeat; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.182+08:00", + comments = "Source field: rpl_task.gmt_heartbeat") + public void setGmtHeartbeat(Date gmtHeartbeat) { + this.gmtHeartbeat = gmtHeartbeat; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.182+08:00", + comments = "Source field: rpl_task.status") + public Integer getStatus() { + return status; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.182+08:00", + comments = "Source field: rpl_task.status") + public void setStatus(Integer status) { + this.status = status; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.183+08:00", + comments = "Source field: rpl_task.service_id") + public Long getServiceId() { + return serviceId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.183+08:00", + comments = "Source field: rpl_task.service_id") + public void setServiceId(Long serviceId) { + this.serviceId = serviceId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.183+08:00", + comments = "Source field: rpl_task.state_machine_id") + public Long getStateMachineId() { + return stateMachineId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.183+08:00", + comments = "Source field: rpl_task.state_machine_id") + public void setStateMachineId(Long stateMachineId) { + this.stateMachineId = stateMachineId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.183+08:00", + comments = "Source field: rpl_task.type") + public Integer getType() { + return type; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.183+08:00", + comments = "Source field: rpl_task.type") + public void setType(Integer type) { + this.type = type; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.183+08:00", + comments = "Source field: rpl_task.master_host") + public String getMasterHost() { + return masterHost; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.184+08:00", + comments = "Source field: rpl_task.master_host") + public void setMasterHost(String masterHost) { + this.masterHost = masterHost == null ? null : masterHost.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.184+08:00", + comments = "Source field: rpl_task.master_port") + public Integer getMasterPort() { + return masterPort; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.184+08:00", + comments = "Source field: rpl_task.master_port") + public void setMasterPort(Integer masterPort) { + this.masterPort = masterPort; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.184+08:00", + comments = "Source field: rpl_task.position") + public String getPosition() { + return position; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.184+08:00", + comments = "Source field: rpl_task.position") + public void setPosition(String position) { + this.position = position == null ? null : position.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.184+08:00", + comments = "Source field: rpl_task.worker") + public String getWorker() { + return worker; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.184+08:00", + comments = "Source field: rpl_task.worker") + public void setWorker(String worker) { + this.worker = worker == null ? null : worker.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.185+08:00", + comments = "Source field: rpl_task.cluster_id") + public String getClusterId() { + return clusterId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.185+08:00", + comments = "Source field: rpl_task.cluster_id") + public void setClusterId(String clusterId) { + this.clusterId = clusterId == null ? null : clusterId.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.185+08:00", + comments = "Source field: rpl_task.extractor_config") + public String getExtractorConfig() { + return extractorConfig; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.185+08:00", + comments = "Source field: rpl_task.extractor_config") + public void setExtractorConfig(String extractorConfig) { + this.extractorConfig = extractorConfig == null ? null : extractorConfig.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.185+08:00", + comments = "Source field: rpl_task.pipeline_config") + public String getPipelineConfig() { + return pipelineConfig; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.185+08:00", + comments = "Source field: rpl_task.pipeline_config") + public void setPipelineConfig(String pipelineConfig) { + this.pipelineConfig = pipelineConfig == null ? null : pipelineConfig.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.186+08:00", + comments = "Source field: rpl_task.applier_config") + public String getApplierConfig() { + return applierConfig; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.186+08:00", + comments = "Source field: rpl_task.applier_config") + public void setApplierConfig(String applierConfig) { + this.applierConfig = applierConfig == null ? null : applierConfig.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.186+08:00", + comments = "Source field: rpl_task.last_error") + public String getLastError() { + return lastError; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.186+08:00", + comments = "Source field: rpl_task.last_error") + public void setLastError(String lastError) { + this.lastError = lastError == null ? null : lastError.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.186+08:00", + comments = "Source field: rpl_task.statistic") + public String getStatistic() { + return statistic; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.186+08:00", + comments = "Source field: rpl_task.statistic") + public void setStatistic(String statistic) { + this.statistic = statistic == null ? null : statistic.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.186+08:00", + comments = "Source field: rpl_task.extra") + public String getExtra() { + return extra; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2021-11-30T17:10:06.187+08:00", + comments = "Source field: rpl_task.extra") + public void setExtra(String extra) { + this.extra = extra == null ? null : extra.trim(); + } +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/SemiSnapshotInfo.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/SemiSnapshotInfo.java new file mode 100644 index 00000000..2711d8f1 --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/domain/po/SemiSnapshotInfo.java @@ -0,0 +1,102 @@ +package com.aliyun.polardbx.binlog.domain.po; + +import javax.annotation.Generated; +import java.util.Date; + +public class SemiSnapshotInfo { + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.12+08:00", + comments = "Source field: binlog_semi_snapshot.id") + private Long id; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.12+08:00", + comments = "Source field: binlog_semi_snapshot.gmt_created") + private Date gmtCreated; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.12+08:00", + comments = "Source field: binlog_semi_snapshot.gmt_modified") + private Date gmtModified; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.12+08:00", + comments = "Source field: binlog_semi_snapshot.tso") + private String tso; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.121+08:00", + comments = "Source field: binlog_semi_snapshot.storage_inst_id") + private String storageInstId; + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.117+08:00", + comments = "Source Table: binlog_semi_snapshot") + public SemiSnapshotInfo(Long id, Date gmtCreated, Date gmtModified, String tso, String storageInstId) { + this.id = id; + this.gmtCreated = gmtCreated; + this.gmtModified = gmtModified; + this.tso = tso; + this.storageInstId = storageInstId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.119+08:00", + comments = "Source Table: binlog_semi_snapshot") + public SemiSnapshotInfo() { + super(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.12+08:00", + comments = "Source field: binlog_semi_snapshot.id") + public Long getId() { + return id; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.12+08:00", + comments = "Source field: binlog_semi_snapshot.id") + public void setId(Long id) { + this.id = id; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.12+08:00", + comments = "Source field: binlog_semi_snapshot.gmt_created") + public Date getGmtCreated() { + return gmtCreated; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.12+08:00", + comments = "Source field: binlog_semi_snapshot.gmt_created") + public void setGmtCreated(Date gmtCreated) { + this.gmtCreated = gmtCreated; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.12+08:00", + comments = "Source field: binlog_semi_snapshot.gmt_modified") + public Date getGmtModified() { + return gmtModified; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.12+08:00", + comments = "Source field: binlog_semi_snapshot.gmt_modified") + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.121+08:00", + comments = "Source field: binlog_semi_snapshot.tso") + public String getTso() { + return tso; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.121+08:00", + comments = "Source field: binlog_semi_snapshot.tso") + public void setTso(String tso) { + this.tso = tso == null ? null : tso.trim(); + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.121+08:00", + comments = "Source field: binlog_semi_snapshot.storage_inst_id") + public String getStorageInstId() { + return storageInstId; + } + + @Generated(value = "org.mybatis.generator.api.MyBatisGenerator", date = "2022-02-14T10:39:59.121+08:00", + comments = "Source field: binlog_semi_snapshot.storage_inst_id") + public void setStorageInstId(String storageInstId) { + this.storageInstId = storageInstId == null ? null : storageInstId.trim(); + } +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/util/HexUtil.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/util/HexUtil.java new file mode 100644 index 00000000..6024df1d --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/util/HexUtil.java @@ -0,0 +1,446 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.util; + +import org.apache.commons.lang3.StringUtils; + +import java.awt.*; +import java.math.BigInteger; +import java.nio.charset.Charset; + +/** + * 十六进制(简写为hex或下标16)在数学中是一种逢16进1的进位制,一般用数字0到9和字母A到F表示(其中:A~F即10~15)。
+ * 例如十进制数57,在二进制写作111001,在16进制写作39。
+ * 像java,c这样的语言为了区分十六进制和十进制数值,会在十六进制数的前面加上 0x,比如0x20是十进制的32,而不是十进制的20
+ *

+ * 参考:https://my.oschina.net/xinxingegeya/blog/287476 + * + * @author Looly + */ +public class HexUtil { + + /** + * 用于建立十六进制字符的输出的小写字符数组 + */ + private static final char[] DIGITS_LOWER = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', + 'e', 'f'}; + /** + * 用于建立十六进制字符的输出的大写字符数组 + */ + private static final char[] DIGITS_UPPER = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', + 'E', 'F'}; + + /** + * 判断给定字符串是否为16进制数
+ * 如果是,需要使用对应数字类型对象的decode方法解码
+ * 例如:{@code Integer.decode}方法解码int类型的16进制数字 + * + * @param value 值 + * @return 是否为16进制 + */ + public static boolean isHexNumber(String value) { + final int index = (value.startsWith("-") ? 1 : 0); + if (value.startsWith("0x", index) || value.startsWith("0X", index) || value.startsWith("#", index)) { + try { + //noinspection ResultOfMethodCallIgnored + Long.decode(value); + } catch (NumberFormatException e) { + return false; + } + return true; + } + + return false; + } + + // ---------------------------------------------------------------------------------------------------- encode + + /** + * 将字节数组转换为十六进制字符数组 + * + * @param data byte[] + * @return 十六进制char[] + */ + public static char[] encodeHex(byte[] data) { + return encodeHex(data, true); + } + + /** + * 将字节数组转换为十六进制字符数组 + * + * @param str 字符串 + * @param charset 编码 + * @return 十六进制char[] + */ + public static char[] encodeHex(String str, Charset charset) { + return encodeHex(str.getBytes(charset), true); + } + + /** + * 将字节数组转换为十六进制字符数组 + * + * @param data byte[] + * @param toLowerCase true 传换成小写格式 , false 传换成大写格式 + * @return 十六进制char[] + */ + public static char[] encodeHex(byte[] data, boolean toLowerCase) { + return encodeHex(data, toLowerCase ? DIGITS_LOWER : DIGITS_UPPER); + } + + /** + * 将字节数组转换为十六进制字符串 + * + * @param data byte[] + * @return 十六进制String + */ + public static String encodeHexStr(byte[] data) { + return encodeHexStr(data, true); + } + + /** + * 将字符串转换为十六进制字符串,结果为小写 + * + * @param data 需要被编码的字符串 + * @param charset 编码 + * @return 十六进制String + */ + public static String encodeHexStr(String data, Charset charset) { + return encodeHexStr(data.getBytes(charset), true); + } + + /** + * 将字符串转换为十六进制字符串,结果为小写,默认编码是UTF-8 + * + * @param data 被编码的字符串 + * @return 十六进制String + */ + public static String encodeHexStr(String data) { + return encodeHexStr(data, Charset.defaultCharset()); + } + + /** + * 将字节数组转换为十六进制字符串 + * + * @param data byte[] + * @param toLowerCase true 传换成小写格式 , false 传换成大写格式 + * @return 十六进制String + */ + public static String encodeHexStr(byte[] data, boolean toLowerCase) { + return encodeHexStr(data, toLowerCase ? DIGITS_LOWER : DIGITS_UPPER); + } + + // ---------------------------------------------------------------------------------------------------- decode + + /** + * 将十六进制字符数组转换为字符串,默认编码UTF-8 + * + * @param hexStr 十六进制String + * @return 字符串 + */ + public static String decodeHexStr(String hexStr) { + return decodeHexStr(hexStr, Charset.defaultCharset()); + } + + /** + * 将十六进制字符数组转换为字符串 + * + * @param hexStr 十六进制String + * @param charset 编码 + * @return 字符串 + */ + public static String decodeHexStr(String hexStr, Charset charset) { + if (StringUtils.isEmpty(hexStr)) { + return hexStr; + } + return decodeHexStr(hexStr.toCharArray(), charset); + } + + /** + * 将十六进制字符数组转换为字符串 + * + * @param hexData 十六进制char[] + * @param charset 编码 + * @return 字符串 + */ + public static String decodeHexStr(char[] hexData, Charset charset) { + return new String(decodeHex(hexData), charset); + } + + /** + * 将十六进制字符数组转换为字节数组 + * + * @param hexData 十六进制char[] + * @return byte[] + * @throws RuntimeException 如果源十六进制字符数组是一个奇怪的长度,将抛出运行时异常 + */ + public static byte[] decodeHex(char[] hexData) { + + int len = hexData.length; + + if ((len & 0x01) != 0) { + throw new RuntimeException("Odd number of characters."); + } + + byte[] out = new byte[len >> 1]; + + // two characters form the hex value. + for (int i = 0, j = 0; j < len; i++) { + int f = toDigit(hexData[j], j) << 4; + j++; + f = f | toDigit(hexData[j], j); + j++; + out[i] = (byte) (f & 0xFF); + } + + return out; + } + + /** + * 将十六进制字符串解码为byte[] + * + * @param hexStr 十六进制String + * @return byte[] + */ + public static byte[] decodeHex(String hexStr) { + if (StringUtils.isEmpty(hexStr)) { + return null; + } + + return decodeHex(hexStr.toCharArray()); + } + + // ---------------------------------------------------------------------------------------- Color + + /** + * 将{@link Color}编码为Hex形式 + * + * @param color {@link Color} + * @return Hex字符串 + * @since 3.0.8 + */ + public static String encodeColor(Color color) { + return encodeColor(color, "#"); + } + + /** + * 将{@link Color}编码为Hex形式 + * + * @param color {@link Color} + * @param prefix 前缀字符串,可以是#、0x等 + * @return Hex字符串 + * @since 3.0.8 + */ + public static String encodeColor(Color color, String prefix) { + final StringBuilder builder = new StringBuilder(prefix); + String colorHex; + colorHex = Integer.toHexString(color.getRed()); + if (1 == colorHex.length()) { + builder.append('0'); + } + builder.append(colorHex); + colorHex = Integer.toHexString(color.getGreen()); + if (1 == colorHex.length()) { + builder.append('0'); + } + builder.append(colorHex); + colorHex = Integer.toHexString(color.getBlue()); + if (1 == colorHex.length()) { + builder.append('0'); + } + builder.append(colorHex); + return builder.toString(); + } + + /** + * 将Hex颜色值转为 + * + * @param hexColor 16进制颜色值,可以以#开头,也可以用0x开头 + * @return {@link Color} + * @since 3.0.8 + */ + public static Color decodeColor(String hexColor) { + return Color.decode(hexColor); + } + + /** + * 将指定int值转换为Unicode字符串形式,常用于特殊字符(例如汉字)转Unicode形式
+ * 转换的字符串如果u后不足4位,则前面用0填充,例如: + * + *

+     * '我' =》\u4f60
+     * 
+ * + * @param value int值,也可以是char + * @return Unicode表现形式 + */ + public static String toUnicodeHex(int value) { + final StringBuilder builder = new StringBuilder(6); + + builder.append("\\u"); + String hex = toHex(value); + int len = hex.length(); + if (len < 4) { + builder.append("0000", 0, 4 - len);// 不足4位补0 + } + builder.append(hex); + + return builder.toString(); + } + + /** + * 将指定char值转换为Unicode字符串形式,常用于特殊字符(例如汉字)转Unicode形式
+ * 转换的字符串如果u后不足4位,则前面用0填充,例如: + * + *
+     * '我' =》\u4f60
+     * 
+ * + * @param ch char值 + * @return Unicode表现形式 + * @since 4.0.1 + */ + public static String toUnicodeHex(char ch) { + return "\\u" +// + DIGITS_LOWER[(ch >> 12) & 15] +// + DIGITS_LOWER[(ch >> 8) & 15] +// + DIGITS_LOWER[(ch >> 4) & 15] +// + DIGITS_LOWER[(ch) & 15]; + } + + /** + * 转为16进制字符串 + * + * @param value int值 + * @return 16进制字符串 + * @since 4.4.1 + */ + public static String toHex(int value) { + return Integer.toHexString(value); + } + + /** + * 转为16进制字符串 + * + * @param value int值 + * @return 16进制字符串 + * @since 4.4.1 + */ + public static String toHex(long value) { + return Long.toHexString(value); + } + + /** + * 将byte值转为16进制并添加到{@link StringBuilder}中 + * + * @param builder {@link StringBuilder} + * @param b byte + * @param toLowerCase 是否使用小写 + * @since 4.4.1 + */ + public static void appendHex(StringBuilder builder, byte b, boolean toLowerCase) { + final char[] toDigits = toLowerCase ? DIGITS_LOWER : DIGITS_UPPER; + + int high = (b & 0xf0) >>> 4;//高位 + int low = b & 0x0f;//低位 + builder.append(toDigits[high]); + builder.append(toDigits[low]); + } + + /** + * Hex(16进制)字符串转为BigInteger + * + * @param hexStr Hex(16进制字符串) + * @return {@link BigInteger} + * @since 5.2.0 + */ + public static BigInteger toBigInteger(String hexStr) { + if (null == hexStr) { + return null; + } + return new BigInteger(hexStr, 16); + } + + /** + * 格式化Hex字符串,结果为每2位加一个空格,类似于: + *
+     *     e8 8c 67 03 80 cb 22 00 95 26 8f
+     * 
+ * + * @param hexStr Hex字符串 + * @return 格式化后的字符串 + */ + public static String format(String hexStr) { + final int length = hexStr.length(); + final StringBuilder builder = new StringBuilder(); + builder.append(hexStr.charAt(0)).append(hexStr.charAt(1)); + for (int i = 2; i < length - 1; i += 2) { + builder.append(StringUtils.SPACE).append(hexStr.charAt(i)).append(hexStr.charAt(i + 1)); + } + return builder.toString(); + } + + // ---------------------------------------------------------------------------------------- Private method start + + /** + * 将字节数组转换为十六进制字符串 + * + * @param data byte[] + * @param toDigits 用于控制输出的char[] + * @return 十六进制String + */ + private static String encodeHexStr(byte[] data, char[] toDigits) { + return new String(encodeHex(data, toDigits)); + } + + /** + * 将字节数组转换为十六进制字符数组 + * + * @param data byte[] + * @param toDigits 用于控制输出的char[] + * @return 十六进制char[] + */ + private static char[] encodeHex(byte[] data, char[] toDigits) { + final int len = data.length; + final char[] out = new char[len << 1];//len*2 + // two characters from the hex value. + for (int i = 0, j = 0; i < len; i++) { + out[j++] = toDigits[(0xF0 & data[i]) >>> 4];// 高位 + out[j++] = toDigits[0x0F & data[i]];// 低位 + } + return out; + } + + /** + * 将十六进制字符转换成一个整数 + * + * @param ch 十六进制char + * @param index 十六进制字符在字符数组中的位置 + * @return 一个整数 + * @throws RuntimeException 当ch不是一个合法的十六进制字符时,抛出运行时异常 + */ + private static int toDigit(char ch, int index) { + int digit = Character.digit(ch, 16); + if (digit == -1) { + throw new RuntimeException("Illegal hexadecimal character " + ch + " at index " + index); + } + return digit; + } + // ---------------------------------------------------------------------------------------- Private method end +} \ No newline at end of file diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/util/LoopRetry.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/util/LoopRetry.java new file mode 100644 index 00000000..bb0e167a --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/util/LoopRetry.java @@ -0,0 +1,128 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.util; + +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * @author yudong + */ +public abstract class LoopRetry { + + private final IntervalStrategy intervalStrategy; + + private final AtomicBoolean isRunning = new AtomicBoolean(false); + + public LoopRetry(IntervalStrategy intervalStrategy) { + this.intervalStrategy = intervalStrategy; + } + + /** + * 实现重试逻辑,重试成功返回true,将会退出重试机制 + * + * @return 本次执行是否成功 + */ + public abstract boolean retry(); + + /** + * 是否已经在执行重试逻辑 + */ + public boolean isRunning() { + return isRunning.get(); + } + + /** + * 重试几次 + * + * @return 重试几次之后成功还是失败 + */ + public boolean loop(AtomicInteger times) { + isRunning.set(true); + while (times.getAndDecrement() > 0) { + if (this.retry()) { + isRunning.set(false); + return true; + } + intervalStrategy.interval(); + } + isRunning.set(false); + return false; + } + + static void doSleep(long millis) { + try { + Thread.sleep(millis); + } catch (InterruptedException e) { + } + } + + public interface IntervalStrategy { + + /** + * 重试间隔做什么 + */ + void interval(); + } + + /** + * 重试间隔时sleep + */ + public static class SleepIntervalStrategy implements IntervalStrategy { + + private final long sleepMs; + + public SleepIntervalStrategy(long sleepMs) { + this.sleepMs = sleepMs; + } + + @Override + public void interval() { + doSleep(sleepMs); + } + } + + /** + * 重试间隔成倍递增策略 + */ + public static class IncreaseSleepIntervalStrategy implements IntervalStrategy { + + private final long sleepMs; + private final AtomicInteger times; + + public IncreaseSleepIntervalStrategy(long sleepMs, AtomicInteger times) { + this.sleepMs = sleepMs; + this.times = times; + } + + @Override + public void interval() { + doSleep(times.get() * sleepMs); + } + } + + /** + * 重试间隔什么也不做 + */ + public static class NoneIntervalStrategy implements IntervalStrategy { + + @Override + public void interval() { + } + } +} diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/util/WgetCmd.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/util/WgetCmd.java index fb3ebd07..6498c4bc 100644 --- a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/util/WgetCmd.java +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/util/WgetCmd.java @@ -17,9 +17,12 @@ package com.aliyun.polardbx.binlog.util; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.File; import java.io.IOException; -import java.io.InputStream; +import java.util.Scanner; /** * @author chengjin.lyf on 2019/3/3 3:08 PM @@ -27,6 +30,8 @@ */ public class WgetCmd { + private static final Logger logger = LoggerFactory.getLogger(WgetCmd.class); + private String link; private String fileName; @@ -39,35 +44,22 @@ public File execute() throws IOException, InterruptedException { ProcessBuilder pb = new ProcessBuilder("wget", "--no-check-certificate", link, "-O", fileName + "_tmp_wget"); pb.redirectErrorStream(true); Process process = pb.start(); - final InputStream inputStream = process.getInputStream(); - Thread t = new Thread() { + final Scanner scanner = new Scanner(process.getInputStream()); + scanner.useDelimiter("\n"); + Thread t = new Thread("wget-progress") { @Override public void run() { - byte[] cache = new byte[512]; - int idx = 0; - int data = 0; - long st = 0; try { - while ((data = inputStream.read()) != -1) { - long now = System.currentTimeMillis(); - if (idx >= cache.length) { - System.out.write(cache, 0, idx); - idx = 0; - continue; - } - cache[idx++] = (byte) data; - if (data == '\n') { - if (now - st > 30000) { - st = now; - System.out.write(cache, 0, idx); - } - idx = 0; - continue; - } + while (scanner.hasNext()) { + String line = scanner.next(); + WgetContext.add(line); } } catch (Exception e) { - + logger.error("print wget progress error! link : " + link, e); + } finally { + WgetContext.finish(); + scanner.close(); } } }; diff --git a/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/util/WgetContext.java b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/util/WgetContext.java new file mode 100644 index 00000000..ae3854b4 --- /dev/null +++ b/polardbx-cdc-common/src/main/java/com/aliyun/polardbx/binlog/util/WgetContext.java @@ -0,0 +1,130 @@ +package com.aliyun.polardbx.binlog.util; + +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.TimeUnit; + +public class WgetContext { + + private static final Logger logger = LoggerFactory.getLogger(WgetContext.class); + private static final int SIZE_IDX = 0; + private static final int SPEED_IDX = 7; + private static final int PROGRESS_IDX = 6; + private static LoadingCache speedPerSecMap = + CacheBuilder.newBuilder().expireAfterAccess(10, TimeUnit.SECONDS).build( + new CacheLoader() { + @Override + public AvgSpeed load(Long s) throws Exception { + return new AvgSpeed(); + } + }); + + public static void main(String[] args) { +// WgetContext.add("196700K .......... .......... .......... .......... .......... 38% 6.50M 48s"); + WgetContext.add("9000K .......... .......... .......... .......... .......... 1% 234K 27m52s"); + WgetContext.add("0K .......... .......... .......... .......... .......... 0% 1 20d6h"); + WgetContext.add("0K .......... .......... .......... .......... .......... 0% 1M 20d6h"); + } + + /** + * 196700K .......... .......... .......... .......... .......... 38% 6.50M 48s + */ + public static void add(String log) { + try { + String args[] = log.trim().split(" "); + int idx = 0; + if (args.length <= SPEED_IDX) { + logger.info(log); + return; + } + String speedReg = args[SPEED_IDX]; + for (int i = 0; i < args.length; i++) { + if (StringUtils.isBlank(args[i])) { + continue; + } + if (idx == SPEED_IDX) { + speedReg = args[i]; + break; + } + idx++; + } + if (StringUtils.isBlank(speedReg)) { + return; + } + speedReg = speedReg.trim(); + if (speedReg.length() > 1) { + if (!NumberUtils.isCreatable(speedReg.substring(0, speedReg.length() - 1))) { + return; + } + } else if (!NumberUtils.isCreatable(speedReg)) { + return; + } + Long speed = convert(speedReg); + speedPerSecMap.get(Thread.currentThread().getId()).addSpeed(speed); + } catch (Exception e) { + logger.error("parse wget log error", e); + } + + } + + public static void finish() { + speedPerSecMap.invalidate(Thread.currentThread().getId()); + } + + private static Long convert(String reg) { + char unit = reg.charAt(reg.length() - 1); + Long v = 0L; + switch (unit) { + case 'M': + v = (long) (extract(reg) * 1024 * 1024); + break; + case 'K': + v = (long) (extract(reg) * 1024); + break; + default: + // byte + v = Long.valueOf(reg); + } + return v; + } + + private static double extract(String reg) { + return Double.parseDouble(reg.substring(0, reg.length() - 1)); + } + + public static long size() { + return speedPerSecMap.size(); + } + + public static long totalSpeed() { + long total = 0; + for (AvgSpeed v : speedPerSecMap.asMap().values()) { + total += v.eval(); + } + return total; + } + + public static class AvgSpeed { + private long totalSpeed = 0; + private int count = 0; + + public void addSpeed(long speed) { + synchronized (this) { + this.totalSpeed += speed; + this.count++; + } + } + + public long eval() { + synchronized (this) { + return totalSpeed / count; + } + } + } +} diff --git a/polardbx-cdc-common/src/main/resources/config.properties b/polardbx-cdc-common/src/main/resources/config.properties index 1179d11a..5ba1d27a 100644 --- a/polardbx-cdc-common/src/main/resources/config.properties +++ b/polardbx-cdc-common/src/main/resources/config.properties @@ -17,6 +17,7 @@ enableInterfaceACL=false cluster_type=${maven.cluster_type} dnPasswordKey=${maven.dnPasswordKey} useEncryptedPassword=false +assignedDnIp= # # Storage相关的参数配置 # @@ -48,10 +49,12 @@ binlog.dir.path=${maven.binlog.dir.path} binlog.file.size=${maven.binlog.file.size} binlog.file.seek.bufferSize=${maven.binlog.file.seek.bufferSize} binlog.write.dryrun=false +binlog.write.supportRowsQueryLog=${maven.binlog.write.supportRowsQueryLog} binlog.write.buffer.size=1048576 binlog.write.flush.policy=0 binlog.write.flush.interval=1000 binlog.write.heartbeatFlushInterval=30 +binlog.write.tableId.baseValue=0 # # Daemon和拓扑相关的配置 # @@ -81,6 +84,9 @@ task.transmitter.chunkMode=MEMSIZE task.transmitter.chunkItemSize=10240 task.transmitter.maxMessageSize=1073741824 task.extractor.recordTransLog=false +task.support.drdsHiddenPk=false +task.traceid.disorder.ignore=false +task.skip.exception.bufferKey.duplicate=false # # 报警相关的参数配置 # @@ -94,3 +100,14 @@ alarm.reportAlarmEvent=true # meta.openTopologyRepair=false meta.useHistoryTableFirst=false +meta.rollback.mode=${maven.meta.rollback.mode} +meta.rollback.mode.supportInstantCreatTable=SNAPSHOT_SEMI,SNAPSHOT_UNSAFE +meta.checkConsistencyAfterEachApply=${maven.meta.checkConsistencyAfterEachApply} +meta.printSummaryAfterApply.switch=false +meta.printSummaryAfterApply.tables= +meta.printDetailAfterApply.switch=false +meta.printDetailAfterApply.tables= +meta.semiSnapshot.holdingTime=${maven.meta.semiSnapshot.holdingTime} +meta.semiSnapshot.holdingTime.checkInterval=${maven.meta.semiSnapshot.holdingTime.checkInterval} +meta.semiSnapshot.deltaChange.checkInterval=60 + diff --git a/polardbx-cdc-common/src/main/resources/generatorConfig.xml b/polardbx-cdc-common/src/main/resources/generatorConfig.xml index 523262f5..10fae10a 100644 --- a/polardbx-cdc-common/src/main/resources/generatorConfig.xml +++ b/polardbx-cdc-common/src/main/resources/generatorConfig.xml @@ -54,5 +54,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/polardbx-cdc-common/src/test/java/com/aliyun/polardbx/binlog/CommonUtilsTest.java b/polardbx-cdc-common/src/test/java/com/aliyun/polardbx/binlog/CommonUtilsTest.java index 9818a69c..23dcba9c 100644 --- a/polardbx-cdc-common/src/test/java/com/aliyun/polardbx/binlog/CommonUtilsTest.java +++ b/polardbx-cdc-common/src/test/java/com/aliyun/polardbx/binlog/CommonUtilsTest.java @@ -46,7 +46,7 @@ public void testTso2Datetime() { @Test public void testGetTsoDatetime() { - long seconds = CommonUtils.getTsoPhysicalTime("681932084883116608013503860643882680350000000000754228", + long seconds = CommonUtils.getTsoPhysicalTime("690693687595761670414380020914056724480000000000000000", TimeUnit.SECONDS); System.out.println("seconds is :" + DateFormatUtils.format(seconds * 1000, "yyyy-MM-dd HH:mm:ss")); } diff --git a/polardbx-cdc-daemon/pom.xml b/polardbx-cdc-daemon/pom.xml index 265db2db..0ffdc0b0 100644 --- a/polardbx-cdc-daemon/pom.xml +++ b/polardbx-cdc-daemon/pom.xml @@ -6,7 +6,7 @@ com.aliyun.polardbx polardbx-cdc - 5.4.12-SNAPSHOT + 5.4.13-SNAPSHOT com.aliyun.polardbxpolardbx-cdc-daemon @@ -20,7 +20,7 @@ com.aliyun.polardbx polardbx-cdc-common - 5.4.12-SNAPSHOT + 5.4.13-SNAPSHOT * @@ -31,7 +31,7 @@ com.aliyun.polardbx polardbx-cdc-meta - 5.4.12-SNAPSHOT + 5.4.13-SNAPSHOT @@ -118,6 +118,12 @@ 4.12 test + + com.aliyun.polardbx + polardbx-cdc-rpl + 5.4.13-SNAPSHOT + compile + diff --git a/polardbx-cdc-daemon/src/main/java/com/aliyun/polardbx/binlog/daemon/cluster/TopologyService.java b/polardbx-cdc-daemon/src/main/java/com/aliyun/polardbx/binlog/daemon/cluster/TopologyService.java index 750be99e..dfa52a2b 100644 --- a/polardbx-cdc-daemon/src/main/java/com/aliyun/polardbx/binlog/daemon/cluster/TopologyService.java +++ b/polardbx-cdc-daemon/src/main/java/com/aliyun/polardbx/binlog/daemon/cluster/TopologyService.java @@ -260,7 +260,7 @@ private ClusterSnapshot buildPostClusterSnapshot(List topology private String selectDumperMasterNode(Set containers, ClusterSnapshot preClusterSnapshot) { //如果强制指定了master node, 且node状态正常,则使用强制指定的node - String assignedDumperNode = SystemDbConfig.getSystemDbConfig(CLUSTER_TOPOLOGY_DUMPER_MASTER_NODE_KEY); + String assignedDumperNode = DynamicApplicationConfig.getString(CLUSTER_TOPOLOGY_DUMPER_MASTER_NODE_KEY); if (StringUtils.isNotBlank(assignedDumperNode) && containers.contains(assignedDumperNode)) { log.info("Dumper master node is selected by force mode, with name {}", assignedDumperNode); return assignedDumperNode; diff --git a/polardbx-cdc-daemon/src/main/java/com/aliyun/polardbx/binlog/daemon/cluster/service/BinlogBootstrapService.java b/polardbx-cdc-daemon/src/main/java/com/aliyun/polardbx/binlog/daemon/cluster/service/BinlogBootstrapService.java index 1b0c63e8..0343692a 100644 --- a/polardbx-cdc-daemon/src/main/java/com/aliyun/polardbx/binlog/daemon/cluster/service/BinlogBootstrapService.java +++ b/polardbx-cdc-daemon/src/main/java/com/aliyun/polardbx/binlog/daemon/cluster/service/BinlogBootstrapService.java @@ -21,6 +21,8 @@ import com.aliyun.polardbx.binlog.ConfigKeys; import com.aliyun.polardbx.binlog.DynamicApplicationConfig; import com.aliyun.polardbx.binlog.daemon.cluster.ClusterBootstrapService; +import com.aliyun.polardbx.binlog.daemon.schedule.RplLeaderJob; +import com.aliyun.polardbx.binlog.daemon.schedule.RplWorkerJob; import com.aliyun.polardbx.binlog.daemon.schedule.TaskAliveWatcher; import com.aliyun.polardbx.binlog.daemon.schedule.TopologyWatcher; import com.aliyun.polardbx.binlog.heartbeat.TsoHeartbeat; @@ -59,5 +61,12 @@ public void start() { TaskAliveWatcher taskAliveWatcher = new TaskAliveWatcher(cluster, clusterType, "TaskKeepAlive", DynamicApplicationConfig.getInt(DAEMON_TASK_WATCH_INTERVAL_MS)); taskAliveWatcher.start(); + + // 运行replica task + // 定期抢 Leader,如抢到 Leader,则负责:调度所有 Rpl 状态机,分发任务到各个 worker + new RplLeaderJob(cluster, clusterType, "RplLeaderJob", 1 * 5 * 1000).start(); + // 定期检测本地需要启动哪些 Rpl 任务,停止哪些 Rpl 任务 + new RplWorkerJob(cluster, clusterType, "RplWorkerJob", 1 * 5 * 1000).start(); + } } diff --git a/polardbx-cdc-daemon/src/main/java/com/aliyun/polardbx/binlog/daemon/rest/resources/SystemControlResource.java b/polardbx-cdc-daemon/src/main/java/com/aliyun/polardbx/binlog/daemon/rest/resources/SystemControlResource.java index 3f236b35..33446109 100644 --- a/polardbx-cdc-daemon/src/main/java/com/aliyun/polardbx/binlog/daemon/rest/resources/SystemControlResource.java +++ b/polardbx-cdc-daemon/src/main/java/com/aliyun/polardbx/binlog/daemon/rest/resources/SystemControlResource.java @@ -84,6 +84,7 @@ public class SystemControlResource { private static final String CDC_METADB_RESET_10 = String.format("delete from binlog_system_config where config_key='%s';", CLUSTER_TOPOLOGY_DUMPER_MASTER_NODE_KEY); + private static final String CDC_METADB_RESET_11 = "truncate binlog_semi_snapshot"; private static final String QUERY_VIP_STORAGE = "select * from storage_info where inst_kind=0 and is_vip = 1 and storage_inst_id = '%s' limit 1"; diff --git a/polardbx-cdc-daemon/src/main/java/com/aliyun/polardbx/binlog/daemon/schedule/RplLeaderJob.java b/polardbx-cdc-daemon/src/main/java/com/aliyun/polardbx/binlog/daemon/schedule/RplLeaderJob.java new file mode 100644 index 00000000..39e1f096 --- /dev/null +++ b/polardbx-cdc-daemon/src/main/java/com/aliyun/polardbx/binlog/daemon/schedule/RplLeaderJob.java @@ -0,0 +1,58 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.daemon.schedule; + +import com.aliyun.polardbx.binlog.error.PolardbxException; +import com.aliyun.polardbx.binlog.leader.RuntimeLeaderElector; +import com.aliyun.polardbx.binlog.task.AbstractBinlogTimerTask; +import com.aliyun.polardbx.rpl.common.LogUtil; +import com.aliyun.polardbx.rpl.common.fsmutil.FSMManager; +import com.aliyun.polardbx.rpl.taskmeta.FSMMetaManager; +import com.aliyun.polardbx.rpl.taskmeta.RplServiceManager; +import org.slf4j.Logger; + +/** + * @author shicai.xsc 2021/1/15 14:19 + * @since 5.0.0.0 + */ +public class RplLeaderJob extends AbstractBinlogTimerTask { + + private static Logger metaLogger = LogUtil.getMetaLogger(); + + public RplLeaderJob(String clusterId, String clusterType, String name, int interval) { + super(clusterId, clusterType, name, interval); + } + + @Override + public void exec() { + try { + metaLogger.info("try to elect leader"); + if (!RuntimeLeaderElector.isDaemonLeader()) { + metaLogger.info("NOT a leader"); + return; + } + + FSMManager.update(); + FSMMetaManager.distributeTasks(); + + } catch (Throwable th) { + metaLogger.error("RplLeaderJob fail {} {} {}", clusterId, name, interval, th); + throw new PolardbxException("RplLeaderJob fail", th); + } + } +} diff --git a/polardbx-cdc-daemon/src/main/java/com/aliyun/polardbx/binlog/daemon/schedule/RplWorkerJob.java b/polardbx-cdc-daemon/src/main/java/com/aliyun/polardbx/binlog/daemon/schedule/RplWorkerJob.java new file mode 100644 index 00000000..af0a6fc0 --- /dev/null +++ b/polardbx-cdc-daemon/src/main/java/com/aliyun/polardbx/binlog/daemon/schedule/RplWorkerJob.java @@ -0,0 +1,51 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.daemon.schedule; + +import com.aliyun.polardbx.binlog.error.PolardbxException; +import com.aliyun.polardbx.binlog.task.AbstractBinlogTimerTask; +import com.aliyun.polardbx.rpl.common.LogUtil; +import com.aliyun.polardbx.rpl.taskmeta.FSMMetaManager; +import org.slf4j.Logger; + +/** + * @author shicai.xsc 2021/1/15 14:20 + * @since 5.0.0.0 + */ +public class RplWorkerJob extends AbstractBinlogTimerTask { + + private static Logger metaLogger = LogUtil.getMetaLogger(); + + public RplWorkerJob(String clusterId, String clusterType, String name, int interval) { + super(clusterId, clusterType, name, interval); + } + + @Override + public void exec() { + refresh(); + } + + public void refresh() { + try { + FSMMetaManager.checkAndRunLocalTasks(clusterId); + } catch (Throwable e) { + metaLogger.error("RplWorkerJob fail {} {} {}", clusterId, name, interval, e); + throw new PolardbxException("RplWorkerJob fail", e); + } + } +} diff --git a/polardbx-cdc-dumper/pom.xml b/polardbx-cdc-dumper/pom.xml index d4c96d13..9ae241e7 100644 --- a/polardbx-cdc-dumper/pom.xml +++ b/polardbx-cdc-dumper/pom.xml @@ -6,7 +6,7 @@ com.aliyun.polardbx polardbx-cdc - 5.4.12-SNAPSHOT + 5.4.13-SNAPSHOT com.aliyun.polardbx polardbx-cdc-dumper @@ -43,5 +43,11 @@ HikariCP 3.4.5 + + com.aliyun.polardbx + polardbx-cdc-rpl + 5.4.13-SNAPSHOT + compile + diff --git a/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/CdcServer.java b/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/CdcServer.java index fe8f245a..6c10bdd6 100644 --- a/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/CdcServer.java +++ b/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/CdcServer.java @@ -25,17 +25,28 @@ import com.aliyun.polardbx.rpc.cdc.BinaryLog; import com.aliyun.polardbx.rpc.cdc.BinlogEvent; import com.aliyun.polardbx.rpc.cdc.CdcServiceGrpc; +import com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest; +import com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest; import com.aliyun.polardbx.rpc.cdc.DumpRequest; import com.aliyun.polardbx.rpc.cdc.DumpStream; import com.aliyun.polardbx.rpc.cdc.MasterStatus; import com.aliyun.polardbx.rpc.cdc.Request; +import com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest; +import com.aliyun.polardbx.rpc.cdc.RplCommandResponse; import com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest; +import com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest; +import com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse; +import com.aliyun.polardbx.rpc.cdc.StartSlaveRequest; +import com.aliyun.polardbx.rpc.cdc.StopSlaveRequest; +import com.aliyun.polardbx.rpl.common.LogUtil; +import com.aliyun.polardbx.rpl.taskmeta.RplServiceManager; import io.grpc.Server; import io.grpc.ServerBuilder; import io.grpc.stub.ServerCallStreamObserver; import io.grpc.stub.StreamObserver; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; import java.io.File; import java.io.IOException; @@ -59,6 +70,7 @@ public class CdcServer { private Server server; private boolean localMode; private final ExecutorService executor; + private static Logger metaLogger = LogUtil.getMetaLogger(); public CdcServer(String taskName, LogFileManager logFileManager, int port) { this.taskName = taskName; @@ -93,7 +105,7 @@ public void showBinlogEvents(ShowBinlogEventsRequest request, (ServerCallStreamObserver) responseObserver; LogFileReader logFileReader = new LogFileReader(logFileManager); String fileName = StringUtils.isEmpty(request.getLogName()) ? logFileManager - .getMaxBinlogFileName() + .getMinBinlogFileName() : request.getLogName(); logFileReader.showBinlogEvent(fileName, request.getPos(), request.getOffset(), request.getRowCount(), serverCallStreamObserver); @@ -144,6 +156,45 @@ public void sync(DumpRequest request, StreamObserver responseObserve logFileReader.binlogSync(request.getFileName(), request.getPosition(), txnOutputStream); }); } + + ///////////////////////////// Replicate ///////////////////////// + @Override + public void changeMaster(ChangeMasterRequest request, StreamObserver responseObserver) { + metaLogger.info("changeMaster: " + request.getRequest()); + RplServiceManager.changeMaster(request, responseObserver); + } + + @Override + public void changeReplicationFilter(ChangeReplicationFilterRequest request, + StreamObserver responseObserver) { + metaLogger.info("changeReplicationFilter: " + request.getRequest()); + RplServiceManager.changeReplicationFilter(request, responseObserver); + } + + @Override + public void startSlave(StartSlaveRequest request, StreamObserver responseObserver) { + metaLogger.info("startSlave: " + request.getRequest()); + RplServiceManager.startSlave(request, responseObserver); + } + + @Override + public void stopSlave(StopSlaveRequest request, StreamObserver responseObserver) { + metaLogger.info("stopSlave: " + request.getRequest()); + RplServiceManager.stopSlave(request, responseObserver); + } + + @Override + public void resetSlave(ResetSlaveRequest request, StreamObserver responseObserver) { + metaLogger.info("resetSlave: " + request.getRequest()); + RplServiceManager.resetSlave(request, responseObserver); + } + + @Override + public void showSlaveStatus(ShowSlaveStatusRequest request, + StreamObserver responseObserver) { + metaLogger.info("showSlaveStatus: " + request.getRequest()); + RplServiceManager.showSlaveStatus(request, responseObserver); + } }; try { diff --git a/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/logfile/BinlogEventReader.java b/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/logfile/BinlogEventReader.java index d3024558..43007e1a 100644 --- a/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/logfile/BinlogEventReader.java +++ b/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/logfile/BinlogEventReader.java @@ -240,6 +240,9 @@ private ServerCharactorSet loadCharactorSet() { list.forEach(pair -> { String variableName = pair.getLeft(); String charset = pair.getRight(); + if (StringUtils.equals("utf8mb3", charset)) { + charset = "utf8"; + } log.info(variableName + " : " + charset); if ("character_set_client".equalsIgnoreCase(variableName)) { set.setCharacterSetClient(charset); diff --git a/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/logfile/BinlogFile.java b/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/logfile/BinlogFile.java index bde1ffe5..079eb188 100644 --- a/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/logfile/BinlogFile.java +++ b/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/logfile/BinlogFile.java @@ -35,6 +35,10 @@ import java.nio.ByteBuffer; import java.util.zip.CRC32; +import static com.aliyun.polardbx.binlog.canal.binlog.LogEvent.ROWS_QUERY_LOG_EVENT; +import static com.aliyun.polardbx.binlog.dumper.dump.util.TableIdManager.containsTableId; +import static com.aliyun.polardbx.binlog.dumper.dump.util.TableIdManager.getTableIdLength; + /** * Created by ziyang.lb */ @@ -264,10 +268,10 @@ private SeekResult seekFirst() { buffer.flip(); if (buffer.hasRemaining() && buffer.remaining() >= 19) { - lastEventTimestamp = readLong(buffer);//read timestamp + lastEventTimestamp = readInt32(buffer);//read timestamp lastEventType = buffer.get();//read event_type buffer.position(buffer.position() + 4);//skip server_id - long eventSize = readLong(buffer);//read eventSizeer_id + long eventSize = readInt32(buffer);//read eventSizeer_id nextEventAbsolutePos += eventSize; if (lastEventType == LogEvent.FORMAT_DESCRIPTION_EVENT) { continue; @@ -311,6 +315,7 @@ private SeekResult seekLastTsoV2() { String lastTso = ""; byte lastEventType = -1; Long lastEventTimestamp = null; + Long maxTableId = null; if (fileLength > 4) { long nextEventAbsolutePos = 4; @@ -326,10 +331,10 @@ private SeekResult seekLastTsoV2() { int nextEventRelativePos = buffer.position(); while (buffer.hasRemaining() && buffer.remaining() >= 19) { - lastEventTimestamp = readLong(buffer);//read timestamp + lastEventTimestamp = readInt32(buffer);//read timestamp lastEventType = buffer.get();//read event_type buffer.position(buffer.position() + 4);//skip server_id - long eventSize = readLong(buffer);//read eventSize + long eventSize = readInt32(buffer);//read eventSize // next position需要通过计算获取,不能直接用header中的log_pos字段的值 // 因为对于超大事务(>2G),log_pos的四个字节已经无法准确表达下个事件的位置 @@ -338,12 +343,12 @@ private SeekResult seekLastTsoV2() { if (nextEventRelativePos > buffer.limit()) { // 如果当前这个Event是ROWS_QUERY_LOG_EVENT,则不能直接跳过,需要将nextEventAbsolutePos进行回调后再break - if (lastEventType == LogEvent.ROWS_QUERY_LOG_EVENT) { + if (lastEventType == ROWS_QUERY_LOG_EVENT || containsTableId(lastEventType)) { nextEventAbsolutePos -= eventSize; } break; } else { - if (lastEventType == LogEvent.ROWS_QUERY_LOG_EVENT) { + if (lastEventType == ROWS_QUERY_LOG_EVENT) { //跳过剩余的header buffer.position(buffer.position() + 6); //在之前的版本中,ROWS_QUERY_LOG_EVENT只用来记录tso,这个字段的值并不是1,而是tso的长度 @@ -365,6 +370,10 @@ private SeekResult seekLastTsoV2() { lastTso = markInfo.getTso(); seekPosition = nextEventAbsolutePos; } + } else if (containsTableId(lastEventType)) { + buffer.position(buffer.position() + 6); + long tableId = readTableId(buffer); + maxTableId = maxTableId == null ? tableId : Math.max(maxTableId, tableId); } buffer.position(nextEventRelativePos); seekEventCount++; @@ -392,7 +401,7 @@ private SeekResult seekLastTsoV2() { log.info("seek last tso cost time:" + (System.currentTimeMillis() - startTime) + "ms, skipped event count:" + seekEventCount); - return new SeekResult(lastTso, lastEventType, lastEventTimestamp); + return new SeekResult(lastTso, lastEventType, lastEventTimestamp, maxTableId); } catch (IOException e) { throw new PolardbxException("seek tso failed.", e); } @@ -423,7 +432,7 @@ private void writeInternal(byte[] data, int offset, int length) throws IOExcepti } } - private long readLong(ByteBuffer buffer) { + private long readInt32(ByteBuffer buffer) { return ((long) (0xff & buffer.get())) | ((long) (0xff & buffer.get()) << 8) | ((long) (0xff & buffer.get()) << 16) | ((long) (0xff & buffer.get()) << 24); } @@ -440,6 +449,19 @@ private String readString(long length, ByteBuffer buffer) throws IOException { return new String(bytes); } + private long readTableId(ByteBuffer buffer) { + int length = getTableIdLength(); + return readLongByLength(buffer, length); + } + + public long readLongByLength(ByteBuffer buffer, int length) { + long result = 0; + for (int i = 0; i < length; ++i) { + result |= (((long) (0xff & buffer.get())) << (i << 3)); + } + return result; + } + public long getLogBegin() { if (logBegin == null) { SeekResult result = seekFirst(); @@ -461,6 +483,7 @@ public static class SeekResult { private String lastTso; private Byte lastEventType; private Long lastEventTimestamp; + private Long maxTableId; public SeekResult(String lastTso, Byte lastEventType, Long lastEventTimestamp) { this.lastTso = lastTso; @@ -468,6 +491,13 @@ public SeekResult(String lastTso, Byte lastEventType, Long lastEventTimestamp) { this.lastEventTimestamp = lastEventTimestamp; } + public SeekResult(String lastTso, Byte lastEventType, Long lastEventTimestamp, Long maxTableId) { + this.lastTso = lastTso; + this.lastEventType = lastEventType; + this.lastEventTimestamp = lastEventTimestamp; + this.maxTableId = maxTableId; + } + public String getLastTso() { return lastTso; } @@ -491,5 +521,23 @@ public Long getLastEventTimestamp() { public void setLastEventTimestamp(Long lastEventTimestamp) { this.lastEventTimestamp = lastEventTimestamp; } + + public Long getMaxTableId() { + return maxTableId; + } + + public void setMaxTableId(Long maxTableId) { + this.maxTableId = maxTableId; + } + + @Override + public String toString() { + return "SeekResult{" + + "lastTso='" + lastTso + '\'' + + ", lastEventType=" + lastEventType + + ", lastEventTimestamp=" + lastEventTimestamp + + ", maxTableId=" + maxTableId + + '}'; + } } } diff --git a/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/logfile/BinlogRecorderListener.java b/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/logfile/BinlogRecorderListener.java index cc99159e..ef61734c 100644 --- a/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/logfile/BinlogRecorderListener.java +++ b/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/logfile/BinlogRecorderListener.java @@ -221,7 +221,7 @@ public void exec() throws FileNotFoundException { if (recordOptional.isPresent()) { BinlogOssRecord record = recordOptional.get(); BinlogOssRecord newRecord = new BinlogOssRecord(); - newRecord.setLogSize(file.getTotalSpace()); + newRecord.setLogSize(file.length()); newRecord.setLogBegin(new Date(binlogFile.getLogBegin())); newRecord.setLogEnd(new Date(binlogFile.getLogEnd())); newRecord.setGmtModified(new Date()); @@ -243,7 +243,7 @@ public void exec() throws FileNotFoundException { record.setPurgeStatus(BinlogPurgeStatusEnum.UN_COMPLETE.getValue()); record.setLogBegin(new Date(binlogFile.getLogBegin())); record.setLogEnd(new Date(binlogFile.getLogEnd())); - record.setLogSize(file.getTotalSpace()); + record.setLogSize(file.length()); recordMapper.insert(record); } } finally { diff --git a/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/logfile/LogFileGenerator.java b/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/logfile/LogFileGenerator.java index 4b3f7a44..097b2b42 100644 --- a/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/logfile/LogFileGenerator.java +++ b/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/logfile/LogFileGenerator.java @@ -50,6 +50,7 @@ import com.aliyun.polardbx.binlog.domain.po.StorageHistoryInfo; import com.aliyun.polardbx.binlog.domain.po.StorageInfo; import com.aliyun.polardbx.binlog.dumper.dump.util.EventGenerator; +import com.aliyun.polardbx.binlog.dumper.dump.util.TableIdManager; import com.aliyun.polardbx.binlog.dumper.metrics.Metrics; import com.aliyun.polardbx.binlog.error.PolardbxException; import com.aliyun.polardbx.binlog.error.RetryableException; @@ -65,6 +66,7 @@ import com.aliyun.polardbx.binlog.scheduler.model.TaskConfig; import com.aliyun.polardbx.binlog.util.StorageUtil; import com.aliyun.polardbx.binlog.util.SystemDbConfig; +import com.google.common.collect.Sets; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -77,6 +79,7 @@ import org.mybatis.dynamic.sql.SqlBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.transaction.support.TransactionTemplate; import org.springframework.util.CollectionUtils; @@ -92,6 +95,8 @@ import java.util.stream.Collectors; import static com.aliyun.polardbx.binlog.CommonUtils.getTsoPhysicalTime; +import static com.aliyun.polardbx.binlog.ConfigKeys.BINLOG_WRITE_SUPPORT_ROWS_QUERY_LOG; +import static com.aliyun.polardbx.binlog.ConfigKeys.BINLOG_WRITE_TABLE_ID_BASE_VALUE; import static com.aliyun.polardbx.binlog.ConfigKeys.EXPECTED_STORAGE_TSO_KEY; import static com.aliyun.polardbx.binlog.dao.StorageHistoryInfoDynamicSqlSupport.instructionId; import static com.aliyun.polardbx.binlog.dao.StorageHistoryInfoDynamicSqlSupport.tso; @@ -102,6 +107,8 @@ import static com.aliyun.polardbx.binlog.dumper.dump.util.EventGenerator.makeBegin; import static com.aliyun.polardbx.binlog.dumper.dump.util.EventGenerator.makeCommit; import static com.aliyun.polardbx.binlog.dumper.dump.util.EventGenerator.makeMarkEvent; +import static com.aliyun.polardbx.binlog.dumper.dump.util.EventGenerator.makeRowsQuery; +import static com.aliyun.polardbx.binlog.dumper.dump.util.TableIdManager.containsTableId; import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo; import static org.mybatis.dynamic.sql.SqlBuilder.isIn; import static org.mybatis.dynamic.sql.SqlBuilder.isLessThanOrEqualTo; @@ -125,6 +132,7 @@ public class LogFileGenerator { private final int flushInterval; private final int writeBufferSize; private final int seekBufferSize; + private final boolean supportWriteRowQueryLogEvent; private byte[] formatDescData; private ExecutorService executor; @@ -133,6 +141,7 @@ public class LogFileGenerator { private BinlogFile binlogFile; private String targetTaskAddress; private FlushPolicy currentFlushPolicy; + private TableIdManager tableIdManager; private volatile boolean running; public LogFileGenerator(LogFileManager logFileManager, int binlogFileSize, boolean dryRun, FlushPolicy flushPolicy, @@ -146,6 +155,7 @@ public LogFileGenerator(LogFileManager logFileManager, int binlogFileSize, boole this.writeBufferSize = writeBufferSize; this.seekBufferSize = seekBufferSize; this.startTso = ""; + this.supportWriteRowQueryLogEvent = DynamicApplicationConfig.getBoolean(BINLOG_WRITE_SUPPORT_ROWS_QUERY_LOG); } public void start() { @@ -304,6 +314,7 @@ private void consume(TxnMessage message, MessageType processType) throws IOExcep currentToken = message.getTxnTag().getTxnMergedToken(); if (currentToken.getType() == TxnType.META_DDL) { writeDdl(currentToken.getPayload().toByteArray()); + tryInvalidateTableId(); tryFlush(true); } else if (currentToken.getType() == TxnType.META_DDL_PRIVATE) { writePrivateDdl(currentToken.getPayload().toByteArray()); @@ -337,6 +348,13 @@ private void consume(TxnMessage message, MessageType processType) throws IOExcep } } + private void tryInvalidateTableId() { + if (StringUtils.isNotBlank(currentToken.getSchema()) && StringUtils + .isNotBlank(currentToken.getTable())) { + tableIdManager.invalidate(currentToken.getSchema(), currentToken.getTable()); + } + } + private long extractServerId(TxnMessage message) { List itemList = message.getTxnData().getTxnItemsList(); if (CollectionUtils.isEmpty(itemList)) { @@ -382,6 +400,8 @@ private boolean tryWriteHeartBeat() throws IOException { */ private void buildBinlogFile() throws IOException { File file = logFileManager.getMaxBinlogFile(); + long maxTableId = DynamicApplicationConfig.getLong(BINLOG_WRITE_TABLE_ID_BASE_VALUE); + if (file == null) { file = logFileManager.createFirstLogFile(); binlogFile = new BinlogFile(file, MODE, writeBufferSize, seekBufferSize); @@ -426,9 +446,14 @@ private void buildBinlogFile() throws IOException { } } + logger.info("seek result is : " + seekResult); startTso = seekResult.getLastTso(); + if (seekResult.getMaxTableId() != null) { + maxTableId = seekResult.getMaxTableId(); + } } + tableIdManager = new TableIdManager(maxTableId, binlogFile.position() == 0); logger.info("start tso is :[" + startTso + "]"); } @@ -453,7 +478,7 @@ private void buildTarget() { private void writeBegin(long serverId) throws IOException { Pair begin = makeBegin(getTsoPhysicalTime(currentToken.getTso(), TimeUnit.SECONDS), - currentToken.getBeginSchema(), serverId); + currentToken.getSchema(), serverId); binlogFile.writeEvent(begin.getLeft(), 0, begin.getRight(), true); if (logger.isDebugEnabled()) { @@ -463,14 +488,30 @@ private void writeBegin(long serverId) throws IOException { private void writeDml(List itemsList) throws IOException { for (TxnItem txnItem : itemsList) { + // 从TableMap中取之前暂存的RowsQuery,生成一个RowsQuery Event + if (txnItem.getEventType() == LogEvent.TABLE_MAP_EVENT && StringUtils.isNotBlank(txnItem.getRowsQuery()) + && supportWriteRowQueryLogEvent) { + writeRowsQuery(txnItem.getRowsQuery()); + } + final byte[] data = txnItem.getPayload().toByteArray(); - EventGenerator.updateTimeStamp(data, - CommonUtils.getTsoPhysicalTime(currentToken.getTso(), TimeUnit.SECONDS)); + EventGenerator.updateTimeStamp(data, getTsoPhysicalTime(currentToken.getTso(), TimeUnit.SECONDS)); + if (StringUtils.isNotBlank(txnItem.getSchema()) && StringUtils.isNotBlank(txnItem.getTable()) + && containsTableId((byte) txnItem.getEventType())) { + long tableId = tableIdManager.getTableId(txnItem.getSchema(), txnItem.getTable()); + EventGenerator.updateTableId(data, tableId); + } binlogFile.writeEvent(data, 0, data.length, true); Metrics.get().incrementTotalWriteDmlEventCount(); } } + private void writeRowsQuery(String rowsQuery) throws IOException { + final Pair rowsQueryEvent = + makeRowsQuery(getTsoPhysicalTime(currentToken.getTso(), TimeUnit.SECONDS), rowsQuery); + binlogFile.writeEvent(rowsQueryEvent.getLeft(), 0, rowsQueryEvent.getRight(), true); + } + private void writeCommit(long serverId) throws IOException { final Pair commit = makeCommit(getTsoPhysicalTime(currentToken.getTso(), TimeUnit.SECONDS), serverId); @@ -481,7 +522,6 @@ private void writeCommit(long serverId) throws IOException { private void writeDdl(byte[] data) throws IOException { EventGenerator.updateTimeStamp(data, CommonUtils.getTsoPhysicalTime(currentToken.getTso(), TimeUnit.SECONDS)); -// EventGenerator.updateServerId(data); binlogFile.writeEvent(data, 0, data.length, true); writeTso(); @@ -640,6 +680,12 @@ private void recordMetaEnvConfigHistory(final String tso, EnvConfigChangeInfo en } private boolean tryRepairStorageList(String instructionIdParam, List storageList) { + if (!needTryRepairStorage()) { + logger.info("no need to repair storage."); + return false; + } + + logger.info("start try repairing storage."); BinlogPolarxCommandMapper commandMapper = SpringContextHolder.getObject(BinlogPolarxCommandMapper.class); StorageInfoMapper storageInfoMapper = SpringContextHolder.getObject(StorageInfoMapper.class); Optional optional = commandMapper @@ -684,6 +730,7 @@ private void tryFlush(boolean forceFlush) throws IOException { } boolean needRotate = checkRotate(getTsoPhysicalTime(currentToken.getTso(), TimeUnit.SECONDS), false); if (needRotate) { + tableIdManager.tryReset(); tryWriteFileHeader(); } } @@ -780,4 +827,16 @@ private void waitTaskConfigReady(String startTso) throws InterruptedException { } } } + + private boolean needTryRepairStorage() { + Set needRepairVersions = Sets.newHashSet("5.4.9", "5.4.10", "5.4.11"); + JdbcTemplate polarxTemplate = SpringContextHolder.getObject("polarxJdbcTemplate"); + String version = polarxTemplate.queryForObject("select version()", String.class); + String[] versionArray = version.split("-"); + if (!StringUtils.equals("TDDL", versionArray[1])) { + throw new PolardbxException("invalid polardbx version " + version); + } + String kernelVersion = versionArray[2]; + return needRepairVersions.contains(kernelVersion); + } } diff --git a/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/logfile/LogFileManager.java b/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/logfile/LogFileManager.java index 877390af..94441762 100644 --- a/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/logfile/LogFileManager.java +++ b/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/logfile/LogFileManager.java @@ -23,6 +23,8 @@ import com.aliyun.polardbx.binlog.task.ICursorProvider; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; @@ -40,6 +42,7 @@ public class LogFileManager implements ICursorProvider { private static final String BINLOG_FILE_PREFIX = "binlog."; private static final int BINLOG_FILE_SUFFIX_LENGTH = 6; // TODO binlog file name的数字编号是可以大于6位的 + private static final Logger logger = LoggerFactory.getLogger(LogFileManager.class); private String taskName; private String binlogFileDirPath; diff --git a/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/util/EventGenerator.java b/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/util/EventGenerator.java index 77b4a30a..73639ddf 100644 --- a/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/util/EventGenerator.java +++ b/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/util/EventGenerator.java @@ -25,6 +25,8 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.zip.CRC32; +import static com.aliyun.polardbx.binlog.dumper.dump.util.TableIdManager.getTableIdLength; + /** * Created by ziyang.lb */ @@ -32,7 +34,7 @@ public class EventGenerator { private static final int EVENT_LEN_OFFSET = 9; - private static final ThreadLocal BYTES = ThreadLocal.withInitial(() -> new byte[256]); + private static final ThreadLocal BYTES = ThreadLocal.withInitial(() -> new byte[1024]); private static final AtomicLong XID_SEQ = new AtomicLong(0); //高频使用,为了性能,复用byte数组 @@ -51,7 +53,7 @@ public static Pair makeMarkEvent(long timestamp, String markCon //write tso event body byte[] bytes = markContent.getBytes(); tsoEvent.write((byte) 1);// - tsoEvent.writeString(markContent, markContent.length());// content + tsoEvent.writeString(markContent, bytes.length);// content tsoEvent.writeLong(0, 4);//crc32 checksum // rewrite size, log pos @@ -208,6 +210,10 @@ public static Pair makeFakeRotate(long timestamp, String fileNa return Pair.of(data, length); } + public static Pair makeRowsQuery(long timestamp, String rowsQuery) { + return makeMarkEvent(timestamp, rowsQuery); + } + public static void updatePos(byte[] data, long newPos) { if (log.isDebugEnabled()) { log.debug("updatePos {}", newPos); @@ -228,6 +234,17 @@ public static void updateTimeStamp(byte[] data, long timeStamp) { byteArray.writeLong(timeStamp, 4); } + public static void updateTableId(byte[] data, long tableId) { + if (log.isDebugEnabled()) { + log.debug("updateTableId {}", tableId); + } + + int length = getTableIdLength(); + ByteArray byteArray = new ByteArray(data); + byteArray.skip(19); + byteArray.writeLong(tableId, length); + } + public static void updateServerId(byte[] data) { if (log.isDebugEnabled()) { log.debug("updateServerId {}", ServerConfigUtil.getGlobalNumberVar("SERVER_ID")); diff --git a/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/util/TableIdManager.java b/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/util/TableIdManager.java new file mode 100644 index 00000000..647e7d97 --- /dev/null +++ b/polardbx-cdc-dumper/src/main/java/com/aliyun/polardbx/binlog/dumper/dump/util/TableIdManager.java @@ -0,0 +1,112 @@ +package com.aliyun.polardbx.binlog.dumper.dump.util; + +import com.aliyun.polardbx.binlog.DynamicApplicationConfig; +import com.aliyun.polardbx.binlog.format.FormatDescriptionEvent; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import com.google.common.cache.RemovalListener; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import java.util.concurrent.atomic.AtomicLong; + +import static com.aliyun.polardbx.binlog.ConfigKeys.BINLOG_WRITE_TABLE_ID_BASE_VALUE; +import static com.aliyun.polardbx.binlog.canal.binlog.LogEvent.DELETE_ROWS_EVENT; +import static com.aliyun.polardbx.binlog.canal.binlog.LogEvent.DELETE_ROWS_EVENT_V1; +import static com.aliyun.polardbx.binlog.canal.binlog.LogEvent.TABLE_MAP_EVENT; +import static com.aliyun.polardbx.binlog.canal.binlog.LogEvent.UPDATE_ROWS_EVENT; +import static com.aliyun.polardbx.binlog.canal.binlog.LogEvent.UPDATE_ROWS_EVENT_V1; +import static com.aliyun.polardbx.binlog.canal.binlog.LogEvent.WRITE_ROWS_EVENT; +import static com.aliyun.polardbx.binlog.canal.binlog.LogEvent.WRITE_ROWS_EVENT_V1; + +/** + * created by ziyang.lb + **/ +@Slf4j +public class TableIdManager { + + /** + * TableId最大可占用6个字节 + */ + private static final long TABLE_ID_MAX_VALUE = 0XFFFFFFFFFFFFL; + /** + * TableId达到最大值的一半时,就尝试进行一下Reset,避免越界 + */ + private static final long TABLE_ID_RESET_THRESHOLD = TABLE_ID_MAX_VALUE >> 1; + /** + * TableId的初始值 + */ + private static final long TABLE_ID_BASE_VALUE = DynamicApplicationConfig.getLong(BINLOG_WRITE_TABLE_ID_BASE_VALUE); + + private LoadingCache cache; + private AtomicLong counter; + + //只有当创建了一个新的Binlog文件时,tryReset才可以设置为true + public TableIdManager(long initValue, boolean tryReset) { + if (tryReset && initValue >= TABLE_ID_RESET_THRESHOLD) { + log.info("reset table id , from initValue {} to baseValue {}.", initValue, TABLE_ID_BASE_VALUE); + initValue = TABLE_ID_BASE_VALUE; + } + init(initValue); + } + + public void invalidate(String schema, String table) { + if (StringUtils.isBlank(schema) || StringUtils.isBlank(table)) { + return; + } + cache.invalidate(buildKey(schema, table)); + } + + public long getTableId(String schema, String table) { + return cache.getUnchecked(buildKey(schema, table)); + } + + public void tryReset() { + if (counter.get() >= TABLE_ID_RESET_THRESHOLD) { + init(TABLE_ID_BASE_VALUE); + log.info("table id counter is reset."); + } + } + + private void init(long initValue) { + counter = new AtomicLong(initValue); + cache = CacheBuilder.newBuilder().removalListener((RemovalListener) notification -> { + log.info("invalidate tableId {} for table {}", notification.getValue(), notification.getKey()); + }).build(new CacheLoader() { + @Override + public Long load(String s) { + long newValue = TableIdManager.this.counter.addAndGet(1); + //容错逻辑,实际场景不应该出现大于MAX_VALUE的场景,触达TABLE_ID_RESET_THRESHOLD后就应该被reset了 + while (newValue > TABLE_ID_MAX_VALUE) { + newValue = newValue - TABLE_ID_MAX_VALUE; + } + return newValue; + } + }); + } + + private String buildKey(String schema, String table) { + return schema + "." + table; + } + + public static boolean containsTableId(byte logEventType) { + return logEventType == UPDATE_ROWS_EVENT || logEventType == UPDATE_ROWS_EVENT_V1 + || logEventType == DELETE_ROWS_EVENT || logEventType == DELETE_ROWS_EVENT_V1 + || logEventType == WRITE_ROWS_EVENT || logEventType == WRITE_ROWS_EVENT_V1 + || logEventType == TABLE_MAP_EVENT; + } + + public static int getTableIdLength() { + if (FormatDescriptionEvent.EVENT_HEADER_LENGTH[TABLE_MAP_EVENT - 1] == 6) { + return 4; + } else { + return 6; + } + } + + public static void main(String[] args) { + System.out.println(TABLE_ID_MAX_VALUE); + System.out.println(TABLE_ID_RESET_THRESHOLD); + } +} diff --git a/polardbx-cdc-format/pom.xml b/polardbx-cdc-format/pom.xml index 2331e441..8ada69de 100644 --- a/polardbx-cdc-format/pom.xml +++ b/polardbx-cdc-format/pom.xml @@ -5,7 +5,7 @@ polardbx-cdc com.aliyun.polardbx - 5.4.12-SNAPSHOT + 5.4.13-SNAPSHOT 4.0.0 @@ -22,7 +22,7 @@ com.aliyun.polardbx polardbx-cdc-canal - 5.4.12-SNAPSHOT + 5.4.13-SNAPSHOT test diff --git a/polardbx-cdc-format/src/main/java/com/aliyun/polardbx/binlog/format/QueryEventBuilder.java b/polardbx-cdc-format/src/main/java/com/aliyun/polardbx/binlog/format/QueryEventBuilder.java index a443da90..e4d82dc0 100644 --- a/polardbx-cdc-format/src/main/java/com/aliyun/polardbx/binlog/format/QueryEventBuilder.java +++ b/polardbx-cdc-format/src/main/java/com/aliyun/polardbx/binlog/format/QueryEventBuilder.java @@ -187,7 +187,6 @@ private int putStatusVars(AutoExpandBuffer outputData) throws UnsupportedEncodin statuVarPars.putInt(Q_FLAGS2_CODE, 0); statuVarPars.putLong(Q_SQL_MODE_CODE, SQLModeConsts.MODE_ONLY_FULL_GROUP_BY | SQLModeConsts.MODE_STRICT_TRANS_TABLES - | SQLModeConsts.MODE_NO_ZERO_IN_DATE | SQLModeConsts.MODE_NO_ZERO_DATE | SQLModeConsts.MODE_ERROR_FOR_DIVISION_BY_ZERO | SQLModeConsts.MODE_NO_ENGINE_SUBSTITUTION); statuVarPars.putString(Q_CATALOG_NZ_CODE, "std"); statuVarPars.putString(Q_TIME_ZONE_CODE, "SYSTEM"); diff --git a/polardbx-cdc-format/src/main/java/com/aliyun/polardbx/binlog/format/RowEventBuilder.java b/polardbx-cdc-format/src/main/java/com/aliyun/polardbx/binlog/format/RowEventBuilder.java index ff3f1430..3dcab029 100644 --- a/polardbx-cdc-format/src/main/java/com/aliyun/polardbx/binlog/format/RowEventBuilder.java +++ b/polardbx-cdc-format/src/main/java/com/aliyun/polardbx/binlog/format/RowEventBuilder.java @@ -51,17 +51,23 @@ public class RowEventBuilder extends BinlogBuilder { private int _flags; private String commitLog; - public RowEventBuilder(int tableId, int columnCount, BinlogEventType type, int createTime, long serverId) { + public RowEventBuilder(long tableId, int columnCount, BinlogEventType type, int createTime, long serverId) { this(tableId, columnCount, type.getType(), createTime, serverId); } - public RowEventBuilder(int tableId, int columnCount, int eventType, int createTime, long serverId) { + public RowEventBuilder(long tableId, int columnCount, int eventType, int createTime, long serverId) { super(createTime, eventType, serverId); this.tableId = tableId; this.columnCount = columnCount; _flags = ROW_FLAG_END_STATMENT; } + @Override + protected void writeCommonHeader(AutoExpandBuffer outputData) { + convertType(); + super.writeCommonHeader(outputData); + } + private boolean isEmpty(Collection collection) { return collection == null || collection.isEmpty(); } @@ -107,6 +113,27 @@ public boolean isInsert() { || eventType == BinlogEventType.WRITE_ROWS_EVENT_V1.getType(); } + public boolean isDelete() { + return eventType == BinlogEventType.DELETE_ROWS_EVENT.getType() + || eventType == BinlogEventType.DELETE_ROWS_EVENT_V1.getType(); + } + + private void convertType() { + if (isUpdate()) { + eventType = BinlogEventType.UPDATE_ROWS_EVENT.getType(); + return; + } + if (isInsert()) { + eventType = BinlogEventType.WRITE_ROWS_EVENT.getType(); + return; + } + if (isDelete()) { + eventType = BinlogEventType.DELETE_ROWS_EVENT.getType(); + return; + } + throw new UnsupportedOperationException("not support event type : " + eventType); + } + @Override protected void writePostHeader(AutoExpandBuffer outputData) throws Exception { int postHeaderLen = FormatDescriptionEvent.EVENT_HEADER_LENGTH[eventType - 1]; diff --git a/polardbx-cdc-format/src/main/java/com/aliyun/polardbx/binlog/format/TableMapEventBuilder.java b/polardbx-cdc-format/src/main/java/com/aliyun/polardbx/binlog/format/TableMapEventBuilder.java index 1f01d6ee..1e65a326 100644 --- a/polardbx-cdc-format/src/main/java/com/aliyun/polardbx/binlog/format/TableMapEventBuilder.java +++ b/polardbx-cdc-format/src/main/java/com/aliyun/polardbx/binlog/format/TableMapEventBuilder.java @@ -119,10 +119,10 @@ protected void writePayload(AutoExpandBuffer outputData) throws Exception { @Override protected void writePostHeader(AutoExpandBuffer outputData) throws Exception { - if (FormatDescriptionEvent.EVENT_HEADER_LENGTH[BinlogEventType.TABLE_MAP_EVENT.getType() - 1] == 8) { - numberToBytes(outputData, tableId, 6); - } else { + if (FormatDescriptionEvent.EVENT_HEADER_LENGTH[BinlogEventType.TABLE_MAP_EVENT.getType() - 1] == 6) { numberToBytes(outputData, tableId, INT32); + } else { + numberToBytes(outputData, tableId, 6); } numberToBytes(outputData, _flags, INT16); } diff --git a/polardbx-cdc-format/src/main/java/com/aliyun/polardbx/binlog/format/utils/CharsetConversion.java b/polardbx-cdc-format/src/main/java/com/aliyun/polardbx/binlog/format/utils/CharsetConversion.java index 2ba1b254..23ab9198 100644 --- a/polardbx-cdc-format/src/main/java/com/aliyun/polardbx/binlog/format/utils/CharsetConversion.java +++ b/polardbx-cdc-format/src/main/java/com/aliyun/polardbx/binlog/format/utils/CharsetConversion.java @@ -423,6 +423,11 @@ public static String getJavaCharset(String mysqlCharset) { return mysqlCharset; } + //https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8mb3.html + if ("utf8mb3".equalsIgnoreCase(mysqlCharset)) { + mysqlCharset = "utf8"; + } + Entry entry = mysqlCharsetMap.get(mysqlCharset.toUpperCase()); if (entry == null) { return mysqlCharset; diff --git a/polardbx-cdc-format/src/test/java/com/aliyun/com/polardbx/binlog/format/utils/CharsetConversionTest.java b/polardbx-cdc-format/src/test/java/com/aliyun/com/polardbx/binlog/format/utils/CharsetConversionTest.java new file mode 100644 index 00000000..ae243295 --- /dev/null +++ b/polardbx-cdc-format/src/test/java/com/aliyun/com/polardbx/binlog/format/utils/CharsetConversionTest.java @@ -0,0 +1,38 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.com.polardbx.binlog.format.utils; + +import com.aliyun.polardbx.binlog.canal.binlog.CharsetConversion; +import org.junit.Assert; +import org.junit.Test; + +/** + * created by ziyang.lb + **/ +public class CharsetConversionTest { + + @Test + public void testGetJavaCharset() { + String s1 = CharsetConversion.getJavaCharset("utf8"); + String s2 = CharsetConversion.getJavaCharset("utf8mb4"); + System.out.println(s1); + System.out.println(s2); + Assert.assertEquals(s1, "UTF-8"); + Assert.assertEquals(s2, "UTF-8"); + } +} diff --git a/polardbx-cdc-meta/pom.xml b/polardbx-cdc-meta/pom.xml index f4e61a45..6d552faa 100644 --- a/polardbx-cdc-meta/pom.xml +++ b/polardbx-cdc-meta/pom.xml @@ -5,7 +5,7 @@ polardbx-cdc com.aliyun.polardbx - 5.4.12-SNAPSHOT + 5.4.13-SNAPSHOT 4.0.0 @@ -21,7 +21,7 @@ com.aliyun.polardbx polardbx-cdc-common - 5.4.12-SNAPSHOT + 5.4.13-SNAPSHOT com.alibaba.fastsql @@ -32,7 +32,7 @@ com.aliyun.polardbx polardbx-cdc-canal - 5.4.12-SNAPSHOT + 5.4.13-SNAPSHOT @@ -40,6 +40,12 @@ polardbx-parser ${polardbx-parser.version} + + + com.aliyun.polardbx + polardbx-cdc-monitor + 5.4.13-SNAPSHOT + \ No newline at end of file diff --git a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/ConsistencyChecker.java b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/ConsistencyChecker.java new file mode 100644 index 00000000..33224bf3 --- /dev/null +++ b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/ConsistencyChecker.java @@ -0,0 +1,286 @@ +package com.aliyun.polardbx.binlog.cdc.meta; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.polardbx.druid.DbType; +import com.alibaba.polardbx.druid.sql.SQLUtils; +import com.alibaba.polardbx.druid.sql.ast.SQLStatement; +import com.alibaba.polardbx.druid.sql.dialect.mysql.ast.statement.MySqlRenameTableStatement; +import com.alibaba.polardbx.druid.sql.parser.SQLParserUtils; +import com.alibaba.polardbx.druid.sql.parser.SQLStatementParser; +import com.aliyun.polardbx.binlog.DynamicApplicationConfig; +import com.aliyun.polardbx.binlog.SpringContextHolder; +import com.aliyun.polardbx.binlog.canal.core.ddl.TableMeta; +import com.aliyun.polardbx.binlog.cdc.meta.domain.DDLRecord; +import com.aliyun.polardbx.binlog.cdc.topology.LogicMetaTopology; +import com.aliyun.polardbx.binlog.cdc.topology.TopologyManager; +import com.aliyun.polardbx.binlog.cdc.topology.vo.TopologyRecord; +import com.aliyun.polardbx.binlog.error.PolardbxException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.Pair; +import org.springframework.jdbc.core.JdbcTemplate; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static com.aliyun.polardbx.binlog.ConfigKeys.META_CHECK_CONSISTENCY_AFTER_EACH_APPLY; +import static com.aliyun.polardbx.binlog.util.FastSQLConstant.FEATURES; + +/** + * created by ziyang.lb + **/ +public class ConsistencyChecker { + + private static final Gson GSON = new GsonBuilder().create(); + + private final JdbcTemplate polarxTemplate = SpringContextHolder.getObject("polarxJdbcTemplate"); + private final TopologyManager topologyManager; + private final PolarDbXLogicTableMeta polarDbXLogicTableMeta; + private final PolarDbXStorageTableMeta polarDbXStorageTableMeta; + private final PolarDbXTableMetaManager polarDbXTableMetaManager; + private final String cdcPhyTableName; + private final String storageInstId; + + public ConsistencyChecker(TopologyManager topologyManager, PolarDbXLogicTableMeta polarDbXLogicTableMeta, + PolarDbXStorageTableMeta polarDbXStorageTableMeta, + PolarDbXTableMetaManager polarDbXTableMetaManager, String storageInstId) { + this.topologyManager = topologyManager; + this.polarDbXLogicTableMeta = polarDbXLogicTableMeta; + this.polarDbXStorageTableMeta = polarDbXStorageTableMeta; + this.polarDbXTableMetaManager = polarDbXTableMetaManager; + this.storageInstId = storageInstId; + this.cdcPhyTableName = getCdcPhyTableName(); + } + + public void checkLogicAndPhysicalConsistency(String tso, DDLRecord record) { + boolean needCheckConsistency = DynamicApplicationConfig.getBoolean(META_CHECK_CONSISTENCY_AFTER_EACH_APPLY); + if (needCheckConsistency) { + TopologyRecord r = GSON.fromJson(record.getMetaInfo(), TopologyRecord.class); + if ("DROP_DATABASE".equals(record.getSqlKind())) { + checkForDropDatabase(tso, record); + } else if ("DROP_TABLE".equals(record.getSqlKind())) { + checkForDropTable(tso, record); + } else if ("RENAME_TABLE".equals(record.getSqlKind())) { + String tableName = renameTo(record.getDdlSql()); + compareForOneLogicTable(tso, record.getSchemaName(), tableName, r != null); + } else if (StringUtils.isNotEmpty(record.getTableName())) { + compareForOneLogicTable(tso, record.getSchemaName(), record.getTableName(), r != null); + } + } + } + + public void checkTopologyConsistencyWithOrigin(String tso, DDLRecord ddlRecord) { + //校验topology的一致性 + boolean needCheckConsistency = DynamicApplicationConfig.getBoolean(META_CHECK_CONSISTENCY_AFTER_EACH_APPLY); + if (!needCheckConsistency) { + return; + } + + if (CreateDropTableWithExistFilter.shouldIgnore(ddlRecord.getDdlSql(), ddlRecord.getId(), + ddlRecord.getJobId())) { + return; + } + + String metaStr = polarxTemplate.queryForObject("/!+TDDL:node(0)*/select meta_info from __cdc___000000." + + cdcPhyTableName + " where id = " + ddlRecord.getId(), String.class); + + if (StringUtils.isNotBlank(metaStr)) { + TopologyRecord r = GSON.fromJson(metaStr, TopologyRecord.class); + if (r == null) { + return; + } + + if (r.getLogicTableMeta() != null) { + String renameTo = renameTo(ddlRecord.getDdlSql()); + Pair pair = + topologyManager.getTopology(ddlRecord.getSchemaName(), + StringUtils.isNotBlank(renameTo) ? renameTo : ddlRecord.getTableName()); + LogicMetaTopology.LogicTableMetaTopology srcTopology = r.getLogicTableMeta(); + LogicMetaTopology.LogicTableMetaTopology destTopology = pair.getValue(); + + boolean result = false; + if (destTopology != null) { + result = + StringUtils.equalsIgnoreCase(srcTopology.getTableName(), destTopology.getTableName()) && + (srcTopology.getTableType() == destTopology.getTableType()) && + comparePhyTableTopology(srcTopology.getPhySchemas(), destTopology.getPhySchemas()); + } + + if (!result) { + throw new PolardbxException( + String.format("check table topology failed, tso is %s, metaStr is %s, origin is %s, " + + "dest is %s.", tso, metaStr, JSONObject.toJSONString(srcTopology), + JSONObject.toJSONString(destTopology))); + } + } else if (r.getLogicDbMeta() != null) { + LogicMetaTopology.LogicDbTopology srcTopology = r.getLogicDbMeta(); + LogicMetaTopology.LogicDbTopology destTopology = getTopologyBySchema(ddlRecord.getSchemaName()); + boolean result = StringUtils.equalsIgnoreCase(srcTopology.getSchema(), destTopology.getSchema()) && + comparePhyDbTopology(srcTopology.getPhySchemas(), destTopology.getPhySchemas()); + if (!result) { + throw new PolardbxException( + String.format("check db topology failed, tso is %s, metaStr is %s, origin is %s, dest is %s.", + tso, metaStr, JSONObject.toJSONString(srcTopology), JSONObject.toJSONString(destTopology))); + } + } + } + } + + private void checkForDropDatabase(String tso, DDLRecord record) { + LogicMetaTopology.LogicDbTopology logicDbTopology = topologyManager.getTopology(record.getSchemaName()); + if (logicDbTopology != null) { + String message = String.format("check consistency failed, schema has been dropped but topology " + + "still there, schema is %s, tso is %s", record.getSchemaName(), tso); + throw new PolardbxException(message); + } + } + + private void checkForDropTable(String tso, DDLRecord record) { + Pair pair = + topologyManager.getTopology(record.getSchemaName(), record.getTableName()); + if (pair.getRight() != null) { + String message = String.format("check consistency failed, table has been dropped but topology " + + "still there, schema is %s, table is %s, tso is %s", record.getSchemaName(), record.getTableName(), + tso); + throw new PolardbxException(message); + } + } + + private void compareForOneLogicTable(String tso, String logicSchema, String logicTable, + boolean createPhyIfNotExist) { + Pair pair = + topologyManager.getTopology(logicSchema, logicTable); + LogicMetaTopology.LogicTableMetaTopology logicTableMetaTopology = pair.getRight(); + if (logicTableMetaTopology == null) { + throw new PolardbxException( + String.format("logic table meta topology should not be null, logicSchema %s, logicTable %s ,tso %s.", + logicSchema, logicTable, tso)); + } + + if (logicTableMetaTopology.getPhySchemas() != null) { + for (LogicMetaTopology.PhyTableTopology phyTableTopology : logicTableMetaTopology.getPhySchemas()) { + if (storageInstId.equals(phyTableTopology.getStorageInstId())) { + for (String table : phyTableTopology.getPhyTables()) { + compareLogicWithPhysicalTable(tso, logicSchema, logicTable, + phyTableTopology.getSchema(), table, createPhyIfNotExist); + } + } + } + } + } + + private void compareLogicWithPhysicalTable(String tso, String logicSchemaName, String logicTableName, + String phySchemaName, String phyTableName, boolean createPhyIfNotExist) { + //get table meta + TableMeta logicDimTableMeta = polarDbXLogicTableMeta.findDistinctPhy(logicSchemaName, logicTableName); + if (logicDimTableMeta == null) { + logicDimTableMeta = polarDbXLogicTableMeta.find(logicSchemaName, logicTableName); + } + TableMeta phyDimTableMeta = + createPhyIfNotExist ? polarDbXTableMetaManager.findPhyTable(phySchemaName, phyTableName) : + polarDbXStorageTableMeta.find(phySchemaName, phyTableName); + + // check meta if null + if (logicDimTableMeta == null) { + String message = String.format("check consistency failed, can`t find logic table meta %s:%s, with tso %s.", + logicSchemaName, logicTableName, tso); + throw new PolardbxException(message); + } + if (phyDimTableMeta == null) { + String message = String.format("check consistency failed, can`t find phy table meta %s:%s, with tso %s.", + phySchemaName, phyTableName, tso); + throw new PolardbxException(message); + } + + //compare table meta + List logicDimColumns = logicDimTableMeta.getFields().stream() + .map(f -> SQLUtils.normalize(f.getColumnName().toLowerCase())).collect(Collectors.toList()); + List phyDimColumns = phyDimTableMeta.getFields().stream() + .map(f -> SQLUtils.normalize(f.getColumnName().toLowerCase())).collect(Collectors.toList()); + boolean result = logicDimColumns.equals(phyDimColumns); + if (!result) { + String message = String.format( + "check consistency failed, logic and phy table meta is not consistent, logicSchema %s," + + " logicTable %s , phySchema %s, phyTable %s,logicColumns %s, phy Columns %s, tso %s.", + logicSchemaName, logicTableName, phySchemaName, phyTableName, logicDimColumns, phyDimColumns, tso); + throw new PolardbxException(message); + } + } + + private boolean comparePhyDbTopology(List src, + List dest) { + if (src.size() != dest.size()) { + return false; + } + + boolean result = true; + for (int i = 0; i < src.size(); i++) { + LogicMetaTopology.PhyDbTopology t1 = src.get(i); + LogicMetaTopology.PhyDbTopology t2 = dest.get(i); + result &= StringUtils.equalsIgnoreCase(t1.getSchema(), t2.getSchema()) && StringUtils + .equalsIgnoreCase(t1.getGroup(), t2.getGroup()) && StringUtils + .equalsIgnoreCase(t1.getStorageInstId(), t2.getStorageInstId()); + } + return result; + } + + private LogicMetaTopology.LogicDbTopology getTopologyBySchema(String schemaName) { + LogicMetaTopology.LogicDbTopology topology = topologyManager.getTopology(schemaName); + + LogicMetaTopology.LogicDbTopology result = new LogicMetaTopology.LogicDbTopology(); + result.setSchema(topology.getSchema()); + result.setCharset(topology.getCharset()); + result.setPhySchemas(topology.getPhySchemas()); + return result; + } + + private boolean comparePhyTableTopology(List src, + List dest) { + if (src.size() != dest.size()) { + return false; + } + + boolean result = true; + for (int i = 0; i < src.size(); i++) { + LogicMetaTopology.PhyTableTopology t1 = src.get(i); + LogicMetaTopology.PhyTableTopology t2 = dest.get(i); + result &= StringUtils.equalsIgnoreCase(t1.getSchema(), t2.getSchema()) && StringUtils + .equalsIgnoreCase(t1.getGroup(), t2.getGroup()) && StringUtils + .equalsIgnoreCase(t1.getStorageInstId(), t2.getStorageInstId()); + result &= (t1.getPhyTables().size() == t2.getPhyTables().size()); + if (!result) { + return result; + } + for (int j = 0; j < t1.getPhyTables().size(); j++) { + String p1 = t1.getPhyTables().get(j); + String p2 = t2.getPhyTables().get(j); + result &= StringUtils.equalsIgnoreCase(p1, p2); + } + } + return result; + } + + private String getCdcPhyTableName() { + List> list = polarxTemplate.queryForList("show topology from __cdc__.__cdc_ddl_record__"); + return list.get(0).get("TABLE_NAME").toString(); + } + + private static String renameTo(String sql) { + if (StringUtils.isNotBlank(sql)) { + SQLStatementParser parser = + SQLParserUtils.createSQLStatementParser(sql, DbType.mysql, FEATURES); + SQLStatement stmt = parser.parseStatementList().get(0); + + if (stmt instanceof MySqlRenameTableStatement) { + MySqlRenameTableStatement renameTableStatement = (MySqlRenameTableStatement) stmt; + for (MySqlRenameTableStatement.Item item : renameTableStatement.getItems()) { + //CN只支持一次Rename一张表,直接返回即可 + return SQLUtils.normalize(item.getTo().getSimpleName()); + } + } + } + return ""; + } +} diff --git a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/CreateDropTableWithExistFilter.java b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/CreateDropTableWithExistFilter.java new file mode 100644 index 00000000..6d57e933 --- /dev/null +++ b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/CreateDropTableWithExistFilter.java @@ -0,0 +1,51 @@ +package com.aliyun.polardbx.binlog.cdc.meta; + +import com.alibaba.polardbx.druid.DbType; +import com.alibaba.polardbx.druid.sql.ast.SQLStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLDropTableStatement; +import com.alibaba.polardbx.druid.sql.dialect.mysql.ast.statement.MySqlCreateTableStatement; +import com.alibaba.polardbx.druid.sql.parser.SQLParserUtils; +import com.alibaba.polardbx.druid.sql.parser.SQLStatementParser; + +import static com.aliyun.polardbx.binlog.util.FastSQLConstant.FEATURES; + +/** + * created by ziyang.lb + **/ +public class CreateDropTableWithExistFilter { + + //@see Aone,ID:39665786 + public static boolean shouldIgnore(String sql, Long ddlRecordId, Long ddlJobId) { + if (ddlRecordId != null && ddlJobId == null && isCreateTableWithIfNotExist(sql)) { + return true; + } + if (ddlRecordId != null && ddlJobId == null && isDropTableWithIfExist(sql)) { + return true; + } + return false; + } + + private static boolean isCreateTableWithIfNotExist(String sql) { + SQLStatementParser parser = + SQLParserUtils.createSQLStatementParser(sql, DbType.mysql, FEATURES); + SQLStatement stmt = parser.parseStatementList().get(0); + + if (stmt instanceof MySqlCreateTableStatement) { + MySqlCreateTableStatement createTableStatement = (MySqlCreateTableStatement) stmt; + return createTableStatement.isIfNotExists(); + } + return false; + } + + private static boolean isDropTableWithIfExist(String sql) { + SQLStatementParser parser = + SQLParserUtils.createSQLStatementParser(sql, DbType.mysql, FEATURES); + SQLStatement stmt = parser.parseStatementList().get(0); + + if (stmt instanceof SQLDropTableStatement) { + SQLDropTableStatement dropTableStatement = (SQLDropTableStatement) stmt; + return dropTableStatement.isIfExists(); + } + return false; + } +} diff --git a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/ICdcTableMeta.java b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/ICdcTableMeta.java new file mode 100644 index 00000000..7ac0001b --- /dev/null +++ b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/ICdcTableMeta.java @@ -0,0 +1,20 @@ +package com.aliyun.polardbx.binlog.cdc.meta; + +import com.aliyun.polardbx.binlog.canal.core.ddl.tsdb.TableMetaTSDB; + +/** + * Created by ziyang.lb + */ +public interface ICdcTableMeta extends TableMetaTSDB { + + /** + * Apply镜像元数据 + */ + void applySnapshot(String snapshotTso); + + /** + * Apply历史变更 + */ + void applyHistory(String snapshotTso, String rollbackTso); + +} diff --git a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/LogicTableMeta.java b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/LogicTableMeta.java index 63b7bc92..afac8ff7 100644 --- a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/LogicTableMeta.java +++ b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/LogicTableMeta.java @@ -23,7 +23,7 @@ import java.util.List; /** - * Created by Shuguang + * created by ziyang.lb */ public class LogicTableMeta { private boolean compatible;//是否兼容 diff --git a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/MetaType.java b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/MetaType.java new file mode 100644 index 00000000..1ec7f0f1 --- /dev/null +++ b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/MetaType.java @@ -0,0 +1,25 @@ +package com.aliyun.polardbx.binlog.cdc.meta; + +/** + * created by ziyang.lb + **/ +public enum MetaType { + /** + * Snapshot + */ + SNAPSHOT((byte) 1), + /** + * DDL SQL + */ + DDL((byte) 2); + + private final byte value; + + MetaType(byte value) { + this.value = value; + } + + public byte getValue() { + return value; + } +} diff --git a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/PolarDbXLogicTableMeta.java b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/PolarDbXLogicTableMeta.java index bb9e48a3..aeb5baa9 100644 --- a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/PolarDbXLogicTableMeta.java +++ b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/PolarDbXLogicTableMeta.java @@ -25,10 +25,12 @@ import com.alibaba.polardbx.druid.sql.ast.statement.SQLDropTableStatement; import com.alibaba.polardbx.druid.sql.ast.statement.SQLExprTableSource; import com.alibaba.polardbx.druid.sql.dialect.mysql.ast.statement.MySqlCreateTableStatement; +import com.alibaba.polardbx.druid.sql.dialect.mysql.ast.statement.MySqlRenameTableStatement; import com.alibaba.polardbx.druid.sql.parser.SQLParserUtils; import com.alibaba.polardbx.druid.sql.parser.SQLStatementParser; import com.alibaba.polardbx.druid.sql.repository.Schema; import com.aliyun.polardbx.binlog.SpringContextHolder; +import com.aliyun.polardbx.binlog.canal.core.ddl.TableMeta; import com.aliyun.polardbx.binlog.canal.core.ddl.tsdb.MemoryTableMeta; import com.aliyun.polardbx.binlog.canal.core.model.BinlogPosition; import com.aliyun.polardbx.binlog.cdc.meta.domain.DDLExtInfo; @@ -39,7 +41,8 @@ import com.aliyun.polardbx.binlog.dao.BinlogLogicMetaHistoryDynamicSqlSupport; import com.aliyun.polardbx.binlog.dao.BinlogLogicMetaHistoryMapper; import com.aliyun.polardbx.binlog.domain.po.BinlogLogicMetaHistory; -import com.aliyun.polardbx.binlog.util.FastSQLConstant; +import com.aliyun.polardbx.binlog.jvm.JvmSnapshot; +import com.aliyun.polardbx.binlog.jvm.JvmUtils; import com.google.common.base.Preconditions; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -48,34 +51,29 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.dao.DuplicateKeyException; -import org.springframework.jdbc.core.JdbcTemplate; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLong; import static com.aliyun.polardbx.binlog.CommonUtils.escape; +import static com.aliyun.polardbx.binlog.util.FastSQLConstant.FEATURES; /** - * Created by Shuguang + * Created by ShuGuang,ziyang.lb */ -public class PolarDbXLogicTableMeta extends MemoryTableMeta { +public class PolarDbXLogicTableMeta extends MemoryTableMeta implements ICdcTableMeta { private static final Logger logger = LoggerFactory.getLogger(PolarDbXLogicTableMeta.class); - private static final byte TYPE_SNAPSHOT = 1; - private static final byte TYPE_DDL = 2; - private static final int SIZE = 100; + private static final int PAGE_SIZE = 100; private static final Gson GSON = new GsonBuilder().create(); + + private final TopologyManager topologyManager; + private final MemoryTableMeta distinctPhyMeta = new MemoryTableMeta(logger);//保存逻辑表和物理表列序不一致的meta private final BinlogLogicMetaHistoryMapper binlogLogicMetaHistoryMapper = SpringContextHolder.getObject( BinlogLogicMetaHistoryMapper.class); - private AtomicBoolean initialized = new AtomicBoolean(false); - private String destination; - private TopologyManager topologyManager; - - private MemoryTableMeta phyMeta = new MemoryTableMeta(logger); - public PolarDbXLogicTableMeta(TopologyManager topologyManager) { super(logger); this.topologyManager = topologyManager; @@ -83,130 +81,165 @@ public PolarDbXLogicTableMeta(TopologyManager topologyManager) { @Override public boolean init(final String destination) { - if (initialized.compareAndSet(false, true)) { - this.destination = destination; - } return true; } - public boolean applyBase(BinlogPosition position, LogicMetaTopology topology) { - topology.getLogicDbMetas().forEach(s -> { - String schema = s.getSchema(); - s.getLogicTableMetas().forEach(t -> { - String createSql = t.getCreateSql(); - apply(position, schema, createSql, null); - if (StringUtils.isNotEmpty(t.getCreateSql4Phy())) { - phyMeta.apply(position, schema, t.getCreateSql4Phy(), null); - } - }); - }); - topologyManager.setTopology(topology); - DDLRecord record = DDLRecord.builder().schemaName("*").ddlSql(GSON.toJson(snapshot())).metaInfo( - GSON.toJson(topology)).build(); - applySnapshotToDB(position, record, TYPE_SNAPSHOT, null); - return true; + public void applyBase(BinlogPosition position, LogicMetaTopology topology) { + applySnapshotInternal(topology); + DDLRecord record = DDLRecord.builder().schemaName("*").ddlSql(GSON.toJson(snapshot())) + .metaInfo(GSON.toJson(topology)).build(); + applyToDb(position, record, MetaType.SNAPSHOT.getValue(), null); } public boolean apply(BinlogPosition position, DDLRecord record, String extra) { - //apply meta - if (checkBeforeApply(position.getRtso(), record.getSchemaName(), record.getTableName(), record.getDdlSql())) { + boolean result = false; + if (checkBeforeApply(position.getRtso(), record.getSchemaName(), record.getTableName(), record.getDdlSql(), + record.getId(), record.getJobId())) { apply(position, record.getSchemaName(), record.getDdlSql(), extra); - if (record.getExtInfo() != null && StringUtils.isNotEmpty(record.getExtInfo().getCreateSql4PhyTable())) { - phyMeta.apply(position, record.getSchemaName(), record.getExtInfo().getCreateSql4PhyTable(), extra); + + //apply distinct phy meta + if (record.getExtInfo() != null) { + String createSql4PhyTable = record.getExtInfo().getCreateSql4PhyTable(); + if (StringUtils.isNotEmpty(createSql4PhyTable)) { + distinctPhyMeta.apply(position, record.getSchemaName(), StringUtils.lowerCase(createSql4PhyTable), + extra); + } } + //apply topology TopologyRecord r = GSON.fromJson(record.getMetaInfo(), TopologyRecord.class); - - fixOrDropPhyMeta(position.getRtso(), record.getSchemaName(), record.getTableName(), record.getSqlKind(), - record.getDdlSql()); + tryRepair1(position.getRtso(), r, record); + updateOrDropDistinctPhyMeta(position.getRtso(), record.getSchemaName(), record.getTableName(), + record.getSqlKind(), record.getDdlSql(), record.getExtInfo()); dropTopology(position.getRtso(), record.getSchemaName(), record.getTableName(), record.getDdlSql()); - topologyManager.apply(position.getRtso(), record.getSchemaName(), record.getTableName(), r); + + result = true; } - // store with db - applySnapshotToDB(position, record, TYPE_DDL, extra); - return true; + applyToDb(position, record, MetaType.DDL.getValue(), extra); + Printer.tryPrint(position, record.getSchemaName(), record.getTableName(), this); + return result; } @Override - public boolean rollback(BinlogPosition position) { - // 每次rollback需要重新构建一次memory data - destory(); - //获取快照tso - BinlogPosition snapshotPosition = getSnapshotPosition(position); - if (snapshotPosition.getRtso() != null) { - //apply snapshot - applySnapshot(snapshotPosition.getRtso()); - //重放ddl和topology - applyHistory(snapshotPosition.getRtso(), position.getRtso()); - } - return true; - } + public void applySnapshot(String snapshotTso) { + // log before apply snapshot + AtomicLong applyCount = new AtomicLong(0L); + long startTime = System.currentTimeMillis(); + JvmSnapshot jvmSnapshot = JvmUtils.buildJvmSnapshot(); + logger.info("build logic meta snapshot started, current used memory -> young:{}, old:{}", + jvmSnapshot.getYoungUsed(), jvmSnapshot.getOldUsed()); - private void applySnapshot(String snapshotTso) { + // do apply + destory(); Optional snapshot = binlogLogicMetaHistoryMapper.selectOne(s -> s - .where(BinlogLogicMetaHistoryDynamicSqlSupport.tso, SqlBuilder.isEqualTo(snapshotTso)) - ); - + .where(BinlogLogicMetaHistoryDynamicSqlSupport.tso, SqlBuilder.isEqualTo(snapshotTso))); snapshot.ifPresent(s -> { logger.warn("apply logic snapshot: [id={}, dbName={}, tso={}]", s.getId(), s.getDbName(), s.getTso()); LogicMetaTopology topology = GSON.fromJson(s.getTopology(), LogicMetaTopology.class); - topology.getLogicDbMetas().forEach(x -> { - String schema = x.getSchema(); - x.getLogicTableMetas().forEach(t -> { - String createSql = t.getCreateSql(); - apply(null, schema, createSql, null); - if (StringUtils.isNotEmpty(t.getCreateSql4Phy())) { - phyMeta.apply(null, schema, t.getCreateSql4Phy(), null); - } - }); + applyCount.set(applySnapshotInternal(topology)); + }); + + //log after apply snapshot + long costTime = System.currentTimeMillis() - startTime; + jvmSnapshot = JvmUtils.buildJvmSnapshot(); + logger.info("build logic meta snapshot finished, applyCount {}, cost time {}(ms), current used memory -> " + + "young:{}, old:{}", costTime, applyCount.get(), jvmSnapshot.getYoungUsed(), jvmSnapshot.getOldUsed()); + } + + private long applySnapshotInternal(LogicMetaTopology topology) { + AtomicLong applyCount = new AtomicLong(0L); + topology.getLogicDbMetas().forEach(s -> { + String schema = s.getSchema(); + s.getLogicTableMetas().forEach(t -> { + String createSql = t.getCreateSql(); + apply(null, schema, createSql, null); + if (StringUtils.isNotEmpty(t.getCreateSql4Phy())) { + distinctPhyMeta.apply(null, schema, t.getCreateSql4Phy(), null); + } + applyCount.incrementAndGet(); }); - topologyManager.setTopology(topology); }); + topologyManager.setTopology(topology); + return applyCount.get(); } - private void applyHistory(String snapshotTso, String rollbackTso) { - BinlogPosition position = new BinlogPosition(null, snapshotTso); + @Override + public void applyHistory(String snapshotTso, String rollbackTso) { + // log before apply + long startTime = System.currentTimeMillis(); + long applyCount = 0; + JvmSnapshot jvmSnapshot = JvmUtils.buildJvmSnapshot(); + logger.info("apply logic ddl history started, current used memory -> young:{}, old:{}", + jvmSnapshot.getYoungUsed(), jvmSnapshot.getOldUsed()); + + //apply history while (true) { + final String snapshotTsoCondition = snapshotTso; List histories = binlogLogicMetaHistoryMapper.select(s -> s - .where(BinlogLogicMetaHistoryDynamicSqlSupport.tso, SqlBuilder.isGreaterThan(position.getRtso())) + .where(BinlogLogicMetaHistoryDynamicSqlSupport.tso, SqlBuilder.isGreaterThan(snapshotTsoCondition)) .and(BinlogLogicMetaHistoryDynamicSqlSupport.tso, SqlBuilder.isLessThanOrEqualTo(rollbackTso)) - .orderBy(BinlogLogicMetaHistoryDynamicSqlSupport.tso).limit(SIZE) + .and(BinlogLogicMetaHistoryDynamicSqlSupport.type, SqlBuilder.isEqualTo(MetaType.DDL.getValue())) + .orderBy(BinlogLogicMetaHistoryDynamicSqlSupport.tso).limit(PAGE_SIZE) ); histories.forEach(h -> { - if (checkBeforeApply(position.getRtso(), h.getDbName(), h.getTableName(), h.getDdl())) { - super.apply(null, h.getDbName(), h.getDdl(), null); - if (StringUtils.isNotEmpty(h.getExtInfo())) { - DDLExtInfo extInfo = GSON.fromJson(h.getExtInfo(), DDLExtInfo.class); - if (extInfo != null && StringUtils.isNotEmpty(extInfo.getCreateSql4PhyTable())) { - phyMeta.apply(null, h.getDbName(), extInfo.getCreateSql4PhyTable(), null); - } + toLowerCase(h); + BinlogPosition position = new BinlogPosition(null, h.getTso()); + if (checkBeforeApply(h.getTso(), h.getDbName(), h.getTableName(), h.getDdl(), h.getDdlRecordId(), + h.getDdlJobId())) { + super.apply(position, h.getDbName(), h.getDdl(), null); + + // apply create sql for distinct phy meta + DDLExtInfo extInfo = parseExtInfo(h.getExtInfo()); + if (extInfo != null && StringUtils.isNotEmpty(extInfo.getCreateSql4PhyTable())) { + distinctPhyMeta.apply(position, h.getDbName(), extInfo.getCreateSql4PhyTable(), null); } + + // apply topology if (StringUtils.isNotEmpty(h.getTopology())) { TopologyRecord topologyRecord = GSON.fromJson(h.getTopology(), TopologyRecord.class); - logger - .warn("apply logic ddl: [id={}, dbName={}, tso={}]", h.getId(), h.getDbName(), h.getTso()); topologyManager.apply(h.getTso(), h.getDbName(), h.getTableName(), topologyRecord); } - fixOrDropPhyMeta(h.getTso(), h.getDbName(), h.getTableName(), h.getSqlKind(), h.getDdl()); + + // try update distinct phy meta + updateOrDropDistinctPhyMeta(h.getTso(), h.getDbName(), h.getTableName(), h.getSqlKind(), + h.getDdl(), extInfo); + + //try drop topology dropTopology(h.getTso(), h.getDbName(), h.getTableName(), h.getDdl()); + + if (logger.isDebugEnabled()) { + logger.debug("apply one history logic ddl : [id={}, dbName={}, tableName={}, tso={}]", + h.getId(), h.getDbName(), h.getTableName(), h.getTso()); + } } + + Printer.tryPrint(position, h.getDbName(), h.getTableName(), this); }); - if (histories.size() == SIZE) { - position.setRtso(histories.get(SIZE - 1).getTso()); + + applyCount += histories.size(); + if (histories.size() == PAGE_SIZE) { + snapshotTso = histories.get(PAGE_SIZE - 1).getTso(); } else { break; } } + + //log after apply + long costTime = System.currentTimeMillis() - startTime; + jvmSnapshot = JvmUtils.buildJvmSnapshot(); + logger.info("apply logic ddl history finished, snapshot tso {}, rollback tso {}, cost time {}(ms)," + + " applyCount {}" + ", current used memory -> young:{}, old:{}", snapshotTso, rollbackTso, costTime, + applyCount, jvmSnapshot.getYoungUsed(), jvmSnapshot.getOldUsed()); } /** * 快照备份到存储, 这里只需要备份变动的table */ - private boolean applySnapshotToDB(BinlogPosition position, DDLRecord record, byte type, String extra) { + private void applyToDb(BinlogPosition position, DDLRecord record, byte type, String extra) { if (position == null) { - return false; + return; } try { BinlogLogicMetaHistory history = BinlogLogicMetaHistory.builder() @@ -217,37 +250,54 @@ private boolean applySnapshotToDB(BinlogPosition position, DDLRecord record, byt .ddl(record.getDdlSql()) .topology(record.getMetaInfo()).type(type) .extInfo(record.getExtInfo() != null ? GSON.toJson(record.getExtInfo()) : null) + .ddlRecordId(record.getId()) + .ddlJobId(record.getJobId()) .build(); binlogLogicMetaHistoryMapper.insert(history); } catch (DuplicateKeyException e) { - logger.warn("ddl record already applied, ignore this time, record info is " + record); + if (logger.isDebugEnabled()) { + logger.debug("ddl record already applied, ignore this time, record tso is " + position.getRtso()); + } } - return true; - } - - /** - * 从存储从获取快照位点 - */ - protected BinlogPosition getSnapshotPosition(BinlogPosition position) { - JdbcTemplate metaJdbcTemplate = SpringContextHolder.getObject("metaJdbcTemplate"); - String tso = metaJdbcTemplate.queryForObject( - "select max(tso) tso from binlog_logic_meta_history where tso <= '" + position.getRtso() + "' and type = " - + TYPE_SNAPSHOT, - String.class); - return new BinlogPosition(null, tso); } - public Map phySnapshot() { - Collection schemas = phyMeta.getRepository().getSchemas(); + public Map distinctPhySnapshot() { + Collection schemas = distinctPhyMeta.getRepository().getSchemas(); schemas.forEach(schema -> { logger.warn("to be replaced phySchema:{}, tables:{}", schema.getCatalog(), schema.showTables()); }); - return phyMeta.snapshot(); + return distinctPhyMeta.snapshot(); + } + + public TableMeta findDistinctPhy(String schema, String table) { + return distinctPhyMeta.find(schema, table); + } + + public String distinctPhySnapshot(String schema, String table) { + return distinctPhyMeta.snapshot(schema, table); + } + + /** + * 兼容性方法,主要为了兼容很老之前的一个内核版本,在Rename场景下,Topology中记录的tablename不是Rename后的名字,而是rename前的名字 + */ + private void tryRepair1(String tso, TopologyRecord r, DDLRecord record) { + if (r != null && StringUtils.isNotEmpty(record.getDdlSql())) { + SQLStatementParser parser = SQLParserUtils.createSQLStatementParser(record.getDdlSql(), DbType.mysql, + FEATURES); + SQLStatement stmt = parser.parseStatementList().get(0); + if (stmt instanceof MySqlRenameTableStatement) { + String renameTo = ((MySqlRenameTableStatement) stmt).getItems().get(0).getTo().getSimpleName(); + if (r.getLogicTableMeta() != null) { + renameTo = SQLUtils.normalize(renameTo); + r.getLogicTableMeta().setTableName(renameTo); + record.setMetaInfo(GSON.toJson(r)); + } + } + } } private void dropTopology(String tso, String schema, String tableName, String ddl) { - SQLStatementParser parser = SQLParserUtils.createSQLStatementParser(ddl, DbType.mysql, - FastSQLConstant.FEATURES); + SQLStatementParser parser = SQLParserUtils.createSQLStatementParser(ddl, DbType.mysql, FEATURES); SQLStatement stmt = parser.parseStatementList().get(0); if (stmt instanceof SQLDropDatabaseStatement) { String databaseName = ((SQLDropDatabaseStatement) stmt).getDatabaseName(); @@ -266,40 +316,98 @@ private void dropTopology(String tso, String schema, String tableName, String dd } } - private boolean checkBeforeApply(String tso, String schema, String tableName, String ddl) { + private boolean checkBeforeApply(String tso, String schema, String tableName, String ddl, Long ddlRecordId, + Long ddlJobId) { SQLStatementParser parser = - SQLParserUtils.createSQLStatementParser(ddl, DbType.mysql, FastSQLConstant.FEATURES); + SQLParserUtils.createSQLStatementParser(ddl, DbType.mysql, FEATURES); SQLStatement stmt = parser.parseStatementList().get(0); - // 如果是create database sql,做一下double check,将元数据尝试进行一下清理 - // 正常不应该有元数据的,但是不排除意外情况,比如:polarx内核针对drop database未接入ddl引擎,sql执行和cdc打标无法保证原子性 + boolean result = true; if (stmt instanceof SQLCreateDatabaseStatement) { + tryRemovePreviousMeta((SQLCreateDatabaseStatement) stmt, schema, tso); SQLCreateDatabaseStatement createDatabaseStatement = (SQLCreateDatabaseStatement) stmt; - // 对于含有if not exist的sql来说,无法判断当前create database操作是否是有效操作,所以不予处理 - if (!createDatabaseStatement.isIfNotExists()) { - String databaseName = createDatabaseStatement.getDatabaseName(); - databaseName = SQLUtils.normalize(databaseName); - Preconditions.checkArgument(StringUtils.equalsIgnoreCase(databaseName, schema), - "create database record should be coincident DDL(" + databaseName + "), History(" + schema + ")"); - super.apply(null, schema, "drop database if exists `" + escape(databaseName) + "`", null); - topologyManager.removeTopology(tso, schema.toLowerCase(), null); + result = !createDatabaseStatement.isIfNotExists() + || (topologyManager.getTopology(schema) == null && !isSchemaExists(schema)); + } else if (stmt instanceof MySqlCreateTableStatement) { + // fix https://aone.alibaba-inc.com/issue/38023203 + // fix https://aone.alibaba-inc.com/issue/39665786 + MySqlCreateTableStatement createTableStatement = (MySqlCreateTableStatement) stmt; + boolean isIfNotExists = createTableStatement.isIfNotExists(); + if (isIfNotExists) { + if (ddlRecordId != null) { + result = ddlJobId != null; + } else { + result = find(schema, tableName) == null; + } + } else { + result = true; + } + //result = !isIfNotExists || find(schema, tableName) == null; + } else if (stmt instanceof SQLDropTableStatement) { + SQLDropTableStatement dropTableStatement = (SQLDropTableStatement) stmt; + boolean isIfExists = dropTableStatement.isIfExists(); + if (isIfExists) { + if (ddlRecordId != null) { + result = ddlJobId != null; + } else { + result = true; + } + } else { + result = true; } } - if (stmt instanceof MySqlCreateTableStatement) { - MySqlCreateTableStatement createTableStatement = (MySqlCreateTableStatement) stmt; - return !createTableStatement.isIfNotExists() || find(schema, tableName) == null; + if (!result) { + logger.warn("ignore logic ddl sql, with tso {}, schema {}, tableName {}.", tso, schema, tableName); } - - return true; + return result; } - private void fixOrDropPhyMeta(String tso, String schema, String tableName, String sqlKind, String ddlSql) { - if (phyMeta.find(schema, tableName) != null) { + private void updateOrDropDistinctPhyMeta(String tso, String schema, String tableName, String sqlKind, String ddlSql, + DDLExtInfo extInfo) { + if (distinctPhyMeta.find(schema, tableName) != null) { if (StringUtils.equals(sqlKind, "DROP_DATABASE") || StringUtils.equals(sqlKind, "DROP_TABLE") || StringUtils.equals(sqlKind, "RENAME_TABLE")) { - phyMeta.apply(new BinlogPosition(null, tso), schema, ddlSql, null); + distinctPhyMeta.apply(new BinlogPosition(null, tso), schema, ddlSql, null); + } else if (StringUtils.equals(sqlKind, "ALTER_TABLE") && (extInfo == null || StringUtils + .isEmpty(extInfo.getCreateSql4PhyTable()))) { + //如果是一个普通的ALTER SQL,还是要在distinct phy meta执行的,否则会取到不一致的数据 + distinctPhyMeta.apply(new BinlogPosition(null, tso), schema, ddlSql, null); + } + } + } + + private void tryRemovePreviousMeta(SQLCreateDatabaseStatement createDatabaseStatement, String schema, String tso) { + // 如果是create database,将元数据尝试进行一下清理,正常不应该有元数据的,但是不排除意外情况 + // 比如:polarx内核针对drop database未接入ddl引擎,sql执行和cdc打标无法保证原子性 + // 但对于含有if not exist的sql来说,无法判断当前create database操作是否是有效操作,所以不予处理 + if (!createDatabaseStatement.isIfNotExists()) { + String databaseName = createDatabaseStatement.getDatabaseName(); + databaseName = SQLUtils.normalize(databaseName); + Preconditions.checkArgument(StringUtils.equalsIgnoreCase(databaseName, schema), + "create database record should be coincident DDL(" + databaseName + "), History(" + schema + ")"); + super.apply(null, schema, "drop database if exists `" + escape(databaseName) + "`", null); + topologyManager.removeTopology(tso, schema.toLowerCase(), null); + + logger.warn("remove previous meta for newly create database sql, tso :{}, sql :{} ", tso, + createDatabaseStatement.toUnformattedString()); + } + } + + private void toLowerCase(BinlogLogicMetaHistory logicMetaHistory) { + logicMetaHistory.setDbName(StringUtils.lowerCase(logicMetaHistory.getDbName())); + logicMetaHistory.setTableName(StringUtils.lowerCase(logicMetaHistory.getTableName())); + logicMetaHistory.setDdl(StringUtils.lowerCase(logicMetaHistory.getDdl())); + } + + private DDLExtInfo parseExtInfo(String str) { + DDLExtInfo extInfo = null; + if (StringUtils.isNotEmpty(str)) { + extInfo = GSON.fromJson(str, DDLExtInfo.class); + if (extInfo != null && StringUtils.isNotBlank(extInfo.getCreateSql4PhyTable())) { + extInfo.setCreateSql4PhyTable(StringUtils.lowerCase(extInfo.getCreateSql4PhyTable())); } } + return extInfo; } } diff --git a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/PolarDbXStorageTableMeta.java b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/PolarDbXStorageTableMeta.java index 7b33e57d..92e7140e 100644 --- a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/PolarDbXStorageTableMeta.java +++ b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/PolarDbXStorageTableMeta.java @@ -17,6 +17,16 @@ package com.aliyun.polardbx.binlog.cdc.meta; +import com.alibaba.polardbx.druid.DbType; +import com.alibaba.polardbx.druid.sql.SQLUtils; +import com.alibaba.polardbx.druid.sql.ast.SQLStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLCreateTableStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLDropTableStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLExprTableSource; +import com.alibaba.polardbx.druid.sql.dialect.mysql.ast.statement.MySqlRenameTableStatement; +import com.alibaba.polardbx.druid.sql.parser.SQLStatementParser; +import com.aliyun.polardbx.binlog.CommonUtils; import com.aliyun.polardbx.binlog.SpringContextHolder; import com.aliyun.polardbx.binlog.canal.core.ddl.tsdb.MemoryTableMeta; import com.aliyun.polardbx.binlog.canal.core.model.BinlogPosition; @@ -26,38 +36,39 @@ import com.aliyun.polardbx.binlog.dao.BinlogPhyDdlHistoryDynamicSqlSupport; import com.aliyun.polardbx.binlog.dao.BinlogPhyDdlHistoryMapper; import com.aliyun.polardbx.binlog.domain.po.BinlogPhyDdlHistory; +import com.aliyun.polardbx.binlog.jvm.JvmSnapshot; +import com.aliyun.polardbx.binlog.jvm.JvmUtils; +import com.aliyun.polardbx.binlog.util.FastSQLConstant; import com.google.common.base.Preconditions; +import org.apache.commons.lang3.StringUtils; import org.mybatis.dynamic.sql.SqlBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.dao.DuplicateKeyException; -import org.springframework.jdbc.core.JdbcTemplate; import java.util.List; import java.util.Map; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; +import static com.alibaba.polardbx.druid.sql.parser.SQLParserUtils.createSQLStatementParser; + /** - * Created by ziyang.lb + * Created by Shuguang & ziyang.lb */ -public class PolarDbXStorageTableMeta extends MemoryTableMeta { - private static Logger logger = LoggerFactory.getLogger(PolarDbXStorageTableMeta.class); - private static final int SIZE = 200; - private ReadWriteLock lock = new ReentrantReadWriteLock(); - private AtomicBoolean initialized = new AtomicBoolean(false); - private String destination; - private String storageInstId; - - private BinlogPhyDdlHistoryMapper binlogPhyDdlHistoryMapper = SpringContextHolder.getObject( - BinlogPhyDdlHistoryMapper.class); +public class PolarDbXStorageTableMeta extends MemoryTableMeta implements ICdcTableMeta { + private static final Logger logger = LoggerFactory.getLogger(PolarDbXStorageTableMeta.class); + private static final int PAGE_SIZE = 200; - private PolarDbXLogicTableMeta polarDbXLogicTableMeta; - private TopologyManager topologyManager; + private final ReadWriteLock lock = new ReentrantReadWriteLock(); + private final String storageInstId; + private final PolarDbXLogicTableMeta polarDbXLogicTableMeta; + private final TopologyManager topologyManager; + private final BinlogPhyDdlHistoryMapper binlogPhyDdlHistoryMapper = SpringContextHolder.getObject( + BinlogPhyDdlHistoryMapper.class); - public PolarDbXStorageTableMeta(String storageInstId, - PolarDbXLogicTableMeta polarDbXLogicTableMeta, TopologyManager topologyManager) { + public PolarDbXStorageTableMeta(String storageInstId, PolarDbXLogicTableMeta polarDbXLogicTableMeta, + TopologyManager topologyManager) { super(logger); this.storageInstId = storageInstId; this.polarDbXLogicTableMeta = polarDbXLogicTableMeta; @@ -66,53 +77,108 @@ public PolarDbXStorageTableMeta(String storageInstId, @Override public boolean init(final String destination) { - if (initialized.compareAndSet(false, true)) { - this.destination = destination; - } return true; } - public boolean applyBase(BinlogPosition position) { - // 每次rollback需要重新构建一次memory data + public void applyBase(BinlogPosition position) { + applySnapshot(position.getRtso()); + } + + @Override + public void applySnapshot(String snapshotTso) { + // log before apply snapshot + long applyCount = 0; + long startTime = System.currentTimeMillis(); + JvmSnapshot jvmSnapshot = JvmUtils.buildJvmSnapshot(); + logger.info("build physical meta snapshot started, current used memory -> young:{}, old:{}", + jvmSnapshot.getYoungUsed(), jvmSnapshot.getOldUsed()); + + // 获取Logic Snapshot Map snapshot = polarDbXLogicTableMeta.snapshot(); - snapshot.forEach((k, v) -> super.apply(position, k, v, null)); + snapshot.forEach((k, v) -> super.apply(null, k, v, null)); //用于订正逻辑表和物理表结构不一致的情况 - Map snapshotToFix = polarDbXLogicTableMeta.phySnapshot(); + Map snapshotToFix = polarDbXLogicTableMeta.distinctPhySnapshot(); if (snapshotToFix != null && !snapshotToFix.isEmpty()) { - snapshotToFix.forEach((k, v) -> super.apply(position, k, v, null)); + snapshotToFix.forEach((k, v) -> super.apply(null, k, v, null)); } else { - logger.info("all tables is compatible for rollback to tso:{}...", position.getRtso()); + logger.info("All logical and physical tables is compatible for snapshot tso:{}...", snapshotTso); } // 根据逻辑MetaSnapshot构建物理 List phyTables = topologyManager.getPhyTables(storageInstId); - for (PhyTableTopology phyTable : phyTables) { final List tables = phyTable.getPhyTables(); if (tables != null) { for (String table : tables) { LogicDbTopology logicSchema = topologyManager.getLogicSchema(phyTable.getSchema(), table); - Preconditions.checkNotNull(logicSchema, - "phyTable " + phyTable.getSchema() + "." + table + "'s logicSchema should not be null!"); - Preconditions.checkNotNull(logicSchema.getLogicTableMetas(), - "phyTable " + phyTable.getSchema() + "." + table + "'s logicTables should not be null!"); - Preconditions.checkNotNull(logicSchema.getLogicTableMetas().get(0), - "phyTable " + phyTable.getSchema() + "." + table + "'s logicTable should not be null!"); + checkSchema(logicSchema, phyTable, table); String tableName = logicSchema.getLogicTableMetas().get(0).getTableName(); - String createTable = "create table `" + table + "` like `" + logicSchema.getSchema() + "`.`" - + tableName - + "`"; - logger.warn("apply from logic table phy:{}.{}, logic:{}.{} [{}] ...", phyTable.getSchema(), table, - logicSchema.getSchema(), tableName, createTable); - super.apply(null, phyTable.getSchema(), createTable, null); + String createTableSql = "create table `" + CommonUtils.escape(table) + "` like `" + + CommonUtils.escape(logicSchema.getSchema()) + "`.`" + CommonUtils.escape(tableName) + "`"; + super.apply(null, phyTable.getSchema(), createTableSql, null); + applyCount++; + + if (logger.isDebugEnabled()) { + logger.debug("apply from logic table, phy:{}.{}, logic:{}.{} [{}] ...", phyTable.getSchema(), + table, logicSchema.getSchema(), tableName, createTableSql); + } } } } //drop 逻辑库 - snapshot.forEach((k, v) -> { - super.apply(position, k, "drop database `" + k + "`", null); - }); - return true; + snapshot.forEach((k, v) -> super.apply(null, k, "drop database `" + k + "`", null)); + + //log after apply snapshot + long costTime = System.currentTimeMillis() - startTime; + jvmSnapshot = JvmUtils.buildJvmSnapshot(); + logger.info("build physical meta snapshot finished, applyCount {}, cost time {}(ms), current used memory -> " + + "young:{}, old:{}", costTime, applyCount, jvmSnapshot.getYoungUsed(), jvmSnapshot.getOldUsed()); + } + + @Override + public void applyHistory(String snapshotTso, String rollbackTso) { + // log before apply + long applyCount = 0; + long startTime = System.currentTimeMillis(); + JvmSnapshot jvmSnapshot = JvmUtils.buildJvmSnapshot(); + logger.info("apply phy ddl history started, current used memory -> young:{}, old:{}", + jvmSnapshot.getYoungUsed(), jvmSnapshot.getOldUsed()); + + // apply history + while (true) { + final String snapshotTsoCondition = snapshotTso; + List ddlHistories = binlogPhyDdlHistoryMapper.select( + s -> s.where(BinlogPhyDdlHistoryDynamicSqlSupport.storageInstId, SqlBuilder.isEqualTo(storageInstId)) + .and(BinlogPhyDdlHistoryDynamicSqlSupport.tso, SqlBuilder.isGreaterThan(snapshotTsoCondition)) + .and(BinlogPhyDdlHistoryDynamicSqlSupport.tso, SqlBuilder.isLessThanOrEqualTo(rollbackTso)) + .orderBy(BinlogPhyDdlHistoryDynamicSqlSupport.tso).limit(PAGE_SIZE) + ); + for (BinlogPhyDdlHistory ddlHistory : ddlHistories) { + toLowerCase(ddlHistory); + BinlogPosition position = new BinlogPosition(null, ddlHistory.getTso()); + super.apply(position, ddlHistory.getDbName(), ddlHistory.getDdl(), ddlHistory.getExtra()); + if (logger.isDebugEnabled()) { + logger.debug("apply one physical phy ddl: [id={}, dbName={}, tso={}]", ddlHistory.getId(), + ddlHistory.getDbName(), ddlHistory.getTso()); + } + tryPrint(position, ddlHistory.getDbName(), ddlHistory.getDdl()); + } + + applyCount += ddlHistories.size(); + if (ddlHistories.size() == PAGE_SIZE) { + snapshotTso = ddlHistories.get(PAGE_SIZE - 1).getTso(); + } else { + break; + } + } + + //log after apply + long costTime = System.currentTimeMillis() - startTime; + jvmSnapshot = JvmUtils.buildJvmSnapshot(); + logger.info( + "apply phy ddl history finished, snapshot tso {}, rollback tso {}, cost time {}(ms), applyCount {}, " + + "current used memory -> young:{}, old:{}", snapshotTso, rollbackTso, costTime, applyCount, + jvmSnapshot.getYoungUsed(), jvmSnapshot.getOldUsed()); } @Override @@ -122,7 +188,8 @@ public boolean apply(BinlogPosition position, String schema, String ddl, String try { if (super.apply(position, schema, ddl, extra)) { // 同步每次变更给远程做历史记录,只记录ddl,不记录快照 - applyHistoryToDB(position, schema, ddl, extra); + applyHistoryToDb(position, schema, ddl, extra); + tryPrint(position, schema, ddl); return true; } else { throw new RuntimeException("apply to memory is failed"); @@ -132,60 +199,81 @@ public boolean apply(BinlogPosition position, String schema, String ddl, String } } - @Override - public boolean rollback(BinlogPosition position) { - // 每次rollback需要重新构建一次memory data - applyBase(position); - - BinlogPosition snapshotPosition = getSnapshotPosition(position); - //2do 根据MetaHistory重放ddl - if (position != null && snapshotPosition != null && snapshotPosition.getRtso() != null) { - while (true) { - List ddlHistories = binlogPhyDdlHistoryMapper.select( - s -> s - .where(BinlogPhyDdlHistoryDynamicSqlSupport.storageInstId, SqlBuilder.isEqualTo(storageInstId)) - .and(BinlogPhyDdlHistoryDynamicSqlSupport.tso, - SqlBuilder.isGreaterThan(snapshotPosition.getRtso())) - .and(BinlogPhyDdlHistoryDynamicSqlSupport.tso, - SqlBuilder.isLessThanOrEqualTo(position.getRtso())) - .orderBy(BinlogPhyDdlHistoryDynamicSqlSupport.tso).limit(SIZE) - ); - for (BinlogPhyDdlHistory ddlHistory : ddlHistories) { - logger.warn("apply phy ddl: [id={}, dbName={}, tso={}]", ddlHistory.getId(), ddlHistory.getDbName(), - ddlHistory.getTso()); - super.apply(position, ddlHistory.getDbName(), ddlHistory.getDdl(), ddlHistory.getExtra()); - } - if (ddlHistories.size() == SIZE) { - snapshotPosition.setRtso(ddlHistories.get(SIZE - 1).getTso()); - } else { - break; - } - } - } - return true; + public boolean apply(String schema, String ddl) { + return super.apply(null, schema, ddl, null); } - private void applyHistoryToDB(BinlogPosition position, String schema, String ddl, String extra) { + private void checkSchema(LogicDbTopology logicSchema, PhyTableTopology phyTable, String table) { + Preconditions.checkNotNull(logicSchema, + "phyTable " + phyTable.getSchema() + "." + table + "'s logicSchema should not be null!"); + Preconditions.checkNotNull(logicSchema.getLogicTableMetas(), + "phyTable " + phyTable.getSchema() + "." + table + "'s logicTables should not be null!"); + Preconditions.checkNotNull(logicSchema.getLogicTableMetas().get(0), + "phyTable " + phyTable.getSchema() + "." + table + "'s logicTable should not be null!"); + } + + private void applyHistoryToDb(BinlogPosition position, String schema, String ddl, String extra) { try { - binlogPhyDdlHistoryMapper.insert(BinlogPhyDdlHistory.builder().storageInstId(storageInstId).binlogFile( - position.getFileName()).tso( - position.getRtso()).dbName(schema) - .ddl(ddl).extra(extra).build()); + binlogPhyDdlHistoryMapper.insert(BinlogPhyDdlHistory.builder().storageInstId(storageInstId) + .binlogFile(position.getFileName()) + .tso(position.getRtso()) + .dbName(schema) + .ddl(ddl) + .extra(extra).build()); } catch (DuplicateKeyException e) { - logger.warn( - "already applyHistoryToDB, ignore this time, position is : {}, schema is {}, ddl is {}, extra is {}", - position, schema, ddl, extra); + if (logger.isDebugEnabled()) { + logger.debug("already applyHistoryToDB, ignore this time, position is : {}, schema is {}, tso is {}," + + " extra is {}", position, schema, position.getRtso(), extra); + } } } - /** - * 从存储从获取快照位点,用于补齐逻辑和物理之间的差距 - */ - protected BinlogPosition getSnapshotPosition(BinlogPosition position) { - JdbcTemplate metaJdbcTemplate = SpringContextHolder.getObject("metaJdbcTemplate"); - String tso = metaJdbcTemplate.queryForObject( - "select max(tso) tso from binlog_logic_meta_history where tso <= '" + position.getRtso() + "'", - String.class); - return new BinlogPosition(null, tso); + private void toLowerCase(BinlogPhyDdlHistory phyDdlHistory) { + phyDdlHistory.setDbName(StringUtils.lowerCase(phyDdlHistory.getDbName())); + phyDdlHistory.setDdl(StringUtils.lowerCase(phyDdlHistory.getDdl())); + } + + private void tryPrint(BinlogPosition position, String schema, String ddl) { + if (Printer.isSupportPrint()) { + String tableName = parseTableName(ddl); + if (StringUtils.isNotBlank(tableName)) { + Printer.tryPrint(position, schema, tableName, this); + } + } + } + + private String parseTableName(String ddl) { + try { + if (StringUtils.isBlank(ddl)) { + return ""; + } + + SQLStatementParser parser = createSQLStatementParser(ddl, DbType.mysql, FastSQLConstant.FEATURES); + List statementList = parser.parseStatementList(); + SQLStatement sqlStatement = statementList.get(0); + + if (sqlStatement instanceof SQLCreateTableStatement) { + SQLCreateTableStatement sqlCreateTableStatement = (SQLCreateTableStatement) sqlStatement; + return SQLUtils.normalize(sqlCreateTableStatement.getTableName()); + } else if (sqlStatement instanceof SQLDropTableStatement) { + SQLDropTableStatement sqlDropTableStatement = (SQLDropTableStatement) sqlStatement; + for (SQLExprTableSource tableSource : sqlDropTableStatement.getTableSources()) { + //CN只支持一次drop一张表,直接返回即可 + return tableSource.getTableName(true); + } + } else if (sqlStatement instanceof MySqlRenameTableStatement) { + MySqlRenameTableStatement renameTableStatement = (MySqlRenameTableStatement) sqlStatement; + for (MySqlRenameTableStatement.Item item : renameTableStatement.getItems()) { + //CN只支持一次Rename一张表,直接返回即可 + return SQLUtils.normalize(item.getName().getSimpleName()); + } + } else if (sqlStatement instanceof SQLAlterTableStatement) { + SQLAlterTableStatement sqlAlterTableStatement = (SQLAlterTableStatement) sqlStatement; + return SQLUtils.normalize(sqlAlterTableStatement.getTableName()); + } + } catch (Throwable t) { + logger.error("parse table from ddl sql failed.", t); + } + return ""; } } diff --git a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/PolarDbXTableMetaManager.java b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/PolarDbXTableMetaManager.java index 019b0deb..cfa2c22e 100644 --- a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/PolarDbXTableMetaManager.java +++ b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/PolarDbXTableMetaManager.java @@ -17,12 +17,26 @@ package com.aliyun.polardbx.binlog.cdc.meta; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.polardbx.druid.DbType; +import com.alibaba.polardbx.druid.sql.SQLUtils; +import com.alibaba.polardbx.druid.sql.ast.SQLStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableAddColumn; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableDropColumnItem; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableItem; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLDropDatabaseStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLDropTableStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLExprTableSource; +import com.alibaba.polardbx.druid.sql.dialect.mysql.ast.statement.MySqlAlterTableChangeColumn; +import com.alibaba.polardbx.druid.sql.dialect.mysql.ast.statement.MySqlRenameTableStatement; +import com.alibaba.polardbx.druid.sql.parser.SQLStatementParser; +import com.aliyun.polardbx.binlog.CommonUtils; +import com.aliyun.polardbx.binlog.ConfigKeys; +import com.aliyun.polardbx.binlog.DynamicApplicationConfig; import com.aliyun.polardbx.binlog.SpringContextHolder; -import com.aliyun.polardbx.binlog.canal.ReplicateFilter; import com.aliyun.polardbx.binlog.canal.core.ddl.TableMeta; import com.aliyun.polardbx.binlog.canal.core.ddl.TableMeta.FieldMeta; -import com.aliyun.polardbx.binlog.canal.core.ddl.tsdb.TableMetaTSDB; -import com.aliyun.polardbx.binlog.canal.core.dump.MysqlConnection; import com.aliyun.polardbx.binlog.canal.core.model.BinlogPosition; import com.aliyun.polardbx.binlog.canal.system.SystemDB; import com.aliyun.polardbx.binlog.cdc.meta.LogicTableMeta.FieldMetaExt; @@ -33,88 +47,186 @@ import com.aliyun.polardbx.binlog.cdc.topology.LogicMetaTopology.LogicTableMetaTopology; import com.aliyun.polardbx.binlog.cdc.topology.LogicMetaTopology.PhyTableTopology; import com.aliyun.polardbx.binlog.cdc.topology.TopologyManager; -import com.aliyun.polardbx.binlog.dao.BinlogLogicMetaHistoryMapper; +import com.aliyun.polardbx.binlog.cdc.topology.vo.TopologyRecord; +import com.aliyun.polardbx.binlog.dao.SemiSnapshotInfoDynamicSqlSupport; +import com.aliyun.polardbx.binlog.dao.SemiSnapshotInfoMapper; +import com.aliyun.polardbx.binlog.domain.po.SemiSnapshotInfo; +import com.aliyun.polardbx.binlog.error.PolardbxException; +import com.aliyun.polardbx.binlog.monitor.MonitorManager; +import com.aliyun.polardbx.binlog.util.FastSQLConstant; import com.google.common.base.Preconditions; import com.google.common.base.Stopwatch; +import com.google.common.collect.Lists; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; +import org.joda.time.DateTime; +import org.mybatis.dynamic.sql.SqlBuilder; +import org.springframework.dao.DuplicateKeyException; +import org.springframework.jdbc.core.JdbcTemplate; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; +import static com.alibaba.polardbx.druid.sql.parser.SQLParserUtils.createSQLStatementParser; +import static com.aliyun.polardbx.binlog.ConfigKeys.META_ROLLBACK_MODE; +import static com.aliyun.polardbx.binlog.ConfigKeys.META_ROLLBACK_MODE_SUPPORT_INSTANT_CREATE_TABLE; +import static com.aliyun.polardbx.binlog.ConfigKeys.META_SEMI_SNAPSHOT_DELTA_CHANGE_CHECK_INTERVAL; +import static com.aliyun.polardbx.binlog.ConfigKeys.META_SEMI_SNAPSHOT_HOLDING_TIME; +import static com.aliyun.polardbx.binlog.ConfigKeys.META_SEMI_SNAPSHOT_HOLDING_TIME_CHECK_INTERVAL; +import static com.aliyun.polardbx.binlog.cdc.meta.RollbackMode.SNAPSHOT_EXACTLY; +import static com.aliyun.polardbx.binlog.cdc.meta.RollbackMode.SNAPSHOT_SEMI; +import static com.aliyun.polardbx.binlog.cdc.meta.RollbackMode.SNAPSHOT_UNSAFE; +import static com.aliyun.polardbx.binlog.monitor.MonitorType.META_DATA_INCONSISTENT_WARNNIN; + /** - * Created by Shuguang + * Created by ShuGuang & ziyang.lb */ @Slf4j -public class PolarDbXTableMetaManager implements TableMetaTSDB { +public class PolarDbXTableMetaManager { private static final Gson GSON = new GsonBuilder().create(); - private AtomicBoolean initialized = new AtomicBoolean(false); + private final AtomicBoolean initialized = new AtomicBoolean(false); + private final String storageInstId; + private final Map> deltaChangeMap; + private final RollbackMode rollbackMode; + private TopologyManager topologyManager; private PolarDbXLogicTableMeta polarDbXLogicTableMeta; private PolarDbXStorageTableMeta polarDbXStorageTableMeta; - private String storageInstId; - private ReplicateFilter filter; - private TopologyManager topologyManager; + private ConsistencyChecker consistencyChecker; + private ScheduledExecutorService cleaner; + private long lastCheckAllDeltaTime; - private BinlogLogicMetaHistoryMapper binlogLogicMetaHistoryMapper = SpringContextHolder.getObject( - BinlogLogicMetaHistoryMapper.class); - - public PolarDbXTableMetaManager(String storageInstId, MysqlConnection storageConnection, ReplicateFilter filter) { + public PolarDbXTableMetaManager(String storageInstId) { this.storageInstId = storageInstId; - this.filter = filter; - this.filter = filter; + this.deltaChangeMap = new HashMap<>(); + this.rollbackMode = getRollbackMode(); } - @Override - public boolean init(String destination) { + public void init() { if (initialized.compareAndSet(false, true)) { this.topologyManager = new TopologyManager(); - this.polarDbXLogicTableMeta = new PolarDbXLogicTableMeta(this.topologyManager); - this.polarDbXLogicTableMeta.init(destination); + this.polarDbXLogicTableMeta.init(null); this.polarDbXStorageTableMeta = new PolarDbXStorageTableMeta(storageInstId, - polarDbXLogicTableMeta, this.topologyManager); - this.polarDbXStorageTableMeta.init(destination); - + polarDbXLogicTableMeta, topologyManager); + this.polarDbXStorageTableMeta.init(null); + this.consistencyChecker = new ConsistencyChecker(topologyManager, polarDbXLogicTableMeta, + polarDbXStorageTableMeta, this, storageInstId); + this.startCleaner(); } - return true; } - @Override - public void destory() { + public void destroy() { this.polarDbXStorageTableMeta.destory(); this.polarDbXLogicTableMeta.destory(); + if (this.cleaner != null) { + this.cleaner.shutdownNow(); + } + } + + public TableMeta findPhyTable(String schema, String table) { + TableMeta phy = polarDbXStorageTableMeta.find(schema, table); + //进行一下补偿,如果表不存在,实时创建一下 + if (phy == null && supportInstantCreatTableWhenNotfound()) { + LogicDbTopology logicTopology = getLogicSchema(schema, table); + if (logicTopology != null && logicTopology.getLogicTableMetas() != null + && logicTopology.getLogicTableMetas().size() == 1) { + log.info("phy table meta is not found for {}:{}, will instantly try to create for compensation.", + schema, table); + String logicSchema = logicTopology.getSchema(); + String logicTable = logicTopology.getLogicTableMetas().get(0).getTableName(); + TableMeta distinctPhyTableMeta = polarDbXLogicTableMeta.findDistinctPhy(logicSchema, logicTable); + if (distinctPhyTableMeta == null) { + TableMeta logicTableMeta = polarDbXLogicTableMeta.find(logicSchema, logicTable); + String ddl = polarDbXLogicTableMeta.snapshot(logicSchema, logicTable); + createNotExistPhyTable(logicSchema, schema, logicTable, table, ddl); + return logicTableMeta; + } else { + String ddl = polarDbXLogicTableMeta.distinctPhySnapshot(logicSchema, logicTable); + createNotExistPhyTable(logicSchema, schema, logicTable, table, ddl); + return distinctPhyTableMeta; + } + } + } + return phy; + } + + private void startCleaner() { + if (rollbackMode == SNAPSHOT_SEMI) { + long checkInterval = DynamicApplicationConfig.getLong(META_SEMI_SNAPSHOT_HOLDING_TIME_CHECK_INTERVAL); + this.cleaner = Executors.newSingleThreadScheduledExecutor((r) -> { + Thread t = new Thread(r, "semi-snapshot-cleaner"); + t.setDaemon(true); + return t; + }); + cleaner.scheduleAtFixedRate(() -> { + try { + cleanExpiredSemiSnapshot(); + } catch (Exception e) { + log.error("clean semi snapshot error!", e); + } + }, 0, checkInterval, TimeUnit.MINUTES); + } + } + + private void cleanExpiredSemiSnapshot() { + int holdingTime = DynamicApplicationConfig.getInt(META_SEMI_SNAPSHOT_HOLDING_TIME); + Date expireTime = DateTime.now().minusHours(holdingTime).toDate(); + SemiSnapshotInfoMapper mapper = SpringContextHolder.getObject(SemiSnapshotInfoMapper.class); + + List list = mapper + .select(s -> s.where(SemiSnapshotInfoDynamicSqlSupport.storageInstId, SqlBuilder.isEqualTo(storageInstId)) + .and(SemiSnapshotInfoDynamicSqlSupport.gmtCreated, SqlBuilder.isLessThanOrEqualTo(expireTime)) + .orderBy(SemiSnapshotInfoDynamicSqlSupport.tso.descending()) + .limit(1)); + if (!list.isEmpty()) { + int count = mapper.delete( + s -> s.where(SemiSnapshotInfoDynamicSqlSupport.storageInstId, SqlBuilder.isEqualTo(storageInstId)) + .and(SemiSnapshotInfoDynamicSqlSupport.tso, SqlBuilder.isLessThan(list.get(0).getTso()))); + log.info("successfully deleted expired semi snapshot records which tso is less than {}, delete count: {}. ", + list.get(0).getTso(), count); + } } - @Override - public TableMeta find(String schema, String table) { - return polarDbXStorageTableMeta.find(schema, table); + private void createNotExistPhyTable(String logicSchema, String phySchema, String logicTable, String phyTable, + String ddl) { + String createSql = "create table `" + CommonUtils.escape(phyTable) + "` like `" + + CommonUtils.escape(logicSchema) + "`.`" + CommonUtils.escape(logicTable) + "`"; + polarDbXStorageTableMeta.apply(logicSchema, ddl); + polarDbXStorageTableMeta.apply(phySchema, createSql); + polarDbXStorageTableMeta.apply(logicSchema, "drop database `" + logicSchema + "`"); } - public TableMeta findLogic(String schema, String table) { + public TableMeta findLogicTable(String schema, String table) { return polarDbXLogicTableMeta.find(schema, table); } public LogicTableMeta compare(String schema, String table) { - TableMeta phy = find(schema, table); - Preconditions.checkNotNull(phy, - "phyTable " + schema + "." + table + "'s tableMeta should not be null!"); - LogicDbTopology logicTopology = getLogicSchema(schema, table); + TableMeta phy = findPhyTable(schema, table); + Preconditions.checkNotNull(phy, "phyTable " + schema + "." + table + "'s tableMeta should not be null!"); + LogicDbTopology logicTopology = getLogicSchema(schema, table); Preconditions.checkArgument(logicTopology != null && logicTopology.getLogicTableMetas() != null && logicTopology.getLogicTableMetas().size() == 1, "can not find logic meta " + logicTopology); - TableMeta logic = findLogic(logicTopology.getSchema(), - logicTopology.getLogicTableMetas().get(0).getTableName()); - Preconditions.checkNotNull(logic, - "phyTable [" + schema + "." + table + "], logic tableMeta[" + logicTopology.getSchema() + "." - + logicTopology - .getLogicTableMetas().get(0).getTableName() + "] should not be null!"); + TableMeta logic = + findLogicTable(logicTopology.getSchema(), logicTopology.getLogicTableMetas().get(0).getTableName()); + Preconditions.checkNotNull(logic, "phyTable [" + schema + "." + table + "], logic tableMeta[" + + logicTopology.getSchema() + "." + logicTopology.getLogicTableMetas().get(0).getTableName() + + "] should not be null!"); final List columnNames = phy.getFields().stream().map(FieldMeta::getColumnName).collect( Collectors.toList()); @@ -147,7 +259,7 @@ public LogicTableMeta compare(String schema, String table) { log.warn("meta is not compatible {}", meta); } // 如果有隐藏主键,直接放到最后 - if (hiddenPK != null) { + if (hiddenPK != null && DynamicApplicationConfig.getBoolean(ConfigKeys.TASK_DRDS_HIDDEN_PK_SUPPORT)) { final int x = columnNames.indexOf(hiddenPK.getColumnName()); meta.add(new FieldMetaExt(hiddenPK, logicIndex, x)); } @@ -155,43 +267,474 @@ public LogicTableMeta compare(String schema, String table) { return meta; } - public boolean applyBase(BinlogPosition position, LogicMetaTopology topology) { + public void applyBase(BinlogPosition position, LogicMetaTopology topology) { this.polarDbXLogicTableMeta.applyBase(position, topology); this.polarDbXStorageTableMeta.applyBase(position); - return true; } - public boolean applyLogic(BinlogPosition position, DDLRecord record, String extra) { + public void applyLogic(BinlogPosition position, DDLRecord record, String extra) { if (StringUtils.isNotEmpty(extra)) { record.setExtInfo(GSON.fromJson(extra, DDLExtInfo.class)); } - this.polarDbXLogicTableMeta.apply(position, record, extra); - return true; + boolean result = this.polarDbXLogicTableMeta.apply(position, record, extra); + //只有发生了Actual Apply Operation,才进行后续处理 + if (result) { + this.processSnapshotSemi(position, record); + //对拓扑和表结构进行一致性对比,正常情况下,每个表执行完一个逻辑DDL后,都应该是一个一致的状态,如果不一致说明出现了问题 + this.consistencyChecker.checkTopologyConsistencyWithOrigin(position.getRtso(), record); + this.consistencyChecker.checkLogicAndPhysicalConsistency(position.getRtso(), record); + } } - @Override - public boolean apply(BinlogPosition position, String schema, String ddl, String extra) { + public void applyPhysical(BinlogPosition position, String schema, String ddl, String extra) { this.polarDbXStorageTableMeta.apply(position, schema, ddl, extra); - return true; + this.updateDeltaChangeByPhysicalDdl(position.getRtso(), schema, ddl); } - @Override - public boolean rollback(BinlogPosition position) { + public void rollback(BinlogPosition position) { Stopwatch sw = Stopwatch.createStarted(); - polarDbXLogicTableMeta.rollback(position); - polarDbXStorageTableMeta.rollback(position); + + if (rollbackMode == SNAPSHOT_EXACTLY) { + rollbackInSnapshotExactlyMode(position); + } else if (rollbackMode == SNAPSHOT_SEMI) { + rollbackInSnapshotSemiMode(position); + } else if (rollbackMode == SNAPSHOT_UNSAFE) { + rollbackInSnapshotUnSafeMode(position); + } else { + throw new PolardbxException("invalid rollback mode " + rollbackMode); + } sw.stop(); - log.warn("Final task rollback to tso:{}, cost {}", position.getRtso(), sw); - return true; + log.warn("successfully rollback to tso:{}, cost {}", position.getRtso(), sw); } - @Override public Map snapshot() { log.info("Logic: {}", polarDbXLogicTableMeta.snapshot()); log.info("Storage: {}", polarDbXStorageTableMeta.snapshot()); throw new RuntimeException("not support for PolarDbXTableMetaManager"); } + public Set findIndexes(String schema, String table) { + return polarDbXLogicTableMeta.findIndexes(schema, table); + } + + /** + * 从存储中获取小于等于rollback tso的最新一次Snapshot的位点 + */ + protected String getLatestSnapshotTso(String rollbackTso) { + JdbcTemplate metaJdbcTemplate = SpringContextHolder.getObject("metaJdbcTemplate"); + return metaJdbcTemplate.queryForObject( + "select max(tso) tso from binlog_logic_meta_history where tso <= '" + rollbackTso + + "' and type = " + MetaType.SNAPSHOT.getValue(), String.class); + } + + /** + * 从存储中获取小于等于rollback tso的最新一次的位点 + */ + protected String getLatestLogicDDLTso(String rollbackTso) { + JdbcTemplate metaJdbcTemplate = SpringContextHolder.getObject("metaJdbcTemplate"); + return metaJdbcTemplate.queryForObject( + "select max(tso) tso from binlog_logic_meta_history where tso <= '" + rollbackTso + "' +" + + "and type = " + MetaType.DDL.getValue(), String.class); + } + + private void processSnapshotSemi(BinlogPosition position, DDLRecord record) { + if (rollbackMode == SNAPSHOT_SEMI) { + this.updateDeltaChangeByLogicDdl(position.getRtso(), record); + this.tryUpdateSemiSnapshotPosition(position.getRtso()); + } + } + + /** + * 获取回滚模式 + */ + private RollbackMode getRollbackMode() { + String phyMetaBuildModeStr = DynamicApplicationConfig.getString(META_ROLLBACK_MODE); + RollbackMode mode = RollbackMode.valueOf(phyMetaBuildModeStr); + if (mode == RollbackMode.RANDOM) { + List list = Lists.newArrayList(SNAPSHOT_SEMI, SNAPSHOT_EXACTLY); + Collections.shuffle(list); + mode = list.get(0); + log.info("random selected rollback mode is " + mode); + } + return mode; + } + + /** + * 在不出现bug的情况下,只有SNAPSHOT_SEMI 和 SNAPSHOT_UNSAFE才有必要 + */ + private boolean supportInstantCreatTableWhenNotfound() { + String configStr = DynamicApplicationConfig.getString(META_ROLLBACK_MODE_SUPPORT_INSTANT_CREATE_TABLE); + if (StringUtils.isNotBlank(configStr)) { + String[] configArray = StringUtils.split(configStr, ","); + for (String s : configArray) { + if (rollbackMode.name().equals(s)) { + return true; + } + } + } + return false; + } + + private void rollbackInSnapshotExactlyMode(BinlogPosition position) { + String snapshotTso = getLatestSnapshotTso(position.getRtso()); + polarDbXLogicTableMeta.applySnapshot(snapshotTso); + polarDbXStorageTableMeta.applySnapshot(snapshotTso); + polarDbXLogicTableMeta.applyHistory(snapshotTso, position.getRtso()); + polarDbXStorageTableMeta.applyHistory(snapshotTso, position.getRtso()); + } + + private void rollbackInSnapshotSemiMode(BinlogPosition position) { + String snapshotTso = getLatestSnapshotTso(position.getRtso()); + String semiSnapshotTso = getSuitableSemiSnapshotTso(snapshotTso, position.getRtso()); + if (StringUtils.isBlank(semiSnapshotTso)) { + log.info("semi snapshot is not found between {} and {}.", snapshotTso, position.getRtso()); + rollbackInSnapshotExactlyMode(position); + } else { + log.info("found semi snapshot {} between {} and {}.", semiSnapshotTso, snapshotTso, position.getRtso()); + polarDbXLogicTableMeta.applySnapshot(snapshotTso); + polarDbXLogicTableMeta.applyHistory(snapshotTso, semiSnapshotTso); + polarDbXStorageTableMeta.applySnapshot(snapshotTso); + polarDbXLogicTableMeta.applyHistory(semiSnapshotTso, position.getRtso()); + polarDbXStorageTableMeta.applyHistory(semiSnapshotTso, position.getRtso()); + initDeltaChangeMap(position.getRtso()); + } + } + + private void rollbackInSnapshotUnSafeMode(BinlogPosition position) { + String snapshotTso = getLatestSnapshotTso(position.getRtso()); + polarDbXLogicTableMeta.applySnapshot(snapshotTso); + polarDbXLogicTableMeta.applyHistory(snapshotTso, position.getRtso()); + polarDbXStorageTableMeta.applySnapshot(snapshotTso); + polarDbXStorageTableMeta.applyHistory(getLatestLogicDDLTso(position.getRtso()), position.getRtso()); + } + + private void initDeltaChangeMap(String tso) { + Stopwatch sw = Stopwatch.createStarted(); + + long logicDbCount = 0; + long logicTableCount = 0; + long phyTableCount = 0; + Map> inconsistencyTables = new HashMap<>(); + + List logicDbTopologies = topologyManager.getTopology().getLogicDbMetas(); + for (LogicDbTopology logicDbTopology : logicDbTopologies) { + final List logicTableMetas = logicDbTopology.getLogicTableMetas(); + if (logicTableMetas == null || logicTableMetas.isEmpty()) { + continue; + } + for (LogicTableMetaTopology tableMetaTopology : logicTableMetas) { + List phyTableTopologies = tableMetaTopology.getPhySchemas(); + if (phyTableTopologies == null || phyTableTopologies.isEmpty()) { + continue; + } + for (PhyTableTopology phyTableTopology : phyTableTopologies) { + if (!storageInstId.equals(phyTableTopology.getStorageInstId())) { + continue; + } + for (String phyTable : phyTableTopology.getPhyTables()) { + boolean result = compareLogicWithPhysical(tso, logicDbTopology.getSchema(), + tableMetaTopology.getTableName(), phyTableTopology.getSchema(), phyTable, true); + if (!result) { + inconsistencyTables.computeIfAbsent(tableMetaTopology.getTableName(), k -> new HashSet<>()); + inconsistencyTables.get(tableMetaTopology.getTableName()).add(phyTable); + } + phyTableCount++; + } + } + logicTableCount++; + } + logicDbCount++; + } + + log.warn("successfully initialized delta change map, cost {}, checked logic db count {}, checked logic table " + + "count {}, checked phy table count {}, inconsistency Tables {}.", sw, logicDbCount, logicTableCount, + phyTableCount, JSONObject.toJSONString(inconsistencyTables)); + } + + private void updateDeltaChangeByLogicDdl(String tso, DDLRecord record) { + if (deltaChangeMap.isEmpty()) { + return; + } + if ("DROP_DATABASE".equals(record.getSqlKind())) { + removeFromDeltaChangeMap(record.getSchemaName().toLowerCase()); + } else if ("DROP_TABLE".equals(record.getSqlKind())) { + removeFromDeltaChangeMap(record.getSchemaName(), record.getTableName()); + } else if ("RENAME_TABLE".equals(record.getSqlKind())) { + removeFromDeltaChangeMap(record.getSchemaName(), record.getTableName()); + TopologyRecord r = GSON.fromJson(record.getMetaInfo(), TopologyRecord.class); + updateDeltaChangeForOneLogicTable(tso, record.getSchemaName(), getRenameTo(record.getDdlSql()), + r != null, true); + } else if (StringUtils.isNotEmpty(record.getTableName())) { + TopologyRecord r = GSON.fromJson(record.getMetaInfo(), TopologyRecord.class); + updateDeltaChangeForOneLogicTable(tso, record.getSchemaName(), record.getTableName(), + r != null, true); + } + + doPeriodCheck(tso); + } + + private void doPeriodCheck(String tso) { + // 定时检测所有的deltaChange,将已经一致的表进行清理,比如 + // 1. ddl任务发生过rollback的场景,物理表先加列,然后删列,都会触发delta change data的变化,由于没有最后的打标,需要定时check + // 2. 或者一些变态场景,绕过ddl引擎,手动修改了物理表结构,导致和logic不一致,也需要定时check + long checkInterval = DynamicApplicationConfig.getLong(META_SEMI_SNAPSHOT_DELTA_CHANGE_CHECK_INTERVAL); + if (System.currentTimeMillis() - lastCheckAllDeltaTime > checkInterval * 1000) { + Map> toRemoveData = new HashMap<>(); + for (Map.Entry> entry : deltaChangeMap.entrySet()) { + for (String logicTable : entry.getValue()) { + boolean flag = updateDeltaChangeForOneLogicTable(tso, entry.getKey(), logicTable, false, false); + if (flag) { + toRemoveData.computeIfAbsent(entry.getKey(), k -> new HashSet<>()); + toRemoveData.get(entry.getKey()).add(logicTable); + } + } + } + for (Map.Entry> entry : toRemoveData.entrySet()) { + for (String logicTable : entry.getValue()) { + removeFromDeltaChangeMap(entry.getKey(), logicTable); + } + } + + log.info("latest delta change data after checking is " + JSONObject.toJSONString(deltaChangeMap)); + checkConsistencyBetweenTopologyAndLogicSchema(); + tryTriggerAlarm(); + lastCheckAllDeltaTime = System.currentTimeMillis(); + } + } + + private boolean updateDeltaChangeForOneLogicTable(String tso, String logicSchema, String logicTable, + boolean createPhyIfNotExist, + boolean directRemoveIfHasRecoverConsistent) { + Pair pair = topologyManager.getTopology(logicSchema, logicTable); + LogicTableMetaTopology logicTableMetaTopology = pair.getRight(); + if (logicTableMetaTopology == null) { + throw new PolardbxException( + String.format("logic table meta topology should not be null, logicSchema %s, logicTable %s ,tso %s.", + logicSchema, logicTable, tso)); + } + if (logicTableMetaTopology.getPhySchemas() != null) { + boolean flag = true; + for (PhyTableTopology phyTableTopology : logicTableMetaTopology.getPhySchemas()) { + if (storageInstId.equals(phyTableTopology.getStorageInstId())) { + for (String table : phyTableTopology.getPhyTables()) { + flag &= compareLogicWithPhysical(tso, logicSchema, logicTable, + phyTableTopology.getSchema(), table, createPhyIfNotExist); + } + } + } + if (flag && directRemoveIfHasRecoverConsistent) { + removeFromDeltaChangeMap(logicSchema, logicTable); + } + return flag; + } + return true; + } + + private void updateDeltaChangeByPhysicalDdl(String tso, String phySchema, String phyDdl) { + SQLStatementParser parser = createSQLStatementParser(phyDdl, DbType.mysql, FastSQLConstant.FEATURES); + List statementList = parser.parseStatementList(); + SQLStatement sqlStatement = statementList.get(0); + + if (sqlStatement instanceof SQLDropTableStatement) { + SQLDropTableStatement sqlDropTableStatement = (SQLDropTableStatement) sqlStatement; + for (SQLExprTableSource tableSource : sqlDropTableStatement.getTableSources()) { + String phyTableName = tableSource.getTableName(true); + recordDeltaChangeByPhysicalChange(tso, phySchema, phyTableName); + } + } else if (sqlStatement instanceof SQLDropDatabaseStatement) { + String databaseName = ((SQLDropDatabaseStatement) sqlStatement).getDatabaseName(); + databaseName = SQLUtils.normalize(databaseName); + recordDeltaChangeByPhysicalChange(tso, databaseName, null); + } else if (sqlStatement instanceof MySqlRenameTableStatement) { + MySqlRenameTableStatement renameTableStatement = (MySqlRenameTableStatement) sqlStatement; + for (MySqlRenameTableStatement.Item item : renameTableStatement.getItems()) { + String tableName = SQLUtils.normalize(item.getName().getSimpleName()); + recordDeltaChangeByPhysicalChange(tso, phySchema, tableName); + } + } else if (sqlStatement instanceof SQLAlterTableStatement) { + SQLAlterTableStatement sqlAlterTableStatement = (SQLAlterTableStatement) sqlStatement; + String phyTableName = SQLUtils.normalize(sqlAlterTableStatement.getTableName()); + for (SQLAlterTableItem item : sqlAlterTableStatement.getItems()) { + if (item instanceof SQLAlterTableAddColumn || item instanceof SQLAlterTableDropColumnItem + || item instanceof MySqlAlterTableChangeColumn) { + recordDeltaChangeByPhysicalChange(tso, phySchema, phyTableName); + break; + } + } + } + } + + private String getRenameTo(String ddl) { + SQLStatementParser parser = createSQLStatementParser(ddl, DbType.mysql, FastSQLConstant.FEATURES); + List statementList = parser.parseStatementList(); + SQLStatement sqlStatement = statementList.get(0); + + if (sqlStatement instanceof MySqlRenameTableStatement) { + MySqlRenameTableStatement renameTableStatement = (MySqlRenameTableStatement) sqlStatement; + for (MySqlRenameTableStatement.Item item : renameTableStatement.getItems()) { + return SQLUtils.normalize(item.getTo().getSimpleName()); + } + } + throw new PolardbxException("not a rename ddl sql :" + ddl); + } + + private void recordDeltaChangeByPhysicalChange(String tso, String phySchema, String phyTable) { + if (StringUtils.isBlank(phyTable)) { + LogicDbTopology logicDbTopology = topologyManager.getLogicSchema(phySchema); + // 如果拓扑中保存的phySchema对应的storageInstId和当前的storageInstId不匹配,则不进行记录 + // 什么情况下会出现不匹配?比如执行move database命令时,把physical_db_1从dn1 move到 dn2, + // 然后清理dn1上的physical_db_1,此时dn1会受到drop database命令,需要忽略 + if (logicDbTopology != null && checkStorageInstId(tso, phySchema)) { + addToDeltaChangMap(logicDbTopology.getSchema(), null); + } + } else { + LogicDbTopology logicTopology = topologyManager.getLogicSchema(phySchema, phyTable); + if (logicTopology == null || logicTopology.getLogicTableMetas() == null + || logicTopology.getLogicTableMetas().get(0) == null) { + return; + } + if (checkStorageInstId(tso, phySchema)) { + addToDeltaChangMap(logicTopology.getSchema().toLowerCase(), + logicTopology.getLogicTableMetas().get(0).getTableName().toLowerCase()); + } + } + log.info("record delta change by physical change , with tso {}.", tso); + } + + private boolean checkStorageInstId(String tso, String phySchema) { + String storageInstIdInTopology = topologyManager.getStorageInstIdByPhySchema(phySchema); + if (!storageInstId.equals(storageInstIdInTopology)) { + log.info("receive a physical sql whose schema existing in topology but its storageInstId in topology is " + + "different with storageInstId in current meta manager, tso is {}, physical schema is {}, " + + "storageInstId in topology is {}, storageInstId in current meta manager is {}. ", tso, + phySchema, storageInstIdInTopology, storageInstId); + return false; + } else { + return true; + } + } + + private void addToDeltaChangMap(String logicSchema, String logicTable) { + deltaChangeMap.computeIfAbsent(logicSchema.toLowerCase(), k -> new HashSet<>()); + if (StringUtils.isNotBlank(logicTable)) { + deltaChangeMap.get(logicSchema.toLowerCase()).add(logicTable.toLowerCase()); + } + } + + private void removeFromDeltaChangeMap(String logicSchema) { + deltaChangeMap.remove(logicSchema.toLowerCase()); + } + + private void removeFromDeltaChangeMap(String logicSchema, String logicTable) { + if (deltaChangeMap.containsKey(logicSchema.toLowerCase())) { + Set deltaTables = deltaChangeMap.get(logicSchema.toLowerCase()); + deltaTables.remove(logicTable.toLowerCase()); + if (deltaTables.isEmpty()) { + deltaChangeMap.remove(logicSchema.toLowerCase()); + } + } + } + + private boolean compareLogicWithPhysical(String tso, String logicSchemaName, String logicTableName, + String phySchemaName, String phyTableName, boolean createPhyIfNotExist) { + // get table meta + // 先从distinctPhyMeta查,如果没查到,说明物理表和逻辑表的列序是一致的,如果查到了,在进行对比的时候必须以此为准 + TableMeta logicDimTableMeta = polarDbXLogicTableMeta.findDistinctPhy(logicSchemaName, logicTableName); + if (logicDimTableMeta == null) { + logicDimTableMeta = polarDbXLogicTableMeta.find(logicSchemaName, logicTableName); + } + TableMeta phyDimTableMeta = createPhyIfNotExist ? findPhyTable(phySchemaName, phyTableName) : + polarDbXStorageTableMeta.find(phySchemaName, phyTableName); + + // check meta if null + if (logicDimTableMeta == null) { + String message = String.format("compare failed, can`t find logic table meta %s:%s, with tso %s.", + logicSchemaName, logicTableName, tso); + throw new PolardbxException(message); + } + if (phyDimTableMeta == null) { + addToDeltaChangMap(logicSchemaName, logicTableName); + log.info("can`t find physical table meta, will record it to deltaChangeMap, phySchema {}, phyTable {}, " + + "tso {}.", phySchemaName, phyTableName, tso); + return false; + } + + //compare table meta + List logicDimColumns = logicDimTableMeta.getFields().stream() + .map(f -> SQLUtils.normalize(f.getColumnName().toLowerCase())).collect(Collectors.toList()); + List phyDimColumns = phyDimTableMeta.getFields().stream() + .map(f -> SQLUtils.normalize(f.getColumnName().toLowerCase())).collect(Collectors.toList()); + boolean result = logicDimColumns.equals(phyDimColumns); + if (!result) { + addToDeltaChangMap(logicSchemaName, logicTableName); + log.warn("logic and phy meta is not consistent, will record it to deltaChangeMap, logicSchema {}," + + " logicTable {}, phySchema {}, phyTable {},logicColumns {}, phy Columns {}, tso {}.", + logicSchemaName, logicTableName, phySchemaName, phyTableName, logicDimColumns, phyDimColumns, tso); + return false; + } + + return true; + } + + private void tryUpdateSemiSnapshotPosition(String tso) { + if (deltaChangeMap.isEmpty()) { + try { + SemiSnapshotInfoMapper mapper = SpringContextHolder.getObject(SemiSnapshotInfoMapper.class); + SemiSnapshotInfo info = new SemiSnapshotInfo(); + info.setTso(tso); + info.setStorageInstId(storageInstId); + mapper.insert(info); + } catch (DuplicateKeyException e) { + if (log.isDebugEnabled()) { + log.debug("semi snapshot point has existed for tso " + tso); + } + } + } else { + log.info("it is not a consistent semi snapshot point for tso {}, deltChangData is {}.", + tso, JSONObject.toJSONString(deltaChangeMap)); + } + } + + private String getSuitableSemiSnapshotTso(String snapshotTso, String rollbackTso) { + JdbcTemplate metaJdbcTemplate = SpringContextHolder.getObject("metaJdbcTemplate"); + return metaJdbcTemplate.queryForObject( + "select max(tso) tso from binlog_semi_snapshot where tso > '" + snapshotTso + + "' and tso <= '" + rollbackTso + "' and storage_inst_id = '" + storageInstId + "'", String.class); + } + + private void checkConsistencyBetweenTopologyAndLogicSchema() { + //看一下拓扑中的逻辑表是否都存在,fastsql之前出现过bug,创建一个和表名同名的索引,索引会把表覆盖掉,这里做一个校验 + List logicDbTopologies = topologyManager.getTopology().getLogicDbMetas(); + for (LogicDbTopology logicSchema : logicDbTopologies) { + String schema = logicSchema.getSchema(); + if (logicSchema.getLogicTableMetas() == null || logicSchema.getLogicTableMetas().isEmpty()) { + continue; + } + for (LogicTableMetaTopology tableMetaTopology : logicSchema.getLogicTableMetas()) { + TableMeta tableMeta = polarDbXLogicTableMeta.find(schema, tableMetaTopology.getTableName()); + if (tableMeta == null) { + throw new PolardbxException(String.format("checking consistency failed, logic table is not found," + + " %s:%s.", schema, tableMetaTopology.getTableName())); + } + } + } + } + + private void tryTriggerAlarm() { + try { + if (!deltaChangeMap.isEmpty()) { + JdbcTemplate polarxTemplate = SpringContextHolder.getObject("polarxJdbcTemplate"); + List> list = polarxTemplate.queryForList("show ddl"); + //如果ddl引擎中已经没有任务了,但是还有delta change data,可能出现了bug,触发报警 + if (list.isEmpty()) { + MonitorManager.getInstance() + .triggerAlarm(META_DATA_INCONSISTENT_WARNNIN, JSONObject.toJSONString(deltaChangeMap)); + } + } + } catch (Throwable t) { + log.error("send alarm error!", t); + } + } //------------------------------------------拓扑相关--------------------------------------- /** diff --git a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/Printer.java b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/Printer.java new file mode 100644 index 00000000..0083ab0b --- /dev/null +++ b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/Printer.java @@ -0,0 +1,75 @@ +package com.aliyun.polardbx.binlog.cdc.meta; + +import com.aliyun.polardbx.binlog.DynamicApplicationConfig; +import com.aliyun.polardbx.binlog.canal.core.ddl.TableMeta; +import com.aliyun.polardbx.binlog.canal.core.ddl.tsdb.MemoryTableMeta; +import com.aliyun.polardbx.binlog.canal.core.model.BinlogPosition; +import lombok.extern.slf4j.Slf4j; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static com.aliyun.polardbx.binlog.ConfigKeys.META_PRINT_DETAIL_AFTER_APPLY_SWITCH; +import static com.aliyun.polardbx.binlog.ConfigKeys.META_PRINT_DETAIL_AFTER_APPLY_TABLES; +import static com.aliyun.polardbx.binlog.ConfigKeys.META_PRINT_SUMMARY_AFTER_APPLY_SWITCH; +import static com.aliyun.polardbx.binlog.ConfigKeys.META_PRINT_SUMMARY_AFTER_APPLY_TABLES; + +/** + * created by ziyang.lb + **/ +@Slf4j +public class Printer { + private final static boolean IS_PRINT_SUMMARY = + DynamicApplicationConfig.getBoolean(META_PRINT_SUMMARY_AFTER_APPLY_SWITCH); + + private final static boolean IS_PRINT_DETAIL = + DynamicApplicationConfig.getBoolean(META_PRINT_DETAIL_AFTER_APPLY_SWITCH); + + private final static String SUMMARY_TABLES_PATTERN_STR = + DynamicApplicationConfig.getString(META_PRINT_SUMMARY_AFTER_APPLY_TABLES); + + private final static String DETAIL_TABLES_PATTERN_STR = + DynamicApplicationConfig.getString(META_PRINT_DETAIL_AFTER_APPLY_TABLES); + + private final static Pattern SUMMARY_PATTERN = Pattern.compile(SUMMARY_TABLES_PATTERN_STR); + + private final static Pattern DETAIL_PATTERN = Pattern.compile(DETAIL_TABLES_PATTERN_STR); + + public static boolean isSupportPrint() { + return IS_PRINT_SUMMARY || IS_PRINT_DETAIL; + } + + public static void tryPrint(BinlogPosition position, String schema, String table, + MemoryTableMeta memoryTableMeta) { + if (IS_PRINT_SUMMARY) { + printSummary(position, schema, table, memoryTableMeta); + } + if (IS_PRINT_DETAIL) { + printDetail(position, schema, table, memoryTableMeta); + } + } + + private static void printSummary(BinlogPosition position, String schema, String table, + MemoryTableMeta memoryTableMeta) { + String fullTable = schema + "." + table; + Matcher matcher = SUMMARY_PATTERN.matcher(fullTable); + if (matcher.find()) { + TableMeta tableMeta = memoryTableMeta.find(schema, table); + log.info("print summary : tso {}, fileName {}, filePosition {}, schema {}, table {}, tableMetaNullable {} ", + position.getRtso(), position.getFileName(), position.getPosition(), schema, table, tableMeta == null); + + } + } + + private static void printDetail(BinlogPosition position, String schema, String table, + MemoryTableMeta memoryTableMeta) { + String fullTable = schema + "." + table; + Matcher matcher = DETAIL_PATTERN.matcher(fullTable); + if (matcher.find()) { + TableMeta tableMeta = memoryTableMeta.find(schema, table); + log.info("print summary : tso {}, fileName {}, filePosition {}, schema {}, table {}, tableMetaNullable {}," + + " tableMetaInfo {}", position.getRtso(), position.getFileName(), position.getPosition(), schema, + table, tableMeta == null, tableMeta); + } + } +} diff --git a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/RollbackMode.java b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/RollbackMode.java new file mode 100644 index 00000000..621ecd80 --- /dev/null +++ b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/RollbackMode.java @@ -0,0 +1,44 @@ +package com.aliyun.polardbx.binlog.cdc.meta; + +/** + * Rollback时,元数据的构建方式 + **/ +public enum RollbackMode { + /** + * 逻辑表和物理表,都使用基于[一致的SNAPSHOT]的事件溯源模式进行元数据构建,真正意义上的基于镜像进行数据溯源的模式 + *

+ * 1. Snapshot:和时间线关联的一份全量元数据镜像,该镜像对应的元数据一定是保证[全局数据一致]的(即镜像所在的时间点,逻辑表和物理表结构一致,拓扑一致),是一个安全点 + * 2. 首先基于最近一次的Snapshot构建出一份全量元数据(逻辑+物理),然后重放该Snapshot之后的所有小于等于rollback tso的Logic&&Physical DDL Event + * 3. Baseline是一种特殊的Snapshot,如果不存在除了Baseline的其它Snapshot,则相当于每次都从CDC初始化的时间开始重放构建 + */ + SNAPSHOT_EXACTLY, + + /** + * 轻量级的Snapshot,或者说它只是一个Snapshot Point,不具备全局一致性,作用域限定在某个Storage。基本原理如下:Extractor每执行完一个逻辑DDL之后,会对逻辑表和物理表的 + * 元数据进行一次“Consistenty Check”,如果一致,则认为是一个Snapshot Point(这个Snapshot针对当前这个Storage有效),反正则忽略;每次Rollback的(Rollback的点记为RP), + * 会查找离rollback点最近的一次Snapshot Point(记为SP),然后按照如下步骤构建: + * 1. 基于Base构造Logic Meta + * 2. 重放大于Base小于等于SP的Logic DDL + * 3. 基于内存中最新的Logic Meta构造,构造Physical Meta + * 4. 重放大于SP,小于等于Rollback的 Logic DDL + * 5. 重放大于SP,小于等于Rollback的 Physical DDL + * 6. 构建完毕 + */ + SNAPSHOT_SEMI, + + /** + * 只有逻辑表使用基于[一致的SNAPSHOT]的事件溯源模式进行元数据构建,待逻辑表构建完成后,会在内存中得到一个Snapshot,这个Snapshot可能是一致的,也可能是不一致的 + * 物理表会基于这个Snapshot先构建出全量元数据,然后重放该该Snapshot之后的所有小于等于rollback tso的Physical DDL Event,不安全的方案,早期版本使用 + *

+ * 1. 基于逻辑表Schema直接创建出物理表Schema,这是一个有缺陷的模式,可能会触发数据一致性问题(是个概率事件) + * 2. 数据一致性问题的细节可参见: + * https://work.aone.alibaba-inc.com/issue/39018646 + * https://work.aone.alibaba-inc.com/issue/38874539 + */ + SNAPSHOT_UNSAFE, + + /** + * 从SNAPSHOT_EXACTLY和SNAPSHOT_SEMI中随机选择,主要在实验室环境使用 + */ + RANDOM, +} diff --git a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/domain/DDLRecord.java b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/domain/DDLRecord.java index 55b44022..1ad4df8e 100644 --- a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/domain/DDLRecord.java +++ b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/meta/domain/DDLRecord.java @@ -22,12 +22,18 @@ import lombok.ToString; /** - * + * created by ziyang.lb */ @Data @Builder @ToString public class DDLRecord { - private String sqlKind, schemaName, tableName, ddlSql, metaInfo, originDdlSql; + private Long id; + private Long jobId; + private String sqlKind; + private String schemaName; + private String tableName; + private String ddlSql; + private String metaInfo; private DDLExtInfo extInfo; } diff --git a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/topology/LogicMetaTopology.java b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/topology/LogicMetaTopology.java index 7b764b2d..3c424ea2 100644 --- a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/topology/LogicMetaTopology.java +++ b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/topology/LogicMetaTopology.java @@ -25,7 +25,7 @@ import java.util.List; /** - * Created by Shuguang + * created by ziyang.lb */ @Data @AllArgsConstructor diff --git a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/topology/TopologyManager.java b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/topology/TopologyManager.java index 6184d0fc..1319a4a0 100644 --- a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/topology/TopologyManager.java +++ b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/topology/TopologyManager.java @@ -162,6 +162,19 @@ public LogicDbTopology getLogicSchema(String phySchema) { return null; } + public String getStorageInstIdByPhySchema(String phySchema) { + Preconditions.checkNotNull(phySchema); + toLowerCase(phySchema); + for (LogicDbTopology logicSchema : topology.getLogicDbMetas()) { + for (PhyDbTopology phyDbTopology : logicSchema.getPhySchemas()) { + if (phySchema.equals(phyDbTopology.getSchema())) { + return phyDbTopology.getStorageInstId(); + } + } + } + return ""; + } + public LogicDbTopology getLogicSchema(String phySchema, String phyTable) { Preconditions.checkNotNull(phySchema); Preconditions.checkNotNull(phyTable); diff --git a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/topology/vo/TopologyRecord.java b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/topology/vo/TopologyRecord.java index 4d0263bc..64e47547 100644 --- a/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/topology/vo/TopologyRecord.java +++ b/polardbx-cdc-meta/src/main/java/com/aliyun/polardbx/binlog/cdc/topology/vo/TopologyRecord.java @@ -22,7 +22,7 @@ import lombok.Data; /** - * Created by Shuguang + * created by ziyang.lb */ @Data public class TopologyRecord { diff --git a/polardbx-cdc-meta/src/main/resources/db/migration/V17__Semi_Snapshot.sql b/polardbx-cdc-meta/src/main/resources/db/migration/V17__Semi_Snapshot.sql new file mode 100644 index 00000000..cc0ee2c8 --- /dev/null +++ b/polardbx-cdc-meta/src/main/resources/db/migration/V17__Semi_Snapshot.sql @@ -0,0 +1,9 @@ +create TABLE IF NOT EXISTS `binlog_semi_snapshot` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `gmt_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON update CURRENT_TIMESTAMP, + `tso` varchar(128) NOT NULL, + `storage_inst_id` varchar(200) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `uindex_storage_tso` (`storage_inst_id`,`tso`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; \ No newline at end of file diff --git a/polardbx-cdc-meta/src/main/resources/db/migration/V18__Binlog_Logic_Meta_History.sql b/polardbx-cdc-meta/src/main/resources/db/migration/V18__Binlog_Logic_Meta_History.sql new file mode 100644 index 00000000..c39cd000 --- /dev/null +++ b/polardbx-cdc-meta/src/main/resources/db/migration/V18__Binlog_Logic_Meta_History.sql @@ -0,0 +1,20 @@ +DELIMITER $$ + +DROP PROCEDURE IF EXISTS `add_column_binlog_logic_meta_history_v18` $$ + +CREATE PROCEDURE add_column_binlog_logic_meta_history_v18() +BEGIN + IF NOT EXISTS(SELECT * FROM information_schema.columns WHERE table_schema=(select database()) AND table_name='binlog_logic_meta_history' AND column_name='ddl_record_id') + THEN + ALTER TABLE `binlog_logic_meta_history` ADD column `ddl_record_id` bigint NULL DEFAULT NULL COMMENT '打标记录对应的id'; + ALTER TABLE `binlog_logic_meta_history` ADD index `idx_ddl_record_id`(`ddl_record_id`); + END IF; + + IF NOT EXISTS(SELECT * FROM information_schema.columns WHERE table_schema=(select database()) AND table_name='binlog_logic_meta_history' AND column_name='ddl_job_id') + THEN + ALTER TABLE `binlog_logic_meta_history` ADD column `ddl_job_id` bigint NULL DEFAULT NULL COMMENT '打标记录对应的job_id'; + END IF; +END $$ +DELIMITER ; + +CALL add_column_binlog_logic_meta_history_v18; \ No newline at end of file diff --git a/polardbx-cdc-meta/src/main/resources/db/migration/V19__Modify_Import_Meta.sql b/polardbx-cdc-meta/src/main/resources/db/migration/V19__Modify_Import_Meta.sql new file mode 100644 index 00000000..163d9cb9 --- /dev/null +++ b/polardbx-cdc-meta/src/main/resources/db/migration/V19__Modify_Import_Meta.sql @@ -0,0 +1,31 @@ +DELIMITER $$ +DROP PROCEDURE IF EXISTS `modify_import_meta_v19` $$ +CREATE PROCEDURE modify_import_meta_v19() +BEGIN + IF EXISTS(SELECT * FROM information_schema.columns WHERE table_schema=(select database()) AND table_name='rpl_task' AND column_name='extractor_config') + THEN + alter table rpl_task modify column `extractor_config` longtext; + END IF; + IF EXISTS(SELECT * FROM information_schema.columns WHERE table_schema=(select database()) AND table_name='rpl_task' AND column_name='pipeline__config') + THEN + alter table rpl_task modify column `pipeline_config` longtext; + END IF; + IF EXISTS(SELECT * FROM information_schema.columns WHERE table_schema=(select database()) AND table_name='rpl_task' AND column_name='applier_config') + THEN + alter table rpl_task modify column `applier_config` longtext; + END IF; + IF EXISTS(SELECT * FROM information_schema.columns WHERE table_schema=(select database()) AND table_name='rpl_task' AND column_name='worker') + THEN + alter table rpl_task modify column `worker` varchar(64) DEFAULT NULL; + END IF; + IF EXISTS(SELECT * FROM information_schema.columns WHERE table_schema=(select database()) AND table_name='rpl_table_position' AND column_name='full_table_name') + THEN + alter table rpl_table_position modify column `full_table_name` varchar(128) DEFAULT NULL; + END IF; + IF EXISTS(SELECT * FROM information_schema.columns WHERE table_schema=(select database()) AND table_name='rpl_db_full_position' AND column_name='full_table_name') + THEN + alter table rpl_db_full_position modify column `full_table_name` varchar(128) DEFAULT NULL; + END IF; +END $$ +DELIMITER ; +CALL modify_import_meta_v19; \ No newline at end of file diff --git a/polardbx-cdc-meta/src/test/java/com/aliyun/polardbx/binlog/cdc/meta/PolarDbXTableMetaManagerTest.java b/polardbx-cdc-meta/src/test/java/com/aliyun/polardbx/binlog/cdc/meta/PolarDbXTableMetaManagerTest.java index 8054c414..d29ad0d5 100644 --- a/polardbx-cdc-meta/src/test/java/com/aliyun/polardbx/binlog/cdc/meta/PolarDbXTableMetaManagerTest.java +++ b/polardbx-cdc-meta/src/test/java/com/aliyun/polardbx/binlog/cdc/meta/PolarDbXTableMetaManagerTest.java @@ -40,25 +40,25 @@ public void init() { @Test public void apply() { - PolarDbXTableMetaManager metaManager = new PolarDbXTableMetaManager("polardbx-storage-0-master", null, null); - metaManager.init("Final"); + PolarDbXTableMetaManager metaManager = new PolarDbXTableMetaManager("polardbx-storage-0-master"); + metaManager.init(); metaManager.rollback(new BinlogPosition(null, "675548357978085952012865487953073274880000000000000000")); - System.out.println(metaManager.findLogic("ddl_test", "all_type")); - System.out.println(metaManager.find("ddl_test_single", "all_type")); + System.out.println(metaManager.findLogicTable("ddl_test", "all_type")); + System.out.println(metaManager.findPhyTable("ddl_test_single", "all_type")); } @Test public void rollback() { - PolarDbXTableMetaManager metaManager = new PolarDbXTableMetaManager("polardbx-storage-0-master", null, null); - metaManager.init("Final"); + PolarDbXTableMetaManager metaManager = new PolarDbXTableMetaManager("polardbx-storage-0-master"); + metaManager.init(); metaManager.rollback(new BinlogPosition(null, "684854406688853196813796092824455782400000000000000000")); - System.out.println(metaManager.findLogic("d1", "t4")); - System.out.println(metaManager.findLogic("d1", "t5")); + System.out.println(metaManager.findLogicTable("d1", "t4")); + System.out.println(metaManager.findLogicTable("d1", "t5")); } @@ -79,19 +79,19 @@ public void apply1() { + "type_text text DEFAULT '你好'" + ")"; - PolarDbXTableMetaManager metaManager = new PolarDbXTableMetaManager("polardbx-storage-0-master", null, null); + PolarDbXTableMetaManager metaManager = new PolarDbXTableMetaManager("polardbx-storage-0-master"); - metaManager.init("Final"); + metaManager.init(); DDLRecord record = DDLRecord.builder() .schemaName("d1") .ddlSql(create) .build(); - metaManager.apply(new BinlogPosition(null, "2"), "d2", create, null); + metaManager.applyPhysical(new BinlogPosition(null, "2"), "d2", create, null); metaManager.applyLogic(new BinlogPosition(null, "2"), record, ""); - System.out.println(metaManager.findLogic("d1", "t1")); + System.out.println(metaManager.findLogicTable("d1", "t1")); } @@ -99,16 +99,16 @@ public void apply1() { public void apply2() { LogicMetaTopology x = gson.fromJson(MockData.BASE, LogicMetaTopology.class); - PolarDbXTableMetaManager metaManager1 = new PolarDbXTableMetaManager("polardbx-storage-0-master", null, null); + PolarDbXTableMetaManager metaManager1 = new PolarDbXTableMetaManager("polardbx-storage-0-master"); - metaManager1.init("Final"); + metaManager1.init(); metaManager1.applyBase(new BinlogPosition(null, "1"), x); System.out.println(metaManager1.getPhyTables("polardbx-storage-0-master")); - PolarDbXTableMetaManager metaManager2 = new PolarDbXTableMetaManager("polardbx-storage-1-master", null, null); + PolarDbXTableMetaManager metaManager2 = new PolarDbXTableMetaManager("polardbx-storage-1-master"); - metaManager2.init("Final"); + metaManager2.init(); metaManager2.applyBase(new BinlogPosition(null, "2"), x); System.out.println(metaManager2.getPhyTables("polardbx-storage-1-master")); @@ -118,12 +118,12 @@ public void apply2() { @Test public void rollback1() { - PolarDbXTableMetaManager metaManager = new PolarDbXTableMetaManager("polardbx-storage-0-master", null, null); - metaManager.init("Final"); + PolarDbXTableMetaManager metaManager = new PolarDbXTableMetaManager("polardbx-storage-0-master"); + metaManager.init(); - metaManager.rollback(new BinlogPosition(null, "684854406688853196813796092824455782400000000000000000")); - System.out.println(metaManager.findLogic("d1", "t4")); - System.out.println(metaManager.findLogic("d1", "t5")); + metaManager.rollback(new BinlogPosition(null, "88735321530669472014184184307253288970000000000000000")); + System.out.println(metaManager.findLogicTable("d1", "t4")); + System.out.println(metaManager.findLogicTable("d1", "t5")); } diff --git a/polardbx-cdc-monitor/pom.xml b/polardbx-cdc-monitor/pom.xml index ecaabf88..80182099 100644 --- a/polardbx-cdc-monitor/pom.xml +++ b/polardbx-cdc-monitor/pom.xml @@ -5,7 +5,7 @@ polardbx-cdc com.aliyun.polardbx - 5.4.12-SNAPSHOT + 5.4.13-SNAPSHOT 4.0.0 diff --git a/polardbx-cdc-monitor/src/main/java/com/aliyun/polardbx/binlog/monitor/MonitorType.java b/polardbx-cdc-monitor/src/main/java/com/aliyun/polardbx/binlog/monitor/MonitorType.java index 78bdd0e8..3a9ffbb6 100644 --- a/polardbx-cdc-monitor/src/main/java/com/aliyun/polardbx/binlog/monitor/MonitorType.java +++ b/polardbx-cdc-monitor/src/main/java/com/aliyun/polardbx/binlog/monitor/MonitorType.java @@ -176,6 +176,14 @@ public enum MonitorType { 5, 10, true + ), + META_DATA_INCONSISTENT_WARNNIN( + "polarx_cdc_meta_data_inconsistent_warnning", + true, + "当前已经没有执行中的DDL任务,CDC元数据仍然存在不一致,请及时关注,DeltaChangeData: %s", + 1, + 10, + true ); private String desc; diff --git a/polardbx-cdc-protocol/pom.xml b/polardbx-cdc-protocol/pom.xml index aaaf6010..283b671c 100644 --- a/polardbx-cdc-protocol/pom.xml +++ b/polardbx-cdc-protocol/pom.xml @@ -5,12 +5,12 @@ polardbx-cdc com.aliyun.polardbx - 5.4.12-SNAPSHOT + 5.4.13-SNAPSHOT 4.0.0 polardbx-cdc-protocol - + diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/DumpReply.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/DumpReply.java index 447dfa4b..ac5551e8 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/DumpReply.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/DumpReply.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -27,834 +10,761 @@ public final class DumpReply extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:com.aliyun.polardbx.binlog.protocol.DumpReply) DumpReplyOrBuilder { - private static final long serialVersionUID = 0L; - - // Use DumpReply.newBuilder() to construct. - private DumpReply(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); +private static final long serialVersionUID = 0L; + // Use DumpReply.newBuilder() to construct. + private DumpReply(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private DumpReply() { + txnMessage_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new DumpReply(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private DumpReply( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + txnMessage_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + txnMessage_.add( + input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnMessage.parser(), extensionRegistry)); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + txnMessage_ = java.util.Collections.unmodifiableList(txnMessage_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_DumpReply_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_DumpReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.binlog.protocol.DumpReply.class, com.aliyun.polardbx.binlog.protocol.DumpReply.Builder.class); + } + + public static final int TXNMESSAGE_FIELD_NUMBER = 1; + private java.util.List txnMessage_; + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + @java.lang.Override + public java.util.List getTxnMessageList() { + return txnMessage_; + } + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + @java.lang.Override + public java.util.List + getTxnMessageOrBuilderList() { + return txnMessage_; + } + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + @java.lang.Override + public int getTxnMessageCount() { + return txnMessage_.size(); + } + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnMessage getTxnMessage(int index) { + return txnMessage_.get(index); + } + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnMessageOrBuilder getTxnMessageOrBuilder( + int index) { + return txnMessage_.get(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < txnMessage_.size(); i++) { + output.writeMessage(1, txnMessage_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < txnMessage_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, txnMessage_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.DumpReply)) { + return super.equals(obj); + } + com.aliyun.polardbx.binlog.protocol.DumpReply other = (com.aliyun.polardbx.binlog.protocol.DumpReply) obj; + + if (!getTxnMessageList() + .equals(other.getTxnMessageList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getTxnMessageCount() > 0) { + hash = (37 * hash) + TXNMESSAGE_FIELD_NUMBER; + hash = (53 * hash) + getTxnMessageList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.binlog.protocol.DumpReply parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.DumpReply parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.DumpReply parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.DumpReply parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.DumpReply parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.DumpReply parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.DumpReply parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.DumpReply parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.DumpReply parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.DumpReply parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.DumpReply parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.DumpReply parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.DumpReply prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.DumpReply} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.DumpReply) + com.aliyun.polardbx.binlog.protocol.DumpReplyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_DumpReply_descriptor; } - private DumpReply() { - txnMessage_ = java.util.Collections.emptyList(); + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_DumpReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.binlog.protocol.DumpReply.class, com.aliyun.polardbx.binlog.protocol.DumpReply.Builder.class); } - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new DumpReply(); + // Construct using com.aliyun.polardbx.binlog.protocol.DumpReply.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); } + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getTxnMessageFieldBuilder(); + } + } @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; + public Builder clear() { + super.clear(); + if (txnMessageBuilder_ == null) { + txnMessage_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + txnMessageBuilder_.clear(); + } + return this; } - private DumpReply( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - 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; - case 10: { - if (!((mutable_bitField0_ & 0x00000001) != 0)) { - txnMessage_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000001; - } - txnMessage_.add( - input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnMessage.parser(), extensionRegistry)); - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000001) != 0)) { - txnMessage_ = java.util.Collections.unmodifiableList(txnMessage_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_DumpReply_descriptor; } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_DumpReply_descriptor; + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.DumpReply getDefaultInstanceForType() { + return com.aliyun.polardbx.binlog.protocol.DumpReply.getDefaultInstance(); } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_DumpReply_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.aliyun.polardbx.binlog.protocol.DumpReply.class, - com.aliyun.polardbx.binlog.protocol.DumpReply.Builder.class); + public com.aliyun.polardbx.binlog.protocol.DumpReply build() { + com.aliyun.polardbx.binlog.protocol.DumpReply result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; } - public static final int TXNMESSAGE_FIELD_NUMBER = 1; - private java.util.List txnMessage_; - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ @java.lang.Override - public java.util.List getTxnMessageList() { - return txnMessage_; + public com.aliyun.polardbx.binlog.protocol.DumpReply buildPartial() { + com.aliyun.polardbx.binlog.protocol.DumpReply result = new com.aliyun.polardbx.binlog.protocol.DumpReply(this); + int from_bitField0_ = bitField0_; + if (txnMessageBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + txnMessage_ = java.util.Collections.unmodifiableList(txnMessage_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.txnMessage_ = txnMessage_; + } else { + result.txnMessage_ = txnMessageBuilder_.build(); + } + onBuilt(); + return result; } - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ @java.lang.Override - public java.util.List - getTxnMessageOrBuilderList() { - return txnMessage_; + public Builder clone() { + return super.clone(); } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ @java.lang.Override - public int getTxnMessageCount() { - return txnMessage_.size(); + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnMessage getTxnMessage(int index) { - return txnMessage_.get(index); + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnMessageOrBuilder getTxnMessageOrBuilder( - int index) { - return txnMessage_.get(index); + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); } - - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } - - memoizedIsInitialized = 1; - return true; + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); } - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - for (int i = 0; i < txnMessage_.size(); i++) { - output.writeMessage(1, txnMessage_.get(i)); - } - unknownFields.writeTo(output); + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); } - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) { - return size; - } - - size = 0; - for (int i = 0; i < txnMessage_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, txnMessage_.get(i)); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.binlog.protocol.DumpReply) { + return mergeFrom((com.aliyun.polardbx.binlog.protocol.DumpReply)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.DumpReply other) { + if (other == com.aliyun.polardbx.binlog.protocol.DumpReply.getDefaultInstance()) return this; + if (txnMessageBuilder_ == null) { + if (!other.txnMessage_.isEmpty()) { + if (txnMessage_.isEmpty()) { + txnMessage_ = other.txnMessage_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureTxnMessageIsMutable(); + txnMessage_.addAll(other.txnMessage_); + } + onChanged(); + } + } else { + if (!other.txnMessage_.isEmpty()) { + if (txnMessageBuilder_.isEmpty()) { + txnMessageBuilder_.dispose(); + txnMessageBuilder_ = null; + txnMessage_ = other.txnMessage_; + bitField0_ = (bitField0_ & ~0x00000001); + txnMessageBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getTxnMessageFieldBuilder() : null; + } else { + txnMessageBuilder_.addAllMessages(other.txnMessage_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; } @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.DumpReply)) { - return super.equals(obj); - } - com.aliyun.polardbx.binlog.protocol.DumpReply other = (com.aliyun.polardbx.binlog.protocol.DumpReply) obj; - - if (!getTxnMessageList() - .equals(other.getTxnMessageList())) { - return false; - } - if (!unknownFields.equals(other.unknownFields)) { - return false; - } - return true; + public final boolean isInitialized() { + return true; } @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (getTxnMessageCount() > 0) { - hash = (37 * hash) + TXNMESSAGE_FIELD_NUMBER; - hash = (53 * hash) + getTxnMessageList().hashCode(); + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.aliyun.polardbx.binlog.protocol.DumpReply parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.binlog.protocol.DumpReply) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; + } + return this; } + private int bitField0_; - public static com.aliyun.polardbx.binlog.protocol.DumpReply parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + private java.util.List txnMessage_ = + java.util.Collections.emptyList(); + private void ensureTxnMessageIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + txnMessage_ = new java.util.ArrayList(txnMessage_); + bitField0_ |= 0x00000001; + } } - public static com.aliyun.polardbx.binlog.protocol.DumpReply parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } + private com.google.protobuf.RepeatedFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnMessage, com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder, com.aliyun.polardbx.binlog.protocol.TxnMessageOrBuilder> txnMessageBuilder_; - public static com.aliyun.polardbx.binlog.protocol.DumpReply parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + public java.util.List getTxnMessageList() { + if (txnMessageBuilder_ == null) { + return java.util.Collections.unmodifiableList(txnMessage_); + } else { + return txnMessageBuilder_.getMessageList(); + } } - - public static com.aliyun.polardbx.binlog.protocol.DumpReply parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + public int getTxnMessageCount() { + if (txnMessageBuilder_ == null) { + return txnMessage_.size(); + } else { + return txnMessageBuilder_.getCount(); + } } - - public static com.aliyun.polardbx.binlog.protocol.DumpReply parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + public com.aliyun.polardbx.binlog.protocol.TxnMessage getTxnMessage(int index) { + if (txnMessageBuilder_ == null) { + return txnMessage_.get(index); + } else { + return txnMessageBuilder_.getMessage(index); + } } - - public static com.aliyun.polardbx.binlog.protocol.DumpReply parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + public Builder setTxnMessage( + int index, com.aliyun.polardbx.binlog.protocol.TxnMessage value) { + if (txnMessageBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTxnMessageIsMutable(); + txnMessage_.set(index, value); + onChanged(); + } else { + txnMessageBuilder_.setMessage(index, value); + } + return this; } - - public static com.aliyun.polardbx.binlog.protocol.DumpReply parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + public Builder setTxnMessage( + int index, com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder builderForValue) { + if (txnMessageBuilder_ == null) { + ensureTxnMessageIsMutable(); + txnMessage_.set(index, builderForValue.build()); + onChanged(); + } else { + txnMessageBuilder_.setMessage(index, builderForValue.build()); + } + return this; } - - public static com.aliyun.polardbx.binlog.protocol.DumpReply parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + public Builder addTxnMessage(com.aliyun.polardbx.binlog.protocol.TxnMessage value) { + if (txnMessageBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTxnMessageIsMutable(); + txnMessage_.add(value); + onChanged(); + } else { + txnMessageBuilder_.addMessage(value); + } + return this; } - - public static com.aliyun.polardbx.binlog.protocol.DumpReply parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + public Builder addTxnMessage( + int index, com.aliyun.polardbx.binlog.protocol.TxnMessage value) { + if (txnMessageBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTxnMessageIsMutable(); + txnMessage_.add(index, value); + onChanged(); + } else { + txnMessageBuilder_.addMessage(index, value); + } + return this; } - - public static com.aliyun.polardbx.binlog.protocol.DumpReply parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + public Builder addTxnMessage( + com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder builderForValue) { + if (txnMessageBuilder_ == null) { + ensureTxnMessageIsMutable(); + txnMessage_.add(builderForValue.build()); + onChanged(); + } else { + txnMessageBuilder_.addMessage(builderForValue.build()); + } + return this; } - - public static com.aliyun.polardbx.binlog.protocol.DumpReply parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + public Builder addTxnMessage( + int index, com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder builderForValue) { + if (txnMessageBuilder_ == null) { + ensureTxnMessageIsMutable(); + txnMessage_.add(index, builderForValue.build()); + onChanged(); + } else { + txnMessageBuilder_.addMessage(index, builderForValue.build()); + } + return this; } - - public static com.aliyun.polardbx.binlog.protocol.DumpReply parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + public Builder addAllTxnMessage( + java.lang.Iterable values) { + if (txnMessageBuilder_ == null) { + ensureTxnMessageIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, txnMessage_); + onChanged(); + } else { + txnMessageBuilder_.addAllMessages(values); + } + return this; } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + public Builder clearTxnMessage() { + if (txnMessageBuilder_ == null) { + txnMessage_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + txnMessageBuilder_.clear(); + } + return this; } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + public Builder removeTxnMessage(int index) { + if (txnMessageBuilder_ == null) { + ensureTxnMessageIsMutable(); + txnMessage_.remove(index); + onChanged(); + } else { + txnMessageBuilder_.remove(index); + } + return this; } - - public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.DumpReply prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + public com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder getTxnMessageBuilder( + int index) { + return getTxnMessageFieldBuilder().getBuilder(index); } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + public com.aliyun.polardbx.binlog.protocol.TxnMessageOrBuilder getTxnMessageOrBuilder( + int index) { + if (txnMessageBuilder_ == null) { + return txnMessage_.get(index); } else { + return txnMessageBuilder_.getMessageOrBuilder(index); + } } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + public java.util.List + getTxnMessageOrBuilderList() { + if (txnMessageBuilder_ != null) { + return txnMessageBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(txnMessage_); + } } - /** - * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.DumpReply} + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.DumpReply) - com.aliyun.polardbx.binlog.protocol.DumpReplyOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_DumpReply_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_DumpReply_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.aliyun.polardbx.binlog.protocol.DumpReply.class, - com.aliyun.polardbx.binlog.protocol.DumpReply.Builder.class); - } - - // Construct using com.aliyun.polardbx.binlog.protocol.DumpReply.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - getTxnMessageFieldBuilder(); - } - } - - @java.lang.Override - public Builder clear() { - super.clear(); - if (txnMessageBuilder_ == null) { - txnMessage_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - } else { - txnMessageBuilder_.clear(); - } - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_DumpReply_descriptor; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.DumpReply getDefaultInstanceForType() { - return com.aliyun.polardbx.binlog.protocol.DumpReply.getDefaultInstance(); - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.DumpReply build() { - com.aliyun.polardbx.binlog.protocol.DumpReply result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.DumpReply buildPartial() { - com.aliyun.polardbx.binlog.protocol.DumpReply result = - new com.aliyun.polardbx.binlog.protocol.DumpReply(this); - int from_bitField0_ = bitField0_; - if (txnMessageBuilder_ == null) { - if (((bitField0_ & 0x00000001) != 0)) { - txnMessage_ = java.util.Collections.unmodifiableList(txnMessage_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.txnMessage_ = txnMessage_; - } else { - result.txnMessage_ = txnMessageBuilder_.build(); - } - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.aliyun.polardbx.binlog.protocol.DumpReply) { - return mergeFrom((com.aliyun.polardbx.binlog.protocol.DumpReply) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.DumpReply other) { - if (other == com.aliyun.polardbx.binlog.protocol.DumpReply.getDefaultInstance()) { - return this; - } - if (txnMessageBuilder_ == null) { - if (!other.txnMessage_.isEmpty()) { - if (txnMessage_.isEmpty()) { - txnMessage_ = other.txnMessage_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureTxnMessageIsMutable(); - txnMessage_.addAll(other.txnMessage_); - } - onChanged(); - } - } else { - if (!other.txnMessage_.isEmpty()) { - if (txnMessageBuilder_.isEmpty()) { - txnMessageBuilder_.dispose(); - txnMessageBuilder_ = null; - txnMessage_ = other.txnMessage_; - bitField0_ = (bitField0_ & ~0x00000001); - txnMessageBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? - getTxnMessageFieldBuilder() : null; - } else { - txnMessageBuilder_.addAllMessages(other.txnMessage_); - } - } - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.aliyun.polardbx.binlog.protocol.DumpReply parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.aliyun.polardbx.binlog.protocol.DumpReply) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private int bitField0_; - - private java.util.List txnMessage_ = - java.util.Collections.emptyList(); - - private void ensureTxnMessageIsMutable() { - if (!((bitField0_ & 0x00000001) != 0)) { - txnMessage_ = new java.util.ArrayList(txnMessage_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnMessage, com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder, com.aliyun.polardbx.binlog.protocol.TxnMessageOrBuilder> - txnMessageBuilder_; - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - public java.util.List getTxnMessageList() { - if (txnMessageBuilder_ == null) { - return java.util.Collections.unmodifiableList(txnMessage_); - } else { - return txnMessageBuilder_.getMessageList(); - } - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - public int getTxnMessageCount() { - if (txnMessageBuilder_ == null) { - return txnMessage_.size(); - } else { - return txnMessageBuilder_.getCount(); - } - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - public com.aliyun.polardbx.binlog.protocol.TxnMessage getTxnMessage(int index) { - if (txnMessageBuilder_ == null) { - return txnMessage_.get(index); - } else { - return txnMessageBuilder_.getMessage(index); - } - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - public Builder setTxnMessage( - int index, com.aliyun.polardbx.binlog.protocol.TxnMessage value) { - if (txnMessageBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureTxnMessageIsMutable(); - txnMessage_.set(index, value); - onChanged(); - } else { - txnMessageBuilder_.setMessage(index, value); - } - return this; - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - public Builder setTxnMessage( - int index, com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder builderForValue) { - if (txnMessageBuilder_ == null) { - ensureTxnMessageIsMutable(); - txnMessage_.set(index, builderForValue.build()); - onChanged(); - } else { - txnMessageBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - public Builder addTxnMessage(com.aliyun.polardbx.binlog.protocol.TxnMessage value) { - if (txnMessageBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureTxnMessageIsMutable(); - txnMessage_.add(value); - onChanged(); - } else { - txnMessageBuilder_.addMessage(value); - } - return this; - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - public Builder addTxnMessage( - int index, com.aliyun.polardbx.binlog.protocol.TxnMessage value) { - if (txnMessageBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureTxnMessageIsMutable(); - txnMessage_.add(index, value); - onChanged(); - } else { - txnMessageBuilder_.addMessage(index, value); - } - return this; - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - public Builder addTxnMessage( - com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder builderForValue) { - if (txnMessageBuilder_ == null) { - ensureTxnMessageIsMutable(); - txnMessage_.add(builderForValue.build()); - onChanged(); - } else { - txnMessageBuilder_.addMessage(builderForValue.build()); - } - return this; - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - public Builder addTxnMessage( - int index, com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder builderForValue) { - if (txnMessageBuilder_ == null) { - ensureTxnMessageIsMutable(); - txnMessage_.add(index, builderForValue.build()); - onChanged(); - } else { - txnMessageBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - public Builder addAllTxnMessage( - java.lang.Iterable values) { - if (txnMessageBuilder_ == null) { - ensureTxnMessageIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, txnMessage_); - onChanged(); - } else { - txnMessageBuilder_.addAllMessages(values); - } - return this; - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - public Builder clearTxnMessage() { - if (txnMessageBuilder_ == null) { - txnMessage_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - txnMessageBuilder_.clear(); - } - return this; - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - public Builder removeTxnMessage(int index) { - if (txnMessageBuilder_ == null) { - ensureTxnMessageIsMutable(); - txnMessage_.remove(index); - onChanged(); - } else { - txnMessageBuilder_.remove(index); - } - return this; - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - public com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder getTxnMessageBuilder( - int index) { - return getTxnMessageFieldBuilder().getBuilder(index); - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - public com.aliyun.polardbx.binlog.protocol.TxnMessageOrBuilder getTxnMessageOrBuilder( - int index) { - if (txnMessageBuilder_ == null) { - return txnMessage_.get(index); - } else { - return txnMessageBuilder_.getMessageOrBuilder(index); - } - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - public java.util.List - getTxnMessageOrBuilderList() { - if (txnMessageBuilder_ != null) { - return txnMessageBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(txnMessage_); - } - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - public com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder addTxnMessageBuilder() { - return getTxnMessageFieldBuilder().addBuilder( - com.aliyun.polardbx.binlog.protocol.TxnMessage.getDefaultInstance()); - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - public com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder addTxnMessageBuilder( - int index) { - return getTxnMessageFieldBuilder().addBuilder( - index, com.aliyun.polardbx.binlog.protocol.TxnMessage.getDefaultInstance()); - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - public java.util.List - getTxnMessageBuilderList() { - return getTxnMessageFieldBuilder().getBuilderList(); - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnMessage, com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder, com.aliyun.polardbx.binlog.protocol.TxnMessageOrBuilder> + public com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder addTxnMessageBuilder() { + return getTxnMessageFieldBuilder().addBuilder( + com.aliyun.polardbx.binlog.protocol.TxnMessage.getDefaultInstance()); + } + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + public com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder addTxnMessageBuilder( + int index) { + return getTxnMessageFieldBuilder().addBuilder( + index, com.aliyun.polardbx.binlog.protocol.TxnMessage.getDefaultInstance()); + } + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + public java.util.List + getTxnMessageBuilderList() { + return getTxnMessageFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnMessage, com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder, com.aliyun.polardbx.binlog.protocol.TxnMessageOrBuilder> getTxnMessageFieldBuilder() { - if (txnMessageBuilder_ == null) { - txnMessageBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnMessage, com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder, com.aliyun.polardbx.binlog.protocol.TxnMessageOrBuilder>( - txnMessage_, - ((bitField0_ & 0x00000001) != 0), - getParentForChildren(), - isClean()); - txnMessage_ = null; - } - return txnMessageBuilder_; - } - - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.DumpReply) + if (txnMessageBuilder_ == null) { + txnMessageBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnMessage, com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder, com.aliyun.polardbx.binlog.protocol.TxnMessageOrBuilder>( + txnMessage_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + txnMessage_ = null; + } + return txnMessageBuilder_; } - - // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.DumpReply) - private static final com.aliyun.polardbx.binlog.protocol.DumpReply DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.DumpReply(); + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); } - public static com.aliyun.polardbx.binlog.protocol.DumpReply getDefaultInstance() { - return DEFAULT_INSTANCE; + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public DumpReply parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new DumpReply(input, extensionRegistry); - } - }; - public static com.google.protobuf.Parser parser() { - return PARSER; - } + // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.DumpReply) + } - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } + // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.DumpReply) + private static final com.aliyun.polardbx.binlog.protocol.DumpReply DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.DumpReply(); + } + + public static com.aliyun.polardbx.binlog.protocol.DumpReply getDefaultInstance() { + return DEFAULT_INSTANCE; + } + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.DumpReply getDefaultInstanceForType() { - return DEFAULT_INSTANCE; + public DumpReply parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DumpReply(input, extensionRegistry); } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.DumpReply getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/DumpReplyOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/DumpReplyOrBuilder.java index 27b57545..c4bdcc80 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/DumpReplyOrBuilder.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/DumpReplyOrBuilder.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -24,31 +7,27 @@ public interface DumpReplyOrBuilder extends // @@protoc_insertion_point(interface_extends:com.aliyun.polardbx.binlog.protocol.DumpReply) com.google.protobuf.MessageOrBuilder { - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - java.util.List - getTxnMessageList(); - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - com.aliyun.polardbx.binlog.protocol.TxnMessage getTxnMessage(int index); - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - int getTxnMessageCount(); - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - java.util.List - getTxnMessageOrBuilderList(); - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; - */ - com.aliyun.polardbx.binlog.protocol.TxnMessageOrBuilder getTxnMessageOrBuilder( - int index); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + java.util.List + getTxnMessageList(); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + com.aliyun.polardbx.binlog.protocol.TxnMessage getTxnMessage(int index); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + int getTxnMessageCount(); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + java.util.List + getTxnMessageOrBuilderList(); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnMessage txnMessage = 1; + */ + com.aliyun.polardbx.binlog.protocol.TxnMessageOrBuilder getTxnMessageOrBuilder( + int index); } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/DumpRequest.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/DumpRequest.java index ec1ea62d..6cf4ec27 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/DumpRequest.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/DumpRequest.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -27,608 +10,548 @@ public final class DumpRequest extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:com.aliyun.polardbx.binlog.protocol.DumpRequest) DumpRequestOrBuilder { - private static final long serialVersionUID = 0L; - - // Use DumpRequest.newBuilder() to construct. - private DumpRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private DumpRequest() { - tso_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new DumpRequest(); - } +private static final long serialVersionUID = 0L; + // Use DumpRequest.newBuilder() to construct. + private DumpRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private DumpRequest() { + tso_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new DumpRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private DumpRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - - private DumpRequest( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - 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; - case 10: { - java.lang.String s = input.readStringRequireUtf8(); - - tso_ = s; - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } + tso_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_DumpRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_DumpRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.binlog.protocol.DumpRequest.class, com.aliyun.polardbx.binlog.protocol.DumpRequest.Builder.class); + } + + public static final int TSO_FIELD_NUMBER = 1; + private volatile java.lang.Object tso_; + /** + * string tso = 1; + * @return The tso. + */ + @java.lang.Override + public java.lang.String getTso() { + java.lang.Object ref = tso_; + 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(); + tso_ = s; + return s; + } + } + /** + * string tso = 1; + * @return The bytes for tso. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getTsoBytes() { + java.lang.Object ref = tso_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + tso_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getTsoBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, tso_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getTsoBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, tso_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.DumpRequest)) { + return super.equals(obj); + } + com.aliyun.polardbx.binlog.protocol.DumpRequest other = (com.aliyun.polardbx.binlog.protocol.DumpRequest) obj; + + if (!getTso() + .equals(other.getTso())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TSO_FIELD_NUMBER; + hash = (53 * hash) + getTso().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.DumpRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.DumpRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.DumpRequest) + com.aliyun.polardbx.binlog.protocol.DumpRequestOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_DumpRequest_descriptor; + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_DumpRequest_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_DumpRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.aliyun.polardbx.binlog.protocol.DumpRequest.class, - com.aliyun.polardbx.binlog.protocol.DumpRequest.Builder.class); + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_DumpRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.binlog.protocol.DumpRequest.class, com.aliyun.polardbx.binlog.protocol.DumpRequest.Builder.class); } - public static final int TSO_FIELD_NUMBER = 1; - private volatile java.lang.Object tso_; - - /** - * string tso = 1; - * - * @return The tso. - */ - @java.lang.Override - public java.lang.String getTso() { - java.lang.Object ref = tso_; - 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(); - tso_ = s; - return s; - } + // Construct using com.aliyun.polardbx.binlog.protocol.DumpRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); } - /** - * string tso = 1; - * - * @return The bytes for tso. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getTsoBytes() { - java.lang.Object ref = tso_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - tso_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } } - - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } + public Builder clear() { + super.clear(); + tso_ = ""; - memoizedIsInitialized = 1; - return true; + return this; } @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getTsoBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, tso_); - } - unknownFields.writeTo(output); + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_DumpRequest_descriptor; } @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) { - return size; - } - - size = 0; - if (!getTsoBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, tso_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; + public com.aliyun.polardbx.binlog.protocol.DumpRequest getDefaultInstanceForType() { + return com.aliyun.polardbx.binlog.protocol.DumpRequest.getDefaultInstance(); } @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.DumpRequest)) { - return super.equals(obj); - } - com.aliyun.polardbx.binlog.protocol.DumpRequest other = (com.aliyun.polardbx.binlog.protocol.DumpRequest) obj; - - if (!getTso() - .equals(other.getTso())) { - return false; - } - if (!unknownFields.equals(other.unknownFields)) { - return false; - } - return true; + public com.aliyun.polardbx.binlog.protocol.DumpRequest build() { + com.aliyun.polardbx.binlog.protocol.DumpRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; } @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + TSO_FIELD_NUMBER; - hash = (53 * hash) + getTso().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; + public com.aliyun.polardbx.binlog.protocol.DumpRequest buildPartial() { + com.aliyun.polardbx.binlog.protocol.DumpRequest result = new com.aliyun.polardbx.binlog.protocol.DumpRequest(this); + result.tso_ = tso_; + onBuilt(); + return result; } - public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + @java.lang.Override + public Builder clone() { + return super.clone(); } - - public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); } - - public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); } - - public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); } - - public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); } - - public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); } - - public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.binlog.protocol.DumpRequest) { + return mergeFrom((com.aliyun.polardbx.binlog.protocol.DumpRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.DumpRequest other) { + if (other == com.aliyun.polardbx.binlog.protocol.DumpRequest.getDefaultInstance()) return this; + if (!other.getTso().isEmpty()) { + tso_ = other.tso_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; } - public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); + @java.lang.Override + public final boolean isInitialized() { + return true; } - public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseDelimitedFrom( - java.io.InputStream input, + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + com.aliyun.polardbx.binlog.protocol.DumpRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.binlog.protocol.DumpRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; } - public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + private java.lang.Object tso_ = ""; + /** + * string tso = 1; + * @return The tso. + */ + public java.lang.String getTso() { + java.lang.Object ref = tso_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + tso_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - - public static com.aliyun.polardbx.binlog.protocol.DumpRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + /** + * string tso = 1; + * @return The bytes for tso. + */ + public com.google.protobuf.ByteString + getTsoBytes() { + java.lang.Object ref = tso_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + tso_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); + /** + * string tso = 1; + * @param value The tso to set. + * @return This builder for chaining. + */ + public Builder setTso( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + tso_ = value; + onChanged(); + return this; } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); + /** + * string tso = 1; + * @return This builder for chaining. + */ + public Builder clearTso() { + + tso_ = getDefaultInstance().getTso(); + onChanged(); + return this; } - - public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.DumpRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + /** + * string tso = 1; + * @param value The bytes for tso to set. + * @return This builder for chaining. + */ + public Builder setTsoBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + tso_ = value; + onChanged(); + return this; } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); } @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - /** - * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.DumpRequest} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.DumpRequest) - com.aliyun.polardbx.binlog.protocol.DumpRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_DumpRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_DumpRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.aliyun.polardbx.binlog.protocol.DumpRequest.class, - com.aliyun.polardbx.binlog.protocol.DumpRequest.Builder.class); - } - - // Construct using com.aliyun.polardbx.binlog.protocol.DumpRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - @java.lang.Override - public Builder clear() { - super.clear(); - tso_ = ""; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_DumpRequest_descriptor; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.DumpRequest getDefaultInstanceForType() { - return com.aliyun.polardbx.binlog.protocol.DumpRequest.getDefaultInstance(); - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.DumpRequest build() { - com.aliyun.polardbx.binlog.protocol.DumpRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.DumpRequest buildPartial() { - com.aliyun.polardbx.binlog.protocol.DumpRequest result = - new com.aliyun.polardbx.binlog.protocol.DumpRequest(this); - result.tso_ = tso_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.aliyun.polardbx.binlog.protocol.DumpRequest) { - return mergeFrom((com.aliyun.polardbx.binlog.protocol.DumpRequest) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.DumpRequest other) { - if (other == com.aliyun.polardbx.binlog.protocol.DumpRequest.getDefaultInstance()) { - return this; - } - if (!other.getTso().isEmpty()) { - tso_ = other.tso_; - onChanged(); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.aliyun.polardbx.binlog.protocol.DumpRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.aliyun.polardbx.binlog.protocol.DumpRequest) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object tso_ = ""; - - /** - * string tso = 1; - * - * @return The tso. - */ - public java.lang.String getTso() { - java.lang.Object ref = tso_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - tso_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * string tso = 1; - * - * @return The bytes for tso. - */ - public com.google.protobuf.ByteString - getTsoBytes() { - java.lang.Object ref = tso_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - tso_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string tso = 1; - * - * @param value The tso to set. - * @return This builder for chaining. - */ - public Builder setTso( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - tso_ = value; - onChanged(); - return this; - } - - /** - * string tso = 1; - * - * @return This builder for chaining. - */ - public Builder clearTso() { - - tso_ = getDefaultInstance().getTso(); - onChanged(); - return this; - } - /** - * string tso = 1; - * - * @param value The bytes for tso to set. - * @return This builder for chaining. - */ - public Builder setTsoBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - tso_ = value; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.DumpRequest) - } + // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.DumpRequest) + } - // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.DumpRequest) - private static final com.aliyun.polardbx.binlog.protocol.DumpRequest DEFAULT_INSTANCE; + // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.DumpRequest) + private static final com.aliyun.polardbx.binlog.protocol.DumpRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.DumpRequest(); + } - static { - DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.DumpRequest(); - } + public static com.aliyun.polardbx.binlog.protocol.DumpRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } - public static com.aliyun.polardbx.binlog.protocol.DumpRequest getDefaultInstance() { - return DEFAULT_INSTANCE; + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DumpRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DumpRequest(input, extensionRegistry); } + }; - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public DumpRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new DumpRequest(input, extensionRegistry); - } - }; + public static com.google.protobuf.Parser parser() { + return PARSER; + } - public static com.google.protobuf.Parser parser() { - return PARSER; - } + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.DumpRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.DumpRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/DumpRequestOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/DumpRequestOrBuilder.java index 1d3579d1..852d36f0 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/DumpRequestOrBuilder.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/DumpRequestOrBuilder.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -24,18 +7,15 @@ public interface DumpRequestOrBuilder extends // @@protoc_insertion_point(interface_extends:com.aliyun.polardbx.binlog.protocol.DumpRequest) com.google.protobuf.MessageOrBuilder { - /** - * string tso = 1; - * - * @return The tso. - */ - java.lang.String getTso(); - - /** - * string tso = 1; - * - * @return The bytes for tso. - */ - com.google.protobuf.ByteString - getTsoBytes(); + /** + * string tso = 1; + * @return The tso. + */ + java.lang.String getTso(); + /** + * string tso = 1; + * @return The bytes for tso. + */ + com.google.protobuf.ByteString + getTsoBytes(); } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/MessageType.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/MessageType.java index 5e879226..6802051d 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/MessageType.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/MessageType.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -25,191 +8,183 @@ */ public enum MessageType implements com.google.protobuf.ProtocolMessageEnum { - /** - *

-     * *
-     * Begin,Data,End未拆分,一个完整的消息体
-     * 
- * - * WHOLE = 0; - */ - WHOLE(0), - /** - *
-     * *
-     * Message开始标识
-     * 
- * - * BEGIN = 1; - */ - BEGIN(1), - /** - *
-     * *
-     * Message包含的数据
-     * 
- * - * DATA = 2; - */ - DATA(2), - /** - *
-     * *
-     * Message结束标识
-     * 
- * - * END = 3; - */ - END(3), - /** - *
-     * *
-     * 一个独立的消息标记,当没有TxnItem需要传递时,使用该类型
-     * 
- * - * TAG = 4; - */ - TAG(4), - UNRECOGNIZED(-1), - ; - - /** - *
-     * *
-     * Begin,Data,End未拆分,一个完整的消息体
-     * 
- * - * WHOLE = 0; - */ - public static final int WHOLE_VALUE = 0; - /** - *
-     * *
-     * Message开始标识
-     * 
- * - * BEGIN = 1; - */ - public static final int BEGIN_VALUE = 1; - /** - *
-     * *
-     * Message包含的数据
-     * 
- * - * DATA = 2; - */ - public static final int DATA_VALUE = 2; - /** - *
-     * *
-     * Message结束标识
-     * 
- * - * END = 3; - */ - public static final int END_VALUE = 3; - /** - *
-     * *
-     * 一个独立的消息标记,当没有TxnItem需要传递时,使用该类型
-     * 
- * - * TAG = 4; - */ - public static final int TAG_VALUE = 4; - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static MessageType valueOf(int value) { - return forNumber(value); - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static MessageType forNumber(int value) { - switch (value) { - case 0: - return WHOLE; - case 1: - return BEGIN; - case 2: - return DATA; - case 3: - return END; - case 4: - return TAG; - default: - return null; - } + /** + *
+   **
+   *Begin,Data,End未拆分,一个完整的消息体
+   * 
+ * + * WHOLE = 0; + */ + WHOLE(0), + /** + *
+   **
+   *Message开始标识
+   * 
+ * + * BEGIN = 1; + */ + BEGIN(1), + /** + *
+   **
+   *Message包含的数据
+   * 
+ * + * DATA = 2; + */ + DATA(2), + /** + *
+   **
+   *Message结束标识
+   * 
+ * + * END = 3; + */ + END(3), + /** + *
+   **
+   *一个独立的消息标记,当没有TxnItem需要传递时,使用该类型
+   * 
+ * + * TAG = 4; + */ + TAG(4), + UNRECOGNIZED(-1), + ; + + /** + *
+   **
+   *Begin,Data,End未拆分,一个完整的消息体
+   * 
+ * + * WHOLE = 0; + */ + public static final int WHOLE_VALUE = 0; + /** + *
+   **
+   *Message开始标识
+   * 
+ * + * BEGIN = 1; + */ + public static final int BEGIN_VALUE = 1; + /** + *
+   **
+   *Message包含的数据
+   * 
+ * + * DATA = 2; + */ + public static final int DATA_VALUE = 2; + /** + *
+   **
+   *Message结束标识
+   * 
+ * + * END = 3; + */ + public static final int END_VALUE = 3; + /** + *
+   **
+   *一个独立的消息标记,当没有TxnItem需要传递时,使用该类型
+   * 
+ * + * TAG = 4; + */ + public static final int TAG_VALUE = 4; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static MessageType valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static MessageType forNumber(int value) { + switch (value) { + case 0: return WHOLE; + case 1: return BEGIN; + case 2: return DATA; + case 3: return END; + case 4: return TAG; + default: return null; } - - private static final com.google.protobuf.Internal.EnumLiteMap< - MessageType> internalValueMap = + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + MessageType> internalValueMap = new com.google.protobuf.Internal.EnumLiteMap() { - public MessageType findValueByNumber(int number) { - return MessageType.forNumber(number); - } + public MessageType findValueByNumber(int number) { + return MessageType.forNumber(number); + } }; - public final com.google.protobuf.Descriptors.EnumValueDescriptor - getValueDescriptor() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalStateException( - "Can't get the descriptor of an unrecognized enum value."); - } - return getDescriptor().getValues().get(ordinal()); - } - - public final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptorForType() { - return getDescriptor(); + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); } - - public static final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.getDescriptor().getEnumTypes().get(0); + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.getDescriptor().getEnumTypes().get(0); + } + + private static final MessageType[] VALUES = values(); + + public static MessageType valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); } - - private static final MessageType[] VALUES = values(); - - public static MessageType valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException( - "EnumValueDescriptor is not for this type."); - } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; - } - return VALUES[desc.getIndex()]; + if (desc.getIndex() == -1) { + return UNRECOGNIZED; } + return VALUES[desc.getIndex()]; + } - private final int value; + private final int value; - private MessageType(int value) { - this.value = value; - } + private MessageType(int value) { + this.value = value; + } - // @@protoc_insertion_point(enum_scope:com.aliyun.polardbx.binlog.protocol.MessageType) + // @@protoc_insertion_point(enum_scope:com.aliyun.polardbx.binlog.protocol.MessageType) } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnBegin.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnBegin.java index 08329d87..4c2a822c 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnBegin.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnBegin.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -27,1007 +10,907 @@ public final class TxnBegin extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:com.aliyun.polardbx.binlog.protocol.TxnBegin) TxnBeginOrBuilder { - private static final long serialVersionUID = 0L; +private static final long serialVersionUID = 0L; + // Use TxnBegin.newBuilder() to construct. + private TxnBegin(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TxnBegin() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new TxnBegin(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TxnBegin( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + com.aliyun.polardbx.binlog.protocol.TxnToken.Builder subBuilder = null; + if (tokenOneofCase_ == 1) { + subBuilder = ((com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_).toBuilder(); + } + tokenOneof_ = + input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnToken.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_); + tokenOneof_ = subBuilder.buildPartial(); + } + tokenOneofCase_ = 1; + break; + } + case 18: { + com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder subBuilder = null; + if (tokenOneofCase_ == 2) { + subBuilder = ((com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_).toBuilder(); + } + tokenOneof_ = + input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnMergedToken.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_); + tokenOneof_ = subBuilder.buildPartial(); + } + tokenOneofCase_ = 2; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnBegin_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnBegin_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.binlog.protocol.TxnBegin.class, com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder.class); + } + + private int tokenOneofCase_ = 0; + private java.lang.Object tokenOneof_; + public enum TokenOneofCase + implements com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + TXNTOKEN(1), + TXNMERGEDTOKEN(2), + TOKENONEOF_NOT_SET(0); + private final int value; + private TokenOneofCase(int value) { + this.value = value; + } + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static TokenOneofCase valueOf(int value) { + return forNumber(value); + } + + public static TokenOneofCase forNumber(int value) { + switch (value) { + case 1: return TXNTOKEN; + case 2: return TXNMERGEDTOKEN; + case 0: return TOKENONEOF_NOT_SET; + default: return null; + } + } + public int getNumber() { + return this.value; + } + }; + + public TokenOneofCase + getTokenOneofCase() { + return TokenOneofCase.forNumber( + tokenOneofCase_); + } + + public static final int TXNTOKEN_FIELD_NUMBER = 1; + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + * @return Whether the txnToken field is set. + */ + @java.lang.Override + public boolean hasTxnToken() { + return tokenOneofCase_ == 1; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + * @return The txnToken. + */ + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnToken getTxnToken() { + if (tokenOneofCase_ == 1) { + return (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_; + } + return com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + */ + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder getTxnTokenOrBuilder() { + if (tokenOneofCase_ == 1) { + return (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_; + } + return com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); + } + + public static final int TXNMERGEDTOKEN_FIELD_NUMBER = 2; + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + * @return Whether the txnMergedToken field is set. + */ + @java.lang.Override + public boolean hasTxnMergedToken() { + return tokenOneofCase_ == 2; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + * @return The txnMergedToken. + */ + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnMergedToken getTxnMergedToken() { + if (tokenOneofCase_ == 2) { + return (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_; + } + return com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + */ + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder getTxnMergedTokenOrBuilder() { + if (tokenOneofCase_ == 2) { + return (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_; + } + return com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (tokenOneofCase_ == 1) { + output.writeMessage(1, (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_); + } + if (tokenOneofCase_ == 2) { + output.writeMessage(2, (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (tokenOneofCase_ == 1) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_); + } + if (tokenOneofCase_ == 2) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.TxnBegin)) { + return super.equals(obj); + } + com.aliyun.polardbx.binlog.protocol.TxnBegin other = (com.aliyun.polardbx.binlog.protocol.TxnBegin) obj; + + if (!getTokenOneofCase().equals(other.getTokenOneofCase())) return false; + switch (tokenOneofCase_) { + case 1: + if (!getTxnToken() + .equals(other.getTxnToken())) return false; + break; + case 2: + if (!getTxnMergedToken() + .equals(other.getTxnMergedToken())) return false; + break; + case 0: + default: + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + switch (tokenOneofCase_) { + case 1: + hash = (37 * hash) + TXNTOKEN_FIELD_NUMBER; + hash = (53 * hash) + getTxnToken().hashCode(); + break; + case 2: + hash = (37 * hash) + TXNMERGEDTOKEN_FIELD_NUMBER; + hash = (53 * hash) + getTxnMergedToken().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.TxnBegin prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnBegin} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.TxnBegin) + com.aliyun.polardbx.binlog.protocol.TxnBeginOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnBegin_descriptor; + } - // Use TxnBegin.newBuilder() to construct. - private TxnBegin(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnBegin_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.binlog.protocol.TxnBegin.class, com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder.class); } - private TxnBegin() { + // Construct using com.aliyun.polardbx.binlog.protocol.TxnBegin.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); } + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new TxnBegin(); + public Builder clear() { + super.clear(); + tokenOneofCase_ = 0; + tokenOneof_ = null; + return this; } @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnBegin_descriptor; } - private TxnBegin( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - 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; - case 10: { - com.aliyun.polardbx.binlog.protocol.TxnToken.Builder subBuilder = null; - if (tokenOneofCase_ == 1) { - subBuilder = ((com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_).toBuilder(); - } - tokenOneof_ = - input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnToken.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_); - tokenOneof_ = subBuilder.buildPartial(); - } - tokenOneofCase_ = 1; - break; - } - case 18: { - com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder subBuilder = null; - if (tokenOneofCase_ == 2) { - subBuilder = ((com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_).toBuilder(); - } - tokenOneof_ = - input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnMergedToken.parser(), - extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_); - tokenOneof_ = subBuilder.buildPartial(); - } - tokenOneofCase_ = 2; - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnBegin getDefaultInstanceForType() { + return com.aliyun.polardbx.binlog.protocol.TxnBegin.getDefaultInstance(); } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnBegin_descriptor; + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnBegin build() { + com.aliyun.polardbx.binlog.protocol.TxnBegin result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnBegin_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.aliyun.polardbx.binlog.protocol.TxnBegin.class, - com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder.class); + public com.aliyun.polardbx.binlog.protocol.TxnBegin buildPartial() { + com.aliyun.polardbx.binlog.protocol.TxnBegin result = new com.aliyun.polardbx.binlog.protocol.TxnBegin(this); + if (tokenOneofCase_ == 1) { + if (txnTokenBuilder_ == null) { + result.tokenOneof_ = tokenOneof_; + } else { + result.tokenOneof_ = txnTokenBuilder_.build(); + } + } + if (tokenOneofCase_ == 2) { + if (txnMergedTokenBuilder_ == null) { + result.tokenOneof_ = tokenOneof_; + } else { + result.tokenOneof_ = txnMergedTokenBuilder_.build(); + } + } + result.tokenOneofCase_ = tokenOneofCase_; + onBuilt(); + return result; } - private int tokenOneofCase_ = 0; - private java.lang.Object tokenOneof_; - - public enum TokenOneofCase - implements com.google.protobuf.Internal.EnumLite, - com.google.protobuf.AbstractMessage.InternalOneOfEnum { - TXNTOKEN(1), - TXNMERGEDTOKEN(2), - TOKENONEOF_NOT_SET(0); - private final int value; - - private TokenOneofCase(int value) { - this.value = value; - } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.binlog.protocol.TxnBegin) { + return mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnBegin)other); + } else { + super.mergeFrom(other); + return this; + } + } - /** - * @param value The number of the enum to look for. - * @return The enum associated with the given number. - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static TokenOneofCase valueOf(int value) { - return forNumber(value); + public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.TxnBegin other) { + if (other == com.aliyun.polardbx.binlog.protocol.TxnBegin.getDefaultInstance()) return this; + switch (other.getTokenOneofCase()) { + case TXNTOKEN: { + mergeTxnToken(other.getTxnToken()); + break; } - - public static TokenOneofCase forNumber(int value) { - switch (value) { - case 1: - return TXNTOKEN; - case 2: - return TXNMERGEDTOKEN; - case 0: - return TOKENONEOF_NOT_SET; - default: - return null; - } + case TXNMERGEDTOKEN: { + mergeTxnMergedToken(other.getTxnMergedToken()); + break; } - - public int getNumber() { - return this.value; + case TOKENONEOF_NOT_SET: { + break; } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; } - ; + @java.lang.Override + public final boolean isInitialized() { + return true; + } + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.aliyun.polardbx.binlog.protocol.TxnBegin parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.binlog.protocol.TxnBegin) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int tokenOneofCase_ = 0; + private java.lang.Object tokenOneof_; public TokenOneofCase - getTokenOneofCase() { - return TokenOneofCase.forNumber( - tokenOneofCase_); + getTokenOneofCase() { + return TokenOneofCase.forNumber( + tokenOneofCase_); + } + + public Builder clearTokenOneof() { + tokenOneofCase_ = 0; + tokenOneof_ = null; + onChanged(); + return this; } - public static final int TXNTOKEN_FIELD_NUMBER = 1; + private com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnToken, com.aliyun.polardbx.binlog.protocol.TxnToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder> txnTokenBuilder_; /** * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - * * @return Whether the txnToken field is set. */ @java.lang.Override public boolean hasTxnToken() { - return tokenOneofCase_ == 1; + return tokenOneofCase_ == 1; } - /** * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - * * @return The txnToken. */ @java.lang.Override public com.aliyun.polardbx.binlog.protocol.TxnToken getTxnToken() { + if (txnTokenBuilder_ == null) { + if (tokenOneofCase_ == 1) { + return (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_; + } + return com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); + } else { if (tokenOneofCase_ == 1) { - return (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_; + return txnTokenBuilder_.getMessage(); } return com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); + } + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + */ + public Builder setTxnToken(com.aliyun.polardbx.binlog.protocol.TxnToken value) { + if (txnTokenBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + tokenOneof_ = value; + onChanged(); + } else { + txnTokenBuilder_.setMessage(value); + } + tokenOneofCase_ = 1; + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + */ + public Builder setTxnToken( + com.aliyun.polardbx.binlog.protocol.TxnToken.Builder builderForValue) { + if (txnTokenBuilder_ == null) { + tokenOneof_ = builderForValue.build(); + onChanged(); + } else { + txnTokenBuilder_.setMessage(builderForValue.build()); + } + tokenOneofCase_ = 1; + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + */ + public Builder mergeTxnToken(com.aliyun.polardbx.binlog.protocol.TxnToken value) { + if (txnTokenBuilder_ == null) { + if (tokenOneofCase_ == 1 && + tokenOneof_ != com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance()) { + tokenOneof_ = com.aliyun.polardbx.binlog.protocol.TxnToken.newBuilder((com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_) + .mergeFrom(value).buildPartial(); + } else { + tokenOneof_ = value; + } + onChanged(); + } else { + if (tokenOneofCase_ == 1) { + txnTokenBuilder_.mergeFrom(value); + } + txnTokenBuilder_.setMessage(value); + } + tokenOneofCase_ = 1; + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + */ + public Builder clearTxnToken() { + if (txnTokenBuilder_ == null) { + if (tokenOneofCase_ == 1) { + tokenOneofCase_ = 0; + tokenOneof_ = null; + onChanged(); + } + } else { + if (tokenOneofCase_ == 1) { + tokenOneofCase_ = 0; + tokenOneof_ = null; + } + txnTokenBuilder_.clear(); + } + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + */ + public com.aliyun.polardbx.binlog.protocol.TxnToken.Builder getTxnTokenBuilder() { + return getTxnTokenFieldBuilder().getBuilder(); } - /** * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; */ @java.lang.Override public com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder getTxnTokenOrBuilder() { + if ((tokenOneofCase_ == 1) && (txnTokenBuilder_ != null)) { + return txnTokenBuilder_.getMessageOrBuilder(); + } else { if (tokenOneofCase_ == 1) { - return (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_; + return (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_; } return com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); + } } - - public static final int TXNMERGEDTOKEN_FIELD_NUMBER = 2; - + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnToken, com.aliyun.polardbx.binlog.protocol.TxnToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder> + getTxnTokenFieldBuilder() { + if (txnTokenBuilder_ == null) { + if (!(tokenOneofCase_ == 1)) { + tokenOneof_ = com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); + } + txnTokenBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnToken, com.aliyun.polardbx.binlog.protocol.TxnToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder>( + (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_, + getParentForChildren(), + isClean()); + tokenOneof_ = null; + } + tokenOneofCase_ = 1; + onChanged();; + return txnTokenBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnMergedToken, com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder> txnMergedTokenBuilder_; /** * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - * * @return Whether the txnMergedToken field is set. */ @java.lang.Override public boolean hasTxnMergedToken() { - return tokenOneofCase_ == 2; + return tokenOneofCase_ == 2; } - /** * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - * * @return The txnMergedToken. */ @java.lang.Override public com.aliyun.polardbx.binlog.protocol.TxnMergedToken getTxnMergedToken() { + if (txnMergedTokenBuilder_ == null) { + if (tokenOneofCase_ == 2) { + return (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_; + } + return com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); + } else { if (tokenOneofCase_ == 2) { - return (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_; + return txnMergedTokenBuilder_.getMessage(); } return com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); + } } - /** * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; */ - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder getTxnMergedTokenOrBuilder() { - if (tokenOneofCase_ == 2) { - return (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_; - } - return com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); + public Builder setTxnMergedToken(com.aliyun.polardbx.binlog.protocol.TxnMergedToken value) { + if (txnMergedTokenBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + tokenOneof_ = value; + onChanged(); + } else { + txnMergedTokenBuilder_.setMessage(value); + } + tokenOneofCase_ = 2; + return this; } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } - - memoizedIsInitialized = 1; - return true; + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + */ + public Builder setTxnMergedToken( + com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder builderForValue) { + if (txnMergedTokenBuilder_ == null) { + tokenOneof_ = builderForValue.build(); + onChanged(); + } else { + txnMergedTokenBuilder_.setMessage(builderForValue.build()); + } + tokenOneofCase_ = 2; + return this; } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (tokenOneofCase_ == 1) { - output.writeMessage(1, (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_); - } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + */ + public Builder mergeTxnMergedToken(com.aliyun.polardbx.binlog.protocol.TxnMergedToken value) { + if (txnMergedTokenBuilder_ == null) { + if (tokenOneofCase_ == 2 && + tokenOneof_ != com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance()) { + tokenOneof_ = com.aliyun.polardbx.binlog.protocol.TxnMergedToken.newBuilder((com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_) + .mergeFrom(value).buildPartial(); + } else { + tokenOneof_ = value; + } + onChanged(); + } else { if (tokenOneofCase_ == 2) { - output.writeMessage(2, (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_); + txnMergedTokenBuilder_.mergeFrom(value); } - unknownFields.writeTo(output); + txnMergedTokenBuilder_.setMessage(value); + } + tokenOneofCase_ = 2; + return this; } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) { - return size; - } - - size = 0; - if (tokenOneofCase_ == 1) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + */ + public Builder clearTxnMergedToken() { + if (txnMergedTokenBuilder_ == null) { + if (tokenOneofCase_ == 2) { + tokenOneofCase_ = 0; + tokenOneof_ = null; + onChanged(); } + } else { if (tokenOneofCase_ == 2) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(2, (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_); + tokenOneofCase_ = 0; + tokenOneof_ = null; } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; + txnMergedTokenBuilder_.clear(); + } + return this; } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.TxnBegin)) { - return super.equals(obj); - } - com.aliyun.polardbx.binlog.protocol.TxnBegin other = (com.aliyun.polardbx.binlog.protocol.TxnBegin) obj; - - if (!getTokenOneofCase().equals(other.getTokenOneofCase())) { - return false; - } - switch (tokenOneofCase_) { - case 1: - if (!getTxnToken() - .equals(other.getTxnToken())) { - return false; - } - break; - case 2: - if (!getTxnMergedToken() - .equals(other.getTxnMergedToken())) { - return false; - } - break; - case 0: - default: - } - if (!unknownFields.equals(other.unknownFields)) { - return false; - } - return true; + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + */ + public com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder getTxnMergedTokenBuilder() { + return getTxnMergedTokenFieldBuilder().getBuilder(); } - + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + */ @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - switch (tokenOneofCase_) { - case 1: - hash = (37 * hash) + TXNTOKEN_FIELD_NUMBER; - hash = (53 * hash) + getTxnToken().hashCode(); - break; - case 2: - hash = (37 * hash) + TXNMERGEDTOKEN_FIELD_NUMBER; - hash = (53 * hash) + getTxnMergedToken().hashCode(); - break; - case 0: - default: + public com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder getTxnMergedTokenOrBuilder() { + if ((tokenOneofCase_ == 2) && (txnMergedTokenBuilder_ != null)) { + return txnMergedTokenBuilder_.getMessageOrBuilder(); + } else { + if (tokenOneofCase_ == 2) { + return (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_; } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + return com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); + } } - - public static com.aliyun.polardbx.binlog.protocol.TxnBegin parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnMergedToken, com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder> + getTxnMergedTokenFieldBuilder() { + if (txnMergedTokenBuilder_ == null) { + if (!(tokenOneofCase_ == 2)) { + tokenOneof_ = com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); + } + txnMergedTokenBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnMergedToken, com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder>( + (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_, + getParentForChildren(), + isClean()); + tokenOneof_ = null; + } + tokenOneofCase_ = 2; + onChanged();; + return txnMergedTokenBuilder_; } - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.TxnBegin prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); } @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnBegin} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.TxnBegin) - com.aliyun.polardbx.binlog.protocol.TxnBeginOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnBegin_descriptor; - } + // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.TxnBegin) + } - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnBegin_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.aliyun.polardbx.binlog.protocol.TxnBegin.class, - com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder.class); - } + // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.TxnBegin) + private static final com.aliyun.polardbx.binlog.protocol.TxnBegin DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.TxnBegin(); + } - // Construct using com.aliyun.polardbx.binlog.protocol.TxnBegin.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - @java.lang.Override - public Builder clear() { - super.clear(); - tokenOneofCase_ = 0; - tokenOneof_ = null; - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnBegin_descriptor; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnBegin getDefaultInstanceForType() { - return com.aliyun.polardbx.binlog.protocol.TxnBegin.getDefaultInstance(); - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnBegin build() { - com.aliyun.polardbx.binlog.protocol.TxnBegin result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnBegin buildPartial() { - com.aliyun.polardbx.binlog.protocol.TxnBegin result = - new com.aliyun.polardbx.binlog.protocol.TxnBegin(this); - if (tokenOneofCase_ == 1) { - if (txnTokenBuilder_ == null) { - result.tokenOneof_ = tokenOneof_; - } else { - result.tokenOneof_ = txnTokenBuilder_.build(); - } - } - if (tokenOneofCase_ == 2) { - if (txnMergedTokenBuilder_ == null) { - result.tokenOneof_ = tokenOneof_; - } else { - result.tokenOneof_ = txnMergedTokenBuilder_.build(); - } - } - result.tokenOneofCase_ = tokenOneofCase_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.aliyun.polardbx.binlog.protocol.TxnBegin) { - return mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnBegin) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.TxnBegin other) { - if (other == com.aliyun.polardbx.binlog.protocol.TxnBegin.getDefaultInstance()) { - return this; - } - switch (other.getTokenOneofCase()) { - case TXNTOKEN: { - mergeTxnToken(other.getTxnToken()); - break; - } - case TXNMERGEDTOKEN: { - mergeTxnMergedToken(other.getTxnMergedToken()); - break; - } - case TOKENONEOF_NOT_SET: { - break; - } - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } + public static com.aliyun.polardbx.binlog.protocol.TxnBegin getDefaultInstance() { + return DEFAULT_INSTANCE; + } - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.aliyun.polardbx.binlog.protocol.TxnBegin parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.aliyun.polardbx.binlog.protocol.TxnBegin) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private int tokenOneofCase_ = 0; - private java.lang.Object tokenOneof_; - - public TokenOneofCase - getTokenOneofCase() { - return TokenOneofCase.forNumber( - tokenOneofCase_); - } - - public Builder clearTokenOneof() { - tokenOneofCase_ = 0; - tokenOneof_ = null; - onChanged(); - return this; - } - - private com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnToken, com.aliyun.polardbx.binlog.protocol.TxnToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder> - txnTokenBuilder_; - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - * - * @return Whether the txnToken field is set. - */ - @java.lang.Override - public boolean hasTxnToken() { - return tokenOneofCase_ == 1; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - * - * @return The txnToken. - */ - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnToken getTxnToken() { - if (txnTokenBuilder_ == null) { - if (tokenOneofCase_ == 1) { - return (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_; - } - return com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); - } else { - if (tokenOneofCase_ == 1) { - return txnTokenBuilder_.getMessage(); - } - return com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); - } - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - */ - public Builder setTxnToken(com.aliyun.polardbx.binlog.protocol.TxnToken value) { - if (txnTokenBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - tokenOneof_ = value; - onChanged(); - } else { - txnTokenBuilder_.setMessage(value); - } - tokenOneofCase_ = 1; - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - */ - public Builder setTxnToken( - com.aliyun.polardbx.binlog.protocol.TxnToken.Builder builderForValue) { - if (txnTokenBuilder_ == null) { - tokenOneof_ = builderForValue.build(); - onChanged(); - } else { - txnTokenBuilder_.setMessage(builderForValue.build()); - } - tokenOneofCase_ = 1; - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - */ - public Builder mergeTxnToken(com.aliyun.polardbx.binlog.protocol.TxnToken value) { - if (txnTokenBuilder_ == null) { - if (tokenOneofCase_ == 1 && - tokenOneof_ != com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance()) { - tokenOneof_ = com.aliyun.polardbx.binlog.protocol.TxnToken - .newBuilder((com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_) - .mergeFrom(value).buildPartial(); - } else { - tokenOneof_ = value; - } - onChanged(); - } else { - if (tokenOneofCase_ == 1) { - txnTokenBuilder_.mergeFrom(value); - } - txnTokenBuilder_.setMessage(value); - } - tokenOneofCase_ = 1; - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - */ - public Builder clearTxnToken() { - if (txnTokenBuilder_ == null) { - if (tokenOneofCase_ == 1) { - tokenOneofCase_ = 0; - tokenOneof_ = null; - onChanged(); - } - } else { - if (tokenOneofCase_ == 1) { - tokenOneofCase_ = 0; - tokenOneof_ = null; - } - txnTokenBuilder_.clear(); - } - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - */ - public com.aliyun.polardbx.binlog.protocol.TxnToken.Builder getTxnTokenBuilder() { - return getTxnTokenFieldBuilder().getBuilder(); - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - */ - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder getTxnTokenOrBuilder() { - if ((tokenOneofCase_ == 1) && (txnTokenBuilder_ != null)) { - return txnTokenBuilder_.getMessageOrBuilder(); - } else { - if (tokenOneofCase_ == 1) { - return (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_; - } - return com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); - } - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnToken, com.aliyun.polardbx.binlog.protocol.TxnToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder> - getTxnTokenFieldBuilder() { - if (txnTokenBuilder_ == null) { - if (!(tokenOneofCase_ == 1)) { - tokenOneof_ = com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); - } - txnTokenBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnToken, com.aliyun.polardbx.binlog.protocol.TxnToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder>( - (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_, - getParentForChildren(), - isClean()); - tokenOneof_ = null; - } - tokenOneofCase_ = 1; - onChanged(); - ; - return txnTokenBuilder_; - } - - private com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnMergedToken, com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder> - txnMergedTokenBuilder_; - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - * - * @return Whether the txnMergedToken field is set. - */ - @java.lang.Override - public boolean hasTxnMergedToken() { - return tokenOneofCase_ == 2; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - * - * @return The txnMergedToken. - */ - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnMergedToken getTxnMergedToken() { - if (txnMergedTokenBuilder_ == null) { - if (tokenOneofCase_ == 2) { - return (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_; - } - return com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); - } else { - if (tokenOneofCase_ == 2) { - return txnMergedTokenBuilder_.getMessage(); - } - return com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); - } - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - */ - public Builder setTxnMergedToken(com.aliyun.polardbx.binlog.protocol.TxnMergedToken value) { - if (txnMergedTokenBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - tokenOneof_ = value; - onChanged(); - } else { - txnMergedTokenBuilder_.setMessage(value); - } - tokenOneofCase_ = 2; - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - */ - public Builder setTxnMergedToken( - com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder builderForValue) { - if (txnMergedTokenBuilder_ == null) { - tokenOneof_ = builderForValue.build(); - onChanged(); - } else { - txnMergedTokenBuilder_.setMessage(builderForValue.build()); - } - tokenOneofCase_ = 2; - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - */ - public Builder mergeTxnMergedToken(com.aliyun.polardbx.binlog.protocol.TxnMergedToken value) { - if (txnMergedTokenBuilder_ == null) { - if (tokenOneofCase_ == 2 && - tokenOneof_ != com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance()) { - tokenOneof_ = com.aliyun.polardbx.binlog.protocol.TxnMergedToken - .newBuilder((com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_) - .mergeFrom(value).buildPartial(); - } else { - tokenOneof_ = value; - } - onChanged(); - } else { - if (tokenOneofCase_ == 2) { - txnMergedTokenBuilder_.mergeFrom(value); - } - txnMergedTokenBuilder_.setMessage(value); - } - tokenOneofCase_ = 2; - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - */ - public Builder clearTxnMergedToken() { - if (txnMergedTokenBuilder_ == null) { - if (tokenOneofCase_ == 2) { - tokenOneofCase_ = 0; - tokenOneof_ = null; - onChanged(); - } - } else { - if (tokenOneofCase_ == 2) { - tokenOneofCase_ = 0; - tokenOneof_ = null; - } - txnMergedTokenBuilder_.clear(); - } - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - */ - public com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder getTxnMergedTokenBuilder() { - return getTxnMergedTokenFieldBuilder().getBuilder(); - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - */ - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder getTxnMergedTokenOrBuilder() { - if ((tokenOneofCase_ == 2) && (txnMergedTokenBuilder_ != null)) { - return txnMergedTokenBuilder_.getMessageOrBuilder(); - } else { - if (tokenOneofCase_ == 2) { - return (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_; - } - return com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); - } - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnMergedToken, com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder> - getTxnMergedTokenFieldBuilder() { - if (txnMergedTokenBuilder_ == null) { - if (!(tokenOneofCase_ == 2)) { - tokenOneof_ = com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); - } - txnMergedTokenBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnMergedToken, com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder>( - (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_, - getParentForChildren(), - isClean()); - tokenOneof_ = null; - } - tokenOneofCase_ = 2; - onChanged(); - ; - return txnMergedTokenBuilder_; - } - - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.TxnBegin) - } - - // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.TxnBegin) - private static final com.aliyun.polardbx.binlog.protocol.TxnBegin DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.TxnBegin(); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnBegin getDefaultInstance() { - return DEFAULT_INSTANCE; + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public TxnBegin parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TxnBegin(input, extensionRegistry); } + }; - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public TxnBegin parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new TxnBegin(input, extensionRegistry); - } - }; + public static com.google.protobuf.Parser parser() { + return PARSER; + } - public static com.google.protobuf.Parser parser() { - return PARSER; - } + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnBegin getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnBegin getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnBeginOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnBeginOrBuilder.java index 0f38961b..efd8a20c 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnBeginOrBuilder.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnBeginOrBuilder.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -24,43 +7,35 @@ public interface TxnBeginOrBuilder extends // @@protoc_insertion_point(interface_extends:com.aliyun.polardbx.binlog.protocol.TxnBegin) com.google.protobuf.MessageOrBuilder { - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - * - * @return Whether the txnToken field is set. - */ - boolean hasTxnToken(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - * - * @return The txnToken. - */ - com.aliyun.polardbx.binlog.protocol.TxnToken getTxnToken(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - */ - com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder getTxnTokenOrBuilder(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - * - * @return Whether the txnMergedToken field is set. - */ - boolean hasTxnMergedToken(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - * - * @return The txnMergedToken. - */ - com.aliyun.polardbx.binlog.protocol.TxnMergedToken getTxnMergedToken(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - */ - com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder getTxnMergedTokenOrBuilder(); - - public com.aliyun.polardbx.binlog.protocol.TxnBegin.TokenOneofCase getTokenOneofCase(); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + * @return Whether the txnToken field is set. + */ + boolean hasTxnToken(); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + * @return The txnToken. + */ + com.aliyun.polardbx.binlog.protocol.TxnToken getTxnToken(); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + */ + com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder getTxnTokenOrBuilder(); + + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + * @return Whether the txnMergedToken field is set. + */ + boolean hasTxnMergedToken(); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + * @return The txnMergedToken. + */ + com.aliyun.polardbx.binlog.protocol.TxnMergedToken getTxnMergedToken(); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + */ + com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder getTxnMergedTokenOrBuilder(); + + public com.aliyun.polardbx.binlog.protocol.TxnBegin.TokenOneofCase getTokenOneofCase(); } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnData.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnData.java index 14499f0e..35b2b1a9 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnData.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnData.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -27,833 +10,761 @@ public final class TxnData extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:com.aliyun.polardbx.binlog.protocol.TxnData) TxnDataOrBuilder { - private static final long serialVersionUID = 0L; - - // Use TxnData.newBuilder() to construct. - private TxnData(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); +private static final long serialVersionUID = 0L; + // Use TxnData.newBuilder() to construct. + private TxnData(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TxnData() { + txnItems_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new TxnData(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TxnData( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + txnItems_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + txnItems_.add( + input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnItem.parser(), extensionRegistry)); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + txnItems_ = java.util.Collections.unmodifiableList(txnItems_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnData_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnData_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.binlog.protocol.TxnData.class, com.aliyun.polardbx.binlog.protocol.TxnData.Builder.class); + } + + public static final int TXNITEMS_FIELD_NUMBER = 1; + private java.util.List txnItems_; + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + @java.lang.Override + public java.util.List getTxnItemsList() { + return txnItems_; + } + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + @java.lang.Override + public java.util.List + getTxnItemsOrBuilderList() { + return txnItems_; + } + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + @java.lang.Override + public int getTxnItemsCount() { + return txnItems_.size(); + } + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnItem getTxnItems(int index) { + return txnItems_.get(index); + } + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnItemOrBuilder getTxnItemsOrBuilder( + int index) { + return txnItems_.get(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < txnItems_.size(); i++) { + output.writeMessage(1, txnItems_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < txnItems_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, txnItems_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.TxnData)) { + return super.equals(obj); + } + com.aliyun.polardbx.binlog.protocol.TxnData other = (com.aliyun.polardbx.binlog.protocol.TxnData) obj; + + if (!getTxnItemsList() + .equals(other.getTxnItemsList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getTxnItemsCount() > 0) { + hash = (37 * hash) + TXNITEMS_FIELD_NUMBER; + hash = (53 * hash) + getTxnItemsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.binlog.protocol.TxnData parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnData parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnData parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnData parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnData parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnData parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnData parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnData parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnData parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnData parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnData parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnData parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.TxnData prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnData} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.TxnData) + com.aliyun.polardbx.binlog.protocol.TxnDataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnData_descriptor; } - private TxnData() { - txnItems_ = java.util.Collections.emptyList(); + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnData_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.binlog.protocol.TxnData.class, com.aliyun.polardbx.binlog.protocol.TxnData.Builder.class); } - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new TxnData(); + // Construct using com.aliyun.polardbx.binlog.protocol.TxnData.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); } + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getTxnItemsFieldBuilder(); + } + } @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; + public Builder clear() { + super.clear(); + if (txnItemsBuilder_ == null) { + txnItems_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + txnItemsBuilder_.clear(); + } + return this; } - private TxnData( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - 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; - case 10: { - if (!((mutable_bitField0_ & 0x00000001) != 0)) { - txnItems_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000001; - } - txnItems_.add( - input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnItem.parser(), extensionRegistry)); - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000001) != 0)) { - txnItems_ = java.util.Collections.unmodifiableList(txnItems_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnData_descriptor; } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnData_descriptor; + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnData getDefaultInstanceForType() { + return com.aliyun.polardbx.binlog.protocol.TxnData.getDefaultInstance(); } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnData_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.aliyun.polardbx.binlog.protocol.TxnData.class, - com.aliyun.polardbx.binlog.protocol.TxnData.Builder.class); + public com.aliyun.polardbx.binlog.protocol.TxnData build() { + com.aliyun.polardbx.binlog.protocol.TxnData result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; } - public static final int TXNITEMS_FIELD_NUMBER = 1; - private java.util.List txnItems_; - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ @java.lang.Override - public java.util.List getTxnItemsList() { - return txnItems_; + public com.aliyun.polardbx.binlog.protocol.TxnData buildPartial() { + com.aliyun.polardbx.binlog.protocol.TxnData result = new com.aliyun.polardbx.binlog.protocol.TxnData(this); + int from_bitField0_ = bitField0_; + if (txnItemsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + txnItems_ = java.util.Collections.unmodifiableList(txnItems_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.txnItems_ = txnItems_; + } else { + result.txnItems_ = txnItemsBuilder_.build(); + } + onBuilt(); + return result; } - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ @java.lang.Override - public java.util.List - getTxnItemsOrBuilderList() { - return txnItems_; + public Builder clone() { + return super.clone(); } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ @java.lang.Override - public int getTxnItemsCount() { - return txnItems_.size(); + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnItem getTxnItems(int index) { - return txnItems_.get(index); + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnItemOrBuilder getTxnItemsOrBuilder( - int index) { - return txnItems_.get(index); + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); } - - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } - - memoizedIsInitialized = 1; - return true; + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); } - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - for (int i = 0; i < txnItems_.size(); i++) { - output.writeMessage(1, txnItems_.get(i)); - } - unknownFields.writeTo(output); + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); } - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) { - return size; - } - - size = 0; - for (int i = 0; i < txnItems_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, txnItems_.get(i)); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.binlog.protocol.TxnData) { + return mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnData)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.TxnData other) { + if (other == com.aliyun.polardbx.binlog.protocol.TxnData.getDefaultInstance()) return this; + if (txnItemsBuilder_ == null) { + if (!other.txnItems_.isEmpty()) { + if (txnItems_.isEmpty()) { + txnItems_ = other.txnItems_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureTxnItemsIsMutable(); + txnItems_.addAll(other.txnItems_); + } + onChanged(); + } + } else { + if (!other.txnItems_.isEmpty()) { + if (txnItemsBuilder_.isEmpty()) { + txnItemsBuilder_.dispose(); + txnItemsBuilder_ = null; + txnItems_ = other.txnItems_; + bitField0_ = (bitField0_ & ~0x00000001); + txnItemsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getTxnItemsFieldBuilder() : null; + } else { + txnItemsBuilder_.addAllMessages(other.txnItems_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; } @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.TxnData)) { - return super.equals(obj); - } - com.aliyun.polardbx.binlog.protocol.TxnData other = (com.aliyun.polardbx.binlog.protocol.TxnData) obj; - - if (!getTxnItemsList() - .equals(other.getTxnItemsList())) { - return false; - } - if (!unknownFields.equals(other.unknownFields)) { - return false; - } - return true; + public final boolean isInitialized() { + return true; } @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (getTxnItemsCount() > 0) { - hash = (37 * hash) + TXNITEMS_FIELD_NUMBER; - hash = (53 * hash) + getTxnItemsList().hashCode(); + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.aliyun.polardbx.binlog.protocol.TxnData parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.binlog.protocol.TxnData) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; + } + return this; } + private int bitField0_; - public static com.aliyun.polardbx.binlog.protocol.TxnData parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + private java.util.List txnItems_ = + java.util.Collections.emptyList(); + private void ensureTxnItemsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + txnItems_ = new java.util.ArrayList(txnItems_); + bitField0_ |= 0x00000001; + } } - public static com.aliyun.polardbx.binlog.protocol.TxnData parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } + private com.google.protobuf.RepeatedFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnItem, com.aliyun.polardbx.binlog.protocol.TxnItem.Builder, com.aliyun.polardbx.binlog.protocol.TxnItemOrBuilder> txnItemsBuilder_; - public static com.aliyun.polardbx.binlog.protocol.TxnData parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + public java.util.List getTxnItemsList() { + if (txnItemsBuilder_ == null) { + return java.util.Collections.unmodifiableList(txnItems_); + } else { + return txnItemsBuilder_.getMessageList(); + } } - - public static com.aliyun.polardbx.binlog.protocol.TxnData parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + public int getTxnItemsCount() { + if (txnItemsBuilder_ == null) { + return txnItems_.size(); + } else { + return txnItemsBuilder_.getCount(); + } } - - public static com.aliyun.polardbx.binlog.protocol.TxnData parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + public com.aliyun.polardbx.binlog.protocol.TxnItem getTxnItems(int index) { + if (txnItemsBuilder_ == null) { + return txnItems_.get(index); + } else { + return txnItemsBuilder_.getMessage(index); + } } - - public static com.aliyun.polardbx.binlog.protocol.TxnData parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + public Builder setTxnItems( + int index, com.aliyun.polardbx.binlog.protocol.TxnItem value) { + if (txnItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTxnItemsIsMutable(); + txnItems_.set(index, value); + onChanged(); + } else { + txnItemsBuilder_.setMessage(index, value); + } + return this; } - - public static com.aliyun.polardbx.binlog.protocol.TxnData parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + public Builder setTxnItems( + int index, com.aliyun.polardbx.binlog.protocol.TxnItem.Builder builderForValue) { + if (txnItemsBuilder_ == null) { + ensureTxnItemsIsMutable(); + txnItems_.set(index, builderForValue.build()); + onChanged(); + } else { + txnItemsBuilder_.setMessage(index, builderForValue.build()); + } + return this; } - - public static com.aliyun.polardbx.binlog.protocol.TxnData parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + public Builder addTxnItems(com.aliyun.polardbx.binlog.protocol.TxnItem value) { + if (txnItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTxnItemsIsMutable(); + txnItems_.add(value); + onChanged(); + } else { + txnItemsBuilder_.addMessage(value); + } + return this; } - - public static com.aliyun.polardbx.binlog.protocol.TxnData parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + public Builder addTxnItems( + int index, com.aliyun.polardbx.binlog.protocol.TxnItem value) { + if (txnItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTxnItemsIsMutable(); + txnItems_.add(index, value); + onChanged(); + } else { + txnItemsBuilder_.addMessage(index, value); + } + return this; } - - public static com.aliyun.polardbx.binlog.protocol.TxnData parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + public Builder addTxnItems( + com.aliyun.polardbx.binlog.protocol.TxnItem.Builder builderForValue) { + if (txnItemsBuilder_ == null) { + ensureTxnItemsIsMutable(); + txnItems_.add(builderForValue.build()); + onChanged(); + } else { + txnItemsBuilder_.addMessage(builderForValue.build()); + } + return this; } - - public static com.aliyun.polardbx.binlog.protocol.TxnData parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + public Builder addTxnItems( + int index, com.aliyun.polardbx.binlog.protocol.TxnItem.Builder builderForValue) { + if (txnItemsBuilder_ == null) { + ensureTxnItemsIsMutable(); + txnItems_.add(index, builderForValue.build()); + onChanged(); + } else { + txnItemsBuilder_.addMessage(index, builderForValue.build()); + } + return this; } - - public static com.aliyun.polardbx.binlog.protocol.TxnData parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + public Builder addAllTxnItems( + java.lang.Iterable values) { + if (txnItemsBuilder_ == null) { + ensureTxnItemsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, txnItems_); + onChanged(); + } else { + txnItemsBuilder_.addAllMessages(values); + } + return this; } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + public Builder clearTxnItems() { + if (txnItemsBuilder_ == null) { + txnItems_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + txnItemsBuilder_.clear(); + } + return this; } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + public Builder removeTxnItems(int index) { + if (txnItemsBuilder_ == null) { + ensureTxnItemsIsMutable(); + txnItems_.remove(index); + onChanged(); + } else { + txnItemsBuilder_.remove(index); + } + return this; } - - public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.TxnData prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + public com.aliyun.polardbx.binlog.protocol.TxnItem.Builder getTxnItemsBuilder( + int index) { + return getTxnItemsFieldBuilder().getBuilder(index); } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + public com.aliyun.polardbx.binlog.protocol.TxnItemOrBuilder getTxnItemsOrBuilder( + int index) { + if (txnItemsBuilder_ == null) { + return txnItems_.get(index); } else { + return txnItemsBuilder_.getMessageOrBuilder(index); + } } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + public java.util.List + getTxnItemsOrBuilderList() { + if (txnItemsBuilder_ != null) { + return txnItemsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(txnItems_); + } } - /** - * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnData} + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.TxnData) - com.aliyun.polardbx.binlog.protocol.TxnDataOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnData_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnData_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.aliyun.polardbx.binlog.protocol.TxnData.class, - com.aliyun.polardbx.binlog.protocol.TxnData.Builder.class); - } - - // Construct using com.aliyun.polardbx.binlog.protocol.TxnData.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - getTxnItemsFieldBuilder(); - } - } - - @java.lang.Override - public Builder clear() { - super.clear(); - if (txnItemsBuilder_ == null) { - txnItems_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - } else { - txnItemsBuilder_.clear(); - } - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnData_descriptor; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnData getDefaultInstanceForType() { - return com.aliyun.polardbx.binlog.protocol.TxnData.getDefaultInstance(); - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnData build() { - com.aliyun.polardbx.binlog.protocol.TxnData result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnData buildPartial() { - com.aliyun.polardbx.binlog.protocol.TxnData result = new com.aliyun.polardbx.binlog.protocol.TxnData(this); - int from_bitField0_ = bitField0_; - if (txnItemsBuilder_ == null) { - if (((bitField0_ & 0x00000001) != 0)) { - txnItems_ = java.util.Collections.unmodifiableList(txnItems_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.txnItems_ = txnItems_; - } else { - result.txnItems_ = txnItemsBuilder_.build(); - } - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.aliyun.polardbx.binlog.protocol.TxnData) { - return mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnData) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.TxnData other) { - if (other == com.aliyun.polardbx.binlog.protocol.TxnData.getDefaultInstance()) { - return this; - } - if (txnItemsBuilder_ == null) { - if (!other.txnItems_.isEmpty()) { - if (txnItems_.isEmpty()) { - txnItems_ = other.txnItems_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureTxnItemsIsMutable(); - txnItems_.addAll(other.txnItems_); - } - onChanged(); - } - } else { - if (!other.txnItems_.isEmpty()) { - if (txnItemsBuilder_.isEmpty()) { - txnItemsBuilder_.dispose(); - txnItemsBuilder_ = null; - txnItems_ = other.txnItems_; - bitField0_ = (bitField0_ & ~0x00000001); - txnItemsBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? - getTxnItemsFieldBuilder() : null; - } else { - txnItemsBuilder_.addAllMessages(other.txnItems_); - } - } - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.aliyun.polardbx.binlog.protocol.TxnData parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.aliyun.polardbx.binlog.protocol.TxnData) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private int bitField0_; - - private java.util.List txnItems_ = - java.util.Collections.emptyList(); - - private void ensureTxnItemsIsMutable() { - if (!((bitField0_ & 0x00000001) != 0)) { - txnItems_ = new java.util.ArrayList(txnItems_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnItem, com.aliyun.polardbx.binlog.protocol.TxnItem.Builder, com.aliyun.polardbx.binlog.protocol.TxnItemOrBuilder> - txnItemsBuilder_; - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - public java.util.List getTxnItemsList() { - if (txnItemsBuilder_ == null) { - return java.util.Collections.unmodifiableList(txnItems_); - } else { - return txnItemsBuilder_.getMessageList(); - } - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - public int getTxnItemsCount() { - if (txnItemsBuilder_ == null) { - return txnItems_.size(); - } else { - return txnItemsBuilder_.getCount(); - } - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - public com.aliyun.polardbx.binlog.protocol.TxnItem getTxnItems(int index) { - if (txnItemsBuilder_ == null) { - return txnItems_.get(index); - } else { - return txnItemsBuilder_.getMessage(index); - } - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - public Builder setTxnItems( - int index, com.aliyun.polardbx.binlog.protocol.TxnItem value) { - if (txnItemsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureTxnItemsIsMutable(); - txnItems_.set(index, value); - onChanged(); - } else { - txnItemsBuilder_.setMessage(index, value); - } - return this; - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - public Builder setTxnItems( - int index, com.aliyun.polardbx.binlog.protocol.TxnItem.Builder builderForValue) { - if (txnItemsBuilder_ == null) { - ensureTxnItemsIsMutable(); - txnItems_.set(index, builderForValue.build()); - onChanged(); - } else { - txnItemsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - public Builder addTxnItems(com.aliyun.polardbx.binlog.protocol.TxnItem value) { - if (txnItemsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureTxnItemsIsMutable(); - txnItems_.add(value); - onChanged(); - } else { - txnItemsBuilder_.addMessage(value); - } - return this; - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - public Builder addTxnItems( - int index, com.aliyun.polardbx.binlog.protocol.TxnItem value) { - if (txnItemsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureTxnItemsIsMutable(); - txnItems_.add(index, value); - onChanged(); - } else { - txnItemsBuilder_.addMessage(index, value); - } - return this; - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - public Builder addTxnItems( - com.aliyun.polardbx.binlog.protocol.TxnItem.Builder builderForValue) { - if (txnItemsBuilder_ == null) { - ensureTxnItemsIsMutable(); - txnItems_.add(builderForValue.build()); - onChanged(); - } else { - txnItemsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - public Builder addTxnItems( - int index, com.aliyun.polardbx.binlog.protocol.TxnItem.Builder builderForValue) { - if (txnItemsBuilder_ == null) { - ensureTxnItemsIsMutable(); - txnItems_.add(index, builderForValue.build()); - onChanged(); - } else { - txnItemsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - public Builder addAllTxnItems( - java.lang.Iterable values) { - if (txnItemsBuilder_ == null) { - ensureTxnItemsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, txnItems_); - onChanged(); - } else { - txnItemsBuilder_.addAllMessages(values); - } - return this; - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - public Builder clearTxnItems() { - if (txnItemsBuilder_ == null) { - txnItems_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - txnItemsBuilder_.clear(); - } - return this; - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - public Builder removeTxnItems(int index) { - if (txnItemsBuilder_ == null) { - ensureTxnItemsIsMutable(); - txnItems_.remove(index); - onChanged(); - } else { - txnItemsBuilder_.remove(index); - } - return this; - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - public com.aliyun.polardbx.binlog.protocol.TxnItem.Builder getTxnItemsBuilder( - int index) { - return getTxnItemsFieldBuilder().getBuilder(index); - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - public com.aliyun.polardbx.binlog.protocol.TxnItemOrBuilder getTxnItemsOrBuilder( - int index) { - if (txnItemsBuilder_ == null) { - return txnItems_.get(index); - } else { - return txnItemsBuilder_.getMessageOrBuilder(index); - } - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - public java.util.List - getTxnItemsOrBuilderList() { - if (txnItemsBuilder_ != null) { - return txnItemsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(txnItems_); - } - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - public com.aliyun.polardbx.binlog.protocol.TxnItem.Builder addTxnItemsBuilder() { - return getTxnItemsFieldBuilder().addBuilder( - com.aliyun.polardbx.binlog.protocol.TxnItem.getDefaultInstance()); - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - public com.aliyun.polardbx.binlog.protocol.TxnItem.Builder addTxnItemsBuilder( - int index) { - return getTxnItemsFieldBuilder().addBuilder( - index, com.aliyun.polardbx.binlog.protocol.TxnItem.getDefaultInstance()); - } - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - public java.util.List - getTxnItemsBuilderList() { - return getTxnItemsFieldBuilder().getBuilderList(); - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnItem, com.aliyun.polardbx.binlog.protocol.TxnItem.Builder, com.aliyun.polardbx.binlog.protocol.TxnItemOrBuilder> + public com.aliyun.polardbx.binlog.protocol.TxnItem.Builder addTxnItemsBuilder() { + return getTxnItemsFieldBuilder().addBuilder( + com.aliyun.polardbx.binlog.protocol.TxnItem.getDefaultInstance()); + } + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + public com.aliyun.polardbx.binlog.protocol.TxnItem.Builder addTxnItemsBuilder( + int index) { + return getTxnItemsFieldBuilder().addBuilder( + index, com.aliyun.polardbx.binlog.protocol.TxnItem.getDefaultInstance()); + } + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + public java.util.List + getTxnItemsBuilderList() { + return getTxnItemsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnItem, com.aliyun.polardbx.binlog.protocol.TxnItem.Builder, com.aliyun.polardbx.binlog.protocol.TxnItemOrBuilder> getTxnItemsFieldBuilder() { - if (txnItemsBuilder_ == null) { - txnItemsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnItem, com.aliyun.polardbx.binlog.protocol.TxnItem.Builder, com.aliyun.polardbx.binlog.protocol.TxnItemOrBuilder>( - txnItems_, - ((bitField0_ & 0x00000001) != 0), - getParentForChildren(), - isClean()); - txnItems_ = null; - } - return txnItemsBuilder_; - } - - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.TxnData) + if (txnItemsBuilder_ == null) { + txnItemsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnItem, com.aliyun.polardbx.binlog.protocol.TxnItem.Builder, com.aliyun.polardbx.binlog.protocol.TxnItemOrBuilder>( + txnItems_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + txnItems_ = null; + } + return txnItemsBuilder_; } - - // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.TxnData) - private static final com.aliyun.polardbx.binlog.protocol.TxnData DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.TxnData(); + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); } - public static com.aliyun.polardbx.binlog.protocol.TxnData getDefaultInstance() { - return DEFAULT_INSTANCE; + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public TxnData parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new TxnData(input, extensionRegistry); - } - }; - public static com.google.protobuf.Parser parser() { - return PARSER; - } + // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.TxnData) + } - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } + // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.TxnData) + private static final com.aliyun.polardbx.binlog.protocol.TxnData DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.TxnData(); + } + + public static com.aliyun.polardbx.binlog.protocol.TxnData getDefaultInstance() { + return DEFAULT_INSTANCE; + } + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnData getDefaultInstanceForType() { - return DEFAULT_INSTANCE; + public TxnData parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TxnData(input, extensionRegistry); } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnData getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnDataOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnDataOrBuilder.java index e60e5262..c922826b 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnDataOrBuilder.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnDataOrBuilder.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -24,31 +7,27 @@ public interface TxnDataOrBuilder extends // @@protoc_insertion_point(interface_extends:com.aliyun.polardbx.binlog.protocol.TxnData) com.google.protobuf.MessageOrBuilder { - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - java.util.List - getTxnItemsList(); - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - com.aliyun.polardbx.binlog.protocol.TxnItem getTxnItems(int index); - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - int getTxnItemsCount(); - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - java.util.List - getTxnItemsOrBuilderList(); - - /** - * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; - */ - com.aliyun.polardbx.binlog.protocol.TxnItemOrBuilder getTxnItemsOrBuilder( - int index); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + java.util.List + getTxnItemsList(); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + com.aliyun.polardbx.binlog.protocol.TxnItem getTxnItems(int index); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + int getTxnItemsCount(); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + java.util.List + getTxnItemsOrBuilderList(); + /** + * repeated .com.aliyun.polardbx.binlog.protocol.TxnItem txnItems = 1; + */ + com.aliyun.polardbx.binlog.protocol.TxnItemOrBuilder getTxnItemsOrBuilder( + int index); } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnEnd.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnEnd.java index e76c2f8e..08e64a73 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnEnd.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnEnd.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -22,466 +5,423 @@ /** *
- * 暂时没有payload
+ *暂时没有payload
  * 
- *

+ * * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnEnd} */ public final class TxnEnd extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:com.aliyun.polardbx.binlog.protocol.TxnEnd) TxnEndOrBuilder { - private static final long serialVersionUID = 0L; - - // Use TxnEnd.newBuilder() to construct. - private TxnEnd(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private TxnEnd() { +private static final long serialVersionUID = 0L; + // Use TxnEnd.newBuilder() to construct. + private TxnEnd(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TxnEnd() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new TxnEnd(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TxnEnd( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnEnd_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnEnd_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.binlog.protocol.TxnEnd.class, com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder.class); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.TxnEnd)) { + return super.equals(obj); + } + com.aliyun.polardbx.binlog.protocol.TxnEnd other = (com.aliyun.polardbx.binlog.protocol.TxnEnd) obj; + + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.TxnEnd prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *

+   *暂时没有payload
+   * 
+ * + * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnEnd} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.TxnEnd) + com.aliyun.polardbx.binlog.protocol.TxnEndOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnEnd_descriptor; } @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new TxnEnd(); + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnEnd_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.binlog.protocol.TxnEnd.class, com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder.class); } - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; + // Construct using com.aliyun.polardbx.binlog.protocol.TxnEnd.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); } - private TxnEnd( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - 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; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnEnd_descriptor; + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } } - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnEnd_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.aliyun.polardbx.binlog.protocol.TxnEnd.class, - com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder.class); + public Builder clear() { + super.clear(); + return this; } - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } - - memoizedIsInitialized = 1; - return true; + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnEnd_descriptor; } @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - unknownFields.writeTo(output); + public com.aliyun.polardbx.binlog.protocol.TxnEnd getDefaultInstanceForType() { + return com.aliyun.polardbx.binlog.protocol.TxnEnd.getDefaultInstance(); } @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) { - return size; - } - - size = 0; - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; + public com.aliyun.polardbx.binlog.protocol.TxnEnd build() { + com.aliyun.polardbx.binlog.protocol.TxnEnd result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; } @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.TxnEnd)) { - return super.equals(obj); - } - com.aliyun.polardbx.binlog.protocol.TxnEnd other = (com.aliyun.polardbx.binlog.protocol.TxnEnd) obj; - - if (!unknownFields.equals(other.unknownFields)) { - return false; - } - return true; + public com.aliyun.polardbx.binlog.protocol.TxnEnd buildPartial() { + com.aliyun.polardbx.binlog.protocol.TxnEnd result = new com.aliyun.polardbx.binlog.protocol.TxnEnd(this); + onBuilt(); + return result; } @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + public Builder clone() { + return super.clone(); } - - public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); } - - public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); } - - public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); } - - public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); } - - public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); } - - public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.binlog.protocol.TxnEnd) { + return mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnEnd)other); + } else { + super.mergeFrom(other); + return this; + } } - public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.TxnEnd other) { + if (other == com.aliyun.polardbx.binlog.protocol.TxnEnd.getDefaultInstance()) return this; + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; } - public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + @java.lang.Override + public final boolean isInitialized() { + return true; } - public static com.aliyun.polardbx.binlog.protocol.TxnEnd parseFrom( + @java.lang.Override + public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + com.aliyun.polardbx.binlog.protocol.TxnEnd parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.binlog.protocol.TxnEnd) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; } - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.TxnEnd prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); } @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - /** - *
-     * 暂时没有payload
-     * 
- *

- * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnEnd} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.TxnEnd) - com.aliyun.polardbx.binlog.protocol.TxnEndOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnEnd_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnEnd_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.aliyun.polardbx.binlog.protocol.TxnEnd.class, - com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder.class); - } - - // Construct using com.aliyun.polardbx.binlog.protocol.TxnEnd.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - @java.lang.Override - public Builder clear() { - super.clear(); - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnEnd_descriptor; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnEnd getDefaultInstanceForType() { - return com.aliyun.polardbx.binlog.protocol.TxnEnd.getDefaultInstance(); - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnEnd build() { - com.aliyun.polardbx.binlog.protocol.TxnEnd result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnEnd buildPartial() { - com.aliyun.polardbx.binlog.protocol.TxnEnd result = new com.aliyun.polardbx.binlog.protocol.TxnEnd(this); - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.aliyun.polardbx.binlog.protocol.TxnEnd) { - return mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnEnd) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.TxnEnd other) { - if (other == com.aliyun.polardbx.binlog.protocol.TxnEnd.getDefaultInstance()) { - return this; - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.aliyun.polardbx.binlog.protocol.TxnEnd parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.aliyun.polardbx.binlog.protocol.TxnEnd) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.TxnEnd) - } + // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.TxnEnd) + } - // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.TxnEnd) - private static final com.aliyun.polardbx.binlog.protocol.TxnEnd DEFAULT_INSTANCE; + // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.TxnEnd) + private static final com.aliyun.polardbx.binlog.protocol.TxnEnd DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.TxnEnd(); + } - static { - DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.TxnEnd(); - } + public static com.aliyun.polardbx.binlog.protocol.TxnEnd getDefaultInstance() { + return DEFAULT_INSTANCE; + } - public static com.aliyun.polardbx.binlog.protocol.TxnEnd getDefaultInstance() { - return DEFAULT_INSTANCE; + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public TxnEnd parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TxnEnd(input, extensionRegistry); } + }; - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public TxnEnd parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new TxnEnd(input, extensionRegistry); - } - }; + public static com.google.protobuf.Parser parser() { + return PARSER; + } - public static com.google.protobuf.Parser parser() { - return PARSER; - } + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnEnd getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnEnd getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnEndOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnEndOrBuilder.java index 3baa5af0..ac647fef 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnEndOrBuilder.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnEndOrBuilder.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnItem.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnItem.java index 8b2895bb..c26ed3e7 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnItem.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnItem.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -27,1002 +10,1288 @@ public final class TxnItem extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:com.aliyun.polardbx.binlog.protocol.TxnItem) TxnItemOrBuilder { - private static final long serialVersionUID = 0L; +private static final long serialVersionUID = 0L; + // Use TxnItem.newBuilder() to construct. + private TxnItem(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TxnItem() { + traceId_ = ""; + payload_ = com.google.protobuf.ByteString.EMPTY; + rowsQuery_ = ""; + schema_ = ""; + table_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new TxnItem(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TxnItem( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + traceId_ = s; + break; + } + case 16: { + + eventType_ = input.readInt32(); + break; + } + case 26: { + + payload_ = input.readBytes(); + break; + } + case 34: { + java.lang.String s = input.readStringRequireUtf8(); - // Use TxnItem.newBuilder() to construct. - private TxnItem(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); + rowsQuery_ = s; + break; + } + case 42: { + java.lang.String s = input.readStringRequireUtf8(); + + schema_ = s; + break; + } + case 50: { + java.lang.String s = input.readStringRequireUtf8(); + + table_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnItem_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnItem_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.binlog.protocol.TxnItem.class, com.aliyun.polardbx.binlog.protocol.TxnItem.Builder.class); + } + + public static final int TRACEID_FIELD_NUMBER = 1; + private volatile java.lang.Object traceId_; + /** + *

+   **
+   *1.traceId是分布式事务内,合并多个物理分片的事件时,进行排序的依据</br>
+   *2.为了便于统一处理,不管是单机事务还是分布式事务都要求传入,并且要保证同一事务在同一物理分片的traceID单调递增 </br>
+   *3.如果物理binlog中带有traceId标识,直接使用即可;如果物理binlog中不带有traceId标识,通过"时间戳+自增序列"手动生成 </br>
+   * 
+ * + * string traceId = 1; + * @return The traceId. + */ + @java.lang.Override + public java.lang.String getTraceId() { + java.lang.Object ref = traceId_; + 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(); + traceId_ = s; + return s; + } + } + /** + *
+   **
+   *1.traceId是分布式事务内,合并多个物理分片的事件时,进行排序的依据</br>
+   *2.为了便于统一处理,不管是单机事务还是分布式事务都要求传入,并且要保证同一事务在同一物理分片的traceID单调递增 </br>
+   *3.如果物理binlog中带有traceId标识,直接使用即可;如果物理binlog中不带有traceId标识,通过"时间戳+自增序列"手动生成 </br>
+   * 
+ * + * string traceId = 1; + * @return The bytes for traceId. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getTraceIdBytes() { + java.lang.Object ref = traceId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + traceId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int EVENTTYPE_FIELD_NUMBER = 2; + private int eventType_; + /** + *
+   **
+   *1.对应mysql的EventType
+   * 
+ * + * int32 eventType = 2; + * @return The eventType. + */ + @java.lang.Override + public int getEventType() { + return eventType_; + } + + public static final int PAYLOAD_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString payload_; + /** + *
+   **
+   *1.二进制数据
+   * 
+ * + * bytes payload = 3; + * @return The payload. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPayload() { + return payload_; + } + + public static final int ROWSQUERY_FIELD_NUMBER = 4; + private volatile java.lang.Object rowsQuery_; + /** + *
+   **
+   *1.保存RowsQuery信息
+   * 
+ * + * string rowsQuery = 4; + * @return The rowsQuery. + */ + @java.lang.Override + public java.lang.String getRowsQuery() { + java.lang.Object ref = rowsQuery_; + 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(); + rowsQuery_ = s; + return s; + } + } + /** + *
+   **
+   *1.保存RowsQuery信息
+   * 
+ * + * string rowsQuery = 4; + * @return The bytes for rowsQuery. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getRowsQueryBytes() { + java.lang.Object ref = rowsQuery_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + rowsQuery_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SCHEMA_FIELD_NUMBER = 5; + private volatile java.lang.Object schema_; + /** + *
+   **
+   *对应的库名
+   * 
+ * + * string schema = 5; + * @return The schema. + */ + @java.lang.Override + public java.lang.String getSchema() { + java.lang.Object ref = schema_; + 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(); + schema_ = s; + return s; } + } + /** + *
+   **
+   *对应的库名
+   * 
+ * + * string schema = 5; + * @return The bytes for schema. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getSchemaBytes() { + java.lang.Object ref = schema_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + schema_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TABLE_FIELD_NUMBER = 6; + private volatile java.lang.Object table_; + /** + *
+   **
+   *对应的表名
+   * 
+ * + * string table = 6; + * @return The table. + */ + @java.lang.Override + public java.lang.String getTable() { + java.lang.Object ref = table_; + 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(); + table_ = s; + return s; + } + } + /** + *
+   **
+   *对应的表名
+   * 
+ * + * string table = 6; + * @return The bytes for table. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getTableBytes() { + java.lang.Object ref = table_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + table_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getTraceIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, traceId_); + } + if (eventType_ != 0) { + output.writeInt32(2, eventType_); + } + if (!payload_.isEmpty()) { + output.writeBytes(3, payload_); + } + if (!getRowsQueryBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, rowsQuery_); + } + if (!getSchemaBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, schema_); + } + if (!getTableBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, table_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; - private TxnItem() { - traceId_ = ""; - rowsQuery_ = ""; - payload_ = com.google.protobuf.ByteString.EMPTY; + size = 0; + if (!getTraceIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, traceId_); + } + if (eventType_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, eventType_); + } + if (!payload_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, payload_); + } + if (!getRowsQueryBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, rowsQuery_); + } + if (!getSchemaBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, schema_); + } + if (!getTableBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, table_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.TxnItem)) { + return super.equals(obj); + } + com.aliyun.polardbx.binlog.protocol.TxnItem other = (com.aliyun.polardbx.binlog.protocol.TxnItem) obj; + + if (!getTraceId() + .equals(other.getTraceId())) return false; + if (getEventType() + != other.getEventType()) return false; + if (!getPayload() + .equals(other.getPayload())) return false; + if (!getRowsQuery() + .equals(other.getRowsQuery())) return false; + if (!getSchema() + .equals(other.getSchema())) return false; + if (!getTable() + .equals(other.getTable())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TRACEID_FIELD_NUMBER; + hash = (53 * hash) + getTraceId().hashCode(); + hash = (37 * hash) + EVENTTYPE_FIELD_NUMBER; + hash = (53 * hash) + getEventType(); + hash = (37 * hash) + PAYLOAD_FIELD_NUMBER; + hash = (53 * hash) + getPayload().hashCode(); + hash = (37 * hash) + ROWSQUERY_FIELD_NUMBER; + hash = (53 * hash) + getRowsQuery().hashCode(); + hash = (37 * hash) + SCHEMA_FIELD_NUMBER; + hash = (53 * hash) + getSchema().hashCode(); + hash = (37 * hash) + TABLE_FIELD_NUMBER; + hash = (53 * hash) + getTable().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.binlog.protocol.TxnItem parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnItem parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnItem parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnItem parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnItem parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnItem parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnItem parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnItem parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnItem parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnItem parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnItem parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnItem parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.TxnItem prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnItem} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.TxnItem) + com.aliyun.polardbx.binlog.protocol.TxnItemOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnItem_descriptor; } @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new TxnItem(); + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnItem_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.binlog.protocol.TxnItem.class, com.aliyun.polardbx.binlog.protocol.TxnItem.Builder.class); } + // Construct using com.aliyun.polardbx.binlog.protocol.TxnItem.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; + public Builder clear() { + super.clear(); + traceId_ = ""; + + eventType_ = 0; + + payload_ = com.google.protobuf.ByteString.EMPTY; + + rowsQuery_ = ""; + + schema_ = ""; + + table_ = ""; + + return this; } - private TxnItem( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - 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; - case 10: { - java.lang.String s = input.readStringRequireUtf8(); + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnItem_descriptor; + } - traceId_ = s; - break; - } - case 18: { - java.lang.String s = input.readStringRequireUtf8(); + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnItem getDefaultInstanceForType() { + return com.aliyun.polardbx.binlog.protocol.TxnItem.getDefaultInstance(); + } - rowsQuery_ = s; - break; - } - case 24: { + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnItem build() { + com.aliyun.polardbx.binlog.protocol.TxnItem result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } - eventType_ = input.readInt32(); - break; - } - case 34: { + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnItem buildPartial() { + com.aliyun.polardbx.binlog.protocol.TxnItem result = new com.aliyun.polardbx.binlog.protocol.TxnItem(this); + result.traceId_ = traceId_; + result.eventType_ = eventType_; + result.payload_ = payload_; + result.rowsQuery_ = rowsQuery_; + result.schema_ = schema_; + result.table_ = table_; + onBuilt(); + return result; + } - payload_ = input.readBytes(); - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.binlog.protocol.TxnItem) { + return mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnItem)other); + } else { + super.mergeFrom(other); + return this; + } } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnItem_descriptor; + public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.TxnItem other) { + if (other == com.aliyun.polardbx.binlog.protocol.TxnItem.getDefaultInstance()) return this; + if (!other.getTraceId().isEmpty()) { + traceId_ = other.traceId_; + onChanged(); + } + if (other.getEventType() != 0) { + setEventType(other.getEventType()); + } + if (other.getPayload() != com.google.protobuf.ByteString.EMPTY) { + setPayload(other.getPayload()); + } + if (!other.getRowsQuery().isEmpty()) { + rowsQuery_ = other.rowsQuery_; + onChanged(); + } + if (!other.getSchema().isEmpty()) { + schema_ = other.schema_; + onChanged(); + } + if (!other.getTable().isEmpty()) { + table_ = other.table_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnItem_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.aliyun.polardbx.binlog.protocol.TxnItem.class, - com.aliyun.polardbx.binlog.protocol.TxnItem.Builder.class); + public final boolean isInitialized() { + return true; } - public static final int TRACEID_FIELD_NUMBER = 1; - private volatile java.lang.Object traceId_; + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.aliyun.polardbx.binlog.protocol.TxnItem parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.binlog.protocol.TxnItem) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private java.lang.Object traceId_ = ""; /** *
-     * *
-     * 1.traceId是分布式事务内,合并多个物理分片的事件时,进行排序的依据</br>
-     * 2.为了便于统一处理,不管是单机事务还是分布式事务都要求传入,并且要保证同一事务在同一物理分片的traceID单调递增 </br>
-     * 3.如果物理binlog中带有traceId标识,直接使用即可;如果物理binlog中不带有traceId标识,通过"时间戳+自增序列"手动生成 </br>
+     **
+     *1.traceId是分布式事务内,合并多个物理分片的事件时,进行排序的依据</br>
+     *2.为了便于统一处理,不管是单机事务还是分布式事务都要求传入,并且要保证同一事务在同一物理分片的traceID单调递增 </br>
+     *3.如果物理binlog中带有traceId标识,直接使用即可;如果物理binlog中不带有traceId标识,通过"时间戳+自增序列"手动生成 </br>
      * 
* * string traceId = 1; - * * @return The traceId. */ - @java.lang.Override public java.lang.String getTraceId() { - java.lang.Object ref = traceId_; - 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(); - traceId_ = s; - return s; - } + java.lang.Object ref = traceId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + traceId_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - /** *
-     * *
-     * 1.traceId是分布式事务内,合并多个物理分片的事件时,进行排序的依据</br>
-     * 2.为了便于统一处理,不管是单机事务还是分布式事务都要求传入,并且要保证同一事务在同一物理分片的traceID单调递增 </br>
-     * 3.如果物理binlog中带有traceId标识,直接使用即可;如果物理binlog中不带有traceId标识,通过"时间戳+自增序列"手动生成 </br>
+     **
+     *1.traceId是分布式事务内,合并多个物理分片的事件时,进行排序的依据</br>
+     *2.为了便于统一处理,不管是单机事务还是分布式事务都要求传入,并且要保证同一事务在同一物理分片的traceID单调递增 </br>
+     *3.如果物理binlog中带有traceId标识,直接使用即可;如果物理binlog中不带有traceId标识,通过"时间戳+自增序列"手动生成 </br>
      * 
* * string traceId = 1; - * * @return The bytes for traceId. */ - @java.lang.Override public com.google.protobuf.ByteString - getTraceIdBytes() { - java.lang.Object ref = traceId_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - traceId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + getTraceIdBytes() { + java.lang.Object ref = traceId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + traceId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } - - public static final int ROWSQUERY_FIELD_NUMBER = 2; - private volatile java.lang.Object rowsQuery_; - /** - * string rowsQuery = 2; + *
+     **
+     *1.traceId是分布式事务内,合并多个物理分片的事件时,进行排序的依据</br>
+     *2.为了便于统一处理,不管是单机事务还是分布式事务都要求传入,并且要保证同一事务在同一物理分片的traceID单调递增 </br>
+     *3.如果物理binlog中带有traceId标识,直接使用即可;如果物理binlog中不带有traceId标识,通过"时间戳+自增序列"手动生成 </br>
+     * 
* - * @return The rowsQuery. + * string traceId = 1; + * @param value The traceId to set. + * @return This builder for chaining. */ - @java.lang.Override - public java.lang.String getRowsQuery() { - java.lang.Object ref = rowsQuery_; - 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(); - rowsQuery_ = s; - return s; - } + public Builder setTraceId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + traceId_ = value; + onChanged(); + return this; } - /** - * string rowsQuery = 2; + *
+     **
+     *1.traceId是分布式事务内,合并多个物理分片的事件时,进行排序的依据</br>
+     *2.为了便于统一处理,不管是单机事务还是分布式事务都要求传入,并且要保证同一事务在同一物理分片的traceID单调递增 </br>
+     *3.如果物理binlog中带有traceId标识,直接使用即可;如果物理binlog中不带有traceId标识,通过"时间戳+自增序列"手动生成 </br>
+     * 
* - * @return The bytes for rowsQuery. + * string traceId = 1; + * @return This builder for chaining. */ - @java.lang.Override - public com.google.protobuf.ByteString - getRowsQueryBytes() { - java.lang.Object ref = rowsQuery_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - rowsQuery_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + public Builder clearTraceId() { + + traceId_ = getDefaultInstance().getTraceId(); + onChanged(); + return this; } - - public static final int EVENTTYPE_FIELD_NUMBER = 3; - private int eventType_; - /** *
-     * *
-     * 1.对应mysql的EventType
+     **
+     *1.traceId是分布式事务内,合并多个物理分片的事件时,进行排序的依据</br>
+     *2.为了便于统一处理,不管是单机事务还是分布式事务都要求传入,并且要保证同一事务在同一物理分片的traceID单调递增 </br>
+     *3.如果物理binlog中带有traceId标识,直接使用即可;如果物理binlog中不带有traceId标识,通过"时间戳+自增序列"手动生成 </br>
      * 
* - * int32 eventType = 3; + * string traceId = 1; + * @param value The bytes for traceId to set. + * @return This builder for chaining. + */ + public Builder setTraceIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + traceId_ = value; + onChanged(); + return this; + } + + private int eventType_ ; + /** + *
+     **
+     *1.对应mysql的EventType
+     * 
* + * int32 eventType = 2; * @return The eventType. */ @java.lang.Override public int getEventType() { - return eventType_; + return eventType_; } - - public static final int PAYLOAD_FIELD_NUMBER = 4; - private com.google.protobuf.ByteString payload_; - /** *
-     * *
-     * 1.二进制数据
+     **
+     *1.对应mysql的EventType
      * 
* - * bytes payload = 4; - * - * @return The payload. + * int32 eventType = 2; + * @param value The eventType to set. + * @return This builder for chaining. */ - @java.lang.Override - public com.google.protobuf.ByteString getPayload() { - return payload_; - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } - - memoizedIsInitialized = 1; - return true; + public Builder setEventType(int value) { + + eventType_ = value; + onChanged(); + return this; } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getTraceIdBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, traceId_); - } - if (!getRowsQueryBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, rowsQuery_); - } - if (eventType_ != 0) { - output.writeInt32(3, eventType_); - } - if (!payload_.isEmpty()) { - output.writeBytes(4, payload_); - } - unknownFields.writeTo(output); + /** + *
+     **
+     *1.对应mysql的EventType
+     * 
+ * + * int32 eventType = 2; + * @return This builder for chaining. + */ + public Builder clearEventType() { + + eventType_ = 0; + onChanged(); + return this; } + private com.google.protobuf.ByteString payload_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+     **
+     *1.二进制数据
+     * 
+ * + * bytes payload = 3; + * @return The payload. + */ @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) { - return size; - } - - size = 0; - if (!getTraceIdBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, traceId_); - } - if (!getRowsQueryBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, rowsQuery_); - } - if (eventType_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(3, eventType_); - } - if (!payload_.isEmpty()) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(4, payload_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; + public com.google.protobuf.ByteString getPayload() { + return payload_; } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.TxnItem)) { - return super.equals(obj); - } - com.aliyun.polardbx.binlog.protocol.TxnItem other = (com.aliyun.polardbx.binlog.protocol.TxnItem) obj; - - if (!getTraceId() - .equals(other.getTraceId())) { - return false; - } - if (!getRowsQuery() - .equals(other.getRowsQuery())) { - return false; - } - if (getEventType() - != other.getEventType()) { - return false; - } - if (!getPayload() - .equals(other.getPayload())) { - return false; - } - if (!unknownFields.equals(other.unknownFields)) { - return false; - } - return true; + /** + *
+     **
+     *1.二进制数据
+     * 
+ * + * bytes payload = 3; + * @param value The payload to set. + * @return This builder for chaining. + */ + public Builder setPayload(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + payload_ = value; + onChanged(); + return this; } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + TRACEID_FIELD_NUMBER; - hash = (53 * hash) + getTraceId().hashCode(); - hash = (37 * hash) + ROWSQUERY_FIELD_NUMBER; - hash = (53 * hash) + getRowsQuery().hashCode(); - hash = (37 * hash) + EVENTTYPE_FIELD_NUMBER; - hash = (53 * hash) + getEventType(); - hash = (37 * hash) + PAYLOAD_FIELD_NUMBER; - hash = (53 * hash) + getPayload().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; + /** + *
+     **
+     *1.二进制数据
+     * 
+ * + * bytes payload = 3; + * @return This builder for chaining. + */ + public Builder clearPayload() { + + payload_ = getDefaultInstance().getPayload(); + onChanged(); + return this; } - public static com.aliyun.polardbx.binlog.protocol.TxnItem parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + private java.lang.Object rowsQuery_ = ""; + /** + *
+     **
+     *1.保存RowsQuery信息
+     * 
+ * + * string rowsQuery = 4; + * @return The rowsQuery. + */ + public java.lang.String getRowsQuery() { + java.lang.Object ref = rowsQuery_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + rowsQuery_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - - public static com.aliyun.polardbx.binlog.protocol.TxnItem parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + /** + *
+     **
+     *1.保存RowsQuery信息
+     * 
+ * + * string rowsQuery = 4; + * @return The bytes for rowsQuery. + */ + public com.google.protobuf.ByteString + getRowsQueryBytes() { + java.lang.Object ref = rowsQuery_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + rowsQuery_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } - - public static com.aliyun.polardbx.binlog.protocol.TxnItem parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + /** + *
+     **
+     *1.保存RowsQuery信息
+     * 
+ * + * string rowsQuery = 4; + * @param value The rowsQuery to set. + * @return This builder for chaining. + */ + public Builder setRowsQuery( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + rowsQuery_ = value; + onChanged(); + return this; } - - public static com.aliyun.polardbx.binlog.protocol.TxnItem parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + /** + *
+     **
+     *1.保存RowsQuery信息
+     * 
+ * + * string rowsQuery = 4; + * @return This builder for chaining. + */ + public Builder clearRowsQuery() { + + rowsQuery_ = getDefaultInstance().getRowsQuery(); + onChanged(); + return this; } - - public static com.aliyun.polardbx.binlog.protocol.TxnItem parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + /** + *
+     **
+     *1.保存RowsQuery信息
+     * 
+ * + * string rowsQuery = 4; + * @param value The bytes for rowsQuery to set. + * @return This builder for chaining. + */ + public Builder setRowsQueryBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + rowsQuery_ = value; + onChanged(); + return this; } - public static com.aliyun.polardbx.binlog.protocol.TxnItem parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + private java.lang.Object schema_ = ""; + /** + *
+     **
+     *对应的库名
+     * 
+ * + * string schema = 5; + * @return The schema. + */ + public java.lang.String getSchema() { + java.lang.Object ref = schema_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + schema_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - - public static com.aliyun.polardbx.binlog.protocol.TxnItem parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + /** + *
+     **
+     *对应的库名
+     * 
+ * + * string schema = 5; + * @return The bytes for schema. + */ + public com.google.protobuf.ByteString + getSchemaBytes() { + java.lang.Object ref = schema_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + schema_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } - - public static com.aliyun.polardbx.binlog.protocol.TxnItem parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + /** + *
+     **
+     *对应的库名
+     * 
+ * + * string schema = 5; + * @param value The schema to set. + * @return This builder for chaining. + */ + public Builder setSchema( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + schema_ = value; + onChanged(); + return this; } - - public static com.aliyun.polardbx.binlog.protocol.TxnItem parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); + /** + *
+     **
+     *对应的库名
+     * 
+ * + * string schema = 5; + * @return This builder for chaining. + */ + public Builder clearSchema() { + + schema_ = getDefaultInstance().getSchema(); + onChanged(); + return this; } - - public static com.aliyun.polardbx.binlog.protocol.TxnItem parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + /** + *
+     **
+     *对应的库名
+     * 
+ * + * string schema = 5; + * @param value The bytes for schema to set. + * @return This builder for chaining. + */ + public Builder setSchemaBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + schema_ = value; + onChanged(); + return this; } - public static com.aliyun.polardbx.binlog.protocol.TxnItem parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + private java.lang.Object table_ = ""; + /** + *
+     **
+     *对应的表名
+     * 
+ * + * string table = 6; + * @return The table. + */ + public java.lang.String getTable() { + java.lang.Object ref = table_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + table_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - - public static com.aliyun.polardbx.binlog.protocol.TxnItem parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + /** + *
+     **
+     *对应的表名
+     * 
+ * + * string table = 6; + * @return The bytes for table. + */ + public com.google.protobuf.ByteString + getTableBytes() { + java.lang.Object ref = table_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + table_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); + /** + *
+     **
+     *对应的表名
+     * 
+ * + * string table = 6; + * @param value The table to set. + * @return This builder for chaining. + */ + public Builder setTable( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + table_ = value; + onChanged(); + return this; } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); + /** + *
+     **
+     *对应的表名
+     * 
+ * + * string table = 6; + * @return This builder for chaining. + */ + public Builder clearTable() { + + table_ = getDefaultInstance().getTable(); + onChanged(); + return this; } - - public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.TxnItem prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + /** + *
+     **
+     *对应的表名
+     * 
+ * + * string table = 6; + * @param value The bytes for table to set. + * @return This builder for chaining. + */ + public Builder setTableBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + table_ = value; + onChanged(); + return this; } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); } @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - /** - * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnItem} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.TxnItem) - com.aliyun.polardbx.binlog.protocol.TxnItemOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnItem_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnItem_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.aliyun.polardbx.binlog.protocol.TxnItem.class, - com.aliyun.polardbx.binlog.protocol.TxnItem.Builder.class); - } - // Construct using com.aliyun.polardbx.binlog.protocol.TxnItem.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } + // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.TxnItem) + } - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } + // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.TxnItem) + private static final com.aliyun.polardbx.binlog.protocol.TxnItem DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.TxnItem(); + } - @java.lang.Override - public Builder clear() { - super.clear(); - traceId_ = ""; - - rowsQuery_ = ""; - - eventType_ = 0; - - payload_ = com.google.protobuf.ByteString.EMPTY; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnItem_descriptor; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnItem getDefaultInstanceForType() { - return com.aliyun.polardbx.binlog.protocol.TxnItem.getDefaultInstance(); - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnItem build() { - com.aliyun.polardbx.binlog.protocol.TxnItem result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } + public static com.aliyun.polardbx.binlog.protocol.TxnItem getDefaultInstance() { + return DEFAULT_INSTANCE; + } - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnItem buildPartial() { - com.aliyun.polardbx.binlog.protocol.TxnItem result = new com.aliyun.polardbx.binlog.protocol.TxnItem(this); - result.traceId_ = traceId_; - result.rowsQuery_ = rowsQuery_; - result.eventType_ = eventType_; - result.payload_ = payload_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.aliyun.polardbx.binlog.protocol.TxnItem) { - return mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnItem) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.TxnItem other) { - if (other == com.aliyun.polardbx.binlog.protocol.TxnItem.getDefaultInstance()) { - return this; - } - if (!other.getTraceId().isEmpty()) { - traceId_ = other.traceId_; - onChanged(); - } - if (!other.getRowsQuery().isEmpty()) { - rowsQuery_ = other.rowsQuery_; - onChanged(); - } - if (other.getEventType() != 0) { - setEventType(other.getEventType()); - } - if (other.getPayload() != com.google.protobuf.ByteString.EMPTY) { - setPayload(other.getPayload()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.aliyun.polardbx.binlog.protocol.TxnItem parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.aliyun.polardbx.binlog.protocol.TxnItem) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object traceId_ = ""; - - /** - *
-         * *
-         * 1.traceId是分布式事务内,合并多个物理分片的事件时,进行排序的依据</br>
-         * 2.为了便于统一处理,不管是单机事务还是分布式事务都要求传入,并且要保证同一事务在同一物理分片的traceID单调递增 </br>
-         * 3.如果物理binlog中带有traceId标识,直接使用即可;如果物理binlog中不带有traceId标识,通过"时间戳+自增序列"手动生成 </br>
-         * 
- * - * string traceId = 1; - * - * @return The traceId. - */ - public java.lang.String getTraceId() { - java.lang.Object ref = traceId_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - traceId_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - *
-         * *
-         * 1.traceId是分布式事务内,合并多个物理分片的事件时,进行排序的依据</br>
-         * 2.为了便于统一处理,不管是单机事务还是分布式事务都要求传入,并且要保证同一事务在同一物理分片的traceID单调递增 </br>
-         * 3.如果物理binlog中带有traceId标识,直接使用即可;如果物理binlog中不带有traceId标识,通过"时间戳+自增序列"手动生成 </br>
-         * 
- * - * string traceId = 1; - * - * @return The bytes for traceId. - */ - public com.google.protobuf.ByteString - getTraceIdBytes() { - java.lang.Object ref = traceId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - traceId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - *
-         * *
-         * 1.traceId是分布式事务内,合并多个物理分片的事件时,进行排序的依据</br>
-         * 2.为了便于统一处理,不管是单机事务还是分布式事务都要求传入,并且要保证同一事务在同一物理分片的traceID单调递增 </br>
-         * 3.如果物理binlog中带有traceId标识,直接使用即可;如果物理binlog中不带有traceId标识,通过"时间戳+自增序列"手动生成 </br>
-         * 
- * - * string traceId = 1; - * - * @param value The traceId to set. - * @return This builder for chaining. - */ - public Builder setTraceId( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - traceId_ = value; - onChanged(); - return this; - } - - /** - *
-         * *
-         * 1.traceId是分布式事务内,合并多个物理分片的事件时,进行排序的依据</br>
-         * 2.为了便于统一处理,不管是单机事务还是分布式事务都要求传入,并且要保证同一事务在同一物理分片的traceID单调递增 </br>
-         * 3.如果物理binlog中带有traceId标识,直接使用即可;如果物理binlog中不带有traceId标识,通过"时间戳+自增序列"手动生成 </br>
-         * 
- * - * string traceId = 1; - * - * @return This builder for chaining. - */ - public Builder clearTraceId() { - - traceId_ = getDefaultInstance().getTraceId(); - onChanged(); - return this; - } - - /** - *
-         * *
-         * 1.traceId是分布式事务内,合并多个物理分片的事件时,进行排序的依据</br>
-         * 2.为了便于统一处理,不管是单机事务还是分布式事务都要求传入,并且要保证同一事务在同一物理分片的traceID单调递增 </br>
-         * 3.如果物理binlog中带有traceId标识,直接使用即可;如果物理binlog中不带有traceId标识,通过"时间戳+自增序列"手动生成 </br>
-         * 
- * - * string traceId = 1; - * - * @param value The bytes for traceId to set. - * @return This builder for chaining. - */ - public Builder setTraceIdBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - traceId_ = value; - onChanged(); - return this; - } - - private java.lang.Object rowsQuery_ = ""; - - /** - * string rowsQuery = 2; - * - * @return The rowsQuery. - */ - public java.lang.String getRowsQuery() { - java.lang.Object ref = rowsQuery_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - rowsQuery_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * string rowsQuery = 2; - * - * @return The bytes for rowsQuery. - */ - public com.google.protobuf.ByteString - getRowsQueryBytes() { - java.lang.Object ref = rowsQuery_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - rowsQuery_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string rowsQuery = 2; - * - * @param value The rowsQuery to set. - * @return This builder for chaining. - */ - public Builder setRowsQuery( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - rowsQuery_ = value; - onChanged(); - return this; - } - - /** - * string rowsQuery = 2; - * - * @return This builder for chaining. - */ - public Builder clearRowsQuery() { - - rowsQuery_ = getDefaultInstance().getRowsQuery(); - onChanged(); - return this; - } - - /** - * string rowsQuery = 2; - * - * @param value The bytes for rowsQuery to set. - * @return This builder for chaining. - */ - public Builder setRowsQueryBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - rowsQuery_ = value; - onChanged(); - return this; - } - - private int eventType_; - - /** - *
-         * *
-         * 1.对应mysql的EventType
-         * 
- * - * int32 eventType = 3; - * - * @return The eventType. - */ - @java.lang.Override - public int getEventType() { - return eventType_; - } - - /** - *
-         * *
-         * 1.对应mysql的EventType
-         * 
- * - * int32 eventType = 3; - * - * @param value The eventType to set. - * @return This builder for chaining. - */ - public Builder setEventType(int value) { - - eventType_ = value; - onChanged(); - return this; - } - - /** - *
-         * *
-         * 1.对应mysql的EventType
-         * 
- * - * int32 eventType = 3; - * - * @return This builder for chaining. - */ - public Builder clearEventType() { - - eventType_ = 0; - onChanged(); - return this; - } - - private com.google.protobuf.ByteString payload_ = com.google.protobuf.ByteString.EMPTY; - - /** - *
-         * *
-         * 1.二进制数据
-         * 
- * - * bytes payload = 4; - * - * @return The payload. - */ - @java.lang.Override - public com.google.protobuf.ByteString getPayload() { - return payload_; - } - - /** - *
-         * *
-         * 1.二进制数据
-         * 
- * - * bytes payload = 4; - * - * @param value The payload to set. - * @return This builder for chaining. - */ - public Builder setPayload(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - - payload_ = value; - onChanged(); - return this; - } - - /** - *
-         * *
-         * 1.二进制数据
-         * 
- * - * bytes payload = 4; - * - * @return This builder for chaining. - */ - public Builder clearPayload() { - - payload_ = getDefaultInstance().getPayload(); - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.TxnItem) - } - - // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.TxnItem) - private static final com.aliyun.polardbx.binlog.protocol.TxnItem DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.TxnItem(); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnItem getDefaultInstance() { - return DEFAULT_INSTANCE; + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public TxnItem parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TxnItem(input, extensionRegistry); } + }; - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public TxnItem parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new TxnItem(input, extensionRegistry); - } - }; + public static com.google.protobuf.Parser parser() { + return PARSER; + } - public static com.google.protobuf.Parser parser() { - return PARSER; - } + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnItem getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnItem getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnItemOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnItemOrBuilder.java index 371d7547..4522f784 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnItemOrBuilder.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnItemOrBuilder.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -24,71 +7,117 @@ public interface TxnItemOrBuilder extends // @@protoc_insertion_point(interface_extends:com.aliyun.polardbx.binlog.protocol.TxnItem) com.google.protobuf.MessageOrBuilder { - /** - *
-     * *
-     * 1.traceId是分布式事务内,合并多个物理分片的事件时,进行排序的依据</br>
-     * 2.为了便于统一处理,不管是单机事务还是分布式事务都要求传入,并且要保证同一事务在同一物理分片的traceID单调递增 </br>
-     * 3.如果物理binlog中带有traceId标识,直接使用即可;如果物理binlog中不带有traceId标识,通过"时间戳+自增序列"手动生成 </br>
-     * 
- * - * string traceId = 1; - * - * @return The traceId. - */ - java.lang.String getTraceId(); + /** + *
+   **
+   *1.traceId是分布式事务内,合并多个物理分片的事件时,进行排序的依据</br>
+   *2.为了便于统一处理,不管是单机事务还是分布式事务都要求传入,并且要保证同一事务在同一物理分片的traceID单调递增 </br>
+   *3.如果物理binlog中带有traceId标识,直接使用即可;如果物理binlog中不带有traceId标识,通过"时间戳+自增序列"手动生成 </br>
+   * 
+ * + * string traceId = 1; + * @return The traceId. + */ + java.lang.String getTraceId(); + /** + *
+   **
+   *1.traceId是分布式事务内,合并多个物理分片的事件时,进行排序的依据</br>
+   *2.为了便于统一处理,不管是单机事务还是分布式事务都要求传入,并且要保证同一事务在同一物理分片的traceID单调递增 </br>
+   *3.如果物理binlog中带有traceId标识,直接使用即可;如果物理binlog中不带有traceId标识,通过"时间戳+自增序列"手动生成 </br>
+   * 
+ * + * string traceId = 1; + * @return The bytes for traceId. + */ + com.google.protobuf.ByteString + getTraceIdBytes(); - /** - *
-     * *
-     * 1.traceId是分布式事务内,合并多个物理分片的事件时,进行排序的依据</br>
-     * 2.为了便于统一处理,不管是单机事务还是分布式事务都要求传入,并且要保证同一事务在同一物理分片的traceID单调递增 </br>
-     * 3.如果物理binlog中带有traceId标识,直接使用即可;如果物理binlog中不带有traceId标识,通过"时间戳+自增序列"手动生成 </br>
-     * 
- * - * string traceId = 1; - * - * @return The bytes for traceId. - */ - com.google.protobuf.ByteString - getTraceIdBytes(); + /** + *
+   **
+   *1.对应mysql的EventType
+   * 
+ * + * int32 eventType = 2; + * @return The eventType. + */ + int getEventType(); - /** - * string rowsQuery = 2; - * - * @return The rowsQuery. - */ - java.lang.String getRowsQuery(); + /** + *
+   **
+   *1.二进制数据
+   * 
+ * + * bytes payload = 3; + * @return The payload. + */ + com.google.protobuf.ByteString getPayload(); - /** - * string rowsQuery = 2; - * - * @return The bytes for rowsQuery. - */ - com.google.protobuf.ByteString - getRowsQueryBytes(); + /** + *
+   **
+   *1.保存RowsQuery信息
+   * 
+ * + * string rowsQuery = 4; + * @return The rowsQuery. + */ + java.lang.String getRowsQuery(); + /** + *
+   **
+   *1.保存RowsQuery信息
+   * 
+ * + * string rowsQuery = 4; + * @return The bytes for rowsQuery. + */ + com.google.protobuf.ByteString + getRowsQueryBytes(); - /** - *
-     * *
-     * 1.对应mysql的EventType
-     * 
- * - * int32 eventType = 3; - * - * @return The eventType. - */ - int getEventType(); + /** + *
+   **
+   *对应的库名
+   * 
+ * + * string schema = 5; + * @return The schema. + */ + java.lang.String getSchema(); + /** + *
+   **
+   *对应的库名
+   * 
+ * + * string schema = 5; + * @return The bytes for schema. + */ + com.google.protobuf.ByteString + getSchemaBytes(); - /** - *
-     * *
-     * 1.二进制数据
-     * 
- * - * bytes payload = 4; - * - * @return The payload. - */ - com.google.protobuf.ByteString getPayload(); + /** + *
+   **
+   *对应的表名
+   * 
+ * + * string table = 6; + * @return The table. + */ + java.lang.String getTable(); + /** + *
+   **
+   *对应的表名
+   * 
+ * + * string table = 6; + * @return The bytes for table. + */ + com.google.protobuf.ByteString + getTableBytes(); } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnMergedToken.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnMergedToken.java index 62759e4e..d41d81b0 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnMergedToken.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnMergedToken.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -27,957 +10,988 @@ public final class TxnMergedToken extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:com.aliyun.polardbx.binlog.protocol.TxnMergedToken) TxnMergedTokenOrBuilder { - private static final long serialVersionUID = 0L; +private static final long serialVersionUID = 0L; + // Use TxnMergedToken.newBuilder() to construct. + private TxnMergedToken(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TxnMergedToken() { + tso_ = ""; + type_ = 0; + schema_ = ""; + payload_ = com.google.protobuf.ByteString.EMPTY; + table_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new TxnMergedToken(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TxnMergedToken( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); - // Use TxnMergedToken.newBuilder() to construct. - private TxnMergedToken(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); + tso_ = s; + break; + } + case 16: { + int rawValue = input.readEnum(); + + type_ = rawValue; + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + schema_ = s; + break; + } + case 34: { + + payload_ = input.readBytes(); + break; + } + case 42: { + java.lang.String s = input.readStringRequireUtf8(); + + table_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMergedToken_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMergedToken_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.binlog.protocol.TxnMergedToken.class, com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder.class); + } + + public static final int TSO_FIELD_NUMBER = 1; + private volatile java.lang.Object tso_; + /** + * string tso = 1; + * @return The tso. + */ + @java.lang.Override + public java.lang.String getTso() { + java.lang.Object ref = tso_; + 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(); + tso_ = s; + return s; + } + } + /** + * string tso = 1; + * @return The bytes for tso. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getTsoBytes() { + java.lang.Object ref = tso_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + tso_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TYPE_FIELD_NUMBER = 2; + private int type_; + /** + * .com.aliyun.polardbx.binlog.protocol.TxnType type = 2; + * @return The enum numeric value on the wire for type. + */ + @java.lang.Override public int getTypeValue() { + return type_; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnType type = 2; + * @return The type. + */ + @java.lang.Override public com.aliyun.polardbx.binlog.protocol.TxnType getType() { + @SuppressWarnings("deprecation") + com.aliyun.polardbx.binlog.protocol.TxnType result = com.aliyun.polardbx.binlog.protocol.TxnType.valueOf(type_); + return result == null ? com.aliyun.polardbx.binlog.protocol.TxnType.UNRECOGNIZED : result; + } + + public static final int SCHEMA_FIELD_NUMBER = 3; + private volatile java.lang.Object schema_; + /** + * string schema = 3; + * @return The schema. + */ + @java.lang.Override + public java.lang.String getSchema() { + java.lang.Object ref = schema_; + 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(); + schema_ = s; + return s; + } + } + /** + * string schema = 3; + * @return The bytes for schema. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getSchemaBytes() { + java.lang.Object ref = schema_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + schema_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PAYLOAD_FIELD_NUMBER = 4; + private com.google.protobuf.ByteString payload_; + /** + * bytes payload = 4; + * @return The payload. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPayload() { + return payload_; + } + + public static final int TABLE_FIELD_NUMBER = 5; + private volatile java.lang.Object table_; + /** + * string table = 5; + * @return The table. + */ + @java.lang.Override + public java.lang.String getTable() { + java.lang.Object ref = table_; + 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(); + table_ = s; + return s; + } + } + /** + * string table = 5; + * @return The bytes for table. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getTableBytes() { + java.lang.Object ref = table_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + table_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getTsoBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, tso_); + } + if (type_ != com.aliyun.polardbx.binlog.protocol.TxnType.DML.getNumber()) { + output.writeEnum(2, type_); + } + if (!getSchemaBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, schema_); + } + if (!payload_.isEmpty()) { + output.writeBytes(4, payload_); + } + if (!getTableBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, table_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getTsoBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, tso_); + } + if (type_ != com.aliyun.polardbx.binlog.protocol.TxnType.DML.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(2, type_); + } + if (!getSchemaBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, schema_); + } + if (!payload_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(4, payload_); + } + if (!getTableBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, table_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.TxnMergedToken)) { + return super.equals(obj); + } + com.aliyun.polardbx.binlog.protocol.TxnMergedToken other = (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) obj; + + if (!getTso() + .equals(other.getTso())) return false; + if (type_ != other.type_) return false; + if (!getSchema() + .equals(other.getSchema())) return false; + if (!getPayload() + .equals(other.getPayload())) return false; + if (!getTable() + .equals(other.getTable())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TSO_FIELD_NUMBER; + hash = (53 * hash) + getTso().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + type_; + hash = (37 * hash) + SCHEMA_FIELD_NUMBER; + hash = (53 * hash) + getSchema().hashCode(); + hash = (37 * hash) + PAYLOAD_FIELD_NUMBER; + hash = (53 * hash) + getPayload().hashCode(); + hash = (37 * hash) + TABLE_FIELD_NUMBER; + hash = (53 * hash) + getTable().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.TxnMergedToken prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnMergedToken} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.TxnMergedToken) + com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMergedToken_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMergedToken_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.binlog.protocol.TxnMergedToken.class, com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder.class); } - private TxnMergedToken() { - tso_ = ""; - type_ = 0; - beginSchema_ = ""; - payload_ = com.google.protobuf.ByteString.EMPTY; + // Construct using com.aliyun.polardbx.binlog.protocol.TxnMergedToken.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); } + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new TxnMergedToken(); + public Builder clear() { + super.clear(); + tso_ = ""; + + type_ = 0; + + schema_ = ""; + + payload_ = com.google.protobuf.ByteString.EMPTY; + + table_ = ""; + + return this; } @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMergedToken_descriptor; } - private TxnMergedToken( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - 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; - case 10: { - java.lang.String s = input.readStringRequireUtf8(); - - tso_ = s; - break; - } - case 16: { - int rawValue = input.readEnum(); - - type_ = rawValue; - break; - } - case 26: { - java.lang.String s = input.readStringRequireUtf8(); - - beginSchema_ = s; - break; - } - case 34: { - - payload_ = input.readBytes(); - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnMergedToken getDefaultInstanceForType() { + return com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMergedToken_descriptor; + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnMergedToken build() { + com.aliyun.polardbx.binlog.protocol.TxnMergedToken result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMergedToken_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.aliyun.polardbx.binlog.protocol.TxnMergedToken.class, - com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder.class); + public com.aliyun.polardbx.binlog.protocol.TxnMergedToken buildPartial() { + com.aliyun.polardbx.binlog.protocol.TxnMergedToken result = new com.aliyun.polardbx.binlog.protocol.TxnMergedToken(this); + result.tso_ = tso_; + result.type_ = type_; + result.schema_ = schema_; + result.payload_ = payload_; + result.table_ = table_; + onBuilt(); + return result; } - public static final int TSO_FIELD_NUMBER = 1; - private volatile java.lang.Object tso_; + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.binlog.protocol.TxnMergedToken) { + return mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnMergedToken)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.TxnMergedToken other) { + if (other == com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance()) return this; + if (!other.getTso().isEmpty()) { + tso_ = other.tso_; + onChanged(); + } + if (other.type_ != 0) { + setTypeValue(other.getTypeValue()); + } + if (!other.getSchema().isEmpty()) { + schema_ = other.schema_; + onChanged(); + } + if (other.getPayload() != com.google.protobuf.ByteString.EMPTY) { + setPayload(other.getPayload()); + } + if (!other.getTable().isEmpty()) { + table_ = other.table_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.aliyun.polardbx.binlog.protocol.TxnMergedToken parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object tso_ = ""; /** * string tso = 1; - * * @return The tso. */ - @java.lang.Override public java.lang.String getTso() { - java.lang.Object ref = tso_; - 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(); - tso_ = s; - return s; - } + java.lang.Object ref = tso_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + tso_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - /** * string tso = 1; - * * @return The bytes for tso. */ - @java.lang.Override public com.google.protobuf.ByteString - getTsoBytes() { - java.lang.Object ref = tso_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - tso_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + getTsoBytes() { + java.lang.Object ref = tso_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + tso_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string tso = 1; + * @param value The tso to set. + * @return This builder for chaining. + */ + public Builder setTso( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + tso_ = value; + onChanged(); + return this; } - - public static final int TYPE_FIELD_NUMBER = 2; - private int type_; - + /** + * string tso = 1; + * @return This builder for chaining. + */ + public Builder clearTso() { + + tso_ = getDefaultInstance().getTso(); + onChanged(); + return this; + } + /** + * string tso = 1; + * @param value The bytes for tso to set. + * @return This builder for chaining. + */ + public Builder setTsoBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + tso_ = value; + onChanged(); + return this; + } + + private int type_ = 0; /** * .com.aliyun.polardbx.binlog.protocol.TxnType type = 2; - * * @return The enum numeric value on the wire for type. */ - @java.lang.Override - public int getTypeValue() { - return type_; + @java.lang.Override public int getTypeValue() { + return type_; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnType type = 2; + * @param value The enum numeric value on the wire for type to set. + * @return This builder for chaining. + */ + public Builder setTypeValue(int value) { + + type_ = value; + onChanged(); + return this; } - /** * .com.aliyun.polardbx.binlog.protocol.TxnType type = 2; - * * @return The type. */ @java.lang.Override public com.aliyun.polardbx.binlog.protocol.TxnType getType() { - @SuppressWarnings("deprecation") - com.aliyun.polardbx.binlog.protocol.TxnType result = com.aliyun.polardbx.binlog.protocol.TxnType.valueOf(type_); - return result == null ? com.aliyun.polardbx.binlog.protocol.TxnType.UNRECOGNIZED : result; + @SuppressWarnings("deprecation") + com.aliyun.polardbx.binlog.protocol.TxnType result = com.aliyun.polardbx.binlog.protocol.TxnType.valueOf(type_); + return result == null ? com.aliyun.polardbx.binlog.protocol.TxnType.UNRECOGNIZED : result; } - - public static final int BEGINSCHEMA_FIELD_NUMBER = 3; - private volatile java.lang.Object beginSchema_; - /** - * string beginSchema = 3; - * - * @return The beginSchema. + * .com.aliyun.polardbx.binlog.protocol.TxnType type = 2; + * @param value The type to set. + * @return This builder for chaining. */ - @java.lang.Override - public java.lang.String getBeginSchema() { - java.lang.Object ref = beginSchema_; - 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(); - beginSchema_ = s; - return s; - } + public Builder setType(com.aliyun.polardbx.binlog.protocol.TxnType value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value.getNumber(); + onChanged(); + return this; } - /** - * string beginSchema = 3; - * - * @return The bytes for beginSchema. + * .com.aliyun.polardbx.binlog.protocol.TxnType type = 2; + * @return This builder for chaining. */ - @java.lang.Override - public com.google.protobuf.ByteString - getBeginSchemaBytes() { - java.lang.Object ref = beginSchema_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - beginSchema_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + public Builder clearType() { + + type_ = 0; + onChanged(); + return this; } - public static final int PAYLOAD_FIELD_NUMBER = 4; - private com.google.protobuf.ByteString payload_; - + private java.lang.Object schema_ = ""; /** - * bytes payload = 4; - * - * @return The payload. + * string schema = 3; + * @return The schema. */ - @java.lang.Override - public com.google.protobuf.ByteString getPayload() { - return payload_; + public java.lang.String getSchema() { + java.lang.Object ref = schema_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + schema_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getTsoBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, tso_); - } - if (type_ != com.aliyun.polardbx.binlog.protocol.TxnType.DML.getNumber()) { - output.writeEnum(2, type_); - } - if (!getBeginSchemaBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, beginSchema_); - } - if (!payload_.isEmpty()) { - output.writeBytes(4, payload_); - } - unknownFields.writeTo(output); + /** + * string schema = 3; + * @return The bytes for schema. + */ + public com.google.protobuf.ByteString + getSchemaBytes() { + java.lang.Object ref = schema_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + schema_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) { - return size; - } - - size = 0; - if (!getTsoBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, tso_); - } - if (type_ != com.aliyun.polardbx.binlog.protocol.TxnType.DML.getNumber()) { - size += com.google.protobuf.CodedOutputStream - .computeEnumSize(2, type_); - } - if (!getBeginSchemaBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, beginSchema_); - } - if (!payload_.isEmpty()) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(4, payload_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; + /** + * string schema = 3; + * @param value The schema to set. + * @return This builder for chaining. + */ + public Builder setSchema( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + schema_ = value; + onChanged(); + return this; } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.TxnMergedToken)) { - return super.equals(obj); - } - com.aliyun.polardbx.binlog.protocol.TxnMergedToken other = - (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) obj; - - if (!getTso() - .equals(other.getTso())) { - return false; - } - if (type_ != other.type_) { - return false; - } - if (!getBeginSchema() - .equals(other.getBeginSchema())) { - return false; - } - if (!getPayload() - .equals(other.getPayload())) { - return false; - } - if (!unknownFields.equals(other.unknownFields)) { - return false; - } - return true; + /** + * string schema = 3; + * @return This builder for chaining. + */ + public Builder clearSchema() { + + schema_ = getDefaultInstance().getSchema(); + onChanged(); + return this; } - + /** + * string schema = 3; + * @param value The bytes for schema to set. + * @return This builder for chaining. + */ + public Builder setSchemaBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + schema_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString payload_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes payload = 4; + * @return The payload. + */ @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + TSO_FIELD_NUMBER; - hash = (53 * hash) + getTso().hashCode(); - hash = (37 * hash) + TYPE_FIELD_NUMBER; - hash = (53 * hash) + type_; - hash = (37 * hash) + BEGINSCHEMA_FIELD_NUMBER; - hash = (53 * hash) + getBeginSchema().hashCode(); - hash = (37 * hash) + PAYLOAD_FIELD_NUMBER; - hash = (53 * hash) + getPayload().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + public com.google.protobuf.ByteString getPayload() { + return payload_; } - - public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); + /** + * bytes payload = 4; + * @param value The payload to set. + * @return This builder for chaining. + */ + public Builder setPayload(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + payload_ = value; + onChanged(); + return this; } - - public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + /** + * bytes payload = 4; + * @return This builder for chaining. + */ + public Builder clearPayload() { + + payload_ = getDefaultInstance().getPayload(); + onChanged(); + return this; } - public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + private java.lang.Object table_ = ""; + /** + * string table = 5; + * @return The table. + */ + public java.lang.String getTable() { + java.lang.Object ref = table_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + table_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - - public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + /** + * string table = 5; + * @return The bytes for table. + */ + public com.google.protobuf.ByteString + getTableBytes() { + java.lang.Object ref = table_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + table_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); + /** + * string table = 5; + * @param value The table to set. + * @return This builder for chaining. + */ + public Builder setTable( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + table_ = value; + onChanged(); + return this; } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); + /** + * string table = 5; + * @return This builder for chaining. + */ + public Builder clearTable() { + + table_ = getDefaultInstance().getTable(); + onChanged(); + return this; } - - public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.TxnMergedToken prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + /** + * string table = 5; + * @param value The bytes for table to set. + * @return This builder for chaining. + */ + public Builder setTableBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + table_ = value; + onChanged(); + return this; } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); } @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - /** - * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnMergedToken} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.TxnMergedToken) - com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMergedToken_descriptor; - } - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMergedToken_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.aliyun.polardbx.binlog.protocol.TxnMergedToken.class, - com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder.class); - } + // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.TxnMergedToken) + } - // Construct using com.aliyun.polardbx.binlog.protocol.TxnMergedToken.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } + // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.TxnMergedToken) + private static final com.aliyun.polardbx.binlog.protocol.TxnMergedToken DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.TxnMergedToken(); + } - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } + public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken getDefaultInstance() { + return DEFAULT_INSTANCE; + } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - @java.lang.Override - public Builder clear() { - super.clear(); - tso_ = ""; - - type_ = 0; - - beginSchema_ = ""; - - payload_ = com.google.protobuf.ByteString.EMPTY; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMergedToken_descriptor; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnMergedToken getDefaultInstanceForType() { - return com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnMergedToken build() { - com.aliyun.polardbx.binlog.protocol.TxnMergedToken result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnMergedToken buildPartial() { - com.aliyun.polardbx.binlog.protocol.TxnMergedToken result = - new com.aliyun.polardbx.binlog.protocol.TxnMergedToken(this); - result.tso_ = tso_; - result.type_ = type_; - result.beginSchema_ = beginSchema_; - result.payload_ = payload_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.aliyun.polardbx.binlog.protocol.TxnMergedToken) { - return mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnMergedToken) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.TxnMergedToken other) { - if (other == com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance()) { - return this; - } - if (!other.getTso().isEmpty()) { - tso_ = other.tso_; - onChanged(); - } - if (other.type_ != 0) { - setTypeValue(other.getTypeValue()); - } - if (!other.getBeginSchema().isEmpty()) { - beginSchema_ = other.beginSchema_; - onChanged(); - } - if (other.getPayload() != com.google.protobuf.ByteString.EMPTY) { - setPayload(other.getPayload()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.aliyun.polardbx.binlog.protocol.TxnMergedToken parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object tso_ = ""; - - /** - * string tso = 1; - * - * @return The tso. - */ - public java.lang.String getTso() { - java.lang.Object ref = tso_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - tso_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * string tso = 1; - * - * @return The bytes for tso. - */ - public com.google.protobuf.ByteString - getTsoBytes() { - java.lang.Object ref = tso_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - tso_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string tso = 1; - * - * @param value The tso to set. - * @return This builder for chaining. - */ - public Builder setTso( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - tso_ = value; - onChanged(); - return this; - } - - /** - * string tso = 1; - * - * @return This builder for chaining. - */ - public Builder clearTso() { - - tso_ = getDefaultInstance().getTso(); - onChanged(); - return this; - } - - /** - * string tso = 1; - * - * @param value The bytes for tso to set. - * @return This builder for chaining. - */ - public Builder setTsoBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - tso_ = value; - onChanged(); - return this; - } - - private int type_ = 0; - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnType type = 2; - * - * @return The enum numeric value on the wire for type. - */ - @java.lang.Override - public int getTypeValue() { - return type_; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnType type = 2; - * - * @param value The enum numeric value on the wire for type to set. - * @return This builder for chaining. - */ - public Builder setTypeValue(int value) { - - type_ = value; - onChanged(); - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnType type = 2; - * - * @return The type. - */ - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnType getType() { - @SuppressWarnings("deprecation") - com.aliyun.polardbx.binlog.protocol.TxnType result = - com.aliyun.polardbx.binlog.protocol.TxnType.valueOf(type_); - return result == null ? com.aliyun.polardbx.binlog.protocol.TxnType.UNRECOGNIZED : result; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnType type = 2; - * - * @param value The type to set. - * @return This builder for chaining. - */ - public Builder setType(com.aliyun.polardbx.binlog.protocol.TxnType value) { - if (value == null) { - throw new NullPointerException(); - } - - type_ = value.getNumber(); - onChanged(); - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnType type = 2; - * - * @return This builder for chaining. - */ - public Builder clearType() { - - type_ = 0; - onChanged(); - return this; - } - - private java.lang.Object beginSchema_ = ""; - - /** - * string beginSchema = 3; - * - * @return The beginSchema. - */ - public java.lang.String getBeginSchema() { - java.lang.Object ref = beginSchema_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - beginSchema_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * string beginSchema = 3; - * - * @return The bytes for beginSchema. - */ - public com.google.protobuf.ByteString - getBeginSchemaBytes() { - java.lang.Object ref = beginSchema_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - beginSchema_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string beginSchema = 3; - * - * @param value The beginSchema to set. - * @return This builder for chaining. - */ - public Builder setBeginSchema( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - beginSchema_ = value; - onChanged(); - return this; - } - - /** - * string beginSchema = 3; - * - * @return This builder for chaining. - */ - public Builder clearBeginSchema() { - - beginSchema_ = getDefaultInstance().getBeginSchema(); - onChanged(); - return this; - } - - /** - * string beginSchema = 3; - * - * @param value The bytes for beginSchema to set. - * @return This builder for chaining. - */ - public Builder setBeginSchemaBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - beginSchema_ = value; - onChanged(); - return this; - } - - private com.google.protobuf.ByteString payload_ = com.google.protobuf.ByteString.EMPTY; - - /** - * bytes payload = 4; - * - * @return The payload. - */ - @java.lang.Override - public com.google.protobuf.ByteString getPayload() { - return payload_; - } - - /** - * bytes payload = 4; - * - * @param value The payload to set. - * @return This builder for chaining. - */ - public Builder setPayload(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - - payload_ = value; - onChanged(); - return this; - } - - /** - * bytes payload = 4; - * - * @return This builder for chaining. - */ - public Builder clearPayload() { - - payload_ = getDefaultInstance().getPayload(); - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.TxnMergedToken) - } - - // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.TxnMergedToken) - private static final com.aliyun.polardbx.binlog.protocol.TxnMergedToken DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.TxnMergedToken(); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMergedToken getDefaultInstance() { - return DEFAULT_INSTANCE; + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public TxnMergedToken parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TxnMergedToken(input, extensionRegistry); } + }; - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public TxnMergedToken parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new TxnMergedToken(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } + public static com.google.protobuf.Parser parser() { + return PARSER; + } - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnMergedToken getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnMergedToken getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnMergedTokenOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnMergedTokenOrBuilder.java index c3a3ba9a..0d13115f 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnMergedTokenOrBuilder.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnMergedTokenOrBuilder.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -24,54 +7,56 @@ public interface TxnMergedTokenOrBuilder extends // @@protoc_insertion_point(interface_extends:com.aliyun.polardbx.binlog.protocol.TxnMergedToken) com.google.protobuf.MessageOrBuilder { - /** - * string tso = 1; - * - * @return The tso. - */ - java.lang.String getTso(); - - /** - * string tso = 1; - * - * @return The bytes for tso. - */ - com.google.protobuf.ByteString - getTsoBytes(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnType type = 2; - * - * @return The enum numeric value on the wire for type. - */ - int getTypeValue(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnType type = 2; - * - * @return The type. - */ - com.aliyun.polardbx.binlog.protocol.TxnType getType(); - - /** - * string beginSchema = 3; - * - * @return The beginSchema. - */ - java.lang.String getBeginSchema(); - - /** - * string beginSchema = 3; - * - * @return The bytes for beginSchema. - */ - com.google.protobuf.ByteString - getBeginSchemaBytes(); - - /** - * bytes payload = 4; - * - * @return The payload. - */ - com.google.protobuf.ByteString getPayload(); + /** + * string tso = 1; + * @return The tso. + */ + java.lang.String getTso(); + /** + * string tso = 1; + * @return The bytes for tso. + */ + com.google.protobuf.ByteString + getTsoBytes(); + + /** + * .com.aliyun.polardbx.binlog.protocol.TxnType type = 2; + * @return The enum numeric value on the wire for type. + */ + int getTypeValue(); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnType type = 2; + * @return The type. + */ + com.aliyun.polardbx.binlog.protocol.TxnType getType(); + + /** + * string schema = 3; + * @return The schema. + */ + java.lang.String getSchema(); + /** + * string schema = 3; + * @return The bytes for schema. + */ + com.google.protobuf.ByteString + getSchemaBytes(); + + /** + * bytes payload = 4; + * @return The payload. + */ + com.google.protobuf.ByteString getPayload(); + + /** + * string table = 5; + * @return The table. + */ + java.lang.String getTable(); + /** + * string table = 5; + * @return The bytes for table. + */ + com.google.protobuf.ByteString + getTableBytes(); } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnMessage.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnMessage.java index 0980a022..94ff1fdf 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnMessage.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnMessage.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -27,1412 +10,1258 @@ public final class TxnMessage extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:com.aliyun.polardbx.binlog.protocol.TxnMessage) TxnMessageOrBuilder { - private static final long serialVersionUID = 0L; +private static final long serialVersionUID = 0L; + // Use TxnMessage.newBuilder() to construct. + private TxnMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TxnMessage() { + type_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new TxnMessage(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TxnMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 8: { + int rawValue = input.readEnum(); + + type_ = rawValue; + break; + } + case 18: { + com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder subBuilder = null; + if (txnBegin_ != null) { + subBuilder = txnBegin_.toBuilder(); + } + txnBegin_ = input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnBegin.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(txnBegin_); + txnBegin_ = subBuilder.buildPartial(); + } + + break; + } + case 26: { + com.aliyun.polardbx.binlog.protocol.TxnData.Builder subBuilder = null; + if (txnData_ != null) { + subBuilder = txnData_.toBuilder(); + } + txnData_ = input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnData.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(txnData_); + txnData_ = subBuilder.buildPartial(); + } + + break; + } + case 34: { + com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder subBuilder = null; + if (txnEnd_ != null) { + subBuilder = txnEnd_.toBuilder(); + } + txnEnd_ = input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnEnd.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(txnEnd_); + txnEnd_ = subBuilder.buildPartial(); + } + + break; + } + case 42: { + com.aliyun.polardbx.binlog.protocol.TxnTag.Builder subBuilder = null; + if (txnTag_ != null) { + subBuilder = txnTag_.toBuilder(); + } + txnTag_ = input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnTag.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(txnTag_); + txnTag_ = subBuilder.buildPartial(); + } + + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.binlog.protocol.TxnMessage.class, com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder.class); + } + + public static final int TYPE_FIELD_NUMBER = 1; + private int type_; + /** + * .com.aliyun.polardbx.binlog.protocol.MessageType type = 1; + * @return The enum numeric value on the wire for type. + */ + @java.lang.Override public int getTypeValue() { + return type_; + } + /** + * .com.aliyun.polardbx.binlog.protocol.MessageType type = 1; + * @return The type. + */ + @java.lang.Override public com.aliyun.polardbx.binlog.protocol.MessageType getType() { + @SuppressWarnings("deprecation") + com.aliyun.polardbx.binlog.protocol.MessageType result = com.aliyun.polardbx.binlog.protocol.MessageType.valueOf(type_); + return result == null ? com.aliyun.polardbx.binlog.protocol.MessageType.UNRECOGNIZED : result; + } + + public static final int TXNBEGIN_FIELD_NUMBER = 2; + private com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin_; + /** + * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; + * @return Whether the txnBegin field is set. + */ + @java.lang.Override + public boolean hasTxnBegin() { + return txnBegin_ != null; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; + * @return The txnBegin. + */ + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnBegin getTxnBegin() { + return txnBegin_ == null ? com.aliyun.polardbx.binlog.protocol.TxnBegin.getDefaultInstance() : txnBegin_; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; + */ + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnBeginOrBuilder getTxnBeginOrBuilder() { + return getTxnBegin(); + } + + public static final int TXNDATA_FIELD_NUMBER = 3; + private com.aliyun.polardbx.binlog.protocol.TxnData txnData_; + /** + * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; + * @return Whether the txnData field is set. + */ + @java.lang.Override + public boolean hasTxnData() { + return txnData_ != null; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; + * @return The txnData. + */ + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnData getTxnData() { + return txnData_ == null ? com.aliyun.polardbx.binlog.protocol.TxnData.getDefaultInstance() : txnData_; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; + */ + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnDataOrBuilder getTxnDataOrBuilder() { + return getTxnData(); + } + + public static final int TXNEND_FIELD_NUMBER = 4; + private com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd_; + /** + * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; + * @return Whether the txnEnd field is set. + */ + @java.lang.Override + public boolean hasTxnEnd() { + return txnEnd_ != null; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; + * @return The txnEnd. + */ + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnEnd getTxnEnd() { + return txnEnd_ == null ? com.aliyun.polardbx.binlog.protocol.TxnEnd.getDefaultInstance() : txnEnd_; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; + */ + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnEndOrBuilder getTxnEndOrBuilder() { + return getTxnEnd(); + } + + public static final int TXNTAG_FIELD_NUMBER = 5; + private com.aliyun.polardbx.binlog.protocol.TxnTag txnTag_; + /** + * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; + * @return Whether the txnTag field is set. + */ + @java.lang.Override + public boolean hasTxnTag() { + return txnTag_ != null; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; + * @return The txnTag. + */ + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnTag getTxnTag() { + return txnTag_ == null ? com.aliyun.polardbx.binlog.protocol.TxnTag.getDefaultInstance() : txnTag_; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; + */ + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnTagOrBuilder getTxnTagOrBuilder() { + return getTxnTag(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (type_ != com.aliyun.polardbx.binlog.protocol.MessageType.WHOLE.getNumber()) { + output.writeEnum(1, type_); + } + if (txnBegin_ != null) { + output.writeMessage(2, getTxnBegin()); + } + if (txnData_ != null) { + output.writeMessage(3, getTxnData()); + } + if (txnEnd_ != null) { + output.writeMessage(4, getTxnEnd()); + } + if (txnTag_ != null) { + output.writeMessage(5, getTxnTag()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (type_ != com.aliyun.polardbx.binlog.protocol.MessageType.WHOLE.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(1, type_); + } + if (txnBegin_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getTxnBegin()); + } + if (txnData_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, getTxnData()); + } + if (txnEnd_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, getTxnEnd()); + } + if (txnTag_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, getTxnTag()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.TxnMessage)) { + return super.equals(obj); + } + com.aliyun.polardbx.binlog.protocol.TxnMessage other = (com.aliyun.polardbx.binlog.protocol.TxnMessage) obj; + + if (type_ != other.type_) return false; + if (hasTxnBegin() != other.hasTxnBegin()) return false; + if (hasTxnBegin()) { + if (!getTxnBegin() + .equals(other.getTxnBegin())) return false; + } + if (hasTxnData() != other.hasTxnData()) return false; + if (hasTxnData()) { + if (!getTxnData() + .equals(other.getTxnData())) return false; + } + if (hasTxnEnd() != other.hasTxnEnd()) return false; + if (hasTxnEnd()) { + if (!getTxnEnd() + .equals(other.getTxnEnd())) return false; + } + if (hasTxnTag() != other.hasTxnTag()) return false; + if (hasTxnTag()) { + if (!getTxnTag() + .equals(other.getTxnTag())) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + type_; + if (hasTxnBegin()) { + hash = (37 * hash) + TXNBEGIN_FIELD_NUMBER; + hash = (53 * hash) + getTxnBegin().hashCode(); + } + if (hasTxnData()) { + hash = (37 * hash) + TXNDATA_FIELD_NUMBER; + hash = (53 * hash) + getTxnData().hashCode(); + } + if (hasTxnEnd()) { + hash = (37 * hash) + TXNEND_FIELD_NUMBER; + hash = (53 * hash) + getTxnEnd().hashCode(); + } + if (hasTxnTag()) { + hash = (37 * hash) + TXNTAG_FIELD_NUMBER; + hash = (53 * hash) + getTxnTag().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.TxnMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.TxnMessage) + com.aliyun.polardbx.binlog.protocol.TxnMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.binlog.protocol.TxnMessage.class, com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder.class); + } - // Use TxnMessage.newBuilder() to construct. - private TxnMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); + // Construct using com.aliyun.polardbx.binlog.protocol.TxnMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); } - private TxnMessage() { - type_ = 0; + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + type_ = 0; + + if (txnBeginBuilder_ == null) { + txnBegin_ = null; + } else { + txnBegin_ = null; + txnBeginBuilder_ = null; + } + if (txnDataBuilder_ == null) { + txnData_ = null; + } else { + txnData_ = null; + txnDataBuilder_ = null; + } + if (txnEndBuilder_ == null) { + txnEnd_ = null; + } else { + txnEnd_ = null; + txnEndBuilder_ = null; + } + if (txnTagBuilder_ == null) { + txnTag_ = null; + } else { + txnTag_ = null; + txnTagBuilder_ = null; + } + return this; } @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new TxnMessage(); + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_descriptor; } @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; + public com.aliyun.polardbx.binlog.protocol.TxnMessage getDefaultInstanceForType() { + return com.aliyun.polardbx.binlog.protocol.TxnMessage.getDefaultInstance(); } - private TxnMessage( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - 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; - case 8: { - int rawValue = input.readEnum(); - - type_ = rawValue; - break; - } - case 18: { - com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder subBuilder = null; - if (txnBegin_ != null) { - subBuilder = txnBegin_.toBuilder(); - } - txnBegin_ = - input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnBegin.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(txnBegin_); - txnBegin_ = subBuilder.buildPartial(); - } - - break; - } - case 26: { - com.aliyun.polardbx.binlog.protocol.TxnData.Builder subBuilder = null; - if (txnData_ != null) { - subBuilder = txnData_.toBuilder(); - } - txnData_ = - input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnData.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(txnData_); - txnData_ = subBuilder.buildPartial(); - } - - break; - } - case 34: { - com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder subBuilder = null; - if (txnEnd_ != null) { - subBuilder = txnEnd_.toBuilder(); - } - txnEnd_ = input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnEnd.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(txnEnd_); - txnEnd_ = subBuilder.buildPartial(); - } - - break; - } - case 42: { - com.aliyun.polardbx.binlog.protocol.TxnTag.Builder subBuilder = null; - if (txnTag_ != null) { - subBuilder = txnTag_.toBuilder(); - } - txnTag_ = input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnTag.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(txnTag_); - txnTag_ = subBuilder.buildPartial(); - } - - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnMessage build() { + com.aliyun.polardbx.binlog.protocol.TxnMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_descriptor; + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnMessage buildPartial() { + com.aliyun.polardbx.binlog.protocol.TxnMessage result = new com.aliyun.polardbx.binlog.protocol.TxnMessage(this); + result.type_ = type_; + if (txnBeginBuilder_ == null) { + result.txnBegin_ = txnBegin_; + } else { + result.txnBegin_ = txnBeginBuilder_.build(); + } + if (txnDataBuilder_ == null) { + result.txnData_ = txnData_; + } else { + result.txnData_ = txnDataBuilder_.build(); + } + if (txnEndBuilder_ == null) { + result.txnEnd_ = txnEnd_; + } else { + result.txnEnd_ = txnEndBuilder_.build(); + } + if (txnTagBuilder_ == null) { + result.txnTag_ = txnTag_; + } else { + result.txnTag_ = txnTagBuilder_.build(); + } + onBuilt(); + return result; } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.aliyun.polardbx.binlog.protocol.TxnMessage.class, - com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder.class); + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.binlog.protocol.TxnMessage) { + return mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.TxnMessage other) { + if (other == com.aliyun.polardbx.binlog.protocol.TxnMessage.getDefaultInstance()) return this; + if (other.type_ != 0) { + setTypeValue(other.getTypeValue()); + } + if (other.hasTxnBegin()) { + mergeTxnBegin(other.getTxnBegin()); + } + if (other.hasTxnData()) { + mergeTxnData(other.getTxnData()); + } + if (other.hasTxnEnd()) { + mergeTxnEnd(other.getTxnEnd()); + } + if (other.hasTxnTag()) { + mergeTxnTag(other.getTxnTag()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; } - public static final int TYPE_FIELD_NUMBER = 1; - private int type_; + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.aliyun.polardbx.binlog.protocol.TxnMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.binlog.protocol.TxnMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int type_ = 0; /** * .com.aliyun.polardbx.binlog.protocol.MessageType type = 1; - * * @return The enum numeric value on the wire for type. */ - @java.lang.Override - public int getTypeValue() { - return type_; + @java.lang.Override public int getTypeValue() { + return type_; + } + /** + * .com.aliyun.polardbx.binlog.protocol.MessageType type = 1; + * @param value The enum numeric value on the wire for type to set. + * @return This builder for chaining. + */ + public Builder setTypeValue(int value) { + + type_ = value; + onChanged(); + return this; } - /** * .com.aliyun.polardbx.binlog.protocol.MessageType type = 1; - * * @return The type. */ @java.lang.Override public com.aliyun.polardbx.binlog.protocol.MessageType getType() { - @SuppressWarnings("deprecation") - com.aliyun.polardbx.binlog.protocol.MessageType result = - com.aliyun.polardbx.binlog.protocol.MessageType.valueOf(type_); - return result == null ? com.aliyun.polardbx.binlog.protocol.MessageType.UNRECOGNIZED : result; + @SuppressWarnings("deprecation") + com.aliyun.polardbx.binlog.protocol.MessageType result = com.aliyun.polardbx.binlog.protocol.MessageType.valueOf(type_); + return result == null ? com.aliyun.polardbx.binlog.protocol.MessageType.UNRECOGNIZED : result; + } + /** + * .com.aliyun.polardbx.binlog.protocol.MessageType type = 1; + * @param value The type to set. + * @return This builder for chaining. + */ + public Builder setType(com.aliyun.polardbx.binlog.protocol.MessageType value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.MessageType type = 1; + * @return This builder for chaining. + */ + public Builder clearType() { + + type_ = 0; + onChanged(); + return this; } - public static final int TXNBEGIN_FIELD_NUMBER = 2; private com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin_; - + private com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnBegin, com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder, com.aliyun.polardbx.binlog.protocol.TxnBeginOrBuilder> txnBeginBuilder_; /** * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; - * * @return Whether the txnBegin field is set. */ - @java.lang.Override public boolean hasTxnBegin() { - return txnBegin_ != null; + return txnBeginBuilder_ != null || txnBegin_ != null; } - /** * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; - * * @return The txnBegin. */ - @java.lang.Override public com.aliyun.polardbx.binlog.protocol.TxnBegin getTxnBegin() { + if (txnBeginBuilder_ == null) { return txnBegin_ == null ? com.aliyun.polardbx.binlog.protocol.TxnBegin.getDefaultInstance() : txnBegin_; + } else { + return txnBeginBuilder_.getMessage(); + } + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; + */ + public Builder setTxnBegin(com.aliyun.polardbx.binlog.protocol.TxnBegin value) { + if (txnBeginBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + txnBegin_ = value; + onChanged(); + } else { + txnBeginBuilder_.setMessage(value); + } + + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; + */ + public Builder setTxnBegin( + com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder builderForValue) { + if (txnBeginBuilder_ == null) { + txnBegin_ = builderForValue.build(); + onChanged(); + } else { + txnBeginBuilder_.setMessage(builderForValue.build()); + } + + return this; } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; + */ + public Builder mergeTxnBegin(com.aliyun.polardbx.binlog.protocol.TxnBegin value) { + if (txnBeginBuilder_ == null) { + if (txnBegin_ != null) { + txnBegin_ = + com.aliyun.polardbx.binlog.protocol.TxnBegin.newBuilder(txnBegin_).mergeFrom(value).buildPartial(); + } else { + txnBegin_ = value; + } + onChanged(); + } else { + txnBeginBuilder_.mergeFrom(value); + } + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; + */ + public Builder clearTxnBegin() { + if (txnBeginBuilder_ == null) { + txnBegin_ = null; + onChanged(); + } else { + txnBegin_ = null; + txnBeginBuilder_ = null; + } + + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; + */ + public com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder getTxnBeginBuilder() { + + onChanged(); + return getTxnBeginFieldBuilder().getBuilder(); + } /** * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; */ - @java.lang.Override public com.aliyun.polardbx.binlog.protocol.TxnBeginOrBuilder getTxnBeginOrBuilder() { - return getTxnBegin(); + if (txnBeginBuilder_ != null) { + return txnBeginBuilder_.getMessageOrBuilder(); + } else { + return txnBegin_ == null ? + com.aliyun.polardbx.binlog.protocol.TxnBegin.getDefaultInstance() : txnBegin_; + } + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnBegin, com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder, com.aliyun.polardbx.binlog.protocol.TxnBeginOrBuilder> + getTxnBeginFieldBuilder() { + if (txnBeginBuilder_ == null) { + txnBeginBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnBegin, com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder, com.aliyun.polardbx.binlog.protocol.TxnBeginOrBuilder>( + getTxnBegin(), + getParentForChildren(), + isClean()); + txnBegin_ = null; + } + return txnBeginBuilder_; } - public static final int TXNDATA_FIELD_NUMBER = 3; private com.aliyun.polardbx.binlog.protocol.TxnData txnData_; - + private com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnData, com.aliyun.polardbx.binlog.protocol.TxnData.Builder, com.aliyun.polardbx.binlog.protocol.TxnDataOrBuilder> txnDataBuilder_; /** * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; - * * @return Whether the txnData field is set. */ - @java.lang.Override public boolean hasTxnData() { - return txnData_ != null; + return txnDataBuilder_ != null || txnData_ != null; } - /** * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; - * * @return The txnData. */ - @java.lang.Override public com.aliyun.polardbx.binlog.protocol.TxnData getTxnData() { + if (txnDataBuilder_ == null) { return txnData_ == null ? com.aliyun.polardbx.binlog.protocol.TxnData.getDefaultInstance() : txnData_; + } else { + return txnDataBuilder_.getMessage(); + } + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; + */ + public Builder setTxnData(com.aliyun.polardbx.binlog.protocol.TxnData value) { + if (txnDataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + txnData_ = value; + onChanged(); + } else { + txnDataBuilder_.setMessage(value); + } + + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; + */ + public Builder setTxnData( + com.aliyun.polardbx.binlog.protocol.TxnData.Builder builderForValue) { + if (txnDataBuilder_ == null) { + txnData_ = builderForValue.build(); + onChanged(); + } else { + txnDataBuilder_.setMessage(builderForValue.build()); + } + + return this; } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; + */ + public Builder mergeTxnData(com.aliyun.polardbx.binlog.protocol.TxnData value) { + if (txnDataBuilder_ == null) { + if (txnData_ != null) { + txnData_ = + com.aliyun.polardbx.binlog.protocol.TxnData.newBuilder(txnData_).mergeFrom(value).buildPartial(); + } else { + txnData_ = value; + } + onChanged(); + } else { + txnDataBuilder_.mergeFrom(value); + } + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; + */ + public Builder clearTxnData() { + if (txnDataBuilder_ == null) { + txnData_ = null; + onChanged(); + } else { + txnData_ = null; + txnDataBuilder_ = null; + } + + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; + */ + public com.aliyun.polardbx.binlog.protocol.TxnData.Builder getTxnDataBuilder() { + + onChanged(); + return getTxnDataFieldBuilder().getBuilder(); + } /** * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; */ - @java.lang.Override public com.aliyun.polardbx.binlog.protocol.TxnDataOrBuilder getTxnDataOrBuilder() { - return getTxnData(); + if (txnDataBuilder_ != null) { + return txnDataBuilder_.getMessageOrBuilder(); + } else { + return txnData_ == null ? + com.aliyun.polardbx.binlog.protocol.TxnData.getDefaultInstance() : txnData_; + } + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnData, com.aliyun.polardbx.binlog.protocol.TxnData.Builder, com.aliyun.polardbx.binlog.protocol.TxnDataOrBuilder> + getTxnDataFieldBuilder() { + if (txnDataBuilder_ == null) { + txnDataBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnData, com.aliyun.polardbx.binlog.protocol.TxnData.Builder, com.aliyun.polardbx.binlog.protocol.TxnDataOrBuilder>( + getTxnData(), + getParentForChildren(), + isClean()); + txnData_ = null; + } + return txnDataBuilder_; } - public static final int TXNEND_FIELD_NUMBER = 4; private com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd_; - + private com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnEnd, com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder, com.aliyun.polardbx.binlog.protocol.TxnEndOrBuilder> txnEndBuilder_; /** * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; - * * @return Whether the txnEnd field is set. */ - @java.lang.Override public boolean hasTxnEnd() { - return txnEnd_ != null; + return txnEndBuilder_ != null || txnEnd_ != null; } - /** * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; - * * @return The txnEnd. */ - @java.lang.Override public com.aliyun.polardbx.binlog.protocol.TxnEnd getTxnEnd() { + if (txnEndBuilder_ == null) { return txnEnd_ == null ? com.aliyun.polardbx.binlog.protocol.TxnEnd.getDefaultInstance() : txnEnd_; + } else { + return txnEndBuilder_.getMessage(); + } + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; + */ + public Builder setTxnEnd(com.aliyun.polardbx.binlog.protocol.TxnEnd value) { + if (txnEndBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + txnEnd_ = value; + onChanged(); + } else { + txnEndBuilder_.setMessage(value); + } + + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; + */ + public Builder setTxnEnd( + com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder builderForValue) { + if (txnEndBuilder_ == null) { + txnEnd_ = builderForValue.build(); + onChanged(); + } else { + txnEndBuilder_.setMessage(builderForValue.build()); + } + + return this; } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; + */ + public Builder mergeTxnEnd(com.aliyun.polardbx.binlog.protocol.TxnEnd value) { + if (txnEndBuilder_ == null) { + if (txnEnd_ != null) { + txnEnd_ = + com.aliyun.polardbx.binlog.protocol.TxnEnd.newBuilder(txnEnd_).mergeFrom(value).buildPartial(); + } else { + txnEnd_ = value; + } + onChanged(); + } else { + txnEndBuilder_.mergeFrom(value); + } + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; + */ + public Builder clearTxnEnd() { + if (txnEndBuilder_ == null) { + txnEnd_ = null; + onChanged(); + } else { + txnEnd_ = null; + txnEndBuilder_ = null; + } + + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; + */ + public com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder getTxnEndBuilder() { + + onChanged(); + return getTxnEndFieldBuilder().getBuilder(); + } /** * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; */ - @java.lang.Override public com.aliyun.polardbx.binlog.protocol.TxnEndOrBuilder getTxnEndOrBuilder() { - return getTxnEnd(); + if (txnEndBuilder_ != null) { + return txnEndBuilder_.getMessageOrBuilder(); + } else { + return txnEnd_ == null ? + com.aliyun.polardbx.binlog.protocol.TxnEnd.getDefaultInstance() : txnEnd_; + } + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnEnd, com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder, com.aliyun.polardbx.binlog.protocol.TxnEndOrBuilder> + getTxnEndFieldBuilder() { + if (txnEndBuilder_ == null) { + txnEndBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnEnd, com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder, com.aliyun.polardbx.binlog.protocol.TxnEndOrBuilder>( + getTxnEnd(), + getParentForChildren(), + isClean()); + txnEnd_ = null; + } + return txnEndBuilder_; } - public static final int TXNTAG_FIELD_NUMBER = 5; private com.aliyun.polardbx.binlog.protocol.TxnTag txnTag_; - + private com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnTag, com.aliyun.polardbx.binlog.protocol.TxnTag.Builder, com.aliyun.polardbx.binlog.protocol.TxnTagOrBuilder> txnTagBuilder_; /** * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; - * * @return Whether the txnTag field is set. */ - @java.lang.Override public boolean hasTxnTag() { - return txnTag_ != null; + return txnTagBuilder_ != null || txnTag_ != null; } - /** * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; - * * @return The txnTag. */ - @java.lang.Override public com.aliyun.polardbx.binlog.protocol.TxnTag getTxnTag() { + if (txnTagBuilder_ == null) { return txnTag_ == null ? com.aliyun.polardbx.binlog.protocol.TxnTag.getDefaultInstance() : txnTag_; + } else { + return txnTagBuilder_.getMessage(); + } + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; + */ + public Builder setTxnTag(com.aliyun.polardbx.binlog.protocol.TxnTag value) { + if (txnTagBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + txnTag_ = value; + onChanged(); + } else { + txnTagBuilder_.setMessage(value); + } + + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; + */ + public Builder setTxnTag( + com.aliyun.polardbx.binlog.protocol.TxnTag.Builder builderForValue) { + if (txnTagBuilder_ == null) { + txnTag_ = builderForValue.build(); + onChanged(); + } else { + txnTagBuilder_.setMessage(builderForValue.build()); + } + + return this; } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; + */ + public Builder mergeTxnTag(com.aliyun.polardbx.binlog.protocol.TxnTag value) { + if (txnTagBuilder_ == null) { + if (txnTag_ != null) { + txnTag_ = + com.aliyun.polardbx.binlog.protocol.TxnTag.newBuilder(txnTag_).mergeFrom(value).buildPartial(); + } else { + txnTag_ = value; + } + onChanged(); + } else { + txnTagBuilder_.mergeFrom(value); + } + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; + */ + public Builder clearTxnTag() { + if (txnTagBuilder_ == null) { + txnTag_ = null; + onChanged(); + } else { + txnTag_ = null; + txnTagBuilder_ = null; + } + + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; + */ + public com.aliyun.polardbx.binlog.protocol.TxnTag.Builder getTxnTagBuilder() { + + onChanged(); + return getTxnTagFieldBuilder().getBuilder(); + } /** * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; */ - @java.lang.Override public com.aliyun.polardbx.binlog.protocol.TxnTagOrBuilder getTxnTagOrBuilder() { - return getTxnTag(); + if (txnTagBuilder_ != null) { + return txnTagBuilder_.getMessageOrBuilder(); + } else { + return txnTag_ == null ? + com.aliyun.polardbx.binlog.protocol.TxnTag.getDefaultInstance() : txnTag_; + } + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnTag, com.aliyun.polardbx.binlog.protocol.TxnTag.Builder, com.aliyun.polardbx.binlog.protocol.TxnTagOrBuilder> + getTxnTagFieldBuilder() { + if (txnTagBuilder_ == null) { + txnTagBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnTag, com.aliyun.polardbx.binlog.protocol.TxnTag.Builder, com.aliyun.polardbx.binlog.protocol.TxnTagOrBuilder>( + getTxnTag(), + getParentForChildren(), + isClean()); + txnTag_ = null; + } + return txnTagBuilder_; } - - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } - - memoizedIsInitialized = 1; - return true; + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); } @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (type_ != com.aliyun.polardbx.binlog.protocol.MessageType.WHOLE.getNumber()) { - output.writeEnum(1, type_); - } - if (txnBegin_ != null) { - output.writeMessage(2, getTxnBegin()); - } - if (txnData_ != null) { - output.writeMessage(3, getTxnData()); - } - if (txnEnd_ != null) { - output.writeMessage(4, getTxnEnd()); - } - if (txnTag_ != null) { - output.writeMessage(5, getTxnTag()); - } - unknownFields.writeTo(output); + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) { - return size; - } - size = 0; - if (type_ != com.aliyun.polardbx.binlog.protocol.MessageType.WHOLE.getNumber()) { - size += com.google.protobuf.CodedOutputStream - .computeEnumSize(1, type_); - } - if (txnBegin_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(2, getTxnBegin()); - } - if (txnData_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, getTxnData()); - } - if (txnEnd_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(4, getTxnEnd()); - } - if (txnTag_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(5, getTxnTag()); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } + // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.TxnMessage) + } - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.TxnMessage)) { - return super.equals(obj); - } - com.aliyun.polardbx.binlog.protocol.TxnMessage other = (com.aliyun.polardbx.binlog.protocol.TxnMessage) obj; + // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.TxnMessage) + private static final com.aliyun.polardbx.binlog.protocol.TxnMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.TxnMessage(); + } - if (type_ != other.type_) { - return false; - } - if (hasTxnBegin() != other.hasTxnBegin()) { - return false; - } - if (hasTxnBegin()) { - if (!getTxnBegin() - .equals(other.getTxnBegin())) { - return false; - } - } - if (hasTxnData() != other.hasTxnData()) { - return false; - } - if (hasTxnData()) { - if (!getTxnData() - .equals(other.getTxnData())) { - return false; - } - } - if (hasTxnEnd() != other.hasTxnEnd()) { - return false; - } - if (hasTxnEnd()) { - if (!getTxnEnd() - .equals(other.getTxnEnd())) { - return false; - } - } - if (hasTxnTag() != other.hasTxnTag()) { - return false; - } - if (hasTxnTag()) { - if (!getTxnTag() - .equals(other.getTxnTag())) { - return false; - } - } - if (!unknownFields.equals(other.unknownFields)) { - return false; - } - return true; - } + public static com.aliyun.polardbx.binlog.protocol.TxnMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + TYPE_FIELD_NUMBER; - hash = (53 * hash) + type_; - if (hasTxnBegin()) { - hash = (37 * hash) + TXNBEGIN_FIELD_NUMBER; - hash = (53 * hash) + getTxnBegin().hashCode(); - } - if (hasTxnData()) { - hash = (37 * hash) + TXNDATA_FIELD_NUMBER; - hash = (53 * hash) + getTxnData().hashCode(); - } - if (hasTxnEnd()) { - hash = (37 * hash) + TXNEND_FIELD_NUMBER; - hash = (53 * hash) + getTxnEnd().hashCode(); - } - if (hasTxnTag()) { - hash = (37 * hash) + TXNTAG_FIELD_NUMBER; - hash = (53 * hash) + getTxnTag().hashCode(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMessage parseFrom( + public TxnMessage parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.TxnMessage prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - /** - * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnMessage} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.TxnMessage) - com.aliyun.polardbx.binlog.protocol.TxnMessageOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.aliyun.polardbx.binlog.protocol.TxnMessage.class, - com.aliyun.polardbx.binlog.protocol.TxnMessage.Builder.class); - } - - // Construct using com.aliyun.polardbx.binlog.protocol.TxnMessage.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - @java.lang.Override - public Builder clear() { - super.clear(); - type_ = 0; - - if (txnBeginBuilder_ == null) { - txnBegin_ = null; - } else { - txnBegin_ = null; - txnBeginBuilder_ = null; - } - if (txnDataBuilder_ == null) { - txnData_ = null; - } else { - txnData_ = null; - txnDataBuilder_ = null; - } - if (txnEndBuilder_ == null) { - txnEnd_ = null; - } else { - txnEnd_ = null; - txnEndBuilder_ = null; - } - if (txnTagBuilder_ == null) { - txnTag_ = null; - } else { - txnTag_ = null; - txnTagBuilder_ = null; - } - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_descriptor; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnMessage getDefaultInstanceForType() { - return com.aliyun.polardbx.binlog.protocol.TxnMessage.getDefaultInstance(); - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnMessage build() { - com.aliyun.polardbx.binlog.protocol.TxnMessage result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnMessage buildPartial() { - com.aliyun.polardbx.binlog.protocol.TxnMessage result = - new com.aliyun.polardbx.binlog.protocol.TxnMessage(this); - result.type_ = type_; - if (txnBeginBuilder_ == null) { - result.txnBegin_ = txnBegin_; - } else { - result.txnBegin_ = txnBeginBuilder_.build(); - } - if (txnDataBuilder_ == null) { - result.txnData_ = txnData_; - } else { - result.txnData_ = txnDataBuilder_.build(); - } - if (txnEndBuilder_ == null) { - result.txnEnd_ = txnEnd_; - } else { - result.txnEnd_ = txnEndBuilder_.build(); - } - if (txnTagBuilder_ == null) { - result.txnTag_ = txnTag_; - } else { - result.txnTag_ = txnTagBuilder_.build(); - } - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.aliyun.polardbx.binlog.protocol.TxnMessage) { - return mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnMessage) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.TxnMessage other) { - if (other == com.aliyun.polardbx.binlog.protocol.TxnMessage.getDefaultInstance()) { - return this; - } - if (other.type_ != 0) { - setTypeValue(other.getTypeValue()); - } - if (other.hasTxnBegin()) { - mergeTxnBegin(other.getTxnBegin()); - } - if (other.hasTxnData()) { - mergeTxnData(other.getTxnData()); - } - if (other.hasTxnEnd()) { - mergeTxnEnd(other.getTxnEnd()); - } - if (other.hasTxnTag()) { - mergeTxnTag(other.getTxnTag()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.aliyun.polardbx.binlog.protocol.TxnMessage parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.aliyun.polardbx.binlog.protocol.TxnMessage) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private int type_ = 0; - - /** - * .com.aliyun.polardbx.binlog.protocol.MessageType type = 1; - * - * @return The enum numeric value on the wire for type. - */ - @java.lang.Override - public int getTypeValue() { - return type_; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.MessageType type = 1; - * - * @param value The enum numeric value on the wire for type to set. - * @return This builder for chaining. - */ - public Builder setTypeValue(int value) { - - type_ = value; - onChanged(); - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.MessageType type = 1; - * - * @return The type. - */ - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.MessageType getType() { - @SuppressWarnings("deprecation") - com.aliyun.polardbx.binlog.protocol.MessageType result = - com.aliyun.polardbx.binlog.protocol.MessageType.valueOf(type_); - return result == null ? com.aliyun.polardbx.binlog.protocol.MessageType.UNRECOGNIZED : result; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.MessageType type = 1; - * - * @param value The type to set. - * @return This builder for chaining. - */ - public Builder setType(com.aliyun.polardbx.binlog.protocol.MessageType value) { - if (value == null) { - throw new NullPointerException(); - } - - type_ = value.getNumber(); - onChanged(); - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.MessageType type = 1; - * - * @return This builder for chaining. - */ - public Builder clearType() { - - type_ = 0; - onChanged(); - return this; - } - - private com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin_; - private com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnBegin, com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder, com.aliyun.polardbx.binlog.protocol.TxnBeginOrBuilder> - txnBeginBuilder_; - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; - * - * @return Whether the txnBegin field is set. - */ - public boolean hasTxnBegin() { - return txnBeginBuilder_ != null || txnBegin_ != null; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; - * - * @return The txnBegin. - */ - public com.aliyun.polardbx.binlog.protocol.TxnBegin getTxnBegin() { - if (txnBeginBuilder_ == null) { - return txnBegin_ == null ? com.aliyun.polardbx.binlog.protocol.TxnBegin.getDefaultInstance() : - txnBegin_; - } else { - return txnBeginBuilder_.getMessage(); - } - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; - */ - public Builder setTxnBegin(com.aliyun.polardbx.binlog.protocol.TxnBegin value) { - if (txnBeginBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - txnBegin_ = value; - onChanged(); - } else { - txnBeginBuilder_.setMessage(value); - } - - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; - */ - public Builder setTxnBegin( - com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder builderForValue) { - if (txnBeginBuilder_ == null) { - txnBegin_ = builderForValue.build(); - onChanged(); - } else { - txnBeginBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; - */ - public Builder mergeTxnBegin(com.aliyun.polardbx.binlog.protocol.TxnBegin value) { - if (txnBeginBuilder_ == null) { - if (txnBegin_ != null) { - txnBegin_ = - com.aliyun.polardbx.binlog.protocol.TxnBegin.newBuilder(txnBegin_).mergeFrom(value) - .buildPartial(); - } else { - txnBegin_ = value; - } - onChanged(); - } else { - txnBeginBuilder_.mergeFrom(value); - } - - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; - */ - public Builder clearTxnBegin() { - if (txnBeginBuilder_ == null) { - txnBegin_ = null; - onChanged(); - } else { - txnBegin_ = null; - txnBeginBuilder_ = null; - } - - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; - */ - public com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder getTxnBeginBuilder() { - - onChanged(); - return getTxnBeginFieldBuilder().getBuilder(); - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; - */ - public com.aliyun.polardbx.binlog.protocol.TxnBeginOrBuilder getTxnBeginOrBuilder() { - if (txnBeginBuilder_ != null) { - return txnBeginBuilder_.getMessageOrBuilder(); - } else { - return txnBegin_ == null ? - com.aliyun.polardbx.binlog.protocol.TxnBegin.getDefaultInstance() : txnBegin_; - } - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnBegin, com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder, com.aliyun.polardbx.binlog.protocol.TxnBeginOrBuilder> - getTxnBeginFieldBuilder() { - if (txnBeginBuilder_ == null) { - txnBeginBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnBegin, com.aliyun.polardbx.binlog.protocol.TxnBegin.Builder, com.aliyun.polardbx.binlog.protocol.TxnBeginOrBuilder>( - getTxnBegin(), - getParentForChildren(), - isClean()); - txnBegin_ = null; - } - return txnBeginBuilder_; - } - - private com.aliyun.polardbx.binlog.protocol.TxnData txnData_; - private com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnData, com.aliyun.polardbx.binlog.protocol.TxnData.Builder, com.aliyun.polardbx.binlog.protocol.TxnDataOrBuilder> - txnDataBuilder_; - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; - * - * @return Whether the txnData field is set. - */ - public boolean hasTxnData() { - return txnDataBuilder_ != null || txnData_ != null; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; - * - * @return The txnData. - */ - public com.aliyun.polardbx.binlog.protocol.TxnData getTxnData() { - if (txnDataBuilder_ == null) { - return txnData_ == null ? com.aliyun.polardbx.binlog.protocol.TxnData.getDefaultInstance() : txnData_; - } else { - return txnDataBuilder_.getMessage(); - } - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; - */ - public Builder setTxnData(com.aliyun.polardbx.binlog.protocol.TxnData value) { - if (txnDataBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - txnData_ = value; - onChanged(); - } else { - txnDataBuilder_.setMessage(value); - } - - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; - */ - public Builder setTxnData( - com.aliyun.polardbx.binlog.protocol.TxnData.Builder builderForValue) { - if (txnDataBuilder_ == null) { - txnData_ = builderForValue.build(); - onChanged(); - } else { - txnDataBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; - */ - public Builder mergeTxnData(com.aliyun.polardbx.binlog.protocol.TxnData value) { - if (txnDataBuilder_ == null) { - if (txnData_ != null) { - txnData_ = - com.aliyun.polardbx.binlog.protocol.TxnData.newBuilder(txnData_).mergeFrom(value) - .buildPartial(); - } else { - txnData_ = value; - } - onChanged(); - } else { - txnDataBuilder_.mergeFrom(value); - } - - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; - */ - public Builder clearTxnData() { - if (txnDataBuilder_ == null) { - txnData_ = null; - onChanged(); - } else { - txnData_ = null; - txnDataBuilder_ = null; - } - - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; - */ - public com.aliyun.polardbx.binlog.protocol.TxnData.Builder getTxnDataBuilder() { - - onChanged(); - return getTxnDataFieldBuilder().getBuilder(); - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; - */ - public com.aliyun.polardbx.binlog.protocol.TxnDataOrBuilder getTxnDataOrBuilder() { - if (txnDataBuilder_ != null) { - return txnDataBuilder_.getMessageOrBuilder(); - } else { - return txnData_ == null ? - com.aliyun.polardbx.binlog.protocol.TxnData.getDefaultInstance() : txnData_; - } - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnData, com.aliyun.polardbx.binlog.protocol.TxnData.Builder, com.aliyun.polardbx.binlog.protocol.TxnDataOrBuilder> - getTxnDataFieldBuilder() { - if (txnDataBuilder_ == null) { - txnDataBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnData, com.aliyun.polardbx.binlog.protocol.TxnData.Builder, com.aliyun.polardbx.binlog.protocol.TxnDataOrBuilder>( - getTxnData(), - getParentForChildren(), - isClean()); - txnData_ = null; - } - return txnDataBuilder_; - } - - private com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd_; - private com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnEnd, com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder, com.aliyun.polardbx.binlog.protocol.TxnEndOrBuilder> - txnEndBuilder_; - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; - * - * @return Whether the txnEnd field is set. - */ - public boolean hasTxnEnd() { - return txnEndBuilder_ != null || txnEnd_ != null; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; - * - * @return The txnEnd. - */ - public com.aliyun.polardbx.binlog.protocol.TxnEnd getTxnEnd() { - if (txnEndBuilder_ == null) { - return txnEnd_ == null ? com.aliyun.polardbx.binlog.protocol.TxnEnd.getDefaultInstance() : txnEnd_; - } else { - return txnEndBuilder_.getMessage(); - } - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; - */ - public Builder setTxnEnd(com.aliyun.polardbx.binlog.protocol.TxnEnd value) { - if (txnEndBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - txnEnd_ = value; - onChanged(); - } else { - txnEndBuilder_.setMessage(value); - } - - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; - */ - public Builder setTxnEnd( - com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder builderForValue) { - if (txnEndBuilder_ == null) { - txnEnd_ = builderForValue.build(); - onChanged(); - } else { - txnEndBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; - */ - public Builder mergeTxnEnd(com.aliyun.polardbx.binlog.protocol.TxnEnd value) { - if (txnEndBuilder_ == null) { - if (txnEnd_ != null) { - txnEnd_ = - com.aliyun.polardbx.binlog.protocol.TxnEnd.newBuilder(txnEnd_).mergeFrom(value).buildPartial(); - } else { - txnEnd_ = value; - } - onChanged(); - } else { - txnEndBuilder_.mergeFrom(value); - } - - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; - */ - public Builder clearTxnEnd() { - if (txnEndBuilder_ == null) { - txnEnd_ = null; - onChanged(); - } else { - txnEnd_ = null; - txnEndBuilder_ = null; - } - - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; - */ - public com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder getTxnEndBuilder() { - - onChanged(); - return getTxnEndFieldBuilder().getBuilder(); - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; - */ - public com.aliyun.polardbx.binlog.protocol.TxnEndOrBuilder getTxnEndOrBuilder() { - if (txnEndBuilder_ != null) { - return txnEndBuilder_.getMessageOrBuilder(); - } else { - return txnEnd_ == null ? - com.aliyun.polardbx.binlog.protocol.TxnEnd.getDefaultInstance() : txnEnd_; - } - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnEnd, com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder, com.aliyun.polardbx.binlog.protocol.TxnEndOrBuilder> - getTxnEndFieldBuilder() { - if (txnEndBuilder_ == null) { - txnEndBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnEnd, com.aliyun.polardbx.binlog.protocol.TxnEnd.Builder, com.aliyun.polardbx.binlog.protocol.TxnEndOrBuilder>( - getTxnEnd(), - getParentForChildren(), - isClean()); - txnEnd_ = null; - } - return txnEndBuilder_; - } - - private com.aliyun.polardbx.binlog.protocol.TxnTag txnTag_; - private com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnTag, com.aliyun.polardbx.binlog.protocol.TxnTag.Builder, com.aliyun.polardbx.binlog.protocol.TxnTagOrBuilder> - txnTagBuilder_; - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; - * - * @return Whether the txnTag field is set. - */ - public boolean hasTxnTag() { - return txnTagBuilder_ != null || txnTag_ != null; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; - * - * @return The txnTag. - */ - public com.aliyun.polardbx.binlog.protocol.TxnTag getTxnTag() { - if (txnTagBuilder_ == null) { - return txnTag_ == null ? com.aliyun.polardbx.binlog.protocol.TxnTag.getDefaultInstance() : txnTag_; - } else { - return txnTagBuilder_.getMessage(); - } - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; - */ - public Builder setTxnTag(com.aliyun.polardbx.binlog.protocol.TxnTag value) { - if (txnTagBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - txnTag_ = value; - onChanged(); - } else { - txnTagBuilder_.setMessage(value); - } - - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; - */ - public Builder setTxnTag( - com.aliyun.polardbx.binlog.protocol.TxnTag.Builder builderForValue) { - if (txnTagBuilder_ == null) { - txnTag_ = builderForValue.build(); - onChanged(); - } else { - txnTagBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; - */ - public Builder mergeTxnTag(com.aliyun.polardbx.binlog.protocol.TxnTag value) { - if (txnTagBuilder_ == null) { - if (txnTag_ != null) { - txnTag_ = - com.aliyun.polardbx.binlog.protocol.TxnTag.newBuilder(txnTag_).mergeFrom(value).buildPartial(); - } else { - txnTag_ = value; - } - onChanged(); - } else { - txnTagBuilder_.mergeFrom(value); - } - - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; - */ - public Builder clearTxnTag() { - if (txnTagBuilder_ == null) { - txnTag_ = null; - onChanged(); - } else { - txnTag_ = null; - txnTagBuilder_ = null; - } - - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; - */ - public com.aliyun.polardbx.binlog.protocol.TxnTag.Builder getTxnTagBuilder() { - - onChanged(); - return getTxnTagFieldBuilder().getBuilder(); - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; - */ - public com.aliyun.polardbx.binlog.protocol.TxnTagOrBuilder getTxnTagOrBuilder() { - if (txnTagBuilder_ != null) { - return txnTagBuilder_.getMessageOrBuilder(); - } else { - return txnTag_ == null ? - com.aliyun.polardbx.binlog.protocol.TxnTag.getDefaultInstance() : txnTag_; - } - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnTag, com.aliyun.polardbx.binlog.protocol.TxnTag.Builder, com.aliyun.polardbx.binlog.protocol.TxnTagOrBuilder> - getTxnTagFieldBuilder() { - if (txnTagBuilder_ == null) { - txnTagBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnTag, com.aliyun.polardbx.binlog.protocol.TxnTag.Builder, com.aliyun.polardbx.binlog.protocol.TxnTagOrBuilder>( - getTxnTag(), - getParentForChildren(), - isClean()); - txnTag_ = null; - } - return txnTagBuilder_; - } - - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.TxnMessage) - } - - // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.TxnMessage) - private static final com.aliyun.polardbx.binlog.protocol.TxnMessage DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.TxnMessage(); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnMessage getDefaultInstance() { - return DEFAULT_INSTANCE; + throws com.google.protobuf.InvalidProtocolBufferException { + return new TxnMessage(input, extensionRegistry); } + }; - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public TxnMessage parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new TxnMessage(input, extensionRegistry); - } - }; + public static com.google.protobuf.Parser parser() { + return PARSER; + } - public static com.google.protobuf.Parser parser() { - return PARSER; - } + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnMessage getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnMessageOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnMessageOrBuilder.java index 133e8554..43d5c07d 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnMessageOrBuilder.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnMessageOrBuilder.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -24,93 +7,74 @@ public interface TxnMessageOrBuilder extends // @@protoc_insertion_point(interface_extends:com.aliyun.polardbx.binlog.protocol.TxnMessage) com.google.protobuf.MessageOrBuilder { - /** - * .com.aliyun.polardbx.binlog.protocol.MessageType type = 1; - * - * @return The enum numeric value on the wire for type. - */ - int getTypeValue(); - - /** - * .com.aliyun.polardbx.binlog.protocol.MessageType type = 1; - * - * @return The type. - */ - com.aliyun.polardbx.binlog.protocol.MessageType getType(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; - * - * @return Whether the txnBegin field is set. - */ - boolean hasTxnBegin(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; - * - * @return The txnBegin. - */ - com.aliyun.polardbx.binlog.protocol.TxnBegin getTxnBegin(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; - */ - com.aliyun.polardbx.binlog.protocol.TxnBeginOrBuilder getTxnBeginOrBuilder(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; - * - * @return Whether the txnData field is set. - */ - boolean hasTxnData(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; - * - * @return The txnData. - */ - com.aliyun.polardbx.binlog.protocol.TxnData getTxnData(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; - */ - com.aliyun.polardbx.binlog.protocol.TxnDataOrBuilder getTxnDataOrBuilder(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; - * - * @return Whether the txnEnd field is set. - */ - boolean hasTxnEnd(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; - * - * @return The txnEnd. - */ - com.aliyun.polardbx.binlog.protocol.TxnEnd getTxnEnd(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; - */ - com.aliyun.polardbx.binlog.protocol.TxnEndOrBuilder getTxnEndOrBuilder(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; - * - * @return Whether the txnTag field is set. - */ - boolean hasTxnTag(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; - * - * @return The txnTag. - */ - com.aliyun.polardbx.binlog.protocol.TxnTag getTxnTag(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; - */ - com.aliyun.polardbx.binlog.protocol.TxnTagOrBuilder getTxnTagOrBuilder(); + /** + * .com.aliyun.polardbx.binlog.protocol.MessageType type = 1; + * @return The enum numeric value on the wire for type. + */ + int getTypeValue(); + /** + * .com.aliyun.polardbx.binlog.protocol.MessageType type = 1; + * @return The type. + */ + com.aliyun.polardbx.binlog.protocol.MessageType getType(); + + /** + * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; + * @return Whether the txnBegin field is set. + */ + boolean hasTxnBegin(); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; + * @return The txnBegin. + */ + com.aliyun.polardbx.binlog.protocol.TxnBegin getTxnBegin(); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnBegin txnBegin = 2; + */ + com.aliyun.polardbx.binlog.protocol.TxnBeginOrBuilder getTxnBeginOrBuilder(); + + /** + * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; + * @return Whether the txnData field is set. + */ + boolean hasTxnData(); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; + * @return The txnData. + */ + com.aliyun.polardbx.binlog.protocol.TxnData getTxnData(); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnData txnData = 3; + */ + com.aliyun.polardbx.binlog.protocol.TxnDataOrBuilder getTxnDataOrBuilder(); + + /** + * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; + * @return Whether the txnEnd field is set. + */ + boolean hasTxnEnd(); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; + * @return The txnEnd. + */ + com.aliyun.polardbx.binlog.protocol.TxnEnd getTxnEnd(); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnEnd txnEnd = 4; + */ + com.aliyun.polardbx.binlog.protocol.TxnEndOrBuilder getTxnEndOrBuilder(); + + /** + * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; + * @return Whether the txnTag field is set. + */ + boolean hasTxnTag(); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; + * @return The txnTag. + */ + com.aliyun.polardbx.binlog.protocol.TxnTag getTxnTag(); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnTag txnTag = 5; + */ + com.aliyun.polardbx.binlog.protocol.TxnTagOrBuilder getTxnTagOrBuilder(); } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnServiceGrpc.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnServiceGrpc.java index cb00705e..b65e4321 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnServiceGrpc.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnServiceGrpc.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.protocol; import static io.grpc.MethodDescriptor.generateFullMethodName; @@ -33,279 +16,266 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; /** - * */ @javax.annotation.Generated( value = "by gRPC proto compiler (version 1.30.0)", comments = "Source: TxnStream.proto") public final class TxnServiceGrpc { - private TxnServiceGrpc() { - } + private TxnServiceGrpc() {} + + public static final String SERVICE_NAME = "com.aliyun.polardbx.binlog.protocol.TxnService"; - public static final String SERVICE_NAME = "com.aliyun.polardbx.binlog.protocol.TxnService"; - - // Static method descriptors that strictly reflect the proto. - private static volatile io.grpc.MethodDescriptor getDumpMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "dump", - requestType = com.aliyun.polardbx.binlog.protocol.DumpRequest.class, - responseType = com.aliyun.polardbx.binlog.protocol.DumpReply.class, - methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) - public static io.grpc.MethodDescriptor getDumpMethod() { - io.grpc.MethodDescriptor - getDumpMethod; + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor getDumpMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "dump", + requestType = com.aliyun.polardbx.binlog.protocol.DumpRequest.class, + responseType = com.aliyun.polardbx.binlog.protocol.DumpReply.class, + methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + public static io.grpc.MethodDescriptor getDumpMethod() { + io.grpc.MethodDescriptor getDumpMethod; + if ((getDumpMethod = TxnServiceGrpc.getDumpMethod) == null) { + synchronized (TxnServiceGrpc.class) { if ((getDumpMethod = TxnServiceGrpc.getDumpMethod) == null) { - synchronized (TxnServiceGrpc.class) { - if ((getDumpMethod = TxnServiceGrpc.getDumpMethod) == null) { - TxnServiceGrpc.getDumpMethod = getDumpMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) - .setFullMethodName(generateFullMethodName(SERVICE_NAME, "dump")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - com.aliyun.polardbx.binlog.protocol.DumpRequest.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - com.aliyun.polardbx.binlog.protocol.DumpReply.getDefaultInstance())) - .setSchemaDescriptor(new TxnServiceMethodDescriptorSupplier("dump")) - .build(); - } - } + TxnServiceGrpc.getDumpMethod = getDumpMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "dump")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.binlog.protocol.DumpRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.binlog.protocol.DumpReply.getDefaultInstance())) + .setSchemaDescriptor(new TxnServiceMethodDescriptorSupplier("dump")) + .build(); } - return getDumpMethod; + } } + return getDumpMethod; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static TxnServiceStub newStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public TxnServiceStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new TxnServiceStub(channel, callOptions); + } + }; + return TxnServiceStub.newStub(factory, channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static TxnServiceBlockingStub newBlockingStub( + io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public TxnServiceBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new TxnServiceBlockingStub(channel, callOptions); + } + }; + return TxnServiceBlockingStub.newStub(factory, channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static TxnServiceFutureStub newFutureStub( + io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public TxnServiceFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new TxnServiceFutureStub(channel, callOptions); + } + }; + return TxnServiceFutureStub.newStub(factory, channel); + } - /** - * Creates a new async stub that supports all call types for the service - */ - public static TxnServiceStub newStub(io.grpc.Channel channel) { - io.grpc.stub.AbstractStub.StubFactory factory = - new io.grpc.stub.AbstractStub.StubFactory() { - @java.lang.Override - public TxnServiceStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - return new TxnServiceStub(channel, callOptions); - } - }; - return TxnServiceStub.newStub(factory, channel); - } + /** + */ + public static abstract class TxnServiceImplBase implements io.grpc.BindableService { /** - * Creates a new blocking-style stub that supports unary and streaming output calls on the service */ - public static TxnServiceBlockingStub newBlockingStub( - io.grpc.Channel channel) { - io.grpc.stub.AbstractStub.StubFactory factory = - new io.grpc.stub.AbstractStub.StubFactory() { - @java.lang.Override - public TxnServiceBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - return new TxnServiceBlockingStub(channel, callOptions); - } - }; - return TxnServiceBlockingStub.newStub(factory, channel); + public void dump(com.aliyun.polardbx.binlog.protocol.DumpRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getDumpMethod(), responseObserver); } - /** - * Creates a new ListenableFuture-style stub that supports unary calls on the service - */ - public static TxnServiceFutureStub newFutureStub( - io.grpc.Channel channel) { - io.grpc.stub.AbstractStub.StubFactory factory = - new io.grpc.stub.AbstractStub.StubFactory() { - @java.lang.Override - public TxnServiceFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - return new TxnServiceFutureStub(channel, callOptions); - } - }; - return TxnServiceFutureStub.newStub(factory, channel); + @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getDumpMethod(), + asyncServerStreamingCall( + new MethodHandlers< + com.aliyun.polardbx.binlog.protocol.DumpRequest, + com.aliyun.polardbx.binlog.protocol.DumpReply>( + this, METHODID_DUMP))) + .build(); } - - /** - * - */ - public static abstract class TxnServiceImplBase implements io.grpc.BindableService { - - /** - * - */ - public void dump(com.aliyun.polardbx.binlog.protocol.DumpRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getDumpMethod(), responseObserver); - } - - @java.lang.Override - public final io.grpc.ServerServiceDefinition bindService() { - return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) - .addMethod( - getDumpMethod(), - asyncServerStreamingCall( - new MethodHandlers< - com.aliyun.polardbx.binlog.protocol.DumpRequest, - com.aliyun.polardbx.binlog.protocol.DumpReply>( - this, METHODID_DUMP))) - .build(); - } + } + + /** + */ + public static final class TxnServiceStub extends io.grpc.stub.AbstractAsyncStub { + private TxnServiceStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); } - /** - * - */ - public static final class TxnServiceStub extends io.grpc.stub.AbstractAsyncStub { - private TxnServiceStub( - io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @java.lang.Override - protected TxnServiceStub build( - io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - return new TxnServiceStub(channel, callOptions); - } - - /** - * - */ - public void dump(com.aliyun.polardbx.binlog.protocol.DumpRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncServerStreamingCall( - getChannel().newCall(getDumpMethod(), getCallOptions()), request, responseObserver); - } + @java.lang.Override + protected TxnServiceStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new TxnServiceStub(channel, callOptions); } /** - * */ - public static final class TxnServiceBlockingStub extends io.grpc.stub.AbstractBlockingStub { - private TxnServiceBlockingStub( - io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @java.lang.Override - protected TxnServiceBlockingStub build( - io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - return new TxnServiceBlockingStub(channel, callOptions); - } + public void dump(com.aliyun.polardbx.binlog.protocol.DumpRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncServerStreamingCall( + getChannel().newCall(getDumpMethod(), getCallOptions()), request, responseObserver); + } + } + + /** + */ + public static final class TxnServiceBlockingStub extends io.grpc.stub.AbstractBlockingStub { + private TxnServiceBlockingStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } - /** - * - */ - public java.util.Iterator dump( - com.aliyun.polardbx.binlog.protocol.DumpRequest request) { - return blockingServerStreamingCall( - getChannel(), getDumpMethod(), getCallOptions(), request); - } + @java.lang.Override + protected TxnServiceBlockingStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new TxnServiceBlockingStub(channel, callOptions); } /** - * */ - public static final class TxnServiceFutureStub extends io.grpc.stub.AbstractFutureStub { - private TxnServiceFutureStub( - io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @java.lang.Override - protected TxnServiceFutureStub build( - io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - return new TxnServiceFutureStub(channel, callOptions); - } + public java.util.Iterator dump( + com.aliyun.polardbx.binlog.protocol.DumpRequest request) { + return blockingServerStreamingCall( + getChannel(), getDumpMethod(), getCallOptions(), request); + } + } + + /** + */ + public static final class TxnServiceFutureStub extends io.grpc.stub.AbstractFutureStub { + private TxnServiceFutureStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); } - private static final int METHODID_DUMP = 0; + @java.lang.Override + protected TxnServiceFutureStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new TxnServiceFutureStub(channel, callOptions); + } + } - private static final class MethodHandlers implements - io.grpc.stub.ServerCalls.UnaryMethod, - io.grpc.stub.ServerCalls.ServerStreamingMethod, - io.grpc.stub.ServerCalls.ClientStreamingMethod, - io.grpc.stub.ServerCalls.BidiStreamingMethod { - private final TxnServiceImplBase serviceImpl; - private final int methodId; + private static final int METHODID_DUMP = 0; - MethodHandlers(TxnServiceImplBase serviceImpl, int methodId) { - this.serviceImpl = serviceImpl; - this.methodId = methodId; - } + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final TxnServiceImplBase serviceImpl; + private final int methodId; - @java.lang.Override - @java.lang.SuppressWarnings("unchecked") - public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { - switch (methodId) { - case METHODID_DUMP: - serviceImpl.dump((com.aliyun.polardbx.binlog.protocol.DumpRequest) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - default: - throw new AssertionError(); - } - } + MethodHandlers(TxnServiceImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } - @java.lang.Override - @java.lang.SuppressWarnings("unchecked") - public io.grpc.stub.StreamObserver invoke( - io.grpc.stub.StreamObserver responseObserver) { - switch (methodId) { - default: - throw new AssertionError(); - } - } + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_DUMP: + serviceImpl.dump((com.aliyun.polardbx.binlog.protocol.DumpRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } } - private static abstract class TxnServiceBaseDescriptorSupplier - implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { - TxnServiceBaseDescriptorSupplier() { - } + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } - @java.lang.Override - public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.getDescriptor(); - } + private static abstract class TxnServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + TxnServiceBaseDescriptorSupplier() {} - @java.lang.Override - public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { - return getFileDescriptor().findServiceByName("TxnService"); - } + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.getDescriptor(); } - private static final class TxnServiceFileDescriptorSupplier - extends TxnServiceBaseDescriptorSupplier { - TxnServiceFileDescriptorSupplier() { - } + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("TxnService"); } + } - private static final class TxnServiceMethodDescriptorSupplier - extends TxnServiceBaseDescriptorSupplier - implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { - private final String methodName; + private static final class TxnServiceFileDescriptorSupplier + extends TxnServiceBaseDescriptorSupplier { + TxnServiceFileDescriptorSupplier() {} + } - TxnServiceMethodDescriptorSupplier(String methodName) { - this.methodName = methodName; - } + private static final class TxnServiceMethodDescriptorSupplier + extends TxnServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; - @java.lang.Override - public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { - return getServiceDescriptor().findMethodByName(methodName); - } + TxnServiceMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); } + } - private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; - public static io.grpc.ServiceDescriptor getServiceDescriptor() { - io.grpc.ServiceDescriptor result = serviceDescriptor; + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (TxnServiceGrpc.class) { + result = serviceDescriptor; if (result == null) { - synchronized (TxnServiceGrpc.class) { - result = serviceDescriptor; - if (result == null) { - serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) - .setSchemaDescriptor(new TxnServiceFileDescriptorSupplier()) - .addMethod(getDumpMethod()) - .build(); - } - } + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new TxnServiceFileDescriptorSupplier()) + .addMethod(getDumpMethod()) + .build(); } - return result; + } } + return result; + } } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnStream.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnStream.java index ae4bd2e3..e02d5d9a 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnStream.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnStream.java @@ -1,214 +1,191 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto package com.aliyun.polardbx.binlog.protocol; public final class TxnStream { - private TxnStream() { - } - - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistryLite registry) { - } - - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - registerAllExtensions( - (com.google.protobuf.ExtensionRegistryLite) registry); - } + private TxnStream() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } - static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_aliyun_polardbx_binlog_protocol_DumpRequest_descriptor; - static final + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_aliyun_polardbx_binlog_protocol_DumpRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_com_aliyun_polardbx_binlog_protocol_DumpRequest_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_aliyun_polardbx_binlog_protocol_DumpReply_descriptor; - static final + internal_static_com_aliyun_polardbx_binlog_protocol_DumpRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_aliyun_polardbx_binlog_protocol_DumpReply_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_com_aliyun_polardbx_binlog_protocol_DumpReply_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_descriptor; - static final + internal_static_com_aliyun_polardbx_binlog_protocol_DumpReply_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_aliyun_polardbx_binlog_protocol_TxnBegin_descriptor; - static final + internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_aliyun_polardbx_binlog_protocol_TxnBegin_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_com_aliyun_polardbx_binlog_protocol_TxnBegin_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_aliyun_polardbx_binlog_protocol_TxnData_descriptor; - static final + internal_static_com_aliyun_polardbx_binlog_protocol_TxnBegin_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_aliyun_polardbx_binlog_protocol_TxnData_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_com_aliyun_polardbx_binlog_protocol_TxnData_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_aliyun_polardbx_binlog_protocol_TxnEnd_descriptor; - static final + internal_static_com_aliyun_polardbx_binlog_protocol_TxnData_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_aliyun_polardbx_binlog_protocol_TxnEnd_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_com_aliyun_polardbx_binlog_protocol_TxnEnd_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_aliyun_polardbx_binlog_protocol_TxnTag_descriptor; - static final + internal_static_com_aliyun_polardbx_binlog_protocol_TxnEnd_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_aliyun_polardbx_binlog_protocol_TxnTag_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_com_aliyun_polardbx_binlog_protocol_TxnTag_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_descriptor; - static final + internal_static_com_aliyun_polardbx_binlog_protocol_TxnTag_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_aliyun_polardbx_binlog_protocol_TxnMergedToken_descriptor; - static final + internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_aliyun_polardbx_binlog_protocol_TxnMergedToken_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_com_aliyun_polardbx_binlog_protocol_TxnMergedToken_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_aliyun_polardbx_binlog_protocol_TxnItem_descriptor; - static final + internal_static_com_aliyun_polardbx_binlog_protocol_TxnMergedToken_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_aliyun_polardbx_binlog_protocol_TxnItem_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_com_aliyun_polardbx_binlog_protocol_TxnItem_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; + internal_static_com_aliyun_polardbx_binlog_protocol_TxnItem_fieldAccessorTable; - static { - java.lang.String[] descriptorData = { - "\n\017TxnStream.proto\022#com.aliyun.polardbx.b" + - "inlog.protocol\"\032\n\013DumpRequest\022\013\n\003tso\030\001 \001" + - "(\t\"P\n\tDumpReply\022C\n\ntxnMessage\030\001 \003(\0132/.co" + - "m.aliyun.polardbx.binlog.protocol.TxnMes" + - "sage\"\306\002\n\nTxnMessage\022>\n\004type\030\001 \001(\01620.com." + - "aliyun.polardbx.binlog.protocol.MessageT" + - "ype\022?\n\010txnBegin\030\002 \001(\0132-.com.aliyun.polar" + - "dbx.binlog.protocol.TxnBegin\022=\n\007txnData\030" + - "\003 \001(\0132,.com.aliyun.polardbx.binlog.proto" + - "col.TxnData\022;\n\006txnEnd\030\004 \001(\0132+.com.aliyun" + - ".polardbx.binlog.protocol.TxnEnd\022;\n\006txnT" + - "ag\030\005 \001(\0132+.com.aliyun.polardbx.binlog.pr" + - "otocol.TxnTag\"\253\001\n\010TxnBegin\022A\n\010txnToken\030\001" + - " \001(\0132-.com.aliyun.polardbx.binlog.protoc" + - "ol.TxnTokenH\000\022M\n\016txnMergedToken\030\002 \001(\01323." + - "com.aliyun.polardbx.binlog.protocol.TxnM" + - "ergedTokenH\000B\r\n\013token_oneof\"I\n\007TxnData\022>" + - "\n\010txnItems\030\001 \003(\0132,.com.aliyun.polardbx.b" + - "inlog.protocol.TxnItem\"\010\n\006TxnEnd\"\251\001\n\006Txn" + - "Tag\022A\n\010txnToken\030\001 \001(\0132-.com.aliyun.polar" + - "dbx.binlog.protocol.TxnTokenH\000\022M\n\016txnMer" + - "gedToken\030\002 \001(\01323.com.aliyun.polardbx.bin" + - "log.protocol.TxnMergedTokenH\000B\r\n\013token_o" + - "neof\"\233\002\n\010TxnToken\022\013\n\003tso\030\001 \001(\t\022\r\n\005txnId\030" + - "\002 \001(\t\022\023\n\013partitionId\030\003 \001(\t\022\033\n\023originMerg" + - "eSourceId\030\004 \001(\t\022:\n\004type\030\005 \001(\0162,.com.aliy" + - "un.polardbx.binlog.protocol.TxnType\022\r\n\005x" + - "aTxn\030\006 \001(\010\022\026\n\016tsoTransaction\030\007 \001(\010\022\017\n\007tx" + - "nSize\030\010 \001(\005\022\023\n\013beginSchema\030\t \001(\t\022\022\n\nallP" + - "arties\030\n \003(\t\022\017\n\007payload\030\013 \001(\014\022\023\n\013snapsho" + - "tSeq\030\014 \001(\003\"\177\n\016TxnMergedToken\022\013\n\003tso\030\001 \001(" + - "\t\022:\n\004type\030\002 \001(\0162,.com.aliyun.polardbx.bi" + - "nlog.protocol.TxnType\022\023\n\013beginSchema\030\003 \001" + - "(\t\022\017\n\007payload\030\004 \001(\014\"Q\n\007TxnItem\022\017\n\007traceI" + - "d\030\001 \001(\t\022\021\n\trowsQuery\030\002 \001(\t\022\021\n\teventType\030" + - "\003 \001(\005\022\017\n\007payload\030\004 \001(\014*?\n\013MessageType\022\t\n" + - "\005WHOLE\020\000\022\t\n\005BEGIN\020\001\022\010\n\004DATA\020\002\022\007\n\003END\020\003\022\007" - + - "\n\003TAG\020\004*k\n\007TxnType\022\007\n\003DML\020\000\022\017\n\013FORMAT_DE" + - "SC\020\001\022\014\n\010META_DDL\020\002\022\016\n\nMETA_SCALE\020\003\022\024\n\020ME" + - "TA_DDL_PRIVATE\020\004\022\022\n\016META_HEARTBEAT\020\0052z\n\n" + - "TxnService\022l\n\004dump\0220.com.aliyun.polardbx" + - ".binlog.protocol.DumpRequest\032..com.aliyu" + - "n.polardbx.binlog.protocol.DumpReply\"\0000\001" + - "B)\n#com.aliyun.polardbx.binlog.protocolH" + - "\001P\001b\006proto3" - }; - descriptor = com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }); - internal_static_com_aliyun_polardbx_binlog_protocol_DumpRequest_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_com_aliyun_polardbx_binlog_protocol_DumpRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_com_aliyun_polardbx_binlog_protocol_DumpRequest_descriptor, - new java.lang.String[] {"Tso",}); - internal_static_com_aliyun_polardbx_binlog_protocol_DumpReply_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_com_aliyun_polardbx_binlog_protocol_DumpReply_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_com_aliyun_polardbx_binlog_protocol_DumpReply_descriptor, - new java.lang.String[] {"TxnMessage",}); - internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_descriptor, - new java.lang.String[] {"Type", "TxnBegin", "TxnData", "TxnEnd", "TxnTag",}); - internal_static_com_aliyun_polardbx_binlog_protocol_TxnBegin_descriptor = - getDescriptor().getMessageTypes().get(3); - internal_static_com_aliyun_polardbx_binlog_protocol_TxnBegin_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_com_aliyun_polardbx_binlog_protocol_TxnBegin_descriptor, - new java.lang.String[] {"TxnToken", "TxnMergedToken", "TokenOneof",}); - internal_static_com_aliyun_polardbx_binlog_protocol_TxnData_descriptor = - getDescriptor().getMessageTypes().get(4); - internal_static_com_aliyun_polardbx_binlog_protocol_TxnData_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_com_aliyun_polardbx_binlog_protocol_TxnData_descriptor, - new java.lang.String[] {"TxnItems",}); - internal_static_com_aliyun_polardbx_binlog_protocol_TxnEnd_descriptor = - getDescriptor().getMessageTypes().get(5); - internal_static_com_aliyun_polardbx_binlog_protocol_TxnEnd_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_com_aliyun_polardbx_binlog_protocol_TxnEnd_descriptor, - new java.lang.String[] {}); - internal_static_com_aliyun_polardbx_binlog_protocol_TxnTag_descriptor = - getDescriptor().getMessageTypes().get(6); - internal_static_com_aliyun_polardbx_binlog_protocol_TxnTag_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_com_aliyun_polardbx_binlog_protocol_TxnTag_descriptor, - new java.lang.String[] {"TxnToken", "TxnMergedToken", "TokenOneof",}); - internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_descriptor = - getDescriptor().getMessageTypes().get(7); - internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_descriptor, - new java.lang.String[] { - "Tso", "TxnId", "PartitionId", "OriginMergeSourceId", "Type", "XaTxn", "TsoTransaction", "TxnSize", - "BeginSchema", "AllParties", "Payload", "SnapshotSeq",}); - internal_static_com_aliyun_polardbx_binlog_protocol_TxnMergedToken_descriptor = - getDescriptor().getMessageTypes().get(8); - internal_static_com_aliyun_polardbx_binlog_protocol_TxnMergedToken_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_com_aliyun_polardbx_binlog_protocol_TxnMergedToken_descriptor, - new java.lang.String[] {"Tso", "Type", "BeginSchema", "Payload",}); - internal_static_com_aliyun_polardbx_binlog_protocol_TxnItem_descriptor = - getDescriptor().getMessageTypes().get(9); - internal_static_com_aliyun_polardbx_binlog_protocol_TxnItem_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_com_aliyun_polardbx_binlog_protocol_TxnItem_descriptor, - new java.lang.String[] {"TraceId", "RowsQuery", "EventType", "Payload",}); - } + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\017TxnStream.proto\022#com.aliyun.polardbx.b" + + "inlog.protocol\"\032\n\013DumpRequest\022\013\n\003tso\030\001 \001" + + "(\t\"P\n\tDumpReply\022C\n\ntxnMessage\030\001 \003(\0132/.co" + + "m.aliyun.polardbx.binlog.protocol.TxnMes" + + "sage\"\306\002\n\nTxnMessage\022>\n\004type\030\001 \001(\01620.com." + + "aliyun.polardbx.binlog.protocol.MessageT" + + "ype\022?\n\010txnBegin\030\002 \001(\0132-.com.aliyun.polar" + + "dbx.binlog.protocol.TxnBegin\022=\n\007txnData\030" + + "\003 \001(\0132,.com.aliyun.polardbx.binlog.proto" + + "col.TxnData\022;\n\006txnEnd\030\004 \001(\0132+.com.aliyun" + + ".polardbx.binlog.protocol.TxnEnd\022;\n\006txnT" + + "ag\030\005 \001(\0132+.com.aliyun.polardbx.binlog.pr" + + "otocol.TxnTag\"\253\001\n\010TxnBegin\022A\n\010txnToken\030\001" + + " \001(\0132-.com.aliyun.polardbx.binlog.protoc" + + "ol.TxnTokenH\000\022M\n\016txnMergedToken\030\002 \001(\01323." + + "com.aliyun.polardbx.binlog.protocol.TxnM" + + "ergedTokenH\000B\r\n\013token_oneof\"I\n\007TxnData\022>" + + "\n\010txnItems\030\001 \003(\0132,.com.aliyun.polardbx.b" + + "inlog.protocol.TxnItem\"\010\n\006TxnEnd\"\251\001\n\006Txn" + + "Tag\022A\n\010txnToken\030\001 \001(\0132-.com.aliyun.polar" + + "dbx.binlog.protocol.TxnTokenH\000\022M\n\016txnMer" + + "gedToken\030\002 \001(\01323.com.aliyun.polardbx.bin" + + "log.protocol.TxnMergedTokenH\000B\r\n\013token_o" + + "neof\"\245\002\n\010TxnToken\022\013\n\003tso\030\001 \001(\t\022\r\n\005txnId\030" + + "\002 \001(\t\022\023\n\013partitionId\030\003 \001(\t\022\033\n\023originMerg" + + "eSourceId\030\004 \001(\t\022:\n\004type\030\005 \001(\0162,.com.aliy" + + "un.polardbx.binlog.protocol.TxnType\022\r\n\005x" + + "aTxn\030\006 \001(\010\022\026\n\016tsoTransaction\030\007 \001(\010\022\017\n\007tx" + + "nSize\030\010 \001(\005\022\016\n\006schema\030\t \001(\t\022\022\n\nallPartie" + + "s\030\n \003(\t\022\017\n\007payload\030\013 \001(\014\022\023\n\013snapshotSeq\030" + + "\014 \001(\003\022\r\n\005table\030\r \001(\t\"\211\001\n\016TxnMergedToken\022" + + "\013\n\003tso\030\001 \001(\t\022:\n\004type\030\002 \001(\0162,.com.aliyun." + + "polardbx.binlog.protocol.TxnType\022\016\n\006sche" + + "ma\030\003 \001(\t\022\017\n\007payload\030\004 \001(\014\022\r\n\005table\030\005 \001(\t" + + "\"p\n\007TxnItem\022\017\n\007traceId\030\001 \001(\t\022\021\n\teventTyp" + + "e\030\002 \001(\005\022\017\n\007payload\030\003 \001(\014\022\021\n\trowsQuery\030\004 " + + "\001(\t\022\016\n\006schema\030\005 \001(\t\022\r\n\005table\030\006 \001(\t*?\n\013Me" + + "ssageType\022\t\n\005WHOLE\020\000\022\t\n\005BEGIN\020\001\022\010\n\004DATA\020" + + "\002\022\007\n\003END\020\003\022\007\n\003TAG\020\004*\207\001\n\007TxnType\022\007\n\003DML\020\000" + + "\022\017\n\013FORMAT_DESC\020\001\022\014\n\010META_DDL\020\002\022\016\n\nMETA_" + + "SCALE\020\003\022\024\n\020META_DDL_PRIVATE\020\004\022\022\n\016META_HE" + + "ARTBEAT\020\005\022\032\n\026META_CONFIG_ENV_CHANGE\020\0062z\n" + + "\nTxnService\022l\n\004dump\0220.com.aliyun.polardb" + + "x.binlog.protocol.DumpRequest\032..com.aliy" + + "un.polardbx.binlog.protocol.DumpReply\"\0000" + + "\001B)\n#com.aliyun.polardbx.binlog.protocol" + + "H\001P\001b\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }); + internal_static_com_aliyun_polardbx_binlog_protocol_DumpRequest_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_com_aliyun_polardbx_binlog_protocol_DumpRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_aliyun_polardbx_binlog_protocol_DumpRequest_descriptor, + new java.lang.String[] { "Tso", }); + internal_static_com_aliyun_polardbx_binlog_protocol_DumpReply_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_com_aliyun_polardbx_binlog_protocol_DumpReply_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_aliyun_polardbx_binlog_protocol_DumpReply_descriptor, + new java.lang.String[] { "TxnMessage", }); + internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_aliyun_polardbx_binlog_protocol_TxnMessage_descriptor, + new java.lang.String[] { "Type", "TxnBegin", "TxnData", "TxnEnd", "TxnTag", }); + internal_static_com_aliyun_polardbx_binlog_protocol_TxnBegin_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_com_aliyun_polardbx_binlog_protocol_TxnBegin_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_aliyun_polardbx_binlog_protocol_TxnBegin_descriptor, + new java.lang.String[] { "TxnToken", "TxnMergedToken", "TokenOneof", }); + internal_static_com_aliyun_polardbx_binlog_protocol_TxnData_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_com_aliyun_polardbx_binlog_protocol_TxnData_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_aliyun_polardbx_binlog_protocol_TxnData_descriptor, + new java.lang.String[] { "TxnItems", }); + internal_static_com_aliyun_polardbx_binlog_protocol_TxnEnd_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_com_aliyun_polardbx_binlog_protocol_TxnEnd_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_aliyun_polardbx_binlog_protocol_TxnEnd_descriptor, + new java.lang.String[] { }); + internal_static_com_aliyun_polardbx_binlog_protocol_TxnTag_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_com_aliyun_polardbx_binlog_protocol_TxnTag_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_aliyun_polardbx_binlog_protocol_TxnTag_descriptor, + new java.lang.String[] { "TxnToken", "TxnMergedToken", "TokenOneof", }); + internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_descriptor = + getDescriptor().getMessageTypes().get(7); + internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_descriptor, + new java.lang.String[] { "Tso", "TxnId", "PartitionId", "OriginMergeSourceId", "Type", "XaTxn", "TsoTransaction", "TxnSize", "Schema", "AllParties", "Payload", "SnapshotSeq", "Table", }); + internal_static_com_aliyun_polardbx_binlog_protocol_TxnMergedToken_descriptor = + getDescriptor().getMessageTypes().get(8); + internal_static_com_aliyun_polardbx_binlog_protocol_TxnMergedToken_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_aliyun_polardbx_binlog_protocol_TxnMergedToken_descriptor, + new java.lang.String[] { "Tso", "Type", "Schema", "Payload", "Table", }); + internal_static_com_aliyun_polardbx_binlog_protocol_TxnItem_descriptor = + getDescriptor().getMessageTypes().get(9); + internal_static_com_aliyun_polardbx_binlog_protocol_TxnItem_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_aliyun_polardbx_binlog_protocol_TxnItem_descriptor, + new java.lang.String[] { "TraceId", "EventType", "Payload", "RowsQuery", "Schema", "Table", }); + } - // @@protoc_insertion_point(outer_class_scope) + // @@protoc_insertion_point(outer_class_scope) } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnTag.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnTag.java index 2aaced45..665fa3ef 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnTag.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnTag.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -27,1006 +10,907 @@ public final class TxnTag extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:com.aliyun.polardbx.binlog.protocol.TxnTag) TxnTagOrBuilder { - private static final long serialVersionUID = 0L; +private static final long serialVersionUID = 0L; + // Use TxnTag.newBuilder() to construct. + private TxnTag(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TxnTag() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new TxnTag(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TxnTag( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + com.aliyun.polardbx.binlog.protocol.TxnToken.Builder subBuilder = null; + if (tokenOneofCase_ == 1) { + subBuilder = ((com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_).toBuilder(); + } + tokenOneof_ = + input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnToken.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_); + tokenOneof_ = subBuilder.buildPartial(); + } + tokenOneofCase_ = 1; + break; + } + case 18: { + com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder subBuilder = null; + if (tokenOneofCase_ == 2) { + subBuilder = ((com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_).toBuilder(); + } + tokenOneof_ = + input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnMergedToken.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_); + tokenOneof_ = subBuilder.buildPartial(); + } + tokenOneofCase_ = 2; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnTag_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnTag_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.binlog.protocol.TxnTag.class, com.aliyun.polardbx.binlog.protocol.TxnTag.Builder.class); + } + + private int tokenOneofCase_ = 0; + private java.lang.Object tokenOneof_; + public enum TokenOneofCase + implements com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + TXNTOKEN(1), + TXNMERGEDTOKEN(2), + TOKENONEOF_NOT_SET(0); + private final int value; + private TokenOneofCase(int value) { + this.value = value; + } + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static TokenOneofCase valueOf(int value) { + return forNumber(value); + } + + public static TokenOneofCase forNumber(int value) { + switch (value) { + case 1: return TXNTOKEN; + case 2: return TXNMERGEDTOKEN; + case 0: return TOKENONEOF_NOT_SET; + default: return null; + } + } + public int getNumber() { + return this.value; + } + }; + + public TokenOneofCase + getTokenOneofCase() { + return TokenOneofCase.forNumber( + tokenOneofCase_); + } + + public static final int TXNTOKEN_FIELD_NUMBER = 1; + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + * @return Whether the txnToken field is set. + */ + @java.lang.Override + public boolean hasTxnToken() { + return tokenOneofCase_ == 1; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + * @return The txnToken. + */ + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnToken getTxnToken() { + if (tokenOneofCase_ == 1) { + return (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_; + } + return com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + */ + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder getTxnTokenOrBuilder() { + if (tokenOneofCase_ == 1) { + return (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_; + } + return com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); + } + + public static final int TXNMERGEDTOKEN_FIELD_NUMBER = 2; + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + * @return Whether the txnMergedToken field is set. + */ + @java.lang.Override + public boolean hasTxnMergedToken() { + return tokenOneofCase_ == 2; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + * @return The txnMergedToken. + */ + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnMergedToken getTxnMergedToken() { + if (tokenOneofCase_ == 2) { + return (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_; + } + return com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + */ + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder getTxnMergedTokenOrBuilder() { + if (tokenOneofCase_ == 2) { + return (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_; + } + return com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (tokenOneofCase_ == 1) { + output.writeMessage(1, (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_); + } + if (tokenOneofCase_ == 2) { + output.writeMessage(2, (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (tokenOneofCase_ == 1) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_); + } + if (tokenOneofCase_ == 2) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.TxnTag)) { + return super.equals(obj); + } + com.aliyun.polardbx.binlog.protocol.TxnTag other = (com.aliyun.polardbx.binlog.protocol.TxnTag) obj; + + if (!getTokenOneofCase().equals(other.getTokenOneofCase())) return false; + switch (tokenOneofCase_) { + case 1: + if (!getTxnToken() + .equals(other.getTxnToken())) return false; + break; + case 2: + if (!getTxnMergedToken() + .equals(other.getTxnMergedToken())) return false; + break; + case 0: + default: + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + switch (tokenOneofCase_) { + case 1: + hash = (37 * hash) + TXNTOKEN_FIELD_NUMBER; + hash = (53 * hash) + getTxnToken().hashCode(); + break; + case 2: + hash = (37 * hash) + TXNMERGEDTOKEN_FIELD_NUMBER; + hash = (53 * hash) + getTxnMergedToken().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.binlog.protocol.TxnTag parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnTag parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnTag parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnTag parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnTag parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnTag parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnTag parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnTag parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnTag parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnTag parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnTag parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnTag parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.TxnTag prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnTag} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.TxnTag) + com.aliyun.polardbx.binlog.protocol.TxnTagOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnTag_descriptor; + } - // Use TxnTag.newBuilder() to construct. - private TxnTag(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnTag_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.binlog.protocol.TxnTag.class, com.aliyun.polardbx.binlog.protocol.TxnTag.Builder.class); } - private TxnTag() { + // Construct using com.aliyun.polardbx.binlog.protocol.TxnTag.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); } + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new TxnTag(); + public Builder clear() { + super.clear(); + tokenOneofCase_ = 0; + tokenOneof_ = null; + return this; } @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnTag_descriptor; } - private TxnTag( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - 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; - case 10: { - com.aliyun.polardbx.binlog.protocol.TxnToken.Builder subBuilder = null; - if (tokenOneofCase_ == 1) { - subBuilder = ((com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_).toBuilder(); - } - tokenOneof_ = - input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnToken.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_); - tokenOneof_ = subBuilder.buildPartial(); - } - tokenOneofCase_ = 1; - break; - } - case 18: { - com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder subBuilder = null; - if (tokenOneofCase_ == 2) { - subBuilder = ((com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_).toBuilder(); - } - tokenOneof_ = - input.readMessage(com.aliyun.polardbx.binlog.protocol.TxnMergedToken.parser(), - extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_); - tokenOneof_ = subBuilder.buildPartial(); - } - tokenOneofCase_ = 2; - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnTag getDefaultInstanceForType() { + return com.aliyun.polardbx.binlog.protocol.TxnTag.getDefaultInstance(); } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnTag_descriptor; + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnTag build() { + com.aliyun.polardbx.binlog.protocol.TxnTag result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnTag_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.aliyun.polardbx.binlog.protocol.TxnTag.class, - com.aliyun.polardbx.binlog.protocol.TxnTag.Builder.class); + public com.aliyun.polardbx.binlog.protocol.TxnTag buildPartial() { + com.aliyun.polardbx.binlog.protocol.TxnTag result = new com.aliyun.polardbx.binlog.protocol.TxnTag(this); + if (tokenOneofCase_ == 1) { + if (txnTokenBuilder_ == null) { + result.tokenOneof_ = tokenOneof_; + } else { + result.tokenOneof_ = txnTokenBuilder_.build(); + } + } + if (tokenOneofCase_ == 2) { + if (txnMergedTokenBuilder_ == null) { + result.tokenOneof_ = tokenOneof_; + } else { + result.tokenOneof_ = txnMergedTokenBuilder_.build(); + } + } + result.tokenOneofCase_ = tokenOneofCase_; + onBuilt(); + return result; } - private int tokenOneofCase_ = 0; - private java.lang.Object tokenOneof_; - - public enum TokenOneofCase - implements com.google.protobuf.Internal.EnumLite, - com.google.protobuf.AbstractMessage.InternalOneOfEnum { - TXNTOKEN(1), - TXNMERGEDTOKEN(2), - TOKENONEOF_NOT_SET(0); - private final int value; - - private TokenOneofCase(int value) { - this.value = value; - } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.binlog.protocol.TxnTag) { + return mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnTag)other); + } else { + super.mergeFrom(other); + return this; + } + } - /** - * @param value The number of the enum to look for. - * @return The enum associated with the given number. - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static TokenOneofCase valueOf(int value) { - return forNumber(value); + public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.TxnTag other) { + if (other == com.aliyun.polardbx.binlog.protocol.TxnTag.getDefaultInstance()) return this; + switch (other.getTokenOneofCase()) { + case TXNTOKEN: { + mergeTxnToken(other.getTxnToken()); + break; } - - public static TokenOneofCase forNumber(int value) { - switch (value) { - case 1: - return TXNTOKEN; - case 2: - return TXNMERGEDTOKEN; - case 0: - return TOKENONEOF_NOT_SET; - default: - return null; - } + case TXNMERGEDTOKEN: { + mergeTxnMergedToken(other.getTxnMergedToken()); + break; } - - public int getNumber() { - return this.value; + case TOKENONEOF_NOT_SET: { + break; } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; } - ; + @java.lang.Override + public final boolean isInitialized() { + return true; + } + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.aliyun.polardbx.binlog.protocol.TxnTag parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.binlog.protocol.TxnTag) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int tokenOneofCase_ = 0; + private java.lang.Object tokenOneof_; public TokenOneofCase - getTokenOneofCase() { - return TokenOneofCase.forNumber( - tokenOneofCase_); + getTokenOneofCase() { + return TokenOneofCase.forNumber( + tokenOneofCase_); + } + + public Builder clearTokenOneof() { + tokenOneofCase_ = 0; + tokenOneof_ = null; + onChanged(); + return this; } - public static final int TXNTOKEN_FIELD_NUMBER = 1; + private com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnToken, com.aliyun.polardbx.binlog.protocol.TxnToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder> txnTokenBuilder_; /** * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - * * @return Whether the txnToken field is set. */ @java.lang.Override public boolean hasTxnToken() { - return tokenOneofCase_ == 1; + return tokenOneofCase_ == 1; } - /** * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - * * @return The txnToken. */ @java.lang.Override public com.aliyun.polardbx.binlog.protocol.TxnToken getTxnToken() { + if (txnTokenBuilder_ == null) { + if (tokenOneofCase_ == 1) { + return (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_; + } + return com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); + } else { if (tokenOneofCase_ == 1) { - return (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_; + return txnTokenBuilder_.getMessage(); } return com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); + } + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + */ + public Builder setTxnToken(com.aliyun.polardbx.binlog.protocol.TxnToken value) { + if (txnTokenBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + tokenOneof_ = value; + onChanged(); + } else { + txnTokenBuilder_.setMessage(value); + } + tokenOneofCase_ = 1; + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + */ + public Builder setTxnToken( + com.aliyun.polardbx.binlog.protocol.TxnToken.Builder builderForValue) { + if (txnTokenBuilder_ == null) { + tokenOneof_ = builderForValue.build(); + onChanged(); + } else { + txnTokenBuilder_.setMessage(builderForValue.build()); + } + tokenOneofCase_ = 1; + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + */ + public Builder mergeTxnToken(com.aliyun.polardbx.binlog.protocol.TxnToken value) { + if (txnTokenBuilder_ == null) { + if (tokenOneofCase_ == 1 && + tokenOneof_ != com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance()) { + tokenOneof_ = com.aliyun.polardbx.binlog.protocol.TxnToken.newBuilder((com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_) + .mergeFrom(value).buildPartial(); + } else { + tokenOneof_ = value; + } + onChanged(); + } else { + if (tokenOneofCase_ == 1) { + txnTokenBuilder_.mergeFrom(value); + } + txnTokenBuilder_.setMessage(value); + } + tokenOneofCase_ = 1; + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + */ + public Builder clearTxnToken() { + if (txnTokenBuilder_ == null) { + if (tokenOneofCase_ == 1) { + tokenOneofCase_ = 0; + tokenOneof_ = null; + onChanged(); + } + } else { + if (tokenOneofCase_ == 1) { + tokenOneofCase_ = 0; + tokenOneof_ = null; + } + txnTokenBuilder_.clear(); + } + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + */ + public com.aliyun.polardbx.binlog.protocol.TxnToken.Builder getTxnTokenBuilder() { + return getTxnTokenFieldBuilder().getBuilder(); } - /** * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; */ @java.lang.Override public com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder getTxnTokenOrBuilder() { + if ((tokenOneofCase_ == 1) && (txnTokenBuilder_ != null)) { + return txnTokenBuilder_.getMessageOrBuilder(); + } else { if (tokenOneofCase_ == 1) { - return (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_; + return (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_; } return com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); + } } - - public static final int TXNMERGEDTOKEN_FIELD_NUMBER = 2; - + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnToken, com.aliyun.polardbx.binlog.protocol.TxnToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder> + getTxnTokenFieldBuilder() { + if (txnTokenBuilder_ == null) { + if (!(tokenOneofCase_ == 1)) { + tokenOneof_ = com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); + } + txnTokenBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnToken, com.aliyun.polardbx.binlog.protocol.TxnToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder>( + (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_, + getParentForChildren(), + isClean()); + tokenOneof_ = null; + } + tokenOneofCase_ = 1; + onChanged();; + return txnTokenBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnMergedToken, com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder> txnMergedTokenBuilder_; /** * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - * * @return Whether the txnMergedToken field is set. */ @java.lang.Override public boolean hasTxnMergedToken() { - return tokenOneofCase_ == 2; + return tokenOneofCase_ == 2; } - /** * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - * * @return The txnMergedToken. */ @java.lang.Override public com.aliyun.polardbx.binlog.protocol.TxnMergedToken getTxnMergedToken() { + if (txnMergedTokenBuilder_ == null) { + if (tokenOneofCase_ == 2) { + return (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_; + } + return com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); + } else { if (tokenOneofCase_ == 2) { - return (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_; + return txnMergedTokenBuilder_.getMessage(); } return com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); + } } - /** * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; */ - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder getTxnMergedTokenOrBuilder() { - if (tokenOneofCase_ == 2) { - return (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_; - } - return com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); + public Builder setTxnMergedToken(com.aliyun.polardbx.binlog.protocol.TxnMergedToken value) { + if (txnMergedTokenBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + tokenOneof_ = value; + onChanged(); + } else { + txnMergedTokenBuilder_.setMessage(value); + } + tokenOneofCase_ = 2; + return this; } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } - - memoizedIsInitialized = 1; - return true; + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + */ + public Builder setTxnMergedToken( + com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder builderForValue) { + if (txnMergedTokenBuilder_ == null) { + tokenOneof_ = builderForValue.build(); + onChanged(); + } else { + txnMergedTokenBuilder_.setMessage(builderForValue.build()); + } + tokenOneofCase_ = 2; + return this; } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (tokenOneofCase_ == 1) { - output.writeMessage(1, (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_); - } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + */ + public Builder mergeTxnMergedToken(com.aliyun.polardbx.binlog.protocol.TxnMergedToken value) { + if (txnMergedTokenBuilder_ == null) { + if (tokenOneofCase_ == 2 && + tokenOneof_ != com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance()) { + tokenOneof_ = com.aliyun.polardbx.binlog.protocol.TxnMergedToken.newBuilder((com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_) + .mergeFrom(value).buildPartial(); + } else { + tokenOneof_ = value; + } + onChanged(); + } else { if (tokenOneofCase_ == 2) { - output.writeMessage(2, (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_); + txnMergedTokenBuilder_.mergeFrom(value); } - unknownFields.writeTo(output); + txnMergedTokenBuilder_.setMessage(value); + } + tokenOneofCase_ = 2; + return this; } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) { - return size; - } - - size = 0; - if (tokenOneofCase_ == 1) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + */ + public Builder clearTxnMergedToken() { + if (txnMergedTokenBuilder_ == null) { + if (tokenOneofCase_ == 2) { + tokenOneofCase_ = 0; + tokenOneof_ = null; + onChanged(); } + } else { if (tokenOneofCase_ == 2) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(2, (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_); + tokenOneofCase_ = 0; + tokenOneof_ = null; } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; + txnMergedTokenBuilder_.clear(); + } + return this; } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.TxnTag)) { - return super.equals(obj); - } - com.aliyun.polardbx.binlog.protocol.TxnTag other = (com.aliyun.polardbx.binlog.protocol.TxnTag) obj; - - if (!getTokenOneofCase().equals(other.getTokenOneofCase())) { - return false; - } - switch (tokenOneofCase_) { - case 1: - if (!getTxnToken() - .equals(other.getTxnToken())) { - return false; - } - break; - case 2: - if (!getTxnMergedToken() - .equals(other.getTxnMergedToken())) { - return false; - } - break; - case 0: - default: - } - if (!unknownFields.equals(other.unknownFields)) { - return false; - } - return true; + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + */ + public com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder getTxnMergedTokenBuilder() { + return getTxnMergedTokenFieldBuilder().getBuilder(); } - + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + */ @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - switch (tokenOneofCase_) { - case 1: - hash = (37 * hash) + TXNTOKEN_FIELD_NUMBER; - hash = (53 * hash) + getTxnToken().hashCode(); - break; - case 2: - hash = (37 * hash) + TXNMERGEDTOKEN_FIELD_NUMBER; - hash = (53 * hash) + getTxnMergedToken().hashCode(); - break; - case 0: - default: + public com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder getTxnMergedTokenOrBuilder() { + if ((tokenOneofCase_ == 2) && (txnMergedTokenBuilder_ != null)) { + return txnMergedTokenBuilder_.getMessageOrBuilder(); + } else { + if (tokenOneofCase_ == 2) { + return (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_; } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.aliyun.polardbx.binlog.protocol.TxnTag parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnTag parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnTag parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnTag parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnTag parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnTag parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnTag parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnTag parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnTag parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnTag parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnTag parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + return com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); + } } - - public static com.aliyun.polardbx.binlog.protocol.TxnTag parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnMergedToken, com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder> + getTxnMergedTokenFieldBuilder() { + if (txnMergedTokenBuilder_ == null) { + if (!(tokenOneofCase_ == 2)) { + tokenOneof_ = com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); + } + txnMergedTokenBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + com.aliyun.polardbx.binlog.protocol.TxnMergedToken, com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder>( + (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_, + getParentForChildren(), + isClean()); + tokenOneof_ = null; + } + tokenOneofCase_ = 2; + onChanged();; + return txnMergedTokenBuilder_; } - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.TxnTag prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); } @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnTag} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.TxnTag) - com.aliyun.polardbx.binlog.protocol.TxnTagOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnTag_descriptor; - } + // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.TxnTag) + } - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnTag_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.aliyun.polardbx.binlog.protocol.TxnTag.class, - com.aliyun.polardbx.binlog.protocol.TxnTag.Builder.class); - } + // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.TxnTag) + private static final com.aliyun.polardbx.binlog.protocol.TxnTag DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.TxnTag(); + } - // Construct using com.aliyun.polardbx.binlog.protocol.TxnTag.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - @java.lang.Override - public Builder clear() { - super.clear(); - tokenOneofCase_ = 0; - tokenOneof_ = null; - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnTag_descriptor; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnTag getDefaultInstanceForType() { - return com.aliyun.polardbx.binlog.protocol.TxnTag.getDefaultInstance(); - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnTag build() { - com.aliyun.polardbx.binlog.protocol.TxnTag result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnTag buildPartial() { - com.aliyun.polardbx.binlog.protocol.TxnTag result = new com.aliyun.polardbx.binlog.protocol.TxnTag(this); - if (tokenOneofCase_ == 1) { - if (txnTokenBuilder_ == null) { - result.tokenOneof_ = tokenOneof_; - } else { - result.tokenOneof_ = txnTokenBuilder_.build(); - } - } - if (tokenOneofCase_ == 2) { - if (txnMergedTokenBuilder_ == null) { - result.tokenOneof_ = tokenOneof_; - } else { - result.tokenOneof_ = txnMergedTokenBuilder_.build(); - } - } - result.tokenOneofCase_ = tokenOneofCase_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.aliyun.polardbx.binlog.protocol.TxnTag) { - return mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnTag) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.TxnTag other) { - if (other == com.aliyun.polardbx.binlog.protocol.TxnTag.getDefaultInstance()) { - return this; - } - switch (other.getTokenOneofCase()) { - case TXNTOKEN: { - mergeTxnToken(other.getTxnToken()); - break; - } - case TXNMERGEDTOKEN: { - mergeTxnMergedToken(other.getTxnMergedToken()); - break; - } - case TOKENONEOF_NOT_SET: { - break; - } - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } + public static com.aliyun.polardbx.binlog.protocol.TxnTag getDefaultInstance() { + return DEFAULT_INSTANCE; + } - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.aliyun.polardbx.binlog.protocol.TxnTag parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.aliyun.polardbx.binlog.protocol.TxnTag) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private int tokenOneofCase_ = 0; - private java.lang.Object tokenOneof_; - - public TokenOneofCase - getTokenOneofCase() { - return TokenOneofCase.forNumber( - tokenOneofCase_); - } - - public Builder clearTokenOneof() { - tokenOneofCase_ = 0; - tokenOneof_ = null; - onChanged(); - return this; - } - - private com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnToken, com.aliyun.polardbx.binlog.protocol.TxnToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder> - txnTokenBuilder_; - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - * - * @return Whether the txnToken field is set. - */ - @java.lang.Override - public boolean hasTxnToken() { - return tokenOneofCase_ == 1; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - * - * @return The txnToken. - */ - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnToken getTxnToken() { - if (txnTokenBuilder_ == null) { - if (tokenOneofCase_ == 1) { - return (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_; - } - return com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); - } else { - if (tokenOneofCase_ == 1) { - return txnTokenBuilder_.getMessage(); - } - return com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); - } - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - */ - public Builder setTxnToken(com.aliyun.polardbx.binlog.protocol.TxnToken value) { - if (txnTokenBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - tokenOneof_ = value; - onChanged(); - } else { - txnTokenBuilder_.setMessage(value); - } - tokenOneofCase_ = 1; - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - */ - public Builder setTxnToken( - com.aliyun.polardbx.binlog.protocol.TxnToken.Builder builderForValue) { - if (txnTokenBuilder_ == null) { - tokenOneof_ = builderForValue.build(); - onChanged(); - } else { - txnTokenBuilder_.setMessage(builderForValue.build()); - } - tokenOneofCase_ = 1; - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - */ - public Builder mergeTxnToken(com.aliyun.polardbx.binlog.protocol.TxnToken value) { - if (txnTokenBuilder_ == null) { - if (tokenOneofCase_ == 1 && - tokenOneof_ != com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance()) { - tokenOneof_ = com.aliyun.polardbx.binlog.protocol.TxnToken - .newBuilder((com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_) - .mergeFrom(value).buildPartial(); - } else { - tokenOneof_ = value; - } - onChanged(); - } else { - if (tokenOneofCase_ == 1) { - txnTokenBuilder_.mergeFrom(value); - } - txnTokenBuilder_.setMessage(value); - } - tokenOneofCase_ = 1; - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - */ - public Builder clearTxnToken() { - if (txnTokenBuilder_ == null) { - if (tokenOneofCase_ == 1) { - tokenOneofCase_ = 0; - tokenOneof_ = null; - onChanged(); - } - } else { - if (tokenOneofCase_ == 1) { - tokenOneofCase_ = 0; - tokenOneof_ = null; - } - txnTokenBuilder_.clear(); - } - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - */ - public com.aliyun.polardbx.binlog.protocol.TxnToken.Builder getTxnTokenBuilder() { - return getTxnTokenFieldBuilder().getBuilder(); - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - */ - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder getTxnTokenOrBuilder() { - if ((tokenOneofCase_ == 1) && (txnTokenBuilder_ != null)) { - return txnTokenBuilder_.getMessageOrBuilder(); - } else { - if (tokenOneofCase_ == 1) { - return (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_; - } - return com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); - } - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnToken, com.aliyun.polardbx.binlog.protocol.TxnToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder> - getTxnTokenFieldBuilder() { - if (txnTokenBuilder_ == null) { - if (!(tokenOneofCase_ == 1)) { - tokenOneof_ = com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); - } - txnTokenBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnToken, com.aliyun.polardbx.binlog.protocol.TxnToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder>( - (com.aliyun.polardbx.binlog.protocol.TxnToken) tokenOneof_, - getParentForChildren(), - isClean()); - tokenOneof_ = null; - } - tokenOneofCase_ = 1; - onChanged(); - ; - return txnTokenBuilder_; - } - - private com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnMergedToken, com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder> - txnMergedTokenBuilder_; - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - * - * @return Whether the txnMergedToken field is set. - */ - @java.lang.Override - public boolean hasTxnMergedToken() { - return tokenOneofCase_ == 2; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - * - * @return The txnMergedToken. - */ - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnMergedToken getTxnMergedToken() { - if (txnMergedTokenBuilder_ == null) { - if (tokenOneofCase_ == 2) { - return (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_; - } - return com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); - } else { - if (tokenOneofCase_ == 2) { - return txnMergedTokenBuilder_.getMessage(); - } - return com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); - } - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - */ - public Builder setTxnMergedToken(com.aliyun.polardbx.binlog.protocol.TxnMergedToken value) { - if (txnMergedTokenBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - tokenOneof_ = value; - onChanged(); - } else { - txnMergedTokenBuilder_.setMessage(value); - } - tokenOneofCase_ = 2; - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - */ - public Builder setTxnMergedToken( - com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder builderForValue) { - if (txnMergedTokenBuilder_ == null) { - tokenOneof_ = builderForValue.build(); - onChanged(); - } else { - txnMergedTokenBuilder_.setMessage(builderForValue.build()); - } - tokenOneofCase_ = 2; - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - */ - public Builder mergeTxnMergedToken(com.aliyun.polardbx.binlog.protocol.TxnMergedToken value) { - if (txnMergedTokenBuilder_ == null) { - if (tokenOneofCase_ == 2 && - tokenOneof_ != com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance()) { - tokenOneof_ = com.aliyun.polardbx.binlog.protocol.TxnMergedToken - .newBuilder((com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_) - .mergeFrom(value).buildPartial(); - } else { - tokenOneof_ = value; - } - onChanged(); - } else { - if (tokenOneofCase_ == 2) { - txnMergedTokenBuilder_.mergeFrom(value); - } - txnMergedTokenBuilder_.setMessage(value); - } - tokenOneofCase_ = 2; - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - */ - public Builder clearTxnMergedToken() { - if (txnMergedTokenBuilder_ == null) { - if (tokenOneofCase_ == 2) { - tokenOneofCase_ = 0; - tokenOneof_ = null; - onChanged(); - } - } else { - if (tokenOneofCase_ == 2) { - tokenOneofCase_ = 0; - tokenOneof_ = null; - } - txnMergedTokenBuilder_.clear(); - } - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - */ - public com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder getTxnMergedTokenBuilder() { - return getTxnMergedTokenFieldBuilder().getBuilder(); - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - */ - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder getTxnMergedTokenOrBuilder() { - if ((tokenOneofCase_ == 2) && (txnMergedTokenBuilder_ != null)) { - return txnMergedTokenBuilder_.getMessageOrBuilder(); - } else { - if (tokenOneofCase_ == 2) { - return (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_; - } - return com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); - } - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnMergedToken, com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder> - getTxnMergedTokenFieldBuilder() { - if (txnMergedTokenBuilder_ == null) { - if (!(tokenOneofCase_ == 2)) { - tokenOneof_ = com.aliyun.polardbx.binlog.protocol.TxnMergedToken.getDefaultInstance(); - } - txnMergedTokenBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - com.aliyun.polardbx.binlog.protocol.TxnMergedToken, com.aliyun.polardbx.binlog.protocol.TxnMergedToken.Builder, com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder>( - (com.aliyun.polardbx.binlog.protocol.TxnMergedToken) tokenOneof_, - getParentForChildren(), - isClean()); - tokenOneof_ = null; - } - tokenOneofCase_ = 2; - onChanged(); - ; - return txnMergedTokenBuilder_; - } - - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.TxnTag) - } - - // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.TxnTag) - private static final com.aliyun.polardbx.binlog.protocol.TxnTag DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.TxnTag(); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnTag getDefaultInstance() { - return DEFAULT_INSTANCE; + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public TxnTag parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TxnTag(input, extensionRegistry); } + }; - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public TxnTag parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new TxnTag(input, extensionRegistry); - } - }; + public static com.google.protobuf.Parser parser() { + return PARSER; + } - public static com.google.protobuf.Parser parser() { - return PARSER; - } + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnTag getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnTag getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnTagOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnTagOrBuilder.java index d454342a..6847fe2a 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnTagOrBuilder.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnTagOrBuilder.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -24,43 +7,35 @@ public interface TxnTagOrBuilder extends // @@protoc_insertion_point(interface_extends:com.aliyun.polardbx.binlog.protocol.TxnTag) com.google.protobuf.MessageOrBuilder { - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - * - * @return Whether the txnToken field is set. - */ - boolean hasTxnToken(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - * - * @return The txnToken. - */ - com.aliyun.polardbx.binlog.protocol.TxnToken getTxnToken(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; - */ - com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder getTxnTokenOrBuilder(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - * - * @return Whether the txnMergedToken field is set. - */ - boolean hasTxnMergedToken(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - * - * @return The txnMergedToken. - */ - com.aliyun.polardbx.binlog.protocol.TxnMergedToken getTxnMergedToken(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; - */ - com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder getTxnMergedTokenOrBuilder(); - - public com.aliyun.polardbx.binlog.protocol.TxnTag.TokenOneofCase getTokenOneofCase(); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + * @return Whether the txnToken field is set. + */ + boolean hasTxnToken(); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + * @return The txnToken. + */ + com.aliyun.polardbx.binlog.protocol.TxnToken getTxnToken(); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnToken txnToken = 1; + */ + com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder getTxnTokenOrBuilder(); + + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + * @return Whether the txnMergedToken field is set. + */ + boolean hasTxnMergedToken(); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + * @return The txnMergedToken. + */ + com.aliyun.polardbx.binlog.protocol.TxnMergedToken getTxnMergedToken(); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnMergedToken txnMergedToken = 2; + */ + com.aliyun.polardbx.binlog.protocol.TxnMergedTokenOrBuilder getTxnMergedTokenOrBuilder(); + + public com.aliyun.polardbx.binlog.protocol.TxnTag.TokenOneofCase getTokenOneofCase(); } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnToken.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnToken.java index 38fe1550..1fce14a7 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnToken.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnToken.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -27,2061 +10,2082 @@ public final class TxnToken extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:com.aliyun.polardbx.binlog.protocol.TxnToken) TxnTokenOrBuilder { - private static final long serialVersionUID = 0L; +private static final long serialVersionUID = 0L; + // Use TxnToken.newBuilder() to construct. + private TxnToken(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TxnToken() { + tso_ = ""; + txnId_ = ""; + partitionId_ = ""; + originMergeSourceId_ = ""; + type_ = 0; + schema_ = ""; + allParties_ = com.google.protobuf.LazyStringArrayList.EMPTY; + payload_ = com.google.protobuf.ByteString.EMPTY; + table_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new TxnToken(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TxnToken( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + tso_ = s; + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + txnId_ = s; + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + partitionId_ = s; + break; + } + case 34: { + java.lang.String s = input.readStringRequireUtf8(); + + originMergeSourceId_ = s; + break; + } + case 40: { + int rawValue = input.readEnum(); + + type_ = rawValue; + break; + } + case 48: { + + xaTxn_ = input.readBool(); + break; + } + case 56: { + + tsoTransaction_ = input.readBool(); + break; + } + case 64: { + + txnSize_ = input.readInt32(); + break; + } + case 74: { + java.lang.String s = input.readStringRequireUtf8(); + + schema_ = s; + break; + } + case 82: { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + allParties_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000001; + } + allParties_.add(s); + break; + } + case 90: { + + payload_ = input.readBytes(); + break; + } + case 96: { + + snapshotSeq_ = input.readInt64(); + break; + } + case 106: { + java.lang.String s = input.readStringRequireUtf8(); + + table_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + allParties_ = allParties_.getUnmodifiableView(); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.binlog.protocol.TxnToken.class, com.aliyun.polardbx.binlog.protocol.TxnToken.Builder.class); + } + + public static final int TSO_FIELD_NUMBER = 1; + private volatile java.lang.Object tso_; + /** + * string tso = 1; + * @return The tso. + */ + @java.lang.Override + public java.lang.String getTso() { + java.lang.Object ref = tso_; + 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(); + tso_ = s; + return s; + } + } + /** + * string tso = 1; + * @return The bytes for tso. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getTsoBytes() { + java.lang.Object ref = tso_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + tso_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TXNID_FIELD_NUMBER = 2; + private volatile java.lang.Object txnId_; + /** + * string txnId = 2; + * @return The txnId. + */ + @java.lang.Override + public java.lang.String getTxnId() { + java.lang.Object ref = txnId_; + 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(); + txnId_ = s; + return s; + } + } + /** + * string txnId = 2; + * @return The bytes for txnId. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getTxnIdBytes() { + java.lang.Object ref = txnId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + txnId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PARTITIONID_FIELD_NUMBER = 3; + private volatile java.lang.Object partitionId_; + /** + * string partitionId = 3; + * @return The partitionId. + */ + @java.lang.Override + public java.lang.String getPartitionId() { + java.lang.Object ref = partitionId_; + 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(); + partitionId_ = s; + return s; + } + } + /** + * string partitionId = 3; + * @return The bytes for partitionId. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getPartitionIdBytes() { + java.lang.Object ref = partitionId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + partitionId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ORIGINMERGESOURCEID_FIELD_NUMBER = 4; + private volatile java.lang.Object originMergeSourceId_; + /** + * string originMergeSourceId = 4; + * @return The originMergeSourceId. + */ + @java.lang.Override + public java.lang.String getOriginMergeSourceId() { + java.lang.Object ref = originMergeSourceId_; + 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(); + originMergeSourceId_ = s; + return s; + } + } + /** + * string originMergeSourceId = 4; + * @return The bytes for originMergeSourceId. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getOriginMergeSourceIdBytes() { + java.lang.Object ref = originMergeSourceId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + originMergeSourceId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TYPE_FIELD_NUMBER = 5; + private int type_; + /** + * .com.aliyun.polardbx.binlog.protocol.TxnType type = 5; + * @return The enum numeric value on the wire for type. + */ + @java.lang.Override public int getTypeValue() { + return type_; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnType type = 5; + * @return The type. + */ + @java.lang.Override public com.aliyun.polardbx.binlog.protocol.TxnType getType() { + @SuppressWarnings("deprecation") + com.aliyun.polardbx.binlog.protocol.TxnType result = com.aliyun.polardbx.binlog.protocol.TxnType.valueOf(type_); + return result == null ? com.aliyun.polardbx.binlog.protocol.TxnType.UNRECOGNIZED : result; + } + + public static final int XATXN_FIELD_NUMBER = 6; + private boolean xaTxn_; + /** + * bool xaTxn = 6; + * @return The xaTxn. + */ + @java.lang.Override + public boolean getXaTxn() { + return xaTxn_; + } + + public static final int TSOTRANSACTION_FIELD_NUMBER = 7; + private boolean tsoTransaction_; + /** + *
+   **
+   *标识是否为Tso事务。虽然【Tso事务】和【NoTso事务】的Token都有tso字段,
+   *但是【NoTso事务】的tso是根据其前序【Tso事务】的真实tso生成的虚拟tso
+   * 
+ * + * bool tsoTransaction = 7; + * @return The tsoTransaction. + */ + @java.lang.Override + public boolean getTsoTransaction() { + return tsoTransaction_; + } + + public static final int TXNSIZE_FIELD_NUMBER = 8; + private int txnSize_; + /** + *
+   **
+   *该事务下的所有LogEvent的个数,注意:不是某个批次的的个数
+   * 
+ * + * int32 txnSize = 8; + * @return The txnSize. + */ + @java.lang.Override + public int getTxnSize() { + return txnSize_; + } + + public static final int SCHEMA_FIELD_NUMBER = 9; + private volatile java.lang.Object schema_; + /** + *
+   **
+   *1.dumper生成事务的begin头时使用
+   *2.ddl场景下标识ddl sql对应的库名
+   * 
+ * + * string schema = 9; + * @return The schema. + */ + @java.lang.Override + public java.lang.String getSchema() { + java.lang.Object ref = schema_; + 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(); + schema_ = s; + return s; + } + } + /** + *
+   **
+   *1.dumper生成事务的begin头时使用
+   *2.ddl场景下标识ddl sql对应的库名
+   * 
+ * + * string schema = 9; + * @return The bytes for schema. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getSchemaBytes() { + java.lang.Object ref = schema_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + schema_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ALLPARTIES_FIELD_NUMBER = 10; + private com.google.protobuf.LazyStringList allParties_; + /** + *
+   **
+   *该事务的所有参与者
+   * 
+ * + * repeated string allParties = 10; + * @return A list containing the allParties. + */ + public com.google.protobuf.ProtocolStringList + getAllPartiesList() { + return allParties_; + } + /** + *
+   **
+   *该事务的所有参与者
+   * 
+ * + * repeated string allParties = 10; + * @return The count of allParties. + */ + public int getAllPartiesCount() { + return allParties_.size(); + } + /** + *
+   **
+   *该事务的所有参与者
+   * 
+ * + * repeated string allParties = 10; + * @param index The index of the element to return. + * @return The allParties at the given index. + */ + public java.lang.String getAllParties(int index) { + return allParties_.get(index); + } + /** + *
+   **
+   *该事务的所有参与者
+   * 
+ * + * repeated string allParties = 10; + * @param index The index of the value to return. + * @return The bytes of the allParties at the given index. + */ + public com.google.protobuf.ByteString + getAllPartiesBytes(int index) { + return allParties_.getByteString(index); + } + + public static final int PAYLOAD_FIELD_NUMBER = 11; + private com.google.protobuf.ByteString payload_; + /** + *
+   **
+   *一些特殊的TxnToken,没有TxnItem的概念,此时通过payload字段传输数据
+   * 
+ * + * bytes payload = 11; + * @return The payload. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPayload() { + return payload_; + } + + public static final int SNAPSHOTSEQ_FIELD_NUMBER = 12; + private long snapshotSeq_; + /** + *
+   **
+   *Tso事务专用
+   * 
+ * + * int64 snapshotSeq = 12; + * @return The snapshotSeq. + */ + @java.lang.Override + public long getSnapshotSeq() { + return snapshotSeq_; + } + + public static final int TABLE_FIELD_NUMBER = 13; + private volatile java.lang.Object table_; + /** + *
+   **
+   *表名,非必须
+   * 
+ * + * string table = 13; + * @return The table. + */ + @java.lang.Override + public java.lang.String getTable() { + java.lang.Object ref = table_; + 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(); + table_ = s; + return s; + } + } + /** + *
+   **
+   *表名,非必须
+   * 
+ * + * string table = 13; + * @return The bytes for table. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getTableBytes() { + java.lang.Object ref = table_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + table_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getTsoBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, tso_); + } + if (!getTxnIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, txnId_); + } + if (!getPartitionIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, partitionId_); + } + if (!getOriginMergeSourceIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, originMergeSourceId_); + } + if (type_ != com.aliyun.polardbx.binlog.protocol.TxnType.DML.getNumber()) { + output.writeEnum(5, type_); + } + if (xaTxn_ != false) { + output.writeBool(6, xaTxn_); + } + if (tsoTransaction_ != false) { + output.writeBool(7, tsoTransaction_); + } + if (txnSize_ != 0) { + output.writeInt32(8, txnSize_); + } + if (!getSchemaBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 9, schema_); + } + for (int i = 0; i < allParties_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 10, allParties_.getRaw(i)); + } + if (!payload_.isEmpty()) { + output.writeBytes(11, payload_); + } + if (snapshotSeq_ != 0L) { + output.writeInt64(12, snapshotSeq_); + } + if (!getTableBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 13, table_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getTsoBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, tso_); + } + if (!getTxnIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, txnId_); + } + if (!getPartitionIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, partitionId_); + } + if (!getOriginMergeSourceIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, originMergeSourceId_); + } + if (type_ != com.aliyun.polardbx.binlog.protocol.TxnType.DML.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(5, type_); + } + if (xaTxn_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(6, xaTxn_); + } + if (tsoTransaction_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(7, tsoTransaction_); + } + if (txnSize_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(8, txnSize_); + } + if (!getSchemaBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, schema_); + } + { + int dataSize = 0; + for (int i = 0; i < allParties_.size(); i++) { + dataSize += computeStringSizeNoTag(allParties_.getRaw(i)); + } + size += dataSize; + size += 1 * getAllPartiesList().size(); + } + if (!payload_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(11, payload_); + } + if (snapshotSeq_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(12, snapshotSeq_); + } + if (!getTableBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(13, table_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.TxnToken)) { + return super.equals(obj); + } + com.aliyun.polardbx.binlog.protocol.TxnToken other = (com.aliyun.polardbx.binlog.protocol.TxnToken) obj; + + if (!getTso() + .equals(other.getTso())) return false; + if (!getTxnId() + .equals(other.getTxnId())) return false; + if (!getPartitionId() + .equals(other.getPartitionId())) return false; + if (!getOriginMergeSourceId() + .equals(other.getOriginMergeSourceId())) return false; + if (type_ != other.type_) return false; + if (getXaTxn() + != other.getXaTxn()) return false; + if (getTsoTransaction() + != other.getTsoTransaction()) return false; + if (getTxnSize() + != other.getTxnSize()) return false; + if (!getSchema() + .equals(other.getSchema())) return false; + if (!getAllPartiesList() + .equals(other.getAllPartiesList())) return false; + if (!getPayload() + .equals(other.getPayload())) return false; + if (getSnapshotSeq() + != other.getSnapshotSeq()) return false; + if (!getTable() + .equals(other.getTable())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TSO_FIELD_NUMBER; + hash = (53 * hash) + getTso().hashCode(); + hash = (37 * hash) + TXNID_FIELD_NUMBER; + hash = (53 * hash) + getTxnId().hashCode(); + hash = (37 * hash) + PARTITIONID_FIELD_NUMBER; + hash = (53 * hash) + getPartitionId().hashCode(); + hash = (37 * hash) + ORIGINMERGESOURCEID_FIELD_NUMBER; + hash = (53 * hash) + getOriginMergeSourceId().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + type_; + hash = (37 * hash) + XATXN_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getXaTxn()); + hash = (37 * hash) + TSOTRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getTsoTransaction()); + hash = (37 * hash) + TXNSIZE_FIELD_NUMBER; + hash = (53 * hash) + getTxnSize(); + hash = (37 * hash) + SCHEMA_FIELD_NUMBER; + hash = (53 * hash) + getSchema().hashCode(); + if (getAllPartiesCount() > 0) { + hash = (37 * hash) + ALLPARTIES_FIELD_NUMBER; + hash = (53 * hash) + getAllPartiesList().hashCode(); + } + hash = (37 * hash) + PAYLOAD_FIELD_NUMBER; + hash = (53 * hash) + getPayload().hashCode(); + hash = (37 * hash) + SNAPSHOTSEQ_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getSnapshotSeq()); + hash = (37 * hash) + TABLE_FIELD_NUMBER; + hash = (53 * hash) + getTable().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnToken parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnToken parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.TxnToken prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnToken} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.TxnToken) + com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.binlog.protocol.TxnToken.class, com.aliyun.polardbx.binlog.protocol.TxnToken.Builder.class); + } + + // Construct using com.aliyun.polardbx.binlog.protocol.TxnToken.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } - // Use TxnToken.newBuilder() to construct. - private TxnToken(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } } + @java.lang.Override + public Builder clear() { + super.clear(); + tso_ = ""; + + txnId_ = ""; + + partitionId_ = ""; + + originMergeSourceId_ = ""; + + type_ = 0; + + xaTxn_ = false; + + tsoTransaction_ = false; + + txnSize_ = 0; + + schema_ = ""; + + allParties_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + payload_ = com.google.protobuf.ByteString.EMPTY; - private TxnToken() { - tso_ = ""; - txnId_ = ""; - partitionId_ = ""; - originMergeSourceId_ = ""; - type_ = 0; - beginSchema_ = ""; - allParties_ = com.google.protobuf.LazyStringArrayList.EMPTY; - payload_ = com.google.protobuf.ByteString.EMPTY; + snapshotSeq_ = 0L; + + table_ = ""; + + return this; } @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new TxnToken(); + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_descriptor; } @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; + public com.aliyun.polardbx.binlog.protocol.TxnToken getDefaultInstanceForType() { + return com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); } - private TxnToken( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - 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; - case 10: { - java.lang.String s = input.readStringRequireUtf8(); - - tso_ = s; - break; - } - case 18: { - java.lang.String s = input.readStringRequireUtf8(); - - txnId_ = s; - break; - } - case 26: { - java.lang.String s = input.readStringRequireUtf8(); - - partitionId_ = s; - break; - } - case 34: { - java.lang.String s = input.readStringRequireUtf8(); - - originMergeSourceId_ = s; - break; - } - case 40: { - int rawValue = input.readEnum(); - - type_ = rawValue; - break; - } - case 48: { - - xaTxn_ = input.readBool(); - break; - } - case 56: { - - tsoTransaction_ = input.readBool(); - break; - } - case 64: { - - txnSize_ = input.readInt32(); - break; - } - case 74: { - java.lang.String s = input.readStringRequireUtf8(); - - beginSchema_ = s; - break; - } - case 82: { - java.lang.String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000001) != 0)) { - allParties_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000001; - } - allParties_.add(s); - break; - } - case 90: { - - payload_ = input.readBytes(); - break; - } - case 96: { - - snapshotSeq_ = input.readInt64(); - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000001) != 0)) { - allParties_ = allParties_.getUnmodifiableView(); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnToken build() { + com.aliyun.polardbx.binlog.protocol.TxnToken result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_descriptor; + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnToken buildPartial() { + com.aliyun.polardbx.binlog.protocol.TxnToken result = new com.aliyun.polardbx.binlog.protocol.TxnToken(this); + int from_bitField0_ = bitField0_; + result.tso_ = tso_; + result.txnId_ = txnId_; + result.partitionId_ = partitionId_; + result.originMergeSourceId_ = originMergeSourceId_; + result.type_ = type_; + result.xaTxn_ = xaTxn_; + result.tsoTransaction_ = tsoTransaction_; + result.txnSize_ = txnSize_; + result.schema_ = schema_; + if (((bitField0_ & 0x00000001) != 0)) { + allParties_ = allParties_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.allParties_ = allParties_; + result.payload_ = payload_; + result.snapshotSeq_ = snapshotSeq_; + result.table_ = table_; + onBuilt(); + return result; } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.aliyun.polardbx.binlog.protocol.TxnToken.class, - com.aliyun.polardbx.binlog.protocol.TxnToken.Builder.class); + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.binlog.protocol.TxnToken) { + return mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnToken)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.TxnToken other) { + if (other == com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance()) return this; + if (!other.getTso().isEmpty()) { + tso_ = other.tso_; + onChanged(); + } + if (!other.getTxnId().isEmpty()) { + txnId_ = other.txnId_; + onChanged(); + } + if (!other.getPartitionId().isEmpty()) { + partitionId_ = other.partitionId_; + onChanged(); + } + if (!other.getOriginMergeSourceId().isEmpty()) { + originMergeSourceId_ = other.originMergeSourceId_; + onChanged(); + } + if (other.type_ != 0) { + setTypeValue(other.getTypeValue()); + } + if (other.getXaTxn() != false) { + setXaTxn(other.getXaTxn()); + } + if (other.getTsoTransaction() != false) { + setTsoTransaction(other.getTsoTransaction()); + } + if (other.getTxnSize() != 0) { + setTxnSize(other.getTxnSize()); + } + if (!other.getSchema().isEmpty()) { + schema_ = other.schema_; + onChanged(); + } + if (!other.allParties_.isEmpty()) { + if (allParties_.isEmpty()) { + allParties_ = other.allParties_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureAllPartiesIsMutable(); + allParties_.addAll(other.allParties_); + } + onChanged(); + } + if (other.getPayload() != com.google.protobuf.ByteString.EMPTY) { + setPayload(other.getPayload()); + } + if (other.getSnapshotSeq() != 0L) { + setSnapshotSeq(other.getSnapshotSeq()); + } + if (!other.getTable().isEmpty()) { + table_ = other.table_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; } - public static final int TSO_FIELD_NUMBER = 1; - private volatile java.lang.Object tso_; + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.aliyun.polardbx.binlog.protocol.TxnToken parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.binlog.protocol.TxnToken) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + private java.lang.Object tso_ = ""; /** * string tso = 1; - * * @return The tso. */ - @java.lang.Override public java.lang.String getTso() { - java.lang.Object ref = tso_; - 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(); - tso_ = s; - return s; - } + java.lang.Object ref = tso_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + tso_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - /** * string tso = 1; - * * @return The bytes for tso. */ - @java.lang.Override public com.google.protobuf.ByteString - getTsoBytes() { - java.lang.Object ref = tso_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - tso_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + getTsoBytes() { + java.lang.Object ref = tso_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + tso_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string tso = 1; + * @param value The tso to set. + * @return This builder for chaining. + */ + public Builder setTso( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + tso_ = value; + onChanged(); + return this; + } + /** + * string tso = 1; + * @return This builder for chaining. + */ + public Builder clearTso() { + + tso_ = getDefaultInstance().getTso(); + onChanged(); + return this; + } + /** + * string tso = 1; + * @param value The bytes for tso to set. + * @return This builder for chaining. + */ + public Builder setTsoBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + tso_ = value; + onChanged(); + return this; } - public static final int TXNID_FIELD_NUMBER = 2; - private volatile java.lang.Object txnId_; - + private java.lang.Object txnId_ = ""; /** * string txnId = 2; - * * @return The txnId. */ - @java.lang.Override public java.lang.String getTxnId() { - java.lang.Object ref = txnId_; - 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(); - txnId_ = s; - return s; - } + java.lang.Object ref = txnId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + txnId_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - /** * string txnId = 2; - * * @return The bytes for txnId. */ - @java.lang.Override public com.google.protobuf.ByteString - getTxnIdBytes() { - java.lang.Object ref = txnId_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - txnId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + getTxnIdBytes() { + java.lang.Object ref = txnId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + txnId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string txnId = 2; + * @param value The txnId to set. + * @return This builder for chaining. + */ + public Builder setTxnId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + txnId_ = value; + onChanged(); + return this; + } + /** + * string txnId = 2; + * @return This builder for chaining. + */ + public Builder clearTxnId() { + + txnId_ = getDefaultInstance().getTxnId(); + onChanged(); + return this; + } + /** + * string txnId = 2; + * @param value The bytes for txnId to set. + * @return This builder for chaining. + */ + public Builder setTxnIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + txnId_ = value; + onChanged(); + return this; } - public static final int PARTITIONID_FIELD_NUMBER = 3; - private volatile java.lang.Object partitionId_; - + private java.lang.Object partitionId_ = ""; /** * string partitionId = 3; - * * @return The partitionId. */ - @java.lang.Override public java.lang.String getPartitionId() { - java.lang.Object ref = partitionId_; - 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(); - partitionId_ = s; - return s; - } + java.lang.Object ref = partitionId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + partitionId_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - /** * string partitionId = 3; - * * @return The bytes for partitionId. */ - @java.lang.Override public com.google.protobuf.ByteString - getPartitionIdBytes() { - java.lang.Object ref = partitionId_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - partitionId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + getPartitionIdBytes() { + java.lang.Object ref = partitionId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + partitionId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string partitionId = 3; + * @param value The partitionId to set. + * @return This builder for chaining. + */ + public Builder setPartitionId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + partitionId_ = value; + onChanged(); + return this; + } + /** + * string partitionId = 3; + * @return This builder for chaining. + */ + public Builder clearPartitionId() { + + partitionId_ = getDefaultInstance().getPartitionId(); + onChanged(); + return this; + } + /** + * string partitionId = 3; + * @param value The bytes for partitionId to set. + * @return This builder for chaining. + */ + public Builder setPartitionIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + partitionId_ = value; + onChanged(); + return this; } - public static final int ORIGINMERGESOURCEID_FIELD_NUMBER = 4; - private volatile java.lang.Object originMergeSourceId_; - + private java.lang.Object originMergeSourceId_ = ""; /** * string originMergeSourceId = 4; - * * @return The originMergeSourceId. */ - @java.lang.Override public java.lang.String getOriginMergeSourceId() { - java.lang.Object ref = originMergeSourceId_; - 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(); - originMergeSourceId_ = s; - return s; - } + java.lang.Object ref = originMergeSourceId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + originMergeSourceId_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - /** * string originMergeSourceId = 4; - * * @return The bytes for originMergeSourceId. */ - @java.lang.Override public com.google.protobuf.ByteString - getOriginMergeSourceIdBytes() { - java.lang.Object ref = originMergeSourceId_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - originMergeSourceId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + getOriginMergeSourceIdBytes() { + java.lang.Object ref = originMergeSourceId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + originMergeSourceId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string originMergeSourceId = 4; + * @param value The originMergeSourceId to set. + * @return This builder for chaining. + */ + public Builder setOriginMergeSourceId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + originMergeSourceId_ = value; + onChanged(); + return this; + } + /** + * string originMergeSourceId = 4; + * @return This builder for chaining. + */ + public Builder clearOriginMergeSourceId() { + + originMergeSourceId_ = getDefaultInstance().getOriginMergeSourceId(); + onChanged(); + return this; + } + /** + * string originMergeSourceId = 4; + * @param value The bytes for originMergeSourceId to set. + * @return This builder for chaining. + */ + public Builder setOriginMergeSourceIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + originMergeSourceId_ = value; + onChanged(); + return this; } - public static final int TYPE_FIELD_NUMBER = 5; - private int type_; - + private int type_ = 0; /** * .com.aliyun.polardbx.binlog.protocol.TxnType type = 5; - * * @return The enum numeric value on the wire for type. */ - @java.lang.Override - public int getTypeValue() { - return type_; + @java.lang.Override public int getTypeValue() { + return type_; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnType type = 5; + * @param value The enum numeric value on the wire for type to set. + * @return This builder for chaining. + */ + public Builder setTypeValue(int value) { + + type_ = value; + onChanged(); + return this; } - /** * .com.aliyun.polardbx.binlog.protocol.TxnType type = 5; - * * @return The type. */ @java.lang.Override public com.aliyun.polardbx.binlog.protocol.TxnType getType() { - @SuppressWarnings("deprecation") - com.aliyun.polardbx.binlog.protocol.TxnType result = com.aliyun.polardbx.binlog.protocol.TxnType.valueOf(type_); - return result == null ? com.aliyun.polardbx.binlog.protocol.TxnType.UNRECOGNIZED : result; + @SuppressWarnings("deprecation") + com.aliyun.polardbx.binlog.protocol.TxnType result = com.aliyun.polardbx.binlog.protocol.TxnType.valueOf(type_); + return result == null ? com.aliyun.polardbx.binlog.protocol.TxnType.UNRECOGNIZED : result; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnType type = 5; + * @param value The type to set. + * @return This builder for chaining. + */ + public Builder setType(com.aliyun.polardbx.binlog.protocol.TxnType value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .com.aliyun.polardbx.binlog.protocol.TxnType type = 5; + * @return This builder for chaining. + */ + public Builder clearType() { + + type_ = 0; + onChanged(); + return this; } - public static final int XATXN_FIELD_NUMBER = 6; - private boolean xaTxn_; - + private boolean xaTxn_ ; /** * bool xaTxn = 6; - * * @return The xaTxn. */ @java.lang.Override public boolean getXaTxn() { - return xaTxn_; + return xaTxn_; + } + /** + * bool xaTxn = 6; + * @param value The xaTxn to set. + * @return This builder for chaining. + */ + public Builder setXaTxn(boolean value) { + + xaTxn_ = value; + onChanged(); + return this; + } + /** + * bool xaTxn = 6; + * @return This builder for chaining. + */ + public Builder clearXaTxn() { + + xaTxn_ = false; + onChanged(); + return this; } - public static final int TSOTRANSACTION_FIELD_NUMBER = 7; - private boolean tsoTransaction_; - + private boolean tsoTransaction_ ; /** *
-     * *
-     * 标识是否为Tso事务。虽然【Tso事务】和【NoTso事务】的Token都有tso字段,
-     * 但是【NoTso事务】的tso是根据其前序【Tso事务】的真实tso生成的虚拟tso
+     **
+     *标识是否为Tso事务。虽然【Tso事务】和【NoTso事务】的Token都有tso字段,
+     *但是【NoTso事务】的tso是根据其前序【Tso事务】的真实tso生成的虚拟tso
      * 
* * bool tsoTransaction = 7; - * * @return The tsoTransaction. */ @java.lang.Override public boolean getTsoTransaction() { - return tsoTransaction_; + return tsoTransaction_; } - - public static final int TXNSIZE_FIELD_NUMBER = 8; - private int txnSize_; - /** *
-     * *
-     * 该事务下的所有LogEvent的个数,注意:不是某个批次的的个数
+     **
+     *标识是否为Tso事务。虽然【Tso事务】和【NoTso事务】的Token都有tso字段,
+     *但是【NoTso事务】的tso是根据其前序【Tso事务】的真实tso生成的虚拟tso
      * 
* - * int32 txnSize = 8; - * - * @return The txnSize. + * bool tsoTransaction = 7; + * @param value The tsoTransaction to set. + * @return This builder for chaining. */ - @java.lang.Override - public int getTxnSize() { - return txnSize_; + public Builder setTsoTransaction(boolean value) { + + tsoTransaction_ = value; + onChanged(); + return this; } - - public static final int BEGINSCHEMA_FIELD_NUMBER = 9; - private volatile java.lang.Object beginSchema_; - /** *
-     * *
-     * dumper生成事务的begin头时使用
+     **
+     *标识是否为Tso事务。虽然【Tso事务】和【NoTso事务】的Token都有tso字段,
+     *但是【NoTso事务】的tso是根据其前序【Tso事务】的真实tso生成的虚拟tso
      * 
* - * string beginSchema = 9; - * - * @return The beginSchema. + * bool tsoTransaction = 7; + * @return This builder for chaining. */ - @java.lang.Override - public java.lang.String getBeginSchema() { - java.lang.Object ref = beginSchema_; - 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(); - beginSchema_ = s; - return s; - } + public Builder clearTsoTransaction() { + + tsoTransaction_ = false; + onChanged(); + return this; } + private int txnSize_ ; /** *
-     * *
-     * dumper生成事务的begin头时使用
+     **
+     *该事务下的所有LogEvent的个数,注意:不是某个批次的的个数
      * 
* - * string beginSchema = 9; - * - * @return The bytes for beginSchema. + * int32 txnSize = 8; + * @return The txnSize. */ @java.lang.Override - public com.google.protobuf.ByteString - getBeginSchemaBytes() { - java.lang.Object ref = beginSchema_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - beginSchema_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + public int getTxnSize() { + return txnSize_; + } + /** + *
+     **
+     *该事务下的所有LogEvent的个数,注意:不是某个批次的的个数
+     * 
+ * + * int32 txnSize = 8; + * @param value The txnSize to set. + * @return This builder for chaining. + */ + public Builder setTxnSize(int value) { + + txnSize_ = value; + onChanged(); + return this; + } + /** + *
+     **
+     *该事务下的所有LogEvent的个数,注意:不是某个批次的的个数
+     * 
+ * + * int32 txnSize = 8; + * @return This builder for chaining. + */ + public Builder clearTxnSize() { + + txnSize_ = 0; + onChanged(); + return this; } - public static final int ALLPARTIES_FIELD_NUMBER = 10; - private com.google.protobuf.LazyStringList allParties_; + private java.lang.Object schema_ = ""; + /** + *
+     **
+     *1.dumper生成事务的begin头时使用
+     *2.ddl场景下标识ddl sql对应的库名
+     * 
+ * + * string schema = 9; + * @return The schema. + */ + public java.lang.String getSchema() { + java.lang.Object ref = schema_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + schema_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+     **
+     *1.dumper生成事务的begin头时使用
+     *2.ddl场景下标识ddl sql对应的库名
+     * 
+ * + * string schema = 9; + * @return The bytes for schema. + */ + public com.google.protobuf.ByteString + getSchemaBytes() { + java.lang.Object ref = schema_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + schema_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+     **
+     *1.dumper生成事务的begin头时使用
+     *2.ddl场景下标识ddl sql对应的库名
+     * 
+ * + * string schema = 9; + * @param value The schema to set. + * @return This builder for chaining. + */ + public Builder setSchema( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + schema_ = value; + onChanged(); + return this; + } + /** + *
+     **
+     *1.dumper生成事务的begin头时使用
+     *2.ddl场景下标识ddl sql对应的库名
+     * 
+ * + * string schema = 9; + * @return This builder for chaining. + */ + public Builder clearSchema() { + + schema_ = getDefaultInstance().getSchema(); + onChanged(); + return this; + } + /** + *
+     **
+     *1.dumper生成事务的begin头时使用
+     *2.ddl场景下标识ddl sql对应的库名
+     * 
+ * + * string schema = 9; + * @param value The bytes for schema to set. + * @return This builder for chaining. + */ + public Builder setSchemaBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + schema_ = value; + onChanged(); + return this; + } + private com.google.protobuf.LazyStringList allParties_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureAllPartiesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + allParties_ = new com.google.protobuf.LazyStringArrayList(allParties_); + bitField0_ |= 0x00000001; + } + } /** - * repeated string allParties = 10; + *
+     **
+     *该事务的所有参与者
+     * 
* + * repeated string allParties = 10; * @return A list containing the allParties. */ public com.google.protobuf.ProtocolStringList - getAllPartiesList() { - return allParties_; + getAllPartiesList() { + return allParties_.getUnmodifiableView(); } - /** - * repeated string allParties = 10; + *
+     **
+     *该事务的所有参与者
+     * 
* + * repeated string allParties = 10; * @return The count of allParties. */ public int getAllPartiesCount() { - return allParties_.size(); + return allParties_.size(); } - /** - * repeated string allParties = 10; + *
+     **
+     *该事务的所有参与者
+     * 
* + * repeated string allParties = 10; * @param index The index of the element to return. * @return The allParties at the given index. */ public java.lang.String getAllParties(int index) { - return allParties_.get(index); + return allParties_.get(index); } - /** - * repeated string allParties = 10; + *
+     **
+     *该事务的所有参与者
+     * 
* + * repeated string allParties = 10; * @param index The index of the value to return. * @return The bytes of the allParties at the given index. */ public com.google.protobuf.ByteString - getAllPartiesBytes(int index) { - return allParties_.getByteString(index); + getAllPartiesBytes(int index) { + return allParties_.getByteString(index); + } + /** + *
+     **
+     *该事务的所有参与者
+     * 
+ * + * repeated string allParties = 10; + * @param index The index to set the value at. + * @param value The allParties to set. + * @return This builder for chaining. + */ + public Builder setAllParties( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureAllPartiesIsMutable(); + allParties_.set(index, value); + onChanged(); + return this; + } + /** + *
+     **
+     *该事务的所有参与者
+     * 
+ * + * repeated string allParties = 10; + * @param value The allParties to add. + * @return This builder for chaining. + */ + public Builder addAllParties( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureAllPartiesIsMutable(); + allParties_.add(value); + onChanged(); + return this; + } + /** + *
+     **
+     *该事务的所有参与者
+     * 
+ * + * repeated string allParties = 10; + * @param values The allParties to add. + * @return This builder for chaining. + */ + public Builder addAllAllParties( + java.lang.Iterable values) { + ensureAllPartiesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, allParties_); + onChanged(); + return this; + } + /** + *
+     **
+     *该事务的所有参与者
+     * 
+ * + * repeated string allParties = 10; + * @return This builder for chaining. + */ + public Builder clearAllParties() { + allParties_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + *
+     **
+     *该事务的所有参与者
+     * 
+ * + * repeated string allParties = 10; + * @param value The bytes of the allParties to add. + * @return This builder for chaining. + */ + public Builder addAllPartiesBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureAllPartiesIsMutable(); + allParties_.add(value); + onChanged(); + return this; } - public static final int PAYLOAD_FIELD_NUMBER = 11; - private com.google.protobuf.ByteString payload_; - + private com.google.protobuf.ByteString payload_ = com.google.protobuf.ByteString.EMPTY; /** *
-     * *
-     * 一些特殊的TxnToken,没有TxnItem的概念,此时通过payload字段传输数据
+     **
+     *一些特殊的TxnToken,没有TxnItem的概念,此时通过payload字段传输数据
      * 
* * bytes payload = 11; - * * @return The payload. */ @java.lang.Override public com.google.protobuf.ByteString getPayload() { - return payload_; + return payload_; + } + /** + *
+     **
+     *一些特殊的TxnToken,没有TxnItem的概念,此时通过payload字段传输数据
+     * 
+ * + * bytes payload = 11; + * @param value The payload to set. + * @return This builder for chaining. + */ + public Builder setPayload(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + payload_ = value; + onChanged(); + return this; + } + /** + *
+     **
+     *一些特殊的TxnToken,没有TxnItem的概念,此时通过payload字段传输数据
+     * 
+ * + * bytes payload = 11; + * @return This builder for chaining. + */ + public Builder clearPayload() { + + payload_ = getDefaultInstance().getPayload(); + onChanged(); + return this; } - public static final int SNAPSHOTSEQ_FIELD_NUMBER = 12; - private long snapshotSeq_; - + private long snapshotSeq_ ; /** *
-     * *
-     * Tso事务专用
+     **
+     *Tso事务专用
      * 
* * int64 snapshotSeq = 12; - * * @return The snapshotSeq. */ @java.lang.Override public long getSnapshotSeq() { - return snapshotSeq_; + return snapshotSeq_; } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } - - memoizedIsInitialized = 1; - return true; + /** + *
+     **
+     *Tso事务专用
+     * 
+ * + * int64 snapshotSeq = 12; + * @param value The snapshotSeq to set. + * @return This builder for chaining. + */ + public Builder setSnapshotSeq(long value) { + + snapshotSeq_ = value; + onChanged(); + return this; } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getTsoBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, tso_); - } - if (!getTxnIdBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, txnId_); - } - if (!getPartitionIdBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, partitionId_); - } - if (!getOriginMergeSourceIdBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, originMergeSourceId_); - } - if (type_ != com.aliyun.polardbx.binlog.protocol.TxnType.DML.getNumber()) { - output.writeEnum(5, type_); - } - if (xaTxn_ != false) { - output.writeBool(6, xaTxn_); - } - if (tsoTransaction_ != false) { - output.writeBool(7, tsoTransaction_); - } - if (txnSize_ != 0) { - output.writeInt32(8, txnSize_); - } - if (!getBeginSchemaBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 9, beginSchema_); - } - for (int i = 0; i < allParties_.size(); i++) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 10, allParties_.getRaw(i)); - } - if (!payload_.isEmpty()) { - output.writeBytes(11, payload_); - } - if (snapshotSeq_ != 0L) { - output.writeInt64(12, snapshotSeq_); - } - unknownFields.writeTo(output); + /** + *
+     **
+     *Tso事务专用
+     * 
+ * + * int64 snapshotSeq = 12; + * @return This builder for chaining. + */ + public Builder clearSnapshotSeq() { + + snapshotSeq_ = 0L; + onChanged(); + return this; } - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) { - return size; - } - - size = 0; - if (!getTsoBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, tso_); - } - if (!getTxnIdBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, txnId_); - } - if (!getPartitionIdBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, partitionId_); - } - if (!getOriginMergeSourceIdBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, originMergeSourceId_); - } - if (type_ != com.aliyun.polardbx.binlog.protocol.TxnType.DML.getNumber()) { - size += com.google.protobuf.CodedOutputStream - .computeEnumSize(5, type_); - } - if (xaTxn_ != false) { - size += com.google.protobuf.CodedOutputStream - .computeBoolSize(6, xaTxn_); - } - if (tsoTransaction_ != false) { - size += com.google.protobuf.CodedOutputStream - .computeBoolSize(7, tsoTransaction_); - } - if (txnSize_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(8, txnSize_); - } - if (!getBeginSchemaBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, beginSchema_); - } - { - int dataSize = 0; - for (int i = 0; i < allParties_.size(); i++) { - dataSize += computeStringSizeNoTag(allParties_.getRaw(i)); - } - size += dataSize; - size += 1 * getAllPartiesList().size(); - } - if (!payload_.isEmpty()) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(11, payload_); - } - if (snapshotSeq_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(12, snapshotSeq_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; + private java.lang.Object table_ = ""; + /** + *
+     **
+     *表名,非必须
+     * 
+ * + * string table = 13; + * @return The table. + */ + public java.lang.String getTable() { + java.lang.Object ref = table_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + table_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.TxnToken)) { - return super.equals(obj); - } - com.aliyun.polardbx.binlog.protocol.TxnToken other = (com.aliyun.polardbx.binlog.protocol.TxnToken) obj; - - if (!getTso() - .equals(other.getTso())) { - return false; - } - if (!getTxnId() - .equals(other.getTxnId())) { - return false; - } - if (!getPartitionId() - .equals(other.getPartitionId())) { - return false; - } - if (!getOriginMergeSourceId() - .equals(other.getOriginMergeSourceId())) { - return false; - } - if (type_ != other.type_) { - return false; - } - if (getXaTxn() - != other.getXaTxn()) { - return false; - } - if (getTsoTransaction() - != other.getTsoTransaction()) { - return false; - } - if (getTxnSize() - != other.getTxnSize()) { - return false; - } - if (!getBeginSchema() - .equals(other.getBeginSchema())) { - return false; - } - if (!getAllPartiesList() - .equals(other.getAllPartiesList())) { - return false; - } - if (!getPayload() - .equals(other.getPayload())) { - return false; - } - if (getSnapshotSeq() - != other.getSnapshotSeq()) { - return false; - } - if (!unknownFields.equals(other.unknownFields)) { - return false; - } - return true; + /** + *
+     **
+     *表名,非必须
+     * 
+ * + * string table = 13; + * @return The bytes for table. + */ + public com.google.protobuf.ByteString + getTableBytes() { + java.lang.Object ref = table_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + table_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + TSO_FIELD_NUMBER; - hash = (53 * hash) + getTso().hashCode(); - hash = (37 * hash) + TXNID_FIELD_NUMBER; - hash = (53 * hash) + getTxnId().hashCode(); - hash = (37 * hash) + PARTITIONID_FIELD_NUMBER; - hash = (53 * hash) + getPartitionId().hashCode(); - hash = (37 * hash) + ORIGINMERGESOURCEID_FIELD_NUMBER; - hash = (53 * hash) + getOriginMergeSourceId().hashCode(); - hash = (37 * hash) + TYPE_FIELD_NUMBER; - hash = (53 * hash) + type_; - hash = (37 * hash) + XATXN_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( - getXaTxn()); - hash = (37 * hash) + TSOTRANSACTION_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( - getTsoTransaction()); - hash = (37 * hash) + TXNSIZE_FIELD_NUMBER; - hash = (53 * hash) + getTxnSize(); - hash = (37 * hash) + BEGINSCHEMA_FIELD_NUMBER; - hash = (53 * hash) + getBeginSchema().hashCode(); - if (getAllPartiesCount() > 0) { - hash = (37 * hash) + ALLPARTIES_FIELD_NUMBER; - hash = (53 * hash) + getAllPartiesList().hashCode(); - } - hash = (37 * hash) + PAYLOAD_FIELD_NUMBER; - hash = (53 * hash) + getPayload().hashCode(); - hash = (37 * hash) + SNAPSHOTSEQ_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getSnapshotSeq()); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + /** + *
+     **
+     *表名,非必须
+     * 
+ * + * string table = 13; + * @param value The table to set. + * @return This builder for chaining. + */ + public Builder setTable( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + table_ = value; + onChanged(); + return this; } - - public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + /** + *
+     **
+     *表名,非必须
+     * 
+ * + * string table = 13; + * @return This builder for chaining. + */ + public Builder clearTable() { + + table_ = getDefaultInstance().getTable(); + onChanged(); + return this; } - - public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + /** + *
+     **
+     *表名,非必须
+     * 
+ * + * string table = 13; + * @param value The bytes for table to set. + * @return This builder for chaining. + */ + public Builder setTableBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + table_ = value; + onChanged(); + return this; } - - public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); } - public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } + // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.TxnToken) + } - public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } + // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.TxnToken) + private static final com.aliyun.polardbx.binlog.protocol.TxnToken DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.TxnToken(); + } - public static com.aliyun.polardbx.binlog.protocol.TxnToken parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } + public static com.aliyun.polardbx.binlog.protocol.TxnToken getDefaultInstance() { + return DEFAULT_INSTANCE; + } - public static com.aliyun.polardbx.binlog.protocol.TxnToken parseDelimitedFrom( - java.io.InputStream input, + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public TxnToken parsePartialFrom( + com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + throws com.google.protobuf.InvalidProtocolBufferException { + return new TxnToken(input, extensionRegistry); } + }; - public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } + public static com.google.protobuf.Parser parser() { + return PARSER; + } - public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.TxnToken prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - /** - * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnToken} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.TxnToken) - com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.aliyun.polardbx.binlog.protocol.TxnToken.class, - com.aliyun.polardbx.binlog.protocol.TxnToken.Builder.class); - } - - // Construct using com.aliyun.polardbx.binlog.protocol.TxnToken.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - @java.lang.Override - public Builder clear() { - super.clear(); - tso_ = ""; - - txnId_ = ""; - - partitionId_ = ""; - - originMergeSourceId_ = ""; - - type_ = 0; - - xaTxn_ = false; - - tsoTransaction_ = false; - - txnSize_ = 0; - - beginSchema_ = ""; - - allParties_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); - payload_ = com.google.protobuf.ByteString.EMPTY; - - snapshotSeq_ = 0L; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_descriptor; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnToken getDefaultInstanceForType() { - return com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance(); - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnToken build() { - com.aliyun.polardbx.binlog.protocol.TxnToken result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnToken buildPartial() { - com.aliyun.polardbx.binlog.protocol.TxnToken result = - new com.aliyun.polardbx.binlog.protocol.TxnToken(this); - int from_bitField0_ = bitField0_; - result.tso_ = tso_; - result.txnId_ = txnId_; - result.partitionId_ = partitionId_; - result.originMergeSourceId_ = originMergeSourceId_; - result.type_ = type_; - result.xaTxn_ = xaTxn_; - result.tsoTransaction_ = tsoTransaction_; - result.txnSize_ = txnSize_; - result.beginSchema_ = beginSchema_; - if (((bitField0_ & 0x00000001) != 0)) { - allParties_ = allParties_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.allParties_ = allParties_; - result.payload_ = payload_; - result.snapshotSeq_ = snapshotSeq_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.aliyun.polardbx.binlog.protocol.TxnToken) { - return mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnToken) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.TxnToken other) { - if (other == com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance()) { - return this; - } - if (!other.getTso().isEmpty()) { - tso_ = other.tso_; - onChanged(); - } - if (!other.getTxnId().isEmpty()) { - txnId_ = other.txnId_; - onChanged(); - } - if (!other.getPartitionId().isEmpty()) { - partitionId_ = other.partitionId_; - onChanged(); - } - if (!other.getOriginMergeSourceId().isEmpty()) { - originMergeSourceId_ = other.originMergeSourceId_; - onChanged(); - } - if (other.type_ != 0) { - setTypeValue(other.getTypeValue()); - } - if (other.getXaTxn() != false) { - setXaTxn(other.getXaTxn()); - } - if (other.getTsoTransaction() != false) { - setTsoTransaction(other.getTsoTransaction()); - } - if (other.getTxnSize() != 0) { - setTxnSize(other.getTxnSize()); - } - if (!other.getBeginSchema().isEmpty()) { - beginSchema_ = other.beginSchema_; - onChanged(); - } - if (!other.allParties_.isEmpty()) { - if (allParties_.isEmpty()) { - allParties_ = other.allParties_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureAllPartiesIsMutable(); - allParties_.addAll(other.allParties_); - } - onChanged(); - } - if (other.getPayload() != com.google.protobuf.ByteString.EMPTY) { - setPayload(other.getPayload()); - } - if (other.getSnapshotSeq() != 0L) { - setSnapshotSeq(other.getSnapshotSeq()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.aliyun.polardbx.binlog.protocol.TxnToken parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.aliyun.polardbx.binlog.protocol.TxnToken) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private int bitField0_; - - private java.lang.Object tso_ = ""; - - /** - * string tso = 1; - * - * @return The tso. - */ - public java.lang.String getTso() { - java.lang.Object ref = tso_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - tso_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * string tso = 1; - * - * @return The bytes for tso. - */ - public com.google.protobuf.ByteString - getTsoBytes() { - java.lang.Object ref = tso_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - tso_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string tso = 1; - * - * @param value The tso to set. - * @return This builder for chaining. - */ - public Builder setTso( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - tso_ = value; - onChanged(); - return this; - } - - /** - * string tso = 1; - * - * @return This builder for chaining. - */ - public Builder clearTso() { - - tso_ = getDefaultInstance().getTso(); - onChanged(); - return this; - } - - /** - * string tso = 1; - * - * @param value The bytes for tso to set. - * @return This builder for chaining. - */ - public Builder setTsoBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - tso_ = value; - onChanged(); - return this; - } - - private java.lang.Object txnId_ = ""; - - /** - * string txnId = 2; - * - * @return The txnId. - */ - public java.lang.String getTxnId() { - java.lang.Object ref = txnId_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - txnId_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * string txnId = 2; - * - * @return The bytes for txnId. - */ - public com.google.protobuf.ByteString - getTxnIdBytes() { - java.lang.Object ref = txnId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - txnId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string txnId = 2; - * - * @param value The txnId to set. - * @return This builder for chaining. - */ - public Builder setTxnId( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - txnId_ = value; - onChanged(); - return this; - } - - /** - * string txnId = 2; - * - * @return This builder for chaining. - */ - public Builder clearTxnId() { - - txnId_ = getDefaultInstance().getTxnId(); - onChanged(); - return this; - } - - /** - * string txnId = 2; - * - * @param value The bytes for txnId to set. - * @return This builder for chaining. - */ - public Builder setTxnIdBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - txnId_ = value; - onChanged(); - return this; - } - - private java.lang.Object partitionId_ = ""; - - /** - * string partitionId = 3; - * - * @return The partitionId. - */ - public java.lang.String getPartitionId() { - java.lang.Object ref = partitionId_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - partitionId_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * string partitionId = 3; - * - * @return The bytes for partitionId. - */ - public com.google.protobuf.ByteString - getPartitionIdBytes() { - java.lang.Object ref = partitionId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - partitionId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string partitionId = 3; - * - * @param value The partitionId to set. - * @return This builder for chaining. - */ - public Builder setPartitionId( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - partitionId_ = value; - onChanged(); - return this; - } + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } - /** - * string partitionId = 3; - * - * @return This builder for chaining. - */ - public Builder clearPartitionId() { - - partitionId_ = getDefaultInstance().getPartitionId(); - onChanged(); - return this; - } - - /** - * string partitionId = 3; - * - * @param value The bytes for partitionId to set. - * @return This builder for chaining. - */ - public Builder setPartitionIdBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - partitionId_ = value; - onChanged(); - return this; - } - - private java.lang.Object originMergeSourceId_ = ""; - - /** - * string originMergeSourceId = 4; - * - * @return The originMergeSourceId. - */ - public java.lang.String getOriginMergeSourceId() { - java.lang.Object ref = originMergeSourceId_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - originMergeSourceId_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * string originMergeSourceId = 4; - * - * @return The bytes for originMergeSourceId. - */ - public com.google.protobuf.ByteString - getOriginMergeSourceIdBytes() { - java.lang.Object ref = originMergeSourceId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - originMergeSourceId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string originMergeSourceId = 4; - * - * @param value The originMergeSourceId to set. - * @return This builder for chaining. - */ - public Builder setOriginMergeSourceId( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - originMergeSourceId_ = value; - onChanged(); - return this; - } - - /** - * string originMergeSourceId = 4; - * - * @return This builder for chaining. - */ - public Builder clearOriginMergeSourceId() { - - originMergeSourceId_ = getDefaultInstance().getOriginMergeSourceId(); - onChanged(); - return this; - } - - /** - * string originMergeSourceId = 4; - * - * @param value The bytes for originMergeSourceId to set. - * @return This builder for chaining. - */ - public Builder setOriginMergeSourceIdBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - originMergeSourceId_ = value; - onChanged(); - return this; - } - - private int type_ = 0; - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnType type = 5; - * - * @return The enum numeric value on the wire for type. - */ - @java.lang.Override - public int getTypeValue() { - return type_; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnType type = 5; - * - * @param value The enum numeric value on the wire for type to set. - * @return This builder for chaining. - */ - public Builder setTypeValue(int value) { - - type_ = value; - onChanged(); - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnType type = 5; - * - * @return The type. - */ - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnType getType() { - @SuppressWarnings("deprecation") - com.aliyun.polardbx.binlog.protocol.TxnType result = - com.aliyun.polardbx.binlog.protocol.TxnType.valueOf(type_); - return result == null ? com.aliyun.polardbx.binlog.protocol.TxnType.UNRECOGNIZED : result; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnType type = 5; - * - * @param value The type to set. - * @return This builder for chaining. - */ - public Builder setType(com.aliyun.polardbx.binlog.protocol.TxnType value) { - if (value == null) { - throw new NullPointerException(); - } - - type_ = value.getNumber(); - onChanged(); - return this; - } - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnType type = 5; - * - * @return This builder for chaining. - */ - public Builder clearType() { - - type_ = 0; - onChanged(); - return this; - } - - private boolean xaTxn_; - - /** - * bool xaTxn = 6; - * - * @return The xaTxn. - */ - @java.lang.Override - public boolean getXaTxn() { - return xaTxn_; - } - - /** - * bool xaTxn = 6; - * - * @param value The xaTxn to set. - * @return This builder for chaining. - */ - public Builder setXaTxn(boolean value) { - - xaTxn_ = value; - onChanged(); - return this; - } - - /** - * bool xaTxn = 6; - * - * @return This builder for chaining. - */ - public Builder clearXaTxn() { - - xaTxn_ = false; - onChanged(); - return this; - } - - private boolean tsoTransaction_; - - /** - *
-         * *
-         * 标识是否为Tso事务。虽然【Tso事务】和【NoTso事务】的Token都有tso字段,
-         * 但是【NoTso事务】的tso是根据其前序【Tso事务】的真实tso生成的虚拟tso
-         * 
- * - * bool tsoTransaction = 7; - * - * @return The tsoTransaction. - */ - @java.lang.Override - public boolean getTsoTransaction() { - return tsoTransaction_; - } - - /** - *
-         * *
-         * 标识是否为Tso事务。虽然【Tso事务】和【NoTso事务】的Token都有tso字段,
-         * 但是【NoTso事务】的tso是根据其前序【Tso事务】的真实tso生成的虚拟tso
-         * 
- * - * bool tsoTransaction = 7; - * - * @param value The tsoTransaction to set. - * @return This builder for chaining. - */ - public Builder setTsoTransaction(boolean value) { - - tsoTransaction_ = value; - onChanged(); - return this; - } - - /** - *
-         * *
-         * 标识是否为Tso事务。虽然【Tso事务】和【NoTso事务】的Token都有tso字段,
-         * 但是【NoTso事务】的tso是根据其前序【Tso事务】的真实tso生成的虚拟tso
-         * 
- * - * bool tsoTransaction = 7; - * - * @return This builder for chaining. - */ - public Builder clearTsoTransaction() { - - tsoTransaction_ = false; - onChanged(); - return this; - } - - private int txnSize_; - - /** - *
-         * *
-         * 该事务下的所有LogEvent的个数,注意:不是某个批次的的个数
-         * 
- * - * int32 txnSize = 8; - * - * @return The txnSize. - */ - @java.lang.Override - public int getTxnSize() { - return txnSize_; - } - - /** - *
-         * *
-         * 该事务下的所有LogEvent的个数,注意:不是某个批次的的个数
-         * 
- * - * int32 txnSize = 8; - * - * @param value The txnSize to set. - * @return This builder for chaining. - */ - public Builder setTxnSize(int value) { - - txnSize_ = value; - onChanged(); - return this; - } - - /** - *
-         * *
-         * 该事务下的所有LogEvent的个数,注意:不是某个批次的的个数
-         * 
- * - * int32 txnSize = 8; - * - * @return This builder for chaining. - */ - public Builder clearTxnSize() { - - txnSize_ = 0; - onChanged(); - return this; - } - - private java.lang.Object beginSchema_ = ""; - - /** - *
-         * *
-         * dumper生成事务的begin头时使用
-         * 
- * - * string beginSchema = 9; - * - * @return The beginSchema. - */ - public java.lang.String getBeginSchema() { - java.lang.Object ref = beginSchema_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - beginSchema_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - *
-         * *
-         * dumper生成事务的begin头时使用
-         * 
- * - * string beginSchema = 9; - * - * @return The bytes for beginSchema. - */ - public com.google.protobuf.ByteString - getBeginSchemaBytes() { - java.lang.Object ref = beginSchema_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - beginSchema_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - *
-         * *
-         * dumper生成事务的begin头时使用
-         * 
- * - * string beginSchema = 9; - * - * @param value The beginSchema to set. - * @return This builder for chaining. - */ - public Builder setBeginSchema( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - beginSchema_ = value; - onChanged(); - return this; - } - - /** - *
-         * *
-         * dumper生成事务的begin头时使用
-         * 
- * - * string beginSchema = 9; - * - * @return This builder for chaining. - */ - public Builder clearBeginSchema() { - - beginSchema_ = getDefaultInstance().getBeginSchema(); - onChanged(); - return this; - } - - /** - *
-         * *
-         * dumper生成事务的begin头时使用
-         * 
- * - * string beginSchema = 9; - * - * @param value The bytes for beginSchema to set. - * @return This builder for chaining. - */ - public Builder setBeginSchemaBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - beginSchema_ = value; - onChanged(); - return this; - } - - private com.google.protobuf.LazyStringList allParties_ = com.google.protobuf.LazyStringArrayList.EMPTY; - - private void ensureAllPartiesIsMutable() { - if (!((bitField0_ & 0x00000001) != 0)) { - allParties_ = new com.google.protobuf.LazyStringArrayList(allParties_); - bitField0_ |= 0x00000001; - } - } - - /** - * repeated string allParties = 10; - * - * @return A list containing the allParties. - */ - public com.google.protobuf.ProtocolStringList - getAllPartiesList() { - return allParties_.getUnmodifiableView(); - } - - /** - * repeated string allParties = 10; - * - * @return The count of allParties. - */ - public int getAllPartiesCount() { - return allParties_.size(); - } - - /** - * repeated string allParties = 10; - * - * @param index The index of the element to return. - * @return The allParties at the given index. - */ - public java.lang.String getAllParties(int index) { - return allParties_.get(index); - } - - /** - * repeated string allParties = 10; - * - * @param index The index of the value to return. - * @return The bytes of the allParties at the given index. - */ - public com.google.protobuf.ByteString - getAllPartiesBytes(int index) { - return allParties_.getByteString(index); - } - - /** - * repeated string allParties = 10; - * - * @param index The index to set the value at. - * @param value The allParties to set. - * @return This builder for chaining. - */ - public Builder setAllParties( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureAllPartiesIsMutable(); - allParties_.set(index, value); - onChanged(); - return this; - } - - /** - * repeated string allParties = 10; - * - * @param value The allParties to add. - * @return This builder for chaining. - */ - public Builder addAllParties( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureAllPartiesIsMutable(); - allParties_.add(value); - onChanged(); - return this; - } - - /** - * repeated string allParties = 10; - * - * @param values The allParties to add. - * @return This builder for chaining. - */ - public Builder addAllAllParties( - java.lang.Iterable values) { - ensureAllPartiesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, allParties_); - onChanged(); - return this; - } - - /** - * repeated string allParties = 10; - * - * @return This builder for chaining. - */ - public Builder clearAllParties() { - allParties_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - return this; - } - - /** - * repeated string allParties = 10; - * - * @param value The bytes of the allParties to add. - * @return This builder for chaining. - */ - public Builder addAllPartiesBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - ensureAllPartiesIsMutable(); - allParties_.add(value); - onChanged(); - return this; - } - - private com.google.protobuf.ByteString payload_ = com.google.protobuf.ByteString.EMPTY; - - /** - *
-         * *
-         * 一些特殊的TxnToken,没有TxnItem的概念,此时通过payload字段传输数据
-         * 
- * - * bytes payload = 11; - * - * @return The payload. - */ - @java.lang.Override - public com.google.protobuf.ByteString getPayload() { - return payload_; - } - - /** - *
-         * *
-         * 一些特殊的TxnToken,没有TxnItem的概念,此时通过payload字段传输数据
-         * 
- * - * bytes payload = 11; - * - * @param value The payload to set. - * @return This builder for chaining. - */ - public Builder setPayload(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - - payload_ = value; - onChanged(); - return this; - } - - /** - *
-         * *
-         * 一些特殊的TxnToken,没有TxnItem的概念,此时通过payload字段传输数据
-         * 
- * - * bytes payload = 11; - * - * @return This builder for chaining. - */ - public Builder clearPayload() { - - payload_ = getDefaultInstance().getPayload(); - onChanged(); - return this; - } - - private long snapshotSeq_; - - /** - *
-         * *
-         * Tso事务专用
-         * 
- * - * int64 snapshotSeq = 12; - * - * @return The snapshotSeq. - */ - @java.lang.Override - public long getSnapshotSeq() { - return snapshotSeq_; - } - - /** - *
-         * *
-         * Tso事务专用
-         * 
- * - * int64 snapshotSeq = 12; - * - * @param value The snapshotSeq to set. - * @return This builder for chaining. - */ - public Builder setSnapshotSeq(long value) { - - snapshotSeq_ = value; - onChanged(); - return this; - } - - /** - *
-         * *
-         * Tso事务专用
-         * 
- * - * int64 snapshotSeq = 12; - * - * @return This builder for chaining. - */ - public Builder clearSnapshotSeq() { - - snapshotSeq_ = 0L; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.TxnToken) - } - - // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.TxnToken) - private static final com.aliyun.polardbx.binlog.protocol.TxnToken DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.TxnToken(); - } - - public static com.aliyun.polardbx.binlog.protocol.TxnToken getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public TxnToken parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new TxnToken(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.aliyun.polardbx.binlog.protocol.TxnToken getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } + @java.lang.Override + public com.aliyun.polardbx.binlog.protocol.TxnToken getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnTokenOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnTokenOrBuilder.java index ea9e337c..2df8ceaf 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnTokenOrBuilder.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnTokenOrBuilder.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -24,190 +7,204 @@ public interface TxnTokenOrBuilder extends // @@protoc_insertion_point(interface_extends:com.aliyun.polardbx.binlog.protocol.TxnToken) com.google.protobuf.MessageOrBuilder { - /** - * string tso = 1; - * - * @return The tso. - */ - java.lang.String getTso(); - - /** - * string tso = 1; - * - * @return The bytes for tso. - */ - com.google.protobuf.ByteString - getTsoBytes(); - - /** - * string txnId = 2; - * - * @return The txnId. - */ - java.lang.String getTxnId(); - - /** - * string txnId = 2; - * - * @return The bytes for txnId. - */ - com.google.protobuf.ByteString - getTxnIdBytes(); - - /** - * string partitionId = 3; - * - * @return The partitionId. - */ - java.lang.String getPartitionId(); - - /** - * string partitionId = 3; - * - * @return The bytes for partitionId. - */ - com.google.protobuf.ByteString - getPartitionIdBytes(); - - /** - * string originMergeSourceId = 4; - * - * @return The originMergeSourceId. - */ - java.lang.String getOriginMergeSourceId(); - - /** - * string originMergeSourceId = 4; - * - * @return The bytes for originMergeSourceId. - */ - com.google.protobuf.ByteString - getOriginMergeSourceIdBytes(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnType type = 5; - * - * @return The enum numeric value on the wire for type. - */ - int getTypeValue(); - - /** - * .com.aliyun.polardbx.binlog.protocol.TxnType type = 5; - * - * @return The type. - */ - com.aliyun.polardbx.binlog.protocol.TxnType getType(); - - /** - * bool xaTxn = 6; - * - * @return The xaTxn. - */ - boolean getXaTxn(); - - /** - *
-     * *
-     * 标识是否为Tso事务。虽然【Tso事务】和【NoTso事务】的Token都有tso字段,
-     * 但是【NoTso事务】的tso是根据其前序【Tso事务】的真实tso生成的虚拟tso
-     * 
- * - * bool tsoTransaction = 7; - * - * @return The tsoTransaction. - */ - boolean getTsoTransaction(); - - /** - *
-     * *
-     * 该事务下的所有LogEvent的个数,注意:不是某个批次的的个数
-     * 
- * - * int32 txnSize = 8; - * - * @return The txnSize. - */ - int getTxnSize(); - - /** - *
-     * *
-     * dumper生成事务的begin头时使用
-     * 
- * - * string beginSchema = 9; - * - * @return The beginSchema. - */ - java.lang.String getBeginSchema(); - - /** - *
-     * *
-     * dumper生成事务的begin头时使用
-     * 
- * - * string beginSchema = 9; - * - * @return The bytes for beginSchema. - */ - com.google.protobuf.ByteString - getBeginSchemaBytes(); - - /** - * repeated string allParties = 10; - * - * @return A list containing the allParties. - */ - java.util.List - getAllPartiesList(); - - /** - * repeated string allParties = 10; - * - * @return The count of allParties. - */ - int getAllPartiesCount(); - - /** - * repeated string allParties = 10; - * - * @param index The index of the element to return. - * @return The allParties at the given index. - */ - java.lang.String getAllParties(int index); - - /** - * repeated string allParties = 10; - * - * @param index The index of the value to return. - * @return The bytes of the allParties at the given index. - */ - com.google.protobuf.ByteString - getAllPartiesBytes(int index); - - /** - *
-     * *
-     * 一些特殊的TxnToken,没有TxnItem的概念,此时通过payload字段传输数据
-     * 
- * - * bytes payload = 11; - * - * @return The payload. - */ - com.google.protobuf.ByteString getPayload(); - - /** - *
-     * *
-     * Tso事务专用
-     * 
- * - * int64 snapshotSeq = 12; - * - * @return The snapshotSeq. - */ - long getSnapshotSeq(); + /** + * string tso = 1; + * @return The tso. + */ + java.lang.String getTso(); + /** + * string tso = 1; + * @return The bytes for tso. + */ + com.google.protobuf.ByteString + getTsoBytes(); + + /** + * string txnId = 2; + * @return The txnId. + */ + java.lang.String getTxnId(); + /** + * string txnId = 2; + * @return The bytes for txnId. + */ + com.google.protobuf.ByteString + getTxnIdBytes(); + + /** + * string partitionId = 3; + * @return The partitionId. + */ + java.lang.String getPartitionId(); + /** + * string partitionId = 3; + * @return The bytes for partitionId. + */ + com.google.protobuf.ByteString + getPartitionIdBytes(); + + /** + * string originMergeSourceId = 4; + * @return The originMergeSourceId. + */ + java.lang.String getOriginMergeSourceId(); + /** + * string originMergeSourceId = 4; + * @return The bytes for originMergeSourceId. + */ + com.google.protobuf.ByteString + getOriginMergeSourceIdBytes(); + + /** + * .com.aliyun.polardbx.binlog.protocol.TxnType type = 5; + * @return The enum numeric value on the wire for type. + */ + int getTypeValue(); + /** + * .com.aliyun.polardbx.binlog.protocol.TxnType type = 5; + * @return The type. + */ + com.aliyun.polardbx.binlog.protocol.TxnType getType(); + + /** + * bool xaTxn = 6; + * @return The xaTxn. + */ + boolean getXaTxn(); + + /** + *
+   **
+   *标识是否为Tso事务。虽然【Tso事务】和【NoTso事务】的Token都有tso字段,
+   *但是【NoTso事务】的tso是根据其前序【Tso事务】的真实tso生成的虚拟tso
+   * 
+ * + * bool tsoTransaction = 7; + * @return The tsoTransaction. + */ + boolean getTsoTransaction(); + + /** + *
+   **
+   *该事务下的所有LogEvent的个数,注意:不是某个批次的的个数
+   * 
+ * + * int32 txnSize = 8; + * @return The txnSize. + */ + int getTxnSize(); + + /** + *
+   **
+   *1.dumper生成事务的begin头时使用
+   *2.ddl场景下标识ddl sql对应的库名
+   * 
+ * + * string schema = 9; + * @return The schema. + */ + java.lang.String getSchema(); + /** + *
+   **
+   *1.dumper生成事务的begin头时使用
+   *2.ddl场景下标识ddl sql对应的库名
+   * 
+ * + * string schema = 9; + * @return The bytes for schema. + */ + com.google.protobuf.ByteString + getSchemaBytes(); + + /** + *
+   **
+   *该事务的所有参与者
+   * 
+ * + * repeated string allParties = 10; + * @return A list containing the allParties. + */ + java.util.List + getAllPartiesList(); + /** + *
+   **
+   *该事务的所有参与者
+   * 
+ * + * repeated string allParties = 10; + * @return The count of allParties. + */ + int getAllPartiesCount(); + /** + *
+   **
+   *该事务的所有参与者
+   * 
+ * + * repeated string allParties = 10; + * @param index The index of the element to return. + * @return The allParties at the given index. + */ + java.lang.String getAllParties(int index); + /** + *
+   **
+   *该事务的所有参与者
+   * 
+ * + * repeated string allParties = 10; + * @param index The index of the value to return. + * @return The bytes of the allParties at the given index. + */ + com.google.protobuf.ByteString + getAllPartiesBytes(int index); + + /** + *
+   **
+   *一些特殊的TxnToken,没有TxnItem的概念,此时通过payload字段传输数据
+   * 
+ * + * bytes payload = 11; + * @return The payload. + */ + com.google.protobuf.ByteString getPayload(); + + /** + *
+   **
+   *Tso事务专用
+   * 
+ * + * int64 snapshotSeq = 12; + * @return The snapshotSeq. + */ + long getSnapshotSeq(); + + /** + *
+   **
+   *表名,非必须
+   * 
+ * + * string table = 13; + * @return The table. + */ + java.lang.String getTable(); + /** + *
+   **
+   *表名,非必须
+   * 
+ * + * string table = 13; + * @return The bytes for table. + */ + com.google.protobuf.ByteString + getTableBytes(); } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnType.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnType.java index 8a1deb92..80729410 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnType.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/binlog/protocol/TxnType.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: TxnStream.proto @@ -25,231 +8,221 @@ */ public enum TxnType implements com.google.protobuf.ProtocolMessageEnum { - /** - *
-     * *
-     * 正常的DML
-     * 
- * - * DML = 0; - */ - DML(0), - /** - *
-     * *
-     * BINLOG协议描述
-     * 
- * - * FORMAT_DESC = 1; - */ - FORMAT_DESC(1), - /** - *
-     * *
-     * 元信息:逻辑DDL
-     * 
- * - * META_DDL = 2; - */ - META_DDL(2), - /** - *
-     * *
-     * 元信息:Storage发生ScaleOut or ScaleIn
-     * 
- * - * META_SCALE = 3; - */ - META_SCALE(3), - /** - *
-     * *
-     * 元信息:逻辑DDL(PolarX私有类型的DDL)
-     * 
- * - * META_DDL_PRIVATE = 4; - */ - META_DDL_PRIVATE(4), - /** - *
-     * *
-     * 元信息:心跳信息
-     * 
- * - * META_HEARTBEAT = 5; - */ - META_HEARTBEAT(5), - /** - *
-     * *
-     * 元信息:config配置变更
-     * 
- * - * META_CONFIG_ENV_CHANGE = 6; - */ - META_CONFIG_ENV_CHANGE(6), - UNRECOGNIZED(-1), - ; - - /** - *
-     * *
-     * 正常的DML
-     * 
- * - * DML = 0; - */ - public static final int DML_VALUE = 0; - /** - *
-     * *
-     * BINLOG协议描述
-     * 
- * - * FORMAT_DESC = 1; - */ - public static final int FORMAT_DESC_VALUE = 1; - /** - *
-     * *
-     * 元信息:逻辑DDL
-     * 
- * - * META_DDL = 2; - */ - public static final int META_DDL_VALUE = 2; - /** - *
-     * *
-     * 元信息:Storage发生ScaleOut or ScaleIn
-     * 
- * - * META_SCALE = 3; - */ - public static final int META_SCALE_VALUE = 3; - /** - *
-     * *
-     * 元信息:逻辑DDL(PolarX私有类型的DDL)
-     * 
- * - * META_DDL_PRIVATE = 4; - */ - public static final int META_DDL_PRIVATE_VALUE = 4; - /** - *
-     * *
-     * 元信息:心跳信息
-     * 
- * - * META_HEARTBEAT = 5; - */ - public static final int META_HEARTBEAT_VALUE = 5; - /** - *
-     * *
-     * 元信息:config配置变更
-     * 
- * - * META_CONFIG_ENV_CHANGE = 6; - */ - public static final int META_CONFIG_ENV_CHANGE_VALUE = 6; - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static TxnType valueOf(int value) { - return forNumber(value); - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static TxnType forNumber(int value) { - switch (value) { - case 0: - return DML; - case 1: - return FORMAT_DESC; - case 2: - return META_DDL; - case 3: - return META_SCALE; - case 4: - return META_DDL_PRIVATE; - case 5: - return META_HEARTBEAT; - case 6: - return META_CONFIG_ENV_CHANGE; - default: - return null; - } + /** + *
+   **
+   *正常的DML
+   * 
+ * + * DML = 0; + */ + DML(0), + /** + *
+   **
+   *BINLOG协议描述
+   * 
+ * + * FORMAT_DESC = 1; + */ + FORMAT_DESC(1), + /** + *
+   **
+   *元信息:逻辑DDL
+   * 
+ * + * META_DDL = 2; + */ + META_DDL(2), + /** + *
+   **
+   *元信息:Storage发生ScaleOut or ScaleIn
+   * 
+ * + * META_SCALE = 3; + */ + META_SCALE(3), + /** + *
+   **
+   *元信息:逻辑DDL(PolarX私有类型的DDL)
+   * 
+ * + * META_DDL_PRIVATE = 4; + */ + META_DDL_PRIVATE(4), + /** + *
+   **
+   *元信息:心跳信息
+   * 
+ * + * META_HEARTBEAT = 5; + */ + META_HEARTBEAT(5), + /** + *
+   **
+   *元信息:config配置变更
+   * 
+ * + * META_CONFIG_ENV_CHANGE = 6; + */ + META_CONFIG_ENV_CHANGE(6), + UNRECOGNIZED(-1), + ; + + /** + *
+   **
+   *正常的DML
+   * 
+ * + * DML = 0; + */ + public static final int DML_VALUE = 0; + /** + *
+   **
+   *BINLOG协议描述
+   * 
+ * + * FORMAT_DESC = 1; + */ + public static final int FORMAT_DESC_VALUE = 1; + /** + *
+   **
+   *元信息:逻辑DDL
+   * 
+ * + * META_DDL = 2; + */ + public static final int META_DDL_VALUE = 2; + /** + *
+   **
+   *元信息:Storage发生ScaleOut or ScaleIn
+   * 
+ * + * META_SCALE = 3; + */ + public static final int META_SCALE_VALUE = 3; + /** + *
+   **
+   *元信息:逻辑DDL(PolarX私有类型的DDL)
+   * 
+ * + * META_DDL_PRIVATE = 4; + */ + public static final int META_DDL_PRIVATE_VALUE = 4; + /** + *
+   **
+   *元信息:心跳信息
+   * 
+ * + * META_HEARTBEAT = 5; + */ + public static final int META_HEARTBEAT_VALUE = 5; + /** + *
+   **
+   *元信息:config配置变更
+   * 
+ * + * META_CONFIG_ENV_CHANGE = 6; + */ + public static final int META_CONFIG_ENV_CHANGE_VALUE = 6; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static TxnType valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static TxnType forNumber(int value) { + switch (value) { + case 0: return DML; + case 1: return FORMAT_DESC; + case 2: return META_DDL; + case 3: return META_SCALE; + case 4: return META_DDL_PRIVATE; + case 5: return META_HEARTBEAT; + case 6: return META_CONFIG_ENV_CHANGE; + default: return null; } - - private static final com.google.protobuf.Internal.EnumLiteMap< - TxnType> internalValueMap = + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + TxnType> internalValueMap = new com.google.protobuf.Internal.EnumLiteMap() { - public TxnType findValueByNumber(int number) { - return TxnType.forNumber(number); - } + public TxnType findValueByNumber(int number) { + return TxnType.forNumber(number); + } }; - public final com.google.protobuf.Descriptors.EnumValueDescriptor - getValueDescriptor() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalStateException( - "Can't get the descriptor of an unrecognized enum value."); - } - return getDescriptor().getValues().get(ordinal()); - } - - public final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptorForType() { - return getDescriptor(); + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); } - - public static final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptor() { - return com.aliyun.polardbx.binlog.protocol.TxnStream.getDescriptor().getEnumTypes().get(1); + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return com.aliyun.polardbx.binlog.protocol.TxnStream.getDescriptor().getEnumTypes().get(1); + } + + private static final TxnType[] VALUES = values(); + + public static TxnType valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); } - - private static final TxnType[] VALUES = values(); - - public static TxnType valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException( - "EnumValueDescriptor is not for this type."); - } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; - } - return VALUES[desc.getIndex()]; + if (desc.getIndex() == -1) { + return UNRECOGNIZED; } + return VALUES[desc.getIndex()]; + } - private final int value; + private final int value; - private TxnType(int value) { - this.value = value; - } + private TxnType(int value) { + this.value = value; + } - // @@protoc_insertion_point(enum_scope:com.aliyun.polardbx.binlog.protocol.TxnType) + // @@protoc_insertion_point(enum_scope:com.aliyun.polardbx.binlog.protocol.TxnType) } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/BinaryLog.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/BinaryLog.java index 31e7497d..9c1bf9d6 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/BinaryLog.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/BinaryLog.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: DumperServer.proto @@ -27,680 +10,613 @@ public final class BinaryLog extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:dumper.BinaryLog) BinaryLogOrBuilder { - private static final long serialVersionUID = 0L; - - // Use BinaryLog.newBuilder() to construct. - private BinaryLog(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } +private static final long serialVersionUID = 0L; + // Use BinaryLog.newBuilder() to construct. + private BinaryLog(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BinaryLog() { + logName_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new BinaryLog(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BinaryLog( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); - private BinaryLog() { - logName_ = ""; + logName_ = s; + break; + } + case 16: { + + fileSize_ = input.readInt64(); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_BinaryLog_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_BinaryLog_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.BinaryLog.class, com.aliyun.polardbx.rpc.cdc.BinaryLog.Builder.class); + } + + public static final int LOGNAME_FIELD_NUMBER = 1; + private volatile java.lang.Object logName_; + /** + * string logName = 1; + * @return The logName. + */ + @java.lang.Override + public java.lang.String getLogName() { + java.lang.Object ref = logName_; + 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(); + logName_ = s; + return s; + } + } + /** + * string logName = 1; + * @return The bytes for logName. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getLogNameBytes() { + java.lang.Object ref = logName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + logName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int FILESIZE_FIELD_NUMBER = 2; + private long fileSize_; + /** + * int64 fileSize = 2; + * @return The fileSize. + */ + @java.lang.Override + public long getFileSize() { + return fileSize_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getLogNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, logName_); + } + if (fileSize_ != 0L) { + output.writeInt64(2, fileSize_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getLogNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, logName_); + } + if (fileSize_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, fileSize_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.rpc.cdc.BinaryLog)) { + return super.equals(obj); + } + com.aliyun.polardbx.rpc.cdc.BinaryLog other = (com.aliyun.polardbx.rpc.cdc.BinaryLog) obj; + + if (!getLogName() + .equals(other.getLogName())) return false; + if (getFileSize() + != other.getFileSize()) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + LOGNAME_FIELD_NUMBER; + hash = (53 * hash) + getLogName().hashCode(); + hash = (37 * hash) + FILESIZE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFileSize()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.rpc.cdc.BinaryLog parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.BinaryLog parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.BinaryLog parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.BinaryLog parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.BinaryLog parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.BinaryLog parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.BinaryLog parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.BinaryLog parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.BinaryLog parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.BinaryLog parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.BinaryLog parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.BinaryLog parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.rpc.cdc.BinaryLog prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code dumper.BinaryLog} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:dumper.BinaryLog) + com.aliyun.polardbx.rpc.cdc.BinaryLogOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_BinaryLog_descriptor; } @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new BinaryLog(); + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_BinaryLog_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.BinaryLog.class, com.aliyun.polardbx.rpc.cdc.BinaryLog.Builder.class); } - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; + // Construct using com.aliyun.polardbx.rpc.cdc.BinaryLog.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); } - private BinaryLog( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - 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; - case 10: { - java.lang.String s = input.readStringRequireUtf8(); - - logName_ = s; - break; - } - case 16: { - - fileSize_ = input.readInt64(); - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return DumperServer.internal_static_dumper_BinaryLog_descriptor; + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } } - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return DumperServer.internal_static_dumper_BinaryLog_fieldAccessorTable - .ensureFieldAccessorsInitialized( - BinaryLog.class, BinaryLog.Builder.class); - } + public Builder clear() { + super.clear(); + logName_ = ""; - public static final int LOGNAME_FIELD_NUMBER = 1; - private volatile java.lang.Object logName_; + fileSize_ = 0L; - /** - * string logName = 1; - * - * @return The logName. - */ - @java.lang.Override - public java.lang.String getLogName() { - java.lang.Object ref = logName_; - 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(); - logName_ = s; - return s; - } + return this; } - /** - * string logName = 1; - * - * @return The bytes for logName. - */ @java.lang.Override - public com.google.protobuf.ByteString - getLogNameBytes() { - java.lang.Object ref = logName_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - logName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_BinaryLog_descriptor; } - public static final int FILESIZE_FIELD_NUMBER = 2; - private long fileSize_; - - /** - * int64 fileSize = 2; - * - * @return The fileSize. - */ @java.lang.Override - public long getFileSize() { - return fileSize_; + public com.aliyun.polardbx.rpc.cdc.BinaryLog getDefaultInstanceForType() { + return com.aliyun.polardbx.rpc.cdc.BinaryLog.getDefaultInstance(); } - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } - - memoizedIsInitialized = 1; - return true; + public com.aliyun.polardbx.rpc.cdc.BinaryLog build() { + com.aliyun.polardbx.rpc.cdc.BinaryLog result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; } @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getLogNameBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, logName_); - } - if (fileSize_ != 0L) { - output.writeInt64(2, fileSize_); - } - unknownFields.writeTo(output); + public com.aliyun.polardbx.rpc.cdc.BinaryLog buildPartial() { + com.aliyun.polardbx.rpc.cdc.BinaryLog result = new com.aliyun.polardbx.rpc.cdc.BinaryLog(this); + result.logName_ = logName_; + result.fileSize_ = fileSize_; + onBuilt(); + return result; } @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) { - return size; - } - - size = 0; - if (!getLogNameBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, logName_); - } - if (fileSize_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(2, fileSize_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; + public Builder clone() { + return super.clone(); } - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof BinaryLog)) { - return super.equals(obj); - } - BinaryLog other = (BinaryLog) obj; - - if (!getLogName() - .equals(other.getLogName())) { - return false; - } - if (getFileSize() - != other.getFileSize()) { - return false; - } - if (!unknownFields.equals(other.unknownFields)) { - return false; - } - return true; + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); } - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + LOGNAME_FIELD_NUMBER; - hash = (53 * hash) + getLogName().hashCode(); - hash = (37 * hash) + FILESIZE_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getFileSize()); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static BinaryLog parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); } - - public static BinaryLog parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static BinaryLog parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); } - - public static BinaryLog parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); } - - public static BinaryLog parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); } - - public static BinaryLog parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.rpc.cdc.BinaryLog) { + return mergeFrom((com.aliyun.polardbx.rpc.cdc.BinaryLog)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.polardbx.rpc.cdc.BinaryLog other) { + if (other == com.aliyun.polardbx.rpc.cdc.BinaryLog.getDefaultInstance()) return this; + if (!other.getLogName().isEmpty()) { + logName_ = other.logName_; + onChanged(); + } + if (other.getFileSize() != 0L) { + setFileSize(other.getFileSize()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; } - public static BinaryLog parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + @java.lang.Override + public final boolean isInitialized() { + return true; } - public static BinaryLog parseFrom( - java.io.InputStream input, + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + com.aliyun.polardbx.rpc.cdc.BinaryLog parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.rpc.cdc.BinaryLog) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; } - public static BinaryLog parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); + private java.lang.Object logName_ = ""; + /** + * string logName = 1; + * @return The logName. + */ + public java.lang.String getLogName() { + java.lang.Object ref = logName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + logName_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - - public static BinaryLog parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + /** + * string logName = 1; + * @return The bytes for logName. + */ + public com.google.protobuf.ByteString + getLogNameBytes() { + java.lang.Object ref = logName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + logName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } - - public static BinaryLog parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + /** + * string logName = 1; + * @param value The logName to set. + * @return This builder for chaining. + */ + public Builder setLogName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + logName_ = value; + onChanged(); + return this; } - - public static BinaryLog parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + /** + * string logName = 1; + * @return This builder for chaining. + */ + public Builder clearLogName() { + + logName_ = getDefaultInstance().getLogName(); + onChanged(); + return this; } - + /** + * string logName = 1; + * @param value The bytes for logName to set. + * @return This builder for chaining. + */ + public Builder setLogNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + logName_ = value; + onChanged(); + return this; + } + + private long fileSize_ ; + /** + * int64 fileSize = 2; + * @return The fileSize. + */ @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); + public long getFileSize() { + return fileSize_; } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); + /** + * int64 fileSize = 2; + * @param value The fileSize to set. + * @return This builder for chaining. + */ + public Builder setFileSize(long value) { + + fileSize_ = value; + onChanged(); + return this; } - - public static Builder newBuilder(BinaryLog prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + /** + * int64 fileSize = 2; + * @return This builder for chaining. + */ + public Builder clearFileSize() { + + fileSize_ = 0L; + onChanged(); + return this; } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); } @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - /** - * Protobuf type {@code dumper.BinaryLog} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:dumper.BinaryLog) - BinaryLogOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return DumperServer.internal_static_dumper_BinaryLog_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return DumperServer.internal_static_dumper_BinaryLog_fieldAccessorTable - .ensureFieldAccessorsInitialized( - BinaryLog.class, BinaryLog.Builder.class); - } - - // Construct using com.alibaba.tddl.rpc.cdc.BinaryLog.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - @java.lang.Override - public Builder clear() { - super.clear(); - logName_ = ""; - - fileSize_ = 0L; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return DumperServer.internal_static_dumper_BinaryLog_descriptor; - } - - @java.lang.Override - public BinaryLog getDefaultInstanceForType() { - return BinaryLog.getDefaultInstance(); - } - - @java.lang.Override - public BinaryLog build() { - BinaryLog result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public BinaryLog buildPartial() { - BinaryLog result = new BinaryLog(this); - result.logName_ = logName_; - result.fileSize_ = fileSize_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof BinaryLog) { - return mergeFrom((BinaryLog) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(BinaryLog other) { - if (other == BinaryLog.getDefaultInstance()) { - return this; - } - if (!other.getLogName().isEmpty()) { - logName_ = other.logName_; - onChanged(); - } - if (other.getFileSize() != 0L) { - setFileSize(other.getFileSize()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - BinaryLog parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (BinaryLog) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object logName_ = ""; - - /** - * string logName = 1; - * - * @return The logName. - */ - public java.lang.String getLogName() { - java.lang.Object ref = logName_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - logName_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * string logName = 1; - * - * @return The bytes for logName. - */ - public com.google.protobuf.ByteString - getLogNameBytes() { - java.lang.Object ref = logName_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - logName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string logName = 1; - * - * @param value The logName to set. - * @return This builder for chaining. - */ - public Builder setLogName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - logName_ = value; - onChanged(); - return this; - } - - /** - * string logName = 1; - * - * @return This builder for chaining. - */ - public Builder clearLogName() { - - logName_ = getDefaultInstance().getLogName(); - onChanged(); - return this; - } - - /** - * string logName = 1; - * - * @param value The bytes for logName to set. - * @return This builder for chaining. - */ - public Builder setLogNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - logName_ = value; - onChanged(); - return this; - } - - private long fileSize_; - - /** - * int64 fileSize = 2; - * - * @return The fileSize. - */ - @java.lang.Override - public long getFileSize() { - return fileSize_; - } - /** - * int64 fileSize = 2; - * - * @param value The fileSize to set. - * @return This builder for chaining. - */ - public Builder setFileSize(long value) { - - fileSize_ = value; - onChanged(); - return this; - } + // @@protoc_insertion_point(builder_scope:dumper.BinaryLog) + } - /** - * int64 fileSize = 2; - * - * @return This builder for chaining. - */ - public Builder clearFileSize() { + // @@protoc_insertion_point(class_scope:dumper.BinaryLog) + private static final com.aliyun.polardbx.rpc.cdc.BinaryLog DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.rpc.cdc.BinaryLog(); + } - fileSize_ = 0L; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:dumper.BinaryLog) - } + public static com.aliyun.polardbx.rpc.cdc.BinaryLog getDefaultInstance() { + return DEFAULT_INSTANCE; + } - // @@protoc_insertion_point(class_scope:dumper.BinaryLog) - private static final BinaryLog DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new BinaryLog(); - } - - public static BinaryLog getDefaultInstance() { - return DEFAULT_INSTANCE; + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BinaryLog parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BinaryLog(input, extensionRegistry); } + }; - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public BinaryLog parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new BinaryLog(input, extensionRegistry); - } - }; + public static com.google.protobuf.Parser parser() { + return PARSER; + } - public static com.google.protobuf.Parser parser() { - return PARSER; - } + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public BinaryLog getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.BinaryLog getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/BinaryLogOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/BinaryLogOrBuilder.java index 6cc044a1..14089284 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/BinaryLogOrBuilder.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/BinaryLogOrBuilder.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: DumperServer.proto @@ -24,25 +7,21 @@ public interface BinaryLogOrBuilder extends // @@protoc_insertion_point(interface_extends:dumper.BinaryLog) com.google.protobuf.MessageOrBuilder { - /** - * string logName = 1; - * - * @return The logName. - */ - java.lang.String getLogName(); - - /** - * string logName = 1; - * - * @return The bytes for logName. - */ - com.google.protobuf.ByteString - getLogNameBytes(); + /** + * string logName = 1; + * @return The logName. + */ + java.lang.String getLogName(); + /** + * string logName = 1; + * @return The bytes for logName. + */ + com.google.protobuf.ByteString + getLogNameBytes(); - /** - * int64 fileSize = 2; - * - * @return The fileSize. - */ - long getFileSize(); + /** + * int64 fileSize = 2; + * @return The fileSize. + */ + long getFileSize(); } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/BinlogEvent.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/BinlogEvent.java index 3820ca7a..fdad1dd0 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/BinlogEvent.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/BinlogEvent.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: DumperServer.proto @@ -27,1138 +10,1019 @@ public final class BinlogEvent extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:dumper.BinlogEvent) BinlogEventOrBuilder { - private static final long serialVersionUID = 0L; +private static final long serialVersionUID = 0L; + // Use BinlogEvent.newBuilder() to construct. + private BinlogEvent(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BinlogEvent() { + logName_ = ""; + eventType_ = ""; + info_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new BinlogEvent(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BinlogEvent( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + logName_ = s; + break; + } + case 16: { + + pos_ = input.readInt64(); + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + eventType_ = s; + break; + } + case 32: { + + serverId_ = input.readInt64(); + break; + } + case 40: { - // Use BinlogEvent.newBuilder() to construct. - private BinlogEvent(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); + endLogPos_ = input.readInt64(); + break; + } + case 50: { + java.lang.String s = input.readStringRequireUtf8(); + + info_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_BinlogEvent_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_BinlogEvent_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.BinlogEvent.class, com.aliyun.polardbx.rpc.cdc.BinlogEvent.Builder.class); + } + + public static final int LOGNAME_FIELD_NUMBER = 1; + private volatile java.lang.Object logName_; + /** + * string logName = 1; + * @return The logName. + */ + @java.lang.Override + public java.lang.String getLogName() { + java.lang.Object ref = logName_; + 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(); + logName_ = s; + return s; + } + } + /** + * string logName = 1; + * @return The bytes for logName. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getLogNameBytes() { + java.lang.Object ref = logName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + logName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; } + } + + public static final int POS_FIELD_NUMBER = 2; + private long pos_; + /** + * int64 pos = 2; + * @return The pos. + */ + @java.lang.Override + public long getPos() { + return pos_; + } + + public static final int EVENTTYPE_FIELD_NUMBER = 3; + private volatile java.lang.Object eventType_; + /** + * string eventType = 3; + * @return The eventType. + */ + @java.lang.Override + public java.lang.String getEventType() { + java.lang.Object ref = eventType_; + 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(); + eventType_ = s; + return s; + } + } + /** + * string eventType = 3; + * @return The bytes for eventType. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getEventTypeBytes() { + java.lang.Object ref = eventType_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + eventType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SERVERID_FIELD_NUMBER = 4; + private long serverId_; + /** + * int64 serverId = 4; + * @return The serverId. + */ + @java.lang.Override + public long getServerId() { + return serverId_; + } + + public static final int ENDLOGPOS_FIELD_NUMBER = 5; + private long endLogPos_; + /** + * int64 endLogPos = 5; + * @return The endLogPos. + */ + @java.lang.Override + public long getEndLogPos() { + return endLogPos_; + } + + public static final int INFO_FIELD_NUMBER = 6; + private volatile java.lang.Object info_; + /** + * string info = 6; + * @return The info. + */ + @java.lang.Override + public java.lang.String getInfo() { + java.lang.Object ref = info_; + 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(); + info_ = s; + return s; + } + } + /** + * string info = 6; + * @return The bytes for info. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getInfoBytes() { + java.lang.Object ref = info_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + info_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getLogNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, logName_); + } + if (pos_ != 0L) { + output.writeInt64(2, pos_); + } + if (!getEventTypeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, eventType_); + } + if (serverId_ != 0L) { + output.writeInt64(4, serverId_); + } + if (endLogPos_ != 0L) { + output.writeInt64(5, endLogPos_); + } + if (!getInfoBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, info_); + } + unknownFields.writeTo(output); + } - private BinlogEvent() { - logName_ = ""; - eventType_ = ""; - info_ = ""; + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getLogNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, logName_); + } + if (pos_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, pos_); + } + if (!getEventTypeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, eventType_); + } + if (serverId_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, serverId_); + } + if (endLogPos_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(5, endLogPos_); + } + if (!getInfoBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, info_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.rpc.cdc.BinlogEvent)) { + return super.equals(obj); + } + com.aliyun.polardbx.rpc.cdc.BinlogEvent other = (com.aliyun.polardbx.rpc.cdc.BinlogEvent) obj; + + if (!getLogName() + .equals(other.getLogName())) return false; + if (getPos() + != other.getPos()) return false; + if (!getEventType() + .equals(other.getEventType())) return false; + if (getServerId() + != other.getServerId()) return false; + if (getEndLogPos() + != other.getEndLogPos()) return false; + if (!getInfo() + .equals(other.getInfo())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + LOGNAME_FIELD_NUMBER; + hash = (53 * hash) + getLogName().hashCode(); + hash = (37 * hash) + POS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getPos()); + hash = (37 * hash) + EVENTTYPE_FIELD_NUMBER; + hash = (53 * hash) + getEventType().hashCode(); + hash = (37 * hash) + SERVERID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getServerId()); + hash = (37 * hash) + ENDLOGPOS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getEndLogPos()); + hash = (37 * hash) + INFO_FIELD_NUMBER; + hash = (53 * hash) + getInfo().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.rpc.cdc.BinlogEvent parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.BinlogEvent parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.BinlogEvent parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.BinlogEvent parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.BinlogEvent parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.BinlogEvent parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.BinlogEvent parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.BinlogEvent parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.BinlogEvent parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.BinlogEvent parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.BinlogEvent parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.BinlogEvent parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.rpc.cdc.BinlogEvent prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code dumper.BinlogEvent} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:dumper.BinlogEvent) + com.aliyun.polardbx.rpc.cdc.BinlogEventOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_BinlogEvent_descriptor; } @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new BinlogEvent(); + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_BinlogEvent_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.BinlogEvent.class, com.aliyun.polardbx.rpc.cdc.BinlogEvent.Builder.class); } - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; + // Construct using com.aliyun.polardbx.rpc.cdc.BinlogEvent.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); } - private BinlogEvent( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - 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; - case 10: { - java.lang.String s = input.readStringRequireUtf8(); + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + logName_ = ""; - logName_ = s; - break; - } - case 16: { + pos_ = 0L; - pos_ = input.readInt64(); - break; - } - case 26: { - java.lang.String s = input.readStringRequireUtf8(); + eventType_ = ""; - eventType_ = s; - break; - } - case 32: { + serverId_ = 0L; - serverId_ = input.readInt64(); - break; - } - case 40: { + endLogPos_ = 0L; - endLogPos_ = input.readInt64(); - break; - } - case 50: { - java.lang.String s = input.readStringRequireUtf8(); + info_ = ""; - info_ = s; - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } + return this; } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return DumperServer.internal_static_dumper_BinlogEvent_descriptor; + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_BinlogEvent_descriptor; } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return DumperServer.internal_static_dumper_BinlogEvent_fieldAccessorTable - .ensureFieldAccessorsInitialized( - BinlogEvent.class, BinlogEvent.Builder.class); + public com.aliyun.polardbx.rpc.cdc.BinlogEvent getDefaultInstanceForType() { + return com.aliyun.polardbx.rpc.cdc.BinlogEvent.getDefaultInstance(); } - public static final int LOGNAME_FIELD_NUMBER = 1; - private volatile java.lang.Object logName_; + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.BinlogEvent build() { + com.aliyun.polardbx.rpc.cdc.BinlogEvent result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.BinlogEvent buildPartial() { + com.aliyun.polardbx.rpc.cdc.BinlogEvent result = new com.aliyun.polardbx.rpc.cdc.BinlogEvent(this); + result.logName_ = logName_; + result.pos_ = pos_; + result.eventType_ = eventType_; + result.serverId_ = serverId_; + result.endLogPos_ = endLogPos_; + result.info_ = info_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.rpc.cdc.BinlogEvent) { + return mergeFrom((com.aliyun.polardbx.rpc.cdc.BinlogEvent)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.polardbx.rpc.cdc.BinlogEvent other) { + if (other == com.aliyun.polardbx.rpc.cdc.BinlogEvent.getDefaultInstance()) return this; + if (!other.getLogName().isEmpty()) { + logName_ = other.logName_; + onChanged(); + } + if (other.getPos() != 0L) { + setPos(other.getPos()); + } + if (!other.getEventType().isEmpty()) { + eventType_ = other.eventType_; + onChanged(); + } + if (other.getServerId() != 0L) { + setServerId(other.getServerId()); + } + if (other.getEndLogPos() != 0L) { + setEndLogPos(other.getEndLogPos()); + } + if (!other.getInfo().isEmpty()) { + info_ = other.info_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.aliyun.polardbx.rpc.cdc.BinlogEvent parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.rpc.cdc.BinlogEvent) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object logName_ = ""; /** * string logName = 1; - * * @return The logName. */ - @java.lang.Override public java.lang.String getLogName() { - java.lang.Object ref = logName_; - 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(); - logName_ = s; - return s; - } + java.lang.Object ref = logName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + logName_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - /** * string logName = 1; - * * @return The bytes for logName. */ - @java.lang.Override public com.google.protobuf.ByteString - getLogNameBytes() { - java.lang.Object ref = logName_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - logName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + getLogNameBytes() { + java.lang.Object ref = logName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + logName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string logName = 1; + * @param value The logName to set. + * @return This builder for chaining. + */ + public Builder setLogName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + logName_ = value; + onChanged(); + return this; + } + /** + * string logName = 1; + * @return This builder for chaining. + */ + public Builder clearLogName() { + + logName_ = getDefaultInstance().getLogName(); + onChanged(); + return this; + } + /** + * string logName = 1; + * @param value The bytes for logName to set. + * @return This builder for chaining. + */ + public Builder setLogNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + logName_ = value; + onChanged(); + return this; } - public static final int POS_FIELD_NUMBER = 2; - private long pos_; - + private long pos_ ; /** * int64 pos = 2; - * * @return The pos. */ @java.lang.Override public long getPos() { - return pos_; + return pos_; + } + /** + * int64 pos = 2; + * @param value The pos to set. + * @return This builder for chaining. + */ + public Builder setPos(long value) { + + pos_ = value; + onChanged(); + return this; + } + /** + * int64 pos = 2; + * @return This builder for chaining. + */ + public Builder clearPos() { + + pos_ = 0L; + onChanged(); + return this; } - public static final int EVENTTYPE_FIELD_NUMBER = 3; - private volatile java.lang.Object eventType_; - + private java.lang.Object eventType_ = ""; /** * string eventType = 3; - * * @return The eventType. */ - @java.lang.Override public java.lang.String getEventType() { - java.lang.Object ref = eventType_; - 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(); - eventType_ = s; - return s; - } + java.lang.Object ref = eventType_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + eventType_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - /** * string eventType = 3; - * * @return The bytes for eventType. */ - @java.lang.Override public com.google.protobuf.ByteString - getEventTypeBytes() { - java.lang.Object ref = eventType_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - eventType_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + getEventTypeBytes() { + java.lang.Object ref = eventType_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + eventType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string eventType = 3; + * @param value The eventType to set. + * @return This builder for chaining. + */ + public Builder setEventType( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + eventType_ = value; + onChanged(); + return this; + } + /** + * string eventType = 3; + * @return This builder for chaining. + */ + public Builder clearEventType() { + + eventType_ = getDefaultInstance().getEventType(); + onChanged(); + return this; + } + /** + * string eventType = 3; + * @param value The bytes for eventType to set. + * @return This builder for chaining. + */ + public Builder setEventTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + eventType_ = value; + onChanged(); + return this; } - public static final int SERVERID_FIELD_NUMBER = 4; - private long serverId_; - + private long serverId_ ; /** * int64 serverId = 4; - * * @return The serverId. */ @java.lang.Override public long getServerId() { - return serverId_; + return serverId_; + } + /** + * int64 serverId = 4; + * @param value The serverId to set. + * @return This builder for chaining. + */ + public Builder setServerId(long value) { + + serverId_ = value; + onChanged(); + return this; + } + /** + * int64 serverId = 4; + * @return This builder for chaining. + */ + public Builder clearServerId() { + + serverId_ = 0L; + onChanged(); + return this; } - public static final int ENDLOGPOS_FIELD_NUMBER = 5; - private long endLogPos_; - + private long endLogPos_ ; /** * int64 endLogPos = 5; - * * @return The endLogPos. */ @java.lang.Override public long getEndLogPos() { - return endLogPos_; + return endLogPos_; + } + /** + * int64 endLogPos = 5; + * @param value The endLogPos to set. + * @return This builder for chaining. + */ + public Builder setEndLogPos(long value) { + + endLogPos_ = value; + onChanged(); + return this; + } + /** + * int64 endLogPos = 5; + * @return This builder for chaining. + */ + public Builder clearEndLogPos() { + + endLogPos_ = 0L; + onChanged(); + return this; } - public static final int INFO_FIELD_NUMBER = 6; - private volatile java.lang.Object info_; - + private java.lang.Object info_ = ""; /** * string info = 6; - * * @return The info. */ - @java.lang.Override public java.lang.String getInfo() { - java.lang.Object ref = info_; - 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(); - info_ = s; - return s; - } + java.lang.Object ref = info_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + info_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - /** * string info = 6; - * * @return The bytes for info. */ - @java.lang.Override public com.google.protobuf.ByteString - getInfoBytes() { - java.lang.Object ref = info_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - info_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + getInfoBytes() { + java.lang.Object ref = info_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + info_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } - - memoizedIsInitialized = 1; - return true; + /** + * string info = 6; + * @param value The info to set. + * @return This builder for chaining. + */ + public Builder setInfo( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + info_ = value; + onChanged(); + return this; } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getLogNameBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, logName_); - } - if (pos_ != 0L) { - output.writeInt64(2, pos_); - } - if (!getEventTypeBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, eventType_); - } - if (serverId_ != 0L) { - output.writeInt64(4, serverId_); - } - if (endLogPos_ != 0L) { - output.writeInt64(5, endLogPos_); - } - if (!getInfoBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 6, info_); - } - unknownFields.writeTo(output); + /** + * string info = 6; + * @return This builder for chaining. + */ + public Builder clearInfo() { + + info_ = getDefaultInstance().getInfo(); + onChanged(); + return this; } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) { - return size; - } - - size = 0; - if (!getLogNameBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, logName_); - } - if (pos_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(2, pos_); - } - if (!getEventTypeBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, eventType_); - } - if (serverId_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(4, serverId_); - } - if (endLogPos_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(5, endLogPos_); - } - if (!getInfoBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, info_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; + /** + * string info = 6; + * @param value The bytes for info to set. + * @return This builder for chaining. + */ + public Builder setInfoBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + info_ = value; + onChanged(); + return this; } - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof BinlogEvent)) { - return super.equals(obj); - } - BinlogEvent other = (BinlogEvent) obj; - - if (!getLogName() - .equals(other.getLogName())) { - return false; - } - if (getPos() - != other.getPos()) { - return false; - } - if (!getEventType() - .equals(other.getEventType())) { - return false; - } - if (getServerId() - != other.getServerId()) { - return false; - } - if (getEndLogPos() - != other.getEndLogPos()) { - return false; - } - if (!getInfo() - .equals(other.getInfo())) { - return false; - } - if (!unknownFields.equals(other.unknownFields)) { - return false; - } - return true; + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); } @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + LOGNAME_FIELD_NUMBER; - hash = (53 * hash) + getLogName().hashCode(); - hash = (37 * hash) + POS_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getPos()); - hash = (37 * hash) + EVENTTYPE_FIELD_NUMBER; - hash = (53 * hash) + getEventType().hashCode(); - hash = (37 * hash) + SERVERID_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getServerId()); - hash = (37 * hash) + ENDLOGPOS_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getEndLogPos()); - hash = (37 * hash) + INFO_FIELD_NUMBER; - hash = (53 * hash) + getInfo().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - public static BinlogEvent parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static BinlogEvent parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } + // @@protoc_insertion_point(builder_scope:dumper.BinlogEvent) + } - public static BinlogEvent parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static BinlogEvent parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static BinlogEvent parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } + // @@protoc_insertion_point(class_scope:dumper.BinlogEvent) + private static final com.aliyun.polardbx.rpc.cdc.BinlogEvent DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.rpc.cdc.BinlogEvent(); + } - public static BinlogEvent parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } + public static com.aliyun.polardbx.rpc.cdc.BinlogEvent getDefaultInstance() { + return DEFAULT_INSTANCE; + } - public static BinlogEvent parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static BinlogEvent parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public static BinlogEvent parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - - public static BinlogEvent parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - - public static BinlogEvent parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static BinlogEvent parseFrom( + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BinlogEvent parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(BinlogEvent prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - /** - * Protobuf type {@code dumper.BinlogEvent} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:dumper.BinlogEvent) - BinlogEventOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return DumperServer.internal_static_dumper_BinlogEvent_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return DumperServer.internal_static_dumper_BinlogEvent_fieldAccessorTable - .ensureFieldAccessorsInitialized( - BinlogEvent.class, BinlogEvent.Builder.class); - } - - // Construct using com.alibaba.tddl.rpc.cdc.BinlogEvent.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - @java.lang.Override - public Builder clear() { - super.clear(); - logName_ = ""; - - pos_ = 0L; - - eventType_ = ""; - - serverId_ = 0L; - - endLogPos_ = 0L; - - info_ = ""; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return DumperServer.internal_static_dumper_BinlogEvent_descriptor; - } - - @java.lang.Override - public BinlogEvent getDefaultInstanceForType() { - return BinlogEvent.getDefaultInstance(); - } - - @java.lang.Override - public BinlogEvent build() { - BinlogEvent result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public BinlogEvent buildPartial() { - BinlogEvent result = new BinlogEvent(this); - result.logName_ = logName_; - result.pos_ = pos_; - result.eventType_ = eventType_; - result.serverId_ = serverId_; - result.endLogPos_ = endLogPos_; - result.info_ = info_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof BinlogEvent) { - return mergeFrom((BinlogEvent) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(BinlogEvent other) { - if (other == BinlogEvent.getDefaultInstance()) { - return this; - } - if (!other.getLogName().isEmpty()) { - logName_ = other.logName_; - onChanged(); - } - if (other.getPos() != 0L) { - setPos(other.getPos()); - } - if (!other.getEventType().isEmpty()) { - eventType_ = other.eventType_; - onChanged(); - } - if (other.getServerId() != 0L) { - setServerId(other.getServerId()); - } - if (other.getEndLogPos() != 0L) { - setEndLogPos(other.getEndLogPos()); - } - if (!other.getInfo().isEmpty()) { - info_ = other.info_; - onChanged(); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - BinlogEvent parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (BinlogEvent) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object logName_ = ""; - - /** - * string logName = 1; - * - * @return The logName. - */ - public java.lang.String getLogName() { - java.lang.Object ref = logName_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - logName_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * string logName = 1; - * - * @return The bytes for logName. - */ - public com.google.protobuf.ByteString - getLogNameBytes() { - java.lang.Object ref = logName_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - logName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string logName = 1; - * - * @param value The logName to set. - * @return This builder for chaining. - */ - public Builder setLogName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - logName_ = value; - onChanged(); - return this; - } - - /** - * string logName = 1; - * - * @return This builder for chaining. - */ - public Builder clearLogName() { - - logName_ = getDefaultInstance().getLogName(); - onChanged(); - return this; - } - - /** - * string logName = 1; - * - * @param value The bytes for logName to set. - * @return This builder for chaining. - */ - public Builder setLogNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - logName_ = value; - onChanged(); - return this; - } - - private long pos_; - - /** - * int64 pos = 2; - * - * @return The pos. - */ - @java.lang.Override - public long getPos() { - return pos_; - } - - /** - * int64 pos = 2; - * - * @param value The pos to set. - * @return This builder for chaining. - */ - public Builder setPos(long value) { - - pos_ = value; - onChanged(); - return this; - } - - /** - * int64 pos = 2; - * - * @return This builder for chaining. - */ - public Builder clearPos() { - - pos_ = 0L; - onChanged(); - return this; - } - - private java.lang.Object eventType_ = ""; - - /** - * string eventType = 3; - * - * @return The eventType. - */ - public java.lang.String getEventType() { - java.lang.Object ref = eventType_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - eventType_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * string eventType = 3; - * - * @return The bytes for eventType. - */ - public com.google.protobuf.ByteString - getEventTypeBytes() { - java.lang.Object ref = eventType_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - eventType_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string eventType = 3; - * - * @param value The eventType to set. - * @return This builder for chaining. - */ - public Builder setEventType( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - eventType_ = value; - onChanged(); - return this; - } - - /** - * string eventType = 3; - * - * @return This builder for chaining. - */ - public Builder clearEventType() { - - eventType_ = getDefaultInstance().getEventType(); - onChanged(); - return this; - } - - /** - * string eventType = 3; - * - * @param value The bytes for eventType to set. - * @return This builder for chaining. - */ - public Builder setEventTypeBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - eventType_ = value; - onChanged(); - return this; - } - - private long serverId_; - - /** - * int64 serverId = 4; - * - * @return The serverId. - */ - @java.lang.Override - public long getServerId() { - return serverId_; - } - - /** - * int64 serverId = 4; - * - * @param value The serverId to set. - * @return This builder for chaining. - */ - public Builder setServerId(long value) { - - serverId_ = value; - onChanged(); - return this; - } - - /** - * int64 serverId = 4; - * - * @return This builder for chaining. - */ - public Builder clearServerId() { - - serverId_ = 0L; - onChanged(); - return this; - } - - private long endLogPos_; - - /** - * int64 endLogPos = 5; - * - * @return The endLogPos. - */ - @java.lang.Override - public long getEndLogPos() { - return endLogPos_; - } - - /** - * int64 endLogPos = 5; - * - * @param value The endLogPos to set. - * @return This builder for chaining. - */ - public Builder setEndLogPos(long value) { - - endLogPos_ = value; - onChanged(); - return this; - } - - /** - * int64 endLogPos = 5; - * - * @return This builder for chaining. - */ - public Builder clearEndLogPos() { - - endLogPos_ = 0L; - onChanged(); - return this; - } - - private java.lang.Object info_ = ""; - - /** - * string info = 6; - * - * @return The info. - */ - public java.lang.String getInfo() { - java.lang.Object ref = info_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - info_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * string info = 6; - * - * @return The bytes for info. - */ - public com.google.protobuf.ByteString - getInfoBytes() { - java.lang.Object ref = info_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - info_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string info = 6; - * - * @param value The info to set. - * @return This builder for chaining. - */ - public Builder setInfo( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - info_ = value; - onChanged(); - return this; - } - - /** - * string info = 6; - * - * @return This builder for chaining. - */ - public Builder clearInfo() { - - info_ = getDefaultInstance().getInfo(); - onChanged(); - return this; - } - - /** - * string info = 6; - * - * @param value The bytes for info to set. - * @return This builder for chaining. - */ - public Builder setInfoBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - info_ = value; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:dumper.BinlogEvent) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BinlogEvent(input, extensionRegistry); } + }; - // @@protoc_insertion_point(class_scope:dumper.BinlogEvent) - private static final BinlogEvent DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new BinlogEvent(); - } + public static com.google.protobuf.Parser parser() { + return PARSER; + } - public static BinlogEvent getDefaultInstance() { - return DEFAULT_INSTANCE; - } + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public BinlogEvent parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new BinlogEvent(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public BinlogEvent getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.BinlogEvent getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/BinlogEventOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/BinlogEventOrBuilder.java index f3586b3c..6c60193b 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/BinlogEventOrBuilder.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/BinlogEventOrBuilder.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: DumperServer.proto @@ -24,69 +7,57 @@ public interface BinlogEventOrBuilder extends // @@protoc_insertion_point(interface_extends:dumper.BinlogEvent) com.google.protobuf.MessageOrBuilder { - /** - * string logName = 1; - * - * @return The logName. - */ - java.lang.String getLogName(); - - /** - * string logName = 1; - * - * @return The bytes for logName. - */ - com.google.protobuf.ByteString - getLogNameBytes(); - - /** - * int64 pos = 2; - * - * @return The pos. - */ - long getPos(); - - /** - * string eventType = 3; - * - * @return The eventType. - */ - java.lang.String getEventType(); - - /** - * string eventType = 3; - * - * @return The bytes for eventType. - */ - com.google.protobuf.ByteString - getEventTypeBytes(); - - /** - * int64 serverId = 4; - * - * @return The serverId. - */ - long getServerId(); - - /** - * int64 endLogPos = 5; - * - * @return The endLogPos. - */ - long getEndLogPos(); - - /** - * string info = 6; - * - * @return The info. - */ - java.lang.String getInfo(); - - /** - * string info = 6; - * - * @return The bytes for info. - */ - com.google.protobuf.ByteString - getInfoBytes(); + /** + * string logName = 1; + * @return The logName. + */ + java.lang.String getLogName(); + /** + * string logName = 1; + * @return The bytes for logName. + */ + com.google.protobuf.ByteString + getLogNameBytes(); + + /** + * int64 pos = 2; + * @return The pos. + */ + long getPos(); + + /** + * string eventType = 3; + * @return The eventType. + */ + java.lang.String getEventType(); + /** + * string eventType = 3; + * @return The bytes for eventType. + */ + com.google.protobuf.ByteString + getEventTypeBytes(); + + /** + * int64 serverId = 4; + * @return The serverId. + */ + long getServerId(); + + /** + * int64 endLogPos = 5; + * @return The endLogPos. + */ + long getEndLogPos(); + + /** + * string info = 6; + * @return The info. + */ + java.lang.String getInfo(); + /** + * string info = 6; + * @return The bytes for info. + */ + com.google.protobuf.ByteString + getInfoBytes(); } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/CdcServiceGrpc.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/CdcServiceGrpc.java index a0d40a4a..b71b14c6 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/CdcServiceGrpc.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/CdcServiceGrpc.java @@ -1,599 +1,1014 @@ -/* - * - * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpc.cdc; import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; import static io.grpc.stub.ClientCalls.asyncUnaryCall; import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; import static io.grpc.stub.ClientCalls.blockingUnaryCall; import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; /** - * */ @javax.annotation.Generated( value = "by gRPC proto compiler (version 1.30.0)", comments = "Source: DumperServer.proto") public final class CdcServiceGrpc { - private CdcServiceGrpc() { - } + private CdcServiceGrpc() {} - public static final String SERVICE_NAME = "dumper.CdcService"; + public static final String SERVICE_NAME = "dumper.CdcService"; - // Static method descriptors that strictly reflect the proto. - private static volatile io.grpc.MethodDescriptor getShowBinaryLogsMethod; + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor getShowBinaryLogsMethod; - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "ShowBinaryLogs", - requestType = Request.class, - responseType = BinaryLog.class, - methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) - public static io.grpc.MethodDescriptor getShowBinaryLogsMethod() { - io.grpc.MethodDescriptor getShowBinaryLogsMethod; + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ShowBinaryLogs", + requestType = com.aliyun.polardbx.rpc.cdc.Request.class, + responseType = com.aliyun.polardbx.rpc.cdc.BinaryLog.class, + methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + public static io.grpc.MethodDescriptor getShowBinaryLogsMethod() { + io.grpc.MethodDescriptor getShowBinaryLogsMethod; + if ((getShowBinaryLogsMethod = CdcServiceGrpc.getShowBinaryLogsMethod) == null) { + synchronized (CdcServiceGrpc.class) { if ((getShowBinaryLogsMethod = CdcServiceGrpc.getShowBinaryLogsMethod) == null) { - synchronized (CdcServiceGrpc.class) { - if ((getShowBinaryLogsMethod = CdcServiceGrpc.getShowBinaryLogsMethod) == null) { - CdcServiceGrpc.getShowBinaryLogsMethod = getShowBinaryLogsMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) - .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ShowBinaryLogs")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - Request.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - BinaryLog.getDefaultInstance())) - .setSchemaDescriptor(new CdcServiceMethodDescriptorSupplier("ShowBinaryLogs")) - .build(); - } - } + CdcServiceGrpc.getShowBinaryLogsMethod = getShowBinaryLogsMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ShowBinaryLogs")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.Request.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.BinaryLog.getDefaultInstance())) + .setSchemaDescriptor(new CdcServiceMethodDescriptorSupplier("ShowBinaryLogs")) + .build(); + } + } + } + return getShowBinaryLogsMethod; + } + + private static volatile io.grpc.MethodDescriptor getShowMasterStatusMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ShowMasterStatus", + requestType = com.aliyun.polardbx.rpc.cdc.Request.class, + responseType = com.aliyun.polardbx.rpc.cdc.MasterStatus.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getShowMasterStatusMethod() { + io.grpc.MethodDescriptor getShowMasterStatusMethod; + if ((getShowMasterStatusMethod = CdcServiceGrpc.getShowMasterStatusMethod) == null) { + synchronized (CdcServiceGrpc.class) { + if ((getShowMasterStatusMethod = CdcServiceGrpc.getShowMasterStatusMethod) == null) { + CdcServiceGrpc.getShowMasterStatusMethod = getShowMasterStatusMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ShowMasterStatus")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.Request.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.MasterStatus.getDefaultInstance())) + .setSchemaDescriptor(new CdcServiceMethodDescriptorSupplier("ShowMasterStatus")) + .build(); + } + } + } + return getShowMasterStatusMethod; + } + + private static volatile io.grpc.MethodDescriptor getShowBinlogEventsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ShowBinlogEvents", + requestType = com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest.class, + responseType = com.aliyun.polardbx.rpc.cdc.BinlogEvent.class, + methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + public static io.grpc.MethodDescriptor getShowBinlogEventsMethod() { + io.grpc.MethodDescriptor getShowBinlogEventsMethod; + if ((getShowBinlogEventsMethod = CdcServiceGrpc.getShowBinlogEventsMethod) == null) { + synchronized (CdcServiceGrpc.class) { + if ((getShowBinlogEventsMethod = CdcServiceGrpc.getShowBinlogEventsMethod) == null) { + CdcServiceGrpc.getShowBinlogEventsMethod = getShowBinlogEventsMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ShowBinlogEvents")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.BinlogEvent.getDefaultInstance())) + .setSchemaDescriptor(new CdcServiceMethodDescriptorSupplier("ShowBinlogEvents")) + .build(); + } + } + } + return getShowBinlogEventsMethod; + } + + private static volatile io.grpc.MethodDescriptor getDumpMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "Dump", + requestType = com.aliyun.polardbx.rpc.cdc.DumpRequest.class, + responseType = com.aliyun.polardbx.rpc.cdc.DumpStream.class, + methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + public static io.grpc.MethodDescriptor getDumpMethod() { + io.grpc.MethodDescriptor getDumpMethod; + if ((getDumpMethod = CdcServiceGrpc.getDumpMethod) == null) { + synchronized (CdcServiceGrpc.class) { + if ((getDumpMethod = CdcServiceGrpc.getDumpMethod) == null) { + CdcServiceGrpc.getDumpMethod = getDumpMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "Dump")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.DumpRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.DumpStream.getDefaultInstance())) + .setSchemaDescriptor(new CdcServiceMethodDescriptorSupplier("Dump")) + .build(); + } + } + } + return getDumpMethod; + } + + private static volatile io.grpc.MethodDescriptor getSyncMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "Sync", + requestType = com.aliyun.polardbx.rpc.cdc.DumpRequest.class, + responseType = com.aliyun.polardbx.rpc.cdc.DumpStream.class, + methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + public static io.grpc.MethodDescriptor getSyncMethod() { + io.grpc.MethodDescriptor getSyncMethod; + if ((getSyncMethod = CdcServiceGrpc.getSyncMethod) == null) { + synchronized (CdcServiceGrpc.class) { + if ((getSyncMethod = CdcServiceGrpc.getSyncMethod) == null) { + CdcServiceGrpc.getSyncMethod = getSyncMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "Sync")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.DumpRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.DumpStream.getDefaultInstance())) + .setSchemaDescriptor(new CdcServiceMethodDescriptorSupplier("Sync")) + .build(); + } + } + } + return getSyncMethod; + } + + private static volatile io.grpc.MethodDescriptor getChangeMasterMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ChangeMaster", + requestType = com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest.class, + responseType = com.aliyun.polardbx.rpc.cdc.RplCommandResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getChangeMasterMethod() { + io.grpc.MethodDescriptor getChangeMasterMethod; + if ((getChangeMasterMethod = CdcServiceGrpc.getChangeMasterMethod) == null) { + synchronized (CdcServiceGrpc.class) { + if ((getChangeMasterMethod = CdcServiceGrpc.getChangeMasterMethod) == null) { + CdcServiceGrpc.getChangeMasterMethod = getChangeMasterMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ChangeMaster")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.RplCommandResponse.getDefaultInstance())) + .setSchemaDescriptor(new CdcServiceMethodDescriptorSupplier("ChangeMaster")) + .build(); + } + } + } + return getChangeMasterMethod; + } + + private static volatile io.grpc.MethodDescriptor getChangeReplicationFilterMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ChangeReplicationFilter", + requestType = com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest.class, + responseType = com.aliyun.polardbx.rpc.cdc.RplCommandResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getChangeReplicationFilterMethod() { + io.grpc.MethodDescriptor getChangeReplicationFilterMethod; + if ((getChangeReplicationFilterMethod = CdcServiceGrpc.getChangeReplicationFilterMethod) == null) { + synchronized (CdcServiceGrpc.class) { + if ((getChangeReplicationFilterMethod = CdcServiceGrpc.getChangeReplicationFilterMethod) == null) { + CdcServiceGrpc.getChangeReplicationFilterMethod = getChangeReplicationFilterMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ChangeReplicationFilter")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.RplCommandResponse.getDefaultInstance())) + .setSchemaDescriptor(new CdcServiceMethodDescriptorSupplier("ChangeReplicationFilter")) + .build(); + } + } + } + return getChangeReplicationFilterMethod; + } + + private static volatile io.grpc.MethodDescriptor getStartSlaveMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "StartSlave", + requestType = com.aliyun.polardbx.rpc.cdc.StartSlaveRequest.class, + responseType = com.aliyun.polardbx.rpc.cdc.RplCommandResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getStartSlaveMethod() { + io.grpc.MethodDescriptor getStartSlaveMethod; + if ((getStartSlaveMethod = CdcServiceGrpc.getStartSlaveMethod) == null) { + synchronized (CdcServiceGrpc.class) { + if ((getStartSlaveMethod = CdcServiceGrpc.getStartSlaveMethod) == null) { + CdcServiceGrpc.getStartSlaveMethod = getStartSlaveMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "StartSlave")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.StartSlaveRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.RplCommandResponse.getDefaultInstance())) + .setSchemaDescriptor(new CdcServiceMethodDescriptorSupplier("StartSlave")) + .build(); + } + } + } + return getStartSlaveMethod; + } + + private static volatile io.grpc.MethodDescriptor getStopSlaveMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "StopSlave", + requestType = com.aliyun.polardbx.rpc.cdc.StopSlaveRequest.class, + responseType = com.aliyun.polardbx.rpc.cdc.RplCommandResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getStopSlaveMethod() { + io.grpc.MethodDescriptor getStopSlaveMethod; + if ((getStopSlaveMethod = CdcServiceGrpc.getStopSlaveMethod) == null) { + synchronized (CdcServiceGrpc.class) { + if ((getStopSlaveMethod = CdcServiceGrpc.getStopSlaveMethod) == null) { + CdcServiceGrpc.getStopSlaveMethod = getStopSlaveMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "StopSlave")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.StopSlaveRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.RplCommandResponse.getDefaultInstance())) + .setSchemaDescriptor(new CdcServiceMethodDescriptorSupplier("StopSlave")) + .build(); + } + } + } + return getStopSlaveMethod; + } + + private static volatile io.grpc.MethodDescriptor getResetSlaveMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ResetSlave", + requestType = com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest.class, + responseType = com.aliyun.polardbx.rpc.cdc.RplCommandResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getResetSlaveMethod() { + io.grpc.MethodDescriptor getResetSlaveMethod; + if ((getResetSlaveMethod = CdcServiceGrpc.getResetSlaveMethod) == null) { + synchronized (CdcServiceGrpc.class) { + if ((getResetSlaveMethod = CdcServiceGrpc.getResetSlaveMethod) == null) { + CdcServiceGrpc.getResetSlaveMethod = getResetSlaveMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ResetSlave")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.RplCommandResponse.getDefaultInstance())) + .setSchemaDescriptor(new CdcServiceMethodDescriptorSupplier("ResetSlave")) + .build(); + } + } + } + return getResetSlaveMethod; + } + + private static volatile io.grpc.MethodDescriptor getShowSlaveStatusMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ShowSlaveStatus", + requestType = com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest.class, + responseType = com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + public static io.grpc.MethodDescriptor getShowSlaveStatusMethod() { + io.grpc.MethodDescriptor getShowSlaveStatusMethod; + if ((getShowSlaveStatusMethod = CdcServiceGrpc.getShowSlaveStatusMethod) == null) { + synchronized (CdcServiceGrpc.class) { + if ((getShowSlaveStatusMethod = CdcServiceGrpc.getShowSlaveStatusMethod) == null) { + CdcServiceGrpc.getShowSlaveStatusMethod = getShowSlaveStatusMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ShowSlaveStatus")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse.getDefaultInstance())) + .setSchemaDescriptor(new CdcServiceMethodDescriptorSupplier("ShowSlaveStatus")) + .build(); + } + } + } + return getShowSlaveStatusMethod; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static CdcServiceStub newStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public CdcServiceStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new CdcServiceStub(channel, callOptions); + } + }; + return CdcServiceStub.newStub(factory, channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static CdcServiceBlockingStub newBlockingStub( + io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public CdcServiceBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new CdcServiceBlockingStub(channel, callOptions); + } + }; + return CdcServiceBlockingStub.newStub(factory, channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static CdcServiceFutureStub newFutureStub( + io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public CdcServiceFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new CdcServiceFutureStub(channel, callOptions); } - return getShowBinaryLogsMethod; + }; + return CdcServiceFutureStub.newStub(factory, channel); + } + + /** + */ + public static abstract class CdcServiceImplBase implements io.grpc.BindableService { + + /** + *
+     * ShowBinaryLogs + ShowMasterLogs
+     * 
+ */ + public void showBinaryLogs(com.aliyun.polardbx.rpc.cdc.Request request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getShowBinaryLogsMethod(), responseObserver); } - private static volatile io.grpc.MethodDescriptor getShowMasterStatusMethod; + /** + */ + public void showMasterStatus(com.aliyun.polardbx.rpc.cdc.Request request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getShowMasterStatusMethod(), responseObserver); + } - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "ShowMasterStatus", - requestType = Request.class, - responseType = MasterStatus.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getShowMasterStatusMethod() { - io.grpc.MethodDescriptor getShowMasterStatusMethod; - if ((getShowMasterStatusMethod = CdcServiceGrpc.getShowMasterStatusMethod) == null) { - synchronized (CdcServiceGrpc.class) { - if ((getShowMasterStatusMethod = CdcServiceGrpc.getShowMasterStatusMethod) == null) { - CdcServiceGrpc.getShowMasterStatusMethod = getShowMasterStatusMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ShowMasterStatus")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - Request.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - MasterStatus.getDefaultInstance())) - .setSchemaDescriptor(new CdcServiceMethodDescriptorSupplier("ShowMasterStatus")) - .build(); - } - } - } - return getShowMasterStatusMethod; + /** + */ + public void showBinlogEvents(com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getShowBinlogEventsMethod(), responseObserver); } - private static volatile io.grpc.MethodDescriptor getShowBinlogEventsMethod; + /** + */ + public void dump(com.aliyun.polardbx.rpc.cdc.DumpRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getDumpMethod(), responseObserver); + } - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "ShowBinlogEvents", - requestType = ShowBinlogEventsRequest.class, - responseType = BinlogEvent.class, - methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) - public static io.grpc.MethodDescriptor getShowBinlogEventsMethod() { - io.grpc.MethodDescriptor getShowBinlogEventsMethod; - if ((getShowBinlogEventsMethod = CdcServiceGrpc.getShowBinlogEventsMethod) == null) { - synchronized (CdcServiceGrpc.class) { - if ((getShowBinlogEventsMethod = CdcServiceGrpc.getShowBinlogEventsMethod) == null) { - CdcServiceGrpc.getShowBinlogEventsMethod = getShowBinlogEventsMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) - .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ShowBinlogEvents")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - ShowBinlogEventsRequest.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - BinlogEvent.getDefaultInstance())) - .setSchemaDescriptor(new CdcServiceMethodDescriptorSupplier("ShowBinlogEvents")) - .build(); - } - } - } - return getShowBinlogEventsMethod; + /** + */ + public void sync(com.aliyun.polardbx.rpc.cdc.DumpRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getSyncMethod(), responseObserver); } - private static volatile io.grpc.MethodDescriptor getDumpMethod; + /** + *
+     *//////////////////////////// replicate   ///////////////////////////
+     * 
+ */ + public void changeMaster(com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getChangeMasterMethod(), responseObserver); + } - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "Dump", - requestType = DumpRequest.class, - responseType = DumpStream.class, - methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) - public static io.grpc.MethodDescriptor getDumpMethod() { - io.grpc.MethodDescriptor getDumpMethod; - if ((getDumpMethod = CdcServiceGrpc.getDumpMethod) == null) { - synchronized (CdcServiceGrpc.class) { - if ((getDumpMethod = CdcServiceGrpc.getDumpMethod) == null) { - CdcServiceGrpc.getDumpMethod = getDumpMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) - .setFullMethodName(generateFullMethodName(SERVICE_NAME, "Dump")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - DumpRequest.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - DumpStream.getDefaultInstance())) - .setSchemaDescriptor(new CdcServiceMethodDescriptorSupplier("Dump")) - .build(); - } - } - } - return getDumpMethod; + /** + */ + public void changeReplicationFilter(com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getChangeReplicationFilterMethod(), responseObserver); } - private static volatile io.grpc.MethodDescriptor getSyncMethod; + /** + */ + public void startSlave(com.aliyun.polardbx.rpc.cdc.StartSlaveRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getStartSlaveMethod(), responseObserver); + } - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "Sync", - requestType = DumpRequest.class, - responseType = DumpStream.class, - methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) - public static io.grpc.MethodDescriptor getSyncMethod() { - io.grpc.MethodDescriptor getSyncMethod; - if ((getSyncMethod = CdcServiceGrpc.getSyncMethod) == null) { - synchronized (CdcServiceGrpc.class) { - if ((getSyncMethod = CdcServiceGrpc.getSyncMethod) == null) { - CdcServiceGrpc.getSyncMethod = getSyncMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) - .setFullMethodName(generateFullMethodName(SERVICE_NAME, "Sync")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - DumpRequest.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - DumpStream.getDefaultInstance())) - .setSchemaDescriptor(new CdcServiceMethodDescriptorSupplier("Sync")) - .build(); - } - } - } - return getSyncMethod; + /** + */ + public void stopSlave(com.aliyun.polardbx.rpc.cdc.StopSlaveRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getStopSlaveMethod(), responseObserver); } /** - * Creates a new async stub that supports all call types for the service */ - public static CdcServiceStub newStub(io.grpc.Channel channel) { - io.grpc.stub.AbstractStub.StubFactory factory = - new io.grpc.stub.AbstractStub.StubFactory() { - @java.lang.Override - public CdcServiceStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - return new CdcServiceStub(channel, callOptions); - } - }; - return CdcServiceStub.newStub(factory, channel); + public void resetSlave(com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getResetSlaveMethod(), responseObserver); } /** - * Creates a new blocking-style stub that supports unary and streaming output calls on the service */ - public static CdcServiceBlockingStub newBlockingStub( - io.grpc.Channel channel) { - io.grpc.stub.AbstractStub.StubFactory factory = - new io.grpc.stub.AbstractStub.StubFactory() { - @java.lang.Override - public CdcServiceBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - return new CdcServiceBlockingStub(channel, callOptions); - } - }; - return CdcServiceBlockingStub.newStub(factory, channel); + public void showSlaveStatus(com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getShowSlaveStatusMethod(), responseObserver); + } + + @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getShowBinaryLogsMethod(), + asyncServerStreamingCall( + new MethodHandlers< + com.aliyun.polardbx.rpc.cdc.Request, + com.aliyun.polardbx.rpc.cdc.BinaryLog>( + this, METHODID_SHOW_BINARY_LOGS))) + .addMethod( + getShowMasterStatusMethod(), + asyncUnaryCall( + new MethodHandlers< + com.aliyun.polardbx.rpc.cdc.Request, + com.aliyun.polardbx.rpc.cdc.MasterStatus>( + this, METHODID_SHOW_MASTER_STATUS))) + .addMethod( + getShowBinlogEventsMethod(), + asyncServerStreamingCall( + new MethodHandlers< + com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest, + com.aliyun.polardbx.rpc.cdc.BinlogEvent>( + this, METHODID_SHOW_BINLOG_EVENTS))) + .addMethod( + getDumpMethod(), + asyncServerStreamingCall( + new MethodHandlers< + com.aliyun.polardbx.rpc.cdc.DumpRequest, + com.aliyun.polardbx.rpc.cdc.DumpStream>( + this, METHODID_DUMP))) + .addMethod( + getSyncMethod(), + asyncServerStreamingCall( + new MethodHandlers< + com.aliyun.polardbx.rpc.cdc.DumpRequest, + com.aliyun.polardbx.rpc.cdc.DumpStream>( + this, METHODID_SYNC))) + .addMethod( + getChangeMasterMethod(), + asyncUnaryCall( + new MethodHandlers< + com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest, + com.aliyun.polardbx.rpc.cdc.RplCommandResponse>( + this, METHODID_CHANGE_MASTER))) + .addMethod( + getChangeReplicationFilterMethod(), + asyncUnaryCall( + new MethodHandlers< + com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest, + com.aliyun.polardbx.rpc.cdc.RplCommandResponse>( + this, METHODID_CHANGE_REPLICATION_FILTER))) + .addMethod( + getStartSlaveMethod(), + asyncUnaryCall( + new MethodHandlers< + com.aliyun.polardbx.rpc.cdc.StartSlaveRequest, + com.aliyun.polardbx.rpc.cdc.RplCommandResponse>( + this, METHODID_START_SLAVE))) + .addMethod( + getStopSlaveMethod(), + asyncUnaryCall( + new MethodHandlers< + com.aliyun.polardbx.rpc.cdc.StopSlaveRequest, + com.aliyun.polardbx.rpc.cdc.RplCommandResponse>( + this, METHODID_STOP_SLAVE))) + .addMethod( + getResetSlaveMethod(), + asyncUnaryCall( + new MethodHandlers< + com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest, + com.aliyun.polardbx.rpc.cdc.RplCommandResponse>( + this, METHODID_RESET_SLAVE))) + .addMethod( + getShowSlaveStatusMethod(), + asyncServerStreamingCall( + new MethodHandlers< + com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest, + com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse>( + this, METHODID_SHOW_SLAVE_STATUS))) + .build(); + } + } + + /** + */ + public static final class CdcServiceStub extends io.grpc.stub.AbstractAsyncStub { + private CdcServiceStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected CdcServiceStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new CdcServiceStub(channel, callOptions); } /** - * Creates a new ListenableFuture-style stub that supports unary calls on the service + *
+     * ShowBinaryLogs + ShowMasterLogs
+     * 
*/ - public static CdcServiceFutureStub newFutureStub( - io.grpc.Channel channel) { - io.grpc.stub.AbstractStub.StubFactory factory = - new io.grpc.stub.AbstractStub.StubFactory() { - @java.lang.Override - public CdcServiceFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - return new CdcServiceFutureStub(channel, callOptions); - } - }; - return CdcServiceFutureStub.newStub(factory, channel); + public void showBinaryLogs(com.aliyun.polardbx.rpc.cdc.Request request, + io.grpc.stub.StreamObserver responseObserver) { + asyncServerStreamingCall( + getChannel().newCall(getShowBinaryLogsMethod(), getCallOptions()), request, responseObserver); } /** - * */ - public static abstract class CdcServiceImplBase implements io.grpc.BindableService { + public void showMasterStatus(com.aliyun.polardbx.rpc.cdc.Request request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getShowMasterStatusMethod(), getCallOptions()), request, responseObserver); + } - /** - *
-         * ShowBinaryLogs + ShowMasterLogs
-         * 
- */ - public void showBinaryLogs(Request request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getShowBinaryLogsMethod(), responseObserver); - } + /** + */ + public void showBinlogEvents(com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncServerStreamingCall( + getChannel().newCall(getShowBinlogEventsMethod(), getCallOptions()), request, responseObserver); + } - /** - * - */ - public void showMasterStatus(Request request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getShowMasterStatusMethod(), responseObserver); - } + /** + */ + public void dump(com.aliyun.polardbx.rpc.cdc.DumpRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncServerStreamingCall( + getChannel().newCall(getDumpMethod(), getCallOptions()), request, responseObserver); + } - /** - * - */ - public void showBinlogEvents(ShowBinlogEventsRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getShowBinlogEventsMethod(), responseObserver); - } + /** + */ + public void sync(com.aliyun.polardbx.rpc.cdc.DumpRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncServerStreamingCall( + getChannel().newCall(getSyncMethod(), getCallOptions()), request, responseObserver); + } - /** - * - */ - public void dump(DumpRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getDumpMethod(), responseObserver); - } + /** + *
+     *//////////////////////////// replicate   ///////////////////////////
+     * 
+ */ + public void changeMaster(com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getChangeMasterMethod(), getCallOptions()), request, responseObserver); + } - /** - * - */ - public void sync(DumpRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getSyncMethod(), responseObserver); - } + /** + */ + public void changeReplicationFilter(com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getChangeReplicationFilterMethod(), getCallOptions()), request, responseObserver); + } - @java.lang.Override - public final io.grpc.ServerServiceDefinition bindService() { - return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) - .addMethod( - getShowBinaryLogsMethod(), - asyncServerStreamingCall( - new MethodHandlers< - Request, - BinaryLog>( - this, METHODID_SHOW_BINARY_LOGS))) - .addMethod( - getShowMasterStatusMethod(), - asyncUnaryCall( - new MethodHandlers< - Request, - MasterStatus>( - this, METHODID_SHOW_MASTER_STATUS))) - .addMethod( - getShowBinlogEventsMethod(), - asyncServerStreamingCall( - new MethodHandlers< - ShowBinlogEventsRequest, - BinlogEvent>( - this, METHODID_SHOW_BINLOG_EVENTS))) - .addMethod( - getDumpMethod(), - asyncServerStreamingCall( - new MethodHandlers< - DumpRequest, - DumpStream>( - this, METHODID_DUMP))) - .addMethod( - getSyncMethod(), - asyncServerStreamingCall( - new MethodHandlers< - DumpRequest, - DumpStream>( - this, METHODID_SYNC))) - .build(); - } + /** + */ + public void startSlave(com.aliyun.polardbx.rpc.cdc.StartSlaveRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getStartSlaveMethod(), getCallOptions()), request, responseObserver); } /** - * */ - public static final class CdcServiceStub extends io.grpc.stub.AbstractAsyncStub { - private CdcServiceStub( - io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } + public void stopSlave(com.aliyun.polardbx.rpc.cdc.StopSlaveRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getStopSlaveMethod(), getCallOptions()), request, responseObserver); + } - @java.lang.Override - protected CdcServiceStub build( - io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - return new CdcServiceStub(channel, callOptions); - } + /** + */ + public void resetSlave(com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getResetSlaveMethod(), getCallOptions()), request, responseObserver); + } - /** - *
-         * ShowBinaryLogs + ShowMasterLogs
-         * 
- */ - public void showBinaryLogs(Request request, - io.grpc.stub.StreamObserver responseObserver) { - asyncServerStreamingCall( - getChannel().newCall(getShowBinaryLogsMethod(), getCallOptions()), request, responseObserver); - } + /** + */ + public void showSlaveStatus(com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncServerStreamingCall( + getChannel().newCall(getShowSlaveStatusMethod(), getCallOptions()), request, responseObserver); + } + } + + /** + */ + public static final class CdcServiceBlockingStub extends io.grpc.stub.AbstractBlockingStub { + private CdcServiceBlockingStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } - /** - * - */ - public void showMasterStatus(Request request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(getShowMasterStatusMethod(), getCallOptions()), request, responseObserver); - } + @java.lang.Override + protected CdcServiceBlockingStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new CdcServiceBlockingStub(channel, callOptions); + } - /** - * - */ - public void showBinlogEvents(ShowBinlogEventsRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncServerStreamingCall( - getChannel().newCall(getShowBinlogEventsMethod(), getCallOptions()), request, responseObserver); - } + /** + *
+     * ShowBinaryLogs + ShowMasterLogs
+     * 
+ */ + public java.util.Iterator showBinaryLogs( + com.aliyun.polardbx.rpc.cdc.Request request) { + return blockingServerStreamingCall( + getChannel(), getShowBinaryLogsMethod(), getCallOptions(), request); + } - /** - * - */ - public void dump(DumpRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncServerStreamingCall( - getChannel().newCall(getDumpMethod(), getCallOptions()), request, responseObserver); - } + /** + */ + public com.aliyun.polardbx.rpc.cdc.MasterStatus showMasterStatus(com.aliyun.polardbx.rpc.cdc.Request request) { + return blockingUnaryCall( + getChannel(), getShowMasterStatusMethod(), getCallOptions(), request); + } - /** - * - */ - public void sync(DumpRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncServerStreamingCall( - getChannel().newCall(getSyncMethod(), getCallOptions()), request, responseObserver); - } + /** + */ + public java.util.Iterator showBinlogEvents( + com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest request) { + return blockingServerStreamingCall( + getChannel(), getShowBinlogEventsMethod(), getCallOptions(), request); } /** - * */ - public static final class CdcServiceBlockingStub extends io.grpc.stub.AbstractBlockingStub { - private CdcServiceBlockingStub( - io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } + public java.util.Iterator dump( + com.aliyun.polardbx.rpc.cdc.DumpRequest request) { + return blockingServerStreamingCall( + getChannel(), getDumpMethod(), getCallOptions(), request); + } - @java.lang.Override - protected CdcServiceBlockingStub build( - io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - return new CdcServiceBlockingStub(channel, callOptions); - } + /** + */ + public java.util.Iterator sync( + com.aliyun.polardbx.rpc.cdc.DumpRequest request) { + return blockingServerStreamingCall( + getChannel(), getSyncMethod(), getCallOptions(), request); + } - /** - *
-         * ShowBinaryLogs + ShowMasterLogs
-         * 
- */ - public java.util.Iterator showBinaryLogs( - Request request) { - return blockingServerStreamingCall( - getChannel(), getShowBinaryLogsMethod(), getCallOptions(), request); - } + /** + *
+     *//////////////////////////// replicate   ///////////////////////////
+     * 
+ */ + public com.aliyun.polardbx.rpc.cdc.RplCommandResponse changeMaster(com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest request) { + return blockingUnaryCall( + getChannel(), getChangeMasterMethod(), getCallOptions(), request); + } - /** - * - */ - public MasterStatus showMasterStatus(Request request) { - return blockingUnaryCall( - getChannel(), getShowMasterStatusMethod(), getCallOptions(), request); - } + /** + */ + public com.aliyun.polardbx.rpc.cdc.RplCommandResponse changeReplicationFilter(com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest request) { + return blockingUnaryCall( + getChannel(), getChangeReplicationFilterMethod(), getCallOptions(), request); + } - /** - * - */ - public java.util.Iterator showBinlogEvents( - ShowBinlogEventsRequest request) { - return blockingServerStreamingCall( - getChannel(), getShowBinlogEventsMethod(), getCallOptions(), request); - } + /** + */ + public com.aliyun.polardbx.rpc.cdc.RplCommandResponse startSlave(com.aliyun.polardbx.rpc.cdc.StartSlaveRequest request) { + return blockingUnaryCall( + getChannel(), getStartSlaveMethod(), getCallOptions(), request); + } - /** - * - */ - public java.util.Iterator dump( - DumpRequest request) { - return blockingServerStreamingCall( - getChannel(), getDumpMethod(), getCallOptions(), request); - } + /** + */ + public com.aliyun.polardbx.rpc.cdc.RplCommandResponse stopSlave(com.aliyun.polardbx.rpc.cdc.StopSlaveRequest request) { + return blockingUnaryCall( + getChannel(), getStopSlaveMethod(), getCallOptions(), request); + } - /** - * - */ - public java.util.Iterator sync( - DumpRequest request) { - return blockingServerStreamingCall( - getChannel(), getSyncMethod(), getCallOptions(), request); - } + /** + */ + public com.aliyun.polardbx.rpc.cdc.RplCommandResponse resetSlave(com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest request) { + return blockingUnaryCall( + getChannel(), getResetSlaveMethod(), getCallOptions(), request); } /** - * */ - public static final class CdcServiceFutureStub extends io.grpc.stub.AbstractFutureStub { - private CdcServiceFutureStub( - io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } + public java.util.Iterator showSlaveStatus( + com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest request) { + return blockingServerStreamingCall( + getChannel(), getShowSlaveStatusMethod(), getCallOptions(), request); + } + } + + /** + */ + public static final class CdcServiceFutureStub extends io.grpc.stub.AbstractFutureStub { + private CdcServiceFutureStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } - @java.lang.Override - protected CdcServiceFutureStub build( - io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - return new CdcServiceFutureStub(channel, callOptions); - } + @java.lang.Override + protected CdcServiceFutureStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new CdcServiceFutureStub(channel, callOptions); + } - /** - * - */ - public com.google.common.util.concurrent.ListenableFuture showMasterStatus( - Request request) { - return futureUnaryCall( - getChannel().newCall(getShowMasterStatusMethod(), getCallOptions()), request); - } + /** + */ + public com.google.common.util.concurrent.ListenableFuture showMasterStatus( + com.aliyun.polardbx.rpc.cdc.Request request) { + return futureUnaryCall( + getChannel().newCall(getShowMasterStatusMethod(), getCallOptions()), request); } - private static final int METHODID_SHOW_BINARY_LOGS = 0; - private static final int METHODID_SHOW_MASTER_STATUS = 1; - private static final int METHODID_SHOW_BINLOG_EVENTS = 2; - private static final int METHODID_DUMP = 3; - private static final int METHODID_SYNC = 4; + /** + *
+     *//////////////////////////// replicate   ///////////////////////////
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture changeMaster( + com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest request) { + return futureUnaryCall( + getChannel().newCall(getChangeMasterMethod(), getCallOptions()), request); + } - private static final class MethodHandlers implements - io.grpc.stub.ServerCalls.UnaryMethod, - io.grpc.stub.ServerCalls.ServerStreamingMethod, - io.grpc.stub.ServerCalls.ClientStreamingMethod, - io.grpc.stub.ServerCalls.BidiStreamingMethod { - private final CdcServiceImplBase serviceImpl; - private final int methodId; + /** + */ + public com.google.common.util.concurrent.ListenableFuture changeReplicationFilter( + com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest request) { + return futureUnaryCall( + getChannel().newCall(getChangeReplicationFilterMethod(), getCallOptions()), request); + } - MethodHandlers(CdcServiceImplBase serviceImpl, int methodId) { - this.serviceImpl = serviceImpl; - this.methodId = methodId; - } + /** + */ + public com.google.common.util.concurrent.ListenableFuture startSlave( + com.aliyun.polardbx.rpc.cdc.StartSlaveRequest request) { + return futureUnaryCall( + getChannel().newCall(getStartSlaveMethod(), getCallOptions()), request); + } - @java.lang.Override - @java.lang.SuppressWarnings("unchecked") - public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { - switch (methodId) { - case METHODID_SHOW_BINARY_LOGS: - serviceImpl.showBinaryLogs((Request) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_SHOW_MASTER_STATUS: - serviceImpl.showMasterStatus((Request) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_SHOW_BINLOG_EVENTS: - serviceImpl.showBinlogEvents((ShowBinlogEventsRequest) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_DUMP: - serviceImpl.dump((DumpRequest) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_SYNC: - serviceImpl.sync((DumpRequest) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - default: - throw new AssertionError(); - } - } + /** + */ + public com.google.common.util.concurrent.ListenableFuture stopSlave( + com.aliyun.polardbx.rpc.cdc.StopSlaveRequest request) { + return futureUnaryCall( + getChannel().newCall(getStopSlaveMethod(), getCallOptions()), request); + } - @java.lang.Override - @java.lang.SuppressWarnings("unchecked") - public io.grpc.stub.StreamObserver invoke( - io.grpc.stub.StreamObserver responseObserver) { - switch (methodId) { - default: - throw new AssertionError(); - } - } + /** + */ + public com.google.common.util.concurrent.ListenableFuture resetSlave( + com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest request) { + return futureUnaryCall( + getChannel().newCall(getResetSlaveMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_SHOW_BINARY_LOGS = 0; + private static final int METHODID_SHOW_MASTER_STATUS = 1; + private static final int METHODID_SHOW_BINLOG_EVENTS = 2; + private static final int METHODID_DUMP = 3; + private static final int METHODID_SYNC = 4; + private static final int METHODID_CHANGE_MASTER = 5; + private static final int METHODID_CHANGE_REPLICATION_FILTER = 6; + private static final int METHODID_START_SLAVE = 7; + private static final int METHODID_STOP_SLAVE = 8; + private static final int METHODID_RESET_SLAVE = 9; + private static final int METHODID_SHOW_SLAVE_STATUS = 10; + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final CdcServiceImplBase serviceImpl; + private final int methodId; + + MethodHandlers(CdcServiceImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; } - private static abstract class CdcServiceBaseDescriptorSupplier - implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { - CdcServiceBaseDescriptorSupplier() { - } + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_SHOW_BINARY_LOGS: + serviceImpl.showBinaryLogs((com.aliyun.polardbx.rpc.cdc.Request) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_SHOW_MASTER_STATUS: + serviceImpl.showMasterStatus((com.aliyun.polardbx.rpc.cdc.Request) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_SHOW_BINLOG_EVENTS: + serviceImpl.showBinlogEvents((com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_DUMP: + serviceImpl.dump((com.aliyun.polardbx.rpc.cdc.DumpRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_SYNC: + serviceImpl.sync((com.aliyun.polardbx.rpc.cdc.DumpRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_CHANGE_MASTER: + serviceImpl.changeMaster((com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_CHANGE_REPLICATION_FILTER: + serviceImpl.changeReplicationFilter((com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_START_SLAVE: + serviceImpl.startSlave((com.aliyun.polardbx.rpc.cdc.StartSlaveRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_STOP_SLAVE: + serviceImpl.stopSlave((com.aliyun.polardbx.rpc.cdc.StopSlaveRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_RESET_SLAVE: + serviceImpl.resetSlave((com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_SHOW_SLAVE_STATUS: + serviceImpl.showSlaveStatus((com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } - @java.lang.Override - public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { - return DumperServer.getDescriptor(); - } + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } - @java.lang.Override - public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { - return getFileDescriptor().findServiceByName("CdcService"); - } + private static abstract class CdcServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + CdcServiceBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.getDescriptor(); } - private static final class CdcServiceFileDescriptorSupplier - extends CdcServiceBaseDescriptorSupplier { - CdcServiceFileDescriptorSupplier() { - } + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("CdcService"); } + } - private static final class CdcServiceMethodDescriptorSupplier - extends CdcServiceBaseDescriptorSupplier - implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { - private final String methodName; + private static final class CdcServiceFileDescriptorSupplier + extends CdcServiceBaseDescriptorSupplier { + CdcServiceFileDescriptorSupplier() {} + } - CdcServiceMethodDescriptorSupplier(String methodName) { - this.methodName = methodName; - } + private static final class CdcServiceMethodDescriptorSupplier + extends CdcServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; - @java.lang.Override - public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { - return getServiceDescriptor().findMethodByName(methodName); - } + CdcServiceMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; } - private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + @java.lang.Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; - public static io.grpc.ServiceDescriptor getServiceDescriptor() { - io.grpc.ServiceDescriptor result = serviceDescriptor; + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (CdcServiceGrpc.class) { + result = serviceDescriptor; if (result == null) { - synchronized (CdcServiceGrpc.class) { - result = serviceDescriptor; - if (result == null) { - serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) - .setSchemaDescriptor(new CdcServiceFileDescriptorSupplier()) - .addMethod(getShowBinaryLogsMethod()) - .addMethod(getShowMasterStatusMethod()) - .addMethod(getShowBinlogEventsMethod()) - .addMethod(getDumpMethod()) - .addMethod(getSyncMethod()) - .build(); - } - } - } - return result; + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new CdcServiceFileDescriptorSupplier()) + .addMethod(getShowBinaryLogsMethod()) + .addMethod(getShowMasterStatusMethod()) + .addMethod(getShowBinlogEventsMethod()) + .addMethod(getDumpMethod()) + .addMethod(getSyncMethod()) + .addMethod(getChangeMasterMethod()) + .addMethod(getChangeReplicationFilterMethod()) + .addMethod(getStartSlaveMethod()) + .addMethod(getStopSlaveMethod()) + .addMethod(getResetSlaveMethod()) + .addMethod(getShowSlaveStatusMethod()) + .build(); + } + } } + return result; + } } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ChangeMasterRequest.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ChangeMasterRequest.java new file mode 100644 index 00000000..e82bf471 --- /dev/null +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ChangeMasterRequest.java @@ -0,0 +1,557 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DumperServer.proto + +package com.aliyun.polardbx.rpc.cdc; + +/** + * Protobuf type {@code dumper.ChangeMasterRequest} + */ +public final class ChangeMasterRequest extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:dumper.ChangeMasterRequest) + ChangeMasterRequestOrBuilder { +private static final long serialVersionUID = 0L; + // Use ChangeMasterRequest.newBuilder() to construct. + private ChangeMasterRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ChangeMasterRequest() { + request_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new ChangeMasterRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ChangeMasterRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + request_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ChangeMasterRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ChangeMasterRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest.class, com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest.Builder.class); + } + + public static final int REQUEST_FIELD_NUMBER = 1; + private volatile java.lang.Object request_; + /** + * string request = 1; + * @return The request. + */ + @java.lang.Override + public java.lang.String getRequest() { + java.lang.Object ref = request_; + 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(); + request_ = s; + return s; + } + } + /** + * string request = 1; + * @return The bytes for request. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getRequestBytes() { + java.lang.Object ref = request_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + request_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getRequestBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, request_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getRequestBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, request_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest)) { + return super.equals(obj); + } + com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest other = (com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest) obj; + + if (!getRequest() + .equals(other.getRequest())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + REQUEST_FIELD_NUMBER; + hash = (53 * hash) + getRequest().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code dumper.ChangeMasterRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:dumper.ChangeMasterRequest) + com.aliyun.polardbx.rpc.cdc.ChangeMasterRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ChangeMasterRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ChangeMasterRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest.class, com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest.Builder.class); + } + + // Construct using com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + request_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ChangeMasterRequest_descriptor; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest getDefaultInstanceForType() { + return com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest build() { + com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest buildPartial() { + com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest result = new com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest(this); + result.request_ = request_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest) { + return mergeFrom((com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest other) { + if (other == com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest.getDefaultInstance()) return this; + if (!other.getRequest().isEmpty()) { + request_ = other.request_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object request_ = ""; + /** + * string request = 1; + * @return The request. + */ + public java.lang.String getRequest() { + java.lang.Object ref = request_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + request_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string request = 1; + * @return The bytes for request. + */ + public com.google.protobuf.ByteString + getRequestBytes() { + java.lang.Object ref = request_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + request_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string request = 1; + * @param value The request to set. + * @return This builder for chaining. + */ + public Builder setRequest( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + request_ = value; + onChanged(); + return this; + } + /** + * string request = 1; + * @return This builder for chaining. + */ + public Builder clearRequest() { + + request_ = getDefaultInstance().getRequest(); + onChanged(); + return this; + } + /** + * string request = 1; + * @param value The bytes for request to set. + * @return This builder for chaining. + */ + public Builder setRequestBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + request_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:dumper.ChangeMasterRequest) + } + + // @@protoc_insertion_point(class_scope:dumper.ChangeMasterRequest) + private static final com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest(); + } + + public static com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ChangeMasterRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ChangeMasterRequest(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ChangeMasterRequestOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ChangeMasterRequestOrBuilder.java new file mode 100644 index 00000000..02a298a5 --- /dev/null +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ChangeMasterRequestOrBuilder.java @@ -0,0 +1,21 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DumperServer.proto + +package com.aliyun.polardbx.rpc.cdc; + +public interface ChangeMasterRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:dumper.ChangeMasterRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * string request = 1; + * @return The request. + */ + java.lang.String getRequest(); + /** + * string request = 1; + * @return The bytes for request. + */ + com.google.protobuf.ByteString + getRequestBytes(); +} diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ChangeReplicationFilterRequest.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ChangeReplicationFilterRequest.java new file mode 100644 index 00000000..b834726d --- /dev/null +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ChangeReplicationFilterRequest.java @@ -0,0 +1,557 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DumperServer.proto + +package com.aliyun.polardbx.rpc.cdc; + +/** + * Protobuf type {@code dumper.ChangeReplicationFilterRequest} + */ +public final class ChangeReplicationFilterRequest extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:dumper.ChangeReplicationFilterRequest) + ChangeReplicationFilterRequestOrBuilder { +private static final long serialVersionUID = 0L; + // Use ChangeReplicationFilterRequest.newBuilder() to construct. + private ChangeReplicationFilterRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ChangeReplicationFilterRequest() { + request_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new ChangeReplicationFilterRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ChangeReplicationFilterRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + request_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ChangeReplicationFilterRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ChangeReplicationFilterRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest.class, com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest.Builder.class); + } + + public static final int REQUEST_FIELD_NUMBER = 1; + private volatile java.lang.Object request_; + /** + * string request = 1; + * @return The request. + */ + @java.lang.Override + public java.lang.String getRequest() { + java.lang.Object ref = request_; + 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(); + request_ = s; + return s; + } + } + /** + * string request = 1; + * @return The bytes for request. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getRequestBytes() { + java.lang.Object ref = request_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + request_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getRequestBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, request_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getRequestBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, request_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest)) { + return super.equals(obj); + } + com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest other = (com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest) obj; + + if (!getRequest() + .equals(other.getRequest())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + REQUEST_FIELD_NUMBER; + hash = (53 * hash) + getRequest().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code dumper.ChangeReplicationFilterRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:dumper.ChangeReplicationFilterRequest) + com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ChangeReplicationFilterRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ChangeReplicationFilterRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest.class, com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest.Builder.class); + } + + // Construct using com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + request_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ChangeReplicationFilterRequest_descriptor; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest getDefaultInstanceForType() { + return com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest build() { + com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest buildPartial() { + com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest result = new com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest(this); + result.request_ = request_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest) { + return mergeFrom((com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest other) { + if (other == com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest.getDefaultInstance()) return this; + if (!other.getRequest().isEmpty()) { + request_ = other.request_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object request_ = ""; + /** + * string request = 1; + * @return The request. + */ + public java.lang.String getRequest() { + java.lang.Object ref = request_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + request_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string request = 1; + * @return The bytes for request. + */ + public com.google.protobuf.ByteString + getRequestBytes() { + java.lang.Object ref = request_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + request_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string request = 1; + * @param value The request to set. + * @return This builder for chaining. + */ + public Builder setRequest( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + request_ = value; + onChanged(); + return this; + } + /** + * string request = 1; + * @return This builder for chaining. + */ + public Builder clearRequest() { + + request_ = getDefaultInstance().getRequest(); + onChanged(); + return this; + } + /** + * string request = 1; + * @param value The bytes for request to set. + * @return This builder for chaining. + */ + public Builder setRequestBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + request_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:dumper.ChangeReplicationFilterRequest) + } + + // @@protoc_insertion_point(class_scope:dumper.ChangeReplicationFilterRequest) + private static final com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest(); + } + + public static com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ChangeReplicationFilterRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ChangeReplicationFilterRequest(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ChangeReplicationFilterRequestOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ChangeReplicationFilterRequestOrBuilder.java new file mode 100644 index 00000000..0a05136c --- /dev/null +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ChangeReplicationFilterRequestOrBuilder.java @@ -0,0 +1,21 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DumperServer.proto + +package com.aliyun.polardbx.rpc.cdc; + +public interface ChangeReplicationFilterRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:dumper.ChangeReplicationFilterRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * string request = 1; + * @return The request. + */ + java.lang.String getRequest(); + /** + * string request = 1; + * @return The bytes for request. + */ + com.google.protobuf.ByteString + getRequestBytes(); +} diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/DumpRequest.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/DumpRequest.java index c38c38a6..9769f385 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/DumpRequest.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/DumpRequest.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: DumperServer.proto @@ -27,680 +10,613 @@ public final class DumpRequest extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:dumper.DumpRequest) DumpRequestOrBuilder { - private static final long serialVersionUID = 0L; - - // Use DumpRequest.newBuilder() to construct. - private DumpRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } +private static final long serialVersionUID = 0L; + // Use DumpRequest.newBuilder() to construct. + private DumpRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private DumpRequest() { + fileName_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new DumpRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private DumpRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); - private DumpRequest() { - fileName_ = ""; + fileName_ = s; + break; + } + case 16: { + + position_ = input.readInt64(); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_DumpRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_DumpRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.DumpRequest.class, com.aliyun.polardbx.rpc.cdc.DumpRequest.Builder.class); + } + + public static final int FILENAME_FIELD_NUMBER = 1; + private volatile java.lang.Object fileName_; + /** + * string fileName = 1; + * @return The fileName. + */ + @java.lang.Override + public java.lang.String getFileName() { + java.lang.Object ref = fileName_; + 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(); + fileName_ = s; + return s; + } + } + /** + * string fileName = 1; + * @return The bytes for fileName. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getFileNameBytes() { + java.lang.Object ref = fileName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + fileName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int POSITION_FIELD_NUMBER = 2; + private long position_; + /** + * int64 position = 2; + * @return The position. + */ + @java.lang.Override + public long getPosition() { + return position_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getFileNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, fileName_); + } + if (position_ != 0L) { + output.writeInt64(2, position_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getFileNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, fileName_); + } + if (position_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, position_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.rpc.cdc.DumpRequest)) { + return super.equals(obj); + } + com.aliyun.polardbx.rpc.cdc.DumpRequest other = (com.aliyun.polardbx.rpc.cdc.DumpRequest) obj; + + if (!getFileName() + .equals(other.getFileName())) return false; + if (getPosition() + != other.getPosition()) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + FILENAME_FIELD_NUMBER; + hash = (53 * hash) + getFileName().hashCode(); + hash = (37 * hash) + POSITION_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getPosition()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.rpc.cdc.DumpRequest parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.DumpRequest parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.DumpRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.DumpRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.DumpRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.DumpRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.DumpRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.DumpRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.DumpRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.DumpRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.DumpRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.DumpRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.rpc.cdc.DumpRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code dumper.DumpRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:dumper.DumpRequest) + com.aliyun.polardbx.rpc.cdc.DumpRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_DumpRequest_descriptor; } @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new DumpRequest(); + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_DumpRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.DumpRequest.class, com.aliyun.polardbx.rpc.cdc.DumpRequest.Builder.class); } - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; + // Construct using com.aliyun.polardbx.rpc.cdc.DumpRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); } - private DumpRequest( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - 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; - case 10: { - java.lang.String s = input.readStringRequireUtf8(); - - fileName_ = s; - break; - } - case 16: { - - position_ = input.readInt64(); - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return DumperServer.internal_static_dumper_DumpRequest_descriptor; + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } } - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return DumperServer.internal_static_dumper_DumpRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - DumpRequest.class, DumpRequest.Builder.class); - } + public Builder clear() { + super.clear(); + fileName_ = ""; - public static final int FILENAME_FIELD_NUMBER = 1; - private volatile java.lang.Object fileName_; + position_ = 0L; - /** - * string fileName = 1; - * - * @return The fileName. - */ - @java.lang.Override - public java.lang.String getFileName() { - java.lang.Object ref = fileName_; - 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(); - fileName_ = s; - return s; - } + return this; } - /** - * string fileName = 1; - * - * @return The bytes for fileName. - */ @java.lang.Override - public com.google.protobuf.ByteString - getFileNameBytes() { - java.lang.Object ref = fileName_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - fileName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_DumpRequest_descriptor; } - public static final int POSITION_FIELD_NUMBER = 2; - private long position_; - - /** - * int64 position = 2; - * - * @return The position. - */ @java.lang.Override - public long getPosition() { - return position_; + public com.aliyun.polardbx.rpc.cdc.DumpRequest getDefaultInstanceForType() { + return com.aliyun.polardbx.rpc.cdc.DumpRequest.getDefaultInstance(); } - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } - - memoizedIsInitialized = 1; - return true; + public com.aliyun.polardbx.rpc.cdc.DumpRequest build() { + com.aliyun.polardbx.rpc.cdc.DumpRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; } @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getFileNameBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, fileName_); - } - if (position_ != 0L) { - output.writeInt64(2, position_); - } - unknownFields.writeTo(output); + public com.aliyun.polardbx.rpc.cdc.DumpRequest buildPartial() { + com.aliyun.polardbx.rpc.cdc.DumpRequest result = new com.aliyun.polardbx.rpc.cdc.DumpRequest(this); + result.fileName_ = fileName_; + result.position_ = position_; + onBuilt(); + return result; } @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) { - return size; - } - - size = 0; - if (!getFileNameBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, fileName_); - } - if (position_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(2, position_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; + public Builder clone() { + return super.clone(); } - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof DumpRequest)) { - return super.equals(obj); - } - DumpRequest other = (DumpRequest) obj; - - if (!getFileName() - .equals(other.getFileName())) { - return false; - } - if (getPosition() - != other.getPosition()) { - return false; - } - if (!unknownFields.equals(other.unknownFields)) { - return false; - } - return true; + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); } - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + FILENAME_FIELD_NUMBER; - hash = (53 * hash) + getFileName().hashCode(); - hash = (37 * hash) + POSITION_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getPosition()); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static DumpRequest parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); } - - public static DumpRequest parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static DumpRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); } - - public static DumpRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); } - - public static DumpRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); } - - public static DumpRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.rpc.cdc.DumpRequest) { + return mergeFrom((com.aliyun.polardbx.rpc.cdc.DumpRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.polardbx.rpc.cdc.DumpRequest other) { + if (other == com.aliyun.polardbx.rpc.cdc.DumpRequest.getDefaultInstance()) return this; + if (!other.getFileName().isEmpty()) { + fileName_ = other.fileName_; + onChanged(); + } + if (other.getPosition() != 0L) { + setPosition(other.getPosition()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; } - public static DumpRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + @java.lang.Override + public final boolean isInitialized() { + return true; } - public static DumpRequest parseFrom( - java.io.InputStream input, + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + com.aliyun.polardbx.rpc.cdc.DumpRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.rpc.cdc.DumpRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; } - public static DumpRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); + private java.lang.Object fileName_ = ""; + /** + * string fileName = 1; + * @return The fileName. + */ + public java.lang.String getFileName() { + java.lang.Object ref = fileName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + fileName_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - - public static DumpRequest parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + /** + * string fileName = 1; + * @return The bytes for fileName. + */ + public com.google.protobuf.ByteString + getFileNameBytes() { + java.lang.Object ref = fileName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + fileName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } - - public static DumpRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + /** + * string fileName = 1; + * @param value The fileName to set. + * @return This builder for chaining. + */ + public Builder setFileName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + fileName_ = value; + onChanged(); + return this; } - - public static DumpRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + /** + * string fileName = 1; + * @return This builder for chaining. + */ + public Builder clearFileName() { + + fileName_ = getDefaultInstance().getFileName(); + onChanged(); + return this; } - + /** + * string fileName = 1; + * @param value The bytes for fileName to set. + * @return This builder for chaining. + */ + public Builder setFileNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + fileName_ = value; + onChanged(); + return this; + } + + private long position_ ; + /** + * int64 position = 2; + * @return The position. + */ @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); + public long getPosition() { + return position_; } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); + /** + * int64 position = 2; + * @param value The position to set. + * @return This builder for chaining. + */ + public Builder setPosition(long value) { + + position_ = value; + onChanged(); + return this; } - - public static Builder newBuilder(DumpRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + /** + * int64 position = 2; + * @return This builder for chaining. + */ + public Builder clearPosition() { + + position_ = 0L; + onChanged(); + return this; } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); } @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - /** - * Protobuf type {@code dumper.DumpRequest} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:dumper.DumpRequest) - DumpRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return DumperServer.internal_static_dumper_DumpRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return DumperServer.internal_static_dumper_DumpRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - DumpRequest.class, DumpRequest.Builder.class); - } - - // Construct using com.alibaba.tddl.rpc.cdc.DumpRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - @java.lang.Override - public Builder clear() { - super.clear(); - fileName_ = ""; - - position_ = 0L; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return DumperServer.internal_static_dumper_DumpRequest_descriptor; - } - - @java.lang.Override - public DumpRequest getDefaultInstanceForType() { - return DumpRequest.getDefaultInstance(); - } - - @java.lang.Override - public DumpRequest build() { - DumpRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public DumpRequest buildPartial() { - DumpRequest result = new DumpRequest(this); - result.fileName_ = fileName_; - result.position_ = position_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof DumpRequest) { - return mergeFrom((DumpRequest) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(DumpRequest other) { - if (other == DumpRequest.getDefaultInstance()) { - return this; - } - if (!other.getFileName().isEmpty()) { - fileName_ = other.fileName_; - onChanged(); - } - if (other.getPosition() != 0L) { - setPosition(other.getPosition()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - DumpRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (DumpRequest) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object fileName_ = ""; - - /** - * string fileName = 1; - * - * @return The fileName. - */ - public java.lang.String getFileName() { - java.lang.Object ref = fileName_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - fileName_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * string fileName = 1; - * - * @return The bytes for fileName. - */ - public com.google.protobuf.ByteString - getFileNameBytes() { - java.lang.Object ref = fileName_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - fileName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string fileName = 1; - * - * @param value The fileName to set. - * @return This builder for chaining. - */ - public Builder setFileName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - fileName_ = value; - onChanged(); - return this; - } - - /** - * string fileName = 1; - * - * @return This builder for chaining. - */ - public Builder clearFileName() { - - fileName_ = getDefaultInstance().getFileName(); - onChanged(); - return this; - } - - /** - * string fileName = 1; - * - * @param value The bytes for fileName to set. - * @return This builder for chaining. - */ - public Builder setFileNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - fileName_ = value; - onChanged(); - return this; - } - - private long position_; - - /** - * int64 position = 2; - * - * @return The position. - */ - @java.lang.Override - public long getPosition() { - return position_; - } - /** - * int64 position = 2; - * - * @param value The position to set. - * @return This builder for chaining. - */ - public Builder setPosition(long value) { - - position_ = value; - onChanged(); - return this; - } + // @@protoc_insertion_point(builder_scope:dumper.DumpRequest) + } - /** - * int64 position = 2; - * - * @return This builder for chaining. - */ - public Builder clearPosition() { + // @@protoc_insertion_point(class_scope:dumper.DumpRequest) + private static final com.aliyun.polardbx.rpc.cdc.DumpRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.rpc.cdc.DumpRequest(); + } - position_ = 0L; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:dumper.DumpRequest) - } + public static com.aliyun.polardbx.rpc.cdc.DumpRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } - // @@protoc_insertion_point(class_scope:dumper.DumpRequest) - private static final DumpRequest DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new DumpRequest(); - } - - public static DumpRequest getDefaultInstance() { - return DEFAULT_INSTANCE; + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DumpRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DumpRequest(input, extensionRegistry); } + }; - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public DumpRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new DumpRequest(input, extensionRegistry); - } - }; + public static com.google.protobuf.Parser parser() { + return PARSER; + } - public static com.google.protobuf.Parser parser() { - return PARSER; - } + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public DumpRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.DumpRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/DumpRequestOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/DumpRequestOrBuilder.java index a1bb53bf..53fe9869 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/DumpRequestOrBuilder.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/DumpRequestOrBuilder.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: DumperServer.proto @@ -24,25 +7,21 @@ public interface DumpRequestOrBuilder extends // @@protoc_insertion_point(interface_extends:dumper.DumpRequest) com.google.protobuf.MessageOrBuilder { - /** - * string fileName = 1; - * - * @return The fileName. - */ - java.lang.String getFileName(); - - /** - * string fileName = 1; - * - * @return The bytes for fileName. - */ - com.google.protobuf.ByteString - getFileNameBytes(); + /** + * string fileName = 1; + * @return The fileName. + */ + java.lang.String getFileName(); + /** + * string fileName = 1; + * @return The bytes for fileName. + */ + com.google.protobuf.ByteString + getFileNameBytes(); - /** - * int64 position = 2; - * - * @return The position. - */ - long getPosition(); + /** + * int64 position = 2; + * @return The position. + */ + long getPosition(); } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/DumpStream.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/DumpStream.java index ae924fc0..a0295616 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/DumpStream.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/DumpStream.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: DumperServer.proto @@ -27,529 +10,478 @@ public final class DumpStream extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:dumper.DumpStream) DumpStreamOrBuilder { - private static final long serialVersionUID = 0L; - - // Use DumpStream.newBuilder() to construct. - private DumpStream(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private DumpStream() { - payload_ = com.google.protobuf.ByteString.EMPTY; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new DumpStream(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - - private DumpStream( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - 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; - case 10: { - - payload_ = input.readBytes(); - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } +private static final long serialVersionUID = 0L; + // Use DumpStream.newBuilder() to construct. + private DumpStream(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private DumpStream() { + payload_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new DumpStream(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private DumpStream( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + + payload_ = input.readBytes(); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_DumpStream_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_DumpStream_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.DumpStream.class, com.aliyun.polardbx.rpc.cdc.DumpStream.Builder.class); + } + + public static final int PAYLOAD_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString payload_; + /** + * bytes payload = 1; + * @return The payload. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPayload() { + return payload_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!payload_.isEmpty()) { + output.writeBytes(1, payload_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!payload_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, payload_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.rpc.cdc.DumpStream)) { + return super.equals(obj); + } + com.aliyun.polardbx.rpc.cdc.DumpStream other = (com.aliyun.polardbx.rpc.cdc.DumpStream) obj; + + if (!getPayload() + .equals(other.getPayload())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PAYLOAD_FIELD_NUMBER; + hash = (53 * hash) + getPayload().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.rpc.cdc.DumpStream parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.DumpStream parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.DumpStream parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.DumpStream parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.DumpStream parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.DumpStream parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.DumpStream parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.DumpStream parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.DumpStream parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.DumpStream parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.DumpStream parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.DumpStream parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.rpc.cdc.DumpStream prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code dumper.DumpStream} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:dumper.DumpStream) + com.aliyun.polardbx.rpc.cdc.DumpStreamOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return DumperServer.internal_static_dumper_DumpStream_descriptor; + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_DumpStream_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return DumperServer.internal_static_dumper_DumpStream_fieldAccessorTable - .ensureFieldAccessorsInitialized( - DumpStream.class, DumpStream.Builder.class); + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_DumpStream_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.DumpStream.class, com.aliyun.polardbx.rpc.cdc.DumpStream.Builder.class); } - public static final int PAYLOAD_FIELD_NUMBER = 1; - private com.google.protobuf.ByteString payload_; - - /** - * bytes payload = 1; - * - * @return The payload. - */ - @java.lang.Override - public com.google.protobuf.ByteString getPayload() { - return payload_; + // Construct using com.aliyun.polardbx.rpc.cdc.DumpStream.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); } - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } - - memoizedIsInitialized = 1; - return true; + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!payload_.isEmpty()) { - output.writeBytes(1, payload_); - } - unknownFields.writeTo(output); + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } } - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) { - return size; - } + public Builder clear() { + super.clear(); + payload_ = com.google.protobuf.ByteString.EMPTY; - size = 0; - if (!payload_.isEmpty()) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(1, payload_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; + return this; } @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof DumpStream)) { - return super.equals(obj); - } - DumpStream other = (DumpStream) obj; - - if (!getPayload() - .equals(other.getPayload())) { - return false; - } - if (!unknownFields.equals(other.unknownFields)) { - return false; - } - return true; + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_DumpStream_descriptor; } @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + PAYLOAD_FIELD_NUMBER; - hash = (53 * hash) + getPayload().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; + public com.aliyun.polardbx.rpc.cdc.DumpStream getDefaultInstanceForType() { + return com.aliyun.polardbx.rpc.cdc.DumpStream.getDefaultInstance(); } - public static DumpStream parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.DumpStream build() { + com.aliyun.polardbx.rpc.cdc.DumpStream result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; } - public static DumpStream parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.DumpStream buildPartial() { + com.aliyun.polardbx.rpc.cdc.DumpStream result = new com.aliyun.polardbx.rpc.cdc.DumpStream(this); + result.payload_ = payload_; + onBuilt(); + return result; } - public static DumpStream parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + @java.lang.Override + public Builder clone() { + return super.clone(); } - - public static DumpStream parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); } - - public static DumpStream parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); } - - public static DumpStream parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); } - - public static DumpStream parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); } - - public static DumpStream parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); } - - public static DumpStream parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.rpc.cdc.DumpStream) { + return mergeFrom((com.aliyun.polardbx.rpc.cdc.DumpStream)other); + } else { + super.mergeFrom(other); + return this; + } } - public static DumpStream parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + public Builder mergeFrom(com.aliyun.polardbx.rpc.cdc.DumpStream other) { + if (other == com.aliyun.polardbx.rpc.cdc.DumpStream.getDefaultInstance()) return this; + if (other.getPayload() != com.google.protobuf.ByteString.EMPTY) { + setPayload(other.getPayload()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; } - public static DumpStream parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + @java.lang.Override + public final boolean isInitialized() { + return true; } - public static DumpStream parseFrom( + @java.lang.Override + public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + com.aliyun.polardbx.rpc.cdc.DumpStream parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.rpc.cdc.DumpStream) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; } + private com.google.protobuf.ByteString payload_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes payload = 1; + * @return The payload. + */ @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); + public com.google.protobuf.ByteString getPayload() { + return payload_; } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); + /** + * bytes payload = 1; + * @param value The payload to set. + * @return This builder for chaining. + */ + public Builder setPayload(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + payload_ = value; + onChanged(); + return this; } - - public static Builder newBuilder(DumpStream prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + /** + * bytes payload = 1; + * @return This builder for chaining. + */ + public Builder clearPayload() { + + payload_ = getDefaultInstance().getPayload(); + onChanged(); + return this; } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); } @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - /** - * Protobuf type {@code dumper.DumpStream} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:dumper.DumpStream) - DumpStreamOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return DumperServer.internal_static_dumper_DumpStream_descriptor; - } - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return DumperServer.internal_static_dumper_DumpStream_fieldAccessorTable - .ensureFieldAccessorsInitialized( - DumpStream.class, DumpStream.Builder.class); - } + // @@protoc_insertion_point(builder_scope:dumper.DumpStream) + } - // Construct using com.alibaba.tddl.rpc.cdc.DumpStream.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } + // @@protoc_insertion_point(class_scope:dumper.DumpStream) + private static final com.aliyun.polardbx.rpc.cdc.DumpStream DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.rpc.cdc.DumpStream(); + } - @java.lang.Override - public Builder clear() { - super.clear(); - payload_ = com.google.protobuf.ByteString.EMPTY; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return DumperServer.internal_static_dumper_DumpStream_descriptor; - } - - @java.lang.Override - public DumpStream getDefaultInstanceForType() { - return DumpStream.getDefaultInstance(); - } - - @java.lang.Override - public DumpStream build() { - DumpStream result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public DumpStream buildPartial() { - DumpStream result = new DumpStream(this); - result.payload_ = payload_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } + public static com.aliyun.polardbx.rpc.cdc.DumpStream getDefaultInstance() { + return DEFAULT_INSTANCE; + } - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof DumpStream) { - return mergeFrom((DumpStream) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(DumpStream other) { - if (other == DumpStream.getDefaultInstance()) { - return this; - } - if (other.getPayload() != com.google.protobuf.ByteString.EMPTY) { - setPayload(other.getPayload()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - DumpStream parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (DumpStream) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private com.google.protobuf.ByteString payload_ = com.google.protobuf.ByteString.EMPTY; - - /** - * bytes payload = 1; - * - * @return The payload. - */ - @java.lang.Override - public com.google.protobuf.ByteString getPayload() { - return payload_; - } - - /** - * bytes payload = 1; - * - * @param value The payload to set. - * @return This builder for chaining. - */ - public Builder setPayload(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - - payload_ = value; - onChanged(); - return this; - } - - /** - * bytes payload = 1; - * - * @return This builder for chaining. - */ - public Builder clearPayload() { - - payload_ = getDefaultInstance().getPayload(); - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:dumper.DumpStream) - } - - // @@protoc_insertion_point(class_scope:dumper.DumpStream) - private static final DumpStream DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new DumpStream(); - } - - public static DumpStream getDefaultInstance() { - return DEFAULT_INSTANCE; + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DumpStream parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DumpStream(input, extensionRegistry); } + }; - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public DumpStream parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new DumpStream(input, extensionRegistry); - } - }; + public static com.google.protobuf.Parser parser() { + return PARSER; + } - public static com.google.protobuf.Parser parser() { - return PARSER; - } + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public DumpStream getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.DumpStream getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/DumpStreamOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/DumpStreamOrBuilder.java index 730a3a23..88789acf 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/DumpStreamOrBuilder.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/DumpStreamOrBuilder.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: DumperServer.proto @@ -24,10 +7,9 @@ public interface DumpStreamOrBuilder extends // @@protoc_insertion_point(interface_extends:dumper.DumpStream) com.google.protobuf.MessageOrBuilder { - /** - * bytes payload = 1; - * - * @return The payload. - */ - com.google.protobuf.ByteString getPayload(); + /** + * bytes payload = 1; + * @return The payload. + */ + com.google.protobuf.ByteString getPayload(); } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/DumperServer.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/DumperServer.java index 60887fa6..cf3904c5 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/DumperServer.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/DumperServer.java @@ -1,155 +1,242 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: DumperServer.proto package com.aliyun.polardbx.rpc.cdc; public final class DumperServer { - private DumperServer() { - } - - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistryLite registry) { - } + private DumperServer() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - registerAllExtensions( - (com.google.protobuf.ExtensionRegistryLite) registry); - } - - static final com.google.protobuf.Descriptors.Descriptor - internal_static_dumper_Request_descriptor; - static final + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + static final com.google.protobuf.Descriptors.Descriptor + internal_static_dumper_Request_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_dumper_Request_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_dumper_ShowBinlogEventsRequest_descriptor; - static final + internal_static_dumper_Request_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_dumper_ShowBinlogEventsRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_dumper_ShowBinlogEventsRequest_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_dumper_DumpRequest_descriptor; - static final + internal_static_dumper_ShowBinlogEventsRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_dumper_DumpRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_dumper_DumpRequest_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_dumper_BinaryLog_descriptor; - static final + internal_static_dumper_DumpRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_dumper_BinaryLog_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_dumper_BinaryLog_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_dumper_MasterStatus_descriptor; - static final + internal_static_dumper_BinaryLog_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_dumper_MasterStatus_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_dumper_MasterStatus_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_dumper_BinlogEvent_descriptor; - static final + internal_static_dumper_MasterStatus_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_dumper_BinlogEvent_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_dumper_BinlogEvent_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_dumper_DumpStream_descriptor; - static final + internal_static_dumper_BinlogEvent_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_dumper_DumpStream_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_dumper_DumpStream_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; + internal_static_dumper_DumpStream_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_dumper_RplCommandResponse_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_dumper_RplCommandResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_dumper_ChangeMasterRequest_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_dumper_ChangeMasterRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_dumper_StartSlaveRequest_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_dumper_StartSlaveRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_dumper_StopSlaveRequest_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_dumper_StopSlaveRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_dumper_ResetSlaveRequest_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_dumper_ResetSlaveRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_dumper_ChangeReplicationFilterRequest_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_dumper_ChangeReplicationFilterRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_dumper_ShowSlaveStatusRequest_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_dumper_ShowSlaveStatusRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_dumper_ShowSlaveStatusResponse_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_dumper_ShowSlaveStatusResponse_fieldAccessorTable; - static { - java.lang.String[] descriptorData = { - "\n\022DumperServer.proto\022\006dumper\"\026\n\007Request\022" + - "\013\n\003req\030\001 \001(\t\"Y\n\027ShowBinlogEventsRequest\022" + - "\017\n\007logName\030\001 \001(\t\022\013\n\003pos\030\002 \001(\003\022\016\n\006offset\030" + - "\003 \001(\003\022\020\n\010rowCount\030\004 \001(\003\"1\n\013DumpRequest\022\020" + - "\n\010fileName\030\001 \001(\t\022\020\n\010position\030\002 \001(\003\".\n\tBi" + - "naryLog\022\017\n\007logName\030\001 \001(\t\022\020\n\010fileSize\030\002 \001" + - "(\003\"s\n\014MasterStatus\022\014\n\004file\030\001 \001(\t\022\020\n\010posi" + - "tion\030\002 \001(\003\022\022\n\nbinlogDoDB\030\003 \001(\t\022\026\n\016binlog" + - "IgnoreDB\030\004 \001(\t\022\027\n\017executedGtidSet\030\005 \001(\t\"" + - "q\n\013BinlogEvent\022\017\n\007logName\030\001 \001(\t\022\013\n\003pos\030\002" + - " \001(\003\022\021\n\teventType\030\003 \001(\t\022\020\n\010serverId\030\004 \001(" + - "\003\022\021\n\tendLogPos\030\005 \001(\003\022\014\n\004info\030\006 \001(\t\"\035\n\nDu" + - "mpStream\022\017\n\007payload\030\001 \001(\0142\273\002\n\nCdcService" + - "\0228\n\016ShowBinaryLogs\022\017.dumper.Request\032\021.du" + - "mper.BinaryLog\"\0000\001\022;\n\020ShowMasterStatus\022\017" + - ".dumper.Request\032\024.dumper.MasterStatus\"\000\022" + - "L\n\020ShowBinlogEvents\022\037.dumper.ShowBinlogE" + - "ventsRequest\032\023.dumper.BinlogEvent\"\0000\001\0223\n" + - "\004Dump\022\023.dumper.DumpRequest\032\022.dumper.Dump" + - "Stream\"\0000\001\0223\n\004Sync\022\023.dumper.DumpRequest\032" + - "\022.dumper.DumpStream\"\0000\001B\036\n\030com.alibaba.t" + - "ddl.rpc.cdcH\001P\001b\006proto3" - }; - descriptor = com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }); - internal_static_dumper_Request_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_dumper_Request_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_dumper_Request_descriptor, - new java.lang.String[] {"Req",}); - internal_static_dumper_ShowBinlogEventsRequest_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_dumper_ShowBinlogEventsRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_dumper_ShowBinlogEventsRequest_descriptor, - new java.lang.String[] {"LogName", "Pos", "Offset", "RowCount",}); - internal_static_dumper_DumpRequest_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_dumper_DumpRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_dumper_DumpRequest_descriptor, - new java.lang.String[] {"FileName", "Position",}); - internal_static_dumper_BinaryLog_descriptor = - getDescriptor().getMessageTypes().get(3); - internal_static_dumper_BinaryLog_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_dumper_BinaryLog_descriptor, - new java.lang.String[] {"LogName", "FileSize",}); - internal_static_dumper_MasterStatus_descriptor = - getDescriptor().getMessageTypes().get(4); - internal_static_dumper_MasterStatus_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_dumper_MasterStatus_descriptor, - new java.lang.String[] {"File", "Position", "BinlogDoDB", "BinlogIgnoreDB", "ExecutedGtidSet",}); - internal_static_dumper_BinlogEvent_descriptor = - getDescriptor().getMessageTypes().get(5); - internal_static_dumper_BinlogEvent_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_dumper_BinlogEvent_descriptor, - new java.lang.String[] {"LogName", "Pos", "EventType", "ServerId", "EndLogPos", "Info",}); - internal_static_dumper_DumpStream_descriptor = - getDescriptor().getMessageTypes().get(6); - internal_static_dumper_DumpStream_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_dumper_DumpStream_descriptor, - new java.lang.String[] {"Payload",}); - } + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\022DumperServer.proto\022\006dumper\"\026\n\007Request\022" + + "\013\n\003req\030\001 \001(\t\"Y\n\027ShowBinlogEventsRequest\022" + + "\017\n\007logName\030\001 \001(\t\022\013\n\003pos\030\002 \001(\003\022\016\n\006offset\030" + + "\003 \001(\003\022\020\n\010rowCount\030\004 \001(\003\"1\n\013DumpRequest\022\020" + + "\n\010fileName\030\001 \001(\t\022\020\n\010position\030\002 \001(\003\".\n\tBi" + + "naryLog\022\017\n\007logName\030\001 \001(\t\022\020\n\010fileSize\030\002 \001" + + "(\003\"s\n\014MasterStatus\022\014\n\004file\030\001 \001(\t\022\020\n\010posi" + + "tion\030\002 \001(\003\022\022\n\nbinlogDoDB\030\003 \001(\t\022\026\n\016binlog" + + "IgnoreDB\030\004 \001(\t\022\027\n\017executedGtidSet\030\005 \001(\t\"" + + "q\n\013BinlogEvent\022\017\n\007logName\030\001 \001(\t\022\013\n\003pos\030\002" + + " \001(\003\022\021\n\teventType\030\003 \001(\t\022\020\n\010serverId\030\004 \001(" + + "\003\022\021\n\tendLogPos\030\005 \001(\003\022\014\n\004info\030\006 \001(\t\"\035\n\nDu" + + "mpStream\022\017\n\007payload\030\001 \001(\014\"7\n\022RplCommandR" + + "esponse\022\022\n\nresultCode\030\001 \001(\005\022\r\n\005error\030\002 \001" + + "(\t\"&\n\023ChangeMasterRequest\022\017\n\007request\030\001 \001" + + "(\t\"$\n\021StartSlaveRequest\022\017\n\007request\030\001 \001(\t" + + "\"#\n\020StopSlaveRequest\022\017\n\007request\030\001 \001(\t\"$\n" + + "\021ResetSlaveRequest\022\017\n\007request\030\001 \001(\t\"1\n\036C" + + "hangeReplicationFilterRequest\022\017\n\007request" + + "\030\001 \001(\t\")\n\026ShowSlaveStatusRequest\022\017\n\007requ" + + "est\030\001 \001(\t\"+\n\027ShowSlaveStatusResponse\022\020\n\010" + + "response\030\001 \001(\t2\222\006\n\nCdcService\0228\n\016ShowBin" + + "aryLogs\022\017.dumper.Request\032\021.dumper.Binary" + + "Log\"\0000\001\022;\n\020ShowMasterStatus\022\017.dumper.Req" + + "uest\032\024.dumper.MasterStatus\"\000\022L\n\020ShowBinl" + + "ogEvents\022\037.dumper.ShowBinlogEventsReques" + + "t\032\023.dumper.BinlogEvent\"\0000\001\0223\n\004Dump\022\023.dum" + + "per.DumpRequest\032\022.dumper.DumpStream\"\0000\001\022" + + "3\n\004Sync\022\023.dumper.DumpRequest\032\022.dumper.Du" + + "mpStream\"\0000\001\022I\n\014ChangeMaster\022\033.dumper.Ch" + + "angeMasterRequest\032\032.dumper.RplCommandRes" + + "ponse\"\000\022_\n\027ChangeReplicationFilter\022&.dum" + + "per.ChangeReplicationFilterRequest\032\032.dum" + + "per.RplCommandResponse\"\000\022E\n\nStartSlave\022\031" + + ".dumper.StartSlaveRequest\032\032.dumper.RplCo" + + "mmandResponse\"\000\022C\n\tStopSlave\022\030.dumper.St" + + "opSlaveRequest\032\032.dumper.RplCommandRespon" + + "se\"\000\022E\n\nResetSlave\022\031.dumper.ResetSlaveRe" + + "quest\032\032.dumper.RplCommandResponse\"\000\022V\n\017S" + + "howSlaveStatus\022\036.dumper.ShowSlaveStatusR" + + "equest\032\037.dumper.ShowSlaveStatusResponse\"" + + "\0000\001B!\n\033com.aliyun.polardbx.rpc.cdcH\001P\001b\006" + + "proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }); + internal_static_dumper_Request_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_dumper_Request_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_dumper_Request_descriptor, + new java.lang.String[] { "Req", }); + internal_static_dumper_ShowBinlogEventsRequest_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_dumper_ShowBinlogEventsRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_dumper_ShowBinlogEventsRequest_descriptor, + new java.lang.String[] { "LogName", "Pos", "Offset", "RowCount", }); + internal_static_dumper_DumpRequest_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_dumper_DumpRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_dumper_DumpRequest_descriptor, + new java.lang.String[] { "FileName", "Position", }); + internal_static_dumper_BinaryLog_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_dumper_BinaryLog_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_dumper_BinaryLog_descriptor, + new java.lang.String[] { "LogName", "FileSize", }); + internal_static_dumper_MasterStatus_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_dumper_MasterStatus_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_dumper_MasterStatus_descriptor, + new java.lang.String[] { "File", "Position", "BinlogDoDB", "BinlogIgnoreDB", "ExecutedGtidSet", }); + internal_static_dumper_BinlogEvent_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_dumper_BinlogEvent_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_dumper_BinlogEvent_descriptor, + new java.lang.String[] { "LogName", "Pos", "EventType", "ServerId", "EndLogPos", "Info", }); + internal_static_dumper_DumpStream_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_dumper_DumpStream_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_dumper_DumpStream_descriptor, + new java.lang.String[] { "Payload", }); + internal_static_dumper_RplCommandResponse_descriptor = + getDescriptor().getMessageTypes().get(7); + internal_static_dumper_RplCommandResponse_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_dumper_RplCommandResponse_descriptor, + new java.lang.String[] { "ResultCode", "Error", }); + internal_static_dumper_ChangeMasterRequest_descriptor = + getDescriptor().getMessageTypes().get(8); + internal_static_dumper_ChangeMasterRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_dumper_ChangeMasterRequest_descriptor, + new java.lang.String[] { "Request", }); + internal_static_dumper_StartSlaveRequest_descriptor = + getDescriptor().getMessageTypes().get(9); + internal_static_dumper_StartSlaveRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_dumper_StartSlaveRequest_descriptor, + new java.lang.String[] { "Request", }); + internal_static_dumper_StopSlaveRequest_descriptor = + getDescriptor().getMessageTypes().get(10); + internal_static_dumper_StopSlaveRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_dumper_StopSlaveRequest_descriptor, + new java.lang.String[] { "Request", }); + internal_static_dumper_ResetSlaveRequest_descriptor = + getDescriptor().getMessageTypes().get(11); + internal_static_dumper_ResetSlaveRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_dumper_ResetSlaveRequest_descriptor, + new java.lang.String[] { "Request", }); + internal_static_dumper_ChangeReplicationFilterRequest_descriptor = + getDescriptor().getMessageTypes().get(12); + internal_static_dumper_ChangeReplicationFilterRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_dumper_ChangeReplicationFilterRequest_descriptor, + new java.lang.String[] { "Request", }); + internal_static_dumper_ShowSlaveStatusRequest_descriptor = + getDescriptor().getMessageTypes().get(13); + internal_static_dumper_ShowSlaveStatusRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_dumper_ShowSlaveStatusRequest_descriptor, + new java.lang.String[] { "Request", }); + internal_static_dumper_ShowSlaveStatusResponse_descriptor = + getDescriptor().getMessageTypes().get(14); + internal_static_dumper_ShowSlaveStatusResponse_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_dumper_ShowSlaveStatusResponse_descriptor, + new java.lang.String[] { "Response", }); + } - // @@protoc_insertion_point(outer_class_scope) + // @@protoc_insertion_point(outer_class_scope) } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/MasterStatus.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/MasterStatus.java index 3445070c..d21e0efb 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/MasterStatus.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/MasterStatus.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: DumperServer.proto @@ -27,1142 +10,1027 @@ public final class MasterStatus extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:dumper.MasterStatus) MasterStatusOrBuilder { - private static final long serialVersionUID = 0L; +private static final long serialVersionUID = 0L; + // Use MasterStatus.newBuilder() to construct. + private MasterStatus(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private MasterStatus() { + file_ = ""; + binlogDoDB_ = ""; + binlogIgnoreDB_ = ""; + executedGtidSet_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new MasterStatus(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private MasterStatus( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + file_ = s; + break; + } + case 16: { + + position_ = input.readInt64(); + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + binlogDoDB_ = s; + break; + } + case 34: { + java.lang.String s = input.readStringRequireUtf8(); + + binlogIgnoreDB_ = s; + break; + } + case 42: { + java.lang.String s = input.readStringRequireUtf8(); - // Use MasterStatus.newBuilder() to construct. - private MasterStatus(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); + executedGtidSet_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_MasterStatus_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_MasterStatus_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.MasterStatus.class, com.aliyun.polardbx.rpc.cdc.MasterStatus.Builder.class); + } + + public static final int FILE_FIELD_NUMBER = 1; + private volatile java.lang.Object file_; + /** + * string file = 1; + * @return The file. + */ + @java.lang.Override + public java.lang.String getFile() { + java.lang.Object ref = file_; + 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(); + file_ = s; + return s; + } + } + /** + * string file = 1; + * @return The bytes for file. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getFileBytes() { + java.lang.Object ref = file_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + file_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; } + } + + public static final int POSITION_FIELD_NUMBER = 2; + private long position_; + /** + * int64 position = 2; + * @return The position. + */ + @java.lang.Override + public long getPosition() { + return position_; + } + + public static final int BINLOGDODB_FIELD_NUMBER = 3; + private volatile java.lang.Object binlogDoDB_; + /** + * string binlogDoDB = 3; + * @return The binlogDoDB. + */ + @java.lang.Override + public java.lang.String getBinlogDoDB() { + java.lang.Object ref = binlogDoDB_; + 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(); + binlogDoDB_ = s; + return s; + } + } + /** + * string binlogDoDB = 3; + * @return The bytes for binlogDoDB. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getBinlogDoDBBytes() { + java.lang.Object ref = binlogDoDB_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + binlogDoDB_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int BINLOGIGNOREDB_FIELD_NUMBER = 4; + private volatile java.lang.Object binlogIgnoreDB_; + /** + * string binlogIgnoreDB = 4; + * @return The binlogIgnoreDB. + */ + @java.lang.Override + public java.lang.String getBinlogIgnoreDB() { + java.lang.Object ref = binlogIgnoreDB_; + 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(); + binlogIgnoreDB_ = s; + return s; + } + } + /** + * string binlogIgnoreDB = 4; + * @return The bytes for binlogIgnoreDB. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getBinlogIgnoreDBBytes() { + java.lang.Object ref = binlogIgnoreDB_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + binlogIgnoreDB_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int EXECUTEDGTIDSET_FIELD_NUMBER = 5; + private volatile java.lang.Object executedGtidSet_; + /** + * string executedGtidSet = 5; + * @return The executedGtidSet. + */ + @java.lang.Override + public java.lang.String getExecutedGtidSet() { + java.lang.Object ref = executedGtidSet_; + 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(); + executedGtidSet_ = s; + return s; + } + } + /** + * string executedGtidSet = 5; + * @return The bytes for executedGtidSet. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getExecutedGtidSetBytes() { + java.lang.Object ref = executedGtidSet_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + executedGtidSet_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getFileBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, file_); + } + if (position_ != 0L) { + output.writeInt64(2, position_); + } + if (!getBinlogDoDBBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, binlogDoDB_); + } + if (!getBinlogIgnoreDBBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, binlogIgnoreDB_); + } + if (!getExecutedGtidSetBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, executedGtidSet_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; - private MasterStatus() { - file_ = ""; - binlogDoDB_ = ""; - binlogIgnoreDB_ = ""; - executedGtidSet_ = ""; + size = 0; + if (!getFileBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, file_); + } + if (position_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, position_); + } + if (!getBinlogDoDBBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, binlogDoDB_); + } + if (!getBinlogIgnoreDBBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, binlogIgnoreDB_); + } + if (!getExecutedGtidSetBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, executedGtidSet_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.rpc.cdc.MasterStatus)) { + return super.equals(obj); + } + com.aliyun.polardbx.rpc.cdc.MasterStatus other = (com.aliyun.polardbx.rpc.cdc.MasterStatus) obj; + + if (!getFile() + .equals(other.getFile())) return false; + if (getPosition() + != other.getPosition()) return false; + if (!getBinlogDoDB() + .equals(other.getBinlogDoDB())) return false; + if (!getBinlogIgnoreDB() + .equals(other.getBinlogIgnoreDB())) return false; + if (!getExecutedGtidSet() + .equals(other.getExecutedGtidSet())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + FILE_FIELD_NUMBER; + hash = (53 * hash) + getFile().hashCode(); + hash = (37 * hash) + POSITION_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getPosition()); + hash = (37 * hash) + BINLOGDODB_FIELD_NUMBER; + hash = (53 * hash) + getBinlogDoDB().hashCode(); + hash = (37 * hash) + BINLOGIGNOREDB_FIELD_NUMBER; + hash = (53 * hash) + getBinlogIgnoreDB().hashCode(); + hash = (37 * hash) + EXECUTEDGTIDSET_FIELD_NUMBER; + hash = (53 * hash) + getExecutedGtidSet().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.rpc.cdc.MasterStatus parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.MasterStatus parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.MasterStatus parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.MasterStatus parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.MasterStatus parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.MasterStatus parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.MasterStatus parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.MasterStatus parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.MasterStatus parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.MasterStatus parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.MasterStatus parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.MasterStatus parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.rpc.cdc.MasterStatus prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code dumper.MasterStatus} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:dumper.MasterStatus) + com.aliyun.polardbx.rpc.cdc.MasterStatusOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_MasterStatus_descriptor; } @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new MasterStatus(); + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_MasterStatus_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.MasterStatus.class, com.aliyun.polardbx.rpc.cdc.MasterStatus.Builder.class); } - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; + // Construct using com.aliyun.polardbx.rpc.cdc.MasterStatus.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); } - private MasterStatus( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - 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; - case 10: { - java.lang.String s = input.readStringRequireUtf8(); + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + file_ = ""; - file_ = s; - break; - } - case 16: { + position_ = 0L; - position_ = input.readInt64(); - break; - } - case 26: { - java.lang.String s = input.readStringRequireUtf8(); + binlogDoDB_ = ""; - binlogDoDB_ = s; - break; - } - case 34: { - java.lang.String s = input.readStringRequireUtf8(); + binlogIgnoreDB_ = ""; - binlogIgnoreDB_ = s; - break; - } - case 42: { - java.lang.String s = input.readStringRequireUtf8(); + executedGtidSet_ = ""; - executedGtidSet_ = s; - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } + return this; } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return DumperServer.internal_static_dumper_MasterStatus_descriptor; + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_MasterStatus_descriptor; } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return DumperServer.internal_static_dumper_MasterStatus_fieldAccessorTable - .ensureFieldAccessorsInitialized( - MasterStatus.class, MasterStatus.Builder.class); + public com.aliyun.polardbx.rpc.cdc.MasterStatus getDefaultInstanceForType() { + return com.aliyun.polardbx.rpc.cdc.MasterStatus.getDefaultInstance(); } - public static final int FILE_FIELD_NUMBER = 1; - private volatile java.lang.Object file_; + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.MasterStatus build() { + com.aliyun.polardbx.rpc.cdc.MasterStatus result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.MasterStatus buildPartial() { + com.aliyun.polardbx.rpc.cdc.MasterStatus result = new com.aliyun.polardbx.rpc.cdc.MasterStatus(this); + result.file_ = file_; + result.position_ = position_; + result.binlogDoDB_ = binlogDoDB_; + result.binlogIgnoreDB_ = binlogIgnoreDB_; + result.executedGtidSet_ = executedGtidSet_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.rpc.cdc.MasterStatus) { + return mergeFrom((com.aliyun.polardbx.rpc.cdc.MasterStatus)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.polardbx.rpc.cdc.MasterStatus other) { + if (other == com.aliyun.polardbx.rpc.cdc.MasterStatus.getDefaultInstance()) return this; + if (!other.getFile().isEmpty()) { + file_ = other.file_; + onChanged(); + } + if (other.getPosition() != 0L) { + setPosition(other.getPosition()); + } + if (!other.getBinlogDoDB().isEmpty()) { + binlogDoDB_ = other.binlogDoDB_; + onChanged(); + } + if (!other.getBinlogIgnoreDB().isEmpty()) { + binlogIgnoreDB_ = other.binlogIgnoreDB_; + onChanged(); + } + if (!other.getExecutedGtidSet().isEmpty()) { + executedGtidSet_ = other.executedGtidSet_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.aliyun.polardbx.rpc.cdc.MasterStatus parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.rpc.cdc.MasterStatus) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object file_ = ""; /** * string file = 1; - * * @return The file. */ - @java.lang.Override public java.lang.String getFile() { - java.lang.Object ref = file_; - 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(); - file_ = s; - return s; - } + java.lang.Object ref = file_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + file_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - /** * string file = 1; - * * @return The bytes for file. */ - @java.lang.Override public com.google.protobuf.ByteString - getFileBytes() { - java.lang.Object ref = file_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - file_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + getFileBytes() { + java.lang.Object ref = file_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + file_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string file = 1; + * @param value The file to set. + * @return This builder for chaining. + */ + public Builder setFile( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + file_ = value; + onChanged(); + return this; + } + /** + * string file = 1; + * @return This builder for chaining. + */ + public Builder clearFile() { + + file_ = getDefaultInstance().getFile(); + onChanged(); + return this; + } + /** + * string file = 1; + * @param value The bytes for file to set. + * @return This builder for chaining. + */ + public Builder setFileBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + file_ = value; + onChanged(); + return this; } - public static final int POSITION_FIELD_NUMBER = 2; - private long position_; - + private long position_ ; /** * int64 position = 2; - * * @return The position. */ @java.lang.Override public long getPosition() { - return position_; + return position_; + } + /** + * int64 position = 2; + * @param value The position to set. + * @return This builder for chaining. + */ + public Builder setPosition(long value) { + + position_ = value; + onChanged(); + return this; + } + /** + * int64 position = 2; + * @return This builder for chaining. + */ + public Builder clearPosition() { + + position_ = 0L; + onChanged(); + return this; } - public static final int BINLOGDODB_FIELD_NUMBER = 3; - private volatile java.lang.Object binlogDoDB_; - + private java.lang.Object binlogDoDB_ = ""; /** * string binlogDoDB = 3; - * * @return The binlogDoDB. */ - @java.lang.Override public java.lang.String getBinlogDoDB() { - java.lang.Object ref = binlogDoDB_; - 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(); - binlogDoDB_ = s; - return s; - } + java.lang.Object ref = binlogDoDB_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + binlogDoDB_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - /** * string binlogDoDB = 3; - * * @return The bytes for binlogDoDB. */ - @java.lang.Override public com.google.protobuf.ByteString - getBinlogDoDBBytes() { - java.lang.Object ref = binlogDoDB_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - binlogDoDB_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + getBinlogDoDBBytes() { + java.lang.Object ref = binlogDoDB_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + binlogDoDB_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string binlogDoDB = 3; + * @param value The binlogDoDB to set. + * @return This builder for chaining. + */ + public Builder setBinlogDoDB( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + binlogDoDB_ = value; + onChanged(); + return this; + } + /** + * string binlogDoDB = 3; + * @return This builder for chaining. + */ + public Builder clearBinlogDoDB() { + + binlogDoDB_ = getDefaultInstance().getBinlogDoDB(); + onChanged(); + return this; + } + /** + * string binlogDoDB = 3; + * @param value The bytes for binlogDoDB to set. + * @return This builder for chaining. + */ + public Builder setBinlogDoDBBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + binlogDoDB_ = value; + onChanged(); + return this; } - public static final int BINLOGIGNOREDB_FIELD_NUMBER = 4; - private volatile java.lang.Object binlogIgnoreDB_; - + private java.lang.Object binlogIgnoreDB_ = ""; /** * string binlogIgnoreDB = 4; - * * @return The binlogIgnoreDB. */ - @java.lang.Override public java.lang.String getBinlogIgnoreDB() { - java.lang.Object ref = binlogIgnoreDB_; - 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(); - binlogIgnoreDB_ = s; - return s; - } + java.lang.Object ref = binlogIgnoreDB_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + binlogIgnoreDB_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - /** * string binlogIgnoreDB = 4; - * * @return The bytes for binlogIgnoreDB. */ - @java.lang.Override public com.google.protobuf.ByteString - getBinlogIgnoreDBBytes() { - java.lang.Object ref = binlogIgnoreDB_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - binlogIgnoreDB_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + getBinlogIgnoreDBBytes() { + java.lang.Object ref = binlogIgnoreDB_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + binlogIgnoreDB_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string binlogIgnoreDB = 4; + * @param value The binlogIgnoreDB to set. + * @return This builder for chaining. + */ + public Builder setBinlogIgnoreDB( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + binlogIgnoreDB_ = value; + onChanged(); + return this; + } + /** + * string binlogIgnoreDB = 4; + * @return This builder for chaining. + */ + public Builder clearBinlogIgnoreDB() { + + binlogIgnoreDB_ = getDefaultInstance().getBinlogIgnoreDB(); + onChanged(); + return this; + } + /** + * string binlogIgnoreDB = 4; + * @param value The bytes for binlogIgnoreDB to set. + * @return This builder for chaining. + */ + public Builder setBinlogIgnoreDBBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + binlogIgnoreDB_ = value; + onChanged(); + return this; } - public static final int EXECUTEDGTIDSET_FIELD_NUMBER = 5; - private volatile java.lang.Object executedGtidSet_; - + private java.lang.Object executedGtidSet_ = ""; /** * string executedGtidSet = 5; - * * @return The executedGtidSet. */ - @java.lang.Override public java.lang.String getExecutedGtidSet() { - java.lang.Object ref = executedGtidSet_; - 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(); - executedGtidSet_ = s; - return s; - } + java.lang.Object ref = executedGtidSet_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + executedGtidSet_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - /** * string executedGtidSet = 5; - * * @return The bytes for executedGtidSet. */ - @java.lang.Override public com.google.protobuf.ByteString - getExecutedGtidSetBytes() { - java.lang.Object ref = executedGtidSet_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - executedGtidSet_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + getExecutedGtidSetBytes() { + java.lang.Object ref = executedGtidSet_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + executedGtidSet_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } - - memoizedIsInitialized = 1; - return true; + /** + * string executedGtidSet = 5; + * @param value The executedGtidSet to set. + * @return This builder for chaining. + */ + public Builder setExecutedGtidSet( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + executedGtidSet_ = value; + onChanged(); + return this; } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getFileBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, file_); - } - if (position_ != 0L) { - output.writeInt64(2, position_); - } - if (!getBinlogDoDBBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, binlogDoDB_); - } - if (!getBinlogIgnoreDBBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, binlogIgnoreDB_); - } - if (!getExecutedGtidSetBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 5, executedGtidSet_); - } - unknownFields.writeTo(output); + /** + * string executedGtidSet = 5; + * @return This builder for chaining. + */ + public Builder clearExecutedGtidSet() { + + executedGtidSet_ = getDefaultInstance().getExecutedGtidSet(); + onChanged(); + return this; } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) { - return size; - } - - size = 0; - if (!getFileBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, file_); - } - if (position_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(2, position_); - } - if (!getBinlogDoDBBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, binlogDoDB_); - } - if (!getBinlogIgnoreDBBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, binlogIgnoreDB_); - } - if (!getExecutedGtidSetBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, executedGtidSet_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; + /** + * string executedGtidSet = 5; + * @param value The bytes for executedGtidSet to set. + * @return This builder for chaining. + */ + public Builder setExecutedGtidSetBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + executedGtidSet_ = value; + onChanged(); + return this; } - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof MasterStatus)) { - return super.equals(obj); - } - MasterStatus other = (MasterStatus) obj; - - if (!getFile() - .equals(other.getFile())) { - return false; - } - if (getPosition() - != other.getPosition()) { - return false; - } - if (!getBinlogDoDB() - .equals(other.getBinlogDoDB())) { - return false; - } - if (!getBinlogIgnoreDB() - .equals(other.getBinlogIgnoreDB())) { - return false; - } - if (!getExecutedGtidSet() - .equals(other.getExecutedGtidSet())) { - return false; - } - if (!unknownFields.equals(other.unknownFields)) { - return false; - } - return true; + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); } @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + FILE_FIELD_NUMBER; - hash = (53 * hash) + getFile().hashCode(); - hash = (37 * hash) + POSITION_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getPosition()); - hash = (37 * hash) + BINLOGDODB_FIELD_NUMBER; - hash = (53 * hash) + getBinlogDoDB().hashCode(); - hash = (37 * hash) + BINLOGIGNOREDB_FIELD_NUMBER; - hash = (53 * hash) + getBinlogIgnoreDB().hashCode(); - hash = (37 * hash) + EXECUTEDGTIDSET_FIELD_NUMBER; - hash = (53 * hash) + getExecutedGtidSet().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - public static MasterStatus parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static MasterStatus parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } + // @@protoc_insertion_point(builder_scope:dumper.MasterStatus) + } - public static MasterStatus parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static MasterStatus parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static MasterStatus parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } + // @@protoc_insertion_point(class_scope:dumper.MasterStatus) + private static final com.aliyun.polardbx.rpc.cdc.MasterStatus DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.rpc.cdc.MasterStatus(); + } - public static MasterStatus parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } + public static com.aliyun.polardbx.rpc.cdc.MasterStatus getDefaultInstance() { + return DEFAULT_INSTANCE; + } - public static MasterStatus parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static MasterStatus parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public static MasterStatus parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - - public static MasterStatus parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - - public static MasterStatus parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static MasterStatus parseFrom( + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public MasterStatus parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(MasterStatus prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - /** - * Protobuf type {@code dumper.MasterStatus} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:dumper.MasterStatus) - MasterStatusOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return DumperServer.internal_static_dumper_MasterStatus_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return DumperServer.internal_static_dumper_MasterStatus_fieldAccessorTable - .ensureFieldAccessorsInitialized( - MasterStatus.class, MasterStatus.Builder.class); - } - - // Construct using com.alibaba.tddl.rpc.cdc.MasterStatus.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - @java.lang.Override - public Builder clear() { - super.clear(); - file_ = ""; - - position_ = 0L; - - binlogDoDB_ = ""; - - binlogIgnoreDB_ = ""; - - executedGtidSet_ = ""; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return DumperServer.internal_static_dumper_MasterStatus_descriptor; - } - - @java.lang.Override - public MasterStatus getDefaultInstanceForType() { - return MasterStatus.getDefaultInstance(); - } - - @java.lang.Override - public MasterStatus build() { - MasterStatus result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public MasterStatus buildPartial() { - MasterStatus result = new MasterStatus(this); - result.file_ = file_; - result.position_ = position_; - result.binlogDoDB_ = binlogDoDB_; - result.binlogIgnoreDB_ = binlogIgnoreDB_; - result.executedGtidSet_ = executedGtidSet_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof MasterStatus) { - return mergeFrom((MasterStatus) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(MasterStatus other) { - if (other == MasterStatus.getDefaultInstance()) { - return this; - } - if (!other.getFile().isEmpty()) { - file_ = other.file_; - onChanged(); - } - if (other.getPosition() != 0L) { - setPosition(other.getPosition()); - } - if (!other.getBinlogDoDB().isEmpty()) { - binlogDoDB_ = other.binlogDoDB_; - onChanged(); - } - if (!other.getBinlogIgnoreDB().isEmpty()) { - binlogIgnoreDB_ = other.binlogIgnoreDB_; - onChanged(); - } - if (!other.getExecutedGtidSet().isEmpty()) { - executedGtidSet_ = other.executedGtidSet_; - onChanged(); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - MasterStatus parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (MasterStatus) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object file_ = ""; - - /** - * string file = 1; - * - * @return The file. - */ - public java.lang.String getFile() { - java.lang.Object ref = file_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - file_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * string file = 1; - * - * @return The bytes for file. - */ - public com.google.protobuf.ByteString - getFileBytes() { - java.lang.Object ref = file_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - file_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string file = 1; - * - * @param value The file to set. - * @return This builder for chaining. - */ - public Builder setFile( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - file_ = value; - onChanged(); - return this; - } - - /** - * string file = 1; - * - * @return This builder for chaining. - */ - public Builder clearFile() { - - file_ = getDefaultInstance().getFile(); - onChanged(); - return this; - } - - /** - * string file = 1; - * - * @param value The bytes for file to set. - * @return This builder for chaining. - */ - public Builder setFileBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - file_ = value; - onChanged(); - return this; - } - - private long position_; - - /** - * int64 position = 2; - * - * @return The position. - */ - @java.lang.Override - public long getPosition() { - return position_; - } - - /** - * int64 position = 2; - * - * @param value The position to set. - * @return This builder for chaining. - */ - public Builder setPosition(long value) { - - position_ = value; - onChanged(); - return this; - } - - /** - * int64 position = 2; - * - * @return This builder for chaining. - */ - public Builder clearPosition() { - - position_ = 0L; - onChanged(); - return this; - } - - private java.lang.Object binlogDoDB_ = ""; - - /** - * string binlogDoDB = 3; - * - * @return The binlogDoDB. - */ - public java.lang.String getBinlogDoDB() { - java.lang.Object ref = binlogDoDB_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - binlogDoDB_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * string binlogDoDB = 3; - * - * @return The bytes for binlogDoDB. - */ - public com.google.protobuf.ByteString - getBinlogDoDBBytes() { - java.lang.Object ref = binlogDoDB_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - binlogDoDB_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string binlogDoDB = 3; - * - * @param value The binlogDoDB to set. - * @return This builder for chaining. - */ - public Builder setBinlogDoDB( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - binlogDoDB_ = value; - onChanged(); - return this; - } - - /** - * string binlogDoDB = 3; - * - * @return This builder for chaining. - */ - public Builder clearBinlogDoDB() { - - binlogDoDB_ = getDefaultInstance().getBinlogDoDB(); - onChanged(); - return this; - } - - /** - * string binlogDoDB = 3; - * - * @param value The bytes for binlogDoDB to set. - * @return This builder for chaining. - */ - public Builder setBinlogDoDBBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - binlogDoDB_ = value; - onChanged(); - return this; - } - - private java.lang.Object binlogIgnoreDB_ = ""; - - /** - * string binlogIgnoreDB = 4; - * - * @return The binlogIgnoreDB. - */ - public java.lang.String getBinlogIgnoreDB() { - java.lang.Object ref = binlogIgnoreDB_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - binlogIgnoreDB_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * string binlogIgnoreDB = 4; - * - * @return The bytes for binlogIgnoreDB. - */ - public com.google.protobuf.ByteString - getBinlogIgnoreDBBytes() { - java.lang.Object ref = binlogIgnoreDB_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - binlogIgnoreDB_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string binlogIgnoreDB = 4; - * - * @param value The binlogIgnoreDB to set. - * @return This builder for chaining. - */ - public Builder setBinlogIgnoreDB( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - binlogIgnoreDB_ = value; - onChanged(); - return this; - } - - /** - * string binlogIgnoreDB = 4; - * - * @return This builder for chaining. - */ - public Builder clearBinlogIgnoreDB() { - - binlogIgnoreDB_ = getDefaultInstance().getBinlogIgnoreDB(); - onChanged(); - return this; - } - - /** - * string binlogIgnoreDB = 4; - * - * @param value The bytes for binlogIgnoreDB to set. - * @return This builder for chaining. - */ - public Builder setBinlogIgnoreDBBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - binlogIgnoreDB_ = value; - onChanged(); - return this; - } - - private java.lang.Object executedGtidSet_ = ""; - - /** - * string executedGtidSet = 5; - * - * @return The executedGtidSet. - */ - public java.lang.String getExecutedGtidSet() { - java.lang.Object ref = executedGtidSet_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - executedGtidSet_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * string executedGtidSet = 5; - * - * @return The bytes for executedGtidSet. - */ - public com.google.protobuf.ByteString - getExecutedGtidSetBytes() { - java.lang.Object ref = executedGtidSet_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - executedGtidSet_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string executedGtidSet = 5; - * - * @param value The executedGtidSet to set. - * @return This builder for chaining. - */ - public Builder setExecutedGtidSet( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - executedGtidSet_ = value; - onChanged(); - return this; - } - - /** - * string executedGtidSet = 5; - * - * @return This builder for chaining. - */ - public Builder clearExecutedGtidSet() { - - executedGtidSet_ = getDefaultInstance().getExecutedGtidSet(); - onChanged(); - return this; - } - - /** - * string executedGtidSet = 5; - * - * @param value The bytes for executedGtidSet to set. - * @return This builder for chaining. - */ - public Builder setExecutedGtidSetBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - executedGtidSet_ = value; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:dumper.MasterStatus) + throws com.google.protobuf.InvalidProtocolBufferException { + return new MasterStatus(input, extensionRegistry); } + }; - // @@protoc_insertion_point(class_scope:dumper.MasterStatus) - private static final MasterStatus DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new MasterStatus(); - } + public static com.google.protobuf.Parser parser() { + return PARSER; + } - public static MasterStatus getDefaultInstance() { - return DEFAULT_INSTANCE; - } + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public MasterStatus parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new MasterStatus(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public MasterStatus getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.MasterStatus getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/MasterStatusOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/MasterStatusOrBuilder.java index 77358174..05df8656 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/MasterStatusOrBuilder.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/MasterStatusOrBuilder.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: DumperServer.proto @@ -24,70 +7,57 @@ public interface MasterStatusOrBuilder extends // @@protoc_insertion_point(interface_extends:dumper.MasterStatus) com.google.protobuf.MessageOrBuilder { - /** - * string file = 1; - * - * @return The file. - */ - java.lang.String getFile(); - - /** - * string file = 1; - * - * @return The bytes for file. - */ - com.google.protobuf.ByteString - getFileBytes(); - - /** - * int64 position = 2; - * - * @return The position. - */ - long getPosition(); - - /** - * string binlogDoDB = 3; - * - * @return The binlogDoDB. - */ - java.lang.String getBinlogDoDB(); - - /** - * string binlogDoDB = 3; - * - * @return The bytes for binlogDoDB. - */ - com.google.protobuf.ByteString - getBinlogDoDBBytes(); - - /** - * string binlogIgnoreDB = 4; - * - * @return The binlogIgnoreDB. - */ - java.lang.String getBinlogIgnoreDB(); - - /** - * string binlogIgnoreDB = 4; - * - * @return The bytes for binlogIgnoreDB. - */ - com.google.protobuf.ByteString - getBinlogIgnoreDBBytes(); - - /** - * string executedGtidSet = 5; - * - * @return The executedGtidSet. - */ - java.lang.String getExecutedGtidSet(); - - /** - * string executedGtidSet = 5; - * - * @return The bytes for executedGtidSet. - */ - com.google.protobuf.ByteString - getExecutedGtidSetBytes(); + /** + * string file = 1; + * @return The file. + */ + java.lang.String getFile(); + /** + * string file = 1; + * @return The bytes for file. + */ + com.google.protobuf.ByteString + getFileBytes(); + + /** + * int64 position = 2; + * @return The position. + */ + long getPosition(); + + /** + * string binlogDoDB = 3; + * @return The binlogDoDB. + */ + java.lang.String getBinlogDoDB(); + /** + * string binlogDoDB = 3; + * @return The bytes for binlogDoDB. + */ + com.google.protobuf.ByteString + getBinlogDoDBBytes(); + + /** + * string binlogIgnoreDB = 4; + * @return The binlogIgnoreDB. + */ + java.lang.String getBinlogIgnoreDB(); + /** + * string binlogIgnoreDB = 4; + * @return The bytes for binlogIgnoreDB. + */ + com.google.protobuf.ByteString + getBinlogIgnoreDBBytes(); + + /** + * string executedGtidSet = 5; + * @return The executedGtidSet. + */ + java.lang.String getExecutedGtidSet(); + /** + * string executedGtidSet = 5; + * @return The bytes for executedGtidSet. + */ + com.google.protobuf.ByteString + getExecutedGtidSetBytes(); } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/Request.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/Request.java index 651c6a40..82ff10e9 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/Request.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/Request.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: DumperServer.proto @@ -27,605 +10,548 @@ public final class Request extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:dumper.Request) RequestOrBuilder { - private static final long serialVersionUID = 0L; - - // Use Request.newBuilder() to construct. - private Request(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } +private static final long serialVersionUID = 0L; + // Use Request.newBuilder() to construct. + private Request(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Request() { + req_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new Request(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Request( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); - private Request() { - req_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new Request(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - - private Request( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - 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; - case 10: { - java.lang.String s = input.readStringRequireUtf8(); - - req_ = s; - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } + req_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_Request_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_Request_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.Request.class, com.aliyun.polardbx.rpc.cdc.Request.Builder.class); + } + + public static final int REQ_FIELD_NUMBER = 1; + private volatile java.lang.Object req_; + /** + * string req = 1; + * @return The req. + */ + @java.lang.Override + public java.lang.String getReq() { + java.lang.Object ref = req_; + 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(); + req_ = s; + return s; + } + } + /** + * string req = 1; + * @return The bytes for req. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getReqBytes() { + java.lang.Object ref = req_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + req_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getReqBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, req_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getReqBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, req_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.rpc.cdc.Request)) { + return super.equals(obj); + } + com.aliyun.polardbx.rpc.cdc.Request other = (com.aliyun.polardbx.rpc.cdc.Request) obj; + + if (!getReq() + .equals(other.getReq())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + REQ_FIELD_NUMBER; + hash = (53 * hash) + getReq().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.rpc.cdc.Request parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.Request parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.Request parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.Request parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.Request parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.Request parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.Request parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.Request parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.Request parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.Request parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.Request parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.Request parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.rpc.cdc.Request prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code dumper.Request} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:dumper.Request) + com.aliyun.polardbx.rpc.cdc.RequestOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return DumperServer.internal_static_dumper_Request_descriptor; + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_Request_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return DumperServer.internal_static_dumper_Request_fieldAccessorTable - .ensureFieldAccessorsInitialized( - Request.class, Request.Builder.class); + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_Request_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.Request.class, com.aliyun.polardbx.rpc.cdc.Request.Builder.class); } - public static final int REQ_FIELD_NUMBER = 1; - private volatile java.lang.Object req_; - - /** - * string req = 1; - * - * @return The req. - */ - @java.lang.Override - public java.lang.String getReq() { - java.lang.Object ref = req_; - 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(); - req_ = s; - return s; - } + // Construct using com.aliyun.polardbx.rpc.cdc.Request.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); } - /** - * string req = 1; - * - * @return The bytes for req. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getReqBytes() { - java.lang.Object ref = req_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - req_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } } - - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } + public Builder clear() { + super.clear(); + req_ = ""; - memoizedIsInitialized = 1; - return true; + return this; } @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getReqBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, req_); - } - unknownFields.writeTo(output); + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_Request_descriptor; } @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) { - return size; - } - - size = 0; - if (!getReqBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, req_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; + public com.aliyun.polardbx.rpc.cdc.Request getDefaultInstanceForType() { + return com.aliyun.polardbx.rpc.cdc.Request.getDefaultInstance(); } @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof Request)) { - return super.equals(obj); - } - Request other = (Request) obj; - - if (!getReq() - .equals(other.getReq())) { - return false; - } - if (!unknownFields.equals(other.unknownFields)) { - return false; - } - return true; + public com.aliyun.polardbx.rpc.cdc.Request build() { + com.aliyun.polardbx.rpc.cdc.Request result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; } @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + REQ_FIELD_NUMBER; - hash = (53 * hash) + getReq().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; + public com.aliyun.polardbx.rpc.cdc.Request buildPartial() { + com.aliyun.polardbx.rpc.cdc.Request result = new com.aliyun.polardbx.rpc.cdc.Request(this); + result.req_ = req_; + onBuilt(); + return result; } - public static Request parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Request parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + @java.lang.Override + public Builder clone() { + return super.clone(); } - - public static Request parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); } - - public static Request parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); } - - public static Request parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); } - - public static Request parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); } - - public static Request parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); } - - public static Request parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.rpc.cdc.Request) { + return mergeFrom((com.aliyun.polardbx.rpc.cdc.Request)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.polardbx.rpc.cdc.Request other) { + if (other == com.aliyun.polardbx.rpc.cdc.Request.getDefaultInstance()) return this; + if (!other.getReq().isEmpty()) { + req_ = other.req_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; } - public static Request parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); + @java.lang.Override + public final boolean isInitialized() { + return true; } - public static Request parseDelimitedFrom( - java.io.InputStream input, + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + com.aliyun.polardbx.rpc.cdc.Request parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.rpc.cdc.Request) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; } - public static Request parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + private java.lang.Object req_ = ""; + /** + * string req = 1; + * @return The req. + */ + public java.lang.String getReq() { + java.lang.Object ref = req_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + req_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - - public static Request parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + /** + * string req = 1; + * @return The bytes for req. + */ + public com.google.protobuf.ByteString + getReqBytes() { + java.lang.Object ref = req_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + req_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); + /** + * string req = 1; + * @param value The req to set. + * @return This builder for chaining. + */ + public Builder setReq( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + req_ = value; + onChanged(); + return this; } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); + /** + * string req = 1; + * @return This builder for chaining. + */ + public Builder clearReq() { + + req_ = getDefaultInstance().getReq(); + onChanged(); + return this; } - - public static Builder newBuilder(Request prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + /** + * string req = 1; + * @param value The bytes for req to set. + * @return This builder for chaining. + */ + public Builder setReqBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + req_ = value; + onChanged(); + return this; } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); } @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - /** - * Protobuf type {@code dumper.Request} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:dumper.Request) - RequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return DumperServer.internal_static_dumper_Request_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return DumperServer.internal_static_dumper_Request_fieldAccessorTable - .ensureFieldAccessorsInitialized( - Request.class, Request.Builder.class); - } - - // Construct using com.alibaba.tddl.rpc.cdc.Request.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - @java.lang.Override - public Builder clear() { - super.clear(); - req_ = ""; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return DumperServer.internal_static_dumper_Request_descriptor; - } - - @java.lang.Override - public Request getDefaultInstanceForType() { - return Request.getDefaultInstance(); - } - - @java.lang.Override - public Request build() { - Request result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - @java.lang.Override - public Request buildPartial() { - Request result = new Request(this); - result.req_ = req_; - onBuilt(); - return result; - } + // @@protoc_insertion_point(builder_scope:dumper.Request) + } - @java.lang.Override - public Builder clone() { - return super.clone(); - } + // @@protoc_insertion_point(class_scope:dumper.Request) + private static final com.aliyun.polardbx.rpc.cdc.Request DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.rpc.cdc.Request(); + } - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } + public static com.aliyun.polardbx.rpc.cdc.Request getDefaultInstance() { + return DEFAULT_INSTANCE; + } - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof Request) { - return mergeFrom((Request) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(Request other) { - if (other == Request.getDefaultInstance()) { - return this; - } - if (!other.getReq().isEmpty()) { - req_ = other.req_; - onChanged(); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Request parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (Request) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object req_ = ""; - - /** - * string req = 1; - * - * @return The req. - */ - public java.lang.String getReq() { - java.lang.Object ref = req_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - req_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * string req = 1; - * - * @return The bytes for req. - */ - public com.google.protobuf.ByteString - getReqBytes() { - java.lang.Object ref = req_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - req_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string req = 1; - * - * @param value The req to set. - * @return This builder for chaining. - */ - public Builder setReq( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - req_ = value; - onChanged(); - return this; - } - - /** - * string req = 1; - * - * @return This builder for chaining. - */ - public Builder clearReq() { - - req_ = getDefaultInstance().getReq(); - onChanged(); - return this; - } - - /** - * string req = 1; - * - * @param value The bytes for req to set. - * @return This builder for chaining. - */ - public Builder setReqBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - req_ = value; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:dumper.Request) - } - - // @@protoc_insertion_point(class_scope:dumper.Request) - private static final Request DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new Request(); - } - - public static Request getDefaultInstance() { - return DEFAULT_INSTANCE; + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Request parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Request(input, extensionRegistry); } + }; - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public Request parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Request(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } + public static com.google.protobuf.Parser parser() { + return PARSER; + } - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } - @java.lang.Override - public Request getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.Request getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/RequestOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/RequestOrBuilder.java index bcbe35ea..4a118fdd 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/RequestOrBuilder.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/RequestOrBuilder.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: DumperServer.proto @@ -24,18 +7,15 @@ public interface RequestOrBuilder extends // @@protoc_insertion_point(interface_extends:dumper.Request) com.google.protobuf.MessageOrBuilder { - /** - * string req = 1; - * - * @return The req. - */ - java.lang.String getReq(); - - /** - * string req = 1; - * - * @return The bytes for req. - */ - com.google.protobuf.ByteString - getReqBytes(); + /** + * string req = 1; + * @return The req. + */ + java.lang.String getReq(); + /** + * string req = 1; + * @return The bytes for req. + */ + com.google.protobuf.ByteString + getReqBytes(); } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ResetSlaveRequest.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ResetSlaveRequest.java new file mode 100644 index 00000000..80390f89 --- /dev/null +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ResetSlaveRequest.java @@ -0,0 +1,557 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DumperServer.proto + +package com.aliyun.polardbx.rpc.cdc; + +/** + * Protobuf type {@code dumper.ResetSlaveRequest} + */ +public final class ResetSlaveRequest extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:dumper.ResetSlaveRequest) + ResetSlaveRequestOrBuilder { +private static final long serialVersionUID = 0L; + // Use ResetSlaveRequest.newBuilder() to construct. + private ResetSlaveRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ResetSlaveRequest() { + request_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new ResetSlaveRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ResetSlaveRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + request_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ResetSlaveRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ResetSlaveRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest.class, com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest.Builder.class); + } + + public static final int REQUEST_FIELD_NUMBER = 1; + private volatile java.lang.Object request_; + /** + * string request = 1; + * @return The request. + */ + @java.lang.Override + public java.lang.String getRequest() { + java.lang.Object ref = request_; + 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(); + request_ = s; + return s; + } + } + /** + * string request = 1; + * @return The bytes for request. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getRequestBytes() { + java.lang.Object ref = request_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + request_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getRequestBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, request_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getRequestBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, request_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest)) { + return super.equals(obj); + } + com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest other = (com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest) obj; + + if (!getRequest() + .equals(other.getRequest())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + REQUEST_FIELD_NUMBER; + hash = (53 * hash) + getRequest().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code dumper.ResetSlaveRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:dumper.ResetSlaveRequest) + com.aliyun.polardbx.rpc.cdc.ResetSlaveRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ResetSlaveRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ResetSlaveRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest.class, com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest.Builder.class); + } + + // Construct using com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + request_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ResetSlaveRequest_descriptor; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest getDefaultInstanceForType() { + return com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest build() { + com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest buildPartial() { + com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest result = new com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest(this); + result.request_ = request_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest) { + return mergeFrom((com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest other) { + if (other == com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest.getDefaultInstance()) return this; + if (!other.getRequest().isEmpty()) { + request_ = other.request_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object request_ = ""; + /** + * string request = 1; + * @return The request. + */ + public java.lang.String getRequest() { + java.lang.Object ref = request_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + request_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string request = 1; + * @return The bytes for request. + */ + public com.google.protobuf.ByteString + getRequestBytes() { + java.lang.Object ref = request_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + request_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string request = 1; + * @param value The request to set. + * @return This builder for chaining. + */ + public Builder setRequest( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + request_ = value; + onChanged(); + return this; + } + /** + * string request = 1; + * @return This builder for chaining. + */ + public Builder clearRequest() { + + request_ = getDefaultInstance().getRequest(); + onChanged(); + return this; + } + /** + * string request = 1; + * @param value The bytes for request to set. + * @return This builder for chaining. + */ + public Builder setRequestBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + request_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:dumper.ResetSlaveRequest) + } + + // @@protoc_insertion_point(class_scope:dumper.ResetSlaveRequest) + private static final com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest(); + } + + public static com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ResetSlaveRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ResetSlaveRequest(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ResetSlaveRequestOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ResetSlaveRequestOrBuilder.java new file mode 100644 index 00000000..585efd1c --- /dev/null +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ResetSlaveRequestOrBuilder.java @@ -0,0 +1,21 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DumperServer.proto + +package com.aliyun.polardbx.rpc.cdc; + +public interface ResetSlaveRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:dumper.ResetSlaveRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * string request = 1; + * @return The request. + */ + java.lang.String getRequest(); + /** + * string request = 1; + * @return The bytes for request. + */ + com.google.protobuf.ByteString + getRequestBytes(); +} diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/RplCommandResponse.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/RplCommandResponse.java new file mode 100644 index 00000000..bac12ad4 --- /dev/null +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/RplCommandResponse.java @@ -0,0 +1,629 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DumperServer.proto + +package com.aliyun.polardbx.rpc.cdc; + +/** + *
+ *//////////////////////////// replicate ///////////////////////////
+ * 
+ * + * Protobuf type {@code dumper.RplCommandResponse} + */ +public final class RplCommandResponse extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:dumper.RplCommandResponse) + RplCommandResponseOrBuilder { +private static final long serialVersionUID = 0L; + // Use RplCommandResponse.newBuilder() to construct. + private RplCommandResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private RplCommandResponse() { + error_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new RplCommandResponse(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private RplCommandResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 8: { + + resultCode_ = input.readInt32(); + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + error_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_RplCommandResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_RplCommandResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.RplCommandResponse.class, com.aliyun.polardbx.rpc.cdc.RplCommandResponse.Builder.class); + } + + public static final int RESULTCODE_FIELD_NUMBER = 1; + private int resultCode_; + /** + * int32 resultCode = 1; + * @return The resultCode. + */ + @java.lang.Override + public int getResultCode() { + return resultCode_; + } + + public static final int ERROR_FIELD_NUMBER = 2; + private volatile java.lang.Object error_; + /** + * string error = 2; + * @return The error. + */ + @java.lang.Override + public java.lang.String getError() { + java.lang.Object ref = error_; + 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(); + error_ = s; + return s; + } + } + /** + * string error = 2; + * @return The bytes for error. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getErrorBytes() { + java.lang.Object ref = error_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + error_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (resultCode_ != 0) { + output.writeInt32(1, resultCode_); + } + if (!getErrorBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, error_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (resultCode_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, resultCode_); + } + if (!getErrorBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, error_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.rpc.cdc.RplCommandResponse)) { + return super.equals(obj); + } + com.aliyun.polardbx.rpc.cdc.RplCommandResponse other = (com.aliyun.polardbx.rpc.cdc.RplCommandResponse) obj; + + if (getResultCode() + != other.getResultCode()) return false; + if (!getError() + .equals(other.getError())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + RESULTCODE_FIELD_NUMBER; + hash = (53 * hash) + getResultCode(); + hash = (37 * hash) + ERROR_FIELD_NUMBER; + hash = (53 * hash) + getError().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.rpc.cdc.RplCommandResponse parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.RplCommandResponse parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.RplCommandResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.RplCommandResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.RplCommandResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.RplCommandResponse parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.RplCommandResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.RplCommandResponse parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.RplCommandResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.RplCommandResponse parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.RplCommandResponse parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.RplCommandResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.rpc.cdc.RplCommandResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+   *//////////////////////////// replicate ///////////////////////////
+   * 
+ * + * Protobuf type {@code dumper.RplCommandResponse} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:dumper.RplCommandResponse) + com.aliyun.polardbx.rpc.cdc.RplCommandResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_RplCommandResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_RplCommandResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.RplCommandResponse.class, com.aliyun.polardbx.rpc.cdc.RplCommandResponse.Builder.class); + } + + // Construct using com.aliyun.polardbx.rpc.cdc.RplCommandResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + resultCode_ = 0; + + error_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_RplCommandResponse_descriptor; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.RplCommandResponse getDefaultInstanceForType() { + return com.aliyun.polardbx.rpc.cdc.RplCommandResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.RplCommandResponse build() { + com.aliyun.polardbx.rpc.cdc.RplCommandResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.RplCommandResponse buildPartial() { + com.aliyun.polardbx.rpc.cdc.RplCommandResponse result = new com.aliyun.polardbx.rpc.cdc.RplCommandResponse(this); + result.resultCode_ = resultCode_; + result.error_ = error_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.rpc.cdc.RplCommandResponse) { + return mergeFrom((com.aliyun.polardbx.rpc.cdc.RplCommandResponse)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.polardbx.rpc.cdc.RplCommandResponse other) { + if (other == com.aliyun.polardbx.rpc.cdc.RplCommandResponse.getDefaultInstance()) return this; + if (other.getResultCode() != 0) { + setResultCode(other.getResultCode()); + } + if (!other.getError().isEmpty()) { + error_ = other.error_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.aliyun.polardbx.rpc.cdc.RplCommandResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.rpc.cdc.RplCommandResponse) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int resultCode_ ; + /** + * int32 resultCode = 1; + * @return The resultCode. + */ + @java.lang.Override + public int getResultCode() { + return resultCode_; + } + /** + * int32 resultCode = 1; + * @param value The resultCode to set. + * @return This builder for chaining. + */ + public Builder setResultCode(int value) { + + resultCode_ = value; + onChanged(); + return this; + } + /** + * int32 resultCode = 1; + * @return This builder for chaining. + */ + public Builder clearResultCode() { + + resultCode_ = 0; + onChanged(); + return this; + } + + private java.lang.Object error_ = ""; + /** + * string error = 2; + * @return The error. + */ + public java.lang.String getError() { + java.lang.Object ref = error_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + error_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string error = 2; + * @return The bytes for error. + */ + public com.google.protobuf.ByteString + getErrorBytes() { + java.lang.Object ref = error_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + error_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string error = 2; + * @param value The error to set. + * @return This builder for chaining. + */ + public Builder setError( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + error_ = value; + onChanged(); + return this; + } + /** + * string error = 2; + * @return This builder for chaining. + */ + public Builder clearError() { + + error_ = getDefaultInstance().getError(); + onChanged(); + return this; + } + /** + * string error = 2; + * @param value The bytes for error to set. + * @return This builder for chaining. + */ + public Builder setErrorBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + error_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:dumper.RplCommandResponse) + } + + // @@protoc_insertion_point(class_scope:dumper.RplCommandResponse) + private static final com.aliyun.polardbx.rpc.cdc.RplCommandResponse DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.rpc.cdc.RplCommandResponse(); + } + + public static com.aliyun.polardbx.rpc.cdc.RplCommandResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public RplCommandResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new RplCommandResponse(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.RplCommandResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/RplCommandResponseOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/RplCommandResponseOrBuilder.java new file mode 100644 index 00000000..2ab91463 --- /dev/null +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/RplCommandResponseOrBuilder.java @@ -0,0 +1,27 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DumperServer.proto + +package com.aliyun.polardbx.rpc.cdc; + +public interface RplCommandResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:dumper.RplCommandResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * int32 resultCode = 1; + * @return The resultCode. + */ + int getResultCode(); + + /** + * string error = 2; + * @return The error. + */ + java.lang.String getError(); + /** + * string error = 2; + * @return The bytes for error. + */ + com.google.protobuf.ByteString + getErrorBytes(); +} diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowBinlogEventsRequest.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowBinlogEventsRequest.java index c6131f3b..93a502fe 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowBinlogEventsRequest.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowBinlogEventsRequest.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: DumperServer.proto @@ -27,830 +10,743 @@ public final class ShowBinlogEventsRequest extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:dumper.ShowBinlogEventsRequest) ShowBinlogEventsRequestOrBuilder { - private static final long serialVersionUID = 0L; +private static final long serialVersionUID = 0L; + // Use ShowBinlogEventsRequest.newBuilder() to construct. + private ShowBinlogEventsRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ShowBinlogEventsRequest() { + logName_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new ShowBinlogEventsRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ShowBinlogEventsRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); - // Use ShowBinlogEventsRequest.newBuilder() to construct. - private ShowBinlogEventsRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private ShowBinlogEventsRequest() { - logName_ = ""; + logName_ = s; + break; + } + case 16: { + + pos_ = input.readInt64(); + break; + } + case 24: { + + offset_ = input.readInt64(); + break; + } + case 32: { + + rowCount_ = input.readInt64(); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ShowBinlogEventsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ShowBinlogEventsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest.class, com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest.Builder.class); + } + + public static final int LOGNAME_FIELD_NUMBER = 1; + private volatile java.lang.Object logName_; + /** + * string logName = 1; + * @return The logName. + */ + @java.lang.Override + public java.lang.String getLogName() { + java.lang.Object ref = logName_; + 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(); + logName_ = s; + return s; + } + } + /** + * string logName = 1; + * @return The bytes for logName. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getLogNameBytes() { + java.lang.Object ref = logName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + logName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int POS_FIELD_NUMBER = 2; + private long pos_; + /** + * int64 pos = 2; + * @return The pos. + */ + @java.lang.Override + public long getPos() { + return pos_; + } + + public static final int OFFSET_FIELD_NUMBER = 3; + private long offset_; + /** + * int64 offset = 3; + * @return The offset. + */ + @java.lang.Override + public long getOffset() { + return offset_; + } + + public static final int ROWCOUNT_FIELD_NUMBER = 4; + private long rowCount_; + /** + * int64 rowCount = 4; + * @return The rowCount. + */ + @java.lang.Override + public long getRowCount() { + return rowCount_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getLogNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, logName_); + } + if (pos_ != 0L) { + output.writeInt64(2, pos_); + } + if (offset_ != 0L) { + output.writeInt64(3, offset_); + } + if (rowCount_ != 0L) { + output.writeInt64(4, rowCount_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getLogNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, logName_); + } + if (pos_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, pos_); + } + if (offset_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, offset_); + } + if (rowCount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, rowCount_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest)) { + return super.equals(obj); + } + com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest other = (com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest) obj; + + if (!getLogName() + .equals(other.getLogName())) return false; + if (getPos() + != other.getPos()) return false; + if (getOffset() + != other.getOffset()) return false; + if (getRowCount() + != other.getRowCount()) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + LOGNAME_FIELD_NUMBER; + hash = (53 * hash) + getLogName().hashCode(); + hash = (37 * hash) + POS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getPos()); + hash = (37 * hash) + OFFSET_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getOffset()); + hash = (37 * hash) + ROWCOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getRowCount()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code dumper.ShowBinlogEventsRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:dumper.ShowBinlogEventsRequest) + com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ShowBinlogEventsRequest_descriptor; } @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new ShowBinlogEventsRequest(); + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ShowBinlogEventsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest.class, com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest.Builder.class); } - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; + // Construct using com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); } - private ShowBinlogEventsRequest( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - 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; - case 10: { - java.lang.String s = input.readStringRequireUtf8(); - - logName_ = s; - break; - } - case 16: { - - pos_ = input.readInt64(); - break; - } - case 24: { - - offset_ = input.readInt64(); - break; - } - case 32: { - - rowCount_ = input.readInt64(); - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } } + @java.lang.Override + public Builder clear() { + super.clear(); + logName_ = ""; - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return DumperServer.internal_static_dumper_ShowBinlogEventsRequest_descriptor; + pos_ = 0L; + + offset_ = 0L; + + rowCount_ = 0L; + + return this; } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return DumperServer.internal_static_dumper_ShowBinlogEventsRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - ShowBinlogEventsRequest.class, ShowBinlogEventsRequest.Builder.class); + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ShowBinlogEventsRequest_descriptor; } - public static final int LOGNAME_FIELD_NUMBER = 1; - private volatile java.lang.Object logName_; - - /** - * string logName = 1; - * - * @return The logName. - */ @java.lang.Override - public java.lang.String getLogName() { - java.lang.Object ref = logName_; - 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(); - logName_ = s; - return s; - } + public com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest getDefaultInstanceForType() { + return com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest.getDefaultInstance(); } - /** - * string logName = 1; - * - * @return The bytes for logName. - */ @java.lang.Override - public com.google.protobuf.ByteString - getLogNameBytes() { - java.lang.Object ref = logName_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - logName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + public com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest build() { + com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; } - public static final int POS_FIELD_NUMBER = 2; - private long pos_; - - /** - * int64 pos = 2; - * - * @return The pos. - */ @java.lang.Override - public long getPos() { - return pos_; + public com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest buildPartial() { + com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest result = new com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest(this); + result.logName_ = logName_; + result.pos_ = pos_; + result.offset_ = offset_; + result.rowCount_ = rowCount_; + onBuilt(); + return result; } - public static final int OFFSET_FIELD_NUMBER = 3; - private long offset_; - - /** - * int64 offset = 3; - * - * @return The offset. - */ @java.lang.Override - public long getOffset() { - return offset_; + public Builder clone() { + return super.clone(); } - - public static final int ROWCOUNT_FIELD_NUMBER = 4; - private long rowCount_; - - /** - * int64 rowCount = 4; - * - * @return The rowCount. - */ @java.lang.Override - public long getRowCount() { - return rowCount_; + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); } - - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } - - memoizedIsInitialized = 1; - return true; + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); } - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getLogNameBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, logName_); - } - if (pos_ != 0L) { - output.writeInt64(2, pos_); - } - if (offset_ != 0L) { - output.writeInt64(3, offset_); - } - if (rowCount_ != 0L) { - output.writeInt64(4, rowCount_); - } - unknownFields.writeTo(output); + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); } - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) { - return size; - } - - size = 0; - if (!getLogNameBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, logName_); - } - if (pos_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(2, pos_); - } - if (offset_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(3, offset_); - } - if (rowCount_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(4, rowCount_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); } - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof ShowBinlogEventsRequest)) { - return super.equals(obj); - } - ShowBinlogEventsRequest other = (ShowBinlogEventsRequest) obj; - - if (!getLogName() - .equals(other.getLogName())) { - return false; - } - if (getPos() - != other.getPos()) { - return false; - } - if (getOffset() - != other.getOffset()) { - return false; - } - if (getRowCount() - != other.getRowCount()) { - return false; - } - if (!unknownFields.equals(other.unknownFields)) { - return false; - } - return true; + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest) { + return mergeFrom((com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest other) { + if (other == com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest.getDefaultInstance()) return this; + if (!other.getLogName().isEmpty()) { + logName_ = other.logName_; + onChanged(); + } + if (other.getPos() != 0L) { + setPos(other.getPos()); + } + if (other.getOffset() != 0L) { + setOffset(other.getOffset()); + } + if (other.getRowCount() != 0L) { + setRowCount(other.getRowCount()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; } @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + LOGNAME_FIELD_NUMBER; - hash = (53 * hash) + getLogName().hashCode(); - hash = (37 * hash) + POS_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getPos()); - hash = (37 * hash) + OFFSET_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getOffset()); - hash = (37 * hash) + ROWCOUNT_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getRowCount()); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static ShowBinlogEventsRequest parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + public final boolean isInitialized() { + return true; } - public static ShowBinlogEventsRequest parseFrom( - java.nio.ByteBuffer data, + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + throws java.io.IOException { + com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; } - public static ShowBinlogEventsRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + private java.lang.Object logName_ = ""; + /** + * string logName = 1; + * @return The logName. + */ + public java.lang.String getLogName() { + java.lang.Object ref = logName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + logName_ = s; + return s; + } else { + return (java.lang.String) ref; + } } - - public static ShowBinlogEventsRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + /** + * string logName = 1; + * @return The bytes for logName. + */ + public com.google.protobuf.ByteString + getLogNameBytes() { + java.lang.Object ref = logName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + logName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } - - public static ShowBinlogEventsRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); + /** + * string logName = 1; + * @param value The logName to set. + * @return This builder for chaining. + */ + public Builder setLogName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + logName_ = value; + onChanged(); + return this; } - - public static ShowBinlogEventsRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); + /** + * string logName = 1; + * @return This builder for chaining. + */ + public Builder clearLogName() { + + logName_ = getDefaultInstance().getLogName(); + onChanged(); + return this; } - - public static ShowBinlogEventsRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + /** + * string logName = 1; + * @param value The bytes for logName to set. + * @return This builder for chaining. + */ + public Builder setLogNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + logName_ = value; + onChanged(); + return this; + } + + private long pos_ ; + /** + * int64 pos = 2; + * @return The pos. + */ + @java.lang.Override + public long getPos() { + return pos_; } - - public static ShowBinlogEventsRequest parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + /** + * int64 pos = 2; + * @param value The pos to set. + * @return This builder for chaining. + */ + public Builder setPos(long value) { + + pos_ = value; + onChanged(); + return this; } - - public static ShowBinlogEventsRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); + /** + * int64 pos = 2; + * @return This builder for chaining. + */ + public Builder clearPos() { + + pos_ = 0L; + onChanged(); + return this; } - public static ShowBinlogEventsRequest parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + private long offset_ ; + /** + * int64 offset = 3; + * @return The offset. + */ + @java.lang.Override + public long getOffset() { + return offset_; } - - public static ShowBinlogEventsRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + /** + * int64 offset = 3; + * @param value The offset to set. + * @return This builder for chaining. + */ + public Builder setOffset(long value) { + + offset_ = value; + onChanged(); + return this; } - - public static ShowBinlogEventsRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + /** + * int64 offset = 3; + * @return This builder for chaining. + */ + public Builder clearOffset() { + + offset_ = 0L; + onChanged(); + return this; } + private long rowCount_ ; + /** + * int64 rowCount = 4; + * @return The rowCount. + */ @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); + public long getRowCount() { + return rowCount_; } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); + /** + * int64 rowCount = 4; + * @param value The rowCount to set. + * @return This builder for chaining. + */ + public Builder setRowCount(long value) { + + rowCount_ = value; + onChanged(); + return this; } - - public static Builder newBuilder(ShowBinlogEventsRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + /** + * int64 rowCount = 4; + * @return This builder for chaining. + */ + public Builder clearRowCount() { + + rowCount_ = 0L; + onChanged(); + return this; } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); } @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - /** - * Protobuf type {@code dumper.ShowBinlogEventsRequest} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:dumper.ShowBinlogEventsRequest) - ShowBinlogEventsRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return DumperServer.internal_static_dumper_ShowBinlogEventsRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return DumperServer.internal_static_dumper_ShowBinlogEventsRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - ShowBinlogEventsRequest.class, ShowBinlogEventsRequest.Builder.class); - } - - // Construct using com.alibaba.tddl.rpc.cdc.ShowBinlogEventsRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - @java.lang.Override - public Builder clear() { - super.clear(); - logName_ = ""; - - pos_ = 0L; - - offset_ = 0L; - - rowCount_ = 0L; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return DumperServer.internal_static_dumper_ShowBinlogEventsRequest_descriptor; - } - - @java.lang.Override - public ShowBinlogEventsRequest getDefaultInstanceForType() { - return ShowBinlogEventsRequest.getDefaultInstance(); - } - - @java.lang.Override - public ShowBinlogEventsRequest build() { - ShowBinlogEventsRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public ShowBinlogEventsRequest buildPartial() { - ShowBinlogEventsRequest result = new ShowBinlogEventsRequest(this); - result.logName_ = logName_; - result.pos_ = pos_; - result.offset_ = offset_; - result.rowCount_ = rowCount_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof ShowBinlogEventsRequest) { - return mergeFrom((ShowBinlogEventsRequest) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(ShowBinlogEventsRequest other) { - if (other == ShowBinlogEventsRequest.getDefaultInstance()) { - return this; - } - if (!other.getLogName().isEmpty()) { - logName_ = other.logName_; - onChanged(); - } - if (other.getPos() != 0L) { - setPos(other.getPos()); - } - if (other.getOffset() != 0L) { - setOffset(other.getOffset()); - } - if (other.getRowCount() != 0L) { - setRowCount(other.getRowCount()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - ShowBinlogEventsRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (ShowBinlogEventsRequest) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object logName_ = ""; - - /** - * string logName = 1; - * - * @return The logName. - */ - public java.lang.String getLogName() { - java.lang.Object ref = logName_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - logName_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - - /** - * string logName = 1; - * - * @return The bytes for logName. - */ - public com.google.protobuf.ByteString - getLogNameBytes() { - java.lang.Object ref = logName_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - logName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string logName = 1; - * - * @param value The logName to set. - * @return This builder for chaining. - */ - public Builder setLogName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - logName_ = value; - onChanged(); - return this; - } - - /** - * string logName = 1; - * - * @return This builder for chaining. - */ - public Builder clearLogName() { - - logName_ = getDefaultInstance().getLogName(); - onChanged(); - return this; - } - - /** - * string logName = 1; - * - * @param value The bytes for logName to set. - * @return This builder for chaining. - */ - public Builder setLogNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - logName_ = value; - onChanged(); - return this; - } - - private long pos_; - - /** - * int64 pos = 2; - * - * @return The pos. - */ - @java.lang.Override - public long getPos() { - return pos_; - } - - /** - * int64 pos = 2; - * - * @param value The pos to set. - * @return This builder for chaining. - */ - public Builder setPos(long value) { - - pos_ = value; - onChanged(); - return this; - } - - /** - * int64 pos = 2; - * - * @return This builder for chaining. - */ - public Builder clearPos() { - - pos_ = 0L; - onChanged(); - return this; - } - - private long offset_; - /** - * int64 offset = 3; - * - * @return The offset. - */ - @java.lang.Override - public long getOffset() { - return offset_; - } - - /** - * int64 offset = 3; - * - * @param value The offset to set. - * @return This builder for chaining. - */ - public Builder setOffset(long value) { - - offset_ = value; - onChanged(); - return this; - } + // @@protoc_insertion_point(builder_scope:dumper.ShowBinlogEventsRequest) + } - /** - * int64 offset = 3; - * - * @return This builder for chaining. - */ - public Builder clearOffset() { - - offset_ = 0L; - onChanged(); - return this; - } + // @@protoc_insertion_point(class_scope:dumper.ShowBinlogEventsRequest) + private static final com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest(); + } - private long rowCount_; - - /** - * int64 rowCount = 4; - * - * @return The rowCount. - */ - @java.lang.Override - public long getRowCount() { - return rowCount_; - } - - /** - * int64 rowCount = 4; - * - * @param value The rowCount to set. - * @return This builder for chaining. - */ - public Builder setRowCount(long value) { - - rowCount_ = value; - onChanged(); - return this; - } - - /** - * int64 rowCount = 4; - * - * @return This builder for chaining. - */ - public Builder clearRowCount() { - - rowCount_ = 0L; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } + public static com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:dumper.ShowBinlogEventsRequest) - } - - // @@protoc_insertion_point(class_scope:dumper.ShowBinlogEventsRequest) - private static final ShowBinlogEventsRequest DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new ShowBinlogEventsRequest(); - } - - public static ShowBinlogEventsRequest getDefaultInstance() { - return DEFAULT_INSTANCE; + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ShowBinlogEventsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ShowBinlogEventsRequest(input, extensionRegistry); } + }; - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public ShowBinlogEventsRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new ShowBinlogEventsRequest(input, extensionRegistry); - } - }; + public static com.google.protobuf.Parser parser() { + return PARSER; + } - public static com.google.protobuf.Parser parser() { - return PARSER; - } + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public ShowBinlogEventsRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ShowBinlogEventsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowBinlogEventsRequestOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowBinlogEventsRequestOrBuilder.java index 8193ddb6..5dde3276 100644 --- a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowBinlogEventsRequestOrBuilder.java +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowBinlogEventsRequestOrBuilder.java @@ -1,20 +1,3 @@ -/* - * - * Copyright (c) 2013-2021, 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. - * - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: DumperServer.proto @@ -24,39 +7,33 @@ public interface ShowBinlogEventsRequestOrBuilder extends // @@protoc_insertion_point(interface_extends:dumper.ShowBinlogEventsRequest) com.google.protobuf.MessageOrBuilder { - /** - * string logName = 1; - * - * @return The logName. - */ - java.lang.String getLogName(); - - /** - * string logName = 1; - * - * @return The bytes for logName. - */ - com.google.protobuf.ByteString - getLogNameBytes(); - - /** - * int64 pos = 2; - * - * @return The pos. - */ - long getPos(); - - /** - * int64 offset = 3; - * - * @return The offset. - */ - long getOffset(); - - /** - * int64 rowCount = 4; - * - * @return The rowCount. - */ - long getRowCount(); + /** + * string logName = 1; + * @return The logName. + */ + java.lang.String getLogName(); + /** + * string logName = 1; + * @return The bytes for logName. + */ + com.google.protobuf.ByteString + getLogNameBytes(); + + /** + * int64 pos = 2; + * @return The pos. + */ + long getPos(); + + /** + * int64 offset = 3; + * @return The offset. + */ + long getOffset(); + + /** + * int64 rowCount = 4; + * @return The rowCount. + */ + long getRowCount(); } diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowSlaveStatusRequest.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowSlaveStatusRequest.java new file mode 100644 index 00000000..223ab117 --- /dev/null +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowSlaveStatusRequest.java @@ -0,0 +1,557 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DumperServer.proto + +package com.aliyun.polardbx.rpc.cdc; + +/** + * Protobuf type {@code dumper.ShowSlaveStatusRequest} + */ +public final class ShowSlaveStatusRequest extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:dumper.ShowSlaveStatusRequest) + ShowSlaveStatusRequestOrBuilder { +private static final long serialVersionUID = 0L; + // Use ShowSlaveStatusRequest.newBuilder() to construct. + private ShowSlaveStatusRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ShowSlaveStatusRequest() { + request_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new ShowSlaveStatusRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ShowSlaveStatusRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + request_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ShowSlaveStatusRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ShowSlaveStatusRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest.class, com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest.Builder.class); + } + + public static final int REQUEST_FIELD_NUMBER = 1; + private volatile java.lang.Object request_; + /** + * string request = 1; + * @return The request. + */ + @java.lang.Override + public java.lang.String getRequest() { + java.lang.Object ref = request_; + 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(); + request_ = s; + return s; + } + } + /** + * string request = 1; + * @return The bytes for request. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getRequestBytes() { + java.lang.Object ref = request_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + request_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getRequestBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, request_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getRequestBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, request_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest)) { + return super.equals(obj); + } + com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest other = (com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest) obj; + + if (!getRequest() + .equals(other.getRequest())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + REQUEST_FIELD_NUMBER; + hash = (53 * hash) + getRequest().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code dumper.ShowSlaveStatusRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:dumper.ShowSlaveStatusRequest) + com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ShowSlaveStatusRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ShowSlaveStatusRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest.class, com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest.Builder.class); + } + + // Construct using com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + request_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ShowSlaveStatusRequest_descriptor; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest getDefaultInstanceForType() { + return com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest build() { + com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest buildPartial() { + com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest result = new com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest(this); + result.request_ = request_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest) { + return mergeFrom((com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest other) { + if (other == com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest.getDefaultInstance()) return this; + if (!other.getRequest().isEmpty()) { + request_ = other.request_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object request_ = ""; + /** + * string request = 1; + * @return The request. + */ + public java.lang.String getRequest() { + java.lang.Object ref = request_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + request_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string request = 1; + * @return The bytes for request. + */ + public com.google.protobuf.ByteString + getRequestBytes() { + java.lang.Object ref = request_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + request_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string request = 1; + * @param value The request to set. + * @return This builder for chaining. + */ + public Builder setRequest( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + request_ = value; + onChanged(); + return this; + } + /** + * string request = 1; + * @return This builder for chaining. + */ + public Builder clearRequest() { + + request_ = getDefaultInstance().getRequest(); + onChanged(); + return this; + } + /** + * string request = 1; + * @param value The bytes for request to set. + * @return This builder for chaining. + */ + public Builder setRequestBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + request_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:dumper.ShowSlaveStatusRequest) + } + + // @@protoc_insertion_point(class_scope:dumper.ShowSlaveStatusRequest) + private static final com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest(); + } + + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ShowSlaveStatusRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ShowSlaveStatusRequest(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowSlaveStatusRequestOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowSlaveStatusRequestOrBuilder.java new file mode 100644 index 00000000..794860df --- /dev/null +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowSlaveStatusRequestOrBuilder.java @@ -0,0 +1,21 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DumperServer.proto + +package com.aliyun.polardbx.rpc.cdc; + +public interface ShowSlaveStatusRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:dumper.ShowSlaveStatusRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * string request = 1; + * @return The request. + */ + java.lang.String getRequest(); + /** + * string request = 1; + * @return The bytes for request. + */ + com.google.protobuf.ByteString + getRequestBytes(); +} diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowSlaveStatusResponse.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowSlaveStatusResponse.java new file mode 100644 index 00000000..d0710712 --- /dev/null +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowSlaveStatusResponse.java @@ -0,0 +1,557 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DumperServer.proto + +package com.aliyun.polardbx.rpc.cdc; + +/** + * Protobuf type {@code dumper.ShowSlaveStatusResponse} + */ +public final class ShowSlaveStatusResponse extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:dumper.ShowSlaveStatusResponse) + ShowSlaveStatusResponseOrBuilder { +private static final long serialVersionUID = 0L; + // Use ShowSlaveStatusResponse.newBuilder() to construct. + private ShowSlaveStatusResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ShowSlaveStatusResponse() { + response_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new ShowSlaveStatusResponse(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ShowSlaveStatusResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + response_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ShowSlaveStatusResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ShowSlaveStatusResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse.class, com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse.Builder.class); + } + + public static final int RESPONSE_FIELD_NUMBER = 1; + private volatile java.lang.Object response_; + /** + * string response = 1; + * @return The response. + */ + @java.lang.Override + public java.lang.String getResponse() { + java.lang.Object ref = response_; + 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(); + response_ = s; + return s; + } + } + /** + * string response = 1; + * @return The bytes for response. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getResponseBytes() { + java.lang.Object ref = response_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + response_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getResponseBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, response_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getResponseBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, response_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse)) { + return super.equals(obj); + } + com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse other = (com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse) obj; + + if (!getResponse() + .equals(other.getResponse())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + RESPONSE_FIELD_NUMBER; + hash = (53 * hash) + getResponse().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code dumper.ShowSlaveStatusResponse} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:dumper.ShowSlaveStatusResponse) + com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ShowSlaveStatusResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ShowSlaveStatusResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse.class, com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse.Builder.class); + } + + // Construct using com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + response_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_ShowSlaveStatusResponse_descriptor; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse getDefaultInstanceForType() { + return com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse build() { + com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse buildPartial() { + com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse result = new com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse(this); + result.response_ = response_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse) { + return mergeFrom((com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse other) { + if (other == com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse.getDefaultInstance()) return this; + if (!other.getResponse().isEmpty()) { + response_ = other.response_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object response_ = ""; + /** + * string response = 1; + * @return The response. + */ + public java.lang.String getResponse() { + java.lang.Object ref = response_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + response_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string response = 1; + * @return The bytes for response. + */ + public com.google.protobuf.ByteString + getResponseBytes() { + java.lang.Object ref = response_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + response_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string response = 1; + * @param value The response to set. + * @return This builder for chaining. + */ + public Builder setResponse( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + response_ = value; + onChanged(); + return this; + } + /** + * string response = 1; + * @return This builder for chaining. + */ + public Builder clearResponse() { + + response_ = getDefaultInstance().getResponse(); + onChanged(); + return this; + } + /** + * string response = 1; + * @param value The bytes for response to set. + * @return This builder for chaining. + */ + public Builder setResponseBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + response_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:dumper.ShowSlaveStatusResponse) + } + + // @@protoc_insertion_point(class_scope:dumper.ShowSlaveStatusResponse) + private static final com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse(); + } + + public static com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ShowSlaveStatusResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ShowSlaveStatusResponse(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowSlaveStatusResponseOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowSlaveStatusResponseOrBuilder.java new file mode 100644 index 00000000..ceb3ea91 --- /dev/null +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/ShowSlaveStatusResponseOrBuilder.java @@ -0,0 +1,21 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DumperServer.proto + +package com.aliyun.polardbx.rpc.cdc; + +public interface ShowSlaveStatusResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:dumper.ShowSlaveStatusResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * string response = 1; + * @return The response. + */ + java.lang.String getResponse(); + /** + * string response = 1; + * @return The bytes for response. + */ + com.google.protobuf.ByteString + getResponseBytes(); +} diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/StartSlaveRequest.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/StartSlaveRequest.java new file mode 100644 index 00000000..f5836b4e --- /dev/null +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/StartSlaveRequest.java @@ -0,0 +1,557 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DumperServer.proto + +package com.aliyun.polardbx.rpc.cdc; + +/** + * Protobuf type {@code dumper.StartSlaveRequest} + */ +public final class StartSlaveRequest extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:dumper.StartSlaveRequest) + StartSlaveRequestOrBuilder { +private static final long serialVersionUID = 0L; + // Use StartSlaveRequest.newBuilder() to construct. + private StartSlaveRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private StartSlaveRequest() { + request_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new StartSlaveRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private StartSlaveRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + request_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_StartSlaveRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_StartSlaveRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.StartSlaveRequest.class, com.aliyun.polardbx.rpc.cdc.StartSlaveRequest.Builder.class); + } + + public static final int REQUEST_FIELD_NUMBER = 1; + private volatile java.lang.Object request_; + /** + * string request = 1; + * @return The request. + */ + @java.lang.Override + public java.lang.String getRequest() { + java.lang.Object ref = request_; + 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(); + request_ = s; + return s; + } + } + /** + * string request = 1; + * @return The bytes for request. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getRequestBytes() { + java.lang.Object ref = request_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + request_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getRequestBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, request_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getRequestBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, request_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.rpc.cdc.StartSlaveRequest)) { + return super.equals(obj); + } + com.aliyun.polardbx.rpc.cdc.StartSlaveRequest other = (com.aliyun.polardbx.rpc.cdc.StartSlaveRequest) obj; + + if (!getRequest() + .equals(other.getRequest())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + REQUEST_FIELD_NUMBER; + hash = (53 * hash) + getRequest().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.rpc.cdc.StartSlaveRequest parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.StartSlaveRequest parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.StartSlaveRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.StartSlaveRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.StartSlaveRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.StartSlaveRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.StartSlaveRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.StartSlaveRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.StartSlaveRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.StartSlaveRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.StartSlaveRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.StartSlaveRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.rpc.cdc.StartSlaveRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code dumper.StartSlaveRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:dumper.StartSlaveRequest) + com.aliyun.polardbx.rpc.cdc.StartSlaveRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_StartSlaveRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_StartSlaveRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.StartSlaveRequest.class, com.aliyun.polardbx.rpc.cdc.StartSlaveRequest.Builder.class); + } + + // Construct using com.aliyun.polardbx.rpc.cdc.StartSlaveRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + request_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_StartSlaveRequest_descriptor; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.StartSlaveRequest getDefaultInstanceForType() { + return com.aliyun.polardbx.rpc.cdc.StartSlaveRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.StartSlaveRequest build() { + com.aliyun.polardbx.rpc.cdc.StartSlaveRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.StartSlaveRequest buildPartial() { + com.aliyun.polardbx.rpc.cdc.StartSlaveRequest result = new com.aliyun.polardbx.rpc.cdc.StartSlaveRequest(this); + result.request_ = request_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.rpc.cdc.StartSlaveRequest) { + return mergeFrom((com.aliyun.polardbx.rpc.cdc.StartSlaveRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.polardbx.rpc.cdc.StartSlaveRequest other) { + if (other == com.aliyun.polardbx.rpc.cdc.StartSlaveRequest.getDefaultInstance()) return this; + if (!other.getRequest().isEmpty()) { + request_ = other.request_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.aliyun.polardbx.rpc.cdc.StartSlaveRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.rpc.cdc.StartSlaveRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object request_ = ""; + /** + * string request = 1; + * @return The request. + */ + public java.lang.String getRequest() { + java.lang.Object ref = request_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + request_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string request = 1; + * @return The bytes for request. + */ + public com.google.protobuf.ByteString + getRequestBytes() { + java.lang.Object ref = request_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + request_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string request = 1; + * @param value The request to set. + * @return This builder for chaining. + */ + public Builder setRequest( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + request_ = value; + onChanged(); + return this; + } + /** + * string request = 1; + * @return This builder for chaining. + */ + public Builder clearRequest() { + + request_ = getDefaultInstance().getRequest(); + onChanged(); + return this; + } + /** + * string request = 1; + * @param value The bytes for request to set. + * @return This builder for chaining. + */ + public Builder setRequestBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + request_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:dumper.StartSlaveRequest) + } + + // @@protoc_insertion_point(class_scope:dumper.StartSlaveRequest) + private static final com.aliyun.polardbx.rpc.cdc.StartSlaveRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.rpc.cdc.StartSlaveRequest(); + } + + public static com.aliyun.polardbx.rpc.cdc.StartSlaveRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public StartSlaveRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new StartSlaveRequest(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.StartSlaveRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/StartSlaveRequestOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/StartSlaveRequestOrBuilder.java new file mode 100644 index 00000000..c82c096c --- /dev/null +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/StartSlaveRequestOrBuilder.java @@ -0,0 +1,21 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DumperServer.proto + +package com.aliyun.polardbx.rpc.cdc; + +public interface StartSlaveRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:dumper.StartSlaveRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * string request = 1; + * @return The request. + */ + java.lang.String getRequest(); + /** + * string request = 1; + * @return The bytes for request. + */ + com.google.protobuf.ByteString + getRequestBytes(); +} diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/StopSlaveRequest.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/StopSlaveRequest.java new file mode 100644 index 00000000..3e7ef531 --- /dev/null +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/StopSlaveRequest.java @@ -0,0 +1,557 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DumperServer.proto + +package com.aliyun.polardbx.rpc.cdc; + +/** + * Protobuf type {@code dumper.StopSlaveRequest} + */ +public final class StopSlaveRequest extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:dumper.StopSlaveRequest) + StopSlaveRequestOrBuilder { +private static final long serialVersionUID = 0L; + // Use StopSlaveRequest.newBuilder() to construct. + private StopSlaveRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private StopSlaveRequest() { + request_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new StopSlaveRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private StopSlaveRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + request_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_StopSlaveRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_StopSlaveRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.StopSlaveRequest.class, com.aliyun.polardbx.rpc.cdc.StopSlaveRequest.Builder.class); + } + + public static final int REQUEST_FIELD_NUMBER = 1; + private volatile java.lang.Object request_; + /** + * string request = 1; + * @return The request. + */ + @java.lang.Override + public java.lang.String getRequest() { + java.lang.Object ref = request_; + 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(); + request_ = s; + return s; + } + } + /** + * string request = 1; + * @return The bytes for request. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getRequestBytes() { + java.lang.Object ref = request_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + request_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getRequestBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, request_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getRequestBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, request_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.polardbx.rpc.cdc.StopSlaveRequest)) { + return super.equals(obj); + } + com.aliyun.polardbx.rpc.cdc.StopSlaveRequest other = (com.aliyun.polardbx.rpc.cdc.StopSlaveRequest) obj; + + if (!getRequest() + .equals(other.getRequest())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + REQUEST_FIELD_NUMBER; + hash = (53 * hash) + getRequest().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.polardbx.rpc.cdc.StopSlaveRequest parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.StopSlaveRequest parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.StopSlaveRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.StopSlaveRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.StopSlaveRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.polardbx.rpc.cdc.StopSlaveRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.StopSlaveRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.StopSlaveRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.StopSlaveRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.StopSlaveRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.polardbx.rpc.cdc.StopSlaveRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.polardbx.rpc.cdc.StopSlaveRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.polardbx.rpc.cdc.StopSlaveRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code dumper.StopSlaveRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:dumper.StopSlaveRequest) + com.aliyun.polardbx.rpc.cdc.StopSlaveRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_StopSlaveRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_StopSlaveRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.polardbx.rpc.cdc.StopSlaveRequest.class, com.aliyun.polardbx.rpc.cdc.StopSlaveRequest.Builder.class); + } + + // Construct using com.aliyun.polardbx.rpc.cdc.StopSlaveRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + request_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.polardbx.rpc.cdc.DumperServer.internal_static_dumper_StopSlaveRequest_descriptor; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.StopSlaveRequest getDefaultInstanceForType() { + return com.aliyun.polardbx.rpc.cdc.StopSlaveRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.StopSlaveRequest build() { + com.aliyun.polardbx.rpc.cdc.StopSlaveRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.StopSlaveRequest buildPartial() { + com.aliyun.polardbx.rpc.cdc.StopSlaveRequest result = new com.aliyun.polardbx.rpc.cdc.StopSlaveRequest(this); + result.request_ = request_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.polardbx.rpc.cdc.StopSlaveRequest) { + return mergeFrom((com.aliyun.polardbx.rpc.cdc.StopSlaveRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.polardbx.rpc.cdc.StopSlaveRequest other) { + if (other == com.aliyun.polardbx.rpc.cdc.StopSlaveRequest.getDefaultInstance()) return this; + if (!other.getRequest().isEmpty()) { + request_ = other.request_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.aliyun.polardbx.rpc.cdc.StopSlaveRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.aliyun.polardbx.rpc.cdc.StopSlaveRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object request_ = ""; + /** + * string request = 1; + * @return The request. + */ + public java.lang.String getRequest() { + java.lang.Object ref = request_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + request_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string request = 1; + * @return The bytes for request. + */ + public com.google.protobuf.ByteString + getRequestBytes() { + java.lang.Object ref = request_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + request_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string request = 1; + * @param value The request to set. + * @return This builder for chaining. + */ + public Builder setRequest( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + request_ = value; + onChanged(); + return this; + } + /** + * string request = 1; + * @return This builder for chaining. + */ + public Builder clearRequest() { + + request_ = getDefaultInstance().getRequest(); + onChanged(); + return this; + } + /** + * string request = 1; + * @param value The bytes for request to set. + * @return This builder for chaining. + */ + public Builder setRequestBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + request_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:dumper.StopSlaveRequest) + } + + // @@protoc_insertion_point(class_scope:dumper.StopSlaveRequest) + private static final com.aliyun.polardbx.rpc.cdc.StopSlaveRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.polardbx.rpc.cdc.StopSlaveRequest(); + } + + public static com.aliyun.polardbx.rpc.cdc.StopSlaveRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public StopSlaveRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new StopSlaveRequest(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.aliyun.polardbx.rpc.cdc.StopSlaveRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/StopSlaveRequestOrBuilder.java b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/StopSlaveRequestOrBuilder.java new file mode 100644 index 00000000..0342f6f7 --- /dev/null +++ b/polardbx-cdc-protocol/src/main/java/com/aliyun/polardbx/rpc/cdc/StopSlaveRequestOrBuilder.java @@ -0,0 +1,21 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DumperServer.proto + +package com.aliyun.polardbx.rpc.cdc; + +public interface StopSlaveRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:dumper.StopSlaveRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * string request = 1; + * @return The request. + */ + java.lang.String getRequest(); + /** + * string request = 1; + * @return The bytes for request. + */ + com.google.protobuf.ByteString + getRequestBytes(); +} diff --git a/polardbx-cdc-protocol/src/main/proto/DumperServer.proto b/polardbx-cdc-protocol/src/main/proto/DumperServer.proto index dac25522..dd28ad28 100644 --- a/polardbx-cdc-protocol/src/main/proto/DumperServer.proto +++ b/polardbx-cdc-protocol/src/main/proto/DumperServer.proto @@ -17,6 +17,19 @@ service CdcService { rpc Dump (DumpRequest) returns (stream DumpStream) {} rpc Sync (DumpRequest) returns (stream DumpStream) {} + + ////////////////////////////// replicate /////////////////////////// + rpc ChangeMaster (ChangeMasterRequest) returns (RplCommandResponse) {} + + rpc ChangeReplicationFilter (ChangeReplicationFilterRequest) returns (RplCommandResponse) {} + + rpc StartSlave (StartSlaveRequest) returns (RplCommandResponse) {} + + rpc StopSlave (StopSlaveRequest) returns (RplCommandResponse) {} + + rpc ResetSlave (ResetSlaveRequest) returns (RplCommandResponse) {} + + rpc ShowSlaveStatus (ShowSlaveStatusRequest) returns (stream ShowSlaveStatusResponse) {} } message Request { @@ -60,4 +73,38 @@ message BinlogEvent { message DumpStream { bytes payload = 1; +} + +////////////////////////////// replicate /////////////////////////// +message RplCommandResponse{ + int32 resultCode = 1; + string error = 2; +} + +message ChangeMasterRequest{ + string request = 1; +} + +message StartSlaveRequest{ + string request = 1; +} + +message StopSlaveRequest{ + string request = 1; +} + +message ResetSlaveRequest{ + string request = 1; +} + +message ChangeReplicationFilterRequest{ + string request = 1; +} + +message ShowSlaveStatusRequest{ + string request = 1; +} + +message ShowSlaveStatusResponse{ + string response = 1; } \ No newline at end of file diff --git a/polardbx-cdc-protocol/src/main/proto/TxnStream.proto b/polardbx-cdc-protocol/src/main/proto/TxnStream.proto index 76895574..d5f5a01c 100644 --- a/polardbx-cdc-protocol/src/main/proto/TxnStream.proto +++ b/polardbx-cdc-protocol/src/main/proto/TxnStream.proto @@ -88,9 +88,13 @@ message TxnToken{ */ int32 txnSize = 8; /** - dumper生成事务的begin头时使用 + 1.dumper生成事务的begin头时使用 + 2.ddl场景下标识ddl sql对应的库名 + */ + string schema = 9; + /** + 该事务的所有参与者 */ - string beginSchema = 9; repeated string allParties = 10; /** 一些特殊的TxnToken,没有TxnItem的概念,此时通过payload字段传输数据 @@ -100,13 +104,18 @@ message TxnToken{ Tso事务专用 */ int64 snapshotSeq = 12; + /** + 表名,非必须 + */ + string table = 13; } message TxnMergedToken{ string tso = 1; TxnType type = 2; - string beginSchema = 3; + string schema = 3; bytes payload = 4; + string table = 5; } message TxnItem{ @@ -116,15 +125,26 @@ message TxnItem{ 3.如果物理binlog中带有traceId标识,直接使用即可;如果物理binlog中不带有traceId标识,通过"时间戳+自增序列"手动生成
*/ string traceId = 1; - string rowsQuery = 2; /** 1.对应mysql的EventType */ - int32 eventType = 3; + int32 eventType = 2; /** 1.二进制数据 */ - bytes payload = 4; + bytes payload = 3; + /** + 1.保存RowsQuery信息 + */ + string rowsQuery = 4; + /** + 对应的库名 + */ + string schema = 5; + /** + 对应的表名 + */ + string table = 6; } enum TxnType{ diff --git a/polardbx-cdc-rpl/README.md b/polardbx-cdc-rpl/README.md new file mode 100644 index 00000000..58332693 --- /dev/null +++ b/polardbx-cdc-rpl/README.md @@ -0,0 +1,87 @@ +Replica Reference Manual +======================== + +## CHANGE MASTER TO +CHANGE MASTER TO option [, option] ... [channel_option] + +option : { + MASTER_HOST='host_name' + | MASTER_USER='user_name' + | MASTER_PASSWORD='password' + | MASTER_PORT=port_num + | MASTER_HEARTBEAT_PERIOD=interval + | MASTER_LOG_FILE='source_log_name' + | MASTER_LOG_POS=source_log_pos + | IGNORE_SERVER_IDS=(server_id_list) + | SOURCE_HOST_TYPE='rds' / 'polardbx' / 'mysql' +} + +channel_option: + FOR CHANNEL channel + +server_id_list: + [server_id [, server_id]...] + +options supported soon: + MASTER_HEARTBEAT_PERIOD=interval (interval is now fixed to 120) + WRITER_TYPE='transaction' / 'serial' / 'split' / 'merge' +
+ +## CHANGE REPLICATION FILTER + +CHANGE REPLICATION FILTER filter [, filter][, ...] +filter : { + REPLICATE_DO_DB=(db_list) + | REPLICATE_IGNORE_DB=(db_list) + | REPLICATE_DO_TABLE=(tbl_list) + | REPLICATE_IGNORE_TABLE=(tbl_list) + | REPLICATE_WILD_DO_TABLE=(wild_tbl_list) + | REPLICATE_WILD_IGNORE_TABLE=(wild_tbl_list) + | REPLICATE_REWRITE_DB=(db_pair_list) +} + +db_list : + db_name[, db_name][, ... ] + +tbl_list : + db_name.table_name[, db_table_name][, ... ] + +wild_tbl_list : + 'db_pattern.table_pattern'[, 'db_pattern.table_pattern'][, ...] + +db_pair_list : + (db_pair)[, (db_pair)][, ...] + +db_pair: + from_db, to_db +
+ +## START SLAVE + +START SLAVE [channel_option] + +channel_option: + FOR CHANNEL channel +
+ +## STOP SLAVE + +STOP SLAVE [channel_option] + +channel_option: + FOR CHANNEL channel +
+ +## RESET SLAVE +RESET SLAVE [ALL] [channel_option] + +channel_option: + FOR CHANNEL channel +
+ +## Commands supported soon: +SET SQL_SLAVE_SKIP_COUNTER=N +
+ +## More details +For more details about commands and options, refer to MySQL [official Mysql document](https://dev.mysql.com/doc/refman/5.7/en/replication-statements-replica.html). diff --git a/polardbx-cdc-rpl/assembly.xml b/polardbx-cdc-rpl/assembly.xml new file mode 100644 index 00000000..0810ef03 --- /dev/null +++ b/polardbx-cdc-rpl/assembly.xml @@ -0,0 +1,41 @@ + + + + + tar.gz + + + + bin + + polardbx-rpl.standalone/bin + + + * + + + + + + target/classes/logback.xml + polardbx-rpl.standalone/conf + + + ../common/target/classes/config.properties + polardbx-rpl.standalone/conf + + + + + + false + compile + polardbx-rpl.standalone/lib + + com.alibaba.fastsql:fastsql + + + + diff --git a/polardbx-cdc-rpl/bin/tool.sh b/polardbx-cdc-rpl/bin/tool.sh new file mode 100755 index 00000000..e505a7e0 --- /dev/null +++ b/polardbx-cdc-rpl/bin/tool.sh @@ -0,0 +1,116 @@ +#!/bin/bash + +### ====================================================================== ### +## ## +## Polardbx-rpl Task Startup Script ## +## ## +### ====================================================================== ### +### 2020-08-08 by chengjin +### make some different + +echo "*****************************" +echo "params examples" +echo "clearPosition [serviceId]" +echo "start [serviceId]" +echo "stop [serviceId]" +echo "*****************************" + +OP=$1 +SERVICE_ID=$2 + +MEMORY=256 +PERM_MEMORY=128 +BASE_HOME=$HOME/polardbx-rpl.standalone + +#get param from 16th to end +JVM_PARAMS="" + +usage() { + echo "please set startup Args String" + exit 1 +} + +if [ $# -lt 1 ]; then + usage +fi + +if [ $(whoami) == "root" ]; then + echo DO NOT use root user to launch me. + exit 1 +fi + +export LD_LIBRARY_PATH=${BASE_HOME}/lib:${LD_LIBRARY_PATH} +export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK +export LANG=zh_CN.GB18030 + +if [ -f /home/admin/bin/jdk8.sh ]; then + sudo sh /home/admin/bin/jdk8.sh +fi + +if [[ ! "$JVM_PARAMS" =~ "PermSize" ]]; then + JAVA_OPTS="${JAVA_OPTS} -XX:PermSize=${PERM_MEMORY}m -XX:MaxPermSize=${PERM_MEMORY}m" +fi +#JAVA_OPTS="${JAVA_OPTS} -XX:NewSize=128m -XX:MaxNewSize=256m" +JAVA_OPTS="${JAVA_OPTS} -XX:+UseParallelGC" +JAVA_OPTS="${JAVA_OPTS} -XX:-UseAdaptiveSizePolicy -XX:SurvivorRatio=2 -XX:NewRatio=1 -XX:ParallelGCThreads=6" +JAVA_OPTS="${JAVA_OPTS} -XX:-OmitStackTraceInFastThrow" + +JAVA_OPTS="${JAVA_OPTS} -Djava.net.preferIPv4Stack=true" +JAVA_OPTS="${JAVA_OPTS} -XX:+PrintGCDetails" +JAVA_OPTS="${JAVA_OPTS} -XX:+PrintGCDateStamps" +JAVA_OPTS="${JAVA_OPTS} -XX:+DisableExplicitGC" +JAVA_OPTS="${JAVA_OPTS} -Dmemory=${MEMORY}" +JAVA_OPTS="${JAVA_OPTS} -Djava.util.prefs.systemRoot=${HOME}/.java -Djava.util.prefs.userRoot=${HOME}/.java/.userPrefs" +JAVA_OPTS="${JAVA_OPTS} -Ddaemon.home.dir=${BASE_HOME}" + +if [ -f /home/admin/env.properties ]; then + for line in `cat /home/admin/env.properties` + do + JAVA_OPTS="${JAVA_OPTS} -D$line" + done +fi + +if [ ! -d ${HOME}/.java ]; then + mkdir -p "${HOME}/.java" +fi + +if [ ! -d ${HOME}/.java/.userPrefs ]; then + mkdir -p "${HOME}/.java/.userPrefs" +fi + +if [ ! -d ${HOME}/.java/.systemPrefs ]; then + mkdir -p "${HOME}/.java/.systemPrefs" +fi + +JAVA_OPTS="${JAVA_OPTS} -XX:+HeapDumpOnOutOfMemoryError" +JAVA_OPTS="${JAVA_OPTS} ${JVM_PARAMS}" + +## set java path +TAOBAO_JAVA="/opt/taobao/java/bin/java" +ALIBABA_JAVA="/usr/alibaba/java/bin/java" +if [ -f $TAOBAO_JAVA ]; then + JAVA=$TAOBAO_JAVA +elif [ -f $ALIBABA_JAVA ]; then + JAVA=$ALIBABA_JAVA +else + JAVA=$(which java) + if [ ! -f $JAVA ]; then + echo "Cannot find a Java JDK. Please set either set JAVA or put java (>=1.7) in your PATH." 2>&2 + exit 1 + fi +fi + +#BUILDER IN classpath +CLASSPATH="" + +for jar in $(ls ${BASE_HOME}/lib/*.jar); do + CLASSPATH="${CLASSPATH}:""${jar}" +done + +#change user.dir to /home/admin +cd $HOME + +#Start Java Process +echo "${JAVA} ${JAVA_OPTS} -classpath ${CLASSPATH}:. com.aliyun.polardbx.RplTool "op=${OP} serviceId=${SERVICE_ID}" +${JAVA} ${JAVA_OPTS} -classpath ${CLASSPATH}:. com.aliyun.polardbx.RplTool "op=${OP} serviceId=${SERVICE_ID}" + diff --git a/polardbx-cdc-rpl/pom.xml b/polardbx-cdc-rpl/pom.xml new file mode 100644 index 00000000..dbc824d6 --- /dev/null +++ b/polardbx-cdc-rpl/pom.xml @@ -0,0 +1,121 @@ + + + + com.aliyun.polardbx + polardbx-cdc + 5.4.13-SNAPSHOT + ../pom.xml + + 4.0.0 + + polardbx-cdc-rpl + + + com.aliyun.polardbx + polardbx-cdc-canal + ${project.version} + compile + + + com.aliyun.polardbx + polardbx-cdc-task + ${project.version} + compile + + + junit + junit + 4.12 + test + + + org.powermock + powermock-api-mockito + 1.6.2 + test + + + org.powermock + powermock-module-junit4 + 1.6.2 + test + + + commons-configuration + commons-configuration + 1.8 + test + + + org.ini4j + ini4j + 0.5.4 + + + org.apache.commons + commons-math + 2.2 + + + com.squareup.okhttp3 + okhttp + 4.2.2 + + + com.aliyun.polardbx + polardbx-cdc-transfer + ${project.version} + test + + + commons-collections + commons-collections + 3.2.2 + compile + + + com.aliyun.polardbx + polardbx-cdc-canal + 5.4.13-SNAPSHOT + compile + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/RplTaskEngine.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/RplTaskEngine.java new file mode 100644 index 00000000..1a426eca --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/RplTaskEngine.java @@ -0,0 +1,69 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl; + +import com.aliyun.polardbx.binlog.SpringContextBootStrap; +import com.aliyun.polardbx.binlog.domain.po.RplTask; +import com.aliyun.polardbx.binlog.leader.RuntimeLeaderElector; +import com.aliyun.polardbx.rpl.common.CommonUtil; +import com.aliyun.polardbx.rpl.common.RplConstants; +import com.aliyun.polardbx.rpl.common.TaskBasedDiscriminator; +import com.aliyun.polardbx.rpl.taskmeta.DbTaskMetaManager; +import com.aliyun.polardbx.rpl.taskmeta.ServiceType; +import lombok.extern.slf4j.Slf4j; + +import java.util.Map; + +import static com.aliyun.polardbx.binlog.ConfigKeys.TASK_NAME; + +/** + * @author shicai.xsc 2020/11/27 11:28 + * @since 5.0.0.0 + */ +@Slf4j +public class RplTaskEngine { + + public static void main(String[] args) { + try { + Map argsMap = CommonUtil.handleArgs(args[0]); + String taskId = argsMap.get(RplConstants.TASK_ID); + String taskName = argsMap.get(RplConstants.TASK_NAME); + TaskBasedDiscriminator.put(RplConstants.TASK_ID, String.valueOf(taskId)); + TaskBasedDiscriminator.put(RplConstants.TASK_NAME, taskName); + System.setProperty(TASK_NAME, taskName); + + // spring context + log.info("Spring context booting"); + SpringContextBootStrap appContextBootStrap = new SpringContextBootStrap("spring/spring.xml"); + appContextBootStrap.boot(); + log.info("Spring context botted"); + + if (!RuntimeLeaderElector.isLeader("RplTaskEngine_" + taskId)) { + log.error("another process is already running, exit"); + return; + } + + RplTaskRunner taskRunner = new RplTaskRunner(Long.parseLong(taskId)); + taskRunner.start(); + + log.info("RplTaskEngine end"); + } catch (Throwable e) { + log.error("RplTaskEngine exit by exception", e); + } + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/RplTaskRunner.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/RplTaskRunner.java new file mode 100644 index 00000000..621805bf --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/RplTaskRunner.java @@ -0,0 +1,234 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl; + +import com.alibaba.fastjson.JSON; +import com.aliyun.polardbx.binlog.AddressUtil; +import com.aliyun.polardbx.binlog.canal.core.model.BinlogPosition; +import com.aliyun.polardbx.binlog.domain.po.RplService; +import com.aliyun.polardbx.binlog.domain.po.RplStateMachine; +import com.aliyun.polardbx.binlog.domain.po.RplTask; +import com.aliyun.polardbx.rpl.applier.BaseApplier; +import com.aliyun.polardbx.rpl.applier.MergeApplier; +import com.aliyun.polardbx.rpl.applier.MergeTransactionApplier; +import com.aliyun.polardbx.rpl.applier.MysqlApplier; +import com.aliyun.polardbx.rpl.applier.SplitApplier; +import com.aliyun.polardbx.rpl.applier.SplitTransactionApplier; +import com.aliyun.polardbx.rpl.applier.StatisticalProxy; +import com.aliyun.polardbx.rpl.applier.TransactionApplier; +import com.aliyun.polardbx.rpl.common.TaskContext; +import com.aliyun.polardbx.rpl.extractor.BaseExtractor; +import com.aliyun.polardbx.rpl.extractor.CanalBinlogExtractor; +import com.aliyun.polardbx.rpl.filter.BaseFilter; +import com.aliyun.polardbx.rpl.filter.ReplicateFilter; +import com.aliyun.polardbx.rpl.pipeline.BasePipeline; +import com.aliyun.polardbx.rpl.pipeline.SerialPipeline; +import com.aliyun.polardbx.rpl.taskmeta.ApplierConfig; +import com.aliyun.polardbx.rpl.taskmeta.ApplierType; +import com.aliyun.polardbx.rpl.taskmeta.DbTaskMetaManager; +import com.aliyun.polardbx.rpl.taskmeta.ExtractorConfig; +import com.aliyun.polardbx.rpl.taskmeta.ExtractorType; +import com.aliyun.polardbx.rpl.taskmeta.FSMMetaManager; +import com.aliyun.polardbx.rpl.taskmeta.FilterType; +import com.aliyun.polardbx.rpl.taskmeta.HostInfo; +import com.aliyun.polardbx.rpl.taskmeta.PipelineConfig; +import com.aliyun.polardbx.rpl.taskmeta.ReplicateMeta; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +/** + * @author shicai.xsc 2020/12/8 14:11 + * @since 5.0.0.0 + */ +@Data +@Slf4j +public class RplTaskRunner { + + private long taskId; + private RplTask task; + private BaseExtractor extractor; + private BasePipeline pipeline; + private BaseApplier applier; + private BaseFilter filter; + private String config; + private boolean enableStatistic = true; + + public RplTaskRunner(long taskId) { + this.taskId = taskId; + } + + public void start() { + try { + log.info("RplTaskEngine initializing"); + if (!init()) { + log.error("RplTaskRunner init failed"); + return; + } + log.info("RplTaskEngine initialized"); + + // start task + log.info("RplTaskEngine starting"); + pipeline.start(); + log.info("RplTaskRunner started"); + + // wait task done + while (!pipeline.checkDone()) { + Thread.sleep(1000); + } + + FSMMetaManager.setTaskFinish(taskId); + log.info("RplTaskRunner done"); + } catch (Throwable e) { + log.error("RplTaskRunner exited", e); + } + } + + public void stop() { + pipeline.stop(); + } + + private boolean init() { + try { + task = DbTaskMetaManager.getTask(taskId); + RplService service = DbTaskMetaManager.getService(task.getServiceId()); + RplStateMachine stateMachine = DbTaskMetaManager.getStateMachine(service.getStateMachineId()); + if (task == null || service == null || stateMachine == null) { + log.error("Has been deleted from db"); + System.exit(1); + } + config = stateMachine.getConfig(); + log.info("RplTaskRunner init, task id: {}", taskId); + + // do this before init applier and extractor + TaskContext context = TaskContext.getInstance(); + context.setService(service); + context.setTask(task); + context.setWorker(AddressUtil.getHostAddress().getHostAddress()); + context.setStateMachine(stateMachine); + context.setConfig(config); + ExtractorConfig extractorConfig = JSON.parseObject(task.getExtractorConfig(), ExtractorConfig.class); + + log.info("RplTaskRunner prepare filter"); + initFilter(); + log.info("RplTaskRunner prepare extractor"); + initExtractor(); + log.info("RplTaskRunner prepare applier"); + initApplier(); + log.info("RplTaskRunner prepare pipeline"); + initPipeline(); + StatisticalProxy.getInstance().init(pipeline, task.getPosition()); + extractor.setPipeline(pipeline); + + log.info("RplTaskRunner init all"); + return filter.init() && extractor.init() && pipeline.init() && applier.init(); + } catch (Throwable e) { + log.error("RplTaskRunner init failed", e); + return false; + } + } + + private void initIncExtractor(int extractorType) { + BinlogPosition binlogPosition = null; + if (StringUtils.isNotBlank(task.getPosition())) { + binlogPosition = BinlogPosition.parseFromString(task.getPosition()); + } + ApplierConfig applierConfig = JSON.parseObject(task.getApplierConfig(), ApplierConfig.class); + switch (ExtractorType.from(extractorType)) { + case RPL_INC: + ExtractorConfig extractorConfig = JSON.parseObject(task.getExtractorConfig(), ExtractorConfig.class); + extractor = new CanalBinlogExtractor(extractorConfig, + extractorConfig.getHostInfo(), + applierConfig.getHostInfo(), + binlogPosition, + filter); + break; + default: + break; + } + // if applier enabled transaction, the extractor should NOT filter + // TransactionEnd + ((CanalBinlogExtractor) extractor) + .setFilterTransactionEnd(applierConfig.getApplierType() != ApplierType.TRANSACTION.getValue()); + } + + private void initExtractor() { + ExtractorConfig config = JSON.parseObject(task.getExtractorConfig(), ExtractorConfig.class); + switch (ExtractorType.from(config.getExtractorType())) { + case RPL_INC: + initIncExtractor(config.getExtractorType()); + break; + default: + break; + } + + } + + private void initApplier() { + ApplierConfig config = JSON.parseObject(task.getApplierConfig(), ApplierConfig.class); + ExtractorConfig extractorConfig = JSON.parseObject(task.getExtractorConfig(), ExtractorConfig.class); + HostInfo hostInfo = config.getHostInfo(); + + switch (ApplierType.from(config.getApplierType())) { + case TRANSACTION: + applier = new TransactionApplier(config, hostInfo); + break; + case SERIAL: + applier = new MysqlApplier(config, hostInfo); + break; + case SPLIT: + applier = new SplitApplier(config, hostInfo); + break; + case SPLIT_TRANSACTION: + applier = new SplitTransactionApplier(config, hostInfo); + break; + case MERGE: + applier = new MergeApplier(config, hostInfo); + break; + case MERGE_TRANSACTION: + applier = new MergeTransactionApplier(config, hostInfo); + break; + default: + break; + } + if (applier instanceof MysqlApplier) { + ((MysqlApplier) applier).setSrcHostInfo(extractorConfig.getHostInfo()); + } + } + + private void initPipeline() { + PipelineConfig pipelineConfig = JSON.parseObject(task.getPipelineConfig(), PipelineConfig.class); + pipeline = new SerialPipeline(pipelineConfig, extractor, applier); + } + + private void initFilter() { + ExtractorConfig extractorConfig = JSON.parseObject(task.getExtractorConfig(), ExtractorConfig.class); + switch (FilterType.from(extractorConfig.getFilterType())) { + case RPL_FILTER: + ReplicateMeta replicateMeta = JSON.parseObject( + extractorConfig.getSourceToTargetConfig(), ReplicateMeta.class); + filter = new ReplicateFilter(replicateMeta); + break; + case NO_FILTER: + filter = new BaseFilter(); + break; + default: + break; + } + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/ApplyHelper.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/ApplyHelper.java new file mode 100644 index 00000000..2b0415af --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/ApplyHelper.java @@ -0,0 +1,638 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSColumn; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSEvent; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSRowChange; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultQueryLog; +import com.aliyun.polardbx.binlog.canal.core.ddl.parser.DdlResult; +import com.aliyun.polardbx.binlog.canal.core.ddl.parser.DruidDdlParser; +import com.aliyun.polardbx.rpl.common.DataSourceUtil; +import com.aliyun.polardbx.rpl.common.RplConstants; +import com.aliyun.polardbx.rpl.common.TaskContext; +import com.aliyun.polardbx.rpl.dbmeta.ColumnInfo; +import com.aliyun.polardbx.rpl.dbmeta.TableInfo; +import com.aliyun.polardbx.rpl.taskmeta.DbTaskMetaManager; +import com.aliyun.polardbx.rpl.taskmeta.DdlState; +import com.google.common.collect.Lists; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import javax.sql.DataSource; +import java.io.Serializable; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import static com.aliyun.polardbx.binlog.CommonUtils.escape; + +/** + * @author shicai.xsc 2020/12/1 21:09 + * @since 5.0.0.0 + */ +@Slf4j +@Data +public class ApplyHelper { + + private static final String INSERT_UPDATE_SQL = "INSERT INTO `%s`.`%s`(%s) VALUES (%s) ON DUPLICATE KEY UPDATE %s"; + private static final String BATCH_INSERT_SQL = "INSERT INTO `%s`.`%s`(%s) VALUES %s"; + private static final String REPLACE_SQL = "REPLACE INTO `%s`.`%s`(%s) VALUES %s"; + private static final String INSERT_IGNORE_SQL = "INSERT IGNORE INTO `%s`.`%s`(%s) VALUES %s"; + private static final String DELETE_SQL = "DELETE FROM `%s`.`%s` WHERE %s"; + private static final String UPDATE_SQL = "UPDATE `%s`.`%s` SET %s WHERE %s"; + private static final String SELECT_SQL = "SELECT * FROM `%s`.`%s` WHERE %s"; + private static final String IF_NOT_EXISTS = " IF NOT EXISTS "; + private static final String IF_EXISTS = " IF EXISTS "; + private static final String CREATE_TABLE = "CREATE TABLE"; + private static final String DROP_TABLE = "DROP TALBE"; + private static final String ASYNC_DDL_HINT = "/*+TDDL:cmd_extra(PURE_ASYNC_DDL_MODE=TRUE,TSO=%s)*/"; + private static final String DDL_HINT = "/*+TDDL:cmd_extra(TSO=%s)*/"; + private static final String SHOW_FULL_DDL = "SHOW FULL DDL"; + private static final String TSO_PATTERN = "TSO=%s)"; + private static final String DDL_STMT = "DDL_STMT"; + private static final String DDL_STATE = "STATE"; + private static final String DDL_STATE_PENDING = "PENDING"; + + public static boolean isDdl(DBMSEvent dbmsEvent) { + switch (dbmsEvent.getAction()) { + case CREATE: + case ERASE: + case ALTER: + case RENAME: + case TRUNCATE: + case CREATEDB: + case DROPDB: + case CINDEX: + case DINDEX: + return true; + default: + return false; + } + } + + public static boolean tranExecUpdate(DataSource dataSource, List sqlContexts) { + Connection conn = null; + List stmts = new ArrayList<>(); + SqlContext sqlContext = null; + + try { + conn = dataSource.getConnection(); + // start transaction + conn.setAutoCommit(false); + + for (int i = 0; i < sqlContexts.size(); i++) { + sqlContext = sqlContexts.get(i); + PreparedStatement stmt = conn.prepareStatement(sqlContext.getSql()); + stmts.add(stmt); + // set value + int j = 1; + for (Serializable dataValue : sqlContext.getParams()) { + stmt.setObject(j, dataValue); + j++; + } + // execute + stmt.executeUpdate(); + logExecUpdateDebug(sqlContext); + } + + // commit + conn.commit(); + return true; + } catch (Throwable e) { + logExecUpdateError(sqlContext, e); + try { + conn.rollback(); + } catch (Throwable e1) { + log.error("failed in tranExecUpdate, rollback failed", e1); + } + return false; + } finally { + for (PreparedStatement stmt : stmts) { + DataSourceUtil.closeQuery(null, stmt, null); + } + DataSourceUtil.closeQuery(null, null, conn); + } + } + + public static boolean execUpdate(DataSource dataSource, SqlContext sqlContext) { + Connection conn = null; + PreparedStatement stmt = null; + + try { + conn = dataSource.getConnection(); + stmt = conn.prepareStatement(sqlContext.getSql()); + + if (sqlContext.getParams() != null) { + // set value + int i = 1; + for (Serializable dataValue : sqlContext.getParams()) { + stmt.setObject(i, dataValue); + i++; + } + } + + // execute + stmt.executeUpdate(); + logExecUpdateDebug(sqlContext); + return true; + } catch (Throwable e) { + logExecUpdateError(sqlContext, e); + DbTaskMetaManager.updateTaskLastError(TaskContext.getInstance().getTaskId(), e.getMessage()); + return false; + } finally { + DataSourceUtil.closeQuery(null, stmt, conn); + } + } + + public static DdlState getAsyncDdlState(DataSource dataSource, String tso) throws Throwable { + Connection conn = null; + PreparedStatement stmt = null; + ResultSet rs = null; + + try { + conn = dataSource.getConnection(); + stmt = conn.prepareStatement(SHOW_FULL_DDL); + rs = stmt.executeQuery(SHOW_FULL_DDL); + while (rs.next()) { + String ddlStmt = rs.getString(DDL_STMT); + String tsoPattern = String.format(TSO_PATTERN, tso); + if (ddlStmt.contains(tsoPattern)) { + return rs.getString(DDL_STATE).contains(DDL_STATE_PENDING) ? DdlState.FAILED : DdlState.RUNNING; + } + } + // if ddl done, show full ddl will be empty + return DdlState.SUCCEED; + } catch (Throwable e) { + log.error("failed in getAsyncDdlState, tso: {}", tso, e); + throw e; + } finally { + DataSourceUtil.closeQuery(rs, stmt, conn); + } + } + + public static DdlSqlContext getDdlSqlExeContext(DefaultQueryLog queryLog, String tso) { + DdlSqlContext sqlContext = new DdlSqlContext(queryLog.getQuery(), "", new ArrayList<>()); + + String originSql = DdlHelper.getOriginSql(queryLog.getQuery()); + String sql = StringUtils.isBlank(originSql) ? queryLog.getQuery() : originSql; + // use actual schemaName + DdlResult result = DruidDdlParser.parse(sql, queryLog.getSchema()).get(0); + sqlContext.setSchema(result.getSchemaName()); + + switch (queryLog.getAction()) { + case CREATE: + case ERASE: + case ALTER: + case CINDEX: + case DINDEX: + case RENAME: + case TRUNCATE: + String hint = String.format(DDL_HINT, tso); + sqlContext.setSql(hint + sql); + break; + case CREATEDB: + case DROPDB: + sqlContext.setSchema(""); + break; + default: + break; + } + + return sqlContext; + } + + public static boolean isFiltered(String columnName) { + return StringUtils.equalsIgnoreCase(RplConstants.RDS_IMPLICIT_ID, columnName); + } + + + public static List getInsertUpdateSqlExecContext(DBMSRowChange rowChange, TableInfo dstTbInfo) { + List columns = rowChange.getColumns(); + + int rowCount = rowChange.getRowSize(); + List contexts = Lists.newArrayListWithCapacity(rowCount); + + for (int i = 1; i <= rowCount; i++) { + // INSERT INTO t1(column1, column2) VALUES(value1, value2) + StringBuilder nameSqlSb = new StringBuilder(); + StringBuilder valueSqlSb = new StringBuilder(); + StringBuilder updateSqlSb = new StringBuilder(); + List parmas = new ArrayList<>(); + + Iterator it = columns.iterator(); + while (it.hasNext()) { + DBMSColumn column = it.next(); + String repairedColumnName = repairDMLName(column.getName()); + if (isFiltered(column.getName())) { + nameSqlSb.setLength(nameSqlSb.length() - 1); + valueSqlSb.setLength(valueSqlSb.length() - 1); + updateSqlSb.setLength(updateSqlSb.length() - 1); + continue; + } + nameSqlSb.append(repairedColumnName); + valueSqlSb.append("?"); + // ON DUPLICATE KEY UPDATE + updateSqlSb.append(repairedColumnName).append("=?"); + if (it.hasNext()) { + nameSqlSb.append(","); + valueSqlSb.append(","); + updateSqlSb.append(","); + } + + Serializable columnValue = rowChange.getRowValue(i, column.getName()); + parmas.add(columnValue); + } + + parmas.addAll(parmas); + String insertSql = String + .format(INSERT_UPDATE_SQL, + dstTbInfo.getSchema(), + dstTbInfo.getName(), + nameSqlSb, + valueSqlSb, + updateSqlSb); + SqlContext context = new SqlContext(insertSql, dstTbInfo.getName(), parmas); + contexts.add(context); + } + + return contexts; + } + + public static List getDeleteThenInsertSqlExecContext(DBMSRowChange rowChange, TableInfo dstTbInfo) { + List columns = rowChange.getColumns(); + + int rowCount = rowChange.getRowSize(); + List contexts = Lists.newArrayListWithCapacity(rowCount); + + for (int i = 1; i <= rowCount; i++) { + // WHERE {column1} = {value1} AND {column2} = {value2} + if (!getWhereColumns(dstTbInfo).isEmpty()) { + StringBuilder whereSqlSb = new StringBuilder(); + List whereParams = new ArrayList<>(); + getWhereSql(rowChange, i, dstTbInfo, whereSqlSb, whereParams); + String deleteSql = String.format(DELETE_SQL, dstTbInfo.getSchema(), dstTbInfo.getName(), whereSqlSb); + SqlContext context1 = new SqlContext(deleteSql, dstTbInfo.getName(), whereParams); + contexts.add(context1); + } + + // INSERT INTO t1(column1, column2) VALUES(value1, value2) + StringBuilder nameSqlSb = new StringBuilder(); + StringBuilder valueSqlSb = new StringBuilder(); + List parmas = new ArrayList<>(); + + valueSqlSb.append("("); + Iterator it = columns.iterator(); + while (it.hasNext()) { + DBMSColumn column = it.next(); + if (isFiltered(column.getName())) { + nameSqlSb.setLength(nameSqlSb.length() - 1); + valueSqlSb.setLength(valueSqlSb.length() - 1); + continue; + } + String repairedColumnName = repairDMLName(column.getName()); + nameSqlSb.append(repairedColumnName); + valueSqlSb.append("?"); + // ON DUPLICATE KEY UPDATE + if (it.hasNext()) { + nameSqlSb.append(","); + valueSqlSb.append(","); + } + + Serializable columnValue = rowChange.getRowValue(i, column.getName()); + parmas.add(columnValue); + } + valueSqlSb.append(")"); + String insertSql = String + .format(BATCH_INSERT_SQL, + dstTbInfo.getSchema(), + dstTbInfo.getName(), + nameSqlSb, + valueSqlSb); + SqlContext context2 = new SqlContext(insertSql, dstTbInfo.getName(), parmas); + contexts.add(context2); + } + + return contexts; + } + + + public static MergeDmlSqlContext getMergeInsertUpdateSqlExecContext(DBMSRowChange rowChange, TableInfo dstTbInfo) { + List columns = rowChange.getColumns(); + + StringBuilder nameSqlSb = new StringBuilder(); + StringBuilder valueSqlSb = new StringBuilder(); + List parmas = new ArrayList<>(); + + for (int i = 1; i <= rowChange.getRowSize(); i++) { + // INSERT INTO t1(column1, column2) VALUES(value1, value2),(value3, value4) + // ON DUPLICATE KEY UPDATE column1=VALUES(column1),columns2=VALUES(column2) + if (i > 1) { + valueSqlSb.append(","); + } + valueSqlSb.append("("); + Iterator it = columns.iterator(); + while (it.hasNext()) { + DBMSColumn column = it.next(); + String repairedColumnName = repairDMLName(column.getName()); + if (isFiltered(column.getName())) { + if (i == 1) { + nameSqlSb.setLength(nameSqlSb.length() - 1); + } + valueSqlSb.setLength(valueSqlSb.length() - 1); + continue; + } + if (i == 1) { + nameSqlSb.append(repairedColumnName); + } + valueSqlSb.append("?"); + + if (it.hasNext()) { + if (i == 1) { + nameSqlSb.append(","); + } + valueSqlSb.append(","); + } + + Serializable columnValue = rowChange.getRowValue(i, column.getName()); + parmas.add(columnValue); + } + valueSqlSb.append(")"); + } + + String insertSql = String + .format(REPLACE_SQL, dstTbInfo.getSchema(), dstTbInfo.getName(), nameSqlSb, valueSqlSb); + return new MergeDmlSqlContext(insertSql, dstTbInfo.getName(), parmas); + } + + public static MergeDmlSqlContext getMergeInsertSqlExecContext(DBMSRowChange rowChange, TableInfo dstTbInfo, + int insertMode) { + List columns = rowChange.getColumns(); + StringBuilder nameSqlSb = new StringBuilder(); + StringBuilder valueSqlSb = new StringBuilder(); + List parmas = new ArrayList<>(); + for (int i = 1; i <= rowChange.getRowSize(); i++) { + // INSERT INTO t1(column1, column2) VALUES(value1, value2),(value3, value4) + // ON DUPLICATE KEY UPDATE column1=VALUES(column1),columns2=VALUES(column2) + if (i > 1) { + valueSqlSb.append(","); + } + valueSqlSb.append("("); + Iterator it = columns.iterator(); + while (it.hasNext()) { + DBMSColumn column = it.next(); + String repairedColumnName = repairDMLName(column.getName()); + if (isFiltered(column.getName())) { + if (i == 1) { + nameSqlSb.setLength(nameSqlSb.length() - 1); + } + valueSqlSb.setLength(valueSqlSb.length() - 1); + continue; + } + if (i == 1) { + nameSqlSb.append(repairedColumnName); + } + valueSqlSb.append("?"); + + if (it.hasNext()) { + if (i == 1) { + nameSqlSb.append(","); + } + valueSqlSb.append(","); + } + + Serializable columnValue = rowChange.getRowValue(i, column.getName()); + parmas.add(columnValue); + } + valueSqlSb.append(")"); + } + String sql = null; + switch (insertMode) { + case RplConstants.INSERT_MODE_SIMPLE_INSERT_OR_DELETE: + sql = BATCH_INSERT_SQL; + break; + case RplConstants.INSERT_MODE_INSERT_IGNORE: + sql = INSERT_IGNORE_SQL; + break; + case RplConstants.INSERT_MODE_REPLACE: + sql = REPLACE_SQL; + break; + default: + break; + } + String insertSql = String + .format(sql, dstTbInfo.getSchema(), dstTbInfo.getName(), nameSqlSb, valueSqlSb); + return new MergeDmlSqlContext(insertSql, dstTbInfo.getName(), parmas); + } + + public static List getDeleteSqlExecContext(DBMSRowChange rowChange, TableInfo dstTbInfo) { + // actually, only 1 row in a rowChange + int rowCount = rowChange.getRowSize(); + List contexts = Lists.newArrayListWithCapacity(rowCount); + + for (int i = 1; i <= rowCount; i++) { + // WHERE {column1} = {value1} AND {column2} = {value2} + StringBuilder whereSqlSb = new StringBuilder(); + List params = new ArrayList<>(); + getWhereSql(rowChange, i, dstTbInfo, whereSqlSb, params); + + String deleteSql = String.format(DELETE_SQL, dstTbInfo.getSchema(), dstTbInfo.getName(), whereSqlSb); + SqlContext context = new SqlContext(deleteSql, dstTbInfo.getName(), params); + contexts.add(context); + } + + return contexts; + } + + public static MergeDmlSqlContext getMergeDeleteSqlExecContext(DBMSRowChange rowChange, TableInfo dstTbInfo) { + StringBuilder whereSqlSb = new StringBuilder(); + List params = new ArrayList<>(); + getWhereInSql(rowChange, dstTbInfo, whereSqlSb, params); + String deleteSql = String.format(DELETE_SQL, dstTbInfo.getSchema(), dstTbInfo.getName(), whereSqlSb); + return new MergeDmlSqlContext(deleteSql, dstTbInfo.getName(), params); + } + + public static List getUpdateSqlExecContext(DBMSRowChange rowChange, TableInfo dstTbInfo) { + List changeColumns = rowChange.getChangeColumns(); + + int rowCount = rowChange.getRowSize(); + List contexts = Lists.newArrayListWithCapacity(rowCount); + + for (int i = 1; i <= rowCount; i++) { + // SET {column1} = {value1}, {column2} = {value2} + StringBuilder setSqlSb = new StringBuilder(); + List parmas = new ArrayList<>(); + + Iterator it = changeColumns.iterator(); + while (it.hasNext()) { + DBMSColumn changeColumn = it.next(); + String repairedColumnName = repairDMLName(changeColumn.getName()); + setSqlSb.append(repairedColumnName).append("=?"); + if (it.hasNext()) { + setSqlSb.append(","); + } + + Serializable changeColumnValue = rowChange.getChangeValue(i, changeColumn.getName()); + parmas.add(changeColumnValue); + } + + // WHERE {column1} = {value1} AND {column2} = {value2} + StringBuilder whereSqlSb = new StringBuilder(); + List whereColumnValues = new ArrayList<>(); + getWhereSql(rowChange, i, dstTbInfo, whereSqlSb, whereColumnValues); + + parmas.addAll(whereColumnValues); + String updateSql = String + .format(UPDATE_SQL, dstTbInfo.getSchema(), dstTbInfo.getName(), setSqlSb, whereSqlSb); + SqlContext context = new SqlContext(updateSql, dstTbInfo.getName(), parmas); + contexts.add(context); + } + + return contexts; + } + + public static List getWhereColumns(TableInfo tableInfo) { + List whereColumns = new ArrayList<>(); + if (tableInfo.getPks().size() > 0) { + whereColumns.addAll(tableInfo.getPks()); + } else { + whereColumns.addAll(tableInfo.getUks()); + } + + // 无主键表 + if (whereColumns.isEmpty()) { + for (ColumnInfo column: tableInfo.getColumns()) { + whereColumns.add(column.getName()); + } + return whereColumns; + } + + // add shard key to where sql if exists + if (StringUtils.isNotBlank(tableInfo.getDbShardKey()) && !whereColumns.contains(tableInfo.getDbShardKey())) { + whereColumns.add(tableInfo.getDbShardKey()); + } + if (StringUtils.isNotBlank(tableInfo.getTbShardKey()) && !whereColumns.contains(tableInfo.getTbShardKey())) { + whereColumns.add(tableInfo.getTbShardKey()); + } + + return whereColumns; + } + + public static List getIdentifyColumns(TableInfo tableInfo) { + List identifyColumns = getWhereColumns(tableInfo); + if (tableInfo.getPks().size() > 0) { + identifyColumns.addAll(tableInfo.getUks()); + } + return identifyColumns; + } + + private static void getWhereSql(DBMSRowChange rowChange, int rowIndex, TableInfo tableInfo, + StringBuilder whereSqlSb, + List whereColumnValues) { + List whereColumns = getWhereColumns(tableInfo); + + for (int i = 0; i < whereColumns.size(); i++) { + String columnName = whereColumns.get(i); + + // build where sql + Serializable whereColumnValue = rowChange.getRowValue(rowIndex, columnName); + String repairedName = repairDMLName(columnName); + if (whereColumnValue == null) { + // _drds_implicit_id_ should never be null + whereSqlSb.append(repairedName).append(" IS NULL "); + } else { + whereSqlSb.append(repairedName).append("=?"); + } + + if (i < whereColumns.size() - 1) { + whereSqlSb.append(" AND "); + } + + // fill in where column values + if (whereColumnValue != null) { + whereColumnValues.add(whereColumnValue); + } + } + } + + private static void getWhereInSql(DBMSRowChange rowChange, TableInfo tableInfo, StringBuilder whereSqlSb, + List whereColumnValues) { + List whereColumns = getWhereColumns(tableInfo); + + // WHERE (column1, column2) in + whereSqlSb.append("("); + for (int i = 0; i < whereColumns.size(); i++) { + String columnName = whereColumns.get(i); + String repairedName = repairDMLName(columnName); + whereSqlSb.append(repairedName); + if (i < whereColumns.size() - 1) { + whereSqlSb.append(","); + } + } + whereSqlSb.append(")"); + whereSqlSb.append(" in "); + + // ((column1_value1, column2_value1), (column1_value2, column2_value2)) + whereSqlSb.append("("); + for (int i = 1; i <= rowChange.getRowSize(); i++) { + whereSqlSb.append("("); + for (int j = 0; j < whereColumns.size(); j++) { + whereSqlSb.append("?"); + if (j < whereColumns.size() - 1) { + whereSqlSb.append(","); + } + String columnName = whereColumns.get(j); + whereColumnValues.add(rowChange.getRowValue(i, columnName)); + } + whereSqlSb.append(")"); + if (i < rowChange.getRowSize()) { + whereSqlSb.append(","); + } + } + whereSqlSb.append(")"); + } + + private static void logExecUpdateError(SqlContext sqlContext, Throwable e) { + StringBuilder sb = new StringBuilder(); + log.error("failed in execUpdate, sql: {}, params: {}", sqlContext.getSql(), sb, e); + } + + private static void logExecUpdateDebug(SqlContext sqlContext) { + if (!log.isDebugEnabled()) { + return; + } + + StringBuilder sb = new StringBuilder(); + for (Serializable p : sqlContext.getParams()) { + if (p == null) { + sb.append("null-value").append(RplConstants.COMMA); + } else { + sb.append(p).append(RplConstants.COMMA); + } + } + log.info("execUpdate, sql: {}, params: {}", sqlContext.getSql(), sb); + } + + private static String repairDMLName(String name) { + return "`" + escape(name) + "`"; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/BaseApplier.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/BaseApplier.java new file mode 100644 index 00000000..e9f491d2 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/BaseApplier.java @@ -0,0 +1,71 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSEvent; +import com.aliyun.polardbx.rpl.common.LogUtil; +import com.aliyun.polardbx.rpl.common.RplConstants; +import com.aliyun.polardbx.rpl.taskmeta.ApplierConfig; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author shicai.xsc 2021/2/18 21:45 + * @since 5.0.0.0 + */ +@Data +@Slf4j +public class BaseApplier { + + protected ApplierConfig applierConfig; + + protected boolean skipAllException; + + public BaseApplier(ApplierConfig applierConfig) { + this.applierConfig = applierConfig; + } + + public boolean init() { + return true; + } + + public boolean apply(List dbmsEvents) { + return true; + } + + public boolean tranApply(List transactions) { + return true; + } + + public void logCommitInfo(List dbmsEvents) { + List logs = new ArrayList<>(); + if (applierConfig.getLogCommitLevel() == RplConstants.LOG_ALL_COMMIT) { + for (DBMSEvent event : dbmsEvents) { + logs.addAll(LogUtil.generateCommitLog(event, null)); + } + } else if (dbmsEvents.size() > 0 && applierConfig.getLogCommitLevel() == RplConstants.LOG_END_COMMIT) { + logs.addAll(LogUtil.generateCommitLog(dbmsEvents.get(dbmsEvents.size() - 1), null)); + } + + LogUtil.writeBatchLogs(logs, LogUtil.getCommitLogger()); + } + +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/DdlHelper.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/DdlHelper.java new file mode 100644 index 00000000..5434ea7a --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/DdlHelper.java @@ -0,0 +1,191 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import com.alibaba.polardbx.druid.sql.SQLUtils; +import com.alibaba.polardbx.druid.sql.ast.SQLStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableAddConstraint; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableAddIndex; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableDropConstraint; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableDropIndex; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableDropKey; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableItem; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableRename; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLColumnDefinition; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLCreateIndexStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLCreateTableStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLDropIndexStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLDropTableStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLExprTableSource; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLSelectOrderByItem; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLTableElement; +import com.alibaba.polardbx.druid.sql.dialect.mysql.ast.MySqlPrimaryKey; +import com.alibaba.polardbx.druid.util.JdbcConstants; +import com.aliyun.polardbx.binlog.domain.po.RplDdl; +import com.aliyun.polardbx.rpl.common.RplConstants; +import com.aliyun.polardbx.rpl.common.TaskContext; +import com.aliyun.polardbx.rpl.dbmeta.DbMetaCache; +import com.aliyun.polardbx.rpl.dbmeta.TableInfo; +import com.aliyun.polardbx.rpl.taskmeta.DbTaskMetaManager; +import com.aliyun.polardbx.rpl.taskmeta.DdlState; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import java.sql.Timestamp; +import java.util.Iterator; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author shicai.xsc 2021/4/5 23:22 + * @since 5.0.0.0 + */ +@Slf4j +public class DdlHelper { + + private static Pattern tsoPattern = Pattern.compile("/\\*TSO=([\\W\\w]+)\\*/"); + private static Pattern originSqlPattern = Pattern.compile("/\\*POLARX_ORIGIN_SQL=([\\W\\w]+)\\*/[\\W\\w]+/*TSO"); + + public static boolean checkDdlDone(String sql, String schema, DbMetaCache dbMetaCache) { + try { + + List stmtList = SQLUtils.parseStatements(sql, JdbcConstants.MYSQL, false); + for (SQLStatement statement : stmtList) { + if (statement instanceof SQLCreateTableStatement) { + SQLCreateTableStatement createTable = (SQLCreateTableStatement) statement; + schema = StringUtils.isBlank(createTable.getSchema()) ? schema : createTable.getSchema(); + return dbMetaCache.getTables(schema).contains(createTable.getTableName()); + } else if (statement instanceof SQLDropTableStatement) { + SQLDropTableStatement dropTable = (SQLDropTableStatement) statement; + for (SQLExprTableSource tableSource : dropTable.getTableSources()) { + schema = StringUtils.isBlank(tableSource.getSchema()) ? schema : tableSource.getSchema(); + if (dbMetaCache.getTables(schema).contains(tableSource.getTableName())) { + return false; + } + } + return true; + } else if (statement instanceof SQLCreateIndexStatement) { + SQLCreateIndexStatement createIndex = (SQLCreateIndexStatement) statement; + TableInfo tableInfo = dbMetaCache.getTableInfo(createIndex.getSchema(), createIndex.getTableName()); + SQLCreateTableStatement createTable = (SQLCreateTableStatement) SQLUtils + .parseSingleMysqlStatement(tableInfo.getCreateTable()); + for (SQLSelectOrderByItem item : createIndex.getItems()) { + + } + } else if (statement instanceof SQLDropIndexStatement) { + SQLDropIndexStatement dropIndex = (SQLDropIndexStatement) statement; + dropIndex.getIndexName(); + } else if (statement instanceof SQLAlterTableStatement) { + SQLAlterTableStatement alterTable = (SQLAlterTableStatement) statement; + for (SQLAlterTableItem item : alterTable.getItems()) { + if (item instanceof SQLAlterTableRename) { + } else if (item instanceof SQLAlterTableAddIndex) { + + } else if (item instanceof SQLAlterTableDropIndex || item instanceof SQLAlterTableDropKey) { + + } else if (item instanceof SQLAlterTableAddConstraint) { + + } else if (item instanceof SQLAlterTableDropConstraint) { + + } else { + + } + } + } + } + } catch (Throwable e) { + } + + return true; + } + + public static String getTso(String sql, Timestamp timestamp, String pos) { + Matcher matcher = tsoPattern.matcher(sql); + if (matcher.find()) { + return matcher.group(1); + } + return String.valueOf(sql.hashCode()) + timestamp.hashCode() + pos.hashCode(); + } + + public static String getOriginSql(String sql) { + Matcher matcher = originSqlPattern.matcher(sql); + if (!matcher.find()) { + return ""; + } + + String originSql = matcher.group(1); + List stmtList = SQLUtils.parseStatements(originSql, JdbcConstants.MYSQL, false); + SQLStatement statement = stmtList.get(0); + if (!(statement instanceof SQLCreateTableStatement)) { + return originSql; + } + + // remove _drds_implicit_id_ + SQLCreateTableStatement createTable = (SQLCreateTableStatement) statement; + Iterator iter = createTable.getTableElementList().iterator(); + while (iter.hasNext()) { + SQLTableElement cur = iter.next(); + if (cur instanceof SQLColumnDefinition) { + SQLColumnDefinition column = (SQLColumnDefinition) cur; + if (StringUtils.equalsIgnoreCase(column.getColumnName(), RplConstants.POLARX_IMPLICIT_ID) + || StringUtils.equalsIgnoreCase(column.getColumnName(), RplConstants.RDS_IMPLICIT_ID)) { + iter.remove(); + } + } + + // remove rds/_drds_implicit_id_ primary key + if (cur instanceof MySqlPrimaryKey) { + MySqlPrimaryKey pk = (MySqlPrimaryKey) cur; + String columnName = pk.getColumns().get(0).getExpr().toString(); + if (StringUtils.equalsIgnoreCase(columnName, RplConstants.POLARX_IMPLICIT_ID) + || StringUtils.equalsIgnoreCase(columnName, RplConstants.RDS_IMPLICIT_ID)) { + iter.remove(); + } + } + } + + return createTable.toString(); + } + + public static boolean getDdlLock(String ddlTso, String sql) { + // get ddl lock + RplDdl existDdl = DbTaskMetaManager.getDdl(ddlTso); + if (existDdl == null) { + try { + // record ddl in DB + RplDdl ddl = new RplDdl(); + ddl.setDdlTso(ddlTso); + ddl.setStateMachineId(TaskContext.getInstance().getStateMachineId()); + ddl.setServiceId(TaskContext.getInstance().getServiceId()); + ddl.setTaskId(TaskContext.getInstance().getTaskId()); + ddl.setJobId(0L); + ddl.setState(DdlState.NOT_START.getValue()); + ddl.setDdlStmt(sql); + DbTaskMetaManager.addDdl(ddl); + return true; + } catch (Throwable e) { + log.error("failed to get ddl lock", e); + return false; + } + } else { + return TaskContext.getInstance().getTaskId() == existDdl.getTaskId(); + } + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/DdlSqlContext.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/DdlSqlContext.java new file mode 100644 index 00000000..5bf4bca2 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/DdlSqlContext.java @@ -0,0 +1,37 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import java.io.Serializable; +import java.util.List; + +import lombok.Data; + +/** + * @author shicai.xsc 2021/4/16 17:40 + * @since 5.0.0.0 + */ +@Data +public class DdlSqlContext extends SqlContext { + + private String schema; + + public DdlSqlContext(String sql, String dstTable, List params) { + super(sql, dstTable, params); + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/FlowLimiter.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/FlowLimiter.java new file mode 100644 index 00000000..45d07354 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/FlowLimiter.java @@ -0,0 +1,28 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSEvent; + +import java.util.List; + +public interface FlowLimiter { + boolean runTask(List events); + + boolean runTranTask(List transactions); +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/MergeApplier.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/MergeApplier.java new file mode 100644 index 00000000..e1704d93 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/MergeApplier.java @@ -0,0 +1,225 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSAction; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSEvent; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultRowChange; +import com.aliyun.polardbx.rpl.common.NamedThreadFactory; +import com.aliyun.polardbx.rpl.common.RplConstants; +import com.aliyun.polardbx.rpl.common.ThreadPoolUtil; +import com.aliyun.polardbx.rpl.taskmeta.ApplierConfig; +import com.aliyun.polardbx.rpl.taskmeta.HostInfo; +import lombok.extern.slf4j.Slf4j; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +/** + * @author shicai.xsc 2021/5/17 20:52 + * @since 5.0.0.0 + */ +@Slf4j +public class MergeApplier extends MergeTransactionApplier { + + ExecutorService mergeAndTranExecutorService; + MergeTransactionApplier mergeTransactionApplier; + + public MergeApplier(ApplierConfig applierConfig, HostInfo hostInfo) { + super(applierConfig, hostInfo); + } + + @Override + public boolean init() { + super.init(); + mergeTransactionApplier = new MergeTransactionApplier(applierConfig, hostInfo); + mergeTransactionApplier.init(); + mergeTransactionApplier.dbMetaCache = dbMetaCache; + mergeAndTranExecutorService = ThreadPoolUtil.createExecutorWithFixedNum(2, "MergeApplier"); + return true; + } + + @Override + protected boolean dmlApply(List dbmsEvents) throws Throwable { + if (dbmsEvents == null || dbmsEvents.size() == 0) { + return true; + } + + // Map> + Map> insertRowChanges = new HashMap<>(); + Map> deleteRowChanges = new HashMap<>(); + Map lastRowChanges = new HashMap<>(); + Set changedIdentifyColumnTables = new HashSet<>(); + mergeByTable(dbmsEvents, insertRowChanges, deleteRowChanges, lastRowChanges, changedIdentifyColumnTables); + + // 考虑如下情况: + // 某表 a.a,既有 uk 又有 pk: create table a.a (f0 int, f1 int, f2 int, primary key(f0), unique key uk(f1)); + // 在执行过程中,任务发生了重启。 + + // 已经记录的位点 A + // A.1 insert (1, 1, 1),当前: (1, 1, 1) + // A.2 insert (2, 2, 2),当前: (1, 1, 1), (2, 2, 2) + // A.3 update (1, 1, 1) to (1, 3, 1), 当前: (1, 3, 1), (2, 2, 2) + // A.4 update (2, 2, 2) to (2, 1, 2), 当前: (1, 3, 1), (2, 1, 2) + // 实际执行完的地方 B + + // 任务重启后,从 A 开始接收数据,第一批收到数据可能为 A.1 而不是 A-B 之间所有数据。 + // 此时生成 sql: insert (1, 1, 1) on duplicate key update, + // 则此 sql 无法写入目标表,会发生 uk(f1) 冲突。 + + // 故对于涉及到 pk/uk/shard key 变更的 events,需将此一批 events 执行完成后,记录其真实位点 B。 + // 如果任务发生故障重启,需将 A-B 之间的所有数据略过。 + + // 在 MergeApplier 中,同一张表的 events 也是按照 applierConfig.mergeBatchSize 进行拆分,然后并行, + // 可能发生 A-B 之间的 events 一部分已经执行完毕,一部分还未执行。 + // 故无法准确记录某表已经执行过的所有 events 的位点 B。 + // 针对此情况,这里做一个 pk/uk/shard key 变更检测,一旦发现某张表更改了这些字段,就使用 MergeTransactionApplier。 + // MergeTransactionApplier 以事务的方式执行 A-B 之间的 events,并在执行完成后记录位点 B。 + Map> tranInsertRowChanges = new HashMap<>(); + Map> tranDeleteRowChanges = new HashMap<>(); + for (String fullTbName : changedIdentifyColumnTables) { + tranInsertRowChanges.put(fullTbName, insertRowChanges.get(fullTbName)); + tranDeleteRowChanges.put(fullTbName, deleteRowChanges.get(fullTbName)); + insertRowChanges.remove(fullTbName); + deleteRowChanges.remove(fullTbName); + log.info("{} changes will be executed by MergeTransactionApplier", fullTbName); + } + + if (tranInsertRowChanges.size() == 0 && tranDeleteRowChanges.size() == 0) { + return parallelExecSqlContexts(deleteRowChanges, DBMSAction.DELETE) + && parallelExecSqlContexts(insertRowChanges, DBMSAction.INSERT); + } + + // mergeTransactionApplier 和 mergeApplier 并行 + List futures = new ArrayList<>(); + Callable tranTask = () -> { + try { + return mergeTransactionApplier + .parallelExecSqlContexts(tranInsertRowChanges, tranDeleteRowChanges, lastRowChanges); + } catch (Throwable e) { + log.error("mergeTransactionApplier parallelExecSqlContexts failed: " + e); + return false; + } + }; + Callable task = () -> { + try { + return parallelExecSqlContexts(deleteRowChanges, DBMSAction.DELETE) + && parallelExecSqlContexts(insertRowChanges, DBMSAction.INSERT); + } catch (Throwable e) { + log.error("mergeApplier parallelExecSqlContexts failed: " + e); + return false; + } + }; + futures.add(mergeAndTranExecutorService.submit(() -> tranTask.call())); + futures.add(mergeAndTranExecutorService.submit(() -> task.call())); + + // get result + boolean res = true; + for (Future future : futures) { + res &= (Boolean) future.get(); + } + + return res; + } + + private boolean parallelExecSqlContexts(Map> allRowChanges, + DBMSAction action) throws Throwable { + List mergeDmlSqlContexts = new ArrayList<>(); + + for (String tbName : allRowChanges.keySet()) { + Collection tbRowChanges = allRowChanges.get(tbName).values(); + if (tbRowChanges.size() == 0) { + continue; + } + + // merge + List sqlContexts = getMergeDmlSqlContexts(tbRowChanges, + RplConstants.INSERT_MODE_SIMPLE_INSERT_OR_DELETE); + mergeDmlSqlContexts.addAll(sqlContexts); + } + + boolean res = true; + List futures = new ArrayList<>(); + + // parallel execute, each table cost a thread + for (MergeDmlSqlContext sqlContext : mergeDmlSqlContexts) { + Callable task = () -> { + boolean succeed = execSqlContexts(Arrays.asList(sqlContext)); + sqlContext.setSucceed(succeed); + return succeed; + }; + futures.add(executorService.submit(() -> task.call())); + // record merge size + StatisticalProxy.getInstance().addMergeBatchSize(sqlContext.getOriginRowChanges().size()); + } + + // get result + for (Future future : futures) { + res &= (Boolean) future.get(); + } + + // return res; + + if (res) { + return res; + } + + // for those failed sqlContext, excute the originRowChanges with the sql to be + // INSERT ON DUPLICATE UPDATE + futures.clear(); + res = true; + for (final MergeDmlSqlContext sqlContext : mergeDmlSqlContexts) { + if (sqlContext.isSucceed()) { + continue; + } + + log.error("merge execute failed for: {}, action: {}, try serial execute", + sqlContext.getDstTable(), + action.name()); + + for (DefaultRowChange rowChange : sqlContext.getOriginRowChanges()) { + final Callable task = () -> { + List newSqlContexts = getSqlContexts(rowChange, sqlContext.getDstTable()); + // execute + return newSqlContexts == null ? false : execSqlContexts(newSqlContexts); + }; + futures.add(executorService.submit(() -> task.call())); + } + } + + for (Future future : futures) { + res &= (Boolean) future.get(); + } + + if (!res) { + log.error("single execute failed"); + } + + return res; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/MergeDmlSqlContext.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/MergeDmlSqlContext.java new file mode 100644 index 00000000..dc4f8055 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/MergeDmlSqlContext.java @@ -0,0 +1,38 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultRowChange; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author shicai.xsc 2021/4/30 19:26 + * @since 5.0.0.0 + */ +@Data +public class MergeDmlSqlContext extends SqlContext { + protected boolean succeed; + protected List originRowChanges; + + public MergeDmlSqlContext(String sql, String dstTable, List params) { + super(sql, dstTable, params); + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/MergeTransactionApplier.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/MergeTransactionApplier.java new file mode 100644 index 00000000..cd0220a5 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/MergeTransactionApplier.java @@ -0,0 +1,325 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSAction; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSEvent; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSRowData; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultRowChange; +import com.aliyun.polardbx.rpl.common.RplConstants; +import com.aliyun.polardbx.rpl.dbmeta.TableInfo; +import com.aliyun.polardbx.rpl.taskmeta.ApplierConfig; +import com.aliyun.polardbx.rpl.taskmeta.HostInfo; +import lombok.extern.slf4j.Slf4j; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Callable; +import java.util.concurrent.Future; + +/** + * @author shicai.xsc 2021/5/19 19:56 + * @since 5.0.0.0 + */ +@Slf4j +public class MergeTransactionApplier extends MysqlApplier { + public MergeTransactionApplier(ApplierConfig applierConfig, HostInfo hostInfo) { + super(applierConfig, hostInfo); + } + + @Override + protected boolean dmlApply(List dbmsEvents) throws Throwable { + if (dbmsEvents == null || dbmsEvents.size() == 0) { + return true; + } + + // Map> + Map> insertRowChanges = new HashMap<>(); + Map> deleteRowChanges = new HashMap<>(); + Map lastRowChanes = new HashMap<>(); + mergeByTable(dbmsEvents, insertRowChanges, deleteRowChanges, lastRowChanes, null); + + // execute delete + return parallelExecSqlContexts(insertRowChanges, deleteRowChanges, lastRowChanes); + } + + protected void mergeByTable(List dbmsEvents, + Map> insertRowChanges, + Map> deleteRowChanges, + Map lastRowChanges, + Set changedIdentifyColumnTables) throws Throwable { + Map> allTbIdentifyColumns = new HashMap<>(); + + for (DBMSEvent event : dbmsEvents) { + DefaultRowChange rowChange = (DefaultRowChange) event; + String fullTbName = rowChange.getSchema() + "." + rowChange.getTable(); + + // filter + if (filterCommitedEvent(fullTbName, rowChange)) { + continue; + } + + // get identify columns + List identifyColumns = getIdentifyColumns(allTbIdentifyColumns, fullTbName, rowChange); + + if (!insertRowChanges.containsKey(fullTbName)) { + insertRowChanges.put(fullTbName, new HashMap<>()); + } + if (!deleteRowChanges.containsKey(fullTbName)) { + deleteRowChanges.put(fullTbName, new HashMap<>()); + } + + mergeTableRowChanges(rowChange, + identifyColumns, + insertRowChanges.get(fullTbName), + deleteRowChanges.get(fullTbName)); + + lastRowChanges.put(fullTbName, rowChange); + + // find out events which changed where columns of a table + if (changedIdentifyColumnTables != null + && !changedIdentifyColumnTables.contains(fullTbName) + && rowChange.getAction() == DBMSAction.UPDATE) { + for (Integer column : identifyColumns) { + if (rowChange.hasChangeColumn(column)) { + changedIdentifyColumnTables.add(fullTbName); + break; + } + } + } + } + } + + private void mergeTableRowChanges(DefaultRowChange rowChange, List identifyColumns, + Map insertRowChanges, + Map deleteRowChanges) { + RowKey key = new RowKey(rowChange, identifyColumns); + switch (rowChange.getAction()) { + case INSERT: + insertRowChanges.put(key, rowChange); + break; + case UPDATE: + DefaultRowChange beforeRowChange = new DefaultRowChange(); + beforeRowChange.setDataSet(rowChange.getDataSet()); + beforeRowChange.setAction(DBMSAction.DELETE); + beforeRowChange.setSchema(rowChange.getSchema()); + beforeRowChange.setTable(rowChange.getTable()); + beforeRowChange.setColumnSet(rowChange.getColumnSet()); + + DefaultRowChange afterRowChange = new DefaultRowChange(); + afterRowChange.setDataSet(rowChange.getChangeDataSet()); + afterRowChange.setAction(DBMSAction.INSERT); + afterRowChange.setSchema(rowChange.getSchema()); + afterRowChange.setTable(rowChange.getTable()); + afterRowChange.setColumnSet(rowChange.getColumnSet()); + + if (insertRowChanges.containsKey(key)) { + insertRowChanges.remove(key); + } + deleteRowChanges.put(key, beforeRowChange); + + RowKey afterKey = new RowKey(afterRowChange, identifyColumns); + insertRowChanges.put(afterKey, afterRowChange); + break; + case DELETE: + if (insertRowChanges.containsKey(key)) { + insertRowChanges.remove(key); + } + deleteRowChanges.put(key, rowChange); + break; + default: + break; + } + } + + protected boolean parallelExecSqlContexts(Map> insertRowChanges, + Map> deleteRowChanges, + Map lastRowChanes) + throws Throwable { + Set allTbNames = new HashSet<>(); + for (String tbName : insertRowChanges.keySet()) { + allTbNames.add(tbName); + } + for (String table : deleteRowChanges.keySet()) { + allTbNames.add(table); + } + + boolean res = true; + List futures = new ArrayList<>(); + + Map> allTbMergeDmlSqlContexts = new HashMap<>(); + for (String tbName : allTbNames) { + List mergeDmlSqlContexts = new ArrayList<>(); + + // execute delete first + if (deleteRowChanges.containsKey(tbName)) { + List sqlContexts = getMergeDmlSqlContexts(deleteRowChanges.get(tbName).values(), + RplConstants.INSERT_MODE_SIMPLE_INSERT_OR_DELETE); + mergeDmlSqlContexts.addAll(sqlContexts); + } + + if (insertRowChanges.containsKey(tbName)) { + List sqlContexts = getMergeDmlSqlContexts(insertRowChanges.get(tbName).values(), + RplConstants.INSERT_MODE_SIMPLE_INSERT_OR_DELETE); + mergeDmlSqlContexts.addAll(sqlContexts); + } + + if (mergeDmlSqlContexts.size() == 0) { + continue; + } + allTbMergeDmlSqlContexts.put(tbName, mergeDmlSqlContexts); + + // submit task + Callable task = () -> { + List sqlContexts = new ArrayList<>(); + for (MergeDmlSqlContext sqlContext : mergeDmlSqlContexts) { + sqlContexts.add(sqlContext); + } + + boolean succeed = tranExecSqlContexts(sqlContexts); + if (succeed) { + recordTablePosition(tbName, lastRowChanes.get(tbName)); + } + mergeDmlSqlContexts.get(0).setSucceed(succeed); + return succeed; + }; + futures.add(executorService.submit(() -> task.call())); + + // record merge size + for (int i = 0; i < mergeDmlSqlContexts.size(); i++) { + StatisticalProxy.getInstance() + .addMergeBatchSize(mergeDmlSqlContexts.get(i).getOriginRowChanges().size()); + } + } + + // get result + for (Future future : futures) { + res &= (Boolean) future.get(); + } + + if (res) { + return res; + } + + // for those failed sqlContext, excute the originRowChanges with the sql to be + // INSERT ON DUPLICATE UPDATE + futures.clear(); + res = true; + + for (String tbName : allTbMergeDmlSqlContexts.keySet()) { + List tbMergeDmlSqlContexts = allTbMergeDmlSqlContexts.get(tbName); + if (tbMergeDmlSqlContexts.get(0).isSucceed()) { + continue; + } + + List tbSqlContexts = new ArrayList<>(); + for (MergeDmlSqlContext mergeDmlSqlContext : tbMergeDmlSqlContexts) { + log.error("merge execute failed for: {}, try serial execute", + mergeDmlSqlContext.getDstTable()); + for (DefaultRowChange rowChange : mergeDmlSqlContext.getOriginRowChanges()) { + List sqlContexts = getSqlContexts(rowChange, mergeDmlSqlContext.getDstTable()); + tbSqlContexts.addAll(sqlContexts); + } + } + + final Callable task = () -> { + // execute + boolean succeed; + if (skipAllException) { + succeed = execSqlContexts(tbSqlContexts); + } else { + succeed = tranExecSqlContexts(tbSqlContexts); + } + if (succeed) { + recordTablePosition(tbName, lastRowChanes.get(tbName)); + } + return succeed; + + }; + futures.add(executorService.submit(() -> task.call())); + } + + for (Future future : futures) { + res &= (Boolean) future.get(); + } + + if (!res) { + log.error("single execute failed"); + } + + return res; + } + + protected List getMergeDmlSqlContexts(Collection rowChanges, int insertMode) + throws Throwable { + List mergeDmlSqlContexts = new ArrayList<>(); + + Iterator iterator = rowChanges.iterator(); + int count = 0; + + while (iterator.hasNext()) { + DefaultRowChange mergedRowChange = new DefaultRowChange(); + DefaultRowChange firstRowChange = iterator.next(); + mergedRowChange.setAction(firstRowChange.getAction()); + mergedRowChange.setSchema(firstRowChange.getSchema()); + mergedRowChange.setTable(firstRowChange.getTable()); + mergedRowChange.setColumnSet(firstRowChange.getColumnSet()); + List dataSet = new ArrayList<>(); + dataSet.addAll(firstRowChange.getDataSet()); + mergedRowChange.setDataSet(dataSet); + + List originRowChanges = new ArrayList<>(); + originRowChanges.add(firstRowChange); + + while (iterator.hasNext() && count <= applierConfig.getMergeBatchSize()) { + DefaultRowChange rowChange = iterator.next(); + mergedRowChange.addRowData(rowChange.getRowData(1)); + originRowChanges.add(rowChange); + count++; + } + + // get MergeDmlSqlContext + MergeDmlSqlContext sqlContext = null; + TableInfo dstTbInfo = dbMetaCache.getTableInfo(mergedRowChange.getSchema(), mergedRowChange.getTable()); + switch (mergedRowChange.getAction()) { + case DELETE: + sqlContext = ApplyHelper.getMergeDeleteSqlExecContext(mergedRowChange, dstTbInfo); + break; + case INSERT: + sqlContext = ApplyHelper.getMergeInsertSqlExecContext(mergedRowChange, dstTbInfo, insertMode); + break; + default: + break; + } + + if (sqlContext != null) { + sqlContext.setOriginRowChanges(originRowChanges); + mergeDmlSqlContexts.add(sqlContext); + } + + count = 0; + } + return mergeDmlSqlContexts; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/MysqlApplier.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/MysqlApplier.java new file mode 100644 index 00000000..140ca7e2 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/MysqlApplier.java @@ -0,0 +1,369 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSEvent; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSRowChange; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultQueryLog; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultRowChange; +import com.aliyun.polardbx.binlog.canal.core.dump.MysqlConnection; +import com.aliyun.polardbx.binlog.canal.core.model.AuthenticationInfo; +import com.aliyun.polardbx.binlog.canal.exception.CanalParseException; +import com.aliyun.polardbx.binlog.domain.po.RplDdl; +import com.aliyun.polardbx.rpl.common.CommonUtil; +import com.aliyun.polardbx.rpl.common.NamedThreadFactory; +import com.aliyun.polardbx.rpl.common.RplConstants; +import com.aliyun.polardbx.rpl.common.ThreadPoolUtil; +import com.aliyun.polardbx.rpl.dbmeta.DbMetaCache; +import com.aliyun.polardbx.rpl.dbmeta.TableInfo; +import com.aliyun.polardbx.rpl.taskmeta.ApplierConfig; +import com.aliyun.polardbx.rpl.taskmeta.DdlState; +import com.aliyun.polardbx.rpl.taskmeta.HostInfo; +import com.aliyun.polardbx.rpl.taskmeta.DbTaskMetaManager; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import javax.sql.DataSource; +import java.io.Serializable; +import java.net.InetSocketAddress; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** + * @author shicai.xsc 2020/12/9 16:24 + * @since 5.0.0.0 + */ +@Slf4j +public class MysqlApplier extends BaseApplier { + + protected HostInfo hostInfo; + protected HostInfo srcHostInfo; + protected DbMetaCache dbMetaCache; + protected ExecutorService executorService; + protected DataSource defaultDataSource; + + public MysqlApplier(ApplierConfig applierConfig, HostInfo hostInfo) { + super(applierConfig); + this.applierConfig = applierConfig; + this.hostInfo = hostInfo; + } + + public void setSrcHostInfo(HostInfo srcHostInfo) { + this.srcHostInfo = srcHostInfo; + } + + @Override + public boolean init() { + try { + log.info("init Applier: " + this.getClass().getName()); + if (hostInfo.getServerId() == RplConstants.SERVER_ID_NULL) { + hostInfo.setServerId(getSrcServerId()); + } + dbMetaCache = new DbMetaCache(hostInfo, applierConfig.getMaxPoolSize()); + defaultDataSource = dbMetaCache.getDataSource(); + executorService = + ThreadPoolUtil + .createExecutor(applierConfig.getMinPoolSize(), applierConfig.getMaxPoolSize(), "mysqlApplier"); + return true; + } catch (Throwable e) { + log.error("MysqlApplier init failed", e); + return false; + } + } + + @Override + public boolean apply(List dbmsEvents) { + if (dbmsEvents == null || dbmsEvents.size() == 0) { + return true; + } + + try { + boolean res = true; + if (dbmsEvents.size() == 1 && ApplyHelper.isDdl(dbmsEvents.get(0))) { + res = ddlApply(dbmsEvents.get(0)); + } else { + res = dmlApply(dbmsEvents); + } + + if (res) { + logCommitInfo(dbmsEvents); + } + return res; + } catch (Throwable e) { + log.error("apply failed", e); + return false; + } + } + + protected boolean ddlApply(DBMSEvent dbmsEvent) throws Throwable { + // get tso + DefaultQueryLog queryLog = (DefaultQueryLog) dbmsEvent; + String position = (String) (queryLog.getOption(RplConstants.BINLOG_EVENT_OPTION_POSITION_STR).getValue()); + String tso = DdlHelper.getTso(queryLog.getQuery(), queryLog.getTimestamp(), position); + + // get sqlExeContext + DdlSqlContext sqlContext = ApplyHelper.getDdlSqlExeContext(queryLog, tso); + log.info("ddlApply start, schema: {}, sql: {}", sqlContext.getSchema(), sqlContext.getSql()); + if (!applierConfig.isEnableDdl()) { + log.info("ddlApply ignore since ddl is not enabled"); + return true; + } + + // try get ddl lock + boolean lock = DdlHelper.getDdlLock(tso, sqlContext.getSql()); + RplDdl ddl = DbTaskMetaManager.getDdl(tso); + + // for ddl like: create table db1.t1_1(id int, f1 int, f2 int), + // the schema will be db2 if there is a record (db1, db2) in rewriteDbs, + // db2 may not exists, but the ddl should be executed in db1 + DataSource dataSource = StringUtils.isNotBlank(sqlContext.getSchema()) ? dbMetaCache + .getDataSource(sqlContext.getSchema()) : dbMetaCache.getDefaultDataSource(); + // execute ddl if get ddl lock + if (lock && ddl.getState() == DdlState.NOT_START.getValue()) { + boolean res = ApplyHelper.execUpdate(dataSource, sqlContext); + if (res) { + // set ddl status to RUNNING + RplDdl newDdl = new RplDdl(); + newDdl.setId(ddl.getId()); + newDdl.setState(DdlState.RUNNING.getValue()); + DbTaskMetaManager.updateDdl(newDdl); + } + log.info("ddlApply end, result: {}, schema: {}, sql: {}, pos: {}", res, sqlContext.getSchema(), + sqlContext.getSql(), position); + if (!res) { + log.error("ddlApply failed when submit ddl job"); + return res; + } + } + + // wait ddl finish + while (!DdlState.from(ddl.getState()).isFinished()) { + StatisticalProxy.getInstance().heartbeat(); + if (lock) { + // check if ddl is done by "show full ddl" + DdlState state = ApplyHelper.getAsyncDdlState(dataSource, tso); + ddl.setState(state.getValue()); + DbTaskMetaManager.updateDdl(ddl); + } else { + ddl = DbTaskMetaManager.getDdl(tso); + } + + if (DdlState.from(ddl.getState()).isFinished()) { + break; + } else { + Thread.sleep(1000); + } + } + + // check ddl succeed + if (ddl.getState() == DdlState.SUCCEED.getValue()) { + // refresh metadata + if (StringUtils.isNotBlank(sqlContext.getSchema()) && StringUtils.isNotBlank(sqlContext.getDstTable())) { + dbMetaCache.refreshTableInfo(sqlContext.getSchema(), sqlContext.getDstTable()); + } + // recordTablePositionForDdl(sqlContext.getSchema() + sqlContext.getDstTable(), queryLog); + return true; + } else { + log.error("ddlApply failed after ddl finished"); + return false; + } + } + + protected boolean dmlApply(List dbmsEvents) throws Throwable { + List allSqlContexts = new ArrayList<>(); + for (DBMSEvent event : dbmsEvents) { + DBMSRowChange rowChangeEvent = (DBMSRowChange) event; + List sqlContexts = getSqlContexts(rowChangeEvent, rowChangeEvent.getTable()); + allSqlContexts.addAll(sqlContexts); + } + // for no merge apply, can NOT execute parallel + return execSqlContexts(allSqlContexts); + } + + protected List getSqlContexts(DBMSRowChange rowChangeEvent, String dstTbName) { + try { + List sqlContexts = new ArrayList<>(); + TableInfo dstTableInfo = dbMetaCache.getTableInfo(rowChangeEvent.getSchema(), dstTbName); + + switch (rowChangeEvent.getAction()) { + case INSERT: + sqlContexts = ApplyHelper.getDeleteThenInsertSqlExecContext(rowChangeEvent, dstTableInfo); + break; + case UPDATE: + sqlContexts = ApplyHelper.getUpdateSqlExecContext(rowChangeEvent, dstTableInfo); + break; + case DELETE: + sqlContexts = ApplyHelper.getDeleteSqlExecContext(rowChangeEvent, dstTableInfo); + break; + default: + log.error("receive " + rowChangeEvent.getAction().name() + " action message, action is " + + rowChangeEvent.getAction()); + break; + } + return sqlContexts; + } catch (Throwable e) { + log.error("getSqlContexts failed, dstTbName: {}", dstTbName, e); + return null; + } + } + + protected boolean execSqlContexts(List sqlContexts) { + if (sqlContexts == null || sqlContexts.size() == 0) { + return true; + } + + boolean res = true; + List batchSqlContexts = mergeSendBatchSqlContexts(sqlContexts); + for (SqlContext sqlContext : batchSqlContexts) { + long startTime = System.currentTimeMillis(); + res &= ApplyHelper.execUpdate(defaultDataSource, sqlContext); + if (!res) { + log.error("execSqlContexts failed, mergeSqlContext: {}", sqlContext); + if (skipAllException) { + StatisticalProxy.getInstance().addSkipExceptionCount(1); + } + return skipAllException; + } + + // counter + long endTime = System.currentTimeMillis(); + StatisticalProxy.getInstance().addApplyCount(1); + StatisticalProxy.getInstance().addRt(endTime - startTime); + } + return true; + } + + protected boolean tranExecSqlContexts(List sqlContexts) { + long startTime = System.currentTimeMillis(); + List mergeSqlContexts = mergeSendBatchSqlContexts(sqlContexts); + boolean res = ApplyHelper.tranExecUpdate(defaultDataSource, mergeSqlContexts); + if (res) { + long endTime = System.currentTimeMillis(); + StatisticalProxy.getInstance().addApplyCount(1); + StatisticalProxy.getInstance().addRt(endTime - startTime); + } + return res; + } + + protected void recordTablePosition(String tbName, DefaultRowChange lastRowChange) { + logCommitInfo(Arrays.asList(lastRowChange)); + StatisticalProxy.getInstance().recordTablePosition(tbName, lastRowChange); + } + + protected boolean filterCommitedEvent(String fullTbName, DefaultRowChange rowChange) { + Map lastRunTablePositions = StatisticalProxy.getInstance().getLastRunTablePositions(); + + if (!lastRunTablePositions.containsKey(fullTbName)) { + return false; + } + + String lastRunTablePosition = lastRunTablePositions.get(fullTbName); + if (StringUtils.isBlank(lastRunTablePosition)) { + return false; + } + + String position = (String) (rowChange.getOption(RplConstants.BINLOG_EVENT_OPTION_POSITION).getValue()); + if (CommonUtil.comparePosition(position, lastRunTablePosition) <= 0) { + log.info("event filtered, tbName: {}, position: {}, lastRunTablePosition:{}", fullTbName, position, + lastRunTablePosition); + return true; + } + + // 走到这里,说明当前位点已经超过了上次任务退出时记录的该表最后位点,则后续都不需要校验是否 filter + lastRunTablePositions.remove(fullTbName); + return false; + } + + protected List getIdentifyColumns(Map> allTbIdentifyColumns, + String fullTbName, + DefaultRowChange rowChange) throws Throwable { + if (allTbIdentifyColumns.containsKey(fullTbName)) { + return allTbIdentifyColumns.get(fullTbName); + } + + TableInfo tbInfo = dbMetaCache.getTableInfo(rowChange.getSchema(), rowChange.getTable()); + List identifyColumnNames = ApplyHelper.getIdentifyColumns(tbInfo); + List whereColumns = new ArrayList<>(); + for (String columnName : identifyColumnNames) { + whereColumns.add(rowChange.getColumnIndex(columnName)); + } + allTbIdentifyColumns.put(fullTbName, whereColumns); + return whereColumns; + } + + private List mergeSendBatchSqlContexts(List sqlContexts) { + List results = new ArrayList<>(); + + int i = 0; + while (i < sqlContexts.size()) { + StringBuilder sqlSb = new StringBuilder(); + List params = new ArrayList<>(); + for (int j = 0; j < applierConfig.getSendBatchSize() && i < sqlContexts.size(); j++) { + SqlContext sqlContext = sqlContexts.get(i); + sqlSb.append(sqlContext.getSql()).append(";"); + params.addAll(sqlContext.getParams()); + i++; + } + + SqlContext batchSqlContext = new SqlContext(sqlSb.toString(), "", params); + results.add(batchSqlContext); + } + + return results; + } + + private long getSrcServerId() throws Exception { + AuthenticationInfo authenticationInfo = new AuthenticationInfo(); + authenticationInfo.setAddress(new InetSocketAddress(srcHostInfo.getHost(), srcHostInfo.getPort())); + authenticationInfo.setCharset(RplConstants.EXTRACTOR_DEFAULT_CHARSET); + authenticationInfo.setUsername(srcHostInfo.getUserName()); + authenticationInfo.setPassword(srcHostInfo.getPassword()); + MysqlConnection connection = new MysqlConnection(authenticationInfo); + connection.connect(); + long serverId = findServerId(connection); + connection.disconnect(); + return serverId; + } + + /** + * 查询当前db的serverId信息 + */ + protected Long findServerId(MysqlConnection mysqlConnection) { + return mysqlConnection.query("show variables like 'server_id'", new MysqlConnection.ProcessJdbcResult() { + + @Override + public Long process(ResultSet rs) throws SQLException { + if (rs.next()) { + return rs.getLong(2); + } else { + throw new CanalParseException( + "command : show variables like 'server_id' has an error! pls check. you need (at least one " + + "of) the SUPER,REPLICATION CLIENT privilege(s) for this operation"); + } + } + }); + } + + +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/RowKey.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/RowKey.java new file mode 100644 index 00000000..d9ccb255 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/RowKey.java @@ -0,0 +1,99 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSRowChange; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author shicai.xsc 2021/2/20 10:25 + * @since 5.0.0.0 + */ +public class RowKey { + + private String schema; + private String table; + private Map keys; + + public RowKey(DBMSRowChange rowChange, List identifyColumns) { + Map keys = new HashMap<>(identifyColumns.size()); + for (Integer columnIndex : identifyColumns) { + keys.put(columnIndex, rowChange.getRowValue(1, columnIndex)); + } + this.keys = keys; + this.schema = rowChange.getSchema(); + this.table = rowChange.getTable(); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((keys == null) ? 0 : keys.hashCode()); + result = prime * result + ((schema == null) ? 0 : schema.hashCode()); + result = prime * result + ((table == null) ? 0 : table.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj == null) { + return false; + } + + if (getClass() != obj.getClass()) { + return false; + } + + RowKey other = (RowKey) obj; + + if (keys == null) { + if (other.keys != null) { + return false; + } + } else if (!keys.equals(other.keys)) { + return false; + } + + if (schema == null) { + if (other.schema != null) { + return false; + } + } else if (!schema.equals(other.schema)) { + return false; + } + + if (table == null) { + if (other.table != null) { + return false; + } + } else if (!table.equals(other.table)) { + return false; + } + + return true; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/SplitApplier.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/SplitApplier.java new file mode 100644 index 00000000..a6c88107 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/SplitApplier.java @@ -0,0 +1,155 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSAction; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSEvent; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultRowChange; +import com.aliyun.polardbx.rpl.taskmeta.ApplierConfig; +import com.aliyun.polardbx.rpl.taskmeta.HostInfo; +import lombok.extern.slf4j.Slf4j; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @author shicai.xsc 2021/5/24 11:42 + * @since 5.0.0.0 + */ +@Slf4j +public class SplitApplier extends SplitTransactionApplier { + + public SplitApplier(ApplierConfig applierConfig, HostInfo hostInfo) { + super(applierConfig, hostInfo); + } + + @Override + protected boolean dmlApply(List dbmsEvents) throws Throwable { + if (dbmsEvents == null || dbmsEvents.size() == 0) { + return true; + } + + Map>> allSplitRowChanges = new HashMap<>(); + Map> allSerialRowChanges = new HashMap<>(); + Set changedIdentifyColumnTables = new HashSet<>(); + + split(dbmsEvents, allSplitRowChanges, allSerialRowChanges, changedIdentifyColumnTables); + + int allSerialRowChangeCount = 0; + for (String fullTbName : allSerialRowChanges.keySet()) { + allSerialRowChangeCount += allSerialRowChanges.get(fullTbName).size(); + } + + // 对于 allSplitRowChanges,分成多个队列并行执行 + int avgQueueSize = (dbmsEvents.size() - allSerialRowChangeCount) / applierConfig.getMaxPoolSize(); + Map> allQueues = new HashMap<>(); + List curQueue = null; + int queueIndex = 0; + + for (String fullTbName : allSplitRowChanges.keySet()) { + Map> tbSplitRowChanges = allSplitRowChanges.get(fullTbName); + // 保证同一个表 a.a 的同一个 identify key 的 rowChanges 在同一个 queue 内,且按照顺序执行 + // 同一个表 a.a 的不同 identify key 的 rowChanges 不必在同一个 queue 内 + for (List rowChanges : tbSplitRowChanges.values()) { + if (curQueue == null || curQueue.size() >= avgQueueSize) { + curQueue = new ArrayList<>(); + String fakeTbName = String.valueOf(queueIndex); + allQueues.put(fakeTbName, curQueue); + queueIndex++; + } + + curQueue.addAll(rowChanges); + } + } + + // 多个队列并行执行,每个队列内部不需要事务 + boolean res = parallelExecSqlContexts(allQueues, false); + if (!res) { + return res; + } + + // allSerialRowChanges 并行执行,每个队列内需要事务 + for (String fullTbName : allSerialRowChanges.keySet()) { + log.info("{} changes will be executed by SplitTransactionApplier, rowChanges: {}", fullTbName, + allSerialRowChanges.get(fullTbName).size()); + } + return parallelExecSqlContexts(allSerialRowChanges, true); + } + + protected void split(List dbmsEvents, + Map>> allSplitRowChanges, + Map> allSerialRowChanges, + Set changedIdentifyColumnTables) throws Throwable { + Map> allTbIdentifyColumns = new HashMap<>(); + + for (DBMSEvent event : dbmsEvents) { + DefaultRowChange rowChange = (DefaultRowChange) event; + String fullTbName = rowChange.getSchema() + "." + rowChange.getTable(); + + // filter + if (filterCommitedEvent(fullTbName, rowChange)) { + continue; + } + + // get identify columns + List identifyColumns = getIdentifyColumns(allTbIdentifyColumns, fullTbName, rowChange); + + // find out events which changed identify columns of a table + if (changedIdentifyColumnTables != null + && !changedIdentifyColumnTables.contains(fullTbName) + && rowChange.getAction() == DBMSAction.UPDATE) { + for (Integer column : identifyColumns) { + if (rowChange.hasChangeColumn(column)) { + changedIdentifyColumnTables.add(fullTbName); + break; + } + } + } + + // 发现某表 a.a 某条记录 a.a.1 修改了 identify columns,则 a.a.1 之后所有记录都改为串行 + if (changedIdentifyColumnTables.contains(fullTbName)) { + List tbSerialRowChanges = allSerialRowChanges.get(fullTbName); + if (tbSerialRowChanges == null) { + tbSerialRowChanges = new ArrayList<>(); + allSerialRowChanges.put(fullTbName, tbSerialRowChanges); + } + tbSerialRowChanges.add(rowChange); + continue; + } + + RowKey key = new RowKey(rowChange, identifyColumns); + Map> tbSplitRowChanges = allSplitRowChanges.get(fullTbName); + if (tbSplitRowChanges == null) { + tbSplitRowChanges = new HashMap<>(); + allSplitRowChanges.put(fullTbName, tbSplitRowChanges); + } + + // 保证同一个 key 的变更按照顺序排列 + List tbKeyRowChanges = tbSplitRowChanges.get(key); + if (tbKeyRowChanges == null) { + tbKeyRowChanges = new ArrayList<>(); + tbSplitRowChanges.put(key, tbKeyRowChanges); + } + tbKeyRowChanges.add(rowChange); + } + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/SplitTransactionApplier.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/SplitTransactionApplier.java new file mode 100644 index 00000000..a2f9ead6 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/SplitTransactionApplier.java @@ -0,0 +1,109 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSEvent; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultRowChange; +import com.aliyun.polardbx.rpl.taskmeta.ApplierConfig; +import com.aliyun.polardbx.rpl.taskmeta.HostInfo; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; +import java.util.concurrent.Future; + +/** + * @author shicai.xsc 2021/5/18 14:19 + * @since 5.0.0.0 + */ +public class SplitTransactionApplier extends MysqlApplier { + public SplitTransactionApplier(ApplierConfig applierConfig, HostInfo hostInfo) { + super(applierConfig, hostInfo); + } + + @Override + protected boolean dmlApply(List dbmsEvents) throws Throwable { + if (dbmsEvents == null || dbmsEvents.size() == 0) { + return true; + } + + Map> splitRowChanges = splitByTable(dbmsEvents); + return parallelExecSqlContexts(splitRowChanges, true); + } + + private Map> splitByTable(List dbmsEvents) { + Map> splitRowChanges = new HashMap<>(); + + for (DBMSEvent event : dbmsEvents) { + DefaultRowChange rowChange = (DefaultRowChange) event; + String fullTbName = rowChange.getSchema() + "." + rowChange.getTable(); + if (splitRowChanges.containsKey(fullTbName)) { + splitRowChanges.get(fullTbName).add(rowChange); + } else { + List tbRowChanges = new ArrayList<>(); + tbRowChanges.add(rowChange); + splitRowChanges.put(fullTbName, tbRowChanges); + } + } + + return splitRowChanges; + } + + protected boolean parallelExecSqlContexts(Map> allRowChanges, boolean tbTranExec) + throws Throwable { + boolean res = true; + List futures = new ArrayList<>(); + + for (String fullTbName : allRowChanges.keySet()) { + List tbRowChanges = allRowChanges.get(fullTbName); + List tbSqlContexts = new ArrayList<>(); + + for (DefaultRowChange rowChange : tbRowChanges) { + tbSqlContexts.addAll(getSqlContexts(rowChange, rowChange.getTable())); + } + + // execute + final Callable task; + if (tbTranExec) { + task = () -> { + boolean succeed; + if (skipAllException) { + succeed = execSqlContexts(tbSqlContexts); + } else { + succeed = tranExecSqlContexts(tbSqlContexts); + } + if (succeed) { + recordTablePosition(fullTbName, tbRowChanges.get(tbRowChanges.size() - 1)); + } + return succeed; + }; + } else { + task = () -> execSqlContexts(tbSqlContexts); + } + futures.add(executorService.submit(() -> task.call())); + } + + for (Future future : futures) { + res &= (Boolean) future.get(); + } + + return res; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/SqlContext.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/SqlContext.java new file mode 100644 index 00000000..66039e98 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/SqlContext.java @@ -0,0 +1,41 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author shicai.xsc 2020/12/1 22:06 + * @since 5.0.0.0 + */ +@Data +public class SqlContext { + + protected String sql; + protected String dstTable; + protected List params; + + public SqlContext(String sql, String dstTable, List params) { + this.sql = sql; + this.dstTable = dstTable; + this.params = params; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/StatisticCounter.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/StatisticCounter.java new file mode 100644 index 00000000..197476d5 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/StatisticCounter.java @@ -0,0 +1,75 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import lombok.Data; +import org.joda.time.DateTime; + +import java.util.Queue; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.atomic.AtomicLong; + +/** + * @author shicai.xsc 2021/5/13 13:08 + * @since 5.0.0.0 + */ +@Data +public class StatisticCounter { + + private Queue counters = new ConcurrentLinkedQueue<>(); + private AtomicLong totalCount = new AtomicLong(0); + private int outdateSeconds; + + public StatisticCounter(int outdateSeconds) { + this.outdateSeconds = outdateSeconds; + } + + public void add(long count) { + Counter counter = new Counter(System.currentTimeMillis(), count); + counters.add(counter); + totalCount.addAndGet(count); + } + + public synchronized long getTotalCount() { + int size = counters.size(); + for (int i = 0; i < size; i++) { + Counter peek = counters.peek(); + if (!isOutdate(peek)) { + break; + } + + totalCount.addAndGet(0 - peek.count); + counters.remove(); + } + return totalCount.get(); + } + + private boolean isOutdate(Counter counter) { + return DateTime.now().minusSeconds(outdateSeconds).isAfter(counter.timestamp); + } + + private static class Counter { + private long timestamp; + private long count; + + public Counter(long timestamp, long count) { + this.timestamp = timestamp; + this.count = count; + } + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/StatisticUnit.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/StatisticUnit.java new file mode 100644 index 00000000..12d786b4 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/StatisticUnit.java @@ -0,0 +1,41 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import java.util.HashMap; +import java.util.Map; + +import lombok.Data; + +/** + * @author shicai.xsc 2021/2/20 16:06 + * @since 5.0.0.0 + */ +@Data +public class StatisticUnit { + + // private Map totalBatchConsumeMessageCount = new HashMap<>(); + private Map totalConsumeMessageCount = new HashMap<>(); + private Map avgMergeBatchSize = new HashMap<>(); + private Map applyRt = new HashMap<>(); + private Map messageTps = new HashMap<>(); + private Map applyTps = new HashMap<>(); + private long skipCounter = 0; + private long skipExceptionCounter = 0; + private long persistentMessageCounter = 0; +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/StatisticalProxy.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/StatisticalProxy.java new file mode 100644 index 00000000..9db08c0f --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/StatisticalProxy.java @@ -0,0 +1,371 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import com.alibaba.fastjson.JSON; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSEvent; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultRowChange; +import com.aliyun.polardbx.binlog.domain.po.RplTablePosition; +import com.aliyun.polardbx.binlog.domain.po.RplTask; +import com.aliyun.polardbx.rpl.common.LogUtil; +import com.aliyun.polardbx.rpl.common.NamedThreadFactory; +import com.aliyun.polardbx.rpl.common.RplConstants; +import com.aliyun.polardbx.rpl.common.TaskContext; +import com.aliyun.polardbx.rpl.pipeline.BasePipeline; +import com.aliyun.polardbx.rpl.taskmeta.ApplierConfig; +import com.aliyun.polardbx.rpl.taskmeta.DbTaskMetaManager; +import com.aliyun.polardbx.rpl.taskmeta.ExtractorConfig; +import com.aliyun.polardbx.rpl.taskmeta.PipelineConfig; +import com.aliyun.polardbx.rpl.taskmeta.TaskStatus; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; + +/** + * @author shicai.xsc 2021/2/20 15:15 + * @since 5.0.0.0 + */ +@Slf4j +public class StatisticalProxy implements FlowLimiter { + + private final static int MAX_RETRY = 4; + private final static int COUNTER_OUTDATE_SECONDS = 60; + private final static int HEARTBEAT_OUTDATE_SECONDS = 120; + + public final static String INTERVAL_1M = "oneMinute"; + + private StatisticCounter messageCount = new StatisticCounter(COUNTER_OUTDATE_SECONDS); + private StatisticCounter mergeBatchSize = new StatisticCounter(COUNTER_OUTDATE_SECONDS); + private StatisticCounter rt = new StatisticCounter(COUNTER_OUTDATE_SECONDS); + private StatisticCounter applyCount = new StatisticCounter(COUNTER_OUTDATE_SECONDS); + + private AtomicLong skipCounter = new AtomicLong(); + private AtomicLong skipExceptionCounter = new AtomicLong(); + private AtomicLong persistentMessageCounter = new AtomicLong(); + + private AtomicLong totalInCache = new AtomicLong(); + + private ScheduledExecutorService executorService; + private ExtractorConfig extractorConfig; + private ApplierConfig applierConfig; + private Logger positionLogger = LogUtil.getPositionLogger(); + private Logger statisticLogger = LogUtil.getStatisticLogger(); + private String position; + private long lastEventTimestamp; + private BaseApplier applier; + private boolean skipAllException = false; + private int tpsLimit; + private volatile FlowLimiter limiter; + + private Map lastRunTablePositions = new HashMap<>(); + private static StatisticalProxy instance = new StatisticalProxy(); + + private StatisticalProxy() { + } + + public static StatisticalProxy getInstance() { + return instance; + } + + public boolean init(BasePipeline pipeline, String position) { + try { + this.position = position; + this.extractorConfig = pipeline.getExtractor().getExtractorConfig(); + this.applierConfig = pipeline.getApplier().getApplierConfig(); + executorService = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("StatisticalProxy")); + lastEventTimestamp = System.currentTimeMillis(); + + // 加载上次任务崩溃前各个表已经执行到的位点 + List rplTablePositions = DbTaskMetaManager + .listTablePosition(TaskContext.getInstance().getTaskId()); + for (RplTablePosition rplTablePosition : rplTablePositions) { + lastRunTablePositions.put(rplTablePosition.getFullTableName(), rplTablePosition.getPosition()); + } + + applier = pipeline.getApplier(); + skipAllException = pipeline.getPipeLineConfig().isSkipException(); + applier.setSkipAllException(skipAllException); + tpsLimit = pipeline.getPipeLineConfig().getFixedTpsLimit(); + initFlowLimiter(); + + } catch (Throwable e) { + log.error("StatisticManager init failed", e); + return false; + } + start(); + return true; + } + + public void start() { + executorService.scheduleAtFixedRate( + () -> flushStatistic(), 0, applierConfig.getStatisticIntervalSec(), TimeUnit.SECONDS); + executorService.scheduleAtFixedRate( + () -> flushPosition(), 0, 1, TimeUnit.SECONDS); + executorService.scheduleAtFixedRate( + () -> checkPipelineConfig(), 0, applierConfig.getStatisticIntervalSec(), TimeUnit.SECONDS); + } + + public boolean apply(List events) { + return limiter.runTask(events); + } + + public boolean tranApply(List transactions) { + return limiter.runTranTask(transactions); + } + + @Override + public boolean runTask(List events) { + return innerApply(events); + } + + @Override + public boolean runTranTask(List transactions) { + return innerTranApply(transactions); + } + + private void initFlowLimiter() { + FlowLimiter newLimitBucket = this; + if (tpsLimit > 0) { + newLimitBucket = new TPSLimiter(tpsLimit, newLimitBucket); + } + limiter = newLimitBucket; + } + + private void checkPipelineConfig() { + RplTask task = DbTaskMetaManager.getTask(TaskContext.getInstance().getTaskId()); + PipelineConfig config = JSON.parseObject(task.getPipelineConfig(), PipelineConfig.class); + skipAllException = config.isSkipException(); + applier.setSkipAllException(skipAllException); + if (this.tpsLimit != config.getFixedTpsLimit()) { + this.tpsLimit = config.getFixedTpsLimit(); + initFlowLimiter(); + } + } + + public boolean innerApply(List events) { + boolean res = applier.apply(events); + if (res) { + return true; + } else { + log.warn("batch apply events failure"); + for (DBMSEvent event : events) { + boolean result = applier.apply(Arrays.asList(event)); + if (!result) { + log.error("stop because of the msg, " + event.toString()); + Runtime.getRuntime().halt(1); + } + } + } + return true; + } + + public boolean innerTranApply(List transactions) { + boolean res = applier.tranApply(transactions); + if (res) { + return true; + } else { + log.warn("batch apply transactions failure"); + for (Transaction transaction : transactions) { + boolean result = applier.tranApply(Arrays.asList(transaction)); + if (!result) { + if (skipAllException) { + log.warn("SKIP_ALL_EXCEPTION is true, will skip the transaction, " + transaction.toString()); + addSkipExceptionCount(1); + } else { + log.warn("SKIP_ALL_EXCEPTION is false, stop because of transaction, " + transaction.toString()); + return false; + } + } + } + } + return true; + } + + public void recordPosition(String position, boolean log) { + if (StringUtils.isBlank(position)) { + return; + } + this.position = position; + if (log) { + positionLogger.info(LogUtil.generatePositionLog(position)); + } + } + + public void setTotalInCache(long totalInCache) { + this.totalInCache.set(totalInCache); + } + + public void addMessageCount(long count) { + messageCount.add(count); + persistentMessageCounter.addAndGet(count); + } + + public void addMergeBatchSize(long count) { + mergeBatchSize.add(count); + } + + public void addRt(long count) { + rt.add(count); + } + + public void addApplyCount(long count) { + applyCount.add(count); + } + + public void addSkipCount(long count) { + skipCounter.addAndGet(count); + } + + public void addSkipExceptionCount(long count) { + skipExceptionCounter.addAndGet(count); + } + + public void heartbeat() { + lastEventTimestamp = System.currentTimeMillis(); + } + + public void recordTablePosition(String tbName, DefaultRowChange lastRowChange) { + String position = (String) (lastRowChange.getOption(RplConstants.BINLOG_EVENT_OPTION_POSITION).getValue()); + DbTaskMetaManager + .updateTablePosition(TaskContext.getInstance().getStateMachineId(), + TaskContext.getInstance().getServiceId(), TaskContext.getInstance().getTaskId(), tbName, position); + } + + public void deleteTaskTablePosition() { + DbTaskMetaManager.deleteTablePositionByTask(TaskContext.getInstance().getTaskId()); + } + + public Map getLastRunTablePositions() { + return lastRunTablePositions; + } + + public void flushStatistic() { + RplTask task = DbTaskMetaManager.getTask(TaskContext.getInstance().getTaskId()); + if (task == null) { + log.error("task has been deleted from db"); + Runtime.getRuntime().halt(1);; + } + if (task.getStatus() != TaskStatus.RUNNING.getValue()) { + log.info("task id: {}, task status: {}, exit", task.getId(), TaskStatus.from(task.getStatus()).name()); + Runtime.getRuntime().halt(1);; + } + + int retry = 0; + while (retry < MAX_RETRY) { + try { + flushInternal(); + break; + } catch (Throwable e) { + log.error("StatisticManager flush failed", e); + retry++; + } + } + + if (retry >= MAX_RETRY) { + log.error("StatisticManager flush failed, retry: {}, process exit", retry); + Runtime.getRuntime().halt(1);; + } + + // In some cases, for example, Polar-x CDC dumper restarts, no events will be dumped to Replica and no error throws, + // so we need to check the last event timestamp and restart the Replica + if (extractorConfig.isEnableHeartbeat() + && lastEventTimestamp > 0 + && System.currentTimeMillis() - lastEventTimestamp > HEARTBEAT_OUTDATE_SECONDS * 1000) { + log.error("lastEventTimestamp: {} exceeds {} seconds, process exit", new Date(lastEventTimestamp), + HEARTBEAT_OUTDATE_SECONDS); + Runtime.getRuntime().halt(1);; + } + } + + public void flushPosition() { + // get the latest status before update + RplTask task = DbTaskMetaManager.getTask(TaskContext.getInstance().getTaskId()); + if (task == null) { + log.error("task has been deleted from db"); + Runtime.getRuntime().halt(1);; + } + // task may be set to STOPPED but the still running + Date gmtHeartBeat = null; + if (lastEventTimestamp > 0) { + gmtHeartBeat = new Date(lastEventTimestamp); + } + if (task.getStatus() == TaskStatus.RUNNING.getValue()) { + DbTaskMetaManager.updateTask(TaskContext.getInstance().getTaskId(), + null, null, position, null, + gmtHeartBeat); + } else { + log.error("task is not in running status"); + Runtime.getRuntime().halt(1);; + } + } + + private void flushInternal() { + StatisticUnit unit = new StatisticUnit(); + flushFields(unit, INTERVAL_1M, 1 * 60); + unit.setSkipCounter(skipCounter.get()); + unit.setSkipExceptionCounter(skipExceptionCounter.get()); + unit.setPersistentMessageCounter(persistentMessageCounter.get()); + + statisticLogger.info(LogUtil.generateStatisticLog(unit, INTERVAL_1M, totalInCache.get())); + + // task may be set to STOPPED but the still running + Date gmtHeartBeat = null; + if (lastEventTimestamp > 0) { + gmtHeartBeat = new Date(lastEventTimestamp); + } + + // get the latest status before update + RplTask task = DbTaskMetaManager.getTask(TaskContext.getInstance().getTaskId()); + if (task == null) { + log.error("task has been deleted from db"); + Runtime.getRuntime().halt(1);; + } + if (task.getStatus() == TaskStatus.RUNNING.getValue()) { + DbTaskMetaManager.updateTask(TaskContext.getInstance().getTaskId(), + null, null, null, JSON.toJSONString(unit), + gmtHeartBeat); + } else { + log.error("task is not in running status"); + Runtime.getRuntime().halt(1);; + } + } + + private void flushFields(StatisticUnit unit, String intervalItem, int seconds) { + long curApplyCount = applyCount.getTotalCount(); + long curMessageCount = messageCount.getTotalCount(); + long curBatchSize = mergeBatchSize.getTotalCount(); + long curRt = rt.getTotalCount(); + + unit.getTotalConsumeMessageCount().put(intervalItem, curMessageCount); + unit.getMessageTps().put(intervalItem, curMessageCount / seconds); + unit.getApplyTps().put(intervalItem, curApplyCount / seconds); + if (curApplyCount > 0) { + unit.getAvgMergeBatchSize().put(intervalItem, curBatchSize / curApplyCount); + unit.getApplyRt().put(intervalItem, curRt / curApplyCount); + } + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/TPSLimiter.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/TPSLimiter.java new file mode 100644 index 00000000..842398b5 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/TPSLimiter.java @@ -0,0 +1,97 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSEvent; +import com.google.common.util.concurrent.RateLimiter; + +import java.util.ArrayList; +import java.util.List; + +public class TPSLimiter implements FlowLimiter { + + private Integer tps; + private FlowLimiter target; + private RateLimiter rateLimiter; + + public TPSLimiter(Integer tps, FlowLimiter target) { + this.tps = tps; + this.target = target; + this.rateLimiter = RateLimiter.create(tps); + } + + @Override + public boolean runTask(List events) { + + List needHandleMsg = new ArrayList<>(); + int handleCount = 0, totalSize = events.size(); + int needSize = totalSize; + int acq = needSize; + while (needSize > 0) { + acq = Math.min(acq, tps); + if (acq > 0 && !rateLimiter.tryAcquire(acq)) { + acq = acq >> 1; + continue; + } + if (acq == 0) { + acq = 1; + rateLimiter.acquire(acq); + } + int start = handleCount; + handleCount = handleCount + acq; + for (int i = start; i < handleCount; i++) { + needHandleMsg.add(events.get(i)); + } + if (!target.runTask(needHandleMsg)) { + return false; + } + needSize = totalSize - handleCount; + needHandleMsg.clear(); + acq = needSize; + } + return true; + } + + @Override + public boolean runTranTask(List transactions) { + + int nowSize = 0; + List transferTransactions = new ArrayList<>(); + for (Transaction transaction : transactions) { + if (nowSize == 0 || nowSize + transaction.getEvents().size() <= tps) { + nowSize += transaction.getEvents().size(); + transferTransactions.add(transaction); + } else { + rateLimiter.acquire(nowSize); + if (!target.runTranTask(transferTransactions)) { + return false; + } + transferTransactions.clear(); + nowSize = 0; + } + } + if (!transferTransactions.isEmpty()) { + rateLimiter.acquire(nowSize); + if (!target.runTranTask(transferTransactions)) { + return false; + } + } + return true; + } + +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/Transaction.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/Transaction.java new file mode 100644 index 00000000..3d6e8b9d --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/Transaction.java @@ -0,0 +1,52 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSEvent; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSRowChange; + +import lombok.Data; + +/** + * @author shicai.xsc 2021/3/17 16:30 + * @since 5.0.0.0 + */ +@Data +public class Transaction { + + private Set tables = new HashSet<>(); + private List events = new ArrayList<>(); + private boolean finished = false; + private boolean prepared = false; + + public void appendRowChange(DBMSEvent event) { + events.add(event); + DBMSRowChange rowChange = (DBMSRowChange) event; + String fullTableName = rowChange.getSchema() + "." + rowChange.getTable(); + tables.add(fullTableName); + } + + public void appendQueryLog(DBMSEvent event) { + events.add(event); + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/TransactionApplier.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/TransactionApplier.java new file mode 100644 index 00000000..11a5b2a4 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/TransactionApplier.java @@ -0,0 +1,100 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSEvent; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSRowChange; +import com.aliyun.polardbx.rpl.taskmeta.ApplierConfig; +import com.aliyun.polardbx.rpl.taskmeta.HostInfo; +import lombok.extern.slf4j.Slf4j; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * @author shicai.xsc 2021/5/25 14:45 + * @since 5.0.0.0 + */ +@Slf4j +public class TransactionApplier extends MysqlApplier { + public TransactionApplier(ApplierConfig applierConfig, HostInfo hostInfo) { + super(applierConfig, hostInfo); + } + + @Override + public boolean tranApply(List transactions) { + boolean res = true; + try { + if (transactions.size() == 1 && transactions.get(0).getEvents().size() > 0 + && ApplyHelper.isDdl(transactions.get(0).getEvents().get(0))) { + return ddlApply(transactions.get(0).getEvents().get(0)); + } + + int i = 0; + while (i < transactions.size()) { + List sqlContexts = new ArrayList<>(); + DBMSEvent lastEvent = null; + // merge multiple small transactions into one to accelerate + while (i < transactions.size()) { + Transaction curTransaction = transactions.get(i); + if (curTransaction.getEvents().size() == 0) { + i++; + continue; + } + + if (sqlContexts.size() == 0 + || sqlContexts.size() + curTransaction.getEvents().size() < applierConfig.getSendBatchSize()) { + sqlContexts.addAll(getSqlContexts(curTransaction)); + lastEvent = curTransaction.getEvents().get(curTransaction.getEvents().size() - 1); + i++; + } else { + break; + } + } + + if (sqlContexts.size() == 0) { + continue; + } + + res &= tranExecSqlContexts(sqlContexts); + sqlContexts.clear(); + if (!res) { + log.error("tranApply failed"); + return res; + } else { + logCommitInfo(Arrays.asList(lastEvent)); + } + } + } catch (Throwable e) { + log.error("tranApply failed", e); + res = false; + } + return res; + } + + private List getSqlContexts(Transaction transaction) { + List allSqlContexts = new ArrayList<>(); + for (DBMSEvent event : transaction.getEvents()) { + DBMSRowChange rowChangeEvent = (DBMSRowChange) event; + List sqlContexts = getSqlContexts(rowChangeEvent, rowChangeEvent.getTable()); + allSqlContexts.addAll(sqlContexts); + } + return allSqlContexts; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/TransactionBatch.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/TransactionBatch.java new file mode 100644 index 00000000..7ff123e5 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/applier/TransactionBatch.java @@ -0,0 +1,41 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import lombok.Data; + +/** + * @author shicai.xsc 2021/3/17 17:24 + * @since 5.0.0.0 + */ +@Data +public class TransactionBatch { + + private Set tables = new HashSet<>(); + private List transactions = new ArrayList<>(); + + public void append(Transaction transaction) { + tables.addAll(transaction.getTables()); + transactions.add(transaction); + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/CalendarUtil.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/CalendarUtil.java new file mode 100644 index 00000000..0fab7d4d --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/CalendarUtil.java @@ -0,0 +1,663 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common; + +import java.sql.Timestamp; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +import org.apache.commons.lang3.StringUtils; + +/** + * @author shicai.xsc 2021/1/14 17:51 + * @since 5.0.0.0 + */ +public class CalendarUtil { + + /** + * the milli second of a day + */ + public static final long DAYMILLI = 24 * 60 * 60 * 1000; + + /** + * the milli seconds of an hour + */ + public static final long HOURMILLI = 60 * 60 * 1000; + + /** + * the milli seconds of a minute + */ + public static final long MINUTEMILLI = 60 * 1000; + + /** + * the milli seconds of a second + */ + public static final long SECONDMILLI = 1000; + + /** + * added time + */ + public static final String TIMETO = " 23:59:59"; + + /** + * flag before + */ + public static final transient int BEFORE = 1; + + /** + * flag after + */ + public static final transient int AFTER = 2; + + /** + * flag equal + */ + public static final transient int EQUAL = 3; + + /** + * date format dd/MMM/yyyy:HH:mm:ss +0900 + */ + public static final String TIME_PATTERN_LONG = "dd/MMM/yyyy:HH:mm:ss +0900"; + + /** + * date format dd/MM/yyyy:HH:mm:ss +0900 + */ + public static final String TIME_PATTERN_LONG2 = "dd/MM/yyyy:HH:mm:ss +0900"; + + /** + * date format yyyy-MM-dd HH:mm:ss + */ + public static final String TIME_PATTERN = "yyyy-MM-dd HH:mm:ss"; + + /** + * date format YYYY-MM-DD HH24:MI:SS + */ + public static final String DB_TIME_PATTERN = "YYYY-MM-DD HH24:MI:SS"; + + /** + * date format dd/MM/yy HH:mm:ss + */ + public static final String TIME_PATTERN_SHORT = "dd/MM/yy HH:mm:ss"; + + public static final String TIME_PATTERN_SHORT_2 = "MM/dd/yyyy HH:mm:ss"; + + /** + * date format dd/MM/yy HH24:mm + */ + public static final String TIME_PATTERN_SHORT_1 = "yyyy/MM/dd HH:mm"; + + /** + * date format yyyyMMddHHmmss + */ + public static final String TIME_PATTERN_SESSION = "yyyyMMddHHmmss"; + + /** + * date format yyyyMMdd + */ + public static final String DATE_FMT_0 = "yyyyMMdd"; + + /** + * date format yyyy/MM/dd + */ + public static final String DATE_FMT_1 = "yyyy/MM/dd"; + + /** + * date format yyyy/MM/dd hh:mm:ss + */ + public static final String DATE_FMT_2 = "yyyy/MM/dd hh:mm:ss"; + + /** + * date format yyyy-MM-dd + */ + public static final String DATE_FMT_3 = "yyyy-MM-dd"; + + public static final String DATE_FMT_4 = "MM/dd/yyyy"; + + /** + * change string to date 将String类型的日期转成Date类型 + * + * @param sDate the date string + * @param sFmt the date format + * @return Date object + */ + public static Date toDate(String sDate, String sFmt) { + if (StringUtils.isBlank(sDate) || StringUtils.isBlank(sFmt)) { + return null; + } + try { + SimpleDateFormat sdfFrom = new SimpleDateFormat(sFmt); + return sdfFrom.parse(sDate); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + /** + * change date to string 将日期类型的参数转成String类型 + * + * @param dt a date + * @return the format string + */ + public static String toString(Date dt) { + return toString(dt, DATE_FMT_0); + } + + public static String toString(Date dt, String sFmt) { + if (null == dt || StringUtils.isBlank(sFmt)) { + return null; + } + try { + SimpleDateFormat sdfFrom = new SimpleDateFormat(sFmt); + return sdfFrom.format(dt).toString(); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + /** + * 获取Date所属月的最后一天日期 + * + * @return Date 默认null + */ + public static Date getMonthLastDate(Date date) { + if (null == date) { + return null; + } + Calendar ca = Calendar.getInstance(); + ca.setTime(date); + ca.set(Calendar.HOUR_OF_DAY, 23); + ca.set(Calendar.MINUTE, 59); + ca.set(Calendar.SECOND, 59); + ca.set(Calendar.DAY_OF_MONTH, 1); + ca.add(Calendar.MONTH, 1); + ca.add(Calendar.DAY_OF_MONTH, -1); + Date lastDate = ca.getTime(); + return lastDate; + } + + /** + * 获取Date所属月的最后一天日期 + * + * @return String 默认null + */ + public static String getMonthLastDate(Date date, String pattern) { + Date lastDate = getMonthLastDate(date); + if (null == lastDate) { + return null; + } + if (StringUtils.isBlank(pattern)) { + pattern = TIME_PATTERN; + } + return toString(lastDate, pattern); + } + + /** + * 获取Date所属月的第一天日期 + * + * @return Date 默认null + */ + public static Date getMonthFirstDate(Date date) { + if (null == date) { + return null; + } + Calendar ca = Calendar.getInstance(); + ca.setTime(date); + ca.set(Calendar.HOUR_OF_DAY, 0); + ca.set(Calendar.MINUTE, 0); + ca.set(Calendar.SECOND, 0); + ca.set(Calendar.DAY_OF_MONTH, 1); + Date firstDate = ca.getTime(); + return firstDate; + } + + /** + * 获取Date所属月的第一天日期 + * + * @return String 默认null + */ + public static String getMonthFirstDate(Date date, String pattern) { + Date firstDate = getMonthFirstDate(date); + if (null == firstDate) { + return null; + } + if (StringUtils.isBlank(pattern)) { + pattern = TIME_PATTERN; + } + return toString(firstDate, pattern); + } + + /** + * 计算两个日期间隔的天数 + * + * @param firstDate 小者 + * @param lastDate 大者 + * @return int 默认-1 + */ + public static int getIntervalDays(Date firstDate, Date lastDate) { + if (null == firstDate || null == lastDate) { + return -1; + } + long intervalMilli = lastDate.getTime() - firstDate.getTime(); + return (int) (intervalMilli / (24 * 60 * 60 * 1000)); + } + + /** + * 计算两个日期间隔的小时数 + * + * @param firstDate 小者 + * @param lastDate 大者 + * @return int 默认-1 + */ + public static int getTimeIntervalHours(Date firstDate, Date lastDate) { + if (null == firstDate || null == lastDate) { + return -1; + } + long intervalMilli = lastDate.getTime() - firstDate.getTime(); + return (int) (intervalMilli / (60 * 60 * 1000)); + } + + /** + * 计算两个日期间隔的分钟数 + * + * @param firstDate 小者 + * @param lastDate 大者 + * @return int 默认-1 + */ + public static int getTimeIntervalMins(Date firstDate, Date lastDate) { + if (null == firstDate || null == lastDate) { + return -1; + } + long intervalMilli = lastDate.getTime() - firstDate.getTime(); + return (int) (intervalMilli / (60 * 1000)); + } + + /** + * format the date in given pattern 格式化日期 + * + * @param d date + * @param pattern time pattern + * @return the formatted string + */ + public static String formatDate(Date d, String pattern) { + if (null == d || StringUtils.isBlank(pattern)) { + return null; + } + + SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getDateInstance(); + formatter.applyPattern(pattern); + return formatter.format(d); + } + + /** + * 比较两个日期的先后顺序 + */ + public static int compareDate(Date src, Date desc) { + if ((src == null) && (desc == null)) { + return EQUAL; + } else if (desc == null) { + return BEFORE; + } else if (src == null) { + return AFTER; + } else { + long timeSrc = src.getTime(); + long timeDesc = desc.getTime(); + if (timeSrc == timeDesc) { + return EQUAL; + } else { + return (timeDesc > timeSrc) ? AFTER : BEFORE; + } + } + } + + /** + * 比较两个日期的先后顺序 + * + * @param first date1 + * @param second date2 + * @return EQUAL - if equal BEFORE - if before than date2 AFTER - if over than date2 + */ + public static int compareTwoDate(Date first, Date second) { + if ((first == null) && (second == null)) { + return EQUAL; + } else if (first == null) { + return BEFORE; + } else if (second == null) { + return AFTER; + } else if (first.before(second)) { + return BEFORE; + } else if (first.after(second)) { + return AFTER; + } else { + return EQUAL; + } + } + + /** + * 比较日期是否介于两者之间 + * + * @param date the specified date + * @param begin date1 + * @param end date2 + * @return true - between date1 and date2 false - not between date1 and date2 + */ + public static boolean isDateBetween(Date date, Date begin, Date end) { + int c1 = compareTwoDate(begin, date); + int c2 = compareTwoDate(date, end); + + return (((c1 == BEFORE) && (c2 == BEFORE)) || (c1 == EQUAL) || (c2 == EQUAL)); + } + + /** + * change string to Timestamp 字符串类型转成Timestamp 如果传入的String是数字格式的则优先会转化成Long构造Date + * + * @param str formatted timestamp string + * @param sFmt string format + * @return timestamp + * @deprecated plz use Calendar.toDate(String sDate, String sFmt) + */ + public static Timestamp parseString2Timestamp(String str, String sFmt) { + if ((str == null) || str.equals("")) { + return null; + } + + try { + long time = Long.parseLong(str); + return new Timestamp(time); + } catch (Exception ex) { + try { + DateFormat df = new SimpleDateFormat(sFmt); + Date dt = df.parse(str); + return new Timestamp(dt.getTime()); + } catch (Exception pe) { + try { + return Timestamp.valueOf(str); + } catch (Exception e) { + return null; + } + } + } + } + + /** + * 增加天数 + * + * @return Date + */ + public static Date addDate(Date date, int day) { + if (null == date) { + return null; + } + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + day); + return calendar.getTime(); + } + + /** + * 增加天数 + */ + public static String addDays(Date date, int day, String pattern) { + return addDays(toString(date, pattern), day, pattern); + } + + /** + * 增加天数 + */ + public static String addDays(Date date, int day) { + return addDays(toString(date, TIME_PATTERN), day); + } + + /** + * 增加天数 + */ + public static String addDays(String date, int day) { + return addDays(date, day, TIME_PATTERN); + } + + /** + * get the time of the specified date after given days + * + * @param date the specified date + * @param day day distance + * @return the format string of time + */ + public static String addDays(String date, int day, String pattern) { + if (date == null) { + return ""; + } + + if (date.equals("")) { + return ""; + } + + if (day == 0) { + return date; + } + + try { + SimpleDateFormat dateFormat = new SimpleDateFormat(pattern); + Calendar calendar = dateFormat.getCalendar(); + + calendar.setTime(dateFormat.parse(date)); + calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + day); + return dateFormat.format(calendar.getTime()); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + /** + * change timestamp to formatted string + * + * @param t Timestamp + * @param sFmt date format + * @return formatted string + */ + public static String formatTimestamp(Timestamp t, String sFmt) { + if (t == null || StringUtils.isBlank(sFmt)) { + return ""; + } + + t.setNanos(0); + + DateFormat ft = new SimpleDateFormat(sFmt); + String str = ""; + + try { + str = ft.format(t); + } catch (NullPointerException ex) { + throw new RuntimeException(ex); + } + return str; + } + + /** + * change string to Timestamp 如果传入的String是数字格式的则优先会转化成Long构造Date + * + * @param str formatted timestamp string + * @param sFmt string format + * @return timestamp + * @deprecated plz use Calendar.toDate(String sDate, String sFmt) + */ + public static Timestamp parseString(String str, String sFmt) { + if ((str == null) || str.equals("")) { + return null; + } + + try { + long time = Long.parseLong(str); + + return new Timestamp(time); + } catch (Exception ex) { + try { + DateFormat df = new SimpleDateFormat(sFmt); + Date dt = df.parse(str); + + return new Timestamp(dt.getTime()); + } catch (Exception pe) { + try { + return Timestamp.valueOf(str); + } catch (Exception e) { + return null; + } + } + } + } + + /** + * return current date + * + * @return current date + */ + public static Date getCurrentDate() { + return new Date(System.currentTimeMillis()); + } + + /** + * return current calendar instance + * + * @return Calendar + */ + public static Calendar getCurrentCalendar() { + return Calendar.getInstance(); + } + + /** + * return current time + * + * @return current time + */ + public static Timestamp getCurrentDateTime() { + return new Timestamp(System.currentTimeMillis()); + } + + /** + * 获取年份 + * + * @param date Date + * @return int + */ + public static final int getYear(Date date) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + return calendar.get(Calendar.YEAR); + } + + /** + * 获取年份 + * + * @param millis long + * @return int + */ + public static final int getYear(long millis) { + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(millis); + return calendar.get(Calendar.YEAR); + } + + /** + * 获取月份 + * + * @param date Date + * @return int + */ + public static final int getMonth(Date date) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + return calendar.get(Calendar.MONTH) + 1; + } + + /** + * 获取月份 + * + * @param millis long + * @return int + */ + public static final int getMonth(long millis) { + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(millis); + return calendar.get(Calendar.MONTH) + 1; + } + + /** + * 获取日期 + * + * @param date Date + * @return int + */ + public static final int getDate(Date date) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + return calendar.get(Calendar.DATE); + } + + /** + * 获取日期 + * + * @param millis long + * @return int + */ + public static final int getDate(long millis) { + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(millis); + return calendar.get(Calendar.DATE); + } + + /** + * 获取小时 + * + * @param date Date + * @return int + */ + public static final int getHour(Date date) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + return calendar.get(Calendar.HOUR_OF_DAY); + } + + /** + * 获取小时 + * + * @param millis long + * @return int + */ + public static final int getHour(long millis) { + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(millis); + return calendar.get(Calendar.HOUR_OF_DAY); + } + + /** + * 把日期后的时间归0 变成(yyyy-MM-dd 00:00:00:000) + * + * @param fullDate Date + * @return Date + */ + public static final Date zerolizedTime(Date fullDate) { + Calendar cal = Calendar.getInstance(); + + cal.setTime(fullDate); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + return cal.getTime(); + } +} \ No newline at end of file diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/CommonUtil.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/CommonUtil.java new file mode 100644 index 00000000..899cd72b --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/CommonUtil.java @@ -0,0 +1,156 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common; + +import com.aliyun.polardbx.binlog.canal.core.model.BinlogPosition; +import com.aliyun.polardbx.binlog.domain.po.RplTask; +import com.aliyun.polardbx.rpl.taskmeta.ServiceType; +import org.apache.commons.lang3.StringUtils; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * @author shicai.xsc 2021/1/14 17:50 + * @since 5.0.0.0 + */ +public class CommonUtil { + + public static String createInitialBinlogPosition() { + String timeStr = new SimpleDateFormat(RplConstants.DEFAULT_DATE_FORMAT).format(System.currentTimeMillis()); + return CommonUtil.getRollBackBinlogPositon(timeStr); + } + + public static boolean isMeaninglessBinlogFileName(BinlogPosition binlogPosition) { + return (StringUtils.isBlank(binlogPosition.getFileName()) || binlogPosition.getFileName().equals("0")); + } + + public static int comparePosition(String positionA, String positionB) { + List detailsA = parsePosition(positionA); + List detailsB = parsePosition(positionB); + + int res = StringUtils.compare(detailsA.get(0), detailsB.get(0)); + if (res != 0) { + return res; + } + + return StringUtils.compare(detailsA.get(1), detailsB.get(1)); + } + + public static List parsePosition(String position) { + // mysql_bin.000012:0000002388#1.1611938857 + List details = new ArrayList<>(); + String[] tokens = position.split("#"); + + String logFile = StringUtils.split(tokens[0], ":")[0]; + String logPos = StringUtils.split(tokens[0], ":")[1]; + details.add(logFile); + details.add(trimLeftAll(logPos, '0')); + + // if (tokens.length > 1 && tokens[1].contains(".")) { + // String rawTimeStamp = StringUtils.split(position, ".")[1]; + // Date date = new Date(rawTimeStamp + "000"); + // String timeStamp = new + // SimpleDateFormat(RplConstants.DEFAULT_DATE_FORMAT).format(date); + // details.add(timeStamp); + // } + + return details; + } + + public static String removeBracket(String s) { + s = s.trim(); + s = trimLeftOne(s, '('); + s = trimRightOne(s, ')'); + return s; + } + + public static String trimLeftOne(String s, char c) { + if (s.length() > 0 && s.charAt(0) == c) { + return s.substring(1); + } + return s; + } + + public static String trimRightOne(String s, char c) { + if (s.length() > 0 && s.charAt(s.length() - 1) == c) { + return s.substring(0, s.length() - 1); + } + return s; + } + + public static String trimLeftAll(String s, char c) { + int i = 0; + while (i < s.length() && s.charAt(i) == c) { + i++; + } + return s.substring(i); + } + + public static String getCurrentTime() { + Date date = new Date(); + return new SimpleDateFormat(RplConstants.DEFAULT_DATE_FORMAT).format(date); + } + + public static Map handleArgs(String arg) { + Map propMap = new HashMap(); + String[] argpiece = arg.split(" "); + for (String argstr : argpiece) { + String[] kv = argstr.split("="); + if (kv.length == 2) { + propMap.put(kv[0], kv[1]); + } else if (kv.length == 1) { + propMap.put(kv[0], StringUtils.EMPTY); + } else { + throw new RuntimeException("parameter format need to like: key1=value1 key2=value2 ..."); + } + } + return propMap; + } + + /** + * 传入2015-04-16 08:00:00格式的时间字符串,返回这个时间对应的binlog位点 + */ + private static String getRollBackBinlogPositon(String timeStr) { + Date date = CalendarUtil.toDate(timeStr, CalendarUtil.TIME_PATTERN); + if (date == null) { + return null; + } + long postionTime = date.getTime() / 1000; + return "0:0#" + RplConstants.ROLLBACK_STRING + "." + postionTime; + } + + /** + * 任务名称构建 + */ + public static String buildRplTaskName(RplTask rplTask) { + StringBuilder sb = new StringBuilder(); + sb.append("F").append(rplTask.getStateMachineId()).append("_").append(ServiceType.from(rplTask.getType())) + .append("_").append(rplTask.getId()); + return sb.toString(); + } + + public static String getRplInitialPosition() { + return "0:4#0.0"; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/DataCompareUtil.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/DataCompareUtil.java new file mode 100644 index 00000000..6889d744 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/DataCompareUtil.java @@ -0,0 +1,295 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common; + +import java.lang.reflect.Array; +import java.math.BigDecimal; +import java.sql.Types; +import java.util.Date; + +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.math.util.MathUtils; + +/** + * @author 燧木 + */ +public class DataCompareUtil { + /** + * 比较源值与目标值是否相同 + * + * @return boolean + */ + public static boolean compareValue(Object sourceValue, int sourceColumnType, Object targetValue, + int targetColumnType) { + if (sourceValue == null && targetValue == null) { + return true; + } + + if (sourceValue != null && targetValue != null) { + if (sourceValue.equals(targetValue)) { + return true; + } + // custom define + if (sourceValue instanceof java.util.Date && targetValue instanceof java.util.Date) { + boolean result = dateValueEquals((java.util.Date) sourceValue, (java.util.Date) targetValue); + if (!result) { + String v1 = getDateString(sourceValue); + String v2 = getDateString(targetValue); + // 2012-02-02 02:02:02 与 2012-02-02 肯定是一种包含关系 + if ((v1.contains(v2) || v2.contains(v1))) { + return true; + } else { + // 考虑精度差一秒,四舍五入 + if (isDateRoundOneSencond(v1, v2)) { + return true; + } + return false; + } + } else { + return true; + } + } else if (isDateType(sourceColumnType) && isDateType(targetColumnType)) { + // 2012-02-02 02:02:02 与 2012-02-02 肯定是一种包含关系 + String v1 = getDateString(sourceValue); + String v2 = getDateString(targetValue); + if ((v1.contains(v2) || v2.contains(v1))) { + return true; + } else { + // 考虑精度差一秒,四舍五入 + if (isDateRoundOneSencond(v1, v2)) { + return true; + } + + return false; + } + } else if (Number.class.isAssignableFrom(sourceValue.getClass()) + && Number.class.isAssignableFrom(targetValue.getClass())) { + String v1 = getNumberString(sourceValue); + String v2 = getNumberString(targetValue); + boolean result = v1.equals(v2); + if (!result) { + // 如果出现浮点数,使用浮点计数法再对比一次 + if (isRealType(sourceColumnType) || isRealType(targetColumnType)) { + v1 = getRealString(sourceValue); + v2 = getRealString(targetValue); + result = v1.equals(v2); + if (!result) { + return compareBigDecimalStr(v1, v2); + } + } + } + + return result; + } else if (sourceValue.getClass().isArray() && targetValue.getClass().isArray()) { + boolean result = true; + if (Array.getLength(sourceValue) == Array.getLength(targetValue)) { + int length = Array.getLength(sourceValue); + for (int i = 0; i < length; i++) { + result &= ObjectUtils.equals(Array.get(sourceValue, i), Array.get(targetValue, i)); + } + + if (result) { + return true; + } + } + + return false; + } else if (sourceColumnType == Types.BOOLEAN || sourceColumnType == Types.BIT + || targetColumnType == Types.BOOLEAN || targetColumnType == Types.BIT) { + + String boolStr, theOtherStr; + if (sourceColumnType == Types.BOOLEAN || sourceColumnType == Types.BIT) { + boolStr = sourceValue.toString(); + theOtherStr = targetValue.toString(); + } else { + boolStr = targetValue.toString(); + theOtherStr = sourceValue.toString(); + } + + if (isTrueValue(boolStr) && isTrueValue(theOtherStr)) { + return true; + } + if (isFalseValue(boolStr) && isFalseValue(theOtherStr)) { + return true; + } + + return false; + } + + // 通用比较 + boolean result = sourceValue.toString().equals(targetValue.toString()); + if (result) { + return true; + } + + if (isNumberType(sourceColumnType) && isNumberType(targetColumnType)) { + String v1 = getNumberString(sourceValue); + String v2 = getNumberString(targetValue); + return v1.equals(v2); + } + + // 特殊情况都匹配不上 + return false; + } else { + // 可能一个为空,另一个不为空的情况 + return false; + } + } + + private static boolean isTrueValue(String value) { + return ("true".equalsIgnoreCase(value) || "1".equals(value)); + } + + private static boolean isFalseValue(String value) { + return ("false".equalsIgnoreCase(value) || "0".equals(value)); + } + + private static String getNumberString(Object sourceValue) { + String v1; + if (sourceValue instanceof BigDecimal) { + v1 = ((BigDecimal) sourceValue).toPlainString(); + } else if (sourceValue instanceof Float) { + v1 = new BigDecimal(sourceValue.toString()).toPlainString(); + } else if (sourceValue instanceof Double) { + v1 = new BigDecimal((double) sourceValue).toPlainString(); + } else { + v1 = sourceValue.toString(); + } + + if (StringUtils.indexOf(v1, ".") != -1) { + v1 = StringUtils.stripEnd(v1, "0");// 如果0是末尾,则删除之 + v1 = StringUtils.stripEnd(v1, ".");// 如果.是末尾,则删除之 + } + return v1; + } + + private static String getRealString(Object sourceValue) { + String v1; + if (sourceValue instanceof BigDecimal) { + v1 = String.valueOf(((BigDecimal) sourceValue).doubleValue()); + } else { + v1 = String.valueOf(new BigDecimal(sourceValue.toString()).doubleValue()); + } + + if (StringUtils.indexOf(v1, ".") != -1) { + v1 = StringUtils.stripEnd(v1, "0");// 如果0是末尾,则删除之 + v1 = StringUtils.stripEnd(v1, ".");// 如果.是末尾,则删除之 + } + return v1; + } + + private static String getDateString(Object date) { + // 处理一下2017-01-01 22:00:00.00 + String str = date.toString(); + if (StringUtils.indexOf(str, ".") != -1) { + str = StringUtils.stripEnd(str, "0");// 如果0是末尾,则删除之 + str = StringUtils.stripEnd(str, ".");// 如果.是末尾,则删除之 + } + return str; + } + + private static boolean dateValueEquals(Date source, Date target) { + return source.getTime() == target.getTime(); + } + + private static boolean isDateType(int type) { + switch (type) { + case Types.DATE: + case Types.TIME: + case Types.TIMESTAMP: + return true; + default: + return false; + } + } + + private static boolean isNumberType(int type) { + switch (type) { + case Types.TINYINT: + case Types.SMALLINT: + case Types.INTEGER: + case Types.BIGINT: + case Types.NUMERIC: + case Types.DECIMAL: + case Types.DOUBLE: + case Types.FLOAT: + case Types.REAL: + return true; + default: + return false; + } + } + + private static boolean isRealType(int type) { + switch (type) { + case Types.DOUBLE: + case Types.FLOAT: + case Types.REAL: + case 100: + case 101: + return true; + default: + return false; + } + } + + private static boolean compareBigDecimalStr(String source, String target) { + if (StringUtils.equals(source, target)) { + return true; + } + if (source == null || target == null) { + return false; + } + // 精度 + int srcPrecision = 0; + int tgtPrecision = 0; + String sourceVal = source; + String targetVal = target; + // 截取E的前部分 + if (source.contains(".") && source.contains("E")) { + srcPrecision = StringUtils.substringBetween(source, ".", "E").length(); + sourceVal = StringUtils.substring(source, 0, source.indexOf("E")); + } + if (target.contains(".") && target.contains("E")) { + tgtPrecision = StringUtils.substringBetween(target, ".", "E").length(); + targetVal = StringUtils.substring(target, 0, target.indexOf("E")); + } + if (StringUtils.equals(sourceVal, targetVal)) { + return true; + } + // 根据源数据精度进行折算 + if (srcPrecision != 0 && tgtPrecision >= srcPrecision) { + targetVal = String.valueOf(MathUtils.round(Double.valueOf(targetVal), srcPrecision)); + return sourceVal.equals(targetVal); + } + return StringUtils.equals(source, target); + } + + private static boolean isDateRoundOneSencond(String source, String target) { + Date v1 = DateParseUtil.str_to_time(source); + Date v2 = DateParseUtil.str_to_time(target); + //异常情况 返回false + if (v1 == null || v2 == null) { + return false; + } + long vs1 = v1.getTime() / 1000; + long vs2 = v2.getTime() / 1000; + return Math.abs(vs1 - vs2) == 1; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/DataSourceUtil.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/DataSourceUtil.java new file mode 100644 index 00000000..46c2b119 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/DataSourceUtil.java @@ -0,0 +1,475 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common; + +import com.alibaba.druid.pool.DruidDataSource; +import com.alibaba.druid.pool.vendor.MySqlExceptionSorter; +import com.alibaba.druid.pool.vendor.MySqlValidConnectionChecker; +import com.alibaba.fastjson.JSON; +import com.google.common.collect.Maps; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Properties; + +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.jdbc.support.JdbcUtils; + +/** + * @author shicai.xsc 2020/12/1 22:36 + * @since 5.0.0.0 + */ +@Slf4j +public class DataSourceUtil { + + /** + * in seconds. default 2 hours + */ + private static int QUERY_TIMEOUT = 7200; + public static final List CONSTRAINT_TYPE_LIST = new ArrayList<>(); + public static Map DEFAULT_MYSQL_CONNECTION_PROPERTIES = Maps.newHashMap(); + + static { + CONSTRAINT_TYPE_LIST.add("PRIMARY KEY"); + CONSTRAINT_TYPE_LIST.add("UNIQUE"); + // CONSTRAINT_TYPE_LIST.add("__#alibaba_rds_row_id#__"); + + // 开启多语句能力 + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("allowMultiQueries", "true"); + // 全量目标数据源加上这个批量的参数 + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("rewriteBatchedStatements", "true"); + // 关闭每次读取read-only状态,提升batch性能 + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("readOnlyPropagatesToServer", "false"); + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("connectTimeout", "1000"); + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("autoReconnect", "true"); + // 将0000-00-00的时间类型返回null + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("zeroDateTimeBehavior", "convertToNull"); + // 直接返回字符串,不做year转换date处理 + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("yearIsDateType", "false"); + // 返回时间类型的字符串,不做时区处理 + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("noDatetimeStringSync", "true"); + // 不处理tinyint转为bit + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("tinyInt1isBit", "false"); + // 16MB,兼容一下ADS不支持mysql,5.1.38+的server变量查询为大写的问题,人肉指定一下最大包大小 + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("maxAllowedPacket", "1073741824"); + // net_write_timeout + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("netTimeoutForStreamingResults", "72000"); + } + + @FunctionalInterface + public static interface ResultSetMapper { + T process(ResultSet rs) throws SQLException; + } + +// public static String getCharset(String ip, int port, String dbName, String user, String passwd) throws Exception { +// DruidDataSource dataSource = null; +// PreparedStatement stmt = null; +// Connection conn = null; +// ResultSet rs = null; +// String sql = "show variables like 'character_set_database'"; +// +// try { +// dataSource = createDruidMySqlDataSource(ip, port, dbName, user, passwd, "", 1, 1, null, null); +// conn = dataSource.getConnection(); +// stmt = conn.prepareStatement(sql); +// rs = stmt.executeQuery(sql); +// if (rs.next()) { +// return rs.getString("Value"); +// } +// return ""; +// } catch (SQLException e) { +// log.error("failed in getCharset: {}", sql, e); +// throw e; +// } finally { +// DataSourceUtil.closeQuery(rs, stmt, conn); +// dataSource.close(); +// } +// } + + /** + * Get key columns from db. It does NOT close data source. + */ + public static Map> getKeyColumnsInDB(List tables, DruidDataSource dataSource) throws Exception { + PreparedStatement stmt = null; + Connection conn = null; + ResultSet rs = null; + Map> ret; + try { + if (null == tables || tables.isEmpty()) { + tables = getTables(dataSource); + } + ret = new HashMap<>(); + for (String table : tables) { + List keyColumns = getKeyColumnsInTable(dataSource, table); + ret.put(table, keyColumns); + } + } catch (Exception e) { + throw e; + } finally { + DataSourceUtil.closeQuery(rs, stmt, conn); + } + return ret; + } + + /** + * Check if table is empty + */ + public static boolean isEmpty(DruidDataSource ds, String tableName) throws Exception { + int cnt = getTableSize(ds, tableName); + if (cnt > 0) { + return false; + } else { + return true; + } + } + + /** + * Get table size + */ + public static int getTableSize(DruidDataSource ds, String tableName) throws Exception { + Connection conn = ds.getConnection(); + String sql = String.format("SELECT COUNT(1) FROM `%s`.`%s`", conn.getCatalog(), tableName); + PreparedStatement stmt = conn.prepareStatement(sql); + ResultSet rs = null; + int count = 0; + try { + rs = stmt.executeQuery(sql); + while (rs.next()) { + count = rs.getInt(1); + } + } catch (SQLException e) { + log.error("Exception in finding table size", sql, e); + throw e; + } finally { + DataSourceUtil.closeQuery(rs, stmt, conn); + } + return count; + } + + /** + * Get key column out from one db table + * NOTE: This method DOESN'T close data source + * @param dataSource + * @param tableName + * @return + * @throws SQLException + */ + public static List getKeyColumnsInTable(DruidDataSource dataSource, String tableName) throws Exception { + Connection conn = dataSource.getConnection(); + PreparedStatement stmt = null; + ResultSet rs = null; + + /** + * This SQL should return result looks like this + * +-----------------+-------------+ + * | CONSTRAINT TYPE | COLUMN_NAME | + * +-----------------+-------------+ + * | PRIMARY KEY | id | + * +-----------------+-------------+ + * | UNIQUE | name | + * +-----------------+-------------+ + * | FOREIGN KEY | order_id | + * +-----------------+-------------+ + */ + String sql = String.format("SELECT t.CONSTRAINT_TYPE, k.COLUMN_NAME\n" + + "FROM information_schema.table_constraints t\n" + + " LEFT JOIN information_schema.key_column_usage k\n" + + " USING(constraint_name,table_schema,table_name)\n" + + "WHERE t.table_schema='%s'\n" + + " AND t.table_name='%s'", conn.getCatalog(), tableName); + log.debug("Try retrieving keys from table. SQL: {}", sql); + List keyTypeList = new ArrayList<>(); + List keyList = new ArrayList<>(); + try { + stmt = conn.prepareStatement(sql); + rs = stmt.executeQuery(); + while (rs.next()) { + keyTypeList.add(rs.getString(1)); + keyList.add(rs.getString(2)); + } + } catch (SQLException e) { + log.error("failed in getTables: {}", sql, e); + throw e; + } finally { + DataSourceUtil.closeQuery(rs, stmt, conn); + } + + List keyColumns = new ArrayList<>(); + + for (int i = 0; i < keyList.size(); i++) { + String type = keyTypeList.get(i); + String key = keyList.get(i); + if (CONSTRAINT_TYPE_LIST.contains(type)) { + keyColumns.add(key); + } + } + + return keyColumns; + } + + /** + * Get min value of column from a table. It does NOT close data source + */ + public static String getMin(DruidDataSource dataSource, String tableName, String columnName) throws Exception { + Connection conn = dataSource.getConnection(); + String sql = String.format("SELECT MIN(`%s`) FROM `%s`.`%s`", columnName, conn.getCatalog(), tableName); + PreparedStatement stmt = conn.prepareStatement(sql); + ResultSet rs = null; + String minVal = null; + try { + rs = stmt.executeQuery(sql); + while (rs.next()) { + minVal = rs.getString(1); + } + } catch (SQLException e) { + log.error("Exception in finding min value", sql, e); + throw e; + } finally { + DataSourceUtil.closeQuery(rs, stmt, conn); + } + return minVal; + } + + /** + * Get max value of column from a table. It does NOT close data source + */ + public static String getMax(DruidDataSource dataSource, String tableName, String columnName) throws Exception { + String sql = null; + String maxVal; + try (Connection conn = dataSource.getConnection()) { + sql = String.format("SELECT MAX(`%s`) FROM `%s`.`%s`", columnName, conn.getCatalog(), tableName); + maxVal = query(conn, sql, 1, 3, rs -> { + if (rs.next()) { + return rs.getString(1); + } + return ""; + }); + } catch (Exception e) { + log.error("Exception in finding max value", sql, e); + throw e; + } + return maxVal; + } + + /** + * Get columns from table. It does NOT close data source + */ + public static List getColumns(DruidDataSource dataSource, String tableName) throws Exception { + PreparedStatement stmt = null; + Connection conn = null; + ResultSet rs = null; + List columns = new ArrayList<>(); + String sql = null; + try { + conn = dataSource.getConnection(); + sql = String.format( + "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s'", + conn.getCatalog(), tableName); + stmt = conn.prepareStatement(sql); + rs = stmt.executeQuery(sql); + while (rs.next()) { + columns.add(rs.getString(1)); + } + } catch (SQLException e) { + log.error("Exception in finding columns. SQL: {}", sql, e); + throw e; + } finally { + DataSourceUtil.closeQuery(rs, stmt, conn); + } + return columns; + } + + /** + * Get all tables from db. It does NOT close data source. + */ + public static List getTables(DruidDataSource dataSource) throws Exception { + String sql = "SHOW TABLES"; + List tables; + try (Connection conn = dataSource.getConnection()) { + tables = query(conn, sql, Integer.MIN_VALUE, 3, rs -> { + List list = new ArrayList<>(); + while (rs.next()) { + list.add(rs.getString(1)); + } + return list; + }); + } catch (Exception e) { + log.error("failed in getTables: {}", sql, e); + throw e; + } + return tables; + } + + /** + * Execute query and process with mapper + */ + public static T query(Connection conn, String query, int fetchSize, int tryTimes, ResultSetMapper mapper) throws SQLException { + Objects.requireNonNull(mapper, "ResultSetMapper should not be null"); + for (int i = 0; i < tryTimes; i++) { + try (Statement stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, + ResultSet.CONCUR_READ_ONLY)) { + stmt.setFetchSize(fetchSize); + log.debug("Executing query: {}", query); + try (ResultSet rs = query(stmt, query)) { + return mapper.process(rs); + } + } catch (Exception e) { + log.error("TryTimes: {}, current round: {}, Error query: {}", tryTimes, i, query); + try { + Thread.sleep(1000); + } catch (InterruptedException e2) { + log.error("Query retry interrupted.", e2); + } + if (i == tryTimes - 1) { + throw e; + } + } + } + return null; + } + + /** + * SQL query helper + */ + public static ResultSet query(Connection conn, String sql, int fetchSize) + throws SQLException { + return query(conn, sql, fetchSize, QUERY_TIMEOUT); + } + + /** + * SQL query helper + */ + public static ResultSet query(Connection conn, String sql, int fetchSize, int queryTimeout) + throws SQLException { + Statement stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); + stmt.setFetchSize(fetchSize); + stmt.setQueryTimeout(queryTimeout); + return query(stmt, sql); + } + + /** + * Query helper + */ + public static ResultSet query(Statement stmt, String sql) throws SQLException { + return stmt.executeQuery(sql); + } + + public static void closeQuery(ResultSet rs, Statement stmt, Connection conn) { + JdbcUtils.closeResultSet(rs); + JdbcUtils.closeStatement(stmt); + JdbcUtils.closeConnection(conn); + } + + public static DruidDataSource createDruidMySqlDataSource(boolean usePolarxPoolCN, String ip, int port, + String dbName, String user, + String passwd, String encoding, int minPoolSize, + int maxPoolSize, Map params, + List newConnectionSQLs) throws Exception { + if (usePolarxPoolCN) { + DruidDataSourceWrapper dataSource = + new DruidDataSourceWrapper(dbName, user, passwd, encoding, minPoolSize, maxPoolSize, params, + newConnectionSQLs); + dataSource.init(); + return dataSource; + } else { + return createDruidMySqlDataSource(ip, port, dbName, user, passwd, encoding, minPoolSize, maxPoolSize, + params, newConnectionSQLs); + } + } + + public static DruidDataSource createDruidMySqlDataSource(String ip, int port, String dbName, String user, + String passwd, String encoding, int minPoolSize, + int maxPoolSize, Map params, + List newConnectionSQLs) throws Exception { + checkParams(ip, port, user, maxPoolSize, minPoolSize); + DruidDataSource ds = new DruidDataSource(); + String url = "jdbc:mysql://" + ip + ":" + port; + if (StringUtils.isNotBlank(dbName)) { + url = url + "/" + dbName; + } + // remove warning msg + url = url + "?useSSL=false"; + ds.setUrl(url); + ds.setUsername(user); + ds.setPassword(passwd); + ds.setTestWhileIdle(true); + ds.setTestOnBorrow(false); + ds.setTestOnReturn(false); + ds.setNotFullTimeoutRetryCount(2); + ds.setValidConnectionCheckerClassName(MySqlValidConnectionChecker.class.getName()); + ds.setExceptionSorterClassName(MySqlExceptionSorter.class.getName()); + ds.setValidationQuery("SELECT 1"); + ds.setInitialSize(minPoolSize); + ds.setMinIdle(minPoolSize); + ds.setMaxActive(maxPoolSize); + ds.setMaxWait(10 * 1000); + ds.setTimeBetweenEvictionRunsMillis(60 * 1000); + ds.setMinEvictableIdleTimeMillis(50 * 1000); + ds.setUseUnfairLock(true); + Properties prop = new Properties(); + encoding = StringUtils.isNotBlank(encoding) ? encoding : "utf8mb4"; + if (StringUtils.isNotEmpty(encoding)) { + if (StringUtils.equalsIgnoreCase(encoding, "utf8mb4")) { + prop.put("characterEncoding", "utf8"); + if (newConnectionSQLs == null) { + newConnectionSQLs = new ArrayList<>(); + } + newConnectionSQLs.add("set names utf8mb4"); + } else { + prop.put("characterEncoding", encoding); + } + } + + prop.putAll(DEFAULT_MYSQL_CONNECTION_PROPERTIES); + if (params != null) { + prop.putAll(params); + } + ds.setConnectProperties(prop); + if (newConnectionSQLs != null && newConnectionSQLs.size() > 0) { + ds.setConnectionInitSqls(newConnectionSQLs); + log.info("druid setConnectionInitSqls, {}", JSON.toJSONString(newConnectionSQLs)); + } + try { + ds.init(); + } catch (Exception e) { + throw new Exception("create druid datasource occur exception, with url : " + url + ", user : " + user + + ", passwd : " + passwd, + e); + } + return ds; + } + + private static void checkParams(String ip, int port, String user, int maxPoolSize, int minPoolSize) { + if (StringUtils.isBlank(ip) || port == 0 || StringUtils.isBlank(user)) { + throw new IllegalArgumentException("ip or port or schema or user is blank, check the pass params, ip:" + ip + + ", port:" + port + ", user:" + user); + } + if (maxPoolSize < 0 || minPoolSize < 0) { + throw new IllegalArgumentException("maxPoolSize and minPoolSize must be positive"); + } + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/DateParseUtil.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/DateParseUtil.java new file mode 100644 index 00000000..88bd537e --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/DateParseUtil.java @@ -0,0 +1,629 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common; + +import java.util.Date; + +/** + * MySQL针对时间解析的java版实现 + * + * @author agapple 2017年4月19日 上午11:12:20 + * @since 3.2.3 + */ +public class DateParseUtil { + + public static final int TIME_DATETIME_ONLY = 0; + public static int internal_format_positions[] = {0, 1, 2, 3, 4, 5, 6, 255}; + public static final int MAX_DATE_PARTS = 8; + // long log_10_int[] = new long[] { 1, 10, 100, 1000, 10000L, 100000L, + // 1000000L, 10000000L, 100000000L }; + public static final int YY_PART_YEAR = 70; + + @SuppressWarnings({"deprecation", "unused"}) + public static Date str_to_time(String str) { + int length = str.length(); + int was_cut; + Date time = new Date(0); + int field_length; + int digits; + int year_length = 0; + int add_hours = 0, start_loop; + long not_zero_date, allow_space; + boolean is_internal_format; + int pos; + int last_field_pos = 0; + int cur_pos = 0; + int i; + int date[] = new int[MAX_DATE_PARTS]; + int date_len[] = new int[MAX_DATE_PARTS]; + int number_of_fields; + boolean found_delimitier = false, found_space = false; + int frac_pos; + int frac_len; + // DBUG_ENTER("str_to_datetime"); + // DBUG_PRINT("ENTER",("str: %.*s",length,str)); + // + // LINT_INIT(field_length); + + was_cut = 0; + + /* Skip space at start */ + str = str.trim(); + // for (; str != end && my_isspace(&my_charset_latin1, *str) ; str++) + // ; + int end = str.length(); + if (str.isEmpty() || !isdigit(str.charAt(0))) { + was_cut = 1; + return null; + } + + is_internal_format = false; + int format_position[] = internal_format_positions; + + for (pos = 0; pos < str.length() && (isdigit(str.charAt(pos)) || str.charAt(pos) == 'T'); pos++) { + } + ; + digits = pos; + // digits= (uint) (pos-str); + start_loop = 0; /* Start of scan loop */ + date_len[format_position[0]] = 0; /* Length of year field */ + + if (pos == str.length() || str.charAt(pos) == '.') { + /* Found date in internal format (only numbers like YYYYMMDD) */ + year_length = (digits == 4 || digits == 8 || digits >= 14) ? 4 : 2; + field_length = year_length; + is_internal_format = true; + format_position = internal_format_positions; + } else { + if (format_position[0] >= 3) /* If year is after HHMMDD */ { + + while (pos < end && !my_isspace(str.charAt(pos))) { + pos++; + } + while (pos < end && !isdigit(str.charAt(pos))) { + pos++; + } + if (pos == end) { + /* Date field. Set hour, minutes and seconds to 0 */ + date[0] = date[1] = date[2] = date[3] = date[4] = 0; + start_loop = 5; /* Start with first date part */ + } + } + + field_length = format_position[0] == 0 ? 4 : 2; + } + + /* + * Only allow space in the first "part" of the datetime field and: - after days, part seconds - before and after + * AM/PM (handled by code later) 2003-03-03 20:00:20 AM 20:00:20.000000 AM 03-03-2000 + */ + i = max(format_position[0], format_position[1]); + + if (i < format_position[2]) { + i = format_position[2]; + } + // set_if_bigger(i,format_position[2]); + allow_space = ((1 << i) | (1 << format_position[6])); + allow_space &= (1 | 2 | 4 | 8); + + not_zero_date = 0; + for (i = start_loop; i < MAX_DATE_PARTS - 1 && cur_pos != end && isdigit(str.charAt(cur_pos)); i++) { + int start = cur_pos; + int tmp_value = (str.charAt(cur_pos++) - '0'); + + boolean scan_until_delim = !is_internal_format && ((i != format_position[6])); + + while (cur_pos != end && isdigit(str.charAt(cur_pos)) && (scan_until_delim || (--field_length != 0))) { + tmp_value = tmp_value * 10 + (str.charAt(cur_pos) - '0'); + cur_pos++; + } + date_len[i] = (cur_pos - start); + if (tmp_value > 999999) /* Impossible date part */ { + was_cut = 1; + return null; + } + date[i] = tmp_value; + not_zero_date |= tmp_value; + + /* Length of next field */ + field_length = format_position[i + 1] == 0 ? 4 : 2; + + if ((last_field_pos = cur_pos) == end) { + i++; /* Register last found part */ + break; + } + if (i == format_position[2] && str.charAt(cur_pos) == 'T') { + cur_pos++; /* ISO8601: CCYYMMDDThhmmss */ + continue; + } + if (i == format_position[5]) /* Seconds */ { + if (str.charAt(cur_pos) == '.') /* Followed by part seconds */ { + cur_pos++; + field_length = 6; /* 6 digits */ + } + continue; + } + while (cur_pos != end && (my_ispunct(str.charAt(cur_pos)) || my_isspace(str.charAt(cur_pos)))) { + if (my_isspace(str.charAt(cur_pos))) { + if (!((allow_space & (1 << i)) != 0)) { + was_cut = 1; + return null; + } + found_space = true; + } + cur_pos++; + found_delimitier = true; /* Should be a 'normal' date */ + } + /* Check if next position is AM/PM */ + if (i == format_position[6]) /* Seconds, time for AM/PM */ { + i++; /* Skip AM/PM part */ + if (format_position[7] != 255) /* If using AM/PM */ { + if (cur_pos + 2 <= end && (str.charAt(cur_pos + 1) == 'M' || str.charAt(cur_pos) + 1 == 'm')) { + if (str.charAt(cur_pos) == 'p' || str.charAt(cur_pos) == 'P') { + add_hours = 12; + } else if (str.charAt(cur_pos) != 'a' || str.charAt(cur_pos) != 'A') { + continue; /* + * Not AM / PM + */ + } + str += 2; /* Skip AM/PM */ + /* Skip space after AM/PM */ + while (cur_pos != end && my_isspace(str.charAt(cur_pos))) { + cur_pos++; + } + } + } + } + last_field_pos = cur_pos; + } + + cur_pos = last_field_pos; + + number_of_fields = i - start_loop; + while (i < MAX_DATE_PARTS) { + date_len[i] = 0; + date[i++] = 0; + } + + if (!is_internal_format) { + year_length = date_len[format_position[0]]; + if (!(year_length != 0)) /* Year must be specified */ { + was_cut = 1; + return null; + } + time.setYear(date[format_position[0]] - 1900); + // l_time->year= date[(uint) format_position[0]]; + time.setMonth(date[format_position[1]] - 1); + // l_time->month= date[(uint) format_position[1]]; + time.setDate(date[format_position[2]]); + // l_time->day= date[(uint) format_position[2]]; + time.setHours(date[format_position[3]]); + time.setMinutes(date[format_position[4]]); + time.setSeconds(date[format_position[5]]); + // l_time->hour= date[(uint) format_position[3]]; + // l_time->minute= date[(uint) format_position[4]]; + // l_time->second= date[(uint) format_position[5]]; + + frac_pos = format_position[6]; + frac_len = date_len[frac_pos]; + // if (frac_len < 6) + // date[frac_pos]*= log_10_int[6 - frac_len]; + // l_time->second_part= date[frac_pos]; + + if (format_position[7] != 255) { + if (time.getHours() > 12) { + was_cut = 1; + return null; + } + time.setHours(time.getHours() % 12 + add_hours); + } + } else { + time.setYear(date[0] - 1900); + time.setMonth(date[1] - 1); + time.setDate(date[2]); + time.setHours(date[3]); + time.setMinutes(date[4]); + time.setSeconds(date[5]); + // if (date_len[6] < 6) + // date[6]*= log_10_int[6 - date_len[6]]; + // l_time->second_part=date[6]; + } + // l_time->neg= 0; + + if (year_length == 2 && (not_zero_date != 0)) { + time.setYear(time.getYear() + (time.getYear() < YY_PART_YEAR ? 2000 : 1900)); + } + // l_time->year+= (l_time->year < YY_PART_YEAR ? 2000 : 1900); + + if (number_of_fields < 3 || time.getYear() > 9999 || time.getMonth() > 12 || time.getDate() > 31 + || time.getHours() > 23 || time.getMinutes() > 59 || time.getMinutes() > 59) { + /* Only give warning for a zero date if there is some garbage after */ + if (!(not_zero_date != 0)) /* If zero date */ { + for (; cur_pos != end; cur_pos++) { + if (!my_isspace(str.charAt(cur_pos))) { + not_zero_date = 1; /* Give warning */ + break; + } + } + } + // was_cut= test(not_zero_date); + return null; + } + + if (check_date(time, not_zero_date != 0, was_cut)) { + return null; + } + + // l_time->time_type= (number_of_fields <= 3 ? + // MYSQL_TIMESTAMP_DATE : MYSQL_TIMESTAMP_DATETIME); + + for (; cur_pos != end; cur_pos++) { + if (!my_isspace(str.charAt(cur_pos))) { + was_cut = 1; + break; + } + } + + return time; + } + + public static boolean check_date(Date time, boolean not_zero_date, int was_cut) { + return false; + } + + private static int uplimits[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + + /** + * 检查日期是否合法,大部分从上面函数借鉴过来 + */ + @SuppressWarnings({"deprecation", "unused"}) + public static Boolean check(String str) { + int length = str.length(); + int was_cut; + Date time = new Date(0); + int field_length; + int digits; + int year_length = 0; + int add_hours = 0, start_loop; + long not_zero_date, allow_space; + boolean is_internal_format; + int pos; + int last_field_pos = 0; + int cur_pos = 0; + int i; + int date[] = new int[MAX_DATE_PARTS]; + int date_len[] = new int[MAX_DATE_PARTS]; + int number_of_fields; + boolean found_delimitier = false, found_space = false; + int frac_pos; + int frac_len; + + was_cut = 0; + + /* Skip space at start */ + str = str.trim(); + int end = str.length(); + if (str.isEmpty() || !isdigit(str.charAt(0))) { + was_cut = 1; + return null; + } + + is_internal_format = false; + /* + * This has to be changed if want to activate different timestamp formats + */ + int format_position[] = internal_format_positions; + + /* + * Calculate number of digits in first part. If length= 8 or >= 14 then year is of format YYYY. (YYYY-MM-DD, + * YYYYMMDD, YYYYYMMDDHHMMSS) + */ + + for (pos = 0; pos < str.length() && (isdigit(str.charAt(pos)) || str.charAt(pos) == 'T'); pos++) { + ; + } + + digits = pos; + // digits= (uint) (pos-str); + start_loop = 0; /* Start of scan loop */ + date_len[format_position[0]] = 0; /* Length of year field */ + + if (pos == str.length() || str.charAt(pos) == '.') { + /* Found date in internal format (only numbers like YYYYMMDD) */ + year_length = (digits == 4 || digits == 8 || digits >= 14) ? 4 : 2; + field_length = year_length; + is_internal_format = true; + format_position = internal_format_positions; + } else { + if (format_position[0] >= 3) /* If year is after HHMMDD */ { + /* + * If year is not in first part then we have to determinate if we got a date field or a datetime field. + * We do this by checking if there is two numbers separated by space in the input. + */ + while (pos < end && !my_isspace(str.charAt(pos))) { + pos++; + } + while (pos < end && !isdigit(str.charAt(pos))) { + pos++; + } + if (pos == end) { + /* Date field. Set hour, minutes and seconds to 0 */ + date[0] = date[1] = date[2] = date[3] = date[4] = 0; + start_loop = 5; /* Start with first date part */ + } + } + + field_length = format_position[0] == 0 ? 4 : 2; + } + + /* + * Only allow space in the first "part" of the datetime field and: - after days, part seconds - before and after + * AM/PM (handled by code later) 2003-03-03 20:00:20 AM 20:00:20.000000 AM 03-03-2000 + */ + i = max(format_position[0], format_position[1]); + + if (i < format_position[2]) { + i = format_position[2]; + } + // set_if_bigger(i,format_position[2]); + allow_space = ((1 << i) | (1 << format_position[6])); + allow_space &= (1 | 2 | 4 | 8); + + not_zero_date = 0; + for (i = start_loop; i < MAX_DATE_PARTS - 1 && cur_pos != end && isdigit(str.charAt(cur_pos)); i++) { + int start = cur_pos; + int tmp_value = (str.charAt(cur_pos++) - '0'); + + /* + * Internal format means no delimiters; every field has a fixed width. Otherwise, we scan until we find a + * delimiter and discard leading zeroes -- except for the microsecond part, where leading zeroes are + * significant, and where we never process more than six digits. + */ + boolean scan_until_delim = !is_internal_format && ((i != format_position[6])); + + while (cur_pos != end && isdigit(str.charAt(cur_pos)) && (scan_until_delim || (--field_length != 0))) { + tmp_value = tmp_value * 10 + (str.charAt(cur_pos) - '0'); + cur_pos++; + } + date_len[i] = (cur_pos - start); + if (tmp_value > 999999) /* Impossible date part */ { + was_cut = 1; + return null; + } + date[i] = tmp_value; + not_zero_date |= tmp_value; + + /* Length of next field */ + field_length = format_position[i + 1] == 0 ? 4 : 2; + + if ((last_field_pos = cur_pos) == end) { + i++; /* Register last found part */ + break; + } + /* Allow a 'T' after day to allow CCYYMMDDT type of fields */ + if (i == format_position[2] && str.charAt(cur_pos) == 'T') { + cur_pos++; /* ISO8601: CCYYMMDDThhmmss */ + continue; + } + if (i == format_position[5]) /* Seconds */ { + if (str.charAt(cur_pos) == '.') /* Followed by part seconds */ { + cur_pos++; + field_length = 6; /* 6 digits */ + } + continue; + } + while (cur_pos != end && (my_ispunct(str.charAt(cur_pos)) || my_isspace(str.charAt(cur_pos)))) { + if (my_isspace(str.charAt(cur_pos))) { + if (!((allow_space & (1 << i)) != 0)) { + was_cut = 1; + return null; + } + found_space = true; + } + cur_pos++; + found_delimitier = true; /* Should be a 'normal' date */ + } + /* Check if next position is AM/PM */ + if (i == format_position[6]) /* Seconds, time for AM/PM */ { + i++; /* Skip AM/PM part */ + if (format_position[7] != 255) /* If using AM/PM */ { + if (cur_pos + 2 <= end && (str.charAt(cur_pos + 1) == 'M' || str.charAt(cur_pos) + 1 == 'm')) { + if (str.charAt(cur_pos) == 'p' || str.charAt(cur_pos) == 'P') { + add_hours = 12; + } else if (str.charAt(cur_pos) != 'a' || str.charAt(cur_pos) != 'A') { + continue; /* + * Not AM / PM + */ + } + str += 2; /* Skip AM/PM */ + /* Skip space after AM/PM */ + while (cur_pos != end && my_isspace(str.charAt(cur_pos))) { + cur_pos++; + } + } + } + } + last_field_pos = cur_pos; + } + + cur_pos = last_field_pos; + + number_of_fields = i - start_loop; + while (i < MAX_DATE_PARTS) { + date_len[i] = 0; + date[i++] = 0; + } + + if (!is_internal_format) { + year_length = date_len[format_position[0]]; + if (!(year_length != 0)) /* Year must be specified */ { + was_cut = 1; + return null; + } + int year = date[format_position[0]]; + int month = date[format_position[1]]; + int day = date[format_position[2]]; + int hours = date[format_position[3]]; + int mins = date[format_position[4]]; + int seconds = date[format_position[5]]; + if (!checkDateTime(year_length, not_zero_date, year, month, day, hours, mins, seconds)) { + return false; + } + time.setYear(date[format_position[0]] - 1900); + // l_time->year= date[(uint) format_position[0]]; + time.setMonth(date[format_position[1]] - 1); + // l_time->month= date[(uint) format_position[1]]; + time.setDate(date[format_position[2]]); + // l_time->day= date[(uint) format_position[2]]; + time.setHours(date[format_position[3]]); + time.setMinutes(date[format_position[4]]); + time.setSeconds(date[format_position[5]]); + // l_time->hour= date[(uint) format_position[3]]; + // l_time->minute= date[(uint) format_position[4]]; + // l_time->second= date[(uint) format_position[5]]; + + frac_pos = format_position[6]; + frac_len = date_len[frac_pos]; + // if (frac_len < 6) + // date[frac_pos]*= log_10_int[6 - frac_len]; + // l_time->second_part= date[frac_pos]; + + if (format_position[7] != 255) { + if (time.getHours() > 12) { + was_cut = 1; + return null; + } + time.setHours(time.getHours() % 12 + add_hours); + } + } else { + + int year = date[0]; + int month = date[1]; + int day = date[2]; + int hours = date[3]; + int mins = date[4]; + int seconds = date[5]; + + if (!checkDateTime(year_length, not_zero_date, year, month, day, hours, mins, seconds)) { + return false; + } + + time.setYear(date[0] - 1900); + time.setMonth(date[1] - 1); + time.setDate(date[2]); + + time.setHours(date[3]); + time.setMinutes(date[4]); + time.setSeconds(date[5]); + } + + if (number_of_fields < 3 || time.getYear() > 9999 || time.getMonth() > 12 || time.getDate() > 31 + || time.getHours() > 23 || time.getMinutes() > 59 || time.getMinutes() > 59) { + /* Only give warning for a zero date if there is some garbage after */ + if (!(not_zero_date != 0)) /* If zero date */ { + for (; cur_pos != end; cur_pos++) { + if (!my_isspace(str.charAt(cur_pos))) { + not_zero_date = 1; /* Give warning */ + break; + } + } + } + // was_cut= test(not_zero_date); + return null; + } + + return true; + } + + /** + * + */ + private static boolean checkDateTime(int year_length, long not_zero_date, int year, int month, int day, int hours, + int mins, int seconds) { + + if (month > 12 || month <= 0) { + return false; + } + if (year_length == 2 && (not_zero_date != 0)) { + year = year + (year < YY_PART_YEAR ? 2000 : 1900); + } + int uplimit = uplimits[month]; + + if (day != 2) { + if (day > uplimit || day <= 0) { + return false; + } + } else { + if (isLeap(year)) { + if (day > 29 || day <= 0) { + return false; + } + } else { + if (day > 28 || day <= 0) { + return false; + } + } + } + if (hours > 23 || hours < 0) { + return false; + } + if (mins > 59 || mins < 0) { + return false; + } + if (seconds > 59 || seconds < 0) { + return false; + } + return true; + } + + /** + * + */ + private static boolean isLeap(int year) { + return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0); + + } + + public static boolean my_ispunct(char v) { + switch (Character.getType(v)) { + case Character.CONNECTOR_PUNCTUATION: + case Character.DASH_PUNCTUATION: + case Character.END_PUNCTUATION: + case Character.FINAL_QUOTE_PUNCTUATION: + case Character.INITIAL_QUOTE_PUNCTUATION: + case Character.START_PUNCTUATION: + case Character.OTHER_PUNCTUATION: + return true; + } + + return false; + } + + public static int max(int i, int j) { + return i > j ? i : j; + } + + public static boolean my_isspace(char v) { + return Character.isWhitespace(v); + } + + public static boolean isdigit(char v) { + return Character.isDigit(v); + } + +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/DruidDataSourceWrapper.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/DruidDataSourceWrapper.java new file mode 100644 index 00000000..04c90e82 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/DruidDataSourceWrapper.java @@ -0,0 +1,409 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common; + +import com.alibaba.druid.pool.DruidDataSource; +import com.alibaba.druid.pool.DruidPooledConnection; +import com.alibaba.druid.pool.vendor.MySqlExceptionSorter; +import com.alibaba.druid.pool.vendor.MySqlValidConnectionChecker; +import com.aliyun.polardbx.binlog.SpringContextHolder; +import com.aliyun.polardbx.binlog.dao.PolarxCNodeInfoMapper; +import com.aliyun.polardbx.binlog.dao.ServerInfoMapper; +import com.aliyun.polardbx.binlog.error.PolardbxException; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import com.google.common.cache.RemovalListener; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.ParametersAreNonnullByDefault; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.stream.Collectors; + +import static com.aliyun.polardbx.binlog.dao.ServerInfoDynamicSqlSupport.instType; +import static com.aliyun.polardbx.binlog.dao.ServerInfoDynamicSqlSupport.status; +import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo; + +/** + * Created by jiyue + **/ +public class DruidDataSourceWrapper extends DruidDataSource + implements javax.sql.DataSource, javax.sql.ConnectionPoolDataSource { + private static final Logger logger = LoggerFactory.getLogger(com.aliyun.polardbx.binlog.DataSourceWrapper.class); + private static final int SERVER_CHECK_INTERVAL = 1000; + public static Map DEFAULT_MYSQL_CONNECTION_PROPERTIES = Maps.newHashMap(); + + static { + + // 开启多语句能力 + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("allowMultiQueries", "true"); + // 全量目标数据源加上这个批量的参数 + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("rewriteBatchedStatements", "true"); + // 关闭每次读取read-only状态,提升batch性能 + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("readOnlyPropagatesToServer", "false"); + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("connectTimeout", "1000"); + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("autoReconnect", "true"); + // 将0000-00-00的时间类型返回null + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("zeroDateTimeBehavior", "convertToNull"); + // 直接返回字符串,不做year转换date处理 + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("yearIsDateType", "false"); + // 返回时间类型的字符串,不做时区处理 + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("noDatetimeStringSync", "true"); + // 不处理tinyint转为bit + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("tinyInt1isBit", "false"); + // 16MB,兼容一下ADS不支持mysql,5.1.38+的server变量查询为大写的问题,人肉指定一下最大包大小 + DEFAULT_MYSQL_CONNECTION_PROPERTIES.put("maxAllowedPacket", "1073741824"); + } + + protected ReentrantReadWriteLock readWriteLock; + protected AtomicLong seed; + protected String urlTemplate = "jdbc:mysql://%s"; + protected List nestedAddresses; + protected LoadingCache nestedDataSources; + protected volatile DruidDataSource proxyDataSource; + protected ScheduledExecutorService scheduledExecutorService; + +// private volatile static DruidDataSourceWrapper dataSource; +// public static DruidDataSourceWrapper getInstance() { +// if (dataSource == null) { +// synchronized (DruidDataSourceWrapper.class) { +// if (dataSource == null) { +// dataSource = new DruidDataSourceWrapper(); +// } +// } +// } +// return dataSource; +// } +// +// public DruidDataSourceWrapper() { +// +// } + + public DruidDataSourceWrapper(String dbName, String user, + String passwd, String encoding, int minPoolSize, + int maxPoolSize, Map params, + List newConnectionSQLs) throws Exception { + Properties prop = new Properties(); + encoding = StringUtils.isNotBlank(encoding) ? encoding : "utf8mb4"; + if (StringUtils.equalsIgnoreCase(encoding, "utf8mb4")) { + prop.put("characterEncoding", "utf8"); + if (newConnectionSQLs == null) { + newConnectionSQLs = new ArrayList<>(); + } + newConnectionSQLs.add("set names utf8mb4"); + } else { + prop.put("characterEncoding", encoding); + } + prop.putAll(DEFAULT_MYSQL_CONNECTION_PROPERTIES); + if (params != null) { + prop.putAll(params); + } + setUsername(user); + setPassword(passwd); + setTestWhileIdle(true); + setTestOnBorrow(false); + setTestOnReturn(false); + setNotFullTimeoutRetryCount(2); + setValidConnectionCheckerClassName(MySqlValidConnectionChecker.class.getName()); + setExceptionSorterClassName(MySqlExceptionSorter.class.getName()); + setValidationQuery("SELECT 1"); + setInitialSize(minPoolSize); + setMinIdle(minPoolSize); + setMaxActive(maxPoolSize); + setMaxWait(10 * 1000); + setTimeBetweenEvictionRunsMillis(60 * 1000); + setMinEvictableIdleTimeMillis(50 * 1000); + setUseUnfairLock(true); + if (newConnectionSQLs != null && newConnectionSQLs.size() > 0) { + setConnectionInitSqls(newConnectionSQLs); + } + setConnectProperties(prop); + + this.readWriteLock = new ReentrantReadWriteLock(); + this.seed = new AtomicLong(); + this.nestedAddresses = new ArrayList<>(); + this.nestedDataSources = CacheBuilder.newBuilder() + .removalListener( + (RemovalListener) notification -> { + DruidDataSource ds = notification.getValue(); + try { + ds.close(); + logger.info("successfully close datasource for " + notification.getKey()); + } catch (Exception e) { + logger.error("close datasource failed for " + notification.getKey()); + } + }) + .build(new CacheLoader() { + @Override + @ParametersAreNonnullByDefault + public DruidDataSource load(String address) throws Exception { + DruidDataSource ds = cloneDruidDataSource(); + String url = String.format(urlTemplate, address); + if (StringUtils.isNotBlank(dbName)) { + url = url + "/" + dbName; + } + // remove warning msg + url = url + "?useSSL=false"; + ds.setUrl(url); + try { + ds.init(); + } catch (Exception e) { + throw new Exception("create druid datasource occur exception, with url : " + + url + ", user : " + ds.getUsername() + ", passwd : " + ds.getPassword(), e); + } + return ds; + } + }); + + } + + public String getUrlTemplate() { + return urlTemplate; + } + + public void setUrlTemplate(String urlTemplate) { + this.urlTemplate = urlTemplate; + } + + @SuppressWarnings("unused") // Has to match signature in DataSource + @Override + public boolean isWrapperFor(Class iface) { + // we are not a wrapper of anything + return false; + } + + @SuppressWarnings("unused") // Has to match signature in DataSource + @Override + public T unwrap(Class iface) { + //we can't unwrap anything + return null; + } + + @Override + public void init() { + scan(); + scheduledExecutorService = Executors.newSingleThreadScheduledExecutor((r) -> { + Thread thread = new Thread(r, "server-node-scanner"); + thread.setDaemon(true); + return thread; + }); + scheduledExecutorService + .scheduleAtFixedRate(this::scan, SERVER_CHECK_INTERVAL, SERVER_CHECK_INTERVAL, TimeUnit.MILLISECONDS); + } + + private void scan() { + try { + Set latestServers = getLatestServerAddress(); + Set holdingServers = Sets.newHashSet(nestedAddresses); + + Set toBeAddedServers = + latestServers.stream().filter(s -> !holdingServers.contains(s)).collect(Collectors.toSet()); + Set toBeRemovedServers = + holdingServers.stream().filter(s -> !latestServers.contains(s)).collect(Collectors.toSet()); + + Set invalidHoldingServers = holdingServers.stream().filter(s -> { + try (Connection conn = nestedDataSources.getUnchecked(s).getConnection()) { + if (conn.isValid(1)) { + return false; + } else { + logger.warn("detected abnormal server node with address {}.", s); + } + } catch (Throwable t) { + logger.warn("detected abnormal server node with address {}.", s, t); + } + return true; + }).collect(Collectors.toSet()); + toBeRemovedServers.addAll(invalidHoldingServers); + + if (!toBeAddedServers.isEmpty()) { + onServerNodeAdd(toBeAddedServers); + } + if (!toBeRemovedServers.isEmpty()) { + onServerNodeRemove(toBeRemovedServers); + } + } catch (Exception e) { + logger.error("something goes wrong in server node scan!", e); + } + } + + private Set getLatestServerAddress() { + ServerInfoMapper serverInfoMapper = SpringContextHolder.getObject(ServerInfoMapper.class); + return serverInfoMapper.select(c -> + c.where(instType, isEqualTo(0))//0:master, 1:read without htap, 2:read with htap + .and(status, isEqualTo(0))//0: ready, 1: not_ready, 2: deleting + ).stream().map(s -> String.format("%s:%s", s.getIp(), s.getPort())).collect(Collectors.toSet()); + } + + private Set getLatestNodeAddress() { + PolarxCNodeInfoMapper cNodeInfoMapper = SpringContextHolder.getObject(PolarxCNodeInfoMapper.class); + return cNodeInfoMapper.select(c -> + c.where(status, isEqualTo(1))//0:master, 1:read without htap, 2:read with htap + ).stream().map(s -> String.format("%s:%s", s.getIp(), s.getPort())).collect(Collectors.toSet()); + } + + private void onServerNodeAdd(Set toBeAddedServers) { + Set validServers = toBeAddedServers.stream().filter(s -> { + try (Connection conn = nestedDataSources.getUnchecked(s).getConnection()) { + if (conn.isValid(1)) { + return true; + } else { + logger.warn("Server node {} is not ready yet, will retry later.", s); + } + } catch (Throwable t) { + logger.warn("Server node {} is not ready yet, will retry later.", s, t); + } + nestedDataSources.invalidate(s); + return false; + }).collect(Collectors.toSet()); + + if (!validServers.isEmpty()) { + try { + readWriteLock.writeLock().lock(); + nestedAddresses.addAll(validServers); + } finally { + readWriteLock.writeLock().unlock(); + } + } + } + + private void onServerNodeRemove(Set toBeRemovedServerInfoList) { + try { + readWriteLock.writeLock().lock(); + nestedAddresses.removeAll(toBeRemovedServerInfoList); + toBeRemovedServerInfoList.forEach(s -> nestedDataSources.invalidate(s)); + } finally { + readWriteLock.writeLock().unlock(); + } + } + + /** + * Get a database connection. + * {@link javax.sql.DataSource#getConnection()} + * + * @param username The user name + * @param password The password + * @return the connection + * @throws SQLException Connection error + */ + @Override + public Connection getConnection(String username, String password) throws SQLException { + return getConnectionInternal(username, password); + } + + /** + * Get a database connection. + * {@link javax.sql.DataSource#getConnection()} + * + * @return the connection + * @throws SQLException Connection error + */ + @Override + public DruidPooledConnection getConnection() throws SQLException { + return (DruidPooledConnection) getConnectionInternal(null, null); + } + + private Connection getConnectionInternal(String username, String password) throws SQLException { + if (proxyDataSource != null) { + return username == null ? proxyDataSource.getConnection() : + proxyDataSource.getConnection(username, password); + } else { + try { + readWriteLock.readLock().lock(); + + if (nestedAddresses.size() == 0) { + throw new PolardbxException("no server node is ready, please retry later."); + } + + int index = (int) seed.incrementAndGet() % nestedAddresses.size(); + String key = nestedAddresses.get(index); + return username == null ? nestedDataSources.getUnchecked(key).getConnection() : + nestedDataSources.getUnchecked(key).getConnection(username, password); + } finally { + readWriteLock.readLock().unlock(); + } + } + } + + /** + * Get a database connection. + * {@link javax.sql.DataSource#getConnection()} + * + * @return the connection + * @throws SQLException Connection error + */ + @Override + public javax.sql.PooledConnection getPooledConnection() throws SQLException { + return (javax.sql.PooledConnection) getConnection(); + } + + /** + * Get a database connection. + * {@link javax.sql.DataSource#getConnection()} + * + * @param username unused + * @param password unused + * @return the connection + * @throws SQLException Connection error + */ + @Override + public javax.sql.PooledConnection getPooledConnection(String username, + String password) throws SQLException { + return (javax.sql.PooledConnection) getConnection(); + } + + @Override + public void close() { + close(false); + } + + public void close(boolean all) { + try { + readWriteLock.writeLock().lock(); + nestedAddresses.clear(); + nestedDataSources.invalidateAll(); + if (scheduledExecutorService != null) { + scheduledExecutorService.shutdownNow(); + } + } catch (Exception x) { + logger.warn("Error during connection pool closure.", x); + } finally { + readWriteLock.writeLock().unlock(); + } + } + + + /*-----------------------------------------------------------------------*/ +// PROPERTIES WHEN NOT USED WITH FACTORY + /*------------------------------------------------------------------------*/ + +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/HostManager.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/HostManager.java new file mode 100644 index 00000000..f9e6e0bc --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/HostManager.java @@ -0,0 +1,53 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common; + +import com.aliyun.polardbx.binlog.DynamicApplicationConfig; +import com.aliyun.polardbx.binlog.domain.po.PolarxCNodeInfo; +import com.aliyun.polardbx.rpl.taskmeta.DbTaskMetaManager; +import com.aliyun.polardbx.rpl.taskmeta.HostInfo; +import com.aliyun.polardbx.rpl.taskmeta.HostType; +import lombok.extern.slf4j.Slf4j; + +import java.util.List; +import java.util.Random; + +import static com.aliyun.polardbx.binlog.ConfigKeys.POLARX_PASSWORD; +import static com.aliyun.polardbx.binlog.ConfigKeys.POLARX_USERNAME; + +/** + * @author shicai.xsc 2021/2/3 15:58 + * @since 5.0.0.0 + */ +@Slf4j +public class HostManager { + + public static HostInfo getDstPolarxHost() { + PolarxCNodeInfo node = getRandomNode(); + String user = DynamicApplicationConfig.getString(POLARX_USERNAME); + String password = DynamicApplicationConfig.getString(POLARX_PASSWORD); + return new HostInfo(node.getIp(), node.getPort(), user, password, "", HostType.POLARX2, + RplConstants.SERVER_ID_NULL); + } + + private static PolarxCNodeInfo getRandomNode() { + List nodes = DbTaskMetaManager.listPolarxCNodeInfo(); + int random = new Random().nextInt(nodes.size()); + return nodes.get(random); + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/LogUtil.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/LogUtil.java new file mode 100644 index 00000000..634ae1ec --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/LogUtil.java @@ -0,0 +1,187 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSColumn; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSEvent; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSRowChange; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultQueryLog; +import com.aliyun.polardbx.rpl.applier.ApplyHelper; +import com.aliyun.polardbx.rpl.applier.StatisticUnit; +import com.aliyun.polardbx.rpl.dbmeta.ColumnValue; +import com.aliyun.polardbx.rpl.dbmeta.TableInfo; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * @author shicai.xsc 2020/12/21 10:50 + * @since 5.0.0.0 + */ +public class LogUtil { + + private static final ThreadLocal> loggers = new ThreadLocal<>(); + /** + * Log4j is thread safe + */ + + private static String COMMIT_LOGGER = "commitLogger"; + private static String CHECK_RESULT_LOGGER = "checkResultLogger"; + private static String POSITION_LOGGER = "positionLogger"; + private static String META_LOGGER = "metaLogger"; + private static String STATISTIC_LOGGER = "statisticLogger"; + private static String CONSOLE_LOGGER = "consoleLogger"; + private static String RPL_LOGGER = "rplLogger"; + + static { + loggers.set(new HashMap<>()); + } + + public static Logger getStatisticLogger() { + return LoggerFactory.getLogger(STATISTIC_LOGGER); + } + + public static Logger getCommitLogger() { + return LoggerFactory.getLogger(COMMIT_LOGGER); + } + + public static Logger getCheckResultLogger() { + return LoggerFactory.getLogger(CHECK_RESULT_LOGGER); + } + + public static Logger getMetaLogger() { + return LoggerFactory.getLogger(META_LOGGER); + } + + public static Logger getPositionLogger() { + return LoggerFactory.getLogger(POSITION_LOGGER); + } + + public static Logger getConsoleLogger() { + return LoggerFactory.getLogger(CONSOLE_LOGGER); + } + + public static String generatePositionLog(String position) { + return CommonUtil.getCurrentTime() + " " + position; + } + + public static Logger getRplLogger() { + return LoggerFactory.getLogger(RPL_LOGGER); + } + + public static String generateStatisticLog(StatisticUnit unit, String intervalItem, long totalInCache) { + StringBuilder logSb = new StringBuilder(); + logSb.append(CommonUtil.getCurrentTime()) + .append(" totalConsumeMessageCount: ").append(unit.getTotalConsumeMessageCount().get(intervalItem)) + .append(" messageTps: ").append(unit.getMessageTps().get(intervalItem)) + .append(" applyTps: ").append(unit.getApplyTps().get(intervalItem)) + .append(" applyRt: ").append(unit.getApplyRt().get(intervalItem)) + .append(" avgMergeBatchSize: ").append(unit.getAvgMergeBatchSize().get(intervalItem)) + .append(" skipCount: ").append(unit.getSkipCounter()) + .append(" totalInCache: ").append(totalInCache); + return logSb.toString(); + } + + public static void logFullCommitInfo(List dbmsEvents, String physicalInfo) { + List logs = new ArrayList<>(); + for (DBMSEvent event : dbmsEvents) { + logs.addAll(LogUtil.generateCommitLog(event, physicalInfo)); + } + LogUtil.writeBatchLogs(logs, LogUtil.getCommitLogger()); + } + + public static List generateCommitLog(DBMSEvent event, String physicalInfo) { + List logs = new ArrayList<>(); + String timestamp = CommonUtil.getCurrentTime(); + + if (ApplyHelper.isDdl(event)) { + String position = (String) (event.getOption(RplConstants.BINLOG_EVENT_OPTION_POSITION_STR).getValue()); + String log = String.format("%s, DDL: schema: %s, action: %s, sql: %s, position: %s", + timestamp, + event.getSchema(), + event.getAction().name(), + ((DefaultQueryLog) event).getQuery(), + position); + logs.add(log); + } else { + DBMSRowChange rowChange = (DBMSRowChange) event; + String position = null; + String binlogTimestamp = null; + position = (String) (rowChange.getOption(RplConstants.BINLOG_EVENT_OPTION_POSITION).getValue()); + binlogTimestamp = rowChange.getOption(RplConstants.BINLOG_EVENT_OPTION_TIMESTAMP).getValue().toString(); + String[] pks = getPks(event); + StringBuilder logSb = new StringBuilder(); + logSb.append(timestamp).append(RplConstants.COMMA); + logSb.append(physicalInfo).append(RplConstants.COMMA); + logSb.append(rowChange.getSchema()).append("."); + logSb.append(rowChange.getTable()).append(RplConstants.COMMA); + for (String str : pks) { + logSb.append(str); + } + logSb.append(RplConstants.COMMA); + logSb.append(position).append(RplConstants.COMMA); + logSb.append(binlogTimestamp); + logs.add(logSb.toString()); + } + + return logs; + } + + public static String[] getPks(DBMSEvent dbMessage) { + DBMSRowChange rowChange = (DBMSRowChange) dbMessage; + int rowSize = rowChange.getRowSize(); + String[] pks = new String[rowSize]; + for (int i = 0; i < rowSize; i++) { + List primaryKeys = rowChange.getPrimaryKey(); + StringBuilder pkSb = new StringBuilder("["); + if (primaryKeys != null) { + Iterator iterator = primaryKeys.iterator(); + while (iterator.hasNext()) { + DBMSColumn column = iterator.next(); + pkSb.append(rowChange.getRowValue(i + 1, column)); + if (iterator.hasNext()) { + pkSb.append(", "); + } + } + } + pkSb.append("]"); + pks[i] = pkSb.toString(); + } + return pks; + } + + public static void writeBatchLogs(List logs, Logger logger) { + StringBuilder logsSb = new StringBuilder(); + for (int i = 0; i < logs.size(); i++) { + String log = logs.get(i); + logsSb.append(log); + if (logsSb.length() > RplConstants.LOG_MAX_LENGTH || i == logs.size() - 1) { + logger.info(logsSb.toString()); + logsSb.setLength(0); + } else { + logsSb.append(RplConstants.LINE_SEPERATOR); + } + } + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/NamedThreadFactory.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/NamedThreadFactory.java new file mode 100644 index 00000000..efbbc881 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/NamedThreadFactory.java @@ -0,0 +1,44 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common; + +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Actually this class should be provided by some com.aliyun.polardbx.common + * utils. + * + * @author Moshan on 14-10-28. + */ +public class NamedThreadFactory implements ThreadFactory { + + final AtomicInteger threadNumber = new AtomicInteger(); + final String namePrefix; + + public NamedThreadFactory(String namePrefix) { + this.namePrefix = namePrefix; + } + + @Override + public Thread newThread(Runnable r) { + Thread result = new Thread(r, namePrefix + threadNumber.getAndIncrement()); + result.setDaemon(true); + return result; + } +} \ No newline at end of file diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/PasswordUtil.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/PasswordUtil.java new file mode 100644 index 00000000..35c7ec33 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/PasswordUtil.java @@ -0,0 +1,50 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common; + +import java.security.SecureRandom; + +/** + * @author shicai.xsc 2021/4/19 16:40 + * @since 5.0.0.0 + */ +public class PasswordUtil { + + private static final String upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + private static final String lower = upper.toLowerCase(); + + private static final String digits = "0123456789"; + + private static final String special = "@#$%^&+="; + + public static String getRandomPassword() { + String password = getRandomString(upper, 3) + getRandomString(lower, 3) + getRandomString(digits, 3) + + getRandomString(special, 1); + return password; + } + + private static String getRandomString(String src, int length) { + SecureRandom random = new SecureRandom(); + StringBuilder sb = new StringBuilder(length); + for (int i = 0; i < length; i++) { + sb.append(src.charAt(random.nextInt(src.length()))); + } + return sb.toString(); + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/ResultCode.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/ResultCode.java new file mode 100644 index 00000000..84cb6336 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/ResultCode.java @@ -0,0 +1,42 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; + +/** + * Created by jiyue on 21-9-7. + */ +@Data +@Builder +@AllArgsConstructor +public class ResultCode { + + private int code; + private String msg; + private T data; + + public ResultCode(int code, String msg) { + this.code = code; + this.msg = msg; + } + +} + diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/RplConstants.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/RplConstants.java new file mode 100644 index 00000000..adeb2e71 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/RplConstants.java @@ -0,0 +1,229 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common; + +import com.aliyun.polardbx.binlog.ServerConfigUtil; + +/** + * @author shicai.xsc 2020/11/30 16:44 + * @since 5.0.0.0 + */ +public class RplConstants { + + /** + * canal 中,将binlog产生的时间写入option中 + */ + public static final String BINLOG_EVENT_OPTION_TIMESTAMP = "message_event_option_timestamp"; + + /** + * canal 中,将当前binlog position 写入option + */ + public static final String BINLOG_EVENT_OPTION_POSITION = "message_event_option_offset"; + /** + * canal 中,将当前binlog position 写入option + */ + public static final String BINLOG_EVENT_OPTION_POSITION_STR = "message_event_option_position_str"; + /** + * 将source schema name 写入option + */ + public static final String BINLOG_EVENT_OPTION_SOURCE_SCHEMA = "source_schema"; + /** + * 将source table name 写入option + */ + public static final String BINLOG_EVENT_OPTION_SOURCE_TABLE = "source_table"; + + /** + * canal ,事务tid + */ + public static final String BINLOG_EVENT_OPTION_T_ID = "message_event_option_tid"; + + public static final String LINE_SEPERATOR = System.getProperty("line.separator"); + + public static final long LOG_MAX_LENGTH = 10000; + + public static final String SEMICOLON = ";"; + + public static final String COMMA = ","; + + public static final String DOT = "."; + + public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; + + public static final String TASK_ID = "taskId"; + public static final String TASK_NAME = "taskName"; + + public static final String EXTRACTOR_DEFAULT_CHARSET = "utf8"; + + public static final int DEFAULT_FETCH_BATCH_SIZE = 5000; + + public static final int PRODUCER_DEFAULT_PARALLEL_COUNT = 16; + + public static final int CONSUMER_DEFAULT_PARALLEL_COUNT = 64; + + /** + * binlogExtractor按照时间回溯时,使用-2拼装回溯的位点 + */ + public final static String ROLLBACK_STRING = "-2"; + + public final static int TASK_KEEP_ALIVE_INTERVAL_SECONDS = 15; + + public final static int HTTP_PORT = 10183; + + public final static String DOWNLOAD_URL = "http://%s:" + 10183 + "/rpl/download?file=%s"; + + public final static String SUCCEED = "succeed"; + + public final static String TRUE = "true"; + + public final static String FALSE = "false"; + + /** + * Polar-x user name + */ + public final static String POLARX_ROOT_USER = "polardbx_root"; + + public final static String POLARX_SLAVE_USER = "polardbx_slave_inner"; + + /** + * Polar-x implicit ID + */ + public final static String POLARX_IMPLICIT_ID = "_drds_implicit_id_"; + + public final static String ASYNC_DDL = "PURE_ASYNC_DDL_MODE=TRUE"; + + public final static String RDS_IMPLICIT_ID = "__#alibaba_rds_row_id#__"; + + /** + * Http call + */ + public final static String CHECK_AND_RUN_TASKS = "checkAndRunLocalTasks"; + + public final static String CHECK_CHANNEL_RUNNING = "checkChannelRunning"; + + /** + * Server-id + */ + public final static long MY_POLARX_SERVER_ID = Long.valueOf(ServerConfigUtil.getGlobalVar("SERVER_ID").toString()); + + public final static long SERVER_ID_NULL = 0; + + /** + * RPC command params + */ + public final static String MASTER_HOST = "MASTER_HOST"; + + public final static String MASTER_USER = "MASTER_USER"; + + public final static String MASTER_PASSWORD = "MASTER_PASSWORD"; + + public final static String MASTER_PORT = "MASTER_PORT"; + + public final static String MASTER_SERVER_ID = "MASTER_SERVER_ID"; + + public final static String MASTER_LOG_FILE = "MASTER_LOG_FILE"; + + public final static String MASTER_LOG_POS = "MASTER_LOG_POS"; + + public final static String IGNORE_SERVER_IDS = "IGNORE_SERVER_IDS"; + + public final static String SOURCE_HOST_TYPE = "SOURCE_HOST_TYPE"; + + public final static String CHANNEL = "CHANNEL"; + + public final static String REPLICATE_DO_DB = "REPLICATE_DO_DB"; + + public final static String REPLICATE_IGNORE_DB = "REPLICATE_IGNORE_DB"; + + public final static String REPLICATE_DO_TABLE = "REPLICATE_DO_TABLE"; + + public final static String REPLICATE_IGNORE_TABLE = "REPLICATE_IGNORE_TABLE"; + + public final static String REPLICATE_WILD_DO_TABLE = "REPLICATE_WILD_DO_TABLE"; + + public final static String REPLICATE_WILD_IGNORE_TABLE = "REPLICATE_WILD_IGNORE_TABLE"; + + public final static String REPLICATE_REWRITE_DB = "REPLICATE_REWRITE_DB"; + + public final static String RUNNING = "RUNNING"; + + public final static String LAST_ERROR = "LAST_ERROR"; + + public final static String SKIP_COUNTER = "SKIP_COUNTER"; + + public final static String REPLICATE_IGNORE_SERVER_IDS = "REPLICATE_IGNORE_SERVER_IDS"; + + public final static String IS_ALL = "IS_ALL"; + + public static final String NULL_COLUMN = "##NULL##"; + + public static final String CHECK_RESULT_SEPERATOR = "#$#"; + public static final String KEY_GROUP_SEPERATOR = "#&#"; + + public static final int WORKER_KEEP_ALIVE_SECONDS = 120; + + public static final long INC_CATCH_UP_SECOND_THRESHOLD = 30; + + public static final int FALLBACK_INTERVAL_SECONDS = 60; + + public static final int FAILURE = 0; + public static final int SUCCESS = 1; + + public static final int FAILURE_CODE = 500; + public static final int SUCCESS_CODE = 200; + + public static final long ERROR_FSMID = -1; + + public static final int FINISH_PERCENTAGE = 100; + + public static final int NOT_FINISH = 0; + public static final int FINISH = 1; + + public static final int LOG_NO_COMMIT = 0; + public static final int LOG_END_COMMIT = 1; + public static final int LOG_ALL_COMMIT = 2; + + public static final int KEY_TRACE_IDX = 2; + public static final int KEY_DRDS_IDX = 0; + public static final String DRDS_HINT_PREFIX = "DRDS"; + /** + * 精确匹配 or 模糊匹配 + */ + public static final String BINLOG_EVENT_OPTION_SQL_CALLBACK_TYPE = "message_event_option_sql_callback_type"; + + public static final String BINLOG_EVENT_OPTION_SQL_QUERY_LOG = "message_event_option_sql_query_log"; + + public static final String BINLOG_EVENT_OPTION_SHOULD_STOP = "message_event_option_should_stop"; + + public static final String TRANSACTION_END_COMMENT = "\n-- Transaction end;\n"; + + public static final String FLASH_BACK_ROOT_PATH = "SQL_FLASH_BACK"; + + public static final String FLASH_BACK_RESULT_DIR = FLASH_BACK_ROOT_PATH + "/{0}/"; + + public static final String FLASH_BACK_PARTIAL_PREFIX = FLASH_BACK_ROOT_PATH + "/{0}/result-{1}"; + + public static final String FLASH_BACK_PARTIAL_RESULT_FILE = FLASH_BACK_PARTIAL_PREFIX + "-{2}.sql"; + + public static final String FLASH_BACK_COMBINE_RESULT_FILE = FLASH_BACK_ROOT_PATH + "/{0}/result.sql"; + + public static final int INSERT_MODE_SIMPLE_INSERT_OR_DELETE = 1; + + public static final int INSERT_MODE_INSERT_IGNORE = 2; + + public static final int INSERT_MODE_REPLACE = 3; +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/StringUtils2.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/StringUtils2.java new file mode 100644 index 00000000..c4a78cb7 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/StringUtils2.java @@ -0,0 +1,140 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; + +/** + * @author sunxi'en + * @since 1.0.0 + */ +public class StringUtils2 extends StringUtils { + + /** + * @return String + */ + public static String substringPrefix(String str, String prefix) { + if (str != null && prefix != null) { + if (str.startsWith(prefix)) { + str = str.substring(prefix.length(), str.length()); + } + } + return str; + } + + /** + * @return String + */ + public static String substringSuffix(String str, String suffix) { + if (str != null && suffix != null) { + if (str.endsWith(suffix)) { + str = str.substring(0, str.length() - suffix.length()); + } + } + return str; + } + + /** + * @return String + */ + public static String safeToString(Object object) { + return safeToString(object, EMPTY); + } + + /** + * @return String + */ + public static String safeToString(Object object, String nullStr) { + if (object == null || (object instanceof String && EMPTY.equals(object.toString()))) { + return nullStr; + } else if (object.getClass().isArray()) { + return ArrayUtils.toString(object); + } else { + return object.toString(); + } + } + + /** + * @return String + */ + public static String substringBetween2(String str, String open, String close) { + if (str == null || open == null || close == null) { + return str; + } + int start = str.indexOf(open); + if (start != INDEX_NOT_FOUND) { + int end = str.indexOf(close, start + open.length()); + if (end != INDEX_NOT_FOUND) { + return str.substring(start + open.length(), end); + } + } + return str; + } + + /** + * refer to org.apache.commons.lang3.StringUtils + */ + public static String replace(final String text, final String searchString, final String replacement) { + return replace(text, searchString, replacement, -1); + } + + public static String replace(final String text, final String searchString, final String replacement, int max) { + if (isEmpty(text) || isEmpty(searchString) || replacement == null || max == 0) { + return text; + } + int start = 0; + int end = text.indexOf(searchString, start); + if (end == INDEX_NOT_FOUND) { + return text; + } + final int replLength = searchString.length(); + int increase = replacement.length() - replLength; + increase = increase < 0 ? 0 : increase; + increase *= max < 0 ? 16 : max > 64 ? 64 : max; + final StringBuilder buf = new StringBuilder(text.length() + increase); + while (end != INDEX_NOT_FOUND) { + buf.append(text.substring(start, end)).append(replacement); + start = end + replLength; + if (--max == 0) { + break; + } + end = text.indexOf(searchString, start); + } + buf.append(text.substring(start)); + return buf.toString(); + } + + /** + * 返回两个字符串后缀匹配的长度 + */ + public static int suffixMatchLengthIgnoreCase(String str1, String str2) { + if (StringUtils.isBlank(str1) || StringUtils.isBlank(str2)) { + return 0; + } else { + str1 = str1.toLowerCase(); + str2 = str2.toLowerCase(); + for (int i = str1.length() - 1, j = str2.length() - 1; i >= 0 && j >= 0; i--, j--) { + if (str1.charAt(i) != str2.charAt(j)) { + return (str1.length() - 1 - i); + } + } + return Math.min(str1.length(), str2.length()); + } + } +} \ No newline at end of file diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/TaskBasedDiscriminator.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/TaskBasedDiscriminator.java new file mode 100644 index 00000000..45c2073a --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/TaskBasedDiscriminator.java @@ -0,0 +1,85 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common; + +import java.util.HashMap; +import java.util.Map; + +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.sift.AbstractDiscriminator; +import ch.qos.logback.core.util.OptionHelper; + +/** + * @author shicai.xsc 2020/12/24 20:29 + * @since 5.0.0.0 + */ +public class TaskBasedDiscriminator extends AbstractDiscriminator { + private String key; + private String defaultValue; + private static Map values = new HashMap<>(); + + public TaskBasedDiscriminator() { + } + + @Override + public String getDiscriminatingValue(ILoggingEvent event) { + return values.containsKey(key) ? values.get(key) : defaultValue; + } + + @Override + public void start() { + int errors = 0; + if (OptionHelper.isEmpty(this.key)) { + ++errors; + this.addError("The \"Key\" property must be set"); + } + + if (OptionHelper.isEmpty(this.defaultValue)) { + ++errors; + this.addError("The \"DefaultValue\" property must be set"); + } + + if (errors == 0) { + this.started = true; + } + + } + + public static void put(String key, String value) { + values.put(key, value); + } + + @Override + public String getKey() { + return this.key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getDefaultValue() { + return this.defaultValue; + } + + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } +} + + diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/TaskContext.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/TaskContext.java new file mode 100644 index 00000000..7fb2dfc5 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/TaskContext.java @@ -0,0 +1,73 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common; + +import com.aliyun.polardbx.binlog.domain.po.RplService; +import com.aliyun.polardbx.binlog.domain.po.RplStateMachine; +import com.aliyun.polardbx.binlog.domain.po.RplTask; + +import lombok.Data; + +/** + * @author shicai.xsc 2020/12/21 10:48 + * @since 5.0.0.0 + */ +@Data +public class TaskContext { + private RplStateMachine stateMachine; + private RplService service; + private RplTask task; + private String worker; + private String config; + private static TaskContext instance; + private int physicalId; + + private TaskContext() { + } + + public static TaskContext getInstance() { + if (instance == null) { + synchronized (TaskContext.class) { + if (instance == null) { + instance = new TaskContext(); + } + } + } + return instance; + } + + public long getTaskId() { + return task.getId(); + } + + public long getServiceId() { + return service.getId(); + } + + public RplStateMachine getStateMachine() { + return stateMachine; + } + + public long getStateMachineId() { + return stateMachine.getId(); + } + + public String getConfig() { + return config; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/ThreadPoolUtil.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/ThreadPoolUtil.java new file mode 100644 index 00000000..28700337 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/ThreadPoolUtil.java @@ -0,0 +1,55 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common; + +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +public class ThreadPoolUtil { + + private static final int MAX_POOL_SIZE = 2048; + private static final long ALIVE_TIME = 5 * 1000L; + private static final int QUEUE_SIZE = 2048; + + public static ThreadPoolExecutor createExecutorWithFixedNum(int coreSize, String name) { + return new ThreadPoolExecutor( + coreSize, + coreSize, + ALIVE_TIME, + TimeUnit.MILLISECONDS, + new LinkedBlockingQueue<>(), + new NamedThreadFactory(name)); + } + + public static ThreadPoolExecutor createExecutor(int minSize, int maxSize, String name) { + return new ThreadPoolExecutor( + minSize, + maxSize, + ALIVE_TIME, + TimeUnit.MILLISECONDS, + new LinkedBlockingQueue<>(), + new NamedThreadFactory(name)); + } + +} + + + + + diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/AbstractFSM.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/AbstractFSM.java new file mode 100644 index 00000000..9c6ece4f --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/AbstractFSM.java @@ -0,0 +1,78 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common.fsmutil; + +import com.aliyun.polardbx.binlog.domain.po.RplStateMachine; +import com.aliyun.polardbx.rpl.taskmeta.DbTaskMetaManager; +import com.aliyun.polardbx.rpl.taskmeta.FSMMetaManager; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author jiyue 2021/08/29 + */ + +public abstract class AbstractFSM { + + private List transitionList; + private FSMState initialState; + + public AbstractFSM(List transitionList, FSMState initialState) { + this.transitionList = transitionList; + this.initialState = initialState; + } + + public FSMState getInitialState() { + return initialState; + } + + public abstract long create(T metaData); + + public void update(RplStateMachine stateMachine, FSMAction action) { + long FSMId = stateMachine.getId(); + int nowState = stateMachine.getState(); + List transitions = transitionList + .stream() + .filter(tran -> tran.getCurrentState().getValue() == nowState) + .collect(Collectors.toList()); + + if (transitions.isEmpty()) { + return; + } + // 一次update只进行一次状态切换 + for (FSMTransition transition : transitions) { + if (transition.isMatch(FSMId, null)) { + updateState(FSMId, transition.getNextState()); + if (transition.getTriggeredAction() != null) { + transition.getTriggeredAction().execute(FSMId); + } + break; + } + } + } + + public void updateState(long FSMId, FSMState state) { + // 防止重入导致状态错乱 + synchronized (this) { + DbTaskMetaManager.updateStateMachineState(FSMId, state); + FSMMetaManager.startServiceByState(FSMId); + } + } + +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/FSMAction.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/FSMAction.java new file mode 100644 index 00000000..df476b9c --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/FSMAction.java @@ -0,0 +1,48 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common.fsmutil; + +import org.apache.commons.lang3.StringUtils; + +public enum FSMAction { + /* + for non use + * */ + NULL("NULL"), + + START_BACKFLOW("START_BACKFLOW"); + + private String value; + + public String getValue() { + return value; + } + + FSMAction(String value) { + this.value = value; + } + + public static FSMAction from(String value) { + for (FSMAction i : FSMAction.values()) { + if (StringUtils.equals(i.value, value)) { + return i; + } + } + return NULL; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/FSMManager.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/FSMManager.java new file mode 100644 index 00000000..019c6eb8 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/FSMManager.java @@ -0,0 +1,54 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common.fsmutil; + +import com.aliyun.polardbx.binlog.ConfigKeys; +import com.aliyun.polardbx.binlog.DynamicApplicationConfig; +import com.aliyun.polardbx.binlog.domain.po.RplStateMachine; +import com.aliyun.polardbx.rpl.common.LogUtil; +import com.aliyun.polardbx.rpl.taskmeta.DbTaskMetaManager; +import com.aliyun.polardbx.rpl.taskmeta.StateMachineStatus; +import org.slf4j.Logger; + +import java.lang.reflect.Method; +import java.util.List; + +/** + * @author jiyue 2021/08/29 + */ + +public class FSMManager { + + private static String clusterId = DynamicApplicationConfig.getString(ConfigKeys.CLUSTER_ID); + private static Logger metaLogger = LogUtil.getMetaLogger(); + + public static void update() { + List runningFSM = DbTaskMetaManager.listStateMachine(StateMachineStatus.RUNNING, clusterId); + for (RplStateMachine stateMachine : runningFSM) { + try { + Class clazz = Class.forName(stateMachine.getClassName()); + Method method = clazz.getMethod("getInstance"); + AbstractFSM fsm = (AbstractFSM) method.invoke(null); + fsm.update(stateMachine, null); + } catch (Exception e) { + metaLogger.error("update FSM error: ", e); + } + } + } + +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/FSMState.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/FSMState.java new file mode 100644 index 00000000..37a62645 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/FSMState.java @@ -0,0 +1,88 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common.fsmutil; + +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author jiyue 2021/08/29 + */ +public enum FSMState { + /* + for non use + * */ + NULL(-1), + REPLICA(201); + + private final int value; + + FSMState(int value) { + this.value = value; + } + + public static FSMState from(int value) { + for (FSMState i : FSMState.values()) { + if (i.value == value) { + return i; + } + } + return NULL; + } + + public static List listFromString(String stateListStr) { + List stateList = new LinkedList<>(); + String[] strList = stateListStr.split(","); + for (String str : strList) { + stateList.add(from(Integer.parseInt(str))); + } + return stateList; + } + + public static String listToString(List stateList) { + return stateList.stream() + .map(FSMState::getValueStr) + .collect(Collectors.joining(",")); +// return stateList +// .stream() +// .reduce(new StringBuilder(), (sb, s) -> sb.append(s.value).append(','), StringBuilder::append).toString(); + } + + /* 检测stateListStr中是否包含目标state */ + public static boolean contain(String stateListStr, FSMState targetState) { + List stateList = listFromString(stateListStr); + if (stateList == null) { + return false; + } + for (FSMState state : stateList) { + if (state.value == targetState.value) { + return true; + } + } + return false; + } + + public int getValue() { + return value; + } + + public String getValueStr() { + return Integer.toString(value); + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/FSMTransition.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/FSMTransition.java new file mode 100644 index 00000000..3071e8df --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/FSMTransition.java @@ -0,0 +1,57 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common.fsmutil; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class FSMTransition { + /* + 参数1和2:当前状态和目标状态 + triggeredaction:状态转换成功后的触发函数 + fsmAction:用于判断是否可以进行本次转换,如action相等则成功,不相等则取isMatch函数的结果 + * */ + private FSMState currentState; + + private FSMState nextState; + + private FSMTriggeredAction triggeredAction; + + private FSMAction fsmAction; + + /* 重载此函数实现自定义判断 */ + public boolean isMatch(long FSMId) { + return false; + } + + /* action为空时需要自行判断是否match */ + public boolean isMatch(long FSMId, FSMAction action) { + if (fsmAction != null && action != null && StringUtils.equals(action.getValue(), fsmAction.getValue())) { + return true; + } + return isMatch(FSMId); + } + +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/FSMTriggeredAction.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/FSMTriggeredAction.java new file mode 100644 index 00000000..a547086f --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/FSMTriggeredAction.java @@ -0,0 +1,28 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common.fsmutil; + +/** + * @author jiyue 2021/08/29 + */ + +public class FSMTriggeredAction { + public void execute(long FSMId) { + + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/ReplicaFSM.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/ReplicaFSM.java new file mode 100644 index 00000000..50c63c11 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/ReplicaFSM.java @@ -0,0 +1,50 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common.fsmutil; + +import com.aliyun.polardbx.binlog.domain.po.RplStateMachine; +import com.aliyun.polardbx.rpl.common.RplConstants; +import com.aliyun.polardbx.rpl.taskmeta.FSMMetaManager; +import com.aliyun.polardbx.rpl.taskmeta.ReplicateMeta; +import com.aliyun.polardbx.rpl.taskmeta.StateMachineType; + +import java.util.ArrayList; + +public class ReplicaFSM extends AbstractFSM { + + private static ReplicaFSM instance = new ReplicaFSM(); + + public static ReplicaFSM getInstance() { + return instance; + } + + private ReplicaFSM() { + super(new ArrayList<>(), FSMState.REPLICA); + } + + @Override + public long create(ReplicateMeta meta) { + try { + RplStateMachine stateMachine = FSMMetaManager.initStateMachine(StateMachineType.REPLICA, meta, this); + return stateMachine.getId(); + } catch (Throwable e) { + return RplConstants.ERROR_FSMID; + } + } +} + diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/ServiceDetail.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/ServiceDetail.java new file mode 100644 index 00000000..7723f603 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/ServiceDetail.java @@ -0,0 +1,30 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common.fsmutil; + +import lombok.Data; + +import java.util.List; + +@Data +public class ServiceDetail { + private Long id; + private String type; + private String status; + private List taskDetailList; +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/TaskDetail.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/TaskDetail.java new file mode 100644 index 00000000..06e1cf04 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/common/fsmutil/TaskDetail.java @@ -0,0 +1,37 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.common.fsmutil; + +import lombok.Data; + +@Data +public class TaskDetail { + private Long taskId; + private String type; + private String status; + private String physicalDbName; + private String statistics; + private String lastError; + private Integer progress; + private Long delay; + private Long rps; + // arguably should not return following config +// private String taskExtractorConfig; +// private String taskPipelineConfig; +// private String taskApplierConfig; +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/ColumnInfo.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/ColumnInfo.java new file mode 100644 index 00000000..c75c0c32 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/ColumnInfo.java @@ -0,0 +1,42 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.dbmeta; + +import lombok.Data; + +/** + * @author shicai.xsc 2020/11/29 21:19 + * @since 5.0.0.0 + */ +@Data +public class ColumnInfo { + + private String name; + // type value refers to + // "Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/src.zip!/java/sql/Types.java" + private int type; + private String javaCharset; + private boolean nullable; + + public ColumnInfo(String name, int type, String javaCharset, boolean nullable){ + this.name = name; + this.type = type; + this.javaCharset = javaCharset; + this.nullable = nullable; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/ColumnValue.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/ColumnValue.java new file mode 100644 index 00000000..8678918f --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/ColumnValue.java @@ -0,0 +1,54 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.dbmeta; + +import lombok.Data; + +/** + * @author shicai.xsc 2020/12/15 16:51 + * @since 5.0.0.0 + */ +@Data +public class ColumnValue { + + private final Object value; + private final ColumnInfo column; + + public ColumnValue(Object value, ColumnInfo column) { + this.value = value; + this.column = column; + } + + @Override + public String toString() { + if (column != null) { + StringBuilder sb = new StringBuilder(); + sb.append("column:"); + sb.append(column.getName()); + if (value != null) { + sb.append(",value:"); + sb.append(String.valueOf(value)); + } else { + sb.append(",value:null"); + } + return sb.toString(); + } else { + return null; + } + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/DbMetaCache.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/DbMetaCache.java new file mode 100644 index 00000000..e324a660 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/DbMetaCache.java @@ -0,0 +1,142 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.dbmeta; + +import com.aliyun.polardbx.rpl.common.DataSourceUtil; +import com.aliyun.polardbx.rpl.common.RplConstants; +import com.aliyun.polardbx.rpl.taskmeta.HostInfo; +import com.aliyun.polardbx.rpl.taskmeta.HostType; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import javax.sql.DataSource; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author shicai.xsc 2021/1/4 11:02 + * @since 5.0.0.0 + */ +@Slf4j +@Data +public class DbMetaCache { + + private HostInfo hostInfo; + private Map dataSources = new HashMap<>(); + private Map tableInfos = new HashMap<>(); + + private int minPoolSize = 1; + private int maxPoolSize = 60; + private final static String POLARX_DEFAULT_SCHEMA = "polardbx"; + private final static String SET_POLARX_SERVER_ID = "set polardbx_server_id=%d"; + + public DbMetaCache(HostInfo hostInfo, int maxPoolSize) { + this.hostInfo = hostInfo; + this.maxPoolSize = maxPoolSize; + } + + public DataSource getDataSource(String schema) throws Exception { + try { + if (!dataSources.containsKey(schema)) { + List connectionInitSqls = new ArrayList<>(); + String setServerIdSql = + String.format(SET_POLARX_SERVER_ID, hostInfo.getServerId()); + connectionInitSqls.add(setServerIdSql); + DataSource dataSource = DataSourceUtil.createDruidMySqlDataSource(hostInfo.isUsePolarxPoolCN(), + hostInfo.getHost(), + hostInfo.getPort(), + schema, + hostInfo.getUserName(), + hostInfo.getPassword(), + "", + minPoolSize, + maxPoolSize, + null, + connectionInitSqls); + dataSources.put(schema, dataSource); + } + return dataSources.get(schema); + } catch (Exception e) { + log.error("failed in getDataSource, host: {}, port: {}, schema: {}", + hostInfo.getHost(), + hostInfo.getPort(), + schema); + throw e; + } + } + + public DataSource getDataSource() throws Exception { + if (StringUtils.isNotBlank(hostInfo.getSchema())) { + return getDataSource(hostInfo.getSchema()); + } + return getDefaultDataSource(); + } + + public DataSource getDefaultDataSource() throws Exception { + String defaultSchema = hostInfo.getType() == HostType.POLARX2 ? POLARX_DEFAULT_SCHEMA : ""; + return getDataSource(defaultSchema); + } + + public List getDatabases() throws Throwable { + try { + DataSource dataSource = getDefaultDataSource(); + return DbMetaManager.getDatabases(dataSource); + } catch (Throwable e) { + log.error("failed in getDatabases, host: {}, port: {}", hostInfo.getHost(), hostInfo.getPort()); + throw e; + } + } + + public void refreshTableInfo(String schema, String tbName) { + String key = schema + "." + tbName; + tableInfos.remove(key); + } + + public TableInfo getTableInfo(String schema, String tbName) throws Throwable { + String key = schema + "." + tbName; + try { + TableInfo dstTableInfo = tableInfos.get(key); + if (dstTableInfo == null) { + DataSource dataSource = getDataSource(schema); + dstTableInfo = DbMetaManager.getTableInfo(dataSource, schema, tbName, hostInfo.getType()); + tableInfos.put(key, dstTableInfo); + } + } catch (Throwable e) { + log.error("failed in getTableInfo, host: {}, port: {}, schema: {}, tbName: {}", + hostInfo.getHost(), hostInfo.getPort(), schema, tbName); + throw e; + } + return tableInfos.get(key); + } + + public List getTables(String schema) throws Throwable { + try { + DataSource dataSource = getDataSource(schema); + return DbMetaManager.getTables(dataSource); + } catch (Throwable e) { + log.error("failed in getTables, host: {}, port: {}, schema: {}", + hostInfo.getHost(), + hostInfo.getPort(), + schema); + throw e; + } + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/DbMetaManager.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/DbMetaManager.java new file mode 100644 index 00000000..a085d552 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/DbMetaManager.java @@ -0,0 +1,369 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.dbmeta; + +import com.aliyun.polardbx.rpl.common.DataSourceUtil; +import com.aliyun.polardbx.rpl.common.RplConstants; +import com.aliyun.polardbx.rpl.taskmeta.HostType; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.SortedMap; +import java.util.TreeMap; + +/** + * @author shicai.xsc 2020/12/7 19:39 + * @since 5.0.0.0 + */ +@Slf4j +public class DbMetaManager { + + private static final String SHOW_RULE = "SHOW RULE FROM `%s`;"; + private static final String SHOW_INDEXES = "SHOW INDEXES FROM `%s`.`%s` WHERE Non_unique=0"; + private static final String SHOW_DATABASES = "SHOW DATABASES"; + private static final String SHOW_CREATE_TABLE = "SHOW CREATE TABLE `%s`.`%s`"; + private static final String SHOW_TABLES = "SHOW TABLES"; + private static final String PRIMARY = "PRIMARY"; + + public static TableInfo getTableInfo(DataSource dataSource, String schema, String tbName, + HostType hostType) throws SQLException { + TableInfo tableInfo = new TableInfo(schema, tbName); + List columns = getTableColumnInfos(dataSource, schema, tbName); + List pks = getTablePks(dataSource, schema, tbName); + List uks = getTableUks(dataSource, schema, tbName); + + tableInfo.setColumns(columns); + tableInfo.setPks(pks); + tableInfo.setUks(uks); + + if (hostType.getValue() == HostType.POLARX2.getValue()) { + List shardKeys = getTableShardKeys(dataSource, tbName); + if (shardKeys.size() > 0) { + tableInfo.setDbShardKey(shardKeys.get(0)); + } + if (shardKeys.size() > 1) { + tableInfo.setTbShardKey(shardKeys.get(1)); + } + } + return tableInfo; + } + + public static List getDatabases(DataSource dataSource) throws Throwable { + List dbs = new ArrayList<>(); + Connection conn = null; + PreparedStatement stmt = null; + ResultSet rs = null; + + try { + conn = dataSource.getConnection(); + stmt = conn.prepareStatement(SHOW_DATABASES); + rs = stmt.executeQuery(SHOW_DATABASES); + while (rs.next()) { + dbs.add(rs.getString(1)); + } + } catch (Throwable e) { + log.error("failed in getDatabases", e); + throw e; + } finally { + DataSourceUtil.closeQuery(rs, stmt, conn); + } + return dbs; + } + + public static List getTables(DataSource dataSource) throws Throwable { + List tables = new ArrayList<>(); + Connection conn = null; + PreparedStatement stmt = null; + ResultSet rs = null; + + try { + conn = dataSource.getConnection(); + stmt = conn.prepareStatement(SHOW_TABLES); + rs = stmt.executeQuery(SHOW_TABLES); + while (rs.next()) { + tables.add(rs.getString(1)); + } + } catch (Throwable e) { + log.error("failed in getTables", e); + throw e; + } finally { + DataSourceUtil.closeQuery(rs, stmt, conn); + } + return tables; + } + + public static String getCreateTable(DataSource dataSource, String schema, String tbName) throws Throwable { + Connection conn = null; + PreparedStatement stmt = null; + ResultSet rs = null; + + try { + String sql = String.format(SHOW_CREATE_TABLE, schema, tbName); + conn = dataSource.getConnection(); + stmt = conn.prepareStatement(sql); + rs = stmt.executeQuery(sql); + return rs.getString(2); + } catch (Throwable e) { + log.error("failed in getCreateTable", e); + throw e; + } finally { + DataSourceUtil.closeQuery(rs, stmt, conn); + } + } + + /** + * + */ + private static List getTableColumnInfos(DataSource dataSource, String schema, + String tbName) throws SQLException { + List columnList = new ArrayList<>(); + + Connection conn = null; + ResultSet rs = null; + try { + conn = dataSource.getConnection(); + DatabaseMetaData metaData = conn.getMetaData(); + schema = getIdentifierName(schema, metaData); + tbName = getIdentifierName(tbName, metaData); + rs = metaData.getColumns("", schema, tbName, null); + + while (rs.next()) { + String columnName = rs.getString(4); + int columnType = rs.getInt(5); + String typeName = rs.getString(6); + int nullable = rs.getInt(11); + String[] typeSplit = typeName.split(" "); + + // unsigned types + if (typeSplit.length > 1) { + if (columnType == Types.INTEGER && typeSplit[1].toUpperCase().equals("UNSIGNED")) { + columnType = Types.BIGINT; + } + + if (columnType == Types.BIGINT && typeSplit[1].toUpperCase().equals("UNSIGNED")) { + columnType = Types.BIGINT; + } + } + + if (columnType == Types.BIT) { + if (typeName.contains("TINYINT")) { + columnType = Types.TINYINT; + } + } + + if (columnType == Types.OTHER) { + switch (typeName) { + case "NVARCHAR": + case "NVARCHAR2": + columnType = Types.VARCHAR; + break; + // geography type + case "POINT": + case "LINESTRING": + case "POLYGON": + case "MULTIPOINT": + case "MULTILINESTRING": + case "MULTIPOLYGON": + case "GEOMETRY": + case "GEOMETRYCOLLECTION": + columnType = Types.BINARY; + break; + default: + break; + } + } + if (!columnName.equals(RplConstants.POLARX_IMPLICIT_ID) && + !columnName.equals(RplConstants.RDS_IMPLICIT_ID)) { + columnList.add(new ColumnInfo(columnName, columnType, "", + (nullable != DatabaseMetaData.columnNoNulls))); + } + } + } catch (Throwable e) { + log.error("failed in getTableColumnInfos, schema:{}, tbName:{}", schema, tbName); + throw e; + } finally { + DataSourceUtil.closeQuery(rs, null, conn); + } + + return columnList; + } + + /** + * + */ + private static List getTablePks(DataSource dataSource, String schema, String tbName) throws SQLException { + List pks = new ArrayList<>(); + Connection conn = null; + ResultSet rs = null; + + try { + conn = dataSource.getConnection(); + DatabaseMetaData metaData = conn.getMetaData(); + schema = getIdentifierName(schema, metaData); + tbName = getIdentifierName(tbName, metaData); + rs = metaData.getPrimaryKeys(null, schema, tbName); + + SortedMap pmap = new TreeMap(); + while (rs.next()) { + pmap.put(rs.getInt(5), rs.getString(4)); + } + pks.addAll(pmap.values()); + } catch (SQLException e) { + log.error("failed in getTablePks, schema:{}, tbName:{}", schema, tbName); + throw e; + } finally { + DataSourceUtil.closeQuery(rs, null, conn); + } + + return pks; + } + + private static List getTableUks(DataSource dataSource, String schema, String tbName) throws SQLException { + List uks = new ArrayList<>(); + Map> ukGroups = getTableUkGroups(dataSource, schema, tbName); + int minGroupSize = Integer.MAX_VALUE; + String minGroupKey = ""; + for (String groupKey : ukGroups.keySet()) { + int groupSize = ukGroups.get(groupKey).size(); + if (groupSize < minGroupSize) { + minGroupSize = groupSize; + minGroupKey = groupKey; + } + } + + if (StringUtils.isNotBlank(minGroupKey)) { + for (KeyColumnInfo column : ukGroups.get(minGroupKey)) { + uks.add(column.getColumnName()); + } + } + + return uks; + } + + private static List getTableShardKeys(DataSource dataSource, String tbName) throws SQLException { + + List shardKeys = new ArrayList<>(); + + Connection conn = null; + PreparedStatement stmt = null; + ResultSet rs = null; + String sql = String.format(SHOW_RULE, tbName); + + try { + conn = dataSource.getConnection(); + stmt = conn.prepareStatement(sql); + rs = stmt.executeQuery(sql); + + while (rs.next()) { + String dbShardKey = rs.getString("DB_PARTITION_KEY"); + String tbShardKey = rs.getString("TB_PARTITION_KEY"); + if (StringUtils.isNotBlank(dbShardKey)) { + shardKeys.add(dbShardKey); + } + if (StringUtils.isNotBlank(tbShardKey)) { + shardKeys.add(tbShardKey); + } + } + } catch (Throwable e) { + log.error("failed in getTableShardKeys: {}", sql, e); + throw e; + } finally { + DataSourceUtil.closeQuery(rs, stmt, conn); + } + + return shardKeys; + } + + /** + * + */ + private static Map> getTableUkGroups(DataSource dataSource, String schema, + String tbName) throws SQLException { + HashMap> ukGroups = new HashMap<>(); + + Connection conn = null; + PreparedStatement stmt = null; + ResultSet res = null; + String sql = String.format(SHOW_INDEXES, schema, tbName); + + try { + conn = dataSource.getConnection(); + stmt = conn.prepareStatement(sql); + res = stmt.executeQuery(sql); + + while (res.next()) { + int nonUnique = res.getInt("Non_unique"); + String keyName = res.getString("Key_name"); + int seqInIndex = res.getInt("Seq_in_index"); + String columnName = res.getString("Column_name"); + + if (nonUnique == 1) { + continue; + } + + if (StringUtils.equalsIgnoreCase(PRIMARY, keyName)) { + continue; + } + + KeyColumnInfo column = new KeyColumnInfo(tbName, keyName, columnName, nonUnique, seqInIndex); + if (ukGroups.containsKey(keyName)) { + ukGroups.get(keyName).add(column); + } else { + List columns = new ArrayList<>(); + columns.add(column); + ukGroups.put(keyName, columns); + columns.sort(Comparator.comparingInt(KeyColumnInfo::getSeqInIndex)); + } + } + } catch (Throwable e) { + log.error("failed in getTableUkGroups: {}", sql, e); + throw e; + } finally { + DataSourceUtil.closeQuery(res, stmt, conn); + } + + return ukGroups; + } + + /** + * metaData: + * storesUpperCaseIdentifiers,storesUpperCaseQuotedIdentifiers,storesLowerCaseIdentifiers, + * storesLowerCaseQuotedIdentifiers,storesMixedCaseIdentifiers,storesMixedCaseQuotedIdentifiers + */ + private static String getIdentifierName(String name, DatabaseMetaData metaData) throws SQLException { + if (metaData.storesUpperCaseIdentifiers()) { + return StringUtils.upperCase(name); + } else if (metaData.storesLowerCaseIdentifiers()) { + return StringUtils.lowerCase(name); + } + + return name; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/KeyColumnInfo.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/KeyColumnInfo.java new file mode 100644 index 00000000..d7728cc9 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/KeyColumnInfo.java @@ -0,0 +1,42 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.dbmeta; + +import lombok.Data; + +/** + * @author shicai.xsc 2020/12/7 11:02 + * @since 5.0.0.0 + */ +@Data +public class KeyColumnInfo { + + private String table; + private String keyName; + private String columnName; + private int nonUnique; + private int seqInIndex; + + public KeyColumnInfo(String table, String keyName, String columnName, int nonUnique, int seqInIndex) { + this.table = table; + this.keyName = keyName; + this.columnName = columnName; + this.nonUnique = nonUnique; + this.seqInIndex = seqInIndex; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/TableInfo.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/TableInfo.java new file mode 100644 index 00000000..75c6157d --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/dbmeta/TableInfo.java @@ -0,0 +1,45 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.dbmeta; + +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author shicai.xsc 2020/11/29 21:19 + * @since 5.0.0.0 + */ +@Data +public class TableInfo { + + private String schema; + private String name; + private String createTable; + private List pks = new ArrayList<>(); + private List uks = new ArrayList<>(); + private List columns = new ArrayList<>(); + private String dbShardKey; + private String tbShardKey; + + public TableInfo(String schema, String name) { + this.schema = schema; + this.name = name; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/BaseExtractor.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/BaseExtractor.java new file mode 100644 index 00000000..62c4b626 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/BaseExtractor.java @@ -0,0 +1,62 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.extractor; + +import com.aliyun.polardbx.rpl.pipeline.BasePipeline; +import com.aliyun.polardbx.rpl.taskmeta.ExtractorConfig; + +import lombok.Data; + +/** + * @author shicai.xsc 2021/2/18 21:41 + * @since 5.0.0.0 + */ +@Data +public class BaseExtractor { + + protected BasePipeline pipeline; + protected ExtractorConfig extractorConfig; + protected boolean running; + + public BaseExtractor() { + } + + public BaseExtractor(ExtractorConfig extractorConfig) { + this.extractorConfig = extractorConfig; + } + + public boolean init() throws Exception { + return true; + } + + public void start() throws Exception { + } + + public void stop() { + + } + + public boolean isDone() { + return false; + } + + public boolean isRunning() { + return running; + } + +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/CanalBinlogExtractor.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/CanalBinlogExtractor.java new file mode 100644 index 00000000..0d625e45 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/CanalBinlogExtractor.java @@ -0,0 +1,286 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.extractor; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSAction; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSEvent; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSQueryLog; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSTransactionBegin; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSTransactionEnd; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSXATransaction; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultOption; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultRowChange; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.XATransactionType; +import com.aliyun.polardbx.binlog.canal.core.AbstractEventParser; +import com.aliyun.polardbx.binlog.canal.core.BinlogEventSink; +import com.aliyun.polardbx.binlog.canal.core.model.AuthenticationInfo; +import com.aliyun.polardbx.binlog.canal.core.model.BinlogPosition; +import com.aliyun.polardbx.binlog.canal.core.model.MySQLDBMSEvent; +import com.aliyun.polardbx.binlog.domain.po.RplStateMachine; +import com.aliyun.polardbx.rpl.common.RplConstants; +import com.aliyun.polardbx.rpl.common.TaskContext; +import com.aliyun.polardbx.rpl.filter.BaseFilter; +import com.aliyun.polardbx.rpl.pipeline.MessageEvent; +import com.aliyun.polardbx.rpl.taskmeta.ExtractorConfig; +import com.aliyun.polardbx.rpl.taskmeta.HostInfo; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import java.net.InetSocketAddress; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.BitSet; +import java.util.List; + +/** + * @author shicai.xsc 2020/11/29 21:19 + * @since 5.0.0.0 + */ +@Slf4j +@Data +public class CanalBinlogExtractor extends BaseExtractor { + + protected BinlogPosition position; + protected AbstractEventParser parser; + protected long lastHeartTimestamp = 0; + protected boolean filterTransactionEnd = true; + protected HostInfo srcHostInfo; + protected HostInfo metaHostInfo; + protected RplStateMachine stateMachine = TaskContext.getInstance().getStateMachine(); + protected BaseFilter filter; + protected int extracterType; + + protected AuthenticationInfo srcAuthInfo; + protected AuthenticationInfo metaAuthInfo; + + public CanalBinlogExtractor(ExtractorConfig extractorConfig, HostInfo srcHostInfo, HostInfo metaHostInfo, + BinlogPosition position, + BaseFilter filter) { + super(extractorConfig); + this.srcHostInfo = srcHostInfo; + this.metaHostInfo = metaHostInfo; + this.position = position; + this.filter = filter; + initAuthInfo(); + } + + @Override + public boolean init() { + return true; + } + + @Override + public void start() { + try { + parser = new NoTsoMysqlEventParser(); + LogEventConvert logEventConvert = new LogEventConvert(metaHostInfo, filter, position, srcHostInfo.getType()); + logEventConvert.init(); + ((NoTsoMysqlEventParser)parser).setBinlogParser(logEventConvert); + // position specified by user may not be beginning of transaction + parser.setNeedTransactionPosition(true); + log.warn("connecting to : " + srcAuthInfo.getAddress() + " with : " + srcAuthInfo.getUsername()); + parser.start(srcAuthInfo, position, new CanalBinlogEventSink()); + running = true; + } catch (Exception e) { + log.error("extractor start error: ", e); + stop(); + } + } + + @Override + public void stop() { + log.warn("stopping extractor"); + parser.stop(); + log.warn("extractor stopped"); + running = false; + } + + @Override + public boolean isDone() { + return false; + } + + protected void initAuthInfo() { + srcAuthInfo = new AuthenticationInfo(); + srcAuthInfo.setAddress(new InetSocketAddress(srcHostInfo.getHost(), srcHostInfo.getPort())); + srcAuthInfo.setCharset(RplConstants.EXTRACTOR_DEFAULT_CHARSET); + srcAuthInfo.setUsername(srcHostInfo.getUserName()); + srcAuthInfo.setPassword(srcHostInfo.getPassword()); + + metaAuthInfo = new AuthenticationInfo(); + metaAuthInfo.setAddress(new InetSocketAddress(metaHostInfo.getHost(), metaHostInfo.getPort())); + metaAuthInfo.setCharset(RplConstants.EXTRACTOR_DEFAULT_CHARSET); + metaAuthInfo.setUsername(metaHostInfo.getUserName()); + metaAuthInfo.setPassword(metaHostInfo.getPassword()); + } + + protected class CanalBinlogEventSink implements BinlogEventSink { + + private String tid; + private DBMSXATransaction nowXa = null; + + @Override + public boolean sink(Throwable e) { + log.error("sink error", e); + stop(); + return true; + } + + /** + * This will be called by MysqlEventParser + */ + @Override + public boolean sink(List events) { + long now = System.currentTimeMillis(); + Timestamp extractTimestamp = new Timestamp(now); + List datas = new ArrayList<>(events.size()); + + // 一次完整的 XA 事务,会 3 次调用本函数 + // 1. XA_START + // 2. DML SQL(一条或多条) + XA_END + // 3. XA_COMMIT + DBMSXATransaction xaTransaction = null; + if (events.size() > 1) { + xaTransaction = events.get(events.size() - 1).getXaTransaction(); + + if (xaTransaction != null) { + log.warn("com.aliyun.polardbx.extractor events size: {}, xaType: {}", + events.size(), + xaTransaction.getType().getName()); + } + } + + for (MySQLDBMSEvent event : events) { + if (event.getDbMessage() instanceof DBMSTransactionBegin) { + // 只处理正常的数据,事务头和尾就忽略了,避免占用ringbuffer空间 + DBMSTransactionBegin begin = (DBMSTransactionBegin) event.getDbMessage(); + tid = begin.getThreadId() + ""; + continue; + } + + // 默认也过滤掉 DBMSTransactionEnd,避免占用ringbuffer空间,但是要保持心跳以推动位点,所以不能全部过滤 + if (filterTransactionEnd && event.getDbMessage() instanceof DBMSTransactionEnd) { + if (now - lastHeartTimestamp > 1000) { + lastHeartTimestamp = now; + } else { + continue; + } + } + + if (StringUtils.isEmpty(tid)) { + tid = Math.floor(Math.random() * 10000000) + ""; // 随机生成一个 + } + + // 丢弃 XA_START 和 XA_END,但需将 XA_END 的事务信息赋予其关联 DML + // 不丢弃了 + if (event.getXaTransaction() != null + && (event.getXaTransaction().getType() == XATransactionType.XA_START + || event.getXaTransaction().getType() == XATransactionType.XA_END)) { + if (event.getXaTransaction().getType() == XATransactionType.XA_START) { + nowXa = event.getXaTransaction(); + } else if (event.getXaTransaction().getType() == XATransactionType.XA_END) { + nowXa = null; + } + // continue; + } + + DBMSEvent dbmsEvent = event.getDbMessage(); + if (dbmsEvent instanceof DefaultRowChange) { + DefaultRowChange rowChange = (DefaultRowChange) dbmsEvent; + if (rowChange.getRowSize() == 1) { + MessageEvent e = new MessageEvent(); + e.setDbmsEvent(event.getDbMessage()); + e.setPosition(event.getPosition().toString()); + e.setSourceTimestamp(new Timestamp(event.getPosition().getTimestamp() * 1000)); + e.setExtractTimestamp(extractTimestamp); + rowChange.putOption( + new DefaultOption(RplConstants.BINLOG_EVENT_OPTION_TIMESTAMP, e.getSourceTimestamp())); + rowChange.putOption( + new DefaultOption(RplConstants.BINLOG_EVENT_OPTION_POSITION, e.getPosition())); + rowChange.putOption(new DefaultOption(RplConstants.BINLOG_EVENT_OPTION_T_ID, tid)); + // 如果此 DML 与某 XA 事务关联,将 XA_END 的事务信息赋予其关联 DML +// if (xaTransaction != null && xaTransaction.getType() == XATransactionType.XA_END) { +// e.setXaTransaction(xaTransaction); +// } + if (nowXa != null) { + e.setXaTransaction(nowXa); + } + datas.add(e); + } else { + BinlogPosition position = event.getPosition(); + long innerOffset = 0; + for (int rownum = 1; rownum <= rowChange.getRowSize(); rownum++) { + // 多行记录,拆分为单行进行处理 + DefaultRowChange split = new DefaultRowChange(rowChange.getAction(), + rowChange.getSchema(), + rowChange.getTable(), + rowChange.getColumnSet()); + if (DBMSAction.UPDATE == rowChange.getAction()) { + // 需要复制一份changeColumns,避免更新同一个引用 + split.setChangeColumnsBitSet((BitSet) rowChange.getChangeIndexes().clone()); + split.setChangeData(1, rowChange.getChangeData(rownum)); + } + split.setRowData(1, rowChange.getRowData(rownum)); + // 每一行一个事件 + MessageEvent e = new MessageEvent(); + e.setDbmsEvent(split); + position.setInnerOffset(innerOffset++); + e.setPosition(position.toString()); + e.setSourceTimestamp(new Timestamp(event.getPosition().getTimestamp() * 1000)); + e.setExtractTimestamp(extractTimestamp); + split.putOption( + new DefaultOption(RplConstants.BINLOG_EVENT_OPTION_TIMESTAMP, e.getSourceTimestamp())); + split.putOption( + new DefaultOption(RplConstants.BINLOG_EVENT_OPTION_POSITION, e.getPosition())); + split.putOption(new DefaultOption(RplConstants.BINLOG_EVENT_OPTION_T_ID, tid)); + // 如果此 DML 与某 XA 事务关联,将 XA_END 的事务信息赋予其关联 DML +// if (xaTransaction != null && xaTransaction.getType() == XATransactionType.XA_END) { +// e.setXaTransaction(xaTransaction); +// } + if (nowXa != null) { + e.setXaTransaction(nowXa); + } + datas.add(e); + } + } + } else { + // query log event + MessageEvent e = new MessageEvent(); + e.setDbmsEvent(event.getDbMessage()); + e.setPosition(event.getPosition().toString()); + e.setSourceTimestamp(new Timestamp(event.getPosition().getTimestamp() * 1000)); + if (event.getDbMessage() instanceof DBMSQueryLog) { + event.getDbMessage().putOption( + new DefaultOption(RplConstants.BINLOG_EVENT_OPTION_TIMESTAMP, e.getSourceTimestamp())); + event.getDbMessage() + .putOption(new DefaultOption(RplConstants.BINLOG_EVENT_OPTION_POSITION, e.getPosition())); + event.getDbMessage().putOption(new DefaultOption(RplConstants.BINLOG_EVENT_OPTION_T_ID, tid)); + } + e.setExtractTimestamp(extractTimestamp); + e.setXaTransaction(event.getXaTransaction()); + datas.add(e); + } + } + + pipeline.writeRingbuffer(datas); + return true; + } + } + +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/LogEventConvert.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/LogEventConvert.java new file mode 100644 index 00000000..5b761d15 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/LogEventConvert.java @@ -0,0 +1,772 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.extractor; + +import com.alibaba.fastjson.JSON; +import com.aliyun.polardbx.binlog.canal.binlog.CharsetConversion; +import com.aliyun.polardbx.binlog.canal.binlog.LogEvent; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSAction; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSColumn; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSRowData; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSTransactionBegin; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSTransactionEnd; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSXATransaction; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultColumn; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultColumnSet; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultQueryLog; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultRowChange; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultRowData; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.XATransactionType; +import com.aliyun.polardbx.binlog.canal.binlog.event.DeleteRowsLogEvent; +import com.aliyun.polardbx.binlog.canal.binlog.event.IntvarLogEvent; +import com.aliyun.polardbx.binlog.canal.binlog.event.LogHeader; +import com.aliyun.polardbx.binlog.canal.binlog.event.QueryLogEvent; +import com.aliyun.polardbx.binlog.canal.binlog.event.RandLogEvent; +import com.aliyun.polardbx.binlog.canal.binlog.event.RotateLogEvent; +import com.aliyun.polardbx.binlog.canal.binlog.event.RowsLogBuffer; +import com.aliyun.polardbx.binlog.canal.binlog.event.RowsLogEvent; +import com.aliyun.polardbx.binlog.canal.binlog.event.RowsQueryLogEvent; +import com.aliyun.polardbx.binlog.canal.binlog.event.TableMapLogEvent; +import com.aliyun.polardbx.binlog.canal.binlog.event.TableMapLogEvent.ColumnInfo; +import com.aliyun.polardbx.binlog.canal.binlog.event.UnknownLogEvent; +import com.aliyun.polardbx.binlog.canal.binlog.event.UpdateRowsLogEvent; +import com.aliyun.polardbx.binlog.canal.binlog.event.UserVarLogEvent; +import com.aliyun.polardbx.binlog.canal.binlog.event.WriteRowsLogEvent; +import com.aliyun.polardbx.binlog.canal.binlog.event.XidLogEvent; +import com.aliyun.polardbx.binlog.canal.binlog.event.mariadb.AnnotateRowsEvent; +import com.aliyun.polardbx.binlog.canal.core.ddl.TableMeta; +import com.aliyun.polardbx.binlog.canal.core.ddl.TableMeta.FieldMeta; +import com.aliyun.polardbx.binlog.canal.core.ddl.TableMetaCache; +import com.aliyun.polardbx.binlog.canal.core.ddl.parser.DdlResult; +import com.aliyun.polardbx.binlog.canal.core.ddl.parser.DruidDdlParser; +import com.aliyun.polardbx.binlog.canal.core.dump.MysqlConnection; +import com.aliyun.polardbx.binlog.canal.core.model.BinlogPosition; +import com.aliyun.polardbx.binlog.canal.core.model.MySQLDBMSEvent; +import com.aliyun.polardbx.binlog.canal.exception.CanalParseException; +import com.aliyun.polardbx.binlog.canal.exception.TableIdNotFoundException; +import com.aliyun.polardbx.rpl.common.DataSourceUtil; +import com.aliyun.polardbx.rpl.common.RplConstants; +import com.aliyun.polardbx.rpl.filter.BaseFilter; +import com.aliyun.polardbx.rpl.taskmeta.HostInfo; +import com.aliyun.polardbx.rpl.taskmeta.HostType; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.exception.ExceptionUtils; + +import javax.sql.DataSource; +import java.io.Serializable; +import java.io.UnsupportedEncodingException; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.sql.Connection; +import java.sql.Types; +import java.util.Arrays; +import java.util.BitSet; +import java.util.HashMap; +import java.util.List; + +/** + * 基于{@linkplain LogEvent}转化为Entry对象的处理 + * + * @author jianghang 2013-1-17 下午02:41:14 + * @version 1.0.0 + */ +@Slf4j +public class LogEventConvert { + + public static final String ISO_8859_1 = "ISO-8859-1"; + public static final int TINYINT_MAX_VALUE = 256; + public static final int SMALLINT_MAX_VALUE = 65536; + public static final int MEDIUMINT_MAX_VALUE = 16777216; + public static final long INTEGER_MAX_VALUE = 4294967296L; + public static final BigInteger BIGINT_MAX_VALUE = new BigInteger("18446744073709551616"); + public static final int version = 1; + public static final String BEGIN = "BEGIN"; + public static final String COMMIT = "COMMIT"; + + protected static final String MYSQL = "mysql"; + protected static final String HA_HEALTH_CHECK = "ha_health_check"; + protected static final String DRDS_SYSTEM_MYSQL_HEARTBEAT = "__drds__system__mysql__heartbeat__"; + + protected TableMetaCache tableMetaCache; + + protected String binlogFileName = ""; + protected String charset = "utf8"; + protected boolean filterQueryDml = true; + protected boolean filterRowsQuery = false; + // 是否跳过table相关的解析异常,比如表不存在或者列数量不匹配,issue 92 + protected boolean filterTableError = false; + protected boolean firstBinlogFile = true; + protected HostType srcHostType; + protected HostInfo metaHostInfo; + protected BaseFilter filter; + + protected FieldMeta rdsImplicitIDFieldMeta; + protected TableMeta rdsHeartBeatTableMeta; + + public LogEventConvert(HostInfo metaHostInfo, BaseFilter filter, BinlogPosition startBinlogPosition, HostType srcHostType) { + this.metaHostInfo = metaHostInfo; + this.filter = filter; + this.binlogFileName = startBinlogPosition.getFileName(); + this.srcHostType = srcHostType; + } + + public void refreshState() { + firstBinlogFile = true; + } + + public void init() throws Exception { + try { + this.setCharset(RplConstants.EXTRACTOR_DEFAULT_CHARSET); + DataSource dataSource = DataSourceUtil.createDruidMySqlDataSource(metaHostInfo.isUsePolarxPoolCN(), + metaHostInfo.getHost(), + metaHostInfo.getPort(), + "", + metaHostInfo.getUserName(), + metaHostInfo.getPassword(), + "", + 1, + 2, + null, + null); + Connection conn = dataSource.getConnection(); + MysqlConnection connection = new MysqlConnection(conn); + this.tableMetaCache = new TableMetaCache(connection); + initMeta(); + } catch (Throwable e) { + log.error("LogEventConvert init failed, metaHostInfo: {}, {}", e, JSON.toJSONString(metaHostInfo)); + throw e; + } + } + + protected void initMeta() { + rdsImplicitIDFieldMeta = + new FieldMeta(RplConstants.RDS_IMPLICIT_ID, "long", false, true, null, true); + + // 处理rds模式的mysql.ha_health_check心跳数据 + // 主要RDS的心跳表基本无权限,需要mock一个tableMeta + FieldMeta idMeta = new FieldMeta("id", "bigint(20)", true, false, "0", false); + FieldMeta typeMeta = new FieldMeta("type", "char(1)", false, true, "0", false);// type为主键 + rdsHeartBeatTableMeta = new TableMeta(MYSQL, HA_HEALTH_CHECK, Arrays.asList(idMeta, typeMeta)); + } + + public String getBinlogFileName() { + return binlogFileName; + } + + public void setBinlogFileName(String binlogFileName) { + this.binlogFileName = binlogFileName; + } + + public MySQLDBMSEvent parse(LogEvent logEvent, boolean isSeek) throws Exception { + if (logEvent == null || logEvent instanceof UnknownLogEvent) { + return null; + } + + int DBMSAction = logEvent.getHeader().getType(); + switch (DBMSAction) { + // canal 解析 binlog 时,传入的 context (LogContext 类型),其成员 FormatDescriptionLogEvent + // formatDescription 是默认 binlog 不开启 CRC32 校验的(FormatDescriptionLogEvent 的 + // checksumAlg 字段)。 + // 而解析 binlog 时会用到 checksumAlg 值(参考 LogDecoder 第 64 行)。 + // 一个 binlog 文件,第一个事件为 ROTATE_EVENT,第二个为 FORMAT_DESCRIPTION_EVENT。 + // 一个 binlog 文件,只有 ROTATE_EVENT 带有 fileName 信息。 + // ROTATE_EVENT 不包含 checksumAlg 信息。FORMAT_DESCRIPTION_EVENT 包含 checksumAlg 信息。 + // 故如果 binlog 开启了 CRC32,那么: + // canal 解析出来的 ROTATE_EVENT 中的 fileName 是错误的,它将 CRC32 + // 校验值的 4 个字节当成了 fileName 的一部分(参考 LogDecoder 第 64 行)。 + // canal 在解析完 FORMAT_DESCRIPTION_EVENT 后,会解析出正确的 checksumAlg。同时将 context 中的 + // formatDescription 字段替换成正确的。 + // 故如果 binlog 开启了 CRC32,那么解析出来的 binlogFileName 是错误的,而后续解析出的 event 数据却是对的。 + // 但是如果 binlog 文件发生了切换,那么第二个 binlog 文件被解析出来的 binlogFileName 则是对的。 + case LogEvent.ROTATE_EVENT: + if (!firstBinlogFile) { + binlogFileName = ((RotateLogEvent) logEvent).getFilename(); + } + break; + case LogEvent.FORMAT_DESCRIPTION_EVENT: + firstBinlogFile = false; + break; + case LogEvent.QUERY_EVENT: + return parseQueryEvent((QueryLogEvent) logEvent, isSeek); + case LogEvent.XID_EVENT: + return parseXidEvent((XidLogEvent) logEvent); + case LogEvent.TABLE_MAP_EVENT: + break; + case LogEvent.WRITE_ROWS_EVENT_V1: + case LogEvent.WRITE_ROWS_EVENT: + return parseRowsEvent((WriteRowsLogEvent) logEvent); + case LogEvent.UPDATE_ROWS_EVENT_V1: + case LogEvent.UPDATE_ROWS_EVENT: + return parseRowsEvent((UpdateRowsLogEvent) logEvent); + case LogEvent.DELETE_ROWS_EVENT_V1: + case LogEvent.DELETE_ROWS_EVENT: + return parseRowsEvent((DeleteRowsLogEvent) logEvent); + case LogEvent.ROWS_QUERY_LOG_EVENT: + return parseRowsQueryEvent((RowsQueryLogEvent) logEvent); + case LogEvent.ANNOTATE_ROWS_EVENT: + return parseAnnotateRowsEvent((AnnotateRowsEvent) logEvent); + case LogEvent.USER_VAR_EVENT: + return parseUserVarLogEvent((UserVarLogEvent) logEvent); + case LogEvent.INTVAR_EVENT: + return parseIntrvarLogEvent((IntvarLogEvent) logEvent); + case LogEvent.RAND_EVENT: + return parseRandLogEvent((RandLogEvent) logEvent); + case LogEvent.HEARTBEAT_LOG_EVENT: + return null; + default: + break; + } + + return null; + } + + public void reset() { + tableMetaCache.reset(); + } + + protected MySQLDBMSEvent parseQueryEvent(QueryLogEvent event, boolean isSeek) { + String queryString = event.getQuery(); + if (StringUtils.endsWithIgnoreCase(queryString, BEGIN)) { + DBMSTransactionBegin transactionBegin = createTransactionBegin(event.getSessionId()); + return new MySQLDBMSEvent(transactionBegin, createPosition(event.getHeader())); + } else if (StringUtils.endsWithIgnoreCase(queryString, COMMIT)) { + DBMSTransactionEnd transactionEnd = createTransactionEnd(0L); + return new MySQLDBMSEvent(transactionEnd, createPosition(event.getHeader())); + } else { + // DDL语句处理 + // 只保留最后一条,queryString都是一样的 + HashMap ddlInfo = Maps.newHashMap(); + + // 解析 sql 语句 + if (StringUtils.startsWithIgnoreCase(StringUtils.trim(queryString), "flush") + || StringUtils.startsWithIgnoreCase(StringUtils.trim(queryString), "grant") + || StringUtils.startsWithIgnoreCase(StringUtils.trim(queryString), "create user") + || StringUtils.startsWithIgnoreCase(StringUtils.trim(queryString), "drop user")) { + return null; + } + List resultList = DruidDdlParser.parse(queryString, event.getDbName()); + if (CollectionUtils.isEmpty(resultList)) { + if(!(queryString.startsWith("/*!") && queryString.endsWith("*/"))) { + log.error("DDL result list is empty. Raw query string: {}, db: {}", queryString, event.getDbName()); + } + return null; + } + DdlResult result = resultList.get(0); + DBMSAction action = result.getType(); + + // 根据 filter 的 rewriteDbs 重写 dbName + + // 对于非跨库 DDL: use db1, create table tb1(id int) + // event.getDbName() == result.getSchemaName() == db1 + + // 对于跨库 DDL: + // 如在源库 use db1, create db2.tb1(id int) + // 则,event.getDbName() == db1,result.getSchemaName() == db2; + + // 对于 create database db1, drop database db1: + // 则不管是否跨库,始终 event.getDbName() == result.getSchemaName() == db1 + + // getRewriteDb 的作用:如果一条 sql, + // 不管是跨库的 use db2, create table db1.tb1(id int), + // 还是不跨库的 use db1, create table tb1(id int) + // 则 result.getSchemaName() == db1, + // mysql 在目标上执行逻辑:use result.getSchemaName(),create table tb1(id int); + + // 注意:getRewriteDb 对 create database 和 drop database 不生效, + // 因为对于 mysql 来说,即便是有 rewriteDbs: , + // 一条 sql: create database db1,在目标库执行时,不会变成 create database db2, + // 而仍然是 create database db1。 + + // mysql 逻辑,不管是否是跨库 ddl,都使用 event.getDbName() 对应的 rewriteDb 来过滤, + // 而不是使用 result.getSchemaName()。 + // 按照逻辑来说,应该要使用 result.getSchemaName() 的 rewriteDb 来过滤,但此处 polarx 与 mysql 逻辑对齐。 + String rewriteDbName = filter.getRewriteDb(event.getDbName(), action); + if (filter.ignoreEvent(rewriteDbName, result.getTableName(), action, event.getServerId())) { + return null; + } + + // 跨库 ddl,构造 DDL 事件时,要使用其真正的 db,即 result.getSchemaName() + if (!StringUtils.equalsIgnoreCase(event.getDbName(), result.getSchemaName())) { + rewriteDbName = filter.getRewriteDb(result.getSchemaName(), action); + } + + // 对于 create database, drop database,则不再需要指定当前 DDL 在哪个 db 上执行, + // 因为执行 sql: create databases db1 时,本就不要也不能预先执行 use db1 + if (action == DBMSAction.CREATEDB || action == DBMSAction.DROPDB) { + rewriteDbName = ""; + } + + // 更新内存 tableMetaCache + BinlogPosition position = createPosition(event.getHeader()); + tableMetaCache.apply(position, rewriteDbName, queryString); + + // 构造对象 + DefaultQueryLog queryEvent = new DefaultQueryLog(rewriteDbName, + queryString, + new java.sql.Timestamp(event.getHeader().getWhen() * 1000), + event.getErrorCode(), + result.getType()); + + // 将 ddl 的一些信息 set 到 optionValue + if (!ddlInfo.isEmpty()) { + queryEvent.setOptionValue(DefaultQueryLog.ddlInfo, ddlInfo); + } + + MySQLDBMSEvent mySQLDBMSEvent = new MySQLDBMSEvent(queryEvent, createPosition(event.getHeader())); + + // 如果是 XA 事务,解析 + DBMSXATransaction xaTransaction = getXaTransaction(queryString); + if (xaTransaction != null) { + mySQLDBMSEvent.setXaTransaction(xaTransaction); + } + + return mySQLDBMSEvent; + } + } + + protected MySQLDBMSEvent parseRowsQueryEvent(RowsQueryLogEvent event) { + if (filterQueryDml && filterRowsQuery) { + return null; + } + // mysql5.6支持,需要设置binlog-rows-query-log-events=1,可详细打印原始DML语句 + String queryString = null; + try { + queryString = new String(event.getRowsQuery().getBytes(ISO_8859_1), charset); + return buildQueryEntry(queryString, event.getHeader(), DBMSAction.ROWQUERY); + } catch (UnsupportedEncodingException e) { + throw new CanalParseException(e); + } + } + + protected MySQLDBMSEvent parseAnnotateRowsEvent(AnnotateRowsEvent event) { + if (filterQueryDml) { + return null; + } + // mariaDb支持,需要设置binlog_annotate_row_events=true,可详细打印原始DML语句 + String queryString = null; + try { + queryString = new String(event.getRowsQuery().getBytes(ISO_8859_1), charset); + return buildQueryEntry(queryString, event.getHeader(), null); + } catch (UnsupportedEncodingException e) { + throw new CanalParseException(e); + } + } + + protected MySQLDBMSEvent parseUserVarLogEvent(UserVarLogEvent event) { + if (filterQueryDml) { + return null; + } + + return buildQueryEntry(event.getQuery(), event.getHeader(), null); + } + + protected MySQLDBMSEvent parseIntrvarLogEvent(IntvarLogEvent event) { + if (filterQueryDml) { + return null; + } + + return buildQueryEntry(event.getQuery(), event.getHeader(), null); + } + + protected MySQLDBMSEvent parseRandLogEvent(RandLogEvent event) { + if (filterQueryDml) { + return null; + } + + return buildQueryEntry(event.getQuery(), event.getHeader(), null); + } + + protected MySQLDBMSEvent parseXidEvent(XidLogEvent event) { + DBMSTransactionEnd transactionEnd = new DBMSTransactionEnd(); + transactionEnd.setTransactionId(event.getXid()); + return new MySQLDBMSEvent(transactionEnd, createPosition(event.getHeader())); + } + + protected MySQLDBMSEvent parseRowsEvent(RowsLogEvent event) { + try { + TableMapLogEvent table = event.getTable(); + if (table == null) { + // tableId对应的记录不存在 + throw new TableIdNotFoundException("not found tableId:" + event.getTableId()); + } + + DBMSAction action = null; + int type = event.getHeader().getType(); + if (LogEvent.WRITE_ROWS_EVENT_V1 == type || LogEvent.WRITE_ROWS_EVENT == type) { + action = DBMSAction.INSERT; + } else if (LogEvent.UPDATE_ROWS_EVENT_V1 == type || LogEvent.UPDATE_ROWS_EVENT == type) { + action = DBMSAction.UPDATE; + } else if (LogEvent.DELETE_ROWS_EVENT_V1 == type || LogEvent.DELETE_ROWS_EVENT == type) { + action = DBMSAction.DELETE; + } else { + throw new CanalParseException("unsupport event type :" + event.getHeader().getType()); + } + + // 根据 filter 的 rewriteDbs 重写 DbName + String rewriteDbName = filter.getRewriteDb(table.getDbName(), action); + + // 过滤条件 + if (filter.ignoreEvent(rewriteDbName, table.getTableName(), action, event.getServerId())) { + return null; + } + + if (isRDSHeartBeat(rewriteDbName, table.getTableName())) { + return null; + } + + BinlogPosition position = createPosition(event.getHeader()); + RowsLogBuffer buffer = event.getRowsBuf(charset); + BitSet columns = event.getColumns(); + BitSet changeColumns = event.getChangeColumns(); // 非变更的列,而是指存在binlog记录的列,mysql full image模式会提供所有列 + boolean tableError = false; + TableMeta tableMeta = getTableMeta(rewriteDbName, table.getTableName()); + if (tableMeta == null) { + tableError = true; + if (!filterTableError) { + throw new CanalParseException( + "not found [" + rewriteDbName + "." + table.getTableName() + "] in db , pls check!"); + } + } + + // check table fileds count,只能处理加字段 + int columnSize = event.getTable().getColumnCnt(); + + // 构造列信息 + List dbmsColumns = Lists.newArrayList(); + List fieldMetas = tableMeta.getFields(); + // 兼容一下canal的逻辑,认为DDL新增列都加在末尾,如果表结构的列比binlog的要多 + int size = fieldMetas.size(); + if (columnSize < size) { + size = columnSize; + } + for (int i = 0; i < size; i++) { + FieldMeta fieldMeta = fieldMetas.get(i); + // 先临时加一个sqlType=0的值 + DefaultColumn column = new DefaultColumn(fieldMeta.getColumnName(), + i, + Types.OTHER, + fieldMeta.isUnsigned(), + fieldMeta.isNullable(), + fieldMeta.isKey(), + fieldMeta.isUnique()); + dbmsColumns.add(column); + } + + DefaultRowChange rowChange = new DefaultRowChange(action, + rewriteDbName, + table.getTableName(), + new DefaultColumnSet(dbmsColumns)); + BitSet actualChangeColumns = new BitSet(columnSize); // 需要处理到update类型时,基于数据内容进行判定 + rowChange.setChangeColumnsBitSet(actualChangeColumns); + + while (buffer.nextOneRow(columns)) { + // 处理row记录 + if (DBMSAction.INSERT == action) { + // insert的记录放在before字段中 + parseOneRow(rowChange, event, buffer, columns, false, tableMeta, actualChangeColumns); + } else if (DBMSAction.DELETE == action) { + // delete的记录放在before字段中 + parseOneRow(rowChange, event, buffer, columns, false, tableMeta, actualChangeColumns); + } else { + // update需要处理before/after + parseOneRow(rowChange, event, buffer, columns, false, tableMeta, actualChangeColumns); + if (!buffer.nextOneRow(changeColumns)) { + break; + } + + parseOneRow(rowChange, event, buffer, changeColumns, true, tableMeta, actualChangeColumns); + } + } + + MySQLDBMSEvent dbmsEvent = new MySQLDBMSEvent(rowChange, position); + if (tableError) { + log.warn("table parser error : " + rowChange.toString()); + return null; + } else { + return dbmsEvent; + } + } catch (Exception e) { + throw new CanalParseException("parse row data failed.", e); + } + } + + protected void parseOneRow(DefaultRowChange rowChange, RowsLogEvent event, RowsLogBuffer buffer, BitSet cols, + boolean isAfter, TableMeta tableMeta, + BitSet actualChangeColumns) throws UnsupportedEncodingException { + int columnCnt = event.getTable().getColumnCnt(); + ColumnInfo[] columnInfo = event.getTable().getColumnInfo(); + + DefaultRowData rowData = new DefaultRowData(columnCnt); + for (int i = 0; i < columnCnt; i++) { + ColumnInfo info = columnInfo[i]; + // mysql 5.6开始支持nolob/mininal类型,并不一定记录所有的列,需要进行判断 + if (!cols.get(i)) { + continue; + } + + FieldMeta fieldMeta = tableMeta.getFields().get(i); + // fixed issue + // https://github.com/alibaba/canal/issues/66,特殊处理binary/varbinary,不能做编码处理 + boolean isBinary = StringUtils.containsIgnoreCase(fieldMeta.getColumnType(), "VARBINARY") + || StringUtils.containsIgnoreCase(fieldMeta.getColumnType(), "BINARY"); + // 优先使用列的 charset, 如果列没有则使用表的 charset, 表一定有 charset + String charset = StringUtils.isNotBlank(fieldMeta.getCharset()) ? fieldMeta + .getCharset() : tableMeta.getCharset(); + String javaCharset = CharsetConversion.getJavaCharset(charset); + buffer.nextValue(info.type, info.meta, isBinary, javaCharset); + + int javaType = buffer.getJavaType(); + Serializable dataValue = null; + if (!buffer.isNull()) { + final Serializable value = buffer.getValue(); + // 处理各种类型 + switch (javaType) { + case Types.INTEGER: + case Types.TINYINT: + case Types.SMALLINT: + case Types.BIGINT: + // 处理unsigned类型 + Number number = (Number) value; + if (fieldMeta != null && fieldMeta.isUnsigned() && number.longValue() < 0) { + switch (buffer.getLength()) { + case 1: /* MYSQL_TYPE_TINY */ + dataValue = String.valueOf(Integer.valueOf(TINYINT_MAX_VALUE + number.intValue())); + javaType = Types.SMALLINT; // 往上加一个量级 + break; + + case 2: /* MYSQL_TYPE_SHORT */ + dataValue = String.valueOf(Integer.valueOf(SMALLINT_MAX_VALUE + number.intValue())); + javaType = Types.INTEGER; // 往上加一个量级 + break; + + case 3: /* MYSQL_TYPE_INT24 */ + dataValue = String + .valueOf(Integer.valueOf(MEDIUMINT_MAX_VALUE + number.intValue())); + javaType = Types.INTEGER; // 往上加一个量级 + break; + + case 4: /* MYSQL_TYPE_LONG */ + dataValue = String.valueOf(Long.valueOf(INTEGER_MAX_VALUE + number.longValue())); + javaType = Types.BIGINT; // 往上加一个量级 + break; + + case 8: /* MYSQL_TYPE_LONGLONG */ + dataValue = BIGINT_MAX_VALUE.add(BigInteger.valueOf(number.longValue())).toString(); + javaType = Types.DECIMAL; // 往上加一个量级,避免执行出错 + break; + default: + break; + } + } else { + // 对象为number类型,直接valueof即可 + dataValue = String.valueOf(value); + } + break; + case Types.REAL: // float + case Types.DOUBLE: // double + // 对象为number类型,直接valueof即可 + dataValue = String.valueOf(value); + break; + case Types.BIT:// bit + // 对象为byte[]类型,不能直接转为字符串,入库的时候会有问题 + dataValue = value; + break; + case Types.DECIMAL: + dataValue = ((BigDecimal) value).toPlainString(); + break; + case Types.TIMESTAMP: + // 修复时间边界值 + // String v = value.toString(); + // v = v.substring(0, v.length() - 2); + // columnBuilder.setValue(v); + // break; + case Types.TIME: + case Types.DATE: + // 需要处理year + dataValue = value.toString(); + break; + case Types.BINARY: + case Types.VARBINARY: + case Types.LONGVARBINARY: + // fixed text encoding + // https://github.com/AlibabaTech/canal/issues/18 + // mysql binlog中blob/text都处理为blob类型,需要反查table + // meta,按编码解析text + if (fieldMeta != null && isText(fieldMeta.getColumnType())) { + dataValue = new String((byte[]) value, javaCharset); + javaType = Types.CLOB; + } else { + // byte数组,直接使用iso-8859-1保留对应编码,浪费内存 + dataValue = (byte[]) value; + javaType = Types.BLOB; + } + break; + case Types.CHAR: + case Types.VARCHAR: + dataValue = value.toString(); + break; + default: + dataValue = value.toString(); + } + } + + // 下标从1开始 + rowData.setRowValue(i + 1, dataValue); + // 处理一下sqlType + DBMSColumn dbmsColumn = rowChange.getColumns().get(i); + if (dbmsColumn instanceof DefaultColumn && dbmsColumn.getSqlType() == Types.OTHER) { + ((DefaultColumn) dbmsColumn).setSqlType(javaType); + } + } + + if (isAfter) { + rowChange.addChangeData(rowData); + // 处理一下变更列 + DBMSRowData beforeRowData = rowChange.getRowData(rowChange.getRowSize()); + buildChangeColumns(beforeRowData, rowData, columnCnt, actualChangeColumns); + } else { + rowChange.addRowData(rowData); + } + } + + protected void buildChangeColumns(DBMSRowData beforeRowData, DBMSRowData afterRowData, int size, + BitSet changeColumns) { + for (int i = 1; i <= size; i++) { + Serializable before = beforeRowData.getRowValue(i); + Serializable after = afterRowData.getRowValue(i); + + boolean check = isUpdate(before, after); + if (check) { + changeColumns.set(i - 1, true); + } + } + + } + + protected boolean isUpdate(Serializable before, Serializable after) { + if (before == null && after == null) { + return false; + } else if (before != null && after != null && isEqual(before, after)) { + return false; + } + + // 比如nolob/minial模式下,可能找不到before记录,认为是有变化 + return true; + } + + private boolean isEqual(Serializable before, Serializable after) { + if (before instanceof byte[] && after instanceof byte[]) { + return Arrays.equals((byte[]) before, (byte[]) after); + } else { + return before.equals(after); + } + } + + protected MySQLDBMSEvent buildQueryEntry(String queryString, LogHeader logHeader, DBMSAction action) { + DefaultQueryLog queryLog = new DefaultQueryLog(null, + queryString, + new java.sql.Timestamp(logHeader.getWhen() * 1000), + 0, + action); + + return new MySQLDBMSEvent(queryLog, createPosition(logHeader)); + } + + protected BinlogPosition createPosition(LogHeader logHeader) { + return new BinlogPosition(binlogFileName, logHeader.getLogPos(), logHeader.getServerId(), + logHeader.getWhen()); // 记录到秒 + } + + protected TableMeta getTableMeta(String dbName, String tbName) { + try { + TableMeta tableMeta = tableMetaCache.getTableMeta(dbName, tbName); + if (tableMeta.getPrimaryFields().isEmpty() && !tableMeta.getUseImplicitPk()) { + if (srcHostType == HostType.RDS) { + // 添加 polarx 隐藏主键 + log.info("Add implicit id {} for table {}.{}", RplConstants.RDS_IMPLICIT_ID, dbName, tbName); + tableMeta.addFieldMeta(rdsImplicitIDFieldMeta); + tableMeta.setUseImplicitPk(true); + } + } + return tableMeta; + } catch (Throwable e) { + String message = ExceptionUtils.getRootCauseMessage(e); + if (filterTableError) { + if (StringUtils.contains(message, "errorNumber=1146") + && StringUtils.contains(message, "doesn't exist")) { + return null; + } + } + + throw new CanalParseException(e); + } + } + + protected boolean isText(String columnType) { + return "LONGTEXT".equalsIgnoreCase(columnType) || "MEDIUMTEXT".equalsIgnoreCase(columnType) + || "TEXT".equalsIgnoreCase(columnType) || "TINYTEXT".equalsIgnoreCase(columnType); + } + + protected boolean isRDSHeartBeat(String schema, String table) { + return (MYSQL.equalsIgnoreCase(schema) && HA_HEALTH_CHECK.equalsIgnoreCase(table)) + || DRDS_SYSTEM_MYSQL_HEARTBEAT.equalsIgnoreCase(table); + } + + public static DBMSTransactionBegin createTransactionBegin(long threadId) { + DBMSTransactionBegin transactionBegin = new DBMSTransactionBegin(); + transactionBegin.setThreadId(threadId); + return transactionBegin; + } + + public static DBMSTransactionEnd createTransactionEnd(long transactionId) { + DBMSTransactionEnd transactionEnd = new DBMSTransactionEnd(); + transactionEnd.setTransactionId(transactionId); + return transactionEnd; + } + + protected String getXid(String queryString, XATransactionType type) throws CanalParseException { + return queryString.substring(type.getName().length()).trim(); + } + + protected DBMSXATransaction getXaTransaction(String queryString) throws CanalParseException { + DBMSXATransaction xaTransaction = null; + if (StringUtils.startsWithIgnoreCase(queryString, XATransactionType.XA_START.getName())) { + xaTransaction = new DBMSXATransaction(getXid(queryString, XATransactionType.XA_START), + XATransactionType.XA_START); + } else if (StringUtils.startsWithIgnoreCase(queryString, XATransactionType.XA_END.getName())) { + xaTransaction = new DBMSXATransaction(getXid(queryString, XATransactionType.XA_END), + XATransactionType.XA_END); + } else if (StringUtils.startsWithIgnoreCase(queryString, XATransactionType.XA_COMMIT.getName())) { + xaTransaction = new DBMSXATransaction(getXid(queryString, XATransactionType.XA_COMMIT), + XATransactionType.XA_COMMIT); + } else if (StringUtils.startsWithIgnoreCase(queryString, XATransactionType.XA_ROLLBACK.getName())) { + xaTransaction = new DBMSXATransaction(getXid(queryString, XATransactionType.XA_ROLLBACK), + XATransactionType.XA_ROLLBACK); + } + + return xaTransaction; + } + + public void setCharset(String charset) { + this.charset = charset; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/NoTsoMysqlEventParser.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/NoTsoMysqlEventParser.java new file mode 100644 index 00000000..5e48cb1c --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/NoTsoMysqlEventParser.java @@ -0,0 +1,703 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.extractor; + +import com.aliyun.polardbx.binlog.canal.binlog.LogEvent; +import com.aliyun.polardbx.binlog.canal.binlog.LogPosition; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSEvent; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSTransactionBegin; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSTransactionEnd; +import com.aliyun.polardbx.binlog.canal.core.BinlogEventSink; +import com.aliyun.polardbx.binlog.canal.core.MysqlEventParser; +import com.aliyun.polardbx.binlog.canal.core.dump.ErosaConnection; +import com.aliyun.polardbx.binlog.canal.core.dump.EventTransactionBuffer; +import com.aliyun.polardbx.binlog.canal.core.dump.MysqlConnection; +import com.aliyun.polardbx.binlog.canal.core.dump.SinkFunction; +import com.aliyun.polardbx.binlog.canal.core.model.AuthenticationInfo; +import com.aliyun.polardbx.binlog.canal.core.model.BinlogPosition; +import com.aliyun.polardbx.binlog.canal.core.model.MySQLDBMSEvent; +import com.aliyun.polardbx.binlog.canal.exception.CanalParseException; +import com.aliyun.polardbx.binlog.canal.exception.PositionNotFoundException; +import com.aliyun.polardbx.binlog.canal.exception.TableIdNotFoundException; +import com.aliyun.polardbx.binlog.monitor.MonitorManager; +import com.aliyun.polardbx.binlog.monitor.MonitorType; +import com.aliyun.polardbx.rpl.applier.StatisticalProxy; +import com.aliyun.polardbx.rpl.common.CommonUtil; +import com.aliyun.polardbx.rpl.common.TaskContext; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; + +/** + * @author shicai.xsc 2020/11/27 17:37 + * @since 5.0.0.0 + */ +@Slf4j +public class NoTsoMysqlEventParser extends MysqlEventParser { + + // binLogParser + protected LogEventConvert binlogParser; + protected EventTransactionBuffer transactionBuffer; + + protected BinlogEventSink eventSink; + protected boolean tryUseMysqlMinPosition; + protected BinlogPosition startPosition; + protected int MAX_RETRY = 20; + protected boolean autoRetry = true; + protected boolean directExitWhenStop = true; + + public NoTsoMysqlEventParser() { + // 初始化一下 + transactionBuffer = new EventTransactionBuffer(transaction -> { + boolean succeeded = consumeTheEventAndProfilingIfNecessary(transaction); + if (!running) { + return; + } + + if (!succeeded) { + throw new CanalParseException("consume failed!"); + } + }); + } + + protected boolean consumeTheEventAndProfilingIfNecessary(List entrys) throws CanalParseException { + // 收到数据了,重置一下 + //dumpTimeoutCount = 0; + //dumpErrorCount = 0; + + long startTs = -1; + boolean enabled = getProfilingEnabled(); + if (enabled) { + startTs = System.currentTimeMillis(); + } + + boolean result = eventSink.sink(entrys); + if (enabled) { + this.processingInterval = System.currentTimeMillis() - startTs; + } + + if (consumedEventCount.incrementAndGet() < 0) { + consumedEventCount.set(0); + } + + return result; + } + + @Override + public void start(final AuthenticationInfo master, final BinlogPosition position, final BinlogEventSink eventSink) { + if (running) { + return; + } + + running = true; + + this.runningInfo = master; + this.eventSink = eventSink; + this.startPosition = position; + + // 配置transaction buffer + // 初始化缓冲队列 + transactionBuffer.setBufferSize(transactionSize);// 设置buffer大小 + transactionBuffer.start(); + + // 启动工作线程 + parseThread = new ParserThread(); + parseThread.setUncaughtExceptionHandler((t, e) -> { + if (directExitWhenStop) { + log.error("encounter uncaught exception, process will exit.", e); + Runtime.getRuntime().halt(1); + } + }); + parseThread.setName(String.format("address = %s , EventParser", + runningInfo == null ? null : runningInfo.getAddress().toString())); + parseThread.start(); + } + + @Override + protected BinlogPosition findStartPosition(ErosaConnection connection, BinlogPosition position) throws IOException { + BinlogPosition startPosition = findStartPositionInternal(connection, position); + if (needTransactionPosition.get()) { + log.warn("prepare to find last position : " + startPosition.toString()); + Long preTransactionStartPosition = findTransactionBeginPosition(connection, startPosition); + if (!preTransactionStartPosition.equals(startPosition.getPosition())) { + log.warn("find new start Transaction Position {}, old : {}", + startPosition.getPosition(), preTransactionStartPosition); + + BinlogPosition newStartPosition = new BinlogPosition(startPosition.getFileName(), + preTransactionStartPosition, + startPosition.getMasterId(), + startPosition.getTimestamp()); + startPosition = newStartPosition; + } + needTransactionPosition.compareAndSet(true, false); + } + + // 兼容一下以前的dbsync的无文件前缀,添加一个默认值 + if (startPosition != null && startPosition.getFilePattern() == null) { + connection.reconnect(); + BinlogPosition endPosition = findEndPosition((MysqlConnection) connection); + startPosition.setFilePattern(endPosition.getFilePattern()); + } + return startPosition; + } + + @Override + protected BinlogPosition findStartPositionInternal(ErosaConnection connection, BinlogPosition entryPosition) { + MysqlConnection mysqlConnection = (MysqlConnection) connection; + this.currentServerId = findServerId(mysqlConnection); + if (entryPosition == null) {// 找不到历史成功记录 + return findEndPositionWithMasterIdAndTimestamp(mysqlConnection); // 默认从当前最后一个位置进行消费 + } + + // binlog定位位点失败,可能有两个原因: + // 1. binlog位点被删除 + // 2. vip模式的mysql,发生了主备切换,判断一下serverId是否变化,针对这种模式可以发起一次基于时间戳查找合适的binlog位点 + // 此处不考虑vip模式情况,如有需要,可自行实现 + + // 判断一下是否需要按时间订阅 + if (CommonUtil.isMeaninglessBinlogFileName(entryPosition)) { + // 如果没有指定binlogName,尝试按照timestamp进行查找 + if (entryPosition.getTimestamp() > 0L) { + log.warn("prepare to find start position ::" + entryPosition.getTimestamp()); + return findByStartTimeStamp(mysqlConnection, entryPosition.getTimestamp()); + } else { + log.warn("prepare to find start position just show binlog events limit 1"); + return findStartPosition(mysqlConnection); // 默认从能找到的最早位置进行消费 + } + } else { + if (entryPosition.getPosition() > 0L) { + // 如果指定binlogName + offest,直接返回 + log.warn("prepare to find start position just last position " + entryPosition.getFileName() + ":" + + entryPosition.getPosition() + ":"); + return entryPosition; + // return findPositionWithMasterIdAndTimestamp(mysqlConnection, entryPosition); + } else { + BinlogPosition specificLogFilePosition = null; + if (entryPosition.getTimestamp() > 0L) { + // 如果指定binlogName + + // timestamp,但没有指定对应的offest,尝试根据时间找一下offest + BinlogPosition endPosition = findEndPosition(mysqlConnection); + if (endPosition != null) { + log.warn("prepare to find start position " + entryPosition.getFileName() + "::" + + entryPosition.getTimestamp()); + specificLogFilePosition = findAsPerTimestampInSpecificLogFile(mysqlConnection, + entryPosition.getTimestamp(), + endPosition, + entryPosition.getFileName()); + } + } + + if (specificLogFilePosition == null) { + // position不存在,从文件头开始 + entryPosition = new BinlogPosition(entryPosition.getFileName(), + BINLOG_START_OFFEST, + entryPosition.getMasterId(), + entryPosition.getTimestamp()); + return entryPosition; + } else { + return specificLogFilePosition; + } + } + } + } + + protected BinlogPosition findPositionWithMasterIdAndTimestamp(MysqlConnection connection, + BinlogPosition fixedPosition) { + if (fixedPosition.getTimestamp() > 0) { + return fixedPosition; + } + + MysqlConnection mysqlConnection = (MysqlConnection) connection; + long startTimestamp = TimeUnit.MILLISECONDS + .toSeconds(System.currentTimeMillis() + 102L * 365 * 24 * 3600 * 1000); // 当前时间的未来102年 + return findAsPerTimestampInSpecificLogFile(mysqlConnection, + startTimestamp, + fixedPosition, + fixedPosition.getFileName()); + } + + protected BinlogPosition findEndPositionWithMasterIdAndTimestamp(MysqlConnection connection) { + MysqlConnection mysqlConnection = (MysqlConnection) connection; + final BinlogPosition endPosition = findEndPosition(mysqlConnection); + long startTimestamp = System.currentTimeMillis(); + return findAsPerTimestampInSpecificLogFile(mysqlConnection, + startTimestamp, + endPosition, + endPosition.getFileName()); + } + + // 根据时间查找binlog位置 + @Override + protected BinlogPosition findByStartTimeStamp(MysqlConnection mysqlConnection, Long startTimestamp) { + BinlogPosition endPosition = findEndPosition(mysqlConnection); + BinlogPosition startPosition = findStartPosition(mysqlConnection); + String maxBinlogFileName = endPosition.getFileName(); + String minBinlogFileName = startPosition.getFileName(); + log.info("show master status to set search end condition: " + endPosition); + String startSearchBinlogFile = endPosition.getFileName(); + boolean shouldBreak = false; + while (running && !shouldBreak) { + try { + BinlogPosition entryPosition = findAsPerTimestampInSpecificLogFile(mysqlConnection, + startTimestamp, + endPosition, + startSearchBinlogFile); + if (entryPosition == null) { + if (StringUtils.equalsIgnoreCase(minBinlogFileName, startSearchBinlogFile)) { + // 已经找到最早的一个binlog,没必要往前找了 + shouldBreak = true; + log.warn("Didn't find the corresponding binlog files from " + minBinlogFileName + " to " + + maxBinlogFileName); + } else { + // 继续往前找 + int binlogSeqNum = Integer + .parseInt(startSearchBinlogFile.substring(startSearchBinlogFile.indexOf(".") + 1)); + if (binlogSeqNum <= 1) { + log.warn("Didn't find the corresponding binlog files"); + shouldBreak = true; + } else { + int nextBinlogSeqNum = binlogSeqNum - 1; + String binlogFileNamePrefix = startSearchBinlogFile.substring(0, + startSearchBinlogFile.indexOf(".") + 1); + String binlogFileNameSuffix = String.format("%06d", nextBinlogSeqNum); + startSearchBinlogFile = binlogFileNamePrefix + binlogFileNameSuffix; + } + } + } else { + log.info("found and return:" + endPosition + " in findByStartTimeStamp operation."); + return entryPosition; + } + } catch (Exception e) { + log.warn("the binlogfile:" + startSearchBinlogFile + + " doesn't exist, to continue to search the next binlogfile , caused by ", + e); + int binlogSeqNum = Integer + .parseInt(startSearchBinlogFile.substring(startSearchBinlogFile.indexOf(".") + 1)); + if (binlogSeqNum <= 1) { + log.warn("Didn't find the corresponding binlog files"); + shouldBreak = true; + } else { + int nextBinlogSeqNum = binlogSeqNum - 1; + String binlogFileNamePrefix = startSearchBinlogFile.substring(0, + startSearchBinlogFile.indexOf(".") + 1); + String binlogFileNameSuffix = String.format("%06d", nextBinlogSeqNum); + startSearchBinlogFile = binlogFileNamePrefix + binlogFileNameSuffix; + } + } + } + // 找不到 + return null; + } + + // 根据想要的position,可能这个position对应的记录为rowdata,需要找到事务头,避免丢数据 + // 主要考虑一个事务执行时间可能会几秒种,如果仅仅按照timestamp相同,则可能会丢失事务的前半部分数据 + protected Long findTransactionBeginPosition(ErosaConnection mysqlConnection, + final BinlogPosition entryPosition) throws IOException { + // 尝试找到一个合适的位置 + final AtomicBoolean reDump = new AtomicBoolean(false); + mysqlConnection.reconnect(); + binlogParser.refreshState(); + + try { + mysqlConnection.seek(entryPosition.getFileName(), entryPosition.getPosition(), new SinkFunction() { + + private BinlogPosition lastPosition; + + @Override + public boolean sink(LogEvent event, LogPosition logPosition) { + try { + MySQLDBMSEvent entry = parseAndProfilingIfNecessary(event, true); + if (entry == null) { + return true; + } + + DBMSEvent dbmsEvent = entry.getDbMessage(); + // 直接查询第一条业务数据,确认是否为事务Begin/End + if (dbmsEvent instanceof DBMSTransactionBegin || dbmsEvent instanceof DBMSTransactionEnd) { + lastPosition = buildLastPosition(entry); + return false; + } else { + reDump.set(true); + lastPosition = buildLastPosition(entry); + return false; + } + } catch (Exception e) { + // 上一次记录的poistion可能为一条update/insert/delete变更事件,直接进行dump的话,会缺少tableMap事件,导致tableId未进行解析 + processSinkError(e, lastPosition, entryPosition.getFileName(), entryPosition.getPosition()); + reDump.set(true); + return false; + } + } + }); + } catch (Exception e) { + log.error("ERROR ## findTransactionBeginPosition has an error", e); + } + + log.info("begin redump"); + + // 针对开始的第一条为非Begin记录,需要从该binlog扫描 + if (reDump.get()) { + final AtomicLong preTransactionStartPosition = new AtomicLong(0L); + mysqlConnection.reconnect(); + try { + mysqlConnection.seek(entryPosition.getFileName(), 4L, new SinkFunction() { + + private BinlogPosition lastPosition; + + @Override + public boolean sink(LogEvent event, LogPosition logPosition) { + try { + + MySQLDBMSEvent entry = parseAndProfilingIfNecessary(event, true); + if (entry == null) { + return true; + } + + DBMSEvent dbmsEvent = entry.getDbMessage(); + // 直接查询第一条业务数据,确认是否为事务Begin + // 记录一下transaction begin position + if (dbmsEvent instanceof DBMSTransactionBegin + && entry.getPosition().getPosition() < entryPosition.getPosition()) { + preTransactionStartPosition.set(entry.getPosition().getPosition()); + } + + if (entry.getPosition().getPosition() >= entryPosition.getPosition()) { + return false;// 退出 + } + + lastPosition = buildLastPosition(entry); + } catch (Exception e) { + processSinkError(e, lastPosition, entryPosition.getFileName(), entryPosition.getPosition()); + return false; + } + + return running; + } + }); + } catch (Exception e) { + log.error("ERROR ## findTransactionBeginPosition has an error", e); + } + + // 判断一下找到的最接近position的事务头的位置 + if (preTransactionStartPosition.get() > entryPosition.getPosition()) { + log.error("preTransactionEndPosition greater than startPosition from zk or localconf, maybe lost data"); + throw new IOException( + "preTransactionStartPosition greater than startPosition from zk or localconf, maybe lost data"); + } + return preTransactionStartPosition.get(); + } else { + return entryPosition.getPosition(); + } + } + + /** + * 根据给定的时间戳,在指定的binlog中找到最接近于该时间戳(必须是小于时间戳)的一个事务起始位置。 + * 针对最后一个binlog会给定endPosition,避免无尽的查询 + */ + protected BinlogPosition findAsPerTimestampInSpecificLogFile(MysqlConnection mysqlConnection, + final Long startTimestamp, + final BinlogPosition endPosition, + final String searchBinlogFile) { + + final AtomicReference ref = new AtomicReference(); + try { + mysqlConnection.reconnect(); + binlogParser.refreshState(); + // 如果以timestamp来找位点,这里binlog parser的binlogfilename为"0" + binlogParser.setBinlogFileName(searchBinlogFile); + // 开始遍历文件 + mysqlConnection.seek(searchBinlogFile, 4L, new SinkFunction() { + + private BinlogPosition lastPosition; + + @Override + public boolean sink(LogEvent event, LogPosition logPosition) { + BinlogPosition entryPosition = null; + try { + MySQLDBMSEvent entry = parseAndProfilingIfNecessary(event, true); + String logfilename = binlogParser.getBinlogFileName(); + // String logfilename = searchBinlogFile; + Long logfileoffset = event.getLogPos(); + Long logposTimestamp = event.getWhen(); + Long masterId = event.getServerId(); + + // 提前执行判断:找第一条记录时间戳,如果最小的一条记录都不满足条件,可直接退出 + if (logposTimestamp >= startTimestamp) { + return false; + } + + // 不包含任何 transaction 的 binlog + if (entry == null) { + if (StringUtils.equals(endPosition.getFileName(), searchBinlogFile) + || StringUtils.equals(endPosition.getFileName(), logfilename)) { + if (endPosition.getPosition() <= logfileoffset) { + entryPosition = new BinlogPosition(logfilename, + logfileoffset, + masterId, + logposTimestamp); + if (log.isDebugEnabled()) { + log.debug("set " + entryPosition + + " to be pending start position before finding another proper one..."); + } + /** + * 把这个 position 作为查找的结果 + */ + ref.set(entryPosition); + + return false; + } + } + + return true; + } + + logfilename = entry.getPosition().getFileName(); + + DBMSEvent dbmsEvent = entry.getDbMessage(); + if (dbmsEvent instanceof DBMSTransactionBegin || dbmsEvent instanceof DBMSTransactionEnd) { + if (log.isDebugEnabled()) { + log.debug(String.format("compare exit condition:%s,%s,%s, startTimestamp=%s...", + logfilename, + String.valueOf(logfileoffset), + String.valueOf(logposTimestamp), + String.valueOf(startTimestamp))); + } + } + + if (StringUtils.equals(endPosition.getFileName(), searchBinlogFile) + || StringUtils.equals(endPosition.getFileName(), logfilename)) { + if (endPosition.getPosition() <= logfileoffset) { + return false; + } + } + + // 记录一下上一个事务结束的位置,即下一个事务的position + // position = current + + // data.length,代表该事务的下一条offest,避免多余的事务重复 + if (dbmsEvent instanceof DBMSTransactionEnd || dbmsEvent instanceof DBMSTransactionBegin) { + entryPosition = new BinlogPosition(logfilename, logfileoffset, masterId, logposTimestamp); + if (log.isDebugEnabled()) { + log.debug("set " + entryPosition + + " to be pending start position before finding another proper one..."); + } + ref.set(entryPosition); + } + + lastPosition = buildLastPosition(entry); + } catch (Throwable e) { + processSinkError(e, lastPosition, searchBinlogFile, 4L); + } + + return running; + } + }); + } catch (Exception e) { + log.error("ERROR ## findAsPerTimestampInSpecificLogFile has an error", e); + } + + if (ref.get() != null) { + return ref.get(); + } else { + return null; + } + } + + /** + * @param isSeek 是否回溯 + */ + protected MySQLDBMSEvent parseAndProfilingIfNecessary(LogEvent bod, boolean isSeek) throws Exception { + long startTs = -1; + boolean enabled = getProfilingEnabled(); + if (enabled) { + startTs = System.currentTimeMillis(); + } + MySQLDBMSEvent event = binlogParser.parse(bod, isSeek); + if (enabled) { + this.parsingInterval = System.currentTimeMillis() - startTs; + } + + if (parsedEventCount.incrementAndGet() < 0) { + parsedEventCount.set(0); + } + return event; + } + + protected BinlogPosition buildLastPosition(MySQLDBMSEvent entry) { // 初始化一下 + return entry.getPosition(); + } + + private class ParserThread extends Thread { + int retry = 0; + + @Override + public void run() { + ErosaConnection erosaConnection = null; + while (running) { + try { + // 开始执行replication + // 1. 构造Erosa连接 + erosaConnection = buildErosaConnection(); + + // 2. 启动一个心跳线程 + // startHeartBeat(erosaConnection); + + // 3. 执行dump前的准备工作,此处会准备好metaConnection + preDump(erosaConnection); + + erosaConnection.connect(); + + // 5. 获取最后的位置信息 + BinlogPosition processedStartPosition = findStartPosition(erosaConnection, startPosition); + if (processedStartPosition == null) { + if (tryUseMysqlMinPosition) { + processedStartPosition = findStartPosition((MysqlConnection) erosaConnection); + log.warn("can't find start position, will use mysql min position start!:" + + processedStartPosition); + } else { + throw new PositionNotFoundException("can't find start position"); + } + } + startPosition = processedStartPosition; + + if (!processTableMeta(startPosition)) { + throw new CanalParseException( + "can't find init table meta for with position : " + startPosition); + } + log.warn("find start position : " + startPosition.toString()); + // 重新链接,因为在找position过程中可能有状态,需要断开后重建 + erosaConnection.reconnect(); + binlogParser.refreshState(); + binlogParser.setBinlogFileName(startPosition.getFileName()); + + + final SinkFunction sinkHandler = new SinkFunction() { + + private BinlogPosition lastPosition; + + @Override + public boolean sink(LogEvent event, LogPosition logPosition) throws CanalParseException, + TableIdNotFoundException { + try { + MySQLDBMSEvent entry = parseAndProfilingIfNecessary(event, false); + + if (!running) { + return false; + } + + if (entry != null) { + transactionBuffer.add(entry); + // 记录一下对应的positions + this.lastPosition = buildLastPosition(entry); + } + StatisticalProxy.getInstance().heartbeat(); + return running; + } catch (TableIdNotFoundException e) { + throw e; + } catch (Throwable e) { + if (e.getCause() instanceof TableIdNotFoundException) { + throw (TableIdNotFoundException) e.getCause(); + } + // 记录一下,出错的位点信息 + processSinkError(e, + this.lastPosition, + startPosition.getFileName(), + startPosition.getPosition()); + throw new CanalParseException(e); // 继续抛出异常,让上层统一感知 + } + } + }; + + // 4. 开始dump数据 + erosaConnection.dump(startPosition.getFileName(), + startPosition.getPosition(), + startPosition.getTimestamp(), + sinkHandler); + } catch (TableIdNotFoundException e) { + // 特殊处理TableIdNotFound异常,出现这样的异常,一种可能就是起始的position是一个事务当中,导致tablemap + // Event时间没解析过 + needTransactionPosition.compareAndSet(false, true); + log.error(String.format("dump address %s has an error, retrying. caused by ", + runningInfo.getAddress().toString()), e); + } catch (Throwable e) { + processDumpError(e); + if (!running) { + if (!(e instanceof java.nio.channels.ClosedByInterruptException + || e.getCause() instanceof java.nio.channels.ClosedByInterruptException)) { + throw new CanalParseException(String.format("dump address %s has an error, retrying. ", + runningInfo.getAddress().toString()), e); + } + } else { + log.error(String.format("dump address %s has an error, retrying. caused by ", + runningInfo.getAddress().toString()), e); + } + } finally { + // 重新置为中断状态 + Thread.interrupted(); + // 关闭一下链接 + afterDump(erosaConnection); + try { + if (erosaConnection != null) { + erosaConnection.disconnect(); + } + } catch (IOException e1) { + log.error("disconnect address " + runningInfo.getAddress().toString() + + " has an error, retrying., caused by ", + e1); + } + } + // 出异常了,退出sink消费,释放一下状态 + transactionBuffer.reset();// 重置一下缓冲队列,重新记录数据 + binlogParser.reset();// 重新置位 + + log.error("ParserThread run failed, retry: {}", retry); + if (++retry >= MAX_RETRY || !autoRetry) { + running = false; + } + if (running) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + } + } + } + + if (directExitWhenStop) { + log.error("ParserThread failed after retry: {}, process exit", retry); + System.exit(1); + } + } + } + + public void setBinlogParser(LogEventConvert binlogParser) { + this.binlogParser = binlogParser; + } + + public void setAutoRetry(boolean autoRetry) { + this.autoRetry = autoRetry; + } + + public void setDirectExitWhenStop(boolean directExitWhenStop) { + this.directExitWhenStop = directExitWhenStop; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/cdc/DefaultCdcExtractHandler.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/cdc/DefaultCdcExtractHandler.java new file mode 100644 index 00000000..76e97ce1 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/cdc/DefaultCdcExtractHandler.java @@ -0,0 +1,118 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.extractor.cdc; + +import com.aliyun.polardbx.binlog.canal.binlog.LogEvent; +import com.aliyun.polardbx.binlog.canal.binlog.LogPosition; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSEvent; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSQueryLog; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSTransactionEnd; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultOption; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultRowChange; +import com.aliyun.polardbx.binlog.canal.core.handle.EventHandle; +import com.aliyun.polardbx.binlog.canal.core.model.MySQLDBMSEvent; +import com.aliyun.polardbx.binlog.canal.exception.CanalParseException; +import com.aliyun.polardbx.binlog.error.PolardbxException; +import com.aliyun.polardbx.rpl.common.RplConstants; +import com.aliyun.polardbx.rpl.extractor.LogEventConvert; +import com.aliyun.polardbx.rpl.pipeline.BasePipeline; +import com.aliyun.polardbx.rpl.pipeline.MessageEvent; + +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; + +public class DefaultCdcExtractHandler implements EventHandle { + + protected final LogEventConvert binlogParser; + protected BasePipeline pipeline; + protected List datas = new ArrayList<>(); + + public DefaultCdcExtractHandler(LogEventConvert binlogParser, BasePipeline pipeline) { + this.binlogParser = binlogParser; + this.pipeline = pipeline; + } + + @Override + public boolean interrupt() { + return false; + } + + @Override + public void onStart() { + + } + + private boolean acceptEvent(DBMSEvent dbmsEvent) { + if (dbmsEvent instanceof DBMSTransactionEnd) { + return true; + } + if (dbmsEvent instanceof DefaultRowChange) { + return true; + } + if (dbmsEvent instanceof DBMSQueryLog) { + return true; + } + return false; + } + + @Override + public void handle(LogEvent event, LogPosition position) { + try { + MySQLDBMSEvent sqldbmsEvent = binlogParser.parse(event, false); + if (sqldbmsEvent == null) { + return; + } + Timestamp extractTimestamp = new Timestamp(System.currentTimeMillis()); + DBMSEvent dbmsEvent = sqldbmsEvent.getDbMessage(); + if (!acceptEvent(dbmsEvent)) { + return; + } + datas.clear(); + MessageEvent e = new MessageEvent(); + e.setDbmsEvent(sqldbmsEvent.getDbMessage()); + e.setPosition(sqldbmsEvent.getPosition().toString()); + e.setSourceTimestamp(new Timestamp(sqldbmsEvent.getPosition().getTimestamp() * 1000)); + e.setExtractTimestamp(extractTimestamp); + if (dbmsEvent instanceof DefaultRowChange) { + DefaultRowChange rowChange = (DefaultRowChange) sqldbmsEvent.getDbMessage(); + rowChange.putOption( + new DefaultOption(RplConstants.BINLOG_EVENT_OPTION_TIMESTAMP, e.getSourceTimestamp())); + rowChange.putOption( + new DefaultOption(RplConstants.BINLOG_EVENT_OPTION_POSITION, e.getPosition())); + + } + + datas.add(e); + pipeline.writeRingbuffer(datas); + } catch (Exception e) { + if (position != null) { + String message = String.format("binlog parser error at position %s:%s", + position.getFileName(), position.getPosition()); + throw new CanalParseException(message, e); + } else { + throw new PolardbxException("binlog parser error", e); + } + } + } + + @Override + public void onEnd() { + + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/cdc/EventParser.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/cdc/EventParser.java new file mode 100644 index 00000000..c953ca88 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/cdc/EventParser.java @@ -0,0 +1,33 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.extractor.cdc; + +import com.aliyun.polardbx.binlog.canal.core.handle.EventHandle; + +public class EventParser implements Runnable { + private EventHandle eventHandle; + + public void start() { + + } + + @Override + public void run() { + + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/cdc/buffer/StreamObserverBuffer.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/cdc/buffer/StreamObserverBuffer.java new file mode 100644 index 00000000..8eec2b0f --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/cdc/buffer/StreamObserverBuffer.java @@ -0,0 +1,188 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.extractor.cdc.buffer; + +import com.aliyun.polardbx.binlog.canal.binlog.LogFetcher; +import com.aliyun.polardbx.binlog.error.PolardbxException; +import com.aliyun.polardbx.rpc.cdc.DumpStream; +import com.google.protobuf.ByteString; +import io.grpc.stub.StreamObserver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.io.InterruptedIOException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; + +public class StreamObserverBuffer extends LogFetcher implements StreamObserver { + + /** + * Packet header sizes + */ + public static final int NET_HEADER_SIZE = 4; + public static final int SQLSTATE_LENGTH = 5; + /** + * Packet offsets + */ + public static final int PACKET_LEN_OFFSET = 0; + public static final int PACKET_SEQ_OFFSET = 3; + /** + * Maximum packet length + */ + public static final int MAX_PACKET_LENGTH = (256 * 256 * 256 - 1); + /** + * BINLOG_DUMP options + */ + public static final int BINLOG_DUMP_NON_BLOCK = 1; + public static final int BINLOG_SEND_ANNOTATE_ROWS_EVENT = 2; + private static final Logger logger = LoggerFactory.getLogger(StreamObserverBuffer.class); + private AtomicLong count = new AtomicLong(0); + private StreamPipe pipe; + private long lastReceiveTimestamp = 0; + private long lastCounter = 0; + + public StreamObserverBuffer() throws IOException { + pipe = new StreamPipe(); + } + + private final boolean fetch0(final int off, final int len) throws IOException { + ensureCapacity(off + len); + + for (int count, n = 0; n < len; n += count) { + if (0 > (count = pipe.read(buffer, off + n, len - n))) { + // Reached end of input stream + return false; + } + } + + if (limit < off + len) { + limit = off + len; + } + return true; + } + + @Override + public boolean fetch() throws IOException { + try { + // Fetching packet header from input. + if (!fetch0(0, NET_HEADER_SIZE)) { + logger.warn("Reached end of input stream while fetching header"); + return false; + } + + // Fetching the first packet(may a multi-packet). + int netlen = getUint24(PACKET_LEN_OFFSET); + int netnum = getUint8(PACKET_SEQ_OFFSET); + if (!fetch0(NET_HEADER_SIZE, netlen)) { + logger.warn("Reached end of input stream: packet #" + netnum + ", len = " + netlen); + return false; + } + + // Detecting error code. + final int mark = getUint8(NET_HEADER_SIZE); + if (mark != 0) { + if (mark == 255) // error from master + { + // Indicates an error, for example trying to fetch from + // wrong + // binlog position. + position = NET_HEADER_SIZE + 1; + final int errno = getInt16(); + String sqlstate = forward(1).getFixString(SQLSTATE_LENGTH); + String errmsg = getFixString(limit - position); + throw new IOException("Received error packet:" + " errno = " + errno + ", sqlstate = " + sqlstate + + " errmsg = " + errmsg); + } else if (mark == 254) { + // Indicates end of stream. It's not clear when this would + // be sent. + logger.warn("Received EOF packet from server, apparent" + " master disconnected."); + return false; + } else { + // Should not happen. + throw new IOException("Unexpected response " + mark + " while fetching binlog: packet #" + netnum + + ", len = " + netlen); + } + } + + // The first packet is a multi-packet, concatenate the packets. + while (netlen == MAX_PACKET_LENGTH) { + if (!fetch0(0, NET_HEADER_SIZE)) { + logger.warn("Reached end of input stream while fetching header"); + return false; + } + + netlen = getUint24(PACKET_LEN_OFFSET); + netnum = getUint8(PACKET_SEQ_OFFSET); + if (!fetch0(limit, netlen)) { + logger.warn("Reached end of input stream: packet #" + netnum + ", len = " + netlen); + return false; + } + } + + // Preparing buffer variables to decoding. + origin = NET_HEADER_SIZE + 1; + position = origin; + limit -= origin; + return true; + } catch (InterruptedIOException e) { + close(); /* Do cleanup */ + logger.warn("I/O interrupted while reading from client socket", e); + throw e; + } catch (IOException e) { + close(); /* Do cleanup */ + logger.error("I/O error while reading from client socket", e); + throw e; + } + } + + @Override + public void close() throws IOException { + pipe.close(); + } + + @Override + public void onNext(DumpStream dumpStream) { + long counter = count.incrementAndGet(); + final ByteString payload = dumpStream.getPayload(); + byte[] packets = payload.toByteArray(); + try { + pipe.write(packets); + } catch (IOException e) { + throw new PolardbxException(e); + } + long now = System.currentTimeMillis(); + long diff = TimeUnit.MILLISECONDS.toSeconds(now - lastReceiveTimestamp); + if (diff > 15) { + logger.info("receive from dumper tps : " + (counter - lastCounter) * 100 / diff); + lastReceiveTimestamp = now; + lastCounter = counter; + } + } + + @Override + public void onError(Throwable t) { + logger.error("dumper error!", t); + System.exit(1); + } + + @Override + public void onCompleted() { + + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/cdc/buffer/StreamPipe.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/cdc/buffer/StreamPipe.java new file mode 100644 index 00000000..9b7e61a4 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/cdc/buffer/StreamPipe.java @@ -0,0 +1,48 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.extractor.cdc.buffer; + +import java.io.IOException; +import java.io.PipedInputStream; +import java.io.PipedOutputStream; +import java.util.concurrent.atomic.AtomicBoolean; + +public class StreamPipe { + + PipedInputStream reader; + PipedOutputStream writer; + private AtomicBoolean first = new AtomicBoolean(true); + + public StreamPipe() throws IOException { + reader = new PipedInputStream(1024 * 8); + writer = new PipedOutputStream(); + reader.connect(writer); + } + + public int read(byte[] buffer, int offset, int limit) throws IOException { + return reader.read(buffer, offset, limit); + } + + public void write(byte[] data) throws IOException { + writer.write(data); + } + + public void close() throws IOException { + writer.close(); + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/full/ExtractorUtil.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/full/ExtractorUtil.java new file mode 100644 index 00000000..05467e8f --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/full/ExtractorUtil.java @@ -0,0 +1,113 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.extractor.full; + +import java.io.Serializable; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; +import java.util.HashMap; +import java.util.Map; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSAction; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSRowChange; +import com.aliyun.polardbx.rpl.dbmeta.ColumnInfo; +import com.aliyun.polardbx.rpl.dbmeta.TableInfo; +import com.aliyun.polardbx.rpl.pipeline.MessageEvent; + +/** + * 全量使用的工具类 + * + * @author sunxi'en + * @since 1.0.0 + */ +public class ExtractorUtil { + + private final static boolean DEFAULT_NULLABLE = true; + private final static boolean DEFAULT_SIGNED = true; + + /** + * @return Object + */ + public static Object getColumnValue(ResultSet resultSet, String columnName, int type) throws SQLException { + Object value; + if (type == Types.TIME || type == Types.DATE || type == Types.TIMESTAMP || isCharType(type) + || isClobType(type)) { + value = resultSet.getString(columnName); + } else if (isBlobType(type)) { + value = resultSet.getBytes(columnName); + } else if (Types.BIT == type) { + // 需要特殊处理tinyint(1) + value = resultSet.getBytes(columnName); + } else { + value = resultSet.getString(columnName); + } + // 使用clone对象,避免translator修改了引用 + return value; + } + + public static boolean isCharType(int sqlType) { + return (sqlType == Types.CHAR || sqlType == Types.VARCHAR || sqlType == Types.NCHAR + || sqlType == Types.NVARCHAR); + } + + public static boolean isClobType(int sqlType) { + return (sqlType == Types.CLOB || sqlType == Types.LONGVARCHAR || sqlType == Types.NCLOB + || sqlType == Types.LONGNVARCHAR); + } + + public static boolean isBlobType(int sqlType) { + return (sqlType == Types.BLOB || sqlType == Types.BINARY || sqlType == Types.VARBINARY + || sqlType == Types.LONGVARBINARY); + } + + public static boolean isNumber(int sqlType) { + return (sqlType == Types.TINYINT || sqlType == Types.SMALLINT || sqlType == Types.INTEGER + || sqlType == Types.BIGINT || sqlType == Types.NUMERIC || sqlType == Types.DECIMAL); + } + + public static RowChangeBuilder buildRowChangeMeta(TableInfo tableInfo, String schema, String tbName, + DBMSAction action) { + RowChangeBuilder builder = RowChangeBuilder.createBuilder(schema, tbName, action); + for (ColumnInfo column : tableInfo.getColumns()) { + builder.addMetaColumn(column.getName(), + column.getType(), + DEFAULT_SIGNED, + DEFAULT_NULLABLE, + tableInfo.getPks().contains(column.getName())); + } + return builder; + } + + public static DBMSRowChange buildMessageEvent(RowChangeBuilder builder, TableInfo tableInfo, + ResultSet resultSet) throws Exception { + Map fieldValueMap = new HashMap<>(tableInfo.getColumns().size()); + for (ColumnInfo column : tableInfo.getColumns()) { + Object value = ExtractorUtil.getColumnValue(resultSet, column.getName(), column.getType()); + fieldValueMap.put(column.getName(), (Serializable) value); + } + + builder.getRowDatas().clear(); + builder.addRowData(fieldValueMap); + return builder.build(); + // DBMSRowChange rowChange = builder.build(); + // return new MessageEvent(rowChange, null, null, null); + } + +} + diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/full/RowChangeBuilder.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/full/RowChangeBuilder.java new file mode 100644 index 00000000..be738021 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/full/RowChangeBuilder.java @@ -0,0 +1,568 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.extractor.full; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.sql.Blob; +import java.sql.Types; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.lang3.ClassUtils; +import org.apache.commons.lang3.StringUtils; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSAction; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSColumn; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSColumnSet; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSOption; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSRowChange; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultColumn; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultColumnSet; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultOption; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultRowChange; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +public class RowChangeBuilder { + + private DBMSAction action; + + private String schema; // 库名 + + private String table; // 表名 + + private final List metaColumns = new ArrayList(); + + private final List options = new ArrayList(); + + private final List> rowDatas = new ArrayList>(); + + private final List> changeRowDatas = new ArrayList>(); + + /** + * 字段动态增加的插件的映射map,主要用于支持过滤代码中 + */ + protected Map dynamicPluginMap = new HashMap<>(); + + /** + * 保留字段和分隔符的关系 + */ + protected Map separatorMap = new HashMap<>(); + + private final static int DEFAULT_ORDINAL_INDEX = -1; + private final static boolean DEFAULT_SIGNED = true; + private final static boolean DEFAULT_NULLABLE = true; + private final static boolean DEFAULT_PRIMARYKEY = false; + private final static boolean DEFAULT_UNIQUEKEY = false; + + private int currentFieldIndex = 1; + + private RowChangeBuilder(String schema, String table, DBMSAction action) { + this.schema = StringUtils.lowerCase(schema); + this.table = StringUtils.lowerCase(table); + this.action = action; + } + + public static RowChangeBuilder createBuilder(String schema, String table, DBMSAction action) { + return new RowChangeBuilder(schema, table, action); + } + + // for inc copy + public static RowChangeBuilder createFromEvent(DBMSRowChange event) { + // 转换成MAP结构数据 + RowChangeHelper.MapData mapData = RowChangeHelper.convertEvent2Map(event); + RowChangeBuilder builder = new RowChangeBuilder(mapData.getDbName(), + mapData.getTableName(), + mapData.getAction()); + // 获得表头 + List oMetaDatas = event.getColumns(); + List nMetaDatas = new ArrayList(oMetaDatas.size()); + // copy old metaData + nMetaDatas.addAll(oMetaDatas); + builder.addMetaColumns(nMetaDatas); + // 填充变化前数据 + builder.addRowDatas(mapData.getRowDataMaps()); + // 填充变化后的发数据 + builder.addChangeRowDatas(mapData.getModifyRowDataMaps()); + // 填充OPTIONS + builder.addOptions(event.getOptions()); + + // 填充插件相关信息 + builder.setSeparatorMap(((DefaultRowChange) event).getSeparatorMap()); + builder.setDynamicPluginMap(((DefaultRowChange) event).getDynamicPluginMap()); + + return builder; + } +// +// // for full copy +// public RowChangeBuilder getDataFromQueryResult(TableInfo tableInfo, ResultSet resultSet) throws Exception{ +// Map fieldValueMap = new HashMap<>(tableInfo.getColumns().size()); +// for (ColumnInfo column : tableInfo.getColumns()) { +// Object value = ExtractorUtil.getColumnValue(resultSet, column.getName(), column.getType()); +// fieldValueMap.put(column.getName(), (Serializable) value); +// } +// getRowDatas().clear(); +// addRowData(fieldValueMap); +// return this; +// } + + public RowChangeBuilder excludeColumn(String columnName) { + columnName = StringUtils.lowerCase(columnName); + if (!isContainColumn(columnName)) { + // need throw exception here + return this; + } + removeMetaColumn(columnName); + if (rowDatas.isEmpty()) { + return this; + } + if (DBMSAction.UPDATE.equals(getAction())) { + //rowData和changeRowData需要一起过滤 + getChangeRowData(0).remove(columnName); + getRowData(0).remove(columnName); + } else { + getRowData(0).remove(columnName); + } + return this; + } + + public boolean isContainColumn(String columnName) { + for (DBMSColumn column : metaColumns) { + if (column.getName().equals(columnName)) { + return true; + } + } + return false; + } + + public synchronized DBMSRowChange build() throws Exception { + // 必要参数检查 + if (StringUtils.isBlank(this.schema)) { + throw new Exception("schema is empty!"); + } + if (StringUtils.isBlank(this.table)) { + throw new Exception("table is empty!"); + } + if (null == this.action) { + throw new Exception("action is null!"); + } + if (this.metaColumns.isEmpty()) { + throw new Exception("metaColumns is empty!"); + } + if (this.rowDatas.isEmpty()) { + throw new Exception("rowData is empty!"); + } + // 获取所有字段名称,用来当索引判断字段是否存在 + Set metaColumnNames = new HashSet(metaColumns.size()); + for (DBMSColumn column : metaColumns) { + metaColumnNames.add(StringUtils.lowerCase(column.getName())); + } + // 构建columnSet + DBMSColumnSet dbmsColumnSet = new DefaultColumnSet(metaColumns); + DBMSRowChange rowChange = new DefaultRowChange(action, schema, table, dbmsColumnSet); + // 获取总记录数 + int rowCount = this.rowDatas.size(); + // 填充Row数据 + for (int i = 0; i < rowCount; i++) { + Map dataMap = this.rowDatas.get(i); + if (metaColumnNames.size() != dataMap.size()) { + throw new Exception("rowData column count not match meta column count, metaColumnNames : " + + metaColumnNames + ", dataColumnNames : " + dataMap.keySet()); + } + // 全行数据 + for (Map.Entry entry : dataMap.entrySet()) { + String columnName = StringUtils.lowerCase(entry.getKey()); + if (!metaColumnNames.contains(columnName)) { + throw new Exception("metaColumns not contains rowData column: " + columnName); + } + rowChange.setRowValue(i + 1, columnName, entry.getValue()); + } + if (DBMSAction.UPDATE == action) { + if (!this.changeRowDatas.isEmpty()) { + if (this.rowDatas.size() != this.changeRowDatas.size()) { + throw new Exception("update changeRowData Count not Match rowData Count!"); + } + // 填充RowChange数据 + Set changeColumnNames = new HashSet(metaColumns.size()); + Map changeDataMap = this.changeRowDatas.get(i); + changeColumnNames.addAll(changeDataMap.keySet()); + + for (Map.Entry entry : changeDataMap.entrySet()) { + String columnName = StringUtils.lowerCase(entry.getKey()); + if (!metaColumnNames.contains(columnName)) { + throw new Exception("metaColumns not contains rowChangeData column: " + columnName); + } + rowChange.setChangeValue(i + 1, columnName, entry.getValue()); + changeColumnNames.add(columnName); + } + } + } + } + // 填充 options + for (DBMSOption option : this.options) { + rowChange.setOptionValue(option.getName(), option.getValue()); + } + // 填充插件信息 + ((DefaultRowChange) rowChange).setDynamicPluginMap(dynamicPluginMap); + ((DefaultRowChange) rowChange).setSeparatorMap(separatorMap); + return rowChange; + } + + public void addOptions(List list) { + if (null != list && !list.isEmpty()) { + this.options.addAll(list); + } + } + + public void addOption(DBMSOption option) { + this.options.add(option); + } + + public void addOption(String name, Serializable value) { + this.options.add(new DefaultOption(name, value)); + } + + public void addRowDatas(List> rowDatas) { + if (null != rowDatas && !rowDatas.isEmpty()) { + this.rowDatas.addAll(rowDatas); + } + } + + public void addChangeRowDatas(List> changeRowDatas) { + if (null != changeRowDatas && !changeRowDatas.isEmpty()) { + this.changeRowDatas.addAll(changeRowDatas); + } + } + + public void addRowData(Map rowData) { + if (null != rowData && !rowData.isEmpty()) { + this.rowDatas.add(rowData); + } + } + + public void addChangeRowData(Map changeRowData) { + if (null != changeRowData && !changeRowData.isEmpty()) { + this.changeRowDatas.add(changeRowData); + } + } + + public void addMetaColumns(Collection metaColumns) { + if (null != metaColumns && !metaColumns.isEmpty()) { + List newColumns = new ArrayList(metaColumns.size()); + for (DBMSColumn column : metaColumns) { + newColumns.add(cloneDBMSColumn(column)); + } + this.metaColumns.addAll(newColumns); + } + } + + public void addMetaColumn(DBMSColumn metaColumn) { + this.metaColumns.add(this.cloneDBMSColumn(metaColumn)); + } + + public void addMetaColumnWithoutClone(DBMSColumn metaColumn) { + this.metaColumns.add(metaColumn); + } + + /** + * 删除row change event中的列,给opensearch一些字段展开功能使用 + */ + public void removeMetaColumn(String name) { + for (int i = 0; i < this.metaColumns.size(); i++) { + if (metaColumns.get(i).getName().equals(name)) { + metaColumns.remove(i); + break; + } + } + } + + public void addMetaColumn(String name, Class valueClass) { + this.addMetaColumn(name, getSqyTypeByClass(valueClass)); + } + + public void addMetaColumn(String name, Class valueClass, boolean primaryKey) { + + this.addMetaColumn(name, getSqyTypeByClass(valueClass), primaryKey); + } + + public void addMetaColumn(String name, Class valueClass, boolean nullable, boolean primaryKey) { + this.addMetaColumn(name, getSqyTypeByClass(valueClass), DEFAULT_SIGNED, nullable, primaryKey); + } + + public void addMetaColumn(String name, Class valueClass, boolean signed, boolean nullable, boolean primaryKey) { + this.addMetaColumn(name, getSqyTypeByClass(valueClass), signed, nullable, primaryKey); + } + + public void addMetaColumn(String name, Class valueClass, int ordinalIndex, boolean signed, boolean nullable, + boolean primaryKey) { + this.addMetaColumn(name, + ordinalIndex, + getSqyTypeByClass(valueClass), + signed, + nullable, + primaryKey, + DEFAULT_UNIQUEKEY); + } + + public void addMetaColumn(String name, Class valueClass, int ordinalIndex, boolean signed, boolean nullable, + boolean primaryKey, boolean uniqueKey) { + this.addMetaColumn(name, ordinalIndex, getSqyTypeByClass(valueClass), signed, nullable, primaryKey, uniqueKey); + } + + public void addMetaColumn(String name, int sqlType) { + this.addMetaColumn(name, + currentFieldIndex++, + sqlType, + DEFAULT_SIGNED, + DEFAULT_NULLABLE, + DEFAULT_PRIMARYKEY, + DEFAULT_UNIQUEKEY); + } + + public void addMetaColumn(String name, int sqlType, boolean primaryKey) { + this.addMetaColumn(name, + currentFieldIndex++, + sqlType, + DEFAULT_SIGNED, + DEFAULT_NULLABLE, + primaryKey, + DEFAULT_UNIQUEKEY); + } + + public void addMetaColumn(String name, int sqlType, boolean nullable, boolean primaryKey) { + this.addMetaColumn(name, currentFieldIndex++, sqlType, DEFAULT_SIGNED, nullable, primaryKey, DEFAULT_UNIQUEKEY); + } + + public void addMetaColumn(String name, int sqlType, boolean signed, boolean nullable, boolean primaryKey) { + this.addMetaColumn(name, currentFieldIndex++, sqlType, signed, nullable, primaryKey, DEFAULT_UNIQUEKEY); + } + + public void addMetaColumn(String name, int sqlType, boolean signed, boolean nullable, boolean primaryKey, + boolean uniqueKey) { + this.addMetaColumn(name, currentFieldIndex++, sqlType, signed, nullable, primaryKey, uniqueKey); + } + + public void addMetaColumn(String name, int ordinalIndex, int sqlType, boolean nullable, boolean primaryKey) { + this.addMetaColumn(name, ordinalIndex, sqlType, DEFAULT_SIGNED, nullable, primaryKey, DEFAULT_UNIQUEKEY); + } + + public void addMetaColumn(String name, int ordinalIndex, int sqlType, boolean signed, boolean nullable, + boolean primaryKey, boolean uniqueKey) { + this.metaColumns.add(createMetaColumn(name, ordinalIndex, sqlType, signed, nullable, primaryKey, uniqueKey)); + } + + public Map getDynamicPluginMap() { + return dynamicPluginMap; + } + + public void setDynamicPluginMap(Map dynamicPluginMap) { + this.dynamicPluginMap = dynamicPluginMap; + } + + public Map getSeparatorMap() { + return separatorMap; + } + + public void setSeparatorMap(Map separatorMap) { + this.separatorMap = separatorMap; + } + + public static DBMSColumn createMetaColumn(String name, int sqlType) { + return createMetaColumn(name, + DEFAULT_ORDINAL_INDEX, + sqlType, + DEFAULT_SIGNED, + DEFAULT_NULLABLE, + DEFAULT_PRIMARYKEY); + } + + public static DBMSColumn createMetaColumn(String name, int sqlType, boolean primaryKey) { + return createMetaColumn(name, DEFAULT_ORDINAL_INDEX, sqlType, DEFAULT_SIGNED, DEFAULT_NULLABLE, primaryKey); + } + + public static DBMSColumn createMetaColumn(String name, int sqlType, boolean nullable, boolean primaryKey) { + return createMetaColumn(name, DEFAULT_ORDINAL_INDEX, sqlType, DEFAULT_SIGNED, nullable, primaryKey); + } + + public static DBMSColumn createMetaColumn(String name, int ordinalIndex, int sqlType, boolean nullable, + boolean primaryKey) { + return createMetaColumn(name, ordinalIndex, sqlType, DEFAULT_SIGNED, nullable, primaryKey); + } + + public static DBMSColumn createMetaColumn(String name, int sqlType, boolean signed, boolean nullable, + boolean primaryKey) { + return createMetaColumn(name, DEFAULT_ORDINAL_INDEX, sqlType, signed, nullable, primaryKey); + } + + public static DBMSColumn createMetaColumn(String name, int ordinalIndex, int sqlType, boolean signed, + boolean nullable, boolean primaryKey) { + return createMetaColumn(name, ordinalIndex, sqlType, signed, nullable, primaryKey, DEFAULT_UNIQUEKEY); + } + + public static DBMSColumn createMetaColumn(String name, int ordinalIndex, int sqlType, boolean signed, + boolean nullable, boolean primaryKey, boolean uniqueKey) { + DBMSColumn newColumn = new DefaultColumn(StringUtils + .lowerCase(name), ordinalIndex, sqlType, signed, nullable, primaryKey, uniqueKey); + return newColumn; + } + + /** + * 根据value的class和signed获取对应的sqlType + * 参考mysql驱动com.mysql.jdbc.ResultSetMetaData.getClassNameForJavaType(int, + * boolean, int, boolean, boolean) + */ + public static int getSqyTypeByClass(Class valueClass) { + if (null == valueClass) { + return Types.NULL; + } + // 记录数组标记 + boolean isArray = valueClass.isArray(); + // 如果是数组取数组内class,否则用原先的class + valueClass = isArray ? valueClass.getComponentType() : valueClass; + // 如果是小的基本类型,则转换成大的包装类型 + valueClass = valueClass.isPrimitive() ? ClassUtils.primitiveToWrapper(valueClass) : valueClass; + if (isArray) { + if (Byte.class.equals(valueClass)) { + return Types.LONGVARBINARY; + } + } else { + if (valueClass.isPrimitive()) { + valueClass = ClassUtils.primitiveToWrapper(valueClass); + } + if (Boolean.class.equals(valueClass)) { + return Types.BOOLEAN; + } else if (Integer.class.equals(valueClass)) { + return Types.INTEGER; + } else if (Long.class.equals(valueClass)) { + return Types.BIGINT; + } else if (BigDecimal.class.equals(valueClass)) { + return Types.DECIMAL; + } else if (Float.class.equals(valueClass)) { + return Types.REAL; + } else if (Double.class.equals(valueClass)) { + return Types.DOUBLE; + } else if (String.class.equals(valueClass)) { + return Types.VARCHAR; + } else if (java.sql.Date.class.equals(valueClass) || java.util.Date.class.equals(valueClass)) { + return Types.DATE; + } else if (java.sql.Time.class.equals(valueClass)) { + return Types.TIME; + } else if (java.sql.Timestamp.class.equals(valueClass)) { + return Types.TIMESTAMP; + } else if (java.sql.Blob.class.equals(valueClass)) { + return Types.BINARY; + } + } + throw new RuntimeException("not support java Type class: " + valueClass.getName()); + } + + /** + * 根据sqlType返回相应的valueClass,用于EtlBuilder中addColumn、renameColumn等地方 + * + * @return 只会返回泛型的String或者Blob + */ + public Class getGeneralValueTypeBySqlType(int sqlType) { + if (sqlType == Types.BLOB || sqlType == Types.BINARY || sqlType == Types.VARBINARY + || sqlType == Types.LONGVARBINARY) { + return Blob.class; + } else { + return String.class; + } + } + + /** + * 复制一份DBMSColumn 要是DBMSColumn实现cloneable就好了 + * + * @return 复制后 new 出来的DBMSColumn + */ + private DBMSColumn cloneDBMSColumn(DBMSColumn dbmsColumn) { + String name = StringUtils.lowerCase(dbmsColumn.getName()); + int ordinalIndex = dbmsColumn.getOrdinalIndex(); + int sqlType = dbmsColumn.getSqlType(); + boolean signed = dbmsColumn.isSigned(); + boolean nullable = dbmsColumn.isNullable(); + boolean primaryKey = dbmsColumn.isPrimaryKey(); + boolean uniqueKey = dbmsColumn.isUniqueKey(); + DBMSColumn newColumn = new DefaultColumn(name, ordinalIndex, sqlType, signed, nullable, primaryKey, uniqueKey); + return newColumn; + } + + public DBMSAction getAction() { + return action; + } + + public String getSchema() { + return schema; + } + + public String getTable() { + return table; + } + + public List getMetaColumns() { + return metaColumns; + } + + public List getOptions() { + return options; + } + + public List> getRowDatas() { + return rowDatas; + } + + public Map getRowData(int i) { + return rowDatas.get(i); + } + + public List> getChangeRowDatas() { + return changeRowDatas; + } + + public Map getChangeRowData(int i) { + return changeRowDatas.get(i); + } + + private static List> buildDataWithFilterColumn(Set filterColumns, + List> rowDataList) { + if (null == rowDataList || rowDataList.isEmpty()) { + return rowDataList; + } + List> newRowDataList = Lists.newArrayListWithExpectedSize(rowDataList.size()); + for (Map rowData : rowDataList) { + Map newRowData = Maps.newHashMapWithExpectedSize(rowData.size()); + Set columnNameSets = rowData.keySet(); + for (String columnName : columnNameSets) { + if (filterColumns.contains(columnName) || filterColumns.contains(columnName.toLowerCase()) + || filterColumns.contains(columnName.toUpperCase())) { + continue; + } else { + newRowData.put(columnName, rowData.get(columnName)); + } + } + newRowDataList.add(newRowData); + } + return newRowDataList; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/full/RowChangeHelper.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/full/RowChangeHelper.java new file mode 100644 index 00000000..99e4f0c6 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/extractor/full/RowChangeHelper.java @@ -0,0 +1,363 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.extractor.full; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSAction; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSColumn; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSOption; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSRowChange; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSRowData; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +public class RowChangeHelper { + + public static MapData convertEvent2Map(DBMSRowChange event) { + return convertEvent2Map(event, Boolean.FALSE); + } + + /** + * 将DBMSRowChange 转换成K-V 的MAP形式 + * + * @param event DBMSRowChange + * @param upperCase 是否将dbname,table,column的名称转换成大写 + * @return MapData 对象 + */ + public static MapData convertEvent2Map(DBMSRowChange event, boolean upperCase) { + // 获取数据的描述信息 + String dbName = upperCase ? StringUtils.upperCase(event.getSchema()) : StringUtils.lowerCase(event.getSchema()); + String tableName = + upperCase ? StringUtils.upperCase(event.getTable()) : StringUtils.lowerCase(event.getTable()); + DBMSAction action = event.getAction(); + + // 创建MapData + MapData mapData = new MapData(dbName, tableName, action); + + // 设置 primaryKey到DataInfo描述对象中 + List primaryKeyColumns = event.getPrimaryKey(); + List primaryColumnNames = new ArrayList(primaryKeyColumns.size()); + for (DBMSColumn primaryKey : primaryKeyColumns) { + String primaryName = + upperCase ? StringUtils.upperCase(primaryKey.getName()) : StringUtils.lowerCase(primaryKey.getName()); + primaryColumnNames.add(primaryName); + } + mapData.setPrimaryKeyNames(primaryColumnNames); + + // 如果是update设置changeColumnNames到DataInfo描述对象中 + if (DBMSAction.UPDATE == action) { + List changeColumns = event.getChangeColumns(); + List changeColumnNames = new ArrayList(changeColumns.size()); + for (DBMSColumn changeKey : changeColumns) { + String changeColumnName = + upperCase ? StringUtils.upperCase(changeKey.getName()) : StringUtils.lowerCase(changeKey.getName()); + changeColumnNames.add(changeColumnName); + } + mapData.setModifiedFieldNames(changeColumnNames); + } + + int rowSize = event.getRowSize(); + List allColumns = event.getColumns(); + if (DBMSAction.UPDATE == action) { + // 获取变化的Column列表 + List modifyColumns = event.getChangeColumns(); + // 准备调用Dispatcher使用的修改前数据列表,和修改后数据列表 + List> rowDataMaps = new ArrayList>(rowSize); + List> modifyRowDataMaps = new ArrayList>(rowSize); + for (int i = 1; i <= rowSize; i++) { + Map rowDataMap = new HashMap(allColumns.size(), 1.0f); + Map modifyRowDataMap = new HashMap(allColumns.size(), 1.0f); + DBMSRowData rowData = event.getRowData(i); + for (DBMSColumn column : allColumns) { + String columnName = + upperCase ? StringUtils.upperCase(column.getName()) : StringUtils.lowerCase(column.getName()); + Serializable columnValue = rowData.getRowValue(column); + // 设置修改前rowDataMap + rowDataMap.put(columnName, columnValue); + if (modifyColumns.contains(column)) { + // 如果当前字段是修改的字段,使用修改的值 + Serializable modifyColumnValue = event.getChangeValue(i, column); + modifyRowDataMap.put(columnName, modifyColumnValue); + } + } + rowDataMaps.add(rowDataMap); + modifyRowDataMaps.add(modifyRowDataMap); + } + mapData.setRowDataMaps(rowDataMaps); + mapData.setModifyRowDataMaps(modifyRowDataMaps); + } else if (DBMSAction.INSERT == action || DBMSAction.DELETE == action) { + List> rowDataMaps = new ArrayList>(rowSize); + for (int i = 1; i <= rowSize; i++) { + Map rowDataMap = new HashMap(allColumns.size(), 1.0f); + DBMSRowData rowData = event.getRowData(i); + for (DBMSColumn column : allColumns) { + String columnName = + upperCase ? StringUtils.upperCase(column.getName()) : StringUtils.lowerCase(column.getName()); + Serializable columnValue = rowData.getRowValue(column); + rowDataMap.put(columnName, columnValue); + } + rowDataMaps.add(rowDataMap); + } + mapData.setRowDataMaps(rowDataMaps); + } + // options + List optionLists = event.getOptions(); + if (null != optionLists && !optionLists.isEmpty()) { + Map optionMaps = new HashMap(optionLists.size(), 1.0f); + for (DBMSOption dbmsOption : optionLists) { + optionMaps.put(upperCase ? StringUtils.upperCase(dbmsOption.getName()) : + StringUtils.lowerCase(dbmsOption.getName()), + dbmsOption.getValue()); + } + mapData.setOptionMaps(optionMaps); + } + return mapData; + } + + public static DBMSRowChange removeRowData(DBMSRowChange event, RemoveCondition condition) { + if (null == event) { + return null; + } + int rowCount = event.getRowSize(); + for (int i = rowCount; i > 0; i--) { + DBMSRowData rowData = event.getRowData(i); + if (condition.isRemove(event, rowData)) { + event.removeRowData(i); + } + } + if (event.getRowSize() == 0) { + return null; + } else { + return event; + } + } + + public static interface RemoveCondition { + + public boolean isRemove(DBMSRowChange event, DBMSRowData rowData); + } + + public static class MapData implements Serializable { + + private static final long serialVersionUID = 5457745807246773498L; + + public MapData() { + } + + /** + * 数据库名 + */ + private String dbName; + /** + * 表名 + */ + private String tableName; + + /** + * 主键名称 + */ + private List primaryKeyNames; + /** + * 修改后字段名称,只有Update的时候才有 + */ + private List modifiedFieldNames; + + /** + * INSERT,UPDATE,DELETE 对应的枚举类 + */ + private DBMSAction action; + + /** + * 修改前数据,Insert,Update,Delete时都有 + */ + private List> rowDataMaps; + + /** + * 修改后数据,只有Update的时候才有 + */ + private List> modifyRowDataMaps; + + /** + * EVENT消息扩展字段 + */ + private Map optionMaps = Collections.emptyMap(); + + public MapData(String dbName, String tableName, DBMSAction action) { + this.dbName = dbName; + this.tableName = tableName; + this.action = action; + } + + public String getDbName() { + return dbName; + } + + public void setDbName(String dbName) { + this.dbName = dbName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + public void setAction(DBMSAction action) { + this.action = action; + } + + public String getTableName() { + return tableName; + } + + public List getPrimaryKeyNames() { + return primaryKeyNames; + } + + public void setPrimaryKeyNames(List primaryKeyNames) { + this.primaryKeyNames = primaryKeyNames; + } + + public List getModifiedFieldNames() { + return modifiedFieldNames; + } + + public void setModifiedFieldNames(List modifiedFieldNames) { + this.modifiedFieldNames = modifiedFieldNames; + } + + public DBMSAction getAction() { + return action; + } + + public List> getRowDataMaps() { + return rowDataMaps; + } + + public void setRowDataMaps(List> rowDataMaps) { + this.rowDataMaps = rowDataMaps; + } + + public List> getModifyRowDataMaps() { + return modifyRowDataMaps; + } + + public void setModifyRowDataMaps(List> modifyRowDataMaps) { + this.modifyRowDataMaps = modifyRowDataMaps; + } + + public Map getOptionMaps() { + return optionMaps; + } + + public void setOptionMaps(Map optionMaps) { + this.optionMaps = optionMaps; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((action == null) ? 0 : action.hashCode()); + result = prime * result + ((dbName == null) ? 0 : dbName.hashCode()); + result = prime * result + ((modifiedFieldNames == null) ? 0 : modifiedFieldNames.hashCode()); + result = prime * result + ((modifyRowDataMaps == null) ? 0 : modifyRowDataMaps.hashCode()); + result = prime * result + ((optionMaps == null) ? 0 : optionMaps.hashCode()); + result = prime * result + ((primaryKeyNames == null) ? 0 : primaryKeyNames.hashCode()); + result = prime * result + ((rowDataMaps == null) ? 0 : rowDataMaps.hashCode()); + result = prime * result + ((tableName == null) ? 0 : tableName.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + MapData other = (MapData) obj; + if (action != other.action) { + return false; + } + if (dbName == null) { + if (other.dbName != null) { + return false; + } + } else if (!dbName.equals(other.dbName)) { + return false; + } + if (modifiedFieldNames == null) { + if (other.modifiedFieldNames != null) { + return false; + } + } else if (!modifiedFieldNames.equals(other.modifiedFieldNames)) { + return false; + } + if (modifyRowDataMaps == null) { + if (other.modifyRowDataMaps != null) { + return false; + } + } else if (!modifyRowDataMaps.equals(other.modifyRowDataMaps)) { + return false; + } + if (optionMaps == null) { + if (other.optionMaps != null) { + return false; + } + } else if (!optionMaps.equals(other.optionMaps)) { + return false; + } + if (primaryKeyNames == null) { + if (other.primaryKeyNames != null) { + return false; + } + } else if (!primaryKeyNames.equals(other.primaryKeyNames)) { + return false; + } + if (rowDataMaps == null) { + if (other.rowDataMaps != null) { + return false; + } + } else if (!rowDataMaps.equals(other.rowDataMaps)) { + return false; + } + if (tableName == null) { + if (other.tableName != null) { + return false; + } + } else if (!tableName.equals(other.tableName)) { + return false; + } + return true; + } + + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + } + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/filter/BaseFilter.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/filter/BaseFilter.java new file mode 100644 index 00000000..11ca89e2 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/filter/BaseFilter.java @@ -0,0 +1,72 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.filter; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSAction; +import com.aliyun.polardbx.rpl.common.RplConstants; +import org.apache.commons.lang3.StringUtils; + +import java.util.HashSet; +import java.util.Set; + +/** + * @author jiyue 2021/8/17 13:28 + * @since 5.0.0.0 + */ + +public class BaseFilter { + public boolean init() { + return true; + } + + public boolean ignoreEvent(String schema, String tbName, DBMSAction action, long serverId) { + return false; + } + + public String getRewriteDb(String schema, DBMSAction action) { + return schema; + } + + public String getRewriteTable(String table) { + return table; + } + + protected Set initFilterSet(String filterStr) { + Set filters = new HashSet<>(); + + if (StringUtils.isBlank(filterStr)) { + return filters; + } + + for (String token : filterStr.trim().toLowerCase().split(RplConstants.COMMA)) { + filters.add(token.trim()); + } + + return filters; + } + + protected Set initIgnoreServerIds(String filterStr) { + Set tmpIgnoreServerIds = initFilterSet(filterStr); + Set ignoreServerIds = new HashSet<>(); + for (String serverId : tmpIgnoreServerIds) { + ignoreServerIds.add(Long.valueOf(serverId)); + } + return ignoreServerIds; + } + +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/filter/ReplicateFilter.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/filter/ReplicateFilter.java new file mode 100644 index 00000000..ee75dbb0 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/filter/ReplicateFilter.java @@ -0,0 +1,286 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.filter; + +import com.alibaba.fastjson.JSON; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSAction; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultRowChange; +import com.aliyun.polardbx.binlog.domain.po.RplStateMachine; +import com.aliyun.polardbx.rpl.applier.StatisticalProxy; +import com.aliyun.polardbx.rpl.common.CommonUtil; +import com.aliyun.polardbx.rpl.common.RplConstants; +import com.aliyun.polardbx.rpl.common.TaskContext; +import com.aliyun.polardbx.rpl.taskmeta.ReplicateMeta; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.regex.Pattern; + +/** + * @author shicai.xsc 2021/3/1 13:28 + * @since 5.0.0.0 + */ +@Slf4j +public class ReplicateFilter extends BaseFilter { + + private ReplicateMeta replicateMeta; + private Set ignoreTables; + private Set doTables; + private Set ignoreDbs; + private Set doDbs; + private Set ignoreServerIds; + private List> wildIgnoreTables; + private List> wildDoTables; + private Map filterCache; + private Map rewriteDbs; + + public ReplicateFilter(ReplicateMeta replicateMeta) { + this.replicateMeta = replicateMeta; + } + + @Override + public boolean init() { + try { + doTables = initFilterSet(replicateMeta.getDoTable()); + ignoreTables = initFilterSet(replicateMeta.getIgnoreTable()); + doDbs = initFilterSet(replicateMeta.getDoDb()); + ignoreDbs = initFilterSet(replicateMeta.getIgnoreDb()); + ignoreServerIds = initIgnoreServerIds(replicateMeta.getIgnoreServerIds()); + wildDoTables = initWildPatternPairs(replicateMeta.getWildDoTable()); + wildIgnoreTables = initWildPatternPairs(replicateMeta.getWildIgnoreTable()); + filterCache = new HashMap<>(128); + rewriteDbs = initRewriteDbs(replicateMeta.getRewriteDb()); + return true; + } catch (Throwable e) { + log.error("ReplicateFilter init failed", e); + return false; + } + } + + /** + * refer: https://github.com/mysql/mysql-server/blob/8.0/sql/sql_parse.cc bool + * mysql_test_parse_for_slave(THD *thd) bool all_tables_not_ok(THD *thd, + * TABLE_LIST *tables) + */ + public boolean ignoreEvent(DefaultRowChange rowChange) { + return ignoreEvent(getRewriteDb(rowChange.getSchema(), DBMSAction.INSERT), + rowChange.getTable(), rowChange.getAction(), Integer.MIN_VALUE); + } + + @Override + public boolean ignoreEvent(String schema, String tbName, DBMSAction action, long serverId) { + if (ignoreServerIds.contains(serverId)) { + return true; + } + + String key = schema + "." + tbName + "." + action.name(); + if (filterCache.containsKey(key)) { + return filterCache.get(key); + } + + boolean result = !tableOk(schema, tbName) || !dbOk(schema, action); + filterCache.put(key, result); + + if (result) { + StatisticalProxy.getInstance().addSkipCount(1); + } + return result; + } + + @Override + public String getRewriteDb(String schema, DBMSAction action) { + if (action != DBMSAction.CREATEDB && action != DBMSAction.DROPDB) { + return rewriteDbs.containsKey(schema) ? rewriteDbs.get(schema) : schema; + } + return schema; + } + + /** + * refer: https://github.com/mysql/mysql-server/blob/8.0/sql/rpl_filter.cc bool + * Rpl_filter::tables_ok(const char *db, TABLE_LIST *tables) + */ + private boolean tableOk(String db, String tb) { + String fullTbName = db + "." + tb; + if (doTables.size() > 0 && doTables.contains(fullTbName)) { + return true; + } + + if (ignoreTables.size() > 0 && ignoreTables.contains(fullTbName)) { + return false; + } + + if (wildDoTables.size() > 0 && findWildTable(wildDoTables, db, tb)) { + return true; + } + + if (wildIgnoreTables.size() > 0 && findWildTable(wildIgnoreTables, db, tb)) { + return false; + } + + return doTables.size() == 0 && wildDoTables.size() == 0; + } + + /** + * refer: https://github.com/mysql/mysql-server/blob/8.0/sql/sql_parse.cc inline + * bool check_database_filters(THD *thd, const char *db, enum_sql_command + * sql_cmd) + */ + private boolean dbOk(String db, DBMSAction action) { + boolean dbOk = dbOk(db); + + if (dbOk && doDbs.size() == 0 && ignoreDbs.size() == 0) { + switch (action) { + case CREATEDB: + case DROPDB: + // no ALTERDB in Canal + // case ALTERDB: + dbOk = dbOkWithWildTable(db); + break; + } + } + + return dbOk; + } + + /** + * refer: https://github.com/mysql/mysql-server/blob/8.0/sql/rpl_filter.cc bool + * Rpl_filter::db_ok(const char *db, bool need_increase_counter) + */ + private boolean dbOk(String db) { + if (doDbs.size() > 0) { + return doDbs.contains(db); + } + + if (ignoreDbs.size() > 0) { + return !ignoreDbs.contains(db); + } + + return true; + } + + /** + * refer: https://github.com/mysql/mysql-server/blob/8.0/sql/rpl_filter.cc bool + * Rpl_filter::db_ok_with_wild_table(const char *db) + */ + private boolean dbOkWithWildTable(String db) { + if (wildDoTables.size() > 0 && findWildTable(wildDoTables, db, "")) { + return true; + } + + if (wildIgnoreTables.size() > 0 && findWildTable(wildIgnoreTables, db, "")) { + return false; + } + + return wildDoTables.size() == 0; + } + + private boolean findWildDb(List> wilds, String db) { + for (List patterns : wilds) { + if (patterns.get(0).matcher(db).matches()) { + return true; + } + } + return false; + } + + private boolean findWildTable(List> wilds, String db, String tb) { + for (List patterns : wilds) { + if (patterns.get(0).matcher(db).matches() && patterns.get(1).matcher(tb).matches()) { + return true; + } + } + return false; + } + +// private Set initFilterSet(String filterStr) { +// Set filters = new HashSet<>(); +// +// if (StringUtils.isBlank(filterStr)) { +// return filters; +// } +// +// for (String token : filterStr.trim().toLowerCase().split(RplConstants.COMMA)) { +// filters.add(token.trim()); +// } +// +// return filters; +// } + +// private Set initIgnoreServerIds(String filterStr) { +// Set tmpIgnoreServerIds = initFilterSet(filterStr); +// Set ignoreServerIds = new HashSet<>(); +// for (String serverId : tmpIgnoreServerIds) { +// ignoreServerIds.add(Long.valueOf(serverId)); +// } +// // ignore the server id of myself +// ignoreServerIds.add(RplConstants.MY_POLARX_SERVER_ID); +// return ignoreServerIds; +// } + + private List> initWildPatternPairs(String fullWildPairStr) { + List> wildPatternPairs = new ArrayList<>(); + if (StringUtils.isBlank(fullWildPairStr)) { + return wildPatternPairs; + } + + for (String token : fullWildPairStr.trim().toLowerCase().split(RplConstants.COMMA)) { + wildPatternPairs.add(initWildPattern(token)); + } + + return wildPatternPairs; + } + + private Map initRewriteDbs(String rewriteDbStr) { + Map rewriteDbs = new HashMap<>(); + if (StringUtils.isBlank(rewriteDbStr)) { + return rewriteDbs; + } + + String[] rewriteDbList = rewriteDbStr.split("\\)"); + for (String rewriteDb : rewriteDbList) { + rewriteDb = CommonUtil.trimLeftAll(rewriteDb.trim(), ','); + rewriteDb = CommonUtil.removeBracket(rewriteDb.trim()); + String[] tokens = rewriteDb.split(","); + rewriteDbs.put(tokens[0].trim(), tokens[1].trim()); + } + return rewriteDbs; + } + + private List initWildPattern(String wildPairStr) { + String[] wildStrs = wildPairStr.split("\\."); + Pattern dbPattern = getWildPattern(wildStrs[0]); + Pattern tbPattern = getWildPattern(wildStrs[1]); + List patterns = new ArrayList<>(); + patterns.add(dbPattern); + patterns.add(tbPattern); + return patterns; + } + + private Pattern getWildPattern(String wildStr) { + String filter = wildStr.trim().replace("\\_", "(").replace("\\%", ")"); + filter = filter.replace("_", ".").replace("%", ".*"); + filter = filter.replace("(", "_").replace(")", "%"); + return Pattern.compile(filter); + } +} \ No newline at end of file diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/pipeline/BasePipeline.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/pipeline/BasePipeline.java new file mode 100644 index 00000000..f67c7560 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/pipeline/BasePipeline.java @@ -0,0 +1,54 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.pipeline; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSEvent; +import com.aliyun.polardbx.rpl.applier.BaseApplier; +import com.aliyun.polardbx.rpl.extractor.BaseExtractor; +import com.aliyun.polardbx.rpl.taskmeta.PipelineConfig; +import lombok.Data; + +import java.util.List; + +/** + * @author shicai.xsc 2020/11/30 15:00 + * @since 5.0.0.0 + */ +@Data +public abstract class BasePipeline { + + protected BaseExtractor extractor; + protected BaseApplier applier; + protected PipelineConfig pipeLineConfig; + + public abstract boolean init(); + + public abstract void start(); + + public abstract void stop(); + + public abstract boolean checkDone(); + + public abstract void writeRingbuffer(List events); + + public abstract void directApply(List messages); + +// public abstract void apply(List messages); +// +// public abstract void tranApply(List transactions); +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/pipeline/MessageEvent.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/pipeline/MessageEvent.java new file mode 100644 index 00000000..bf8b03d2 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/pipeline/MessageEvent.java @@ -0,0 +1,49 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.pipeline; + +import java.sql.Timestamp; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSEvent; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSXATransaction; + +import lombok.Data; + +/** + * @author shicai.xsc 2020/11/30 15:15 + * @since 5.0.0.0 + */ +@Data +public class MessageEvent { + + private DBMSEvent dbmsEvent; + private Timestamp sourceTimestamp; + private Timestamp extractTimestamp; + private String position; + private DBMSXATransaction xaTransaction; + + public MessageEvent() { + } + + public MessageEvent(DBMSEvent dbmsEvent, Timestamp sourceTimestamp, Timestamp extractTimestamp, String position) { + this.dbmsEvent = dbmsEvent; + this.sourceTimestamp = sourceTimestamp; + this.extractTimestamp = extractTimestamp; + this.position = position; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/pipeline/MessageEventFactory.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/pipeline/MessageEventFactory.java new file mode 100644 index 00000000..3f91bbb0 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/pipeline/MessageEventFactory.java @@ -0,0 +1,32 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.pipeline; + +import com.lmax.disruptor.EventFactory; + +/** + * @author shicai.xsc 2020/11/30 16:03 + * @since 5.0.0.0 + */ +public class MessageEventFactory implements EventFactory { + + @Override + public MessageEvent newInstance() { + return new MessageEvent(); + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/pipeline/SerialPipeline.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/pipeline/SerialPipeline.java new file mode 100644 index 00000000..70bcfd09 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/pipeline/SerialPipeline.java @@ -0,0 +1,515 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.pipeline; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSEvent; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSRowChange; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSTransactionEnd; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSXATransaction; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultOption; +import com.aliyun.polardbx.binlog.error.PolardbxException; +import com.aliyun.polardbx.rpl.applier.ApplyHelper; +import com.aliyun.polardbx.rpl.applier.BaseApplier; +import com.aliyun.polardbx.rpl.applier.StatisticalProxy; +import com.aliyun.polardbx.rpl.applier.Transaction; +import com.aliyun.polardbx.rpl.applier.TransactionApplier; +import com.aliyun.polardbx.rpl.common.RplConstants; +import com.aliyun.polardbx.rpl.common.ThreadPoolUtil; +import com.aliyun.polardbx.rpl.extractor.BaseExtractor; +import com.aliyun.polardbx.rpl.taskmeta.PipelineConfig; +import com.lmax.disruptor.BatchEventProcessor; +import com.lmax.disruptor.BlockingWaitStrategy; +import com.lmax.disruptor.EventHandler; +import com.lmax.disruptor.LifecycleAware; +import com.lmax.disruptor.RingBuffer; +import com.lmax.disruptor.SequenceBarrier; +import com.lmax.disruptor.WorkerPool; +import lombok.extern.slf4j.Slf4j; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.atomic.AtomicLong; + +/** + * @author shicai.xsc 2020/11/30 14:59 + * @since 5.0.0.0 + */ +@Slf4j +public class SerialPipeline extends BasePipeline { + + private RingBuffer msgRingBuffer; + private ExecutorService offerExecutor; + private BatchEventProcessor offerProcessor; + private MessageEventFactory messageEventFactory; + private String position; + private AtomicLong lastStatisticsTime = new AtomicLong(0); + private AtomicLong periodBatchSize = new AtomicLong(0); + private AtomicLong periodBatchCount = new AtomicLong(0); + private AtomicLong periodBatchCost = new AtomicLong(0); + private final long LOG_STAT_PERIOD_MILLS = 10000; + + + public SerialPipeline(PipelineConfig pipeLineConfig, BaseExtractor extractor, BaseApplier applier) { + this.pipeLineConfig = pipeLineConfig; + this.extractor = extractor; + this.applier = applier; + } + + @Override + public boolean init() { + try { + messageEventFactory = new MessageEventFactory(); + offerExecutor = ThreadPoolUtil.createExecutorWithFixedNum(1, "applier"); + // create ringBuffer and set ringBuffer eventFactory + msgRingBuffer = RingBuffer + .createSingleProducer(messageEventFactory, pipeLineConfig.getBufferSize(), + new BlockingWaitStrategy()); + EventHandler eventHandler; + SequenceBarrier sequenceBarrier = msgRingBuffer.newBarrier(); + if (pipeLineConfig.isSupportXa()) { + eventHandler = new XaTranRingBufferEventHandler(pipeLineConfig.getBufferSize()); + } else if (applier instanceof TransactionApplier) { + eventHandler = new TranRingBufferEventHandler(pipeLineConfig.getBufferSize()); + } else { + eventHandler = new RingBufferEventHandler(pipeLineConfig.getBufferSize()); + } + offerProcessor = new BatchEventProcessor<>(msgRingBuffer, sequenceBarrier, eventHandler); + msgRingBuffer.addGatingSequences(offerProcessor.getSequence()); + return true; + } catch (Throwable e) { + log.error("SerialPipeline init failed", e); + return false; + } + } + + @Override + public void start() { + try { + // start extractor thread which will call EXTRACTOR to extract events from + // binlog and write it to ringBuffer + log.info("extractor starting"); + extractor.start(); + log.info("extractor started"); + + // start offerProcessor thread which will call APPLIER to consume events from + // ringBuffer + offerExecutor.submit(offerProcessor); + } catch (Throwable e) { + log.error("start extractor occur error", e); + Runtime.getRuntime().halt(1); + } + } + + @Override + public void stop() { + extractor.stop(); + } + + @Override + public boolean checkDone() { + return extractor.isDone(); + } + + /** + * This will be called by EXTRACTOR to write messages to ringBuffer + */ + @Override + public void writeRingbuffer(List events) { + long lo = -1, hi = -1; + boolean isLowSet = false; + try { + for (MessageEvent event : events) { + while (msgRingBuffer.remainingCapacity() <= 0) { + if (lo != -1 && hi != -1) { + msgRingBuffer.publish(lo, hi); + lo = -1; + hi = -1; + isLowSet = false; + } else { + Thread.sleep(5); + } + } + long next = msgRingBuffer.next(); + if (!isLowSet) { + lo = next; + isLowSet = true; + } + hi = next; + MessageEvent e = msgRingBuffer.get(next); + e.setDbmsEvent(event.getDbmsEvent()); + e.setPosition(event.getPosition()); + e.setXaTransaction(event.getXaTransaction()); + e.setSourceTimestamp(event.getSourceTimestamp()); + e.setExtractTimestamp(event.getExtractTimestamp()); + } + } catch (Throwable e) { + log.error("writeRingBuffer exception ", e); + throw new PolardbxException("write ring buffer error!", e); + } finally { + if (lo != -1 && hi != -1) { + msgRingBuffer.publish(lo, hi); + } + } + } + + @Override + public void directApply(List events) { + if (!StatisticalProxy.getInstance().apply(events)) { + log.error("failed to call applier, exit"); + Runtime.getRuntime().halt(1); + } + StatisticalProxy.getInstance().addMessageCount(events.size()); + } + + private void takeStatisticsWithFlowControl(long currentBatchSize, long sequence, long start) { + StatisticalProxy.getInstance().recordPosition(position, false); + if (currentBatchSize != 0) { + StatisticalProxy.getInstance().addMessageCount(currentBatchSize); + } + long now = System.currentTimeMillis(); + long lastStatisticsTimePre = lastStatisticsTime.get(); + periodBatchSize.addAndGet(currentBatchSize); + periodBatchCost.addAndGet(now - start); + if (periodBatchCount.incrementAndGet() % 100 == 0 + || (now > lastStatisticsTimePre + LOG_STAT_PERIOD_MILLS + && lastStatisticsTime.compareAndSet(lastStatisticsTimePre, now))) { + StatisticalProxy.getInstance().recordPosition(position, true); + long avgBatchSize = periodBatchSize.get() / periodBatchCount.get(); + long avgCost = periodBatchCost.get() / periodBatchCount.get(); + long queueSize = msgRingBuffer.getCursor() - sequence; + log.warn( + "RingBuffer queue size : " + queueSize + ", average batch size : " + avgBatchSize + ", avg cost : " + + avgCost + ", current batch size : " + currentBatchSize + ", current cost : " + (now - start)); + // reset参数 + periodBatchCount.set(0); + periodBatchSize.set(0); + periodBatchCost.set(0); + } + } + + /** + * RingBufferEventHandler, this will call APPLIER to consume ringBuffer messages + */ + private class RingBufferEventHandler implements EventHandler, LifecycleAware { + + private List eventBatch; + + public RingBufferEventHandler(int batchSize) { + eventBatch = new ArrayList<>(batchSize / 2); + } + + @Override + public void onEvent(MessageEvent event, long sequence, boolean endOfBatch) throws Exception { + boolean isDdl = false; + if (event.getDbmsEvent() instanceof DBMSRowChange) { + eventBatch.add(event.getDbmsEvent()); + } else if (ApplyHelper.isDdl(event.getDbmsEvent())) { + isDdl = true; + // first apply all exist events + StatisticalProxy.getInstance().apply(eventBatch); + eventBatch.clear(); + // apply DDL one by one + event.getDbmsEvent().putOption( + new DefaultOption(RplConstants.BINLOG_EVENT_OPTION_POSITION_STR, event.getPosition())); + eventBatch.add(event.getDbmsEvent()); + endOfBatch = true; + position = event.getPosition(); + } else if (event.getDbmsEvent() instanceof DBMSTransactionEnd) { + position = event.getPosition(); + } else { + position = event.getPosition(); + } + + if (endOfBatch) { + try { + StatisticalProxy.getInstance() + .setTotalInCache(msgRingBuffer.getBufferSize() - msgRingBuffer.remainingCapacity()); + long start = System.currentTimeMillis(); + if (!StatisticalProxy.getInstance().apply(eventBatch)) { + log.error("failed to call applier, exit"); + Runtime.getRuntime().halt(1); + } + takeStatisticsWithFlowControl(eventBatch.size(), sequence, start); + // force flush position info if Ddl happened + if (isDdl) { + StatisticalProxy.getInstance().flushPosition(); + } + eventBatch.clear(); + } catch (Throwable e) { + log.error("failed to call applier, exit", e); + Runtime.getRuntime().halt(1); + } + } + } + + @Override + public void onStart() { + } + + @Override + public void onShutdown() { + } + } + + /** + * TranRingBufferEventHandler, this will construct Transactions to call APPLIER + */ + private class TranRingBufferEventHandler implements EventHandler, LifecycleAware { + + private int eventCount = 0; + private List transactionBatch; + + public TranRingBufferEventHandler(int batchSize) { + transactionBatch = new ArrayList<>(batchSize / 2); + } + + @Override + public void onEvent(MessageEvent event, long sequence, boolean endOfBatch) throws Exception { + Transaction transaction = getTransactionToApply(); + boolean isDdl = false; + if (event.getDbmsEvent() instanceof DBMSRowChange) { + transaction.appendRowChange(event.getDbmsEvent()); + eventCount++; + } else if (ApplyHelper.isDdl(event.getDbmsEvent())) { + // first apply all exist events + StatisticalProxy.getInstance().tranApply(transactionBatch); + transactionBatch.clear(); + transaction = getTransactionToApply(); + transaction.appendQueryLog(event.getDbmsEvent()); + position = event.getPosition(); + event.getDbmsEvent().putOption( + new DefaultOption(RplConstants.BINLOG_EVENT_OPTION_POSITION_STR, event.getPosition())); + transaction.setFinished(true); + isDdl = true; + endOfBatch = true; + } else if (event.getDbmsEvent() instanceof DBMSTransactionEnd) { + position = event.getPosition(); + transaction.setFinished(true); + } else { + position = event.getPosition(); + } + + if (endOfBatch) { + try { + // do NOT apply unfinished transaction + Transaction lastTransaction = null; + if (transactionBatch.size() > 0) { + lastTransaction = transactionBatch.get(transactionBatch.size() - 1); + if (!lastTransaction.isFinished()) { + transactionBatch.remove(transactionBatch.size() - 1); + } + } + long start = System.currentTimeMillis(); + // apply + if (!StatisticalProxy.getInstance().tranApply(transactionBatch)) { + log.error("failed to call applier, exit"); + Runtime.getRuntime().halt(1); + } + takeStatisticsWithFlowControl(eventCount, sequence, start); + eventCount = 0; + // force flush position info if Ddl happened + // 位点不能跨ddl + if (isDdl) { + StatisticalProxy.getInstance().flushPosition(); + } + // remove finished, keep the NOT finished transaction + transactionBatch.clear(); + if (lastTransaction != null && !lastTransaction.isFinished()) { + transactionBatch.add(lastTransaction); + log.info("lastTransaction NOT finished, waiting for DBMSTransactionEnd"); + } + } catch (Throwable e) { + log.error("failed to call applier, exit", e); + Runtime.getRuntime().halt(1); + } + } + } + + @Override + public void onStart() { + } + + @Override + public void onShutdown() { + } + + private Transaction getTransactionToApply() { + if (transactionBatch.size() == 0 || transactionBatch.get(transactionBatch.size() - 1).isFinished()) { + Transaction newTransaction = new Transaction(); + transactionBatch.add(newTransaction); + return newTransaction; + } + return transactionBatch.get(transactionBatch.size() - 1); + } + } + + /** + * TranRingBufferEventHandler, this will construct Transactions to call APPLIER + */ + private class XaTranRingBufferEventHandler implements EventHandler, LifecycleAware { + + String nextPosition = null; + private List transactionBatch; + private Map transactionMap; + private LinkedHashMap transactionPositionMap; + + public XaTranRingBufferEventHandler(int batchSize) { + + transactionBatch = new ArrayList<>(batchSize / 2); + transactionMap = new HashMap<>(); + transactionPositionMap = new LinkedHashMap<>(); + } + + @Override + public void onEvent(MessageEvent event, long sequence, boolean endOfBatch) throws Exception { + boolean isDdl = false; + DBMSXATransaction xaTransaction = event.getXaTransaction(); + if (event.getDbmsEvent() instanceof DBMSRowChange) { + if (xaTransaction == null) { + Transaction transaction = getTransactionToApply(); + transaction.appendRowChange(event.getDbmsEvent()); + } else { + transactionMap.get(event.getXaTransaction().getXid()).appendRowChange(event.getDbmsEvent()); + } + } else if (ApplyHelper.isDdl(event.getDbmsEvent())) { + log.error("receive ddl event which will not be processed: {} ", event); + } else if (event.getDbmsEvent() instanceof DBMSTransactionEnd) { + Transaction transaction = getTransactionToApply(); + transaction.setFinished(true); + // 没有未结束的xa事务 + if (transactionPositionMap.size() == 0) { + nextPosition = event.getPosition(); + } + } else if (xaTransaction != null) { + switch (event.getXaTransaction().getType()) { + case XA_START: + transactionMap.put(event.getXaTransaction().getXid(), new Transaction()); + transactionPositionMap.put(event.getXaTransaction().getXid(), event.getPosition()); + break; + case XA_END: + Transaction transaction = transactionMap.get(event.getXaTransaction().getXid()); + transaction.setPrepared(true); + break; + case XA_COMMIT: + Transaction thisTransaction = removeFromCache(event); + if (thisTransaction != null) { + transactionBatch.add(thisTransaction); + } + break; + case XA_ROLLBACK: + removeFromCache(event); + break; + default: + break; + } + } else { + // nextPosition = event.getPosition(); + } + + if (endOfBatch) { + try { + // do NOT apply unfinished transaction + Transaction lastTransaction = null; + if (transactionBatch.size() > 0) { + lastTransaction = transactionBatch.get(transactionBatch.size() - 1); + if (!lastTransaction.isFinished()) { + transactionBatch.remove(transactionBatch.size() - 1); + } + } + int eventCount = 0; + for (Transaction transaction : transactionBatch) { + eventCount += transaction.getEvents().size(); + } + long start = System.currentTimeMillis(); + // apply + if (applier instanceof TransactionApplier) { + if (!StatisticalProxy.getInstance().tranApply(transactionBatch)) { + log.error("failed to call applier, exit"); + Runtime.getRuntime().halt(1); + } + } else { + // 展开transactionBatch + List events = new ArrayList<>(); + for (Transaction transaction : transactionBatch) { + events.addAll(transaction.getEvents()); + } + if (!StatisticalProxy.getInstance().apply(events)) { + log.error("failed to call applier, exit"); + Runtime.getRuntime().halt(1); + } + } + takeStatisticsWithFlowControl(eventCount, sequence, start); + + if (nextPosition != null) { + position = nextPosition; + } + // remove finished, keep the NOT finished transaction + transactionBatch.clear(); + if (lastTransaction != null && !lastTransaction.isFinished()) { + transactionBatch.add(lastTransaction); + log.info("lastTransaction NOT finished, waiting for DBMSTransactionEnd"); + } + } catch (Throwable e) { + log.error("failed to call applier, exit", e); + Runtime.getRuntime().halt(1); + } + } + } + + @Override + public void onStart() { + } + + @Override + public void onShutdown() { + } + + private Transaction getTransactionToApply() { + if (transactionBatch.size() == 0 || transactionBatch.get(transactionBatch.size() - 1).isFinished()) { + Transaction newTransaction = new Transaction(); + transactionBatch.add(newTransaction); + return newTransaction; + } + return transactionBatch.get(transactionBatch.size() - 1); + } + + public Map.Entry getHead(LinkedHashMap map) { + return map.entrySet().iterator().next(); + } + + private Transaction removeFromCache(MessageEvent event) { + transactionPositionMap.remove(event.getXaTransaction().getXid()); + if (transactionPositionMap.size() != 0) { + nextPosition = getHead(transactionPositionMap).getValue(); + } else { + nextPosition = event.getPosition(); + } + Transaction returnTran = transactionMap.remove(event.getXaTransaction().getXid()); + if (returnTran != null) { + returnTran.setFinished(true); + } + return returnTran; + } + + } + +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ApplierConfig.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ApplierConfig.java new file mode 100644 index 00000000..4e28ad6a --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ApplierConfig.java @@ -0,0 +1,38 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.taskmeta; + +import com.aliyun.polardbx.rpl.common.RplConstants; +import lombok.Data; + +/** + * @author shicai.xsc 2020/12/1 11:06 + * @since 5.0.0.0 + */ +@Data +public class ApplierConfig { + protected int mergeBatchSize = 1000; + protected int sendBatchSize = 100; + protected int logCommitLevel = RplConstants.LOG_NO_COMMIT; + protected boolean enableDdl = true; + protected int maxPoolSize = 256; + protected int minPoolSize = 64; + protected int statisticIntervalSec = 5; + protected int applierType = ApplierType.SPLIT.getValue(); + protected HostInfo hostInfo; +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ApplierType.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ApplierType.java new file mode 100644 index 00000000..ad4952be --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ApplierType.java @@ -0,0 +1,78 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.taskmeta; + +/** + * @author shicai.xsc 2021/5/18 14:58 + * @since 5.0.0.0 + */ +public enum ApplierType { + // 保持原 binlog 中的事务完整性 + TRANSACTION(0), + + // 按照原 binlog 中的 event 顺序执行,但不保证事务完整性 + SERIAL(10), + + // 将一批 events 按照标识键 (identify columns, pk + uk + shard key) 拆分成多个队列,多个队列并行执行, + // 如果某表 a.a event a.a.1 修改了 identify columns,某表 b.b event b.b.1 修改了 identify columns, + // 则 a.a 表 a.a.1 之后所有 event 集 serialA 改为事务内串行,b.b 表 b.b.1 之后所有 event 集 serialB 改为事务内串行, + // serialA 和 serialB 并行 + SPLIT(20), + + // 将一批 events 按照 fullTableName 拆分成多个队列,多个队列并行执行,每个队列事务内串行执行 + SPLIT_TRANSACTION(30), + + // 将一批 events 按照 fullTableName 拆分成多个队列,多个队列并行执行, + // 每个队列内,接下来会做 3 步骤 + // 1. update 改写: + // 每个队列内,将 update 转变成 delete + insert,故每个队列中都只存在 delete + insert + // 2. merge: + // 假如 table_1 的队列中存在 200 个 delete + 200 个 insert,而 applierConfig.mergeBatchSize == 100, + // 则 merge 成 2 个 delete + 2 个 insert + // 3. 并行执行: + // 先并行执行完 2 个 delete,2 个 delete 都执行成功后,再并行执行 2 个 insert + MERGE(40), + + // 1,2 步骤和 MERGE 相同,不同的是 3 步骤 + // 3. 每个队列内,merge 成 2 个 delete + 2 个 insert 后,这 4 个 sql 会放在一个事务内串行执行 + // MERGE_TRANSACTION 比 MERGE 缺点:效率低 + // MERGE_TRANSACTION 比 MERGE 优点:不会出现中间状态 + // 即:原本是 update 1 to 2,如果使用 MERGE,可能出现中间状态: 1 被删除了,2 还未插入,用户对账会发现少了一条记录 + MERGE_TRANSACTION(50), + + JUST_EXTRACT(60); + + private int value; + + public int getValue() { + return value; + } + + ApplierType(int value) { + this.value = value; + } + + public static ApplierType from(int state) { + for (ApplierType i : ApplierType.values()) { + if (i.value == state) { + return i; + } + } + return null; + } +} \ No newline at end of file diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/DbTaskMetaManager.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/DbTaskMetaManager.java new file mode 100644 index 00000000..7fa7a4d8 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/DbTaskMetaManager.java @@ -0,0 +1,450 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.taskmeta; + +import com.aliyun.polardbx.binlog.SpringContextHolder; +import com.aliyun.polardbx.binlog.dao.NodeInfoDynamicSqlSupport; +import com.aliyun.polardbx.binlog.dao.NodeInfoMapper; +import com.aliyun.polardbx.binlog.dao.PolarxCNodeInfoDynamicSqlSupport; +import com.aliyun.polardbx.binlog.dao.PolarxCNodeInfoMapper; +import com.aliyun.polardbx.binlog.dao.RplDdlDynamicSqlSupport; +import com.aliyun.polardbx.binlog.dao.RplDdlMapper; +import com.aliyun.polardbx.binlog.dao.RplServiceDynamicSqlSupport; +import com.aliyun.polardbx.binlog.dao.RplServiceMapper; +import com.aliyun.polardbx.binlog.dao.RplStateMachineDynamicSqlSupport; +import com.aliyun.polardbx.binlog.dao.RplStateMachineMapper; +import com.aliyun.polardbx.binlog.dao.RplTablePositionDynamicSqlSupport; +import com.aliyun.polardbx.binlog.dao.RplTablePositionMapper; +import com.aliyun.polardbx.binlog.dao.RplTaskDynamicSqlSupport; +import com.aliyun.polardbx.binlog.dao.RplTaskMapper; +import com.aliyun.polardbx.binlog.domain.po.NodeInfo; +import com.aliyun.polardbx.binlog.domain.po.PolarxCNodeInfo; +import com.aliyun.polardbx.binlog.domain.po.RplDdl; +import com.aliyun.polardbx.binlog.domain.po.RplService; +import com.aliyun.polardbx.binlog.domain.po.RplStateMachine; +import com.aliyun.polardbx.binlog.domain.po.RplTablePosition; +import com.aliyun.polardbx.binlog.domain.po.RplTask; +import com.aliyun.polardbx.rpl.common.RplConstants; +import com.aliyun.polardbx.rpl.common.fsmutil.AbstractFSM; +import com.aliyun.polardbx.rpl.common.fsmutil.FSMState; +import lombok.extern.slf4j.Slf4j; +import org.joda.time.DateTime; +import org.mybatis.dynamic.sql.SqlBuilder; +import org.mybatis.dynamic.sql.render.RenderingStrategies; + +import java.util.Date; +import java.util.List; +import java.util.Optional; + +/** + * @author shicai.xsc 2020/12/29 13:04 + * @since 5.0.0.0 + */ +@Slf4j +public class DbTaskMetaManager { + + private static RplStateMachineMapper stateMachineMapper = SpringContextHolder + .getObject(RplStateMachineMapper.class); + private static RplServiceMapper serviceMapper = SpringContextHolder.getObject(RplServiceMapper.class); + private static RplDdlMapper ddlMapper = SpringContextHolder.getObject(RplDdlMapper.class); + private static RplTaskMapper taskMapper = SpringContextHolder.getObject(RplTaskMapper.class); + private static NodeInfoMapper nodeInfoMapper = SpringContextHolder + .getObject(NodeInfoMapper.class); + private static PolarxCNodeInfoMapper polarxCNodeInfoMapper = SpringContextHolder + .getObject(PolarxCNodeInfoMapper.class); + private static RplTablePositionMapper tablePositionMapper = + SpringContextHolder.getObject(RplTablePositionMapper.class); + + /************************* state machine *******************/ + public static RplStateMachine createStateMachine(String config, StateMachineType type, AbstractFSM fsm, + String channel, String clusterId, String context) { + RplStateMachine record = new RplStateMachine(); + record.setConfig(config); + record.setStatus(StateMachineStatus.STOPPED.getValue()); + record.setType(type.getValue()); + record.setClassName(fsm.getClass().getName()); + record.setState(fsm.getInitialState().getValue()); + record.setClusterId(clusterId); + record.setContext(context); + switch (type) { + case REPLICA: + record.setChannel(channel); + break; + default: + break; + } + stateMachineMapper.insert(record); + return record; + } + + public static List listStateMachine(StateMachineStatus status, String clusterId) { + return stateMachineMapper + .selectMany(SqlBuilder.select(RplStateMachineDynamicSqlSupport.rplStateMachine.allColumns()) + .from(RplStateMachineDynamicSqlSupport.rplStateMachine) + .where(RplStateMachineDynamicSqlSupport.status, SqlBuilder.isEqualTo(status.getValue())) + .and(RplStateMachineDynamicSqlSupport.clusterId, SqlBuilder.isEqualTo(clusterId)) + .build() + .render(RenderingStrategies.MYBATIS3)); + } + + public static List listRplStateMachine() { + return stateMachineMapper + .selectMany(SqlBuilder.select(RplStateMachineDynamicSqlSupport.rplStateMachine.allColumns()) + .from(RplStateMachineDynamicSqlSupport.rplStateMachine) + .where(RplStateMachineDynamicSqlSupport.type, SqlBuilder.isEqualTo(StateMachineType.REPLICA.getValue())) + .build() + .render(RenderingStrategies.MYBATIS3)); + } + + public static RplStateMachine getRplStateMachine(String channel) { + Optional res = stateMachineMapper + .selectOne(i -> i.where(RplStateMachineDynamicSqlSupport.channel, SqlBuilder.isEqualTo(channel)) + .and(RplStateMachineDynamicSqlSupport.type, SqlBuilder.isEqualTo(StateMachineType.REPLICA.getValue()))); + return res.isPresent() ? res.get() : null; + } + + public static RplStateMachine getStateMachine(long id) { + Optional res = stateMachineMapper + .selectOne(i -> i.where(RplStateMachineDynamicSqlSupport.id, SqlBuilder.isEqualTo(id))); + return res.isPresent() ? res.get() : null; + } + + public static RplStateMachine updateStateMachine(RplStateMachine record) { + stateMachineMapper.updateByPrimaryKeySelective(record); + return getStateMachine(record.getId()); + } + + public static RplStateMachine updateStateMachineStatus(long id, StateMachineStatus status) { + RplStateMachine record = new RplStateMachine(); + record.setId(id); + record.setStatus(status.getValue()); + stateMachineMapper.updateByPrimaryKeySelective(record); + return getStateMachine(id); + } + + public static void updateStateMachineContext(long id, String context) { + RplStateMachine record = new RplStateMachine(); + record.setId(id); + record.setContext(context); + stateMachineMapper.updateByPrimaryKeySelective(record); + } + + public static RplStateMachine updateStateMachineState(long id, FSMState state) { + RplStateMachine record = getStateMachine(id); + if (record == null) { + return null; + } + log.info("Update state machine state [id : {}] from : {} to: {}", + id, FSMState.from(record.getState()).name(), state.name()); + RplStateMachine newRecord = new RplStateMachine(); + newRecord.setId(id); + newRecord.setState(state.getValue()); + stateMachineMapper.updateByPrimaryKeySelective(newRecord); + return getStateMachine(id); + } + + public static void deleteStateMachine(long id) { + stateMachineMapper.deleteByPrimaryKey(id); + List services = listService(id); + for (RplService service : services) { + DbTaskMetaManager.deleteService(service.getId()); + } + deleteTablePositionByFsm(id); + deleteDdlByFSM(id); + } + + /************************* service *************************/ + + public static RplService addService(RplService record) { + serviceMapper.insert(record); + return record; + } + + public static RplService addService(long stateMachineId, ServiceType type, List stateList) { + RplService record = new RplService(); + record.setStateMachineId(stateMachineId); + record.setStatus(ServiceStatus.NULL.getValue()); + record.setServiceType(type.getValue()); + record.setStateList(FSMState.listToString(stateList)); + serviceMapper.insert(record); + return record; + } + + public static RplService getService(long id) { + Optional res = serviceMapper + .selectOne(i -> i.where(RplServiceDynamicSqlSupport.id, SqlBuilder.isEqualTo(id))); + return res.isPresent() ? res.get() : null; + } + + public static RplService getService(long stateMachineId, ServiceType type) { + Optional res = serviceMapper + .selectOne(i -> i.where(RplServiceDynamicSqlSupport.stateMachineId, SqlBuilder.isEqualTo(stateMachineId)) + .and(RplServiceDynamicSqlSupport.serviceType, SqlBuilder.isEqualTo(type.getValue()))); + return res.isPresent() ? res.get() : null; + } + + public static List listService(long stateMachineId) { + return serviceMapper.selectMany(SqlBuilder.select(RplServiceDynamicSqlSupport.rplService.allColumns()) + .from(RplServiceDynamicSqlSupport.rplService) + .where(RplServiceDynamicSqlSupport.stateMachineId, SqlBuilder.isEqualTo(stateMachineId)) + .orderBy(RplServiceDynamicSqlSupport.id) + .build() + .render(RenderingStrategies.MYBATIS3)); + } + + public static List listRplService() { + return serviceMapper.selectMany(SqlBuilder.select(RplServiceDynamicSqlSupport.rplService.allColumns()) + .from(RplServiceDynamicSqlSupport.rplService) + .where(RplServiceDynamicSqlSupport.serviceType, SqlBuilder.isEqualTo(ServiceType.REPLICA.getValue())) + .orderBy(RplServiceDynamicSqlSupport.id) + .build() + .render(RenderingStrategies.MYBATIS3)); + } + + public static RplService updateService(long id, ServiceStatus status) { + RplService record = new RplService(); + record.setId(id); + record.setStatus(status.getValue()); + serviceMapper.updateByPrimaryKeySelective(record); + return getService(id); + } + + public static RplService updateService(RplService record) { + serviceMapper.updateByPrimaryKeySelective(record); + return getService(record.getId()); + } + + public static void deleteService(long serviceId) { + serviceMapper.deleteByPrimaryKey(serviceId); + taskMapper.delete(i -> i.where(RplTaskDynamicSqlSupport.serviceId, SqlBuilder.isEqualTo(serviceId))); + } + + /************************* task ***************************/ + + public static RplTask addTask(long stateMachineId, long serviceId, + String extractorConfig, String pipelineConfig, String applierConfig, + ServiceType type, int sequenceId, String clusterId) { + RplTask record = new RplTask(); + record.setStateMachineId(stateMachineId); + record.setServiceId(serviceId); + record.setStatus(ServiceStatus.NULL.getValue()); + record.setType(type.getValue()); + record.setExtractorConfig(extractorConfig); + record.setPipelineConfig(pipelineConfig); + record.setApplierConfig(applierConfig); + record.setLastError(""); + record.setPosition(""); + record.setClusterId(clusterId); + record.setExtra(Integer.toString(sequenceId)); + taskMapper.insert(record); + return record; + } + + public static RplTask getTask(long id) { + Optional res = taskMapper + .selectOne(i -> i.where(RplServiceDynamicSqlSupport.id, SqlBuilder.isEqualTo(id))); + return res.isPresent() ? res.get() : null; + } + + public static List listTask(long serviceId) { + return taskMapper.selectMany(SqlBuilder.select(RplTaskDynamicSqlSupport.rplTask.allColumns()) + .from(RplTaskDynamicSqlSupport.rplTask) + .where(RplTaskDynamicSqlSupport.serviceId, SqlBuilder.isEqualTo(serviceId)) + .orderBy(RplTaskDynamicSqlSupport.id) + .build() + .render(RenderingStrategies.MYBATIS3)); + } + + public static List listClusterTask(TaskStatus status, String clusterId) { + return taskMapper.selectMany(SqlBuilder.select(RplTaskDynamicSqlSupport.rplTask.allColumns()) + .from(RplTaskDynamicSqlSupport.rplTask) + .where(RplTaskDynamicSqlSupport.status, SqlBuilder.isEqualTo(status.getValue())) + .and(RplTaskDynamicSqlSupport.clusterId, SqlBuilder.isEqualTo(clusterId)) + .build() + .render(RenderingStrategies.MYBATIS3)); + } + + public static List listTask(String worker, TaskStatus status, String clusterId) { + return taskMapper.selectMany(SqlBuilder.select(RplTaskDynamicSqlSupport.rplTask.allColumns()) + .from(RplTaskDynamicSqlSupport.rplTask) + .where(RplTaskDynamicSqlSupport.status, SqlBuilder.isEqualTo(status.getValue())) + .and(RplTaskDynamicSqlSupport.worker, SqlBuilder.isEqualTo(worker)) + .and(RplTaskDynamicSqlSupport.clusterId, SqlBuilder.isEqualTo(clusterId)) + .build() + .render(RenderingStrategies.MYBATIS3)); + } + + public static RplTask updateTask(long id, TaskStatus status, String worker, String position, String statistic, + Date gmtHeartbeat) { + RplTask record = new RplTask(); + record.setId(id); + if (status != null) { + record.setStatus(status.getValue()); + } + record.setWorker(worker); + record.setPosition(position); + record.setStatistic(statistic); + record.setGmtHeartbeat(gmtHeartbeat); + taskMapper.updateByPrimaryKeySelective(record); + return getTask(id); + } + + public static RplTask updateTaskLastError(long id, String lastError) { + RplTask record = new RplTask(); + record.setId(id); + record.setLastError(lastError); + taskMapper.updateByPrimaryKeySelective(record); + return getTask(id); + } + + public static RplTask updateTaskStatus(long id, TaskStatus status) { + return updateTask(id, status, null, null, null, null); + } + + public static RplTask updateTaskConfig(long id, String extractorConfig, String pipelineConfig, + String applierConfig) { + RplTask record = new RplTask(); + record.setId(id); + record.setExtractorConfig(extractorConfig); + record.setPipelineConfig(pipelineConfig); + record.setApplierConfig(applierConfig); + taskMapper.updateByPrimaryKeySelective(record); + return getTask(id); + } + + public static RplTask updateTaskWorker(long id, String worker) { + return updateTask(id, null, worker, null, null, null); + } + + public static RplTask updateBinlogPosition(long id, String position) { + return updateTask(id, null, null, position, null, null); + } + + public static RplTask updateExtra(long id, String extra) { + RplTask record = new RplTask(); + record.setId(id); + record.setExtra(extra); + taskMapper.updateByPrimaryKeySelective(record); + return getTask(id); + } + + public static RplTask clearHistory(long id) { + RplTask record = new RplTask(); + record.setId(id); + record.setPosition(""); + record.setLastError(""); + record.setStatistic(""); + taskMapper.updateByPrimaryKeySelective(record); + return record; + } + + public static void deleteAfterTasks(long stateMachineId, long curServiceId) { + taskMapper.delete(i -> i.where(RplTaskDynamicSqlSupport.stateMachineId, SqlBuilder.isEqualTo(stateMachineId)) + .and(RplTaskDynamicSqlSupport.serviceId, SqlBuilder.isGreaterThan(curServiceId))); + } + + public static void deleteTask(long id) { + taskMapper.deleteByPrimaryKey(id); + } + + /************************ workers ********************/ + public static List listRunningWorker(String cluster, int status) { + return nodeInfoMapper.selectMany(SqlBuilder.select(NodeInfoDynamicSqlSupport.nodeInfo.allColumns()) + .from(NodeInfoDynamicSqlSupport.nodeInfo) + .where(NodeInfoDynamicSqlSupport.clusterId, SqlBuilder.isEqualTo(cluster)) + .and(NodeInfoDynamicSqlSupport.gmtModified, + SqlBuilder.isGreaterThan(DateTime.now().minusSeconds(RplConstants.WORKER_KEEP_ALIVE_SECONDS).toDate())) + .and(NodeInfoDynamicSqlSupport.status, SqlBuilder.isEqualTo(status)) + .build() + .render(RenderingStrategies.MYBATIS3)); + } + + /************************ ddl ********************/ + public static RplDdl getDdl(String ddlTso) { + Optional res = ddlMapper + .selectOne(i -> i.where(RplDdlDynamicSqlSupport.ddlTso, SqlBuilder.isEqualTo(ddlTso))); + return res.isPresent() ? res.get() : null; + } + + public static void updateDdl(RplDdl ddl) { + ddlMapper.updateByPrimaryKeySelective(ddl); + } + + public static RplDdl addDdl(RplDdl ddl) { + ddlMapper.insert(ddl); + return ddl; + } + + public static void deleteDdlByFSM(long FSMId) { + ddlMapper.delete(i -> i.where(RplDdlDynamicSqlSupport.stateMachineId, SqlBuilder.isEqualTo(FSMId))); + } + + public static void deleteDdlByTask(long taskId) { + ddlMapper.delete(i -> i.where(RplDdlDynamicSqlSupport.taskId, SqlBuilder.isEqualTo(taskId))); + } + + /************************* table position ***************************/ + public static void updateTablePosition(long stateMachineId, long serviceId, long taskId, String fullTableName, + String position) { + Optional res = tablePositionMapper + .selectOne(i -> i.where(RplTablePositionDynamicSqlSupport.taskId, SqlBuilder.isEqualTo(taskId)) + .and(RplTablePositionDynamicSqlSupport.fullTableName, SqlBuilder.isEqualTo(fullTableName))); + RplTablePosition record; + if (res.isPresent()) { + record = new RplTablePosition(); + record.setId(res.get().getId()); + record.setPosition(position); + tablePositionMapper.updateByPrimaryKeySelective(record); + } else { + record = new RplTablePosition(); + record.setFullTableName(fullTableName); + record.setPosition(position); + record.setStateMachineId(stateMachineId); + record.setServiceId(serviceId); + record.setTaskId(taskId); + tablePositionMapper.insert(record); + } + } + + public static void deleteTablePositionByFsm(long stateMachineId) { + tablePositionMapper.delete(i -> i.where(RplTablePositionDynamicSqlSupport.stateMachineId, + SqlBuilder.isEqualTo(stateMachineId))); + } + + public static void deleteTablePositionByTask(long taskId) { + tablePositionMapper.delete(i -> i.where(RplTablePositionDynamicSqlSupport.taskId, + SqlBuilder.isEqualTo(taskId))); + } + + public static List listTablePosition(long taskId) { + return tablePositionMapper + .selectMany(SqlBuilder.select(RplTablePositionDynamicSqlSupport.rplTablePosition.allColumns()) + .from(RplTablePositionDynamicSqlSupport.rplTablePosition) + .where(RplTablePositionDynamicSqlSupport.taskId, SqlBuilder.isEqualTo(taskId)) + .build() + .render(RenderingStrategies.MYBATIS3)); + } + + /************************* node ***************************/ + public static List listPolarxCNodeInfo() { + return polarxCNodeInfoMapper.select(s -> s.where(PolarxCNodeInfoDynamicSqlSupport.gmtModified, + SqlBuilder.isGreaterThan(DateTime.now().minusMinutes(2).toDate()))); + } + + +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/DdlState.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/DdlState.java new file mode 100644 index 00000000..1218e3aa --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/DdlState.java @@ -0,0 +1,55 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.taskmeta; + +/** + * @author shicai.xsc 2021/4/6 16:26 + * @since 5.0.0.0 + */ +public enum DdlState { + NOT_START(0), + + RUNNING(10), + + FAILED(20), + + SUCCEED(30); + + private int value; + + public int getValue() { + return value; + } + + public boolean isFinished() { + return this == FAILED || this == SUCCEED; + } + + DdlState(int value) { + this.value = value; + } + + public static DdlState from(int state) { + for (DdlState i : DdlState.values()) { + if (i.value == state) { + return i; + } + } + return null; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ExtractorConfig.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ExtractorConfig.java new file mode 100644 index 00000000..4519b497 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ExtractorConfig.java @@ -0,0 +1,33 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.taskmeta; + +import lombok.Data; + +/** + * @author shicai.xsc 2020/12/8 14:30 + * @since 5.0.0.0 + */ +@Data +public class ExtractorConfig { + protected boolean enableHeartbeat = false; + protected int extractorType; + protected int filterType; + protected HostInfo hostInfo; + protected String sourceToTargetConfig; +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ExtractorType.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ExtractorType.java new file mode 100644 index 00000000..832fe11c --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ExtractorType.java @@ -0,0 +1,47 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.taskmeta; + +/** + * @author jiyue 2021/09/06 20:58 + * @since 5.0.0.0 + */ +public enum ExtractorType { + // 用于replica + RPL_INC(30); + + + private int value; + + ExtractorType(int value) { + this.value = value; + } + + public static ExtractorType from(int state) { + for (ExtractorType i : ExtractorType.values()) { + if (i.value == state) { + return i; + } + } + return null; + } + + public int getValue() { + return value; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/FSMMetaManager.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/FSMMetaManager.java new file mode 100644 index 00000000..43e2d7a6 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/FSMMetaManager.java @@ -0,0 +1,522 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.taskmeta; + +import com.alibaba.fastjson.JSON; +import com.aliyun.polardbx.binlog.ConfigKeys; +import com.aliyun.polardbx.binlog.DynamicApplicationConfig; +import com.aliyun.polardbx.binlog.canal.core.model.BinlogPosition; +import com.aliyun.polardbx.binlog.daemon.pipeline.CommandPipeline; +import com.aliyun.polardbx.binlog.daemon.vo.CommandResult; +import com.aliyun.polardbx.binlog.domain.po.RplService; +import com.aliyun.polardbx.binlog.domain.po.RplStateMachine; +import com.aliyun.polardbx.binlog.domain.po.RplTask; +import com.aliyun.polardbx.binlog.scheduler.ResourceManager; +import com.aliyun.polardbx.binlog.scheduler.model.Container; +import com.aliyun.polardbx.rpl.applier.StatisticUnit; +import com.aliyun.polardbx.rpl.applier.StatisticalProxy; +import com.aliyun.polardbx.rpl.common.CommonUtil; +import com.aliyun.polardbx.rpl.common.HostManager; +import com.aliyun.polardbx.rpl.common.LogUtil; +import com.aliyun.polardbx.rpl.common.ResultCode; +import com.aliyun.polardbx.rpl.common.RplConstants; +import com.aliyun.polardbx.rpl.common.fsmutil.AbstractFSM; +import com.aliyun.polardbx.rpl.common.fsmutil.FSMState; +import com.aliyun.polardbx.rpl.common.fsmutil.ReplicaFSM; +import com.aliyun.polardbx.rpl.common.fsmutil.ServiceDetail; +import com.aliyun.polardbx.rpl.common.fsmutil.TaskDetail; +import com.google.common.collect.Sets; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +import static com.aliyun.polardbx.binlog.ConfigKeys.CLUSTER_ID; +import static com.aliyun.polardbx.binlog.ConfigKeys.INST_IP; + +/** + * @author shicai.xsc 2021/1/8 11:15 + * @since 5.0.0.0 + */ +public class FSMMetaManager { + + private final static Logger metaLogger = LogUtil.getMetaLogger(); + private final static CommandPipeline commander = new CommandPipeline(); + private final static ResourceManager resourceManager = + new ResourceManager(DynamicApplicationConfig.getString(CLUSTER_ID)); + private final static String GREP_RPL_TASK_COUNT_COMMAND = "ps -ef | grep 'RplTaskEngine' | grep -v grep | wc -l"; + private final static String GREP_RPL_TASK_COMMAND = "ps -ef | grep 'RplTaskEngine' | grep -v grep"; + + public static ResultCode startStateMachine(long FSMId) { + RplStateMachine stateMachine = DbTaskMetaManager.getStateMachine(FSMId); + if (stateMachine == null) { + metaLogger.error("from id: {} , fsm not found", FSMId); + return new ResultCode(RplConstants.FAILURE_CODE, "fsm not found", RplConstants.FAILURE); + } else { + metaLogger.info("startStateMachine, stateMachineId: {}, state: {}", + FSMId, stateMachine.getState()); + DbTaskMetaManager.updateStateMachineStatus(FSMId, StateMachineStatus.RUNNING); + return startServiceByState(FSMId, FSMState.from(stateMachine.getState())); + } + } + + public static ResultCode stopStateMachine(long stateMachineId) { + metaLogger.info("stopStateMachine, stateMachineId: {}", stateMachineId); + DbTaskMetaManager.updateStateMachineStatus(stateMachineId, StateMachineStatus.STOPPED); + List services = DbTaskMetaManager.listService(stateMachineId); + if (services.isEmpty()) { + return new ResultCode(RplConstants.FAILURE_CODE, "no service in this fsm", RplConstants.FAILURE); + } + for (RplService service : services) { + stopService(service); + } + return new ResultCode(RplConstants.SUCCESS_CODE, "success", RplConstants.SUCCESS); + } + + public static ResultCode startServiceByState(long FSMId) { + RplStateMachine stateMachine = DbTaskMetaManager.getStateMachine(FSMId); + if (stateMachine != null && stateMachine.getStatus() == StateMachineStatus.RUNNING.getValue()) { + return startServiceByState(FSMId, FSMState.from(stateMachine.getState())); + } else { + return new ResultCode(RplConstants.FAILURE_CODE, "fsm not found or fsm not set to running", + RplConstants.FAILURE); + } + } + + public static ResultCode startServiceByState(long FSMId, FSMState state) { + List services = DbTaskMetaManager.listService(FSMId); + for (RplService service : services) { + if (FSMState.contain(service.getStateList(), state)) { + startService(service); + } else { + stopService(service); + } + } + return new ResultCode(RplConstants.SUCCESS_CODE, "success", RplConstants.SUCCESS); + } + + public static RplStateMachine initStateMachine(StateMachineType type, ReplicateMeta meta, + AbstractFSM fsm) throws Exception { + if (type.getValue() != StateMachineType.REPLICA.getValue()) { + metaLogger.error("initStateMachine failed because of unmatched type and meta"); + return null; + } + try { + String config = JSON.toJSONString(meta); + metaLogger.info("initStateMachine, config: {}", config); + + // create stateMachine + RplStateMachine stateMachine = DbTaskMetaManager.createStateMachine(config, StateMachineType.REPLICA, + fsm, meta.channel, DynamicApplicationConfig.getString(ConfigKeys.CLUSTER_ID), null); + metaLogger.info("initStateMachine, created stateMachine, {}", stateMachine.getId()); + + // rpl service + RplService rplService = DbTaskMetaManager + .addService(stateMachine.getId(), ServiceType.REPLICA, + Arrays.asList(FSMState.REPLICA)); + createReplicaTasks(rplService, meta); + metaLogger.info("initStateMachine, created rplService: {}", rplService.getId()); + // should not start automatically for replica task + return stateMachine; + } catch (Throwable e) { + metaLogger.error("initStateMachine failed", e); + throw e; + } + } + + + public static long computeTaskDelay(RplTask task) { + String position = task.getPosition(); + BinlogPosition binlogPosition = BinlogPosition.parseFromString(position); + if (binlogPosition == null || CommonUtil.isMeaninglessBinlogFileName(binlogPosition)) { + return -1; + } + // how to compute delay + long positionTimeStamp = binlogPosition.getTimestamp(); + return TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()) - positionTimeStamp; + } + + public static boolean isServiceAndTaskFinish(long FSMId, ServiceType type) { + RplService service = DbTaskMetaManager.getService(FSMId, type); + if (service == null) { + return false; + } + if (service.getStatus() == ServiceStatus.FINISHED.getValue()) { + return true; + } + // need to check service finish or not + RplService updatedService = checkAndUpdateServiceFinish(service); + if (updatedService.getStatus() != ServiceStatus.FINISHED.getValue()) { + metaLogger.info("service still not finished, stateMachine: {}, service: {}", + FSMId, + updatedService.getId()); + return false; + } + return true; + } + + public static ResultCode startService(RplService service) { + metaLogger.info("startService, {}", service.getId()); + if (service.getStatus() != ServiceStatus.FINISHED.getValue()) { + return updateService(service, ServiceStatus.RUNNING, TaskStatus.RUNNING); + } + return new ResultCode(RplConstants.SUCCESS_CODE, "success", RplConstants.SUCCESS); + } + + public static ResultCode stopService(RplService service) { + metaLogger.info("stopService, {}", service.getId()); + if (service.getStatus() != ServiceStatus.FINISHED.getValue()) { + return updateService(service, ServiceStatus.STOPPED, TaskStatus.STOPPED); + } + return new ResultCode(RplConstants.SUCCESS_CODE, "success", RplConstants.SUCCESS); + } + + private static void createReplicaTasks(RplService rplService, ReplicateMeta meta) { + metaLogger.info("createTasks start, service: {}", rplService.getId()); + try { + RplTask rplTask = DbTaskMetaManager.addTask(rplService.getStateMachineId(), + rplService.getId(), + null, + null, + null, + ServiceType.from(rplService.getServiceType()), + 0, + DynamicApplicationConfig.getString(ConfigKeys.CLUSTER_ID)); + updateReplicaTasksConfig(rplService, meta, true); + metaLogger.info("createTasks end, service: {}, task: {}", rplService.getId(), rplTask.getId()); + } catch (Throwable e) { + metaLogger.error("createTasks failed, service: {}", rplService.getId(), e); + throw e; + } + } + + public static void updateReplicaConfig(RplStateMachine stateMachine, ReplicateMeta replicateMeta, + boolean useMetaPosition) { + metaLogger.info("update rpl config start, statemachine: {}", stateMachine.getId()); + String config = JSON.toJSONString(replicateMeta); + RplStateMachine newStateMachine = new RplStateMachine(); + newStateMachine.setId(stateMachine.getId()); + newStateMachine.setConfig(config); + DbTaskMetaManager.updateStateMachine(newStateMachine); + List services = DbTaskMetaManager.listService(stateMachine.getId()); + for (RplService service: services) { + FSMMetaManager.updateReplicaTasksConfig(service, replicateMeta, useMetaPosition); + } + } + + private static void updateReplicaTasksConfig(RplService rplService, ReplicateMeta meta, boolean useMetaPosition) { + String extractorConfigStr = ""; + String pipelineConfigStr = ""; + String applierConfigStr = ""; + metaLogger.info("update rpl tasks start, service: {}", rplService.getId()); + + ExtractorConfig extractorConfig = new ExtractorConfig(); + extractorConfig.setExtractorType(ExtractorType.RPL_INC.getValue()); + extractorConfig.setFilterType(FilterType.RPL_FILTER.getValue()); + extractorConfig.setSourceToTargetConfig(JSON.toJSONString(meta)); + extractorConfig.setHostInfo(getRplExtractorHostInfo(meta)); + extractorConfig.setEnableHeartbeat(true); + extractorConfigStr = JSON.toJSONString(extractorConfig); + + PipelineConfig pipelineConfig = new PipelineConfig(); + pipelineConfigStr = JSON.toJSONString(pipelineConfig); + + ApplierConfig applierConfig = new ApplierConfig(); + applierConfig.setHostInfo(getRplApplierHostInfo()); + applierConfig.setLogCommitLevel(RplConstants.LOG_ALL_COMMIT); + applierConfigStr = JSON.toJSONString(applierConfig); + + List tasks = DbTaskMetaManager.listTask(rplService.getId()); + for (RplTask task: tasks) { + DbTaskMetaManager.updateTaskConfig(task.getId(), extractorConfigStr, pipelineConfigStr, applierConfigStr); + if (useMetaPosition) { + DbTaskMetaManager.updateBinlogPosition(task.getId(), meta.position); + } + } + } + + public static void clearReplicaHistory(RplStateMachine stateMachine, boolean clearPosOnly) { + metaLogger.info("clear rpl history start, statemachine: {}", stateMachine.getId()); + if (!clearPosOnly) { + RplStateMachine newStateMachine = new RplStateMachine(); + newStateMachine.setId(stateMachine.getId()); + newStateMachine.setContext(""); + DbTaskMetaManager.updateStateMachine(newStateMachine); + } + DbTaskMetaManager.deleteTablePositionByFsm(stateMachine.getId()); + DbTaskMetaManager.deleteDdlByFSM(stateMachine.getId()); + List services = DbTaskMetaManager.listService(stateMachine.getId()); + for (RplService service: services) { + FSMMetaManager.clearReplicaTasksHistory(service, clearPosOnly); + } + } + + private static void clearReplicaTasksHistory(RplService rplService, boolean clearPosOnly) { + metaLogger.info("clear history of rpl tasks start, service: {}", rplService.getId()); + List tasks = DbTaskMetaManager.listTask(rplService.getId()); + for (RplTask task: tasks) { + metaLogger.info("clear history of rpl task start, task: {}", task.getId()); + if (!clearPosOnly) { + DbTaskMetaManager.clearHistory(task.getId()); + } + DbTaskMetaManager.updateBinlogPosition(task.getId(), CommonUtil.getRplInitialPosition()); + } + } + + private static ResultCode updateService(RplService service, ServiceStatus serviceStatus, TaskStatus taskStatus) { + if (service.getStatus() != ServiceStatus.FINISHED.getValue()) { + DbTaskMetaManager.updateService(service.getId(), serviceStatus); + } + List tasks = DbTaskMetaManager.listTask(service.getId()); + if (tasks.isEmpty()) { + return new ResultCode(RplConstants.FAILURE_CODE, "no task in this taskgroup", RplConstants.FAILURE); + } + for (RplTask task : tasks) { + if (task.getStatus() != TaskStatus.FINISHED.getValue()) { + DbTaskMetaManager.updateTaskStatus(task.getId(), taskStatus); + } + } + return new ResultCode(RplConstants.SUCCESS_CODE, "success", RplConstants.SUCCESS); + } + + public static void setTaskFinish(long taskId) { + DbTaskMetaManager.updateTaskStatus(taskId, TaskStatus.FINISHED); + } + + private static RplService checkAndUpdateServiceFinish(RplService service) { + metaLogger.info("checkService start, service: {}", service.getId()); + + try { + boolean allFinished = true; + List tasks = DbTaskMetaManager.listTask(service.getId()); + for (RplTask task : tasks) { + TaskStatus status = TaskStatus.from(task.getStatus()); + if (status != TaskStatus.FINISHED) { + metaLogger.info("checkService, service: {} NOT allFinished, running task: {}", + service.getId(), + task.getId()); + allFinished = false; + break; + } + } + + if (allFinished) { + metaLogger.info("checkService, {} allFinished", service.getId()); + RplService newService = new RplService(); + newService.setId(service.getId()); + newService.setStatus(ServiceStatus.FINISHED.getValue()); + return DbTaskMetaManager.updateService(newService); + } + } catch (Throwable e) { + metaLogger.error("checkService failed", e); + } + + metaLogger.info("checkService end, service: {}", service.getId()); + return service; + } + + private static boolean isTaskAlive(RplTask task) { + return task.getGmtModified() + .after(new Date(System.currentTimeMillis() - RplConstants.TASK_KEEP_ALIVE_INTERVAL_SECONDS * 1000)); + } + + private static HostInfo getRplApplierHostInfo() { + HostInfo info = HostManager.getDstPolarxHost(); + info.setUsePolarxPoolCN(true); + return info; + } + + private static HostInfo getRplExtractorHostInfo(ReplicateMeta replicateMeta) { + return new HostInfo(replicateMeta.getMasterHost(), + replicateMeta.getMasterPort(), + replicateMeta.getMasterUser(), + replicateMeta.getMasterPassword(), + "", + replicateMeta.getMasterType(), RplConstants.SERVER_ID_NULL); + } + + //////////////////////////// For Daemon ////////////////////////////// + + /** + * For Leader + */ + public static int distributeTasks() { + try { + List workers = resourceManager.availableContainers(); + if (workers.size() == 0) { + metaLogger.error("distributeTasks, no running workers"); + return 0; + } + + Map workerLoads = new HashMap<>(); + for (Container worker : workers) { + workerLoads.put(worker.getNodeHttpAddress(), 0); + } + String clusterId = DynamicApplicationConfig.getString(ConfigKeys.CLUSTER_ID); + List tasks = DbTaskMetaManager.listClusterTask(TaskStatus.RUNNING, clusterId); + List toDistributeTasks = new ArrayList<>(); + + for (RplTask task : tasks) { + if (StringUtils.isBlank(task.getWorker()) || !isTaskRunning(task) + || !workerLoads.containsKey(task.getWorker())) { + toDistributeTasks.add(task); + metaLogger.info("distributeTasks, need distribute task: {}", task.getId()); + } else { + metaLogger.info("distributeTasks, task: {} no need to distribute, worker: {}, gmtModified: {}", + task.getId(), + task.getWorker(), + task.getGmtModified()); + workerLoads.put(task.getWorker(), workerLoads.get(task.getWorker()) + 1); + } + } + + metaLogger.info("distributeTasks, workerLoads before: {}", JSON.toJSONString(workerLoads)); + List> sortedWorkLoad = new ArrayList<>(workerLoads.entrySet()); + Collections.sort(sortedWorkLoad, Comparator.comparingInt(Map.Entry::getValue)); + + for (RplTask task : toDistributeTasks) { + Map.Entry entry = sortedWorkLoad.get(0); + DbTaskMetaManager.updateTaskWorker(task.getId(), entry.getKey()); + metaLogger.info("distributeTasks, task: {}, to worker: {}", task.getId(), entry.getKey()); + entry.setValue(entry.getValue() + 1); + Collections.sort(sortedWorkLoad, Comparator.comparingInt(Map.Entry::getValue)); + } + for (Map.Entry entry : sortedWorkLoad) { + workerLoads.put(entry.getKey(), entry.getValue()); + } + + metaLogger.info("distributeTasks end, workerLoads after: {}", JSON.toJSONString(workerLoads)); + return toDistributeTasks.size(); + } catch (Throwable e) { + metaLogger.error("distributeTasks failed", e); + return 0; + } + } + + /** + * For Worker + */ + public static void checkAndRunLocalTasks(String clusterId) throws Exception { + metaLogger.info("checkAndRunLocalTasks start"); + List localNeedRestartTasks = DbTaskMetaManager.listTask(DynamicApplicationConfig.getString(INST_IP), + TaskStatus.RESTART, clusterId); + for (RplTask task : localNeedRestartTasks) { + commander.stopRplTask(task.getId()); + DbTaskMetaManager.updateTaskStatus(task.getId(), TaskStatus.RUNNING); + } + List localNeedRunTasks = + DbTaskMetaManager.listTask(DynamicApplicationConfig.getString(INST_IP), + TaskStatus.RUNNING,clusterId); + Set needRunTaskIds = localNeedRunTasks.stream().map(RplTask::getId).collect(Collectors.toSet()); + Set runningTaskIds = Sets.newHashSet(listLocalRunningTaskId()); + stopNoLocalTasks(runningTaskIds, needRunTaskIds); + startLocalTasks(runningTaskIds, localNeedRunTasks); + metaLogger.info("checkAndRunLocalTasks end"); + } + + /** + * Check if task RUNNING on current worker + */ + public static boolean isTaskLocalRunning(long taskId) throws Exception { + List runningTaskIds = listLocalRunningTaskId(); + return runningTaskIds.contains(taskId); + } + + /** + * Check if task is RUNNING on any worker + */ + private static boolean isTaskRunning(RplTask task) { + return task.getGmtModified() + .after(new Date(System.currentTimeMillis() - RplConstants.TASK_KEEP_ALIVE_INTERVAL_SECONDS * 1000)); + } + + public static List listLocalRunningTaskId() throws Exception { + List runningTaskIds = new ArrayList<>(); + + CommandResult countResult = commander.execCommand(new String[] {"bash", "-c", GREP_RPL_TASK_COUNT_COMMAND}, + 3000); + if (countResult.getCode() != 0) { + metaLogger.warn("check local running RplTaskEngine fail, result code: {}, msg: {}", + countResult.getCode(), + countResult.getMsg()); + return runningTaskIds; + } + + String countStr = StringUtils.split(countResult.getMsg(), System.getProperty("line.separator"))[0]; + if (Integer.valueOf(StringUtils.trim(countStr)) <= 0) { + metaLogger.warn("no local running RplTaskEngine"); + return runningTaskIds; + } + + CommandResult result = commander.execCommand(new String[] {"bash", "-c", GREP_RPL_TASK_COMMAND}, 3000); + if (result.getCode() == 0) { + String[] runningTaskInfos = StringUtils.split(result.getMsg(), System.getProperty("line.separator")); + for (String taskInfo : runningTaskInfos) { + String[] tokens = StringUtils.splitByWholeSeparator(taskInfo, "RplTaskEngine"); + Map args = CommonUtil.handleArgs(StringUtils.trim(tokens[tokens.length - 1])); + String taskId = args.get(RplConstants.TASK_ID); + runningTaskIds.add(Long.valueOf(taskId)); + } + } else { + metaLogger.warn("check local running RplTaskEngine fail, result code: {}, msg: {}", + result.getCode(), + result.getMsg()); + } + + return runningTaskIds; + } + + public static void stopNoLocalTasks(Set runningTaskIds, Set needRunTaskIds) throws Exception { + if (runningTaskIds == null || runningTaskIds.size() == 0) { + metaLogger.info("startLocalTasks, no tasks to stop"); + return; + } + + for (Long runningTaskId : runningTaskIds) { + if (!needRunTaskIds.contains(runningTaskId)) { + commander.stopRplTask(runningTaskId); + metaLogger.warn("stop local running RplTaskEngine {} not in {}", runningTaskId, needRunTaskIds); + } + } + } + + public static void startLocalTasks(Set runningTaskIds, List needRunTasks) throws Exception { + if (needRunTasks == null || needRunTasks.size() == 0) { + metaLogger.info("startLocalTasks, no tasks to start"); + return; + } + + for (RplTask needRunTask : needRunTasks) { + if (!runningTaskIds.contains(needRunTask.getId())) { + String taskName = CommonUtil.buildRplTaskName(needRunTask); + commander.startRplTask(needRunTask.getId(), taskName); + metaLogger.warn("start local running RplTaskEngine {} {}", needRunTask.getId(), taskName); + } + } + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/FilterType.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/FilterType.java new file mode 100644 index 00000000..6852aa97 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/FilterType.java @@ -0,0 +1,50 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.taskmeta; + +public enum FilterType { + + // 无filter, 自行在applier中实现过滤逻辑 + NO_FILTER(0), + + // 标准filter,目前用于data import + NORMAL_FILTER(10), + + // replica使用的filter + RPL_FILTER(20); + + private int value; + + public int getValue() { + return value; + } + + FilterType(int value) { + this.value = value; + } + + public static FilterType from(int state) { + for (FilterType i : FilterType.values()) { + if (i.value == state) { + return i; + } + } + return null; + } +} + diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/HostInfo.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/HostInfo.java new file mode 100644 index 00000000..f0e344b5 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/HostInfo.java @@ -0,0 +1,52 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.taskmeta; + +import lombok.Data; + +/** + * @author shicai.xsc 2021/1/8 11:28 + * @since 5.0.0.0 + */ +@Data +public class HostInfo { + + private boolean usePolarxPoolCN; + private String host; + private int port; + private String userName; + private String password; + private String schema; + private HostType type; + private long serverId; + + public HostInfo() { + } + + public HostInfo(String host, int port, String userName, String password, String schema, HostType type, + long serverId) { + this.usePolarxPoolCN = false; + this.host = host; + this.port = port; + this.userName = userName; + this.password = password; + this.schema = schema; + this.type = type; + this.serverId = serverId; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/HostType.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/HostType.java new file mode 100644 index 00000000..a10371ce --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/HostType.java @@ -0,0 +1,49 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.taskmeta; + +/** + * @author shicai.xsc 2020/12/29 16:07 + * @since 5.0.0.0 + */ +public enum HostType { + RDS(10), + + MYSQL(15), + + POLARX2(30); + + private int value; + + public int getValue() { + return value; + } + + HostType(int value) { + this.value = value; + } + + public static HostType from(int state) { + for (HostType i : HostType.values()) { + if (i.value == state) { + return i; + } + } + return null; + } +} \ No newline at end of file diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/PipelineConfig.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/PipelineConfig.java new file mode 100644 index 00000000..82ccc154 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/PipelineConfig.java @@ -0,0 +1,35 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.taskmeta; + +import lombok.Data; + +/** + * @author shicai.xsc 2020/11/30 15:55 + * @since 5.0.0.0 + */ +@Data +public class PipelineConfig { + + private int consumerParallelCount = 32; + private int bufferSize = 2048; + private boolean supportXa = false; + private int fixedTpsLimit = -1; + private boolean skipException = false; + private boolean useIncValidation = true; +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ReplicateMeta.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ReplicateMeta.java new file mode 100644 index 00000000..8e7f4af6 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ReplicateMeta.java @@ -0,0 +1,47 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.taskmeta; + +import lombok.Data; + +/** + * @author shicai.xsc 2021/2/3 21:51 + * @since 5.0.0.0 + */ +@Data +public class ReplicateMeta { + + String channel; + + String masterHost; + int masterPort; + String masterUser; + String masterPassword; + HostType masterType; + String position; + String ignoreServerIds; + + String doDb; + String ignoreDb; + String doTable; + String ignoreTable; + String wildDoTable; + String wildIgnoreTable; + String rewriteDb; + String extra; +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/RplServiceManager.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/RplServiceManager.java new file mode 100644 index 00000000..014a5090 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/RplServiceManager.java @@ -0,0 +1,506 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.taskmeta; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.alibaba.polardbx.druid.sql.SQLUtils; +import com.aliyun.polardbx.binlog.domain.po.RplService; +import com.aliyun.polardbx.binlog.domain.po.RplStateMachine; +import com.aliyun.polardbx.binlog.domain.po.RplTask; +import com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest; +import com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest; +import com.aliyun.polardbx.rpc.cdc.ResetSlaveRequest; +import com.aliyun.polardbx.rpc.cdc.RplCommandResponse; +import com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusRequest; +import com.aliyun.polardbx.rpc.cdc.ShowSlaveStatusResponse; +import com.aliyun.polardbx.rpc.cdc.StartSlaveRequest; +import com.aliyun.polardbx.rpc.cdc.StopSlaveRequest; +import com.aliyun.polardbx.rpl.applier.StatisticUnit; +import com.aliyun.polardbx.rpl.common.CommonUtil; +import com.aliyun.polardbx.rpl.common.LogUtil; +import com.aliyun.polardbx.rpl.common.RplConstants; +import com.aliyun.polardbx.rpl.common.fsmutil.ReplicaFSM; +import io.grpc.stub.StreamObserver; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author shicai.xsc 2021/2/19 10:18 + * @since 5.0.0.0 + */ +public class RplServiceManager { + + private final static String OPERATION_ON_RUNNING_SLAVE_ERROR = + "This operation cannot be performed with a running slave; " + + "run STOP SLAVE (FOR CHANNEL 'channel_name') first"; + private final static String MULTIPLE_CHANNELS_EXIST = + "Multiple channels exist on the slave. Please provide channel name as an argument"; + private final static String CHANNEL_NOT_EXIST = + "Slave channel for this channel name does not exist"; + + private final static Logger rplLogger = LogUtil.getRplLogger(); + + //////////////////////////////// For RPC calls ///// /////////////////////////// + public static void startSlave(StartSlaveRequest request, StreamObserver responseObserver) { + try { + Map params = parseRequest(request.getRequest()); + rplLogger.info("receive start slave for channel: {}, params: {}", params.get(RplConstants.CHANNEL), params); + if (!checkSlaveExist(params, responseObserver)) { + return; + } + List stateMachines = listRplStateMachine(params.get(RplConstants.CHANNEL)); + for (RplStateMachine stateMachine : stateMachines) { + FSMMetaManager.startStateMachine(stateMachine.getId()); + rplLogger.info("start statemachine, {}", stateMachine.getId()); + } + FSMMetaManager.distributeTasks(); + setRpcRplCommandResponse(responseObserver, 0, ""); + } catch (Throwable e) { + setRpcRplCommandResponse(responseObserver, 1, e.getMessage()); + } + } + + public static void stopSlave(StopSlaveRequest request, StreamObserver responseObserver) { + try { + Map params = parseRequest(request.getRequest()); + rplLogger.info("receive stop slave for channel: {}, params: {}", params.get(RplConstants.CHANNEL), params); + if (!checkSlaveExist(params, responseObserver)) { + return; + } + List stateMachines = listRplStateMachine(params.get(RplConstants.CHANNEL)); + for (RplStateMachine stateMachine : stateMachines) { + FSMMetaManager.stopStateMachine(stateMachine.getId()); + rplLogger.info("stop statemachine, {}", stateMachine.getId()); + } + setRpcRplCommandResponse(responseObserver, 0, ""); + } catch (Throwable e) { + setRpcRplCommandResponse(responseObserver, 1, e.getMessage()); + } + } + + public static void resetSlave(ResetSlaveRequest request, StreamObserver responseObserver) { + try { + Map params = parseRequest(request.getRequest()); + rplLogger.info("receive reset slave for channel: {}, params: {}", params.get(RplConstants.CHANNEL), params); + + // rules : + // RESET SLAVE ALL, remove all rpl fsm + // RESET SLAVE ALL FOR CHANNEL 'xxx', remove rpl fsm with specific channel name + // RESET SLAVE, remove history of all rpl fsm + // RESET SLAVE FOR CHANNEL 'xxx', remove history of rpl fsm with specific channel name + // here history means position, error and statistical data + + if (!checkSlaveRunning(params, responseObserver) || !checkSlaveExist(params, responseObserver)) { + return; + } + + List stateMachines = listRplStateMachine(params.get(RplConstants.CHANNEL)); + for (RplStateMachine stateMachine : stateMachines) { + if (StringUtils.equalsIgnoreCase("false", params.get(RplConstants.IS_ALL))) { + FSMMetaManager.clearReplicaHistory(stateMachine, false); + rplLogger.info("remove history of replica fsm, {}", stateMachine.getId()); + } else { + DbTaskMetaManager.deleteStateMachine(stateMachine.getId()); + rplLogger.info("remove replica fsm itself, {}", stateMachine.getId()); + } + } + setRpcRplCommandResponse(responseObserver, 0, ""); + } catch (Throwable e) { + setRpcRplCommandResponse(responseObserver, 1, e.getMessage()); + } + } + + + public static void showSlaveStatus(ShowSlaveStatusRequest request, + StreamObserver responseObserver) { + Map params = parseRequest(request.getRequest()); + rplLogger.info("receive show slave status for channel: {}, params: {}", params.get(RplConstants.CHANNEL), + params); + + List stateMachines = listRplStateMachine(params.get(RplConstants.CHANNEL)); + // no need to check channel exist + // mysql> show slave status for channel 'a'; + // Empty set (0.01 sec) + + for (RplStateMachine stateMachine : stateMachines) { + rplLogger.info("show status for fsm, {}", stateMachine.getId()); + ReplicateMeta replicateMeta = JSON.parseObject(stateMachine.getConfig(), ReplicateMeta.class); + // assert services长度为1 + List services = DbTaskMetaManager.listService(stateMachine.getId()); + for (RplService service : services) { + List tasks = DbTaskMetaManager.listTask(service.getId()); + RplTask slowestTask = findSlowestTask(tasks); + List positionDetails; + if (StringUtils.isNotBlank(slowestTask.getPosition())) { + positionDetails = CommonUtil.parsePosition(slowestTask.getPosition()); + } else { + rplLogger.error("position of task is blank, fsm id: {}, task id: {}", + stateMachine.getId(), slowestTask.getId()); + positionDetails = CommonUtil.parsePosition(CommonUtil.getRplInitialPosition()); + } + + long skipCounter = 0; + for (RplTask task : tasks) { + if (StringUtils.isBlank(task.getStatistic())) { + continue; + } + StatisticUnit unit = JSON.parseObject(task.getStatistic(), StatisticUnit.class); + skipCounter += unit.getSkipCounter(); + } + + String running = service.getStatus() == ServiceStatus.RUNNING.getValue() ? "Yes" : "No"; + Map response = new HashMap<>(); + response.put("Master_Host", replicateMeta.getMasterHost()); + response.put("Master_User", replicateMeta.getMasterUser()); + response.put("Master_Port", Integer.toString(replicateMeta.getMasterPort())); + response.put("Master_Log_File", positionDetails.get(0)); + response.put("Read_Master_Log_Pos", positionDetails.get(1)); + response.put("Relay_Log_File", positionDetails.get(0)); + response.put("Relay_Log_Pos", positionDetails.get(1)); + response.put("Relay_Master_Log_File", positionDetails.get(0)); + response.put("Slave_IO_Running", running); + response.put("Slave_SQL_Running", running); + response.put("Replicate_Do_DB", replicateMeta.getDoDb()); + response.put("Replicate_Ignore_DB", replicateMeta.getIgnoreDb()); + response.put("Replicate_Do_Table", replicateMeta.getDoTable()); + response.put("Replicate_Ignore_Table", replicateMeta.getIgnoreTable()); + response.put("Replicate_Wild_Do_Table", replicateMeta.getWildDoTable()); + response.put("Replicate_Wild_Ignore_Table", replicateMeta.getWildIgnoreTable()); + response.put("Last_Error", slowestTask.getLastError()); + response.put("Skip_Counter", String.valueOf(skipCounter)); + response.put("Exec_Master_Log_Pos", positionDetails.get(1)); + response.put("Until_Condition", "None"); + response.put("Master_SSL_Allowed", "No"); + response.put("Seconds_Behind_Master", String.valueOf(FSMMetaManager.computeTaskDelay(slowestTask))); + response.put("Master_SSL_Verify_Server_Cert", "No"); + response.put("Replicate_Ignore_Server_Ids", replicateMeta.getIgnoreServerIds()); + response.put("SQL_Remaining_Delay", "NULL"); + response.put("Slave_SQL_Running_State", running); + response.put("Auto_Position", "0"); + response.put("Replicate_Rewrite_DB", replicateMeta.getRewriteDb()); + response.put("Channel_Name", stateMachine.getChannel()); + responseObserver + .onNext(ShowSlaveStatusResponse.newBuilder().setResponse(JSON.toJSONString(response)) + .build()); + } + } + responseObserver.onCompleted(); + } + + public static void changeMaster(ChangeMasterRequest request, StreamObserver responseObserver) { + try { + Map params = parseRequest(request.getRequest()); + rplLogger.info("receive change master for channel: {}, params: {}", params.get(RplConstants.CHANNEL), + params); + List existStateMachines = listRplStateMachine(params.get(RplConstants.CHANNEL)); + if (!checkSlaveRunning(params, responseObserver)) { + return; + } + if (StringUtils.isBlank(params.get(RplConstants.CHANNEL)) && existStateMachines.size() > 1) { + rplLogger.error("This action does not support multiple channels, channel name: {}", + params.get(RplConstants.CHANNEL)); + setRpcRplCommandResponse(responseObserver, 1, MULTIPLE_CHANNELS_EXIST); + return; + } + // 如未设置file和pos,则MASTER_LOG_FILE='' and MASTER_LOG_POS=4,意思是找所能找到的最早的binlog的开头 + if (existStateMachines.size() == 0) { + ReplicateMeta replicateMeta = new ReplicateMeta(); + if (params.containsKey(RplConstants.CHANNEL)) { + replicateMeta.setChannel(params.get(RplConstants.CHANNEL)); + } + if (params.containsKey(RplConstants.MASTER_HOST)) { + replicateMeta.setMasterHost(params.get(RplConstants.MASTER_HOST)); + } + if (params.containsKey(RplConstants.MASTER_PORT)) { + replicateMeta.setMasterPort(Integer.parseInt(params.get(RplConstants.MASTER_PORT))); + } + if (params.containsKey(RplConstants.MASTER_USER)) { + replicateMeta.setMasterUser(params.get(RplConstants.MASTER_USER)); + } + if (params.containsKey(RplConstants.MASTER_PASSWORD)) { + replicateMeta.setMasterPassword(params.get(RplConstants.MASTER_PASSWORD)); + } + if (params.containsKey(RplConstants.MASTER_LOG_FILE) + && params.containsKey(RplConstants.MASTER_LOG_POS)) { + replicateMeta.setPosition( + params.get(RplConstants.MASTER_LOG_FILE) + ":" + params.get(RplConstants.MASTER_LOG_POS)); + } else { + replicateMeta.setPosition(CommonUtil.getRplInitialPosition()); + } + if (params.containsKey(RplConstants.IGNORE_SERVER_IDS)) { + // origin: (1,2) + // in db: 1,2 + String ignoreServerIds = CommonUtil.removeBracket(params.get(RplConstants.IGNORE_SERVER_IDS)); + replicateMeta.setIgnoreServerIds(ignoreServerIds); + } + if (params.containsKey(RplConstants.SOURCE_HOST_TYPE)) { + if (StringUtils.equalsIgnoreCase("polardbx", params.get(RplConstants.SOURCE_HOST_TYPE))) { + replicateMeta.setMasterType(HostType.POLARX2); + } else if (StringUtils.equalsIgnoreCase("rds", params.get(RplConstants.SOURCE_HOST_TYPE))) { + replicateMeta.setMasterType(HostType.RDS); + } + } else { + replicateMeta.setMasterType(HostType.MYSQL); + } + + replicateMeta.setDoDb(""); + replicateMeta.setIgnoreDb(""); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable(""); + replicateMeta.setWildDoTable(""); + replicateMeta.setWildIgnoreTable(""); + replicateMeta.setRewriteDb(""); + + rplLogger.info("receive change master for channel: {}, create new fsm from config: {}", + params.get(RplConstants.CHANNEL), replicateMeta); + ReplicaFSM.getInstance().create(replicateMeta); + + } else { + // rules: + + // 1. 如果我们设置MASTER_HOST 或 MASTER_PORT参数,则"无论如何"视为新的master + // 2. 如果我们设置MASTER_LOG_FILE 与 MASTER_LOG_POS参数,则视为新的position + // 清除位点上下文并修改fsm/service/task的元数据 + // 此时如未设置file和pos,则MASTER_LOG_FILE='0' and MASTER_LOG_POS=4,意思是找所能找到的最早的binlog的开头 + + // 如果未采用新master且MASTER_LOG_FILE 与 MASTER_LOG_POS都没有指定,则使用上次保存的位置 + // 复用table_position和ddl表,修改fsm/service/task的元数据 + + // 不支持MASTER_LOG_POS=0时自动匹配最新binlog offset,mysql8.0文档中无相关信息 + + + // assert that only 1 statemachine here + RplStateMachine stateMachine = existStateMachines.get(0); + ReplicateMeta replicateMeta = JSON.parseObject(stateMachine.getConfig(), ReplicateMeta.class); + if (params.containsKey(RplConstants.MASTER_HOST)) { + replicateMeta.setMasterHost(params.get(RplConstants.MASTER_HOST)); + } + if (params.containsKey(RplConstants.MASTER_PORT)) { + replicateMeta.setMasterPort(Integer.parseInt(params.get(RplConstants.MASTER_PORT))); + } + if (params.containsKey(RplConstants.MASTER_USER)) { + replicateMeta.setMasterUser(params.get(RplConstants.MASTER_USER)); + } + if (params.containsKey(RplConstants.MASTER_PASSWORD)) { + replicateMeta.setMasterPassword(params.get(RplConstants.MASTER_PASSWORD)); + } + if (params.containsKey(RplConstants.MASTER_LOG_FILE) + && params.containsKey(RplConstants.MASTER_LOG_POS)) { + replicateMeta.setPosition(params.get(RplConstants.MASTER_LOG_FILE) + ":" + + params.get(RplConstants.MASTER_LOG_POS)); + } else { + replicateMeta.setPosition(CommonUtil.getRplInitialPosition()); + } + if (params.containsKey(RplConstants.IGNORE_SERVER_IDS)) { + replicateMeta.setIgnoreServerIds(params.get(RplConstants.IGNORE_SERVER_IDS)); + } + + if (params.containsKey(RplConstants.SOURCE_HOST_TYPE)) { + if (StringUtils.equalsIgnoreCase("rds", params.get(RplConstants.SOURCE_HOST_TYPE))) { + replicateMeta.setMasterType(HostType.RDS); + } else if (StringUtils.equalsIgnoreCase("mysql", params.get(RplConstants.SOURCE_HOST_TYPE))) { + replicateMeta.setMasterType(HostType.MYSQL); + } + } else { + replicateMeta.setMasterType(HostType.POLARX2); + } + + if (params.containsKey(RplConstants.MASTER_HOST) || params.containsKey(RplConstants.MASTER_PORT) || + (params.containsKey(RplConstants.MASTER_LOG_FILE) + && params.containsKey(RplConstants.MASTER_LOG_POS))) { + rplLogger.info("receive change master for channel: {}, update old fsm with new master or position " + + "from config: {}", params.get(RplConstants.CHANNEL), replicateMeta); + // clear all context about table position + FSMMetaManager.clearReplicaHistory(stateMachine, true); + FSMMetaManager.updateReplicaConfig(stateMachine, replicateMeta, true); + } else { + rplLogger.info("receive change master for channel: {}, update old fsm without new position " + + "from config: {}", params.get(RplConstants.CHANNEL), replicateMeta); + FSMMetaManager.updateReplicaConfig(stateMachine, replicateMeta, false); + } + } + setRpcRplCommandResponse(responseObserver, 0, ""); + } catch (Throwable e) { + setRpcRplCommandResponse(responseObserver, 1, e.getMessage()); + } + } + + public static void changeReplicationFilter(ChangeReplicationFilterRequest request, + StreamObserver responseObserver) { + try { + + Map params = parseRequest(request.getRequest()); + rplLogger.info("receive change replication filter for channel: {}, params: {}", + params.get(RplConstants.CHANNEL), params); + List stateMachines = listRplStateMachine(params.get(RplConstants.CHANNEL)); + + if (!checkSlaveRunning(params, responseObserver) || !checkSlaveExist(params, responseObserver) || + !checkSchemaTableName(params, responseObserver)) { + return; + } + + for (RplStateMachine stateMachine : stateMachines) { + ReplicateMeta replicateMeta = JSON.parseObject(stateMachine.getConfig(), ReplicateMeta.class); + rplLogger.info("receive change replication filter for stateMachine id: {}, old config: {}", + stateMachine.getId(), replicateMeta); + if (params.containsKey(RplConstants.REPLICATE_DO_DB)) { + // origin: (full_src_1, rpl) d + // in db: full_src_1,rpl + replicateMeta.setDoDb(CommonUtil.removeBracket(params.get(RplConstants.REPLICATE_DO_DB))); + } + if (params.containsKey(RplConstants.REPLICATE_IGNORE_DB)) { + // origin: (full_src_1, gbktest) + // in db: full_src_1,gbktest + replicateMeta.setIgnoreDb(CommonUtil.removeBracket(params.get(RplConstants.REPLICATE_IGNORE_DB))); + } + if (params.containsKey(RplConstants.REPLICATE_DO_TABLE)) { + // origin: (full_src_1.t1, full_src_1.t2) + // in db: full_src_1.t1,full_src_1.t2 + replicateMeta.setDoTable(CommonUtil.removeBracket(params.get(RplConstants.REPLICATE_DO_TABLE))); + } + if (params.containsKey(RplConstants.REPLICATE_IGNORE_TABLE)) { + // origin: (full_src_1.t2, full_src_1.t3) + // in db: full_src_1.t3,full_src_1.t2 + replicateMeta + .setIgnoreTable(CommonUtil.removeBracket(params.get(RplConstants.REPLICATE_IGNORE_TABLE))); + } + if (params.containsKey(RplConstants.REPLICATE_WILD_DO_TABLE)) { + // origin: ('d%.tb\_charset%', 'd%.col\_charset%') + // in db: d%.tb\_charset%,d%.col\_charset% + String replicateWildDoTable = CommonUtil + .removeBracket(params.get(RplConstants.REPLICATE_WILD_DO_TABLE)); + replicateWildDoTable = replicateWildDoTable.replace("'", ""); + replicateMeta.setWildDoTable(replicateWildDoTable); + } + if (params.containsKey(RplConstants.REPLICATE_WILD_IGNORE_TABLE)) { + // origin: ('d%.tb\\_charset%', 'd%.col\\_charset%') + // in db: d%.tb\_charset%,d%.col\_charset% + String replicateWildIgnoreTable = CommonUtil + .removeBracket(params.get(RplConstants.REPLICATE_WILD_IGNORE_TABLE)); + replicateWildIgnoreTable = replicateWildIgnoreTable.replace("'", ""); + replicateMeta.setWildIgnoreTable(replicateWildIgnoreTable); + } + if (params.containsKey(RplConstants.REPLICATE_REWRITE_DB)) { + // origin: ((full_src_1, full_dst_1), (full_src_2, full_dst_2)) + // in db: (full_src_1,full_dst_1),(full_src_2,full_dst_2) + replicateMeta.setRewriteDb(CommonUtil.removeBracket(params.get(RplConstants.REPLICATE_REWRITE_DB))); + } + rplLogger.info("receive change replication filter for stateMachine id: {}, new config: {}", + stateMachine.getId(), replicateMeta); + // update config in task context + FSMMetaManager.updateReplicaConfig(stateMachine, replicateMeta, false); + } + setRpcRplCommandResponse(responseObserver, 0, ""); + } catch (Throwable e) { + setRpcRplCommandResponse(responseObserver, 1, e.getMessage()); + } + } + + public static boolean checkSchemaTableName(Map params, + StreamObserver responseObserver) { + for (Map.Entry entry : params.entrySet()) { + String paramName = entry.getKey(); + String paramValue = entry.getValue(); + if (!StringUtils.equals(paramName, RplConstants.REPLICATE_WILD_DO_TABLE) && + !StringUtils.equals(paramName, RplConstants.REPLICATE_WILD_IGNORE_TABLE)) { + entry.setValue(SQLUtils.normalize(paramValue)); + } + } + return true; + } + + private static Map parseRequest(String request) { + return JSON.parseObject(request, new TypeReference>() {}); + } + + private static void setRpcRplCommandResponse(StreamObserver responseObserver, int resultCode, + String error) { + responseObserver.onNext(RplCommandResponse.newBuilder().setResultCode(resultCode).setError(error).build()); + responseObserver.onCompleted(); + } + + private static RplTask findSlowestTask(List tasks) { + if (tasks.size() == 0) { + return null; + } + + // if pos of one task is blank, return this task as slowest task + for (RplTask task:tasks) { + if (StringUtils.isBlank(task.getPosition())) { + return task; + } + } + + RplTask slowest = tasks.get(0); + for (int i = 1; i < tasks.size(); i++) { + int compare = CommonUtil.comparePosition(slowest.getPosition(), tasks.get(i).getPosition()); + if (compare > 0) { + slowest = tasks.get(i); + } else if (compare == 0 && StringUtils.isNotBlank(tasks.get(i).getLastError())) { + slowest = tasks.get(i); + } + } + return slowest; + } + + private static List listRplStateMachine(String channel) { + List stateMachines = new ArrayList<>(); + + if (StringUtils.isNotBlank(channel)) { + RplStateMachine stateMachine = DbTaskMetaManager.getRplStateMachine(channel); + if (stateMachine != null) { + stateMachines.add(stateMachine); + } + } else { + stateMachines = DbTaskMetaManager.listRplStateMachine(); + } + return stateMachines; + } + + + private static boolean checkSlaveExist(Map params, + StreamObserver responseObserver) { + List stateMachines = listRplStateMachine(params.get(RplConstants.CHANNEL)); + if (StringUtils.isNotBlank(params.get(RplConstants.CHANNEL)) && stateMachines.isEmpty()) { + setRpcRplCommandResponse(responseObserver, 1, CHANNEL_NOT_EXIST); + rplLogger.error("replica fsm not exist for this channel name : {}", params.get(RplConstants.CHANNEL)); + return false; + } + return true; + } + + private static boolean checkSlaveRunning(Map params, + StreamObserver responseObserver) { + List stateMachines = listRplStateMachine(params.get(RplConstants.CHANNEL)); + for (RplStateMachine stateMachine : stateMachines) { + if (stateMachine.getStatus() == StateMachineStatus.RUNNING.getValue()) { + rplLogger.error("replica fsm is running thus not support this action, channel name: {}", + params.get(RplConstants.CHANNEL)); + setRpcRplCommandResponse(responseObserver, 1, OPERATION_ON_RUNNING_SLAVE_ERROR); + return false; + } + } + return true; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ServiceStatus.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ServiceStatus.java new file mode 100644 index 00000000..01fe5267 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ServiceStatus.java @@ -0,0 +1,71 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.taskmeta; + +/** + * @author shicai.xsc 2020/12/29 15:13 + * @since 5.0.0.0 + */ +public enum ServiceStatus { + /* + not used + * */ + NULL(0), + + READY(10), + + RUNNING(20), + + STOPPED(30), + + FINISHED(40), + + DEPRECATED(50); + + private int value; + + public int getValue() { + return value; + } + + public String getName() { + return this.name(); + } + + ServiceStatus(int value) { + this.value = value; + } + + public static ServiceStatus from(int value) { + for (ServiceStatus i : ServiceStatus.values()) { + if (i.value == value) { + return i; + } + } + return NULL; + } + + public static String nameFrom(int value) { + for (ServiceStatus i : ServiceStatus.values()) { + if (i.value == value) { + return i.name(); + } + } + return ""; + } +} \ No newline at end of file diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ServiceType.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ServiceType.java new file mode 100644 index 00000000..83e321b8 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/ServiceType.java @@ -0,0 +1,61 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.taskmeta; + +/** + * @author shicai.xsc 2020/12/8 14:04 + * @since 5.0.0.0 + */ +public enum ServiceType { + INC_COPY(101), + + REPLICA(3), + + FULL_COPY(100), + + FULL_VALIDATION(200), + + REVISE(201), + + REVISE_CHECK(202), + + CDC_INC(300), + + REC_SEARCH(301), + + REC_COMBINE(302); + + private int value; + + ServiceType(int value) { + this.value = value; + } + + public static ServiceType from(int value) { + for (ServiceType i : ServiceType.values()) { + if (i.getValue() == value) { + return i; + } + } + return null; + } + + public int getValue() { + return value; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/StateMachineStatus.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/StateMachineStatus.java new file mode 100644 index 00000000..735ec1a1 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/StateMachineStatus.java @@ -0,0 +1,53 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.taskmeta; + +/** + * @author shicai.xsc 2020/12/29 14:34 + * @since 5.0.0.0 + */ +public enum StateMachineStatus { + NULL(0), + + RUNNING(20), + + STOPPED(30), + + FINISHED(40), + + DEPRECATED(50); + + private int value; + + public int getValue() { + return value; + } + + StateMachineStatus(int value) { + this.value = value; + } + + public static StateMachineStatus from(int value) { + for (StateMachineStatus i : StateMachineStatus.values()) { + if (i.value == value) { + return i; + } + } + return NULL; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/StateMachineType.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/StateMachineType.java new file mode 100644 index 00000000..4ab85b62 --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/StateMachineType.java @@ -0,0 +1,53 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.taskmeta; + +/** + * @author shicai.xsc 2020/12/29 14:57 + * @since 5.0.0.0 + */ +public enum StateMachineType { + NULL(0), + + DATA_IMPORT(10), + + // DATA_EXPORT(20), + + REPLICA(30), + + RECOVERY(40); + + private int value; + + public int getValue() { + return value; + } + + StateMachineType(int value) { + this.value = value; + } + + public static StateMachineType from(int state) { + for (StateMachineType i : StateMachineType.values()) { + if (i.value == state) { + return i; + } + } + return null; + } +} diff --git a/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/TaskStatus.java b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/TaskStatus.java new file mode 100644 index 00000000..0bdb82bc --- /dev/null +++ b/polardbx-cdc-rpl/src/main/java/com/aliyun/polardbx/rpl/taskmeta/TaskStatus.java @@ -0,0 +1,55 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.taskmeta; + +/** + * @author shicai.xsc 2021/1/12 15:24 + * @since 5.0.0.0 + */ +public enum TaskStatus { + NULL(0), + + READY(10), + + RUNNING(20), + + STOPPED(30), + + FINISHED(40), + + RESTART(50); + + private int value; + + public int getValue() { + return value; + } + + TaskStatus(int value) { + this.value = value; + } + + public static TaskStatus from(int value) { + for (TaskStatus i : TaskStatus.values()) { + if (i.value == value) { + return i; + } + } + return NULL; + } +} \ No newline at end of file diff --git a/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/TestBase.java b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/TestBase.java new file mode 100644 index 00000000..2d573e37 --- /dev/null +++ b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/TestBase.java @@ -0,0 +1,497 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl; + +import com.alibaba.fastjson.JSON; +import com.aliyun.polardbx.binlog.SpringContextBootStrap; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSAction; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSRowData; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultRowChange; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultRowData; +import com.aliyun.polardbx.binlog.canal.core.model.BinlogPosition; +import com.aliyun.polardbx.binlog.domain.po.RplService; +import com.aliyun.polardbx.binlog.domain.po.RplStateMachine; +import com.aliyun.polardbx.rpc.cdc.ChangeMasterRequest; +import com.aliyun.polardbx.rpc.cdc.ChangeReplicationFilterRequest; +import com.aliyun.polardbx.rpc.cdc.RplCommandResponse; +import com.aliyun.polardbx.rpc.cdc.StartSlaveRequest; +import com.aliyun.polardbx.rpc.cdc.StopSlaveRequest; +import com.aliyun.polardbx.rpl.common.DataSourceUtil; +import com.aliyun.polardbx.rpl.common.HostManager; +import com.aliyun.polardbx.rpl.common.RplConstants; +import com.aliyun.polardbx.rpl.taskmeta.DbTaskMetaManager; +import com.aliyun.polardbx.rpl.taskmeta.HostInfo; +import com.aliyun.polardbx.rpl.taskmeta.ReplicateMeta; +import com.aliyun.polardbx.rpl.taskmeta.RplServiceManager; +import com.aliyun.polardbx.rpl.taskmeta.ServiceType; +import io.grpc.stub.StreamObserver; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.modules.junit4.PowerMockRunner; + +import javax.sql.DataSource; +import java.io.Serializable; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Future; + +/** + * @author shicai.xsc 2021/2/23 20:38 + * @since 5.0.0.0 + */ +@RunWith(PowerMockRunner.class) +@PowerMockIgnore("javax.management.*") +@Slf4j +public class TestBase { + + protected final int WAIT_DML_SECOND = 1; + protected final int WAIT_DDL_SECOND = 4; + protected final int WAIT_TASK_SECOND = 5; + + protected String channel = "testBase"; + + protected HostInfo srcHostInfo; + protected HostInfo dstHostInfo; + protected HostInfo mysqlDstHostInfo; + + protected DataSource srcDs; + protected DataSource dstDs; + protected DataSource mysqlDstDs; + + protected Connection srcConn; + protected Connection dstConn; + protected Connection mysqlDstConn; + + protected BinlogPosition initBinlogPosition; + + protected RplTaskRunner rplTaskRunner; + protected Thread runnerThread; + + @Before + public void before() throws Exception { + SpringContextBootStrap appContextBootStrap = new SpringContextBootStrap("spring/spring.xml"); + appContextBootStrap.boot(); + + // 创建任务,建连,创建库表 + initConnection(); + initService(); + } + + @After + public void after() throws Exception { + // 删除库,关闭连接,停和删任务 + new Thread(() -> rplTaskRunner.stop()).start(); + // 触发 com/aliyun/polardbx/binlog/canal/core/AbstractEventParser.java 中的 + // parseThread 进入下一次循环以检测到 running == false 从而退出 + String someDb = "some_db"; + while (!rplTaskRunner.getExtractor().isRunning()) { + execUpdate(srcConn, "create database if not exists " + someDb, null); + execUpdate(srcConn, "drop database " + someDb, null); + wait(1); + } + } + + protected void initConnection() throws Exception { + srcHostInfo = new HostInfo(); + srcHostInfo.setHost("127.0.0.1"); + srcHostInfo.setPort(3306); + srcHostInfo.setUserName("root"); + srcHostInfo.setPassword("polarx_test"); + + mysqlDstHostInfo = new HostInfo(); + mysqlDstHostInfo.setHost("127.0.0.1"); + mysqlDstHostInfo.setPort(3307); + mysqlDstHostInfo.setUserName("root"); + mysqlDstHostInfo.setPassword("polarx_test"); + + dstHostInfo = HostManager.getDstPolarxHost(); + dstHostInfo.setUsePolarxPoolCN(true); + + srcDs = createDataSource(srcHostInfo, ""); + dstDs = createDataSource(dstHostInfo, ""); + mysqlDstDs = createDataSource(mysqlDstHostInfo, ""); + + srcConn = srcDs.getConnection(); + dstConn = dstDs.getConnection(); + mysqlDstConn = mysqlDstDs.getConnection(); + } + + protected void initService() throws Exception { + initBinlogPosition = getLastBinlogPosition(); + System.out.println("last binlog position: " + JSON.toJSONString(initBinlogPosition)); + + // setup service + setupService(channel, initBinlogPosition, null); + + // setup compare replica + setupMysqlReplica(mysqlDstConn, initBinlogPosition); + + rplTaskRunner = new RplTaskRunner(getTaskId(channel)); + runnerThread = new Thread(() -> rplTaskRunner.start()); + } + + protected BinlogPosition getLastBinlogPosition() throws Exception { + List> result = execQuery(srcConn, + "show master status", + Arrays.asList("File", "Position")); + String file = result.get(0).get("File"); + long position = Long.valueOf(result.get(0).get("Position")); + return new BinlogPosition(file, position, -1, -1); + } + + protected void setupService(String channel, BinlogPosition position, + Map filterParams) throws Exception { + Map params = new HashMap<>(); + params.put(RplConstants.MASTER_HOST, srcHostInfo.getHost()); + params.put(RplConstants.MASTER_PORT, String.valueOf(srcHostInfo.getPort())); + params.put(RplConstants.MASTER_USER, srcHostInfo.getUserName()); + params.put(RplConstants.MASTER_PASSWORD, srcHostInfo.getPassword()); + params.put(RplConstants.MASTER_LOG_FILE, position.getFileName()); + params.put(RplConstants.MASTER_LOG_POS, String.valueOf(position.getPosition())); + params.put(RplConstants.CHANNEL, channel); + params.put(RplConstants.SOURCE_HOST_TYPE, "rds"); + + StopSlaveRequest stopRequest = StopSlaveRequest.newBuilder().setRequest(JSON.toJSONString(params)).build(); + RplServiceManager.stopSlave(stopRequest, fakeStreamObserver()); + ChangeMasterRequest request = ChangeMasterRequest.newBuilder().setRequest(JSON.toJSONString(params)).build(); + RplServiceManager.changeMaster(request, fakeStreamObserver()); + + if (filterParams == null) { + filterParams = new HashMap<>(); + filterParams.put(RplConstants.REPLICATE_DO_DB, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_DB, ""); + filterParams.put(RplConstants.REPLICATE_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_REWRITE_DB, ""); + } + filterParams.put(RplConstants.CHANNEL, channel); + ChangeReplicationFilterRequest filterRequest = ChangeReplicationFilterRequest.newBuilder() + .setRequest(JSON.toJSONString(filterParams)) + .build(); + RplServiceManager.changeReplicationFilter(filterRequest, fakeStreamObserver()); + + StartSlaveRequest startRequest = StartSlaveRequest.newBuilder().setRequest(JSON.toJSONString(params)).build(); + RplServiceManager.startSlave(startRequest, fakeStreamObserver()); + } + + protected void setupMysqlReplica(Connection mysqlDstConn, BinlogPosition position) { + RplStateMachine stateMachine = DbTaskMetaManager.getRplStateMachine(channel); + ReplicateMeta replicateMeta = JSON.parseObject(stateMachine.getConfig(), ReplicateMeta.class); + execUpdate(mysqlDstConn, "stop slave", null); + execUpdate(mysqlDstConn, getChangeMasterSql(srcHostInfo, position), null); + execUpdate(mysqlDstConn, printChangeFilterSql(replicateMeta), null); + execUpdate(mysqlDstConn, "start slave", null); + } + + private String getChangeMasterSql(HostInfo srcHostInfo, BinlogPosition position) { + String sql = String + .format("CHANGE MASTER TO\n" + "MASTER_HOST='%s',\n" + "MASTER_USER='%s',\n" + "MASTER_PORT=%d,\n" + + "MASTER_PASSWORD='%s',\n" + "MASTER_LOG_FILE='%s',\n" + "MASTER_LOG_POS=%d;", + srcHostInfo.getHost(), + srcHostInfo.getUserName(), + srcHostInfo.getPort(), + srcHostInfo.getPassword(), + position.getFileName(), + position.getPosition()); + return sql; + } + + protected long getTaskId(String channel) { + RplStateMachine stateMachine = DbTaskMetaManager.getRplStateMachine(channel); + RplService service = DbTaskMetaManager.getService(stateMachine.getId(), ServiceType.REPLICA); + return DbTaskMetaManager.listTask(service.getId()).get(0).getId(); + } + + protected void wait(int seconds) throws Exception { + Thread.sleep(seconds * 1000); + } + + protected StreamObserver fakeStreamObserver() { + return new StreamObserver() { + + @Override + public void onNext(RplCommandResponse rplCommandResponse) { + + } + + @Override + public void onError(Throwable throwable) { + + } + + @Override + public void onCompleted() { + + } + }; + } + + protected DataSource createDataSource(HostInfo hostInfo, String db) { + try { + return DataSourceUtil.createDruidMySqlDataSource(hostInfo.isUsePolarxPoolCN(), + hostInfo.getHost(), + hostInfo.getPort(), + db, + hostInfo.getUserName(), + hostInfo.getPassword(), + "utf8mb4", + 1, + 60, + null, + null); + } catch (Throwable e) { + System.out.println(e); + } + return null; + } + + protected boolean execUpdate(DataSource dataSource, String sql, List params) { + Connection conn = null; + PreparedStatement stmt = null; + + try { + conn = dataSource.getConnection(); + stmt = conn.prepareStatement(sql); + + // set value + int i = 1; + if (params != null) { + for (Serializable dataValue : params) { + stmt.setObject(i, dataValue); + i++; + } + } + + // execute + stmt.executeUpdate(); + return true; + } catch (Throwable e) { + log.error("failed in execUpdate: " + sql, e); + return false; + } finally { + DataSourceUtil.closeQuery(null, stmt, conn); + } + } + + protected boolean execUpdate(Connection connection, String sql, List params) { + PreparedStatement stmt = null; + + try { + stmt = connection.prepareStatement(sql); + + // set value + int i = 1; + if (params != null) { + for (Serializable dataValue : params) { + stmt.setObject(i, dataValue); + i++; + } + } + + // execute + stmt.executeUpdate(); + return true; + } catch (Throwable e) { + log.error("failed in execUpdate: " + sql, e); + return false; + } finally { + DataSourceUtil.closeQuery(null, stmt, null); + } + } + + protected List> execQuery(DataSource dataSource, String sql, List fields) { + Connection conn = null; + PreparedStatement stmt = null; + ResultSet res = null; + List> result = new ArrayList<>(); + + try { + conn = dataSource.getConnection(); + stmt = conn.prepareStatement(sql); + + res = stmt.executeQuery(); + while (res.next()) { + List record = new ArrayList<>(); + for (String field : fields) { + record.add(res.getString(field)); + } + result.add(record); + } + } catch (Throwable e) { + log.error("failed in execQuery: " + sql, e); + } finally { + DataSourceUtil.closeQuery(res, stmt, conn); + } + + return result; + } + + protected List> execQuery(Connection connection, String sql, List fields) { + PreparedStatement stmt = null; + ResultSet res = null; + List> result = new ArrayList<>(); + + try { + stmt = connection.prepareStatement(sql); + + res = stmt.executeQuery(); + while (res.next()) { + Map record = new HashMap<>(); + for (String field : fields) { + record.put(field, res.getString(field)); + } + result.add(record); + } + } catch (Throwable e) { + log.error("failed in execQuery: " + sql, e); + } finally { + DataSourceUtil.closeQuery(res, stmt, null); + } + + return result; + } + + protected List execQuery(Connection connection, String sql, int fieldIndex) { + PreparedStatement stmt = null; + ResultSet res = null; + List result = new ArrayList<>(); + + try { + stmt = connection.prepareStatement(sql); + + res = stmt.executeQuery(); + while (res.next()) { + result.add(res.getString(fieldIndex)); + } + } catch (Throwable e) { + log.error("failed in execQuery: " + sql, e); + } finally { + DataSourceUtil.closeQuery(res, stmt, null); + } + + return result; + } + + protected String printChangeFilterSql(ReplicateMeta replicateMeta) { + String wildDoTable = adjustWildFilter(replicateMeta.getWildDoTable()); + wildDoTable = StringUtils.isNotBlank(wildDoTable) ? wildDoTable : ""; + String wildIgnoreTable = adjustWildFilter(replicateMeta.getWildIgnoreTable()); + wildIgnoreTable = StringUtils.isNotBlank(wildIgnoreTable) ? wildIgnoreTable : ""; + + String sql = String.format("CHANGE REPLICATION FILTER \n" + "REPLICATE_DO_DB=(%s),\n" + + "REPLICATE_IGNORE_DB=(%s),\n" + "REPLICATE_DO_TABLE=(%s),\n" + + "REPLICATE_IGNORE_TABLE=(%s),\n" + "REPLICATE_WILD_DO_TABLE=(%s),\n" + + "REPLICATE_WILD_IGNORE_TABLE=(%s),\n" + "REPLICATE_REWRITE_DB=(%s);", + StringUtils.isNotBlank(replicateMeta.getDoDb()) ? replicateMeta.getDoDb() : "", + StringUtils.isNotBlank(replicateMeta.getIgnoreDb()) ? replicateMeta.getIgnoreDb() : "", + StringUtils.isNotBlank(replicateMeta.getDoTable()) ? replicateMeta.getDoTable() : "", + StringUtils.isNotBlank(replicateMeta.getIgnoreTable()) ? replicateMeta.getIgnoreTable() : "", + wildDoTable, + wildIgnoreTable, + replicateMeta.getRewriteDb()); + System.out.println("stop slave;"); + System.out.println(sql); + System.out.println("start slave;"); + return sql; + } + + protected boolean checkFinish(List futures) throws Exception { + boolean finish = false; + while (!finish) { + finish = true; + for (Future future : futures) { + if (!future.isDone()) { + finish = false; + break; + } + } + Thread.sleep(1000); + } + + return finish; + } + + protected void checkTwoDstsSame(String db, String tb, List fields, String orderByField) { + String sql = String.format("select * from %s.%s order by %s", db, tb, orderByField); + List> dstRes = execQuery(dstConn, sql, fields); + List> mysqlDstRes = execQuery(mysqlDstConn, sql, fields); + + Assert.assertEquals(dstRes.size(), mysqlDstRes.size()); + for (int i = 0; i < dstRes.size(); i++) { + Map dstRecord = dstRes.get(i); + Map mysqlDstRecord = mysqlDstRes.get(i); + for (String field : fields) { + Assert.assertEquals(dstRecord.get(field), mysqlDstRecord.get(field)); + } + } + } + + protected DefaultRowChange createRowChange(String schema, String table, DBMSAction action, int f0B, int f1B, + int f2B, int f3B, int f0A, int f1A, + int f2A, int f3A) { + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setSchema(schema); + rowChange.setTable(table); + rowChange.setAction(action); + + List dataSet = new ArrayList<>(); + DefaultRowData rowData = new DefaultRowData(); + rowData.setRowValue(0, f0B); + rowData.setRowValue(1, f1B); + rowData.setRowValue(2, f2B); + rowData.setRowValue(3, f3B); + dataSet.add(rowData); + rowChange.setDataSet(dataSet); + + if (action == DBMSAction.UPDATE) { + List changeDataSet = new ArrayList<>(); + DefaultRowData changeRowData = new DefaultRowData(); + changeRowData.setRowValue(0, f0A); + changeRowData.setRowValue(1, f1A); + changeRowData.setRowValue(2, f2A); + changeRowData.setRowValue(3, f3A); + changeDataSet.add(changeRowData); + rowChange.setChangeDataSet(changeDataSet); + } + + return rowChange; + } + + private String adjustWildFilter(String wildFilter) { + String[] tokens = wildFilter.split(","); + for (int i = 0; i < tokens.length; i++) { + if (StringUtils.isNotBlank(tokens[i])) { + tokens[i] = "'" + tokens[i].trim() + "'"; + } + } + return StringUtils.join(tokens, ","); + } +} diff --git a/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/applier/DdlHelperTest.java b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/applier/DdlHelperTest.java new file mode 100644 index 00000000..bf1e8e16 --- /dev/null +++ b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/applier/DdlHelperTest.java @@ -0,0 +1,85 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import java.sql.Timestamp; +import java.util.List; + +import com.aliyun.polardbx.binlog.canal.core.ddl.parser.DdlResult; +import com.aliyun.polardbx.binlog.canal.core.ddl.parser.DruidDdlParser; +import org.junit.Assert; +import org.junit.Test; + +/** + * @author shicai.xsc 2021/4/19 11:18 + * @since 5.0.0.0 + */ +public class DdlHelperTest { + + @Test + public void getOriginalSql() { + String sql = "/*POLARX_ORIGIN_SQL=CREATE TABLE aaaaaa (\n" + " id int,\n" + " value int,\n" + + " INDEX `auto_shard_key_id` USING BTREE(`ID`),\n" + + " _drds_implicit_id_ bigint AUTO_INCREMENT,\n" + " PRIMARY KEY (_drds_implicit_id_)\n" + + ")\n" + "DBPARTITION BY hash(id)\n" + "TBPARTITION BY hash(id) TBPARTITIONS 2*/ " + + "/*TSO=678700134612901433613180665615960145920000000000000000*/ CREATE TABLE aaaaaa ( id int, value " + + "int, INDEX `auto_shard_key_id` USING BTREE(`ID`) ) DEFAULT CHARACTER SET = utf8mb4 DEFAULT COLLATE = " + + "utf8mb4_general_ci"; + String originSql = DdlHelper.getOriginSql(sql); + Assert.assertEquals("CREATE TABLE aaaaaa (\n" + "\tid int,\n" + "\tvalue int,\n" + + "\tINDEX `auto_shard_key_id` USING BTREE(`ID`)\n" + ")\n" + "DBPARTITION BY hash(id)\n" + + "TBPARTITION BY hash(id) TBPARTITIONS 2", + originSql); + } + + @Test + public void getEnableKeysDdl() { + String sql = "/*! ALTER TABLE `test_tb` DISABLE KEYS */"; + List originSql = DruidDdlParser.parse(sql, "test_db"); + Assert.assertEquals("CREATE TABLE aaaaaa (\n" + "\tid int,\n" + "\tvalue int,\n" + + "\tINDEX `auto_shard_key_id` USING BTREE(`ID`)\n" + ")\n" + "DBPARTITION BY hash(id)\n" + + "TBPARTITION BY hash(id) TBPARTITIONS 2", + originSql); + } + + @Test + public void getTso_1() { + String sql = "/*POLARX_ORIGIN_SQL=CREATE TABLE aaaaaa (\n" + " id int,\n" + " value int,\n" + + " INDEX `auto_shard_key_id` USING BTREE(`ID`),\n" + + " _drds_implicit_id_ bigint AUTO_INCREMENT,\n" + " PRIMARY KEY (_drds_implicit_id_)\n" + + ")\n" + "DBPARTITION BY hash(id)\n" + "TBPARTITION BY hash(id) TBPARTITIONS 2*/ " + + "/*TSO=678700134612901433613180665615960145920000000000000000*/ CREATE TABLE aaaaaa ( id int, value " + + "int, INDEX `auto_shard_key_id` USING BTREE(`ID`) ) DEFAULT CHARACTER SET = utf8mb4 DEFAULT COLLATE = " + + "utf8mb4_general_ci"; + String tso = DdlHelper.getTso(sql, null, null); + Assert.assertEquals(tso, "678700134612901433613180665615960145920000000000000000"); + } + + @Test + public void getTso_2() { + String sql = "/*POLARX_ORIGIN_SQL=CREATE TABLE aaaaaa (\n" + " id int,\n" + " value int,\n" + + " INDEX `auto_shard_key_id` USING BTREE(`ID`),\n" + + " _drds_implicit_id_ bigint AUTO_INCREMENT,\n" + " PRIMARY KEY (_drds_implicit_id_)\n" + + ")\n" + "DBPARTITION BY hash(id)\n" + "TBPARTITION BY hash(id) TBPARTITIONS 2*/ " + + "CREATE TABLE aaaaaa ( id int, value " + + "int, INDEX `auto_shard_key_id` USING BTREE(`ID`) ) DEFAULT CHARACTER SET = utf8mb4 DEFAULT COLLATE = " + + "utf8mb4_general_ci"; + String tso = DdlHelper.getTso(sql, new Timestamp(1618802638), "test"); + // Assert.assertEquals("-3519920771618802638", tso); + } +} diff --git a/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/applier/MergeApplierTest.java b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/applier/MergeApplierTest.java new file mode 100644 index 00000000..29ba83a6 --- /dev/null +++ b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/applier/MergeApplierTest.java @@ -0,0 +1,117 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.applier; + +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSAction; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSEvent; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultRowChange; +import com.aliyun.polardbx.rpl.TestBase; +import com.aliyun.polardbx.rpl.dbmeta.DbMetaCache; +import com.aliyun.polardbx.rpl.dbmeta.TableInfo; +import com.aliyun.polardbx.rpl.taskmeta.HostInfo; +import com.aliyun.polardbx.rpl.taskmeta.HostType; +import org.junit.Before; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author shicai.xsc 2021/5/18 21:38 + * @since 5.0.0.0 + */ +public class MergeApplierTest extends TestBase { + private MergeApplier applier; + private Map> insertRowChanges; + private Map> deleteRowChanges; + private List dbmsEvents; + private HostInfo hostInfo; + private TableInfo tableInfo; + + private final static String SCHEMA = "schema_1"; + private final static String TABLE = "table_1"; + private final static String TB_KEY = SCHEMA + "." + TABLE; + + @Before + public void init() { + applier = new MergeApplier(null, hostInfo); + insertRowChanges = new HashMap<>(); + deleteRowChanges = new HashMap<>(); + dbmsEvents = new ArrayList<>(); + + hostInfo = new HostInfo(); + hostInfo.setType(HostType.POLARX2); + + tableInfo = new TableInfo(SCHEMA, TABLE); + + Map tableInfos = new HashMap<>(); + tableInfos.put(TB_KEY, tableInfo); + applier.dbMetaCache = new DbMetaCache(hostInfo, 10); + applier.dbMetaCache.setTableInfos(tableInfos); + } + +// @Test +// public void pk_NoChangePk() throws Throwable { +// +//// applier.getMergeDmlSqlContexts() +// +// // I + D +// +// applier.mergeByTable(dbmsEvents, insertRowChanges, deleteRowChanges); +// } +// +// @Test +// public void pk_ChangePk() throws Throwable { +// applier.mergeByTable(dbmsEvents, insertRowChanges, deleteRowChanges); +// } +// +// @Test +// public void pk_shardKey_ChangePk() throws Throwable { +// applier.mergeByTable(dbmsEvents, insertRowChanges, deleteRowChanges); +// } +// +// @Test +// public void pk_shardKey_ChangeShardKey() throws Throwable { +// applier.mergeByTable(dbmsEvents, insertRowChanges, deleteRowChanges); +// } +// +// @Test +// public void pk_shardKey_ChangePk_ChangeShardKey() throws Throwable { +// applier.mergeByTable(dbmsEvents, insertRowChanges, deleteRowChanges); +// } +// +// @Test +// public void pk_uk_ChangePk() throws Throwable { +// applier.mergeByTable(dbmsEvents, insertRowChanges, deleteRowChanges); +// } +// +// @Test +// public void pk_uk_ChangeUk() throws Throwable { +// applier.mergeByTable(dbmsEvents, insertRowChanges, deleteRowChanges); +// } +// +// @Test +// public void pk_uk_shardKey() throws Throwable { +// +// } + + private DefaultRowChange createRowChange(DBMSAction action, int f0, int f1, int f2, int f3) { + return createRowChange(SCHEMA, TABLE, action, f0, f1, f2, f3, -1, -1, -1, -1); + } +} diff --git a/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/dbmeta/DbMetaManagerTest.java b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/dbmeta/DbMetaManagerTest.java new file mode 100644 index 00000000..1dd9fe53 --- /dev/null +++ b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/dbmeta/DbMetaManagerTest.java @@ -0,0 +1,54 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.dbmeta; + +import javax.sql.DataSource; + +import com.aliyun.polardbx.rpl.TestBase; +import com.aliyun.polardbx.rpl.taskmeta.HostType; +import org.junit.Assert; +import org.junit.Test; + +import com.aliyun.polardbx.rpl.common.DataSourceUtil; + +import java.util.List; + +/** + * @author shicai.xsc 2021/3/25 16:48 + * @since 5.0.0.0 + */ +public class DbMetaManagerTest extends TestBase { + + @Test + public void metaTest() throws Throwable { + String schema = "rpl"; + String tbName = "no_pk"; + DataSource dataSource = DataSourceUtil.createDruidMySqlDataSource(srcHostInfo.getHost(), + srcHostInfo.getPort(), + schema, + srcHostInfo.getUserName(), + srcHostInfo.getPassword(), + "", + 1, + 16, + null, + null); + TableInfo tableInfo = DbMetaManager.getTableInfo(dataSource, schema, tbName, HostType.RDS); + Assert.assertNotNull(tableInfo); + } +} diff --git a/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/filter/ReplicateFilterTest.java b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/filter/ReplicateFilterTest.java new file mode 100644 index 00000000..1809b4a0 --- /dev/null +++ b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/filter/ReplicateFilterTest.java @@ -0,0 +1,700 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.filter; + + +import com.aliyun.polardbx.binlog.SpringContextBootStrap; +import com.aliyun.polardbx.rpl.taskmeta.ReplicateMeta; +import org.apache.commons.lang3.StringUtils; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DBMSAction; +import com.aliyun.polardbx.binlog.canal.binlog.dbms.DefaultRowChange; +import com.aliyun.polardbx.rpl.TestBase; + +/** + * @author shicai.xsc 2021/3/3 16:58 + * @since 5.0.0.0 + */ +public class ReplicateFilterTest extends TestBase { + + @Before + public void before() throws Exception { } + + @After + public void after() throws Exception { } + + @Test + public void test_Init_Succeed() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb("full_src_1, rpl"); + replicateMeta.setIgnoreDb("full_src_1, rpl"); + replicateMeta.setDoTable("full_src_1.t1, full_src_1.t2"); + replicateMeta.setIgnoreTable("full_src_1.t2, full_src_1.t3"); + replicateMeta.setWildDoTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setWildIgnoreTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setRewriteDb("(full_src_1, full_dst_1), (full_src_2, full_dst_2)"); + printChangeFilterSql(replicateMeta); + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + } + + @Test + public void no_Filter_Keep() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb(""); + replicateMeta.setIgnoreDb(""); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable(""); + replicateMeta.setWildDoTable(""); + replicateMeta.setWildIgnoreTable(""); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + rowChange.setSchema("dutf8"); + rowChange.setTable("tb_charset_gbk"); + Assert.assertFalse(filter.ignoreEvent(rowChange)); + + rowChange.setSchema("full_src_1"); + rowChange.setTable("t1"); + Assert.assertFalse(filter.ignoreEvent(rowChange)); + } + + //////////////// 以下测试用例为根据代码逻辑构造的单元测试,并对比了 Mysql 的行为 ////////////// + + /** + * 与 Mysql 行为一致。tbOk 返回 true。 + */ + @Test + public void hit_DoDb_Hit_Rewrite_Keep() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb("full_src_1, full_src_2, full_dst_2"); + replicateMeta.setIgnoreDb(""); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable(""); + replicateMeta.setWildDoTable(""); + replicateMeta.setWildIgnoreTable(""); + replicateMeta.setRewriteDb("(full_src_1, full_dst_1), (full_src_2, full_dst_2)"); + printChangeFilterSql(replicateMeta); + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + rowChange.setSchema("full_src_1"); + rowChange.setTable("t1"); + Assert.assertTrue(filter.ignoreEvent(rowChange)); + + rowChange.setSchema("full_dst_1"); + rowChange.setTable("t1"); + Assert.assertTrue(filter.ignoreEvent(rowChange)); + + rowChange.setSchema("full_src_2"); + rowChange.setTable("t1"); + Assert.assertFalse(filter.ignoreEvent(rowChange)); + + rowChange.setSchema("full_dst_2"); + rowChange.setTable("t1"); + Assert.assertFalse(filter.ignoreEvent(rowChange)); + } + + /** + * 与 Mysql 行为一致。tbOk 返回 true。 + */ + @Test + public void hit_DoTable_Hit_Rewrite_Keep() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb("full_src_1, rpl, full_dst_2"); + replicateMeta.setIgnoreDb("full_src_1, gbktest"); + replicateMeta.setDoTable("full_src_1.t1, full_src_1.t2, full_dst_1.t1, full_dst_2.t1"); + replicateMeta.setIgnoreTable("full_src_1.t2, full_src_1.t3"); + replicateMeta.setWildDoTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setWildIgnoreTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setRewriteDb("(full_src_1, full_dst_1), (full_src_2, full_dst_2)"); + printChangeFilterSql(replicateMeta); + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + rowChange.setSchema("full_src_1"); + rowChange.setTable("t1"); + Assert.assertTrue(filter.ignoreEvent(rowChange)); + + rowChange.setSchema("full_src_2"); + rowChange.setTable("t1"); + Assert.assertFalse(filter.ignoreEvent(rowChange)); + } + + /** + * 与 Mysql 行为一致。tbOk 返回 true。 + */ + @Test + public void hit_DoTable_Keep() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb("full_src_1, rpl"); + replicateMeta.setIgnoreDb("full_src_1, rpl"); + replicateMeta.setDoTable("full_src_1.t1, full_src_1.t2"); + replicateMeta.setIgnoreTable("full_src_1.t1, full_src_1.t2"); + replicateMeta.setWildDoTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setWildIgnoreTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + rowChange.setSchema("full_src_1"); + rowChange.setTable("t1"); + Assert.assertFalse(filter.ignoreEvent(rowChange)); + } + + /** + * 与 Mysql 行为一致。tbOk 返回 true。 + */ + @Test + public void miss_DoTable_Miss_IgnoreTable_Keep() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb(""); + replicateMeta.setIgnoreDb(""); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable("full_src_1.t1, full_src_1.t2"); + replicateMeta.setWildDoTable(""); + replicateMeta.setWildIgnoreTable(""); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + rowChange.setSchema("dutf8"); + rowChange.setTable("tb_charset_gbk"); + Assert.assertFalse(filter.ignoreEvent(rowChange)); + } + + /** + * 与 Mysql 行为一致。tbOk 返回 false。 + */ + @Test + public void miss_DoTable_Hit_IgnoreTable_Ignore() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb(""); + replicateMeta.setIgnoreDb(""); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable("full_src_1.t1, full_src_1.t2"); + replicateMeta.setWildDoTable(""); + replicateMeta.setWildIgnoreTable(""); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + rowChange.setSchema("full_src_1"); + rowChange.setTable("t1"); + Assert.assertTrue(filter.ignoreEvent(rowChange)); + } + + /** + * 与 Mysql 行为一致。tbOk 返回 true。 + */ + @Test + public void miss_DoTable_Miss_IgnoreTable_Hit_DoWildTable_Keep() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb(""); + replicateMeta.setIgnoreDb(""); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable(""); + replicateMeta.setWildDoTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setWildIgnoreTable(""); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + rowChange.setSchema("dutf8"); + rowChange.setTable("tb_charset_gbk"); + Assert.assertFalse(filter.ignoreEvent(rowChange)); + } + + /** + * 与 Mysql 行为一致。tbOk 返回 false。 + */ + @Test + public void miss_DoTable_Miss_IgnoreTable_Miss_DoWildTable_Hit_IgnoreWildTable_Ignore() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb(""); + replicateMeta.setIgnoreDb(""); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable(""); + replicateMeta.setWildDoTable(""); + replicateMeta.setWildIgnoreTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + rowChange.setSchema("dutf8"); + rowChange.setTable("tb_charset_gbk"); + Assert.assertTrue(filter.ignoreEvent(rowChange)); + } + + /** + * 与 Mysql 行为一致。tbOk 返回 true。dbOk 返回 true。 + */ + @Test + public void miss_DoTable_Miss_IgnoreTable_Hit_DoDb_Keep() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb("full_src_1, dutf8"); + replicateMeta.setIgnoreDb(""); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable("full_src_1.t1, full_src_1.t2"); + replicateMeta.setWildDoTable(""); + replicateMeta.setWildIgnoreTable(""); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + rowChange.setSchema("dutf8"); + rowChange.setTable("tb_charset_gbk"); + Assert.assertFalse(filter.ignoreEvent(rowChange)); + } + + /** + * 与 Mysql 行为一致。tbOk 返回 true。dbOk 返回 false。 + */ + @Test + public void miss_DoTable_Miss_IgnoreTable_Miss_DoDb_Ignore() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb("full_src_1, full_src_2"); + replicateMeta.setIgnoreDb(""); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable("full_src_1.t1, full_src_1.t2"); + replicateMeta.setWildDoTable(""); + replicateMeta.setWildIgnoreTable(""); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + rowChange.setSchema("dutf8"); + rowChange.setTable("tb_charset_gbk"); + Assert.assertTrue(filter.ignoreEvent(rowChange)); + } + + /** + * 与 Mysql 行为一致。tbOk 返回 true。dbOk 返回 false。 + */ + @Test + public void miss_DoTable_Miss_IgnoreTable_Hit_IgnoreDb_Ignore() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb(""); + replicateMeta.setIgnoreDb("full_src_1, dutf8"); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable("full_src_1.t1, full_src_1.t2"); + replicateMeta.setWildDoTable(""); + replicateMeta.setWildIgnoreTable(""); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + rowChange.setSchema("dutf8"); + rowChange.setTable("tb_charset_gbk"); + Assert.assertTrue(filter.ignoreEvent(rowChange)); + } + + /** + * 与 Mysql 行为一致。tbOk 返回 true。dbOk 返回 true。 + */ + @Test + public void miss_DoTable_Miss_IgnoreTable_Miss_IgnoreDb_Keep() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb(""); + replicateMeta.setIgnoreDb("full_src_1, full_src_2"); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable("full_src_1.t1, full_src_1.t2"); + replicateMeta.setWildDoTable(""); + replicateMeta.setWildIgnoreTable(""); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + rowChange.setSchema("dutf8"); + rowChange.setTable("tb_charset_gbk"); + Assert.assertFalse(filter.ignoreEvent(rowChange)); + } + + /** + * 与 Mysql 行为一致。tbOk 返回 true。dbOk 返回 true。 + */ + @Test + public void miss_DoTable_Miss_IgnoreTable_Hit_DoWildTable_Hit_DoDb_Keep() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb("full_src_1, dutf8"); + replicateMeta.setIgnoreDb(""); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable(""); + replicateMeta.setWildDoTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setWildIgnoreTable(""); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + rowChange.setSchema("dutf8"); + rowChange.setTable("tb_charset_gbk"); + Assert.assertFalse(filter.ignoreEvent(rowChange)); + } + + /** + * 与 Mysql 行为一致。tbOk 返回 true。dbOk 返回 false。 + */ + @Test + public void miss_DoTable_Miss_IgnoreTable_Hit_DoWildTable_Miss_DoDb_Ignore() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb("full_src_1, full_src_2"); + replicateMeta.setIgnoreDb(""); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable(""); + replicateMeta.setWildDoTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setWildIgnoreTable(""); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + rowChange.setSchema("dutf8"); + rowChange.setTable("tb_charset_gbk"); + Assert.assertTrue(filter.ignoreEvent(rowChange)); + } + + /** + * 与 Mysql 行为一致。tbOk 返回 true。dbOk 返回 false。 + */ + @Test + public void miss_DoTable_Miss_IgnoreTable_Hit_DoWildTable_Hit_IgnoreDb_Ignore() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb(""); + replicateMeta.setIgnoreDb("full_src_1, dutf8"); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable(""); + replicateMeta.setWildDoTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setWildIgnoreTable(""); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + rowChange.setSchema("dutf8"); + rowChange.setTable("tb_charset_gbk"); + Assert.assertTrue(filter.ignoreEvent(rowChange)); + } + + /** + * 与 Mysql 行为一致。tbOk 返回 true。dbOk 返回 true。 + */ + @Test + public void miss_DoTable_Miss_IgnoreTable_Hit_DoWildTable_Miss_IgnoreDb_Keep() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb(""); + replicateMeta.setIgnoreDb("full_src_1, full_src_2"); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable(""); + replicateMeta.setWildDoTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setWildIgnoreTable(""); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + rowChange.setSchema("dutf8"); + rowChange.setTable("tb_charset_gbk"); + Assert.assertFalse(filter.ignoreEvent(rowChange)); + } + + //////////////// 以下测试用例为单元测试外的补充测试用例,并对比了 Mysql 的行为 ////////////// + + /** + * 与 Mysql 行为一致。 + */ + @Test + public void no_DoTable_Hit_DoDb_Hit_WildDoTable_Keep() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb("full_src_1, rpl, dutf8"); + replicateMeta.setIgnoreDb("full_src_1, rpl, dutf8"); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable("full_src_1.t1, full_src_1.t2"); + replicateMeta.setWildDoTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setWildIgnoreTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + rowChange.setSchema("dutf8"); + rowChange.setTable("tb_charset_gbk"); + Assert.assertFalse(filter.ignoreEvent(rowChange)); + } + + /** + * 与 Mysql 行为一致。 + */ + @Test + public void no_DoTable_No_DoDb_Miss_IgnoreTable_Miss_IgnoreDb_Hit_WildDoTable_Keep() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb(""); + replicateMeta.setIgnoreDb("full_src_1, rpl"); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable("full_src_1.t1, full_src_1.t2"); + replicateMeta.setWildDoTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setWildIgnoreTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + rowChange.setSchema("dutf8"); + rowChange.setTable("tb_charset_gbk"); + Assert.assertFalse(filter.ignoreEvent(rowChange)); + } + + /** + * 与 Mysql 行为一致。 + */ + @Test + public void miss_DoTable_Miss_IgnoreTable_Ignore() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb("full_src_1, rpl"); + replicateMeta.setIgnoreDb("full_src_1, rpl"); + replicateMeta.setDoTable("full_src_1.t1, full_src_1.t2"); + replicateMeta.setIgnoreTable("full_src_1.t1, full_src_1.t2"); + replicateMeta.setWildDoTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setWildIgnoreTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + // Hit Replicate_Do_Table + rowChange.setSchema("full_src_1"); + rowChange.setTable("t3"); + Assert.assertTrue(filter.ignoreEvent(rowChange)); + } + + /** + * 与 Mysql 行为一致。 + */ + @Test + public void no_DoTable_Hit_DoDb_Miss_WildDoTable_Ignore() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb("full_src_1, rpl, dutf8"); + replicateMeta.setIgnoreDb("full_src_1, rpl, dutf8"); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable("full_src_1.t1, full_src_1.t2"); + replicateMeta.setWildDoTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setWildIgnoreTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + rowChange.setSchema("full_src_1"); + rowChange.setTable("t1"); + Assert.assertTrue(filter.ignoreEvent(rowChange)); + } + + /** + * 与 Mysql 行为一致。 + */ + @Test + public void no_DoTable_Miss_DoDb_Hit_WildDoTable_Ignore() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb("full_src_1, rpl"); + replicateMeta.setIgnoreDb("full_src_1, rpl"); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable("full_src_1.t1, full_src_1.t2"); + replicateMeta.setWildDoTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setWildIgnoreTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + rowChange.setSchema("dutf8"); + rowChange.setTable("tb_charset_gbk"); + Assert.assertTrue(filter.ignoreEvent(rowChange)); + } + + /** + * 与 Mysql 行为一致。 + */ + @Test + public void no_DoTable_No_DoDb_Hit_IgnoreDb_Hit_WildDoTable_Ignore() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb(""); + replicateMeta.setIgnoreDb("full_src_1, dutf8"); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable("full_src_1.t1, full_src_1.t2"); + replicateMeta.setWildDoTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setWildIgnoreTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + // Hit Replicate_Do_Table + rowChange.setSchema("dutf8"); + rowChange.setTable("tb_charset_gbk"); + Assert.assertTrue(filter.ignoreEvent(rowChange)); + } + + /** + * 与 Mysql 行为一致。 + */ + @Test + public void no_DoTable_No_DoDb_Miss_IgnoreTable_Miss_IgnoreDb_Miss_WildDoTable_Ignore() { + ReplicateMeta replicateMeta = new ReplicateMeta(); + replicateMeta.setDoDb(""); + replicateMeta.setIgnoreDb("dutf8"); + replicateMeta.setDoTable(""); + replicateMeta.setIgnoreTable("full_src_1.t2"); + replicateMeta.setWildDoTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setWildIgnoreTable("d%.tb\\_charset%, d%.col\\_charset%"); + replicateMeta.setRewriteDb(""); + printChangeFilterSql(replicateMeta); + + // init + ReplicateFilter filter = new ReplicateFilter(replicateMeta); + Assert.assertTrue(filter.init()); + + DefaultRowChange rowChange = new DefaultRowChange(); + rowChange.setAction(DBMSAction.INSERT); + + // Hit Replicate_Do_Table + rowChange.setSchema("full_src_1"); + rowChange.setTable("t1"); + Assert.assertTrue(filter.ignoreEvent(rowChange)); + } +} diff --git a/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/CharsetTest.java b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/CharsetTest.java new file mode 100644 index 00000000..d1c0840f --- /dev/null +++ b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/CharsetTest.java @@ -0,0 +1,213 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.task; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import com.aliyun.polardbx.rpl.TestBase; + +/** + * @author shicai.xsc 2021/4/21 16:15 + * @since 5.0.0.0 + */ +public class CharsetTest extends TestBase { + + private final String NONE_CHARSET = "none"; + private final String LATIN1 = "latin1"; + private final String GBK = "gbk"; + private final String UTF8 = "utf8"; + private final String UTF8MB4 = "utf8mb4"; + + private final String ID = "id"; + private final String VALUE = "value"; + + private List allCharsets = Arrays.asList(NONE_CHARSET, LATIN1, GBK, UTF8, UTF8MB4); + private List chineseCharsets = Arrays.asList(GBK, UTF8, UTF8MB4); + private List emojiCharsets = Arrays.asList(UTF8MB4); + + private final List english = Arrays.asList(1, "english"); + private final List chinese = Arrays.asList(2, "中文"); + private final List emoji = Arrays.asList(3, "中文😀"); + + // 为了加快速度,第一次建库建表之后,就不用再创建 + private boolean doDddl = true; + + @Before + public void before() throws Exception { + channel = "charsetTest"; + super.before(); + } + + @After + public void after() throws Exception { + super.after(); + } + + @Test + public void charset_Test() throws Exception { + runnerThread.start(); + wait(WAIT_TASK_SECOND); + List dbs = createDbs(); + + for (String db : dbs) { + List tables = createTables(db); + + // wait all DDL finish + List dstTables = new ArrayList<>(); + while (dstTables.size() < tables.size()) { + dstTables = execQuery(dstConn, "show tables in " + db, 1); + wait(1); + } + + for (String table : tables) { + executeDmlAndCheck(db, table); + } + } + } + + /** + * 创建数据库 charsetTest_latin1,charsetTest_gbk,charsetTest_utf8,charsetTest_utf8mb4 + */ + private List createDbs() throws Exception { + List dbs = new ArrayList<>(); + for (int i = 1; i < allCharsets.size(); i++) { + String db = "charsetTest_" + allCharsets.get(i); + if (doDddl) { + execUpdate(srcConn, "drop database if exists " + db, null); + + wait(WAIT_DDL_SECOND); + List dstDbs = execQuery(dstConn, "show databases", 1); + Assert.assertFalse(dstDbs.stream().anyMatch(db::equalsIgnoreCase)); + + execUpdate(srcConn, + String.format("create database if not exists %s DEFAULT CHARSET=%s", db, allCharsets.get(i)), + null); + wait(WAIT_DDL_SECOND); + dstDbs = execQuery(dstConn, "show databases", 1); + Assert.assertTrue(dstDbs.stream().anyMatch(db::equalsIgnoreCase)); + } + dbs.add(db); + } + + return dbs; + } + + /** + * @param db 创建以下表 | tb_gbk_col_gbk | | tb_gbk_col_latin1 | | tb_gbk_col_none | + * | tb_gbk_col_utf8 | | tb_gbk_col_utf8mb4 | | tb_latin1_col_gbk | | + * tb_latin1_col_latin1 | | tb_latin1_col_none | | tb_latin1_col_utf8 | | + * tb_latin1_col_utf8mb4 | | tb_none_col_gbk | | tb_none_col_latin1 | | + * tb_none_col_none | | tb_none_col_utf8 | | tb_none_col_utf8mb4 | | + * tb_utf8_col_gbk | | tb_utf8_col_latin1 | | tb_utf8_col_none | | + * tb_utf8_col_utf8 | | tb_utf8_col_utf8mb4 | | tb_utf8mb4_col_gbk | | + * tb_utf8mb4_col_latin1 | | tb_utf8mb4_col_none | | tb_utf8mb4_col_utf8 | | + * tb_utf8mb4_col_utf8mb4 + */ + private List createTables(String db) { + Assert.assertTrue(execUpdate(srcConn, "use " + db, null)); + + List tables = new ArrayList<>(); + for (String tb : allCharsets) { + for (String col : allCharsets) { + String tbName = String.format("tb_%s_col_%s", tb, col); + String colCharset = NONE_CHARSET.equals(col) ? "" : "charset " + col; + String tbCharset = NONE_CHARSET.equals(tb) ? "" : "default charset=" + tb; + String createSql = String.format( + "CREATE TABLE IF NOT EXISTS `%s`(`id` int(11), `value` mediumtext %s, PRIMARY KEY (`id`)) ENGINE=InnoDB %s", + tbName, + colCharset, + tbCharset); + if (doDddl) { + Assert.assertTrue(execUpdate(srcConn, createSql, null)); + } + tables.add(tbName); + } + } + + return tables; + } + + private void executeDmlAndCheck(String db, String table) throws Exception { + Assert.assertTrue(execUpdate(srcConn, "use " + db, null)); + Assert.assertTrue(execUpdate(srcConn, String.format("delete from %s where id >= 0", table), null)); + + String dbCharset = db.split("_")[1]; + String tbCharset = table.split("_")[1]; + String colCharset = table.split("_")[3]; + + String sql = String.format("insert into %s values(?, ?);", table); + System.out.println("sql: " + sql); + + int recordCount = 1; + Assert.assertTrue(execUpdate(srcConn, sql, english)); + + boolean canWriteChinese = chineseCharsets.contains(colCharset); + canWriteChinese |= colCharset.equals(NONE_CHARSET) && chineseCharsets.contains(tbCharset); + canWriteChinese |= colCharset.equals(NONE_CHARSET) && tbCharset.equals(NONE_CHARSET) + && chineseCharsets.contains(dbCharset); + if (canWriteChinese) { + Assert.assertTrue(execUpdate(srcConn, sql, chinese)); + recordCount += 1; + } + + boolean canWriteEmoji = emojiCharsets.contains(colCharset); + canWriteEmoji |= colCharset.equals(NONE_CHARSET) && emojiCharsets.contains(tbCharset); + canWriteEmoji |= colCharset.equals(NONE_CHARSET) && tbCharset.equals(NONE_CHARSET) + && emojiCharsets.contains(dbCharset); + if (canWriteEmoji) { + Assert.assertTrue(execUpdate(srcConn, sql, emoji)); + recordCount += 1; + } + + checkDmlResult(db, table, recordCount); + } + + private void checkDmlResult(String db, String table, int recordCount) throws Exception { + wait(1); + + String sql = String.format("select * from %s.%s order by id", db, table); + List fields = Arrays.asList(ID, VALUE); + List> srcRes = execQuery(srcConn, sql, fields); + List> dstRes = execQuery(srcConn, sql, fields); + List> mysqlRes = execQuery(srcConn, sql, fields); + + Assert.assertEquals(srcRes.size(), recordCount); + Assert.assertEquals(dstRes.size(), recordCount); + Assert.assertEquals(mysqlRes.size(), recordCount); + + for (int i = 0; i < srcRes.size(); i++) { + Map srcRecord = srcRes.get(i); + Map dstRecord = dstRes.get(i); + Map mysqlRecord = mysqlRes.get(i); + Assert.assertEquals(srcRecord.get(VALUE), dstRecord.get(VALUE)); + Assert.assertEquals(srcRecord.get(VALUE), mysqlRecord.get(VALUE)); + } + + System.out.println("************************************************"); + System.out.println(String.format("%s.%s checked, record count: %d", db, table, recordCount)); + } +} diff --git a/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/CharsetWriteTest.java b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/CharsetWriteTest.java new file mode 100644 index 00000000..c10fa00e --- /dev/null +++ b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/CharsetWriteTest.java @@ -0,0 +1,245 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.task; + +import com.aliyun.polardbx.rpl.TestBase; +import com.aliyun.polardbx.rpl.common.DataSourceUtil; +import com.aliyun.polardbx.rpl.common.NamedThreadFactory; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.modules.junit4.PowerMockRunner; + +import javax.sql.DataSource; +import java.io.Serializable; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Types; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** + * @author shicai.xsc 2021/1/13 14:47 + * @since 5.0.0.0 + */ +@RunWith(PowerMockRunner.class) +@PowerMockIgnore("javax.management.*") +@Slf4j +public class CharsetWriteTest extends TestBase { + + @Before + public void before() throws Exception { + initConnection(); + } + + @After + public void after() throws Exception { } + + + + @Test + public void insertData_Test2() throws Exception { + long startTime = System.currentTimeMillis(); + ExecutorService executorService = Executors.newFixedThreadPool(8, new NamedThreadFactory("test")); + List tables = Arrays.asList("aaaaa"); + for (String table : tables) { + executorService.submit(() -> { + int i = 1500000; + for (; i < 100000000; i++) { + StringBuilder sb = new StringBuilder(); + + String values = "(%d, '%d', '%d'),"; + int j = 0; + for (; j < 1000; j++) { + sb.append(String.format(values, i + j, i + j, i + j)); + } + i += j + 1; + + String sql = String.format("insert into %s values %s;", table, sb); + sql = sql.substring(0, sql.length() - 2); + executeSql(srcDs, sql); + + long stopTime = System.currentTimeMillis(); + System.out.println("cost time: " + (stopTime - startTime) / 1000); + System.out.println("count: " + i); + } + }); + } + + Thread.sleep(1000000); + } + + @Test + public void insertData_Test() throws Exception { + long startTime = System.currentTimeMillis(); + ExecutorService executorService = Executors.newFixedThreadPool(8, new NamedThreadFactory("test")); + List tables = Arrays + .asList("bbb"); + for (String table : tables) { + executorService.submit(() -> { + int i = 300000; + for (; i < 100000000; i++) { + StringBuilder sb = new StringBuilder(); + + String values = "(%d, '%d', '%d'),"; + int j = 0; + for (; j < 1000; j++) { + sb.append(String.format(values, i + j, i + j, i + j, i + j)); + } + i += j + 1; + + String sql = String.format("insert into %s values %s;", table, sb); + sql = sql.substring(0, sql.length() - 2); + executeSql(srcDs, sql); + + long stopTime = System.currentTimeMillis(); + System.out.println("cost time: " + (stopTime - startTime) / 1000); + System.out.println("count: " + i); + } + }); + } + + Thread.sleep(1000000); + } + + + private void executeSql(DataSource dataSource, String sql) { + try { + Connection conn = dataSource.getConnection(); + PreparedStatement stmt = conn.prepareStatement(sql); + stmt.executeUpdate(); + DataSourceUtil.closeQuery(null, stmt, conn); + } catch (Throwable e) { + System.out.println(e.getMessage()); + } + } + + + @Test + public void test() throws Exception { + String s = "中文"; + byte[] gbkBytes = s.getBytes("GBK"); + byte[] utf8Bytes = s.getBytes("UTF-8"); + + byte[] latin1Bytes = s.getBytes("ISO8859_1"); + System.out.println("latin1 encode, decode: "); + System.out.println(new String(utf8Bytes, "UTF-8")); + + // 目标库 col_charset_gbk_utf8,编码 utf8mb4 + // 目标表 a (id int, value mediumtext) + + String sql = "INSERT INTO dgbk.col_charset_gbk_utf8 (id, value) VALUES (?, ?)"; + List params = new ArrayList<>(); + + // 1. 直接插入 gbkBytes + // 报错 java.sql.SQLException: Incorrect string value: '\xD6\xD0\xCE\xC4' for + // column 'value' at row 1 + params.clear(); + params.add(1); + params.add(gbkBytes); + execUpdate(dstDs, sql, params); + + // 2. 直接插入 utf8Bytes + // 执行成功,通过 mysql 控制台查询 (建立连接后需设置 set names utf8mb4;),结果 value 为 "中文",说明插入正确 + params.clear(); + params.add(2); + params.add(utf8Bytes); + execUpdate(dstDs, sql, params); + + // 3. 插入 gbkBytes decode String + // 执行成功,通过 mysql 控制台查询 (建立连接后需设置 set names utf8mb4;),结果 value 为 "中文",说明插入正确 + params.clear(); + params.add(3); + params.add(new String(gbkBytes, "GBK")); + execUpdate(dstDs, sql, params); + + // 4. 插入 utf8Bytes decode String + // 执行成功,通过 mysql 控制台查询 (建立连接后需设置 set names utf8mb4;),结果 value 为 "中文",说明插入正确 + params.clear(); + params.add(4); + params.add(new String(utf8Bytes, "UTF-8")); + execUpdate(dstDs, sql, params); + } + + @Test + public void testMysql() throws Exception { + String tableName = "checkout_order"; + String[] columnNames = {"id", "checkout_order_no", "payer_id", "gmt_create", "gmt_modified", "version"}; + String[] placeHolders = new String[columnNames.length]; + for (int i = 0; i < columnNames.length; i++) { + placeHolders[i] = "?"; + } + + String sql = String.format("insert into `%s` (%s) values(%s)", + tableName, + StringUtils.join(columnNames, ","), + StringUtils.join(placeHolders, ",")); + + PreparedStatement ps = null; + try { + ps = srcDs.getConnection().prepareStatement(sql); + ps.setObject(1, "1", Types.BIGINT); + ps.setObject(2, "1", Types.VARCHAR); + ps.setObject(3, "1", Types.BIGINT); + ps.setObject(4, "2021-03-12 10:59:33", Types.TIMESTAMP); + ps.setObject(5, "2021-03-12 10:59:33", Types.TIMESTAMP); + ps.setObject(6, "1"); + ps.executeUpdate(); + } catch (Throwable e) { + throw e; + } finally { + if (ps != null) { + ps.close(); + } + } + } + + @Test + public void testMysql2() throws Exception { + String tableName = "checkout_order"; + PreparedStatement ps = srcDs.getConnection().prepareStatement("show full columns from ?"); + ps.setString(1, tableName); + ResultSet rs = ps.executeQuery(); + while (rs.next()) { + String columnCollation = rs.getString("Collation"); + System.out.println("111111111: " + columnCollation); + } + } + + @Test + public void testMysql3() throws Exception { + PreparedStatement ps = srcDs.getConnection() + .prepareStatement("select * from INFORMATION_SCHEMA.COLUMNS where TABLE_SCHEMA=? and TABLE_NAME=?"); + ps.setString(1, "rpl"); + ps.setString(2, "checkout_order"); + ResultSet rs = ps.executeQuery(); + + while (rs.next()) { + String columnCollation = rs.getString("COLLATION_NAME"); + System.out.println(columnCollation); + } + } +} diff --git a/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/DdlE2ETest.java b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/DdlE2ETest.java new file mode 100644 index 00000000..5ca5dd27 --- /dev/null +++ b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/DdlE2ETest.java @@ -0,0 +1,1619 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.task; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import com.aliyun.polardbx.rpl.TestBase; +import com.aliyun.polardbx.rpl.common.RplConstants; + +/** + * @author shicai.xsc 2021/4/16 00:06 + * @since 5.0.0.0 + */ +public class DdlE2ETest extends TestBase { + + private final static String DB_1 = "db1"; + private final static String DB_2 = "db2"; + private final static String DB_3 = "db3"; + + @Before + public void before() throws Exception { + channel = "ddlTest"; + super.before(); + List dbs = Arrays.asList(DB_1, DB_2, DB_3); + for (String db : dbs) { + execUpdate(srcConn, "drop database if exists " + db, null); + execUpdate(dstConn, "drop database if exists " + db, null); + execUpdate(mysqlDstConn, "drop database if exists " + db, null); + } + wait(WAIT_DDL_SECOND); + } + + @After + public void after() throws Exception { + super.after(); + } + + /** + * 不跨库,没有过滤条件 + */ + @Test + public void basic() throws Exception { + runnerThread.start(); + wait(WAIT_TASK_SECOND); + + List res = null; + + // create database + execUpdate(srcConn, "create database " + DB_1, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + + // use db_1 + execUpdate(srcConn, "use " + DB_1, null); + execUpdate(dstConn, "use " + DB_1, null); + execUpdate(mysqlDstConn, "use " + DB_1, null); + + // create table + execUpdate(srcConn, "create table t1_1(id int, f1 int, f2 int)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertTrue(res.contains("t1_1")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertTrue(res.contains("t1_1")); + + // rename table + execUpdate(srcConn, "rename table t1_1 to t1;", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + Assert.assertTrue(res.contains("t1")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + Assert.assertTrue(res.contains("t1")); + + // alter table add column + execUpdate(srcConn, "alter table t1 add column f3 int;", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "desc t1", 1); + Assert.assertTrue(res.contains("f3")); + res = execQuery(mysqlDstConn, "desc t1", 1); + Assert.assertTrue(res.contains("f3")); + + // alter table drop column + execUpdate(srcConn, "alter table t1 drop column f3", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "desc t1", 1); + Assert.assertFalse(res.contains("f3")); + res = execQuery(mysqlDstConn, "desc t1", 1); + Assert.assertFalse(res.contains("f3")); + + // create index + execUpdate(srcConn, "create index idx_f1 on t1(f1)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f1`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f1`")); + + // alter add index + execUpdate(srcConn, "alter table t1 add index idx_f2(f2)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f2`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f2`")); + + // drop index + execUpdate(srcConn, "drop index idx_f1 on t1", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f1`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f1`")); + + // alter drop index + execUpdate(srcConn, "alter table t1 drop index idx_f2", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f2`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f2`")); + + // truncate table + execUpdate(srcConn, "insert into t1 values(1,2,3)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "select * from t1", 1); + Assert.assertTrue(res.size() > 0); + res = execQuery(mysqlDstConn, "select * from t1", 1); + Assert.assertTrue(res.size() > 0); + + execUpdate(srcConn, "truncate table t1", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "select * from t1", 1); + Assert.assertTrue(res.size() == 0); + res = execQuery(mysqlDstConn, "select * from t1", 1); + Assert.assertTrue(res.size() == 0); + + // drop table + execUpdate(srcConn, "drop table t1", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1")); + + // drop database + execUpdate(srcConn, "drop database " + DB_1, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + } + + /** + * 不跨库,有 doDb 过滤 + */ + @Test + public void doDb() throws Exception { + Map filterParams = new HashMap<>(); + filterParams.put(RplConstants.REPLICATE_DO_DB, String.format("(%s)", DB_1)); + filterParams.put(RplConstants.REPLICATE_IGNORE_DB, ""); + filterParams.put(RplConstants.REPLICATE_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_REWRITE_DB, ""); + setupService(channel, initBinlogPosition, filterParams); + + // setup compare replica + setupMysqlReplica(mysqlDstConn, initBinlogPosition); + + runnerThread.start(); + wait(WAIT_TASK_SECOND); + + List res = null; + + // create database + execUpdate(srcConn, "create database " + DB_1, null); + execUpdate(srcConn, "create database " + DB_2, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + Assert.assertFalse(res.contains(DB_2)); + res = execQuery(dstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + Assert.assertFalse(res.contains(DB_2)); + + // use db_1 + execUpdate(srcConn, "use " + DB_1, null); + execUpdate(dstConn, "use " + DB_1, null); + execUpdate(mysqlDstConn, "use " + DB_1, null); + + // create table + execUpdate(srcConn, "create table t1_1(id int, f1 int, f2 int)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertTrue(res.contains("t1_1")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertTrue(res.contains("t1_1")); + + // rename table + execUpdate(srcConn, "rename table t1_1 to t1;", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + Assert.assertTrue(res.contains("t1")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + Assert.assertTrue(res.contains("t1")); + + // alter table add column + execUpdate(srcConn, "alter table t1 add column f3 int;", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "desc t1", 1); + Assert.assertTrue(res.contains("f3")); + res = execQuery(mysqlDstConn, "desc t1", 1); + Assert.assertTrue(res.contains("f3")); + + // alter table drop column + execUpdate(srcConn, "alter table t1 drop column f3", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "desc t1", 1); + Assert.assertFalse(res.contains("f3")); + res = execQuery(mysqlDstConn, "desc t1", 1); + Assert.assertFalse(res.contains("f3")); + + // create index + execUpdate(srcConn, "create index idx_f1 on t1(f1)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f1`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f1`")); + + // alter add index + execUpdate(srcConn, "alter table t1 add index idx_f2(f2)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f2`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f2`")); + + // drop index + execUpdate(srcConn, "drop index idx_f1 on t1", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f1`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f1`")); + + // alter drop index + execUpdate(srcConn, "alter table t1 drop index idx_f2", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f2`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f2`")); + + // truncate table + execUpdate(srcConn, "insert into t1 values(1,2,3)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "select * from t1", 1); + Assert.assertTrue(res.size() > 0); + res = execQuery(mysqlDstConn, "select * from t1", 1); + Assert.assertTrue(res.size() > 0); + + execUpdate(srcConn, "truncate table t1", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "select * from t1", 1); + Assert.assertTrue(res.size() == 0); + res = execQuery(mysqlDstConn, "select * from t1", 1); + Assert.assertTrue(res.size() == 0); + + // drop table + execUpdate(srcConn, "drop table t1", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1")); + + // drop database + execUpdate(dstConn, "create database " + DB_2, null); + execUpdate(mysqlDstConn, "create database " + DB_2, null); + + execUpdate(srcConn, "drop database " + DB_1, null); + execUpdate(srcConn, "drop database " + DB_2, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertTrue(res.contains(DB_2)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertTrue(res.contains(DB_2)); + } + + /** + * 不跨库,有 ignoreDb 过滤 + */ + @Test + public void ignoreDb() throws Exception { + Map filterParams = new HashMap<>(); + filterParams.put(RplConstants.REPLICATE_DO_DB, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_DB, String.format("(%s)", DB_2)); + filterParams.put(RplConstants.REPLICATE_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_REWRITE_DB, ""); + setupService(channel, initBinlogPosition, filterParams); + + // setup compare replica + setupMysqlReplica(mysqlDstConn, initBinlogPosition); + + runnerThread.start(); + wait(WAIT_TASK_SECOND); + + List res = null; + + // create database + execUpdate(srcConn, "create database " + DB_1, null); + execUpdate(srcConn, "create database " + DB_2, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + Assert.assertFalse(res.contains(DB_2)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + Assert.assertFalse(res.contains(DB_2)); + + // drop database + execUpdate(dstConn, "create database " + DB_2, null); + execUpdate(mysqlDstConn, "create database " + DB_2, null); + + execUpdate(srcConn, "drop database " + DB_1, null); + execUpdate(srcConn, "drop database " + DB_2, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertTrue(res.contains(DB_2)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertTrue(res.contains(DB_2)); + } + + /** + * 不跨库,有 wildDoTables 过滤,不过滤 create database DB_1 + */ + @Test + public void wildDoTables_1() throws Exception { + Map filterParams = new HashMap<>(); + filterParams.put(RplConstants.REPLICATE_DO_DB, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_DB, ""); + filterParams.put(RplConstants.REPLICATE_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_DO_TABLE, String.format("('%s.%%', '%s.%%')", DB_3, DB_1)); + filterParams.put(RplConstants.REPLICATE_WILD_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_REWRITE_DB, ""); + setupService(channel, initBinlogPosition, filterParams); + + // setup compare replica + setupMysqlReplica(mysqlDstConn, initBinlogPosition); + + runnerThread.start(); + wait(WAIT_TASK_SECOND); + + List res = null; + + // create database + execUpdate(srcConn, "create database " + DB_1, null); + execUpdate(srcConn, "create database " + DB_2, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + Assert.assertFalse(res.contains(DB_2)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + Assert.assertFalse(res.contains(DB_2)); + + // drop database + execUpdate(dstConn, "create database " + DB_2, null); + execUpdate(mysqlDstConn, "create database " + DB_2, null); + + execUpdate(srcConn, "drop database " + DB_1, null); + execUpdate(srcConn, "drop database " + DB_2, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertTrue(res.contains(DB_2)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertTrue(res.contains(DB_2)); + } + + /** + * 不跨库,有 wildDoTables 过滤,过滤掉 create database DB_1 + */ + @Test + public void wildDoTables_2() throws Exception { + Map filterParams = new HashMap<>(); + filterParams.put(RplConstants.REPLICATE_DO_DB, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_DB, ""); + filterParams.put(RplConstants.REPLICATE_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_DO_TABLE, String.format("('%s.t1%%', '%s.t1%%')", DB_3, DB_1)); + filterParams.put(RplConstants.REPLICATE_WILD_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_REWRITE_DB, ""); + setupService(channel, initBinlogPosition, filterParams); + + // setup compare replica + setupMysqlReplica(mysqlDstConn, initBinlogPosition); + + runnerThread.start(); + wait(WAIT_TASK_SECOND); + + List res = null; + + // create database + execUpdate(srcConn, "create database " + DB_1, null); + execUpdate(srcConn, "create database " + DB_2, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertFalse(res.contains(DB_2)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertFalse(res.contains(DB_2)); + + // create database in dst manually + execUpdate(dstConn, "create database " + DB_1, null); + execUpdate(mysqlDstConn, "create database " + DB_1, null); + wait(WAIT_DDL_SECOND); + + // use db + execUpdate(srcConn, "use " + DB_1, null); + execUpdate(dstConn, "use " + DB_1, null); + execUpdate(mysqlDstConn, "use " + DB_1, null); + + // create table + execUpdate(srcConn, "create table t1_1(id int, f1 int, f2 int)", null); + execUpdate(srcConn, "create table t2_1(id int, f1 int, f2 int)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertTrue(res.contains("t1_1")); + Assert.assertFalse(res.contains("t2_1")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertTrue(res.contains("t1_1")); + Assert.assertFalse(res.contains("t2_1")); + + // rename table + execUpdate(srcConn, "rename table t1_1 to t1;", null); + execUpdate(srcConn, "rename table t2_1 to t2;", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + Assert.assertTrue(res.contains("t1")); + Assert.assertFalse(res.contains("t2")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + Assert.assertTrue(res.contains("t1")); + Assert.assertFalse(res.contains("t2")); + + // alter table add column + execUpdate(srcConn, "alter table t1 add column f3 int;", null); + execUpdate(srcConn, "alter table t2 add column f3 int;", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "desc t1", 1); + Assert.assertTrue(res.contains("f3")); + res = execQuery(mysqlDstConn, "desc t1", 1); + Assert.assertTrue(res.contains("f3")); + + // alter table drop column + execUpdate(srcConn, "alter table t1 drop column f3", null); + execUpdate(srcConn, "alter table t2 drop column f3", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "desc t1", 1); + Assert.assertFalse(res.contains("f3")); + res = execQuery(mysqlDstConn, "desc t1", 1); + Assert.assertFalse(res.contains("f3")); + + // create index + execUpdate(srcConn, "create index idx_f1 on t1(f1)", null); + execUpdate(srcConn, "create index idx_f1 on t2(f1)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f1`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f1`")); + + // alter add index + execUpdate(srcConn, "alter table t1 add index idx_f2(f2)", null); + execUpdate(srcConn, "alter table t2 add index idx_f2(f2)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f2`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f2`")); + + // drop index + execUpdate(srcConn, "drop index idx_f1 on t1", null); + execUpdate(srcConn, "drop index idx_f1 on t2", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f1`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f1`")); + + // alter drop index + execUpdate(srcConn, "alter table t1 drop index idx_f2", null); + execUpdate(srcConn, "alter table t2 drop index idx_f2", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f2`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f2`")); + + // truncate table + execUpdate(srcConn, "insert into t1 values(1,2,3)", null); + execUpdate(srcConn, "insert into t2 values(1,2,3)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "select * from t1", 1); + Assert.assertTrue(res.size() > 0); + res = execQuery(mysqlDstConn, "select * from t1", 1); + Assert.assertTrue(res.size() > 0); + + execUpdate(srcConn, "truncate table t1", null); + execUpdate(srcConn, "truncate table t2", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "select * from t1", 1); + Assert.assertTrue(res.size() == 0); + res = execQuery(mysqlDstConn, "select * from t1", 1); + Assert.assertTrue(res.size() == 0); + + // drop table + execUpdate(srcConn, "drop table t1", null); + execUpdate(srcConn, "drop table t2", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1")); + + // drop database + execUpdate(srcConn, "drop database " + DB_1, null); + execUpdate(srcConn, "drop database " + DB_2, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + Assert.assertFalse(res.contains(DB_2)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + Assert.assertFalse(res.contains(DB_2)); + } + + /** + * 不跨库,有 wildIgnoreTables 过滤,不过滤 create database DB_1 + */ + @Test + public void wildIgnoreTables_1() throws Exception { + Map filterParams = new HashMap<>(); + filterParams.put(RplConstants.REPLICATE_DO_DB, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_DB, ""); + filterParams.put(RplConstants.REPLICATE_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_IGNORE_TABLE, String.format("('%s.%%', '%s.%%')", DB_2, DB_3)); + filterParams.put(RplConstants.REPLICATE_REWRITE_DB, ""); + setupService(channel, initBinlogPosition, filterParams); + + // setup compare replica + setupMysqlReplica(mysqlDstConn, initBinlogPosition); + + runnerThread.start(); + wait(WAIT_TASK_SECOND); + + List res = null; + + // create database + execUpdate(srcConn, "create database " + DB_1, null); + execUpdate(srcConn, "create database " + DB_2, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + Assert.assertFalse(res.contains(DB_2)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + Assert.assertFalse(res.contains(DB_2)); + + // drop database + execUpdate(dstConn, "create database " + DB_2, null); + execUpdate(mysqlDstConn, "create database " + DB_2, null); + + execUpdate(srcConn, "drop database " + DB_1, null); + execUpdate(srcConn, "drop database " + DB_2, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertTrue(res.contains(DB_2)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertTrue(res.contains(DB_2)); + } + + /** + * 不跨库,有 wildIgnoreTable 过滤,过滤掉 create database DB_1 + */ + @Test + public void wildIgnoreTables_2() throws Exception { + Map filterParams = new HashMap<>(); + filterParams.put(RplConstants.REPLICATE_DO_DB, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_DB, ""); + filterParams.put(RplConstants.REPLICATE_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_IGNORE_TABLE, String.format("('%s.t2%%', '%s.t2%%')", DB_1, DB_2)); + filterParams.put(RplConstants.REPLICATE_REWRITE_DB, ""); + setupService(channel, initBinlogPosition, filterParams); + + // setup compare replica + setupMysqlReplica(mysqlDstConn, initBinlogPosition); + + runnerThread.start(); + wait(WAIT_TASK_SECOND); + + List res = null; + + // create database + execUpdate(srcConn, "create database " + DB_1, null); + execUpdate(srcConn, "create database " + DB_2, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + Assert.assertTrue(res.contains(DB_2)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + Assert.assertTrue(res.contains(DB_2)); + + // use db + execUpdate(srcConn, "use " + DB_1, null); + execUpdate(dstConn, "use " + DB_1, null); + execUpdate(mysqlDstConn, "use " + DB_1, null); + + // create table + execUpdate(srcConn, "create table t1_1(id int, f1 int, f2 int)", null); + execUpdate(srcConn, "create table t2_1(id int, f1 int, f2 int)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertTrue(res.contains("t1_1")); + Assert.assertFalse(res.contains("t2_1")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertTrue(res.contains("t1_1")); + Assert.assertFalse(res.contains("t2_1")); + + // rename table + execUpdate(srcConn, "rename table t1_1 to t1;", null); + execUpdate(srcConn, "rename table t2_1 to t2;", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + Assert.assertTrue(res.contains("t1")); + Assert.assertFalse(res.contains("t2")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + Assert.assertTrue(res.contains("t1")); + Assert.assertFalse(res.contains("t2")); + + // alter table add column + execUpdate(srcConn, "alter table t1 add column f3 int;", null); + execUpdate(srcConn, "alter table t2 add column f3 int;", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "desc t1", 1); + Assert.assertTrue(res.contains("f3")); + res = execQuery(mysqlDstConn, "desc t1", 1); + Assert.assertTrue(res.contains("f3")); + + // alter table drop column + execUpdate(srcConn, "alter table t1 drop column f3", null); + execUpdate(srcConn, "alter table t2 drop column f3", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "desc t1", 1); + Assert.assertFalse(res.contains("f3")); + res = execQuery(mysqlDstConn, "desc t1", 1); + Assert.assertFalse(res.contains("f3")); + + // create index + execUpdate(srcConn, "create index idx_f1 on t1(f1)", null); + execUpdate(srcConn, "create index idx_f1 on t2(f1)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f1`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f1`")); + + // alter add index + execUpdate(srcConn, "alter table t1 add index idx_f2(f2)", null); + execUpdate(srcConn, "alter table t2 add index idx_f2(f2)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f2`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f2`")); + + // drop index + execUpdate(srcConn, "drop index idx_f1 on t1", null); + execUpdate(srcConn, "drop index idx_f1 on t2", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f1`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f1`")); + + // alter drop index + execUpdate(srcConn, "alter table t1 drop index idx_f2", null); + execUpdate(srcConn, "alter table t2 drop index idx_f2", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f2`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f2`")); + + // truncate table + execUpdate(srcConn, "insert into t1 values(1,2,3)", null); + execUpdate(srcConn, "insert into t2 values(1,2,3)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "select * from t1", 1); + Assert.assertTrue(res.size() > 0); + res = execQuery(mysqlDstConn, "select * from t1", 1); + Assert.assertTrue(res.size() > 0); + + execUpdate(srcConn, "truncate table t1", null); + execUpdate(srcConn, "truncate table t2", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "select * from t1", 1); + Assert.assertTrue(res.size() == 0); + res = execQuery(mysqlDstConn, "select * from t1", 1); + Assert.assertTrue(res.size() == 0); + + // drop table + execUpdate(srcConn, "drop table t1", null); + execUpdate(srcConn, "drop table t2", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1")); + + // drop database + execUpdate(srcConn, "drop database " + DB_1, null); + execUpdate(srcConn, "drop database " + DB_2, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertFalse(res.contains(DB_2)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertFalse(res.contains(DB_2)); + } + + /** + * 不跨库,有 rewriteDbs,除 create database 和 drop database 外,在源库 DB_1 上执行的 DDL,会在目标库 + * DB_2 上执行。而 create database 和 drop database 会原样执行。 + */ + @Test + public void rewriteDbs() throws Exception { + Map filterParams = new HashMap<>(); + filterParams.put(RplConstants.REPLICATE_DO_DB, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_DB, ""); + filterParams.put(RplConstants.REPLICATE_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_REWRITE_DB, String.format("((%s, %s))", DB_1, DB_2)); + setupService(channel, initBinlogPosition, filterParams); + + // setup compare replica + setupMysqlReplica(mysqlDstConn, initBinlogPosition); + + runnerThread.start(); + wait(WAIT_TASK_SECOND); + + List res = null; + + // create database + execUpdate(srcConn, "create database " + DB_1, null); + wait(WAIT_DDL_SECOND); + + // rewriteDbs won't affect create database + res = execQuery(dstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + Assert.assertFalse(res.contains(DB_2)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + Assert.assertFalse(res.contains(DB_2)); + + // create DB_2 manually + execUpdate(dstConn, "create database " + DB_2, null); + execUpdate(mysqlDstConn, "create database " + DB_2, null); + wait(WAIT_DDL_SECOND); + + // use db_1 + execUpdate(srcConn, "use " + DB_1, null); + execUpdate(dstConn, "use " + DB_2, null); + execUpdate(mysqlDstConn, "use " + DB_2, null); + + // create table + execUpdate(srcConn, "create table t1_1(id int, f1 int, f2 int)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertTrue(res.contains("t1_1")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertTrue(res.contains("t1_1")); + + // rename table + execUpdate(srcConn, "rename table t1_1 to t1;", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + Assert.assertTrue(res.contains("t1")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + Assert.assertTrue(res.contains("t1")); + + // alter table add column + execUpdate(srcConn, "alter table t1 add column f3 int;", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "desc t1", 1); + Assert.assertTrue(res.contains("f3")); + res = execQuery(mysqlDstConn, "desc t1", 1); + Assert.assertTrue(res.contains("f3")); + + // alter table drop column + execUpdate(srcConn, "alter table t1 drop column f3", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "desc t1", 1); + Assert.assertFalse(res.contains("f3")); + res = execQuery(mysqlDstConn, "desc t1", 1); + Assert.assertFalse(res.contains("f3")); + + // create index + execUpdate(srcConn, "create index idx_f1 on t1(f1)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f1`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f1`")); + + // alter add index + execUpdate(srcConn, "alter table t1 add index idx_f2(f2)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f2`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f2`")); + + // drop index + execUpdate(srcConn, "drop index idx_f1 on t1", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f1`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f1`")); + + // alter drop index + execUpdate(srcConn, "alter table t1 drop index idx_f2", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f2`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f2`")); + + // truncate table + execUpdate(srcConn, "insert into t1 values(1,2,3)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "select * from t1", 1); + Assert.assertTrue(res.size() > 0); + res = execQuery(mysqlDstConn, "select * from t1", 1); + Assert.assertTrue(res.size() > 0); + + execUpdate(srcConn, "truncate table t1", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "select * from t1", 1); + Assert.assertTrue(res.size() == 0); + res = execQuery(mysqlDstConn, "select * from t1", 1); + Assert.assertTrue(res.size() == 0); + + // drop table + execUpdate(srcConn, "drop table t1", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1")); + + // drop database + execUpdate(srcConn, "drop database " + DB_1, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertTrue(res.contains(DB_2)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertTrue(res.contains(DB_2)); + } + + /** + * 不跨库,有 rewriteDbs,在源库 DB_1 上执行的 DDL,在目标库 DB_2 上发生。 有 filter。rewriteDbs 对 + * filter 的影响仅在 ReplicateFilter 的 ignoreEvent(String schema, String tbName, + * DBMSAction action) 入口处,故只写这一个测试用例即可。 rewriteDbs 对 create database 和 drop + * database 不生效。 + */ + @Test + public void rewriteDbs_DoDbs() throws Exception { + Map filterParams = new HashMap<>(); + filterParams.put(RplConstants.REPLICATE_DO_DB, String.format("(%s)", DB_2)); + filterParams.put(RplConstants.REPLICATE_IGNORE_DB, ""); + filterParams.put(RplConstants.REPLICATE_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_REWRITE_DB, String.format("((%s, %s))", DB_1, DB_2)); + setupService(channel, initBinlogPosition, filterParams); + + // setup compare replica + setupMysqlReplica(mysqlDstConn, initBinlogPosition); + + runnerThread.start(); + wait(WAIT_TASK_SECOND); + + List res = null; + + // create database + execUpdate(srcConn, "create database " + DB_1, null); + execUpdate(srcConn, "create database " + DB_2, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertTrue(res.contains(DB_2)); + res = execQuery(dstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertTrue(res.contains(DB_2)); + + // use db_1 + execUpdate(srcConn, "use " + DB_1, null); + execUpdate(dstConn, "use " + DB_2, null); + execUpdate(mysqlDstConn, "use " + DB_2, null); + + // create table + execUpdate(srcConn, "create table t1_1(id int, f1 int, f2 int)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertTrue(res.contains("t1_1")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertTrue(res.contains("t1_1")); + + // rename table + execUpdate(srcConn, "rename table t1_1 to t1;", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + Assert.assertTrue(res.contains("t1")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + Assert.assertTrue(res.contains("t1")); + + // alter table add column + execUpdate(srcConn, "alter table t1 add column f3 int;", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "desc t1", 1); + Assert.assertTrue(res.contains("f3")); + res = execQuery(mysqlDstConn, "desc t1", 1); + Assert.assertTrue(res.contains("f3")); + + // alter table drop column + execUpdate(srcConn, "alter table t1 drop column f3", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "desc t1", 1); + Assert.assertFalse(res.contains("f3")); + res = execQuery(mysqlDstConn, "desc t1", 1); + Assert.assertFalse(res.contains("f3")); + + // create index + execUpdate(srcConn, "create index idx_f1 on t1(f1)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f1`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f1`")); + + // alter add index + execUpdate(srcConn, "alter table t1 add index idx_f2(f2)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f2`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f2`")); + + // drop index + execUpdate(srcConn, "drop index idx_f1 on t1", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f1`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f1`")); + + // alter drop index + execUpdate(srcConn, "alter table t1 drop index idx_f2", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f2`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f2`")); + + // truncate table + execUpdate(srcConn, "truncate table t1", null); + execUpdate(srcConn, "insert into t1 values(1,2,3)", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "select * from t1", 1); + Assert.assertTrue(res.size() > 0); + res = execQuery(mysqlDstConn, "select * from t1", 1); + Assert.assertTrue(res.size() > 0); + + execUpdate(srcConn, "truncate table t1", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "select * from t1", 1); + Assert.assertTrue(res.size() == 0); + res = execQuery(mysqlDstConn, "select * from t1", 1); + Assert.assertTrue(res.size() == 0); + + // drop table + execUpdate(srcConn, "drop table t1", null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1")); + + // drop database + execUpdate(srcConn, "drop database " + DB_1, null); + execUpdate(srcConn, "drop database " + DB_2, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + } + + /** + * 跨库,没有 tbFilter,没有 dbFilter,没有 rewriteDbs,在源库 DB_1 上执行的 DDL,在目标库 DB_1 上发生 + */ + @Test + public void crossDb_Basic() throws Exception { + runnerThread.start(); + wait(WAIT_TASK_SECOND); + + List res = null; + + // create database + execUpdate(srcConn, "create database " + DB_1, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + + // use db_1, 跨库执行 ddl + execUpdate(srcConn, "use information_schema", null); + execUpdate(dstConn, "use " + DB_1, null); + execUpdate(mysqlDstConn, "use " + DB_1, null); + + // create table + execUpdate(srcConn, String.format("create table %s.t1_1(id int, f1 int, f2 int)", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertTrue(res.contains("t1_1")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertTrue(res.contains("t1_1")); + + // rename table + execUpdate(srcConn, String.format("rename table %s.t1_1 to %s.t1;", DB_1, DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + Assert.assertTrue(res.contains("t1")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + Assert.assertTrue(res.contains("t1")); + + // alter table add column + execUpdate(srcConn, String.format("alter table %s.t1 add column f3 int;", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "desc t1", 1); + Assert.assertTrue(res.contains("f3")); + res = execQuery(mysqlDstConn, "desc t1", 1); + Assert.assertTrue(res.contains("f3")); + + // alter table drop column + execUpdate(srcConn, String.format("alter table %s.t1 drop column f3", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "desc t1", 1); + Assert.assertFalse(res.contains("f3")); + res = execQuery(mysqlDstConn, "desc t1", 1); + Assert.assertFalse(res.contains("f3")); + + // create index + execUpdate(srcConn, String.format("create index idx_f1 on %s.t1(f1)", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f1`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f1`")); + + // alter add index + execUpdate(srcConn, String.format("alter table %s.t1 add index idx_f2(f2)", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f2`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f2`")); + + // drop index + execUpdate(srcConn, String.format("drop index idx_f1 on %s.t1", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f1`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f1`")); + + // alter drop index + execUpdate(srcConn, String.format("alter table %s.t1 drop index idx_f2", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f2`")); + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f2`")); + + // truncate table + execUpdate(srcConn, String.format("insert into %s.t1 values(1,2,3)", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "select * from t1", 1); + Assert.assertTrue(res.size() > 0); + res = execQuery(mysqlDstConn, "select * from t1", 1); + Assert.assertTrue(res.size() > 0); + + execUpdate(srcConn, String.format("truncate table %s.t1", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "select * from t1", 1); + Assert.assertTrue(res.size() == 0); + res = execQuery(mysqlDstConn, "select * from t1", 1); + Assert.assertTrue(res.size() == 0); + + // drop table + execUpdate(srcConn, String.format("drop table %s.t1", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1")); + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1")); + + // drop database + execUpdate(srcConn, "drop database " + DB_1, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + } + + /** + * 跨库,有 rewriteDbs,在源库 DB_1 上执行的 DDL,在目标库 DB_1 上发生 + */ + @Test + public void crossDb_RewriteDbs() throws Exception { + Map filterParams = new HashMap<>(); + filterParams.put(RplConstants.REPLICATE_DO_DB, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_DB, ""); + filterParams.put(RplConstants.REPLICATE_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_REWRITE_DB, String.format("((%s, %s))", DB_1, DB_2)); + setupService(channel, initBinlogPosition, filterParams); + + // setup compare replica + setupMysqlReplica(mysqlDstConn, initBinlogPosition); + + runnerThread.start(); + wait(WAIT_TASK_SECOND); + + List res = null; + + // create database + execUpdate(srcConn, "create database " + DB_1, null); + wait(WAIT_DDL_SECOND); + + // rewriteDbs won't affect create database + res = execQuery(dstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + Assert.assertFalse(res.contains(DB_2)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + Assert.assertFalse(res.contains(DB_2)); + + // use db_1 + execUpdate(srcConn, "use information_schema", null); + execUpdate(dstConn, "use " + DB_1, null); + execUpdate(mysqlDstConn, "use " + DB_1, null); + + // DDL sql 应该发生在 DB_1 + // create table + execUpdate(srcConn, String.format("create table %s.t1_1(id int, f1 int, f2 int)", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertTrue(res.contains("t1_1")); + res = execQuery(dstConn, "show tables", 1); + Assert.assertTrue(res.contains("t1_1")); + + // rename table + execUpdate(srcConn, String.format("rename table %s.t1_1 to %s.t1;", DB_1, DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + Assert.assertTrue(res.contains("t1")); + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + Assert.assertTrue(res.contains("t1")); + + // alter table add column + execUpdate(srcConn, String.format("alter table %s.t1 add column f3 int;", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(mysqlDstConn, "desc t1", 1); + Assert.assertTrue(res.contains("f3")); + res = execQuery(dstConn, "desc t1", 1); + Assert.assertTrue(res.contains("f3")); + + // alter table drop column + execUpdate(srcConn, String.format("alter table %s.t1 drop column f3", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(mysqlDstConn, "desc t1", 1); + Assert.assertFalse(res.contains("f3")); + res = execQuery(dstConn, "desc t1", 1); + Assert.assertFalse(res.contains("f3")); + + // create index + execUpdate(srcConn, String.format("create index idx_f1 on %s.t1(f1)", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f1`")); + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f1`")); + + // alter add index + execUpdate(srcConn, String.format("alter table %s.t1 add index idx_f2(f2)", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f2`")); + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertTrue(res.get(0).contains("KEY `idx_f2`")); + + // drop index + execUpdate(srcConn, String.format("drop index idx_f1 on %s.t1", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f1`")); + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f1`")); + + // alter drop index + execUpdate(srcConn, String.format("alter table %s.t1 drop index idx_f2", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(mysqlDstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f2`")); + res = execQuery(dstConn, "show create table t1", 2); + Assert.assertFalse(res.get(0).contains("KEY `idx_f2`")); + + // truncate table + execUpdate(dstConn, String.format("insert into %s.t1 values(1,2,3)", DB_1), null); + execUpdate(mysqlDstConn, String.format("insert into %s.t1 values(1,2,3)", DB_1), null); + res = execQuery(mysqlDstConn, "select * from t1", 1); + Assert.assertTrue(res.size() > 0); + res = execQuery(dstConn, "select * from t1", 1); + Assert.assertTrue(res.size() > 0); + + execUpdate(srcConn, String.format("truncate table %s.t1", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(mysqlDstConn, "select * from t1", 1); + Assert.assertTrue(res.size() == 0); + res = execQuery(dstConn, "select * from t1", 1); + Assert.assertTrue(res.size() == 0); + + // drop table + execUpdate(srcConn, String.format("drop table %s.t1", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1")); + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1")); + + // drop database + execUpdate(srcConn, "drop database " + DB_1, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertFalse(res.contains(DB_2)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertFalse(res.contains(DB_2)); + } + + /** + * 跨库,有 rewriteDbs,在源库 DB_1 上执行的 DDL,在目标库 DB_1 上发生。 有 filter。rewriteDbs 对 filter + * 的影响仅在 ReplicateFilter 的 ignoreEvent(String schema, String tbName, DBMSAction + * action) 入口处。 rewriteDbs 对 create database 和 drop database 不生效。 + */ + @Test + public void crossDb_RewriteDbs_DoDbs_1() throws Exception { + Map filterParams = new HashMap<>(); + filterParams.put(RplConstants.REPLICATE_DO_DB, String.format("(%s)", DB_2)); + filterParams.put(RplConstants.REPLICATE_IGNORE_DB, ""); + filterParams.put(RplConstants.REPLICATE_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_REWRITE_DB, String.format("((%s, %s))", DB_1, DB_2)); + setupService(channel, initBinlogPosition, filterParams); + + // setup compare replica + setupMysqlReplica(mysqlDstConn, initBinlogPosition); + + runnerThread.start(); + wait(WAIT_TASK_SECOND); + + List res = null; + + // create database + execUpdate(srcConn, "create database " + DB_1, null); + execUpdate(srcConn, "create database " + DB_2, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertTrue(res.contains(DB_2)); + res = execQuery(dstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertTrue(res.contains(DB_2)); + + // create DB_1 in dst manually + execUpdate(dstConn, "create database " + DB_1, null); + execUpdate(mysqlDstConn, "create database " + DB_1, null); + + // use information_schema + execUpdate(srcConn, "use information_schema", null); + execUpdate(dstConn, "use " + DB_1, null); + execUpdate(mysqlDstConn, "use " + DB_1, null); + + // DDL sql 应该发生在 DB_1,但因为 srcConn 执行了 use information_schema,mysql 认为当前库是在 + // information_schema, 则过滤掉了 ddl。 + // create table + execUpdate(srcConn, String.format("create table %s.t1_1(id int, f1 int, f2 int)", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + + // rename table + execUpdate(srcConn, String.format("rename table %s.t1_1 to %s.t1;", DB_1, DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + Assert.assertFalse(res.contains("t1")); + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + Assert.assertFalse(res.contains("t1")); + + // drop table + execUpdate(srcConn, String.format("drop table %s.t1", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1")); + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1")); + + // drop database + execUpdate(srcConn, "drop database " + DB_1, null); + execUpdate(srcConn, "drop database " + DB_2, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + } + + /** + * 跨库,有 rewriteDbs,在源库 DB_1 上执行的 DDL,在目标库 DB_1 上发生。 有 filter。rewriteDbs 对 filter + * 的影响仅在 ReplicateFilter 的 ignoreEvent(String schema, String tbName, DBMSAction + * action) 入口处,故只写这一个测试用例即可。 rewriteDbs 对 create database 和 drop database 不生效。 + */ + @Test + public void crossDb_RewriteDbs_DoDbs_2() throws Exception { + Map filterParams = new HashMap<>(); + filterParams.put(RplConstants.REPLICATE_DO_DB, String.format("(%s)", DB_2)); + filterParams.put(RplConstants.REPLICATE_IGNORE_DB, ""); + filterParams.put(RplConstants.REPLICATE_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_REWRITE_DB, String.format("((%s, %s))", DB_1, DB_2)); + setupService(channel, initBinlogPosition, filterParams); + + // setup compare replica + setupMysqlReplica(mysqlDstConn, initBinlogPosition); + + runnerThread.start(); + wait(WAIT_TASK_SECOND); + + List res = null; + + // create database + execUpdate(srcConn, "create database " + DB_1, null); + execUpdate(srcConn, "create database " + DB_2, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertTrue(res.contains(DB_2)); + res = execQuery(dstConn, "show databases", 1); + Assert.assertFalse(res.contains(DB_1)); + Assert.assertTrue(res.contains(DB_2)); + + // create DB_1 in dst manually + execUpdate(dstConn, "create database " + DB_1, null); + execUpdate(mysqlDstConn, "create database " + DB_1, null); + + // use db_2 + execUpdate(srcConn, "use " + DB_2, null); + execUpdate(dstConn, "use " + DB_1, null); + execUpdate(mysqlDstConn, "use " + DB_1, null); + + // DDL sql 应该发生在 DB_1,本来 DB_1 应该被过滤的,但 mysql 却没有过滤,因为 srcConn 执行时用了 use + // DB_2,mysql 便认为当前 DB 是 DB_2,则该 DDL 没有被过滤。 + // create table + execUpdate(srcConn, String.format("create table %s.t1_1(id int, f1 int, f2 int)", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertTrue(res.contains("t1_1")); + res = execQuery(dstConn, "show tables", 1); + Assert.assertTrue(res.contains("t1_1")); + + // rename table + execUpdate(srcConn, String.format("rename table %s.t1_1 to %s.t1;", DB_1, DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + Assert.assertTrue(res.contains("t1")); + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1_1")); + Assert.assertTrue(res.contains("t1")); + + // drop table + execUpdate(srcConn, String.format("drop table %s.t1", DB_1), null); + wait(WAIT_DDL_SECOND); + + res = execQuery(mysqlDstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1")); + res = execQuery(dstConn, "show tables", 1); + Assert.assertFalse(res.contains("t1")); + + // drop database + execUpdate(srcConn, "drop database " + DB_1, null); + execUpdate(srcConn, "drop database " + DB_2, null); + wait(WAIT_DDL_SECOND); + + res = execQuery(dstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + res = execQuery(mysqlDstConn, "show databases", 1); + Assert.assertTrue(res.contains(DB_1)); + } +} diff --git a/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/DmlE2ETest.java b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/DmlE2ETest.java new file mode 100644 index 00000000..1e457612 --- /dev/null +++ b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/DmlE2ETest.java @@ -0,0 +1,459 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.task; + +import com.aliyun.polardbx.rpl.TestBase; +import com.aliyun.polardbx.rpl.common.RplConstants; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.sql.Connection; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author shicai.xsc 2021/4/22 17:01 + * @since 5.0.0.0 + */ +public class DmlE2ETest extends TestBase { + + private static final String DB_1 = "filter_db1"; + private static final String DB_1_R = "filter_db1_rewrite"; + private static final String DB_2 = "filter_db2"; + private static final String DB_3 = "filter_db3"; + private static final String DB_3_R = "filter_db3_rewrite"; + private static final String DB_4 = "filter_db4"; + + private static final String TB_1 = "t1_1"; + private static final String TB_2 = "t2_1"; + + private static final String ID = "id"; + private static final String VALUE = "value"; + private static final List FIELDS = Arrays.asList(ID, VALUE); + private static final List ALL_DBS = Arrays.asList(DB_1, DB_1_R, DB_2, DB_3, DB_3_R, DB_4); + private static final List ALL_TBS = Arrays.asList(TB_1, TB_2); + + private static final int INTERVAL = 3; + private static final int WAIT_DML_SECOND = 10; + + @Before + public void before() throws Exception { + channel = "rpl_replicate_filter_test"; + super.before(); + initDbsAndTables(); + initBinlogPosition = getLastBinlogPosition(); + } + + @After + public void after() throws Exception { + super.after(); + } + + @Test + public void doDb_rewriteDbs() throws Exception { + Map filterParams = new HashMap<>(); + filterParams.put(RplConstants.REPLICATE_DO_DB, String.format("(%s,%s)", DB_1_R, DB_2)); + filterParams.put(RplConstants.REPLICATE_IGNORE_DB, ""); + filterParams.put(RplConstants.REPLICATE_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_REWRITE_DB, + String.format("((%s, %s),(%s, %s))", DB_1, DB_1_R, DB_3, DB_3_R)); + setupService(channel, initBinlogPosition, filterParams); + + // setup compare replica + setupMysqlReplica(mysqlDstConn, initBinlogPosition); + + runnerThread.start(); + wait(WAIT_TASK_SECOND); + + doTest(); + wait(WAIT_DML_SECOND); + + checkTwoDstsSame(); + checkDstEqualsInit(DB_1, TB_1); + checkDstEqualsInit(DB_1, TB_2); + checkDstEqualsChanged(DB_1_R, TB_1); + checkDstEqualsChanged(DB_1_R, TB_2); + checkDstEqualsChanged(DB_2, TB_1); + checkDstEqualsChanged(DB_2, TB_2); + checkDstEqualsInit(DB_3, TB_1); + checkDstEqualsInit(DB_3, TB_2); + checkDstEqualsInit(DB_3_R, TB_1); + checkDstEqualsInit(DB_3_R, TB_2); + checkDstEqualsInit(DB_4, TB_1); + checkDstEqualsInit(DB_4, TB_2); + } + + @Test + public void ignoreDb_rewriteDbs() throws Exception { + Map filterParams = new HashMap<>(); + filterParams.put(RplConstants.REPLICATE_DO_DB, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_DB, String.format("(%s,%s)", DB_3_R, DB_4)); + filterParams.put(RplConstants.REPLICATE_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_REWRITE_DB, + String.format("((%s, %s),(%s, %s))", DB_1, DB_1_R, DB_3, DB_3_R)); + setupService(channel, initBinlogPosition, filterParams); + + // setup compare replica + setupMysqlReplica(mysqlDstConn, initBinlogPosition); + + runnerThread.start(); + wait(WAIT_DML_SECOND); + + doTest(); + wait(5); + + checkTwoDstsSame(); + checkDstEqualsChanged(DB_1_R, TB_1); + checkDstEqualsChanged(DB_1_R, TB_2); + checkDstEqualsChanged(DB_2, TB_1); + checkDstEqualsChanged(DB_2, TB_2); + checkDstEqualsInit(DB_1, TB_1); + checkDstEqualsInit(DB_1, TB_2); + checkDstEqualsInit(DB_3, TB_1); + checkDstEqualsInit(DB_3, TB_2); + checkDstEqualsInit(DB_3_R, TB_1); + checkDstEqualsInit(DB_3_R, TB_2); + checkDstEqualsInit(DB_4, TB_1); + checkDstEqualsInit(DB_4, TB_2); + } + + @Test + public void doTables_rewriteDbs() throws Exception { + Map filterParams = new HashMap<>(); + filterParams.put(RplConstants.REPLICATE_DO_DB, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_DB, ""); + filterParams.put(RplConstants.REPLICATE_DO_TABLE, String.format("(%s.%s, %s.%s)", DB_1_R, TB_1, DB_2, TB_2)); + filterParams.put(RplConstants.REPLICATE_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_REWRITE_DB, + String.format("((%s, %s),(%s, %s))", DB_1, DB_1_R, DB_3, DB_3_R)); + setupService(channel, initBinlogPosition, filterParams); + + // setup compare replica + setupMysqlReplica(mysqlDstConn, initBinlogPosition); + + runnerThread.start(); + wait(WAIT_DDL_SECOND * 3); + + doTest(); + wait(WAIT_DML_SECOND); + + checkTwoDstsSame(); + checkDstEqualsInit(DB_1, TB_1); + checkDstEqualsInit(DB_1, TB_2); + checkDstEqualsChanged(DB_1_R, TB_1); + checkDstEqualsInit(DB_1_R, TB_2); + checkDstEqualsInit(DB_2, TB_1); + checkDstEqualsChanged(DB_2, TB_2); + checkDstEqualsInit(DB_3, TB_1); + checkDstEqualsInit(DB_3, TB_2); + checkDstEqualsInit(DB_3_R, TB_1); + checkDstEqualsInit(DB_3_R, TB_2); + checkDstEqualsInit(DB_4, TB_1); + checkDstEqualsInit(DB_4, TB_2); + } + + @Test + public void ignoreTables_rewriteDbs() throws Exception { + Map filterParams = new HashMap<>(); + filterParams.put(RplConstants.REPLICATE_DO_DB, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_DB, ""); + filterParams.put(RplConstants.REPLICATE_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_TABLE, + String.format("(%s.%s, %s.%s)", DB_3_R, TB_1, DB_4, TB_2)); + filterParams.put(RplConstants.REPLICATE_WILD_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_REWRITE_DB, + String.format("((%s, %s),(%s, %s))", DB_1, DB_1_R, DB_3, DB_3_R)); + setupService(channel, initBinlogPosition, filterParams); + + // setup compare replica + setupMysqlReplica(mysqlDstConn, initBinlogPosition); + + runnerThread.start(); + wait(WAIT_TASK_SECOND); + + doTest(); + wait(WAIT_DML_SECOND); + + checkTwoDstsSame(); + checkDstEqualsInit(DB_1, TB_1); + checkDstEqualsInit(DB_1, TB_2); + checkDstEqualsChanged(DB_1_R, TB_1); + checkDstEqualsChanged(DB_1_R, TB_2); + checkDstEqualsChanged(DB_2, TB_1); + checkDstEqualsChanged(DB_2, TB_2); + checkDstEqualsInit(DB_3, TB_1); + checkDstEqualsInit(DB_3, TB_2); + checkDstEqualsInit(DB_3_R, TB_1); + checkDstEqualsChanged(DB_3_R, TB_2); + checkDstEqualsChanged(DB_4, TB_1); + checkDstEqualsInit(DB_4, TB_2); + } + + @Test + public void wildDoTables_rewriteDbs_1() throws Exception { + Map filterParams = new HashMap<>(); + filterParams.put(RplConstants.REPLICATE_DO_DB, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_DB, ""); + filterParams.put(RplConstants.REPLICATE_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_DO_TABLE, + String.format("('%s.%%', '%s.%%')", escape(DB_1_R), escape(DB_2))); + filterParams.put(RplConstants.REPLICATE_WILD_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_REWRITE_DB, + String.format("((%s, %s),(%s, %s))", DB_1, DB_1_R, DB_3, DB_3_R)); + setupService(channel, initBinlogPosition, filterParams); + + // setup compare replica + setupMysqlReplica(mysqlDstConn, initBinlogPosition); + + runnerThread.start(); + wait(WAIT_TASK_SECOND); + + doTest(); + wait(WAIT_DML_SECOND); + + checkTwoDstsSame(); + checkDstEqualsInit(DB_1, TB_1); + checkDstEqualsInit(DB_1, TB_2); + checkDstEqualsChanged(DB_1_R, TB_1); + checkDstEqualsChanged(DB_1_R, TB_2); + checkDstEqualsChanged(DB_2, TB_1); + checkDstEqualsChanged(DB_2, TB_2); + checkDstEqualsInit(DB_3, TB_1); + checkDstEqualsInit(DB_3, TB_2); + checkDstEqualsInit(DB_3_R, TB_1); + checkDstEqualsInit(DB_3_R, TB_2); + checkDstEqualsInit(DB_4, TB_1); + checkDstEqualsInit(DB_4, TB_2); + } + + @Test + public void wildDoTables_rewriteDbs_2() throws Exception { + Map filterParams = new HashMap<>(); + filterParams.put(RplConstants.REPLICATE_DO_DB, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_DB, ""); + filterParams.put(RplConstants.REPLICATE_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_DO_TABLE, + String.format("('%s.%s%%', '%s.%s%%')", escape(DB_1_R), escape(TB_1), escape(DB_2), escape(TB_2))); + filterParams.put(RplConstants.REPLICATE_WILD_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_REWRITE_DB, + String.format("((%s, %s),(%s, %s))", DB_1, DB_1_R, DB_3, DB_3_R)); + setupService(channel, initBinlogPosition, filterParams); + + // setup compare replica + setupMysqlReplica(mysqlDstConn, initBinlogPosition); + + runnerThread.start(); + wait(WAIT_TASK_SECOND); + + doTest(); + wait(WAIT_DML_SECOND); + + checkTwoDstsSame(); + checkDstEqualsInit(DB_1, TB_1); + checkDstEqualsInit(DB_1, TB_2); + checkDstEqualsChanged(DB_1_R, TB_1); + checkDstEqualsInit(DB_1_R, TB_2); + checkDstEqualsInit(DB_2, TB_1); + checkDstEqualsChanged(DB_2, TB_2); + checkDstEqualsInit(DB_3, TB_1); + checkDstEqualsInit(DB_3, TB_2); + checkDstEqualsInit(DB_3_R, TB_1); + checkDstEqualsInit(DB_3_R, TB_2); + checkDstEqualsInit(DB_4, TB_1); + checkDstEqualsInit(DB_4, TB_2); + } + + @Test + public void wildIgnoreTables_rewriteDbs_1() throws Exception { + Map filterParams = new HashMap<>(); + filterParams.put(RplConstants.REPLICATE_DO_DB, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_DB, ""); + filterParams.put(RplConstants.REPLICATE_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_IGNORE_TABLE, + String.format("('%s.%%', '%s.%%')", escape(DB_3_R), escape(DB_4))); + filterParams.put(RplConstants.REPLICATE_REWRITE_DB, + String.format("((%s, %s),(%s, %s))", DB_1, DB_1_R, DB_3, DB_3_R)); + setupService(channel, initBinlogPosition, filterParams); + + // setup compare replica + setupMysqlReplica(mysqlDstConn, initBinlogPosition); + + runnerThread.start(); + wait(WAIT_TASK_SECOND); + + doTest(); + wait(WAIT_DML_SECOND); + + checkTwoDstsSame(); + checkDstEqualsInit(DB_1, TB_1); + checkDstEqualsInit(DB_1, TB_2); + checkDstEqualsChanged(DB_1_R, TB_1); + checkDstEqualsChanged(DB_1_R, TB_2); + checkDstEqualsChanged(DB_2, TB_1); + checkDstEqualsChanged(DB_2, TB_2); + checkDstEqualsInit(DB_3, TB_1); + checkDstEqualsInit(DB_3, TB_2); + checkDstEqualsInit(DB_3_R, TB_1); + checkDstEqualsInit(DB_3_R, TB_2); + checkDstEqualsInit(DB_4, TB_1); + checkDstEqualsInit(DB_4, TB_2); + } + + @Test + public void wildIgnoreTables_rewriteDbs_2() throws Exception { + Map filterParams = new HashMap<>(); + filterParams.put(RplConstants.REPLICATE_DO_DB, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_DB, ""); + filterParams.put(RplConstants.REPLICATE_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_IGNORE_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_DO_TABLE, ""); + filterParams.put(RplConstants.REPLICATE_WILD_IGNORE_TABLE, + String.format("('%s.%s%%', '%s.%s%%')", escape(DB_3_R), escape(TB_1), escape(DB_4), escape(TB_2))); + filterParams.put(RplConstants.REPLICATE_REWRITE_DB, + String.format("((%s, %s),(%s, %s))", DB_1, DB_1_R, DB_3, DB_3_R)); + setupService(channel, initBinlogPosition, filterParams); + + // setup compare replica + setupMysqlReplica(mysqlDstConn, initBinlogPosition); + + runnerThread.start(); + wait(WAIT_TASK_SECOND); + + doTest(); + wait(WAIT_DML_SECOND); + + checkTwoDstsSame(); + checkDstEqualsInit(DB_1, TB_1); + checkDstEqualsInit(DB_1, TB_2); + checkDstEqualsChanged(DB_1_R, TB_1); + checkDstEqualsChanged(DB_1_R, TB_2); + checkDstEqualsChanged(DB_2, TB_1); + checkDstEqualsChanged(DB_2, TB_2); + checkDstEqualsInit(DB_3, TB_1); + checkDstEqualsInit(DB_3, TB_2); + checkDstEqualsInit(DB_3_R, TB_1); + checkDstEqualsChanged(DB_3_R, TB_2); + checkDstEqualsChanged(DB_4, TB_1); + checkDstEqualsInit(DB_4, TB_2); + } + + private void initDbsAndTables() { + List connections = Arrays.asList(srcConn, dstConn, mysqlDstConn); + + for (String db : ALL_DBS) { + String dropSql = "drop database if exists " + db; + String createSql = "create database " + db; + + for (Connection conn : connections) { + execUpdate(conn, dropSql, null); + execUpdate(conn, createSql, null); + + for (String tb : ALL_TBS) { + String createTable = String + .format("create table %s.%s(id int, value int, primary key(id))", db, tb); + execUpdate(conn, createTable, null); + for (int i = 0; i < INTERVAL * 2; i++) { + String insert = String.format("insert into %s.%s values(%d,%d)", db, tb, i, i); + execUpdate(conn, insert, null); + } + } + } + } + } + + private void doTest() { + List dbs = Arrays.asList(DB_1, DB_2, DB_3, DB_4); + for (String db : dbs) { + for (String tb : ALL_TBS) { + for (int i = INTERVAL * 2; i < INTERVAL * 3; i++) { + String insert = String.format("insert into %s.%s values(%d,%d)", db, tb, i, i); + execUpdate(srcConn, insert, null); + } + for (int i = 0; i < INTERVAL; i++) { + String delete = String.format("delete from %s.%s where id = %d", db, tb, i); + execUpdate(srcConn, delete, null); + } + for (int i = INTERVAL; i < INTERVAL * 2; i++) { + String update = String.format("update %s.%s set value=%d where id = %d", db, tb, i + INTERVAL, i); + execUpdate(srcConn, update, null); + } + } + } + } + + private void checkTwoDstsSame() { + for (String db : ALL_DBS) { + for (String tb : ALL_TBS) { + checkTwoDstsSame(db, tb, FIELDS, ID); + } + } + } + + private void checkDstEqualsInit(String db, String tb) { + String dstSql = String.format("select * from %s.%s order by id", db, tb); + List> dstRes = execQuery(dstConn, dstSql, FIELDS); + Assert.assertEquals(dstRes.size(), INTERVAL * 2); + for (int i = 0; i < INTERVAL * 2; i++) { + Map dstRecord = dstRes.get(i); + Assert.assertEquals(dstRecord.get(ID), String.valueOf(i)); + Assert.assertEquals(dstRecord.get(VALUE), String.valueOf(i)); + } + } + + private void checkDstEqualsChanged(String db, String tb) { + String dstSql = String.format("select * from %s.%s order by id", db, tb); + List> dstRes = execQuery(dstConn, dstSql, FIELDS); + Assert.assertEquals(dstRes.size(), INTERVAL * 2); + + // 被 delete 的记录,d: INTERVAL 到 2 * INTERVAL + + // 被 update 的记录, id: INTERVAL 到 2 * INTERVAL, value == id + INTERVAL + for (int i = 0; i < INTERVAL; i++) { + Map dstRecord = dstRes.get(i); + Assert.assertEquals(dstRecord.get(ID), String.valueOf(i + INTERVAL)); + Assert.assertEquals(dstRecord.get(VALUE), String.valueOf(i + INTERVAL + INTERVAL)); + } + // 被 insert 的记录, id: 2 * INTERVAL 到 3 * INTERVAL, value == id + for (int i = INTERVAL; i < INTERVAL * 2; i++) { + Map dstRecord = dstRes.get(i); + Assert.assertEquals(dstRecord.get(ID), String.valueOf(i + INTERVAL)); + Assert.assertEquals(dstRecord.get(VALUE), String.valueOf(i + INTERVAL)); + } + } + + private String escape(String name) { + return name.replace("_", "\\_"); + } +} diff --git a/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/DmlPerfTest.java b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/DmlPerfTest.java new file mode 100644 index 00000000..6cf6fc78 --- /dev/null +++ b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/DmlPerfTest.java @@ -0,0 +1,153 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.task; + +import com.aliyun.polardbx.rpl.TestBase; +import com.aliyun.polardbx.rpl.common.NamedThreadFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +/** + * @author shicai.xsc 2021/4/28 11:30 + * @since 5.0.0.0 + */ +public class DmlPerfTest extends TestBase { + private static final String DB_1 = "perf_db1"; + private static final String DB_2 = "perf_db2"; + private static final String DB_3 = "perf_db3"; + private static final String DB_4 = "perf_db4"; + + private static final String TB_1 = "t1"; + private static final String TB_2 = "t2"; + private static final String TB_3 = "t3"; + private static final String TB_4 = "t4"; + private static final String TB_5 = "t5"; + private static final String TB_6 = "t6"; + private static final String TB_7 = "t7"; + private static final String TB_8 = "t8"; + + private static final List ALL_DBS = Arrays.asList(DB_1, DB_2, DB_3, DB_4); + private static final List ALL_TBS = Arrays.asList(TB_1, TB_2, TB_3, TB_4, TB_5, TB_6, TB_7, TB_8); + + private static final int COUNT_IN_ONE_TB = 1000; + private static final int WAIT_DML_SECOND = 60; + + @Before + public void before() throws Exception { + channel = "dml_perf_test"; + super.before(); + initDbsAndTables(); + initBinlogPosition = getLastBinlogPosition(); + } + + @After + public void after() throws Exception { + super.after(); + } + + private void initDbsAndTables() { + List connections = Arrays.asList(srcConn, dstConn); + + for (String db : ALL_DBS) { + String dropSql = "drop database if exists " + db; + String createSql = "create database " + db; + + for (Connection conn : connections) { + execUpdate(conn, dropSql, null); + execUpdate(conn, createSql, null); + + for (String tb : ALL_TBS) { + String createTable = String + .format( + "create table %s.%s(id int, f1 int, f2 int, f3 int, f4 int, f5 int, f6 int, f7 int, f8 int, f9 int, f10 int, f11 int, f12 int, f13 int, f14 int, f15 int, f16 int, f17 int, f18 int, f19 int, f20 int, f21 int, f22 int, f23 int, f24 int, f25 int, f26 int, f27 int, f28 int, f29 int, f30 int, primary key(id))", + db, tb); + execUpdate(conn, createTable, null); + } + } + } + } + + @Test + public void test() throws Exception { + // mysql_bin.000017:7257190 + setupService(channel, initBinlogPosition, null); + ExecutorService executorService = Executors.newFixedThreadPool(10, new NamedThreadFactory("")); + List futures = new ArrayList<>(); + + for (String db : ALL_DBS) { + for (String tb : ALL_TBS) { + final String table = db + "." + tb; + Future future = executorService.submit(() -> { + int i = 0; + while (i < COUNT_IN_ONE_TB) { + StringBuilder sb = new StringBuilder(); + + String values = + "('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d'),"; + int j = 0; + for (; j < 1000; j++) { + int field = i + j; + sb.append(String + .format(values, field, field, field, field, field, field, field, field, field, field, + field, field, field, field, field, field, field, field, field, field, field, field, + field, field, field, field, field, field, field, field, field)); + } + i += j + 1; + + String sql = String.format("insert into %s values %s", table, sb); + sql = sql.substring(0, sql.length() - 1); + + execUpdate(srcConn, sql, null); + } + }); + futures.add(future); + } + } + + checkFinish(futures); + + futures.clear(); + for (String db : ALL_DBS) { + for (String tb : ALL_TBS) { + final String table = db + "." + tb; + Future future = executorService.submit(() -> { + String sql = + String.format("update %s set f1=%d where id<%d", table, COUNT_IN_ONE_TB * 2, + COUNT_IN_ONE_TB / 2); + sql = sql.substring(0, sql.length() - 1); + execUpdate(srcConn, sql, null); + }); + futures.add(future); + } + } + + checkFinish(futures); + + runnerThread.start(); + wait(WAIT_DML_SECOND); + } +} diff --git a/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/PrimaryKeyTest.java b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/PrimaryKeyTest.java new file mode 100644 index 00000000..be98799f --- /dev/null +++ b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/PrimaryKeyTest.java @@ -0,0 +1,321 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.task; + +import com.aliyun.polardbx.binlog.canal.core.model.BinlogPosition; +import com.aliyun.polardbx.rpl.RplTaskRunner; +import com.aliyun.polardbx.rpl.TestBase; +import com.aliyun.polardbx.rpl.common.NamedThreadFactory; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +/** + * @author shicai.xsc 2021/4/28 16:00 + * @since 5.0.0.0 + */ +public class PrimaryKeyTest extends TestBase { + private static final String DB_1 = "primary_key_test"; + + private static final String NO_PK_NO_UK = "no_pk_no_uk"; + private static final String SINGLE_PK = "single_pk"; + private static final String MULTI_PK = "multi_pk"; + private static final String SINGLE_UK = "single_uk"; + private static final String MULTI_UK = "multi_uk"; + private static final String SINGLE_PK_SINGLE_UK = "single_pk_single_uk"; + + private static final List ALL_TBS = +// Arrays.asList(NO_PK_NO_UK, SINGLE_PK, MULTI_PK, SINGLE_UK, MULTI_UK, SINGLE_PK_SINGLE_UK); + Arrays.asList(SINGLE_PK, MULTI_PK, SINGLE_UK, MULTI_UK, SINGLE_PK_SINGLE_UK); + private static final List FIELDS = Arrays.asList("f0", "f1", "f2", "f3", "f4", "f5"); + + private static final int COUNT_IN_ONE_TB = 100; + + @Before + public void before() throws Exception { + channel = "primary_key_test"; + super.before(); +// initDbsAndTables(); +// initBinlogPosition = getLastBinlogPosition(); + + String dropSql = "drop database if exists " + DB_1; + String createSql = "create database if not exists " + DB_1; + execUpdate(srcConn, dropSql, null); + execUpdate(srcConn, createSql, null); + execUpdate(dstConn, dropSql, null); + execUpdate(dstConn, createSql, null); + } + + @After + public void after() throws Exception { + super.after(); + } + + private void initDbsAndTables() { + List connections = Arrays.asList(srcConn, dstConn, mysqlDstConn); + + String dropSql = "drop database if exists " + DB_1; + String createSql = "create database " + DB_1; + + for (Connection conn : connections) { + execUpdate(conn, dropSql, null); + execUpdate(conn, createSql, null); + + String createTable = + String.format("create table %s (f0 int, f1 int, f2 int, f3 int, f4 int, f5 int)", NO_PK_NO_UK); + execUpdate(conn, createTable, null); + + createTable = String + .format("create table %s (f0 int, f1 int, f2 int, f3 int, f4 int, f5 int, primary key(f0))", SINGLE_PK); + execUpdate(conn, createTable, null); + + createTable = String + .format("create table %s (f0 int, f1 int, f2 int, f3 int, f4 int, f5 int, primary key(f0, f1))", + MULTI_PK); + execUpdate(conn, createTable, null); + + createTable = String + .format("create table %s (f0 int, f1 int, f2 int, f3 int, f4 int, f5 int, unique key uk(id))", + SINGLE_UK); + execUpdate(conn, createTable, null); + + createTable = String + .format("create table %s (f0 int, f1 int, f2 int, f3 int, f4 int, f5 int, primary key(f0, f1))", + MULTI_UK); + execUpdate(conn, createTable, null); + + createTable = String + .format( + "create table %s (f0 int, f1 int, f2 int, f3 int, f4 int, f5 int, primary key(f0, f1), unique key uk(f2, f3))", + SINGLE_PK_SINGLE_UK); + execUpdate(conn, createTable, null); + } + } + + /** + * 源为 Polarx,有隐藏主键 + */ + @Test + public void primary_Key_Test() throws Exception { + setupService(channel, initBinlogPosition, null); + ExecutorService executorService = Executors.newFixedThreadPool(10, new NamedThreadFactory("")); + List futures = new ArrayList<>(); + + for (String tb : ALL_TBS) { + final String table = DB_1 + "." + tb; + Future future = executorService.submit(() -> { + int i = 0; + while (i < COUNT_IN_ONE_TB) { + StringBuilder sb = new StringBuilder(); + + String values = "('%d', '%d', '%d', '%d', '%d', '%d'),"; + int j = 0; + for (; j < 1000; j++) { + int value = i + j; + sb.append(String.format(values, value, value, value, value, value, value)); + } + i += j + 1; + + String sql = String.format("insert into %s values %s", table, sb); + sql = sql.substring(0, sql.length() - 1); + + execUpdate(srcConn, sql, null); + } + }); + futures.add(future); + } + + checkFinish(futures); + futures.clear(); + + // 更新主键 + for (String tb : ALL_TBS) { + final String table = DB_1 + "." + tb; + Future future = executorService.submit(() -> { + int i = 0; + int oldValue = i; + int newValue = i + 1; + while (i < COUNT_IN_ONE_TB / 2) { + String sql = + String.format("update %s set f0=%d, f1=%d, f2=%d, f3=%d, f4=%d, f5=%d where f0=%d", table, + newValue, + newValue, + newValue, + newValue, + newValue, + newValue, + oldValue); + sql = sql.substring(0, sql.length() - 1); + execUpdate(srcConn, sql, null); + i++; + } + }); + futures.add(future); + } + checkFinish(futures); + + // 交换 pk,但 uk 不变 + for (String tb : ALL_TBS) { + checkTwoDstsSame(DB_1, tb, FIELDS, "f0"); + } + } + + @Test + public void back_Tracking_Test() throws Exception { + String createSql1 = String + .format("create table %s.%s (f0 int, f1 int, f2 int, primary key(f0)) ", + DB_1, SINGLE_PK); + String createSql2 = String + .format("create table %s.%s (f0 int, f1 int, f2 int, primary key(f0), unique key uk(f1)) ", + DB_1, SINGLE_PK_SINGLE_UK); + + String selectSql = String.format("select * from %s.%s order by f0", DB_1, SINGLE_PK_SINGLE_UK); + + execUpdate(srcConn, createSql1, null); + execUpdate(dstConn, createSql1, null); + execUpdate(srcConn, createSql2, null); + execUpdate(dstConn, createSql2, null); + + // 对于 SINGLE_PK_SINGLE_UK 表,所有 sql 不修改 uk/pk + String sql1_1 = String.format("insert into %s.%s values(1,1,1)", DB_1, SINGLE_PK); + String sql1_2 = String.format("insert into %s.%s values(2,2,2)", DB_1, SINGLE_PK); + String sql1_3 = String.format("update %s.%s set f1 = 3 where f0 = 1", DB_1, SINGLE_PK); + String sql1_4 = String.format("update %s.%s set f1 = 1 where f0 = 2", DB_1, SINGLE_PK); + + // 对于 SINGLE_PK_SINGLE_UK 表,sql2_3 修改 f1(uk), sql2_4 修改 f1(uk) + String sql2_1 = String.format("insert into %s.%s values(1,1,1)", DB_1, SINGLE_PK_SINGLE_UK); + String sql2_2 = String.format("insert into %s.%s values(2,2,2)", DB_1, SINGLE_PK_SINGLE_UK); + String sql2_3 = String.format("update %s.%s set f1 = 3 where f0 = 1", DB_1, SINGLE_PK_SINGLE_UK); + String sql2_4 = String.format("update %s.%s set f1 = 1 where f0 = 2", DB_1, SINGLE_PK_SINGLE_UK); + + // execute sqls + BinlogPosition position0 = getLastBinlogPosition(); + execUpdate(srcConn, sql1_1, null); + execUpdate(srcConn, sql2_1, null); + + BinlogPosition position1 = getLastBinlogPosition(); + execUpdate(srcConn, sql1_2, null); + execUpdate(srcConn, sql2_2, null); + + BinlogPosition position2 = getLastBinlogPosition(); + execUpdate(srcConn, sql1_3, null); + execUpdate(srcConn, sql2_3, null); + + BinlogPosition position3 = getLastBinlogPosition(); + execUpdate(srcConn, sql1_4, null); + execUpdate(srcConn, sql2_4, null); + + // start runner + setupService(position0); + runnerThread.start(); + wait(WAIT_TASK_SECOND * 2); + checkBackTrackingTestResult(selectSql); + + // 情况 1 + // 已经记录的位点 + // insert (1, 1, 1),当前: (1, 1, 1) + // insert (2, 2, 2),当前: (1, 1, 1), (2, 2, 2) + // update (1, 1, 1) to (1, 3, 1), 当前: (1, 3, 1), (2, 2, 2) + // update (2, 2, 2) to (2, 1, 2), 当前: (1, 3, 1), (2, 1, 2) + // 实际执行完的地方 + + // stop runner + super.after(); + // start runner + setupService(position0); + runnerThread.start(); + wait(WAIT_TASK_SECOND * 2); + checkBackTrackingTestResult(selectSql); + + // 情况 2 + // insert (1, 1, 1),当前: (1, 1, 1) + // 已经记录的位点 + // insert (2, 2, 2),当前: (1, 1, 1), (2, 2, 2) + // update (1, 1, 1) to (1, 3, 1), 当前: (1, 3, 1), (2, 2, 2) + // update (2, 2, 2) to (2, 1, 2), 当前: (1, 3, 1), (2, 1, 2) + // 实际执行完的地方 + + // stop runner + super.after(); + // start runner + setupService(position1); + runnerThread.start(); + wait(WAIT_TASK_SECOND * 2); + checkBackTrackingTestResult(selectSql); + + // 情况 3 + // insert (1, 1, 1),当前: (1, 1, 1) + // insert (2, 2, 2),当前: (1, 1, 1), (2, 2, 2) + // 已经记录的位点 + // update (1, 1, 1) to (1, 3, 1), 当前: (1, 3, 1), (2, 2, 2) + // update (2, 2, 2) to (2, 1, 2), 当前: (1, 3, 1), (2, 1, 2) + // 实际执行完的地方 + + // stop runner + super.after(); + // start runner + setupService(position2); + runnerThread.start(); + wait(WAIT_TASK_SECOND * 2); + checkBackTrackingTestResult(selectSql); + + // 情况 4 + // insert (1, 1, 1),当前: (1, 1, 1) + // insert (2, 2, 2),当前: (1, 1, 1), (2, 2, 2) + // update (1, 1, 1) to (1, 3, 1), 当前: (1, 3, 1), (2, 2, 2) + // 已经记录的位点 + // update (2, 2, 2) to (2, 1, 2), 当前: (1, 3, 1), (2, 1, 2) + // 实际执行完的地方 + + // stop runner + super.after(); + // start runner + setupService(position3); + runnerThread.start(); + wait(WAIT_TASK_SECOND * 2); + checkBackTrackingTestResult(selectSql); + } + + private void setupService(BinlogPosition position) throws Exception { + setupService(channel, position, null); + rplTaskRunner = new RplTaskRunner(getTaskId(channel)); + runnerThread = new Thread(() -> rplTaskRunner.start()); + } + + private void checkBackTrackingTestResult(String selectSql) { + List fields = Arrays.asList("f0", "f1", "f2"); + List> dstRes = execQuery(dstConn, selectSql, fields); + Assert.assertEquals(dstRes.size(), 2); + Assert.assertEquals(dstRes.get(0).get("f0"), "1"); + Assert.assertEquals(dstRes.get(0).get("f1"), "3"); + Assert.assertEquals(dstRes.get(0).get("f2"), "1"); + Assert.assertEquals(dstRes.get(1).get("f0"), "2"); + Assert.assertEquals(dstRes.get(1).get("f1"), "1"); + Assert.assertEquals(dstRes.get(1).get("f2"), "2"); + } +} diff --git a/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/TransactionTest.java b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/TransactionTest.java new file mode 100644 index 00000000..5e339ff9 --- /dev/null +++ b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/TransactionTest.java @@ -0,0 +1,161 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.task; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import javax.sql.DataSource; + +import com.aliyun.polardbx.rpl.TestBase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.aliyun.polardbx.binlog.SpringContextBootStrap; +import com.aliyun.polardbx.rpl.RplTaskRunner; +import com.aliyun.polardbx.rpl.applier.ApplyHelper; +import com.aliyun.polardbx.rpl.applier.SqlContext; +import com.aliyun.polardbx.rpl.common.DataSourceUtil; +import com.aliyun.polardbx.rpl.common.NamedThreadFactory; + +/** + * @author shicai.xsc 2021/3/18 11:12 + * @since 5.0.0.0 + */ +public class TransactionTest extends TestBase { + + @Before + public void before() throws Exception { + channel = "transactionTest"; + super.before(); + } + + @After + public void after() throws Exception { + super.after(); + } + + @Test + public void startTask_Test() throws Exception { + RplTaskRunner runner = new RplTaskRunner(288); + runner.start(); + } + + @Test + public void insertData_Test() throws Exception { + ExecutorService executorService = Executors.newFixedThreadPool(20, new NamedThreadFactory("test")); + for (int i = 0; i < 20; i++) { + final int j = i; + executorService.submit(() -> { + int start = 30000 + j * 2000000; + while (true) { + ApplyHelper.tranExecUpdate(srcDs, getSqlContexts1(start)); + ApplyHelper.tranExecUpdate(srcDs, getSqlContexts2(start)); + ApplyHelper.tranExecUpdate(srcDs, getSqlContexts3(start)); + ApplyHelper.tranExecUpdate(srcDs, getSqlContexts4(start)); + start += 10; + } + }); + } + Thread.sleep(10000000); + } + + private List getSqlContexts1(int start) { + List contexts = new ArrayList<>(); + + for (int i = start; i < start + 10; i++) { + SqlContext context1 = new SqlContext( + "INSERT INTO `rpl`.`t1`(id,value) VALUES (?,?) ON DUPLICATE KEY UPDATE id=?,value=?", + "t1", + Arrays.asList(i, i, i, i)); + SqlContext context2 = new SqlContext( + "INSERT INTO `rpl`.`t2`(id,value) VALUES (?,?) ON DUPLICATE KEY UPDATE id=?,value=?", + "t2", + Arrays.asList(i, i, i, i)); + SqlContext context3 = new SqlContext("UPDATE `rpl`.`t1` SET value= ? WHERE id=?", + "t1", + Arrays.asList(i + 1, i)); + SqlContext context4 = new SqlContext("UPDATE `rpl`.`t2` SET value= ? WHERE id=?", + "t2", + Arrays.asList(i + 1, i)); + contexts.add(context1); + contexts.add(context2); + contexts.add(context3); + contexts.add(context4); + } + + return contexts; + } + + private List getSqlContexts2(int start) { + List contexts = new ArrayList<>(); + + for (int i = start; i < start + 10; i++) { + SqlContext context1 = new SqlContext( + "INSERT INTO `rpl`.`t3`(id,value) VALUES (?,?) ON DUPLICATE KEY UPDATE id=?,value=?", + "t3", + Arrays.asList(i, i, i, i)); + SqlContext context2 = new SqlContext("UPDATE `rpl`.`t3` SET value= ? WHERE id=?", + "t3", + Arrays.asList(i + 2, i)); + contexts.add(context1); + contexts.add(context2); + } + + return contexts; + } + + private List getSqlContexts3(int start) { + List contexts = new ArrayList<>(); + + for (int i = start; i < start + 10; i++) { + SqlContext context1 = new SqlContext( + "INSERT INTO `rpl`.`t4`(id,value) VALUES (?,?) ON DUPLICATE KEY UPDATE id=?,value=?", + "t4", + Arrays.asList(i, i, i, i)); + SqlContext context2 = new SqlContext("UPDATE `rpl`.`t4` SET value= ? WHERE id=?", + "t4", + Arrays.asList(i + 3, i)); + SqlContext context3 = new SqlContext("UPDATE `rpl`.`t4` SET value= ? WHERE id=?", + "t4", + Arrays.asList(i + 4, i)); + contexts.add(context1); + contexts.add(context2); + contexts.add(context3); + } + + return contexts; + } + + private List getSqlContexts4(int start) { + List contexts = new ArrayList<>(); + + for (int i = start; i < start + 5; i++) { + SqlContext context1 = new SqlContext("DELETE FROM `rpl`.`t3` WHERE id=?", "t3", Arrays.asList(i)); + SqlContext context2 = new SqlContext("DELETE FROM `rpl`.`t4` WHERE id=?", "t4", Arrays.asList(i)); + contexts.add(context1); + contexts.add(context2); + } + + return contexts; + } +} diff --git a/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/TransferTest.java b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/TransferTest.java new file mode 100644 index 00000000..e54652c9 --- /dev/null +++ b/polardbx-cdc-rpl/src/test/java/com/aliyun/polardbx/rpl/task/TransferTest.java @@ -0,0 +1,109 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.rpl.task; + +import com.aliyun.polardbx.binlog.transfer.Bank; +import com.aliyun.polardbx.binlog.transfer.PrepareData; +import com.aliyun.polardbx.rpl.TestBase; +import com.google.common.collect.Lists; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * @author shicai.xsc 2021/4/22 16:43 + * @since 5.0.0.0 + */ +public class TransferTest extends TestBase { + + private String dbName = "rpl_transfer_test"; + private boolean isPolarx = false; + private int runSeconds = 60; + private int connectionCount = 20; + + @Before + public void before() throws Exception { + channel = "transferTest"; + super.before(); + } + + @After + public void after() throws Exception { + super.after(); + } + + @Test + public void transferTest() throws Exception { + execUpdate(srcConn, "drop database if exists rpl_transfer_test", null); + execUpdate(srcConn, "create database rpl_transfer_test", null); + + runnerThread.start(); + wait(WAIT_TASK_SECOND); + + int accountCount = 100; + int initialAmount = 1000; + + System.setProperty("java.util.concurrent.ForkJoinPool.common.parallelism", connectionCount + ""); + String url = String.format( + "jdbc:mysql://%s:%d/%s?autoReconnect=true&useUnicode=true&createDatabaseIfNotExist=true&characterEncoding=utf8&useSSL=false&serverTimezone=UTC", + srcHostInfo.getHost(), + srcHostInfo.getPort(), + dbName); + + // 创建连接 + List connectionList = Lists.newArrayListWithCapacity(connectionCount); + for (int i = 0; i < connectionCount; i++) { + Connection connection = DriverManager + .getConnection(url, srcHostInfo.getUserName(), srcHostInfo.getPassword()); + connectionList.add(connection); + } + + // 准备数据 + PrepareData.setPolarx(isPolarx); + PrepareData.init(connectionList.get(0), accountCount, initialAmount); + + // 启动转账 + Bank bank = new Bank(accountCount, initialAmount, false); + bank.setPolarx(isPolarx); + new Thread(() -> bank.startWork(connectionList)).start(); + wait(runSeconds); + bank.stop(); + + // 校验结果 + wait(1); + List fields = Arrays.asList("id", "balance"); + String sql = String.format("select * from %s.accounts order by id", dbName); + + List> srcRes = execQuery(srcConn, sql, fields); + List> dstRes = execQuery(dstConn, sql, fields); + Assert.assertEquals(srcRes.size(), dstRes.size()); + for (int i = 0; i < srcRes.size(); i++) { + Map srcRecord = srcRes.get(i); + Map dstRecord = dstRes.get(i); + Assert.assertEquals(srcRecord.get("id"), dstRecord.get("id")); + Assert.assertEquals(srcRecord.get("balance"), dstRecord.get("balance")); + } + } +} diff --git a/polardbx-cdc-rpl/src/test/resources/logback.xml b/polardbx-cdc-rpl/src/test/resources/logback.xml new file mode 100644 index 00000000..3a7bb5c2 --- /dev/null +++ b/polardbx-cdc-rpl/src/test/resources/logback.xml @@ -0,0 +1,224 @@ + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{36}) %X{C} - %msg%n + + + + + + + taskId + default + + + + ${HOME}/logs/polardbx-rpl/${taskId}/default.log + true + + + ${HOME}/logs/polardbx-rpl/${taskId}/%d{yyyy-MM-dd}/default.%i.log.gz + + 200MB + 30 + 5GB + 5 + + + + + + UTF-8 + + + + + + + ${HOME}/logs/polardbx-rpl/meta.log + true + + ${HOME}/logs/polardbx-rpl/%d{yyyy-MM-dd}/meta.%i.log.gz + + + 200MB + + 30 + + + + + + UTF-8 + + + + + + taskId + default + + + + ${HOME}/logs/polardbx-rpl/${taskId}/commit.log + true + + + ${HOME}/logs/polardbx-rpl/${taskId}/%d{yyyy-MM-dd}/commit.%i.log.gz + + 200MB + 30 + 5GB + 5 + + + + + + UTF-8 + + + + + + + + taskId + default + + + + ${HOME}/logs/polardbx-rpl/${taskId}/check.log + true + + + + + UTF-8 + + + + + + + + taskId + default + + + + ${HOME}/logs/polardbx-rpl/${taskId}/task.log + true + + + + + UTF-8 + + + + + + + + taskId + default + + + + ${HOME}/logs/polardbx-rpl/${taskId}/position.log + true + + + + + UTF-8 + + + + + + + + taskId + default + + + + ${HOME}/logs/polardbx-rpl/${taskId}/statistic.log + true + + + + + UTF-8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/polardbx-cdc-storage/pom.xml b/polardbx-cdc-storage/pom.xml index ccde0f21..ef810b7c 100644 --- a/polardbx-cdc-storage/pom.xml +++ b/polardbx-cdc-storage/pom.xml @@ -6,7 +6,7 @@ com.aliyun.polardbx polardbx-cdc - 5.4.12-SNAPSHOT + 5.4.13-SNAPSHOT com.aliyun.polardbx polardbx-cdc-storage diff --git a/polardbx-cdc-storage/src/main/java/com/aliyun/polardbx/binlog/storage/TxnBuffer.java b/polardbx-cdc-storage/src/main/java/com/aliyun/polardbx/binlog/storage/TxnBuffer.java index b82e57dd..96f8afa7 100644 --- a/polardbx-cdc-storage/src/main/java/com/aliyun/polardbx/binlog/storage/TxnBuffer.java +++ b/polardbx-cdc-storage/src/main/java/com/aliyun/polardbx/binlog/storage/TxnBuffer.java @@ -17,6 +17,7 @@ package com.aliyun.polardbx.binlog.storage; +import com.aliyun.polardbx.binlog.DynamicApplicationConfig; import com.aliyun.polardbx.binlog.canal.binlog.LogEvent; import com.aliyun.polardbx.binlog.error.PolardbxException; import org.apache.commons.lang3.StringUtils; @@ -32,12 +33,15 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; +import static com.aliyun.polardbx.binlog.ConfigKeys.TASK_TRACEID_DISORDER_IGNORE; + /** * Created by ziyang.lb **/ public class TxnBuffer { private static final Logger logger = LoggerFactory.getLogger(TxnBuffer.class); + private static final Logger traceIdLogger = LoggerFactory.getLogger("traceIdDisorderLogger"); private static final AtomicLong sequenceGenerator = new AtomicLong(0L); private final TxnKey txnKey; @@ -135,11 +139,17 @@ public void push(TxnBufferItem txnItem) { throw new PolardbxException("can't push item to completed txn buffer."); } - if (StringUtils.isNotBlank(lastTraceId) && txnKey.isCheckTraceId()) { - //traceId是允许重复的,但不能回跳,所以此处只对乱序的情况进行校验 - if (txnItem.getTraceId().compareTo(lastTraceId) < 0) { + //traceId是允许重复的,但不能回跳,所以此处只对乱序的情况进行校验 + if (StringUtils.isNotBlank(lastTraceId) && txnItem.getTraceId().compareTo(lastTraceId) < 0) { + boolean ignoreDisorderedTraceId = DynamicApplicationConfig.getBoolean(TASK_TRACEID_DISORDER_IGNORE); + if (!ignoreDisorderedTraceId) { throw new PolardbxException("detected disorderly traceId,current traceId is " + txnItem.getTraceId() + ",last traceId is " + lastTraceId); + } else { + traceIdLogger.warn("detected disorderly traceId,current traceId is " + txnItem.getTraceId() + + " , last traceId is " + lastTraceId + " , origin traceId is " + txnItem.getOriginTraceId() + + " , binlog file name is " + txnItem.getBinlogFile() + " , binlog position is " + txnItem + .getBinlogPosition()); } } @@ -148,9 +158,9 @@ public void push(TxnBufferItem txnItem) { private void doAdd(TxnBufferItem txnItem) { //add to list && try persist - TxnItemRef ref = new TxnItemRef(this, - txnItem.getTraceId(), txnItem.getEventType(), - txnItem.getPayload(), txnItem.getByteStringPayload(), repository); + TxnItemRef ref = new TxnItemRef(this, txnItem.getTraceId(), txnItem.getRowsQuery(), + txnItem.getEventType(), txnItem.getPayload(), txnItem.getByteStringPayload(), txnItem.getSchema(), + txnItem.getTable(), repository); refList.add(ref); memSize += txnItem.size(); @@ -230,14 +240,25 @@ byte[] buildTxnItemRefKey() { private List mergeTwoSortList(List aList, List bList) { int aLength = aList.size(), bLength = bList.size(); List mergeList = new ArrayList<>(); + String lastTraceId = ""; int i = 0, j = 0; while (aLength > i && bLength > j) { if (aList.get(i).getEventType() == LogEvent.TABLE_MAP_EVENT && bList.get(j).getEventType() == LogEvent.TABLE_MAP_EVENT) { if (aList.get(i).compareTo(bList.get(j)) > 0) { + if (bList.get(j).getTraceId().equals(lastTraceId)) { + bList.get(j).setRowsQuery(""); + } else { + lastTraceId = bList.get(j).getTraceId(); + } mergeList.add(i + j, bList.get(j)); j++; } else { + if (aList.get(i).getTraceId().equals(lastTraceId)) { + aList.get(i).setRowsQuery(""); + } else { + lastTraceId = aList.get(i).getTraceId(); + } mergeList.add(i + j, aList.get(i)); i++; } diff --git a/polardbx-cdc-storage/src/main/java/com/aliyun/polardbx/binlog/storage/TxnBufferItem.java b/polardbx-cdc-storage/src/main/java/com/aliyun/polardbx/binlog/storage/TxnBufferItem.java index 687a9997..2f451590 100644 --- a/polardbx-cdc-storage/src/main/java/com/aliyun/polardbx/binlog/storage/TxnBufferItem.java +++ b/polardbx-cdc-storage/src/main/java/com/aliyun/polardbx/binlog/storage/TxnBufferItem.java @@ -28,9 +28,17 @@ @Builder public class TxnBufferItem { private String traceId; + private String rowsQuery; private int eventType; private byte[] payload; private ByteString byteStringPayload; + private String schema; + private String table; + + //可选项 + private String binlogFile; + private long binlogPosition; + private String originTraceId; public int size() { if (payload != null) { diff --git a/polardbx-cdc-storage/src/main/java/com/aliyun/polardbx/binlog/storage/TxnItemRef.java b/polardbx-cdc-storage/src/main/java/com/aliyun/polardbx/binlog/storage/TxnItemRef.java index e77d037a..7f047356 100644 --- a/polardbx-cdc-storage/src/main/java/com/aliyun/polardbx/binlog/storage/TxnItemRef.java +++ b/polardbx-cdc-storage/src/main/java/com/aliyun/polardbx/binlog/storage/TxnItemRef.java @@ -33,12 +33,17 @@ public class TxnItemRef implements Comparable { private final int eventType; private final Repository repository; private final AtomicBoolean persisted; + private final int payloadSize; + private byte[] referenceKey; + private String rowsQuery; + private String schema; + private String table; private volatile byte[] payload; private volatile ByteString byteStringPayload; - private final int payloadSize; - TxnItemRef(TxnBuffer txnBuffer, String traceId, int eventType, byte[] payload, ByteString byteStringPayload, + TxnItemRef(TxnBuffer txnBuffer, String traceId, String rowsQuery, int eventType, byte[] payload, + ByteString byteStringPayload, String schema, String table, Repository repository) { if (payload != null && byteStringPayload != null) { throw new IllegalStateException( @@ -52,9 +57,12 @@ public class TxnItemRef implements Comparable { this.txnBuffer = txnBuffer; this.traceId = traceId; + this.rowsQuery = rowsQuery == null ? "" : rowsQuery; this.eventType = eventType; this.payload = payload; this.byteStringPayload = byteStringPayload; + this.schema = schema; + this.table = table; this.payloadSize = payload != null ? payload.length : byteStringPayload.size(); this.repository = repository; this.persisted = new AtomicBoolean(false); @@ -90,6 +98,14 @@ public int getEventType() { return eventType; } + public String getRowsQuery() { + return rowsQuery; + } + + public void setRowsQuery(String rowsQuery) { + this.rowsQuery = rowsQuery; + } + public boolean isPersisted() { return persisted.get(); } @@ -98,6 +114,22 @@ public int getPayloadSize() { return payloadSize; } + public String getSchema() { + return schema; + } + + public void setSchema(String schema) { + this.schema = schema; + } + + public String getTable() { + return table; + } + + public void setTable(String table) { + this.table = table; + } + public ByteString getByteStringPayload() { if (byteStringPayload != null) { return byteStringPayload; diff --git a/polardbx-cdc-storage/src/main/java/com/aliyun/polardbx/binlog/storage/TxnKey.java b/polardbx-cdc-storage/src/main/java/com/aliyun/polardbx/binlog/storage/TxnKey.java index 88b7d2ea..5ffe534f 100644 --- a/polardbx-cdc-storage/src/main/java/com/aliyun/polardbx/binlog/storage/TxnKey.java +++ b/polardbx-cdc-storage/src/main/java/com/aliyun/polardbx/binlog/storage/TxnKey.java @@ -35,19 +35,9 @@ public class TxnKey { */ private final String partitionId; - /** - * 是否验证traceId的顺序,默认为true - */ - private final boolean checkTraceId; - public TxnKey(String txnId, String partitionId) { - this(txnId, partitionId, true); - } - - public TxnKey(String txnId, String partitionId, boolean checkTraceId) { this.txnId = txnId; this.partitionId = partitionId; - this.checkTraceId = checkTraceId; } public String getTxnId() { @@ -58,10 +48,6 @@ public String getPartitionId() { return partitionId; } - public boolean isCheckTraceId() { - return checkTraceId; - } - // equals和hashcode,用txnId和partitionId就够了 @Override public boolean equals(Object o) { @@ -82,7 +68,6 @@ public int hashCode() { @Override public String toString() { - return "TxnKey{" + "txnId='" + txnId + '\'' + ", partitionId='" + partitionId + '\'' + ", checkTraceId=" - + checkTraceId + '}'; + return "TxnKey{" + "txnId='" + txnId + '\'' + ", partitionId='" + partitionId + '\'' + '}'; } } diff --git a/polardbx-cdc-storage/src/test/java/com/aliyun/polardbx/binlog/storage/TxnBufferTest.java b/polardbx-cdc-storage/src/test/java/com/aliyun/polardbx/binlog/storage/TxnBufferTest.java index 42f69566..1c3d53da 100644 --- a/polardbx-cdc-storage/src/test/java/com/aliyun/polardbx/binlog/storage/TxnBufferTest.java +++ b/polardbx-cdc-storage/src/test/java/com/aliyun/polardbx/binlog/storage/TxnBufferTest.java @@ -45,7 +45,8 @@ public void testMerge() { Assert.assertEquals(size * (count + 1), txnBuffer.itemSize()); // 验证是否有序 - final TxnItemRef lastRef = new TxnItemRef(txnBuffer, "", 19, null, null, null); + final TxnItemRef lastRef = new TxnItemRef(txnBuffer, "", "", 19, null, + null, null, null, null); txnBuffer.iterator().forEachRemaining(i -> { int result = i.compareTo(lastRef); Assert.assertTrue(result > 0); @@ -62,8 +63,9 @@ public void testSeek() { boolean result = txnBuffer.seek(seed); Assert.assertTrue(result); Assert.assertEquals(index, txnBuffer.itemSize()); - Assert - .assertFalse(txnBuffer.seek(new TxnItemRef(txnBuffer, UUID.randomUUID().toString(), 19, null, null, null))); + Assert.assertFalse(txnBuffer.seek( + new TxnItemRef(txnBuffer, UUID.randomUUID().toString(), "", 19, null, + null, null, null, null))); } private static void testMergePerformance() { diff --git a/polardbx-cdc-task/pom.xml b/polardbx-cdc-task/pom.xml index edaaf6bf..c7f212c5 100644 --- a/polardbx-cdc-task/pom.xml +++ b/polardbx-cdc-task/pom.xml @@ -6,7 +6,7 @@ com.aliyun.polardbx polardbx-cdc - 5.4.12-SNAPSHOT + 5.4.13-SNAPSHOT ../pom.xml com.aliyun.polardbx diff --git a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/TaskEngine.java b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/TaskEngine.java index 9a979c3b..639ddca5 100644 --- a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/TaskEngine.java +++ b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/TaskEngine.java @@ -60,6 +60,7 @@ import static com.aliyun.polardbx.binlog.ConfigKeys.STORAGE_PERSIST_REPO_UNIT_COUNT; import static com.aliyun.polardbx.binlog.ConfigKeys.STORAGE_TXNITEM_PERSIST_THRESHOLDE; import static com.aliyun.polardbx.binlog.ConfigKeys.STORAGE_TXN_PERSIST_THRESHOLD; +import static com.aliyun.polardbx.binlog.scheduler.model.TaskConfig.ORIGIN_TSO; /** * Created by ziyang.lb @@ -252,13 +253,15 @@ private Collector buildCollector() { } private LogEventMerger buildMerger(String startTSO) { + String expectedStorageTso = StorageUtil.buildExpectedStorageTso(startTSO); LogEventMerger result = new LogEventMerger(taskInfo.getType(), collector, DynamicApplicationConfig.getBoolean(ConfigKeys.TASK_MERGER_MERGE_NOTSO_XA), startTSO, DynamicApplicationConfig.getBoolean(ConfigKeys.TASK_MERGER_DRYRUN), DynamicApplicationConfig.getInt(ConfigKeys.TASK_MERGER_DRYRUN_MODE), - storage); + storage, + StringUtils.equals(expectedStorageTso, ORIGIN_TSO) ? null : expectedStorageTso); result.addHeartBeatWindowAware(collector); result.setForceCompleteHbWindow(taskInfo.isForceCompleteHbWindow()); return result; diff --git a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/BinlogExtractor.java b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/BinlogExtractor.java index 004eb2b8..f6452800 100644 --- a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/BinlogExtractor.java +++ b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/BinlogExtractor.java @@ -19,6 +19,7 @@ import com.alibaba.fastjson.JSON; import com.aliyun.polardbx.binlog.CommonUtils; +import com.aliyun.polardbx.binlog.DynamicApplicationConfig; import com.aliyun.polardbx.binlog.ServerConfigUtil; import com.aliyun.polardbx.binlog.SpringContextHolder; import com.aliyun.polardbx.binlog.canal.CanalBootstrap; @@ -50,6 +51,8 @@ import java.util.List; import java.util.Map; +import static com.aliyun.polardbx.binlog.ConfigKeys.ASSIGNED_DN_IP; + /** * @author chengjin.lyf on 2020/7/10 6:59 下午 * @since 1.0.25 @@ -98,7 +101,13 @@ public void init(BinlogParameter binlogParameter, Storage storage) { if (dataList.size() != 1) { throw new PolardbxException("storageInstId expect size 1 , but query meta db size " + dataList.size()); } - String ip = (String) dataList.get(0).get("ip"); + + String ip; + if (StringUtils.isNotBlank(DynamicApplicationConfig.getString(ASSIGNED_DN_IP))) { + ip = DynamicApplicationConfig.getString(ASSIGNED_DN_IP); + } else { + ip = (String) dataList.get(0).get("ip"); + } int port = (int) dataList.get(0).get("port"); String user = (String) dataList.get(0).get("user"); String passwordEnc = (String) dataList.get(0).get("passwd_enc"); diff --git a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/DefaultOutputMergeSourceHandler.java b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/DefaultOutputMergeSourceHandler.java index bb504687..34b10d41 100644 --- a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/DefaultOutputMergeSourceHandler.java +++ b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/DefaultOutputMergeSourceHandler.java @@ -53,7 +53,7 @@ public DefaultOutputMergeSourceHandler(MergeSource mergeSource, Storage storage) @Override public void handle(Transaction transaction) throws Exception { if (logger.isDebugEnabled()) { - logger.error("output transaction : " + transaction.toString()); + logger.debug("output transaction : " + transaction.toString()); } pushToken(transaction); @@ -95,7 +95,7 @@ private void pushToken(Transaction transaction) throws Exception { .setTxnSize(transaction.getEventCount()) .setTxnId(txnId) .setType(TxnType.DML) - .setBeginSchema(transaction.getStartSchema()) + .setSchema(transaction.getStartSchema()) .setTsoTransaction(transaction.isTsoTransaction()) .setXaTxn(transaction.isXa()) .setSnapshotSeq(transaction.getSnapshotSeq() == null ? -1 : transaction.getSnapshotSeq()); @@ -114,6 +114,10 @@ private void pushToken(Transaction transaction) throws Exception { if (transaction.isDDL()) { txnTokenBuilder.setPayload(ByteString.copyFrom(transaction.getDdlEvent().getData())); txnTokenBuilder.setType(TxnType.META_DDL); + String schema = transaction.getDdlEvent().getDdlRecord().getSchemaName(); + String table = transaction.getDdlEvent().getDdlRecord().getTableName(); + txnTokenBuilder.setSchema(schema == null ? "" : schema); + txnTokenBuilder.setTable(table == null ? "" : table); logger.info("output logic ddl : " + transaction.getDdlEvent().getDdlRecord().getDdlSql() + " for : " + transaction.getVirtualTSO()); } diff --git a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/RpcExtractor.java b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/RpcExtractor.java index 168bb954..e96f954f 100644 --- a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/RpcExtractor.java +++ b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/RpcExtractor.java @@ -133,7 +133,9 @@ public void processMessage(TxnMessage message, txnBuffer.get().push( message.getTxnData().getTxnItemsList().stream() .map(i -> TxnBufferItem.builder().eventType(i.getEventType()) - .traceId(i.getTraceId()).byteStringPayload(i.getPayload()).build()) + .traceId(i.getTraceId()).byteStringPayload(i.getPayload()) + .rowsQuery(i.getRowsQuery()).schema(i.getSchema()).table(i.getTable()) + .build()) .collect(Collectors.toList()) ); } else if (processType == MessageType.END) { diff --git a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/EventAcceptFilter.java b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/EventAcceptFilter.java index e6b737e2..3878e4dc 100644 --- a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/EventAcceptFilter.java +++ b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/EventAcceptFilter.java @@ -26,7 +26,6 @@ import com.aliyun.polardbx.binlog.canal.binlog.event.QueryLogEvent; import com.aliyun.polardbx.binlog.canal.binlog.event.RowsLogEvent; import com.aliyun.polardbx.binlog.canal.binlog.event.TableMapLogEvent; -import com.aliyun.polardbx.binlog.canal.core.model.AuthenticationInfo; import com.aliyun.polardbx.binlog.cdc.meta.PolarDbXTableMetaManager; import com.aliyun.polardbx.binlog.cdc.topology.LogicMetaTopology; import com.aliyun.polardbx.binlog.error.PolardbxException; @@ -81,12 +80,9 @@ public void onStart(HandlerContext context) { delegate.addTableChangeListener(this); return; } - AuthenticationInfo authInfo = rc.getAuthenticationInfo(); try { - PolarDbXTableMetaManager polarDbXTableMetaManager = new PolarDbXTableMetaManager(rc.getStorageInstId(), - null, - null); - polarDbXTableMetaManager.init(authInfo.getAddress().getHostName()); + PolarDbXTableMetaManager polarDbXTableMetaManager = new PolarDbXTableMetaManager(rc.getStorageInstId()); + polarDbXTableMetaManager.init(); if (rc.isRecovery()) { logger.info("start rollback to " + rc.getStartPosition().getRtso()); polarDbXTableMetaManager.rollback(rc.getStartPosition()); @@ -141,9 +137,15 @@ private void removeUnAcceptTable(Set phyTables, String schema, String gr } private void refreshFilter() { - logger.info("start rebuild table filter : " + new Gson().toJson(filter) + " => " + storageInstanceId); + if (logger.isDebugEnabled()) { + logger.debug("start rebuild table filter : " + new Gson().toJson(filter) + " => " + storageInstanceId); + } + this.filter = delegate.buildTableFilter(storageInstanceId); - logger.info("success rebuild filter : " + new Gson().toJson(filter) + " => " + storageInstanceId); + + if (logger.isDebugEnabled()) { + logger.debug("success rebuild filter : " + new Gson().toJson(filter) + " => " + storageInstanceId); + } } @Override diff --git a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/RebuildEventLogFilter.java b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/RebuildEventLogFilter.java index 22cf0ca6..cd9c1f73 100644 --- a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/RebuildEventLogFilter.java +++ b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/RebuildEventLogFilter.java @@ -18,7 +18,15 @@ package com.aliyun.polardbx.binlog.extractor.filter; import com.alibaba.polardbx.druid.DbType; +import com.alibaba.polardbx.druid.sql.SQLUtils; import com.alibaba.polardbx.druid.sql.ast.SQLStatement; +import com.alibaba.polardbx.druid.sql.ast.expr.SQLIdentifierExpr; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableDropIndex; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableItem; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLDropIndexStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLDropTableStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLExprTableSource; import com.alibaba.polardbx.druid.sql.dialect.mysql.ast.statement.DrdsMoveDataBase; import com.alibaba.polardbx.druid.sql.parser.SQLParserUtils; import com.alibaba.polardbx.druid.sql.parser.SQLStatementParser; @@ -42,6 +50,7 @@ import com.aliyun.polardbx.binlog.canal.core.model.BinlogPosition; import com.aliyun.polardbx.binlog.canal.core.model.ServerCharactorSet; import com.aliyun.polardbx.binlog.canal.system.SystemDB; +import com.aliyun.polardbx.binlog.cdc.meta.CreateDropTableWithExistFilter; import com.aliyun.polardbx.binlog.cdc.meta.LogicTableMeta; import com.aliyun.polardbx.binlog.cdc.meta.domain.DDLRecord; import com.aliyun.polardbx.binlog.cdc.topology.LogicMetaTopology; @@ -82,9 +91,12 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Optional; import java.util.Set; +import static com.aliyun.polardbx.binlog.CommonUtils.escape; import static com.aliyun.polardbx.binlog.ConfigKeys.META_USE_HISTORY_TABLE_FIRST; +import static com.aliyun.polardbx.binlog.canal.system.SystemDB.AUTO_LOCAL_INDEX_PREFIX; /** * @author chengjin.lyf on 2020/8/7 3:13 下午 @@ -93,11 +105,11 @@ public class RebuildEventLogFilter implements LogEventFilter { private static final Logger logger = LoggerFactory.getLogger(RebuildEventLogFilter.class); - private long serviceId; private static final ThreadLocal localBuffer = new ThreadLocal(); private final LogDecoder logDecoder = new LogDecoder(); private final Set cdcSchemaSet; private final EventAcceptFilter eventAcceptFilter; + private long serviceId; private ITableMetaDelegate delegate; private String defaultCharset; private FormatDescriptionLogEvent fde; @@ -116,7 +128,8 @@ public RebuildEventLogFilter(long serviceId, EventAcceptFilter eventAcceptFilter logDecoder.handle(LogEvent.TABLE_MAP_EVENT); } - private boolean reformat(LogEvent event, HandlerContext context, String virtualTSO) throws Exception { + private boolean reformat(TxnItemRef txnItemRef, LogEvent event, HandlerContext context, String virtualTSO) + throws Exception { int type = event.getHeader().getType(); switch (type) { @@ -125,18 +138,18 @@ private boolean reformat(LogEvent event, HandlerContext context, String virtualT return false; case LogEvent.UPDATE_ROWS_EVENT_V1: case LogEvent.UPDATE_ROWS_EVENT: - rebuildRowLogEvent((RowsLogEvent) event, LogEvent.UPDATE_ROWS_EVENT); + rebuildRowLogEvent(txnItemRef, (RowsLogEvent) event, LogEvent.UPDATE_ROWS_EVENT); break; case LogEvent.DELETE_ROWS_EVENT: case LogEvent.DELETE_ROWS_EVENT_V1: - rebuildRowLogEvent((RowsLogEvent) event, LogEvent.DELETE_ROWS_EVENT); + rebuildRowLogEvent(txnItemRef, (RowsLogEvent) event, LogEvent.DELETE_ROWS_EVENT); break; case LogEvent.WRITE_ROWS_EVENT: case LogEvent.WRITE_ROWS_EVENT_V1: - rebuildRowLogEvent((RowsLogEvent) event, LogEvent.WRITE_ROWS_EVENT); + rebuildRowLogEvent(txnItemRef, (RowsLogEvent) event, LogEvent.WRITE_ROWS_EVENT); break; case LogEvent.TABLE_MAP_EVENT: - rebuildTableMapEvent((TableMapLogEvent) event, context); + rebuildTableMapEvent(txnItemRef, (TableMapLogEvent) event, context); break; default: // should not be here @@ -145,7 +158,8 @@ private boolean reformat(LogEvent event, HandlerContext context, String virtualT return true; } - private void rebuildTableMapEvent(TableMapLogEvent tle, HandlerContext context) throws Exception { + private void rebuildTableMapEvent(TxnItemRef txnItemRef, TableMapLogEvent tle, HandlerContext context) + throws Exception { if (SystemDB.isSys(tle.getDbName())) { return; } @@ -181,6 +195,8 @@ private void rebuildTableMapEvent(TableMapLogEvent tle, HandlerContext context) throw e; } } + txnItemRef.setSchema(tableMeta.getLogicSchema()); + txnItemRef.setTable(tableMeta.getLogicTable()); tme.setSchema(tableMeta.getLogicSchema()); tme.setTableName(tableMeta.getLogicTable()); tle.setNewData(toByte(tme)); @@ -189,22 +205,23 @@ private void rebuildTableMapEvent(TableMapLogEvent tle, HandlerContext context) } } - private void rebuildRowLogEvent(RowsLogEvent rle, int eventType) { + private void rebuildRowLogEvent(TxnItemRef txnItemRef, RowsLogEvent rle, int eventType) { if (SystemDB.isSys(rle.getTable().getDbName())) { return; } LogicTableMeta tableMeta = delegate.compare(rle.getTable().getDbName(), rle.getTable().getTableName()); // 整形只考虑 insert,其他可以不考虑,如果 是全镜像导致下游报错,则全部都需要处理 if (logger.isDebugEnabled()) { - logger.debug( - "detected compatible " + tableMeta.isCompatible() + " table meta for event, will reformat event " - + tableMeta.getPhySchema() + tableMeta.getPhyTable()); + logger.debug("detected compatible " + tableMeta.isCompatible() + " table meta for event, " + + "will reformat event " + tableMeta.getPhySchema() + tableMeta.getPhyTable()); } try { RowEventBuilder reb = RowsLogEventRebuilder.convert(rle, serviceId); if (!tableMeta.isCompatible()) { rebuildRowEventBuilder(tableMeta, reb, rle.getTable()); } + txnItemRef.setSchema(tableMeta.getLogicSchema()); + txnItemRef.setTable(tableMeta.getLogicTable()); rle.setNewData(toByte(reb)); } catch (Exception e) { throw new PolardbxException(" reformat log pos : " + rle.getHeader().getLogPos() + " occur error", e); @@ -298,7 +315,7 @@ public void handle(TransactionGroup event, HandlerContext context) throws Except serviceId = transaction.getServerId(); } try { - if (!reformat(e, context, transaction.getVirtualTSO())) { + if (!reformat(tir, e, context, transaction.getVirtualTSO())) { it.remove(); continue; } @@ -393,6 +410,7 @@ private void handleQueryLog(QueryLogEvent event, String virtualTSO, HandlerConte } private void rebuildDDL(Transaction transaction, HandlerContext context) throws Exception { + // prepare parameters DDLEvent ddlEvent = transaction.getDdlEvent(); DDLRecord ddlRecord = ddlEvent.getDdlRecord(); RuntimeContext runtimeContext = context.getRuntimeContext(); @@ -400,15 +418,7 @@ private void rebuildDDL(Transaction transaction, HandlerContext context) throws Integer clientCharsetId = CharsetConversion.getCharsetId(serverCharactorSet.getCharacterSetClient()); Integer connectionCharsetId = CharsetConversion.getCharsetId(serverCharactorSet.getCharacterSetConnection()); Integer serverCharsetId = CharsetConversion.getCharsetId(serverCharactorSet.getCharacterSetServer()); - TopologyRecord topologyRecord; - try { - topologyRecord = new Gson().fromJson(ddlRecord.getMetaInfo(), TopologyRecord.class); - } catch (Throwable t) { - topologyRecord = JsonRepairUtil.repair(ddlRecord); - if (topologyRecord == null) { - throw t; - } - } + TopologyRecord topologyRecord = tryRepairTopology(ddlRecord); String dbCharset = null; String tbCollation = null; if (topologyRecord != null) { @@ -422,7 +432,6 @@ private void rebuildDDL(Transaction transaction, HandlerContext context) throws } } - ddlEvent.getDdlRecord().setDdlSql(ddlRecord.getDdlSql()); // 用来处理一些异常情况,比如打标sql有问题,或cdc识别不了打标sql,都可以通过该方式进行容错处理 boolean useHistoryTableFirst = DynamicApplicationConfig.getBoolean(META_USE_HISTORY_TABLE_FIRST); if (useHistoryTableFirst) { @@ -431,34 +440,49 @@ private void rebuildDDL(Transaction transaction, HandlerContext context) throws String sql = getLogicSqlFromHistoryTable(ddlRecord.getSchemaName(), ddlEvent.getPosition().getRtso()); if (StringUtils.isNotBlank(sql)) { logger.warn("ddl sql in history table is " + sql); - ddlEvent.getDdlRecord().setDdlSql(sql); + ddlRecord.setDdlSql(sql); } else { logger.warn("ddl sql is not existed in history table."); } } - String orgDDL = ddlEvent.getDdlRecord().getDdlSql().trim(); - logger.info("begin to apply logic ddl : " + orgDDL + " tso : " + transaction.getVirtualTSO()); + // try rewrite for drop table sql + ddlRecord.setDdlSql(tryRewriteDropTableSql(ddlRecord.getSchemaName(), + ddlRecord.getTableName(), ddlRecord.getDdlSql())); + + // try rewrite for drop index sql + String dropIndexRewriteSql = tryRewriteForDropIndex(ddlEvent.getPosition().getRtso(), ddlRecord.getSchemaName(), + ddlRecord.getTableName(), ddlRecord.getDdlSql(), ddlEvent); + boolean hasRewrittenDropIndexSql = !StringUtils.equalsIgnoreCase(dropIndexRewriteSql, ddlRecord.getDdlSql()); + if (StringUtils.isBlank(dropIndexRewriteSql)) { + ddlEvent.setVisible(false); + } + + // apply logic ddl sql + String originDDL = ddlRecord.getDdlSql().trim(); + logger.info("begin to apply logic ddl : " + originDDL + ", tso : " + transaction.getVirtualTSO()); boolean isNormalDDL = true; String ddl = "select 1"; - if (isMoveDataBaseSql(orgDDL)) { + if (isMoveDataBaseSql(originDDL)) { isNormalDDL = false; } else { - ddl = DDLConverter.formatPolarxDDL(ddlRecord.getTableName(), orgDDL, dbCharset, tbCollation, + ddl = DDLConverter.formatPolarxDDL(ddlRecord.getTableName(), originDDL, dbCharset, tbCollation, runtimeContext.getLowerCaseTableNames()); } - - ddlEvent.getDdlRecord().setOriginDdlSql(orgDDL); - ddlEvent.getDdlRecord().setDdlSql(ddl); - logger.info("real apply logic ddl is : " + ddl); - delegate.applyLogic(ddlEvent.getPosition(), - ddlEvent.getDdlRecord(), - ddlEvent.getExt(), + ddlRecord.setDdlSql(ddl); + logger.info("real apply logic ddl is : " + ddl + ", tso :" + transaction.getVirtualTSO()); + delegate.applyLogic(ddlEvent.getPosition(), ddlEvent.getDdlRecord(), ddlEvent.getExt(), context.getRuntimeContext()); - if (isNormalDDL) { - //转换成标准DDL - ddl = DDLConverter.convertNormalDDL(ddlRecord.getTableName(), orgDDL, dbCharset, tbCollation, + //try ignore create table or drop table sql with exists + if (CreateDropTableWithExistFilter.shouldIgnore(originDDL, ddlRecord.getId(), ddlRecord.getJobId())) { + ddlEvent.setVisible(false); + } + + //转换成标准DDL + if (isNormalDDL && ddlEvent.isVisible()) { + String sqlStr = hasRewrittenDropIndexSql ? dropIndexRewriteSql : originDDL; + ddl = DDLConverter.convertNormalDDL(ddlRecord.getTableName(), sqlStr, dbCharset, tbCollation, runtimeContext.getLowerCaseTableNames(), transaction.getVirtualTSO()); ddlEvent.setQueryEventBuilder(new QueryEventBuilder(ddlRecord.getSchemaName(), ddl, @@ -473,6 +497,10 @@ private void rebuildDDL(Transaction transaction, HandlerContext context) throws } } + private void applyLogicDdlSql() { + + } + protected boolean isMoveDataBaseSql(String ddlSql) { SQLStatementParser parser = SQLParserUtils.createSQLStatementParser(ddlSql, DbType.mysql, FastSQLConstant.FEATURES); @@ -663,6 +691,127 @@ private String getPhySqlFromHistoryTable(String dbName, String tso, String stora return ddlHistories.isEmpty() ? null : ddlHistories.get(0).getDdl(); } + private TopologyRecord tryRepairTopology(DDLRecord ddlRecord) { + TopologyRecord topologyRecord; + try { + topologyRecord = new Gson().fromJson(ddlRecord.getMetaInfo(), TopologyRecord.class); + } catch (Throwable t) { + topologyRecord = JsonRepairUtil.repair(ddlRecord); + if (topologyRecord == null) { + throw t; + } + } + return topologyRecord; + } + + String tryRewriteDropTableSql(String schema, String tableName, String ddl) { + SQLStatementParser parser = + SQLParserUtils.createSQLStatementParser(ddl, DbType.mysql, FastSQLConstant.FEATURES); + SQLStatement stmt = parser.parseStatementList().get(0); + + //fix https://work.aone.alibaba-inc.com/issue/36762424 + if (stmt instanceof SQLDropTableStatement) { + SQLDropTableStatement dropTableStatement = (SQLDropTableStatement) stmt; + if (dropTableStatement.getTableSources().size() > 1) { + Optional optional = dropTableStatement.getTableSources().stream() + .filter(ts -> + tableName.equalsIgnoreCase(ts.getTableName(true)) && (StringUtils.isBlank(ts.getSchema()) + || schema.equalsIgnoreCase(SQLUtils.normalize(ts.getSchema()))) + ).findFirst(); + if (!optional.isPresent()) { + throw new PolardbxException(String.format("can`t find table %s in sql %s", tableName, ddl)); + } else { + dropTableStatement.getTableSources().clear(); + dropTableStatement.addTableSource(optional.get()); + String newSql = dropTableStatement.toUnformattedString(); + logger.info("rewrite drop table sql from {}, to {}", ddl, newSql); + return newSql; + } + } + } + + return ddl; + } + + private String tryRewriteForDropIndex(String tso, String schema, String tableName, String sql, DDLEvent ddlEvent) { + if (!ddlEvent.isVisible()) { + return sql; + } + + SQLStatementParser parser = + SQLParserUtils.createSQLStatementParser(sql, DbType.mysql, FastSQLConstant.FEATURES); + List statementList = parser.parseStatementList(); + SQLStatement sqlStatement = statementList.get(0); + + // 因为全局索引的存在,CN对于索引的维护比较复杂,CDC为了保证和MySQL的兼容性,对带有global关键字的索引会直接忽略掉 + // CN创建global index时会指定global关键字,但是删除时是可以不指定,所以我们需要判断一下drop index sql中的索引名在meta中是否存在,如果不存在则不能传递给下游 + // 另外CN对于新分区表,在创建全局索引的时候,会自动创建local索引,判断索引是否存在的逻辑会同时判断indexName以及对应的localIndexName是否存在 + if (sqlStatement instanceof SQLDropIndexStatement) { + SQLDropIndexStatement dropIndexStatement = (SQLDropIndexStatement) sqlStatement; + String indexName = SQLUtils.normalize(dropIndexStatement.getIndexName().getSimpleName()); + String localIndexName = AUTO_LOCAL_INDEX_PREFIX + indexName; + if (!containsIndex(schema, tableName, indexName)) { + if (containsIndex(schema, tableName, localIndexName)) { + dropIndexStatement.setIndexName(new SQLIdentifierExpr("`" + escape(localIndexName) + "`")); + String newSql = dropIndexStatement.toUnformattedString(); + logger.info("rewrite drop index sql, tso is ," + tso + " sql before is " + sql + + ", sql after is " + newSql); + return newSql; + } else { + logger.info("skip drop index sql, tso is " + tso + ", sql is " + sql); + return null; + } + } + } else if (sqlStatement instanceof SQLAlterTableStatement) { + SQLAlterTableStatement sqlAlterTableStatement = (SQLAlterTableStatement) sqlStatement; + int itemSize = sqlAlterTableStatement.getItems().size(); + if (itemSize != 0) { + boolean changeFlag = false; + Iterator iterator = sqlAlterTableStatement.getItems().iterator(); + while (iterator.hasNext()) { + SQLAlterTableItem alterTableItem = iterator.next(); + if (alterTableItem instanceof SQLAlterTableDropIndex) { + SQLAlterTableDropIndex dropIndex = (SQLAlterTableDropIndex) alterTableItem; + String indexName = SQLUtils.normalize(dropIndex.getIndexName().getSimpleName()); + String localIndexName = AUTO_LOCAL_INDEX_PREFIX + indexName; + if (!containsIndex(schema, tableName, indexName)) { + if (containsIndex(schema, tableName, localIndexName)) { + dropIndex.setIndexName(new SQLIdentifierExpr("`" + escape(localIndexName) + "`")); + } else { + iterator.remove(); + } + changeFlag = true; + } + } + } + + if (changeFlag) { + String newSql = sqlAlterTableStatement.toUnformattedString(); + try { + //只要还能正常解析,就对外输出 + SQLStatementParser parserTemp = SQLParserUtils.createSQLStatementParser(newSql, DbType.mysql, + FastSQLConstant.FEATURES); + parserTemp.parseStatementList(); + } catch (Throwable t) { + logger.info("skip drop index sql, tso is " + tso + ", sql is " + sql); + return null; + } + logger.info("rewrite drop index sql, tso is " + tso + ", sql before is " + sql + + ", sql after is " + newSql); + return newSql; + } + } + } + + return sql; + } + + private boolean containsIndex(String schema, String tableName, String indexName) { + return delegate.findIndexes(schema, tableName).stream().anyMatch( + i -> StringUtils.equalsIgnoreCase(indexName, i) + ); + } + @Override public void onStart(HandlerContext context) { context.getRuntimeContext().setServerId(serviceId); diff --git a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/TransactionBufferEventFilter.java b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/TransactionBufferEventFilter.java index 96141aba..d8b1a140 100644 --- a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/TransactionBufferEventFilter.java +++ b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/TransactionBufferEventFilter.java @@ -163,9 +163,14 @@ private void processStart(LogEvent logEvent, HandlerContext context) { } lastGcn = -1L; } + if (tran.isIgnore()) { + return; + } transactionStorage.add(tran); } catch (Exception e) { - throw new CanalParseException(e); + throw new CanalParseException( + "new tran error binlogFile : " + context.getRuntimeContext().getBinlogFile() + " , logPos : " + context + .getRuntimeContext().getLogPos(), e); } } diff --git a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/rebuild/DDLConverter.java b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/rebuild/DDLConverter.java index ba95a00f..eea19bb3 100644 --- a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/rebuild/DDLConverter.java +++ b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/rebuild/DDLConverter.java @@ -96,7 +96,7 @@ public static String formatPolarxDDL(String tableName, String polarxDDL, String } ddl = tryLowercase(ddl, lowerCaseTableNames); } catch (Exception e) { - logger.error("parse ddl failed! ", e); + logger.error("parse ddl failed when format polarx ddl sql! ", e); } return ddl; } @@ -141,6 +141,7 @@ public static String convertNormalDDL(String tableName, String polarxDDL, String createTableStatement.setPrefixBroadcast(false); createTableStatement.setPrefixPartition(false); createTableStatement.setTableGroup(null); + createTableStatement.setAutoSplit(null); if (StringUtils.isNotBlank(tbCollation)) { String charset = CharsetConversion.getCharsetByCollation(tbCollation); if (StringUtils.isNotBlank(charset)) { @@ -250,7 +251,8 @@ private static boolean hasImplicit(SQLIndexDefinition indexDefinition) { } return false; } - + + //hack reason : https://aone.alibaba-inc.com/issue/36088240 private static void hack4RepairTableName(String tableName, SQLCreateTableStatement createTableStatement, String ddlSql) { if (StringUtils.isBlank(tableName)) { @@ -261,8 +263,6 @@ private static void hack4RepairTableName(String tableName, SQLCreateTableStateme String tableNameInSqlNormal = SQLUtils.normalize(tableNameInSql); if (!StringUtils.equals(tableName, tableNameInSqlNormal)) { - logger.warn("prepare to repair table name for sql {}, new tableName is {}, old tableName is {}.", - ddlSql, tableName, tableNameInSqlNormal); createTableStatement.setTableName("`" + escape(tableName) + "`"); logger.warn("repair table name in create sql, before : {}, after :{}", tableNameInSql, tableName); } diff --git a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/rebuild/ITableMetaDelegate.java b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/rebuild/ITableMetaDelegate.java index d47e537d..2adf3917 100644 --- a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/rebuild/ITableMetaDelegate.java +++ b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/rebuild/ITableMetaDelegate.java @@ -49,4 +49,6 @@ public interface ITableMetaDelegate { LogicMetaTopology.LogicDbTopology getLogicSchema(String phySchema, String phyTable); LogicTableMeta compare(String schema, String table); + + Set findIndexes(String schema, String table); } diff --git a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/rebuild/RowsLogEventRebuilder.java b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/rebuild/RowsLogEventRebuilder.java index 50ed7aa4..0475b0cc 100644 --- a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/rebuild/RowsLogEventRebuilder.java +++ b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/rebuild/RowsLogEventRebuilder.java @@ -44,7 +44,7 @@ public static RowEventBuilder convert(RowsLogEvent rowsLogEvent, long serverId) int columnLen = rowsLogEvent.getColumnLen(); // prepare prop - RowEventBuilder rowEvent = new RowEventBuilder((int) rowsLogEvent.getTableId(), + RowEventBuilder rowEvent = new RowEventBuilder(rowsLogEvent.getTableId(), rowsLogEvent.getColumnLen(), rowsLogEvent.getHeader().getType(), (int) rowsLogEvent.getWhen(), diff --git a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/rebuild/TableMetaDelegate.java b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/rebuild/TableMetaDelegate.java index 7ab2c28a..50ce8492 100644 --- a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/rebuild/TableMetaDelegate.java +++ b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/filter/rebuild/TableMetaDelegate.java @@ -27,7 +27,6 @@ import com.alibaba.polardbx.druid.sql.dialect.mysql.ast.statement.MySqlRenameTableStatement; import com.alibaba.polardbx.druid.sql.parser.SQLParserUtils; import com.alibaba.polardbx.druid.sql.parser.SQLStatementParser; -import com.aliyun.polardbx.binlog.CommonUtils; import com.aliyun.polardbx.binlog.canal.RuntimeContext; import com.aliyun.polardbx.binlog.canal.core.ddl.TableMeta; import com.aliyun.polardbx.binlog.canal.core.model.BinlogPosition; @@ -52,8 +51,8 @@ public class TableMetaDelegate implements ITableMetaDelegate { private static final Logger logger = LoggerFactory.getLogger(TableMetaDelegate.class); - private PolarDbXTableMetaManager target; - private List changeListenerList = new CopyOnWriteArrayList<>(); + private final PolarDbXTableMetaManager target; + private final List changeListenerList = new CopyOnWriteArrayList<>(); private String lastApplyLogicTSO; public TableMetaDelegate(PolarDbXTableMetaManager target) { @@ -62,12 +61,12 @@ public TableMetaDelegate(PolarDbXTableMetaManager target) { @Override public TableMeta find(String phyDbName, String phyTableName) { - return target.find(phyDbName, phyTableName); + return target.findPhyTable(phyDbName, phyTableName); } @Override public void apply(BinlogPosition position, String schema, String ddl, String extra, RuntimeContext rc) { - target.apply(position, schema, ddl, extra); + target.applyPhysical(position, schema, ddl, extra); fireEvent(schema, ddl, true, false, rc); } @@ -166,13 +165,14 @@ public void addTableChangeListener(TableMetaChangeListener listener) { @Override public void destroy() { - target.destory(); + target.destroy(); } @Override public TableMeta findLogic(String phySchema, String phyTable) { LogicMetaTopology.LogicDbTopology logicTopology = target.getLogicSchema(phySchema, phyTable); - return target.findLogic(logicTopology.getSchema(), logicTopology.getLogicTableMetas().get(0).getTableName()); + return target + .findLogicTable(logicTopology.getSchema(), logicTopology.getLogicTableMetas().get(0).getTableName()); } @Override @@ -182,10 +182,9 @@ public Map> buildTableFilter(String storageInstanceId) { phyTableTopologyList.forEach(s -> { final Set phyTables = s.getPhyTables() .stream() - .map(t -> CommonUtils.unwrap(t.toLowerCase())) + .map(String::toLowerCase) .collect(Collectors.toSet()); - final String schema = CommonUtils.unwrap(s.getSchema().toLowerCase()); - // removeUnAcceptTable(phyTables, schema, s.getGroup(), delegate); + final String schema = s.getSchema().toLowerCase(); Set tmpTablesSet = tmpFilter.computeIfAbsent(schema, k -> new HashSet<>()); tmpTablesSet.addAll(phyTables); }); @@ -195,7 +194,7 @@ public Map> buildTableFilter(String storageInstanceId) { logicDbTopologyList.forEach(t -> { t.getPhySchemas().forEach(phyDbTopology -> { if (phyDbTopology.getStorageInstId().equalsIgnoreCase(storageInstanceId)) { - String phySchema = CommonUtils.unwrap(phyDbTopology.getSchema().toLowerCase()); + String phySchema = phyDbTopology.getSchema().toLowerCase(); if (!tmpFilter.containsKey(phySchema)) { tmpFilter.put(phySchema, new HashSet<>()); } @@ -233,4 +232,9 @@ public LogicMetaTopology.LogicDbTopology getLogicSchema(String phySchema, String public LogicTableMeta compare(String schema, String table) { return target.compare(schema, table); } + + @Override + public Set findIndexes(String schema, String table) { + return target.findIndexes(schema, table); + } } diff --git a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/log/Transaction.java b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/log/Transaction.java index 5b473d79..5ce8ddd9 100644 --- a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/log/Transaction.java +++ b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/extractor/log/Transaction.java @@ -18,6 +18,8 @@ package com.aliyun.polardbx.binlog.extractor.log; import com.aliyun.polardbx.binlog.CommonUtils; +import com.aliyun.polardbx.binlog.ConfigKeys; +import com.aliyun.polardbx.binlog.DynamicApplicationConfig; import com.aliyun.polardbx.binlog.canal.HandlerEvent; import com.aliyun.polardbx.binlog.canal.LogEventUtil; import com.aliyun.polardbx.binlog.canal.RuntimeContext; @@ -56,6 +58,10 @@ import java.io.UnsupportedEncodingException; import java.util.Iterator; +import static com.aliyun.polardbx.binlog.canal.system.SystemDB.DDL_RECORD_FIELD_DDL_ID; +import static com.aliyun.polardbx.binlog.canal.system.SystemDB.DDL_RECORD_FIELD_DDL_SQL; +import static com.aliyun.polardbx.binlog.canal.system.SystemDB.DDL_RECORD_FIELD_JOB_ID; + /** * 只输出 全局有序唯一TSO,下游合并自己去做 真实TSO+Xid 合并 * @@ -64,6 +70,7 @@ */ public class Transaction implements HandlerEvent, IXaTransaction, Iterable { + private static final Logger duplicateTransactionLogger = LoggerFactory.getLogger("duplicateTransactionLogger"); private static final Logger logger = LoggerFactory.getLogger(Transaction.class); private static final String encoding = "UTF-8"; private static final String ZERO_19_PADDING = StringUtils.leftPad("0", 10, "0"); @@ -76,6 +83,7 @@ public class Transaction implements HandlerEvent, IXaTransaction, I private String orginalTraceId; private Long serverId; private String lastTraceId; + private String lastRowsQuery; private String charset; private boolean txGlobal = false; private Long txGlobalTso; @@ -101,6 +109,7 @@ public class Transaction implements HandlerEvent, IXaTransaction, I private Long snapshotSeq; private String storageInstanceId; private TxnBuffer buffer; + private boolean ignore = false; private Storage storage; private String sourceCdcSchema; private String groupName; @@ -166,8 +175,25 @@ public Transaction(LogEvent logEvent, RuntimeContext rc, Storage storage) throws } private void buildBuffer() throws AlreadyExistException { - this.bufferKey = new TxnKey(transactionId + "", partitionId); - buffer = storage.create(bufferKey); + try { + this.bufferKey = new TxnKey(transactionId + "", partitionId); + buffer = storage.create(bufferKey); + } catch (AlreadyExistException e) { + if (!DynamicApplicationConfig.getBoolean(ConfigKeys.TASK_EXCEPTION_SKIP_DUPLICATE_BUFFER_KEY)) { + throw e; + } + duplicateTransactionLogger + .warn("ignore duplicate txnKey Exception, skip transaction : " + transactionId + " , partition: " + + partitionId + " , storageId : " + storageInstanceId + ", binlogFile: " + binlogFileName + + ", logPos: " + + startLogPos + ", xid: " + xid); + buffer = null; + ignore = true; + } + } + + public boolean isIgnore() { + return ignore; } public TxnKey getBufferKey() { @@ -225,6 +251,8 @@ private void processEvent_0(LogEvent event, RuntimeContext rc) throws Unsupporte logger.error("parser trace error " + queryLogEvent.getRowsQuery(), e); throw e; } + // 暂存Rows_Query_Event的内容,放到相邻的下一个Table_Map_Event中 + lastRowsQuery = queryLogEvent.getRowsQuery(); return; } if (filter(event)) { @@ -256,17 +284,29 @@ private void addTxnBuffer(LogEvent logEvent) { if (buffer == null) { return; } + + if (StringUtils.isNotBlank(lastRowsQuery) && !lastRowsQuery.endsWith("*/")) { + lastRowsQuery = StringUtils.substringBetween(lastRowsQuery, "/*DRDS", "*/"); + lastRowsQuery = "/*DRDS" + lastRowsQuery + "*/"; + } TxnBufferItem txnItem = TxnBufferItem.builder() .traceId(logEvent.getTrace()) + .rowsQuery(lastRowsQuery) .payload(logEvent.toBytes()) .eventType(logEvent.getHeader().getType()) + .originTraceId(orginalTraceId) + .binlogFile(binlogFileName) + .binlogPosition(logEvent.getLogPos()) .build(); + + // RowsQuery Event后跟紧Table_Map,所以第一个lastRowsQuery不为空 + // 这里将lastRowsQuery设为空之后,后面的Table_Map中的rowsQuery将为空,直到获得下一个RowsQuery中的内容 + lastRowsQuery = ""; try { buffer.push(txnItem); } catch (Exception e) { - logger.error( - "push to buffer error local trace : " + orginalTraceId + " with : " + binlogFileName + ":" + logEvent - .getLogPos() + " buffer : " + buffer.getTxnKey() + " " + buffer.itemSize(), e); + logger.error("push to buffer error local trace : " + orginalTraceId + " with : " + binlogFileName + ":" + + logEvent.getLogPos() + " buffer : " + buffer.getTxnKey() + " " + buffer.itemSize(), e); logger.error("buffer cache:"); Iterator it = buffer.iterator(); while (it.hasNext()) { @@ -357,7 +397,9 @@ private void processInstruction(WriteRowsLogEvent event, RuntimeContext rc) thro private void processDDL(WriteRowsLogEvent event, RuntimeContext rc) throws UnsupportedEncodingException { BinlogParser binlogParser = new BinlogParser(); binlogParser.parse(SystemDB.getInstance().getDdlTableMeta(), event, "utf8"); - String ddl = (String) binlogParser.getField(SystemDB.DDL_RECORD_FIELD_DDL_SQL); + String id = (String) binlogParser.getField(DDL_RECORD_FIELD_DDL_ID); + String jobId = (String) binlogParser.getField(DDL_RECORD_FIELD_JOB_ID); + String ddl = (String) binlogParser.getField(DDL_RECORD_FIELD_DDL_SQL); String metaInfo = (String) binlogParser.getField(SystemDB.DDL_RECORD_FIELD_META_INFO); String sqlKind = (String) binlogParser.getField(SystemDB.DDL_RECORD_FIELD_SQL_KIND); String logicSchema = (String) binlogParser.getField(SystemDB.DDL_RECORD_FIELD_SCHEMA_NAME); @@ -365,10 +407,12 @@ private void processDDL(WriteRowsLogEvent event, RuntimeContext rc) throws Unsup String visible = (String) binlogParser.getField(SystemDB.DDL_RECORD_FIELD_VISIBILITY); String ext = (String) binlogParser.getField(SystemDB.DDL_RECORD_FIELD_EXT); DDLRecord ddlRecord = DDLRecord.builder() + .id(Long.valueOf(id)) + .jobId(StringUtils.isBlank(jobId) ? null : Long.valueOf(jobId)) .ddlSql(ddl) .sqlKind(sqlKind) - .schemaName(logicSchema) - .tableName(tableName) + .schemaName(StringUtils.lowerCase(logicSchema)) + .tableName(StringUtils.lowerCase(tableName)) .metaInfo(metaInfo) .build(); ddlEvent = new DDLEvent(); diff --git a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/merge/LogEventMerger.java b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/merge/LogEventMerger.java index 53f87a62..4fd3114a 100644 --- a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/merge/LogEventMerger.java +++ b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/merge/LogEventMerger.java @@ -76,7 +76,7 @@ public class LogEventMerger implements Merger { private final AtomicReference firstDmlToken; private MergeItem lastMergeItem; - private TxnToken lastScaleToken; + private String lastScaleTso; private long forceCountAfterLastScale; private String lastTso; private HeartBeatWindow currentWindow; @@ -87,13 +87,14 @@ public class LogEventMerger implements Merger { private volatile boolean running; public LogEventMerger(TaskType taskType, Collector collector, boolean isMergeNoTsoXa, String startTso, - boolean dryRun, int dryRunMode, Storage storage) { + boolean dryRun, int dryRunMode, Storage storage, String lastScaleTso) { this.taskType = taskType; this.collector = collector; this.startTso = startTso; this.dryRun = dryRun; this.dryRunMode = dryRunMode; this.storage = storage; + this.lastScaleTso = lastScaleTso; if (StringUtils.isNotBlank(startTso)) { this.aligned = new AtomicBoolean(true);// 如果startTso不为空,则默认为"已对齐"状态 @@ -209,7 +210,7 @@ public void start() { lastTso = minTso; doMetricsAfter(minItem.getTxnToken()); if (minItem.getTxnToken().getType() == TxnType.META_SCALE) { - lastScaleToken = minItem.getTxnToken(); + lastScaleTso = minItem.getTxnToken().getTso(); forceCountAfterLastScale = 0; logger.info("reset last scale token to : " + minItem.getTxnToken()); } @@ -262,7 +263,7 @@ private void checkHeartbeatWindow(MergeItem item) { // 当前的Window还未达到complete状态,又收到了下一批次的心跳Token,属于异常现象,抛异常处理 // 未对齐之前不进行验证 if (currentWindow != null && !currentWindow.isSameWindow(item.getTxnToken()) && aligned.get()) { - tryForceComplete(); + tryForceComplete(item.getTxnToken()); if (!currentWindow.isComplete()) { throw new PolardbxException( "Received heartbeat token for next window,but current window is not complete yet. The received " @@ -277,7 +278,7 @@ private void checkHeartbeatWindow(MergeItem item) { } else { // 当前Window还未达到complete状态,收到了非心跳Token,属于异常现象,抛异常处理 if (currentWindow != null && aligned.get()) {// 未对齐之前不进行验证 - tryForceComplete(); + tryForceComplete(item.getTxnToken()); if (!currentWindow.isComplete()) { throw new PolardbxException( "Received none heartbeat token, but current window is not ready yet. The received token is " @@ -288,17 +289,14 @@ private void checkHeartbeatWindow(MergeItem item) { } } - private void tryForceComplete() { + private void tryForceComplete(TxnToken latestToken) { if (!currentWindow.isComplete()) { if (forceCompleteHbWindow) { currentWindow.forceComplete(); return; } - if (lastScaleToken != null) { - long commitSeq = CommonUtils.getTsoTimestamp(lastScaleToken.getTso()); - long snapshotSeq = currentWindow.getSnapshotSeq(); - + if (lastScaleTso != null) { // 需要考虑:打标事务和心跳事务并发执行的情况 //

// 之前的一个策略是:使用旧拓扑的心跳事务的snapshotSeq一定小于打标事务的commitSeq,所以,如果snapshotSeq < commitSeq则执行 @@ -308,16 +306,21 @@ private void tryForceComplete() { // 新策略:最优的方案是Server内核在打标的时候,确认持有老拓扑的心跳事务都已经排空,然后再执行打标操作,但分布式场景下不太好做,另外 // 有很多老版本的Server,需要考略兼容性。考虑到心跳事务和打标事务之间的并发度很低,正常来说打标事务之后只会出现一次基于老拓扑的心跳事务, // 除非Daemon发生脑裂,所以暂时采取一种宽松的策略,如果foreComplete的次数没有超过阈值,则也直接进行force - int forceCompleteThreshold = DynamicApplicationConfig.getInt(TASK_HB_WINDOW_FORCE_COMPLETE_THRESHOLD); - if (forceCountAfterLastScale < forceCompleteThreshold) { + long forceCompleteThreshold = DynamicApplicationConfig.getLong(TASK_HB_WINDOW_FORCE_COMPLETE_THRESHOLD); + long interval = getTsoPhysicalTime(latestToken.getTso(), TimeUnit.SECONDS) - getTsoPhysicalTime( + lastScaleTso, TimeUnit.SECONDS); + + if (interval <= forceCompleteThreshold) { currentWindow.forceComplete(); - logger.warn("Force complete heart beat window, last scale token`s commitSeq is {}, " - + "this heart beat window`s snapshot seq is{}.", - commitSeq, snapshotSeq); + logger.warn("Force complete heartbeat window, last scale token`s commit tso is {}," + + " current heartbeat window`s commit tso is {}, latest txn token`s commit tso is {}," + + " forceCountAfterLastScale is {}, interval is {}.", lastScaleTso, + currentWindow.getActualTso(), latestToken.getTso(), forceCountAfterLastScale, interval); } else { - logger.error( - "snapshot seq {} is large than commit seq {}, but heartbeat window is not complete, maybe it`s a bug.", - snapshotSeq, commitSeq); + logger.warn("Can`t force complete heartbeat window, last scale token`s commit tso is {}," + + " current heartbeat window`s commit tso is {}, latest txn token`s commit tso is {}," + + " forceCountAfterLastScale is {}, interval is {}.", lastScaleTso, + currentWindow.getActualTso(), latestToken.getTso(), forceCountAfterLastScale, interval); } } } @@ -366,7 +369,7 @@ public void windowRotate(MergeItem item) { } } - if (currentWindow != null && currentWindow.isForceComplete() && lastScaleToken != null) { + if (currentWindow != null && currentWindow.isForceComplete() && lastScaleTso != null) { forceCountAfterLastScale++; } diff --git a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/stress/FromRpcServerStressSimulator.java b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/stress/FromRpcServerStressSimulator.java index 9de4b74f..5d9d2da5 100644 --- a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/stress/FromRpcServerStressSimulator.java +++ b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/stress/FromRpcServerStressSimulator.java @@ -178,7 +178,7 @@ private static String generateTso() { private static TxnMergedToken buildToken() { return TxnMergedToken.newBuilder() - .setBeginSchema("test") + .setSchema("test") .setTso(generateTso()) .setType(TxnType.DML) .build(); diff --git a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/stress/FromTransmitterStressSimulator.java b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/stress/FromTransmitterStressSimulator.java index 6fd65e77..2719afd9 100644 --- a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/stress/FromTransmitterStressSimulator.java +++ b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/stress/FromTransmitterStressSimulator.java @@ -143,7 +143,7 @@ private static TxnToken buildToken() { String virtualTso = CommonUtils.generateTSO(localTso, String.valueOf(xid), "111111"); return TxnToken.newBuilder() - .setBeginSchema("test") + .setSchema("test") .setTso(virtualTso) .setType(TxnType.DML) .addAllAllParties(ALL_PARTIES) diff --git a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/transmit/LogEventTransmitter.java b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/transmit/LogEventTransmitter.java index 78f7ab81..52304e34 100644 --- a/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/transmit/LogEventTransmitter.java +++ b/polardbx-cdc-task/src/main/java/com/aliyun/polardbx/binlog/transmit/LogEventTransmitter.java @@ -302,8 +302,11 @@ private void sendChunk(TxnOutputStream outputStream) { TxnItemRef txnItemRef = iterator.next(); items.add(TxnItem.newBuilder() .setTraceId(txnItemRef.getTraceId()) + .setRowsQuery(txnItemRef.getRowsQuery()) .setEventType(txnItemRef.getEventType()) .setPayload(txnItemRef.getByteStringPayload()) + .setSchema(txnItemRef.getSchema()) + .setTable(txnItemRef.getTable()) .build()); txnItemRef.clearPayload();//尽快释放内存空间,防止内存溢出 } @@ -356,8 +359,11 @@ private void sendData(TxnBuffer buffer, TxnOutputStream outputStream) items.add(TxnItem.newBuilder() .setTraceId(txnItemRef.getTraceId()) + .setRowsQuery(txnItemRef.getRowsQuery()) .setEventType(txnItemRef.getEventType()) .setPayload(payload) + .setSchema(txnItemRef.getSchema()) + .setTable(txnItemRef.getTable()) .build()); if ((chunkMode == ChunkMode.MEMSIZE && memSize >= chunkItemSize * CHUNK_MEM_UNIT) || @@ -406,9 +412,10 @@ private void sendTag(TxnToken token, TxnOutputStream outputStream) { private TxnMergedToken buildTxnMergedToken(TxnToken token) { return TxnMergedToken.newBuilder() .setType(token.getType()) - .setBeginSchema(token.getBeginSchema()) + .setSchema(token.getSchema()) .setTso(token.getTso()) .setPayload(token.getPayload()) + .setTable(token.getTable()) .build(); } diff --git a/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/DDLConverterTest.java b/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/DDLConverterTest.java index c0439d7a..7e2ebfaf 100644 --- a/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/DDLConverterTest.java +++ b/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/DDLConverterTest.java @@ -20,6 +20,8 @@ import com.alibaba.polardbx.druid.DbType; import com.alibaba.polardbx.druid.sql.SQLUtils; import com.alibaba.polardbx.druid.sql.ast.SQLStatement; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableItem; +import com.alibaba.polardbx.druid.sql.ast.statement.SQLAlterTableStatement; import com.alibaba.polardbx.druid.sql.ast.statement.SQLDropDatabaseStatement; import com.alibaba.polardbx.druid.sql.ast.statement.SQLDropTableStatement; import com.alibaba.polardbx.druid.sql.ast.statement.SQLExprTableSource; @@ -298,4 +300,31 @@ public void testWithHints() { + "TBPARTITION BY hash(JOB_ID) TBPARTITIONS 16"; System.out.println(DDLConverter.convertNormalDDL(sql, null, null, 1, "123456666")); } + + @Test + public void testImplicit() { + String sql = "CREATE TABLE `zqhz0kzsecxfgdf` (\n" + + " `zsjzmjsoidxxtr` int(6) unsigned zerofill DEFAULT NULL,\n" + + " `7jg0ekks` int(6) unsigned zerofill DEFAULT NULL,\n" + + " `3pf6xdowmaf` int(6) unsigned zerofill DEFAULT NULL,\n" + + " `hkqh6gd` int(6) unsigned zerofill DEFAULT NULL,\n" + + " _drds_implicit_id_ bigint(20) NOT NULL AUTO_INCREMENT,\n" + + " PRIMARY KEY (_drds_implicit_id_)\n" + + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"; + System.out.println(DDLConverter.convertNormalDDL(sql, null, null, 1, "123456666")); + } + + @Test + public void testConstraint() { + String sql = "alter table `xxx` drop key k1(`u`)"; + SQLStatementParser parser = + SQLParserUtils.createSQLStatementParser(sql, DbType.mysql, FastSQLConstant.FEATURES); + List stmtList = parser.parseStatementList(); + System.out.println(stmtList.get(0).getClass()); + SQLAlterTableStatement sqlAlterTableStatement = (SQLAlterTableStatement) stmtList.get(0); + for (SQLAlterTableItem item : sqlAlterTableStatement.getItems()) { + System.out.println(item.getClass()); + } + } + } diff --git a/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/LocalBinlogExtractorTest.java b/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/LocalBinlogExtractorTest.java index 31fc449c..a95bdbb7 100644 --- a/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/LocalBinlogExtractorTest.java +++ b/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/LocalBinlogExtractorTest.java @@ -33,7 +33,7 @@ public class LocalBinlogExtractorTest { public static void main(String args[]) { - LocalBinlogParser localBinlogParser = new LocalBinlogParser("/Users/yanfenglin/Downloads/mysql-bin.000004"); + LocalBinlogParser localBinlogParser = new LocalBinlogParser("/Users/yanfenglin/Downloads/mysql-bin.000001"); EventAcceptFilter acceptFilter = new EventAcceptFilter("", true); acceptFilter.addAcceptEvent(LogEvent.FORMAT_DESCRIPTION_EVENT); // accept dml diff --git a/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/LocalBinlogFileReaderTest.java b/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/LocalBinlogFileReaderTest.java new file mode 100644 index 00000000..749347e9 --- /dev/null +++ b/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/LocalBinlogFileReaderTest.java @@ -0,0 +1,72 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.extractor; + +import com.alibaba.fastjson.JSON; +import com.aliyun.polardbx.binlog.canal.binlog.LocalBinlogParser; +import com.aliyun.polardbx.binlog.canal.binlog.LogBuffer; +import com.aliyun.polardbx.binlog.canal.binlog.LogContext; +import com.aliyun.polardbx.binlog.canal.binlog.LogDecoder; +import com.aliyun.polardbx.binlog.canal.binlog.LogEvent; +import com.aliyun.polardbx.binlog.canal.binlog.LogPosition; +import com.aliyun.polardbx.binlog.canal.binlog.event.FormatDescriptionLogEvent; +import com.aliyun.polardbx.binlog.canal.binlog.event.RowsLogEvent; +import com.aliyun.polardbx.binlog.canal.core.dump.SinkFunction; +import com.aliyun.polardbx.binlog.canal.exception.CanalParseException; +import com.aliyun.polardbx.binlog.canal.exception.TableIdNotFoundException; +import org.junit.Test; + +import java.io.IOException; + +public class LocalBinlogFileReaderTest { + @Test + public void testRead() throws IOException, TableIdNotFoundException { + LocalBinlogParser parser = new LocalBinlogParser("/Users/yanfenglin/Downloads/binlog.000001"); + LogDecoder decoder = new LogDecoder(LogEvent.START_EVENT_V3, LogEvent.ENUM_END_EVENT); + LogContext logContext = new LogContext(FormatDescriptionLogEvent.FORMAT_DESCRIPTION_EVENT_5_x); + logContext.setLogPosition(new LogPosition("binlog.000001")); + parser.dump(new SinkFunction() { + @Override + public boolean sink(LogEvent event, LogPosition logPosition) + throws CanalParseException, TableIdNotFoundException { + if (event instanceof RowsLogEvent) { + RowsLogEvent rowsLogEvent = (RowsLogEvent) event; + if (rowsLogEvent.getColumns().isEmpty()) { + this.getClass(); + } + System.out.println(rowsLogEvent.getColumns().toString() + rowsLogEvent.getTable().getTableName()); + } + return true; + } + }); + } + + @Test + public void testEventBytesRecord() throws IOException { + byte[] datas = { + 34, 124, 81, 97, 23, -121, 85, 41, 78, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, -35, 4, 0, 0, 0, 0, 1, 0, 4, -1, -16, + 61, 53, 12, 0, 10, 116, 101, 115, 116, 112, 32, 111, 52, 52, 52, -103, -86, -73, 2, 71, 0, 0, 77, 1, 0, 0, + 0, 0, 0, 0}; + LogDecoder decoder = new LogDecoder(LogEvent.START_EVENT_V3, LogEvent.ENUM_END_EVENT); + LogBuffer logBuffer = new LogBuffer(datas, 0, datas.length); + LogContext logContext = new LogContext(); + logContext.setLogPosition(new LogPosition("binlog.000001")); + LogEvent event = decoder.decode(logBuffer, logContext); + System.out.println(JSON.toJSONString(event)); + } +} diff --git a/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/MemoryEventLogBuffer.java b/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/MemoryEventLogBuffer.java new file mode 100644 index 00000000..2e3565ad --- /dev/null +++ b/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/MemoryEventLogBuffer.java @@ -0,0 +1,23 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.extractor; + +import com.aliyun.polardbx.binlog.canal.binlog.LogBuffer; + +public class MemoryEventLogBuffer extends LogBuffer { +} diff --git a/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/MockTableMetaDelegate.java b/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/MockTableMetaDelegate.java index 0936bee4..a66edfb8 100644 --- a/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/MockTableMetaDelegate.java +++ b/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/MockTableMetaDelegate.java @@ -25,6 +25,7 @@ import com.aliyun.polardbx.binlog.cdc.topology.LogicMetaTopology; import com.aliyun.polardbx.binlog.extractor.filter.rebuild.ITableMetaDelegate; import com.aliyun.polardbx.binlog.extractor.filter.rebuild.TableMetaChangeListener; +import com.google.common.collect.Sets; import java.util.HashMap; import java.util.HashSet; @@ -102,4 +103,9 @@ public LogicTableMeta compare(String schema, String table) { logicTableMeta.setPhyTable(table); return logicTableMeta; } + + @Override + public Set findIndexes(String schema, String table) { + return Sets.newHashSet(); + } } diff --git a/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/TraceExtractTest.java b/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/TraceExtractTest.java index 1272936f..4c21c0c3 100644 --- a/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/TraceExtractTest.java +++ b/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/TraceExtractTest.java @@ -17,6 +17,7 @@ package com.aliyun.polardbx.binlog.extractor; +import com.alibaba.fastjson.JSON; import com.aliyun.polardbx.binlog.canal.LogEventUtil; import com.aliyun.polardbx.binlog.extractor.binlog.BinlogGenerator; import org.junit.Test; @@ -31,6 +32,18 @@ public void grapTraceTest() throws Exception { System.out.println(LogEventUtil.buildTrace(generator.generateRowQueryLogEvent())); } + @Test + public void testTrace() throws Exception { + BinlogGenerator generator = new BinlogGenerator("test_db", + "test_tb", + "create table tt(id bigint(20) default 1)"); + System.out.println(JSON.toJSONString(LogEventUtil.buildTrace( + generator.generateRowQueryLogEvent("/*DRDS /11.196.59.141/1322a3c35bc01000/0/1390188355/ */")))); + + System.out.println(JSON.toJSONString(LogEventUtil.buildTrace( + generator.generateRowQueryLogEvent("/*DRDS /11.196.49.49/1322a3c37f401001-3/1// */")))); + } + @Test public void buildTraceTest() { System.out.println(LogEventUtil.buildTraceId("1", null)); diff --git a/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/filter/RebuildEventLogFilterTest.java b/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/filter/RebuildEventLogFilterTest.java new file mode 100644 index 00000000..57f9313b --- /dev/null +++ b/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/extractor/filter/RebuildEventLogFilterTest.java @@ -0,0 +1,63 @@ +/* + * + * Copyright (c) 2013-2021, 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.aliyun.polardbx.binlog.extractor.filter; + +import org.apache.commons.lang3.StringUtils; +import org.junit.Assert; +import org.junit.Test; + +/** + * Created by ziyang.lb + **/ +public class RebuildEventLogFilterTest { + + @Test + public void testIsMoveDatabase() { + String sql = "move database group1 to 'storage_xxx'"; + RebuildEventLogFilter filter = new RebuildEventLogFilter(0, null, null); + boolean result = filter.isMoveDataBaseSql(sql); + Assert.assertTrue(result); + + sql = "create table test(id int)"; + result = filter.isMoveDataBaseSql(sql); + Assert.assertFalse(result); + } + + @Test + public void testTryRewriteSql() { + RebuildEventLogFilter filter = new RebuildEventLogFilter(0, null, null); + String s1 = filter.tryRewriteDropTableSql("aa", "bb", "drop table aa.bb"); + String s2 = filter.tryRewriteDropTableSql("aa", "bb", "drop table aa.bb,aa.zz,xx.bb"); + String s3 = filter.tryRewriteDropTableSql("a`a", "b`b", "drop table `a``a`.`b``b`,`vv`.`b``b`,`a``a`.cc"); + String s4 = filter.tryRewriteDropTableSql("aa", "bb", "drop table bb,cc,dd"); + String s5 = filter.tryRewriteDropTableSql("aa", "bb", "drop table bb"); + String s6 = filter.tryRewriteDropTableSql("aa", "bb", "drop table aa.bb,aa.zz,aa.bb"); + System.out.println(s1); + System.out.println(s2); + System.out.println(s3); + System.out.println(s4); + System.out.println(s5); + System.out.println(s6); + Assert.assertTrue(StringUtils.equalsIgnoreCase("drop table aa.bb", s1)); + Assert.assertTrue(StringUtils.equalsIgnoreCase("drop table aa.bb", s2)); + Assert.assertTrue(StringUtils.equalsIgnoreCase("drop table `a``a`.`b``b`", s3)); + Assert.assertTrue(StringUtils.equalsIgnoreCase("drop table bb", s4)); + Assert.assertTrue(StringUtils.equalsIgnoreCase("drop table bb", s5)); + Assert.assertTrue(StringUtils.equalsIgnoreCase("drop table aa.bb", s6)); + } +} diff --git a/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/merge/LogEventMergerTest.java b/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/merge/LogEventMergerTest.java index ec8fd6cc..0d58fb07 100644 --- a/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/merge/LogEventMergerTest.java +++ b/polardbx-cdc-task/src/test/java/com/aliyun/polardbx/binlog/merge/LogEventMergerTest.java @@ -98,7 +98,7 @@ public long getQueuedSize() { public void setCurrentHeartBeatWindow(HeartBeatWindow window) { } - }, false, "", false, 1, null); + }, false, "", false, 1, null, null); return merger; } diff --git a/polardbx-cdc-task/src/test/resources/logback.xml b/polardbx-cdc-task/src/test/resources/logback.xml index 3d8bfe34..2ba0b76c 100644 --- a/polardbx-cdc-task/src/test/resources/logback.xml +++ b/polardbx-cdc-task/src/test/resources/logback.xml @@ -113,5 +113,6 @@ + diff --git a/polardbx-cdc-transfer/pom.xml b/polardbx-cdc-transfer/pom.xml index 4d37c896..e281d604 100644 --- a/polardbx-cdc-transfer/pom.xml +++ b/polardbx-cdc-transfer/pom.xml @@ -5,7 +5,7 @@ polardbx-cdc com.aliyun.polardbx - 5.4.12-SNAPSHOT + 5.4.13-SNAPSHOT 4.0.0 polardbx-cdc-transfer diff --git a/polardbx-cdc-transfer/src/main/java/com/aliyun/polardbx/binlog/transfer/Bank.java b/polardbx-cdc-transfer/src/main/java/com/aliyun/polardbx/binlog/transfer/Bank.java index 0f5a44c6..e480d999 100644 --- a/polardbx-cdc-transfer/src/main/java/com/aliyun/polardbx/binlog/transfer/Bank.java +++ b/polardbx-cdc-transfer/src/main/java/com/aliyun/polardbx/binlog/transfer/Bank.java @@ -44,6 +44,7 @@ public class Bank { private boolean start = false; private AtomicLong counter = new AtomicLong(0); private long interval = 15; + private long lastTimestamp = System.currentTimeMillis(); private Random random = new Random(System.currentTimeMillis()); private ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor( new ThreadFactory() { @@ -191,8 +192,9 @@ private void check(Connection connection) throws SQLException { // long counter = Bank.this.counter.getAndSet(0); // throw new RuntimeException("unexpected total balance : " + sum + " tps : (" + counter / interval + ")/s"); // } else { + long now = System.currentTimeMillis(); long counter = this.counter.getAndSet(0); - logger.info("tps : (" + counter / interval + ")/s"); + logger.info("tps : (" + counter / TimeUnit.MILLISECONDS.toSeconds(now - lastTimestamp) + ")/s"); // } } diff --git a/polardbx-cdc-transfer/src/main/java/com/aliyun/polardbx/binlog/transfer/Main.java b/polardbx-cdc-transfer/src/main/java/com/aliyun/polardbx/binlog/transfer/Main.java index 71cedf8d..46aa173f 100644 --- a/polardbx-cdc-transfer/src/main/java/com/aliyun/polardbx/binlog/transfer/Main.java +++ b/polardbx-cdc-transfer/src/main/java/com/aliyun/polardbx/binlog/transfer/Main.java @@ -58,14 +58,27 @@ public static void main(String[] args) throws ClassNotFoundException, SQLExcepti } int accountCount = 100; - int initialAmount = 1000; - int poolAccount = getValue(paramHashMap, "threadNum", 1); - + int initialAmount = 100000; + int poolAccount = getValue(paramHashMap, "threadNum", 10); + + boolean drds = false; + + if (drds) { + paramHashMap.put("ip", "127.0.0.1"); + paramHashMap.put("db", ""); + paramHashMap.put("user", ""); + paramHashMap.put("pwd", ""); + } else { + paramHashMap.put("ip", "127.0.0.1"); + paramHashMap.put("db", ""); + paramHashMap.put("user", ""); + paramHashMap.put("pwd", ""); + } String dbHost = getValue(paramHashMap, "ip", "127.0.0.1"); - String dbName = getValue(paramHashMap, "db", "transfer_test"); - String username = getValue(paramHashMap, "user", "polardbx_root"); - String password = getValue(paramHashMap, "pwd", "123456"); - int port = getValue(paramHashMap, "port", 8527); + String dbName = getValue(paramHashMap, "db", ""); + String username = getValue(paramHashMap, "user", ""); + String password = getValue(paramHashMap, "pwd", ""); + int port = getValue(paramHashMap, "port", 3306); boolean usetso = Boolean.parseBoolean(getValue(paramHashMap, "useTSO", "true")); @@ -102,10 +115,11 @@ public void run() { logger.info("init connection " + i); connectionList.add(connection); } - PrepareData.init(connectionList.get(0), accountCount, initialAmount); +// PrepareData.init(connectionList.get(0), accountCount, initialAmount); logger.info("data prepared success!"); Bank bank = new Bank(accountCount, initialAmount, usetso); logger.info("start transfer!"); + bank.setPolarx(!drds); bank.startWork(connectionList); LockSupport.park(); } finally { diff --git a/pom.xml b/pom.xml index 095aca85..6abd2b95 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.aliyun.polardbx polardbx-cdc - 5.4.12-SNAPSHOT + 5.4.13-SNAPSHOT pom @@ -21,6 +21,7 @@ polardbx-cdc-protocol polardbx-cdc-meta polardbx-cdc-monitor + polardbx-cdc-rpl @@ -33,7 +34,7 @@ 3.8.1 5.1.49 1.0.25.2018030201 - 5.4.12-SNAPSHOT + 5.4.13-SNAPSHOT 1.2.48 1.18.0 4.1.6.RELEASE