diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..1b392e7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: csharp +solution: CanalSharp.sln +mono: none +dotnet: 2.1.302 +script: + - dotnet restore + - dotnet build \ No newline at end of file diff --git a/Canal4Net.sln b/Canal4Net.sln deleted file mode 100644 index c37ca42..0000000 --- a/Canal4Net.sln +++ /dev/null @@ -1,48 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27703.2026 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9F45639B-A9FA-4F6A-94EC-0D251FA3285D}" - ProjectSection(SolutionItems) = preProject - .gitignore = .gitignore - build\common.props = build\common.props - build\package.props = build\package.props - README.md = README.md - build\version.props = build\version.props - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{BD70CDB7-94E9-4621-B702-DC04DB9D59EF}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4B78B79B-7EBE-405E-9BE3-3A59FFAD1910}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Canal4Net", "src\Canal4Net\Canal4Net.csproj", "{3611D6F6-FFAC-4CFE-A160-22E08AD0F2FA}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Canal4Net.UnitTests", "test\Canal4Net.UnitTests\Canal4Net.UnitTests.csproj", "{83F407DD-5810-422F-8AF6-4E9BA75AC678}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3611D6F6-FFAC-4CFE-A160-22E08AD0F2FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3611D6F6-FFAC-4CFE-A160-22E08AD0F2FA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3611D6F6-FFAC-4CFE-A160-22E08AD0F2FA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3611D6F6-FFAC-4CFE-A160-22E08AD0F2FA}.Release|Any CPU.Build.0 = Release|Any CPU - {83F407DD-5810-422F-8AF6-4E9BA75AC678}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {83F407DD-5810-422F-8AF6-4E9BA75AC678}.Debug|Any CPU.Build.0 = Debug|Any CPU - {83F407DD-5810-422F-8AF6-4E9BA75AC678}.Release|Any CPU.ActiveCfg = Release|Any CPU - {83F407DD-5810-422F-8AF6-4E9BA75AC678}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {3611D6F6-FFAC-4CFE-A160-22E08AD0F2FA} = {4B78B79B-7EBE-405E-9BE3-3A59FFAD1910} - {83F407DD-5810-422F-8AF6-4E9BA75AC678} = {BD70CDB7-94E9-4621-B702-DC04DB9D59EF} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {FD9B9146-8418-4F80-A666-9B47BE4F9C9C} - EndGlobalSection -EndGlobal diff --git a/CanalSharp.sln b/CanalSharp.sln new file mode 100644 index 0000000..71e205c --- /dev/null +++ b/CanalSharp.sln @@ -0,0 +1,71 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27703.2026 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "01 Solution Items", "01 Solution Items", "{9F45639B-A9FA-4F6A-94EC-0D251FA3285D}" + ProjectSection(SolutionItems) = preProject + .gitignore = .gitignore + build\common.props = build\common.props + build\package.props = build\package.props + README.md = README.md + build\version.props = build\version.props + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "03 test", "03 test", "{BD70CDB7-94E9-4621-B702-DC04DB9D59EF}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "02 src", "02 src", "{4B78B79B-7EBE-405E-9BE3-3A59FFAD1910}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CanalSharp.UnitTests", "test\CanalSharp.UnitTests\CanalSharp.UnitTests.csproj", "{83F407DD-5810-422F-8AF6-4E9BA75AC678}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CanalSharp.Client", "src\CanalSharp.Client\CanalSharp.Client.csproj", "{E33BCF38-D450-4AFE-B409-E6E7C0251479}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CanalSharp.Protocol", "src\CanalSharp.Protocol\CanalSharp.Protocol.csproj", "{B9782080-16BD-4328-A394-3EC8D9B49326}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CanalSharp.Common", "src\CanalSharp.Common\CanalSharp.Common.csproj", "{B583684C-4E2F-42A5-8F08-1E3C4EE4C586}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "04 sample", "04 sample", "{A4650FA0-4725-4956-90D3-F462F3C7474F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CanalSharp.SimpleClient", "sample\CanalSharp.SimpleClient\CanalSharp.SimpleClient.csproj", "{CE9C0E45-F613-4E28-89EE-7F646B028BFB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {83F407DD-5810-422F-8AF6-4E9BA75AC678}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {83F407DD-5810-422F-8AF6-4E9BA75AC678}.Debug|Any CPU.Build.0 = Debug|Any CPU + {83F407DD-5810-422F-8AF6-4E9BA75AC678}.Release|Any CPU.ActiveCfg = Release|Any CPU + {83F407DD-5810-422F-8AF6-4E9BA75AC678}.Release|Any CPU.Build.0 = Release|Any CPU + {E33BCF38-D450-4AFE-B409-E6E7C0251479}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E33BCF38-D450-4AFE-B409-E6E7C0251479}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E33BCF38-D450-4AFE-B409-E6E7C0251479}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E33BCF38-D450-4AFE-B409-E6E7C0251479}.Release|Any CPU.Build.0 = Release|Any CPU + {B9782080-16BD-4328-A394-3EC8D9B49326}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B9782080-16BD-4328-A394-3EC8D9B49326}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B9782080-16BD-4328-A394-3EC8D9B49326}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B9782080-16BD-4328-A394-3EC8D9B49326}.Release|Any CPU.Build.0 = Release|Any CPU + {B583684C-4E2F-42A5-8F08-1E3C4EE4C586}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B583684C-4E2F-42A5-8F08-1E3C4EE4C586}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B583684C-4E2F-42A5-8F08-1E3C4EE4C586}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B583684C-4E2F-42A5-8F08-1E3C4EE4C586}.Release|Any CPU.Build.0 = Release|Any CPU + {CE9C0E45-F613-4E28-89EE-7F646B028BFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CE9C0E45-F613-4E28-89EE-7F646B028BFB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CE9C0E45-F613-4E28-89EE-7F646B028BFB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CE9C0E45-F613-4E28-89EE-7F646B028BFB}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {83F407DD-5810-422F-8AF6-4E9BA75AC678} = {BD70CDB7-94E9-4621-B702-DC04DB9D59EF} + {E33BCF38-D450-4AFE-B409-E6E7C0251479} = {4B78B79B-7EBE-405E-9BE3-3A59FFAD1910} + {B9782080-16BD-4328-A394-3EC8D9B49326} = {4B78B79B-7EBE-405E-9BE3-3A59FFAD1910} + {B583684C-4E2F-42A5-8F08-1E3C4EE4C586} = {4B78B79B-7EBE-405E-9BE3-3A59FFAD1910} + {CE9C0E45-F613-4E28-89EE-7F646B028BFB} = {A4650FA0-4725-4956-90D3-F462F3C7474F} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FD9B9146-8418-4F80-A666-9B47BE4F9C9C} + EndGlobalSection +EndGlobal diff --git a/README.md b/README.md index ba627bb..bdcca2b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,58 @@ -# Canal4Net -C# client for canal. https://github.com/alibaba/canal + +# CanalSharp + +## 一.CanalSharp是什么? + +CanalSharp 是阿里巴巴开源项目 Canal 的 .NET 客户端。为 .NET 开发者提供一个更友好的使用 Canal 的方式。Canal 是mysql数据库binlog的增量订阅&消费组件。 + +基于日志增量订阅&消费支持的业务: + +1. 数据库镜像 +2. 数据库实时备份 +3. 多级索引 (卖家和买家各自分库索引) +4. search build +5. 业务cache刷新 +6. 价格变化等重要业务消息 + +关于 Canal 的更多信息请访问 https://github.com/alibaba/canal + +## 二.如何使用 + +1.安装Canal + +Canal的安装以及配置使用请查看 https://github.com/alibaba/canal + +2.建立一个.NET Core App项目 + +3.为该项目从 Nuget 安装 CanalSharp + +````shell +Install-Package CanalSharp.Client +```` + +4.建立与Canal的连接 + +````csharp +//canal 配置的 destination,默认为 example +var destination = "example"; +//创建一个简单CanalClient连接对象(此对象不支持集群)传入参数分别为 canal地址、端口、destination、用户名、密码 +var connector = CanalConnectors.NewSingleConnector("127.0.0.1", 11111, destination, "", ""); +//连接 Canal +connector.Connect(); +//订阅,同时传入Filter,如果不传则以Canal的Filter为准。Filter是一种过滤规则,通过该规则的表数据变更才会传递过来 +connector.Subscribe(""); +//获取消息并且需要发送Ack表示消费成功 +connector.Get(batchSize); +//获取消息但是不需要发送Ack来表示消费成功 +connector.GetWithoutAck(batchSize); +```` + +更多详情请查看 Sample + +## 三.贡献代码 + +1.fork本项目 + +2.做出你的更改 + +3.提交 pull request \ No newline at end of file diff --git a/build/package.props b/build/package.props index c8ad077..0783706 100644 --- a/build/package.props +++ b/build/package.props @@ -1,13 +1,14 @@ - C# client for canal. https://github.com/alibaba/canal - https://github.com/Canal4Net/Canal4Net/blob/master/LICENSE - https://github.com/Canal4Net/Canal4Net - https://github.com/Canal4Net/Canal4Net.git + + 阿里巴巴mysql数据库binlog的增量订阅/消费组件 Canal 的 .NET 客户端 + https://github.com/CanalSharp/CanalSharp/blob/dev/LICENSE + https://github.com/CanalSharp/CanalSharp + https://github.com/CanalSharp/CanalSharp.git git canal;mysql;binlog - Canal4Net Org. - stulzq,WithLin + CanalSharp Org. + stulzq,WithLin,CanalSharp diff --git a/sample/CanalSharp.SimpleClient/CanalSharp.SimpleClient.csproj b/sample/CanalSharp.SimpleClient/CanalSharp.SimpleClient.csproj new file mode 100644 index 0000000..f2d4469 --- /dev/null +++ b/sample/CanalSharp.SimpleClient/CanalSharp.SimpleClient.csproj @@ -0,0 +1,13 @@ + + + + Exe + netcoreapp2.1 + + + + + + + + diff --git a/sample/CanalSharp.SimpleClient/Program.cs b/sample/CanalSharp.SimpleClient/Program.cs new file mode 100644 index 0000000..818e96d --- /dev/null +++ b/sample/CanalSharp.SimpleClient/Program.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using CanalSharp.Client.Impl; +using Com.Alibaba.Otter.Canal.Protocol; + +namespace CanalSharp.SimpleClient +{ + class Program + { + static void Main(string[] args) + { + //canal 配置的 destination,默认为 example + var destination = "example"; + //创建一个简单CanalClient连接对象(此对象不支持集群)传入参数分别为 canal地址、端口、destination、用户名、密码 + var connector = CanalConnectors.NewSingleConnector("127.0.0.1", 11111, destination, "", ""); + //连接 Canal + connector.Connect(); + //订阅,同时传入Filter,如果不传则以Canal的Filter为准。Filter是一种过滤规则,通过该规则的表数据变更才会传递过来 + connector.Subscribe(""); + while (true) + { + //获取消息数据 + var message = connector.Get(5000); + var batchId = message.Id; + if (batchId == -1 || message.Entries.Count <= 0) + { + Console.WriteLine("没有数据了............."); + Thread.Sleep(300); + } + PrintEntry(message.Entries); + } + } + + private static void PrintEntry(List entrys) + { + foreach (var entry in entrys) + { + if (entry.EntryType == EntryType.Transactionbegin || entry.EntryType == EntryType.Transactionend) + { + continue; + } + + RowChange rowChange = null; + + try + { + rowChange = RowChange.Parser.ParseFrom(entry.StoreValue); + } + catch (Exception e) + { + + } + + if (rowChange != null) + { + EventType eventType = rowChange.EventType; + Console.WriteLine( + $"================> binlog[{entry.Header.LogfileName}:{entry.Header.LogfileOffset}] , name[{entry.Header.SchemaName},{entry.Header.TableName}] , eventType :{eventType}"); + + foreach (var rowData in rowChange.RowDatas) + { + if (eventType == EventType.Delete) + { + PrintColumn(rowData.BeforeColumns.ToList()); + } + else if (eventType == EventType.Insert) + { + PrintColumn(rowData.BeforeColumns.ToList()); + } + else + { + Console.WriteLine("-------> before"); + PrintColumn(rowData.BeforeColumns.ToList()); + Console.WriteLine("-------> after"); + PrintColumn(rowData.AfterColumns.ToList()); + } + } + } + + } + } + + private static void PrintColumn(List columns) + { + foreach (var column in columns) + { + Console.WriteLine($"{column.Name} : {column.Value} update= {column.Updated}"); + } + } + } +} diff --git a/src/CanalSharp.Client/CanalSharp.Client.csproj b/src/CanalSharp.Client/CanalSharp.Client.csproj new file mode 100644 index 0000000..c394b76 --- /dev/null +++ b/src/CanalSharp.Client/CanalSharp.Client.csproj @@ -0,0 +1,17 @@ + + + + netstandard2.0 + + + + + + + + + + + + + diff --git a/src/CanalSharp.Client/ICanalConnector.cs b/src/CanalSharp.Client/ICanalConnector.cs new file mode 100644 index 0000000..2e86d5f --- /dev/null +++ b/src/CanalSharp.Client/ICanalConnector.cs @@ -0,0 +1,110 @@ +using CanalSharp.Protocol; + +namespace CanalSharp.Client +{ + public interface ICanalConnector + { + /// + /// 链接对应的canal server + /// + void Connect(); + + /// + /// 释放链接 + /// + void Disconnect(); + + /// + /// 检查下链接是否合法 + /// 几种case下链接不合法: + /// 1. 链接canal server失败,一直没有一个可用的链接,返回false + /// 2. 当前客户端在进行running抢占的时候,做为备份节点存在,非处于工作节点,返回false + /// 说明: + /// a. 当前客户端一旦做为备份节点存在,当前所有的对{@linkplain CanalConnector}的操作都会处于阻塞状态,直到转为工作节点 + /// b. 所以业务方最好定时调用checkValid()方法用,比如调用CanalConnector所在线程的interrupt,直接退出CanalConnector,并根据自己的需要退出自己的资源 + /// + /// + bool CheckValid(); + + /// + /// 客户端订阅,重复订阅时会更新对应的filter信息 + /// a. 如果本次订阅中filter信息为空,则直接使用canal server服务端配置的filter信息 + /// b. 如果本次订阅中filter信息不为空,目前会直接替换canal server服务端配置的filter信息,以本次提交的为准 + /// + /// + /// TODO: 后续可以考虑,如果本次提交的filter不为空,在执行过滤时,是对canal server filter + 本次filter的交集处理,达到只取1份binlog数据,多个客户端消费不同的表 + void Subscribe(string filter); + + /// + /// 客户端订阅,不提交客户端filter,以服务端的filter为准 + /// + void Subscribe(); + + /// + /// 取消订阅 + /// + void UnSubscribe(); + + /// + /// 获取数据,自动进行确认,该方法返回的条件:尝试拿batchSize条记录,有多少取多少,不会阻塞等待 + /// + /// + /// + Message Get(int batchSize); + /// + /// 获取数据,自动进行确认 + /// 该方法返回的条件: + /// a. 拿够batchSize条记录或者超过timeout时间 + /// b. 如果timeout=0,则阻塞至拿到batchSize记录才返回 + /// + /// + /// + /// + /// + Message Get(int batchSize, long? timeout, int? unit); + + /// + /// 不指定 position 获取事件,该方法返回的条件: 尝试拿batchSize条记录,有多少取多少,不会阻塞等待 + /// canal 会记住此 client 最新的position + /// 如果是第一次 fetch,则会从 canal 中保存的最老一条数据开始输出。 + /// + /// + /// + Message GetWithoutAck(int batchSize); + + /// + /// 该方法返回的条件: + /// a. 拿够batchSize条记录或者超过timeout时间 + /// b. 如果timeout=0,则阻塞至拿到batchSize记录才返回 + /// canal 会记住此 client 最新的position。 + /// 如果是第一次 fetch,则会从 canal 中保存的最老一条数据开始输出。 + /// + /// + /// + /// + /// + Message GetWithoutAck(int batchSize, long? timeout, int? unit); + + /// + /// 进行 batch id 的确认。确认之后,小于等于此 batchId 的 Message 都会被确认。 + /// + /// + void Ack(long batchId); + + /// + /// 回滚到未进行 {@link #ack} 的地方,指定回滚具体的batchId + /// + /// + void Rollback(long batchId); + + /// + /// 回滚到未进行 {@link #ack} 的地方,下次fetch的时候,可以从最后一个没有 {@link #ack} 的地方开始拿 + /// + void Rollback(); + + /// + /// 中断的阻塞,用于优雅停止client + /// + void StopRunning(); + } +} diff --git a/src/CanalSharp.Client/ICanalNodeAccessStrategy.cs b/src/CanalSharp.Client/ICanalNodeAccessStrategy.cs new file mode 100644 index 0000000..a9ce2e7 --- /dev/null +++ b/src/CanalSharp.Client/ICanalNodeAccessStrategy.cs @@ -0,0 +1,11 @@ +using System.Net; + +namespace CanalSharp.Client +{ + public interface ICanalNodeAccessStrategy + { + SocketAddress CurrentNode(); + + SocketAddress NextNode(); + } +} diff --git a/src/CanalSharp.Client/Impl/CanalConnectors.cs b/src/CanalSharp.Client/Impl/CanalConnectors.cs new file mode 100644 index 0000000..a123bb6 --- /dev/null +++ b/src/CanalSharp.Client/Impl/CanalConnectors.cs @@ -0,0 +1,24 @@ +namespace CanalSharp.Client.Impl +{ + public class CanalConnectors + { + /// + /// 创建单链接的客户端链接 + /// + /// + /// + /// + /// + /// + public static ICanalConnector NewSingleConnector(string address, int port, string destination, string username, + string password) + { + var canalConnector = new SimpleCanalConnector(address, port, username, password, destination) + { + SoTimeout = 60 * 1000, + IdleTimeout = 60 * 60 * 1000 + }; + return canalConnector; + } + } +} diff --git a/src/CanalSharp.Client/Impl/Running/ClientRunningData.cs b/src/CanalSharp.Client/Impl/Running/ClientRunningData.cs new file mode 100644 index 0000000..9708322 --- /dev/null +++ b/src/CanalSharp.Client/Impl/Running/ClientRunningData.cs @@ -0,0 +1,17 @@ +namespace CanalSharp.Client.Impl.Running +{ + /// + /// client running状态信息 + /// + public class ClientRunningData + { + private short ClientId { get; set; } + public string Address { get; } + public bool Active { get; } = true; + + public bool IsActive() + { + return Active; + } + } +} \ No newline at end of file diff --git a/src/CanalSharp.Client/Impl/Running/ClientRunningMonitor.cs b/src/CanalSharp.Client/Impl/Running/ClientRunningMonitor.cs new file mode 100644 index 0000000..90202dc --- /dev/null +++ b/src/CanalSharp.Client/Impl/Running/ClientRunningMonitor.cs @@ -0,0 +1,8 @@ +using CanalSharp.Common; + +namespace CanalSharp.Client.Impl.Running +{ + public class ClientRunningMonitor: AbstractCanalLifeCycle + { + } +} diff --git a/src/CanalSharp.Client/Impl/Running/IClientRunningListener.cs b/src/CanalSharp.Client/Impl/Running/IClientRunningListener.cs new file mode 100644 index 0000000..f030d11 --- /dev/null +++ b/src/CanalSharp.Client/Impl/Running/IClientRunningListener.cs @@ -0,0 +1,24 @@ + + +using System.Net; + +namespace CanalSharp.Client.Impl.Running +{ + + /// + /// 触发一下mainstem发生切换 + /// + public interface IClientRunningListener + { + /// + /// 触发现在轮到自己做为active,需要载入上一个active的上下文数据 + /// + /// + SocketAddress ProcessActiveEnter(); + + /// + /// 触发一下当前active模式失败 + /// + void ProcessActiveExit(); + } +} \ No newline at end of file diff --git a/src/CanalSharp.Client/Impl/SimpleCanalConnector.cs b/src/CanalSharp.Client/Impl/SimpleCanalConnector.cs new file mode 100644 index 0000000..9cc1589 --- /dev/null +++ b/src/CanalSharp.Client/Impl/SimpleCanalConnector.cs @@ -0,0 +1,530 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.Sockets; +using System.Threading.Tasks; +using CanalSharp.Common.Logging; +using CanalSharp.Protocol; +using CanalSharp.Protocol.Exception; +using Com.Alibaba.Otter.Canal.Protocol; +using DotNetty.Transport.Channels; +using DotNetty.Transport.Channels.Sockets; +using Google.Protobuf; + +namespace CanalSharp.Client.Impl +{ + public class SimpleCanalConnector : ChannelHandlerAdapter, ICanalConnector + { + private readonly ILogger _logger = LogManager.GetLogger(typeof(SimpleCanalConnector)); + public string Address { get; set; } + public int Port { get; set; } + public string Username { get; set; } + public string Password { get; set; } + + /// + /// // milliseconds + /// + public int SoTimeout { get; set; } = 60000; + + /// + /// client和server之间的空闲链接超时的时间,默认为1小时 + /// + public int IdleTimeout { get; set; } = 60 * 60 * 1000; + + private ClientIdentity _clientIdentity; + /// + /// // 代表connected是否已正常执行,因为有HA,不代表在工作中 + /// + private volatile bool _connected = false; + + + private volatile bool _running = false; + /// + /// 记录上一次的filter提交值,便于自动重试时提交 + /// + private string _filter; + + private ISocketChannel _channel; + + private Task readableChannel; + + private IChannel writableChannel; + + private List supportedCompressions = new List(); + + private static readonly object _writeDataLock = new object(); + private static readonly object _readDataLock = new object(); + + + // 是否在connect链接成功后,自动执行rollback操作 + private bool _rollbackOnConnect = true; + + private Message _message; + // 是否自动化解析Entry对象,如果考虑最大化性能可以延后解析 + private bool _lazyParseEntry = false; + + private TcpClient _tcpClient; + private NetworkStream _channelNetworkStream; + + /// + /// 是否在connect链接成功后,自动执行rollback操作 + /// + private bool _rollbackOnDisConnect = false; + + + public SimpleCanalConnector(string address, int port, string username, string password, string destination) : this(address, port, username, password, destination, 60000, 60 * 60 * 1000) + { + + } + + public SimpleCanalConnector(string address, int port, string username, string password, string destination, + int soTimeout) : this(address, port, username, password, destination, soTimeout, 60 * 60 * 1000) + { + + } + + public SimpleCanalConnector(string address, int port, string username, string password, string destination, + int soTimeout, int idleTimeout) + { + Address = address; + Port = port; + Username = username; + Password = password; + SoTimeout = soTimeout; + IdleTimeout = idleTimeout; + _clientIdentity = new ClientIdentity(destination, (short)1001); + } + + public void Connect() + { + if (_connected) + { + return; + } + + WaitClientRunning(); + if (!_running) + { + return; + } + + DoConnect(); + if (_filter != null) + { // 如果存在条件,说明是自动切换,基于上一次的条件订阅一次 + Subscribe(_filter); + } + if (_rollbackOnConnect) + { + Rollback(); + } + _connected = true; + } + + public void Disconnect() + { + if (_rollbackOnDisConnect && _tcpClient.Connected == false) + { + Rollback(); + } + _connected = false; + DoDisConnection(); + } + + private void DoDisConnection() + { + if (_tcpClient != null) + { + QuietlyClose(); + } + + } + + private void QuietlyClose() + { + _tcpClient.Close(); + } + + public bool CheckValid() + { + throw new NotImplementedException(); + } + + public void Subscribe(string filter) + { + WaitClientRunning(); + if (!_running) + { + return; + } + + try + { + var pack = new Packet() + { + Type = PacketType.Subscription, + Body = new Sub() + { + Destination = _clientIdentity.Destination, + ClientId = _clientIdentity.ClientId.ToString(), + Filter = _filter != null ? _filter : "" + }.ToByteString() + }.ToByteArray(); + + WriteWithHeader(pack); + + var p = Packet.Parser.ParseFrom(ReadNextPacket()); + var ack = Com.Alibaba.Otter.Canal.Protocol.Ack.Parser.ParseFrom(p.Body); + if (ack.ErrorCode > 0) + { + throw new CanalClientException($"failed to subscribe with reason: {ack.ErrorMessage}"); + } + + _clientIdentity.Filter = filter; + } + catch (Exception e) + { + throw new CanalClientException(e.Message); + } + + } + + public void Subscribe() + { + Subscribe(""); + } + + public void UnSubscribe() + { + WaitClientRunning(); + if (!_running) + { + return; + } + try + { + var unsub = new Unsub() + { + Destination = _clientIdentity.Destination, + ClientId = _clientIdentity.ClientId.ToString(), + }; + var pack = new Packet() + { + Type = PacketType.Unsubscription, + Body = unsub.ToByteString() + }.ToByteArray(); + WriteWithHeader(pack); + var p = Packet.Parser.ParseFrom(ReadNextPacket()); + var ack = Com.Alibaba.Otter.Canal.Protocol.Ack.Parser.ParseFrom(p.Body); + if (ack.ErrorCode > 0) + { + throw new CanalClientException($"failed to unSubscribe with reason: {ack.ErrorMessage}"); + } + } + catch (IOException e) + { + throw new CanalClientException(e.Message, e); + } + } + + public Message Get(int batchSize) + { + var message = Get(batchSize, null, null); + return message; + } + + public Message Get(int batchSize, long? timeout, int? unit) + { + var message = GetWithoutAck(batchSize, timeout, unit); + Ack(message.Id); + return message; + } + + public Message GetWithoutAck(int batchSize) + { + return GetWithoutAck(batchSize, null, null); + } + + public Message GetWithoutAck(int batchSize, long? timeout, int? unit) + { + WaitClientRunning(); + if (!_running) + { + return null; + } + + try + { + var size = (batchSize <= 0) ? 1000 : batchSize; + // -1代表不做timeout控制 + var time = (timeout == null || timeout < 0) ? -1 : timeout; + if (unit == null) + { + unit = 1; + } + var get = new Get() + { + AutoAck = false, + Destination = _clientIdentity.Destination, + ClientId = _clientIdentity.ClientId.ToString(), + FetchSize = size, + Timeout = (long)time, + Unit = (int)unit + }; + var packet = new Packet() + { + Type = PacketType.Get, + Body = get.ToByteString() + }.ToByteArray(); + + WriteWithHeader(packet); + + + + return ReceiveMessages(); + + + } + catch (IOException e) + { + throw e; + } + } + + private Message ReceiveMessages() + { + + try + { + var data = ReadNextPacket(); + var p = Packet.Parser.ParseFrom(data); + switch (p.Type) + { + case PacketType.Messages: + { + if (!p.Compression.Equals(Compression.None)) + { + throw new CanalClientException("compression is not supported in this connector"); + } + + var messages = Messages.Parser.ParseFrom(p.Body); + var result = new Message(messages.BatchId); + if (_lazyParseEntry) + { + // byteString + result.RawEntries = messages.Messages_.ToList(); + + } + else + { + foreach (var byteString in messages.Messages_) + { + result.Entries.Add(Entry.Parser.ParseFrom(byteString)); + } + } + return result; + } + case PacketType.Ack: + { + var ack = Com.Alibaba.Otter.Canal.Protocol.Ack.Parser.ParseFrom(p.Body); + throw new CanalClientException($"something goes wrong with reason:{ack.ErrorMessage}"); + } + default: + { + throw new CanalClientException($"unexpected packet type: {p.Type}"); + } + } + + } + catch (Exception e) + { + throw; + } + + } + + public void Ack(long batchId) + { + WaitClientRunning(); + if (!_running) + { + return; + } + + var ca = new ClientAck() + { + Destination = _clientIdentity.Destination, + ClientId = _clientIdentity.ClientId.ToString(), + BatchId = batchId + }; + + var pack = new Packet() + { + Type = PacketType.Clientack, + Body = ca.ToByteString() + }.ToByteArray(); + + try + { + WriteWithHeader(pack); + } + catch (IOException e) + { + throw new CanalClientException(e.Message, e); + } + } + + public void Rollback(long batchId) + { + WaitClientRunning(); + + var ca = new ClientRollback() + { + Destination = _clientIdentity.Destination, + ClientId = _clientIdentity.ClientId.ToString(), + BatchId = batchId + }; + + try + { + var pack = new Packet() + { + Type = PacketType.Clientrollback, + Body = ca.ToByteString() + }.ToByteArray(); + + WriteWithHeader(pack); + } + catch (IOException e) + { + throw new CanalClientException(e.Message, e); + } + } + + public void Rollback() + { + WaitClientRunning(); + Rollback(0);// 0代笔未设置 + } + + public void StopRunning() + { + throw new NotImplementedException(); + } + private void DoConnect() + { + try + { + _tcpClient = new TcpClient(Address, Port); + _channelNetworkStream = _tcpClient.GetStream(); + var p = Packet.Parser.ParseFrom(ReadNextPacket()); + if (p != null) + { + if (p.Version != 1) + { + throw new CanalClientException("unsupported version at this client."); + } + if (p.Type != PacketType.Handshake) + { + throw new CanalClientException("expect handshake but found other type."); + } + var handshake = Handshake.Parser.ParseFrom(p.Body); + supportedCompressions.Add(handshake.SupportedCompressions); + + var ca = new ClientAuth() + { + Username = Username != null ? Username : "", + Password = ByteString.CopyFromUtf8(Password != null ? Password : ""), + NetReadTimeout = IdleTimeout, + NetWriteTimeout = IdleTimeout + }; + + var packArray = new Packet() + { + Type = PacketType.Clientauthentication, + Body = ca.ToByteString() + }.ToByteArray(); + + WriteWithHeader(packArray); + + var packet = Packet.Parser.ParseFrom(ReadNextPacket()); + if (packet.Type != PacketType.Ack) + { + throw new CanalClientException("unexpected packet type when ack is expected"); + } + + var ackBody = Com.Alibaba.Otter.Canal.Protocol.Ack.Parser.ParseFrom(p.Body); + if (ackBody.ErrorCode > 0) + { + throw new CanalClientException("something goes wrong when doing authentication:" + ackBody.ErrorMessage); + } + + _connected = _tcpClient.Connected; + } + } + catch (Exception e) + { + throw e; + } + + + } + + + private byte[] ReadNextPacket() + { + lock (_readDataLock) + { + var headerLength = ReadHeaderLength(); + var recevieData = new byte[1024 * 2]; + using (var ms = new MemoryStream()) + { + while (headerLength > 0) + { + var len = _channelNetworkStream.Read(recevieData, 0, (headerLength > recevieData.Length ? recevieData.Length : headerLength)); + ms.Write(recevieData, 0, len); + headerLength = headerLength - len; + } + + return ms.ToArray(); + } + + + } + } + + private int ReadHeaderLength() + { + var headerBytes = new byte[4]; + _channelNetworkStream.Read(headerBytes, 0, 4); + Array.Reverse(headerBytes); + return BitConverter.ToInt32(headerBytes, 0); + } + + private void WriteWithHeader(byte[] body) + { + lock (_writeDataLock) + { + var len = body.Length; + var bytes = GetHeaderBytes(len); + _channelNetworkStream.Write(bytes, 0, bytes.Length); + _channelNetworkStream.Write(body, 0, body.Length); + } + + } + + + private byte[] GetHeaderBytes(int lenth) + { + var data = BitConverter.GetBytes(lenth); + Array.Reverse(data); + return data; + } + + private void WaitClientRunning() + { + _running = true; + } + + } +} diff --git a/src/CanalSharp.Client/Impl/SimpleNodeAccessStrategy.cs b/src/CanalSharp.Client/Impl/SimpleNodeAccessStrategy.cs new file mode 100644 index 0000000..cc70fb9 --- /dev/null +++ b/src/CanalSharp.Client/Impl/SimpleNodeAccessStrategy.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; + +namespace CanalSharp.Client.Impl +{ + + /// + /// 简单版本的node访问实现 + /// + public class SimpleNodeAccessStrategy : ICanalNodeAccessStrategy + { + private readonly List _nodes = new List(); + private int _index = 0; + + public SimpleNodeAccessStrategy(List nodes) + { + if (nodes == null || !nodes.Any()) + { + throw new ArgumentException("at least 1 node required.", nameof(nodes)); + } + + this._nodes.AddRange(nodes); + } + + public SocketAddress NextNode() + { + try + { + return _nodes[_index]; + } + finally + { + _index = (_index + 1) % _nodes.Count(); + } + } + + public SocketAddress CurrentNode() + { + return _nodes[_index]; + } + } +} \ No newline at end of file diff --git a/src/CanalSharp.Common/AbstractCanalLifeCycle.cs b/src/CanalSharp.Common/AbstractCanalLifeCycle.cs new file mode 100644 index 0000000..58cbc5d --- /dev/null +++ b/src/CanalSharp.Common/AbstractCanalLifeCycle.cs @@ -0,0 +1,34 @@ +using CanalSharp.Common.Exception; + +namespace CanalSharp.Common +{ + public abstract class AbstractCanalLifeCycle : ICanalLifeCycle + { + protected volatile bool Running = false; // 是否处于运行中 + + public bool IsStart() + { + return Running; + } + + public virtual void Start() + { + if (Running) + { + throw new CanalException($" {nameof(AbstractCanalLifeCycle)} has startup , don't repeat start"); + } + + Running = true; + } + + public virtual void Stop() + { + if (!Running) + { + throw new CanalException($"{nameof(AbstractCanalLifeCycle)} isn't start , please check"); + } + + Running = false; + } + } +} \ No newline at end of file diff --git a/src/CanalSharp.Common/Alarm/ICanalAlarmHandler.cs b/src/CanalSharp.Common/Alarm/ICanalAlarmHandler.cs new file mode 100644 index 0000000..a2fe73b --- /dev/null +++ b/src/CanalSharp.Common/Alarm/ICanalAlarmHandler.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace CanalSharp.Common.Alarm +{ + /// + /// canal报警处理机制 + /// + public interface ICanalAlarmHandler + { + /// + /// 发送对应destination的报警 + /// + /// + /// + void SendAlarm(string destination, string msg); + } +} diff --git a/src/CanalSharp.Common/Alarm/Impl/LogAlarmHandler.cs b/src/CanalSharp.Common/Alarm/Impl/LogAlarmHandler.cs new file mode 100644 index 0000000..af9b81a --- /dev/null +++ b/src/CanalSharp.Common/Alarm/Impl/LogAlarmHandler.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; +using CanalSharp.Common.Logging; + +namespace CanalSharp.Common.Alarm.Impl +{ + public class LogAlarmHandler : ICanalAlarmHandler + { + private readonly ILogger _logger = LogManager.GetLogger(typeof(LogAlarmHandler)); + public void SendAlarm(string destination, string msg) + { + _logger.Warning($"destination:{destination}[{msg}]"); + } + } +} diff --git a/src/Canal4Net/Canal4Net.csproj b/src/CanalSharp.Common/CanalSharp.Common.csproj similarity index 74% rename from src/Canal4Net/Canal4Net.csproj rename to src/CanalSharp.Common/CanalSharp.Common.csproj index a39e84e..a592c21 100644 --- a/src/Canal4Net/Canal4Net.csproj +++ b/src/CanalSharp.Common/CanalSharp.Common.csproj @@ -1,5 +1,5 @@  - + netstandard2.0 diff --git a/src/CanalSharp.Common/Exception/CanalException.cs b/src/CanalSharp.Common/Exception/CanalException.cs new file mode 100644 index 0000000..3d0d840 --- /dev/null +++ b/src/CanalSharp.Common/Exception/CanalException.cs @@ -0,0 +1,13 @@ +namespace CanalSharp.Common.Exception +{ + public class CanalException : System.Exception + { + public CanalException(string errorCode) : base(errorCode) + { + } + + public CanalException(string errorCode, System.Exception cause) : base(errorCode, cause) + { + } + } +} diff --git a/src/CanalSharp.Common/ICanalLifeCycle.cs b/src/CanalSharp.Common/ICanalLifeCycle.cs new file mode 100644 index 0000000..8993491 --- /dev/null +++ b/src/CanalSharp.Common/ICanalLifeCycle.cs @@ -0,0 +1,13 @@ +using System; + +namespace CanalSharp.Common +{ + public interface ICanalLifeCycle + { + void Start(); + + void Stop(); + + bool IsStart(); + } +} diff --git a/src/CanalSharp.Common/Logging/ILogger.cs b/src/CanalSharp.Common/Logging/ILogger.cs new file mode 100644 index 0000000..b0e2add --- /dev/null +++ b/src/CanalSharp.Common/Logging/ILogger.cs @@ -0,0 +1,17 @@ +using System; + +namespace CanalSharp.Common.Logging +{ + public interface ILogger + { + void Debug(String message); + + void Info(String message); + + void Warning(String message); + + void Error(String message, System.Exception exception); + + void Trace(String message); + } +} \ No newline at end of file diff --git a/src/CanalSharp.Common/Logging/ILoggerFactory.cs b/src/CanalSharp.Common/Logging/ILoggerFactory.cs new file mode 100644 index 0000000..7b9c938 --- /dev/null +++ b/src/CanalSharp.Common/Logging/ILoggerFactory.cs @@ -0,0 +1,9 @@ +using System; + +namespace CanalSharp.Common.Logging +{ + public interface ILoggerFactory + { + ILogger CreateLogger(Type type); + } +} \ No newline at end of file diff --git a/src/CanalSharp.Common/Logging/LogManager.cs b/src/CanalSharp.Common/Logging/LogManager.cs new file mode 100644 index 0000000..2e03f16 --- /dev/null +++ b/src/CanalSharp.Common/Logging/LogManager.cs @@ -0,0 +1,26 @@ +using System; + +namespace CanalSharp.Common.Logging +{ + public static class LogManager + { + private static readonly ILoggerFactory defaultLoggerFactory = new NullLoggerFactory(); + private static ILoggerFactory _loggerFactory; + + public static ILogger GetLogger(Type type) + { + var loggerFactory = _loggerFactory ?? defaultLoggerFactory; + return loggerFactory.CreateLogger(type); + } + + public static ILogger GetLogger() + { + return GetLogger(typeof(T)); + } + + public static void SetLoggerFactory(ILoggerFactory loggerFactory) + { + _loggerFactory = loggerFactory; + } + } +} \ No newline at end of file diff --git a/src/CanalSharp.Common/Logging/NullLogger.cs b/src/CanalSharp.Common/Logging/NullLogger.cs new file mode 100644 index 0000000..80627ad --- /dev/null +++ b/src/CanalSharp.Common/Logging/NullLogger.cs @@ -0,0 +1,27 @@ +using System; + +namespace CanalSharp.Common.Logging +{ + internal class NullLogger : ILogger + { + public void Debug(String message) + { + } + + public void Info(String message) + { + } + + public void Warning(String message) + { + } + + public void Error(String message, System.Exception exception) + { + } + + public void Trace(String message) + { + } + } +} \ No newline at end of file diff --git a/src/CanalSharp.Common/Logging/NullLoggerFactory.cs b/src/CanalSharp.Common/Logging/NullLoggerFactory.cs new file mode 100644 index 0000000..33cb92b --- /dev/null +++ b/src/CanalSharp.Common/Logging/NullLoggerFactory.cs @@ -0,0 +1,12 @@ +using System; + +namespace CanalSharp.Common.Logging +{ + public class NullLoggerFactory : ILoggerFactory + { + public ILogger CreateLogger(Type type) + { + return new NullLogger(); + } + } +} \ No newline at end of file diff --git a/src/CanalSharp.Common/Utils/AddressUtils.cs b/src/CanalSharp.Common/Utils/AddressUtils.cs new file mode 100644 index 0000000..f0fd868 --- /dev/null +++ b/src/CanalSharp.Common/Utils/AddressUtils.cs @@ -0,0 +1,132 @@ +using System; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.NetworkInformation; +using System.Net.Sockets; +using System.Text.RegularExpressions; +using CanalSharp.Common.Logging; + +namespace CanalSharp.Common.Utils +{ + + public class AddressUtils + { + private static readonly ILogger _logger = LogManager.GetLogger(typeof(AddressUtils)); + private static string LOCALHOST_IP = "127.0.0.1"; + private static string EMPTY_IP = "0.0.0.0"; + private static readonly Regex IP_PATTERN = new Regex("[0-9]{1,3}(\\.[0-9]{1,3}){3,}"); + + + public static bool IsAvailablePort(int port) + { + TcpListener ss = null; + try + { + ss = new TcpListener(port); + ss.Start(); + return true; + } + catch (IOException e) + { + return false; + } + finally + { + if (ss != null) + { + try + { + ss.Stop(); + } + catch (IOException e) + { + } + } + } + } + + private static bool IsValidHostAddress(IPAddress address) + { + if (address == null || IPAddress.IsLoopback(address)) return false; + var name = Dns.GetHostEntry(address).HostName; + return (name != null && !EMPTY_IP.Equals(name) && !LOCALHOST_IP.Equals(name) && IP_PATTERN.IsMatch(name)); + } + + + public static string GetHostIp() + { + var address = GetHostAddress(); + return address == null ? null : Dns.GetHostEntry(address).HostName; + } + + public static string GetHostName() + { + //IPHostEntry hostEntry; + + //hostEntry = Dns.GetHostEntry(host); + + ////you might get more than one ip for a hostname since + ////DNS supports more than one record + + //if (hostEntry.AddressList.Length > 0) + //{ + // var ip = hostEntry.AddressList[0]; + // Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); + // s.Connect(ip, 80); + //} + var address = GetHostAddress(); + return address == null ? null : Dns.GetHostEntry(address).HostName; + } + + + public static IPAddress GetHostAddress() + { + IPAddress localAddress = null; + try + { + localAddress = Dns.GetHostEntry(Dns.GetHostName()) + .AddressList.First( + f => f.AddressFamily == AddressFamily.InterNetwork); + if (IsValidHostAddress(localAddress)) + { + return localAddress; + } + } + catch (System.Exception e) + { + _logger.Warning($"Failed to retriving local host ip address, try scan network card ip address. cause: {e.Message}"); + } + try + { + var interfaces = NetworkInterface.GetAllNetworkInterfaces(); + if (interfaces != null) + { + foreach (var ni in NetworkInterface.GetAllNetworkInterfaces()) + { + if (ni.NetworkInterfaceType != NetworkInterfaceType.Wireless80211 && + ni.NetworkInterfaceType != NetworkInterfaceType.Ethernet) continue; + Console.WriteLine(ni.Name); + foreach (var ip in ni.GetIPProperties().UnicastAddresses) + { + if (ip.Address.AddressFamily != AddressFamily.InterNetwork) continue; + var address = ip.Address; + if (IsValidHostAddress(address)) + { + return address; + } + } + } + + } + } + catch (System.Exception e) + { + _logger.Warning($"Failed to retriving network card ip address. cause:{e.Message}"); + } + _logger.Warning("Could not get local host ip address, will use 127.0.0.1 instead."); + return localAddress; + } + + } +} diff --git a/src/CanalSharp.Common/Utils/BooleanMutex.cs b/src/CanalSharp.Common/Utils/BooleanMutex.cs new file mode 100644 index 0000000..5ff3633 --- /dev/null +++ b/src/CanalSharp.Common/Utils/BooleanMutex.cs @@ -0,0 +1,13 @@ +using System.Threading; + +namespace CanalSharp.Common.Utils +{ + public class BooleanMutex + { + public void Set() + { + Mutex mutex =new Mutex(); + mutex.ReleaseMutex(); + } + } +} diff --git a/src/CanalSharp.Common/Zookeeper/Running/IServerRunningListener.cs b/src/CanalSharp.Common/Zookeeper/Running/IServerRunningListener.cs new file mode 100644 index 0000000..f7ad672 --- /dev/null +++ b/src/CanalSharp.Common/Zookeeper/Running/IServerRunningListener.cs @@ -0,0 +1,25 @@ +namespace CanalSharp.Common.Zookeeper.Running +{ + public interface IServerRunningListener + { + /** + * 启动时回调做点事情 + */ + void ProcessStart(); + + /** + * 关闭时回调做点事情 + */ + void ProcessStop(); + + /** + * 触发现在轮到自己做为active,需要载入上一个active的上下文数据 + */ + void ProcessActiveEnter(); + + /** + * 触发一下当前active模式失败 + */ + void ProcessActiveExit(); + } +} diff --git a/src/CanalSharp.Protocol/CanalProtocol.cs b/src/CanalSharp.Protocol/CanalProtocol.cs new file mode 100644 index 0000000..9cfef05 --- /dev/null +++ b/src/CanalSharp.Protocol/CanalProtocol.cs @@ -0,0 +1,2885 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: CanalProtocol.proto +// +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using System.Text; +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Com.Alibaba.Otter.Canal.Protocol { + + /// Holder for reflection information generated from CanalProtocol.proto + public static partial class CanalProtocolReflection { + + #region Descriptor + /// File descriptor for CanalProtocol.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static CanalProtocolReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChNDYW5hbFByb3RvY29sLnByb3RvEiBjb20uYWxpYmFiYS5vdHRlci5jYW5h", + "bC5wcm90b2NvbCKFAgoGUGFja2V0EhYKDG1hZ2ljX251bWJlchgBIAEoBUgA", + "EhEKB3ZlcnNpb24YAiABKAVIARI6CgR0eXBlGAMgASgOMiwuY29tLmFsaWJh", + "YmEub3R0ZXIuY2FuYWwucHJvdG9jb2wuUGFja2V0VHlwZRJECgtjb21wcmVz", + "c2lvbhgEIAEoDjItLmNvbS5hbGliYWJhLm90dGVyLmNhbmFsLnByb3RvY29s", + "LkNvbXByZXNzaW9uSAISDAoEYm9keRgFIAEoDEIWChRtYWdpY19udW1iZXJf", + "cHJlc2VudEIRCg92ZXJzaW9uX3ByZXNlbnRCFQoTY29tcHJlc3Npb25fcHJl", + "c2VudCI8CglIZWFydEJlYXQSFgoOc2VuZF90aW1lc3RhbXAYASABKAMSFwoP", + "c3RhcnRfdGltZXN0YW1wGAIgASgDIq0BCglIYW5kc2hha2USIAoWY29tbXVu", + "aWNhdGlvbl9lbmNvZGluZxgBIAEoCUgAEg0KBXNlZWRzGAIgASgMEk0KFnN1", + "cHBvcnRlZF9jb21wcmVzc2lvbnMYAyABKA4yLS5jb20uYWxpYmFiYS5vdHRl", + "ci5jYW5hbC5wcm90b2NvbC5Db21wcmVzc2lvbkIgCh5jb21tdW5pY2F0aW9u", + "X2VuY29kaW5nX3ByZXNlbnQi8wEKCkNsaWVudEF1dGgSEAoIdXNlcm5hbWUY", + "ASABKAkSEAoIcGFzc3dvcmQYAiABKAwSGgoQbmV0X3JlYWRfdGltZW91dBgD", + "IAEoBUgAEhsKEW5ldF93cml0ZV90aW1lb3V0GAQgASgFSAESEwoLZGVzdGlu", + "YXRpb24YBSABKAkSEQoJY2xpZW50X2lkGAYgASgJEg4KBmZpbHRlchgHIAEo", + "CRIXCg9zdGFydF90aW1lc3RhbXAYCCABKANCGgoYbmV0X3JlYWRfdGltZW91", + "dF9wcmVzZW50QhsKGW5ldF93cml0ZV90aW1lb3V0X3ByZXNlbnQiSAoDQWNr", + "EhQKCmVycm9yX2NvZGUYASABKAVIABIVCg1lcnJvcl9tZXNzYWdlGAIgASgJ", + "QhQKEmVycm9yX2NvZGVfcHJlc2VudCJFCglDbGllbnRBY2sSEwoLZGVzdGlu", + "YXRpb24YASABKAkSEQoJY2xpZW50X2lkGAIgASgJEhAKCGJhdGNoX2lkGAMg", + "ASgDIj0KA1N1YhITCgtkZXN0aW5hdGlvbhgBIAEoCRIRCgljbGllbnRfaWQY", + "AiABKAkSDgoGZmlsdGVyGAcgASgJIj8KBVVuc3ViEhMKC2Rlc3RpbmF0aW9u", + "GAEgASgJEhEKCWNsaWVudF9pZBgCIAEoCRIOCgZmaWx0ZXIYByABKAkirwEK", + "A0dldBITCgtkZXN0aW5hdGlvbhgBIAEoCRIRCgljbGllbnRfaWQYAiABKAkS", + "EgoKZmV0Y2hfc2l6ZRgDIAEoBRIRCgd0aW1lb3V0GAQgASgDSAASDgoEdW5p", + "dBgFIAEoBUgBEhIKCGF1dG9fYWNrGAYgASgISAJCEQoPdGltZW91dF9wcmVz", + "ZW50Qg4KDHVuaXRfcHJlc2VudEISChBhdXRvX2Fja19wcmVzZW50Ii4KCE1l", + "c3NhZ2VzEhAKCGJhdGNoX2lkGAEgASgDEhAKCG1lc3NhZ2VzGAIgAygMIlMK", + "BER1bXASDwoHam91cm5hbBgBIAEoCRIQCghwb3NpdGlvbhgCIAEoAxITCgl0", + "aW1lc3RhbXAYAyABKANIAEITChF0aW1lc3RhbXBfcHJlc2VudCJKCg5DbGll", + "bnRSb2xsYmFjaxITCgtkZXN0aW5hdGlvbhgBIAEoCRIRCgljbGllbnRfaWQY", + "AiABKAkSEAoIYmF0Y2hfaWQYAyABKAMqVQoLQ29tcHJlc3Npb24SHwobQ09N", + "UFJFU1NJT05DT01QQVRJQkxFUFJPVE8yEAASCAoETk9ORRABEggKBFpMSUIQ", + "AhIICgRHWklQEAMSBwoDTFpGEAQq5gEKClBhY2tldFR5cGUSHwobUEFDS0FH", + "RVRZUEVDT01QQVRJQkxFUFJPVE8yEAASDQoJSEFORFNIQUtFEAESGAoUQ0xJ", + "RU5UQVVUSEVOVElDQVRJT04QAhIHCgNBQ0sQAxIQCgxTVUJTQ1JJUFRJT04Q", + "BBISCg5VTlNVQlNDUklQVElPThAFEgcKA0dFVBAGEgwKCE1FU1NBR0VTEAcS", + "DQoJQ0xJRU5UQUNLEAgSDAoIU0hVVERPV04QCRIICgREVU1QEAoSDQoJSEVB", + "UlRCRUFUEAsSEgoOQ0xJRU5UUk9MTEJBQ0sQDEIxCiBjb20uYWxpYmFiYS5v", + "dHRlci5jYW5hbC5wcm90b2NvbEILQ2FuYWxQYWNrZXRIAWIGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Com.Alibaba.Otter.Canal.Protocol.Compression), typeof(global::Com.Alibaba.Otter.Canal.Protocol.PacketType), }, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Alibaba.Otter.Canal.Protocol.Packet), global::Com.Alibaba.Otter.Canal.Protocol.Packet.Parser, new[]{ "MagicNumber", "Version", "Type", "Compression", "Body" }, new[]{ "MagicNumberPresent", "VersionPresent", "CompressionPresent" }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Alibaba.Otter.Canal.Protocol.HeartBeat), global::Com.Alibaba.Otter.Canal.Protocol.HeartBeat.Parser, new[]{ "SendTimestamp", "StartTimestamp" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Alibaba.Otter.Canal.Protocol.Handshake), global::Com.Alibaba.Otter.Canal.Protocol.Handshake.Parser, new[]{ "CommunicationEncoding", "Seeds", "SupportedCompressions" }, new[]{ "CommunicationEncodingPresent" }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Alibaba.Otter.Canal.Protocol.ClientAuth), global::Com.Alibaba.Otter.Canal.Protocol.ClientAuth.Parser, new[]{ "Username", "Password", "NetReadTimeout", "NetWriteTimeout", "Destination", "ClientId", "Filter", "StartTimestamp" }, new[]{ "NetReadTimeoutPresent", "NetWriteTimeoutPresent" }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Alibaba.Otter.Canal.Protocol.Ack), global::Com.Alibaba.Otter.Canal.Protocol.Ack.Parser, new[]{ "ErrorCode", "ErrorMessage" }, new[]{ "ErrorCodePresent" }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Alibaba.Otter.Canal.Protocol.ClientAck), global::Com.Alibaba.Otter.Canal.Protocol.ClientAck.Parser, new[]{ "Destination", "ClientId", "BatchId" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Alibaba.Otter.Canal.Protocol.Sub), global::Com.Alibaba.Otter.Canal.Protocol.Sub.Parser, new[]{ "Destination", "ClientId", "Filter" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Alibaba.Otter.Canal.Protocol.Unsub), global::Com.Alibaba.Otter.Canal.Protocol.Unsub.Parser, new[]{ "Destination", "ClientId", "Filter" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Alibaba.Otter.Canal.Protocol.Get), global::Com.Alibaba.Otter.Canal.Protocol.Get.Parser, new[]{ "Destination", "ClientId", "FetchSize", "Timeout", "Unit", "AutoAck" }, new[]{ "TimeoutPresent", "UnitPresent", "AutoAckPresent" }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Alibaba.Otter.Canal.Protocol.Messages), global::Com.Alibaba.Otter.Canal.Protocol.Messages.Parser, new[]{ "BatchId", "Messages_" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Alibaba.Otter.Canal.Protocol.Dump), global::Com.Alibaba.Otter.Canal.Protocol.Dump.Parser, new[]{ "Journal", "Position", "Timestamp" }, new[]{ "TimestampPresent" }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Alibaba.Otter.Canal.Protocol.ClientRollback), global::Com.Alibaba.Otter.Canal.Protocol.ClientRollback.Parser, new[]{ "Destination", "ClientId", "BatchId" }, null, null, null) + })); + } + #endregion + + } + #region Enums + public enum Compression { + [pbr::OriginalName("COMPRESSIONCOMPATIBLEPROTO2")] Compatibleproto2 = 0, + [pbr::OriginalName("NONE")] None = 1, + [pbr::OriginalName("ZLIB")] Zlib = 2, + [pbr::OriginalName("GZIP")] Gzip = 3, + [pbr::OriginalName("LZF")] Lzf = 4, + } + + public enum PacketType { + /// + ///compatible + /// + [pbr::OriginalName("PACKAGETYPECOMPATIBLEPROTO2")] Packagetypecompatibleproto2 = 0, + [pbr::OriginalName("HANDSHAKE")] Handshake = 1, + [pbr::OriginalName("CLIENTAUTHENTICATION")] Clientauthentication = 2, + [pbr::OriginalName("ACK")] Ack = 3, + [pbr::OriginalName("SUBSCRIPTION")] Subscription = 4, + [pbr::OriginalName("UNSUBSCRIPTION")] Unsubscription = 5, + [pbr::OriginalName("GET")] Get = 6, + [pbr::OriginalName("MESSAGES")] Messages = 7, + [pbr::OriginalName("CLIENTACK")] Clientack = 8, + /// + /// management part + /// + [pbr::OriginalName("SHUTDOWN")] Shutdown = 9, + /// + /// integration + /// + [pbr::OriginalName("DUMP")] Dump = 10, + [pbr::OriginalName("HEARTBEAT")] Heartbeat = 11, + [pbr::OriginalName("CLIENTROLLBACK")] Clientrollback = 12, + } + + #endregion + + #region Messages + public sealed partial class Packet : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Packet()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Alibaba.Otter.Canal.Protocol.CanalProtocolReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Packet() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Packet(Packet other) : this() { + type_ = other.type_; + body_ = other.body_; + switch (other.MagicNumberPresentCase) { + case MagicNumberPresentOneofCase.MagicNumber: + MagicNumber = other.MagicNumber; + break; + } + + switch (other.VersionPresentCase) { + case VersionPresentOneofCase.Version: + Version = other.Version; + break; + } + + switch (other.CompressionPresentCase) { + case CompressionPresentOneofCase.Compression: + Compression = other.Compression; + break; + } + + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Packet Clone() { + return new Packet(this); + } + + /// Field number for the "magic_number" field. + public const int MagicNumberFieldNumber = 1; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int MagicNumber { + get { return magicNumberPresentCase_ == MagicNumberPresentOneofCase.MagicNumber ? (int) magicNumberPresent_ : 17; } + set { + magicNumberPresent_ = value; + magicNumberPresentCase_ = MagicNumberPresentOneofCase.MagicNumber; + } + } + + /// Field number for the "version" field. + public const int VersionFieldNumber = 2; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Version { + get { return versionPresentCase_ == VersionPresentOneofCase.Version ? (int) versionPresent_ : 1; } + set { + versionPresent_ = value; + versionPresentCase_ = VersionPresentOneofCase.Version; + } + } + + /// Field number for the "type" field. + public const int TypeFieldNumber = 3; + private global::Com.Alibaba.Otter.Canal.Protocol.PacketType type_ = 0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Com.Alibaba.Otter.Canal.Protocol.PacketType Type { + get { return type_; } + set { + type_ = value; + } + } + + /// Field number for the "compression" field. + public const int CompressionFieldNumber = 4; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Com.Alibaba.Otter.Canal.Protocol.Compression Compression { + get { return compressionPresentCase_ == CompressionPresentOneofCase.Compression ? (global::Com.Alibaba.Otter.Canal.Protocol.Compression) compressionPresent_ : Compression.None; } + set { + compressionPresent_ = value; + compressionPresentCase_ = CompressionPresentOneofCase.Compression; + } + } + + /// Field number for the "body" field. + public const int BodyFieldNumber = 5; + private pb::ByteString body_ = pb::ByteString.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString Body { + get { return body_; } + set { + body_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + private object magicNumberPresent_; + /// Enum of possible cases for the "magic_number_present" oneof. + public enum MagicNumberPresentOneofCase { + None = 0, + MagicNumber = 1, + } + private MagicNumberPresentOneofCase magicNumberPresentCase_ = MagicNumberPresentOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MagicNumberPresentOneofCase MagicNumberPresentCase { + get { return magicNumberPresentCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearMagicNumberPresent() { + magicNumberPresentCase_ = MagicNumberPresentOneofCase.None; + magicNumberPresent_ = null; + } + + private object versionPresent_; + /// Enum of possible cases for the "version_present" oneof. + public enum VersionPresentOneofCase { + None = 0, + Version = 2, + } + private VersionPresentOneofCase versionPresentCase_ = VersionPresentOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public VersionPresentOneofCase VersionPresentCase { + get { return versionPresentCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearVersionPresent() { + versionPresentCase_ = VersionPresentOneofCase.None; + versionPresent_ = null; + } + + private object compressionPresent_; + /// Enum of possible cases for the "compression_present" oneof. + public enum CompressionPresentOneofCase { + None = 0, + Compression = 4, + } + private CompressionPresentOneofCase compressionPresentCase_ = CompressionPresentOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CompressionPresentOneofCase CompressionPresentCase { + get { return compressionPresentCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearCompressionPresent() { + compressionPresentCase_ = CompressionPresentOneofCase.None; + compressionPresent_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Packet); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Packet other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (MagicNumber != other.MagicNumber) return false; + if (Version != other.Version) return false; + if (Type != other.Type) return false; + if (Compression != other.Compression) return false; + if (Body != other.Body) return false; + if (MagicNumberPresentCase != other.MagicNumberPresentCase) return false; + if (VersionPresentCase != other.VersionPresentCase) return false; + if (CompressionPresentCase != other.CompressionPresentCase) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (magicNumberPresentCase_ == MagicNumberPresentOneofCase.MagicNumber) hash ^= MagicNumber.GetHashCode(); + if (versionPresentCase_ == VersionPresentOneofCase.Version) hash ^= Version.GetHashCode(); + if (Type != 0) hash ^= Type.GetHashCode(); + if (compressionPresentCase_ == CompressionPresentOneofCase.Compression) hash ^= Compression.GetHashCode(); + if (Body.Length != 0) hash ^= Body.GetHashCode(); + hash ^= (int) magicNumberPresentCase_; + hash ^= (int) versionPresentCase_; + hash ^= (int) compressionPresentCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (magicNumberPresentCase_ == MagicNumberPresentOneofCase.MagicNumber) { + output.WriteRawTag(8); + output.WriteInt32(MagicNumber); + } + if (versionPresentCase_ == VersionPresentOneofCase.Version) { + output.WriteRawTag(16); + output.WriteInt32(Version); + } + if (Type != 0) { + output.WriteRawTag(24); + output.WriteEnum((int) Type); + } + if (compressionPresentCase_ == CompressionPresentOneofCase.Compression) { + output.WriteRawTag(32); + output.WriteEnum((int) Compression); + } + if (Body.Length != 0) { + output.WriteRawTag(42); + output.WriteBytes(Body); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (magicNumberPresentCase_ == MagicNumberPresentOneofCase.MagicNumber) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(MagicNumber); + } + if (versionPresentCase_ == VersionPresentOneofCase.Version) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Version); + } + if (Type != 0) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type); + } + if (compressionPresentCase_ == CompressionPresentOneofCase.Compression) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Compression); + } + if (Body.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(Body); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Packet other) { + if (other == null) { + return; + } + if (other.Type != 0) { + Type = other.Type; + } + if (other.Body.Length != 0) { + Body = other.Body; + } + switch (other.MagicNumberPresentCase) { + case MagicNumberPresentOneofCase.MagicNumber: + MagicNumber = other.MagicNumber; + break; + } + + switch (other.VersionPresentCase) { + case VersionPresentOneofCase.Version: + Version = other.Version; + break; + } + + switch (other.CompressionPresentCase) { + case CompressionPresentOneofCase.Compression: + Compression = other.Compression; + break; + } + + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + MagicNumber = input.ReadInt32(); + break; + } + case 16: { + Version = input.ReadInt32(); + break; + } + case 24: { + type_ = (global::Com.Alibaba.Otter.Canal.Protocol.PacketType) input.ReadEnum(); + break; + } + case 32: { + compressionPresent_ = input.ReadEnum(); + compressionPresentCase_ = CompressionPresentOneofCase.Compression; + break; + } + case 42: { + Body = input.ReadBytes(); + break; + } + } + } + } + + } + + public sealed partial class HeartBeat : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new HeartBeat()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Alibaba.Otter.Canal.Protocol.CanalProtocolReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public HeartBeat() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public HeartBeat(HeartBeat other) : this() { + sendTimestamp_ = other.sendTimestamp_; + startTimestamp_ = other.startTimestamp_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public HeartBeat Clone() { + return new HeartBeat(this); + } + + /// Field number for the "send_timestamp" field. + public const int SendTimestampFieldNumber = 1; + private long sendTimestamp_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long SendTimestamp { + get { return sendTimestamp_; } + set { + sendTimestamp_ = value; + } + } + + /// Field number for the "start_timestamp" field. + public const int StartTimestampFieldNumber = 2; + private long startTimestamp_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long StartTimestamp { + get { return startTimestamp_; } + set { + startTimestamp_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as HeartBeat); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(HeartBeat other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (SendTimestamp != other.SendTimestamp) return false; + if (StartTimestamp != other.StartTimestamp) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (SendTimestamp != 0L) hash ^= SendTimestamp.GetHashCode(); + if (StartTimestamp != 0L) hash ^= StartTimestamp.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (SendTimestamp != 0L) { + output.WriteRawTag(8); + output.WriteInt64(SendTimestamp); + } + if (StartTimestamp != 0L) { + output.WriteRawTag(16); + output.WriteInt64(StartTimestamp); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (SendTimestamp != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(SendTimestamp); + } + if (StartTimestamp != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(StartTimestamp); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(HeartBeat other) { + if (other == null) { + return; + } + if (other.SendTimestamp != 0L) { + SendTimestamp = other.SendTimestamp; + } + if (other.StartTimestamp != 0L) { + StartTimestamp = other.StartTimestamp; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + SendTimestamp = input.ReadInt64(); + break; + } + case 16: { + StartTimestamp = input.ReadInt64(); + break; + } + } + } + } + + } + + public sealed partial class Handshake : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Handshake()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Alibaba.Otter.Canal.Protocol.CanalProtocolReflection.Descriptor.MessageTypes[2]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Handshake() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Handshake(Handshake other) : this() { + seeds_ = other.seeds_; + supportedCompressions_ = other.supportedCompressions_; + switch (other.CommunicationEncodingPresentCase) { + case CommunicationEncodingPresentOneofCase.CommunicationEncoding: + CommunicationEncoding = other.CommunicationEncoding; + break; + } + + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Handshake Clone() { + return new Handshake(this); + } + + /// Field number for the "communication_encoding" field. + public const int CommunicationEncodingFieldNumber = 1; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string CommunicationEncoding { + get { return communicationEncodingPresentCase_ == CommunicationEncodingPresentOneofCase.CommunicationEncoding ? (string) communicationEncodingPresent_ : Encoding.UTF8.ToString(); } + set { + communicationEncodingPresent_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + communicationEncodingPresentCase_ = CommunicationEncodingPresentOneofCase.CommunicationEncoding; + } + } + + /// Field number for the "seeds" field. + public const int SeedsFieldNumber = 2; + private pb::ByteString seeds_ = pb::ByteString.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString Seeds { + get { return seeds_; } + set { + seeds_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "supported_compressions" field. + public const int SupportedCompressionsFieldNumber = 3; + private global::Com.Alibaba.Otter.Canal.Protocol.Compression supportedCompressions_ = 0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Com.Alibaba.Otter.Canal.Protocol.Compression SupportedCompressions { + get { return supportedCompressions_; } + set { + supportedCompressions_ = value; + } + } + + private object communicationEncodingPresent_; + /// Enum of possible cases for the "communication_encoding_present" oneof. + public enum CommunicationEncodingPresentOneofCase { + None = 0, + CommunicationEncoding = 1, + } + private CommunicationEncodingPresentOneofCase communicationEncodingPresentCase_ = CommunicationEncodingPresentOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CommunicationEncodingPresentOneofCase CommunicationEncodingPresentCase { + get { return communicationEncodingPresentCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearCommunicationEncodingPresent() { + communicationEncodingPresentCase_ = CommunicationEncodingPresentOneofCase.None; + communicationEncodingPresent_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Handshake); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Handshake other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (CommunicationEncoding != other.CommunicationEncoding) return false; + if (Seeds != other.Seeds) return false; + if (SupportedCompressions != other.SupportedCompressions) return false; + if (CommunicationEncodingPresentCase != other.CommunicationEncodingPresentCase) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (communicationEncodingPresentCase_ == CommunicationEncodingPresentOneofCase.CommunicationEncoding) hash ^= CommunicationEncoding.GetHashCode(); + if (Seeds.Length != 0) hash ^= Seeds.GetHashCode(); + if (SupportedCompressions != 0) hash ^= SupportedCompressions.GetHashCode(); + hash ^= (int) communicationEncodingPresentCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (communicationEncodingPresentCase_ == CommunicationEncodingPresentOneofCase.CommunicationEncoding) { + output.WriteRawTag(10); + output.WriteString(CommunicationEncoding); + } + if (Seeds.Length != 0) { + output.WriteRawTag(18); + output.WriteBytes(Seeds); + } + if (SupportedCompressions != 0) { + output.WriteRawTag(24); + output.WriteEnum((int) SupportedCompressions); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (communicationEncodingPresentCase_ == CommunicationEncodingPresentOneofCase.CommunicationEncoding) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(CommunicationEncoding); + } + if (Seeds.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(Seeds); + } + if (SupportedCompressions != 0) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) SupportedCompressions); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Handshake other) { + if (other == null) { + return; + } + if (other.Seeds.Length != 0) { + Seeds = other.Seeds; + } + if (other.SupportedCompressions != 0) { + SupportedCompressions = other.SupportedCompressions; + } + switch (other.CommunicationEncodingPresentCase) { + case CommunicationEncodingPresentOneofCase.CommunicationEncoding: + CommunicationEncoding = other.CommunicationEncoding; + break; + } + + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + CommunicationEncoding = input.ReadString(); + break; + } + case 18: { + Seeds = input.ReadBytes(); + break; + } + case 24: { + supportedCompressions_ = (global::Com.Alibaba.Otter.Canal.Protocol.Compression) input.ReadEnum(); + break; + } + } + } + } + + } + + /// + /// client authentication + /// + public sealed partial class ClientAuth : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ClientAuth()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Alibaba.Otter.Canal.Protocol.CanalProtocolReflection.Descriptor.MessageTypes[3]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ClientAuth() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ClientAuth(ClientAuth other) : this() { + username_ = other.username_; + password_ = other.password_; + destination_ = other.destination_; + clientId_ = other.clientId_; + filter_ = other.filter_; + startTimestamp_ = other.startTimestamp_; + switch (other.NetReadTimeoutPresentCase) { + case NetReadTimeoutPresentOneofCase.NetReadTimeout: + NetReadTimeout = other.NetReadTimeout; + break; + } + + switch (other.NetWriteTimeoutPresentCase) { + case NetWriteTimeoutPresentOneofCase.NetWriteTimeout: + NetWriteTimeout = other.NetWriteTimeout; + break; + } + + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ClientAuth Clone() { + return new ClientAuth(this); + } + + /// Field number for the "username" field. + public const int UsernameFieldNumber = 1; + private string username_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Username { + get { return username_; } + set { + username_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "password" field. + public const int PasswordFieldNumber = 2; + private pb::ByteString password_ = pb::ByteString.Empty; + /// + /// hashed password with seeds from Handshake message + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString Password { + get { return password_; } + set { + password_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "net_read_timeout" field. + public const int NetReadTimeoutFieldNumber = 3; + /// + /// in seconds + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int NetReadTimeout { + get { return netReadTimeoutPresentCase_ == NetReadTimeoutPresentOneofCase.NetReadTimeout ? (int) netReadTimeoutPresent_ : 0; } + set { + netReadTimeoutPresent_ = value; + netReadTimeoutPresentCase_ = NetReadTimeoutPresentOneofCase.NetReadTimeout; + } + } + + /// Field number for the "net_write_timeout" field. + public const int NetWriteTimeoutFieldNumber = 4; + /// + /// in seconds + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int NetWriteTimeout { + get { return netWriteTimeoutPresentCase_ == NetWriteTimeoutPresentOneofCase.NetWriteTimeout ? (int) netWriteTimeoutPresent_ : 0; } + set { + netWriteTimeoutPresent_ = value; + netWriteTimeoutPresentCase_ = NetWriteTimeoutPresentOneofCase.NetWriteTimeout; + } + } + + /// Field number for the "destination" field. + public const int DestinationFieldNumber = 5; + private string destination_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Destination { + get { return destination_; } + set { + destination_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "client_id" field. + public const int ClientIdFieldNumber = 6; + private string clientId_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ClientId { + get { return clientId_; } + set { + clientId_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "filter" field. + public const int FilterFieldNumber = 7; + private string filter_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Filter { + get { return filter_; } + set { + filter_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "start_timestamp" field. + public const int StartTimestampFieldNumber = 8; + private long startTimestamp_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long StartTimestamp { + get { return startTimestamp_; } + set { + startTimestamp_ = value; + } + } + + private object netReadTimeoutPresent_; + /// Enum of possible cases for the "net_read_timeout_present" oneof. + public enum NetReadTimeoutPresentOneofCase { + None = 0, + NetReadTimeout = 3, + } + private NetReadTimeoutPresentOneofCase netReadTimeoutPresentCase_ = NetReadTimeoutPresentOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NetReadTimeoutPresentOneofCase NetReadTimeoutPresentCase { + get { return netReadTimeoutPresentCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearNetReadTimeoutPresent() { + netReadTimeoutPresentCase_ = NetReadTimeoutPresentOneofCase.None; + netReadTimeoutPresent_ = null; + } + + private object netWriteTimeoutPresent_; + /// Enum of possible cases for the "net_write_timeout_present" oneof. + public enum NetWriteTimeoutPresentOneofCase { + None = 0, + NetWriteTimeout = 4, + } + private NetWriteTimeoutPresentOneofCase netWriteTimeoutPresentCase_ = NetWriteTimeoutPresentOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NetWriteTimeoutPresentOneofCase NetWriteTimeoutPresentCase { + get { return netWriteTimeoutPresentCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearNetWriteTimeoutPresent() { + netWriteTimeoutPresentCase_ = NetWriteTimeoutPresentOneofCase.None; + netWriteTimeoutPresent_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ClientAuth); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ClientAuth other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Username != other.Username) return false; + if (Password != other.Password) return false; + if (NetReadTimeout != other.NetReadTimeout) return false; + if (NetWriteTimeout != other.NetWriteTimeout) return false; + if (Destination != other.Destination) return false; + if (ClientId != other.ClientId) return false; + if (Filter != other.Filter) return false; + if (StartTimestamp != other.StartTimestamp) return false; + if (NetReadTimeoutPresentCase != other.NetReadTimeoutPresentCase) return false; + if (NetWriteTimeoutPresentCase != other.NetWriteTimeoutPresentCase) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Username.Length != 0) hash ^= Username.GetHashCode(); + if (Password.Length != 0) hash ^= Password.GetHashCode(); + if (netReadTimeoutPresentCase_ == NetReadTimeoutPresentOneofCase.NetReadTimeout) hash ^= NetReadTimeout.GetHashCode(); + if (netWriteTimeoutPresentCase_ == NetWriteTimeoutPresentOneofCase.NetWriteTimeout) hash ^= NetWriteTimeout.GetHashCode(); + if (Destination.Length != 0) hash ^= Destination.GetHashCode(); + if (ClientId.Length != 0) hash ^= ClientId.GetHashCode(); + if (Filter.Length != 0) hash ^= Filter.GetHashCode(); + if (StartTimestamp != 0L) hash ^= StartTimestamp.GetHashCode(); + hash ^= (int) netReadTimeoutPresentCase_; + hash ^= (int) netWriteTimeoutPresentCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Username.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Username); + } + if (Password.Length != 0) { + output.WriteRawTag(18); + output.WriteBytes(Password); + } + if (netReadTimeoutPresentCase_ == NetReadTimeoutPresentOneofCase.NetReadTimeout) { + output.WriteRawTag(24); + output.WriteInt32(NetReadTimeout); + } + if (netWriteTimeoutPresentCase_ == NetWriteTimeoutPresentOneofCase.NetWriteTimeout) { + output.WriteRawTag(32); + output.WriteInt32(NetWriteTimeout); + } + if (Destination.Length != 0) { + output.WriteRawTag(42); + output.WriteString(Destination); + } + if (ClientId.Length != 0) { + output.WriteRawTag(50); + output.WriteString(ClientId); + } + if (Filter.Length != 0) { + output.WriteRawTag(58); + output.WriteString(Filter); + } + if (StartTimestamp != 0L) { + output.WriteRawTag(64); + output.WriteInt64(StartTimestamp); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Username.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Username); + } + if (Password.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(Password); + } + if (netReadTimeoutPresentCase_ == NetReadTimeoutPresentOneofCase.NetReadTimeout) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(NetReadTimeout); + } + if (netWriteTimeoutPresentCase_ == NetWriteTimeoutPresentOneofCase.NetWriteTimeout) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(NetWriteTimeout); + } + if (Destination.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Destination); + } + if (ClientId.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ClientId); + } + if (Filter.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Filter); + } + if (StartTimestamp != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(StartTimestamp); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ClientAuth other) { + if (other == null) { + return; + } + if (other.Username.Length != 0) { + Username = other.Username; + } + if (other.Password.Length != 0) { + Password = other.Password; + } + if (other.Destination.Length != 0) { + Destination = other.Destination; + } + if (other.ClientId.Length != 0) { + ClientId = other.ClientId; + } + if (other.Filter.Length != 0) { + Filter = other.Filter; + } + if (other.StartTimestamp != 0L) { + StartTimestamp = other.StartTimestamp; + } + switch (other.NetReadTimeoutPresentCase) { + case NetReadTimeoutPresentOneofCase.NetReadTimeout: + NetReadTimeout = other.NetReadTimeout; + break; + } + + switch (other.NetWriteTimeoutPresentCase) { + case NetWriteTimeoutPresentOneofCase.NetWriteTimeout: + NetWriteTimeout = other.NetWriteTimeout; + break; + } + + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Username = input.ReadString(); + break; + } + case 18: { + Password = input.ReadBytes(); + break; + } + case 24: { + NetReadTimeout = input.ReadInt32(); + break; + } + case 32: { + NetWriteTimeout = input.ReadInt32(); + break; + } + case 42: { + Destination = input.ReadString(); + break; + } + case 50: { + ClientId = input.ReadString(); + break; + } + case 58: { + Filter = input.ReadString(); + break; + } + case 64: { + StartTimestamp = input.ReadInt64(); + break; + } + } + } + } + + } + + public sealed partial class Ack : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Ack()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Alibaba.Otter.Canal.Protocol.CanalProtocolReflection.Descriptor.MessageTypes[4]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Ack() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Ack(Ack other) : this() { + errorMessage_ = other.errorMessage_; + switch (other.ErrorCodePresentCase) { + case ErrorCodePresentOneofCase.ErrorCode: + ErrorCode = other.ErrorCode; + break; + } + + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Ack Clone() { + return new Ack(this); + } + + /// Field number for the "error_code" field. + public const int ErrorCodeFieldNumber = 1; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int ErrorCode { + get { return errorCodePresentCase_ == ErrorCodePresentOneofCase.ErrorCode ? (int) errorCodePresent_ : 0; } + set { + errorCodePresent_ = value; + errorCodePresentCase_ = ErrorCodePresentOneofCase.ErrorCode; + } + } + + /// Field number for the "error_message" field. + public const int ErrorMessageFieldNumber = 2; + private string errorMessage_ = ""; + /// + /// if something like compression is not supported, erorr_message will tell about it. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ErrorMessage { + get { return errorMessage_; } + set { + errorMessage_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + private object errorCodePresent_; + /// Enum of possible cases for the "error_code_present" oneof. + public enum ErrorCodePresentOneofCase { + None = 0, + ErrorCode = 1, + } + private ErrorCodePresentOneofCase errorCodePresentCase_ = ErrorCodePresentOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ErrorCodePresentOneofCase ErrorCodePresentCase { + get { return errorCodePresentCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearErrorCodePresent() { + errorCodePresentCase_ = ErrorCodePresentOneofCase.None; + errorCodePresent_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Ack); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Ack other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (ErrorCode != other.ErrorCode) return false; + if (ErrorMessage != other.ErrorMessage) return false; + if (ErrorCodePresentCase != other.ErrorCodePresentCase) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (errorCodePresentCase_ == ErrorCodePresentOneofCase.ErrorCode) hash ^= ErrorCode.GetHashCode(); + if (ErrorMessage.Length != 0) hash ^= ErrorMessage.GetHashCode(); + hash ^= (int) errorCodePresentCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (errorCodePresentCase_ == ErrorCodePresentOneofCase.ErrorCode) { + output.WriteRawTag(8); + output.WriteInt32(ErrorCode); + } + if (ErrorMessage.Length != 0) { + output.WriteRawTag(18); + output.WriteString(ErrorMessage); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (errorCodePresentCase_ == ErrorCodePresentOneofCase.ErrorCode) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(ErrorCode); + } + if (ErrorMessage.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ErrorMessage); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Ack other) { + if (other == null) { + return; + } + if (other.ErrorMessage.Length != 0) { + ErrorMessage = other.ErrorMessage; + } + switch (other.ErrorCodePresentCase) { + case ErrorCodePresentOneofCase.ErrorCode: + ErrorCode = other.ErrorCode; + break; + } + + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + ErrorCode = input.ReadInt32(); + break; + } + case 18: { + ErrorMessage = input.ReadString(); + break; + } + } + } + } + + } + + public sealed partial class ClientAck : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ClientAck()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Alibaba.Otter.Canal.Protocol.CanalProtocolReflection.Descriptor.MessageTypes[5]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ClientAck() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ClientAck(ClientAck other) : this() { + destination_ = other.destination_; + clientId_ = other.clientId_; + batchId_ = other.batchId_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ClientAck Clone() { + return new ClientAck(this); + } + + /// Field number for the "destination" field. + public const int DestinationFieldNumber = 1; + private string destination_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Destination { + get { return destination_; } + set { + destination_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "client_id" field. + public const int ClientIdFieldNumber = 2; + private string clientId_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ClientId { + get { return clientId_; } + set { + clientId_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "batch_id" field. + public const int BatchIdFieldNumber = 3; + private long batchId_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long BatchId { + get { return batchId_; } + set { + batchId_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ClientAck); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ClientAck other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Destination != other.Destination) return false; + if (ClientId != other.ClientId) return false; + if (BatchId != other.BatchId) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Destination.Length != 0) hash ^= Destination.GetHashCode(); + if (ClientId.Length != 0) hash ^= ClientId.GetHashCode(); + if (BatchId != 0L) hash ^= BatchId.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Destination.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Destination); + } + if (ClientId.Length != 0) { + output.WriteRawTag(18); + output.WriteString(ClientId); + } + if (BatchId != 0L) { + output.WriteRawTag(24); + output.WriteInt64(BatchId); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Destination.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Destination); + } + if (ClientId.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ClientId); + } + if (BatchId != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(BatchId); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ClientAck other) { + if (other == null) { + return; + } + if (other.Destination.Length != 0) { + Destination = other.Destination; + } + if (other.ClientId.Length != 0) { + ClientId = other.ClientId; + } + if (other.BatchId != 0L) { + BatchId = other.BatchId; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Destination = input.ReadString(); + break; + } + case 18: { + ClientId = input.ReadString(); + break; + } + case 24: { + BatchId = input.ReadInt64(); + break; + } + } + } + } + + } + + /// + /// subscription + /// + public sealed partial class Sub : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Sub()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Alibaba.Otter.Canal.Protocol.CanalProtocolReflection.Descriptor.MessageTypes[6]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Sub() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Sub(Sub other) : this() { + destination_ = other.destination_; + clientId_ = other.clientId_; + filter_ = other.filter_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Sub Clone() { + return new Sub(this); + } + + /// Field number for the "destination" field. + public const int DestinationFieldNumber = 1; + private string destination_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Destination { + get { return destination_; } + set { + destination_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "client_id" field. + public const int ClientIdFieldNumber = 2; + private string clientId_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ClientId { + get { return clientId_; } + set { + clientId_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "filter" field. + public const int FilterFieldNumber = 7; + private string filter_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Filter { + get { return filter_; } + set { + filter_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Sub); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Sub other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Destination != other.Destination) return false; + if (ClientId != other.ClientId) return false; + if (Filter != other.Filter) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Destination.Length != 0) hash ^= Destination.GetHashCode(); + if (ClientId.Length != 0) hash ^= ClientId.GetHashCode(); + if (Filter.Length != 0) hash ^= Filter.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Destination.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Destination); + } + if (ClientId.Length != 0) { + output.WriteRawTag(18); + output.WriteString(ClientId); + } + if (Filter.Length != 0) { + output.WriteRawTag(58); + output.WriteString(Filter); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Destination.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Destination); + } + if (ClientId.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ClientId); + } + if (Filter.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Filter); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Sub other) { + if (other == null) { + return; + } + if (other.Destination.Length != 0) { + Destination = other.Destination; + } + if (other.ClientId.Length != 0) { + ClientId = other.ClientId; + } + if (other.Filter.Length != 0) { + Filter = other.Filter; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Destination = input.ReadString(); + break; + } + case 18: { + ClientId = input.ReadString(); + break; + } + case 58: { + Filter = input.ReadString(); + break; + } + } + } + } + + } + + /// + /// Unsubscription + /// + public sealed partial class Unsub : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Unsub()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Alibaba.Otter.Canal.Protocol.CanalProtocolReflection.Descriptor.MessageTypes[7]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Unsub() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Unsub(Unsub other) : this() { + destination_ = other.destination_; + clientId_ = other.clientId_; + filter_ = other.filter_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Unsub Clone() { + return new Unsub(this); + } + + /// Field number for the "destination" field. + public const int DestinationFieldNumber = 1; + private string destination_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Destination { + get { return destination_; } + set { + destination_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "client_id" field. + public const int ClientIdFieldNumber = 2; + private string clientId_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ClientId { + get { return clientId_; } + set { + clientId_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "filter" field. + public const int FilterFieldNumber = 7; + private string filter_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Filter { + get { return filter_; } + set { + filter_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Unsub); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Unsub other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Destination != other.Destination) return false; + if (ClientId != other.ClientId) return false; + if (Filter != other.Filter) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Destination.Length != 0) hash ^= Destination.GetHashCode(); + if (ClientId.Length != 0) hash ^= ClientId.GetHashCode(); + if (Filter.Length != 0) hash ^= Filter.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Destination.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Destination); + } + if (ClientId.Length != 0) { + output.WriteRawTag(18); + output.WriteString(ClientId); + } + if (Filter.Length != 0) { + output.WriteRawTag(58); + output.WriteString(Filter); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Destination.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Destination); + } + if (ClientId.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ClientId); + } + if (Filter.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Filter); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Unsub other) { + if (other == null) { + return; + } + if (other.Destination.Length != 0) { + Destination = other.Destination; + } + if (other.ClientId.Length != 0) { + ClientId = other.ClientId; + } + if (other.Filter.Length != 0) { + Filter = other.Filter; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Destination = input.ReadString(); + break; + } + case 18: { + ClientId = input.ReadString(); + break; + } + case 58: { + Filter = input.ReadString(); + break; + } + } + } + } + + } + + /// + /// PullRequest + /// + public sealed partial class Get : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Get()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Alibaba.Otter.Canal.Protocol.CanalProtocolReflection.Descriptor.MessageTypes[8]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Get() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Get(Get other) : this() { + destination_ = other.destination_; + clientId_ = other.clientId_; + fetchSize_ = other.fetchSize_; + switch (other.TimeoutPresentCase) { + case TimeoutPresentOneofCase.Timeout: + Timeout = other.Timeout; + break; + } + + switch (other.UnitPresentCase) { + case UnitPresentOneofCase.Unit: + Unit = other.Unit; + break; + } + + switch (other.AutoAckPresentCase) { + case AutoAckPresentOneofCase.AutoAck: + AutoAck = other.AutoAck; + break; + } + + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Get Clone() { + return new Get(this); + } + + /// Field number for the "destination" field. + public const int DestinationFieldNumber = 1; + private string destination_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Destination { + get { return destination_; } + set { + destination_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "client_id" field. + public const int ClientIdFieldNumber = 2; + private string clientId_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ClientId { + get { return clientId_; } + set { + clientId_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "fetch_size" field. + public const int FetchSizeFieldNumber = 3; + private int fetchSize_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FetchSize { + get { return fetchSize_; } + set { + fetchSize_ = value; + } + } + + /// Field number for the "timeout" field. + public const int TimeoutFieldNumber = 4; + /// + /// 默认-1时代表不控制 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Timeout { + get { return timeoutPresentCase_ == TimeoutPresentOneofCase.Timeout ? (long) timeoutPresent_ : -1L; } + set { + timeoutPresent_ = value; + timeoutPresentCase_ = TimeoutPresentOneofCase.Timeout; + } + } + + /// Field number for the "unit" field. + public const int UnitFieldNumber = 5; + /// + /// 数字类型,0:纳秒,1:毫秒,2:微秒,3:秒,4:分钟,5:小时,6:天 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Unit { + get { return unitPresentCase_ == UnitPresentOneofCase.Unit ? (int) unitPresent_ : 2; } + set { + unitPresent_ = value; + unitPresentCase_ = UnitPresentOneofCase.Unit; + } + } + + /// Field number for the "auto_ack" field. + public const int AutoAckFieldNumber = 6; + /// + /// 是否自动ack + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool AutoAck { + get { return autoAckPresentCase_ == AutoAckPresentOneofCase.AutoAck ? (bool) autoAckPresent_ : false; } + set { + autoAckPresent_ = value; + autoAckPresentCase_ = AutoAckPresentOneofCase.AutoAck; + } + } + + private object timeoutPresent_; + /// Enum of possible cases for the "timeout_present" oneof. + public enum TimeoutPresentOneofCase { + None = 0, + Timeout = 4, + } + private TimeoutPresentOneofCase timeoutPresentCase_ = TimeoutPresentOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TimeoutPresentOneofCase TimeoutPresentCase { + get { return timeoutPresentCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearTimeoutPresent() { + timeoutPresentCase_ = TimeoutPresentOneofCase.None; + timeoutPresent_ = null; + } + + private object unitPresent_; + /// Enum of possible cases for the "unit_present" oneof. + public enum UnitPresentOneofCase { + None = 0, + Unit = 5, + } + private UnitPresentOneofCase unitPresentCase_ = UnitPresentOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public UnitPresentOneofCase UnitPresentCase { + get { return unitPresentCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearUnitPresent() { + unitPresentCase_ = UnitPresentOneofCase.None; + unitPresent_ = null; + } + + private object autoAckPresent_; + /// Enum of possible cases for the "auto_ack_present" oneof. + public enum AutoAckPresentOneofCase { + None = 0, + AutoAck = 6, + } + private AutoAckPresentOneofCase autoAckPresentCase_ = AutoAckPresentOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AutoAckPresentOneofCase AutoAckPresentCase { + get { return autoAckPresentCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearAutoAckPresent() { + autoAckPresentCase_ = AutoAckPresentOneofCase.None; + autoAckPresent_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Get); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Get other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Destination != other.Destination) return false; + if (ClientId != other.ClientId) return false; + if (FetchSize != other.FetchSize) return false; + if (Timeout != other.Timeout) return false; + if (Unit != other.Unit) return false; + if (AutoAck != other.AutoAck) return false; + if (TimeoutPresentCase != other.TimeoutPresentCase) return false; + if (UnitPresentCase != other.UnitPresentCase) return false; + if (AutoAckPresentCase != other.AutoAckPresentCase) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Destination.Length != 0) hash ^= Destination.GetHashCode(); + if (ClientId.Length != 0) hash ^= ClientId.GetHashCode(); + if (FetchSize != 0) hash ^= FetchSize.GetHashCode(); + if (timeoutPresentCase_ == TimeoutPresentOneofCase.Timeout) hash ^= Timeout.GetHashCode(); + if (unitPresentCase_ == UnitPresentOneofCase.Unit) hash ^= Unit.GetHashCode(); + if (autoAckPresentCase_ == AutoAckPresentOneofCase.AutoAck) hash ^= AutoAck.GetHashCode(); + hash ^= (int) timeoutPresentCase_; + hash ^= (int) unitPresentCase_; + hash ^= (int) autoAckPresentCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Destination.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Destination); + } + if (ClientId.Length != 0) { + output.WriteRawTag(18); + output.WriteString(ClientId); + } + if (FetchSize != 0) { + output.WriteRawTag(24); + output.WriteInt32(FetchSize); + } + if (timeoutPresentCase_ == TimeoutPresentOneofCase.Timeout) { + output.WriteRawTag(32); + output.WriteInt64(Timeout); + } + if (unitPresentCase_ == UnitPresentOneofCase.Unit) { + output.WriteRawTag(40); + output.WriteInt32(Unit); + } + if (autoAckPresentCase_ == AutoAckPresentOneofCase.AutoAck) { + output.WriteRawTag(48); + output.WriteBool(AutoAck); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Destination.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Destination); + } + if (ClientId.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ClientId); + } + if (FetchSize != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(FetchSize); + } + if (timeoutPresentCase_ == TimeoutPresentOneofCase.Timeout) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Timeout); + } + if (unitPresentCase_ == UnitPresentOneofCase.Unit) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Unit); + } + if (autoAckPresentCase_ == AutoAckPresentOneofCase.AutoAck) { + size += 1 + 1; + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Get other) { + if (other == null) { + return; + } + if (other.Destination.Length != 0) { + Destination = other.Destination; + } + if (other.ClientId.Length != 0) { + ClientId = other.ClientId; + } + if (other.FetchSize != 0) { + FetchSize = other.FetchSize; + } + switch (other.TimeoutPresentCase) { + case TimeoutPresentOneofCase.Timeout: + Timeout = other.Timeout; + break; + } + + switch (other.UnitPresentCase) { + case UnitPresentOneofCase.Unit: + Unit = other.Unit; + break; + } + + switch (other.AutoAckPresentCase) { + case AutoAckPresentOneofCase.AutoAck: + AutoAck = other.AutoAck; + break; + } + + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Destination = input.ReadString(); + break; + } + case 18: { + ClientId = input.ReadString(); + break; + } + case 24: { + FetchSize = input.ReadInt32(); + break; + } + case 32: { + Timeout = input.ReadInt64(); + break; + } + case 40: { + Unit = input.ReadInt32(); + break; + } + case 48: { + AutoAck = input.ReadBool(); + break; + } + } + } + } + + } + + /// + /// + public sealed partial class Messages : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Messages()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Alibaba.Otter.Canal.Protocol.CanalProtocolReflection.Descriptor.MessageTypes[9]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Messages() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Messages(Messages other) : this() { + batchId_ = other.batchId_; + messages_ = other.messages_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Messages Clone() { + return new Messages(this); + } + + /// Field number for the "batch_id" field. + public const int BatchIdFieldNumber = 1; + private long batchId_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long BatchId { + get { return batchId_; } + set { + batchId_ = value; + } + } + + /// Field number for the "messages" field. + public const int Messages_FieldNumber = 2; + private static readonly pb::FieldCodec _repeated_messages_codec + = pb::FieldCodec.ForBytes(18); + private readonly pbc::RepeatedField messages_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Messages_ { + get { return messages_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Messages); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Messages other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (BatchId != other.BatchId) return false; + if(!messages_.Equals(other.messages_)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (BatchId != 0L) hash ^= BatchId.GetHashCode(); + hash ^= messages_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (BatchId != 0L) { + output.WriteRawTag(8); + output.WriteInt64(BatchId); + } + messages_.WriteTo(output, _repeated_messages_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (BatchId != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(BatchId); + } + size += messages_.CalculateSize(_repeated_messages_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Messages other) { + if (other == null) { + return; + } + if (other.BatchId != 0L) { + BatchId = other.BatchId; + } + messages_.Add(other.messages_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + BatchId = input.ReadInt64(); + break; + } + case 18: { + messages_.AddEntriesFrom(input, _repeated_messages_codec); + break; + } + } + } + } + + } + + /// + /// TBD when new packets are required + /// + public sealed partial class Dump : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Dump()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Alibaba.Otter.Canal.Protocol.CanalProtocolReflection.Descriptor.MessageTypes[10]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Dump() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Dump(Dump other) : this() { + journal_ = other.journal_; + position_ = other.position_; + switch (other.TimestampPresentCase) { + case TimestampPresentOneofCase.Timestamp: + Timestamp = other.Timestamp; + break; + } + + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Dump Clone() { + return new Dump(this); + } + + /// Field number for the "journal" field. + public const int JournalFieldNumber = 1; + private string journal_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Journal { + get { return journal_; } + set { + journal_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "position" field. + public const int PositionFieldNumber = 2; + private long position_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Position { + get { return position_; } + set { + position_ = value; + } + } + + /// Field number for the "timestamp" field. + public const int TimestampFieldNumber = 3; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Timestamp { + get { return timestampPresentCase_ == TimestampPresentOneofCase.Timestamp ? (long) timestampPresent_ : 0L; } + set { + timestampPresent_ = value; + timestampPresentCase_ = TimestampPresentOneofCase.Timestamp; + } + } + + private object timestampPresent_; + /// Enum of possible cases for the "timestamp_present" oneof. + public enum TimestampPresentOneofCase { + None = 0, + Timestamp = 3, + } + private TimestampPresentOneofCase timestampPresentCase_ = TimestampPresentOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TimestampPresentOneofCase TimestampPresentCase { + get { return timestampPresentCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearTimestampPresent() { + timestampPresentCase_ = TimestampPresentOneofCase.None; + timestampPresent_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Dump); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Dump other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Journal != other.Journal) return false; + if (Position != other.Position) return false; + if (Timestamp != other.Timestamp) return false; + if (TimestampPresentCase != other.TimestampPresentCase) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Journal.Length != 0) hash ^= Journal.GetHashCode(); + if (Position != 0L) hash ^= Position.GetHashCode(); + if (timestampPresentCase_ == TimestampPresentOneofCase.Timestamp) hash ^= Timestamp.GetHashCode(); + hash ^= (int) timestampPresentCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Journal.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Journal); + } + if (Position != 0L) { + output.WriteRawTag(16); + output.WriteInt64(Position); + } + if (timestampPresentCase_ == TimestampPresentOneofCase.Timestamp) { + output.WriteRawTag(24); + output.WriteInt64(Timestamp); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Journal.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Journal); + } + if (Position != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Position); + } + if (timestampPresentCase_ == TimestampPresentOneofCase.Timestamp) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Timestamp); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Dump other) { + if (other == null) { + return; + } + if (other.Journal.Length != 0) { + Journal = other.Journal; + } + if (other.Position != 0L) { + Position = other.Position; + } + switch (other.TimestampPresentCase) { + case TimestampPresentOneofCase.Timestamp: + Timestamp = other.Timestamp; + break; + } + + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Journal = input.ReadString(); + break; + } + case 16: { + Position = input.ReadInt64(); + break; + } + case 24: { + Timestamp = input.ReadInt64(); + break; + } + } + } + } + + } + + public sealed partial class ClientRollback : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ClientRollback()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Alibaba.Otter.Canal.Protocol.CanalProtocolReflection.Descriptor.MessageTypes[11]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ClientRollback() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ClientRollback(ClientRollback other) : this() { + destination_ = other.destination_; + clientId_ = other.clientId_; + batchId_ = other.batchId_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ClientRollback Clone() { + return new ClientRollback(this); + } + + /// Field number for the "destination" field. + public const int DestinationFieldNumber = 1; + private string destination_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Destination { + get { return destination_; } + set { + destination_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "client_id" field. + public const int ClientIdFieldNumber = 2; + private string clientId_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ClientId { + get { return clientId_; } + set { + clientId_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "batch_id" field. + public const int BatchIdFieldNumber = 3; + private long batchId_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long BatchId { + get { return batchId_; } + set { + batchId_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ClientRollback); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ClientRollback other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Destination != other.Destination) return false; + if (ClientId != other.ClientId) return false; + if (BatchId != other.BatchId) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Destination.Length != 0) hash ^= Destination.GetHashCode(); + if (ClientId.Length != 0) hash ^= ClientId.GetHashCode(); + if (BatchId != 0L) hash ^= BatchId.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Destination.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Destination); + } + if (ClientId.Length != 0) { + output.WriteRawTag(18); + output.WriteString(ClientId); + } + if (BatchId != 0L) { + output.WriteRawTag(24); + output.WriteInt64(BatchId); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Destination.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Destination); + } + if (ClientId.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ClientId); + } + if (BatchId != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(BatchId); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ClientRollback other) { + if (other == null) { + return; + } + if (other.Destination.Length != 0) { + Destination = other.Destination; + } + if (other.ClientId.Length != 0) { + ClientId = other.ClientId; + } + if (other.BatchId != 0L) { + BatchId = other.BatchId; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Destination = input.ReadString(); + break; + } + case 18: { + ClientId = input.ReadString(); + break; + } + case 24: { + BatchId = input.ReadInt64(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/src/CanalSharp.Protocol/CanalProtocol.proto b/src/CanalSharp.Protocol/CanalProtocol.proto new file mode 100644 index 0000000..660b804 --- /dev/null +++ b/src/CanalSharp.Protocol/CanalProtocol.proto @@ -0,0 +1,154 @@ +syntax = "proto3"; +package com.alibaba.otter.canal.protocol; + +option java_package = "com.alibaba.otter.canal.protocol"; +option java_outer_classname = "CanalPacket"; +option optimize_for = SPEED; + +enum Compression { + COMPRESSIONCOMPATIBLEPROTO2 = 0; + NONE = 1; + ZLIB = 2; + GZIP = 3; + LZF = 4; +} + +enum PacketType { + //compatible + PACKAGETYPECOMPATIBLEPROTO2 = 0; + HANDSHAKE = 1; + CLIENTAUTHENTICATION = 2; + ACK = 3; + SUBSCRIPTION = 4; + UNSUBSCRIPTION = 5; + GET = 6; + MESSAGES = 7; + CLIENTACK = 8; + // management part + SHUTDOWN = 9; + // integration + DUMP = 10; + HEARTBEAT = 11; + CLIENTROLLBACK = 12; +} + +message Packet { + //[default = 17]; + oneof magic_number_present { + int32 magic_number = 1; + } + //[default = 1]; + oneof version_present { + int32 version = 2; + }; + PacketType type = 3; + //[default = NONE]; + oneof compression_present { + Compression compression = 4; + } + + bytes body = 5; +} + +message HeartBeat { + int64 send_timestamp = 1; + int64 start_timestamp = 2; +} + +message Handshake { + // [default = "utf8"]; + oneof communication_encoding_present { + string communication_encoding = 1; + } + bytes seeds = 2; + Compression supported_compressions = 3; +} + +// client authentication +message ClientAuth { + string username = 1; + bytes password = 2; // hashed password with seeds from Handshake message + // [default = 0] + oneof net_read_timeout_present { + int32 net_read_timeout = 3; // in seconds + } + // [default = 0]; + oneof net_write_timeout_present { + int32 net_write_timeout = 4; // in seconds + } + string destination = 5; + string client_id = 6; + string filter = 7; + int64 start_timestamp = 8; +} + +message Ack { + //[default = 0] + oneof error_code_present { + int32 error_code = 1; + } + string error_message = 2; // if something like compression is not supported, erorr_message will tell about it. +} + +message ClientAck { + string destination = 1; + string client_id = 2; + int64 batch_id = 3; +} + +// subscription +message Sub { + string destination = 1; + string client_id = 2; + string filter = 7; +} + +// Unsubscription +message Unsub { + string destination = 1; + string client_id = 2; + string filter = 7; +} + +// PullRequest +message Get { + string destination = 1; + string client_id = 2; + int32 fetch_size = 3; + //[default = -1] + oneof timeout_present { + int64 timeout = 4; // 默认-1时代表不控制 + } + //[default = 2] + oneof unit_present { + int32 unit = 5;// 数字类型,0:纳秒,1:毫秒,2:微秒,3:秒,4:分钟,5:小时,6:天 + } + //[default = false] + oneof auto_ack_present { + bool auto_ack = 6; // 是否自动ack + } + +} + +// +message Messages { + int64 batch_id = 1; + repeated bytes messages = 2; +} + +// TBD when new packets are required +message Dump{ + string journal = 1; + int64 position = 2; + // [default = 0] + oneof timestamp_present { + int64 timestamp = 3; + } + +} + +message ClientRollback{ + string destination = 1; + string client_id = 2; + int64 batch_id = 3; +} \ No newline at end of file diff --git a/src/CanalSharp.Protocol/CanalSharp.Protocol.csproj b/src/CanalSharp.Protocol/CanalSharp.Protocol.csproj new file mode 100644 index 0000000..b9722e7 --- /dev/null +++ b/src/CanalSharp.Protocol/CanalSharp.Protocol.csproj @@ -0,0 +1,11 @@ + + + + netstandard2.0 + + + + + + + diff --git a/src/CanalSharp.Protocol/ClientIdentity.cs b/src/CanalSharp.Protocol/ClientIdentity.cs new file mode 100644 index 0000000..752bdf4 --- /dev/null +++ b/src/CanalSharp.Protocol/ClientIdentity.cs @@ -0,0 +1,75 @@ +using System; + +namespace CanalSharp.Protocol +{ + [Serializable] + public class ClientIdentity + { + public string Destination { get; set; } + public short ClientId { get; set; } + public string Filter { get; set; } + + public ClientIdentity() + { + + } + + public ClientIdentity(string destination,short clientId) + { + Destination = destination; + ClientId = clientId; + } + public ClientIdentity(string destination, short clientId,string filter) + { + Destination = destination; + ClientId = clientId; + Filter = filter; + } + + public bool HasFilter() + { + return Filter != null && string.IsNullOrEmpty(Filter); + } + + public override int GetHashCode() + { + const int prime = 31; + var result = 1; + result = prime * result + ClientId; + result = prime * result + ((Destination == null) ? 0 : Destination.GetHashCode()); + return result; + } + + public override bool Equals(object obj) + { + if (this == obj) + { + return true; + } + if (obj == null) + { + return false; + } + if (!(obj is ClientIdentity)) { + return false; + } + var other = (ClientIdentity)obj; + if (ClientId != other.ClientId) + { + return false; + } + if (Destination == null) + { + if (other.Destination != null) + { + return false; + } + } + else if (!Destination.Equals(other.Destination)) + { + return false; + } + return true; + } + } +} diff --git a/src/CanalSharp.Protocol/EntryProtocol.cs b/src/CanalSharp.Protocol/EntryProtocol.cs new file mode 100644 index 0000000..0ce0114 --- /dev/null +++ b/src/CanalSharp.Protocol/EntryProtocol.cs @@ -0,0 +1,2490 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: EntryProtocol.proto +// +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Com.Alibaba.Otter.Canal.Protocol { + + /// Holder for reflection information generated from EntryProtocol.proto + public static partial class EntryProtocolReflection { + + #region Descriptor + /// File descriptor for EntryProtocol.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static EntryProtocolReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChNFbnRyeVByb3RvY29sLnByb3RvEiBjb20uYWxpYmFiYS5vdHRlci5jYW5h", + "bC5wcm90b2NvbCKsAQoFRW50cnkSOAoGaGVhZGVyGAEgASgLMiguY29tLmFs", + "aWJhYmEub3R0ZXIuY2FuYWwucHJvdG9jb2wuSGVhZGVyEkAKCWVudHJ5VHlw", + "ZRgCIAEoDjIrLmNvbS5hbGliYWJhLm90dGVyLmNhbmFsLnByb3RvY29sLkVu", + "dHJ5VHlwZUgAEhIKCnN0b3JlVmFsdWUYAyABKAxCEwoRZW50cnlUeXBlX3By", + "ZXNlbnQiwwMKBkhlYWRlchIRCgd2ZXJzaW9uGAEgASgFSAASEwoLbG9nZmls", + "ZU5hbWUYAiABKAkSFQoNbG9nZmlsZU9mZnNldBgDIAEoAxIQCghzZXJ2ZXJJ", + "ZBgEIAEoAxIUCgxzZXJ2ZXJlbkNvZGUYBSABKAkSEwoLZXhlY3V0ZVRpbWUY", + "BiABKAMSPAoKc291cmNlVHlwZRgHIAEoDjImLmNvbS5hbGliYWJhLm90dGVy", + "LmNhbmFsLnByb3RvY29sLlR5cGVIARISCgpzY2hlbWFOYW1lGAggASgJEhEK", + "CXRhYmxlTmFtZRgJIAEoCRITCgtldmVudExlbmd0aBgKIAEoAxJACglldmVu", + "dFR5cGUYCyABKA4yKy5jb20uYWxpYmFiYS5vdHRlci5jYW5hbC5wcm90b2Nv", + "bC5FdmVudFR5cGVIAhI1CgVwcm9wcxgMIAMoCzImLmNvbS5hbGliYWJhLm90", + "dGVyLmNhbmFsLnByb3RvY29sLlBhaXISDAoEZ3RpZBgNIAEoCUIRCg92ZXJz", + "aW9uX3ByZXNlbnRCFAoSc291cmNlVHlwZV9wcmVzZW50QhMKEWV2ZW50VHlw", + "ZV9wcmVzZW50IuMBCgZDb2x1bW4SDQoFaW5kZXgYASABKAUSDwoHc3FsVHlw", + "ZRgCIAEoBRIMCgRuYW1lGAMgASgJEg0KBWlzS2V5GAQgASgIEg8KB3VwZGF0", + "ZWQYBSABKAgSEAoGaXNOdWxsGAYgASgISAASNQoFcHJvcHMYByADKAsyJi5j", + "b20uYWxpYmFiYS5vdHRlci5jYW5hbC5wcm90b2NvbC5QYWlyEg0KBXZhbHVl", + "GAggASgJEg4KBmxlbmd0aBgJIAEoBRIRCglteXNxbFR5cGUYCiABKAlCEAoO", + "aXNOdWxsX3ByZXNlbnQiwQEKB1Jvd0RhdGESPwoNYmVmb3JlQ29sdW1ucxgB", + "IAMoCzIoLmNvbS5hbGliYWJhLm90dGVyLmNhbmFsLnByb3RvY29sLkNvbHVt", + "bhI+CgxhZnRlckNvbHVtbnMYAiADKAsyKC5jb20uYWxpYmFiYS5vdHRlci5j", + "YW5hbC5wcm90b2NvbC5Db2x1bW4SNQoFcHJvcHMYAyADKAsyJi5jb20uYWxp", + "YmFiYS5vdHRlci5jYW5hbC5wcm90b2NvbC5QYWlyIq0CCglSb3dDaGFuZ2US", + "DwoHdGFibGVJZBgBIAEoAxJACglldmVudFR5cGUYAiABKA4yKy5jb20uYWxp", + "YmFiYS5vdHRlci5jYW5hbC5wcm90b2NvbC5FdmVudFR5cGVIABIPCgVpc0Rk", + "bBgKIAEoCEgBEgsKA3NxbBgLIAEoCRI7Cghyb3dEYXRhcxgMIAMoCzIpLmNv", + "bS5hbGliYWJhLm90dGVyLmNhbmFsLnByb3RvY29sLlJvd0RhdGESNQoFcHJv", + "cHMYDSADKAsyJi5jb20uYWxpYmFiYS5vdHRlci5jYW5hbC5wcm90b2NvbC5Q", + "YWlyEhUKDWRkbFNjaGVtYU5hbWUYDiABKAlCEwoRZXZlbnRUeXBlX3ByZXNl", + "bnRCDwoNaXNEZGxfcHJlc2VudCKHAQoQVHJhbnNhY3Rpb25CZWdpbhITCgtl", + "eGVjdXRlVGltZRgBIAEoAxIVCg10cmFuc2FjdGlvbklkGAIgASgJEjUKBXBy", + "b3BzGAMgAygLMiYuY29tLmFsaWJhYmEub3R0ZXIuY2FuYWwucHJvdG9jb2wu", + "UGFpchIQCgh0aHJlYWRJZBgEIAEoAyJzCg5UcmFuc2FjdGlvbkVuZBITCgtl", + "eGVjdXRlVGltZRgBIAEoAxIVCg10cmFuc2FjdGlvbklkGAIgASgJEjUKBXBy", + "b3BzGAMgAygLMiYuY29tLmFsaWJhYmEub3R0ZXIuY2FuYWwucHJvdG9jb2wu", + "UGFpciIiCgRQYWlyEgsKA2tleRgBIAEoCRINCgV2YWx1ZRgCIAEoCSp9CglF", + "bnRyeVR5cGUSHQoZRU5UUllUWVBFQ09NUEFUSUJMRVBST1RPMhAAEhQKEFRS", + "QU5TQUNUSU9OQkVHSU4QARILCgdST1dEQVRBEAISEgoOVFJBTlNBQ1RJT05F", + "TkQQAxINCglIRUFSVEJFQVQQBBILCgdHVElETE9HEAUq5QEKCUV2ZW50VHlw", + "ZRIdChlFVkVOVFRZUEVDT01QQVRJQkxFUFJPVE8yEAASCgoGSU5TRVJUEAES", + "CgoGVVBEQVRFEAISCgoGREVMRVRFEAMSCgoGQ1JFQVRFEAQSCQoFQUxURVIQ", + "BRIJCgVFUkFTRRAGEgkKBVFVRVJZEAcSDAoIVFJVTkNBVEUQCBIKCgZSRU5B", + "TUUQCRIKCgZDSU5ERVgQChIKCgZESU5ERVgQCxIICgRHVElEEAwSDAoIWEFD", + "T01NSVQQDRIOCgpYQVJPTExCQUNLEA4SDgoKTUhFQVJUQkVBVBAPKkIKBFR5", + "cGUSGAoUVFlQRUNPTVBBVElCTEVQUk9UTzIQABIKCgZPUkFDTEUQARIJCgVN", + "WVNRTBACEgkKBVBHU1FMEANCMAogY29tLmFsaWJhYmEub3R0ZXIuY2FuYWwu", + "cHJvdG9jb2xCCkNhbmFsRW50cnlIAWIGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Com.Alibaba.Otter.Canal.Protocol.EntryType), typeof(global::Com.Alibaba.Otter.Canal.Protocol.EventType), typeof(global::Com.Alibaba.Otter.Canal.Protocol.Type), }, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Alibaba.Otter.Canal.Protocol.Entry), global::Com.Alibaba.Otter.Canal.Protocol.Entry.Parser, new[]{ "Header", "EntryType", "StoreValue" }, new[]{ "EntryTypePresent" }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Alibaba.Otter.Canal.Protocol.Header), global::Com.Alibaba.Otter.Canal.Protocol.Header.Parser, new[]{ "Version", "LogfileName", "LogfileOffset", "ServerId", "ServerenCode", "ExecuteTime", "SourceType", "SchemaName", "TableName", "EventLength", "EventType", "Props", "Gtid" }, new[]{ "VersionPresent", "SourceTypePresent", "EventTypePresent" }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Alibaba.Otter.Canal.Protocol.Column), global::Com.Alibaba.Otter.Canal.Protocol.Column.Parser, new[]{ "Index", "SqlType", "Name", "IsKey", "Updated", "IsNull", "Props", "Value", "Length", "MysqlType" }, new[]{ "IsNullPresent" }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Alibaba.Otter.Canal.Protocol.RowData), global::Com.Alibaba.Otter.Canal.Protocol.RowData.Parser, new[]{ "BeforeColumns", "AfterColumns", "Props" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Alibaba.Otter.Canal.Protocol.RowChange), global::Com.Alibaba.Otter.Canal.Protocol.RowChange.Parser, new[]{ "TableId", "EventType", "IsDdl", "Sql", "RowDatas", "Props", "DdlSchemaName" }, new[]{ "EventTypePresent", "IsDdlPresent" }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Alibaba.Otter.Canal.Protocol.TransactionBegin), global::Com.Alibaba.Otter.Canal.Protocol.TransactionBegin.Parser, new[]{ "ExecuteTime", "TransactionId", "Props", "ThreadId" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Alibaba.Otter.Canal.Protocol.TransactionEnd), global::Com.Alibaba.Otter.Canal.Protocol.TransactionEnd.Parser, new[]{ "ExecuteTime", "TransactionId", "Props" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Alibaba.Otter.Canal.Protocol.Pair), global::Com.Alibaba.Otter.Canal.Protocol.Pair.Parser, new[]{ "Key", "Value" }, null, null, null) + })); + } + #endregion + + } + #region Enums + /// + ///*打散后的事件类型,主要用于标识事务的开始,变更数据,结束* + /// + public enum EntryType { + [pbr::OriginalName("ENTRYTYPECOMPATIBLEPROTO2")] Compatibleproto2 = 0, + [pbr::OriginalName("TRANSACTIONBEGIN")] Transactionbegin = 1, + [pbr::OriginalName("ROWDATA")] Rowdata = 2, + [pbr::OriginalName("TRANSACTIONEND")] Transactionend = 3, + /// + ///* 心跳类型,内部使用,外部暂不可见,可忽略 * + /// + [pbr::OriginalName("HEARTBEAT")] Heartbeat = 4, + [pbr::OriginalName("GTIDLOG")] Gtidlog = 5, + } + + /// + ///* 事件类型 * + /// + public enum EventType { + [pbr::OriginalName("EVENTTYPECOMPATIBLEPROTO2")] Compatibleproto2 = 0, + [pbr::OriginalName("INSERT")] Insert = 1, + [pbr::OriginalName("UPDATE")] Update = 2, + [pbr::OriginalName("DELETE")] Delete = 3, + [pbr::OriginalName("CREATE")] Create = 4, + [pbr::OriginalName("ALTER")] Alter = 5, + [pbr::OriginalName("ERASE")] Erase = 6, + [pbr::OriginalName("QUERY")] Query = 7, + [pbr::OriginalName("TRUNCATE")] Truncate = 8, + [pbr::OriginalName("RENAME")] Rename = 9, + /// + ///*CREATE INDEX* + /// + [pbr::OriginalName("CINDEX")] Cindex = 10, + [pbr::OriginalName("DINDEX")] Dindex = 11, + [pbr::OriginalName("GTID")] Gtid = 12, + /// + ///* XA * + /// + [pbr::OriginalName("XACOMMIT")] Xacommit = 13, + [pbr::OriginalName("XAROLLBACK")] Xarollback = 14, + /// + ///* MASTER HEARTBEAT * + /// + [pbr::OriginalName("MHEARTBEAT")] Mheartbeat = 15, + } + + /// + ///*数据库类型* + /// + public enum Type { + [pbr::OriginalName("TYPECOMPATIBLEPROTO2")] Compatibleproto2 = 0, + [pbr::OriginalName("ORACLE")] Oracle = 1, + [pbr::OriginalName("MYSQL")] Mysql = 2, + [pbr::OriginalName("PGSQL")] Pgsql = 3, + } + + #endregion + + #region Messages + /// + ///*************************************************************** + /// message model + ///如果要在Enum中新增类型,确保以前的类型的下标值不变. + ///************************************************************** + /// + public sealed partial class Entry : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Entry()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Alibaba.Otter.Canal.Protocol.EntryProtocolReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Entry() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Entry(Entry other) : this() { + header_ = other.header_ != null ? other.header_.Clone() : null; + storeValue_ = other.storeValue_; + switch (other.EntryTypePresentCase) { + case EntryTypePresentOneofCase.EntryType: + EntryType = other.EntryType; + break; + } + + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Entry Clone() { + return new Entry(this); + } + + /// Field number for the "header" field. + public const int HeaderFieldNumber = 1; + private global::Com.Alibaba.Otter.Canal.Protocol.Header header_; + /// + ///*协议头部信息* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Com.Alibaba.Otter.Canal.Protocol.Header Header { + get { return header_; } + set { + header_ = value; + } + } + + /// Field number for the "entryType" field. + public const int EntryTypeFieldNumber = 2; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Com.Alibaba.Otter.Canal.Protocol.EntryType EntryType { + get { return entryTypePresentCase_ == EntryTypePresentOneofCase.EntryType ? (global::Com.Alibaba.Otter.Canal.Protocol.EntryType) entryTypePresent_ : EntryType.Rowdata; } + set { + entryTypePresent_ = value; + entryTypePresentCase_ = EntryTypePresentOneofCase.EntryType; + } + } + + /// Field number for the "storeValue" field. + public const int StoreValueFieldNumber = 3; + private pb::ByteString storeValue_ = pb::ByteString.Empty; + /// + ///*传输的二进制数组* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString StoreValue { + get { return storeValue_; } + set { + storeValue_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + private object entryTypePresent_; + /// Enum of possible cases for the "entryType_present" oneof. + public enum EntryTypePresentOneofCase { + None = 0, + EntryType = 2, + } + private EntryTypePresentOneofCase entryTypePresentCase_ = EntryTypePresentOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public EntryTypePresentOneofCase EntryTypePresentCase { + get { return entryTypePresentCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearEntryTypePresent() { + entryTypePresentCase_ = EntryTypePresentOneofCase.None; + entryTypePresent_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Entry); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Entry other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(Header, other.Header)) return false; + if (EntryType != other.EntryType) return false; + if (StoreValue != other.StoreValue) return false; + if (EntryTypePresentCase != other.EntryTypePresentCase) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (header_ != null) hash ^= Header.GetHashCode(); + if (entryTypePresentCase_ == EntryTypePresentOneofCase.EntryType) hash ^= EntryType.GetHashCode(); + if (StoreValue.Length != 0) hash ^= StoreValue.GetHashCode(); + hash ^= (int) entryTypePresentCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (header_ != null) { + output.WriteRawTag(10); + output.WriteMessage(Header); + } + if (entryTypePresentCase_ == EntryTypePresentOneofCase.EntryType) { + output.WriteRawTag(16); + output.WriteEnum((int) EntryType); + } + if (StoreValue.Length != 0) { + output.WriteRawTag(26); + output.WriteBytes(StoreValue); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (header_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Header); + } + if (entryTypePresentCase_ == EntryTypePresentOneofCase.EntryType) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) EntryType); + } + if (StoreValue.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(StoreValue); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Entry other) { + if (other == null) { + return; + } + if (other.header_ != null) { + if (header_ == null) { + header_ = new global::Com.Alibaba.Otter.Canal.Protocol.Header(); + } + Header.MergeFrom(other.Header); + } + if (other.StoreValue.Length != 0) { + StoreValue = other.StoreValue; + } + switch (other.EntryTypePresentCase) { + case EntryTypePresentOneofCase.EntryType: + EntryType = other.EntryType; + break; + } + + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + if (header_ == null) { + header_ = new global::Com.Alibaba.Otter.Canal.Protocol.Header(); + } + input.ReadMessage(header_); + break; + } + case 16: { + entryTypePresent_ = input.ReadEnum(); + entryTypePresentCase_ = EntryTypePresentOneofCase.EntryType; + break; + } + case 26: { + StoreValue = input.ReadBytes(); + break; + } + } + } + } + + } + + /// + ///*message Header* + /// + public sealed partial class Header : pb::IMessage
{ + private static readonly pb::MessageParser
_parser = new pb::MessageParser
(() => new Header()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser
Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Alibaba.Otter.Canal.Protocol.EntryProtocolReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Header() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Header(Header other) : this() { + logfileName_ = other.logfileName_; + logfileOffset_ = other.logfileOffset_; + serverId_ = other.serverId_; + serverenCode_ = other.serverenCode_; + executeTime_ = other.executeTime_; + schemaName_ = other.schemaName_; + tableName_ = other.tableName_; + eventLength_ = other.eventLength_; + props_ = other.props_.Clone(); + gtid_ = other.gtid_; + switch (other.VersionPresentCase) { + case VersionPresentOneofCase.Version: + Version = other.Version; + break; + } + + switch (other.SourceTypePresentCase) { + case SourceTypePresentOneofCase.SourceType: + SourceType = other.SourceType; + break; + } + + switch (other.EventTypePresentCase) { + case EventTypePresentOneofCase.EventType: + EventType = other.EventType; + break; + } + + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Header Clone() { + return new Header(this); + } + + /// Field number for the "version" field. + public const int VersionFieldNumber = 1; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Version { + get { return versionPresentCase_ == VersionPresentOneofCase.Version ? (int) versionPresent_ : 1; } + set { + versionPresent_ = value; + versionPresentCase_ = VersionPresentOneofCase.Version; + } + } + + /// Field number for the "logfileName" field. + public const int LogfileNameFieldNumber = 2; + private string logfileName_ = ""; + /// + ///*binlog/redolog 文件名* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string LogfileName { + get { return logfileName_; } + set { + logfileName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "logfileOffset" field. + public const int LogfileOffsetFieldNumber = 3; + private long logfileOffset_; + /// + ///*binlog/redolog 文件的偏移位置* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long LogfileOffset { + get { return logfileOffset_; } + set { + logfileOffset_ = value; + } + } + + /// Field number for the "serverId" field. + public const int ServerIdFieldNumber = 4; + private long serverId_; + /// + ///*服务端serverId* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long ServerId { + get { return serverId_; } + set { + serverId_ = value; + } + } + + /// Field number for the "serverenCode" field. + public const int ServerenCodeFieldNumber = 5; + private string serverenCode_ = ""; + /// + ///* 变更数据的编码 * + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ServerenCode { + get { return serverenCode_; } + set { + serverenCode_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "executeTime" field. + public const int ExecuteTimeFieldNumber = 6; + private long executeTime_; + /// + ///*变更数据的执行时间 * + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long ExecuteTime { + get { return executeTime_; } + set { + executeTime_ = value; + } + } + + /// Field number for the "sourceType" field. + public const int SourceTypeFieldNumber = 7; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Com.Alibaba.Otter.Canal.Protocol.Type SourceType { + get { return sourceTypePresentCase_ == SourceTypePresentOneofCase.SourceType ? (global::Com.Alibaba.Otter.Canal.Protocol.Type) sourceTypePresent_ : Type.Mysql; } + set { + sourceTypePresent_ = value; + sourceTypePresentCase_ = SourceTypePresentOneofCase.SourceType; + } + } + + /// Field number for the "schemaName" field. + public const int SchemaNameFieldNumber = 8; + private string schemaName_ = ""; + /// + ///* 变更数据的schemaname* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string SchemaName { + get { return schemaName_; } + set { + schemaName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "tableName" field. + public const int TableNameFieldNumber = 9; + private string tableName_ = ""; + /// + ///*变更数据的tablename* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string TableName { + get { return tableName_; } + set { + tableName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "eventLength" field. + public const int EventLengthFieldNumber = 10; + private long eventLength_; + /// + ///*每个event的长度* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long EventLength { + get { return eventLength_; } + set { + eventLength_ = value; + } + } + + /// Field number for the "eventType" field. + public const int EventTypeFieldNumber = 11; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Com.Alibaba.Otter.Canal.Protocol.EventType EventType { + get { return eventTypePresentCase_ == EventTypePresentOneofCase.EventType ? (global::Com.Alibaba.Otter.Canal.Protocol.EventType) eventTypePresent_ : EventType.Update; } + set { + eventTypePresent_ = value; + eventTypePresentCase_ = EventTypePresentOneofCase.EventType; + } + } + + /// Field number for the "props" field. + public const int PropsFieldNumber = 12; + private static readonly pb::FieldCodec _repeated_props_codec + = pb::FieldCodec.ForMessage(98, global::Com.Alibaba.Otter.Canal.Protocol.Pair.Parser); + private readonly pbc::RepeatedField props_ = new pbc::RepeatedField(); + /// + ///*预留扩展* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Props { + get { return props_; } + } + + /// Field number for the "gtid" field. + public const int GtidFieldNumber = 13; + private string gtid_ = ""; + /// + ///*当前事务的gitd* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Gtid { + get { return gtid_; } + set { + gtid_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + private object versionPresent_; + /// Enum of possible cases for the "version_present" oneof. + public enum VersionPresentOneofCase { + None = 0, + Version = 1, + } + private VersionPresentOneofCase versionPresentCase_ = VersionPresentOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public VersionPresentOneofCase VersionPresentCase { + get { return versionPresentCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearVersionPresent() { + versionPresentCase_ = VersionPresentOneofCase.None; + versionPresent_ = null; + } + + private object sourceTypePresent_; + /// Enum of possible cases for the "sourceType_present" oneof. + public enum SourceTypePresentOneofCase { + None = 0, + SourceType = 7, + } + private SourceTypePresentOneofCase sourceTypePresentCase_ = SourceTypePresentOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SourceTypePresentOneofCase SourceTypePresentCase { + get { return sourceTypePresentCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearSourceTypePresent() { + sourceTypePresentCase_ = SourceTypePresentOneofCase.None; + sourceTypePresent_ = null; + } + + private object eventTypePresent_; + /// Enum of possible cases for the "eventType_present" oneof. + public enum EventTypePresentOneofCase { + None = 0, + EventType = 11, + } + private EventTypePresentOneofCase eventTypePresentCase_ = EventTypePresentOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public EventTypePresentOneofCase EventTypePresentCase { + get { return eventTypePresentCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearEventTypePresent() { + eventTypePresentCase_ = EventTypePresentOneofCase.None; + eventTypePresent_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Header); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Header other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Version != other.Version) return false; + if (LogfileName != other.LogfileName) return false; + if (LogfileOffset != other.LogfileOffset) return false; + if (ServerId != other.ServerId) return false; + if (ServerenCode != other.ServerenCode) return false; + if (ExecuteTime != other.ExecuteTime) return false; + if (SourceType != other.SourceType) return false; + if (SchemaName != other.SchemaName) return false; + if (TableName != other.TableName) return false; + if (EventLength != other.EventLength) return false; + if (EventType != other.EventType) return false; + if(!props_.Equals(other.props_)) return false; + if (Gtid != other.Gtid) return false; + if (VersionPresentCase != other.VersionPresentCase) return false; + if (SourceTypePresentCase != other.SourceTypePresentCase) return false; + if (EventTypePresentCase != other.EventTypePresentCase) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (versionPresentCase_ == VersionPresentOneofCase.Version) hash ^= Version.GetHashCode(); + if (LogfileName.Length != 0) hash ^= LogfileName.GetHashCode(); + if (LogfileOffset != 0L) hash ^= LogfileOffset.GetHashCode(); + if (ServerId != 0L) hash ^= ServerId.GetHashCode(); + if (ServerenCode.Length != 0) hash ^= ServerenCode.GetHashCode(); + if (ExecuteTime != 0L) hash ^= ExecuteTime.GetHashCode(); + if (sourceTypePresentCase_ == SourceTypePresentOneofCase.SourceType) hash ^= SourceType.GetHashCode(); + if (SchemaName.Length != 0) hash ^= SchemaName.GetHashCode(); + if (TableName.Length != 0) hash ^= TableName.GetHashCode(); + if (EventLength != 0L) hash ^= EventLength.GetHashCode(); + if (eventTypePresentCase_ == EventTypePresentOneofCase.EventType) hash ^= EventType.GetHashCode(); + hash ^= props_.GetHashCode(); + if (Gtid.Length != 0) hash ^= Gtid.GetHashCode(); + hash ^= (int) versionPresentCase_; + hash ^= (int) sourceTypePresentCase_; + hash ^= (int) eventTypePresentCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (versionPresentCase_ == VersionPresentOneofCase.Version) { + output.WriteRawTag(8); + output.WriteInt32(Version); + } + if (LogfileName.Length != 0) { + output.WriteRawTag(18); + output.WriteString(LogfileName); + } + if (LogfileOffset != 0L) { + output.WriteRawTag(24); + output.WriteInt64(LogfileOffset); + } + if (ServerId != 0L) { + output.WriteRawTag(32); + output.WriteInt64(ServerId); + } + if (ServerenCode.Length != 0) { + output.WriteRawTag(42); + output.WriteString(ServerenCode); + } + if (ExecuteTime != 0L) { + output.WriteRawTag(48); + output.WriteInt64(ExecuteTime); + } + if (sourceTypePresentCase_ == SourceTypePresentOneofCase.SourceType) { + output.WriteRawTag(56); + output.WriteEnum((int) SourceType); + } + if (SchemaName.Length != 0) { + output.WriteRawTag(66); + output.WriteString(SchemaName); + } + if (TableName.Length != 0) { + output.WriteRawTag(74); + output.WriteString(TableName); + } + if (EventLength != 0L) { + output.WriteRawTag(80); + output.WriteInt64(EventLength); + } + if (eventTypePresentCase_ == EventTypePresentOneofCase.EventType) { + output.WriteRawTag(88); + output.WriteEnum((int) EventType); + } + props_.WriteTo(output, _repeated_props_codec); + if (Gtid.Length != 0) { + output.WriteRawTag(106); + output.WriteString(Gtid); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (versionPresentCase_ == VersionPresentOneofCase.Version) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Version); + } + if (LogfileName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(LogfileName); + } + if (LogfileOffset != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(LogfileOffset); + } + if (ServerId != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(ServerId); + } + if (ServerenCode.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ServerenCode); + } + if (ExecuteTime != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(ExecuteTime); + } + if (sourceTypePresentCase_ == SourceTypePresentOneofCase.SourceType) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) SourceType); + } + if (SchemaName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(SchemaName); + } + if (TableName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TableName); + } + if (EventLength != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(EventLength); + } + if (eventTypePresentCase_ == EventTypePresentOneofCase.EventType) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) EventType); + } + size += props_.CalculateSize(_repeated_props_codec); + if (Gtid.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Gtid); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Header other) { + if (other == null) { + return; + } + if (other.LogfileName.Length != 0) { + LogfileName = other.LogfileName; + } + if (other.LogfileOffset != 0L) { + LogfileOffset = other.LogfileOffset; + } + if (other.ServerId != 0L) { + ServerId = other.ServerId; + } + if (other.ServerenCode.Length != 0) { + ServerenCode = other.ServerenCode; + } + if (other.ExecuteTime != 0L) { + ExecuteTime = other.ExecuteTime; + } + if (other.SchemaName.Length != 0) { + SchemaName = other.SchemaName; + } + if (other.TableName.Length != 0) { + TableName = other.TableName; + } + if (other.EventLength != 0L) { + EventLength = other.EventLength; + } + props_.Add(other.props_); + if (other.Gtid.Length != 0) { + Gtid = other.Gtid; + } + switch (other.VersionPresentCase) { + case VersionPresentOneofCase.Version: + Version = other.Version; + break; + } + + switch (other.SourceTypePresentCase) { + case SourceTypePresentOneofCase.SourceType: + SourceType = other.SourceType; + break; + } + + switch (other.EventTypePresentCase) { + case EventTypePresentOneofCase.EventType: + EventType = other.EventType; + break; + } + + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + Version = input.ReadInt32(); + break; + } + case 18: { + LogfileName = input.ReadString(); + break; + } + case 24: { + LogfileOffset = input.ReadInt64(); + break; + } + case 32: { + ServerId = input.ReadInt64(); + break; + } + case 42: { + ServerenCode = input.ReadString(); + break; + } + case 48: { + ExecuteTime = input.ReadInt64(); + break; + } + case 56: { + sourceTypePresent_ = input.ReadEnum(); + sourceTypePresentCase_ = SourceTypePresentOneofCase.SourceType; + break; + } + case 66: { + SchemaName = input.ReadString(); + break; + } + case 74: { + TableName = input.ReadString(); + break; + } + case 80: { + EventLength = input.ReadInt64(); + break; + } + case 88: { + eventTypePresent_ = input.ReadEnum(); + eventTypePresentCase_ = EventTypePresentOneofCase.EventType; + break; + } + case 98: { + props_.AddEntriesFrom(input, _repeated_props_codec); + break; + } + case 106: { + Gtid = input.ReadString(); + break; + } + } + } + } + + } + + /// + ///*每个字段的数据结构* + /// + public sealed partial class Column : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Column()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Alibaba.Otter.Canal.Protocol.EntryProtocolReflection.Descriptor.MessageTypes[2]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Column() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Column(Column other) : this() { + index_ = other.index_; + sqlType_ = other.sqlType_; + name_ = other.name_; + isKey_ = other.isKey_; + updated_ = other.updated_; + props_ = other.props_.Clone(); + value_ = other.value_; + length_ = other.length_; + mysqlType_ = other.mysqlType_; + switch (other.IsNullPresentCase) { + case IsNullPresentOneofCase.IsNull: + IsNull = other.IsNull; + break; + } + + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Column Clone() { + return new Column(this); + } + + /// Field number for the "index" field. + public const int IndexFieldNumber = 1; + private int index_; + /// + ///*字段下标* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Index { + get { return index_; } + set { + index_ = value; + } + } + + /// Field number for the "sqlType" field. + public const int SqlTypeFieldNumber = 2; + private int sqlType_; + /// + ///*字段java中类型* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int SqlType { + get { return sqlType_; } + set { + sqlType_ = value; + } + } + + /// Field number for the "name" field. + public const int NameFieldNumber = 3; + private string name_ = ""; + /// + ///*字段名称(忽略大小写),在mysql中是没有的* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Name { + get { return name_; } + set { + name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "isKey" field. + public const int IsKeyFieldNumber = 4; + private bool isKey_; + /// + ///*是否是主键* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool IsKey { + get { return isKey_; } + set { + isKey_ = value; + } + } + + /// Field number for the "updated" field. + public const int UpdatedFieldNumber = 5; + private bool updated_; + /// + ///*如果EventType=UPDATE,用于标识这个字段值是否有修改* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Updated { + get { return updated_; } + set { + updated_ = value; + } + } + + /// Field number for the "isNull" field. + public const int IsNullFieldNumber = 6; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool IsNull { + get { return isNullPresentCase_ == IsNullPresentOneofCase.IsNull ? (bool) isNullPresent_ : false; } + set { + isNullPresent_ = value; + isNullPresentCase_ = IsNullPresentOneofCase.IsNull; + } + } + + /// Field number for the "props" field. + public const int PropsFieldNumber = 7; + private static readonly pb::FieldCodec _repeated_props_codec + = pb::FieldCodec.ForMessage(58, global::Com.Alibaba.Otter.Canal.Protocol.Pair.Parser); + private readonly pbc::RepeatedField props_ = new pbc::RepeatedField(); + /// + ///*预留扩展* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Props { + get { return props_; } + } + + /// Field number for the "value" field. + public const int ValueFieldNumber = 8; + private string value_ = ""; + /// + ///* 字段值,timestamp,Datetime是一个时间格式的文本 * + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Value { + get { return value_; } + set { + value_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "length" field. + public const int LengthFieldNumber = 9; + private int length_; + /// + ///* 对应数据对象原始长度 * + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Length { + get { return length_; } + set { + length_ = value; + } + } + + /// Field number for the "mysqlType" field. + public const int MysqlTypeFieldNumber = 10; + private string mysqlType_ = ""; + /// + ///*字段mysql类型* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string MysqlType { + get { return mysqlType_; } + set { + mysqlType_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + private object isNullPresent_; + /// Enum of possible cases for the "isNull_present" oneof. + public enum IsNullPresentOneofCase { + None = 0, + IsNull = 6, + } + private IsNullPresentOneofCase isNullPresentCase_ = IsNullPresentOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public IsNullPresentOneofCase IsNullPresentCase { + get { return isNullPresentCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearIsNullPresent() { + isNullPresentCase_ = IsNullPresentOneofCase.None; + isNullPresent_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Column); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Column other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Index != other.Index) return false; + if (SqlType != other.SqlType) return false; + if (Name != other.Name) return false; + if (IsKey != other.IsKey) return false; + if (Updated != other.Updated) return false; + if (IsNull != other.IsNull) return false; + if(!props_.Equals(other.props_)) return false; + if (Value != other.Value) return false; + if (Length != other.Length) return false; + if (MysqlType != other.MysqlType) return false; + if (IsNullPresentCase != other.IsNullPresentCase) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Index != 0) hash ^= Index.GetHashCode(); + if (SqlType != 0) hash ^= SqlType.GetHashCode(); + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (IsKey != false) hash ^= IsKey.GetHashCode(); + if (Updated != false) hash ^= Updated.GetHashCode(); + if (isNullPresentCase_ == IsNullPresentOneofCase.IsNull) hash ^= IsNull.GetHashCode(); + hash ^= props_.GetHashCode(); + if (Value.Length != 0) hash ^= Value.GetHashCode(); + if (Length != 0) hash ^= Length.GetHashCode(); + if (MysqlType.Length != 0) hash ^= MysqlType.GetHashCode(); + hash ^= (int) isNullPresentCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Index != 0) { + output.WriteRawTag(8); + output.WriteInt32(Index); + } + if (SqlType != 0) { + output.WriteRawTag(16); + output.WriteInt32(SqlType); + } + if (Name.Length != 0) { + output.WriteRawTag(26); + output.WriteString(Name); + } + if (IsKey != false) { + output.WriteRawTag(32); + output.WriteBool(IsKey); + } + if (Updated != false) { + output.WriteRawTag(40); + output.WriteBool(Updated); + } + if (isNullPresentCase_ == IsNullPresentOneofCase.IsNull) { + output.WriteRawTag(48); + output.WriteBool(IsNull); + } + props_.WriteTo(output, _repeated_props_codec); + if (Value.Length != 0) { + output.WriteRawTag(66); + output.WriteString(Value); + } + if (Length != 0) { + output.WriteRawTag(72); + output.WriteInt32(Length); + } + if (MysqlType.Length != 0) { + output.WriteRawTag(82); + output.WriteString(MysqlType); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Index != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Index); + } + if (SqlType != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(SqlType); + } + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + if (IsKey != false) { + size += 1 + 1; + } + if (Updated != false) { + size += 1 + 1; + } + if (isNullPresentCase_ == IsNullPresentOneofCase.IsNull) { + size += 1 + 1; + } + size += props_.CalculateSize(_repeated_props_codec); + if (Value.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Value); + } + if (Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Length); + } + if (MysqlType.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(MysqlType); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Column other) { + if (other == null) { + return; + } + if (other.Index != 0) { + Index = other.Index; + } + if (other.SqlType != 0) { + SqlType = other.SqlType; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + if (other.IsKey != false) { + IsKey = other.IsKey; + } + if (other.Updated != false) { + Updated = other.Updated; + } + props_.Add(other.props_); + if (other.Value.Length != 0) { + Value = other.Value; + } + if (other.Length != 0) { + Length = other.Length; + } + if (other.MysqlType.Length != 0) { + MysqlType = other.MysqlType; + } + switch (other.IsNullPresentCase) { + case IsNullPresentOneofCase.IsNull: + IsNull = other.IsNull; + break; + } + + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + Index = input.ReadInt32(); + break; + } + case 16: { + SqlType = input.ReadInt32(); + break; + } + case 26: { + Name = input.ReadString(); + break; + } + case 32: { + IsKey = input.ReadBool(); + break; + } + case 40: { + Updated = input.ReadBool(); + break; + } + case 48: { + IsNull = input.ReadBool(); + break; + } + case 58: { + props_.AddEntriesFrom(input, _repeated_props_codec); + break; + } + case 66: { + Value = input.ReadString(); + break; + } + case 72: { + Length = input.ReadInt32(); + break; + } + case 82: { + MysqlType = input.ReadString(); + break; + } + } + } + } + + } + + public sealed partial class RowData : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RowData()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Alibaba.Otter.Canal.Protocol.EntryProtocolReflection.Descriptor.MessageTypes[3]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RowData() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RowData(RowData other) : this() { + beforeColumns_ = other.beforeColumns_.Clone(); + afterColumns_ = other.afterColumns_.Clone(); + props_ = other.props_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RowData Clone() { + return new RowData(this); + } + + /// Field number for the "beforeColumns" field. + public const int BeforeColumnsFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_beforeColumns_codec + = pb::FieldCodec.ForMessage(10, global::Com.Alibaba.Otter.Canal.Protocol.Column.Parser); + private readonly pbc::RepeatedField beforeColumns_ = new pbc::RepeatedField(); + /// + ///* 字段信息,增量数据(修改前,删除前) * + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField BeforeColumns { + get { return beforeColumns_; } + } + + /// Field number for the "afterColumns" field. + public const int AfterColumnsFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_afterColumns_codec + = pb::FieldCodec.ForMessage(18, global::Com.Alibaba.Otter.Canal.Protocol.Column.Parser); + private readonly pbc::RepeatedField afterColumns_ = new pbc::RepeatedField(); + /// + ///* 字段信息,增量数据(修改后,新增后) * + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField AfterColumns { + get { return afterColumns_; } + } + + /// Field number for the "props" field. + public const int PropsFieldNumber = 3; + private static readonly pb::FieldCodec _repeated_props_codec + = pb::FieldCodec.ForMessage(26, global::Com.Alibaba.Otter.Canal.Protocol.Pair.Parser); + private readonly pbc::RepeatedField props_ = new pbc::RepeatedField(); + /// + ///*预留扩展* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Props { + get { return props_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as RowData); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(RowData other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!beforeColumns_.Equals(other.beforeColumns_)) return false; + if(!afterColumns_.Equals(other.afterColumns_)) return false; + if(!props_.Equals(other.props_)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + hash ^= beforeColumns_.GetHashCode(); + hash ^= afterColumns_.GetHashCode(); + hash ^= props_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + beforeColumns_.WriteTo(output, _repeated_beforeColumns_codec); + afterColumns_.WriteTo(output, _repeated_afterColumns_codec); + props_.WriteTo(output, _repeated_props_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + size += beforeColumns_.CalculateSize(_repeated_beforeColumns_codec); + size += afterColumns_.CalculateSize(_repeated_afterColumns_codec); + size += props_.CalculateSize(_repeated_props_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(RowData other) { + if (other == null) { + return; + } + beforeColumns_.Add(other.beforeColumns_); + afterColumns_.Add(other.afterColumns_); + props_.Add(other.props_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + beforeColumns_.AddEntriesFrom(input, _repeated_beforeColumns_codec); + break; + } + case 18: { + afterColumns_.AddEntriesFrom(input, _repeated_afterColumns_codec); + break; + } + case 26: { + props_.AddEntriesFrom(input, _repeated_props_codec); + break; + } + } + } + } + + } + + /// + ///*message row 每行变更数据的数据结构* + /// + public sealed partial class RowChange : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RowChange()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Alibaba.Otter.Canal.Protocol.EntryProtocolReflection.Descriptor.MessageTypes[4]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RowChange() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RowChange(RowChange other) : this() { + tableId_ = other.tableId_; + sql_ = other.sql_; + rowDatas_ = other.rowDatas_.Clone(); + props_ = other.props_.Clone(); + ddlSchemaName_ = other.ddlSchemaName_; + switch (other.EventTypePresentCase) { + case EventTypePresentOneofCase.EventType: + EventType = other.EventType; + break; + } + + switch (other.IsDdlPresentCase) { + case IsDdlPresentOneofCase.IsDdl: + IsDdl = other.IsDdl; + break; + } + + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RowChange Clone() { + return new RowChange(this); + } + + /// Field number for the "tableId" field. + public const int TableIdFieldNumber = 1; + private long tableId_; + /// + ///*tableId,由数据库产生* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long TableId { + get { return tableId_; } + set { + tableId_ = value; + } + } + + /// Field number for the "eventType" field. + public const int EventTypeFieldNumber = 2; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Com.Alibaba.Otter.Canal.Protocol.EventType EventType { + get { return eventTypePresentCase_ == EventTypePresentOneofCase.EventType ? (global::Com.Alibaba.Otter.Canal.Protocol.EventType) eventTypePresent_ : EventType.Update; } + set { + eventTypePresent_ = value; + eventTypePresentCase_ = EventTypePresentOneofCase.EventType; + } + } + + /// Field number for the "isDdl" field. + public const int IsDdlFieldNumber = 10; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool IsDdl { + get { return isDdlPresentCase_ == IsDdlPresentOneofCase.IsDdl ? (bool) isDdlPresent_ : false; } + set { + isDdlPresent_ = value; + isDdlPresentCase_ = IsDdlPresentOneofCase.IsDdl; + } + } + + /// Field number for the "sql" field. + public const int SqlFieldNumber = 11; + private string sql_ = ""; + /// + ///* ddl/query的sql语句 * + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Sql { + get { return sql_; } + set { + sql_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "rowDatas" field. + public const int RowDatasFieldNumber = 12; + private static readonly pb::FieldCodec _repeated_rowDatas_codec + = pb::FieldCodec.ForMessage(98, global::Com.Alibaba.Otter.Canal.Protocol.RowData.Parser); + private readonly pbc::RepeatedField rowDatas_ = new pbc::RepeatedField(); + /// + ///* 一次数据库变更可能存在多行 * + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RowDatas { + get { return rowDatas_; } + } + + /// Field number for the "props" field. + public const int PropsFieldNumber = 13; + private static readonly pb::FieldCodec _repeated_props_codec + = pb::FieldCodec.ForMessage(106, global::Com.Alibaba.Otter.Canal.Protocol.Pair.Parser); + private readonly pbc::RepeatedField props_ = new pbc::RepeatedField(); + /// + ///*预留扩展* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Props { + get { return props_; } + } + + /// Field number for the "ddlSchemaName" field. + public const int DdlSchemaNameFieldNumber = 14; + private string ddlSchemaName_ = ""; + /// + ///* ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName * + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string DdlSchemaName { + get { return ddlSchemaName_; } + set { + ddlSchemaName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + private object eventTypePresent_; + /// Enum of possible cases for the "eventType_present" oneof. + public enum EventTypePresentOneofCase { + None = 0, + EventType = 2, + } + private EventTypePresentOneofCase eventTypePresentCase_ = EventTypePresentOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public EventTypePresentOneofCase EventTypePresentCase { + get { return eventTypePresentCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearEventTypePresent() { + eventTypePresentCase_ = EventTypePresentOneofCase.None; + eventTypePresent_ = null; + } + + private object isDdlPresent_; + /// Enum of possible cases for the "isDdl_present" oneof. + public enum IsDdlPresentOneofCase { + None = 0, + IsDdl = 10, + } + private IsDdlPresentOneofCase isDdlPresentCase_ = IsDdlPresentOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public IsDdlPresentOneofCase IsDdlPresentCase { + get { return isDdlPresentCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearIsDdlPresent() { + isDdlPresentCase_ = IsDdlPresentOneofCase.None; + isDdlPresent_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as RowChange); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(RowChange other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TableId != other.TableId) return false; + if (EventType != other.EventType) return false; + if (IsDdl != other.IsDdl) return false; + if (Sql != other.Sql) return false; + if(!rowDatas_.Equals(other.rowDatas_)) return false; + if(!props_.Equals(other.props_)) return false; + if (DdlSchemaName != other.DdlSchemaName) return false; + if (EventTypePresentCase != other.EventTypePresentCase) return false; + if (IsDdlPresentCase != other.IsDdlPresentCase) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (TableId != 0L) hash ^= TableId.GetHashCode(); + if (eventTypePresentCase_ == EventTypePresentOneofCase.EventType) hash ^= EventType.GetHashCode(); + if (isDdlPresentCase_ == IsDdlPresentOneofCase.IsDdl) hash ^= IsDdl.GetHashCode(); + if (Sql.Length != 0) hash ^= Sql.GetHashCode(); + hash ^= rowDatas_.GetHashCode(); + hash ^= props_.GetHashCode(); + if (DdlSchemaName.Length != 0) hash ^= DdlSchemaName.GetHashCode(); + hash ^= (int) eventTypePresentCase_; + hash ^= (int) isDdlPresentCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (TableId != 0L) { + output.WriteRawTag(8); + output.WriteInt64(TableId); + } + if (eventTypePresentCase_ == EventTypePresentOneofCase.EventType) { + output.WriteRawTag(16); + output.WriteEnum((int) EventType); + } + if (isDdlPresentCase_ == IsDdlPresentOneofCase.IsDdl) { + output.WriteRawTag(80); + output.WriteBool(IsDdl); + } + if (Sql.Length != 0) { + output.WriteRawTag(90); + output.WriteString(Sql); + } + rowDatas_.WriteTo(output, _repeated_rowDatas_codec); + props_.WriteTo(output, _repeated_props_codec); + if (DdlSchemaName.Length != 0) { + output.WriteRawTag(114); + output.WriteString(DdlSchemaName); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (TableId != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(TableId); + } + if (eventTypePresentCase_ == EventTypePresentOneofCase.EventType) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) EventType); + } + if (isDdlPresentCase_ == IsDdlPresentOneofCase.IsDdl) { + size += 1 + 1; + } + if (Sql.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Sql); + } + size += rowDatas_.CalculateSize(_repeated_rowDatas_codec); + size += props_.CalculateSize(_repeated_props_codec); + if (DdlSchemaName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(DdlSchemaName); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(RowChange other) { + if (other == null) { + return; + } + if (other.TableId != 0L) { + TableId = other.TableId; + } + if (other.Sql.Length != 0) { + Sql = other.Sql; + } + rowDatas_.Add(other.rowDatas_); + props_.Add(other.props_); + if (other.DdlSchemaName.Length != 0) { + DdlSchemaName = other.DdlSchemaName; + } + switch (other.EventTypePresentCase) { + case EventTypePresentOneofCase.EventType: + EventType = other.EventType; + break; + } + + switch (other.IsDdlPresentCase) { + case IsDdlPresentOneofCase.IsDdl: + IsDdl = other.IsDdl; + break; + } + + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + TableId = input.ReadInt64(); + break; + } + case 16: { + eventTypePresent_ = input.ReadEnum(); + eventTypePresentCase_ = EventTypePresentOneofCase.EventType; + break; + } + case 80: { + IsDdl = input.ReadBool(); + break; + } + case 90: { + Sql = input.ReadString(); + break; + } + case 98: { + rowDatas_.AddEntriesFrom(input, _repeated_rowDatas_codec); + break; + } + case 106: { + props_.AddEntriesFrom(input, _repeated_props_codec); + break; + } + case 114: { + DdlSchemaName = input.ReadString(); + break; + } + } + } + } + + } + + /// + ///*开始事务的一些信息* + /// + public sealed partial class TransactionBegin : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TransactionBegin()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Alibaba.Otter.Canal.Protocol.EntryProtocolReflection.Descriptor.MessageTypes[5]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TransactionBegin() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TransactionBegin(TransactionBegin other) : this() { + executeTime_ = other.executeTime_; + transactionId_ = other.transactionId_; + props_ = other.props_.Clone(); + threadId_ = other.threadId_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TransactionBegin Clone() { + return new TransactionBegin(this); + } + + /// Field number for the "executeTime" field. + public const int ExecuteTimeFieldNumber = 1; + private long executeTime_; + /// + ///*已废弃,请使用header里的executeTime* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long ExecuteTime { + get { return executeTime_; } + set { + executeTime_ = value; + } + } + + /// Field number for the "transactionId" field. + public const int TransactionIdFieldNumber = 2; + private string transactionId_ = ""; + /// + ///*已废弃,Begin里不提供事务id* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string TransactionId { + get { return transactionId_; } + set { + transactionId_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "props" field. + public const int PropsFieldNumber = 3; + private static readonly pb::FieldCodec _repeated_props_codec + = pb::FieldCodec.ForMessage(26, global::Com.Alibaba.Otter.Canal.Protocol.Pair.Parser); + private readonly pbc::RepeatedField props_ = new pbc::RepeatedField(); + /// + ///*预留扩展* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Props { + get { return props_; } + } + + /// Field number for the "threadId" field. + public const int ThreadIdFieldNumber = 4; + private long threadId_; + /// + ///*执行的thread Id* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long ThreadId { + get { return threadId_; } + set { + threadId_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as TransactionBegin); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(TransactionBegin other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (ExecuteTime != other.ExecuteTime) return false; + if (TransactionId != other.TransactionId) return false; + if(!props_.Equals(other.props_)) return false; + if (ThreadId != other.ThreadId) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (ExecuteTime != 0L) hash ^= ExecuteTime.GetHashCode(); + if (TransactionId.Length != 0) hash ^= TransactionId.GetHashCode(); + hash ^= props_.GetHashCode(); + if (ThreadId != 0L) hash ^= ThreadId.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (ExecuteTime != 0L) { + output.WriteRawTag(8); + output.WriteInt64(ExecuteTime); + } + if (TransactionId.Length != 0) { + output.WriteRawTag(18); + output.WriteString(TransactionId); + } + props_.WriteTo(output, _repeated_props_codec); + if (ThreadId != 0L) { + output.WriteRawTag(32); + output.WriteInt64(ThreadId); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (ExecuteTime != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(ExecuteTime); + } + if (TransactionId.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TransactionId); + } + size += props_.CalculateSize(_repeated_props_codec); + if (ThreadId != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(ThreadId); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(TransactionBegin other) { + if (other == null) { + return; + } + if (other.ExecuteTime != 0L) { + ExecuteTime = other.ExecuteTime; + } + if (other.TransactionId.Length != 0) { + TransactionId = other.TransactionId; + } + props_.Add(other.props_); + if (other.ThreadId != 0L) { + ThreadId = other.ThreadId; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + ExecuteTime = input.ReadInt64(); + break; + } + case 18: { + TransactionId = input.ReadString(); + break; + } + case 26: { + props_.AddEntriesFrom(input, _repeated_props_codec); + break; + } + case 32: { + ThreadId = input.ReadInt64(); + break; + } + } + } + } + + } + + /// + ///*结束事务的一些信息* + /// + public sealed partial class TransactionEnd : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TransactionEnd()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Alibaba.Otter.Canal.Protocol.EntryProtocolReflection.Descriptor.MessageTypes[6]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TransactionEnd() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TransactionEnd(TransactionEnd other) : this() { + executeTime_ = other.executeTime_; + transactionId_ = other.transactionId_; + props_ = other.props_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TransactionEnd Clone() { + return new TransactionEnd(this); + } + + /// Field number for the "executeTime" field. + public const int ExecuteTimeFieldNumber = 1; + private long executeTime_; + /// + ///*已废弃,请使用header里的executeTime* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long ExecuteTime { + get { return executeTime_; } + set { + executeTime_ = value; + } + } + + /// Field number for the "transactionId" field. + public const int TransactionIdFieldNumber = 2; + private string transactionId_ = ""; + /// + ///*事务号* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string TransactionId { + get { return transactionId_; } + set { + transactionId_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "props" field. + public const int PropsFieldNumber = 3; + private static readonly pb::FieldCodec _repeated_props_codec + = pb::FieldCodec.ForMessage(26, global::Com.Alibaba.Otter.Canal.Protocol.Pair.Parser); + private readonly pbc::RepeatedField props_ = new pbc::RepeatedField(); + /// + ///*预留扩展* + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Props { + get { return props_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as TransactionEnd); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(TransactionEnd other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (ExecuteTime != other.ExecuteTime) return false; + if (TransactionId != other.TransactionId) return false; + if(!props_.Equals(other.props_)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (ExecuteTime != 0L) hash ^= ExecuteTime.GetHashCode(); + if (TransactionId.Length != 0) hash ^= TransactionId.GetHashCode(); + hash ^= props_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (ExecuteTime != 0L) { + output.WriteRawTag(8); + output.WriteInt64(ExecuteTime); + } + if (TransactionId.Length != 0) { + output.WriteRawTag(18); + output.WriteString(TransactionId); + } + props_.WriteTo(output, _repeated_props_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (ExecuteTime != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(ExecuteTime); + } + if (TransactionId.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TransactionId); + } + size += props_.CalculateSize(_repeated_props_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(TransactionEnd other) { + if (other == null) { + return; + } + if (other.ExecuteTime != 0L) { + ExecuteTime = other.ExecuteTime; + } + if (other.TransactionId.Length != 0) { + TransactionId = other.TransactionId; + } + props_.Add(other.props_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + ExecuteTime = input.ReadInt64(); + break; + } + case 18: { + TransactionId = input.ReadString(); + break; + } + case 26: { + props_.AddEntriesFrom(input, _repeated_props_codec); + break; + } + } + } + } + + } + + /// + ///*预留扩展* + /// + public sealed partial class Pair : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Pair()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Alibaba.Otter.Canal.Protocol.EntryProtocolReflection.Descriptor.MessageTypes[7]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Pair() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Pair(Pair other) : this() { + key_ = other.key_; + value_ = other.value_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Pair Clone() { + return new Pair(this); + } + + /// Field number for the "key" field. + public const int KeyFieldNumber = 1; + private string key_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Key { + get { return key_; } + set { + key_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "value" field. + public const int ValueFieldNumber = 2; + private string value_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Value { + get { return value_; } + set { + value_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Pair); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Pair other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Key != other.Key) return false; + if (Value != other.Value) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Key.Length != 0) hash ^= Key.GetHashCode(); + if (Value.Length != 0) hash ^= Value.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Key.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Key); + } + if (Value.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Value); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Key.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Key); + } + if (Value.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Value); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Pair other) { + if (other == null) { + return; + } + if (other.Key.Length != 0) { + Key = other.Key; + } + if (other.Value.Length != 0) { + Value = other.Value; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Key = input.ReadString(); + break; + } + case 18: { + Value = input.ReadString(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/src/CanalSharp.Protocol/EntryProtocol.proto b/src/CanalSharp.Protocol/EntryProtocol.proto new file mode 100644 index 0000000..01d29c5 --- /dev/null +++ b/src/CanalSharp.Protocol/EntryProtocol.proto @@ -0,0 +1,230 @@ +syntax = "proto3"; +package com.alibaba.otter.canal.protocol; + +option java_package = "com.alibaba.otter.canal.protocol"; +option java_outer_classname = "CanalEntry"; +option optimize_for = SPEED; + +/**************************************************************** + * message model + *如果要在Enum中新增类型,确保以前的类型的下标值不变. + ****************************************************************/ +message Entry { + /**协议头部信息**/ + Header header = 1; + ///**打散后的事件类型**/ [default = ROWDATA] + oneof entryType_present{ + EntryType entryType = 2; + } + + /**传输的二进制数组**/ + bytes storeValue = 3; +} + +/**message Header**/ +message Header { + /**协议的版本号**/ //[default = 1] + oneof version_present { + int32 version = 1; + } + + + /**binlog/redolog 文件名**/ + string logfileName = 2; + + /**binlog/redolog 文件的偏移位置**/ + int64 logfileOffset = 3; + + /**服务端serverId**/ + int64 serverId = 4; + + /** 变更数据的编码 **/ + string serverenCode = 5; + + /**变更数据的执行时间 **/ + int64 executeTime = 6; + + /** 变更数据的来源**/ //[default = MYSQL] + oneof sourceType_present { + Type sourceType = 7; + } + + + /** 变更数据的schemaname**/ + string schemaName = 8; + + /**变更数据的tablename**/ + string tableName = 9; + + /**每个event的长度**/ + int64 eventLength = 10; + + /**数据变更类型**/ // [default = UPDATE] + oneof eventType_present { + EventType eventType = 11; + } + + + /**预留扩展**/ + repeated Pair props = 12; + + /**当前事务的gitd**/ + string gtid = 13; +} + +/**每个字段的数据结构**/ +message Column { + /**字段下标**/ + int32 index = 1; + + /**字段java中类型**/ + int32 sqlType = 2; + + /**字段名称(忽略大小写),在mysql中是没有的**/ + string name = 3; + + /**是否是主键**/ + bool isKey = 4; + + /**如果EventType=UPDATE,用于标识这个字段值是否有修改**/ + bool updated = 5; + + /** 标识是否为空 **/ //[default = false] + oneof isNull_present { + bool isNull = 6; + } + + + /**预留扩展**/ + repeated Pair props = 7; + + /** 字段值,timestamp,Datetime是一个时间格式的文本 **/ + string value = 8; + + /** 对应数据对象原始长度 **/ + int32 length = 9; + + /**字段mysql类型**/ + string mysqlType = 10; +} + +message RowData { + + /** 字段信息,增量数据(修改前,删除前) **/ + repeated Column beforeColumns = 1; + + /** 字段信息,增量数据(修改后,新增后) **/ + repeated Column afterColumns = 2; + + /**预留扩展**/ + repeated Pair props = 3; +} + +/**message row 每行变更数据的数据结构**/ +message RowChange { + + /**tableId,由数据库产生**/ + int64 tableId = 1; + + + /**数据变更类型**/ //[default = UPDATE] + oneof eventType_present { + EventType eventType = 2; + } + + + /** 标识是否是ddl语句 **/ // [default = false] + oneof isDdl_present { + bool isDdl = 10; + } + + + /** ddl/query的sql语句 **/ + string sql = 11; + + /** 一次数据库变更可能存在多行 **/ + repeated RowData rowDatas = 12; + + /**预留扩展**/ + repeated Pair props = 13; + + /** ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName **/ + string ddlSchemaName = 14; +} + +/**开始事务的一些信息**/ +message TransactionBegin{ + + /**已废弃,请使用header里的executeTime**/ + int64 executeTime = 1; + + /**已废弃,Begin里不提供事务id**/ + string transactionId = 2; + + /**预留扩展**/ + repeated Pair props = 3; + + /**执行的thread Id**/ + int64 threadId = 4; +} + +/**结束事务的一些信息**/ +message TransactionEnd{ + + /**已废弃,请使用header里的executeTime**/ + int64 executeTime = 1; + + /**事务号**/ + string transactionId = 2; + + /**预留扩展**/ + repeated Pair props = 3; +} + +/**预留扩展**/ +message Pair{ + string key = 1; + string value = 2; +} + +/**打散后的事件类型,主要用于标识事务的开始,变更数据,结束**/ +enum EntryType{ + ENTRYTYPECOMPATIBLEPROTO2 = 0; + TRANSACTIONBEGIN = 1; + ROWDATA = 2; + TRANSACTIONEND = 3; + /** 心跳类型,内部使用,外部暂不可见,可忽略 **/ + HEARTBEAT = 4; + GTIDLOG = 5; +} + +/** 事件类型 **/ +enum EventType { + EVENTTYPECOMPATIBLEPROTO2 = 0; + INSERT = 1; + UPDATE = 2; + DELETE = 3; + CREATE = 4; + ALTER = 5; + ERASE = 6; + QUERY = 7; + TRUNCATE = 8; + RENAME = 9; + /**CREATE INDEX**/ + CINDEX = 10; + DINDEX = 11; + GTID = 12; + /** XA **/ + XACOMMIT = 13; + XAROLLBACK = 14; + /** MASTER HEARTBEAT **/ + MHEARTBEAT = 15; +} + +/**数据库类型**/ +enum Type { + TYPECOMPATIBLEPROTO2 = 0; + ORACLE = 1; + MYSQL = 2; + PGSQL = 3; +} diff --git a/src/CanalSharp.Protocol/Exception/CanalClientException.cs b/src/CanalSharp.Protocol/Exception/CanalClientException.cs new file mode 100644 index 0000000..3da8ba0 --- /dev/null +++ b/src/CanalSharp.Protocol/Exception/CanalClientException.cs @@ -0,0 +1,13 @@ +namespace CanalSharp.Protocol.Exception +{ + public class CanalClientException : System.Exception + { + public CanalClientException(string errorCode) : base(errorCode) + { + } + + public CanalClientException(string errorCode, System.Exception cause) : base(errorCode, cause) + { + } + } +} diff --git a/src/CanalSharp.Protocol/Message.cs b/src/CanalSharp.Protocol/Message.cs new file mode 100644 index 0000000..0905376 --- /dev/null +++ b/src/CanalSharp.Protocol/Message.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using Com.Alibaba.Otter.Canal.Protocol; +using Google.Protobuf; + +namespace CanalSharp.Protocol +{ + [Serializable] + public class Message + { + public long Id { get; set; } + public List Entries { get; set; } + + public bool Raw { get; set; } + + public List RawEntries = new List(); + + public Message(long id, List entries) + { + Id = id; + Entries = entries ?? new List(); + Raw = false; + } + + public Message(long id) + { + Id = id; + Entries = new List();; + } + public Message(long id, bool raw, object entries) + { + Id = id; + if (raw) + { + RawEntries = (List)(entries ?? new List()); + } + else + { + Entries = (List)(entries ?? new List()); + } + } + } +} diff --git a/src/CanalSharp.Protocol/Position/EntryPosition.cs b/src/CanalSharp.Protocol/Position/EntryPosition.cs new file mode 100644 index 0000000..ff94a5b --- /dev/null +++ b/src/CanalSharp.Protocol/Position/EntryPosition.cs @@ -0,0 +1,124 @@ +using System; + +namespace CanalSharp.Protocol.Position +{ + public class EntryPosition:TimePosition + { + public static int EVENTIDENTITY_SEGMENT = 3; + public static char EVENTIDENTITY_SPLIT = (char)5; + + public bool Included => false; + + public string JournalName { get; set; } + public long? Position { get; set; } + + //// 记录一下位点对应的serverId + public long? ServerId { get; set; } + + public string Gtid = null; + + + public EntryPosition() : base(null) + { + + } + + public EntryPosition(long? timestamp):this(null,null,timestamp) + { + } + + public EntryPosition(string journalName, long? position):this(journalName,position,null) + { + } + + public EntryPosition(string journalName, long? position, long? timestamp):base(timestamp) + { + JournalName = journalName; + Position = position; + } + + public EntryPosition(string journalName, long position, long timestamp, long? serverId):this(journalName, position, timestamp) + { + ServerId = serverId; + } + + public override int GetHashCode() + { + const int prime = 31; + var result = base.GetHashCode(); + result = prime * result + ((JournalName == null) ? 0 : JournalName.GetHashCode()); + result = prime * result + ((Position == null) ? 0 : Position.GetHashCode()); + // 手写equals,自动生成时需注意 + result = prime * result + ((Timestamp == null) ? 0 : Timestamp.GetHashCode()); + return result; + } + + public override bool Equals(object obj) + { + if (this == obj) + { + return true; + } + if (!base.Equals(obj)) + { + return false; + } + if (!(obj is EntryPosition)) { + return false; + } + var other = (EntryPosition)obj; + if (JournalName == null) + { + if (other.JournalName != null) + { + return false; + } + } + else if (!JournalName.Equals(other.JournalName)) + { + return false; + } + if (Position == null) + { + if (other.Position != null) + { + return false; + } + } + else if (!Position.Equals(other.Position)) + { + return false; + } + // 手写equals,自动生成时需注意 + if (Timestamp == null) + { + if (other.Timestamp != null) + { + return false; + } + } + else if (!Timestamp.Equals(other.Timestamp)) + { + return false; + } + return true; + } + + /** + * {@inheritDoc} + * + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + public int CompareTo(EntryPosition o) + { + var val = string.Compare(JournalName, o.JournalName, StringComparison.Ordinal); + + if (val != 0) return val; + if (Position != null) + { + return (int) (Position - o.Position); + } + return val; + } + } +} diff --git a/src/CanalSharp.Protocol/Position/LogIdentity.cs b/src/CanalSharp.Protocol/Position/LogIdentity.cs new file mode 100644 index 0000000..bfaf960 --- /dev/null +++ b/src/CanalSharp.Protocol/Position/LogIdentity.cs @@ -0,0 +1,51 @@ +using System.Net; + +namespace CanalSharp.Protocol.Position +{ + public class LogIdentity:Position + { + // 链接服务器的地址 + public SocketAddress SourceAddress { get; set; } + // 对应的slaveId + public long? SlaveId { get; set; } + + public LogIdentity() + { + + } + + public LogIdentity(SocketAddress sourceAddress,long slaveId) + { + SourceAddress = sourceAddress; + SlaveId = slaveId; + } + + public override int GetHashCode() + { + const int prime = 31; + var result = 1; + result = prime * result + ((SlaveId == null) ? 0 : SlaveId.GetHashCode()); + result = prime * result + ((SourceAddress == null) ? 0 : SourceAddress.GetHashCode()); + return result; + } + + public override bool Equals(object obj) + { + if (this == obj) return true; + if (obj == null) return false; + if (this != obj) return false; + var other = (LogIdentity)obj; + if (SlaveId == null) + { + if (other.SlaveId != null) return false; + } + else if (SlaveId != (other.SlaveId)) return false; + if (SourceAddress == null) + { + if (other.SourceAddress != null) return false; + } + else if (!SourceAddress.Equals(other.SourceAddress)) return false; + return true; + } + } +} diff --git a/src/CanalSharp.Protocol/Position/LogPosition.cs b/src/CanalSharp.Protocol/Position/LogPosition.cs new file mode 100644 index 0000000..1ab3825 --- /dev/null +++ b/src/CanalSharp.Protocol/Position/LogPosition.cs @@ -0,0 +1,56 @@ +namespace CanalSharp.Protocol.Position +{ + public class LogPosition: Position + { + public LogIdentity Identity { get; set; } + private EntryPosition Postion { get; set; } + + public override int GetHashCode() + { + const int prime = 31; + var result = 1; + result = prime * result + ((Identity == null) ? 0 : Identity.GetHashCode()); + result = prime * result + ((Postion == null) ? 0 : Postion.GetHashCode()); + return result; + } + + public override bool Equals(object obj) + { + if (this == obj) + { + return true; + } + if (obj == null) + { + return false; + } + if (!(obj is LogPosition)) { + return false; + } + var other = (LogPosition)obj; + if (Identity == null) + { + if (other.Identity != null) + { + return false; + } + } + else if (!Identity.Equals(other.Identity)) + { + return false; + } + if (Postion == null) + { + if (other.Postion != null) + { + return false; + } + } + else if (!Postion.Equals(other.Postion)) + { + return false; + } + return true; + } + } +} diff --git a/src/CanalSharp.Protocol/Position/MetaqPosition.cs b/src/CanalSharp.Protocol/Position/MetaqPosition.cs new file mode 100644 index 0000000..1f17333 --- /dev/null +++ b/src/CanalSharp.Protocol/Position/MetaqPosition.cs @@ -0,0 +1,16 @@ +namespace CanalSharp.Protocol.Position +{ + public class MetaqPosition:Position + { + public string Topic { get; set; } + public string MsgNewId { get; set; } + public long Offset { get; set; } + + public MetaqPosition(string topic, string msgNewId, long offset) + { + Topic = topic; + MsgNewId = msgNewId; + Offset = offset; + } + } +} diff --git a/src/CanalSharp.Protocol/Position/Position.cs b/src/CanalSharp.Protocol/Position/Position.cs new file mode 100644 index 0000000..520d553 --- /dev/null +++ b/src/CanalSharp.Protocol/Position/Position.cs @@ -0,0 +1,13 @@ +using System; + +namespace CanalSharp.Protocol.Position +{ + /** + * 事件唯一标示 + */ + [Serializable] + public abstract class Position + { + + } +} diff --git a/src/CanalSharp.Protocol/Position/PositionRange.cs b/src/CanalSharp.Protocol/Position/PositionRange.cs new file mode 100644 index 0000000..cce3332 --- /dev/null +++ b/src/CanalSharp.Protocol/Position/PositionRange.cs @@ -0,0 +1,83 @@ +using System; + +namespace CanalSharp.Protocol.Position +{ + [Serializable] + public class PositionRange where T:Position + { + public T Start { get; set; } + // add by ljh at 2012-09-05,用于记录一个可被ack的位置,保证每次提交到cursor中的位置是一个完整事务的结束 + public T Ack { get; set; } + public T End { get; set; } + + public PositionRange() + { + } + + public PositionRange(T start, T end) + { + Start = start; + End = end; + } + + public override int GetHashCode() + { + const int prime = 31; + var result = 1; + result = prime * result + ((Ack == null) ? 0 : Ack.GetHashCode()); + result = prime * result + ((End == null) ? 0 : End.GetHashCode()); + result = prime * result + ((Start == null) ? 0 : Start.GetHashCode()); + return result; + } + + public override bool Equals(object obj) + { + if (this == obj) + { + return true; + } + if (obj == null) + { + return false; + } + if (!(obj is PositionRange)) { + return false; + } + var other = (PositionRange)obj; + if (Ack == null) + { + if (other.Ack != null) + { + return false; + } + } + else if (!Ack.Equals(other.Ack)) + { + return false; + } + if (End == null) + { + if (other.End != null) + { + return false; + } + } + else if (!End.Equals(other.End)) + { + return false; + } + if (Start == null) + { + if (other.Start != null) + { + return false; + } + } + else if (!Start.Equals(other.Start)) + { + return false; + } + return true; + } + } +} diff --git a/src/CanalSharp.Protocol/Position/TimePosition.cs b/src/CanalSharp.Protocol/Position/TimePosition.cs new file mode 100644 index 0000000..0ea62c7 --- /dev/null +++ b/src/CanalSharp.Protocol/Position/TimePosition.cs @@ -0,0 +1,48 @@ +namespace CanalSharp.Protocol.Position +{ + public class TimePosition: Position + { + protected long? Timestamp { get; set; } + + public TimePosition(long? timestamp) + { + Timestamp = timestamp; + } + + public override int GetHashCode() + { + const int prime = 31; + var result = 1; + result = prime * result + ((Timestamp == null) ? 0 : Timestamp.GetHashCode()); + return result; + } + + public override bool Equals(object obj) + { + if (this == obj) + { + return true; + } + if (obj == null) + { + return false; + } + if (!(obj is TimePosition)) { + return false; + } + var other = (TimePosition)obj; + if (Timestamp == null) + { + if (other.Timestamp != null) + { + return false; + } + } + else if (!Timestamp.Equals(other.Timestamp)) + { + return false; + } + return true; + } + } +} diff --git a/test/Canal4Net.UnitTests/UnitTest1.cs b/test/Canal4Net.UnitTests/UnitTest1.cs deleted file mode 100644 index 4512f03..0000000 --- a/test/Canal4Net.UnitTests/UnitTest1.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using Xunit; - -namespace Canal4Net.UnitTests -{ - public class UnitTest1 - { - [Fact] - public void Test1() - { - - } - } -} diff --git a/test/Canal4Net.UnitTests/Canal4Net.UnitTests.csproj b/test/CanalSharp.UnitTests/CanalSharp.UnitTests.csproj similarity index 61% rename from test/Canal4Net.UnitTests/Canal4Net.UnitTests.csproj rename to test/CanalSharp.UnitTests/CanalSharp.UnitTests.csproj index 061aa24..1f4cadf 100644 --- a/test/Canal4Net.UnitTests/Canal4Net.UnitTests.csproj +++ b/test/CanalSharp.UnitTests/CanalSharp.UnitTests.csproj @@ -13,4 +13,10 @@ + + + + + + diff --git a/test/CanalSharp.UnitTests/UnitTest1.cs b/test/CanalSharp.UnitTests/UnitTest1.cs new file mode 100644 index 0000000..fa75ef7 --- /dev/null +++ b/test/CanalSharp.UnitTests/UnitTest1.cs @@ -0,0 +1,44 @@ +using System; +using System.Threading; +using CanalSharp.Client; +using CanalSharp.Client.Impl; +using Xunit; + +namespace CanalSharp.UnitTests +{ + public class UnitTest1 + { + private string aa; + private static readonly object _lock = new object(); + [Fact] + public void Test1() + { + string destination = "example"; + ICanalConnector connector = CanalConnectors.NewSingleConnector("127.0.0.1", 11111, destination, "", ""); + connector.Connect(); + Console.Read(); + + Mutex a=new Mutex(false); + //lock (_lock) + //{ + // new Thread(Test).Start(); + // Monitor.Wait(_lock); + // Console.WriteLine(aa); + // Console.Read(); + //} + + } + + + public void Test() + { + lock (_lock) + { + Thread.Sleep(500); + aa = "aaaaa"; + Monitor.Pulse(_lock); + } + + } + } +}