2021-11-10 23:56:52 +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
|
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// 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-09-15 10:13:49 +08:00
|
|
|
package proxy
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2023-01-11 14:35:40 +08:00
|
|
|
|
2023-09-21 09:45:27 +08:00
|
|
|
"go.uber.org/atomic"
|
2023-09-26 09:57:25 +08:00
|
|
|
"google.golang.org/grpc"
|
2023-09-21 09:45:27 +08:00
|
|
|
|
2023-06-09 01:28:37 +08:00
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
|
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
|
2021-11-10 21:10:46 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/datapb"
|
2023-01-12 09:55:42 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/indexpb"
|
2021-09-15 10:13:49 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/internalpb"
|
2023-01-12 09:55:42 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/types"
|
2023-04-06 19:14:32 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/util/funcutil"
|
2023-09-20 10:57:23 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/util/merr"
|
2023-04-06 19:14:32 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/util/typeutil"
|
|
|
|
"github.com/milvus-io/milvus/pkg/util/uniquegenerator"
|
2021-09-15 10:13:49 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type DataCoordMock struct {
|
2023-09-26 09:57:25 +08:00
|
|
|
types.DataCoordClient
|
2023-01-12 09:55:42 +08:00
|
|
|
|
2021-09-15 10:13:49 +08:00
|
|
|
nodeID typeutil.UniqueID
|
|
|
|
address string
|
|
|
|
|
|
|
|
state atomic.Value // internal.StateCode
|
|
|
|
|
2022-08-12 13:20:39 +08:00
|
|
|
getMetricsFunc getMetricsFuncType
|
|
|
|
showConfigurationsFunc showConfigurationsFuncType
|
|
|
|
statisticsChannel string
|
|
|
|
timeTickChannel string
|
2023-09-26 09:57:25 +08:00
|
|
|
checkHealthFunc func(ctx context.Context, req *milvuspb.CheckHealthRequest, opts ...grpc.CallOption) (*milvuspb.CheckHealthResponse, error)
|
|
|
|
GetIndexStateFunc func(ctx context.Context, request *indexpb.GetIndexStateRequest, opts ...grpc.CallOption) (*indexpb.GetIndexStateResponse, error)
|
|
|
|
DescribeIndexFunc func(ctx context.Context, request *indexpb.DescribeIndexRequest, opts ...grpc.CallOption) (*indexpb.DescribeIndexResponse, error)
|
2021-09-15 10:13:49 +08:00
|
|
|
}
|
|
|
|
|
2022-10-10 15:55:22 +08:00
|
|
|
func (coord *DataCoordMock) updateState(state commonpb.StateCode) {
|
2021-09-15 10:13:49 +08:00
|
|
|
coord.state.Store(state)
|
|
|
|
}
|
|
|
|
|
2022-10-10 15:55:22 +08:00
|
|
|
func (coord *DataCoordMock) getState() commonpb.StateCode {
|
|
|
|
return coord.state.Load().(commonpb.StateCode)
|
2021-09-15 10:13:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (coord *DataCoordMock) healthy() bool {
|
2022-10-10 15:55:22 +08:00
|
|
|
return coord.getState() == commonpb.StateCode_Healthy
|
2021-09-15 10:13:49 +08:00
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetComponentStates(ctx context.Context, req *milvuspb.GetComponentStatesRequest, opts ...grpc.CallOption) (*milvuspb.ComponentStates, error) {
|
2022-10-10 15:55:22 +08:00
|
|
|
return &milvuspb.ComponentStates{
|
|
|
|
State: &milvuspb.ComponentInfo{
|
2021-09-15 10:13:49 +08:00
|
|
|
NodeID: coord.nodeID,
|
|
|
|
Role: typeutil.DataCoordRole,
|
|
|
|
StateCode: coord.getState(),
|
|
|
|
ExtraInfo: nil,
|
|
|
|
},
|
|
|
|
SubcomponentStates: nil,
|
2023-10-11 21:01:35 +08:00
|
|
|
Status: merr.Success(),
|
2021-09-15 10:13:49 +08:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetStatisticsChannel(ctx context.Context, req *internalpb.GetStatisticsChannelRequest, opts ...grpc.CallOption) (*milvuspb.StringResponse, error) {
|
2021-09-15 10:13:49 +08:00
|
|
|
return &milvuspb.StringResponse{
|
2023-10-11 21:01:35 +08:00
|
|
|
Status: merr.Success(),
|
2023-09-20 10:57:23 +08:00
|
|
|
Value: coord.statisticsChannel,
|
2021-09-15 10:13:49 +08:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (coord *DataCoordMock) Register() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetTimeTickChannel(ctx context.Context, req *internalpb.GetTimeTickChannelRequest, opts ...grpc.CallOption) (*milvuspb.StringResponse, error) {
|
2021-09-15 10:13:49 +08:00
|
|
|
return &milvuspb.StringResponse{
|
2023-10-11 21:01:35 +08:00
|
|
|
Status: merr.Success(),
|
2023-09-20 10:57:23 +08:00
|
|
|
Value: coord.timeTickChannel,
|
2021-09-15 10:13:49 +08:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) Flush(ctx context.Context, req *datapb.FlushRequest, opts ...grpc.CallOption) (*datapb.FlushResponse, error) {
|
2021-09-15 10:13:49 +08:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) SaveImportSegment(ctx context.Context, req *datapb.SaveImportSegmentRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2022-09-26 18:06:54 +08:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) UnsetIsImportingState(ctx context.Context, in *datapb.UnsetIsImportingStateRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2022-09-26 18:06:54 +08:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) MarkSegmentsDropped(ctx context.Context, req *datapb.MarkSegmentsDroppedRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2022-06-02 18:54:04 +08:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) BroadcastAlteredCollection(ctx context.Context, req *datapb.AlterCollectionRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2022-10-10 20:31:22 +08:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) CheckHealth(ctx context.Context, req *milvuspb.CheckHealthRequest, opts ...grpc.CallOption) (*milvuspb.CheckHealthResponse, error) {
|
2022-10-18 13:39:26 +08:00
|
|
|
if coord.checkHealthFunc != nil {
|
|
|
|
return coord.checkHealthFunc(ctx, req)
|
|
|
|
}
|
|
|
|
return &milvuspb.CheckHealthResponse{IsHealthy: true}, nil
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) AssignSegmentID(ctx context.Context, req *datapb.AssignSegmentIDRequest, opts ...grpc.CallOption) (*datapb.AssignSegmentIDResponse, error) {
|
2021-09-15 10:13:49 +08:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetSegmentStates(ctx context.Context, req *datapb.GetSegmentStatesRequest, opts ...grpc.CallOption) (*datapb.GetSegmentStatesResponse, error) {
|
2021-09-15 10:13:49 +08:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetInsertBinlogPaths(ctx context.Context, req *datapb.GetInsertBinlogPathsRequest, opts ...grpc.CallOption) (*datapb.GetInsertBinlogPathsResponse, error) {
|
2021-09-15 10:13:49 +08:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetSegmentInfoChannel(ctx context.Context, in *datapb.GetSegmentInfoChannelRequest, opts ...grpc.CallOption) (*milvuspb.StringResponse, error) {
|
2021-09-15 10:13:49 +08:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetCollectionStatistics(ctx context.Context, req *datapb.GetCollectionStatisticsRequest, opts ...grpc.CallOption) (*datapb.GetCollectionStatisticsResponse, error) {
|
2021-09-15 10:13:49 +08:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetPartitionStatistics(ctx context.Context, req *datapb.GetPartitionStatisticsRequest, opts ...grpc.CallOption) (*datapb.GetPartitionStatisticsResponse, error) {
|
2021-09-15 10:13:49 +08:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetSegmentInfo(ctx context.Context, req *datapb.GetSegmentInfoRequest, opts ...grpc.CallOption) (*datapb.GetSegmentInfoResponse, error) {
|
2021-09-15 10:13:49 +08:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetRecoveryInfo(ctx context.Context, req *datapb.GetRecoveryInfoRequest, opts ...grpc.CallOption) (*datapb.GetRecoveryInfoResponse, error) {
|
2021-09-15 10:13:49 +08:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) SaveBinlogPaths(ctx context.Context, req *datapb.SaveBinlogPathsRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2021-09-15 10:13:49 +08:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetFlushedSegments(ctx context.Context, req *datapb.GetFlushedSegmentsRequest, opts ...grpc.CallOption) (*datapb.GetFlushedSegmentsResponse, error) {
|
2022-10-08 11:51:02 +08:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetSegmentsByStates(ctx context.Context, req *datapb.GetSegmentsByStatesRequest, opts ...grpc.CallOption) (*datapb.GetSegmentsByStatesResponse, error) {
|
2021-09-15 10:13:49 +08:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) ShowConfigurations(ctx context.Context, req *internalpb.ShowConfigurationsRequest, opts ...grpc.CallOption) (*internalpb.ShowConfigurationsResponse, error) {
|
2022-08-12 13:20:39 +08:00
|
|
|
if !coord.healthy() {
|
|
|
|
return &internalpb.ShowConfigurationsResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UnexpectedError,
|
|
|
|
Reason: "unhealthy",
|
|
|
|
},
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if coord.showConfigurationsFunc != nil {
|
|
|
|
return coord.showConfigurationsFunc(ctx, req)
|
|
|
|
}
|
|
|
|
|
|
|
|
return &internalpb.ShowConfigurationsResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UnexpectedError,
|
|
|
|
Reason: "not implemented",
|
|
|
|
},
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest, opts ...grpc.CallOption) (*milvuspb.GetMetricsResponse, error) {
|
2021-09-15 10:13:49 +08:00
|
|
|
if !coord.healthy() {
|
|
|
|
return &milvuspb.GetMetricsResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UnexpectedError,
|
|
|
|
Reason: "unhealthy",
|
|
|
|
},
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if coord.getMetricsFunc != nil {
|
|
|
|
return coord.getMetricsFunc(ctx, req)
|
|
|
|
}
|
|
|
|
|
|
|
|
return &milvuspb.GetMetricsResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UnexpectedError,
|
|
|
|
Reason: "not implemented",
|
|
|
|
},
|
|
|
|
Response: "",
|
|
|
|
ComponentName: "",
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2023-11-14 15:56:19 +08:00
|
|
|
func (coord *DataCoordMock) CompleteCompaction(ctx context.Context, req *datapb.CompactionPlanResult, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2021-11-05 22:25:00 +08:00
|
|
|
return &commonpb.Status{}, nil
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) ManualCompaction(ctx context.Context, req *milvuspb.ManualCompactionRequest, opts ...grpc.CallOption) (*milvuspb.ManualCompactionResponse, error) {
|
2021-11-09 14:47:02 +08:00
|
|
|
return &milvuspb.ManualCompactionResponse{}, nil
|
2021-11-05 22:25:00 +08:00
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetCompactionState(ctx context.Context, req *milvuspb.GetCompactionStateRequest, opts ...grpc.CallOption) (*milvuspb.GetCompactionStateResponse, error) {
|
2021-11-09 14:47:02 +08:00
|
|
|
return &milvuspb.GetCompactionStateResponse{}, nil
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetCompactionStateWithPlans(ctx context.Context, req *milvuspb.GetCompactionPlansRequest, opts ...grpc.CallOption) (*milvuspb.GetCompactionPlansResponse, error) {
|
2021-11-09 14:47:02 +08:00
|
|
|
return &milvuspb.GetCompactionPlansResponse{}, nil
|
2021-11-05 22:25:00 +08:00
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) WatchChannels(ctx context.Context, req *datapb.WatchChannelsRequest, opts ...grpc.CallOption) (*datapb.WatchChannelsResponse, error) {
|
2021-11-11 00:54:45 +08:00
|
|
|
return &datapb.WatchChannelsResponse{}, nil
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetFlushState(ctx context.Context, req *datapb.GetFlushStateRequest, opts ...grpc.CallOption) (*milvuspb.GetFlushStateResponse, error) {
|
2021-11-23 10:55:14 +08:00
|
|
|
return &milvuspb.GetFlushStateResponse{}, nil
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetFlushAllState(ctx context.Context, req *milvuspb.GetFlushAllStateRequest, opts ...grpc.CallOption) (*milvuspb.GetFlushAllStateResponse, error) {
|
2023-03-30 11:28:25 +08:00
|
|
|
return &milvuspb.GetFlushAllStateResponse{}, nil
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) DropVirtualChannel(ctx context.Context, req *datapb.DropVirtualChannelRequest, opts ...grpc.CallOption) (*datapb.DropVirtualChannelResponse, error) {
|
2021-11-29 22:35:41 +08:00
|
|
|
return &datapb.DropVirtualChannelResponse{}, nil
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) SetSegmentState(ctx context.Context, req *datapb.SetSegmentStateRequest, opts ...grpc.CallOption) (*datapb.SetSegmentStateResponse, error) {
|
2022-04-06 15:33:32 +08:00
|
|
|
return &datapb.SetSegmentStateResponse{}, nil
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) Import(ctx context.Context, req *datapb.ImportTaskRequest, opts ...grpc.CallOption) (*datapb.ImportTaskResponse, error) {
|
2022-03-22 15:11:24 +08:00
|
|
|
return &datapb.ImportTaskResponse{}, nil
|
2022-03-09 18:33:59 +08:00
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) UpdateSegmentStatistics(ctx context.Context, req *datapb.UpdateSegmentStatisticsRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2023-10-11 21:01:35 +08:00
|
|
|
return merr.Success(), nil
|
2022-04-20 14:03:40 +08:00
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) UpdateChannelCheckpoint(ctx context.Context, req *datapb.UpdateChannelCheckpointRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2023-10-11 21:01:35 +08:00
|
|
|
return merr.Success(), nil
|
2022-11-10 22:13:04 +08:00
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) CreateIndex(ctx context.Context, req *indexpb.CreateIndexRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2023-10-11 21:01:35 +08:00
|
|
|
return merr.Success(), nil
|
2022-05-31 16:36:03 +08:00
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) DropIndex(ctx context.Context, req *indexpb.DropIndexRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2023-10-11 21:01:35 +08:00
|
|
|
return merr.Success(), nil
|
2022-05-31 16:36:03 +08:00
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetIndexState(ctx context.Context, req *indexpb.GetIndexStateRequest, opts ...grpc.CallOption) (*indexpb.GetIndexStateResponse, error) {
|
2023-12-28 16:40:46 +08:00
|
|
|
if coord.GetIndexStateFunc != nil {
|
|
|
|
return coord.GetIndexStateFunc(ctx, req, opts...)
|
|
|
|
}
|
2023-01-11 14:35:40 +08:00
|
|
|
return &indexpb.GetIndexStateResponse{
|
2023-10-11 21:01:35 +08:00
|
|
|
Status: merr.Success(),
|
2023-01-04 19:37:36 +08:00
|
|
|
State: commonpb.IndexState_Finished,
|
|
|
|
FailReason: "",
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetSegmentIndexState gets the index state of the segments in the request from RootCoord.
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetSegmentIndexState(ctx context.Context, req *indexpb.GetSegmentIndexStateRequest, opts ...grpc.CallOption) (*indexpb.GetSegmentIndexStateResponse, error) {
|
2023-01-11 14:35:40 +08:00
|
|
|
return &indexpb.GetSegmentIndexStateResponse{
|
2023-10-11 21:01:35 +08:00
|
|
|
Status: merr.Success(),
|
2023-01-04 19:37:36 +08:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetIndexInfos gets the index files of the IndexBuildIDs in the request from RootCoordinator.
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetIndexInfos(ctx context.Context, req *indexpb.GetIndexInfoRequest, opts ...grpc.CallOption) (*indexpb.GetIndexInfoResponse, error) {
|
2023-01-11 14:35:40 +08:00
|
|
|
return &indexpb.GetIndexInfoResponse{
|
2023-10-11 21:01:35 +08:00
|
|
|
Status: merr.Success(),
|
2023-01-04 19:37:36 +08:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// DescribeIndex describe the index info of the collection.
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) DescribeIndex(ctx context.Context, req *indexpb.DescribeIndexRequest, opts ...grpc.CallOption) (*indexpb.DescribeIndexResponse, error) {
|
2023-12-28 16:40:46 +08:00
|
|
|
if coord.DescribeIndexFunc != nil {
|
|
|
|
return coord.DescribeIndexFunc(ctx, req, opts...)
|
|
|
|
}
|
2023-01-11 14:35:40 +08:00
|
|
|
return &indexpb.DescribeIndexResponse{
|
2023-10-11 21:01:35 +08:00
|
|
|
Status: merr.Success(),
|
2023-01-04 19:37:36 +08:00
|
|
|
IndexInfos: nil,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2023-05-06 10:34:39 +08:00
|
|
|
// GetIndexStatistics get the statistics of the index.
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetIndexStatistics(ctx context.Context, req *indexpb.GetIndexStatisticsRequest, opts ...grpc.CallOption) (*indexpb.GetIndexStatisticsResponse, error) {
|
2023-05-06 10:34:39 +08:00
|
|
|
return &indexpb.GetIndexStatisticsResponse{
|
2023-10-11 21:01:35 +08:00
|
|
|
Status: merr.Success(),
|
2023-05-06 10:34:39 +08:00
|
|
|
IndexInfos: nil,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2023-01-04 19:37:36 +08:00
|
|
|
// GetIndexBuildProgress get the index building progress by num rows.
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) GetIndexBuildProgress(ctx context.Context, req *indexpb.GetIndexBuildProgressRequest, opts ...grpc.CallOption) (*indexpb.GetIndexBuildProgressResponse, error) {
|
2023-01-11 14:35:40 +08:00
|
|
|
return &indexpb.GetIndexBuildProgressResponse{
|
2023-10-11 21:01:35 +08:00
|
|
|
Status: merr.Success(),
|
2023-01-04 19:37:36 +08:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (coord *DataCoordMock) Close() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-09-15 10:13:49 +08:00
|
|
|
func NewDataCoordMock() *DataCoordMock {
|
2023-09-26 09:57:25 +08:00
|
|
|
dc := &DataCoordMock{
|
2021-09-15 10:13:49 +08:00
|
|
|
nodeID: typeutil.UniqueID(uniquegenerator.GetUniqueIntGeneratorIns().GetInt()),
|
|
|
|
address: funcutil.GenRandomStr(), // random address
|
|
|
|
state: atomic.Value{},
|
|
|
|
getMetricsFunc: nil,
|
|
|
|
statisticsChannel: funcutil.GenRandomStr(),
|
|
|
|
timeTickChannel: funcutil.GenRandomStr(),
|
|
|
|
}
|
2023-09-26 09:57:25 +08:00
|
|
|
dc.updateState(commonpb.StateCode_Healthy)
|
|
|
|
return dc
|
2021-09-15 10:13:49 +08:00
|
|
|
}
|