Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
544c701f
M
milvus
项目概览
milvus
/
milvus
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
544c701f
编写于
11月 18, 2020
作者:
N
neza2017
提交者:
yefu.chen
11月 18, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Start timeSyncMsgProducer in master
Signed-off-by:
N
neza2017
<
yefu.chen@zilliz.com
>
上级
3ae7cd59
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
174 addition
and
10 deletion
+174
-10
cmd/master/main.go
cmd/master/main.go
+18
-1
internal/master/collection_task_test.go
internal/master/collection_task_test.go
+18
-1
internal/master/grpc_service_test.go
internal/master/grpc_service_test.go
+18
-1
internal/master/master.go
internal/master/master.go
+71
-4
internal/master/partition_task_test.go
internal/master/partition_task_test.go
+18
-1
internal/master/timesync/timetick.go
internal/master/timesync/timetick.go
+13
-1
internal/proxy/proxy_test.go
internal/proxy/proxy_test.go
+18
-1
未找到文件。
cmd/master/main.go
浏览文件 @
544c701f
...
...
@@ -20,8 +20,25 @@ func main() {
etcdAddress
,
_
:=
masterParams
.
Params
.
EtcdAddress
()
etcdRootPath
,
_
:=
masterParams
.
Params
.
EtcdRootPath
()
pulsarAddr
,
_
:=
masterParams
.
Params
.
PulsarAddress
()
svr
,
err
:=
master
.
CreateServer
(
ctx
,
etcdRootPath
,
etcdRootPath
,
[]
string
{
etcdAddress
})
opt
:=
master
.
Option
{
KVRootPath
:
etcdRootPath
,
MetaRootPath
:
etcdRootPath
,
EtcdAddr
:
[]
string
{
etcdAddress
},
PulsarAddr
:
pulsarAddr
,
ProxyIDs
:
nil
,
PulsarProxyChannels
:
nil
,
PulsarProxySubName
:
""
,
SoftTTBInterval
:
0
,
WriteIDs
:
nil
,
PulsarWriteChannels
:
nil
,
PulsarWriteSubName
:
""
,
PulsarDMChannels
:
nil
,
PulsarK2SChannels
:
nil
,
}
svr
,
err
:=
master
.
CreateServer
(
ctx
,
&
opt
)
if
err
!=
nil
{
log
.
Print
(
"create server failed"
,
zap
.
Error
(
err
))
}
...
...
internal/master/collection_task_test.go
浏览文件 @
544c701f
...
...
@@ -13,6 +13,7 @@ import (
"github.com/zilliztech/milvus-distributed/internal/proto/masterpb"
"github.com/zilliztech/milvus-distributed/internal/proto/schemapb"
"github.com/zilliztech/milvus-distributed/internal/proto/servicepb"
"github.com/zilliztech/milvus-distributed/internal/util/typeutil"
"go.etcd.io/etcd/clientv3"
"google.golang.org/grpc"
)
...
...
@@ -30,7 +31,23 @@ func TestMaster_CollectionTask(t *testing.T) {
_
,
err
=
etcdCli
.
Delete
(
ctx
,
"/test/root"
,
clientv3
.
WithPrefix
())
assert
.
Nil
(
t
,
err
)
svr
,
err
:=
CreateServer
(
ctx
,
"/test/root/kv"
,
"/test/root/meta"
,
[]
string
{
etcdAddr
})
opt
:=
Option
{
KVRootPath
:
"/test/root/kv"
,
MetaRootPath
:
"/test/root/meta"
,
EtcdAddr
:
[]
string
{
etcdAddr
},
PulsarAddr
:
"pulsar://localhost:6650"
,
ProxyIDs
:
[]
typeutil
.
UniqueID
{
1
,
2
},
PulsarProxyChannels
:
[]
string
{
"proxy1"
,
"proxy2"
},
PulsarProxySubName
:
"proxyTopics"
,
SoftTTBInterval
:
300
,
WriteIDs
:
[]
typeutil
.
UniqueID
{
3
,
4
},
PulsarWriteChannels
:
[]
string
{
"write3"
,
"write4"
},
PulsarWriteSubName
:
"writeTopics"
,
PulsarDMChannels
:
[]
string
{
"dm0"
,
"dm1"
},
PulsarK2SChannels
:
[]
string
{
"k2s0"
,
"k2s1"
},
}
svr
,
err
:=
CreateServer
(
ctx
,
&
opt
)
assert
.
Nil
(
t
,
err
)
err
=
svr
.
Run
(
10002
)
assert
.
Nil
(
t
,
err
)
...
...
internal/master/grpc_service_test.go
浏览文件 @
544c701f
...
...
@@ -11,6 +11,7 @@ import (
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb"
"github.com/zilliztech/milvus-distributed/internal/proto/masterpb"
"github.com/zilliztech/milvus-distributed/internal/proto/schemapb"
"github.com/zilliztech/milvus-distributed/internal/util/typeutil"
"go.etcd.io/etcd/clientv3"
"google.golang.org/grpc"
)
...
...
@@ -30,7 +31,23 @@ func TestMaster_CreateCollection(t *testing.T) {
_
,
err
=
etcdCli
.
Delete
(
ctx
,
"/test/root"
,
clientv3
.
WithPrefix
())
assert
.
Nil
(
t
,
err
)
svr
,
err
:=
CreateServer
(
ctx
,
"/test/root/kv"
,
"/test/root/meta"
,
[]
string
{
etcdAddr
})
opt
:=
Option
{
KVRootPath
:
"/test/root/kv"
,
MetaRootPath
:
"/test/root/meta"
,
EtcdAddr
:
[]
string
{
etcdAddr
},
PulsarAddr
:
"pulsar://localhost:6650"
,
ProxyIDs
:
[]
typeutil
.
UniqueID
{
1
,
2
},
PulsarProxyChannels
:
[]
string
{
"proxy1"
,
"proxy2"
},
PulsarProxySubName
:
"proxyTopics"
,
SoftTTBInterval
:
300
,
WriteIDs
:
[]
typeutil
.
UniqueID
{
3
,
4
},
PulsarWriteChannels
:
[]
string
{
"write3"
,
"write4"
},
PulsarWriteSubName
:
"writeTopics"
,
PulsarDMChannels
:
[]
string
{
"dm0"
,
"dm1"
},
PulsarK2SChannels
:
[]
string
{
"k2s0"
,
"k2s1"
},
}
svr
,
err
:=
CreateServer
(
ctx
,
&
opt
)
assert
.
Nil
(
t
,
err
)
err
=
svr
.
Run
(
10001
)
assert
.
Nil
(
t
,
err
)
...
...
internal/master/master.go
浏览文件 @
544c701f
...
...
@@ -22,12 +22,38 @@ import (
"github.com/zilliztech/milvus-distributed/internal/master/id"
"github.com/zilliztech/milvus-distributed/internal/master/informer"
masterParams
"github.com/zilliztech/milvus-distributed/internal/master/paramtable"
"github.com/zilliztech/milvus-distributed/internal/master/timesync"
"github.com/zilliztech/milvus-distributed/internal/master/tso"
ms
"github.com/zilliztech/milvus-distributed/internal/msgstream"
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb"
"github.com/zilliztech/milvus-distributed/internal/proto/masterpb"
"github.com/zilliztech/milvus-distributed/internal/util/typeutil"
)
// Server is the pd server.
type
Option
struct
{
KVRootPath
string
MetaRootPath
string
EtcdAddr
[]
string
PulsarAddr
string
////softTimeTickBarrier
ProxyIDs
[]
typeutil
.
UniqueID
PulsarProxyChannels
[]
string
//TimeTick
PulsarProxySubName
string
SoftTTBInterval
Timestamp
//Physical Time + Logical Time
//hardTimeTickBarrier
WriteIDs
[]
typeutil
.
UniqueID
PulsarWriteChannels
[]
string
PulsarWriteSubName
string
PulsarDMChannels
[]
string
PulsarK2SChannels
[]
string
}
type
Master
struct
{
// Server state.
isServing
int64
...
...
@@ -54,6 +80,7 @@ type Master struct {
kvBase
*
kv
.
EtcdKV
scheduler
*
ddRequestScheduler
mt
*
metaTable
tsmp
timesync
.
MsgProducer
// tso ticker
tsTicker
*
time
.
Ticker
...
...
@@ -89,25 +116,57 @@ func Init() {
}
// CreateServer creates the UNINITIALIZED pd server with given configuration.
func
CreateServer
(
ctx
context
.
Context
,
kvRootPath
,
metaRootPath
string
,
etcdAddr
[]
string
)
(
*
Master
,
error
)
{
func
CreateServer
(
ctx
context
.
Context
,
opt
*
Option
)
(
*
Master
,
error
)
{
//Init(etcdAddr, kvRootPath)
etcdClient
,
err
:=
clientv3
.
New
(
clientv3
.
Config
{
Endpoints
:
e
tcdAddr
})
etcdClient
,
err
:=
clientv3
.
New
(
clientv3
.
Config
{
Endpoints
:
opt
.
E
tcdAddr
})
if
err
!=
nil
{
return
nil
,
err
}
etcdkv
:=
kv
.
NewEtcdKV
(
etcdClient
,
m
etaRootPath
)
etcdkv
:=
kv
.
NewEtcdKV
(
etcdClient
,
opt
.
M
etaRootPath
)
metakv
,
err
:=
NewMetaTable
(
etcdkv
)
if
err
!=
nil
{
return
nil
,
err
}
//timeSyncMsgProducer
tsmp
,
err
:=
timesync
.
NewTimeSyncMsgProducer
(
ctx
)
if
err
!=
nil
{
return
nil
,
err
}
pulsarProxyStream
:=
ms
.
NewPulsarMsgStream
(
ctx
,
1024
)
//output stream
pulsarProxyStream
.
SetPulsarCient
(
opt
.
PulsarAddr
)
pulsarProxyStream
.
CreatePulsarConsumers
(
opt
.
PulsarProxyChannels
,
opt
.
PulsarProxySubName
,
ms
.
NewUnmarshalDispatcher
(),
1024
)
pulsarProxyStream
.
Start
()
var
proxyStream
ms
.
MsgStream
=
pulsarProxyStream
proxyTimeTickBarrier
:=
timesync
.
NewSoftTimeTickBarrier
(
ctx
,
&
proxyStream
,
opt
.
ProxyIDs
,
opt
.
SoftTTBInterval
)
tsmp
.
SetProxyTtBarrier
(
proxyTimeTickBarrier
)
pulsarWriteStream
:=
ms
.
NewPulsarMsgStream
(
ctx
,
1024
)
//output stream
pulsarWriteStream
.
SetPulsarCient
(
opt
.
PulsarAddr
)
pulsarWriteStream
.
CreatePulsarConsumers
(
opt
.
PulsarWriteChannels
,
opt
.
PulsarWriteSubName
,
ms
.
NewUnmarshalDispatcher
(),
1024
)
pulsarWriteStream
.
Start
()
var
writeStream
ms
.
MsgStream
=
pulsarWriteStream
writeTimeTickBarrier
:=
timesync
.
NewHardTimeTickBarrier
(
ctx
,
&
writeStream
,
opt
.
WriteIDs
)
tsmp
.
SetWriteNodeTtBarrier
(
writeTimeTickBarrier
)
pulsarDMStream
:=
ms
.
NewPulsarMsgStream
(
ctx
,
1024
)
//input stream
pulsarDMStream
.
SetPulsarCient
(
opt
.
PulsarAddr
)
pulsarDMStream
.
CreatePulsarProducers
(
opt
.
PulsarDMChannels
)
tsmp
.
SetDMSyncStream
(
pulsarDMStream
)
pulsarK2SStream
:=
ms
.
NewPulsarMsgStream
(
ctx
,
1024
)
//input stream
pulsarK2SStream
.
SetPulsarCient
(
opt
.
PulsarAddr
)
pulsarK2SStream
.
CreatePulsarProducers
(
opt
.
PulsarK2SChannels
)
tsmp
.
SetK2sSyncStream
(
pulsarK2SStream
)
m
:=
&
Master
{
ctx
:
ctx
,
startTimestamp
:
time
.
Now
()
.
Unix
(),
kvBase
:
newKVBase
(
kvRootPath
,
e
tcdAddr
),
kvBase
:
newKVBase
(
opt
.
KVRootPath
,
opt
.
E
tcdAddr
),
scheduler
:
NewDDRequestScheduler
(),
mt
:
metakv
,
tsmp
:
tsmp
,
ssChan
:
make
(
chan
internalpb
.
SegmentStats
,
10
),
grpcErr
:
make
(
chan
error
),
pc
:
informer
.
NewPulsarClient
(),
...
...
@@ -189,6 +248,11 @@ func (s *Master) startServerLoop(ctx context.Context, grpcPort int64) error {
s
.
serverLoopCtx
,
s
.
serverLoopCancel
=
context
.
WithCancel
(
ctx
)
//go s.Se
s
.
serverLoopWg
.
Add
(
1
)
if
err
:=
s
.
tsmp
.
Start
();
err
!=
nil
{
return
err
}
s
.
serverLoopWg
.
Add
(
1
)
go
s
.
grpcLoop
(
grpcPort
)
...
...
@@ -209,6 +273,9 @@ func (s *Master) startServerLoop(ctx context.Context, grpcPort int64) error {
}
func
(
s
*
Master
)
stopServerLoop
()
{
s
.
tsmp
.
Close
()
s
.
serverLoopWg
.
Done
()
if
s
.
grpcServer
!=
nil
{
s
.
grpcServer
.
GracefulStop
()
log
.
Printf
(
"server is closed, exit grpc server"
)
...
...
internal/master/partition_task_test.go
浏览文件 @
544c701f
...
...
@@ -14,6 +14,7 @@ import (
"github.com/zilliztech/milvus-distributed/internal/proto/masterpb"
"github.com/zilliztech/milvus-distributed/internal/proto/schemapb"
"github.com/zilliztech/milvus-distributed/internal/proto/servicepb"
"github.com/zilliztech/milvus-distributed/internal/util/typeutil"
"go.etcd.io/etcd/clientv3"
"google.golang.org/grpc"
)
...
...
@@ -34,8 +35,24 @@ func TestMaster_Partition(t *testing.T) {
_
,
err
=
etcdCli
.
Delete
(
ctx
,
"/test/root"
,
clientv3
.
WithPrefix
())
assert
.
Nil
(
t
,
err
)
opt
:=
Option
{
KVRootPath
:
"/test/root/kv"
,
MetaRootPath
:
"/test/root/meta"
,
EtcdAddr
:
[]
string
{
etcdAddr
},
PulsarAddr
:
"pulsar://localhost:6650"
,
ProxyIDs
:
[]
typeutil
.
UniqueID
{
1
,
2
},
PulsarProxyChannels
:
[]
string
{
"proxy1"
,
"proxy2"
},
PulsarProxySubName
:
"proxyTopics"
,
SoftTTBInterval
:
300
,
WriteIDs
:
[]
typeutil
.
UniqueID
{
3
,
4
},
PulsarWriteChannels
:
[]
string
{
"write3"
,
"write4"
},
PulsarWriteSubName
:
"writeTopics"
,
PulsarDMChannels
:
[]
string
{
"dm0"
,
"dm1"
},
PulsarK2SChannels
:
[]
string
{
"k2s0"
,
"k2s1"
},
}
port
:=
10000
+
rand
.
Intn
(
1000
)
svr
,
err
:=
CreateServer
(
ctx
,
"/test/root/kv"
,
"/test/root/meta"
,
[]
string
{
etcdAddr
}
)
svr
,
err
:=
CreateServer
(
ctx
,
&
opt
)
assert
.
Nil
(
t
,
err
)
err
=
svr
.
Run
(
int64
(
port
))
assert
.
Nil
(
t
,
err
)
...
...
internal/master/timesync/timetick.go
浏览文件 @
544c701f
package
timesync
import
"github.com/zilliztech/milvus-distributed/internal/util/typeutil"
import
(
ms
"github.com/zilliztech/milvus-distributed/internal/msgstream"
"github.com/zilliztech/milvus-distributed/internal/util/typeutil"
)
type
(
UniqueID
=
typeutil
.
UniqueID
Timestamp
=
typeutil
.
Timestamp
)
type
MsgProducer
interface
{
SetProxyTtBarrier
(
proxyTtBarrier
TimeTickBarrier
)
SetWriteNodeTtBarrier
(
writeNodeTtBarrier
TimeTickBarrier
)
SetDMSyncStream
(
dmSync
ms
.
MsgStream
)
SetK2sSyncStream
(
k2sSync
ms
.
MsgStream
)
Start
()
error
Close
()
}
type
TimeTickBarrier
interface
{
GetTimeTick
()
(
Timestamp
,
error
)
Start
()
error
...
...
internal/proxy/proxy_test.go
浏览文件 @
544c701f
...
...
@@ -21,6 +21,7 @@ import (
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb"
"github.com/zilliztech/milvus-distributed/internal/proto/schemapb"
"github.com/zilliztech/milvus-distributed/internal/proto/servicepb"
"github.com/zilliztech/milvus-distributed/internal/util/typeutil"
)
var
ctx
context
.
Context
...
...
@@ -48,7 +49,23 @@ func startMaster(ctx context.Context) {
kvRootPath
:=
path
.
Join
(
rootPath
,
"kv"
)
metaRootPath
:=
path
.
Join
(
rootPath
,
"meta"
)
svr
,
err
:=
master
.
CreateServer
(
ctx
,
kvRootPath
,
metaRootPath
,
[]
string
{
etcdAddr
})
opt
:=
master
.
Option
{
KVRootPath
:
kvRootPath
,
MetaRootPath
:
metaRootPath
,
EtcdAddr
:
[]
string
{
etcdAddr
},
PulsarAddr
:
"pulsar://localhost:6650"
,
ProxyIDs
:
[]
typeutil
.
UniqueID
{
1
,
2
},
PulsarProxyChannels
:
[]
string
{
"proxy1"
,
"proxy2"
},
PulsarProxySubName
:
"proxyTopics"
,
SoftTTBInterval
:
300
,
WriteIDs
:
[]
typeutil
.
UniqueID
{
3
,
4
},
PulsarWriteChannels
:
[]
string
{
"write3"
,
"write4"
},
PulsarWriteSubName
:
"writeTopics"
,
PulsarDMChannels
:
[]
string
{
"dm0"
,
"dm1"
},
PulsarK2SChannels
:
[]
string
{
"k2s0"
,
"k2s1"
},
}
svr
,
err
:=
master
.
CreateServer
(
ctx
,
&
opt
)
masterServer
=
svr
if
err
!=
nil
{
log
.
Print
(
"create server failed"
,
zap
.
Error
(
err
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录