Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
kafka-manager
提交
663e871b
K
kafka-manager
项目概览
DiDi
/
kafka-manager
7 个月 前同步成功
通知
58
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,体验更适合开发者的 AI 搜索 >>
提交
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 {
@Autowired
private
TopicConnectionDao
topicConnectionDao
;
private
int
splitInterval
=
50
;
@Override
public
void
batchAdd
(
List
<
TopicConnectionDO
>
doList
)
{
if
(
ValidateUtils
.
isEmptyList
(
doList
))
{
return
;
}
int
allSize
=
doList
.
size
();
int
successSize
=
0
;
int
count
=
0
;
for
(
TopicConnectionDO
connectionDO:
doList
)
{
try
{
count
+=
topicConnectionDao
.
replace
(
connectionDO
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"class=TopicConnectionServiceImpl||method=batchAdd||connectionDO={}||errMsg={}"
,
connectionDO
,
e
.
getMessage
());
}
int
part
=
doList
.
size
()
/
splitInterval
;
for
(
int
i
=
0
;
i
<
part
;
++
i
)
{
List
<
TopicConnectionDO
>
subList
=
doList
.
subList
(
0
,
splitInterval
);
successSize
+=
topicConnectionDao
.
batchReplace
(
subList
);
doList
.
subList
(
0
,
splitInterval
).
clear
();
}
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
...
...
kafka-manager-dao/src/main/java/com/xiaojukeji/kafka/manager/dao/gateway/TopicConnectionDao.java
浏览文件 @
663e871b
...
...
@@ -13,8 +13,6 @@ import java.util.List;
public
interface
TopicConnectionDao
{
int
batchReplace
(
List
<
TopicConnectionDO
>
doList
);
int
replace
(
TopicConnectionDO
topicConnectionDO
);
List
<
TopicConnectionDO
>
getByTopicName
(
Long
clusterId
,
String
topicName
,
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 {
@Override
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
{
return
sqlSession
.
insert
(
"TopicConnectionDao.
replace"
,
topicConnectionDO
);
return
sqlSession
.
insert
(
"TopicConnectionDao.
batchReplace"
,
doList
);
}
catch
(
DeadlockLoserDataAccessException
e1
)
{
return
0
;
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"add topic connection info, clusterId:{} topicName:{}."
,
topicConnectionDO
.
getClusterId
(),
topicConnectionDO
.
getTopicName
(),
e
);
LOGGER
.
error
(
"add topic connections info failed"
,
e
);
}
return
0
;
}
...
...
kafka-manager-dao/src/main/resources/mapper/TopicConnectionDao.xml
浏览文件 @
663e871b
...
...
@@ -13,7 +13,7 @@
<result
property=
"createTime"
column=
"create_time"
/>
</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 (
cluster_id,
topic_name,
...
...
@@ -22,16 +22,19 @@
ip,
client_version,
create_time
)
VALUES (
#{clusterId},
#{topicName},
#{type},
#{appId},
#{ip},
#{clientVersion},
#{createTime}
)
)
VALUES
<foreach
collection=
"list"
item=
"item"
index=
"index"
separator=
","
>
(
#{item.clusterId},
#{item.topicName},
#{item.type},
#{item.appId},
#{item.ip},
#{item.clientVersion},
#{item.createTime}
)
</foreach>
</insert>
<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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录