Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
oceanbase
oblogclient
提交
426f63aa
O
oblogclient
项目概览
oceanbase
/
oblogclient
1 年多 前同步成功
通知
5
Star
15
Fork
11
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oblogclient
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
未验证
提交
426f63aa
编写于
7月 08, 2022
作者:
H
He Wang
提交者:
GitHub
7月 08, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update logmessage based on internal version (#51)
* update logmessage from internal store client * update comments
上级
92bcf94e
变更
12
展开全部
隐藏空白更改
内联
并排
Showing
12 changed file
with
386 addition
and
335 deletion
+386
-335
common/src/main/java/com/oceanbase/oms/common/enums/DbCategoryEnum.java
...n/java/com/oceanbase/oms/common/enums/DbCategoryEnum.java
+12
-17
common/src/main/java/com/oceanbase/oms/common/enums/DbTypeEnum.java
.../main/java/com/oceanbase/oms/common/enums/DbTypeEnum.java
+85
-0
common/src/main/java/com/oceanbase/oms/logmessage/DataMessage.java
...c/main/java/com/oceanbase/oms/logmessage/DataMessage.java
+53
-37
common/src/main/java/com/oceanbase/oms/logmessage/FieldParseListener.java
...java/com/oceanbase/oms/logmessage/FieldParseListener.java
+33
-4
common/src/main/java/com/oceanbase/oms/logmessage/LogMessage.java
...rc/main/java/com/oceanbase/oms/logmessage/LogMessage.java
+113
-125
common/src/main/java/com/oceanbase/oms/logmessage/typehelper/LogMessageTypeCode.java
...eanbase/oms/logmessage/typehelper/LogMessageTypeCode.java
+53
-53
common/src/main/java/com/oceanbase/oms/logmessage/typehelper/LogTypeHelper.java
...om/oceanbase/oms/logmessage/typehelper/LogTypeHelper.java
+4
-4
common/src/main/java/com/oceanbase/oms/logmessage/typehelper/LogTypeHelperFactory.java
...nbase/oms/logmessage/typehelper/LogTypeHelperFactory.java
+6
-5
common/src/main/java/com/oceanbase/oms/logmessage/typehelper/OBLogTypeHelper.java
.../oceanbase/oms/logmessage/typehelper/OBLogTypeHelper.java
+24
-24
common/src/main/java/com/oceanbase/oms/logmessage/utils/StringUtils.java
.../java/com/oceanbase/oms/logmessage/utils/StringUtils.java
+0
-63
logproxy-client/src/main/java/com/oceanbase/clogproxy/client/config/ObReaderConfig.java
...com/oceanbase/clogproxy/client/config/ObReaderConfig.java
+2
-2
pom.xml
pom.xml
+1
-1
未找到文件。
common/src/main/java/com/oceanbase/oms/
logmessage/enums/DBType
.java
→
common/src/main/java/com/oceanbase/oms/
common/enums/DbCategoryEnum
.java
浏览文件 @
426f63aa
...
...
@@ -8,21 +8,16 @@ 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.enums
;
/** Database type enumeration for open source. */
public
enum
DBType
{
MYSQL
,
OCEANBASE
,
HBASE
,
ORACLE
,
OCEANBASE1
,
DB2
,
UNKNOWN
package
com.oceanbase.oms.common.enums
;
public
enum
DbCategoryEnum
{
/** Relational database. */
RDB
,
/** Message queue. */
MQ
,
/** Big data. */
BIGDATA
,
/** Not only SQL. */
NOSQL
;
}
common/src/main/java/com/oceanbase/oms/common/enums/DbTypeEnum.java
0 → 100644
浏览文件 @
426f63aa
/* 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.common.enums
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Set
;
public
enum
DbTypeEnum
{
/** OceanBase 0.5. */
OB_05
(
DbCategoryEnum
.
RDB
,
new
HashSet
<>(
Arrays
.
asList
(
"oceanbase"
,
"ob05"
))),
/** OceanBase in MySQL mode. */
OB_MYSQL
(
DbCategoryEnum
.
RDB
,
new
HashSet
<>(
Arrays
.
asList
(
"oceanbase1"
,
"ob10"
,
"oceanbase_mysql_mode"
))),
/** OceanBase in Oracle mode. */
OB_ORACLE
(
DbCategoryEnum
.
RDB
,
new
HashSet
<>(
Arrays
.
asList
(
"oceanbase_oracle_mode"
,
"ob_in_oracle_mode"
))),
UNKNOWN
(
null
);
DbTypeEnum
(
DbCategoryEnum
category
)
{
this
.
category
=
category
;
this
.
aliases
=
Collections
.
emptySet
();
}
DbTypeEnum
(
DbCategoryEnum
category
,
Set
<
String
>
aliases
)
{
this
.
category
=
category
;
this
.
aliases
=
aliases
;
}
public
static
DbTypeEnum
fromAlias
(
String
alias
)
{
return
ALIAS_ENUM_MAP
.
get
(
alias
.
toLowerCase
());
}
public
static
DbTypeEnum
valueOfIgnoreCase
(
String
value
)
{
try
{
if
(
DbTypeEnum
.
fromAlias
(
value
)
!=
null
)
{
return
DbTypeEnum
.
fromAlias
(
value
);
}
else
{
return
DbTypeEnum
.
valueOf
(
value
.
toUpperCase
());
}
}
catch
(
IllegalArgumentException
e
)
{
return
null
;
}
}
private
static
final
Map
<
String
,
DbTypeEnum
>
ALIAS_ENUM_MAP
=
new
HashMap
<>();
static
{
for
(
DbTypeEnum
one
:
values
())
{
for
(
String
alias
:
one
.
getAliases
())
{
assert
!
ALIAS_ENUM_MAP
.
containsKey
(
alias
.
toLowerCase
());
ALIAS_ENUM_MAP
.
put
(
alias
.
toLowerCase
(),
one
);
}
}
}
private
final
DbCategoryEnum
category
;
private
final
Set
<
String
>
aliases
;
public
DbCategoryEnum
getCategory
()
{
return
category
;
}
public
Set
<
String
>
getAliases
()
{
return
aliases
;
}
}
common/src/main/java/com/oceanbase/oms/logmessage/DataMessage.java
浏览文件 @
426f63aa
...
...
@@ -11,9 +11,9 @@ See the Mulan PSL v2 for more details. */
package
com.oceanbase.oms.logmessage
;
import
com.oceanbase.oms.
logmessage.enums.DBType
;
import
com.oceanbase.oms.
common.enums.DbTypeEnum
;
import
com.oceanbase.oms.logmessage.typehelper.LogTypeHelper
;
import
com.oceanbase.oms.logmessage.typehelper.
OBLogTypeHelper
;
import
com.oceanbase.oms.logmessage.typehelper.
LogTypeHelperFactory
;
import
java.io.DataInputStream
;
import
java.io.IOException
;
import
java.util.ArrayList
;
...
...
@@ -31,7 +31,6 @@ public class DataMessage extends Message {
/** Record contains data of one record. */
public
static
class
Record
{
public
static
LogTypeHelper
logTypeHelper
=
OBLogTypeHelper
.
OB_LOG_TYPE_HELPER
;
public
static
final
String
UTF8MB4_ENCODING
=
"utf8mb4"
;
public
static
final
String
TRACEID_STRING
=
"traceid"
;
...
...
@@ -122,6 +121,8 @@ public class DataMessage extends Message {
public
boolean
prev
=
false
;
public
boolean
notNull
=
false
;
public
enum
Type
{
INT8
,
INT16
,
...
...
@@ -190,6 +191,10 @@ public class DataMessage extends Message {
this
.
flag
=
flag
;
}
public
void
setNotNull
(
boolean
notNull
)
{
this
.
notNull
=
notNull
;
}
public
final
boolean
isPrimary
()
{
return
primaryKey
;
}
...
...
@@ -223,6 +228,10 @@ public class DataMessage extends Message {
return
encoding
;
}
public
final
boolean
getNotNull
()
{
return
notNull
;
}
public
static
Type
[]
MYSQL_TYPES
=
new
Type
[
256
];
static
{
...
...
@@ -371,6 +380,7 @@ public class DataMessage extends Message {
builder
.
append
(
"Field name: "
+
name
+
System
.
getProperty
(
"line.separator"
));
builder
.
append
(
"Field type: "
+
type
+
System
.
getProperty
(
"line.separator"
));
builder
.
append
(
"Field length: "
+
length
+
System
.
getProperty
(
"line.separator"
));
builder
.
append
(
"Field notNull: "
+
notNull
+
System
.
getProperty
(
"line.separator"
));
if
(
value
!=
null
)
{
if
(
"binary"
.
equalsIgnoreCase
(
encoding
))
{
builder
.
append
(
...
...
@@ -447,7 +457,9 @@ public class DataMessage extends Message {
type
=
Type
.
valueOf
(
stype
.
toUpperCase
());
// set timestamp,process heartbeat between tx
timestamp
=
getAttribute
(
"timestamp"
);
if
(
getDbType
()
==
DBType
.
OCEANBASE1
)
{
DbTypeEnum
dbType
=
getDbType
();
LogTypeHelper
logTypeHelper
=
LogTypeHelperFactory
.
getInstance
(
dbType
);
if
(
dbType
==
DbTypeEnum
.
OB_MYSQL
||
dbType
==
DbTypeEnum
.
OB_ORACLE
)
{
if
(
type
==
Type
.
HEARTBEAT
)
{
globalSafeTimestamp
.
set
(
timestamp
);
}
else
{
...
...
@@ -654,25 +666,8 @@ public class DataMessage extends Message {
return
getAttribute
(
"unique"
);
}
public
DBType
getDbType
()
{
String
type
=
getAttribute
(
"source_type"
);
if
(
StringUtils
.
isEmpty
(
type
))
{
return
DBType
.
UNKNOWN
;
}
if
(
"mysql"
.
equalsIgnoreCase
(
type
))
{
return
DBType
.
MYSQL
;
}
else
if
(
"oceanbase"
.
equalsIgnoreCase
(
type
))
{
return
DBType
.
OCEANBASE
;
}
else
if
(
"oracle"
.
equalsIgnoreCase
(
type
))
{
return
DBType
.
ORACLE
;
}
else
if
(
"hbase"
.
equalsIgnoreCase
(
type
))
{
return
DBType
.
HBASE
;
}
else
if
(
"oceanbase_1_0"
.
equalsIgnoreCase
(
type
))
{
return
DBType
.
OCEANBASE1
;
}
else
if
(
"db2"
.
equalsIgnoreCase
(
type
))
{
return
DBType
.
DB2
;
}
return
DBType
.
UNKNOWN
;
public
DbTypeEnum
getDbType
()
{
return
parseDbTypeStr
(
getAttribute
(
"source_type"
));
}
public
boolean
isQueryBack
()
{
...
...
@@ -772,15 +767,12 @@ public class DataMessage extends Message {
}
public
String
getMessageUniqueIdStr
()
throws
Exception
{
D
BType
dbType
=
getDbType
();
D
bTypeEnum
dbType
=
getDbType
();
this
.
checkDBType
(
dbType
);
StringBuilder
messageId
=
new
StringBuilder
();
if
(
dbType
==
DBType
.
MYSQL
)
{
messageId
.
append
(
getServerId
());
}
messageId
.
append
(
"/"
).
append
(
this
.
getCommonPart
()).
append
(
"/"
);
if
(
dbType
==
D
BType
.
OCEANBASE1
)
{
if
(
dbType
==
D
bTypeEnum
.
OB_MYSQL
||
dbType
==
DbTypeEnum
.
OB_ORACLE
)
{
messageId
.
append
(
"/"
);
}
else
{
String
checkpoint
=
getCheckpoint
();
...
...
@@ -791,7 +783,7 @@ public class DataMessage extends Message {
}
messageId
.
append
(
"/"
);
if
(
dbType
==
D
BType
.
OCEANBASE1
)
{
if
(
dbType
==
D
bTypeEnum
.
OB_MYSQL
||
dbType
==
DbTypeEnum
.
OB_ORACLE
)
{
messageId
.
append
(
getOB10UniqueId
());
}
...
...
@@ -799,14 +791,15 @@ public class DataMessage extends Message {
return
messageId
.
toString
();
}
private
void
checkDBType
(
DBType
dbType
)
{
if
(
dbType
!=
DBType
.
MYSQL
&&
dbType
!=
DBType
.
OCEANBASE
&&
dbType
!=
DBType
.
OCEANBASE1
&&
dbType
!=
DBType
.
ORACLE
&&
dbType
!=
DBType
.
DB2
)
{
throw
new
IllegalStateException
(
"dbType ["
+
dbType
+
"] is not valid for messageId"
);
private
void
checkDBType
(
DbTypeEnum
dbType
)
{
switch
(
dbType
)
{
case
OB_MYSQL:
case
OB_ORACLE:
case
OB_05:
break
;
default
:
throw
new
IllegalStateException
(
"dbType ["
+
dbType
+
"] is not valid for messageId"
);
}
}
...
...
@@ -914,4 +907,27 @@ public class DataMessage extends Message {
public
void
addRecord
(
Record
r
)
{
records
.
add
(
r
);
}
public
static
DbTypeEnum
parseDbTypeStr
(
String
dbTypeInStr
)
{
if
(
StringUtils
.
isEmpty
(
dbTypeInStr
))
{
return
DbTypeEnum
.
UNKNOWN
;
}
if
(
"oceanbase"
.
equalsIgnoreCase
(
dbTypeInStr
))
{
return
DbTypeEnum
.
OB_05
;
}
else
if
(
"oceanbase_1_0"
.
equalsIgnoreCase
(
dbTypeInStr
))
{
return
DbTypeEnum
.
OB_MYSQL
;
}
return
DbTypeEnum
.
UNKNOWN
;
}
public
static
DbTypeEnum
parseDBTypeCode
(
int
dbTypeCode
)
{
switch
(
dbTypeCode
)
{
case
1
:
return
DbTypeEnum
.
OB_05
;
case
4
:
return
DbTypeEnum
.
OB_MYSQL
;
default
:
return
DbTypeEnum
.
UNKNOWN
;
}
}
}
common/src/main/java/com/oceanbase/oms/logmessage/FieldParseListener.java
浏览文件 @
426f63aa
...
...
@@ -10,15 +10,44 @@ See the Mulan PSL v2 for more details. */
package
com.oceanbase.oms.logmessage
;
import
com.oceanbase.oms.logmessage.typehelper.LogMessageTypeCode
;
/** This interface defined a kind of listener for field parsing. */
public
interface
FieldParseListener
{
/**
* Handle the filed parsing result.
*
* @param prev The original field.
* @param next The field after parsing.
* @throws Exception When exception occurs.
* @param fieldName Field name.
* @param type {@link LogMessageTypeCode}.
* @param encoding Encoding of value.
* @param value Field value.
* @param notNull Flag of whether the field is not null (not optional).
* @param isPrev Flag of whether the value is the old one.
*/
void
parseNotify
(
String
fieldName
,
int
type
,
String
encoding
,
ByteString
value
,
boolean
notNull
,
boolean
isPrev
);
/**
* Handle the filed parsing result. Only support value, as we already know schema info.
*
* @param type {@link LogMessageTypeCode}.
* @param value Field value.
* @param encoding Encoding of value.
* @param isPrev Flag of whether the value is the old one.
*/
void
parseNotify
(
int
type
,
ByteString
value
,
String
encoding
,
boolean
isPrev
);
/**
* Flag of whether schema info (fieldName, type, encoding, notNull) is needed.
*
* @return True for needed, otherwise false.
*/
void
parseNotify
(
DataMessage
.
Record
.
Field
prev
,
DataMessage
.
Record
.
Field
next
)
throws
Exception
;
boolean
needSchemaInfo
()
;
}
common/src/main/java/com/oceanbase/oms/logmessage/LogMessage.java
浏览文件 @
426f63aa
此差异已折叠。
点击以展开。
common/src/main/java/com/oceanbase/oms/logmessage/typehelper/LogMessageTypeCode.java
浏览文件 @
426f63aa
...
...
@@ -13,62 +13,62 @@ package com.oceanbase.oms.logmessage.typehelper;
// compatible with mysql type code
// same code may reference different schema type
public
class
LogMessageTypeCode
{
public
static
final
int
DRC
_MSG_TYPE_DECIMAL
=
0
;
public
static
final
int
DRC
_MSG_TYPE_TINY
=
1
;
public
static
final
int
DRC
_MSG_TYPE_SHORT
=
2
;
public
static
final
int
DRC
_MSG_TYPE_LONG
=
3
;
public
static
final
int
DRC
_MSG_TYPE_FLOAT
=
4
;
public
static
final
int
DRC
_MSG_TYPE_DOUBLE
=
5
;
public
static
final
int
DRC
_MSG_TYPE_NULL
=
6
;
public
static
final
int
DRC
_MSG_TYPE_TIMESTAMP
=
7
;
public
static
final
int
DRC
_MSG_TYPE_LONGLONG
=
8
;
public
static
final
int
DRC
_MSG_TYPE_INT24
=
9
;
public
static
final
int
DRC
_MSG_TYPE_DATE
=
10
;
public
static
final
int
DRC
_MSG_TYPE_TIME
=
11
;
public
static
final
int
DRC
_MSG_TYPE_DATETIME
=
12
;
public
static
final
int
DRC
_MSG_TYPE_YEAR
=
13
;
public
static
final
int
DRC
_MSG_TYPE_NEWDATE
=
14
;
public
static
final
int
DRC
_MSG_TYPE_VARCHAR
=
15
;
public
static
final
int
DRC
_MSG_TYPE_BIT
=
16
;
public
static
final
int
LOG
_MSG_TYPE_DECIMAL
=
0
;
public
static
final
int
LOG
_MSG_TYPE_TINY
=
1
;
public
static
final
int
LOG
_MSG_TYPE_SHORT
=
2
;
public
static
final
int
LOG
_MSG_TYPE_LONG
=
3
;
public
static
final
int
LOG
_MSG_TYPE_FLOAT
=
4
;
public
static
final
int
LOG
_MSG_TYPE_DOUBLE
=
5
;
public
static
final
int
LOG
_MSG_TYPE_NULL
=
6
;
public
static
final
int
LOG
_MSG_TYPE_TIMESTAMP
=
7
;
public
static
final
int
LOG
_MSG_TYPE_LONGLONG
=
8
;
public
static
final
int
LOG
_MSG_TYPE_INT24
=
9
;
public
static
final
int
LOG
_MSG_TYPE_DATE
=
10
;
public
static
final
int
LOG
_MSG_TYPE_TIME
=
11
;
public
static
final
int
LOG
_MSG_TYPE_DATETIME
=
12
;
public
static
final
int
LOG
_MSG_TYPE_YEAR
=
13
;
public
static
final
int
LOG
_MSG_TYPE_NEWDATE
=
14
;
public
static
final
int
LOG
_MSG_TYPE_VARCHAR
=
15
;
public
static
final
int
LOG
_MSG_TYPE_BIT
=
16
;
public
static
final
int
DRC
_MSG_TYPE_TIMESTAMP2
=
17
;
public
static
final
int
DRC
_MSG_TYPE_DATETIME2
=
18
;
public
static
final
int
DRC
_MSG_TYPE_TIME2
=
19
;
public
static
final
int
LOG
_MSG_TYPE_TIMESTAMP2
=
17
;
public
static
final
int
LOG
_MSG_TYPE_DATETIME2
=
18
;
public
static
final
int
LOG
_MSG_TYPE_TIME2
=
19
;
// appeared in ob define, but should not appeared in drc types
public
static
final
int
DRC
_MSG_COMPLEX
=
160
;
public
static
final
int
DRC
_MSG_TYPE_ARRAY
=
161
;
public
static
final
int
DRC
_MSG_TYPE_STRUCT
=
162
;
public
static
final
int
DRC
_MSG_TYPE_CURSOR
=
163
;
public
static
final
int
DRC
_MSG_TYPE_ORA_BLOB
=
210
;
public
static
final
int
DRC
_MSG_TYPE_CLOB
=
211
;
public
static
final
int
LOG
_MSG_COMPLEX
=
160
;
public
static
final
int
LOG
_MSG_TYPE_ARRAY
=
161
;
public
static
final
int
LOG
_MSG_TYPE_STRUCT
=
162
;
public
static
final
int
LOG
_MSG_TYPE_CURSOR
=
163
;
public
static
final
int
LOG
_MSG_TYPE_ORA_BLOB
=
210
;
public
static
final
int
LOG
_MSG_TYPE_CLOB
=
211
;
public
static
final
int
DRC
_MSG_TYPE_TEXT
=
197
;
public
static
final
int
DRC
_MSG_TYPE_VAR_BINARY
=
198
;
public
static
final
int
DRC
_MSG_TYPE_BINARY
=
199
;
public
static
final
int
DRC
_MSG_TYPE_TIMESTAMP_WITH_TIME_ZONE
=
200
;
public
static
final
int
DRC
_MSG_TYPE_TIMESTAMP_WITH_LOCAL_TIME_ZONE
=
201
;
public
static
final
int
DRC
_MSG_TYPE_TIMESTAMP_NANO
=
202
;
public
static
final
int
DRC
_MSG_TYPE_RAW
=
203
;
public
static
final
int
DRC
_MSG_TYPE_INTERVAL_YEAR_TO_MONTH
=
204
;
public
static
final
int
DRC
_MSG_TYPE_INTERVAL_DAY_TO_SECOND
=
205
;
public
static
final
int
DRC
_MSG_TYPE_NUMBER_FLOAT
=
206
;
public
static
final
int
DRC
_MSG_TYPE_NVARCHAR2
=
207
;
public
static
final
int
DRC
_MSG_TYPE_NCHAR
=
208
;
public
static
final
int
DRC
_MSG_TYPE_ROW_ID
=
209
;
public
static
final
int
LOG
_MSG_TYPE_TEXT
=
197
;
public
static
final
int
LOG
_MSG_TYPE_VAR_BINARY
=
198
;
public
static
final
int
LOG
_MSG_TYPE_BINARY
=
199
;
public
static
final
int
LOG
_MSG_TYPE_TIMESTAMP_WITH_TIME_ZONE
=
200
;
public
static
final
int
LOG
_MSG_TYPE_TIMESTAMP_WITH_LOCAL_TIME_ZONE
=
201
;
public
static
final
int
LOG
_MSG_TYPE_TIMESTAMP_NANO
=
202
;
public
static
final
int
LOG
_MSG_TYPE_RAW
=
203
;
public
static
final
int
LOG
_MSG_TYPE_INTERVAL_YEAR_TO_MONTH
=
204
;
public
static
final
int
LOG
_MSG_TYPE_INTERVAL_DAY_TO_SECOND
=
205
;
public
static
final
int
LOG
_MSG_TYPE_NUMBER_FLOAT
=
206
;
public
static
final
int
LOG
_MSG_TYPE_NVARCHAR2
=
207
;
public
static
final
int
LOG
_MSG_TYPE_NCHAR
=
208
;
public
static
final
int
LOG
_MSG_TYPE_ROW_ID
=
209
;
public
static
final
int
DRC
_MSG_TYPE_JSON
=
245
;
public
static
final
int
DRC
_MSG_TYPE_NEWDECIMAL
=
246
;
public
static
final
int
DRC
_MSG_TYPE_ENUM
=
247
;
public
static
final
int
DRC
_MSG_TYPE_SET
=
248
;
public
static
final
int
DRC
_MSG_TYPE_TINY_BLOB
=
249
;
public
static
final
int
DRC
_MSG_TYPE_MEDIUM_BLOB
=
250
;
public
static
final
int
DRC
_MSG_TYPE_LONG_BLOB
=
251
;
public
static
final
int
DRC
_MSG_TYPE_BLOB
=
252
;
public
static
final
int
DRC
_MSG_TYPE_VAR_STRING
=
253
;
public
static
final
int
DRC
_MSG_TYPE_STRING
=
254
;
public
static
final
int
DRC
_MSG_TYPE_GEOMETRY
=
255
;
public
static
final
int
DRC
_MSG_TYPE_ORA_BINARY_FLOAT
=
256
;
public
static
final
int
DRC
_MSG_TYPE_ORA_BINARY_DOUBLE
=
257
;
public
static
final
int
DRC_MSG_TYPE_UNKNOWN
=
DRC
_MSG_TYPE_ORA_BINARY_DOUBLE
+
1
;
public
static
final
int
LOG
_MSG_TYPE_JSON
=
245
;
public
static
final
int
LOG
_MSG_TYPE_NEWDECIMAL
=
246
;
public
static
final
int
LOG
_MSG_TYPE_ENUM
=
247
;
public
static
final
int
LOG
_MSG_TYPE_SET
=
248
;
public
static
final
int
LOG
_MSG_TYPE_TINY_BLOB
=
249
;
public
static
final
int
LOG
_MSG_TYPE_MEDIUM_BLOB
=
250
;
public
static
final
int
LOG
_MSG_TYPE_LONG_BLOB
=
251
;
public
static
final
int
LOG
_MSG_TYPE_BLOB
=
252
;
public
static
final
int
LOG
_MSG_TYPE_VAR_STRING
=
253
;
public
static
final
int
LOG
_MSG_TYPE_STRING
=
254
;
public
static
final
int
LOG
_MSG_TYPE_GEOMETRY
=
255
;
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
;
}
common/src/main/java/com/oceanbase/oms/logmessage/typehelper/LogTypeHelper.java
浏览文件 @
426f63aa
...
...
@@ -11,8 +11,8 @@ 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
;
import
com.oceanbase.oms.logmessage.enums.DBType
;
public
abstract
class
LogTypeHelper
{
...
...
@@ -20,13 +20,13 @@ public abstract class LogTypeHelper {
public
static
final
String
EMPTY_ENCODING_STR
=
""
;
protected
final
D
BType
dbType
;
protected
final
D
bTypeEnum
dbType
;
public
LogTypeHelper
(
D
BType
dbType
)
{
public
LogTypeHelper
(
D
bTypeEnum
dbType
)
{
this
.
dbType
=
dbType
;
}
public
D
BType
getDbType
()
{
public
D
bTypeEnum
getDbType
()
{
return
dbType
;
}
...
...
common/src/main/java/com/oceanbase/oms/logmessage/typehelper/LogTypeHelperFactory.java
浏览文件 @
426f63aa
...
...
@@ -11,17 +11,18 @@ See the Mulan PSL v2 for more details. */
package
com.oceanbase.oms.logmessage.typehelper
;
import
com.oceanbase.oms.
logmessage.enums.DBType
;
import
com.oceanbase.oms.
common.enums.DbTypeEnum
;
public
abstract
class
LogTypeHelperFactory
{
public
static
LogTypeHelper
getInstance
(
D
BType
dbType
)
{
public
static
LogTypeHelper
getInstance
(
D
bTypeEnum
dbType
)
{
switch
(
dbType
)
{
case
OCEANBASE:
case
OCEANBASE1:
case
OB_MYSQL:
case
OB_ORACLE:
case
OB_05:
return
OBLogTypeHelper
.
OB_LOG_TYPE_HELPER
;
default
:
throw
new
RuntimeException
(
"unsupported dbtype"
);
throw
new
IllegalArgumentException
(
"Unsupported dbType "
+
dbType
);
}
}
}
common/src/main/java/com/oceanbase/oms/logmessage/typehelper/OBLogTypeHelper.java
浏览文件 @
426f63aa
...
...
@@ -11,8 +11,8 @@ 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
;
import
com.oceanbase.oms.logmessage.enums.DBType
;
import
org.apache.commons.lang3.StringUtils
;
public
class
OBLogTypeHelper
extends
LogTypeHelper
{
...
...
@@ -21,14 +21,14 @@ public class OBLogTypeHelper extends LogTypeHelper {
private
static
final
String
DEFAULT_ENCODING
=
""
;
public
OBLogTypeHelper
()
{
super
(
D
BType
.
OCEANBASE1
);
super
(
D
bTypeEnum
.
OB_MYSQL
);
}
@Override
public
String
correctEncoding
(
int
typeCode
,
String
realEncoding
)
{
switch
(
typeCode
)
{
case
LogMessageTypeCode
.
DRC
_MSG_TYPE_VAR_STRING
:
case
LogMessageTypeCode
.
DRC
_MSG_TYPE_STRING
:
case
LogMessageTypeCode
.
LOG
_MSG_TYPE_VAR_STRING
:
case
LogMessageTypeCode
.
LOG
_MSG_TYPE_STRING
:
return
realEncoding
;
default
:
if
(
StringUtils
.
equals
(
realEncoding
,
"binary"
))
{
...
...
@@ -42,23 +42,23 @@ public class OBLogTypeHelper extends LogTypeHelper {
@Override
public
int
correctCode
(
int
typeCode
,
String
encoding
)
{
switch
(
typeCode
)
{
case
LogMessageTypeCode
.
DRC
_MSG_TYPE_TINY_BLOB
:
case
LogMessageTypeCode
.
DRC
_MSG_TYPE_MEDIUM_BLOB
:
case
LogMessageTypeCode
.
DRC
_MSG_TYPE_LONG_BLOB
:
case
LogMessageTypeCode
.
DRC
_MSG_TYPE_BLOB
:
case
LogMessageTypeCode
.
LOG
_MSG_TYPE_TINY_BLOB
:
case
LogMessageTypeCode
.
LOG
_MSG_TYPE_MEDIUM_BLOB
:
case
LogMessageTypeCode
.
LOG
_MSG_TYPE_LONG_BLOB
:
case
LogMessageTypeCode
.
LOG
_MSG_TYPE_BLOB
:
if
(!
StringUtils
.
isEmpty
(
encoding
)
&&
!
StringUtils
.
equals
(
encoding
,
"binary"
))
{
return
LogMessageTypeCode
.
DRC
_MSG_TYPE_CLOB
;
return
LogMessageTypeCode
.
LOG
_MSG_TYPE_CLOB
;
}
break
;
case
LogMessageTypeCode
.
DRC
_MSG_TYPE_VAR_STRING
:
case
LogMessageTypeCode
.
LOG
_MSG_TYPE_VAR_STRING
:
if
(
StringUtils
.
isEmpty
(
encoding
)
||
StringUtils
.
equals
(
encoding
,
"binary"
))
{
return
LogMessageTypeCode
.
DRC
_MSG_TYPE_VAR_BINARY
;
return
LogMessageTypeCode
.
LOG
_MSG_TYPE_VAR_BINARY
;
}
else
{
return
LogMessageTypeCode
.
DRC
_MSG_TYPE_VARCHAR
;
return
LogMessageTypeCode
.
LOG
_MSG_TYPE_VARCHAR
;
}
case
LogMessageTypeCode
.
DRC
_MSG_TYPE_STRING
:
case
LogMessageTypeCode
.
LOG
_MSG_TYPE_STRING
:
if
(
StringUtils
.
isEmpty
(
encoding
)
||
StringUtils
.
equals
(
encoding
,
"binary"
))
{
return
LogMessageTypeCode
.
DRC
_MSG_TYPE_BINARY
;
return
LogMessageTypeCode
.
LOG
_MSG_TYPE_BINARY
;
}
break
;
}
...
...
@@ -68,24 +68,24 @@ public class OBLogTypeHelper extends LogTypeHelper {
@Override
public
void
correctField
(
DataMessage
.
Record
.
Field
f
,
String
realEncoding
)
{
switch
(
f
.
type
)
{
case
LogMessageTypeCode
.
DRC
_MSG_TYPE_TINY_BLOB
:
case
LogMessageTypeCode
.
DRC
_MSG_TYPE_MEDIUM_BLOB
:
case
LogMessageTypeCode
.
DRC
_MSG_TYPE_LONG_BLOB
:
case
LogMessageTypeCode
.
DRC
_MSG_TYPE_BLOB
:
case
LogMessageTypeCode
.
LOG
_MSG_TYPE_TINY_BLOB
:
case
LogMessageTypeCode
.
LOG
_MSG_TYPE_MEDIUM_BLOB
:
case
LogMessageTypeCode
.
LOG
_MSG_TYPE_LONG_BLOB
:
case
LogMessageTypeCode
.
LOG
_MSG_TYPE_BLOB
:
if
(!
StringUtils
.
isEmpty
(
f
.
encoding
)
&&
!
StringUtils
.
equals
(
f
.
encoding
,
"binary"
))
{
f
.
type
=
LogMessageTypeCode
.
DRC
_MSG_TYPE_CLOB
;
f
.
type
=
LogMessageTypeCode
.
LOG
_MSG_TYPE_CLOB
;
}
break
;
case
LogMessageTypeCode
.
DRC
_MSG_TYPE_VAR_STRING
:
case
LogMessageTypeCode
.
LOG
_MSG_TYPE_VAR_STRING
:
if
(
StringUtils
.
isEmpty
(
f
.
encoding
)
||
StringUtils
.
equals
(
f
.
encoding
,
"binary"
))
{
f
.
type
=
LogMessageTypeCode
.
DRC
_MSG_TYPE_VAR_BINARY
;
f
.
type
=
LogMessageTypeCode
.
LOG
_MSG_TYPE_VAR_BINARY
;
}
else
{
f
.
type
=
LogMessageTypeCode
.
DRC
_MSG_TYPE_VARCHAR
;
f
.
type
=
LogMessageTypeCode
.
LOG
_MSG_TYPE_VARCHAR
;
}
break
;
case
LogMessageTypeCode
.
DRC
_MSG_TYPE_STRING
:
case
LogMessageTypeCode
.
LOG
_MSG_TYPE_STRING
:
if
(
StringUtils
.
isEmpty
(
f
.
encoding
)
||
StringUtils
.
equals
(
f
.
encoding
,
"binary"
))
{
f
.
type
=
LogMessageTypeCode
.
DRC
_MSG_TYPE_BINARY
;
f
.
type
=
LogMessageTypeCode
.
LOG
_MSG_TYPE_BINARY
;
}
break
;
default
:
...
...
common/src/main/java/com/oceanbase/oms/logmessage/utils/StringUtils.java
已删除
100644 → 0
浏览文件 @
92bcf94e
/* 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.utils
;
import
java.util.ArrayList
;
import
java.util.List
;
/** Utils class for string. */
public
class
StringUtils
{
/**
* Split a string by one separator character. The performance is better than Java String split.
*
* @param str The string need be split.
* @param separatorChar The single separator character.
* @return The array of split items.
*/
public
static
String
[]
split
(
String
str
,
char
separatorChar
)
{
if
(
str
==
null
)
{
return
null
;
}
int
length
=
str
.
length
();
if
(
length
==
0
)
{
return
null
;
}
List
<
String
>
list
=
new
ArrayList
<
String
>();
int
i
=
0
;
int
start
=
0
;
boolean
match
=
false
;
while
(
i
<
length
)
{
if
(
str
.
charAt
(
i
)
==
separatorChar
)
{
if
(
match
)
{
list
.
add
(
str
.
substring
(
start
,
i
));
match
=
false
;
}
start
=
++
i
;
continue
;
}
match
=
true
;
i
++;
}
if
(
match
)
{
list
.
add
(
str
.
substring
(
start
,
i
));
}
return
list
.
toArray
(
new
String
[
list
.
size
()]);
}
}
logproxy-client/src/main/java/com/oceanbase/clogproxy/client/config/ObReaderConfig.java
浏览文件 @
426f63aa
...
...
@@ -114,7 +114,7 @@ public class ObReaderConfig extends AbstractConnectionConfig {
}
@Override
public
Map
<
String
,
String
>
generateConfigurationMap
(
boolean
encrypt
_p
assword
)
{
public
Map
<
String
,
String
>
generateConfigurationMap
(
boolean
encrypt
P
assword
)
{
Map
<
String
,
String
>
result
=
new
HashMap
<>();
for
(
Map
.
Entry
<
String
,
ConfigItem
<
Object
>>
entry
:
configs
.
entrySet
())
{
String
value
=
entry
.
getValue
().
val
.
toString
();
...
...
@@ -123,7 +123,7 @@ public class ObReaderConfig extends AbstractConnectionConfig {
if
(
clusterUrl
.
key
.
equals
(
entry
.
getKey
())
&&
StringUtils
.
isEmpty
(
value
))
{
continue
;
}
if
(
encrypt
_p
assword
if
(
encrypt
P
assword
&&
clusterPassword
.
key
.
equals
(
entry
.
getKey
())
&&
SharedConf
.
AUTH_PASSWORD_HASH
)
{
value
=
Hex
.
str
(
CryptoUtil
.
sha1
(
value
));
...
...
pom.xml
浏览文件 @
426f63aa
...
...
@@ -259,7 +259,7 @@ See the Mulan PSL v2 for more details.
<id>
spotless-check
</id>
<phase>
validate
</phase>
<goals>
<goal>
check
</goal>
<goal>
apply
</goal>
</goals>
</execution>
</executions>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录