From 3208c9019a2cfc937e3c5613a53a6eab1c9691bf Mon Sep 17 00:00:00 2001 From: Fankux Date: Tue, 22 Nov 2022 12:17:15 +0800 Subject: [PATCH] introduce `startTimestampUs`, `clusterId`, `sysUser` and `sysPassword` to startup config (#58) * start timestamp in us * fix pom * fix stuffs reviewed in pr * upgrade version * fix PR review issues * fix ut --- common/pom.xml | 2 +- .../common/packet/protocol/LogProxyProto.java | 187 +- .../common/packet/protocol/V1Proto.java | 2736 +++++++++++++++++ .../clogproxy/common/util/CryptoUtil.java | 3 - .../oms/common/enums/DbTypeEnum.java | 5 + .../oceanbase/oms/logmessage/DataMessage.java | 28 +- .../oceanbase/oms/logmessage/LogMessage.java | 2 + .../typehelper/DB2LogTypeHelper.java | 61 + .../typehelper/LogMessageTypeCode.java | 38 + .../typehelper/LogTypeHelperFactory.java | 8 + .../typehelper/MySQLLogTypeHelper.java | 82 + .../typehelper/OracleLogTypeHelper.java | 46 + .../logmessage/typehelper/XLogTypeHelper.java | 36 + logproxy-client/pom.xml | 4 +- .../clogproxy/client/LogProxyClient.java | 3 +- .../clogproxy/client/config/ClientConf.java | 18 +- .../client/config/ObReaderConfig.java | 61 + .../client/connection/ClientHandler.java | 97 +- .../client/connection/ClientHandlerV01.java | 430 +++ .../client/connection/ClientStream.java | 16 +- .../client/connection/StreamContext.java | 6 +- .../client/config/ObReaderConfigTest.java | 3 +- pom.xml | 14 +- .../packet/protocol => proto}/logproxy.proto | 0 proto/v1.proto | 40 + scripts/protoc.sh | 3 +- 26 files changed, 3749 insertions(+), 180 deletions(-) create mode 100644 common/src/main/java/com/oceanbase/clogproxy/common/packet/protocol/V1Proto.java create mode 100644 common/src/main/java/com/oceanbase/oms/logmessage/typehelper/DB2LogTypeHelper.java create mode 100644 common/src/main/java/com/oceanbase/oms/logmessage/typehelper/MySQLLogTypeHelper.java create mode 100644 common/src/main/java/com/oceanbase/oms/logmessage/typehelper/OracleLogTypeHelper.java create mode 100644 common/src/main/java/com/oceanbase/oms/logmessage/typehelper/XLogTypeHelper.java create mode 100644 logproxy-client/src/main/java/com/oceanbase/clogproxy/client/connection/ClientHandlerV01.java rename {common/src/main/java/com/oceanbase/clogproxy/common/packet/protocol => proto}/logproxy.proto (100%) create mode 100644 proto/v1.proto diff --git a/common/pom.xml b/common/pom.xml index 920a63a..2dc43b6 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -16,7 +16,7 @@ See the Mulan PSL v2 for more details. com.oceanbase.logclient logclient - 1.0.8-SNAPSHOT + 1.1.0-SNAPSHOT ../pom.xml diff --git a/common/src/main/java/com/oceanbase/clogproxy/common/packet/protocol/LogProxyProto.java b/common/src/main/java/com/oceanbase/clogproxy/common/packet/protocol/LogProxyProto.java index 838b963..3f6062c 100644 --- a/common/src/main/java/com/oceanbase/clogproxy/common/packet/protocol/LogProxyProto.java +++ b/common/src/main/java/com/oceanbase/clogproxy/common/packet/protocol/LogProxyProto.java @@ -9,7 +9,7 @@ MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the Mulan PSL v2 for more details. */ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: common/src/main/java/com/oceanbase/clogproxy/common/packet/protocol/logproxy.proto +// source: proto/logproxy.proto package com.oceanbase.clogproxy.common.packet.protocol; @@ -182,7 +182,7 @@ public final class LogProxyProto { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); message_ = s; @@ -202,7 +202,7 @@ public final class LogProxyProto { getMessageBytes() { java.lang.Object ref = message_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); message_ = b; @@ -558,7 +558,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder setCode(int value) { - + code_ = value; onChanged(); return this; @@ -572,7 +572,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder clearCode() { - + code_ = 0; onChanged(); return this; @@ -611,7 +611,7 @@ public final class LogProxyProto { getMessageBytes() { java.lang.Object ref = message_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); message_ = b; @@ -634,7 +634,7 @@ public final class LogProxyProto { if (value == null) { throw new NullPointerException(); } - + message_ = value; onChanged(); return this; @@ -648,7 +648,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder clearMessage() { - + message_ = getDefaultInstance().getMessage(); onChanged(); return this; @@ -668,7 +668,7 @@ public final class LogProxyProto { throw new NullPointerException(); } checkByteStringIsUtf8(value); - + message_ = value; onChanged(); return this; @@ -980,7 +980,7 @@ public final class LogProxyProto { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); ip_ = s; @@ -1000,7 +1000,7 @@ public final class LogProxyProto { getIpBytes() { java.lang.Object ref = ip_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); ip_ = b; @@ -1026,7 +1026,7 @@ public final class LogProxyProto { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); id_ = s; @@ -1046,7 +1046,7 @@ public final class LogProxyProto { getIdBytes() { java.lang.Object ref = id_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); id_ = b; @@ -1072,7 +1072,7 @@ public final class LogProxyProto { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); version_ = s; @@ -1092,7 +1092,7 @@ public final class LogProxyProto { getVersionBytes() { java.lang.Object ref = version_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); version_ = b; @@ -1133,7 +1133,7 @@ public final class LogProxyProto { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); configuration_ = s; @@ -1153,7 +1153,7 @@ public final class LogProxyProto { getConfigurationBytes() { java.lang.Object ref = configuration_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); configuration_ = b; @@ -1578,7 +1578,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder setLogType(int value) { - + logType_ = value; onChanged(); return this; @@ -1592,7 +1592,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder clearLogType() { - + logType_ = 0; onChanged(); return this; @@ -1631,7 +1631,7 @@ public final class LogProxyProto { getIpBytes() { java.lang.Object ref = ip_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); ip_ = b; @@ -1654,7 +1654,7 @@ public final class LogProxyProto { if (value == null) { throw new NullPointerException(); } - + ip_ = value; onChanged(); return this; @@ -1668,7 +1668,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder clearIp() { - + ip_ = getDefaultInstance().getIp(); onChanged(); return this; @@ -1688,7 +1688,7 @@ public final class LogProxyProto { throw new NullPointerException(); } checkByteStringIsUtf8(value); - + ip_ = value; onChanged(); return this; @@ -1727,7 +1727,7 @@ public final class LogProxyProto { getIdBytes() { java.lang.Object ref = id_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); id_ = b; @@ -1750,7 +1750,7 @@ public final class LogProxyProto { if (value == null) { throw new NullPointerException(); } - + id_ = value; onChanged(); return this; @@ -1764,7 +1764,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder clearId() { - + id_ = getDefaultInstance().getId(); onChanged(); return this; @@ -1784,7 +1784,7 @@ public final class LogProxyProto { throw new NullPointerException(); } checkByteStringIsUtf8(value); - + id_ = value; onChanged(); return this; @@ -1823,7 +1823,7 @@ public final class LogProxyProto { getVersionBytes() { java.lang.Object ref = version_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); version_ = b; @@ -1846,7 +1846,7 @@ public final class LogProxyProto { if (value == null) { throw new NullPointerException(); } - + version_ = value; onChanged(); return this; @@ -1860,7 +1860,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder clearVersion() { - + version_ = getDefaultInstance().getVersion(); onChanged(); return this; @@ -1880,7 +1880,7 @@ public final class LogProxyProto { throw new NullPointerException(); } checkByteStringIsUtf8(value); - + version_ = value; onChanged(); return this; @@ -1909,7 +1909,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder setEnableMonitor(boolean value) { - + enableMonitor_ = value; onChanged(); return this; @@ -1923,7 +1923,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder clearEnableMonitor() { - + enableMonitor_ = false; onChanged(); return this; @@ -1962,7 +1962,7 @@ public final class LogProxyProto { getConfigurationBytes() { java.lang.Object ref = configuration_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); configuration_ = b; @@ -1985,7 +1985,7 @@ public final class LogProxyProto { if (value == null) { throw new NullPointerException(); } - + configuration_ = value; onChanged(); return this; @@ -1999,7 +1999,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder clearConfiguration() { - + configuration_ = getDefaultInstance().getConfiguration(); onChanged(); return this; @@ -2019,7 +2019,7 @@ public final class LogProxyProto { throw new NullPointerException(); } checkByteStringIsUtf8(value); - + configuration_ = value; onChanged(); return this; @@ -2262,7 +2262,7 @@ public final class LogProxyProto { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); ip_ = s; @@ -2282,7 +2282,7 @@ public final class LogProxyProto { getIpBytes() { java.lang.Object ref = ip_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); ip_ = b; @@ -2308,7 +2308,7 @@ public final class LogProxyProto { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); version_ = s; @@ -2328,7 +2328,7 @@ public final class LogProxyProto { getVersionBytes() { java.lang.Object ref = version_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); version_ = b; @@ -2701,7 +2701,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder setCode(int value) { - + code_ = value; onChanged(); return this; @@ -2715,7 +2715,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder clearCode() { - + code_ = 0; onChanged(); return this; @@ -2754,7 +2754,7 @@ public final class LogProxyProto { getIpBytes() { java.lang.Object ref = ip_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); ip_ = b; @@ -2777,7 +2777,7 @@ public final class LogProxyProto { if (value == null) { throw new NullPointerException(); } - + ip_ = value; onChanged(); return this; @@ -2791,7 +2791,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder clearIp() { - + ip_ = getDefaultInstance().getIp(); onChanged(); return this; @@ -2811,7 +2811,7 @@ public final class LogProxyProto { throw new NullPointerException(); } checkByteStringIsUtf8(value); - + ip_ = value; onChanged(); return this; @@ -2850,7 +2850,7 @@ public final class LogProxyProto { getVersionBytes() { java.lang.Object ref = version_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); version_ = b; @@ -2873,7 +2873,7 @@ public final class LogProxyProto { if (value == null) { throw new NullPointerException(); } - + version_ = value; onChanged(); return this; @@ -2887,7 +2887,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder clearVersion() { - + version_ = getDefaultInstance().getVersion(); onChanged(); return this; @@ -2907,7 +2907,7 @@ public final class LogProxyProto { throw new NullPointerException(); } checkByteStringIsUtf8(value); - + version_ = value; onChanged(); return this; @@ -3138,7 +3138,7 @@ public final class LogProxyProto { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); ip_ = s; @@ -3158,7 +3158,7 @@ public final class LogProxyProto { getIpBytes() { java.lang.Object ref = ip_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); ip_ = b; @@ -3603,7 +3603,7 @@ public final class LogProxyProto { getIpBytes() { java.lang.Object ref = ip_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); ip_ = b; @@ -3626,7 +3626,7 @@ public final class LogProxyProto { if (value == null) { throw new NullPointerException(); } - + ip_ = value; onChanged(); return this; @@ -3640,7 +3640,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder clearIp() { - + ip_ = getDefaultInstance().getIp(); onChanged(); return this; @@ -3660,7 +3660,7 @@ public final class LogProxyProto { throw new NullPointerException(); } checkByteStringIsUtf8(value); - + ip_ = value; onChanged(); return this; @@ -3689,7 +3689,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder setPort(int value) { - + port_ = value; onChanged(); return this; @@ -3703,7 +3703,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder clearPort() { - + port_ = 0; onChanged(); return this; @@ -3732,7 +3732,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder setStreamCount(int value) { - + streamCount_ = value; onChanged(); return this; @@ -3746,7 +3746,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder clearStreamCount() { - + streamCount_ = 0; onChanged(); return this; @@ -3775,7 +3775,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder setWorkerCount(int value) { - + workerCount_ = value; onChanged(); return this; @@ -3789,7 +3789,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder clearWorkerCount() { - + workerCount_ = 0; onChanged(); return this; @@ -4480,7 +4480,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder setCompressType(int value) { - + compressType_ = value; onChanged(); return this; @@ -4494,7 +4494,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder clearCompressType() { - + compressType_ = 0; onChanged(); return this; @@ -4523,7 +4523,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder setRawLen(int value) { - + rawLen_ = value; onChanged(); return this; @@ -4537,7 +4537,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder clearRawLen() { - + rawLen_ = 0; onChanged(); return this; @@ -4566,7 +4566,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder setCompressedLen(int value) { - + compressedLen_ = value; onChanged(); return this; @@ -4580,7 +4580,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder clearCompressedLen() { - + compressedLen_ = 0; onChanged(); return this; @@ -4609,7 +4609,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder setCount(int value) { - + count_ = value; onChanged(); return this; @@ -4623,7 +4623,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder clearCount() { - + count_ = 0; onChanged(); return this; @@ -4655,7 +4655,7 @@ public final class LogProxyProto { if (value == null) { throw new NullPointerException(); } - + records_ = value; onChanged(); return this; @@ -4669,7 +4669,7 @@ public final class LogProxyProto { * @return This builder for chaining. */ public Builder clearRecords() { - + records_ = getDefaultInstance().getRecords(); onChanged(); return this; @@ -4729,27 +4729,27 @@ public final class LogProxyProto { private static final com.google.protobuf.Descriptors.Descriptor internal_static_oceanbase_logproxy_ErrorResponse_descriptor; - private static final + private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_oceanbase_logproxy_ErrorResponse_fieldAccessorTable; private static final com.google.protobuf.Descriptors.Descriptor internal_static_oceanbase_logproxy_ClientHandshakeRequest_descriptor; - private static final + private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_oceanbase_logproxy_ClientHandshakeRequest_fieldAccessorTable; private static final com.google.protobuf.Descriptors.Descriptor internal_static_oceanbase_logproxy_ClientHandshakeResponse_descriptor; - private static final + private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_oceanbase_logproxy_ClientHandshakeResponse_fieldAccessorTable; private static final com.google.protobuf.Descriptors.Descriptor internal_static_oceanbase_logproxy_RuntimeStatus_descriptor; - private static final + private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_oceanbase_logproxy_RuntimeStatus_fieldAccessorTable; private static final com.google.protobuf.Descriptors.Descriptor internal_static_oceanbase_logproxy_RecordData_descriptor; - private static final + private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_oceanbase_logproxy_RecordData_fieldAccessorTable; @@ -4761,22 +4761,21 @@ public final class LogProxyProto { descriptor; static { java.lang.String[] descriptorData = { - "\nRcommon/src/main/java/com/oceanbase/clo" + - "gproxy/common/packet/protocol/logproxy.p" + - "roto\022\022oceanbase.logproxy\".\n\rErrorRespons" + - "e\022\014\n\004code\030\001 \001(\005\022\017\n\007message\030\002 \001(\t\"\202\001\n\026Cli" + - "entHandshakeRequest\022\020\n\010log_type\030\001 \001(\005\022\n\n" + - "\002ip\030\002 \001(\t\022\n\n\002id\030\003 \001(\t\022\017\n\007version\030\004 \001(\t\022\026" + - "\n\016enable_monitor\030\005 \001(\010\022\025\n\rconfiguration\030" + - "\006 \001(\t\"D\n\027ClientHandshakeResponse\022\014\n\004code" + - "\030\001 \001(\005\022\n\n\002ip\030\002 \001(\t\022\017\n\007version\030\003 \001(\t\"U\n\rR" + - "untimeStatus\022\n\n\002ip\030\001 \001(\t\022\014\n\004port\030\002 \001(\005\022\024" + - "\n\014stream_count\030\003 \001(\005\022\024\n\014worker_count\030\004 \001" + - "(\005\"l\n\nRecordData\022\025\n\rcompress_type\030\001 \001(\005\022" + - "\017\n\007raw_len\030\002 \001(\005\022\026\n\016compressed_len\030\003 \001(\005" + - "\022\r\n\005count\030\004 \001(\005\022\017\n\007records\030d \001(\014B?\n.com." + - "oceanbase.clogproxy.common.packet.protoc" + - "olB\rLogProxyProtob\006proto3" + "\n\024proto/logproxy.proto\022\022oceanbase.logpro" + + "xy\".\n\rErrorResponse\022\014\n\004code\030\001 \001(\005\022\017\n\007mes" + + "sage\030\002 \001(\t\"\202\001\n\026ClientHandshakeRequest\022\020\n" + + "\010log_type\030\001 \001(\005\022\n\n\002ip\030\002 \001(\t\022\n\n\002id\030\003 \001(\t\022" + + "\017\n\007version\030\004 \001(\t\022\026\n\016enable_monitor\030\005 \001(\010" + + "\022\025\n\rconfiguration\030\006 \001(\t\"D\n\027ClientHandsha" + + "keResponse\022\014\n\004code\030\001 \001(\005\022\n\n\002ip\030\002 \001(\t\022\017\n\007" + + "version\030\003 \001(\t\"U\n\rRuntimeStatus\022\n\n\002ip\030\001 \001" + + "(\t\022\014\n\004port\030\002 \001(\005\022\024\n\014stream_count\030\003 \001(\005\022\024" + + "\n\014worker_count\030\004 \001(\005\"l\n\nRecordData\022\025\n\rco" + + "mpress_type\030\001 \001(\005\022\017\n\007raw_len\030\002 \001(\005\022\026\n\016co" + + "mpressed_len\030\003 \001(\005\022\r\n\005count\030\004 \001(\005\022\017\n\007rec" + + "ords\030d \001(\014B?\n.com.oceanbase.clogproxy.co" + + "mmon.packet.protocolB\rLogProxyProtob\006pro" + + "to3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, diff --git a/common/src/main/java/com/oceanbase/clogproxy/common/packet/protocol/V1Proto.java b/common/src/main/java/com/oceanbase/clogproxy/common/packet/protocol/V1Proto.java new file mode 100644 index 0000000..88b1b00 --- /dev/null +++ b/common/src/main/java/com/oceanbase/clogproxy/common/packet/protocol/V1Proto.java @@ -0,0 +1,2736 @@ +/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved. +oblogclient is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan PSL v2. +You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: proto/v1.proto + +package com.oceanbase.clogproxy.common.packet.protocol; + +public final class V1Proto { + private V1Proto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface PbPacketOrBuilder extends + // @@protoc_insertion_point(interface_extends:oms.PbPacket) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     * HeaderType
+     * 
+ * + * int32 type = 1; + * @return The type. + */ + int getType(); + + /** + *
+     * CompressType
+     * 
+ * + * int32 compress_type = 2; + * @return The compressType. + */ + int getCompressType(); + + /** + *
+     * resevered for other options
+     * 
+ * + * bytes payload = 100; + * @return The payload. + */ + com.google.protobuf.ByteString getPayload(); + } + /** + * Protobuf type {@code oms.PbPacket} + */ + public static final class PbPacket extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:oms.PbPacket) + PbPacketOrBuilder { + private static final long serialVersionUID = 0L; + // Use PbPacket.newBuilder() to construct. + private PbPacket(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private PbPacket() { + payload_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new PbPacket(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private PbPacket( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + type_ = input.readInt32(); + break; + } + case 16: { + + compressType_ = input.readInt32(); + break; + } + case 802: { + + payload_ = input.readBytes(); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.oceanbase.clogproxy.common.packet.protocol.V1Proto.internal_static_oms_PbPacket_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.oceanbase.clogproxy.common.packet.protocol.V1Proto.internal_static_oms_PbPacket_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket.class, com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket.Builder.class); + } + + public static final int TYPE_FIELD_NUMBER = 1; + private int type_; + /** + *
+     * HeaderType
+     * 
+ * + * int32 type = 1; + * @return The type. + */ + @java.lang.Override + public int getType() { + return type_; + } + + public static final int COMPRESS_TYPE_FIELD_NUMBER = 2; + private int compressType_; + /** + *
+     * CompressType
+     * 
+ * + * int32 compress_type = 2; + * @return The compressType. + */ + @java.lang.Override + public int getCompressType() { + return compressType_; + } + + public static final int PAYLOAD_FIELD_NUMBER = 100; + private com.google.protobuf.ByteString payload_; + /** + *
+     * resevered for other options
+     * 
+ * + * bytes payload = 100; + * @return The payload. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPayload() { + return payload_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (type_ != 0) { + output.writeInt32(1, type_); + } + if (compressType_ != 0) { + output.writeInt32(2, compressType_); + } + if (!payload_.isEmpty()) { + output.writeBytes(100, payload_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (type_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, type_); + } + if (compressType_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, compressType_); + } + if (!payload_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(100, payload_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket)) { + return super.equals(obj); + } + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket other = (com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket) obj; + + if (getType() + != other.getType()) return false; + if (getCompressType() + != other.getCompressType()) return false; + if (!getPayload() + .equals(other.getPayload())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + getType(); + hash = (37 * hash) + COMPRESS_TYPE_FIELD_NUMBER; + hash = (53 * hash) + getCompressType(); + hash = (37 * hash) + PAYLOAD_FIELD_NUMBER; + hash = (53 * hash) + getPayload().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code oms.PbPacket} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:oms.PbPacket) + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacketOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.oceanbase.clogproxy.common.packet.protocol.V1Proto.internal_static_oms_PbPacket_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.oceanbase.clogproxy.common.packet.protocol.V1Proto.internal_static_oms_PbPacket_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket.class, com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket.Builder.class); + } + + // Construct using com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + type_ = 0; + + compressType_ = 0; + + payload_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.oceanbase.clogproxy.common.packet.protocol.V1Proto.internal_static_oms_PbPacket_descriptor; + } + + @java.lang.Override + public com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket getDefaultInstanceForType() { + return com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket.getDefaultInstance(); + } + + @java.lang.Override + public com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket build() { + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket buildPartial() { + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket result = new com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket(this); + result.type_ = type_; + result.compressType_ = compressType_; + result.payload_ = payload_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket) { + return mergeFrom((com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket other) { + if (other == com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket.getDefaultInstance()) return this; + if (other.getType() != 0) { + setType(other.getType()); + } + if (other.getCompressType() != 0) { + setCompressType(other.getCompressType()); + } + if (other.getPayload() != com.google.protobuf.ByteString.EMPTY) { + setPayload(other.getPayload()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int type_ ; + /** + *
+       * HeaderType
+       * 
+ * + * int32 type = 1; + * @return The type. + */ + @java.lang.Override + public int getType() { + return type_; + } + /** + *
+       * HeaderType
+       * 
+ * + * int32 type = 1; + * @param value The type to set. + * @return This builder for chaining. + */ + public Builder setType(int value) { + + type_ = value; + onChanged(); + return this; + } + /** + *
+       * HeaderType
+       * 
+ * + * int32 type = 1; + * @return This builder for chaining. + */ + public Builder clearType() { + + type_ = 0; + onChanged(); + return this; + } + + private int compressType_ ; + /** + *
+       * CompressType
+       * 
+ * + * int32 compress_type = 2; + * @return The compressType. + */ + @java.lang.Override + public int getCompressType() { + return compressType_; + } + /** + *
+       * CompressType
+       * 
+ * + * int32 compress_type = 2; + * @param value The compressType to set. + * @return This builder for chaining. + */ + public Builder setCompressType(int value) { + + compressType_ = value; + onChanged(); + return this; + } + /** + *
+       * CompressType
+       * 
+ * + * int32 compress_type = 2; + * @return This builder for chaining. + */ + public Builder clearCompressType() { + + compressType_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString payload_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+       * resevered for other options
+       * 
+ * + * bytes payload = 100; + * @return The payload. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPayload() { + return payload_; + } + /** + *
+       * resevered for other options
+       * 
+ * + * bytes payload = 100; + * @param value The payload to set. + * @return This builder for chaining. + */ + public Builder setPayload(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + payload_ = value; + onChanged(); + return this; + } + /** + *
+       * resevered for other options
+       * 
+ * + * bytes payload = 100; + * @return This builder for chaining. + */ + public Builder clearPayload() { + + payload_ = getDefaultInstance().getPayload(); + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:oms.PbPacket) + } + + // @@protoc_insertion_point(class_scope:oms.PbPacket) + private static final com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket(); + } + + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PbPacket parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PbPacket(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.oceanbase.clogproxy.common.packet.protocol.V1Proto.PbPacket getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ClientHandShakeOrBuilder extends + // @@protoc_insertion_point(interface_extends:oms.ClientHandShake) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     * LogType
+     * 
+ * + * int32 log_type = 1; + * @return The logType. + */ + int getLogType(); + + /** + * string client_ip = 2; + * @return The clientIp. + */ + java.lang.String getClientIp(); + /** + * string client_ip = 2; + * @return The bytes for clientIp. + */ + com.google.protobuf.ByteString + getClientIpBytes(); + + /** + * string client_id = 3; + * @return The clientId. + */ + java.lang.String getClientId(); + /** + * string client_id = 3; + * @return The bytes for clientId. + */ + com.google.protobuf.ByteString + getClientIdBytes(); + + /** + * string client_version = 4; + * @return The clientVersion. + */ + java.lang.String getClientVersion(); + /** + * string client_version = 4; + * @return The bytes for clientVersion. + */ + com.google.protobuf.ByteString + getClientVersionBytes(); + + /** + * bool enable_monitor = 5; + * @return The enableMonitor. + */ + boolean getEnableMonitor(); + + /** + * string configuration = 6; + * @return The configuration. + */ + java.lang.String getConfiguration(); + /** + * string configuration = 6; + * @return The bytes for configuration. + */ + com.google.protobuf.ByteString + getConfigurationBytes(); + } + /** + * Protobuf type {@code oms.ClientHandShake} + */ + public static final class ClientHandShake extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:oms.ClientHandShake) + ClientHandShakeOrBuilder { + private static final long serialVersionUID = 0L; + // Use ClientHandShake.newBuilder() to construct. + private ClientHandShake(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ClientHandShake() { + clientIp_ = ""; + clientId_ = ""; + clientVersion_ = ""; + configuration_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new ClientHandShake(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ClientHandShake( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + logType_ = input.readInt32(); + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + clientIp_ = s; + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + clientId_ = s; + break; + } + case 34: { + java.lang.String s = input.readStringRequireUtf8(); + + clientVersion_ = s; + break; + } + case 40: { + + enableMonitor_ = input.readBool(); + break; + } + case 50: { + java.lang.String s = input.readStringRequireUtf8(); + + configuration_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.oceanbase.clogproxy.common.packet.protocol.V1Proto.internal_static_oms_ClientHandShake_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.oceanbase.clogproxy.common.packet.protocol.V1Proto.internal_static_oms_ClientHandShake_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake.class, com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake.Builder.class); + } + + public static final int LOG_TYPE_FIELD_NUMBER = 1; + private int logType_; + /** + *
+     * LogType
+     * 
+ * + * int32 log_type = 1; + * @return The logType. + */ + @java.lang.Override + public int getLogType() { + return logType_; + } + + public static final int CLIENT_IP_FIELD_NUMBER = 2; + private volatile java.lang.Object clientIp_; + /** + * string client_ip = 2; + * @return The clientIp. + */ + @java.lang.Override + public java.lang.String getClientIp() { + java.lang.Object ref = clientIp_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + clientIp_ = s; + return s; + } + } + /** + * string client_ip = 2; + * @return The bytes for clientIp. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getClientIpBytes() { + java.lang.Object ref = clientIp_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + clientIp_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CLIENT_ID_FIELD_NUMBER = 3; + private volatile java.lang.Object clientId_; + /** + * string client_id = 3; + * @return The clientId. + */ + @java.lang.Override + public java.lang.String getClientId() { + java.lang.Object ref = clientId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + clientId_ = s; + return s; + } + } + /** + * string client_id = 3; + * @return The bytes for clientId. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getClientIdBytes() { + java.lang.Object ref = clientId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + clientId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CLIENT_VERSION_FIELD_NUMBER = 4; + private volatile java.lang.Object clientVersion_; + /** + * string client_version = 4; + * @return The clientVersion. + */ + @java.lang.Override + public java.lang.String getClientVersion() { + java.lang.Object ref = clientVersion_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + clientVersion_ = s; + return s; + } + } + /** + * string client_version = 4; + * @return The bytes for clientVersion. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getClientVersionBytes() { + java.lang.Object ref = clientVersion_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + clientVersion_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ENABLE_MONITOR_FIELD_NUMBER = 5; + private boolean enableMonitor_; + /** + * bool enable_monitor = 5; + * @return The enableMonitor. + */ + @java.lang.Override + public boolean getEnableMonitor() { + return enableMonitor_; + } + + public static final int CONFIGURATION_FIELD_NUMBER = 6; + private volatile java.lang.Object configuration_; + /** + * string configuration = 6; + * @return The configuration. + */ + @java.lang.Override + public java.lang.String getConfiguration() { + java.lang.Object ref = configuration_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + configuration_ = s; + return s; + } + } + /** + * string configuration = 6; + * @return The bytes for configuration. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getConfigurationBytes() { + java.lang.Object ref = configuration_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + configuration_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (logType_ != 0) { + output.writeInt32(1, logType_); + } + if (!getClientIpBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, clientIp_); + } + if (!getClientIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, clientId_); + } + if (!getClientVersionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, clientVersion_); + } + if (enableMonitor_ != false) { + output.writeBool(5, enableMonitor_); + } + if (!getConfigurationBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, configuration_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (logType_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, logType_); + } + if (!getClientIpBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, clientIp_); + } + if (!getClientIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, clientId_); + } + if (!getClientVersionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, clientVersion_); + } + if (enableMonitor_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(5, enableMonitor_); + } + if (!getConfigurationBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, configuration_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake)) { + return super.equals(obj); + } + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake other = (com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake) obj; + + if (getLogType() + != other.getLogType()) return false; + if (!getClientIp() + .equals(other.getClientIp())) return false; + if (!getClientId() + .equals(other.getClientId())) return false; + if (!getClientVersion() + .equals(other.getClientVersion())) return false; + if (getEnableMonitor() + != other.getEnableMonitor()) return false; + if (!getConfiguration() + .equals(other.getConfiguration())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + LOG_TYPE_FIELD_NUMBER; + hash = (53 * hash) + getLogType(); + hash = (37 * hash) + CLIENT_IP_FIELD_NUMBER; + hash = (53 * hash) + getClientIp().hashCode(); + hash = (37 * hash) + CLIENT_ID_FIELD_NUMBER; + hash = (53 * hash) + getClientId().hashCode(); + hash = (37 * hash) + CLIENT_VERSION_FIELD_NUMBER; + hash = (53 * hash) + getClientVersion().hashCode(); + hash = (37 * hash) + ENABLE_MONITOR_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getEnableMonitor()); + hash = (37 * hash) + CONFIGURATION_FIELD_NUMBER; + hash = (53 * hash) + getConfiguration().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code oms.ClientHandShake} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:oms.ClientHandShake) + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShakeOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.oceanbase.clogproxy.common.packet.protocol.V1Proto.internal_static_oms_ClientHandShake_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.oceanbase.clogproxy.common.packet.protocol.V1Proto.internal_static_oms_ClientHandShake_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake.class, com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake.Builder.class); + } + + // Construct using com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + logType_ = 0; + + clientIp_ = ""; + + clientId_ = ""; + + clientVersion_ = ""; + + enableMonitor_ = false; + + configuration_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.oceanbase.clogproxy.common.packet.protocol.V1Proto.internal_static_oms_ClientHandShake_descriptor; + } + + @java.lang.Override + public com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake getDefaultInstanceForType() { + return com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake.getDefaultInstance(); + } + + @java.lang.Override + public com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake build() { + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake buildPartial() { + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake result = new com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake(this); + result.logType_ = logType_; + result.clientIp_ = clientIp_; + result.clientId_ = clientId_; + result.clientVersion_ = clientVersion_; + result.enableMonitor_ = enableMonitor_; + result.configuration_ = configuration_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake) { + return mergeFrom((com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake other) { + if (other == com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake.getDefaultInstance()) return this; + if (other.getLogType() != 0) { + setLogType(other.getLogType()); + } + if (!other.getClientIp().isEmpty()) { + clientIp_ = other.clientIp_; + onChanged(); + } + if (!other.getClientId().isEmpty()) { + clientId_ = other.clientId_; + onChanged(); + } + if (!other.getClientVersion().isEmpty()) { + clientVersion_ = other.clientVersion_; + onChanged(); + } + if (other.getEnableMonitor() != false) { + setEnableMonitor(other.getEnableMonitor()); + } + if (!other.getConfiguration().isEmpty()) { + configuration_ = other.configuration_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int logType_ ; + /** + *
+       * LogType
+       * 
+ * + * int32 log_type = 1; + * @return The logType. + */ + @java.lang.Override + public int getLogType() { + return logType_; + } + /** + *
+       * LogType
+       * 
+ * + * int32 log_type = 1; + * @param value The logType to set. + * @return This builder for chaining. + */ + public Builder setLogType(int value) { + + logType_ = value; + onChanged(); + return this; + } + /** + *
+       * LogType
+       * 
+ * + * int32 log_type = 1; + * @return This builder for chaining. + */ + public Builder clearLogType() { + + logType_ = 0; + onChanged(); + return this; + } + + private java.lang.Object clientIp_ = ""; + /** + * string client_ip = 2; + * @return The clientIp. + */ + public java.lang.String getClientIp() { + java.lang.Object ref = clientIp_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + clientIp_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string client_ip = 2; + * @return The bytes for clientIp. + */ + public com.google.protobuf.ByteString + getClientIpBytes() { + java.lang.Object ref = clientIp_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + clientIp_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string client_ip = 2; + * @param value The clientIp to set. + * @return This builder for chaining. + */ + public Builder setClientIp( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + clientIp_ = value; + onChanged(); + return this; + } + /** + * string client_ip = 2; + * @return This builder for chaining. + */ + public Builder clearClientIp() { + + clientIp_ = getDefaultInstance().getClientIp(); + onChanged(); + return this; + } + /** + * string client_ip = 2; + * @param value The bytes for clientIp to set. + * @return This builder for chaining. + */ + public Builder setClientIpBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + clientIp_ = value; + onChanged(); + return this; + } + + private java.lang.Object clientId_ = ""; + /** + * string client_id = 3; + * @return The clientId. + */ + public java.lang.String getClientId() { + java.lang.Object ref = clientId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + clientId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string client_id = 3; + * @return The bytes for clientId. + */ + public com.google.protobuf.ByteString + getClientIdBytes() { + java.lang.Object ref = clientId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + clientId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string client_id = 3; + * @param value The clientId to set. + * @return This builder for chaining. + */ + public Builder setClientId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + clientId_ = value; + onChanged(); + return this; + } + /** + * string client_id = 3; + * @return This builder for chaining. + */ + public Builder clearClientId() { + + clientId_ = getDefaultInstance().getClientId(); + onChanged(); + return this; + } + /** + * string client_id = 3; + * @param value The bytes for clientId to set. + * @return This builder for chaining. + */ + public Builder setClientIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + clientId_ = value; + onChanged(); + return this; + } + + private java.lang.Object clientVersion_ = ""; + /** + * string client_version = 4; + * @return The clientVersion. + */ + public java.lang.String getClientVersion() { + java.lang.Object ref = clientVersion_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + clientVersion_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string client_version = 4; + * @return The bytes for clientVersion. + */ + public com.google.protobuf.ByteString + getClientVersionBytes() { + java.lang.Object ref = clientVersion_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + clientVersion_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string client_version = 4; + * @param value The clientVersion to set. + * @return This builder for chaining. + */ + public Builder setClientVersion( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + clientVersion_ = value; + onChanged(); + return this; + } + /** + * string client_version = 4; + * @return This builder for chaining. + */ + public Builder clearClientVersion() { + + clientVersion_ = getDefaultInstance().getClientVersion(); + onChanged(); + return this; + } + /** + * string client_version = 4; + * @param value The bytes for clientVersion to set. + * @return This builder for chaining. + */ + public Builder setClientVersionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + clientVersion_ = value; + onChanged(); + return this; + } + + private boolean enableMonitor_ ; + /** + * bool enable_monitor = 5; + * @return The enableMonitor. + */ + @java.lang.Override + public boolean getEnableMonitor() { + return enableMonitor_; + } + /** + * bool enable_monitor = 5; + * @param value The enableMonitor to set. + * @return This builder for chaining. + */ + public Builder setEnableMonitor(boolean value) { + + enableMonitor_ = value; + onChanged(); + return this; + } + /** + * bool enable_monitor = 5; + * @return This builder for chaining. + */ + public Builder clearEnableMonitor() { + + enableMonitor_ = false; + onChanged(); + return this; + } + + private java.lang.Object configuration_ = ""; + /** + * string configuration = 6; + * @return The configuration. + */ + public java.lang.String getConfiguration() { + java.lang.Object ref = configuration_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + configuration_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string configuration = 6; + * @return The bytes for configuration. + */ + public com.google.protobuf.ByteString + getConfigurationBytes() { + java.lang.Object ref = configuration_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + configuration_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string configuration = 6; + * @param value The configuration to set. + * @return This builder for chaining. + */ + public Builder setConfiguration( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + configuration_ = value; + onChanged(); + return this; + } + /** + * string configuration = 6; + * @return This builder for chaining. + */ + public Builder clearConfiguration() { + + configuration_ = getDefaultInstance().getConfiguration(); + onChanged(); + return this; + } + /** + * string configuration = 6; + * @param value The bytes for configuration to set. + * @return This builder for chaining. + */ + public Builder setConfigurationBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + configuration_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:oms.ClientHandShake) + } + + // @@protoc_insertion_point(class_scope:oms.ClientHandShake) + private static final com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake(); + } + + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ClientHandShake parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ClientHandShake(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.oceanbase.clogproxy.common.packet.protocol.V1Proto.ClientHandShake getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface RuntimeStatusOrBuilder extends + // @@protoc_insertion_point(interface_extends:oms.RuntimeStatus) + com.google.protobuf.MessageOrBuilder { + + /** + * string ip = 1; + * @return The ip. + */ + java.lang.String getIp(); + /** + * string ip = 1; + * @return The bytes for ip. + */ + com.google.protobuf.ByteString + getIpBytes(); + + /** + * int32 port = 2; + * @return The port. + */ + int getPort(); + + /** + * int32 stream_count = 3; + * @return The streamCount. + */ + int getStreamCount(); + + /** + * int32 worker_count = 4; + * @return The workerCount. + */ + int getWorkerCount(); + } + /** + * Protobuf type {@code oms.RuntimeStatus} + */ + public static final class RuntimeStatus extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:oms.RuntimeStatus) + RuntimeStatusOrBuilder { + private static final long serialVersionUID = 0L; + // Use RuntimeStatus.newBuilder() to construct. + private RuntimeStatus(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private RuntimeStatus() { + ip_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new RuntimeStatus(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private RuntimeStatus( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + ip_ = s; + break; + } + case 16: { + + port_ = input.readInt32(); + break; + } + case 24: { + + streamCount_ = input.readInt32(); + break; + } + case 32: { + + workerCount_ = input.readInt32(); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.oceanbase.clogproxy.common.packet.protocol.V1Proto.internal_static_oms_RuntimeStatus_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.oceanbase.clogproxy.common.packet.protocol.V1Proto.internal_static_oms_RuntimeStatus_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus.class, com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus.Builder.class); + } + + public static final int IP_FIELD_NUMBER = 1; + private volatile java.lang.Object ip_; + /** + * string ip = 1; + * @return The ip. + */ + @java.lang.Override + public java.lang.String getIp() { + java.lang.Object ref = ip_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + ip_ = s; + return s; + } + } + /** + * string ip = 1; + * @return The bytes for ip. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getIpBytes() { + java.lang.Object ref = ip_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + ip_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PORT_FIELD_NUMBER = 2; + private int port_; + /** + * int32 port = 2; + * @return The port. + */ + @java.lang.Override + public int getPort() { + return port_; + } + + public static final int STREAM_COUNT_FIELD_NUMBER = 3; + private int streamCount_; + /** + * int32 stream_count = 3; + * @return The streamCount. + */ + @java.lang.Override + public int getStreamCount() { + return streamCount_; + } + + public static final int WORKER_COUNT_FIELD_NUMBER = 4; + private int workerCount_; + /** + * int32 worker_count = 4; + * @return The workerCount. + */ + @java.lang.Override + public int getWorkerCount() { + return workerCount_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getIpBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, ip_); + } + if (port_ != 0) { + output.writeInt32(2, port_); + } + if (streamCount_ != 0) { + output.writeInt32(3, streamCount_); + } + if (workerCount_ != 0) { + output.writeInt32(4, workerCount_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getIpBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, ip_); + } + if (port_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, port_); + } + if (streamCount_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, streamCount_); + } + if (workerCount_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(4, workerCount_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus)) { + return super.equals(obj); + } + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus other = (com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus) obj; + + if (!getIp() + .equals(other.getIp())) return false; + if (getPort() + != other.getPort()) return false; + if (getStreamCount() + != other.getStreamCount()) return false; + if (getWorkerCount() + != other.getWorkerCount()) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + IP_FIELD_NUMBER; + hash = (53 * hash) + getIp().hashCode(); + hash = (37 * hash) + PORT_FIELD_NUMBER; + hash = (53 * hash) + getPort(); + hash = (37 * hash) + STREAM_COUNT_FIELD_NUMBER; + hash = (53 * hash) + getStreamCount(); + hash = (37 * hash) + WORKER_COUNT_FIELD_NUMBER; + hash = (53 * hash) + getWorkerCount(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code oms.RuntimeStatus} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:oms.RuntimeStatus) + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatusOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.oceanbase.clogproxy.common.packet.protocol.V1Proto.internal_static_oms_RuntimeStatus_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.oceanbase.clogproxy.common.packet.protocol.V1Proto.internal_static_oms_RuntimeStatus_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus.class, com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus.Builder.class); + } + + // Construct using com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + ip_ = ""; + + port_ = 0; + + streamCount_ = 0; + + workerCount_ = 0; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.oceanbase.clogproxy.common.packet.protocol.V1Proto.internal_static_oms_RuntimeStatus_descriptor; + } + + @java.lang.Override + public com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus getDefaultInstanceForType() { + return com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus.getDefaultInstance(); + } + + @java.lang.Override + public com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus build() { + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus buildPartial() { + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus result = new com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus(this); + result.ip_ = ip_; + result.port_ = port_; + result.streamCount_ = streamCount_; + result.workerCount_ = workerCount_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus) { + return mergeFrom((com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus other) { + if (other == com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus.getDefaultInstance()) return this; + if (!other.getIp().isEmpty()) { + ip_ = other.ip_; + onChanged(); + } + if (other.getPort() != 0) { + setPort(other.getPort()); + } + if (other.getStreamCount() != 0) { + setStreamCount(other.getStreamCount()); + } + if (other.getWorkerCount() != 0) { + setWorkerCount(other.getWorkerCount()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object ip_ = ""; + /** + * string ip = 1; + * @return The ip. + */ + public java.lang.String getIp() { + java.lang.Object ref = ip_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + ip_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string ip = 1; + * @return The bytes for ip. + */ + public com.google.protobuf.ByteString + getIpBytes() { + java.lang.Object ref = ip_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + ip_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string ip = 1; + * @param value The ip to set. + * @return This builder for chaining. + */ + public Builder setIp( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + ip_ = value; + onChanged(); + return this; + } + /** + * string ip = 1; + * @return This builder for chaining. + */ + public Builder clearIp() { + + ip_ = getDefaultInstance().getIp(); + onChanged(); + return this; + } + /** + * string ip = 1; + * @param value The bytes for ip to set. + * @return This builder for chaining. + */ + public Builder setIpBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + ip_ = value; + onChanged(); + return this; + } + + private int port_ ; + /** + * int32 port = 2; + * @return The port. + */ + @java.lang.Override + public int getPort() { + return port_; + } + /** + * int32 port = 2; + * @param value The port to set. + * @return This builder for chaining. + */ + public Builder setPort(int value) { + + port_ = value; + onChanged(); + return this; + } + /** + * int32 port = 2; + * @return This builder for chaining. + */ + public Builder clearPort() { + + port_ = 0; + onChanged(); + return this; + } + + private int streamCount_ ; + /** + * int32 stream_count = 3; + * @return The streamCount. + */ + @java.lang.Override + public int getStreamCount() { + return streamCount_; + } + /** + * int32 stream_count = 3; + * @param value The streamCount to set. + * @return This builder for chaining. + */ + public Builder setStreamCount(int value) { + + streamCount_ = value; + onChanged(); + return this; + } + /** + * int32 stream_count = 3; + * @return This builder for chaining. + */ + public Builder clearStreamCount() { + + streamCount_ = 0; + onChanged(); + return this; + } + + private int workerCount_ ; + /** + * int32 worker_count = 4; + * @return The workerCount. + */ + @java.lang.Override + public int getWorkerCount() { + return workerCount_; + } + /** + * int32 worker_count = 4; + * @param value The workerCount to set. + * @return This builder for chaining. + */ + public Builder setWorkerCount(int value) { + + workerCount_ = value; + onChanged(); + return this; + } + /** + * int32 worker_count = 4; + * @return This builder for chaining. + */ + public Builder clearWorkerCount() { + + workerCount_ = 0; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:oms.RuntimeStatus) + } + + // @@protoc_insertion_point(class_scope:oms.RuntimeStatus) + private static final com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus(); + } + + public static com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public RuntimeStatus parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new RuntimeStatus(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.oceanbase.clogproxy.common.packet.protocol.V1Proto.RuntimeStatus getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_oms_PbPacket_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_oms_PbPacket_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_oms_ClientHandShake_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_oms_ClientHandShake_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_oms_RuntimeStatus_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_oms_RuntimeStatus_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\016proto/v1.proto\022\003oms\"@\n\010PbPacket\022\014\n\004typ" + + "e\030\001 \001(\005\022\025\n\rcompress_type\030\002 \001(\005\022\017\n\007payloa" + + "d\030d \001(\014\"\220\001\n\017ClientHandShake\022\020\n\010log_type\030" + + "\001 \001(\005\022\021\n\tclient_ip\030\002 \001(\t\022\021\n\tclient_id\030\003 " + + "\001(\t\022\026\n\016client_version\030\004 \001(\t\022\026\n\016enable_mo" + + "nitor\030\005 \001(\010\022\025\n\rconfiguration\030\006 \001(\t\"U\n\rRu" + + "ntimeStatus\022\n\n\002ip\030\001 \001(\t\022\014\n\004port\030\002 \001(\005\022\024\n" + + "\014stream_count\030\003 \001(\005\022\024\n\014worker_count\030\004 \001(" + + "\005B9\n.com.oceanbase.clogproxy.common.pack" + + "et.protocolB\007V1Protob\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }); + internal_static_oms_PbPacket_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_oms_PbPacket_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_oms_PbPacket_descriptor, + new java.lang.String[] { "Type", "CompressType", "Payload", }); + internal_static_oms_ClientHandShake_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_oms_ClientHandShake_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_oms_ClientHandShake_descriptor, + new java.lang.String[] { "LogType", "ClientIp", "ClientId", "ClientVersion", "EnableMonitor", "Configuration", }); + internal_static_oms_RuntimeStatus_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_oms_RuntimeStatus_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_oms_RuntimeStatus_descriptor, + new java.lang.String[] { "Ip", "Port", "StreamCount", "WorkerCount", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/common/src/main/java/com/oceanbase/clogproxy/common/util/CryptoUtil.java b/common/src/main/java/com/oceanbase/clogproxy/common/util/CryptoUtil.java index 2765b83..6b567a9 100644 --- a/common/src/main/java/com/oceanbase/clogproxy/common/util/CryptoUtil.java +++ b/common/src/main/java/com/oceanbase/clogproxy/common/util/CryptoUtil.java @@ -90,7 +90,6 @@ public class CryptoUtil { System.arraycopy(cipherBytes, 0, iv, 0, Math.min(iv.length, cipherBytes.length)); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { - System.out.println("failed to init AES key generator, exit!!! : " + e); System.exit(-1); } } @@ -112,7 +111,6 @@ public class CryptoUtil { | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException e) { - System.out.println("failed to encrypt AES 256 GCM: " + e); return null; } } @@ -134,7 +132,6 @@ public class CryptoUtil { | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException e) { - System.out.println("failed to decrypt AES 256 GCM: " + e); return ""; } } diff --git a/common/src/main/java/com/oceanbase/oms/common/enums/DbTypeEnum.java b/common/src/main/java/com/oceanbase/oms/common/enums/DbTypeEnum.java index cff17fa..5c4aece 100644 --- a/common/src/main/java/com/oceanbase/oms/common/enums/DbTypeEnum.java +++ b/common/src/main/java/com/oceanbase/oms/common/enums/DbTypeEnum.java @@ -33,6 +33,11 @@ public enum DbTypeEnum { DbCategoryEnum.RDB, new HashSet<>(Arrays.asList("oceanbase_oracle_mode", "ob_in_oracle_mode"))), + MYSQL(DbCategoryEnum.RDB), + ORACLE(DbCategoryEnum.RDB), + DB2_LUW(DbCategoryEnum.RDB, Collections.singleton("db2")), + POSTGRESQL(DbCategoryEnum.RDB), + HBASE(DbCategoryEnum.NOSQL), UNKNOWN(null); DbTypeEnum(DbCategoryEnum category) { diff --git a/common/src/main/java/com/oceanbase/oms/logmessage/DataMessage.java b/common/src/main/java/com/oceanbase/oms/logmessage/DataMessage.java index 4033198..bcd5421 100644 --- a/common/src/main/java/com/oceanbase/oms/logmessage/DataMessage.java +++ b/common/src/main/java/com/oceanbase/oms/logmessage/DataMessage.java @@ -776,6 +776,9 @@ public class DataMessage extends Message { DbTypeEnum dbType = getDbType(); this.checkDBType(dbType); StringBuilder messageId = new StringBuilder(); + if (dbType == DbTypeEnum.MYSQL) { + messageId.append(getServerId()); + } messageId.append("/").append(this.getCommonPart()).append("/"); if (dbType == DbTypeEnum.OB_MYSQL || dbType == DbTypeEnum.OB_ORACLE) { @@ -799,6 +802,9 @@ public class DataMessage extends Message { private void checkDBType(DbTypeEnum dbType) { switch (dbType) { + case MYSQL: + case ORACLE: + case DB2_LUW: case OB_MYSQL: case OB_ORACLE: case OB_05: @@ -918,20 +924,40 @@ public class DataMessage extends Message { if (StringUtils.isEmpty(dbTypeInStr)) { return DbTypeEnum.UNKNOWN; } - if ("oceanbase".equalsIgnoreCase(dbTypeInStr)) { + if ("mysql".equalsIgnoreCase(dbTypeInStr)) { + return DbTypeEnum.MYSQL; + } else if ("oceanbase".equalsIgnoreCase(dbTypeInStr)) { return DbTypeEnum.OB_05; + } else if ("oracle".equalsIgnoreCase(dbTypeInStr)) { + return DbTypeEnum.ORACLE; + } else if ("hbase".equalsIgnoreCase(dbTypeInStr)) { + return DbTypeEnum.HBASE; } else if ("oceanbase_1_0".equalsIgnoreCase(dbTypeInStr)) { return DbTypeEnum.OB_MYSQL; + } else if ("db2".equalsIgnoreCase(dbTypeInStr)) { + return DbTypeEnum.DB2_LUW; + } else if ("postgresql".equalsIgnoreCase(dbTypeInStr)) { + return DbTypeEnum.POSTGRESQL; } return DbTypeEnum.UNKNOWN; } public static DbTypeEnum parseDBTypeCode(int dbTypeCode) { switch (dbTypeCode) { + case 0: + return DbTypeEnum.MYSQL; case 1: return DbTypeEnum.OB_05; + case 2: + return DbTypeEnum.HBASE; + case 3: + return DbTypeEnum.ORACLE; case 4: return DbTypeEnum.OB_MYSQL; + case 5: + return DbTypeEnum.DB2_LUW; + case 6: + return DbTypeEnum.POSTGRESQL; default: return DbTypeEnum.UNKNOWN; } diff --git a/common/src/main/java/com/oceanbase/oms/logmessage/LogMessage.java b/common/src/main/java/com/oceanbase/oms/logmessage/LogMessage.java index 858c024..6c3d800 100644 --- a/common/src/main/java/com/oceanbase/oms/logmessage/LogMessage.java +++ b/common/src/main/java/com/oceanbase/oms/logmessage/LogMessage.java @@ -1014,6 +1014,8 @@ public class LogMessage extends DataMessage.Record { case UPDATE: case INDEX_UPDATE: switch (getDbType()) { + case ORACLE: + case MYSQL: case OB_MYSQL: case OB_ORACLE: prev.addAll(getKeys((int) oldColsOffset, keys)); diff --git a/common/src/main/java/com/oceanbase/oms/logmessage/typehelper/DB2LogTypeHelper.java b/common/src/main/java/com/oceanbase/oms/logmessage/typehelper/DB2LogTypeHelper.java new file mode 100644 index 0000000..2ec972d --- /dev/null +++ b/common/src/main/java/com/oceanbase/oms/logmessage/typehelper/DB2LogTypeHelper.java @@ -0,0 +1,61 @@ +/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved. +oblogclient is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan PSL v2. +You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. */ + +package com.oceanbase.oms.logmessage.typehelper; + +import static com.oceanbase.oms.logmessage.LogMessage.UTF8_ENCODING; + +import com.oceanbase.oms.common.enums.DbTypeEnum; +import com.oceanbase.oms.logmessage.DataMessage; + +public class DB2LogTypeHelper extends LogTypeHelper { + public static final DB2LogTypeHelper DB2_LOG_TYPE_HELPER = new DB2LogTypeHelper(); + + public DB2LogTypeHelper() { + super(DbTypeEnum.DB2_LUW); + } + + @Override + public String correctEncoding(int typeCode, String realEncoding) { + switch (typeCode) { + case LogMessageTypeCode.LOG_MSG_TYPE_BINARY: + case LogMessageTypeCode.LOG_MSG_TYPE_BLOB: + case LogMessageTypeCode.LOG_MSG_TYPE_TINY_BLOB: + case LogMessageTypeCode.LOG_MSG_TYPE_VAR_BINARY: + return EMPTY_ENCODING_STR; + default: + return UTF8_ENCODING; + } + } + + @Override + public int correctCode(int typeCode, String encoding) { + if (typeCode == LogMessageTypeCode.LOG_MSG_TYPE_TINY_BLOB) { + return LogMessageTypeCode.LOG_MSG_TYPE_VAR_BINARY; + } else { + return typeCode; + } + } + + @Override + public void correctField(DataMessage.Record.Field f, String realEncoding) { + switch (f.type) { + case LogMessageTypeCode.LOG_MSG_TYPE_BINARY: + case LogMessageTypeCode.LOG_MSG_TYPE_BLOB: + case LogMessageTypeCode.LOG_MSG_TYPE_VAR_BINARY: + f.encoding = EMPTY_ENCODING_STR; + break; + case LogMessageTypeCode.LOG_MSG_TYPE_TINY_BLOB: + f.encoding = EMPTY_ENCODING_STR; + f.type = LogMessageTypeCode.LOG_MSG_TYPE_VAR_BINARY; + break; + } + } +} diff --git a/common/src/main/java/com/oceanbase/oms/logmessage/typehelper/LogMessageTypeCode.java b/common/src/main/java/com/oceanbase/oms/logmessage/typehelper/LogMessageTypeCode.java index 8a3b9d5..603611d 100644 --- a/common/src/main/java/com/oceanbase/oms/logmessage/typehelper/LogMessageTypeCode.java +++ b/common/src/main/java/com/oceanbase/oms/logmessage/typehelper/LogMessageTypeCode.java @@ -71,4 +71,42 @@ public class LogMessageTypeCode { public static final int LOG_MSG_TYPE_ORA_BINARY_FLOAT = 256; public static final int LOG_MSG_TYPE_ORA_BINARY_DOUBLE = 257; public static final int LOG_MSG_TYPE_UNKNOWN = LOG_MSG_TYPE_ORA_BINARY_DOUBLE + 1; + + // type code for xlog + public static final int XLOG_MSG_TYPE_SHORT = 50; + public static final int XLOG_MSG_TYPE_INT = 51; + public static final int XLOG_MSG_TYPE_LONG = 52; + public static final int XLOG_MSG_TYPE_DECIMAL = 53; + public static final int XLOG_MSG_TYPE_FLOAT = 54; + public static final int XLOG_MSG_TYPE_DOUBLE = 55; + public static final int XLOG_MSG_TYPE_BOOLEAN = 56; + public static final int XLOG_MSG_TYPE_TINY = 57; + public static final int XLOG_MSG_TYPE_LONGLONG = 58; + public static final int XLOG_MSG_TYPE_CHAR = 70; + public static final int XLOG_MSG_TYPE_VARCHAR = 71; + public static final int XLOG_MSG_TYPE_BINARY = 72; + public static final int XLOG_MSG_TYPE_JSON = 73; + public static final int XLOG_MSG_TYPE_CLOB = 74; + public static final int XLOG_MSG_TYPE_ENUM = 75; + public static final int XLOG_MSG_TYPE_SET = 76; + public static final int XLOG_MSG_TYPE_UUID = 77; + public static final int XLOG_MSG_TYPE_ROWID = 78; + public static final int XLOG_MSG_TYPE_VARBINARY = 79; + public static final int XLOG_MSG_TYPE_TIMESTAMP = 80; + public static final int XLOG_MSG_TYPE_TIMESTAMP_WITH_TIME_ZONE = 81; + public static final int XLOG_MSG_TYPE_DATE = 82; + public static final int XLOG_MSG_TYPE_TIME = 83; + public static final int XLOG_MSG_TYPE_TIME_WITH_TIME_ZONE = 84; + public static final int XLOG_MSG_TYPE_INSTANT = 85; + public static final int XLOG_MSG_TYPE_YEAR = 86; + public static final int XLOG_MSG_TYPE_INTERVAL_YEAR_TO_MONTH = 87; + public static final int XLOG_MSG_TYPE_INTERVAL_DAY_TO_SECOND = 88; + public static final int XLOG_MSG_TYPE_INTERVAL_YEAR_TO_SECOND = 89; + public static final int XLOG_MSG_TYPE_XML = 90; + public static final int XLOG_MSG_TYPE_BITMAP = 91; + public static final int XLOG_MSG_TYPE_GEOMETRY_EWKT = 92; + public static final int XLOG_MSG_TYPE_GEOMETRY_EWKB = 93; + public static final int XLOG_MSG_TYPE_GEOGRAPHY_EWKT = 94; + public static final int XLOG_MSG_TYPE_GEOGRAPHY_EWKB = 95; + public static final int XLOG_MSG_TYPE_BLOB = 102; } diff --git a/common/src/main/java/com/oceanbase/oms/logmessage/typehelper/LogTypeHelperFactory.java b/common/src/main/java/com/oceanbase/oms/logmessage/typehelper/LogTypeHelperFactory.java index 439b9ed..df9adc9 100644 --- a/common/src/main/java/com/oceanbase/oms/logmessage/typehelper/LogTypeHelperFactory.java +++ b/common/src/main/java/com/oceanbase/oms/logmessage/typehelper/LogTypeHelperFactory.java @@ -21,6 +21,14 @@ public abstract class LogTypeHelperFactory { case OB_ORACLE: case OB_05: return OBLogTypeHelper.OB_LOG_TYPE_HELPER; + case MYSQL: + return MySQLLogTypeHelper.MYSQL_LOG_TYPE_HELPER; + case ORACLE: + return OracleLogTypeHelper.ORACLE_LOG_TYPE_HELPER; + case DB2_LUW: + return DB2LogTypeHelper.DB2_LOG_TYPE_HELPER; + case POSTGRESQL: + return XLogTypeHelper.XLOG_TYPE_HELPER; default: throw new IllegalArgumentException("Unsupported dbType " + dbType); } diff --git a/common/src/main/java/com/oceanbase/oms/logmessage/typehelper/MySQLLogTypeHelper.java b/common/src/main/java/com/oceanbase/oms/logmessage/typehelper/MySQLLogTypeHelper.java new file mode 100644 index 0000000..b25c149 --- /dev/null +++ b/common/src/main/java/com/oceanbase/oms/logmessage/typehelper/MySQLLogTypeHelper.java @@ -0,0 +1,82 @@ +/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved. +oblogclient is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan PSL v2. +You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. */ + +package com.oceanbase.oms.logmessage.typehelper; + +import static com.oceanbase.oms.logmessage.DataMessage.Record.UTF8MB4_ENCODING; + +import com.oceanbase.oms.common.enums.DbTypeEnum; +import com.oceanbase.oms.logmessage.DataMessage; +import org.apache.commons.lang3.StringUtils; + +public class MySQLLogTypeHelper extends LogTypeHelper { + public static final MySQLLogTypeHelper MYSQL_LOG_TYPE_HELPER = new MySQLLogTypeHelper(); + + public MySQLLogTypeHelper() { + super(DbTypeEnum.MYSQL); + } + + @Override + public String correctEncoding(int type, String realEncoding) { + switch (type) { + case LogMessageTypeCode.LOG_MSG_TYPE_VAR_STRING: + case LogMessageTypeCode.LOG_MSG_TYPE_STRING: + return realEncoding.isEmpty() ? BINARY_STR : realEncoding; + case LogMessageTypeCode.LOG_MSG_TYPE_JSON: + return UTF8MB4_ENCODING; + default: + return realEncoding; + } + } + + @Override + public int correctCode(int typeCode, String encoding) { + switch (typeCode) { + case LogMessageTypeCode.LOG_MSG_TYPE_VAR_STRING: + return StringUtils.equals(encoding, BINARY_STR) + ? LogMessageTypeCode.LOG_MSG_TYPE_VAR_BINARY + : LogMessageTypeCode.LOG_MSG_TYPE_VARCHAR; + case LogMessageTypeCode.LOG_MSG_TYPE_STRING: + return StringUtils.equals(encoding, BINARY_STR) + ? LogMessageTypeCode.LOG_MSG_TYPE_BINARY + : LogMessageTypeCode.LOG_MSG_TYPE_STRING; + case LogMessageTypeCode.LOG_MSG_TYPE_LONG_BLOB: + case LogMessageTypeCode.LOG_MSG_TYPE_MEDIUM_BLOB: + case LogMessageTypeCode.LOG_MSG_TYPE_BLOB: + case LogMessageTypeCode.LOG_MSG_TYPE_TINY_BLOB: + return StringUtils.isEmpty(encoding) || StringUtils.equals(encoding, BINARY_STR) + ? LogMessageTypeCode.LOG_MSG_TYPE_BLOB + : LogMessageTypeCode.LOG_MSG_TYPE_TEXT; + default: + return typeCode; + } + } + + @Override + public void correctField(DataMessage.Record.Field field, String enc) { + if (enc.isEmpty()) { + if (field.type == LogMessageTypeCode.LOG_MSG_TYPE_STRING) { + field.encoding = BINARY_STR; + field.type = LogMessageTypeCode.LOG_MSG_TYPE_BINARY; + } else if (field.type == LogMessageTypeCode.LOG_MSG_TYPE_VAR_STRING) { + field.encoding = BINARY_STR; + field.type = LogMessageTypeCode.LOG_MSG_TYPE_VARCHAR; + } else if (field.type == LogMessageTypeCode.LOG_MSG_TYPE_JSON) { + field.encoding = UTF8MB4_ENCODING; + } + } else { + if (field.type >= LogMessageTypeCode.LOG_MSG_TYPE_TINY_BLOB + && field.type <= LogMessageTypeCode.LOG_MSG_TYPE_BLOB) { + field.type = LogMessageTypeCode.LOG_MSG_TYPE_TEXT; + } + field.encoding = enc; + } + } +} diff --git a/common/src/main/java/com/oceanbase/oms/logmessage/typehelper/OracleLogTypeHelper.java b/common/src/main/java/com/oceanbase/oms/logmessage/typehelper/OracleLogTypeHelper.java new file mode 100644 index 0000000..1bbc699 --- /dev/null +++ b/common/src/main/java/com/oceanbase/oms/logmessage/typehelper/OracleLogTypeHelper.java @@ -0,0 +1,46 @@ +/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved. +oblogclient is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan PSL v2. +You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. */ + +package com.oceanbase.oms.logmessage.typehelper; + + +import com.oceanbase.oms.common.enums.DbTypeEnum; +import com.oceanbase.oms.logmessage.DataMessage; + +public class OracleLogTypeHelper extends LogTypeHelper { + public static final OracleLogTypeHelper ORACLE_LOG_TYPE_HELPER = new OracleLogTypeHelper(); + + public OracleLogTypeHelper() { + super(DbTypeEnum.ORACLE); + } + + @Override + public String correctEncoding(int typeCode, String realEncoding) { + switch (typeCode) { + case LogMessageTypeCode.LOG_MSG_TYPE_BLOB: + return EMPTY_ENCODING_STR; + default: + return realEncoding; + } + } + + @Override + public int correctCode(int typeCode, String encoding) { + return typeCode; + } + + @Override + public void correctField(DataMessage.Record.Field f, String realEncoding) { + switch (f.type) { + case LogMessageTypeCode.LOG_MSG_TYPE_BLOB: + f.encoding = EMPTY_ENCODING_STR; + } + } +} diff --git a/common/src/main/java/com/oceanbase/oms/logmessage/typehelper/XLogTypeHelper.java b/common/src/main/java/com/oceanbase/oms/logmessage/typehelper/XLogTypeHelper.java new file mode 100644 index 0000000..fd42177 --- /dev/null +++ b/common/src/main/java/com/oceanbase/oms/logmessage/typehelper/XLogTypeHelper.java @@ -0,0 +1,36 @@ +/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved. +oblogclient is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan PSL v2. +You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. */ + +package com.oceanbase.oms.logmessage.typehelper; + + +import com.oceanbase.oms.common.enums.DbTypeEnum; +import com.oceanbase.oms.logmessage.DataMessage; + +public class XLogTypeHelper extends LogTypeHelper { + public static final XLogTypeHelper XLOG_TYPE_HELPER = new XLogTypeHelper(); + + public XLogTypeHelper() { + super(DbTypeEnum.POSTGRESQL); + } + + @Override + public String correctEncoding(int typeCode, String realEncoding) { + return realEncoding; + } + + @Override + public int correctCode(int typeCode, String encoding) { + return typeCode; + } + + @Override + public void correctField(DataMessage.Record.Field f, String realEncoding) {} +} diff --git a/logproxy-client/pom.xml b/logproxy-client/pom.xml index 312ca73..67c0c17 100644 --- a/logproxy-client/pom.xml +++ b/logproxy-client/pom.xml @@ -16,14 +16,14 @@ See the Mulan PSL v2 for more details. com.oceanbase.logclient logclient - 1.0.8-SNAPSHOT + 1.1.0-SNAPSHOT ../pom.xml logproxy-client jar ${project.groupId}:${project.artifactId} - The Client for OceanBase Log Proxy. + The Client for OceanBase LogProxy. diff --git a/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/LogProxyClient.java b/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/LogProxyClient.java index 7fd9fc0..02b591f 100644 --- a/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/LogProxyClient.java +++ b/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/LogProxyClient.java @@ -54,7 +54,8 @@ public class LogProxyClient { String clientId = clientConf.getClientId(); ConnectionParams connectionParams = new ConnectionParams(config.getLogType(), clientId, host, port, config); - connectionParams.setProtocolVersion(ProtocolVersion.V2); + connectionParams.setProtocolVersion( + ProtocolVersion.codeOf(clientConf.getProtocolVersion())); this.stream = new ClientStream(clientConf, connectionParams); } diff --git a/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/config/ClientConf.java b/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/config/ClientConf.java index 9597c44..da9b1d9 100644 --- a/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/config/ClientConf.java +++ b/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/config/ClientConf.java @@ -13,6 +13,7 @@ package com.oceanbase.clogproxy.client.config; import com.oceanbase.clogproxy.client.util.ClientIdGenerator; import com.oceanbase.clogproxy.common.config.SharedConf; +import com.oceanbase.clogproxy.common.packet.ProtocolVersion; import io.netty.handler.ssl.SslContext; import java.io.Serializable; @@ -22,7 +23,7 @@ public class ClientConf extends SharedConf implements Serializable { private static final long serialVersionUID = 1L; /** Client version. */ - public static final String VERSION = "1.0.7"; + public static final String VERSION = "1.1.0"; /** Queue size for storing records received from log proxy. */ private final int transferQueueSize; @@ -48,6 +49,8 @@ public class ClientConf extends SharedConf implements Serializable { /** Maximum number of reads, after which data will be discarded. */ private final int nettyDiscardAfterReads; + private final int protocolVersion; + /** User defined client id. */ private final String clientId; @@ -68,6 +71,7 @@ public class ClientConf extends SharedConf implements Serializable { int maxReconnectTimes, int idleTimeoutS, int nettyDiscardAfterReads, + int protocolVersion, String clientId, boolean ignoreUnknownRecordType, SslContext sslContext) { @@ -78,6 +82,7 @@ public class ClientConf extends SharedConf implements Serializable { this.maxReconnectTimes = maxReconnectTimes; this.idleTimeoutS = idleTimeoutS; this.nettyDiscardAfterReads = nettyDiscardAfterReads; + this.protocolVersion = protocolVersion; this.clientId = clientId; this.ignoreUnknownRecordType = ignoreUnknownRecordType; this.sslContext = sslContext; @@ -111,6 +116,10 @@ public class ClientConf extends SharedConf implements Serializable { return nettyDiscardAfterReads; } + public int getProtocolVersion() { + return protocolVersion; + } + public String getClientId() { return clientId; } @@ -136,6 +145,7 @@ public class ClientConf extends SharedConf implements Serializable { private int maxReconnectTimes = -1; private int idleTimeoutS = 15; private int nettyDiscardAfterReads = 16; + private int protocolVersion = ProtocolVersion.V2.code(); private String clientId = ClientIdGenerator.generate(); private boolean ignoreUnknownRecordType = false; private SslContext sslContext = null; @@ -175,6 +185,11 @@ public class ClientConf extends SharedConf implements Serializable { return this; } + public Builder protocolVersion(int protocolVersion) { + this.protocolVersion = protocolVersion; + return this; + } + public Builder clientId(String clientId) { this.clientId = clientId; return this; @@ -199,6 +214,7 @@ public class ClientConf extends SharedConf implements Serializable { maxReconnectTimes, idleTimeoutS, nettyDiscardAfterReads, + protocolVersion, clientId, ignoreUnknownRecordType, sslContext); diff --git a/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/config/ObReaderConfig.java b/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/config/ObReaderConfig.java index 2fb030d..9294927 100644 --- a/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/config/ObReaderConfig.java +++ b/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/config/ObReaderConfig.java @@ -29,6 +29,9 @@ public class ObReaderConfig extends AbstractConnectionConfig { private static final Logger logger = LoggerFactory.getLogger(ObReaderConfig.class); + /** Cluster Id. */ + private final ConfigItem clusterId = new ConfigItem<>("cluster_id", ""); + /** Cluster config url. */ private final ConfigItem clusterUrl = new ConfigItem<>("cluster_url", ""); @@ -41,6 +44,10 @@ public class ObReaderConfig extends AbstractConnectionConfig { /** Cluster password. */ private final ConfigItem clusterPassword = new ConfigItem<>("cluster_password", ""); + private final ConfigItem sysUser = new ConfigItem<>("sys_user", ""); + + private final ConfigItem sysPassword = new ConfigItem<>("sys_password", ""); + /** Table whitelist. */ private final ConfigItem tableWhitelist = new ConfigItem<>("tb_white_list", "*.*.*"); @@ -50,6 +57,10 @@ public class ObReaderConfig extends AbstractConnectionConfig { /** Start timestamp. */ private final ConfigItem startTimestamp = new ConfigItem<>("first_start_timestamp", 0L); + /** Start timestamp in microsecond. */ + private final ConfigItem startTimestampUs = + new ConfigItem<>("first_start_timestamp_us", 0L); + /** Timezone offset. */ private final ConfigItem timezone = new ConfigItem<>("timezone", "+8:00"); @@ -101,6 +112,12 @@ public class ObReaderConfig extends AbstractConnectionConfig { if (clusterUrl.key.equals(entry.getKey()) && StringUtils.isEmpty(value)) { continue; } + if (sysUser.key.equals(entry.getKey()) && StringUtils.isEmpty(value)) { + continue; + } + if (sysPassword.key.equals(entry.getKey()) && StringUtils.isEmpty(value)) { + continue; + } if (clusterPassword.key.equals(entry.getKey()) && SharedConf.AUTH_PASSWORD_HASH) { value = Hex.str(CryptoUtil.sha1(value)); } @@ -123,6 +140,12 @@ public class ObReaderConfig extends AbstractConnectionConfig { if (clusterUrl.key.equals(entry.getKey()) && StringUtils.isEmpty(value)) { continue; } + if (sysUser.key.equals(entry.getKey()) && StringUtils.isEmpty(value)) { + continue; + } + if (sysPassword.key.equals(entry.getKey()) && StringUtils.isEmpty(value)) { + continue; + } if (encryptPassword && clusterPassword.key.equals(entry.getKey()) && SharedConf.AUTH_PASSWORD_HASH) { @@ -153,21 +176,37 @@ public class ObReaderConfig extends AbstractConnectionConfig { return (StringUtils.isNotEmpty(clusterUrl.val)) ? ("cluster_url=" + clusterUrl) : ("rootserver_list=" + rsList) + + ", cluster_id=" + + clusterId + ", cluster_user=" + clusterUser + ", cluster_password=******, " + + ", sys_user=" + + sysUser + + ", sys_password=******, " + "tb_white_list=" + tableWhitelist + ", tb_black_list=" + tableBlacklist + ", start_timestamp=" + startTimestamp + + ", start_timestamp_us=" + + startTimestampUs + ", timezone=" + timezone + ", working_mode=" + workingMode; } + /** + * Set cluster id. + * + * @param clusterId Cluster Id. + */ + public void setClusterId(String clusterId) { + this.clusterId.set(clusterId); + } + /** * Set cluster config url. * @@ -204,6 +243,24 @@ public class ObReaderConfig extends AbstractConnectionConfig { this.clusterPassword.set(clusterPassword); } + /** + * Set cluster sys username + * + * @param sysUsername Cluster sys username. + */ + public void setSysUsername(String sysUsername) { + this.sysUser.set(sysUsername); + } + + /** + * Set cluster sys password + * + * @param sysPassword Cluster sys password. + */ + public void setSysPassword(String sysPassword) { + this.sysPassword.set(sysPassword); + } + /** * Set table whitelist. It is composed of three dimensions: tenant, db and table. Pattern * matching is provided by `fnmatch`, so asterisk means any, for example: "A.foo.bar", @@ -233,6 +290,10 @@ public class ObReaderConfig extends AbstractConnectionConfig { this.startTimestamp.set(startTimestamp); } + public void setStartTimestampUs(Long startTimestampUs) { + this.startTimestampUs.set(startTimestampUs); + } + /** * Set the timezone which is used to convert timestamp column. * diff --git a/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/connection/ClientHandler.java b/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/connection/ClientHandler.java index 1433cc2..086f8d1 100644 --- a/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/connection/ClientHandler.java +++ b/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/connection/ClientHandler.java @@ -64,7 +64,7 @@ public class ClientHandler extends ChannelInboundHandlerAdapter { private BlockingQueue recordQueue; /** Handshake type enumeration. */ - enum HandshakeStateV1 { + enum HandshakeState { /** State of parsing the packet header. */ PB_HEAD, /** State of handling handshake response. */ @@ -78,7 +78,7 @@ public class ClientHandler extends ChannelInboundHandlerAdapter { } /** Handshake state. */ - private HandshakeStateV1 state = HandshakeStateV1.PB_HEAD; + private HandshakeState state = HandshakeState.PB_HEAD; /** A {@link Cumulator} instance. */ private final Cumulator cumulator = ByteToMessageDecoder.MERGE_CUMULATOR; @@ -107,12 +107,18 @@ public class ClientHandler extends ChannelInboundHandlerAdapter { /** A {@link LZ4FastDecompressor} instance. */ LZ4FastDecompressor fastDecompressor = factory.fastDecompressor(); + ClientHandlerV01 clientHandlerV01; + /** Constructor with empty arguments. */ public ClientHandler() {} - /** Reset {@link #state} to {@link HandshakeStateV1#PB_HEAD}. */ + /** Reset {@link #state} to {@link HandshakeState#PB_HEAD}. */ protected void resetState() { - state = HandshakeStateV1.PB_HEAD; + if (params.getProtocolVersion().code() < ProtocolVersion.V2.code()) { + clientHandlerV01.resetState(); + } else { + state = HandshakeState.PB_HEAD; + } } @Override @@ -136,6 +142,11 @@ public class ClientHandler extends ChannelInboundHandlerAdapter { } while (poolFlag && buffer.isReadable() && !dataNotEnough) { + if (params.getProtocolVersion().code() < ProtocolVersion.V2.code()) { + dataNotEnough = clientHandlerV01.channelRead(poolFlag, buffer, dataNotEnough); + continue; + } + switch (state) { case PB_HEAD: handleHeader(); @@ -175,13 +186,13 @@ public class ClientHandler extends ChannelInboundHandlerAdapter { HeaderType headerType = HeaderType.codeOf(type); if (headerType == HeaderType.HANDSHAKE_RESPONSE_CLIENT) { - state = HandshakeStateV1.CLIENT_HANDSHAKE_RESPONSE; + state = HandshakeState.CLIENT_HANDSHAKE_RESPONSE; } else if (headerType == HeaderType.ERROR_RESPONSE) { - state = HandshakeStateV1.ERROR_RESPONSE; + state = HandshakeState.ERROR_RESPONSE; } else if (headerType == HeaderType.DATA_CLIENT) { - state = HandshakeStateV1.RECORD; + state = HandshakeState.RECORD; } else if (headerType == HeaderType.STATUS) { - state = HandshakeStateV1.STATUS; + state = HandshakeState.STATUS; } } else { dataNotEnough = true; @@ -199,7 +210,7 @@ public class ClientHandler extends ChannelInboundHandlerAdapter { "Connected to LogProxyServer, ip:{}, version:{}", response.getIp(), response.getVersion()); - state = HandshakeStateV1.PB_HEAD; + state = HandshakeState.PB_HEAD; } else { dataNotEnough = true; } @@ -227,7 +238,7 @@ public class ClientHandler extends ChannelInboundHandlerAdapter { buffer.readBytes(bytes); LogProxyProto.RuntimeStatus response = LogProxyProto.RuntimeStatus.parseFrom(bytes); logger.debug("Server status: {}", response.toString()); - state = HandshakeStateV1.PB_HEAD; + state = HandshakeState.PB_HEAD; } else { dataNotEnough = true; } @@ -236,8 +247,8 @@ public class ClientHandler extends ChannelInboundHandlerAdapter { /** Handle record data response. */ private void handleRecord() { if (buffer.readableBytes() >= dataLength) { - parseDataNew(); - state = HandshakeStateV1.PB_HEAD; + parseData(); + state = HandshakeState.PB_HEAD; } else { dataNotEnough = true; } @@ -251,7 +262,7 @@ public class ClientHandler extends ChannelInboundHandlerAdapter { * @param length Data length. */ private void checkHeader(int version, int type, int length) { - if (ProtocolVersion.codeOf(version) == null) { + if (ProtocolVersion.codeOf(version) == null && version != ProtocolVersion.V2.code()) { logger.error("Unsupported protocol version: {}", version); throw new LogProxyClientException( ErrorCode.E_PROTOCOL, "Unsupported protocol version: " + version); @@ -268,7 +279,7 @@ public class ClientHandler extends ChannelInboundHandlerAdapter { } /** Do parse record data from buffer. It will firstly decompress the raw data if necessary. */ - private void parseDataNew() { + private void parseData() { try { byte[] buff = new byte[dataLength]; buffer.readBytes(buff, 0, dataLength); @@ -342,12 +353,6 @@ public class ClientHandler extends ChannelInboundHandlerAdapter { } } - try { - stream.setCheckpointString(logMessage.getSafeTimestamp()); - } catch (IllegalArgumentException e) { - logger.error("Failed to update checkpoint for log message: " + logMessage, e); - } - offset += (8 + dataLength); } } @@ -375,6 +380,7 @@ public class ClientHandler extends ChannelInboundHandlerAdapter { config = context.config(); params = context.params(); recordQueue = context.recordQueue(); + clientHandlerV01 = new ClientHandlerV01(config, params, recordQueue, fastDecompressor); logger.info( "ClientId: {} connecting LogProxy: {}", @@ -386,9 +392,14 @@ public class ClientHandler extends ChannelInboundHandlerAdapter { /** * Generate the request body for protocol v2. * + * @param version version of protocol * @return Request body. */ - public ByteBuf generateConnectRequestV2() { + public ByteBuf generateConnectRequest(ProtocolVersion version) { + if (version.code() < ProtocolVersion.V2.code()) { + return clientHandlerV01.generateConnectRequest(); + } + LogProxyProto.ClientHandshakeRequest handShake = LogProxyProto.ClientHandshakeRequest.newBuilder() .setLogType(params.getLogType().code()) @@ -411,50 +422,6 @@ public class ClientHandler extends ChannelInboundHandlerAdapter { return byteBuf; } - /** - * Generate the request body. - * - * @param version Protocol version. - * @return Request body. - */ - public ByteBuf generateConnectRequest(ProtocolVersion version) { - if (version == ProtocolVersion.V2) { - return generateConnectRequestV2(); - } - - ByteBuf byteBuf = ByteBufAllocator.DEFAULT.buffer(MAGIC_STRING.length); - byteBuf.writeBytes(MAGIC_STRING); - - // header - byteBuf.capacity(byteBuf.capacity() + 2 + 4 + 1); - byteBuf.writeShort(ProtocolVersion.V0.code()); - byteBuf.writeInt(HeaderType.HANDSHAKE_REQUEST_CLIENT.code()); - byteBuf.writeByte(params.getLogType().code()); - - // body - int length = CLIENT_IP.length(); - byteBuf.capacity(byteBuf.capacity() + length + 4); - byteBuf.writeInt(length); - byteBuf.writeBytes(CLIENT_IP.getBytes()); - - length = params.getClientId().length(); - byteBuf.capacity(byteBuf.capacity() + length + 4); - byteBuf.writeInt(length); - byteBuf.writeBytes(params.getClientId().getBytes()); - - length = ClientConf.VERSION.length(); - byteBuf.capacity(byteBuf.capacity() + length + 4); - byteBuf.writeInt(length); - byteBuf.writeBytes(ClientConf.VERSION.getBytes()); - - length = params.getConfigurationString().length(); - byteBuf.capacity(byteBuf.capacity() + length + 4); - byteBuf.writeInt(length); - byteBuf.writeBytes(params.getConfigurationString().getBytes()); - - return byteBuf; - } - @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { poolFlag = false; diff --git a/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/connection/ClientHandlerV01.java b/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/connection/ClientHandlerV01.java new file mode 100644 index 0000000..26adbbf --- /dev/null +++ b/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/connection/ClientHandlerV01.java @@ -0,0 +1,430 @@ +/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved. +oblogclient is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan PSL v2. +You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. */ + +package com.oceanbase.clogproxy.client.connection; + + +import com.google.protobuf.InvalidProtocolBufferException; +import com.oceanbase.clogproxy.client.config.ClientConf; +import com.oceanbase.clogproxy.client.enums.ErrorCode; +import com.oceanbase.clogproxy.client.exception.LogProxyClientException; +import com.oceanbase.clogproxy.common.packet.CompressType; +import com.oceanbase.clogproxy.common.packet.HeaderType; +import com.oceanbase.clogproxy.common.packet.ProtocolVersion; +import com.oceanbase.clogproxy.common.packet.protocol.LogProxyProto; +import com.oceanbase.clogproxy.common.packet.protocol.V1Proto; +import com.oceanbase.clogproxy.common.util.NetworkUtil; +import com.oceanbase.oms.logmessage.LogMessage; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufAllocator; +import io.netty.buffer.ByteBufUtil; +import java.util.concurrent.BlockingQueue; +import net.jpountz.lz4.LZ4FastDecompressor; +import org.apache.commons.lang3.Conversion; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/* Compatitable for legacy V0 and V1 only, however you should not use */ +public class ClientHandlerV01 { + + private static final Logger logger = LoggerFactory.getLogger(ClientHandlerV01.class); + + private static final byte[] MAGIC_STRING = new byte[] {'x', 'i', '5', '3', 'g', ']', 'q'}; + + private static final String CLIENT_IP = NetworkUtil.getLocalIp(); + + private final ClientConf config; + private ConnectionParams params; + private final BlockingQueue recordQueue; + + private final LZ4FastDecompressor fastDecompressor; + + enum HandshakeState { + /** State of protocol version */ + PROTOCOL_VERSION, + /** State of header code */ + HEADER_CODE, + /** State of handshake response code */ + RESPONSE_CODE, + /** State of error message */ + MESSAGE, + /** State of handsake response version */ + LOGPROXY_IP, + /** State of handsake response version */ + LOGPROXY_VERSION, + /** State of data record */ + STREAM + } + + private HandshakeState state = HandshakeState.PROTOCOL_VERSION; + + private String logProxyIp; + + public ClientHandlerV01( + ClientConf config, + ConnectionParams params, + BlockingQueue recordQueue, + LZ4FastDecompressor fastDecompressor) { + this.config = config; + this.params = params; + this.recordQueue = recordQueue; + this.fastDecompressor = fastDecompressor; + } + + public void setParams(ConnectionParams params) { + this.params = params; + } + + public boolean channelRead(boolean poolflag, ByteBuf buffer, boolean inDataNotEnough) + throws Exception { + boolean dataNotEnough = inDataNotEnough; + + switch (state) { + case PROTOCOL_VERSION: + if (buffer.readableBytes() >= Short.BYTES) { + int code = buffer.readShort(); + ProtocolVersion version = ProtocolVersion.codeOf(code); + if (version == null) { + resetState(); + logger.error("unsupport protocol version: {}", code); + throw new LogProxyClientException( + ErrorCode.E_PROTOCOL, "unsupport protocol version: " + code); + } + state = HandshakeState.HEADER_CODE; + } else { + dataNotEnough = true; + } + break; + case HEADER_CODE: + if (buffer.readableBytes() >= Integer.BYTES) { + int code = buffer.readInt(); + + if ((code != HeaderType.HANDSHAKE_RESPONSE_CLIENT.code()) + && (code != HeaderType.ERROR_RESPONSE.code())) { + resetState(); + logger.error( + "unexpected Header Type, expected: {}({}), income: {}", + HeaderType.HANDSHAKE_RESPONSE_CLIENT.code(), + HeaderType.HANDSHAKE_RESPONSE_CLIENT.name(), + code); + throw new LogProxyClientException( + ErrorCode.E_HEADER_TYPE, "unexpected Header Type: " + code); + } + state = HandshakeState.RESPONSE_CODE; + } else { + dataNotEnough = true; + } + break; + case RESPONSE_CODE: + if (buffer.readableBytes() >= 4) { + int code = buffer.readInt(); + if (code != 0) { + state = HandshakeState.MESSAGE; + } else { + state = HandshakeState.LOGPROXY_IP; + } + } else { + dataNotEnough = true; + } + break; + case MESSAGE: + String message = decodeStringInt(buffer); + if (message != null) { + resetState(); + logger.error("LogProxy refused handshake request: {}", message); + throw new LogProxyClientException( + ErrorCode.NO_AUTH, "LogProxy refused handshake request: " + message); + } else { + dataNotEnough = true; + } + break; + case LOGPROXY_IP: + logProxyIp = decodeStringByte(buffer); + if (logProxyIp != null) { + state = HandshakeState.LOGPROXY_VERSION; + } else { + dataNotEnough = true; + } + break; + + case LOGPROXY_VERSION: + String logProxyVersion = decodeStringByte(buffer); + if (logProxyVersion != null) { + logger.info("Connected to LogProxy: {}, {}", logProxyIp, logProxyVersion); + state = HandshakeState.STREAM; + } else { + dataNotEnough = true; + } + break; + case STREAM: + parseData(poolflag, buffer); + dataNotEnough = true; + break; + } + return dataNotEnough; + } + + private static String decodeStringInt(ByteBuf buffer) { + if (buffer.readableBytes() < Integer.BYTES) { + return null; + } + buffer.markReaderIndex(); + int length = buffer.readInt(); + if (buffer.readableBytes() < length) { + buffer.resetReaderIndex(); + return null; + } + byte[] bytes = new byte[length]; + buffer.readBytes(bytes); + String str = new String(bytes); + if (str.isEmpty()) { + throw new RuntimeException("decode string is null or empty"); + } + return str; + } + + private static String decodeStringByte(ByteBuf buffer) { + if (buffer.readableBytes() < Byte.BYTES) { + return null; + } + buffer.markReaderIndex(); + short length = buffer.readByte(); + if (buffer.readableBytes() < length) { + buffer.resetReaderIndex(); + return null; + } + byte[] bytes = new byte[length]; + buffer.readBytes(bytes); + String str = new String(bytes); + if (str.isEmpty()) { + throw new RuntimeException("decode string is null or empty"); + } + return str; + } + + private void parseData(boolean poolflag, ByteBuf buffer) throws LogProxyClientException { + // TODO... parse data exception handle + while (poolflag && buffer.readableBytes() >= 2) { + buffer.markReaderIndex(); + + int code = buffer.readShort(); + ProtocolVersion version = ProtocolVersion.codeOf(code); + if (version == null) { + resetState(); + logger.error("unsupport protocol version: {}", code); + throw new LogProxyClientException( + ErrorCode.E_PROTOCOL, "unsupport protocol version: " + code); + } + boolean go; + switch (version) { + case V1: + go = parseDataV1(buffer); + break; + case V0: + default: + go = parseDataV0(buffer); + } + + if (!go) { + break; + } + } + } + + private boolean parseDataV0(ByteBuf buffer) { + if (buffer.readableBytes() < 8) { + buffer.resetReaderIndex(); + return false; + } + int code = buffer.readInt(); + if (code != HeaderType.DATA_CLIENT.code()) { + resetState(); + logger.error( + "unexpected Header Type, expected: {}({}), income: {}", + HeaderType.DATA_CLIENT.code(), + HeaderType.DATA_CLIENT.name(), + code); + throw new LogProxyClientException( + ErrorCode.E_HEADER_TYPE, "unexpected Header Type: " + code); + } + + int dataLength = buffer.readInt(); + if (buffer.readableBytes() < dataLength) { + buffer.resetReaderIndex(); + return false; + } + + code = buffer.readByte(); + if (CompressType.codeOf(code) == null) { + throw new LogProxyClientException( + ErrorCode.E_COMPRESS_TYPE, "unexpected Compress Type: " + code); + } + + int totalLength = buffer.readInt(); + int rawDataLength = buffer.readInt(); + byte[] rawData = new byte[rawDataLength]; + buffer.readBytes(rawData); + if (code == CompressType.LZ4.code()) { + byte[] bytes = new byte[totalLength]; + int decompress = fastDecompressor.decompress(rawData, 0, bytes, 0, totalLength); + if (decompress != rawDataLength) { + throw new LogProxyClientException( + ErrorCode.E_LEN, + "decompressed length [" + + decompress + + "] is not expected [" + + rawDataLength + + "]"); + } + parseRecord(bytes); + } else { + parseRecord(rawData); + } + // complete + return true; + } + + /** + * Do parse record data from an array of bytes to a {@link LogMessage} and add it into {@link + * #recordQueue}. + * + * @param bytes An array of bytes of record data. + * @throws LogProxyClientException If exception occurs. + */ + private void parseRecord(byte[] bytes) throws LogProxyClientException { + int offset = 0; + while (offset < bytes.length) { + int dataLength = Conversion.byteArrayToInt(bytes, offset + 4, 0, 0, 4); + dataLength = ByteBufUtil.swapInt(dataLength); + + /* + * We must copy a byte array and call parse after then, + * or got a !!!RIDICULOUS EXCEPTION!!!, + * if we wrap an unpooled buffer with offset and call setByteBuf just as same as `parse` function do. + */ + LogMessage logMessage = new LogMessage(false); + byte[] data = new byte[dataLength]; + System.arraycopy(bytes, offset + 8, data, 0, data.length); + + try { + logMessage.parse(data); + } catch (Exception e) { + if (config.isIgnoreUnknownRecordType()) { + // unsupported type, ignore + logger.debug("Unsupported record type: {}", logMessage); + offset += (8 + dataLength); + continue; + } + throw new LogProxyClientException(ErrorCode.E_PARSE, e); + } + + if (logger.isTraceEnabled()) { + logger.trace("Log message: {}", logMessage); + } + + while (true) { + try { + recordQueue.put(new StreamContext.TransferPacket(logMessage)); + break; + } catch (InterruptedException e) { + // do nothing + } + } + + offset += (8 + dataLength); + } + } + + private boolean parseDataV1(ByteBuf buffer) { + if (buffer.readableBytes() < 4) { + buffer.resetReaderIndex(); + return false; + } + int length = buffer.readInt(); + if (buffer.readableBytes() < length) { + buffer.resetReaderIndex(); + return false; + } + byte[] buff = new byte[length]; + buffer.readBytes(buff, 0, length); + try { + V1Proto.PbPacket packet = V1Proto.PbPacket.parseFrom(buff); + + if (packet.getCompressType() != CompressType.NONE.code()) { + // TODO.. + throw new LogProxyClientException( + ErrorCode.E_COMPRESS_TYPE, + "Unsupport Compress Type: " + packet.getCompressType()); + } + if (packet.getType() != HeaderType.STATUS.code()) { + // TODO.. header type dispatcher + throw new LogProxyClientException( + ErrorCode.E_HEADER_TYPE, "Unsupport Header Type: " + packet.getType()); + } + LogProxyProto.RuntimeStatus status = + LogProxyProto.RuntimeStatus.parseFrom(packet.getPayload()); + if (status == null) { + throw new LogProxyClientException( + ErrorCode.E_PARSE, "Failed to read PB packet, empty Runtime Status"); + } + + while (true) { + try { + recordQueue.put(new StreamContext.TransferPacket(status)); + break; + } catch (InterruptedException e) { + // do nothing + } + } + + } catch (InvalidProtocolBufferException e) { + throw new LogProxyClientException(ErrorCode.E_PARSE, "Failed to read PB packet", e); + } + return true; + } + + public void resetState() { + state = HandshakeState.PROTOCOL_VERSION; + } + + public ByteBuf generateConnectRequest() { + ByteBuf byteBuf = ByteBufAllocator.DEFAULT.buffer(MAGIC_STRING.length); + byteBuf.writeBytes(MAGIC_STRING); + + // header + byteBuf.capacity(byteBuf.capacity() + 2 + 4 + 1); + byteBuf.writeShort(ProtocolVersion.V0.code()); + byteBuf.writeInt(HeaderType.HANDSHAKE_REQUEST_CLIENT.code()); + byteBuf.writeByte(params.getLogType().code()); + + // body + int length = CLIENT_IP.length(); + byteBuf.capacity(byteBuf.capacity() + length + 4); + byteBuf.writeInt(length); + byteBuf.writeBytes(CLIENT_IP.getBytes()); + + length = params.getClientId().length(); + byteBuf.capacity(byteBuf.capacity() + length + 4); + byteBuf.writeInt(length); + byteBuf.writeBytes(params.getClientId().getBytes()); + + length = ClientConf.VERSION.length(); + byteBuf.capacity(byteBuf.capacity() + length + 4); + byteBuf.writeInt(length); + byteBuf.writeBytes(ClientConf.VERSION.getBytes()); + + length = params.getConfigurationString().length(); + byteBuf.capacity(byteBuf.capacity() + length + 4); + byteBuf.writeInt(length); + byteBuf.writeBytes(params.getConfigurationString().getBytes()); + + return byteBuf; + } +} diff --git a/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/connection/ClientStream.java b/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/connection/ClientStream.java index a51a0c4..b181ccb 100644 --- a/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/connection/ClientStream.java +++ b/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/connection/ClientStream.java @@ -192,6 +192,20 @@ public class ClientStream { "Unsupported Packet Type: " + packet.getType()); } + + try { + setCheckpointString( + packet.getRecord().getSafeTimestamp()); + } catch (IllegalArgumentException e) { + logger.error( + "Failed to update checkpoint for log message: " + + packet.getRecord(), + e); + throw new LogProxyClientException( + ErrorCode.E_INNER, + "Failed to update checkpoint"); + } + } catch (LogProxyClientException e) { triggerException(e); break; @@ -295,7 +309,7 @@ public class ClientStream { * * @param checkpointString Checkpoint string. */ - public void setCheckpointString(String checkpointString) { + private void setCheckpointString(String checkpointString) { long timestamp = Long.parseLong(checkpointString); if (timestamp <= 0) { throw new IllegalArgumentException( diff --git a/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/connection/StreamContext.java b/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/connection/StreamContext.java index 4c7548d..63b86c3 100644 --- a/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/connection/StreamContext.java +++ b/logproxy-client/src/main/java/com/oceanbase/clogproxy/client/connection/StreamContext.java @@ -24,11 +24,11 @@ public class StreamContext { public static class TransferPacket { /** Packet header type. */ - private final HeaderType type; + protected final HeaderType type; /** Log message record. */ - private LogMessage record; + protected LogMessage record; /** Log proxy runtime status. */ - private RuntimeStatus status; + protected RuntimeStatus status; /** * Constructor with a {@link LogMessage}. diff --git a/logproxy-client/src/test/java/com/oceanbase/clogproxy/client/config/ObReaderConfigTest.java b/logproxy-client/src/test/java/com/oceanbase/clogproxy/client/config/ObReaderConfigTest.java index 67ab61e..5c7d609 100644 --- a/logproxy-client/src/test/java/com/oceanbase/clogproxy/client/config/ObReaderConfigTest.java +++ b/logproxy-client/src/test/java/com/oceanbase/clogproxy/client/config/ObReaderConfigTest.java @@ -30,6 +30,7 @@ public class ObReaderConfigTest { config.setUsername("root@test_tenant"); config.setPassword("password"); config.setStartTimestamp(0L); + config.setStartTimestampUs(0L); config.setTableWhiteList("test_tenant.test.*"); config.setTableBlackList("|"); config.setTimezone("+8:00"); @@ -53,7 +54,7 @@ public class ObReaderConfigTest { Assert.assertTrue(object instanceof ObReaderConfig); Map configMap = ((ObReaderConfig) object).generateConfigurationMap(false); - Assert.assertEquals(configMap.size(), 8); + Assert.assertEquals(configMap.size(), 10); Assert.assertEquals(configMap, config.generateConfigurationMap(false)); } } diff --git a/pom.xml b/pom.xml index 56f702f..b736114 100644 --- a/pom.xml +++ b/pom.xml @@ -10,12 +10,13 @@ EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the Mulan PSL v2 for more details. --> - + 4.0.0 com.oceanbase.logclient logclient - 1.0.8-SNAPSHOT + 1.1.0-SNAPSHOT pom ${project.groupId}:${project.artifactId} @@ -71,7 +72,7 @@ See the Mulan PSL v2 for more details. 3.12.0 1.15 - 4.1.68.Final + 4.1.77.Final 3.19.6 1.8.0 1.7.32 @@ -210,7 +211,7 @@ See the Mulan PSL v2 for more details. MulanPSL2 Mulan Public Licenseļ¼ŒVersion 2 - + Mulan PSL v2 @@ -245,13 +246,14 @@ See the Mulan PSL v2 for more details. **/LogProxyProto.java + **/V1Proto.java 1.7 - - + + diff --git a/common/src/main/java/com/oceanbase/clogproxy/common/packet/protocol/logproxy.proto b/proto/logproxy.proto similarity index 100% rename from common/src/main/java/com/oceanbase/clogproxy/common/packet/protocol/logproxy.proto rename to proto/logproxy.proto diff --git a/proto/v1.proto b/proto/v1.proto new file mode 100644 index 0000000..b3b18e9 --- /dev/null +++ b/proto/v1.proto @@ -0,0 +1,40 @@ +/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved. +oblogclient is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan PSL v2. +You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. */ + +syntax = "proto3"; + +package oms; + +option java_package = "com.oceanbase.clogproxy.common.packet.protocol"; +option java_outer_classname = "V1Proto"; + +message PbPacket { + int32 type = 1; // HeaderType + int32 compress_type = 2; // CompressType + // resevered for other options + bytes payload = 100; +} + +message ClientHandShake { + int32 log_type = 1; // LogType + string client_ip = 2; + string client_id = 3; + string client_version = 4; + bool enable_monitor = 5; + string configuration = 6; +} + +message RuntimeStatus { + string ip = 1; + int32 port = 2; + + int32 stream_count = 3; + int32 worker_count = 4; +} diff --git a/scripts/protoc.sh b/scripts/protoc.sh index 552f476..ee0106b 100755 --- a/scripts/protoc.sh +++ b/scripts/protoc.sh @@ -13,4 +13,5 @@ cd "$(dirname "$0")/.." || exit -protoc --java_out=common/src/main/java common/src/main/java/com/oceanbase/clogproxy/common/packet/protocol/logproxy.proto +protoc --java_out=common/src/main/java proto/logproxy.proto +protoc --java_out=common/src/main/java proto/v1.proto -- GitLab