Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
kafka-manager
提交
663e871b
K
kafka-manager
项目概览
DiDi
/
kafka-manager
12 个月 前同步成功
通知
59
Star
6372
Fork
1229
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kafka-manager
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
663e871b
编写于
5月 07, 2021
作者:
Z
zengqiao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
连接信息写DB优化为批量写入
上级
6d19acaa
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
40 deletion
+30
-40
kafka-manager-core/src/main/java/com/xiaojukeji/kafka/manager/service/service/gateway/impl/TopicConnectionServiceImpl.java
...vice/service/gateway/impl/TopicConnectionServiceImpl.java
+14
-8
kafka-manager-dao/src/main/java/com/xiaojukeji/kafka/manager/dao/gateway/TopicConnectionDao.java
...ojukeji/kafka/manager/dao/gateway/TopicConnectionDao.java
+0
-2
kafka-manager-dao/src/main/java/com/xiaojukeji/kafka/manager/dao/gateway/impl/TopicConnectionDaoImpl.java
...afka/manager/dao/gateway/impl/TopicConnectionDaoImpl.java
+2
-19
kafka-manager-dao/src/main/resources/mapper/TopicConnectionDao.xml
...ager-dao/src/main/resources/mapper/TopicConnectionDao.xml
+14
-11
未找到文件。
kafka-manager-core/src/main/java/com/xiaojukeji/kafka/manager/service/service/gateway/impl/TopicConnectionServiceImpl.java
浏览文件 @
663e871b
...
@@ -26,21 +26,27 @@ public class TopicConnectionServiceImpl implements TopicConnectionService {
...
@@ -26,21 +26,27 @@ public class TopicConnectionServiceImpl implements TopicConnectionService {
@Autowired
@Autowired
private
TopicConnectionDao
topicConnectionDao
;
private
TopicConnectionDao
topicConnectionDao
;
private
int
splitInterval
=
50
;
@Override
@Override
public
void
batchAdd
(
List
<
TopicConnectionDO
>
doList
)
{
public
void
batchAdd
(
List
<
TopicConnectionDO
>
doList
)
{
if
(
ValidateUtils
.
isEmptyList
(
doList
))
{
if
(
ValidateUtils
.
isEmptyList
(
doList
))
{
return
;
return
;
}
}
int
allSize
=
doList
.
size
();
int
successSize
=
0
;
int
count
=
0
;
int
part
=
doList
.
size
()
/
splitInterval
;
for
(
TopicConnectionDO
connectionDO:
doList
)
{
for
(
int
i
=
0
;
i
<
part
;
++
i
)
{
try
{
List
<
TopicConnectionDO
>
subList
=
doList
.
subList
(
0
,
splitInterval
);
count
+=
topicConnectionDao
.
replace
(
connectionDO
);
successSize
+=
topicConnectionDao
.
batchReplace
(
subList
);
}
catch
(
Exception
e
)
{
doList
.
subList
(
0
,
splitInterval
).
clear
();
LOGGER
.
error
(
"class=TopicConnectionServiceImpl||method=batchAdd||connectionDO={}||errMsg={}"
,
connectionDO
,
e
.
getMessage
());
}
}
}
LOGGER
.
info
(
"class=TopicConnectionServiceImpl||method=batchAdd||allSize={}||successSize={}"
,
doList
.
size
(),
count
);
if
(!
ValidateUtils
.
isEmptyList
(
doList
))
{
successSize
+=
topicConnectionDao
.
batchReplace
(
doList
);
}
LOGGER
.
info
(
"class=TopicConnectionServiceImpl||method=batchAdd||allSize={}||successSize={}"
,
allSize
,
successSize
);
}
}
@Override
@Override
...
...
kafka-manager-dao/src/main/java/com/xiaojukeji/kafka/manager/dao/gateway/TopicConnectionDao.java
浏览文件 @
663e871b
...
@@ -13,8 +13,6 @@ import java.util.List;
...
@@ -13,8 +13,6 @@ import java.util.List;
public
interface
TopicConnectionDao
{
public
interface
TopicConnectionDao
{
int
batchReplace
(
List
<
TopicConnectionDO
>
doList
);
int
batchReplace
(
List
<
TopicConnectionDO
>
doList
);
int
replace
(
TopicConnectionDO
topicConnectionDO
);
List
<
TopicConnectionDO
>
getByTopicName
(
Long
clusterId
,
String
topicName
,
Date
startTime
,
Date
endTime
);
List
<
TopicConnectionDO
>
getByTopicName
(
Long
clusterId
,
String
topicName
,
Date
startTime
,
Date
endTime
);
List
<
TopicConnectionDO
>
getByAppId
(
String
appId
,
Date
startTime
,
Date
endTime
);
List
<
TopicConnectionDO
>
getByAppId
(
String
appId
,
Date
startTime
,
Date
endTime
);
...
...
kafka-manager-dao/src/main/java/com/xiaojukeji/kafka/manager/dao/gateway/impl/TopicConnectionDaoImpl.java
浏览文件 @
663e871b
...
@@ -27,29 +27,12 @@ public class TopicConnectionDaoImpl implements TopicConnectionDao {
...
@@ -27,29 +27,12 @@ public class TopicConnectionDaoImpl implements TopicConnectionDao {
@Override
@Override
public
int
batchReplace
(
List
<
TopicConnectionDO
>
doList
)
{
public
int
batchReplace
(
List
<
TopicConnectionDO
>
doList
)
{
int
count
=
0
;
for
(
TopicConnectionDO
elem:
doList
)
{
try
{
count
+=
sqlSession
.
insert
(
"TopicConnectionDao.replace"
,
elem
);
}
catch
(
DeadlockLoserDataAccessException
e1
)
{
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"add topic connection info, clusterId:{} topicName:{}."
,
elem
.
getClusterId
(),
elem
.
getTopicName
(),
e
);
}
}
return
count
;
}
@Override
public
int
replace
(
TopicConnectionDO
topicConnectionDO
)
{
try
{
try
{
return
sqlSession
.
insert
(
"TopicConnectionDao.
replace"
,
topicConnectionDO
);
return
sqlSession
.
insert
(
"TopicConnectionDao.
batchReplace"
,
doList
);
}
catch
(
DeadlockLoserDataAccessException
e1
)
{
}
catch
(
DeadlockLoserDataAccessException
e1
)
{
return
0
;
return
0
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"add topic connection info, clusterId:{} topicName:{}."
LOGGER
.
error
(
"add topic connections info failed"
,
e
);
,
topicConnectionDO
.
getClusterId
(),
topicConnectionDO
.
getTopicName
(),
e
);
}
}
return
0
;
return
0
;
}
}
...
...
kafka-manager-dao/src/main/resources/mapper/TopicConnectionDao.xml
浏览文件 @
663e871b
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"createTime"
column=
"create_time"
/>
</resultMap>
</resultMap>
<insert
id=
"
replace"
parameterType=
"com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.TopicConnectionDO
"
>
<insert
id=
"
batchReplace"
parameterType=
"java.util.List
"
>
REPLACE INTO topic_connections (
REPLACE INTO topic_connections (
cluster_id,
cluster_id,
topic_name,
topic_name,
...
@@ -22,16 +22,19 @@
...
@@ -22,16 +22,19 @@
ip,
ip,
client_version,
client_version,
create_time
create_time
)
)
VALUES (
VALUES
#{clusterId},
<foreach
collection=
"list"
item=
"item"
index=
"index"
separator=
","
>
#{topicName},
(
#{type},
#{item.clusterId},
#{appId},
#{item.topicName},
#{ip},
#{item.type},
#{clientVersion},
#{item.appId},
#{createTime}
#{item.ip},
)
#{item.clientVersion},
#{item.createTime}
)
</foreach>
</insert>
</insert>
<select
id=
"getByTopicName"
parameterType=
"java.util.Map"
resultMap=
"TopicConnectionMap"
>
<select
id=
"getByTopicName"
parameterType=
"java.util.Map"
resultMap=
"TopicConnectionMap"
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录