2021-01-15 12:12:26 +00:00
|
|
|
package proxyservice
|
|
|
|
|
|
|
|
import (
|
2021-01-22 04:57:23 +00:00
|
|
|
"context"
|
|
|
|
"math/rand"
|
|
|
|
"time"
|
2021-01-26 05:41:41 +00:00
|
|
|
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/distributed/dataservice"
|
|
|
|
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
|
|
|
|
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb2"
|
2021-01-15 12:12:26 +00:00
|
|
|
)
|
|
|
|
|
2021-01-22 04:57:23 +00:00
|
|
|
type ServiceImpl struct {
|
|
|
|
allocator NodeIDAllocator
|
|
|
|
sched *TaskScheduler
|
2021-01-26 05:41:41 +00:00
|
|
|
tick TimeTick
|
2021-01-22 04:57:23 +00:00
|
|
|
nodeInfos *GlobalNodeInfoTable
|
2021-01-15 12:12:26 +00:00
|
|
|
|
2021-01-26 05:41:41 +00:00
|
|
|
state *internalpb2.ComponentStates
|
|
|
|
|
|
|
|
dataServiceClient *dataservice.Client
|
|
|
|
nodeStartParams []*commonpb.KeyValuePair
|
|
|
|
|
2021-01-22 04:57:23 +00:00
|
|
|
ctx context.Context
|
|
|
|
cancel context.CancelFunc
|
2021-01-15 12:12:26 +00:00
|
|
|
}
|
|
|
|
|
2021-01-22 04:57:23 +00:00
|
|
|
func CreateProxyService(ctx context.Context) (ProxyService, error) {
|
|
|
|
rand.Seed(time.Now().UnixNano())
|
|
|
|
ctx1, cancel := context.WithCancel(ctx)
|
|
|
|
s := &ServiceImpl{
|
|
|
|
ctx: ctx1,
|
|
|
|
cancel: cancel,
|
|
|
|
}
|
2021-01-15 12:12:26 +00:00
|
|
|
|
2021-01-22 04:57:23 +00:00
|
|
|
s.allocator = NewNodeIDAllocator()
|
|
|
|
s.sched = NewTaskScheduler(ctx1)
|
|
|
|
s.nodeInfos = NewGlobalNodeInfoTable()
|
2021-01-15 12:12:26 +00:00
|
|
|
|
2021-01-26 05:41:41 +00:00
|
|
|
s.state = &internalpb2.ComponentStates{
|
|
|
|
State: &internalpb2.ComponentInfo{
|
|
|
|
NodeID: 0,
|
|
|
|
Role: "proxyservice",
|
|
|
|
StateCode: internalpb2.StateCode_INITIALIZING,
|
|
|
|
},
|
|
|
|
SubcomponentStates: nil,
|
|
|
|
Status: &commonpb.Status{},
|
|
|
|
}
|
|
|
|
|
2021-01-22 04:57:23 +00:00
|
|
|
return s, nil
|
2021-01-15 12:12:26 +00:00
|
|
|
}
|