Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
21f15d66
M
milvus
项目概览
milvus
/
milvus
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
未验证
提交
21f15d66
编写于
9月 18, 2021
作者:
C
congqixia
提交者:
GitHub
9月 18, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add option for DataNode creation (#8240)
Signed-off-by:
N
Congqi Xia
<
congqi.xia@zilliz.com
>
上级
56b3b2ed
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
8 deletion
+42
-8
internal/datacoord/mock_test.go
internal/datacoord/mock_test.go
+5
-0
internal/datacoord/server.go
internal/datacoord/server.go
+17
-6
internal/datacoord/server_test.go
internal/datacoord/server_test.go
+20
-2
未找到文件。
internal/datacoord/mock_test.go
浏览文件 @
21f15d66
...
...
@@ -17,6 +17,7 @@ import (
"time"
"github.com/milvus-io/milvus/internal/kv"
"github.com/milvus-io/milvus/internal/types"
"github.com/milvus-io/milvus/internal/util/metricsinfo"
"github.com/milvus-io/milvus/internal/util/typeutil"
...
...
@@ -114,6 +115,10 @@ func newMockDataNodeClient(id int64, ch chan interface{}) (*mockDataNodeClient,
},
nil
}
var
mockDataNodeCreator
DataNodeCreatorFunc
=
func
(
_
context
.
Context
,
addr
string
)
(
types
.
DataNode
,
error
)
{
return
newMockDataNodeClient
(
0
,
nil
)
}
func
(
c
*
mockDataNodeClient
)
Init
()
error
{
return
nil
}
...
...
internal/datacoord/server.go
浏览文件 @
21f15d66
...
...
@@ -70,8 +70,11 @@ const (
ServerStateHealthy
ServerState
=
2
)
type
dataNodeCreatorFunc
func
(
ctx
context
.
Context
,
addr
string
)
(
types
.
DataNode
,
error
)
type
rootCoordCreatorFunc
func
(
ctx
context
.
Context
,
metaRootPath
string
,
etcdEndpoints
[]
string
)
(
types
.
RootCoord
,
error
)
// DataNodeCreatorFunc creator function for datanode
type
DataNodeCreatorFunc
func
(
ctx
context
.
Context
,
addr
string
)
(
types
.
DataNode
,
error
)
// RootCoordCreatorFunc creator function for rootcoord
type
RootCoordCreatorFunc
func
(
ctx
context
.
Context
,
metaRootPath
string
,
etcdEndpoints
[]
string
)
(
types
.
RootCoord
,
error
)
// Server implements `types.Datacoord`
// handles Data Cooridinator related jobs
...
...
@@ -99,8 +102,8 @@ type Server struct {
activeCh
<-
chan
bool
eventCh
<-
chan
*
sessionutil
.
SessionEvent
data
ClientCreator
d
ataNodeCreatorFunc
rootCoordClientCreator
r
ootCoordCreatorFunc
data
NodeCreator
D
ataNodeCreatorFunc
rootCoordClientCreator
R
ootCoordCreatorFunc
}
// ServerHelper datacoord server injection helper
...
...
@@ -118,7 +121,7 @@ func defaultServerHelper() ServerHelper {
type
Option
func
(
svr
*
Server
)
// SetRootCoordCreator returns an `Option` setting RootCoord creator with provided parameter
func
SetRootCoordCreator
(
creator
r
ootCoordCreatorFunc
)
Option
{
func
SetRootCoordCreator
(
creator
R
ootCoordCreatorFunc
)
Option
{
return
func
(
svr
*
Server
)
{
svr
.
rootCoordClientCreator
=
creator
}
...
...
@@ -138,6 +141,13 @@ func SetCluster(cluster *Cluster) Option {
}
}
// SetDataNodeCreator returns an `Option` setting DataNode create function
func
SetDataNodeCreator
(
creator
DataNodeCreatorFunc
)
Option
{
return
func
(
svr
*
Server
)
{
svr
.
dataNodeCreator
=
creator
}
}
// CreateServer create `Server` instance
func
CreateServer
(
ctx
context
.
Context
,
factory
msgstream
.
Factory
,
opts
...
Option
)
(
*
Server
,
error
)
{
rand
.
Seed
(
time
.
Now
()
.
UnixNano
())
...
...
@@ -145,7 +155,7 @@ func CreateServer(ctx context.Context, factory msgstream.Factory, opts ...Option
ctx
:
ctx
,
msFactory
:
factory
,
flushCh
:
make
(
chan
UniqueID
,
1024
),
data
ClientCreator
:
defaultDataNodeCreatorFunc
,
data
NodeCreator
:
defaultDataNodeCreatorFunc
,
rootCoordClientCreator
:
defaultRootCoordCreatorFunc
,
helper
:
defaultServerHelper
(),
...
...
@@ -158,6 +168,7 @@ func CreateServer(ctx context.Context, factory msgstream.Factory, opts ...Option
return
s
,
nil
}
// defaultDataNodeCreatorFunc defines the default behavior to get a DataNode
func
defaultDataNodeCreatorFunc
(
ctx
context
.
Context
,
addr
string
)
(
types
.
DataNode
,
error
)
{
return
datanodeclient
.
NewClient
(
ctx
,
addr
)
}
...
...
internal/datacoord/server_test.go
浏览文件 @
21f15d66
...
...
@@ -1252,7 +1252,7 @@ func TestOptions(t *testing.T) {
t
.
Run
(
"SetRootCoordCreator"
,
func
(
t
*
testing
.
T
)
{
svr
:=
newTestServer
(
t
,
nil
)
defer
closeTestServer
(
t
,
svr
)
var
crt
r
ootCoordCreatorFunc
=
func
(
ctx
context
.
Context
,
metaRoot
string
,
endpoints
[]
string
)
(
types
.
RootCoord
,
error
)
{
var
crt
R
ootCoordCreatorFunc
=
func
(
ctx
context
.
Context
,
metaRoot
string
,
endpoints
[]
string
)
(
types
.
RootCoord
,
error
)
{
return
nil
,
errors
.
New
(
"dummy"
)
}
opt
:=
SetRootCoordCreator
(
crt
)
...
...
@@ -1282,6 +1282,24 @@ func TestOptions(t *testing.T) {
assert
.
Equal
(
t
,
cluster
,
svr
.
cluster
)
})
t
.
Run
(
"SetDataNodeCreator"
,
func
(
t
*
testing
.
T
)
{
var
target
int64
var
val
int64
=
rand
.
Int63
()
opt
:=
SetDataNodeCreator
(
func
(
context
.
Context
,
string
)
(
types
.
DataNode
,
error
)
{
target
=
val
return
nil
,
nil
})
assert
.
NotNil
(
t
,
opt
)
factory
:=
msgstream
.
NewPmsFactory
()
svr
,
err
:=
CreateServer
(
context
.
TODO
(),
factory
,
opt
)
assert
.
Nil
(
t
,
err
)
dn
,
err
:=
svr
.
dataNodeCreator
(
context
.
Background
(),
""
)
assert
.
Nil
(
t
,
dn
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
target
,
val
)
})
}
func
TestHandleSessionEvent
(
t
*
testing
.
T
)
{
...
...
@@ -1433,7 +1451,7 @@ func newTestServer(t *testing.T, receiveCh chan interface{}, opts ...Option) *Se
svr
,
err
:=
CreateServer
(
context
.
TODO
(),
factory
,
opts
...
)
assert
.
Nil
(
t
,
err
)
svr
.
data
Client
Creator
=
func
(
ctx
context
.
Context
,
addr
string
)
(
types
.
DataNode
,
error
)
{
svr
.
data
Node
Creator
=
func
(
ctx
context
.
Context
,
addr
string
)
(
types
.
DataNode
,
error
)
{
return
newMockDataNodeClient
(
0
,
receiveCh
)
}
svr
.
rootCoordClientCreator
=
func
(
ctx
context
.
Context
,
metaRootPath
string
,
etcdEndpoints
[]
string
)
(
types
.
RootCoord
,
error
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录