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
|
|
|
|
2021-02-08 06:30:54 +00:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/msgstream"
|
2021-01-26 05:41:41 +00:00
|
|
|
"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-29 01:27:26 +00:00
|
|
|
stateCode internalpb2.StateCode
|
2021-01-15 12:12:26 +00:00
|
|
|
|
2021-01-29 01:27:26 +00:00
|
|
|
//subStates *internalpb2.ComponentStates
|
2021-01-26 05:41:41 +00:00
|
|
|
|
2021-02-23 03:40:30 +00:00
|
|
|
nodeStartParams []*commonpb.KeyValuePair
|
2021-01-26 05:41:41 +00:00
|
|
|
|
2021-01-22 04:57:23 +00:00
|
|
|
ctx context.Context
|
|
|
|
cancel context.CancelFunc
|
2021-02-08 06:30:54 +00:00
|
|
|
|
|
|
|
msFactory msgstream.Factory
|
2021-01-15 12:12:26 +00:00
|
|
|
}
|
|
|
|
|
2021-02-08 06:30:54 +00:00
|
|
|
func NewServiceImpl(ctx context.Context, factory msgstream.Factory) (*ServiceImpl, error) {
|
2021-01-22 04:57:23 +00:00
|
|
|
rand.Seed(time.Now().UnixNano())
|
|
|
|
ctx1, cancel := context.WithCancel(ctx)
|
|
|
|
s := &ServiceImpl{
|
2021-02-08 06:30:54 +00:00
|
|
|
ctx: ctx1,
|
|
|
|
cancel: cancel,
|
|
|
|
msFactory: factory,
|
2021-01-22 04:57:23 +00:00
|
|
|
}
|
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-29 01:27:26 +00:00
|
|
|
s.stateCode = internalpb2.StateCode_ABNORMAL
|
|
|
|
|
|
|
|
return s, nil
|
|
|
|
}
|