Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
604f96ed
M
milvus
项目概览
milvus
/
milvus
大约 1 年 前同步成功
通知
261
Star
22476
Fork
2472
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
604f96ed
编写于
3月 31, 2021
作者:
Y
yukun
提交者:
yefu.chen
3月 31, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Replace consumers map by sync.map
Signed-off-by:
N
yukun
<
kun.yu@zilliz.com
>
上级
7f56f040
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
25 deletion
+38
-25
internal/msgstream/ms/msgstream_impl.go
internal/msgstream/ms/msgstream_impl.go
+0
-1
internal/util/rocksmq/client/rocksmq/client_impl.go
internal/util/rocksmq/client/rocksmq/client_impl.go
+0
-1
internal/util/rocksmq/server/rocksmq/rocksmq_impl.go
internal/util/rocksmq/server/rocksmq/rocksmq_impl.go
+38
-23
未找到文件。
internal/msgstream/ms/msgstream_impl.go
浏览文件 @
604f96ed
...
...
@@ -599,7 +599,6 @@ func (ms *TtMsgStream) findTimeTick(consumer Consumer,
}
// set msg info to tsMsg
log
.
Debug
(
msg
.
Topic
()
+
"--------"
+
string
(
msg
.
ID
()
.
Serialize
()))
tsMsg
.
SetPosition
(
&
msgstream
.
MsgPosition
{
ChannelName
:
filepath
.
Base
(
msg
.
Topic
()),
MsgID
:
msg
.
ID
()
.
Serialize
(),
...
...
internal/util/rocksmq/client/rocksmq/client_impl.go
浏览文件 @
604f96ed
...
...
@@ -99,7 +99,6 @@ func consume(ctx context.Context, consumer *consumer) {
log
.
Debug
(
"client finished"
)
return
case
_
,
ok
:=
<-
consumer
.
MsgMutex
()
:
log
.
Debug
(
"Before consume"
)
if
!
ok
{
// consumer MsgMutex closed, goroutine exit
log
.
Debug
(
"consumer MsgMutex closed"
)
...
...
internal/util/rocksmq/server/rocksmq/rocksmq_impl.go
浏览文件 @
604f96ed
...
...
@@ -60,7 +60,7 @@ type rocksmq struct {
idAllocator
allocator
.
GIDAllocator
channelMu
map
[
string
]
*
sync
.
Mutex
consumers
map
[
string
][]
*
Consumer
consumers
sync
.
Map
}
func
NewRocksMQ
(
name
string
,
idAllocator
allocator
.
GIDAllocator
)
(
*
rocksmq
,
error
)
{
...
...
@@ -84,7 +84,7 @@ func NewRocksMQ(name string, idAllocator allocator.GIDAllocator) (*rocksmq, erro
idAllocator
:
idAllocator
,
}
rmq
.
channelMu
=
make
(
map
[
string
]
*
sync
.
Mutex
)
rmq
.
consumers
=
make
(
map
[
string
][]
*
Consumer
)
rmq
.
consumers
=
sync
.
Map
{}
return
rmq
,
nil
}
...
...
@@ -135,7 +135,7 @@ func (rmq *rocksmq) DestroyTopic(topicName string) error {
return
err
}
delete
(
rmq
.
consumers
,
topicName
)
rmq
.
consumers
.
Delete
(
topicName
)
log
.
Debug
(
"DestroyTopic: "
+
topicName
)
return
nil
...
...
@@ -144,9 +144,11 @@ func (rmq *rocksmq) DestroyTopic(topicName string) error {
func
(
rmq
*
rocksmq
)
ExistConsumerGroup
(
topicName
,
groupName
string
)
(
bool
,
*
Consumer
)
{
key
:=
groupName
+
"/"
+
topicName
+
"/current_id"
if
rmq
.
checkKeyExist
(
key
)
{
for
_
,
con
:=
range
rmq
.
consumers
[
topicName
]
{
if
con
.
GroupName
==
groupName
{
return
true
,
con
if
vals
,
ok
:=
rmq
.
consumers
.
Load
(
topicName
);
ok
{
for
_
,
v
:=
range
vals
.
([]
*
Consumer
)
{
if
v
.
GroupName
==
groupName
{
return
true
,
v
}
}
}
}
...
...
@@ -169,12 +171,20 @@ func (rmq *rocksmq) CreateConsumerGroup(topicName, groupName string) error {
}
func
(
rmq
*
rocksmq
)
RegisterConsumer
(
consumer
*
Consumer
)
{
for
_
,
con
:=
range
rmq
.
consumers
[
consumer
.
Topic
]
{
if
con
.
GroupName
==
consumer
.
GroupName
{
return
if
vals
,
ok
:=
rmq
.
consumers
.
Load
(
consumer
.
Topic
);
ok
{
for
_
,
v
:=
range
vals
.
([]
*
Consumer
)
{
if
v
.
GroupName
==
consumer
.
GroupName
{
return
}
}
consumers
:=
vals
.
([]
*
Consumer
)
consumers
=
append
(
consumers
,
consumer
)
rmq
.
consumers
.
Store
(
consumer
.
Topic
,
consumers
)
}
else
{
consumers
:=
make
([]
*
Consumer
,
1
)
consumers
[
0
]
=
consumer
rmq
.
consumers
.
Store
(
consumer
.
Topic
,
consumers
)
}
rmq
.
consumers
[
consumer
.
Topic
]
=
append
(
rmq
.
consumers
[
consumer
.
Topic
],
consumer
)
}
func
(
rmq
*
rocksmq
)
DestroyConsumerGroup
(
topicName
,
groupName
string
)
error
{
...
...
@@ -185,11 +195,15 @@ func (rmq *rocksmq) DestroyConsumerGroup(topicName, groupName string) error {
log
.
Debug
(
"RocksMQ: remove "
+
key
+
" failed."
)
return
err
}
for
index
,
con
:=
range
rmq
.
consumers
[
topicName
]
{
if
con
.
GroupName
==
groupName
{
close
(
con
.
MsgMutex
)
rmq
.
consumers
[
topicName
]
=
append
(
rmq
.
consumers
[
topicName
][
:
index
],
rmq
.
consumers
[
topicName
][
index
+
1
:
]
...
)
if
vals
,
ok
:=
rmq
.
consumers
.
Load
(
topicName
);
ok
{
consumers
:=
vals
.
([]
*
Consumer
)
for
index
,
v
:=
range
consumers
{
if
v
.
GroupName
==
groupName
{
close
(
v
.
MsgMutex
)
consumers
=
append
(
consumers
[
:
index
],
consumers
[
index
+
1
:
]
...
)
rmq
.
consumers
.
Store
(
topicName
,
consumers
)
break
}
}
}
...
...
@@ -257,13 +271,14 @@ func (rmq *rocksmq) Produce(topicName string, messages []ProducerMessage) error
return
err
}
for
_
,
consumer
:=
range
rmq
.
consumers
[
topicName
]
{
// FIXME: process the problem if msgmutex is full
select
{
case
consumer
.
MsgMutex
<-
struct
{}{}
:
continue
default
:
continue
if
vals
,
ok
:=
rmq
.
consumers
.
Load
(
topicName
);
ok
{
for
_
,
v
:=
range
vals
.
([]
*
Consumer
)
{
select
{
case
v
.
MsgMutex
<-
struct
{}{}
:
continue
default
:
continue
}
}
}
return
nil
...
...
@@ -329,7 +344,7 @@ func (rmq *rocksmq) Consume(topicName string, groupName string, n int) ([]Consum
// When already consume to last mes, an empty slice will be returned
if
len
(
consumerMessage
)
==
0
{
log
.
Debug
(
"RocksMQ: consumerMessage is empty"
)
//
log.Debug("RocksMQ: consumerMessage is empty")
return
consumerMessage
,
nil
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录