2021-10-25 20:21:18 +08:00
|
|
|
// Licensed to the LF AI & Data foundation under one
|
|
|
|
// or more contributor license agreements. See the NOTICE file
|
|
|
|
// distributed with this work for additional information
|
|
|
|
// regarding copyright ownership. The ASF licenses this file
|
|
|
|
// to you under the Apache License, Version 2.0 (the
|
|
|
|
// "License"); you may not use this file except in compliance
|
2021-04-19 11:35:38 +08:00
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
2021-10-25 20:21:18 +08:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2021-04-19 11:35:38 +08:00
|
|
|
//
|
2021-10-25 20:21:18 +08:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2021-06-22 10:42:07 +08:00
|
|
|
package datacoord
|
2021-01-22 19:43:27 +08:00
|
|
|
|
|
|
|
import (
|
2021-02-26 17:44:24 +08:00
|
|
|
"context"
|
2021-09-07 13:59:58 +08:00
|
|
|
"errors"
|
2021-01-22 19:43:27 +08:00
|
|
|
"sync/atomic"
|
|
|
|
"time"
|
|
|
|
|
2021-09-08 11:35:59 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/kv"
|
2021-09-01 10:13:15 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/util/metricsinfo"
|
|
|
|
"github.com/milvus-io/milvus/internal/util/typeutil"
|
|
|
|
|
2021-04-22 14:45:57 +08:00
|
|
|
memkv "github.com/milvus-io/milvus/internal/kv/mem"
|
|
|
|
"github.com/milvus-io/milvus/internal/util/tsoutil"
|
2021-03-05 20:41:34 +08:00
|
|
|
|
2021-04-22 14:45:57 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/commonpb"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/datapb"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/internalpb"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/milvuspb"
|
2021-06-17 17:45:56 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/proxypb"
|
2021-06-22 16:14:09 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/rootcoordpb"
|
2021-04-22 14:45:57 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/schemapb"
|
2021-01-22 19:43:27 +08:00
|
|
|
)
|
|
|
|
|
2021-05-28 09:55:21 +08:00
|
|
|
func newMemoryMeta(allocator allocator) (*meta, error) {
|
2021-01-22 19:43:27 +08:00
|
|
|
memoryKV := memkv.NewMemoryKV()
|
2021-10-02 23:09:56 +08:00
|
|
|
return newMeta(memoryKV)
|
2021-01-22 19:43:27 +08:00
|
|
|
}
|
|
|
|
|
2021-08-23 17:59:51 +08:00
|
|
|
var _ allocator = (*MockAllocator)(nil)
|
|
|
|
|
2021-01-22 19:43:27 +08:00
|
|
|
type MockAllocator struct {
|
|
|
|
cnt int64
|
|
|
|
}
|
|
|
|
|
2021-08-23 17:59:51 +08:00
|
|
|
func (m *MockAllocator) allocTimestamp(ctx context.Context) (Timestamp, error) {
|
2021-01-22 19:43:27 +08:00
|
|
|
val := atomic.AddInt64(&m.cnt, 1)
|
|
|
|
phy := time.Now().UnixNano() / int64(time.Millisecond)
|
|
|
|
ts := tsoutil.ComposeTS(phy, val)
|
|
|
|
return ts, nil
|
|
|
|
}
|
|
|
|
|
2021-08-23 17:59:51 +08:00
|
|
|
func (m *MockAllocator) allocID(ctx context.Context) (UniqueID, error) {
|
2021-01-22 19:43:27 +08:00
|
|
|
val := atomic.AddInt64(&m.cnt, 1)
|
|
|
|
return val, nil
|
|
|
|
}
|
|
|
|
|
2021-09-08 11:35:59 +08:00
|
|
|
var _ allocator = (*FailsAllocator)(nil)
|
|
|
|
|
2021-09-07 13:59:58 +08:00
|
|
|
// FailsAllocator allocator that fails
|
|
|
|
type FailsAllocator struct{}
|
|
|
|
|
|
|
|
func (a *FailsAllocator) allocTimestamp(_ context.Context) (Timestamp, error) {
|
|
|
|
return 0, errors.New("always fail")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *FailsAllocator) allocID(_ context.Context) (UniqueID, error) {
|
|
|
|
return 0, errors.New("always fail")
|
|
|
|
}
|
|
|
|
|
2021-09-08 11:35:59 +08:00
|
|
|
// a mock kv that always fail when do `Save`
|
|
|
|
type saveFailKV struct{ kv.TxnKV }
|
|
|
|
|
|
|
|
// Save override behavior
|
|
|
|
func (kv *saveFailKV) Save(key, value string) error {
|
|
|
|
return errors.New("mocked fail")
|
|
|
|
}
|
|
|
|
|
2021-10-12 23:46:35 +08:00
|
|
|
func (kv *saveFailKV) MultiSave(kvs map[string]string) error {
|
|
|
|
return errors.New("mocked fail")
|
|
|
|
}
|
|
|
|
|
2021-09-08 11:35:59 +08:00
|
|
|
// a mock kv that always fail when do `Remove`
|
|
|
|
type removeFailKV struct{ kv.TxnKV }
|
|
|
|
|
|
|
|
// Remove override behavior, inject error
|
|
|
|
func (kv *removeFailKV) Remove(key string) error {
|
|
|
|
return errors.New("mocked fail")
|
|
|
|
}
|
|
|
|
|
2021-01-22 19:43:27 +08:00
|
|
|
func newMockAllocator() *MockAllocator {
|
|
|
|
return &MockAllocator{}
|
|
|
|
}
|
|
|
|
|
2021-01-23 14:41:29 +08:00
|
|
|
func newTestSchema() *schemapb.CollectionSchema {
|
2021-01-22 19:43:27 +08:00
|
|
|
return &schemapb.CollectionSchema{
|
|
|
|
Name: "test",
|
|
|
|
Description: "schema for test used",
|
|
|
|
AutoID: false,
|
|
|
|
Fields: []*schemapb.FieldSchema{
|
2021-03-12 14:22:09 +08:00
|
|
|
{FieldID: 1, Name: "field1", IsPrimaryKey: false, Description: "field no.1", DataType: schemapb.DataType_String},
|
|
|
|
{FieldID: 2, Name: "field2", IsPrimaryKey: false, Description: "field no.2", DataType: schemapb.DataType_FloatVector},
|
2021-01-22 19:43:27 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2021-02-02 18:53:10 +08:00
|
|
|
|
|
|
|
type mockDataNodeClient struct {
|
2021-04-08 15:08:34 +08:00
|
|
|
id int64
|
|
|
|
state internalpb.StateCode
|
2021-05-25 15:35:37 +08:00
|
|
|
ch chan interface{}
|
2021-04-08 15:08:34 +08:00
|
|
|
}
|
|
|
|
|
2021-05-26 19:06:56 +08:00
|
|
|
func newMockDataNodeClient(id int64, ch chan interface{}) (*mockDataNodeClient, error) {
|
2021-04-08 15:08:34 +08:00
|
|
|
return &mockDataNodeClient{
|
|
|
|
id: id,
|
|
|
|
state: internalpb.StateCode_Initializing,
|
2021-05-26 19:06:56 +08:00
|
|
|
ch: ch,
|
2021-05-25 15:47:08 +08:00
|
|
|
}, nil
|
2021-02-02 18:53:10 +08:00
|
|
|
}
|
|
|
|
|
2021-03-05 20:41:34 +08:00
|
|
|
func (c *mockDataNodeClient) Init() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *mockDataNodeClient) Start() error {
|
2021-04-08 15:08:34 +08:00
|
|
|
c.state = internalpb.StateCode_Healthy
|
2021-03-05 20:41:34 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-05-25 15:06:05 +08:00
|
|
|
func (c *mockDataNodeClient) Register() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-03-12 14:22:09 +08:00
|
|
|
func (c *mockDataNodeClient) GetComponentStates(ctx context.Context) (*internalpb.ComponentStates, error) {
|
2021-04-08 15:08:34 +08:00
|
|
|
return &internalpb.ComponentStates{
|
|
|
|
State: &internalpb.ComponentInfo{
|
|
|
|
NodeID: c.id,
|
|
|
|
StateCode: c.state,
|
|
|
|
},
|
|
|
|
}, nil
|
2021-03-05 20:41:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *mockDataNodeClient) GetStatisticsChannel(ctx context.Context) (*milvuspb.StringResponse, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2021-03-12 14:22:09 +08:00
|
|
|
func (c *mockDataNodeClient) WatchDmChannels(ctx context.Context, in *datapb.WatchDmChannelsRequest) (*commonpb.Status, error) {
|
2021-03-10 22:06:22 +08:00
|
|
|
return &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success}, nil
|
2021-02-02 18:53:10 +08:00
|
|
|
}
|
|
|
|
|
2021-03-12 14:22:09 +08:00
|
|
|
func (c *mockDataNodeClient) FlushSegments(ctx context.Context, in *datapb.FlushSegmentsRequest) (*commonpb.Status, error) {
|
2021-05-25 15:35:37 +08:00
|
|
|
if c.ch != nil {
|
|
|
|
c.ch <- in
|
|
|
|
}
|
2021-03-10 22:06:22 +08:00
|
|
|
return &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success}, nil
|
2021-02-02 18:53:10 +08:00
|
|
|
}
|
|
|
|
|
2021-09-01 17:35:00 +08:00
|
|
|
func (c *mockDataNodeClient) GetMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) {
|
|
|
|
// TODO(dragondriver): change the id, though it's not important in ut
|
2021-09-09 10:16:00 +08:00
|
|
|
nodeID := UniqueID(c.id)
|
2021-09-01 17:35:00 +08:00
|
|
|
|
|
|
|
nodeInfos := metricsinfo.DataNodeInfos{
|
|
|
|
BaseComponentInfos: metricsinfo.BaseComponentInfos{
|
|
|
|
Name: metricsinfo.ConstructComponentName(typeutil.DataNodeRole, nodeID),
|
2021-10-14 11:12:38 +08:00
|
|
|
ID: nodeID,
|
2021-09-01 17:35:00 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
resp, err := metricsinfo.MarshalComponentInfos(nodeInfos)
|
|
|
|
if err != nil {
|
|
|
|
return &milvuspb.GetMetricsResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UnexpectedError,
|
|
|
|
Reason: err.Error(),
|
|
|
|
},
|
|
|
|
Response: "",
|
|
|
|
ComponentName: metricsinfo.ConstructComponentName(typeutil.DataNodeRole, nodeID),
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return &milvuspb.GetMetricsResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_Success,
|
|
|
|
Reason: "",
|
|
|
|
},
|
|
|
|
Response: resp,
|
|
|
|
ComponentName: metricsinfo.ConstructComponentName(typeutil.DataNodeRole, nodeID),
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2021-02-02 18:53:10 +08:00
|
|
|
func (c *mockDataNodeClient) Stop() error {
|
2021-04-08 15:08:34 +08:00
|
|
|
c.state = internalpb.StateCode_Abnormal
|
2021-02-02 18:53:10 +08:00
|
|
|
return nil
|
|
|
|
}
|
2021-04-13 09:47:02 +08:00
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
type mockRootCoordService struct {
|
2021-08-23 17:59:51 +08:00
|
|
|
state internalpb.StateCode
|
|
|
|
cnt int64
|
2021-04-13 09:47:02 +08:00
|
|
|
}
|
|
|
|
|
2021-09-18 11:13:51 +08:00
|
|
|
func (m *mockRootCoordService) CreateAlias(ctx context.Context, req *milvuspb.CreateAliasRequest) (*commonpb.Status, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockRootCoordService) DropAlias(ctx context.Context, req *milvuspb.DropAliasRequest) (*commonpb.Status, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockRootCoordService) AlterAlias(ctx context.Context, req *milvuspb.AlterAliasRequest) (*commonpb.Status, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func newMockRootCoordService() *mockRootCoordService {
|
2021-08-23 17:59:51 +08:00
|
|
|
return &mockRootCoordService{state: internalpb.StateCode_Healthy}
|
2021-04-13 09:47:02 +08:00
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) GetTimeTickChannel(ctx context.Context) (*milvuspb.StringResponse, error) {
|
2021-04-24 17:23:35 +08:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) Init() error {
|
2021-04-13 09:47:02 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) Start() error {
|
2021-04-13 09:47:02 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) Stop() error {
|
2021-08-23 17:59:51 +08:00
|
|
|
m.state = internalpb.StateCode_Abnormal
|
2021-04-13 09:47:02 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) Register() error {
|
2021-05-25 15:06:05 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) GetComponentStates(ctx context.Context) (*internalpb.ComponentStates, error) {
|
2021-04-13 09:47:02 +08:00
|
|
|
return &internalpb.ComponentStates{
|
|
|
|
State: &internalpb.ComponentInfo{
|
|
|
|
NodeID: 0,
|
|
|
|
Role: "",
|
2021-08-23 17:59:51 +08:00
|
|
|
StateCode: m.state,
|
2021-04-13 09:47:02 +08:00
|
|
|
ExtraInfo: []*commonpb.KeyValuePair{},
|
|
|
|
},
|
|
|
|
SubcomponentStates: []*internalpb.ComponentInfo{},
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_Success,
|
|
|
|
Reason: "",
|
|
|
|
},
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) GetStatisticsChannel(ctx context.Context) (*milvuspb.StringResponse, error) {
|
2021-04-13 09:47:02 +08:00
|
|
|
panic("not implemented") // TODO: Implement
|
|
|
|
}
|
|
|
|
|
|
|
|
//DDL request
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) CreateCollection(ctx context.Context, req *milvuspb.CreateCollectionRequest) (*commonpb.Status, error) {
|
2021-04-13 09:47:02 +08:00
|
|
|
panic("not implemented") // TODO: Implement
|
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) DropCollection(ctx context.Context, req *milvuspb.DropCollectionRequest) (*commonpb.Status, error) {
|
2021-04-13 09:47:02 +08:00
|
|
|
panic("not implemented") // TODO: Implement
|
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) HasCollection(ctx context.Context, req *milvuspb.HasCollectionRequest) (*milvuspb.BoolResponse, error) {
|
2021-04-13 09:47:02 +08:00
|
|
|
panic("not implemented") // TODO: Implement
|
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) DescribeCollection(ctx context.Context, req *milvuspb.DescribeCollectionRequest) (*milvuspb.DescribeCollectionResponse, error) {
|
2021-04-16 16:30:55 +08:00
|
|
|
return &milvuspb.DescribeCollectionResponse{
|
|
|
|
Status: &commonpb.Status{
|
2021-04-24 11:29:15 +08:00
|
|
|
ErrorCode: commonpb.ErrorCode_Success,
|
2021-04-16 16:30:55 +08:00
|
|
|
Reason: "",
|
|
|
|
},
|
2021-04-24 11:29:15 +08:00
|
|
|
Schema: &schemapb.CollectionSchema{
|
|
|
|
Name: "test",
|
|
|
|
},
|
2021-06-07 09:47:36 +08:00
|
|
|
CollectionID: 1314,
|
|
|
|
VirtualChannelNames: []string{"vchan1"},
|
2021-04-16 16:30:55 +08:00
|
|
|
}, nil
|
2021-04-13 09:47:02 +08:00
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) ShowCollections(ctx context.Context, req *milvuspb.ShowCollectionsRequest) (*milvuspb.ShowCollectionsResponse, error) {
|
2021-04-13 09:47:02 +08:00
|
|
|
return &milvuspb.ShowCollectionsResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_Success,
|
|
|
|
Reason: "",
|
|
|
|
},
|
2021-04-24 11:29:15 +08:00
|
|
|
CollectionNames: []string{"test"},
|
2021-04-13 09:47:02 +08:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) CreatePartition(ctx context.Context, req *milvuspb.CreatePartitionRequest) (*commonpb.Status, error) {
|
2021-04-13 09:47:02 +08:00
|
|
|
panic("not implemented") // TODO: Implement
|
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) DropPartition(ctx context.Context, req *milvuspb.DropPartitionRequest) (*commonpb.Status, error) {
|
2021-04-13 09:47:02 +08:00
|
|
|
panic("not implemented") // TODO: Implement
|
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) HasPartition(ctx context.Context, req *milvuspb.HasPartitionRequest) (*milvuspb.BoolResponse, error) {
|
2021-04-13 09:47:02 +08:00
|
|
|
panic("not implemented") // TODO: Implement
|
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) ShowPartitions(ctx context.Context, req *milvuspb.ShowPartitionsRequest) (*milvuspb.ShowPartitionsResponse, error) {
|
2021-04-24 11:29:15 +08:00
|
|
|
return &milvuspb.ShowPartitionsResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_Success,
|
|
|
|
Reason: "",
|
|
|
|
},
|
|
|
|
PartitionNames: []string{"_default"},
|
|
|
|
PartitionIDs: []int64{0},
|
|
|
|
}, nil
|
2021-04-13 09:47:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//index builder service
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) CreateIndex(ctx context.Context, req *milvuspb.CreateIndexRequest) (*commonpb.Status, error) {
|
2021-04-13 09:47:02 +08:00
|
|
|
panic("not implemented") // TODO: Implement
|
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) DescribeIndex(ctx context.Context, req *milvuspb.DescribeIndexRequest) (*milvuspb.DescribeIndexResponse, error) {
|
2021-04-13 09:47:02 +08:00
|
|
|
panic("not implemented") // TODO: Implement
|
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) DropIndex(ctx context.Context, req *milvuspb.DropIndexRequest) (*commonpb.Status, error) {
|
2021-04-13 09:47:02 +08:00
|
|
|
panic("not implemented") // TODO: Implement
|
|
|
|
}
|
|
|
|
|
|
|
|
//global timestamp allocator
|
2021-06-22 16:14:09 +08:00
|
|
|
func (m *mockRootCoordService) AllocTimestamp(ctx context.Context, req *rootcoordpb.AllocTimestampRequest) (*rootcoordpb.AllocTimestampResponse, error) {
|
2021-08-23 17:59:51 +08:00
|
|
|
if m.state != internalpb.StateCode_Healthy {
|
|
|
|
return &rootcoordpb.AllocTimestampResponse{Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_UnexpectedError}}, nil
|
|
|
|
}
|
|
|
|
|
2021-04-16 16:30:55 +08:00
|
|
|
val := atomic.AddInt64(&m.cnt, int64(req.Count))
|
|
|
|
phy := time.Now().UnixNano() / int64(time.Millisecond)
|
|
|
|
ts := tsoutil.ComposeTS(phy, val)
|
2021-06-22 16:14:09 +08:00
|
|
|
return &rootcoordpb.AllocTimestampResponse{
|
2021-04-16 16:30:55 +08:00
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_Success,
|
|
|
|
Reason: "",
|
|
|
|
},
|
|
|
|
Timestamp: ts,
|
|
|
|
Count: req.Count,
|
|
|
|
}, nil
|
2021-04-13 09:47:02 +08:00
|
|
|
}
|
|
|
|
|
2021-06-22 16:14:09 +08:00
|
|
|
func (m *mockRootCoordService) AllocID(ctx context.Context, req *rootcoordpb.AllocIDRequest) (*rootcoordpb.AllocIDResponse, error) {
|
2021-08-23 17:59:51 +08:00
|
|
|
if m.state != internalpb.StateCode_Healthy {
|
|
|
|
return &rootcoordpb.AllocIDResponse{Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_UnexpectedError}}, nil
|
|
|
|
}
|
2021-04-16 16:30:55 +08:00
|
|
|
val := atomic.AddInt64(&m.cnt, int64(req.Count))
|
2021-06-22 16:14:09 +08:00
|
|
|
return &rootcoordpb.AllocIDResponse{
|
2021-04-16 16:30:55 +08:00
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_Success,
|
|
|
|
Reason: "",
|
|
|
|
},
|
|
|
|
ID: val,
|
|
|
|
Count: req.Count,
|
|
|
|
}, nil
|
2021-04-13 09:47:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//segment
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) DescribeSegment(ctx context.Context, req *milvuspb.DescribeSegmentRequest) (*milvuspb.DescribeSegmentResponse, error) {
|
2021-04-13 09:47:02 +08:00
|
|
|
panic("not implemented") // TODO: Implement
|
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) ShowSegments(ctx context.Context, req *milvuspb.ShowSegmentsRequest) (*milvuspb.ShowSegmentsResponse, error) {
|
2021-04-13 09:47:02 +08:00
|
|
|
panic("not implemented") // TODO: Implement
|
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) GetDdChannel(ctx context.Context) (*milvuspb.StringResponse, error) {
|
2021-04-13 09:47:02 +08:00
|
|
|
return &milvuspb.StringResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_Success,
|
|
|
|
Reason: "",
|
|
|
|
},
|
|
|
|
Value: "ddchannel",
|
|
|
|
}, nil
|
|
|
|
}
|
2021-05-21 16:08:12 +08:00
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) UpdateChannelTimeTick(ctx context.Context, req *internalpb.ChannelTimeTickMsg) (*commonpb.Status, error) {
|
2021-05-21 16:08:12 +08:00
|
|
|
panic("not implemented") // TODO: Implement
|
|
|
|
}
|
2021-05-25 16:22:02 +08:00
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
func (m *mockRootCoordService) ReleaseDQLMessageStream(ctx context.Context, req *proxypb.ReleaseDQLMessageStreamRequest) (*commonpb.Status, error) {
|
2021-06-17 17:45:56 +08:00
|
|
|
panic("not implemented") // TODO: Implement
|
|
|
|
}
|
2021-07-02 11:16:20 +08:00
|
|
|
func (m *mockRootCoordService) SegmentFlushCompleted(ctx context.Context, in *datapb.SegmentFlushCompletedMsg) (*commonpb.Status, error) {
|
|
|
|
return &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success}, nil
|
2021-07-01 14:58:17 +08:00
|
|
|
}
|
|
|
|
func (m *mockRootCoordService) AddNewSegment(ctx context.Context, in *datapb.SegmentMsg) (*commonpb.Status, error) {
|
|
|
|
panic("not implemented") // TODO: Implement
|
|
|
|
}
|
2021-09-01 10:13:15 +08:00
|
|
|
|
2021-09-01 17:35:00 +08:00
|
|
|
func (m *mockRootCoordService) GetMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) {
|
2021-09-01 10:13:15 +08:00
|
|
|
// TODO(dragondriver): change the id, though it's not important in ut
|
2021-09-01 17:35:00 +08:00
|
|
|
nodeID := UniqueID(20210901)
|
2021-09-01 10:13:15 +08:00
|
|
|
|
2021-09-01 17:35:00 +08:00
|
|
|
rootCoordTopology := metricsinfo.RootCoordTopology{
|
|
|
|
Self: metricsinfo.RootCoordInfos{
|
|
|
|
BaseComponentInfos: metricsinfo.BaseComponentInfos{
|
|
|
|
Name: metricsinfo.ConstructComponentName(typeutil.RootCoordRole, nodeID),
|
2021-10-14 11:12:38 +08:00
|
|
|
ID: nodeID,
|
2021-09-01 17:35:00 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Connections: metricsinfo.ConnTopology{
|
|
|
|
Name: metricsinfo.ConstructComponentName(typeutil.RootCoordRole, nodeID),
|
|
|
|
// TODO(dragondriver): fill ConnectedComponents if necessary
|
|
|
|
ConnectedComponents: []metricsinfo.ConnectionInfo{},
|
2021-09-01 10:13:15 +08:00
|
|
|
},
|
|
|
|
}
|
2021-09-01 17:35:00 +08:00
|
|
|
|
|
|
|
resp, err := metricsinfo.MarshalTopology(rootCoordTopology)
|
2021-09-01 10:13:15 +08:00
|
|
|
if err != nil {
|
|
|
|
return &milvuspb.GetMetricsResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UnexpectedError,
|
|
|
|
Reason: err.Error(),
|
|
|
|
},
|
|
|
|
Response: "",
|
2021-09-01 17:35:00 +08:00
|
|
|
ComponentName: metricsinfo.ConstructComponentName(typeutil.RootCoordRole, nodeID),
|
2021-09-01 10:13:15 +08:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return &milvuspb.GetMetricsResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_Success,
|
|
|
|
Reason: "",
|
|
|
|
},
|
|
|
|
Response: resp,
|
2021-09-01 17:35:00 +08:00
|
|
|
ComponentName: metricsinfo.ConstructComponentName(typeutil.RootCoordRole, nodeID),
|
2021-09-01 10:13:15 +08:00
|
|
|
}, nil
|
|
|
|
}
|