From b2a86946865c2df2ec7947df65dcfbe82f0f8036 Mon Sep 17 00:00:00 2001 From: "yihao.dai" Date: Thu, 13 Mar 2025 14:26:11 +0800 Subject: [PATCH] enhance: Merge IndexNode and DataNode (#40272) Merge DataNode and IndexNode into DataNode. issue: https://github.com/milvus-io/milvus/issues/39115 --------- Signed-off-by: bigsheeper --- Makefile | 7 - cmd/components/index_coord.go | 59 - cmd/components/index_node.go | 85 -- cmd/milvus/help.go | 2 - cmd/milvus/util.go | 24 +- cmd/roles/roles.go | 45 +- configs/milvus.yaml | 9 +- .../datacoord/compaction_task_clustering.go | 2 +- internal/datacoord/index_service.go | 4 +- internal/datacoord/index_service_test.go | 6 +- internal/datacoord/metrics_info.go | 13 +- internal/datacoord/metrics_info_test.go | 284 ++--- internal/datacoord/mock_test.go | 164 --- internal/datacoord/server.go | 87 +- internal/datacoord/server_test.go | 27 +- internal/datacoord/session/common.go | 2 - .../datacoord/session/datanode_manager.go | 2 +- .../datacoord/session/indexnode_manager.go | 38 +- .../session/indexnode_manager_test.go | 20 +- .../datacoord/session/mock_worker_manager.go | 40 +- internal/datacoord/task_analyze.go | 6 +- internal/datacoord/task_index.go | 6 +- internal/datacoord/task_scheduler_test.go | 20 +- internal/datacoord/task_stats.go | 6 +- internal/datacoord/task_stats_test.go | 16 +- internal/datacoord/types.go | 6 +- internal/datanode/OWNERS | 3 + .../chunk_mgr_factory.go | 18 +- internal/datanode/data_node.go | 43 +- internal/datanode/index/init_segcore.go | 84 ++ .../index/scheduler.go} | 56 +- .../index/scheduler_test.go} | 26 +- .../task_state.go => datanode/index/state.go} | 2 +- .../index/state_test.go} | 2 +- .../{indexnode => datanode/index}/task.go | 13 +- .../index}/task_analyze.go | 34 +- .../index}/task_index.go | 66 +- internal/datanode/index/task_manager.go | 483 ++++++++ .../index/task_manager_test.go} | 55 +- .../index}/task_stats.go | 22 +- .../index}/task_stats_test.go | 26 +- .../index}/task_test.go | 13 +- .../{indexnode => datanode/index}/util.go | 29 +- .../index}/util_test.go | 2 +- .../index_services.go} | 374 +++--- .../index_services_test.go} | 385 ++++--- internal/datanode/metrics_info.go | 2 + internal/datanode/services.go | 4 +- internal/datanode/services_test.go | 17 +- .../distributed/datanode/client/client.go | 113 +- .../datanode/client/client_test.go | 157 ++- internal/distributed/datanode/service.go | 34 + internal/distributed/datanode/service_test.go | 437 +++---- .../distributed/indexnode/client/client.go | 194 ---- .../indexnode/client/client_test.go | 179 --- internal/distributed/indexnode/service.go | 329 ------ .../distributed/indexnode/service_test.go | 174 --- internal/indexnode/OWNERS | 12 - internal/indexnode/chunkmgr_mock.go | 264 ----- internal/indexnode/etcd_mock.go | 64 -- internal/indexnode/index_test.go | 185 --- internal/indexnode/indexnode.go | 400 ------- .../indexnode/indexnode_component_mock.go | 42 - internal/indexnode/indexnode_service_test.go | 233 ---- internal/indexnode/metrics_info.go | 93 -- internal/indexnode/metrics_info_test.go | 27 - internal/indexnode/taskinfo_ops.go | 449 -------- internal/mocks/mock_datacoord.go | 33 - internal/mocks/mock_datanode.go | 415 +++++++ internal/mocks/mock_datanode_client.go | 520 +++++++++ internal/mocks/mock_indexnode.go | 1018 ----------------- internal/mocks/mock_indexnode_client.go | 905 --------------- internal/proxy/metrics_info.go | 18 - internal/proxy/metrics_info_test.go | 9 +- internal/proxy/proxy_test.go | 52 +- internal/types/types.go | 35 +- internal/util/mock/grpc_datanode_client.go | 29 + pkg/metrics/datanode_metrics.go | 85 ++ pkg/metrics/indexnode_metrics.go | 111 -- pkg/metrics/metrics_test.go | 1 - pkg/proto/worker.proto | 15 - pkg/proto/workerpb/worker.pb.go | 236 ++-- pkg/proto/workerpb/worker_grpc.pb.go | 166 +-- pkg/util/metricsinfo/metrics_info.go | 24 +- pkg/util/metricsinfo/metrics_info_test.go | 43 - pkg/util/metricsinfo/topology.go | 17 +- pkg/util/metricsinfo/topology_test.go | 12 - pkg/util/paramtable/component_param.go | 36 +- pkg/util/paramtable/component_param_test.go | 15 +- scripts/run_docker.sh | 6 - scripts/run_go_unittest.sh | 9 - scripts/start_cluster.sh | 3 - tests/_helm/values/e2e/distributed | 2 + tests/_helm/values/e2e/standalone | 2 + tests/_helm/values/e2e/standalone-kafka-mmap | 2 + tests/_helm/values/e2e/standalone-one-pod | 2 + tests/_helm/values/nightly/distributed-kafka | 2 + tests/_helm/values/nightly/distributed-pulsar | 2 + tests/_helm/values/nightly/standalone | 2 + .../values/nightly/standalone-authentication | 2 + tests/_helm/values/nightly/standalone-one-pod | 2 + .../cross_cluster_routing_test.go | 11 - tests/integration/minicluster_v2.go | 20 +- .../bulk_insert/test_bulk_insert_api.py | 2 +- .../bulk_insert/test_bulk_insert_bench.py | 2 +- .../bulk_insert/test_bulk_insert_perf.py | 2 +- .../test_bulk_insert_task_clean.py | 2 +- .../test_bulk_insert_with_requests.py | 2 +- tests/python_client/chaos/checker.py | 2 +- .../chaos/test_chaos_bulk_insert.py | 2 +- .../chaos/test_load_with_checker.py | 2 +- .../test_single_request_operation.py | 2 +- tests/python_client/common/milvus_sys.py | 9 - .../testcases/test_bulk_insert.py | 2 +- tests/scripts/values/ci/pr-4am.yaml | 2 + tests/scripts/values/ci/pr-arm.yaml | 2 + tests/scripts/values/ci/pr-gpu.yaml | 2 + tests/scripts/values/ci/pr.yaml | 16 +- tests/scripts/values/pr.yaml | 2 + tests/scripts/values/qa/pr.yaml | 2 + 120 files changed, 3207 insertions(+), 6835 deletions(-) delete mode 100644 cmd/components/index_coord.go delete mode 100644 cmd/components/index_node.go rename internal/{indexnode => datanode}/chunk_mgr_factory.go (69%) create mode 100644 internal/datanode/index/init_segcore.go rename internal/{indexnode/task_scheduler.go => datanode/index/scheduler.go} (78%) rename internal/{indexnode/task_scheduler_test.go => datanode/index/scheduler_test.go} (83%) rename internal/{indexnode/task_state.go => datanode/index/state.go} (98%) rename internal/{indexnode/task_state_test.go => datanode/index/state_test.go} (98%) rename internal/{indexnode => datanode/index}/task.go (87%) rename internal/{indexnode => datanode/index}/task_analyze.go (89%) rename internal/{indexnode => datanode/index}/task_index.go (85%) create mode 100644 internal/datanode/index/task_manager.go rename internal/{indexnode/taskinfo_ops_test.go => datanode/index/task_manager_test.go} (57%) rename internal/{indexnode => datanode/index}/task_stats.go (96%) rename internal/{indexnode => datanode/index}/task_stats_test.go (90%) rename internal/{indexnode => datanode/index}/task_test.go (95%) rename internal/{indexnode => datanode/index}/util.go (76%) rename internal/{indexnode => datanode/index}/util_test.go (98%) rename internal/{indexnode/indexnode_service.go => datanode/index_services.go} (53%) rename internal/{indexnode/indexnode_test.go => datanode/index_services_test.go} (66%) delete mode 100644 internal/distributed/indexnode/client/client.go delete mode 100644 internal/distributed/indexnode/client/client_test.go delete mode 100644 internal/distributed/indexnode/service.go delete mode 100644 internal/distributed/indexnode/service_test.go delete mode 100644 internal/indexnode/OWNERS delete mode 100644 internal/indexnode/chunkmgr_mock.go delete mode 100644 internal/indexnode/etcd_mock.go delete mode 100644 internal/indexnode/index_test.go delete mode 100644 internal/indexnode/indexnode.go delete mode 100644 internal/indexnode/indexnode_component_mock.go delete mode 100644 internal/indexnode/indexnode_service_test.go delete mode 100644 internal/indexnode/metrics_info.go delete mode 100644 internal/indexnode/metrics_info_test.go delete mode 100644 internal/indexnode/taskinfo_ops.go delete mode 100644 internal/mocks/mock_indexnode.go delete mode 100644 internal/mocks/mock_indexnode_client.go delete mode 100644 pkg/metrics/indexnode_metrics.go diff --git a/Makefile b/Makefile index 7fab81fb1d..cdb58df8ee 100644 --- a/Makefile +++ b/Makefile @@ -313,10 +313,6 @@ test-rootcoord: @echo "Running go unittests..." @(env bash $(PWD)/scripts/run_go_unittest.sh -t rootcoord) -test-indexnode: - @echo "Running go unittests..." - @(env bash $(PWD)/scripts/run_go_unittest.sh -t indexnode) - test-indexcoord: @echo "Running go unittests..." @(env bash $(PWD)/scripts/run_go_unittest.sh -t indexcoord) @@ -438,8 +434,6 @@ generate-mockery-types: getdeps $(INSTALL_PATH)/mockery --name=DataCoordComponent --dir=$(PWD)/internal/types --output=$(PWD)/internal/mocks --filename=mock_datacoord.go --with-expecter --structname=MockDataCoord # DataNode $(INSTALL_PATH)/mockery --name=DataNodeComponent --dir=$(PWD)/internal/types --output=$(PWD)/internal/mocks --filename=mock_datanode.go --with-expecter --structname=MockDataNode - # IndexNode - $(INSTALL_PATH)/mockery --name=IndexNodeComponent --dir=$(PWD)/internal/types --output=$(PWD)/internal/mocks --filename=mock_indexnode.go --with-expecter --structname=MockIndexNode # Clients $(INSTALL_PATH)/mockery --name=RootCoordClient --dir=$(PWD)/internal/types --output=$(PWD)/internal/mocks --filename=mock_rootcoord_client.go --with-expecter --structname=MockRootCoordClient @@ -447,7 +441,6 @@ generate-mockery-types: getdeps $(INSTALL_PATH)/mockery --name=DataCoordClient --dir=$(PWD)/internal/types --output=$(PWD)/internal/mocks --filename=mock_datacoord_client.go --with-expecter --structname=MockDataCoordClient $(INSTALL_PATH)/mockery --name=QueryNodeClient --dir=$(PWD)/internal/types --output=$(PWD)/internal/mocks --filename=mock_querynode_client.go --with-expecter --structname=MockQueryNodeClient $(INSTALL_PATH)/mockery --name=DataNodeClient --dir=$(PWD)/internal/types --output=$(PWD)/internal/mocks --filename=mock_datanode_client.go --with-expecter --structname=MockDataNodeClient - $(INSTALL_PATH)/mockery --name=IndexNodeClient --dir=$(PWD)/internal/types --output=$(PWD)/internal/mocks --filename=mock_indexnode_client.go --with-expecter --structname=MockIndexNodeClient $(INSTALL_PATH)/mockery --name=ProxyClient --dir=$(PWD)/internal/types --output=$(PWD)/internal/mocks --filename=mock_proxy_client.go --with-expecter --structname=MockProxyClient generate-mockery-rootcoord: getdeps diff --git a/cmd/components/index_coord.go b/cmd/components/index_coord.go deleted file mode 100644 index 0531f13d87..0000000000 --- a/cmd/components/index_coord.go +++ /dev/null @@ -1,59 +0,0 @@ -// 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. - -package components - -import ( - "context" - - "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" - "github.com/milvus-io/milvus/internal/util/dependency" - "github.com/milvus-io/milvus/pkg/v2/log" - "github.com/milvus-io/milvus/pkg/v2/util/typeutil" -) - -// IndexCoord implements IndexCoord grpc server -type IndexCoord struct{} - -// NewIndexCoord creates a new IndexCoord -func NewIndexCoord(ctx context.Context, factory dependency.Factory) (*IndexCoord, error) { - return &IndexCoord{}, nil -} - -func (s *IndexCoord) Prepare() error { - return nil -} - -// Run starts service -func (s *IndexCoord) Run() error { - log.Ctx(context.TODO()).Info("IndexCoord running ...") - return nil -} - -// Stop terminates service -func (s *IndexCoord) Stop() error { - log.Ctx(context.TODO()).Info("IndexCoord stopping ...") - return nil -} - -// GetComponentStates returns indexnode's states -func (s *IndexCoord) Health(ctx context.Context) commonpb.StateCode { - return commonpb.StateCode_Healthy -} - -func (s *IndexCoord) GetName() string { - return typeutil.IndexCoordRole -} diff --git a/cmd/components/index_node.go b/cmd/components/index_node.go deleted file mode 100644 index 41c4fa4abb..0000000000 --- a/cmd/components/index_node.go +++ /dev/null @@ -1,85 +0,0 @@ -// 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. - -package components - -import ( - "context" - "time" - - "go.uber.org/zap" - - "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" - "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" - grpcindexnode "github.com/milvus-io/milvus/internal/distributed/indexnode" - "github.com/milvus-io/milvus/internal/util/dependency" - "github.com/milvus-io/milvus/pkg/v2/log" - "github.com/milvus-io/milvus/pkg/v2/util/paramtable" - "github.com/milvus-io/milvus/pkg/v2/util/typeutil" -) - -// IndexNode implements IndexNode grpc server -type IndexNode struct { - ctx context.Context - svr *grpcindexnode.Server -} - -// NewIndexNode creates a new IndexNode -func NewIndexNode(ctx context.Context, factory dependency.Factory) (*IndexNode, error) { - var err error - n := &IndexNode{ - ctx: ctx, - } - svr, err := grpcindexnode.NewServer(ctx, factory) - if err != nil { - return nil, err - } - n.svr = svr - return n, nil -} - -func (n *IndexNode) Prepare() error { - return n.svr.Prepare() -} - -// Run starts service -func (n *IndexNode) Run() error { - if err := n.svr.Run(); err != nil { - log.Ctx(n.ctx).Error("IndexNode starts error", zap.Error(err)) - return err - } - log.Ctx(n.ctx).Info("IndexNode successfully started") - return nil -} - -// Stop terminates service -func (n *IndexNode) Stop() error { - timeout := paramtable.Get().IndexNodeCfg.GracefulStopTimeout.GetAsDuration(time.Second) - return exitWhenStopTimeout(n.svr.Stop, timeout) -} - -// GetComponentStates returns IndexNode's states -func (n *IndexNode) Health(ctx context.Context) commonpb.StateCode { - resp, err := n.svr.GetComponentStates(ctx, &milvuspb.GetComponentStatesRequest{}) - if err != nil { - return commonpb.StateCode_Abnormal - } - return resp.State.GetStateCode() -} - -func (n *IndexNode) GetName() string { - return typeutil.IndexNodeRole -} diff --git a/cmd/milvus/help.go b/cmd/milvus/help.go index 0fc8ae6611..1110b53508 100644 --- a/cmd/milvus/help.go +++ b/cmd/milvus/help.go @@ -29,8 +29,6 @@ milvus run [server type] [flags] Start the rootcoord server. -querycoord 'true' Start the querycoord server. - -indexcoord 'true' - Start the indexcoord server. -datacoord 'true' Start the datacoord server. -alias '' diff --git a/cmd/milvus/util.go b/cmd/milvus/util.go index 7393638d6a..7020e10a94 100644 --- a/cmd/milvus/util.go +++ b/cmd/milvus/util.go @@ -123,8 +123,8 @@ func removePidFile(lock *flock.Flock) { } func GetMilvusRoles(args []string, flags *flag.FlagSet) *roles.MilvusRoles { - alias, enableRootCoord, enableQueryCoord, enableIndexCoord, enableDataCoord, enableQueryNode, - enableDataNode, enableIndexNode, enableProxy, enableStreamingNode := formatFlags(args, flags) + alias, enableRootCoord, enableQueryCoord, enableDataCoord, enableQueryNode, + enableDataNode, enableProxy, enableStreamingNode := formatFlags(args, flags) serverType := args[2] role := roles.NewMilvusRoles() @@ -144,10 +144,6 @@ func GetMilvusRoles(args []string, flags *flag.FlagSet) *roles.MilvusRoles { role.EnableDataCoord = true case typeutil.DataNodeRole: role.EnableDataNode = true - case typeutil.IndexCoordRole: - role.EnableIndexCoord = true - case typeutil.IndexNodeRole: - role.EnableIndexNode = true case typeutil.StreamingNodeRole: streamingutil.EnableEmbededQueryNode() role.EnableStreamingNode = true @@ -159,8 +155,6 @@ func GetMilvusRoles(args []string, flags *flag.FlagSet) *roles.MilvusRoles { role.EnableQueryNode = true role.EnableDataCoord = true role.EnableDataNode = true - role.EnableIndexCoord = true - role.EnableIndexNode = true if streamingutil.IsStreamingServiceEnabled() { role.EnableStreamingNode = true } @@ -170,10 +164,8 @@ func GetMilvusRoles(args []string, flags *flag.FlagSet) *roles.MilvusRoles { role.EnableRootCoord = enableRootCoord role.EnableQueryCoord = enableQueryCoord role.EnableDataCoord = enableDataCoord - role.EnableIndexCoord = enableIndexCoord role.EnableQueryNode = enableQueryNode role.EnableDataNode = enableDataNode - role.EnableIndexNode = enableIndexNode role.EnableProxy = enableProxy role.EnableStreamingNode = enableStreamingNode if enableStreamingNode && !enableQueryNode { @@ -189,11 +181,12 @@ func GetMilvusRoles(args []string, flags *flag.FlagSet) *roles.MilvusRoles { } func formatFlags(args []string, flags *flag.FlagSet) (alias string, enableRootCoord, enableQueryCoord, - enableIndexCoord, enableDataCoord, enableQueryNode, enableDataNode, enableIndexNode, enableProxy bool, + enableDataCoord, enableQueryNode, enableDataNode, enableProxy bool, enableStreamingNode bool, ) { flags.StringVar(&alias, "alias", "", "set alias") + var enableIndexCoord bool flags.BoolVar(&enableRootCoord, typeutil.RootCoordRole, false, "enable root coordinator") flags.BoolVar(&enableQueryCoord, typeutil.QueryCoordRole, false, "enable query coordinator") flags.BoolVar(&enableIndexCoord, typeutil.IndexCoordRole, false, "enable index coordinator") @@ -201,7 +194,6 @@ func formatFlags(args []string, flags *flag.FlagSet) (alias string, enableRootCo flags.BoolVar(&enableQueryNode, typeutil.QueryNodeRole, false, "enable query node") flags.BoolVar(&enableDataNode, typeutil.DataNodeRole, false, "enable data node") - flags.BoolVar(&enableIndexNode, typeutil.IndexNodeRole, false, "enable index node") flags.BoolVar(&enableProxy, typeutil.ProxyRole, false, "enable proxy node") flags.BoolVar(&enableStreamingNode, typeutil.StreamingNodeRole, false, "enable streaming node") @@ -267,8 +259,7 @@ func addActiveKeySuffix(ctx context.Context, client *clientv3.Client, sessionPat for _, suffix := range sessionSuffix { if strings.Contains(suffix, "-") && (strings.HasPrefix(suffix, typeutil.RootCoordRole) || - strings.HasPrefix(suffix, typeutil.QueryCoordRole) || strings.HasPrefix(suffix, typeutil.DataCoordRole) || - strings.HasPrefix(suffix, typeutil.IndexCoordRole)) { + strings.HasPrefix(suffix, typeutil.QueryCoordRole) || strings.HasPrefix(suffix, typeutil.DataCoordRole)) { res := strings.Split(suffix, "-") if len(res) != 2 { // skip illegal keys @@ -294,11 +285,6 @@ func addActiveKeySuffix(ctx context.Context, client *clientv3.Client, sessionPat log.Info("add active serverID key", zap.String("suffix", suffix), zap.String("key", key)) suffixSet[serverType] = struct{}{} } - - // also remove a faked indexcoord seesion if role is a datacoord - if strings.HasPrefix(suffix, typeutil.DataCoordRole) { - suffixSet[typeutil.IndexCoordRole] = struct{}{} - } } } diff --git a/cmd/roles/roles.go b/cmd/roles/roles.go index 32e477e506..5554212e67 100644 --- a/cmd/roles/roles.go +++ b/cmd/roles/roles.go @@ -149,8 +149,6 @@ type MilvusRoles struct { EnableQueryNode bool `env:"ENABLE_QUERY_NODE"` EnableDataCoord bool `env:"ENABLE_DATA_COORD"` EnableDataNode bool `env:"ENABLE_DATA_NODE"` - EnableIndexCoord bool `env:"ENABLE_INDEX_COORD"` - EnableIndexNode bool `env:"ENABLE_INDEX_NODE"` EnableStreamingNode bool `env:"ENABLE_STREAMING_NODE"` Local bool @@ -226,22 +224,6 @@ func (mr *MilvusRoles) runDataNode(ctx context.Context, localMsg bool, wg *sync. return runComponent(ctx, localMsg, wg, components.NewDataNode, metrics.RegisterDataNode) } -func (mr *MilvusRoles) runIndexCoord(ctx context.Context, localMsg bool, wg *sync.WaitGroup) component { - wg.Add(1) - return runComponent(ctx, localMsg, wg, components.NewIndexCoord, func(registry *prometheus.Registry) {}) -} - -func (mr *MilvusRoles) runIndexNode(ctx context.Context, localMsg bool, wg *sync.WaitGroup) component { - wg.Add(1) - rootPath := paramtable.Get().LocalStorageCfg.Path.GetValue() - indexDataLocalPath := filepath.Join(rootPath, typeutil.IndexNodeRole) - cleanLocalDir(indexDataLocalPath) - cleanLocalDir(TmpInvertedIndexPrefix) - cleanLocalDir(TmpTextLogPrefix) - - return runComponent(ctx, localMsg, wg, components.NewIndexNode, metrics.RegisterIndexNode) -} - func (mr *MilvusRoles) setupLogger() { params := paramtable.Get() logConfig := log.Config{ @@ -408,8 +390,6 @@ func (mr *MilvusRoles) Run() { mr.EnableQueryNode, mr.EnableDataCoord, mr.EnableDataNode, - mr.EnableIndexCoord, - mr.EnableIndexNode, mr.EnableStreamingNode, } enableComponents = lo.Filter(enableComponents, func(v bool, _ int) bool { @@ -439,8 +419,8 @@ func (mr *MilvusRoles) Run() { local := mr.Local componentMap := make(map[string]component) - var rootCoord, queryCoord, indexCoord, dataCoord component - var proxy, dataNode, indexNode, queryNode, streamingNode component + var rootCoord, queryCoord, dataCoord component + var proxy, dataNode, queryNode, streamingNode component if mr.EnableRootCoord { rootCoord = mr.runRootCoord(ctx, local, &wg) componentMap[typeutil.RootCoordRole] = rootCoord @@ -453,12 +433,6 @@ func (mr *MilvusRoles) Run() { paramtable.SetLocalComponentEnabled(typeutil.DataCoordRole) } - if mr.EnableIndexCoord { - indexCoord = mr.runIndexCoord(ctx, local, &wg) - componentMap[typeutil.IndexCoordRole] = indexCoord - paramtable.SetLocalComponentEnabled(typeutil.IndexCoordRole) - } - if mr.EnableQueryCoord { queryCoord = mr.runQueryCoord(ctx, local, &wg) componentMap[typeutil.QueryCoordRole] = queryCoord @@ -476,11 +450,6 @@ func (mr *MilvusRoles) Run() { componentMap[typeutil.DataNodeRole] = dataNode paramtable.SetLocalComponentEnabled(typeutil.DataNodeRole) } - if mr.EnableIndexNode { - indexNode = mr.runIndexNode(ctx, local, &wg) - componentMap[typeutil.IndexNodeRole] = indexNode - paramtable.SetLocalComponentEnabled(typeutil.IndexNodeRole) - } if mr.EnableProxy { proxy = mr.runProxy(ctx, local, &wg) @@ -554,7 +523,7 @@ func (mr *MilvusRoles) Run() { <-mr.closed // stop coordinators first - coordinators := []component{rootCoord, dataCoord, indexCoord, queryCoord} + coordinators := []component{rootCoord, dataCoord, queryCoord} for idx, coord := range coordinators { log.Warn("stop processing") if coord != nil { @@ -565,7 +534,7 @@ func (mr *MilvusRoles) Run() { log.Info("All coordinators have stopped") // stop nodes - nodes := []component{queryNode, indexNode, dataNode, streamingNode} + nodes := []component{queryNode, dataNode, streamingNode} for idx, node := range nodes { if node != nil { log.Info("stop node", zap.Int("idx", idx), zap.Any("node", node)) @@ -605,11 +574,5 @@ func (mr *MilvusRoles) GetRoles() []string { if mr.EnableDataNode { roles = append(roles, typeutil.DataNodeRole) } - if mr.EnableIndexCoord { - roles = append(roles, typeutil.IndexCoordRole) - } - if mr.EnableIndexNode { - roles = append(roles, typeutil.IndexNodeRole) - } return roles } diff --git a/configs/milvus.yaml b/configs/milvus.yaml index 690471854f..1a96dd09a1 100644 --- a/configs/milvus.yaml +++ b/configs/milvus.yaml @@ -503,15 +503,8 @@ indexCoord: indexNode: scheduler: buildParallel: 1 - enableDisk: true # enable index node build disk vector index + enableDisk: true # enable build disk vector index maxDiskUsagePercentage: 95 - ip: # TCP/IP address of indexNode. If not specified, use the first unicastable address - port: 21121 # TCP port of indexNode - grpc: - serverMaxSendSize: 536870912 # The maximum size of each RPC request that the indexNode can send, unit: byte - serverMaxRecvSize: 268435456 # The maximum size of each RPC request that the indexNode can receive, unit: byte - clientMaxSendSize: 268435456 # The maximum size of each RPC request that the clients on indexNode can send, unit: byte - clientMaxRecvSize: 536870912 # The maximum size of each RPC request that the clients on indexNode can receive, unit: byte dataCoord: channel: diff --git a/internal/datacoord/compaction_task_clustering.go b/internal/datacoord/compaction_task_clustering.go index 237c71be4a..89ce83dcbe 100644 --- a/internal/datacoord/compaction_task_clustering.go +++ b/internal/datacoord/compaction_task_clustering.go @@ -365,7 +365,7 @@ func (t *clusteringCompactionTask) processStats() error { return t.updateAndSaveTaskMeta(setState(datapb.CompactionTaskState_indexing), setResultSegments(resultSegments)) } -// this is just a temporary solution. A more long-term solution should be for the indexnode +// this is just a temporary solution. A more long-term solution should be for the datanode // to regenerate the clustering information corresponding to each segment and merge them at the vshard level. func (t *clusteringCompactionTask) regeneratePartitionStats(tmpToResultSegments map[int64][]int64) error { ctx, cancel := context.WithTimeout(context.Background(), time.Minute) diff --git a/internal/datacoord/index_service.go b/internal/datacoord/index_service.go index 6a2e3e8351..2e9209a5bb 100644 --- a/internal/datacoord/index_service.go +++ b/internal/datacoord/index_service.go @@ -245,7 +245,7 @@ func (s *Server) parseAndVerifyNestedPath(identifier string, schema *schemapb.Co // CreateIndex create an index on collection. // Index building is asynchronous, so when an index building request comes, an IndexID is assigned to the task and // will get all flushed segments from DataCoord and record tasks with these segments. The background process -// indexBuilder will find this task and assign it to IndexNode for execution. +// indexBuilder will find this task and assign it to DataNode for execution. func (s *Server) CreateIndex(ctx context.Context, req *indexpb.CreateIndexRequest) (*commonpb.Status, error) { log := log.Ctx(ctx).With( zap.Int64("collectionID", req.GetCollectionID()), @@ -336,7 +336,7 @@ func (s *Server) CreateIndex(ctx context.Context, req *indexpb.CreateIndexReques return merr.Status(err), nil } if vecindexmgr.GetVecIndexMgrInstance().IsDiskANN(GetIndexType(req.IndexParams)) && !s.indexNodeManager.ClientSupportDisk() { - errMsg := "all IndexNodes do not support disk indexes, please verify" + errMsg := "all DataNodes do not support disk indexes, please verify" log.Warn(errMsg) err = merr.WrapErrIndexNotSupported(GetIndexType(req.IndexParams)) metrics.IndexRequestCounter.WithLabelValues(metrics.FailLabel).Inc() diff --git a/internal/datacoord/index_service_test.go b/internal/datacoord/index_service_test.go index 25c5d2c15c..dd514a8a57 100644 --- a/internal/datacoord/index_service_test.go +++ b/internal/datacoord/index_service_test.go @@ -217,7 +217,7 @@ func TestServer_CreateIndex(t *testing.T) { Value: "DISKANN", }, } - s.indexNodeManager = session.NewNodeManager(ctx, defaultIndexNodeCreatorFunc) + s.indexNodeManager = session.NewNodeManager(ctx, defaultDataNodeCreatorFunc) resp, err := s.CreateIndex(ctx, req) assert.Error(t, merr.CheckRPCCall(resp, err)) }) @@ -235,9 +235,9 @@ func TestServer_CreateIndex(t *testing.T) { Value: "true", }, } - nodeManager := session.NewNodeManager(ctx, defaultIndexNodeCreatorFunc) + nodeManager := session.NewNodeManager(ctx, defaultDataNodeCreatorFunc) s.indexNodeManager = nodeManager - mockNode := mocks.NewMockIndexNodeClient(t) + mockNode := mocks.NewMockDataNodeClient(t) nodeManager.SetClient(1001, mockNode) mockNode.EXPECT().GetJobStats(mock.Anything, mock.Anything).Return(&workerpb.GetJobStatsResponse{ Status: merr.Success(), diff --git a/internal/datacoord/metrics_info.go b/internal/datacoord/metrics_info.go index b6b32db5cb..829037cfa0 100644 --- a/internal/datacoord/metrics_info.go +++ b/internal/datacoord/metrics_info.go @@ -211,9 +211,8 @@ func (s *Server) getSystemInfoMetrics( // get datacoord info nodes := s.cluster.GetSessions() clusterTopology := metricsinfo.DataClusterTopology{ - Self: s.getDataCoordMetrics(ctx), - ConnectedDataNodes: make([]metricsinfo.DataNodeInfos, 0, len(nodes)), - ConnectedIndexNodes: make([]metricsinfo.IndexNodeInfos, 0), + Self: s.getDataCoordMetrics(ctx), + ConnectedDataNodes: make([]metricsinfo.DataNodeInfos, 0, len(nodes)), } // for each data node, fetch metrics info @@ -233,7 +232,7 @@ func (s *Server) getSystemInfoMetrics( log.Warn("fails to get IndexNode metrics", zap.Error(err)) continue } - clusterTopology.ConnectedIndexNodes = append(clusterTopology.ConnectedIndexNodes, infos) + clusterTopology.ConnectedDataNodes = append(clusterTopology.ConnectedDataNodes, infos) } // compose topolgoy struct @@ -343,8 +342,8 @@ func (s *Server) getDataNodeMetrics(ctx context.Context, req *milvuspb.GetMetric return infos, nil } -func (s *Server) getIndexNodeMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest, node types.IndexNodeClient) (metricsinfo.IndexNodeInfos, error) { - infos := metricsinfo.IndexNodeInfos{ +func (s *Server) getIndexNodeMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest, node types.DataNodeClient) (metricsinfo.DataNodeInfos, error) { + infos := metricsinfo.DataNodeInfos{ BaseComponentInfos: metricsinfo.BaseComponentInfos{ HasError: true, ID: int64(uniquegenerator.GetUniqueIntGeneratorIns().GetInt()), @@ -374,7 +373,7 @@ func (s *Server) getIndexNodeMetrics(ctx context.Context, req *milvuspb.GetMetri err = metricsinfo.UnmarshalComponentInfos(metrics.GetResponse(), &infos) if err != nil { - log.Warn("invalid metrics of IndexNode found", + log.Warn("invalid metrics of DataNode found", zap.Error(err)) infos.BaseComponentInfos.ErrorReason = err.Error() return infos, nil diff --git a/internal/datacoord/metrics_info_test.go b/internal/datacoord/metrics_info_test.go index 5c732fa183..ba6cd49497 100644 --- a/internal/datacoord/metrics_info_test.go +++ b/internal/datacoord/metrics_info_test.go @@ -22,6 +22,7 @@ import ( "github.com/cockroachdb/errors" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" "github.com/tidwall/gjson" "google.golang.org/grpc" @@ -31,6 +32,7 @@ import ( "github.com/milvus-io/milvus/internal/datacoord/session" "github.com/milvus-io/milvus/internal/json" "github.com/milvus-io/milvus/internal/metastore/model" + "github.com/milvus-io/milvus/internal/mocks" "github.com/milvus-io/milvus/internal/types" "github.com/milvus-io/milvus/pkg/v2/proto/datapb" "github.com/milvus-io/milvus/pkg/v2/util/merr" @@ -40,30 +42,6 @@ import ( "github.com/milvus-io/milvus/pkg/v2/util/typeutil" ) -type mockMetricDataNodeClient struct { - types.DataNodeClient - mock func() (*milvuspb.GetMetricsResponse, error) -} - -func (c *mockMetricDataNodeClient) GetMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest, opts ...grpc.CallOption) (*milvuspb.GetMetricsResponse, error) { - if c.mock == nil { - return c.DataNodeClient.GetMetrics(ctx, req) - } - return c.mock() -} - -type mockMetricIndexNodeClient struct { - types.IndexNodeClient - mock func() (*milvuspb.GetMetricsResponse, error) -} - -func (m *mockMetricIndexNodeClient) GetMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest, opts ...grpc.CallOption) (*milvuspb.GetMetricsResponse, error) { - if m.mock == nil { - return m.IndexNodeClient.GetMetrics(ctx, req) - } - return m.mock() -} - func TestGetDataNodeMetrics(t *testing.T) { svr := newTestServer(t) defer closeTestServer(t, svr) @@ -79,7 +57,33 @@ func TestGetDataNodeMetrics(t *testing.T) { assert.Error(t, err) creator := func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { - return newMockDataNodeClient(100, nil) + dn := mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, req *milvuspb.GetMetricsRequest, option ...grpc.CallOption) (*milvuspb.GetMetricsResponse, error) { + const nodeID = 100 + nodeInfos := metricsinfo.DataNodeInfos{ + BaseComponentInfos: metricsinfo.BaseComponentInfos{ + Name: metricsinfo.ConstructComponentName(typeutil.DataNodeRole, nodeID), + ID: nodeID, + }, + } + 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: merr.Success(), + Response: resp, + ComponentName: metricsinfo.ConstructComponentName(typeutil.DataNodeRole, nodeID), + }, nil + }) + return dn, nil } // mock datanode client @@ -89,29 +93,24 @@ func TestGetDataNodeMetrics(t *testing.T) { assert.False(t, info.HasError) assert.Equal(t, metricsinfo.ConstructComponentName(typeutil.DataNodeRole, 100), info.BaseComponentInfos.Name) - getMockFailedClientCreator := func(mockFunc func() (*milvuspb.GetMetricsResponse, error)) session.DataNodeCreatorFunc { - return func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { - cli, err := creator(ctx, addr, nodeID) - assert.NoError(t, err) - return &mockMetricDataNodeClient{DataNodeClient: cli, mock: mockFunc}, nil - } + mockFailClientCreator := func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { + dn := mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(nil, errors.New("mocked fail")) + return dn, nil } - mockFailClientCreator := getMockFailedClientCreator(func() (*milvuspb.GetMetricsResponse, error) { - return nil, errors.New("mocked fail") - }) - info, err = svr.getDataNodeMetrics(ctx, req, session.NewSession(&session.NodeInfo{}, mockFailClientCreator)) assert.NoError(t, err) assert.True(t, info.HasError) - mockErr := errors.New("mocked error") // mock status not success - mockFailClientCreator = getMockFailedClientCreator(func() (*milvuspb.GetMetricsResponse, error) { - return &milvuspb.GetMetricsResponse{ - Status: merr.Status(mockErr), - }, nil - }) + mockFailClientCreator = func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { + dn := mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(&milvuspb.GetMetricsResponse{ + Status: merr.Status(errors.New("mocked error")), + }, nil) + return dn, nil + } info, err = svr.getDataNodeMetrics(ctx, req, session.NewSession(&session.NodeInfo{}, mockFailClientCreator)) assert.NoError(t, err) @@ -119,12 +118,14 @@ func TestGetDataNodeMetrics(t *testing.T) { assert.Equal(t, "mocked error", info.ErrorReason) // mock parse error - mockFailClientCreator = getMockFailedClientCreator(func() (*milvuspb.GetMetricsResponse, error) { - return &milvuspb.GetMetricsResponse{ + mockFailClientCreator = func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { + dn := mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(&milvuspb.GetMetricsResponse{ Status: merr.Success(), Response: `{"error_reason": 1}`, - }, nil - }) + }, nil) + return dn, nil + } info, err = svr.getDataNodeMetrics(ctx, req, session.NewSession(&session.NodeInfo{}, mockFailClientCreator)) assert.NoError(t, err) @@ -142,66 +143,62 @@ func TestGetIndexNodeMetrics(t *testing.T) { assert.Error(t, err) // return error - info, err := svr.getIndexNodeMetrics(ctx, req, &mockMetricIndexNodeClient{mock: func() (*milvuspb.GetMetricsResponse, error) { - return nil, errors.New("mock error") - }}) + dn := mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(nil, errors.New("mock error")) + info, err := svr.getIndexNodeMetrics(ctx, req, dn) assert.NoError(t, err) assert.True(t, info.HasError) // failed mockErr := errors.New("mocked error") - info, err = svr.getIndexNodeMetrics(ctx, req, &mockMetricIndexNodeClient{ - mock: func() (*milvuspb.GetMetricsResponse, error) { - return &milvuspb.GetMetricsResponse{ - Status: merr.Status(mockErr), - ComponentName: "indexnode100", - }, nil - }, - }) + dn = mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(&milvuspb.GetMetricsResponse{ + Status: merr.Status(mockErr), + ComponentName: "indexnode100", + }, nil) + info, err = svr.getIndexNodeMetrics(ctx, req, dn) assert.NoError(t, err) assert.True(t, info.HasError) assert.Equal(t, metricsinfo.ConstructComponentName(typeutil.IndexNodeRole, 100), info.BaseComponentInfos.Name) // return unexpected - info, err = svr.getIndexNodeMetrics(ctx, req, &mockMetricIndexNodeClient{ - mock: func() (*milvuspb.GetMetricsResponse, error) { - return &milvuspb.GetMetricsResponse{ - Status: merr.Success(), - Response: "XXXXXXXXXXXXX", - ComponentName: "indexnode100", - }, nil - }, - }) + dn = mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(&milvuspb.GetMetricsResponse{ + Status: merr.Success(), + Response: "XXXXXXXXXXXXX", + ComponentName: "indexnode100", + }, nil) + info, err = svr.getIndexNodeMetrics(ctx, req, dn) assert.NoError(t, err) assert.True(t, info.HasError) assert.Equal(t, metricsinfo.ConstructComponentName(typeutil.IndexNodeRole, 100), info.BaseComponentInfos.Name) // success - info, err = svr.getIndexNodeMetrics(ctx, req, &mockMetricIndexNodeClient{ - mock: func() (*milvuspb.GetMetricsResponse, error) { - nodeID = UniqueID(100) - - nodeInfos := metricsinfo.DataNodeInfos{ - BaseComponentInfos: metricsinfo.BaseComponentInfos{ - Name: metricsinfo.ConstructComponentName(typeutil.IndexNodeRole, nodeID), - ID: nodeID, - }, - } - resp, err := metricsinfo.MarshalComponentInfos(nodeInfos) - if err != nil { - return &milvuspb.GetMetricsResponse{ - Status: merr.Status(err), - ComponentName: metricsinfo.ConstructComponentName(typeutil.IndexNodeRole, nodeID), - }, nil - } + dn = mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, req *milvuspb.GetMetricsRequest, option ...grpc.CallOption) (*milvuspb.GetMetricsResponse, error) { + nodeID = UniqueID(100) + nodeInfos := metricsinfo.DataNodeInfos{ + BaseComponentInfos: metricsinfo.BaseComponentInfos{ + Name: metricsinfo.ConstructComponentName(typeutil.IndexNodeRole, nodeID), + ID: nodeID, + }, + } + resp, err := metricsinfo.MarshalComponentInfos(nodeInfos) + if err != nil { return &milvuspb.GetMetricsResponse{ - Status: merr.Success(), - Response: resp, + Status: merr.Status(err), ComponentName: metricsinfo.ConstructComponentName(typeutil.IndexNodeRole, nodeID), }, nil - }, + } + + return &milvuspb.GetMetricsResponse{ + Status: merr.Success(), + Response: resp, + ComponentName: metricsinfo.ConstructComponentName(typeutil.IndexNodeRole, nodeID), + }, nil }) + info, err = svr.getIndexNodeMetrics(ctx, req, dn) assert.NoError(t, err) assert.False(t, info.HasError) @@ -235,14 +232,11 @@ func TestGetSyncTaskMetrics(t *testing.T) { Response: expectedJSON, } - mockClient := &mockMetricDataNodeClient{ - mock: func() (*milvuspb.GetMetricsResponse, error) { - return mockResp, nil - }, - } + dn := mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(mockResp, nil) dataNodeCreator := func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { - return mockClient, nil + return dn, nil } mockCluster := NewMockCluster(t) @@ -258,14 +252,11 @@ func TestGetSyncTaskMetrics(t *testing.T) { req := &milvuspb.GetMetricsRequest{} ctx := context.Background() - mockClient := &mockMetricDataNodeClient{ - mock: func() (*milvuspb.GetMetricsResponse, error) { - return nil, errors.New("request failed") - }, - } + dn := mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(nil, errors.New("request failed")) dataNodeCreator := func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { - return mockClient, nil + return dn, nil } mockCluster := NewMockCluster(t) @@ -286,14 +277,11 @@ func TestGetSyncTaskMetrics(t *testing.T) { Response: `invalid json`, } - mockClient := &mockMetricDataNodeClient{ - mock: func() (*milvuspb.GetMetricsResponse, error) { - return mockResp, nil - }, - } + dn := mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(mockResp, nil) dataNodeCreator := func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { - return mockClient, nil + return dn, nil } mockCluster := NewMockCluster(t) @@ -314,14 +302,11 @@ func TestGetSyncTaskMetrics(t *testing.T) { Response: "", } - mockClient := &mockMetricDataNodeClient{ - mock: func() (*milvuspb.GetMetricsResponse, error) { - return mockResp, nil - }, - } + dn := mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(mockResp, nil) dataNodeCreator := func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { - return mockClient, nil + return dn, nil } mockCluster := NewMockCluster(t) @@ -359,14 +344,11 @@ func TestGetSegmentsJSON(t *testing.T) { Response: expectedJSON, } - mockClient := &mockMetricDataNodeClient{ - mock: func() (*milvuspb.GetMetricsResponse, error) { - return mockResp, nil - }, - } + dn := mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(mockResp, nil) dataNodeCreator := func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { - return mockClient, nil + return dn, nil } mockCluster := NewMockCluster(t) @@ -382,14 +364,11 @@ func TestGetSegmentsJSON(t *testing.T) { req := &milvuspb.GetMetricsRequest{} ctx := context.Background() - mockClient := &mockMetricDataNodeClient{ - mock: func() (*milvuspb.GetMetricsResponse, error) { - return nil, errors.New("request failed") - }, - } + dn := mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(nil, errors.New("request failed")) dataNodeCreator := func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { - return mockClient, nil + return dn, nil } mockCluster := NewMockCluster(t) @@ -410,14 +389,11 @@ func TestGetSegmentsJSON(t *testing.T) { Response: `invalid json`, } - mockClient := &mockMetricDataNodeClient{ - mock: func() (*milvuspb.GetMetricsResponse, error) { - return mockResp, nil - }, - } + dn := mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(mockResp, nil) dataNodeCreator := func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { - return mockClient, nil + return dn, nil } mockCluster := NewMockCluster(t) @@ -438,14 +414,11 @@ func TestGetSegmentsJSON(t *testing.T) { Response: "", } - mockClient := &mockMetricDataNodeClient{ - mock: func() (*milvuspb.GetMetricsResponse, error) { - return mockResp, nil - }, - } + dn := mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(mockResp, nil) dataNodeCreator := func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { - return mockClient, nil + return dn, nil } mockCluster := NewMockCluster(t) @@ -480,14 +453,11 @@ func TestGetChannelsJSON(t *testing.T) { Response: channelJSON, } - mockClient := &mockMetricDataNodeClient{ - mock: func() (*milvuspb.GetMetricsResponse, error) { - return mockResp, nil - }, - } + dn := mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(mockResp, nil) dataNodeCreator := func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { - return mockClient, nil + return dn, nil } mockCluster := NewMockCluster(t) @@ -519,14 +489,11 @@ func TestGetChannelsJSON(t *testing.T) { req := &milvuspb.GetMetricsRequest{} ctx := context.Background() - mockClient := &mockMetricDataNodeClient{ - mock: func() (*milvuspb.GetMetricsResponse, error) { - return nil, errors.New("request failed") - }, - } + dn := mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(nil, errors.New("request failed")) dataNodeCreator := func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { - return mockClient, nil + return dn, nil } mockCluster := NewMockCluster(t) @@ -549,14 +516,11 @@ func TestGetChannelsJSON(t *testing.T) { Response: `invalid json`, } - mockClient := &mockMetricDataNodeClient{ - mock: func() (*milvuspb.GetMetricsResponse, error) { - return mockResp, nil - }, - } + dn := mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(mockResp, nil) dataNodeCreator := func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { - return mockClient, nil + return dn, nil } mockCluster := NewMockCluster(t) @@ -579,14 +543,11 @@ func TestGetChannelsJSON(t *testing.T) { Response: "", } - mockClient := &mockMetricDataNodeClient{ - mock: func() (*milvuspb.GetMetricsResponse, error) { - return mockResp, nil - }, - } + dn := mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(mockResp, nil) dataNodeCreator := func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { - return mockClient, nil + return dn, nil } mockCluster := NewMockCluster(t) @@ -773,14 +734,11 @@ func TestServer_getSegmentsJSON(t *testing.T) { Response: expectedJSON, } - mockClient := &mockMetricDataNodeClient{ - mock: func() (*milvuspb.GetMetricsResponse, error) { - return mockResp, nil - }, - } + dn := mocks.NewMockDataNodeClient(t) + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(mockResp, nil) dataNodeCreator := func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { - return mockClient, nil + return dn, nil } mockCluster := NewMockCluster(t) diff --git a/internal/datacoord/mock_test.go b/internal/datacoord/mock_test.go index 38cea70791..85da149e22 100644 --- a/internal/datacoord/mock_test.go +++ b/internal/datacoord/mock_test.go @@ -143,170 +143,6 @@ func newTestScalarClusteringKeySchema() *schemapb.CollectionSchema { } } -type mockDataNodeClient struct { - id int64 - state commonpb.StateCode - ch chan interface{} - compactionStateResp *datapb.CompactionStateResponse - compactionResp *commonpb.Status -} - -func newMockDataNodeClient(id int64, ch chan interface{}) (*mockDataNodeClient, error) { - return &mockDataNodeClient{ - id: id, - state: commonpb.StateCode_Initializing, - ch: ch, - }, nil -} - -type mockIndexNodeClient struct { - id int64 - state commonpb.StateCode -} - -func newMockIndexNodeClient(id int64) (*mockIndexNodeClient, error) { - return &mockIndexNodeClient{ - id: id, - state: commonpb.StateCode_Initializing, - }, nil -} - -func (c *mockDataNodeClient) Close() error { - return nil -} - -func (c *mockDataNodeClient) GetComponentStates(ctx context.Context, req *milvuspb.GetComponentStatesRequest, opts ...grpc.CallOption) (*milvuspb.ComponentStates, error) { - return &milvuspb.ComponentStates{ - State: &milvuspb.ComponentInfo{ - NodeID: c.id, - StateCode: c.state, - }, - }, nil -} - -func (c *mockDataNodeClient) GetStatisticsChannel(ctx context.Context, req *internalpb.GetStatisticsChannelRequest, opts ...grpc.CallOption) (*milvuspb.StringResponse, error) { - return nil, nil -} - -func (c *mockDataNodeClient) WatchDmChannels(ctx context.Context, in *datapb.WatchDmChannelsRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { - return &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success}, nil -} - -func (c *mockDataNodeClient) FlushSegments(ctx context.Context, in *datapb.FlushSegmentsRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { - if c.ch != nil { - c.ch <- in - } - return &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success}, nil -} - -func (c *mockDataNodeClient) ResendSegmentStats(ctx context.Context, req *datapb.ResendSegmentStatsRequest, opts ...grpc.CallOption) (*datapb.ResendSegmentStatsResponse, error) { - return &datapb.ResendSegmentStatsResponse{ - Status: merr.Success(), - }, nil -} - -func (c *mockDataNodeClient) ShowConfigurations(ctx context.Context, req *internalpb.ShowConfigurationsRequest, opts ...grpc.CallOption) (*internalpb.ShowConfigurationsResponse, error) { - return &internalpb.ShowConfigurationsResponse{ - Status: merr.Success(), - }, nil -} - -func (c *mockDataNodeClient) GetMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest, opts ...grpc.CallOption) (*milvuspb.GetMetricsResponse, error) { - // TODO(dragondriver): change the id, though it's not important in ut - nodeID := c.id - - nodeInfos := metricsinfo.DataNodeInfos{ - BaseComponentInfos: metricsinfo.BaseComponentInfos{ - Name: metricsinfo.ConstructComponentName(typeutil.DataNodeRole, nodeID), - ID: nodeID, - }, - } - 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: merr.Success(), - Response: resp, - ComponentName: metricsinfo.ConstructComponentName(typeutil.DataNodeRole, nodeID), - }, nil -} - -func (c *mockDataNodeClient) CompactionV2(ctx context.Context, req *datapb.CompactionPlan, opts ...grpc.CallOption) (*commonpb.Status, error) { - if c.ch != nil { - c.ch <- struct{}{} - if c.compactionResp != nil { - return c.compactionResp, nil - } - return &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success}, nil - } - if c.compactionResp != nil { - return c.compactionResp, nil - } - return &commonpb.Status{ErrorCode: commonpb.ErrorCode_UnexpectedError, Reason: "not implemented"}, nil -} - -func (c *mockDataNodeClient) GetCompactionState(ctx context.Context, req *datapb.CompactionStateRequest, opts ...grpc.CallOption) (*datapb.CompactionStateResponse, error) { - return c.compactionStateResp, nil -} - -func (c *mockDataNodeClient) SyncSegments(ctx context.Context, req *datapb.SyncSegmentsRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { - return &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success}, nil -} - -func (c *mockDataNodeClient) FlushChannels(ctx context.Context, req *datapb.FlushChannelsRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { - return &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success}, nil -} - -func (c *mockDataNodeClient) NotifyChannelOperation(ctx context.Context, req *datapb.ChannelOperationsRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { - return merr.Success(), nil -} - -func (c *mockDataNodeClient) CheckChannelOperationProgress(ctx context.Context, req *datapb.ChannelWatchInfo, opts ...grpc.CallOption) (*datapb.ChannelOperationProgressResponse, error) { - return &datapb.ChannelOperationProgressResponse{Status: merr.Success()}, nil -} - -func (c *mockDataNodeClient) PreImport(ctx context.Context, req *datapb.PreImportRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { - return &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success}, nil -} - -func (c *mockDataNodeClient) ImportV2(ctx context.Context, req *datapb.ImportRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { - return &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success}, nil -} - -func (c *mockDataNodeClient) QueryPreImport(ctx context.Context, req *datapb.QueryPreImportRequest, opts ...grpc.CallOption) (*datapb.QueryPreImportResponse, error) { - return &datapb.QueryPreImportResponse{Status: merr.Success()}, nil -} - -func (c *mockDataNodeClient) QueryImport(ctx context.Context, req *datapb.QueryImportRequest, opts ...grpc.CallOption) (*datapb.QueryImportResponse, error) { - return &datapb.QueryImportResponse{Status: merr.Success()}, nil -} - -func (c *mockDataNodeClient) DropImport(ctx context.Context, req *datapb.DropImportRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { - return &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success}, nil -} - -func (c *mockDataNodeClient) QuerySlot(ctx context.Context, req *datapb.QuerySlotRequest, opts ...grpc.CallOption) (*datapb.QuerySlotResponse, error) { - return &datapb.QuerySlotResponse{Status: merr.Success()}, nil -} - -func (c *mockDataNodeClient) DropCompactionPlan(ctx context.Context, req *datapb.DropCompactionPlanRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { - return merr.Success(), nil -} - -func (c *mockDataNodeClient) Stop() error { - c.state = commonpb.StateCode_Abnormal - return nil -} - type mockRootCoordClient struct { state commonpb.StateCode cnt atomic.Int64 diff --git a/internal/datacoord/server.go b/internal/datacoord/server.go index 4bbb1dc9b7..3de8f9fac2 100644 --- a/internal/datacoord/server.go +++ b/internal/datacoord/server.go @@ -42,7 +42,6 @@ import ( "github.com/milvus-io/milvus/internal/datacoord/broker" "github.com/milvus-io/milvus/internal/datacoord/session" datanodeclient "github.com/milvus-io/milvus/internal/distributed/datanode/client" - indexnodeclient "github.com/milvus-io/milvus/internal/distributed/indexnode/client" etcdkv "github.com/milvus-io/milvus/internal/kv/etcd" "github.com/milvus-io/milvus/internal/kv/tikv" "github.com/milvus-io/milvus/internal/metastore/kv/datacoord" @@ -140,7 +139,6 @@ type Server struct { session sessionutil.SessionInterface icSession *sessionutil.Session dnEventCh <-chan *sessionutil.SessionEvent - inEventCh <-chan *sessionutil.SessionEvent // qcEventCh <-chan *sessionutil.SessionEvent qnEventCh <-chan *sessionutil.SessionEvent @@ -148,7 +146,6 @@ type Server struct { activateFunc func() error dataNodeCreator session.DataNodeCreatorFunc - indexNodeCreator session.IndexNodeCreatorFunc rootCoordClientCreator rootCoordCreatorFunc // indexCoord types.IndexCoord @@ -211,7 +208,6 @@ func CreateServer(ctx context.Context, factory dependency.Factory, opts ...Optio flushCh: make(chan UniqueID, 1024), notifyIndexChan: make(chan UniqueID, 1024), dataNodeCreator: defaultDataNodeCreatorFunc, - indexNodeCreator: defaultIndexNodeCreatorFunc, rootCoordClientCreator: defaultRootCoordCreatorFunc, metricsCacheManager: metricsinfo.NewMetricsCacheManager(), enableActiveStandBy: Params.DataCoordCfg.EnableActiveStandby.GetAsBool(), @@ -226,11 +222,7 @@ func CreateServer(ctx context.Context, factory dependency.Factory, opts ...Optio } func defaultDataNodeCreatorFunc(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { - return datanodeclient.NewClient(ctx, addr, nodeID) -} - -func defaultIndexNodeCreatorFunc(ctx context.Context, addr string, nodeID int64) (types.IndexNodeClient, error) { - return indexnodeclient.NewClient(ctx, addr, nodeID, Params.DataCoordCfg.WithCredential.GetAsBool()) + return datanodeclient.NewClient(ctx, addr, nodeID, Params.DataCoordCfg.WithCredential.GetAsBool()) } func defaultRootCoordCreatorFunc(ctx context.Context) (types.RootCoordClient, error) { @@ -526,10 +518,6 @@ func (s *Server) SetDataNodeCreator(f func(context.Context, string, int64) (type s.dataNodeCreator = f } -func (s *Server) SetIndexNodeCreator(f func(context.Context, string, int64) (types.IndexNodeClient, error)) { - s.indexNodeCreator = f -} - func (s *Server) newChunkManagerFactory() (storage.ChunkManager, error) { chunkManagerFactory := storage.NewChunkManagerFactoryWithParam(Params) cli, err := chunkManagerFactory.NewPersistentStorageChunkManager(s.ctx) @@ -591,27 +579,21 @@ func (s *Server) initServiceDiscovery() error { // TODO implement rewatch logic s.dnEventCh = s.session.WatchServicesWithVersionRange(typeutil.DataNodeRole, r, rev+1, nil) - inSessions, inRevision, err := s.session.GetSessions(typeutil.IndexNodeRole) - if err != nil { - log.Warn("DataCoord get QueryCoord session failed", zap.Error(err)) - return err - } if Params.DataCoordCfg.BindIndexNodeMode.GetAsBool() { if err = s.indexNodeManager.AddNode(Params.DataCoordCfg.IndexNodeID.GetAsInt64(), Params.DataCoordCfg.IndexNodeAddress.GetValue()); err != nil { - log.Error("add indexNode fail", zap.Int64("ServerID", Params.DataCoordCfg.IndexNodeID.GetAsInt64()), + log.Error("add dataNode fail", zap.Int64("ServerID", Params.DataCoordCfg.IndexNodeID.GetAsInt64()), zap.String("address", Params.DataCoordCfg.IndexNodeAddress.GetValue()), zap.Error(err)) return err } - log.Info("add indexNode success", zap.String("IndexNode address", Params.DataCoordCfg.IndexNodeAddress.GetValue()), + log.Info("add dataNode success", zap.String("DataNode address", Params.DataCoordCfg.IndexNodeAddress.GetValue()), zap.Int64("nodeID", Params.DataCoordCfg.IndexNodeID.GetAsInt64())) } else { - for _, session := range inSessions { + for _, session := range sessions { if err := s.indexNodeManager.AddNode(session.ServerID, session.Address); err != nil { return err } } } - s.inEventCh = s.session.WatchServices(typeutil.IndexNodeRole, inRevision+1, nil) s.indexEngineVersionManager = newIndexEngineVersionManager() qnSessions, qnRevision, err := s.session.GetSessions(typeutil.QueryNodeRole) @@ -698,7 +680,7 @@ func (s *Server) initJobManager() { func (s *Server) initIndexNodeManager() { if s.indexNodeManager == nil { - s.indexNodeManager = session.NewNodeManager(s.ctx, s.indexNodeCreator) + s.indexNodeManager = session.NewNodeManager(s.ctx, s.dataNodeCreator) } } @@ -843,19 +825,6 @@ func (s *Server) watchService(ctx context.Context) { }() return } - case event, ok := <-s.inEventCh: - if !ok { - s.stopServiceWatch() - return - } - if err := s.handleSessionEvent(ctx, typeutil.IndexNodeRole, event); err != nil { - go func() { - if err := s.Stop(); err != nil { - log.Warn("DataCoord server stop error", zap.Error(err)) - } - }() - return - } case event, ok := <-s.qnEventCh: if !ok { s.stopServiceWatch() @@ -900,6 +869,14 @@ func (s *Server) handleSessionEvent(ctx context.Context, role string, event *ses return err } s.metricsCacheManager.InvalidateSystemInfoMetrics() + if Params.DataCoordCfg.BindIndexNodeMode.GetAsBool() { + log.Info("receive datanode session event, but adding datanode by bind mode, skip it", + zap.String("address", event.Session.Address), + zap.Int64("serverID", event.Session.ServerID), + zap.String("event type", event.EventType.String())) + return nil + } + return s.indexNodeManager.AddNode(event.Session.ServerID, event.Session.Address) case sessionutil.SessionDelEvent: log.Info("received datanode unregister", zap.String("address", info.Address), @@ -909,32 +886,24 @@ func (s *Server) handleSessionEvent(ctx context.Context, role string, event *ses return err } s.metricsCacheManager.InvalidateSystemInfoMetrics() - default: - log.Warn("receive unknown service event type", - zap.Any("type", event.EventType)) - } - case typeutil.IndexNodeRole: - if Params.DataCoordCfg.BindIndexNodeMode.GetAsBool() { - log.Info("receive indexnode session event, but adding indexnode by bind mode, skip it", - zap.String("address", event.Session.Address), - zap.Int64("serverID", event.Session.ServerID), - zap.String("event type", event.EventType.String())) - return nil - } - switch event.EventType { - case sessionutil.SessionAddEvent: - log.Info("received indexnode register", - zap.String("address", event.Session.Address), - zap.Int64("serverID", event.Session.ServerID)) - return s.indexNodeManager.AddNode(event.Session.ServerID, event.Session.Address) - case sessionutil.SessionDelEvent: - log.Info("received indexnode unregister", - zap.String("address", event.Session.Address), - zap.Int64("serverID", event.Session.ServerID)) + if Params.DataCoordCfg.BindIndexNodeMode.GetAsBool() { + log.Info("receive datanode session event, but adding datanode by bind mode, skip it", + zap.String("address", event.Session.Address), + zap.Int64("serverID", event.Session.ServerID), + zap.String("event type", event.EventType.String())) + return nil + } s.indexNodeManager.RemoveNode(event.Session.ServerID) case sessionutil.SessionUpdateEvent: + if Params.DataCoordCfg.BindIndexNodeMode.GetAsBool() { + log.Info("receive datanode session event, but adding indexnode by bind mode, skip it", + zap.String("address", event.Session.Address), + zap.Int64("serverID", event.Session.ServerID), + zap.String("event type", event.EventType.String())) + return nil + } serverID := event.Session.ServerID - log.Info("received indexnode SessionUpdateEvent", zap.Int64("serverID", serverID)) + log.Info("received datanode SessionUpdateEvent", zap.Int64("serverID", serverID)) s.indexNodeManager.StoppingNode(serverID) default: log.Warn("receive unknown service event type", diff --git a/internal/datacoord/server_test.go b/internal/datacoord/server_test.go index d4ec1ef332..3d8492c6ff 100644 --- a/internal/datacoord/server_test.go +++ b/internal/datacoord/server_test.go @@ -2406,7 +2406,7 @@ func newTestServer(t *testing.T, opts ...Option) *Server { svr.SetTiKVClient(globalTestTikv) svr.dataNodeCreator = func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { - return newMockDataNodeClient(0, nil) + return mocks.NewMockDataNodeClient(t), nil } svr.rootCoordClientCreator = func(ctx context.Context) (types.RootCoordClient, error) { return newMockRootCoordClient(), nil @@ -2457,20 +2457,19 @@ func closeTestServer(t *testing.T, svr *Server) { func Test_CheckHealth(t *testing.T) { getSessionManager := func(isHealthy bool) *session.DataNodeManagerImpl { - var client *mockDataNodeClient - if isHealthy { - client = &mockDataNodeClient{ - id: 1, - state: commonpb.StateCode_Healthy, - } - } else { - client = &mockDataNodeClient{ - id: 1, - state: commonpb.StateCode_Abnormal, - } - } - sm := session.NewDataNodeManagerImpl(session.WithDataNodeCreator(func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { + var client *mocks.MockDataNodeClient + if isHealthy { + client = mocks.NewMockDataNodeClient(t) + client.EXPECT().GetComponentStates(mock.Anything, mock.Anything).Return(&milvuspb.ComponentStates{ + State: &milvuspb.ComponentInfo{StateCode: commonpb.StateCode_Healthy}, + }, nil) + } else { + client = mocks.NewMockDataNodeClient(t) + client.EXPECT().GetComponentStates(mock.Anything, mock.Anything).Return(&milvuspb.ComponentStates{ + State: &milvuspb.ComponentInfo{StateCode: commonpb.StateCode_Abnormal}, + }, nil) + } return client, nil })) sm.AddSession(&session.NodeInfo{ diff --git a/internal/datacoord/session/common.go b/internal/datacoord/session/common.go index 0771f562fc..5946da4c8f 100644 --- a/internal/datacoord/session/common.go +++ b/internal/datacoord/session/common.go @@ -7,5 +7,3 @@ import ( ) type DataNodeCreatorFunc func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) - -type IndexNodeCreatorFunc func(ctx context.Context, addr string, nodeID int64) (types.IndexNodeClient, error) diff --git a/internal/datacoord/session/datanode_manager.go b/internal/datacoord/session/datanode_manager.go index b6f2c11d4e..113f7f52f4 100644 --- a/internal/datacoord/session/datanode_manager.go +++ b/internal/datacoord/session/datanode_manager.go @@ -95,7 +95,7 @@ func WithDataNodeCreator(creator DataNodeCreatorFunc) SessionOpt { func defaultSessionCreator() DataNodeCreatorFunc { return func(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { - return grpcdatanodeclient.NewClient(ctx, addr, nodeID) + return grpcdatanodeclient.NewClient(ctx, addr, nodeID, false) } } diff --git a/internal/datacoord/session/indexnode_manager.go b/internal/datacoord/session/indexnode_manager.go index 3f79e2bb0d..c433b92816 100644 --- a/internal/datacoord/session/indexnode_manager.go +++ b/internal/datacoord/session/indexnode_manager.go @@ -24,7 +24,7 @@ import ( "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" - indexnodeclient "github.com/milvus-io/milvus/internal/distributed/indexnode/client" + datanodeclient "github.com/milvus-io/milvus/internal/distributed/datanode/client" "github.com/milvus-io/milvus/internal/types" "github.com/milvus-io/milvus/pkg/v2/log" "github.com/milvus-io/milvus/pkg/v2/metrics" @@ -32,46 +32,46 @@ import ( "github.com/milvus-io/milvus/pkg/v2/util/lock" "github.com/milvus-io/milvus/pkg/v2/util/merr" "github.com/milvus-io/milvus/pkg/v2/util/paramtable" - typeutil "github.com/milvus-io/milvus/pkg/v2/util/typeutil" + "github.com/milvus-io/milvus/pkg/v2/util/typeutil" ) -func defaultIndexNodeCreatorFunc(ctx context.Context, addr string, nodeID int64) (types.IndexNodeClient, error) { - return indexnodeclient.NewClient(ctx, addr, nodeID, paramtable.Get().DataCoordCfg.WithCredential.GetAsBool()) +func defaultIndexNodeCreatorFunc(ctx context.Context, addr string, nodeID int64) (types.DataNodeClient, error) { + return datanodeclient.NewClient(ctx, addr, nodeID, paramtable.Get().DataCoordCfg.WithCredential.GetAsBool()) } type WorkerManager interface { AddNode(nodeID typeutil.UniqueID, address string) error RemoveNode(nodeID typeutil.UniqueID) StoppingNode(nodeID typeutil.UniqueID) - PickClient() (typeutil.UniqueID, types.IndexNodeClient) + PickClient() (typeutil.UniqueID, types.DataNodeClient) QuerySlots() map[int64]int64 ClientSupportDisk() bool - GetAllClients() map[typeutil.UniqueID]types.IndexNodeClient - GetClientByID(nodeID typeutil.UniqueID) (types.IndexNodeClient, bool) + GetAllClients() map[typeutil.UniqueID]types.DataNodeClient + GetClientByID(nodeID typeutil.UniqueID) (types.DataNodeClient, bool) } // IndexNodeManager is used to manage the client of IndexNode. type IndexNodeManager struct { - nodeClients map[typeutil.UniqueID]types.IndexNodeClient + nodeClients map[typeutil.UniqueID]types.DataNodeClient stoppingNodes map[typeutil.UniqueID]struct{} lock lock.RWMutex ctx context.Context - indexNodeCreator IndexNodeCreatorFunc + indexNodeCreator DataNodeCreatorFunc } // NewNodeManager is used to create a new IndexNodeManager. -func NewNodeManager(ctx context.Context, indexNodeCreator IndexNodeCreatorFunc) *IndexNodeManager { +func NewNodeManager(ctx context.Context, dataNodeCreator DataNodeCreatorFunc) *IndexNodeManager { return &IndexNodeManager{ - nodeClients: make(map[typeutil.UniqueID]types.IndexNodeClient), + nodeClients: make(map[typeutil.UniqueID]types.DataNodeClient), stoppingNodes: make(map[typeutil.UniqueID]struct{}), lock: lock.RWMutex{}, ctx: ctx, - indexNodeCreator: indexNodeCreator, + indexNodeCreator: dataNodeCreator, } } // SetClient sets IndexNode client to node manager. -func (nm *IndexNodeManager) SetClient(nodeID typeutil.UniqueID, client types.IndexNodeClient) { +func (nm *IndexNodeManager) SetClient(nodeID typeutil.UniqueID, client types.DataNodeClient) { log := log.Ctx(nm.ctx) log.Debug("set IndexNode client", zap.Int64("nodeID", nodeID)) nm.lock.Lock() @@ -102,7 +102,7 @@ func (nm *IndexNodeManager) StoppingNode(nodeID typeutil.UniqueID) { func (nm *IndexNodeManager) AddNode(nodeID typeutil.UniqueID, address string) error { log.Ctx(nm.ctx).Debug("add IndexNode", zap.Int64("nodeID", nodeID), zap.String("node address", address)) var ( - nodeClient types.IndexNodeClient + nodeClient types.DataNodeClient err error ) @@ -152,7 +152,7 @@ func (nm *IndexNodeManager) QuerySlots() map[int64]int64 { return nodeSlots } -func (nm *IndexNodeManager) PickClient() (typeutil.UniqueID, types.IndexNodeClient) { +func (nm *IndexNodeManager) PickClient() (typeutil.UniqueID, types.DataNodeClient) { nm.lock.Lock() defer nm.lock.Unlock() @@ -256,11 +256,11 @@ func (nm *IndexNodeManager) ClientSupportDisk() bool { return false } -func (nm *IndexNodeManager) GetAllClients() map[typeutil.UniqueID]types.IndexNodeClient { +func (nm *IndexNodeManager) GetAllClients() map[typeutil.UniqueID]types.DataNodeClient { nm.lock.RLock() defer nm.lock.RUnlock() - allClients := make(map[typeutil.UniqueID]types.IndexNodeClient, len(nm.nodeClients)) + allClients := make(map[typeutil.UniqueID]types.DataNodeClient, len(nm.nodeClients)) for nodeID, client := range nm.nodeClients { if _, ok := nm.stoppingNodes[nodeID]; !ok { allClients[nodeID] = client @@ -270,7 +270,7 @@ func (nm *IndexNodeManager) GetAllClients() map[typeutil.UniqueID]types.IndexNod return allClients } -func (nm *IndexNodeManager) GetClientByID(nodeID typeutil.UniqueID) (types.IndexNodeClient, bool) { +func (nm *IndexNodeManager) GetClientByID(nodeID typeutil.UniqueID) (types.DataNodeClient, bool) { nm.lock.RLock() defer nm.lock.RUnlock() @@ -286,7 +286,7 @@ type indexNodeGetMetricsResponse struct { // getMetrics get metrics information of all IndexNode. func (nm *IndexNodeManager) getMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest) []indexNodeGetMetricsResponse { - var clients []types.IndexNodeClient + var clients []types.DataNodeClient nm.lock.RLock() for _, node := range nm.nodeClients { clients = append(clients, node) diff --git a/internal/datacoord/session/indexnode_manager_test.go b/internal/datacoord/session/indexnode_manager_test.go index 71bf022322..1e4372540d 100644 --- a/internal/datacoord/session/indexnode_manager_test.go +++ b/internal/datacoord/session/indexnode_manager_test.go @@ -50,8 +50,8 @@ func TestIndexNodeManager_AddNode(t *testing.T) { func TestIndexNodeManager_PickClient(t *testing.T) { paramtable.Init() - getMockedGetJobStatsClient := func(resp *workerpb.GetJobStatsResponse, err error) types.IndexNodeClient { - ic := mocks.NewMockIndexNodeClient(t) + getMockedGetJobStatsClient := func(resp *workerpb.GetJobStatsResponse, err error) types.DataNodeClient { + ic := mocks.NewMockDataNodeClient(t) ic.EXPECT().GetJobStats(mock.Anything, mock.Anything, mock.Anything).Return(resp, err) return ic } @@ -61,7 +61,7 @@ func TestIndexNodeManager_PickClient(t *testing.T) { t.Run("multiple unavailable IndexNode", func(t *testing.T) { nm := &IndexNodeManager{ ctx: context.TODO(), - nodeClients: map[typeutil.UniqueID]types.IndexNodeClient{ + nodeClients: map[typeutil.UniqueID]types.DataNodeClient{ 1: getMockedGetJobStatsClient(&workerpb.GetJobStatsResponse{ Status: merr.Status(err), }, err), @@ -102,8 +102,8 @@ func TestIndexNodeManager_PickClient(t *testing.T) { func TestIndexNodeManager_ClientSupportDisk(t *testing.T) { paramtable.Init() - getMockedGetJobStatsClient := func(resp *workerpb.GetJobStatsResponse, err error) types.IndexNodeClient { - ic := mocks.NewMockIndexNodeClient(t) + getMockedGetJobStatsClient := func(resp *workerpb.GetJobStatsResponse, err error) types.DataNodeClient { + ic := mocks.NewMockDataNodeClient(t) ic.EXPECT().GetJobStats(mock.Anything, mock.Anything, mock.Anything).Return(resp, err) return ic } @@ -114,7 +114,7 @@ func TestIndexNodeManager_ClientSupportDisk(t *testing.T) { nm := &IndexNodeManager{ ctx: context.Background(), lock: lock.RWMutex{}, - nodeClients: map[typeutil.UniqueID]types.IndexNodeClient{ + nodeClients: map[typeutil.UniqueID]types.DataNodeClient{ 1: getMockedGetJobStatsClient(&workerpb.GetJobStatsResponse{ Status: merr.Success(), TaskSlots: 1, @@ -132,7 +132,7 @@ func TestIndexNodeManager_ClientSupportDisk(t *testing.T) { nm := &IndexNodeManager{ ctx: context.Background(), lock: lock.RWMutex{}, - nodeClients: map[typeutil.UniqueID]types.IndexNodeClient{ + nodeClients: map[typeutil.UniqueID]types.DataNodeClient{ 1: getMockedGetJobStatsClient(&workerpb.GetJobStatsResponse{ Status: merr.Success(), TaskSlots: 1, @@ -150,7 +150,7 @@ func TestIndexNodeManager_ClientSupportDisk(t *testing.T) { nm := &IndexNodeManager{ ctx: context.Background(), lock: lock.RWMutex{}, - nodeClients: map[typeutil.UniqueID]types.IndexNodeClient{}, + nodeClients: map[typeutil.UniqueID]types.DataNodeClient{}, } support := nm.ClientSupportDisk() @@ -161,7 +161,7 @@ func TestIndexNodeManager_ClientSupportDisk(t *testing.T) { nm := &IndexNodeManager{ ctx: context.Background(), lock: lock.RWMutex{}, - nodeClients: map[typeutil.UniqueID]types.IndexNodeClient{ + nodeClients: map[typeutil.UniqueID]types.DataNodeClient{ 1: getMockedGetJobStatsClient(nil, err), }, } @@ -174,7 +174,7 @@ func TestIndexNodeManager_ClientSupportDisk(t *testing.T) { nm := &IndexNodeManager{ ctx: context.Background(), lock: lock.RWMutex{}, - nodeClients: map[typeutil.UniqueID]types.IndexNodeClient{ + nodeClients: map[typeutil.UniqueID]types.DataNodeClient{ 1: getMockedGetJobStatsClient(&workerpb.GetJobStatsResponse{ Status: merr.Status(err), TaskSlots: 0, diff --git a/internal/datacoord/session/mock_worker_manager.go b/internal/datacoord/session/mock_worker_manager.go index 4ecab8be08..d2ab9293c9 100644 --- a/internal/datacoord/session/mock_worker_manager.go +++ b/internal/datacoord/session/mock_worker_manager.go @@ -113,19 +113,19 @@ func (_c *MockWorkerManager_ClientSupportDisk_Call) RunAndReturn(run func() bool } // GetAllClients provides a mock function with given fields: -func (_m *MockWorkerManager) GetAllClients() map[int64]types.IndexNodeClient { +func (_m *MockWorkerManager) GetAllClients() map[int64]types.DataNodeClient { ret := _m.Called() if len(ret) == 0 { panic("no return value specified for GetAllClients") } - var r0 map[int64]types.IndexNodeClient - if rf, ok := ret.Get(0).(func() map[int64]types.IndexNodeClient); ok { + var r0 map[int64]types.DataNodeClient + if rf, ok := ret.Get(0).(func() map[int64]types.DataNodeClient); ok { r0 = rf() } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(map[int64]types.IndexNodeClient) + r0 = ret.Get(0).(map[int64]types.DataNodeClient) } } @@ -149,34 +149,34 @@ func (_c *MockWorkerManager_GetAllClients_Call) Run(run func()) *MockWorkerManag return _c } -func (_c *MockWorkerManager_GetAllClients_Call) Return(_a0 map[int64]types.IndexNodeClient) *MockWorkerManager_GetAllClients_Call { +func (_c *MockWorkerManager_GetAllClients_Call) Return(_a0 map[int64]types.DataNodeClient) *MockWorkerManager_GetAllClients_Call { _c.Call.Return(_a0) return _c } -func (_c *MockWorkerManager_GetAllClients_Call) RunAndReturn(run func() map[int64]types.IndexNodeClient) *MockWorkerManager_GetAllClients_Call { +func (_c *MockWorkerManager_GetAllClients_Call) RunAndReturn(run func() map[int64]types.DataNodeClient) *MockWorkerManager_GetAllClients_Call { _c.Call.Return(run) return _c } // GetClientByID provides a mock function with given fields: nodeID -func (_m *MockWorkerManager) GetClientByID(nodeID int64) (types.IndexNodeClient, bool) { +func (_m *MockWorkerManager) GetClientByID(nodeID int64) (types.DataNodeClient, bool) { ret := _m.Called(nodeID) if len(ret) == 0 { panic("no return value specified for GetClientByID") } - var r0 types.IndexNodeClient + var r0 types.DataNodeClient var r1 bool - if rf, ok := ret.Get(0).(func(int64) (types.IndexNodeClient, bool)); ok { + if rf, ok := ret.Get(0).(func(int64) (types.DataNodeClient, bool)); ok { return rf(nodeID) } - if rf, ok := ret.Get(0).(func(int64) types.IndexNodeClient); ok { + if rf, ok := ret.Get(0).(func(int64) types.DataNodeClient); ok { r0 = rf(nodeID) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(types.IndexNodeClient) + r0 = ret.Get(0).(types.DataNodeClient) } } @@ -207,18 +207,18 @@ func (_c *MockWorkerManager_GetClientByID_Call) Run(run func(nodeID int64)) *Moc return _c } -func (_c *MockWorkerManager_GetClientByID_Call) Return(_a0 types.IndexNodeClient, _a1 bool) *MockWorkerManager_GetClientByID_Call { +func (_c *MockWorkerManager_GetClientByID_Call) Return(_a0 types.DataNodeClient, _a1 bool) *MockWorkerManager_GetClientByID_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockWorkerManager_GetClientByID_Call) RunAndReturn(run func(int64) (types.IndexNodeClient, bool)) *MockWorkerManager_GetClientByID_Call { +func (_c *MockWorkerManager_GetClientByID_Call) RunAndReturn(run func(int64) (types.DataNodeClient, bool)) *MockWorkerManager_GetClientByID_Call { _c.Call.Return(run) return _c } // PickClient provides a mock function with given fields: -func (_m *MockWorkerManager) PickClient() (int64, types.IndexNodeClient) { +func (_m *MockWorkerManager) PickClient() (int64, types.DataNodeClient) { ret := _m.Called() if len(ret) == 0 { @@ -226,8 +226,8 @@ func (_m *MockWorkerManager) PickClient() (int64, types.IndexNodeClient) { } var r0 int64 - var r1 types.IndexNodeClient - if rf, ok := ret.Get(0).(func() (int64, types.IndexNodeClient)); ok { + var r1 types.DataNodeClient + if rf, ok := ret.Get(0).(func() (int64, types.DataNodeClient)); ok { return rf() } if rf, ok := ret.Get(0).(func() int64); ok { @@ -236,11 +236,11 @@ func (_m *MockWorkerManager) PickClient() (int64, types.IndexNodeClient) { r0 = ret.Get(0).(int64) } - if rf, ok := ret.Get(1).(func() types.IndexNodeClient); ok { + if rf, ok := ret.Get(1).(func() types.DataNodeClient); ok { r1 = rf() } else { if ret.Get(1) != nil { - r1 = ret.Get(1).(types.IndexNodeClient) + r1 = ret.Get(1).(types.DataNodeClient) } } @@ -264,12 +264,12 @@ func (_c *MockWorkerManager_PickClient_Call) Run(run func()) *MockWorkerManager_ return _c } -func (_c *MockWorkerManager_PickClient_Call) Return(_a0 int64, _a1 types.IndexNodeClient) *MockWorkerManager_PickClient_Call { +func (_c *MockWorkerManager_PickClient_Call) Return(_a0 int64, _a1 types.DataNodeClient) *MockWorkerManager_PickClient_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockWorkerManager_PickClient_Call) RunAndReturn(run func() (int64, types.IndexNodeClient)) *MockWorkerManager_PickClient_Call { +func (_c *MockWorkerManager_PickClient_Call) RunAndReturn(run func() (int64, types.DataNodeClient)) *MockWorkerManager_PickClient_Call { _c.Call.Return(run) return _c } diff --git a/internal/datacoord/task_analyze.go b/internal/datacoord/task_analyze.go index 8d588b47fa..fca7ce889b 100644 --- a/internal/datacoord/task_analyze.go +++ b/internal/datacoord/task_analyze.go @@ -227,7 +227,7 @@ func (at *analyzeTask) PreCheck(ctx context.Context, dependency *taskScheduler) return true } -func (at *analyzeTask) AssignTask(ctx context.Context, client types.IndexNodeClient, meta *meta) bool { +func (at *analyzeTask) AssignTask(ctx context.Context, client types.DataNodeClient, meta *meta) bool { ctx, cancel := context.WithTimeout(ctx, Params.DataCoordCfg.RequestTimeoutSeconds.GetAsDuration(time.Second)) defer cancel() resp, err := client.CreateJobV2(ctx, &workerpb.CreateJobV2Request{ @@ -256,7 +256,7 @@ func (at *analyzeTask) setResult(result *workerpb.AnalyzeResult) { at.taskInfo = result } -func (at *analyzeTask) QueryResult(ctx context.Context, client types.IndexNodeClient) { +func (at *analyzeTask) QueryResult(ctx context.Context, client types.DataNodeClient) { ctx, cancel := context.WithTimeout(ctx, Params.DataCoordCfg.RequestTimeoutSeconds.GetAsDuration(time.Second)) defer cancel() resp, err := client.QueryJobsV2(ctx, &workerpb.QueryJobsV2Request{ @@ -296,7 +296,7 @@ func (at *analyzeTask) QueryResult(ctx context.Context, client types.IndexNodeCl at.SetState(indexpb.JobState_JobStateRetry, "analyze result is not in info response") } -func (at *analyzeTask) DropTaskOnWorker(ctx context.Context, client types.IndexNodeClient) bool { +func (at *analyzeTask) DropTaskOnWorker(ctx context.Context, client types.DataNodeClient) bool { ctx, cancel := context.WithTimeout(ctx, Params.DataCoordCfg.RequestTimeoutSeconds.GetAsDuration(time.Second)) defer cancel() resp, err := client.DropJobsV2(ctx, &workerpb.DropJobsV2Request{ diff --git a/internal/datacoord/task_index.go b/internal/datacoord/task_index.go index 9458356367..b0837a5cbf 100644 --- a/internal/datacoord/task_index.go +++ b/internal/datacoord/task_index.go @@ -267,7 +267,7 @@ func (it *indexBuildTask) PreCheck(ctx context.Context, dependency *taskSchedule return true } -func (it *indexBuildTask) AssignTask(ctx context.Context, client types.IndexNodeClient, meta *meta) bool { +func (it *indexBuildTask) AssignTask(ctx context.Context, client types.DataNodeClient, meta *meta) bool { ctx, cancel := context.WithTimeout(ctx, Params.DataCoordCfg.RequestTimeoutSeconds.GetAsDuration(time.Second)) defer cancel() resp, err := client.CreateJobV2(ctx, &workerpb.CreateJobV2Request{ @@ -296,7 +296,7 @@ func (it *indexBuildTask) setResult(info *workerpb.IndexTaskInfo) { it.taskInfo = info } -func (it *indexBuildTask) QueryResult(ctx context.Context, node types.IndexNodeClient) { +func (it *indexBuildTask) QueryResult(ctx context.Context, node types.DataNodeClient) { ctx, cancel := context.WithTimeout(ctx, Params.DataCoordCfg.RequestTimeoutSeconds.GetAsDuration(time.Second)) defer cancel() resp, err := node.QueryJobsV2(ctx, &workerpb.QueryJobsV2Request{ @@ -334,7 +334,7 @@ func (it *indexBuildTask) QueryResult(ctx context.Context, node types.IndexNodeC it.SetState(indexpb.JobState_JobStateRetry, "index is not in info response") } -func (it *indexBuildTask) DropTaskOnWorker(ctx context.Context, client types.IndexNodeClient) bool { +func (it *indexBuildTask) DropTaskOnWorker(ctx context.Context, client types.DataNodeClient) bool { ctx, cancel := context.WithTimeout(ctx, Params.DataCoordCfg.RequestTimeoutSeconds.GetAsDuration(time.Second)) defer cancel() resp, err := client.DropJobsV2(ctx, &workerpb.DropJobsV2Request{ diff --git a/internal/datacoord/task_scheduler_test.go b/internal/datacoord/task_scheduler_test.go index 900ff5eae4..1d8d6a8a75 100644 --- a/internal/datacoord/task_scheduler_test.go +++ b/internal/datacoord/task_scheduler_test.go @@ -787,7 +787,7 @@ func (s *taskSchedulerSuite) scheduler(handler Handler) { catalog.EXPECT().AlterSegmentIndexes(mock.Anything, mock.Anything).Return(nil) // catalog.EXPECT().SaveStatsTask(mock.Anything, mock.Anything).Return(nil) - in := mocks.NewMockIndexNodeClient(s.T()) + in := mocks.NewMockDataNodeClient(s.T()) in.EXPECT().CreateJobV2(mock.Anything, mock.Anything).Return(merr.Success(), nil) in.EXPECT().QueryJobsV2(mock.Anything, mock.Anything).RunAndReturn( func(ctx context.Context, request *workerpb.QueryJobsV2Request, option ...grpc.CallOption) (*workerpb.QueryJobsV2Response, error) { @@ -1050,7 +1050,7 @@ func (s *taskSchedulerSuite) Test_analyzeTaskFailCase() { catalog := catalogmocks.NewDataCoordCatalog(s.T()) catalog.EXPECT().DropAnalyzeTask(mock.Anything, mock.Anything).Return(nil) - in := mocks.NewMockIndexNodeClient(s.T()) + in := mocks.NewMockDataNodeClient(s.T()) workerManager := session.NewMockWorkerManager(s.T()) workerManager.EXPECT().QuerySlots().RunAndReturn(func() map[int64]int64 { @@ -1300,7 +1300,7 @@ func (s *taskSchedulerSuite) Test_indexTaskFailCase() { indexNodeTasks := make(map[int64]int) catalog := catalogmocks.NewDataCoordCatalog(s.T()) - in := mocks.NewMockIndexNodeClient(s.T()) + in := mocks.NewMockDataNodeClient(s.T()) workerManager := session.NewMockWorkerManager(s.T()) workerManager.EXPECT().QuerySlots().RunAndReturn(func() map[int64]int64 { return map[int64]int64{ @@ -1403,7 +1403,7 @@ func (s *taskSchedulerSuite) Test_indexTaskFailCase() { }).Once() // assign failed --> retry - workerManager.EXPECT().GetClientByID(mock.Anything).RunAndReturn(func(nodeID int64) (types.IndexNodeClient, bool) { + workerManager.EXPECT().GetClientByID(mock.Anything).RunAndReturn(func(nodeID int64) (types.DataNodeClient, bool) { log.Debug("get client success, but assign failed", zap.Int64("nodeID", nodeID)) return in, true }).Once() @@ -1418,7 +1418,7 @@ func (s *taskSchedulerSuite) Test_indexTaskFailCase() { }).Once() // retry --> init - workerManager.EXPECT().GetClientByID(mock.Anything).RunAndReturn(func(nodeID int64) (types.IndexNodeClient, bool) { + workerManager.EXPECT().GetClientByID(mock.Anything).RunAndReturn(func(nodeID int64) (types.DataNodeClient, bool) { log.Debug("assign failed, drop task on worker", zap.Int64("nodeID", nodeID)) return in, true }).Once() @@ -1431,7 +1431,7 @@ func (s *taskSchedulerSuite) Test_indexTaskFailCase() { }).Once() // init --> inProgress - workerManager.EXPECT().GetClientByID(mock.Anything).RunAndReturn(func(nodeID int64) (types.IndexNodeClient, bool) { + workerManager.EXPECT().GetClientByID(mock.Anything).RunAndReturn(func(nodeID int64) (types.DataNodeClient, bool) { log.Debug("assign task success", zap.Int64("nodeID", nodeID)) return in, true }).Once() @@ -1458,7 +1458,7 @@ func (s *taskSchedulerSuite) Test_indexTaskFailCase() { }).Once() // inProgress --> Finished - workerManager.EXPECT().GetClientByID(mock.Anything).RunAndReturn(func(nodeID int64) (types.IndexNodeClient, bool) { + workerManager.EXPECT().GetClientByID(mock.Anything).RunAndReturn(func(nodeID int64) (types.DataNodeClient, bool) { log.Debug("get task result success, task is finished", zap.Int64("nodeID", nodeID)) return in, true }).Once() @@ -1488,7 +1488,7 @@ func (s *taskSchedulerSuite) Test_indexTaskFailCase() { log.Debug("task is finished, alter segment index success", zap.Int64("taskID", indices[0].BuildID)) return nil }).Once() - workerManager.EXPECT().GetClientByID(mock.Anything).RunAndReturn(func(nodeID int64) (types.IndexNodeClient, bool) { + workerManager.EXPECT().GetClientByID(mock.Anything).RunAndReturn(func(nodeID int64) (types.DataNodeClient, bool) { log.Debug("task is finished, drop task on worker", zap.Int64("nodeID", nodeID)) return in, true }).Once() @@ -1534,7 +1534,7 @@ func (s *taskSchedulerSuite) Test_indexTaskWithMvOptionalScalarField() { ctx := context.Background() catalog := catalogmocks.NewDataCoordCatalog(s.T()) catalog.EXPECT().AlterSegmentIndexes(mock.Anything, mock.Anything).Return(nil) - in := mocks.NewMockIndexNodeClient(s.T()) + in := mocks.NewMockDataNodeClient(s.T()) workerManager := session.NewMockWorkerManager(s.T()) workerManager.EXPECT().QuerySlots().RunAndReturn(func() map[int64]int64 { @@ -2248,7 +2248,7 @@ func (s *taskSchedulerSuite) Test_zeroSegmentStats() { cm := mocks.NewChunkManager(s.T()) catalog.EXPECT().AlterSegments(mock.Anything, mock.Anything, mock.Anything).Return(nil) catalog.EXPECT().SaveStatsTask(mock.Anything, mock.Anything).Return(nil) - in := mocks.NewMockIndexNodeClient(s.T()) + in := mocks.NewMockDataNodeClient(s.T()) in.EXPECT().DropJobsV2(mock.Anything, mock.Anything).Return(&commonpb.Status{ErrorCode: commonpb.ErrorCode_Success}, nil) workerManager.EXPECT().GetClientByID(mock.Anything).Return(in, true) diff --git a/internal/datacoord/task_stats.go b/internal/datacoord/task_stats.go index 5be68a84eb..06ec5c2741 100644 --- a/internal/datacoord/task_stats.go +++ b/internal/datacoord/task_stats.go @@ -244,7 +244,7 @@ func (st *statsTask) PreCheck(ctx context.Context, dependency *taskScheduler) bo return true } -func (st *statsTask) AssignTask(ctx context.Context, client types.IndexNodeClient, meta *meta) bool { +func (st *statsTask) AssignTask(ctx context.Context, client types.DataNodeClient, meta *meta) bool { segment := meta.GetHealthySegment(ctx, st.segmentID) if segment == nil { log.Ctx(ctx).Warn("segment is node healthy, skip stats") @@ -279,7 +279,7 @@ func (st *statsTask) AssignTask(ctx context.Context, client types.IndexNodeClien return true } -func (st *statsTask) QueryResult(ctx context.Context, client types.IndexNodeClient) { +func (st *statsTask) QueryResult(ctx context.Context, client types.DataNodeClient) { ctx, cancel := context.WithTimeout(ctx, Params.DataCoordCfg.RequestTimeoutSeconds.GetAsDuration(time.Second)) defer cancel() resp, err := client.QueryJobsV2(ctx, &workerpb.QueryJobsV2Request{ @@ -315,7 +315,7 @@ func (st *statsTask) QueryResult(ctx context.Context, client types.IndexNodeClie st.SetState(indexpb.JobState_JobStateRetry, "stats task is not in info response") } -func (st *statsTask) DropTaskOnWorker(ctx context.Context, client types.IndexNodeClient) bool { +func (st *statsTask) DropTaskOnWorker(ctx context.Context, client types.DataNodeClient) bool { ctx, cancel := context.WithTimeout(ctx, Params.DataCoordCfg.RequestTimeoutSeconds.GetAsDuration(time.Second)) defer cancel() resp, err := client.DropJobsV2(ctx, &workerpb.DropJobsV2Request{ diff --git a/internal/datacoord/task_stats_test.go b/internal/datacoord/task_stats_test.go index 0576d0e48f..0f44411136 100644 --- a/internal/datacoord/task_stats_test.go +++ b/internal/datacoord/task_stats_test.go @@ -372,7 +372,7 @@ func (s *statsTaskSuite) TestTaskStats_PreCheck() { s.Run("AssignTask", func() { s.Run("assign failed", func() { - in := mocks.NewMockIndexNodeClient(s.T()) + in := mocks.NewMockDataNodeClient(s.T()) in.EXPECT().CreateJobV2(mock.Anything, mock.Anything).Return(&commonpb.Status{ ErrorCode: commonpb.ErrorCode_UnexpectedError, Reason: "mock error", @@ -395,7 +395,7 @@ func (s *statsTaskSuite) TestTaskStats_PreCheck() { }) s.Run("assign success", func() { - in := mocks.NewMockIndexNodeClient(s.T()) + in := mocks.NewMockDataNodeClient(s.T()) in.EXPECT().CreateJobV2(mock.Anything, mock.Anything).Return(&commonpb.Status{ ErrorCode: commonpb.ErrorCode_Success, Reason: "", @@ -420,7 +420,7 @@ func (s *statsTaskSuite) TestTaskStats_PreCheck() { s.Run("QueryResult", func() { s.Run("query failed", func() { - in := mocks.NewMockIndexNodeClient(s.T()) + in := mocks.NewMockDataNodeClient(s.T()) in.EXPECT().QueryJobsV2(mock.Anything, mock.Anything).Return(&workerpb.QueryJobsV2Response{ Status: &commonpb.Status{ ErrorCode: commonpb.ErrorCode_UnexpectedError, @@ -432,7 +432,7 @@ func (s *statsTaskSuite) TestTaskStats_PreCheck() { }) s.Run("state finished", func() { - in := mocks.NewMockIndexNodeClient(s.T()) + in := mocks.NewMockDataNodeClient(s.T()) in.EXPECT().QueryJobsV2(mock.Anything, mock.Anything).Return(&workerpb.QueryJobsV2Response{ Status: &commonpb.Status{ ErrorCode: commonpb.ErrorCode_Success, @@ -463,7 +463,7 @@ func (s *statsTaskSuite) TestTaskStats_PreCheck() { }) s.Run("task none", func() { - in := mocks.NewMockIndexNodeClient(s.T()) + in := mocks.NewMockDataNodeClient(s.T()) in.EXPECT().QueryJobsV2(mock.Anything, mock.Anything).Return(&workerpb.QueryJobsV2Response{ Status: &commonpb.Status{ ErrorCode: commonpb.ErrorCode_Success, @@ -490,7 +490,7 @@ func (s *statsTaskSuite) TestTaskStats_PreCheck() { }) s.Run("task not exist", func() { - in := mocks.NewMockIndexNodeClient(s.T()) + in := mocks.NewMockDataNodeClient(s.T()) in.EXPECT().QueryJobsV2(mock.Anything, mock.Anything).Return(&workerpb.QueryJobsV2Response{ Status: &commonpb.Status{ ErrorCode: commonpb.ErrorCode_Success, @@ -509,7 +509,7 @@ func (s *statsTaskSuite) TestTaskStats_PreCheck() { s.Run("DropTaskOnWorker", func() { s.Run("drop failed", func() { - in := mocks.NewMockIndexNodeClient(s.T()) + in := mocks.NewMockDataNodeClient(s.T()) in.EXPECT().DropJobsV2(mock.Anything, mock.Anything).Return(&commonpb.Status{ ErrorCode: commonpb.ErrorCode_UnexpectedError, Reason: "mock error", @@ -519,7 +519,7 @@ func (s *statsTaskSuite) TestTaskStats_PreCheck() { }) s.Run("drop success", func() { - in := mocks.NewMockIndexNodeClient(s.T()) + in := mocks.NewMockDataNodeClient(s.T()) in.EXPECT().DropJobsV2(mock.Anything, mock.Anything).Return(&commonpb.Status{ ErrorCode: commonpb.ErrorCode_Success, Reason: "", diff --git a/internal/datacoord/types.go b/internal/datacoord/types.go index b0a4200a83..7f9c8edbfb 100644 --- a/internal/datacoord/types.go +++ b/internal/datacoord/types.go @@ -35,9 +35,9 @@ type Task interface { GetFailReason() string UpdateVersion(ctx context.Context, nodeID int64, meta *meta, compactionHandler compactionPlanContext) error UpdateMetaBuildingState(meta *meta) error - AssignTask(ctx context.Context, client types.IndexNodeClient, meta *meta) bool - QueryResult(ctx context.Context, client types.IndexNodeClient) - DropTaskOnWorker(ctx context.Context, client types.IndexNodeClient) bool + AssignTask(ctx context.Context, client types.DataNodeClient, meta *meta) bool + QueryResult(ctx context.Context, client types.DataNodeClient) + DropTaskOnWorker(ctx context.Context, client types.DataNodeClient) bool SetJobInfo(meta *meta) error SetQueueTime(time.Time) GetQueueTime() time.Time diff --git a/internal/datanode/OWNERS b/internal/datanode/OWNERS index 17032aed69..06f5fde5a0 100644 --- a/internal/datanode/OWNERS +++ b/internal/datanode/OWNERS @@ -4,6 +4,9 @@ reviewers: - cydrain - scsven - sunby + - czs007 + - xiaocai2333 + - bigsheeper approvers: - maintainers diff --git a/internal/indexnode/chunk_mgr_factory.go b/internal/datanode/chunk_mgr_factory.go similarity index 69% rename from internal/indexnode/chunk_mgr_factory.go rename to internal/datanode/chunk_mgr_factory.go index e7e8f50ca9..56cd748a38 100644 --- a/internal/indexnode/chunk_mgr_factory.go +++ b/internal/datanode/chunk_mgr_factory.go @@ -1,4 +1,20 @@ -package indexnode +// 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. + +package datanode import ( "context" diff --git a/internal/datanode/data_node.go b/internal/datanode/data_node.go index f558002721..6abc7cc104 100644 --- a/internal/datanode/data_node.go +++ b/internal/datanode/data_node.go @@ -26,7 +26,6 @@ import ( "math/rand" "os" "sync" - "sync/atomic" "time" "github.com/cockroachdb/errors" @@ -40,6 +39,7 @@ import ( "github.com/milvus-io/milvus/internal/datanode/channel" "github.com/milvus-io/milvus/internal/datanode/compactor" "github.com/milvus-io/milvus/internal/datanode/importv2" + "github.com/milvus-io/milvus/internal/datanode/index" "github.com/milvus-io/milvus/internal/datanode/msghandlerimpl" "github.com/milvus-io/milvus/internal/datanode/util" "github.com/milvus-io/milvus/internal/flushcommon/broker" @@ -59,6 +59,7 @@ import ( "github.com/milvus-io/milvus/pkg/v2/mq/msgdispatcher" "github.com/milvus-io/milvus/pkg/v2/util/conc" "github.com/milvus-io/milvus/pkg/v2/util/expr" + "github.com/milvus-io/milvus/pkg/v2/util/lifetime" "github.com/milvus-io/milvus/pkg/v2/util/metricsinfo" "github.com/milvus-io/milvus/pkg/v2/util/paramtable" "github.com/milvus-io/milvus/pkg/v2/util/retry" @@ -92,7 +93,7 @@ type DataNode struct { ctx context.Context cancel context.CancelFunc Role string - stateCode atomic.Value // commonpb.StateCode_Initializing + lifetime lifetime.Lifetime[commonpb.StateCode] flowgraphManager pipeline.FlowgraphManager channelManager channel.ChannelManager @@ -102,6 +103,11 @@ type DataNode struct { importTaskMgr importv2.TaskManager importScheduler importv2.Scheduler + // indexnode related + storageFactory StorageFactory + taskScheduler *index.TaskScheduler + taskManager *index.TaskManager + segmentCache *util.Cache compactionExecutor compactor.Executor timeTickSender *util2.TimeTickSender @@ -139,9 +145,10 @@ func NewDataNode(ctx context.Context, factory dependency.Factory) *DataNode { rand.Seed(time.Now().UnixNano()) ctx2, cancel2 := context.WithCancel(ctx) node := &DataNode{ - ctx: ctx2, - cancel: cancel2, - Role: typeutil.DataNodeRole, + ctx: ctx2, + cancel: cancel2, + Role: typeutil.DataNodeRole, + lifetime: lifetime.NewLifetime(commonpb.StateCode_Abnormal), rootCoord: nil, dataCoord: nil, @@ -151,6 +158,10 @@ func NewDataNode(ctx context.Context, factory dependency.Factory) *DataNode { reportImportRetryTimes: 10, metricsRequest: metricsinfo.NewMetricsRequest(), } + sc := index.NewTaskScheduler(ctx2) + node.storageFactory = NewChunkMgrFactory() + node.taskScheduler = sc + node.taskManager = index.NewTaskManager(ctx2) node.UpdateStateCode(commonpb.StateCode_Abnormal) expr.Register("datanode", node) return node @@ -275,6 +286,8 @@ func (node *DataNode) Init() error { node.channelCheckpointUpdater = util2.NewChannelCheckpointUpdater(node.broker) node.flowgraphManager = pipeline.NewFlowgraphManager() + index.InitSegcore() + log.Info("init datanode done", zap.String("Address", node.address)) }) return initError @@ -360,6 +373,12 @@ func (node *DataNode) Start() error { go node.importScheduler.Start() + err = node.taskScheduler.Start() + if err != nil { + startErr = err + return + } + node.UpdateStateCode(commonpb.StateCode_Healthy) }) return startErr @@ -367,12 +386,12 @@ func (node *DataNode) Start() error { // UpdateStateCode updates datanode's state code func (node *DataNode) UpdateStateCode(code commonpb.StateCode) { - node.stateCode.Store(code) + node.lifetime.SetState(code) } // GetStateCode return datanode's state code func (node *DataNode) GetStateCode() commonpb.StateCode { - return node.stateCode.Load().(commonpb.StateCode) + return node.lifetime.GetState() } func (node *DataNode) isHealthy() bool { @@ -392,6 +411,7 @@ func (node *DataNode) Stop() error { node.stopOnce.Do(func() { // https://github.com/milvus-io/milvus/issues/12282 node.UpdateStateCode(commonpb.StateCode_Abnormal) + node.lifetime.Wait() if node.channelManager != nil { node.channelManager.Close() } @@ -437,6 +457,15 @@ func (node *DataNode) Stop() error { node.importScheduler.Close() } + // cleanup all running tasks + node.taskManager.DeleteAllTasks() + + if node.taskScheduler != nil { + node.taskScheduler.Close() + } + + index.CloseSegcore() + // Delay the cancellation of ctx to ensure that the session is automatically recycled after closed the flow graph node.cancel() }) diff --git a/internal/datanode/index/init_segcore.go b/internal/datanode/index/init_segcore.go new file mode 100644 index 0000000000..affe486438 --- /dev/null +++ b/internal/datanode/index/init_segcore.go @@ -0,0 +1,84 @@ +// 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. + +package index + +/* +#cgo pkg-config: milvus_core + +#include +#include +#include "common/init_c.h" +#include "segcore/segcore_init_c.h" +#include "indexbuilder/init_c.h" +*/ +import "C" +import ( + "path" + "path/filepath" + "unsafe" + + "github.com/milvus-io/milvus/internal/util/initcore" + "github.com/milvus-io/milvus/pkg/v2/util/hardware" + "github.com/milvus-io/milvus/pkg/v2/util/paramtable" + "github.com/milvus-io/milvus/pkg/v2/util/typeutil" +) + +func InitSegcore() { + cGlogConf := C.CString(path.Join(paramtable.GetBaseTable().GetConfigDir(), paramtable.DefaultGlogConf)) + C.IndexBuilderInit(cGlogConf) + C.free(unsafe.Pointer(cGlogConf)) + + // override index builder SIMD type + cSimdType := C.CString(paramtable.Get().CommonCfg.SimdType.GetValue()) + C.IndexBuilderSetSimdType(cSimdType) + C.free(unsafe.Pointer(cSimdType)) + + // override segcore index slice size + cIndexSliceSize := C.int64_t(paramtable.Get().CommonCfg.IndexSliceSize.GetAsInt64()) + C.InitIndexSliceSize(cIndexSliceSize) + + // set up thread pool for different priorities + cHighPriorityThreadCoreCoefficient := C.int64_t(paramtable.Get().CommonCfg.HighPriorityThreadCoreCoefficient.GetAsInt64()) + C.InitHighPriorityThreadCoreCoefficient(cHighPriorityThreadCoreCoefficient) + cMiddlePriorityThreadCoreCoefficient := C.int64_t(paramtable.Get().CommonCfg.MiddlePriorityThreadCoreCoefficient.GetAsInt64()) + C.InitMiddlePriorityThreadCoreCoefficient(cMiddlePriorityThreadCoreCoefficient) + cLowPriorityThreadCoreCoefficient := C.int64_t(paramtable.Get().CommonCfg.LowPriorityThreadCoreCoefficient.GetAsInt64()) + C.InitLowPriorityThreadCoreCoefficient(cLowPriorityThreadCoreCoefficient) + + cCPUNum := C.int(hardware.GetCPUNum()) + C.InitCpuNum(cCPUNum) + + cKnowhereThreadPoolSize := C.uint32_t(hardware.GetCPUNum() * paramtable.DefaultKnowhereThreadPoolNumRatioInBuild) + if paramtable.GetRole() == typeutil.StandaloneRole { + threadPoolSize := int(float64(hardware.GetCPUNum()) * paramtable.Get().CommonCfg.BuildIndexThreadPoolRatio.GetAsFloat()) + if threadPoolSize < 1 { + threadPoolSize = 1 + } + cKnowhereThreadPoolSize = C.uint32_t(threadPoolSize) + } + C.SegcoreSetKnowhereBuildThreadPoolNum(cKnowhereThreadPoolSize) + + localDataRootPath := filepath.Join(paramtable.Get().LocalStorageCfg.Path.GetValue(), typeutil.IndexNodeRole) + initcore.InitLocalChunkManager(localDataRootPath) + cGpuMemoryPoolInitSize := C.uint32_t(paramtable.Get().GpuConfig.InitSize.GetAsUint32()) + cGpuMemoryPoolMaxSize := C.uint32_t(paramtable.Get().GpuConfig.MaxSize.GetAsUint32()) + C.SegcoreSetKnowhereGpuMemoryPoolSize(cGpuMemoryPoolInitSize, cGpuMemoryPoolMaxSize) +} + +func CloseSegcore() { + initcore.CleanGlogManager() +} diff --git a/internal/indexnode/task_scheduler.go b/internal/datanode/index/scheduler.go similarity index 78% rename from internal/indexnode/task_scheduler.go rename to internal/datanode/index/scheduler.go index cd98bed2c4..93196cc77b 100644 --- a/internal/indexnode/task_scheduler.go +++ b/internal/datanode/index/scheduler.go @@ -14,12 +14,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -package indexnode +package index import ( "container/list" "context" - "fmt" "runtime/debug" "sync" @@ -27,7 +26,6 @@ import ( "go.uber.org/zap" "github.com/milvus-io/milvus/pkg/v2/log" - "github.com/milvus-io/milvus/pkg/v2/metrics" "github.com/milvus-io/milvus/pkg/v2/proto/indexpb" "github.com/milvus-io/milvus/pkg/v2/util/merr" "github.com/milvus-io/milvus/pkg/v2/util/paramtable" @@ -38,18 +36,18 @@ type TaskQueue interface { utChan() <-chan int utEmpty() bool utFull() bool - addUnissuedTask(t task) error - PopUnissuedTask() task - AddActiveTask(t task) - PopActiveTask(tName string) task - Enqueue(t task) error + addUnissuedTask(t Task) error + PopUnissuedTask() Task + AddActiveTask(t Task) + PopActiveTask(tName string) Task + Enqueue(t Task) error GetTaskNum() (int, int) } // BaseTaskQueue is a basic instance of TaskQueue. type IndexTaskQueue struct { unissuedTasks *list.List - activeTasks map[string]task + activeTasks map[string]Task utLock sync.Mutex atLock sync.Mutex @@ -73,12 +71,12 @@ func (queue *IndexTaskQueue) utFull() bool { return int64(queue.unissuedTasks.Len()) >= queue.maxTaskNum } -func (queue *IndexTaskQueue) addUnissuedTask(t task) error { +func (queue *IndexTaskQueue) addUnissuedTask(t Task) error { queue.utLock.Lock() defer queue.utLock.Unlock() if queue.utFull() { - return errors.New("IndexNode task queue is full") + return errors.New("index task queue is full") } queue.unissuedTasks.PushBack(t) queue.utBufChan <- 1 @@ -86,7 +84,7 @@ func (queue *IndexTaskQueue) addUnissuedTask(t task) error { } // PopUnissuedTask pops a task from tasks queue. -func (queue *IndexTaskQueue) PopUnissuedTask() task { +func (queue *IndexTaskQueue) PopUnissuedTask() Task { queue.utLock.Lock() defer queue.utLock.Unlock() @@ -97,25 +95,25 @@ func (queue *IndexTaskQueue) PopUnissuedTask() task { ft := queue.unissuedTasks.Front() queue.unissuedTasks.Remove(ft) - return ft.Value.(task) + return ft.Value.(Task) } // AddActiveTask adds a task to activeTasks. -func (queue *IndexTaskQueue) AddActiveTask(t task) { +func (queue *IndexTaskQueue) AddActiveTask(t Task) { queue.atLock.Lock() defer queue.atLock.Unlock() tName := t.Name() _, ok := queue.activeTasks[tName] if ok { - log.Ctx(context.TODO()).Debug("IndexNode task already in active task list", zap.String("TaskID", tName)) + log.Ctx(context.TODO()).Debug("task already in active task list", zap.String("TaskID", tName)) } queue.activeTasks[tName] = t } // PopActiveTask pops a task from activateTask and the task will be executed. -func (queue *IndexTaskQueue) PopActiveTask(tName string) task { +func (queue *IndexTaskQueue) PopActiveTask(tName string) Task { queue.atLock.Lock() defer queue.atLock.Unlock() @@ -124,12 +122,12 @@ func (queue *IndexTaskQueue) PopActiveTask(tName string) task { delete(queue.activeTasks, tName) return t } - log.Ctx(queue.sched.ctx).Debug("IndexNode task was not found in the active task list", zap.String("TaskName", tName)) + log.Ctx(queue.sched.ctx).Debug("task was not found in the active task list", zap.String("TaskName", tName)) return nil } // Enqueue adds a task to TaskQueue. -func (queue *IndexTaskQueue) Enqueue(t task) error { +func (queue *IndexTaskQueue) Enqueue(t Task) error { err := t.OnEnqueue(t.Ctx()) if err != nil { return err @@ -158,7 +156,7 @@ func (queue *IndexTaskQueue) GetTaskNum() (int, int) { func NewIndexBuildTaskQueue(sched *TaskScheduler) *IndexTaskQueue { return &IndexTaskQueue{ unissuedTasks: list.New(), - activeTasks: make(map[string]task), + activeTasks: make(map[string]Task), maxTaskNum: 1024, utBufChan: make(chan int, 1024), @@ -170,7 +168,7 @@ func NewIndexBuildTaskQueue(sched *TaskScheduler) *IndexTaskQueue { type TaskScheduler struct { TaskQueue TaskQueue - buildParallel int + BuildParallel int wg sync.WaitGroup ctx context.Context cancel context.CancelFunc @@ -182,16 +180,16 @@ func NewTaskScheduler(ctx context.Context) *TaskScheduler { s := &TaskScheduler{ ctx: ctx1, cancel: cancel, - buildParallel: Params.IndexNodeCfg.BuildParallel.GetAsInt(), + BuildParallel: paramtable.Get().DataNodeCfg.BuildParallel.GetAsInt(), } s.TaskQueue = NewIndexBuildTaskQueue(s) return s } -func (sched *TaskScheduler) scheduleIndexBuildTask() []task { - ret := make([]task, 0) - for i := 0; i < sched.buildParallel; i++ { +func (sched *TaskScheduler) scheduleIndexBuildTask() []Task { + ret := make([]Task, 0) + for i := 0; i < sched.BuildParallel; i++ { t := sched.TaskQueue.PopUnissuedTask() if t == nil { return ret @@ -213,7 +211,7 @@ func getStateFromError(err error) indexpb.JobState { return indexpb.JobState_JobStateRetry } -func (sched *TaskScheduler) processTask(t task, q TaskQueue) { +func (sched *TaskScheduler) processTask(t Task, q TaskQueue) { wrap := func(fn func(ctx context.Context) error) error { select { case <-t.Ctx().Done(): @@ -239,14 +237,10 @@ func (sched *TaskScheduler) processTask(t task, q TaskQueue) { } } t.SetState(indexpb.JobState_JobStateFinished, "") - if indexBuildTask, ok := t.(*indexBuildTask); ok { - metrics.IndexNodeBuildIndexLatency.WithLabelValues(fmt.Sprint(paramtable.GetNodeID())).Observe(indexBuildTask.tr.ElapseSpan().Seconds()) - metrics.IndexNodeIndexTaskLatencyInQueue.WithLabelValues(fmt.Sprint(paramtable.GetNodeID())).Observe(float64(indexBuildTask.queueDur.Milliseconds())) - } } func (sched *TaskScheduler) indexBuildLoop() { - log.Ctx(sched.ctx).Debug("IndexNode TaskScheduler start build loop ...") + log.Ctx(sched.ctx).Debug("TaskScheduler start build loop ...") defer sched.wg.Done() for { select { @@ -257,7 +251,7 @@ func (sched *TaskScheduler) indexBuildLoop() { var wg sync.WaitGroup for _, t := range tasks { wg.Add(1) - go func(group *sync.WaitGroup, t task) { + go func(group *sync.WaitGroup, t Task) { defer group.Done() sched.processTask(t, sched.TaskQueue) }(&wg, t) diff --git a/internal/indexnode/task_scheduler_test.go b/internal/datanode/index/scheduler_test.go similarity index 83% rename from internal/indexnode/task_scheduler_test.go rename to internal/datanode/index/scheduler_test.go index c68044f815..3baae6faaf 100644 --- a/internal/indexnode/task_scheduler_test.go +++ b/internal/datanode/index/scheduler_test.go @@ -1,4 +1,20 @@ -package indexnode +// 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. + +package index import ( "context" @@ -77,7 +93,7 @@ type fakeTask struct { failReason string } -var _ task = &fakeTask{} +var _ Task = &fakeTask{} func (t *fakeTask) Name() string { return fmt.Sprintf("fake-task-%d", t.id) @@ -136,7 +152,7 @@ var ( id = 0 ) -func newTask(cancelStage fakeTaskState, reterror map[fakeTaskState]error, expectedState indexpb.JobState) task { +func newTask(cancelStage fakeTaskState, reterror map[fakeTaskState]error, expectedState indexpb.JobState) Task { idLock.Lock() newID := id id++ @@ -162,7 +178,7 @@ func TestIndexTaskScheduler(t *testing.T) { scheduler := NewTaskScheduler(context.TODO()) scheduler.Start() - tasks := make([]task, 0) + tasks := make([]Task, 0) tasks = append(tasks, newTask(fakeTaskEnqueued, nil, indexpb.JobState_JobStateRetry), @@ -187,7 +203,7 @@ func TestIndexTaskScheduler(t *testing.T) { assert.Equal(t, tasks[len(tasks)-1].Ctx().(*stagectx).curstate, fakeTaskState(fakeTaskSavedIndexes)) scheduler = NewTaskScheduler(context.TODO()) - tasks = make([]task, 0, 1024) + tasks = make([]Task, 0, 1024) for i := 0; i < 1024; i++ { tasks = append(tasks, newTask(fakeTaskSavedIndexes, nil, indexpb.JobState_JobStateFinished)) assert.Nil(t, scheduler.TaskQueue.Enqueue(tasks[len(tasks)-1])) diff --git a/internal/indexnode/task_state.go b/internal/datanode/index/state.go similarity index 98% rename from internal/indexnode/task_state.go rename to internal/datanode/index/state.go index 6613ff8c3d..3dd373b3c8 100644 --- a/internal/indexnode/task_state.go +++ b/internal/datanode/index/state.go @@ -14,7 +14,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package indexnode +package index type TaskState int32 diff --git a/internal/indexnode/task_state_test.go b/internal/datanode/index/state_test.go similarity index 98% rename from internal/indexnode/task_state_test.go rename to internal/datanode/index/state_test.go index 8489874afd..595f6bef85 100644 --- a/internal/indexnode/task_state_test.go +++ b/internal/datanode/index/state_test.go @@ -14,7 +14,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package indexnode +package index import ( "testing" diff --git a/internal/indexnode/task.go b/internal/datanode/index/task.go similarity index 87% rename from internal/indexnode/task.go rename to internal/datanode/index/task.go index b1c16fe40b..dc57769583 100644 --- a/internal/indexnode/task.go +++ b/internal/datanode/index/task.go @@ -14,24 +14,27 @@ // See the License for the specific language governing permissions and // limitations under the License. -package indexnode +package index import ( "context" "fmt" - "github.com/milvus-io/milvus/internal/storage" "github.com/milvus-io/milvus/pkg/v2/proto/indexpb" + "github.com/milvus-io/milvus/pkg/v2/util/typeutil" ) var ( errCancel = fmt.Errorf("canceled") - diskUsageRatio = 4.0 + DiskUsageRatio = 4.0 ) -type Blob = storage.Blob +type Key struct { + ClusterID string + TaskID typeutil.UniqueID +} -type task interface { +type Task interface { Ctx() context.Context Name() string OnEnqueue(context.Context) error diff --git a/internal/indexnode/task_analyze.go b/internal/datanode/index/task_analyze.go similarity index 89% rename from internal/indexnode/task_analyze.go rename to internal/datanode/index/task_analyze.go index c6e9af1c80..d15e692b31 100644 --- a/internal/indexnode/task_analyze.go +++ b/internal/datanode/index/task_analyze.go @@ -14,7 +14,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package indexnode +package index import ( "context" @@ -34,7 +34,7 @@ import ( "github.com/milvus-io/milvus/pkg/v2/util/timerecord" ) -var _ task = (*analyzeTask)(nil) +var _ Task = (*analyzeTask)(nil) type analyzeTask struct { ident string @@ -44,22 +44,22 @@ type analyzeTask struct { tr *timerecord.TimeRecorder queueDur time.Duration - node *IndexNode + manager *TaskManager analyze analyzecgowrapper.CodecAnalyze } -func newAnalyzeTask(ctx context.Context, +func NewAnalyzeTask(ctx context.Context, cancel context.CancelFunc, req *workerpb.AnalyzeRequest, - node *IndexNode, + manager *TaskManager, ) *analyzeTask { return &analyzeTask{ - ident: fmt.Sprintf("%s/%d", req.GetClusterID(), req.GetTaskID()), - ctx: ctx, - cancel: cancel, - req: req, - node: node, - tr: timerecord.NewTimeRecorder(fmt.Sprintf("ClusterID: %s, TaskID: %d", req.GetClusterID(), req.GetTaskID())), + ident: fmt.Sprintf("%s/%d", req.GetClusterID(), req.GetTaskID()), + ctx: ctx, + cancel: cancel, + req: req, + manager: manager, + tr: timerecord.NewTimeRecorder(fmt.Sprintf("ClusterID: %s, TaskID: %d", req.GetClusterID(), req.GetTaskID())), } } @@ -169,7 +169,7 @@ func (at *analyzeTask) PostExecute(ctx context.Context) error { zap.Int64("partitionID", at.req.GetPartitionID()), zap.Int64("fieldID", at.req.GetFieldID())) gc := func() { if err := at.analyze.Delete(); err != nil { - log.Error("IndexNode indexBuildTask Execute CIndexDelete failed", zap.Error(err)) + log.Error("indexBuildTask Execute CIndexDelete failed", zap.Error(err)) } } defer gc() @@ -181,7 +181,7 @@ func (at *analyzeTask) PostExecute(ctx context.Context) error { } log.Info("analyze result", zap.String("centroidsFile", centroidsFile)) - at.node.storeAnalyzeFilesAndStatistic(at.req.GetClusterID(), + at.manager.StoreAnalyzeFilesAndStatistic(at.req.GetClusterID(), at.req.GetTaskID(), centroidsFile) at.tr.Elapse("index building all done") @@ -193,17 +193,17 @@ func (at *analyzeTask) OnEnqueue(ctx context.Context) error { at.queueDur = 0 at.tr.RecordSpan() - log.Ctx(ctx).Info("IndexNode analyzeTask enqueued", zap.String("clusterID", at.req.GetClusterID()), + log.Ctx(ctx).Info("analyzeTask enqueued", zap.String("clusterID", at.req.GetClusterID()), zap.Int64("TaskID", at.req.GetTaskID())) return nil } func (at *analyzeTask) SetState(state indexpb.JobState, failReason string) { - at.node.storeAnalyzeTaskState(at.req.GetClusterID(), at.req.GetTaskID(), state, failReason) + at.manager.StoreAnalyzeTaskState(at.req.GetClusterID(), at.req.GetTaskID(), state, failReason) } func (at *analyzeTask) GetState() indexpb.JobState { - return at.node.loadAnalyzeTaskState(at.req.GetClusterID(), at.req.GetTaskID()) + return at.manager.LoadAnalyzeTaskState(at.req.GetClusterID(), at.req.GetTaskID()) } func (at *analyzeTask) Reset() { @@ -213,5 +213,5 @@ func (at *analyzeTask) Reset() { at.req = nil at.tr = nil at.queueDur = 0 - at.node = nil + at.manager = nil } diff --git a/internal/indexnode/task_index.go b/internal/datanode/index/task_index.go similarity index 85% rename from internal/indexnode/task_index.go rename to internal/datanode/index/task_index.go index 57861f19f0..29a44885f8 100644 --- a/internal/indexnode/task_index.go +++ b/internal/datanode/index/task_index.go @@ -14,7 +14,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package indexnode +package index import ( "context" @@ -57,23 +57,23 @@ type indexBuildTask struct { newIndexParams map[string]string tr *timerecord.TimeRecorder queueDur time.Duration - node *IndexNode + manager *TaskManager } -func newIndexBuildTask(ctx context.Context, +func NewIndexBuildTask(ctx context.Context, cancel context.CancelFunc, req *workerpb.CreateJobRequest, cm storage.ChunkManager, - node *IndexNode, + manager *TaskManager, ) *indexBuildTask { t := &indexBuildTask{ - ident: fmt.Sprintf("%s/%d", req.GetClusterID(), req.GetBuildID()), - cancel: cancel, - ctx: ctx, - cm: cm, - req: req, - tr: timerecord.NewTimeRecorder(fmt.Sprintf("IndexBuildID: %d, ClusterID: %s", req.GetBuildID(), req.GetClusterID())), - node: node, + ident: fmt.Sprintf("%s/%d", req.GetClusterID(), req.GetBuildID()), + cancel: cancel, + ctx: ctx, + cm: cm, + req: req, + tr: timerecord.NewTimeRecorder(fmt.Sprintf("IndexBuildID: %d, ClusterID: %s", req.GetBuildID(), req.GetClusterID())), + manager: manager, } t.parseParams() @@ -101,7 +101,7 @@ func (it *indexBuildTask) Reset() { it.newTypeParams = nil it.newIndexParams = nil it.tr = nil - it.node = nil + it.manager = nil } // Ctx is the context of index tasks. @@ -115,18 +115,22 @@ func (it *indexBuildTask) Name() string { } func (it *indexBuildTask) SetState(state indexpb.JobState, failReason string) { - it.node.storeIndexTaskState(it.req.GetClusterID(), it.req.GetBuildID(), commonpb.IndexState(state), failReason) + it.manager.StoreIndexTaskState(it.req.GetClusterID(), it.req.GetBuildID(), commonpb.IndexState(state), failReason) + if state == indexpb.JobState_JobStateFinished { + metrics.DataNodeBuildIndexLatency.WithLabelValues(fmt.Sprint(paramtable.GetNodeID())).Observe(it.tr.ElapseSpan().Seconds()) + metrics.DataNodeIndexTaskLatencyInQueue.WithLabelValues(fmt.Sprint(paramtable.GetNodeID())).Observe(float64(it.queueDur.Milliseconds())) + } } func (it *indexBuildTask) GetState() indexpb.JobState { - return indexpb.JobState(it.node.loadIndexTaskState(it.req.GetClusterID(), it.req.GetBuildID())) + return indexpb.JobState(it.manager.LoadIndexTaskState(it.req.GetClusterID(), it.req.GetBuildID())) } // OnEnqueue enqueues indexing tasks. func (it *indexBuildTask) OnEnqueue(ctx context.Context) error { it.queueDur = 0 it.tr.RecordSpan() - log.Ctx(ctx).Info("IndexNode IndexBuilderTask Enqueue", zap.Int64("buildID", it.req.GetBuildID()), + log.Ctx(ctx).Info("IndexBuilderTask Enqueue", zap.Int64("buildID", it.req.GetBuildID()), zap.Int64("segmentID", it.req.GetSegmentID())) return nil } @@ -217,29 +221,29 @@ func (it *indexBuildTask) Execute(ctx context.Context) error { var fieldDataSize uint64 if vecindexmgr.GetVecIndexMgrInstance().IsDiskANN(indexType) { // check index node support disk index - if !Params.IndexNodeCfg.EnableDisk.GetAsBool() { - log.Warn("IndexNode don't support build disk index", + if !paramtable.Get().DataNodeCfg.EnableDisk.GetAsBool() { + log.Warn("don't support build disk index", zap.String("index type", it.newIndexParams[common.IndexTypeKey]), - zap.Bool("enable disk", Params.IndexNodeCfg.EnableDisk.GetAsBool())) + zap.Bool("enable disk", paramtable.Get().DataNodeCfg.EnableDisk.GetAsBool())) return errors.New("index node don't support build disk index") } // check load size and size of field data localUsedSize, err := indexcgowrapper.GetLocalUsedSize(paramtable.Get().LocalStorageCfg.Path.GetValue()) if err != nil { - log.Warn("IndexNode get local used size failed") + log.Warn("get local used size failed") return err } fieldDataSize, err = estimateFieldDataSize(it.req.GetDim(), it.req.GetNumRows(), it.req.GetField().GetDataType()) if err != nil { - log.Warn("IndexNode get local used size failed") + log.Warn("get local used size failed") return err } - usedLocalSizeWhenBuild := int64(float64(fieldDataSize)*diskUsageRatio) + localUsedSize - maxUsedLocalSize := int64(Params.IndexNodeCfg.DiskCapacityLimit.GetAsFloat() * Params.IndexNodeCfg.MaxDiskUsagePercentage.GetAsFloat()) + usedLocalSizeWhenBuild := int64(float64(fieldDataSize)*DiskUsageRatio) + localUsedSize + maxUsedLocalSize := int64(paramtable.Get().DataNodeCfg.DiskCapacityLimit.GetAsFloat() * paramtable.Get().DataNodeCfg.MaxDiskUsagePercentage.GetAsFloat()) if usedLocalSizeWhenBuild > maxUsedLocalSize { - log.Warn("IndexNode don't has enough disk size to build disk ann index", + log.Warn("don't has enough disk size to build disk ann index", zap.Int64("usedLocalSizeWhenBuild", usedLocalSizeWhenBuild), zap.Int64("maxUsedLocalSize", maxUsedLocalSize)) return errors.New("index node don't has enough disk size to build disk ann index") @@ -253,8 +257,8 @@ func (it *indexBuildTask) Execute(ctx context.Context) error { } // system resource-related parameters, such as memory limits, CPU limits, and disk limits, are appended here to the parameter list - if vecindexmgr.GetVecIndexMgrInstance().IsVecIndex(indexType) && Params.KnowhereConfig.Enable.GetAsBool() { - it.newIndexParams, _ = Params.KnowhereConfig.MergeResourceParams(fieldDataSize, paramtable.BuildStage, it.newIndexParams) + if vecindexmgr.GetVecIndexMgrInstance().IsVecIndex(indexType) && paramtable.Get().KnowhereConfig.Enable.GetAsBool() { + it.newIndexParams, _ = paramtable.Get().KnowhereConfig.MergeResourceParams(fieldDataSize, paramtable.BuildStage, it.newIndexParams) } storageConfig := &indexcgopb.StorageConfig{ @@ -321,7 +325,7 @@ func (it *indexBuildTask) Execute(ctx context.Context) error { } buildIndexLatency := it.tr.RecordSpan() - metrics.IndexNodeKnowhereBuildIndexLatency.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10)).Observe(buildIndexLatency.Seconds()) + metrics.DataNodeKnowhereBuildIndexLatency.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10)).Observe(buildIndexLatency.Seconds()) log.Info("Successfully build index") return nil @@ -334,7 +338,7 @@ func (it *indexBuildTask) PostExecute(ctx context.Context) error { gcIndex := func() { if err := it.index.Delete(); err != nil { - log.Warn("IndexNode indexBuildTask Execute CIndexDelete failed", zap.Error(err)) + log.Warn("indexBuildTask Execute CIndexDelete failed", zap.Error(err)) } } indexStats, err := it.index.UpLoad() @@ -344,7 +348,7 @@ func (it *indexBuildTask) PostExecute(ctx context.Context) error { return err } encodeIndexFileDur := it.tr.Record("index serialize and upload done") - metrics.IndexNodeEncodeIndexFileLatency.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10)).Observe(encodeIndexFileDur.Seconds()) + metrics.DataNodeEncodeIndexFileLatency.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10)).Observe(encodeIndexFileDur.Seconds()) // early release index for gc, and we can ensure that Delete is idempotent. gcIndex() @@ -359,7 +363,7 @@ func (it *indexBuildTask) PostExecute(ctx context.Context) error { saveFileKeys = append(saveFileKeys, fileKey) } - it.node.storeIndexFilesAndStatistic( + it.manager.StoreIndexFilesAndStatistic( it.req.GetClusterID(), it.req.GetBuildID(), saveFileKeys, @@ -369,7 +373,7 @@ func (it *indexBuildTask) PostExecute(ctx context.Context) error { it.req.GetCurrentScalarIndexVersion(), ) saveIndexFileDur := it.tr.RecordSpan() - metrics.IndexNodeSaveIndexFileLatency.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10)).Observe(saveIndexFileDur.Seconds()) + metrics.DataNodeSaveIndexFileLatency.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10)).Observe(saveIndexFileDur.Seconds()) it.tr.Elapse("index building all done") log.Info("Successfully save index files", zap.Uint64("serializedSize", serializedSize), @@ -390,7 +394,7 @@ func (it *indexBuildTask) parseFieldMetaFromBinlog(ctx context.Context) error { } var insertCodec storage.InsertCodec - collectionID, partitionID, segmentID, insertData, err := insertCodec.DeserializeAll([]*Blob{{Key: toLoadDataPaths[0], Value: data}}) + collectionID, partitionID, segmentID, insertData, err := insertCodec.DeserializeAll([]*storage.Blob{{Key: toLoadDataPaths[0], Value: data}}) if err != nil { return err } diff --git a/internal/datanode/index/task_manager.go b/internal/datanode/index/task_manager.go new file mode 100644 index 0000000000..c22dce4ccf --- /dev/null +++ b/internal/datanode/index/task_manager.go @@ -0,0 +1,483 @@ +// 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. + +package index + +import "C" +import ( + "context" + "sync" + "time" + + "go.uber.org/zap" + + "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" + "github.com/milvus-io/milvus/pkg/v2/common" + "github.com/milvus-io/milvus/pkg/v2/log" + "github.com/milvus-io/milvus/pkg/v2/proto/datapb" + "github.com/milvus-io/milvus/pkg/v2/proto/indexpb" + "github.com/milvus-io/milvus/pkg/v2/util/paramtable" + "github.com/milvus-io/milvus/pkg/v2/util/typeutil" +) + +type IndexTaskInfo struct { + Cancel context.CancelFunc + State commonpb.IndexState + FileKeys []string + SerializedSize uint64 + MemSize uint64 + FailReason string + CurrentIndexVersion int32 + IndexStoreVersion int64 + CurrentScalarIndexVersion int32 + + // task statistics + statistic *indexpb.JobInfo +} + +type TaskManager struct { + ctx context.Context + stateLock sync.Mutex + indexTasks map[Key]*IndexTaskInfo + analyzeTasks map[Key]*AnalyzeTaskInfo + statsTasks map[Key]*StatsTaskInfo +} + +func NewTaskManager(ctx context.Context) *TaskManager { + return &TaskManager{ + ctx: ctx, + indexTasks: make(map[Key]*IndexTaskInfo), + analyzeTasks: make(map[Key]*AnalyzeTaskInfo), + statsTasks: make(map[Key]*StatsTaskInfo), + } +} + +func (m *TaskManager) LoadOrStoreIndexTask(ClusterID string, buildID typeutil.UniqueID, info *IndexTaskInfo) *IndexTaskInfo { + m.stateLock.Lock() + defer m.stateLock.Unlock() + key := Key{ClusterID: ClusterID, TaskID: buildID} + oldInfo, ok := m.indexTasks[key] + if ok { + return oldInfo + } + m.indexTasks[key] = info + return nil +} + +func (m *TaskManager) LoadIndexTaskState(ClusterID string, buildID typeutil.UniqueID) commonpb.IndexState { + key := Key{ClusterID: ClusterID, TaskID: buildID} + m.stateLock.Lock() + defer m.stateLock.Unlock() + task, ok := m.indexTasks[key] + if !ok { + return commonpb.IndexState_IndexStateNone + } + return task.State +} + +func (m *TaskManager) StoreIndexTaskState(ClusterID string, buildID typeutil.UniqueID, state commonpb.IndexState, failReason string) { + key := Key{ClusterID: ClusterID, TaskID: buildID} + m.stateLock.Lock() + defer m.stateLock.Unlock() + if task, ok := m.indexTasks[key]; ok { + log.Ctx(m.ctx).Debug("store task state", zap.String("clusterID", ClusterID), zap.Int64("buildID", buildID), + zap.String("state", state.String()), zap.String("fail reason", failReason)) + task.State = state + task.FailReason = failReason + } +} + +func (m *TaskManager) ForeachIndexTaskInfo(fn func(ClusterID string, buildID typeutil.UniqueID, info *IndexTaskInfo)) { + m.stateLock.Lock() + defer m.stateLock.Unlock() + for key, info := range m.indexTasks { + fn(key.ClusterID, key.TaskID, info) + } +} + +func (m *TaskManager) StoreIndexFilesAndStatistic( + ClusterID string, + buildID typeutil.UniqueID, + fileKeys []string, + serializedSize uint64, + memSize uint64, + currentIndexVersion int32, + currentScalarIndexVersion int32, +) { + key := Key{ClusterID: ClusterID, TaskID: buildID} + m.stateLock.Lock() + defer m.stateLock.Unlock() + if info, ok := m.indexTasks[key]; ok { + info.FileKeys = common.CloneStringList(fileKeys) + info.SerializedSize = serializedSize + info.MemSize = memSize + info.CurrentIndexVersion = currentIndexVersion + info.CurrentScalarIndexVersion = currentScalarIndexVersion + return + } +} + +func (m *TaskManager) DeleteIndexTaskInfos(ctx context.Context, keys []Key) []*IndexTaskInfo { + m.stateLock.Lock() + defer m.stateLock.Unlock() + deleted := make([]*IndexTaskInfo, 0, len(keys)) + for _, key := range keys { + info, ok := m.indexTasks[key] + if ok { + deleted = append(deleted, info) + delete(m.indexTasks, key) + log.Ctx(ctx).Info("delete task infos", + zap.String("cluster_id", key.ClusterID), zap.Int64("build_id", key.TaskID)) + } + } + return deleted +} + +func (m *TaskManager) deleteAllIndexTasks() []*IndexTaskInfo { + m.stateLock.Lock() + deletedTasks := m.indexTasks + m.indexTasks = make(map[Key]*IndexTaskInfo) + m.stateLock.Unlock() + + deleted := make([]*IndexTaskInfo, 0, len(deletedTasks)) + for _, info := range deletedTasks { + deleted = append(deleted, info) + } + return deleted +} + +type AnalyzeTaskInfo struct { + Cancel context.CancelFunc + State indexpb.JobState + FailReason string + CentroidsFile string +} + +func (m *TaskManager) LoadOrStoreAnalyzeTask(clusterID string, taskID typeutil.UniqueID, info *AnalyzeTaskInfo) *AnalyzeTaskInfo { + m.stateLock.Lock() + defer m.stateLock.Unlock() + key := Key{ClusterID: clusterID, TaskID: taskID} + oldInfo, ok := m.analyzeTasks[key] + if ok { + return oldInfo + } + m.analyzeTasks[key] = info + return nil +} + +func (m *TaskManager) LoadAnalyzeTaskState(clusterID string, taskID typeutil.UniqueID) indexpb.JobState { + key := Key{ClusterID: clusterID, TaskID: taskID} + m.stateLock.Lock() + defer m.stateLock.Unlock() + task, ok := m.analyzeTasks[key] + if !ok { + return indexpb.JobState_JobStateNone + } + return task.State +} + +func (m *TaskManager) StoreAnalyzeTaskState(clusterID string, taskID typeutil.UniqueID, state indexpb.JobState, failReason string) { + key := Key{ClusterID: clusterID, TaskID: taskID} + m.stateLock.Lock() + defer m.stateLock.Unlock() + if task, ok := m.analyzeTasks[key]; ok { + log.Info("store analyze task state", zap.String("clusterID", clusterID), zap.Int64("TaskID", taskID), + zap.String("state", state.String()), zap.String("fail reason", failReason)) + task.State = state + task.FailReason = failReason + } +} + +func (m *TaskManager) StoreAnalyzeFilesAndStatistic( + ClusterID string, + taskID typeutil.UniqueID, + centroidsFile string, +) { + key := Key{ClusterID: ClusterID, TaskID: taskID} + m.stateLock.Lock() + defer m.stateLock.Unlock() + if info, ok := m.analyzeTasks[key]; ok { + info.CentroidsFile = centroidsFile + return + } +} + +func (m *TaskManager) GetAnalyzeTaskInfo(clusterID string, taskID typeutil.UniqueID) *AnalyzeTaskInfo { + m.stateLock.Lock() + defer m.stateLock.Unlock() + + if info, ok := m.analyzeTasks[Key{ClusterID: clusterID, TaskID: taskID}]; ok { + return &AnalyzeTaskInfo{ + Cancel: info.Cancel, + State: info.State, + FailReason: info.FailReason, + CentroidsFile: info.CentroidsFile, + } + } + return nil +} + +func (m *TaskManager) DeleteAnalyzeTaskInfos(ctx context.Context, keys []Key) []*AnalyzeTaskInfo { + m.stateLock.Lock() + defer m.stateLock.Unlock() + deleted := make([]*AnalyzeTaskInfo, 0, len(keys)) + for _, key := range keys { + info, ok := m.analyzeTasks[key] + if ok { + deleted = append(deleted, info) + delete(m.analyzeTasks, key) + log.Ctx(ctx).Info("delete analyze task infos", + zap.String("clusterID", key.ClusterID), zap.Int64("TaskID", key.TaskID)) + } + } + return deleted +} + +func (m *TaskManager) deleteAllAnalyzeTasks() []*AnalyzeTaskInfo { + m.stateLock.Lock() + deletedTasks := m.analyzeTasks + m.analyzeTasks = make(map[Key]*AnalyzeTaskInfo) + m.stateLock.Unlock() + + deleted := make([]*AnalyzeTaskInfo, 0, len(deletedTasks)) + for _, info := range deletedTasks { + deleted = append(deleted, info) + } + return deleted +} + +func (m *TaskManager) HasInProgressTask() bool { + m.stateLock.Lock() + defer m.stateLock.Unlock() + for _, info := range m.indexTasks { + if info.State == commonpb.IndexState_InProgress { + return true + } + } + + for _, info := range m.analyzeTasks { + if info.State == indexpb.JobState_JobStateInProgress { + return true + } + } + return false +} + +func (m *TaskManager) WaitTaskFinish() { + if !m.HasInProgressTask() { + return + } + + gracefulTimeout := ¶mtable.Get().DataNodeCfg.GracefulStopTimeout + ticker := time.NewTicker(time.Second) + defer ticker.Stop() + + timeoutCtx, cancel := context.WithTimeout(m.ctx, gracefulTimeout.GetAsDuration(time.Second)) + defer cancel() + for { + select { + case <-ticker.C: + if !m.HasInProgressTask() { + return + } + case <-timeoutCtx.Done(): + log.Warn("timeout, the index node has some progress task") + for _, info := range m.indexTasks { + if info.State == commonpb.IndexState_InProgress { + log.Warn("progress task", zap.Any("info", info)) + } + } + for _, info := range m.analyzeTasks { + if info.State == indexpb.JobState_JobStateInProgress { + log.Warn("progress task", zap.Any("info", info)) + } + } + return + } + } +} + +type StatsTaskInfo struct { + Cancel context.CancelFunc + State indexpb.JobState + FailReason string + CollID typeutil.UniqueID + PartID typeutil.UniqueID + SegID typeutil.UniqueID + InsertChannel string + NumRows int64 + InsertLogs []*datapb.FieldBinlog + StatsLogs []*datapb.FieldBinlog + TextStatsLogs map[int64]*datapb.TextIndexStats + Bm25Logs []*datapb.FieldBinlog +} + +func (m *TaskManager) LoadOrStoreStatsTask(clusterID string, taskID typeutil.UniqueID, info *StatsTaskInfo) *StatsTaskInfo { + m.stateLock.Lock() + defer m.stateLock.Unlock() + key := Key{ClusterID: clusterID, TaskID: taskID} + oldInfo, ok := m.statsTasks[key] + if ok { + return oldInfo + } + m.statsTasks[key] = info + return nil +} + +func (m *TaskManager) GetStatsTaskState(clusterID string, taskID typeutil.UniqueID) indexpb.JobState { + key := Key{ClusterID: clusterID, TaskID: taskID} + m.stateLock.Lock() + defer m.stateLock.Unlock() + task, ok := m.statsTasks[key] + if !ok { + return indexpb.JobState_JobStateNone + } + return task.State +} + +func (m *TaskManager) StoreStatsTaskState(clusterID string, taskID typeutil.UniqueID, state indexpb.JobState, failReason string) { + key := Key{ClusterID: clusterID, TaskID: taskID} + m.stateLock.Lock() + defer m.stateLock.Unlock() + if task, ok := m.statsTasks[key]; ok { + log.Info("store stats task state", zap.String("clusterID", clusterID), zap.Int64("TaskID", taskID), + zap.String("state", state.String()), zap.String("fail reason", failReason)) + task.State = state + task.FailReason = failReason + } +} + +func (m *TaskManager) StorePKSortStatsResult( + ClusterID string, + taskID typeutil.UniqueID, + collID typeutil.UniqueID, + partID typeutil.UniqueID, + segID typeutil.UniqueID, + channel string, + numRows int64, + insertLogs []*datapb.FieldBinlog, + statsLogs []*datapb.FieldBinlog, + bm25Logs []*datapb.FieldBinlog, +) { + key := Key{ClusterID: ClusterID, TaskID: taskID} + m.stateLock.Lock() + defer m.stateLock.Unlock() + if info, ok := m.statsTasks[key]; ok { + info.CollID = collID + info.PartID = partID + info.SegID = segID + info.InsertChannel = channel + info.NumRows = numRows + info.InsertLogs = insertLogs + info.StatsLogs = statsLogs + info.Bm25Logs = bm25Logs + return + } +} + +func (m *TaskManager) StoreStatsTextIndexResult( + ClusterID string, + taskID typeutil.UniqueID, + collID typeutil.UniqueID, + partID typeutil.UniqueID, + segID typeutil.UniqueID, + channel string, + texIndexLogs map[int64]*datapb.TextIndexStats, +) { + key := Key{ClusterID: ClusterID, TaskID: taskID} + m.stateLock.Lock() + defer m.stateLock.Unlock() + if info, ok := m.statsTasks[key]; ok { + info.TextStatsLogs = texIndexLogs + info.SegID = segID + info.CollID = collID + info.PartID = partID + info.InsertChannel = channel + } +} + +func (m *TaskManager) GetStatsTaskInfo(clusterID string, taskID typeutil.UniqueID) *StatsTaskInfo { + m.stateLock.Lock() + defer m.stateLock.Unlock() + + if info, ok := m.statsTasks[Key{ClusterID: clusterID, TaskID: taskID}]; ok { + return &StatsTaskInfo{ + Cancel: info.Cancel, + State: info.State, + FailReason: info.FailReason, + CollID: info.CollID, + PartID: info.PartID, + SegID: info.SegID, + InsertChannel: info.InsertChannel, + NumRows: info.NumRows, + InsertLogs: info.InsertLogs, + StatsLogs: info.StatsLogs, + TextStatsLogs: info.TextStatsLogs, + Bm25Logs: info.Bm25Logs, + } + } + return nil +} + +func (m *TaskManager) DeleteStatsTaskInfos(ctx context.Context, keys []Key) []*StatsTaskInfo { + m.stateLock.Lock() + defer m.stateLock.Unlock() + deleted := make([]*StatsTaskInfo, 0, len(keys)) + for _, key := range keys { + info, ok := m.statsTasks[key] + if ok { + deleted = append(deleted, info) + delete(m.statsTasks, key) + log.Ctx(ctx).Info("delete stats task infos", + zap.String("clusterID", key.ClusterID), zap.Int64("TaskID", key.TaskID)) + } + } + return deleted +} + +func (m *TaskManager) deleteAllStatsTasks() []*StatsTaskInfo { + m.stateLock.Lock() + deletedTasks := m.statsTasks + m.statsTasks = make(map[Key]*StatsTaskInfo) + m.stateLock.Unlock() + + deleted := make([]*StatsTaskInfo, 0, len(deletedTasks)) + for _, info := range deletedTasks { + deleted = append(deleted, info) + } + return deleted +} + +func (m *TaskManager) DeleteAllTasks() { + deletedIndexTasks := m.deleteAllIndexTasks() + for _, t := range deletedIndexTasks { + if t.Cancel != nil { + t.Cancel() + } + } + deletedAnalyzeTasks := m.deleteAllAnalyzeTasks() + for _, t := range deletedAnalyzeTasks { + if t.Cancel != nil { + t.Cancel() + } + } + deletedStatsTasks := m.deleteAllStatsTasks() + for _, t := range deletedStatsTasks { + if t.Cancel != nil { + t.Cancel() + } + } +} diff --git a/internal/indexnode/taskinfo_ops_test.go b/internal/datanode/index/task_manager_test.go similarity index 57% rename from internal/indexnode/taskinfo_ops_test.go rename to internal/datanode/index/task_manager_test.go index 9c4f167e4e..ac91e4ec46 100644 --- a/internal/indexnode/taskinfo_ops_test.go +++ b/internal/datanode/index/task_manager_test.go @@ -14,7 +14,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package indexnode +package index import ( "context" @@ -29,8 +29,8 @@ import ( type statsTaskInfoSuite struct { suite.Suite - ctx context.Context - node *IndexNode + ctx context.Context + manager *TaskManager cluster string taskID int64 @@ -41,10 +41,7 @@ func Test_statsTaskInfoSuite(t *testing.T) { } func (s *statsTaskInfoSuite) SetupSuite() { - s.node = &IndexNode{ - loopCtx: context.Background(), - statsTasks: make(map[taskKey]*statsTaskInfo), - } + s.manager = NewTaskManager(context.Background()) s.cluster = "test" s.taskID = 100 @@ -52,31 +49,31 @@ func (s *statsTaskInfoSuite) SetupSuite() { func (s *statsTaskInfoSuite) Test_Methods() { s.Run("loadOrStoreStatsTask", func() { - _, cancel := context.WithCancel(s.node.loopCtx) - info := &statsTaskInfo{ - cancel: cancel, - state: indexpb.JobState_JobStateInProgress, + _, cancel := context.WithCancel(s.manager.ctx) + info := &StatsTaskInfo{ + Cancel: cancel, + State: indexpb.JobState_JobStateInProgress, } - reInfo := s.node.loadOrStoreStatsTask(s.cluster, s.taskID, info) + reInfo := s.manager.LoadOrStoreStatsTask(s.cluster, s.taskID, info) s.Nil(reInfo) - reInfo = s.node.loadOrStoreStatsTask(s.cluster, s.taskID, info) - s.Equal(indexpb.JobState_JobStateInProgress, reInfo.state) + reInfo = s.manager.LoadOrStoreStatsTask(s.cluster, s.taskID, info) + s.Equal(indexpb.JobState_JobStateInProgress, reInfo.State) }) s.Run("getStatsTaskState", func() { - s.Equal(indexpb.JobState_JobStateInProgress, s.node.getStatsTaskState(s.cluster, s.taskID)) - s.Equal(indexpb.JobState_JobStateNone, s.node.getStatsTaskState(s.cluster, s.taskID+1)) + s.Equal(indexpb.JobState_JobStateInProgress, s.manager.GetStatsTaskState(s.cluster, s.taskID)) + s.Equal(indexpb.JobState_JobStateNone, s.manager.GetStatsTaskState(s.cluster, s.taskID+1)) }) s.Run("storeStatsTaskState", func() { - s.node.storeStatsTaskState(s.cluster, s.taskID, indexpb.JobState_JobStateFinished, "finished") - s.Equal(indexpb.JobState_JobStateFinished, s.node.getStatsTaskState(s.cluster, s.taskID)) + s.manager.StoreStatsTaskState(s.cluster, s.taskID, indexpb.JobState_JobStateFinished, "finished") + s.Equal(indexpb.JobState_JobStateFinished, s.manager.GetStatsTaskState(s.cluster, s.taskID)) }) s.Run("storeStatsResult", func() { - s.node.storePKSortStatsResult(s.cluster, s.taskID, 1, 2, 3, "ch1", 65535, + s.manager.StorePKSortStatsResult(s.cluster, s.taskID, 1, 2, 3, "ch1", 65535, []*datapb.FieldBinlog{{FieldID: 100, Binlogs: []*datapb.Binlog{{LogID: 1}}}}, []*datapb.FieldBinlog{{FieldID: 100, Binlogs: []*datapb.Binlog{{LogID: 2}}}}, []*datapb.FieldBinlog{}, @@ -84,7 +81,7 @@ func (s *statsTaskInfoSuite) Test_Methods() { }) s.Run("storeStatsTextIndexResult", func() { - s.node.storeStatsTextIndexResult(s.cluster, s.taskID, 1, 2, 3, "ch1", + s.manager.StoreStatsTextIndexResult(s.cluster, s.taskID, 1, 2, 3, "ch1", map[int64]*datapb.TextIndexStats{ 100: { FieldID: 100, @@ -97,19 +94,19 @@ func (s *statsTaskInfoSuite) Test_Methods() { }) s.Run("getStatsTaskInfo", func() { - taskInfo := s.node.getStatsTaskInfo(s.cluster, s.taskID) + taskInfo := s.manager.GetStatsTaskInfo(s.cluster, s.taskID) - s.Equal(indexpb.JobState_JobStateFinished, taskInfo.state) - s.Equal(int64(1), taskInfo.collID) - s.Equal(int64(2), taskInfo.partID) - s.Equal(int64(3), taskInfo.segID) - s.Equal("ch1", taskInfo.insertChannel) - s.Equal(int64(65535), taskInfo.numRows) + s.Equal(indexpb.JobState_JobStateFinished, taskInfo.State) + s.Equal(int64(1), taskInfo.CollID) + s.Equal(int64(2), taskInfo.PartID) + s.Equal(int64(3), taskInfo.SegID) + s.Equal("ch1", taskInfo.InsertChannel) + s.Equal(int64(65535), taskInfo.NumRows) }) s.Run("deleteStatsTaskInfos", func() { - s.node.deleteStatsTaskInfos(s.ctx, []taskKey{{ClusterID: s.cluster, TaskID: s.taskID}}) + s.manager.DeleteStatsTaskInfos(s.ctx, []Key{{ClusterID: s.cluster, TaskID: s.taskID}}) - s.Nil(s.node.getStatsTaskInfo(s.cluster, s.taskID)) + s.Nil(s.manager.GetStatsTaskInfo(s.cluster, s.taskID)) }) } diff --git a/internal/indexnode/task_stats.go b/internal/datanode/index/task_stats.go similarity index 96% rename from internal/indexnode/task_stats.go rename to internal/datanode/index/task_stats.go index c4b25b4abd..7a37752345 100644 --- a/internal/indexnode/task_stats.go +++ b/internal/datanode/index/task_stats.go @@ -14,7 +14,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package indexnode +package index import ( "context" @@ -49,7 +49,7 @@ import ( "github.com/milvus-io/milvus/pkg/v2/util/typeutil" ) -var _ task = (*statsTask)(nil) +var _ Task = (*statsTask)(nil) const statsBatchSize = 100 @@ -61,7 +61,7 @@ type statsTask struct { tr *timerecord.TimeRecorder queueDur time.Duration - node *IndexNode + manager *TaskManager binlogIO io.BinlogIO deltaLogs []string @@ -69,10 +69,10 @@ type statsTask struct { currentTime time.Time } -func newStatsTask(ctx context.Context, +func NewStatsTask(ctx context.Context, cancel context.CancelFunc, req *workerpb.CreateStatsRequest, - node *IndexNode, + manager *TaskManager, binlogIO io.BinlogIO, ) *statsTask { return &statsTask{ @@ -80,7 +80,7 @@ func newStatsTask(ctx context.Context, ctx: ctx, cancel: cancel, req: req, - node: node, + manager: manager, binlogIO: binlogIO, tr: timerecord.NewTimeRecorder(fmt.Sprintf("ClusterID: %s, TaskID: %d", req.GetClusterID(), req.GetTaskID())), currentTime: tsoutil.PhysicalTime(req.GetCurrentTs()), @@ -106,11 +106,11 @@ func (st *statsTask) OnEnqueue(ctx context.Context) error { } func (st *statsTask) SetState(state indexpb.JobState, failReason string) { - st.node.storeStatsTaskState(st.req.GetClusterID(), st.req.GetTaskID(), state, failReason) + st.manager.StoreStatsTaskState(st.req.GetClusterID(), st.req.GetTaskID(), state, failReason) } func (st *statsTask) GetState() indexpb.JobState { - return st.node.getStatsTaskState(st.req.GetClusterID(), st.req.GetTaskID()) + return st.manager.GetStatsTaskState(st.req.GetClusterID(), st.req.GetTaskID()) } func (st *statsTask) PreExecute(ctx context.Context) error { @@ -249,7 +249,7 @@ func (st *statsTask) sort(ctx context.Context) ([]*datapb.FieldBinlog, error) { return nil, err } - st.node.storePKSortStatsResult(st.req.GetClusterID(), + st.manager.StorePKSortStatsResult(st.req.GetClusterID(), st.req.GetTaskID(), st.req.GetCollectionID(), st.req.GetPartitionID(), @@ -317,7 +317,7 @@ func (st *statsTask) Reset() { st.req = nil st.cancel = nil st.tr = nil - st.node = nil + st.manager = nil } func (st *statsTask) isExpiredEntity(ts typeutil.Timestamp) bool { @@ -472,7 +472,7 @@ func (st *statsTask) createTextIndex(ctx context.Context, ) } - st.node.storeStatsTextIndexResult(st.req.GetClusterID(), + st.manager.StoreStatsTextIndexResult(st.req.GetClusterID(), st.req.GetTaskID(), st.req.GetCollectionID(), st.req.GetPartitionID(), diff --git a/internal/indexnode/task_stats_test.go b/internal/datanode/index/task_stats_test.go similarity index 90% rename from internal/indexnode/task_stats_test.go rename to internal/datanode/index/task_stats_test.go index 09794a2115..16ae9c78fa 100644 --- a/internal/indexnode/task_stats_test.go +++ b/internal/datanode/index/task_stats_test.go @@ -14,7 +14,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package indexnode +package index import ( "context" @@ -99,9 +99,10 @@ func (s *TaskStatsSuite) TestSortSegmentWithBM25() { ctx, cancel := context.WithCancel(context.Background()) - testTaskKey := taskKey{ClusterID: s.clusterID, TaskID: 100} - node := &IndexNode{statsTasks: map[taskKey]*statsTaskInfo{testTaskKey: {segID: 1}}} - task := newStatsTask(ctx, cancel, &workerpb.CreateStatsRequest{ + testTaskKey := Key{ClusterID: s.clusterID, TaskID: 100} + manager := NewTaskManager(ctx) + manager.LoadOrStoreStatsTask(s.clusterID, testTaskKey.TaskID, &StatsTaskInfo{SegID: 1}) + task := NewStatsTask(ctx, cancel, &workerpb.CreateStatsRequest{ CollectionID: s.collectionID, PartitionID: s.partitionID, ClusterID: s.clusterID, @@ -116,7 +117,7 @@ func (s *TaskStatsSuite) TestSortSegmentWithBM25() { StorageConfig: &indexpb.StorageConfig{ RootPath: "root_path", }, - }, node, s.mockBinlogIO) + }, manager, s.mockBinlogIO) err = task.PreExecute(ctx) s.Require().NoError(err) binlog, err := task.sort(ctx) @@ -124,11 +125,11 @@ func (s *TaskStatsSuite) TestSortSegmentWithBM25() { s.Equal(5, len(binlog)) // check bm25 log - s.Equal(1, len(node.statsTasks)) - for key, task := range node.statsTasks { + s.Equal(1, len(manager.statsTasks)) + for key, task := range manager.statsTasks { s.Equal(testTaskKey.ClusterID, key.ClusterID) s.Equal(testTaskKey.TaskID, key.TaskID) - s.Equal(1, len(task.bm25Logs)) + s.Equal(1, len(task.Bm25Logs)) } }) @@ -148,9 +149,10 @@ func (s *TaskStatsSuite) TestSortSegmentWithBM25() { ctx, cancel := context.WithCancel(context.Background()) - testTaskKey := taskKey{ClusterID: s.clusterID, TaskID: 100} - node := &IndexNode{statsTasks: map[taskKey]*statsTaskInfo{testTaskKey: {segID: 1}}} - task := newStatsTask(ctx, cancel, &workerpb.CreateStatsRequest{ + testTaskKey := Key{ClusterID: s.clusterID, TaskID: 100} + manager := NewTaskManager(ctx) + manager.LoadOrStoreStatsTask(s.clusterID, testTaskKey.TaskID, &StatsTaskInfo{SegID: 1}) + task := NewStatsTask(ctx, cancel, &workerpb.CreateStatsRequest{ CollectionID: s.collectionID, PartitionID: s.partitionID, ClusterID: s.clusterID, @@ -165,7 +167,7 @@ func (s *TaskStatsSuite) TestSortSegmentWithBM25() { StorageConfig: &indexpb.StorageConfig{ RootPath: "root_path", }, - }, node, s.mockBinlogIO) + }, manager, s.mockBinlogIO) err = task.PreExecute(ctx) s.Require().NoError(err) _, err = task.sort(ctx) diff --git a/internal/indexnode/task_test.go b/internal/datanode/index/task_test.go similarity index 95% rename from internal/indexnode/task_test.go rename to internal/datanode/index/task_test.go index 511696fdb9..360277a4d4 100644 --- a/internal/indexnode/task_test.go +++ b/internal/datanode/index/task_test.go @@ -14,18 +14,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -package indexnode +package index import ( "context" "testing" + "github.com/milvus-io/milvus/internal/util/dependency" + "github.com/stretchr/testify/suite" "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" "github.com/milvus-io/milvus-proto/go-api/v2/schemapb" "github.com/milvus-io/milvus/internal/storage" - "github.com/milvus-io/milvus/internal/util/dependency" "github.com/milvus-io/milvus/pkg/v2/common" "github.com/milvus-io/milvus/pkg/v2/proto/etcdpb" "github.com/milvus-io/milvus/pkg/v2/proto/indexpb" @@ -112,14 +113,14 @@ func (suite *IndexBuildTaskSuite) TestBuildMemoryIndex() { FieldType: schemapb.DataType_FloatVector, } - cm, err := NewChunkMgrFactory().NewChunkManager(ctx, req.GetStorageConfig()) + cm, err := dependency.NewDefaultFactory(true).NewPersistentStorageChunkManager(ctx) suite.NoError(err) blobs, err := suite.serializeData() suite.NoError(err) err = cm.Write(ctx, suite.dataPath, blobs[0].Value) suite.NoError(err) - t := newIndexBuildTask(ctx, cancel, req, cm, NewIndexNode(context.Background(), dependency.NewDefaultFactory(true))) + t := NewIndexBuildTask(ctx, cancel, req, cm, NewTaskManager(context.Background())) err = t.PreExecute(context.Background()) suite.NoError(err) @@ -208,7 +209,7 @@ func (suite *AnalyzeTaskSuite) TestAnalyze() { Dim: 1, } - cm, err := NewChunkMgrFactory().NewChunkManager(ctx, req.GetStorageConfig()) + cm, err := dependency.NewDefaultFactory(true).NewPersistentStorageChunkManager(ctx) suite.NoError(err) blobs, err := suite.serializeData() suite.NoError(err) @@ -225,7 +226,7 @@ func (suite *AnalyzeTaskSuite) TestAnalyze() { req: req, tr: timerecord.NewTimeRecorder("test-indexBuildTask"), queueDur: 0, - node: NewIndexNode(context.Background(), dependency.NewDefaultFactory(true)), + manager: NewTaskManager(context.Background()), } err = t.PreExecute(context.Background()) diff --git a/internal/indexnode/util.go b/internal/datanode/index/util.go similarity index 76% rename from internal/indexnode/util.go rename to internal/datanode/index/util.go index 8aaa929105..eaade5052f 100644 --- a/internal/indexnode/util.go +++ b/internal/datanode/index/util.go @@ -14,15 +14,42 @@ // See the License for the specific language governing permissions and // limitations under the License. -package indexnode +package index +/* +#cgo pkg-config: milvus_core + +#include +#include +#include "common/init_c.h" +#include "segcore/segcore_init_c.h" +#include "indexbuilder/init_c.h" +*/ +import "C" import ( "github.com/cockroachdb/errors" "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" "github.com/milvus-io/milvus-proto/go-api/v2/schemapb" + "github.com/milvus-io/milvus/pkg/v2/common" ) +func getCurrentIndexVersion(v int32) int32 { + cCurrent := int32(C.GetCurrentIndexVersion()) + if cCurrent < v { + return cCurrent + } + return v +} + +func getCurrentScalarIndexVersion(v int32) int32 { + cCurrent := common.CurrentScalarIndexEngineVersion + if cCurrent < v { + return cCurrent + } + return v +} + func estimateFieldDataSize(dim int64, numRows int64, dataType schemapb.DataType) (uint64, error) { switch dataType { case schemapb.DataType_BinaryVector: diff --git a/internal/indexnode/util_test.go b/internal/datanode/index/util_test.go similarity index 98% rename from internal/indexnode/util_test.go rename to internal/datanode/index/util_test.go index 53c59683ad..a0f0123a2b 100644 --- a/internal/indexnode/util_test.go +++ b/internal/datanode/index/util_test.go @@ -14,7 +14,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package indexnode +package index import ( "math/rand" diff --git a/internal/indexnode/indexnode_service.go b/internal/datanode/index_services.go similarity index 53% rename from internal/indexnode/indexnode_service.go rename to internal/datanode/index_services.go index 94abdb23b8..967bbf5627 100644 --- a/internal/indexnode/indexnode_service.go +++ b/internal/datanode/index_services.go @@ -14,21 +14,20 @@ // See the License for the specific language governing permissions and // limitations under the License. -package indexnode +package datanode import ( "context" "fmt" "strconv" - "github.com/tidwall/gjson" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" "go.uber.org/zap" "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" - "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" + "github.com/milvus-io/milvus/internal/datanode/index" "github.com/milvus-io/milvus/internal/flushcommon/io" "github.com/milvus-io/milvus/pkg/v2/common" "github.com/milvus-io/milvus/pkg/v2/log" @@ -36,25 +35,24 @@ import ( "github.com/milvus-io/milvus/pkg/v2/proto/indexpb" "github.com/milvus-io/milvus/pkg/v2/proto/workerpb" "github.com/milvus-io/milvus/pkg/v2/util/merr" - "github.com/milvus-io/milvus/pkg/v2/util/metricsinfo" "github.com/milvus-io/milvus/pkg/v2/util/paramtable" "github.com/milvus-io/milvus/pkg/v2/util/typeutil" ) -func (i *IndexNode) CreateJob(ctx context.Context, req *workerpb.CreateJobRequest) (*commonpb.Status, error) { +func (node *DataNode) CreateJob(ctx context.Context, req *workerpb.CreateJobRequest) (*commonpb.Status, error) { log := log.Ctx(ctx).With( zap.String("clusterID", req.GetClusterID()), zap.Int64("indexBuildID", req.GetBuildID()), ) - if err := i.lifetime.Add(merr.IsHealthy); err != nil { + if err := node.lifetime.Add(merr.IsHealthy); err != nil { log.Warn("index node not ready", zap.Error(err), ) return merr.Status(err), nil } - defer i.lifetime.Done() - log.Info("IndexNode building index ...", + defer node.lifetime.Done() + log.Info("DataNode building index ...", zap.Int64("collectionID", req.GetCollectionID()), zap.Int64("partitionID", req.GetPartitionID()), zap.Int64("segmentID", req.GetSegmentID()), @@ -72,70 +70,70 @@ func (i *IndexNode) CreateJob(ctx context.Context, req *workerpb.CreateJobReques zap.Any("indexstorepath", req.GetIndexStorePath()), zap.Any("dim", req.GetDim()), ) - ctx, sp := otel.Tracer(typeutil.IndexNodeRole).Start(ctx, "IndexNode-CreateIndex", trace.WithAttributes( + ctx, sp := otel.Tracer(typeutil.DataNodeRole).Start(ctx, "DataNode-CreateIndex", trace.WithAttributes( attribute.Int64("indexBuildID", req.GetBuildID()), attribute.String("clusterID", req.GetClusterID()), )) defer sp.End() - metrics.IndexNodeBuildIndexTaskCounter.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), metrics.TotalLabel).Inc() + metrics.DataNodeBuildIndexTaskCounter.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), metrics.TotalLabel).Inc() - taskCtx, taskCancel := context.WithCancel(i.loopCtx) - if oldInfo := i.loadOrStoreIndexTask(req.GetClusterID(), req.GetBuildID(), &indexTaskInfo{ - cancel: taskCancel, - state: commonpb.IndexState_InProgress, + taskCtx, taskCancel := context.WithCancel(node.ctx) + if oldInfo := node.taskManager.LoadOrStoreIndexTask(req.GetClusterID(), req.GetBuildID(), &index.IndexTaskInfo{ + Cancel: taskCancel, + State: commonpb.IndexState_InProgress, }); oldInfo != nil { err := merr.WrapErrIndexDuplicate(req.GetIndexName(), "building index task existed") log.Warn("duplicated index build task", zap.Error(err)) - metrics.IndexNodeBuildIndexTaskCounter.WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), metrics.FailLabel).Inc() + metrics.DataNodeBuildIndexTaskCounter.WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), metrics.FailLabel).Inc() return merr.Status(err), nil } - cm, err := i.storageFactory.NewChunkManager(i.loopCtx, req.GetStorageConfig()) + cm, err := node.storageFactory.NewChunkManager(node.ctx, req.GetStorageConfig()) if err != nil { log.Error("create chunk manager failed", zap.String("bucket", req.GetStorageConfig().GetBucketName()), zap.String("accessKey", req.GetStorageConfig().GetAccessKeyID()), zap.Error(err), ) - i.deleteIndexTaskInfos(ctx, []taskKey{{ClusterID: req.GetClusterID(), TaskID: req.GetBuildID()}}) - metrics.IndexNodeBuildIndexTaskCounter.WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), metrics.FailLabel).Inc() + node.taskManager.DeleteIndexTaskInfos(ctx, []index.Key{{ClusterID: req.GetClusterID(), TaskID: req.GetBuildID()}}) + metrics.DataNodeBuildIndexTaskCounter.WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), metrics.FailLabel).Inc() return merr.Status(err), nil } - task := newIndexBuildTask(taskCtx, taskCancel, req, cm, i) + task := index.NewIndexBuildTask(taskCtx, taskCancel, req, cm, node.taskManager) ret := merr.Success() - if err := i.sched.TaskQueue.Enqueue(task); err != nil { - log.Warn("IndexNode failed to schedule", + if err := node.taskScheduler.TaskQueue.Enqueue(task); err != nil { + log.Warn("DataNode failed to schedule", zap.Error(err)) ret = merr.Status(err) - metrics.IndexNodeBuildIndexTaskCounter.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), metrics.FailLabel).Inc() + metrics.DataNodeBuildIndexTaskCounter.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), metrics.FailLabel).Inc() return ret, nil } - metrics.IndexNodeBuildIndexTaskCounter.WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), metrics.SuccessLabel).Inc() - log.Info("IndexNode successfully scheduled", + metrics.DataNodeBuildIndexTaskCounter.WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), metrics.SuccessLabel).Inc() + log.Info("DataNode successfully scheduled", zap.String("indexName", req.GetIndexName())) return ret, nil } -func (i *IndexNode) QueryJobs(ctx context.Context, req *workerpb.QueryJobsRequest) (*workerpb.QueryJobsResponse, error) { +func (node *DataNode) QueryJobs(ctx context.Context, req *workerpb.QueryJobsRequest) (*workerpb.QueryJobsResponse, error) { log := log.Ctx(ctx).With( zap.String("clusterID", req.GetClusterID()), ).WithRateGroup("in.queryJobs", 1, 60) - if err := i.lifetime.Add(merr.IsHealthyOrStopping); err != nil { + if err := node.lifetime.Add(merr.IsHealthyOrStopping); err != nil { log.Warn("index node not ready", zap.Error(err)) return &workerpb.QueryJobsResponse{ Status: merr.Status(err), }, nil } - defer i.lifetime.Done() - infos := make(map[UniqueID]*indexTaskInfo) - i.foreachIndexTaskInfo(func(ClusterID string, buildID UniqueID, info *indexTaskInfo) { + defer node.lifetime.Done() + infos := make(map[typeutil.UniqueID]*index.IndexTaskInfo) + node.taskManager.ForeachIndexTaskInfo(func(ClusterID string, buildID typeutil.UniqueID, info *index.IndexTaskInfo) { if ClusterID == req.GetClusterID() { - infos[buildID] = &indexTaskInfo{ - state: info.state, - fileKeys: common.CloneStringList(info.fileKeys), - serializedSize: info.serializedSize, - memSize: info.memSize, - failReason: info.failReason, - currentIndexVersion: info.currentIndexVersion, - indexStoreVersion: info.indexStoreVersion, + infos[buildID] = &index.IndexTaskInfo{ + State: info.State, + FileKeys: common.CloneStringList(info.FileKeys), + SerializedSize: info.SerializedSize, + MemSize: info.MemSize, + FailReason: info.FailReason, + CurrentIndexVersion: info.CurrentIndexVersion, + IndexStoreVersion: info.IndexStoreVersion, } } }) @@ -152,41 +150,41 @@ func (i *IndexNode) QueryJobs(ctx context.Context, req *workerpb.QueryJobsReques SerializedSize: 0, }) if info, ok := infos[buildID]; ok { - ret.IndexInfos[i].State = info.state - ret.IndexInfos[i].IndexFileKeys = info.fileKeys - ret.IndexInfos[i].SerializedSize = info.serializedSize - ret.IndexInfos[i].MemSize = info.memSize - ret.IndexInfos[i].FailReason = info.failReason - ret.IndexInfos[i].CurrentIndexVersion = info.currentIndexVersion - ret.IndexInfos[i].IndexStoreVersion = info.indexStoreVersion + ret.IndexInfos[i].State = info.State + ret.IndexInfos[i].IndexFileKeys = info.FileKeys + ret.IndexInfos[i].SerializedSize = info.SerializedSize + ret.IndexInfos[i].MemSize = info.MemSize + ret.IndexInfos[i].FailReason = info.FailReason + ret.IndexInfos[i].CurrentIndexVersion = info.CurrentIndexVersion + ret.IndexInfos[i].IndexStoreVersion = info.IndexStoreVersion log.RatedDebug(5, "querying index build task", zap.Int64("indexBuildID", buildID), - zap.String("state", info.state.String()), - zap.String("reason", info.failReason), + zap.String("state", info.State.String()), + zap.String("reason", info.FailReason), ) } } return ret, nil } -func (i *IndexNode) DropJobs(ctx context.Context, req *workerpb.DropJobsRequest) (*commonpb.Status, error) { +func (node *DataNode) DropJobs(ctx context.Context, req *workerpb.DropJobsRequest) (*commonpb.Status, error) { log.Ctx(ctx).Info("drop index build jobs", zap.String("clusterID", req.ClusterID), zap.Int64s("indexBuildIDs", req.BuildIDs), ) - if err := i.lifetime.Add(merr.IsHealthyOrStopping); err != nil { + if err := node.lifetime.Add(merr.IsHealthyOrStopping); err != nil { log.Ctx(ctx).Warn("index node not ready", zap.Error(err), zap.String("clusterID", req.ClusterID)) return merr.Status(err), nil } - defer i.lifetime.Done() - keys := make([]taskKey, 0, len(req.GetBuildIDs())) + defer node.lifetime.Done() + keys := make([]index.Key, 0, len(req.GetBuildIDs())) for _, buildID := range req.GetBuildIDs() { - keys = append(keys, taskKey{ClusterID: req.GetClusterID(), TaskID: buildID}) + keys = append(keys, index.Key{ClusterID: req.GetClusterID(), TaskID: buildID}) } - infos := i.deleteIndexTaskInfos(ctx, keys) + infos := node.taskManager.DeleteIndexTaskInfos(ctx, keys) for _, info := range infos { - if info.cancel != nil { - info.cancel() + if info.Cancel != nil { + info.Cancel() } } log.Ctx(ctx).Info("drop index build jobs success", zap.String("clusterID", req.GetClusterID()), @@ -195,19 +193,19 @@ func (i *IndexNode) DropJobs(ctx context.Context, req *workerpb.DropJobsRequest) } // GetJobStats should be GetSlots -func (i *IndexNode) GetJobStats(ctx context.Context, req *workerpb.GetJobStatsRequest) (*workerpb.GetJobStatsResponse, error) { - if err := i.lifetime.Add(merr.IsHealthyOrStopping); err != nil { +func (node *DataNode) GetJobStats(ctx context.Context, req *workerpb.GetJobStatsRequest) (*workerpb.GetJobStatsResponse, error) { + if err := node.lifetime.Add(merr.IsHealthyOrStopping); err != nil { log.Ctx(ctx).Warn("index node not ready", zap.Error(err)) return &workerpb.GetJobStatsResponse{ Status: merr.Status(err), }, nil } - defer i.lifetime.Done() - unissued, active := i.sched.TaskQueue.GetTaskNum() + defer node.lifetime.Done() + unissued, active := node.taskScheduler.TaskQueue.GetTaskNum() slots := 0 - if i.sched.buildParallel > unissued+active { - slots = i.sched.buildParallel - unissued - active + if node.taskScheduler.BuildParallel > unissued+active { + slots = node.taskScheduler.BuildParallel - unissued - active } log.Ctx(ctx).Info("Get Index Job Stats", zap.Int("unissued", unissued), @@ -220,80 +218,30 @@ func (i *IndexNode) GetJobStats(ctx context.Context, req *workerpb.GetJobStatsRe InProgressJobNum: int64(active), EnqueueJobNum: int64(unissued), TaskSlots: int64(slots), - EnableDisk: Params.IndexNodeCfg.EnableDisk.GetAsBool(), + EnableDisk: paramtable.Get().DataNodeCfg.EnableDisk.GetAsBool(), }, nil } -// GetMetrics gets the metrics info of IndexNode. -// TODO(dragondriver): cache the Metrics and set a retention to the cache -func (i *IndexNode) GetMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) { - if err := i.lifetime.Add(merr.IsHealthyOrStopping); err != nil { - log.Ctx(ctx).Warn("IndexNode.GetMetrics failed", - zap.Int64("nodeID", paramtable.GetNodeID()), - zap.String("req", req.GetRequest()), - zap.Error(err)) - - return &milvuspb.GetMetricsResponse{ - Status: merr.Status(err), - }, nil - } - defer i.lifetime.Done() - - ret := gjson.Parse(req.GetRequest()) - metricType, err := metricsinfo.ParseMetricRequestType(ret) - if err != nil { - log.Ctx(ctx).Warn("IndexNode.GetMetrics failed to parse metric type", - zap.Int64("nodeID", paramtable.GetNodeID()), - zap.String("req", req.GetRequest()), - zap.Error(err)) - - return &milvuspb.GetMetricsResponse{ - Status: merr.Status(err), - }, nil - } - - if metricType == metricsinfo.SystemInfoMetrics { - metrics, err := getSystemInfoMetrics(ctx, req, i) - - log.Ctx(ctx).RatedDebug(60, "IndexNode.GetMetrics", - zap.Int64("nodeID", paramtable.GetNodeID()), - zap.String("req", req.GetRequest()), - zap.String("metricType", metricType), - zap.Error(err)) - - return metrics, nil - } - - log.Ctx(ctx).RatedWarn(60, "IndexNode.GetMetrics failed, request metric type is not implemented yet", - zap.Int64("nodeID", paramtable.GetNodeID()), - zap.String("req", req.GetRequest()), - zap.String("metricType", metricType)) - - return &milvuspb.GetMetricsResponse{ - Status: merr.Status(merr.WrapErrMetricNotFound(metricType)), - }, nil -} - -func (i *IndexNode) CreateJobV2(ctx context.Context, req *workerpb.CreateJobV2Request) (*commonpb.Status, error) { +func (node *DataNode) CreateJobV2(ctx context.Context, req *workerpb.CreateJobV2Request) (*commonpb.Status, error) { log := log.Ctx(ctx).With( zap.String("clusterID", req.GetClusterID()), zap.Int64("TaskID", req.GetTaskID()), zap.String("jobType", req.GetJobType().String()), ) - if err := i.lifetime.Add(merr.IsHealthy); err != nil { + if err := node.lifetime.Add(merr.IsHealthy); err != nil { log.Warn("index node not ready", zap.Error(err), ) return merr.Status(err), nil } - defer i.lifetime.Done() + defer node.lifetime.Done() - log.Info("IndexNode receive CreateJob request...") + log.Info("DataNode receive CreateJob request...") switch req.GetJobType() { case indexpb.JobType_JobTypeIndexJob: indexRequest := req.GetIndexRequest() - log.Info("IndexNode building index ...", + log.Info("DataNode building index ...", zap.Int64("collectionID", indexRequest.CollectionID), zap.Int64("partitionID", indexRequest.PartitionID), zap.Int64("segmentID", indexRequest.SegmentID), @@ -312,38 +260,38 @@ func (i *IndexNode) CreateJobV2(ctx context.Context, req *workerpb.CreateJobV2Re zap.String("fieldType", indexRequest.GetFieldType().String()), zap.Any("field", indexRequest.GetField()), ) - taskCtx, taskCancel := context.WithCancel(i.loopCtx) - if oldInfo := i.loadOrStoreIndexTask(indexRequest.GetClusterID(), indexRequest.GetBuildID(), &indexTaskInfo{ - cancel: taskCancel, - state: commonpb.IndexState_InProgress, + taskCtx, taskCancel := context.WithCancel(node.ctx) + if oldInfo := node.taskManager.LoadOrStoreIndexTask(indexRequest.GetClusterID(), indexRequest.GetBuildID(), &index.IndexTaskInfo{ + Cancel: taskCancel, + State: commonpb.IndexState_InProgress, }); oldInfo != nil { err := merr.WrapErrTaskDuplicate(req.GetJobType().String(), fmt.Sprintf("building index task existed with %s-%d", req.GetClusterID(), req.GetTaskID())) log.Warn("duplicated index build task", zap.Error(err)) - metrics.IndexNodeBuildIndexTaskCounter.WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), metrics.FailLabel).Inc() + metrics.DataNodeBuildIndexTaskCounter.WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), metrics.FailLabel).Inc() return merr.Status(err), nil } - cm, err := i.storageFactory.NewChunkManager(i.loopCtx, indexRequest.GetStorageConfig()) + cm, err := node.storageFactory.NewChunkManager(node.ctx, indexRequest.GetStorageConfig()) if err != nil { log.Error("create chunk manager failed", zap.String("bucket", indexRequest.GetStorageConfig().GetBucketName()), zap.String("accessKey", indexRequest.GetStorageConfig().GetAccessKeyID()), zap.Error(err), ) - i.deleteIndexTaskInfos(ctx, []taskKey{{ClusterID: indexRequest.GetClusterID(), TaskID: indexRequest.GetBuildID()}}) - metrics.IndexNodeBuildIndexTaskCounter.WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), metrics.FailLabel).Inc() + node.taskManager.DeleteIndexTaskInfos(ctx, []index.Key{{ClusterID: indexRequest.GetClusterID(), TaskID: indexRequest.GetBuildID()}}) + metrics.DataNodeBuildIndexTaskCounter.WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), metrics.FailLabel).Inc() return merr.Status(err), nil } - task := newIndexBuildTask(taskCtx, taskCancel, indexRequest, cm, i) + task := index.NewIndexBuildTask(taskCtx, taskCancel, indexRequest, cm, node.taskManager) ret := merr.Success() - if err := i.sched.TaskQueue.Enqueue(task); err != nil { - log.Warn("IndexNode failed to schedule", + if err := node.taskScheduler.TaskQueue.Enqueue(task); err != nil { + log.Warn("DataNode failed to schedule", zap.Error(err)) ret = merr.Status(err) - metrics.IndexNodeBuildIndexTaskCounter.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), metrics.FailLabel).Inc() + metrics.DataNodeBuildIndexTaskCounter.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), metrics.FailLabel).Inc() return ret, nil } - metrics.IndexNodeBuildIndexTaskCounter.WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), metrics.SuccessLabel).Inc() - log.Info("IndexNode index job enqueued successfully", + metrics.DataNodeBuildIndexTaskCounter.WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), metrics.SuccessLabel).Inc() + log.Info("DataNode index job enqueued successfully", zap.String("indexName", indexRequest.GetIndexName())) return ret, nil case indexpb.JobType_JobTypeAnalyzeJob: @@ -358,24 +306,24 @@ func (i *IndexNode) CreateJobV2(ctx context.Context, req *workerpb.CreateJobV2Re zap.Float64("trainSizeRatio", analyzeRequest.GetMaxTrainSizeRatio()), zap.Int64("numClusters", analyzeRequest.GetNumClusters()), ) - taskCtx, taskCancel := context.WithCancel(i.loopCtx) - if oldInfo := i.loadOrStoreAnalyzeTask(analyzeRequest.GetClusterID(), analyzeRequest.GetTaskID(), &analyzeTaskInfo{ - cancel: taskCancel, - state: indexpb.JobState_JobStateInProgress, + taskCtx, taskCancel := context.WithCancel(node.ctx) + if oldInfo := node.taskManager.LoadOrStoreAnalyzeTask(analyzeRequest.GetClusterID(), analyzeRequest.GetTaskID(), &index.AnalyzeTaskInfo{ + Cancel: taskCancel, + State: indexpb.JobState_JobStateInProgress, }); oldInfo != nil { err := merr.WrapErrTaskDuplicate(req.GetJobType().String(), fmt.Sprintf("analyze task already existed with %s-%d", req.GetClusterID(), req.GetTaskID())) log.Warn("duplicated analyze task", zap.Error(err)) return merr.Status(err), nil } - t := newAnalyzeTask(taskCtx, taskCancel, analyzeRequest, i) + t := index.NewAnalyzeTask(taskCtx, taskCancel, analyzeRequest, node.taskManager) ret := merr.Success() - if err := i.sched.TaskQueue.Enqueue(t); err != nil { - log.Warn("IndexNode failed to schedule", zap.Error(err)) + if err := node.taskScheduler.TaskQueue.Enqueue(t); err != nil { + log.Warn("DataNode failed to schedule", zap.Error(err)) ret = merr.Status(err) return ret, nil } - log.Info("IndexNode analyze job enqueued successfully") + log.Info("DataNode analyze job enqueued successfully") return ret, nil case indexpb.JobType_JobTypeStatsJob: statsRequest := req.GetStatsRequest() @@ -389,69 +337,69 @@ func (i *IndexNode) CreateJobV2(ctx context.Context, req *workerpb.CreateJobV2Re zap.Int64("endLogID", statsRequest.GetEndLogID()), ) - taskCtx, taskCancel := context.WithCancel(i.loopCtx) - if oldInfo := i.loadOrStoreStatsTask(statsRequest.GetClusterID(), statsRequest.GetTaskID(), &statsTaskInfo{ - cancel: taskCancel, - state: indexpb.JobState_JobStateInProgress, + taskCtx, taskCancel := context.WithCancel(node.ctx) + if oldInfo := node.taskManager.LoadOrStoreStatsTask(statsRequest.GetClusterID(), statsRequest.GetTaskID(), &index.StatsTaskInfo{ + Cancel: taskCancel, + State: indexpb.JobState_JobStateInProgress, }); oldInfo != nil { err := merr.WrapErrTaskDuplicate(req.GetJobType().String(), fmt.Sprintf("stats task already existed with %s-%d", req.GetClusterID(), req.GetTaskID())) log.Warn("duplicated stats task", zap.Error(err)) return merr.Status(err), nil } - cm, err := i.storageFactory.NewChunkManager(i.loopCtx, statsRequest.GetStorageConfig()) + cm, err := node.storageFactory.NewChunkManager(node.ctx, statsRequest.GetStorageConfig()) if err != nil { log.Error("create chunk manager failed", zap.String("bucket", statsRequest.GetStorageConfig().GetBucketName()), zap.String("accessKey", statsRequest.GetStorageConfig().GetAccessKeyID()), zap.Error(err), ) - i.deleteStatsTaskInfos(ctx, []taskKey{{ClusterID: req.GetClusterID(), TaskID: req.GetTaskID()}}) + node.taskManager.DeleteStatsTaskInfos(ctx, []index.Key{{ClusterID: req.GetClusterID(), TaskID: req.GetTaskID()}}) return merr.Status(err), nil } - t := newStatsTask(taskCtx, taskCancel, statsRequest, i, io.NewBinlogIO(cm)) + t := index.NewStatsTask(taskCtx, taskCancel, statsRequest, node.taskManager, io.NewBinlogIO(cm)) ret := merr.Success() - if err := i.sched.TaskQueue.Enqueue(t); err != nil { - log.Warn("IndexNode failed to schedule", zap.Error(err)) + if err := node.taskScheduler.TaskQueue.Enqueue(t); err != nil { + log.Warn("DataNode failed to schedule", zap.Error(err)) ret = merr.Status(err) return ret, nil } - log.Info("IndexNode stats job enqueued successfully") + log.Info("DataNode stats job enqueued successfully") return ret, nil default: - log.Warn("IndexNode receive unknown type job") - return merr.Status(fmt.Errorf("IndexNode receive unknown type job with TaskID: %d", req.GetTaskID())), nil + log.Warn("DataNode receive unknown type job") + return merr.Status(fmt.Errorf("DataNode receive unknown type job with TaskID: %d", req.GetTaskID())), nil } } -func (i *IndexNode) QueryJobsV2(ctx context.Context, req *workerpb.QueryJobsV2Request) (*workerpb.QueryJobsV2Response, error) { +func (node *DataNode) QueryJobsV2(ctx context.Context, req *workerpb.QueryJobsV2Request) (*workerpb.QueryJobsV2Response, error) { log := log.Ctx(ctx).With( zap.String("clusterID", req.GetClusterID()), zap.Int64s("taskIDs", req.GetTaskIDs()), ).WithRateGroup("QueryResult", 1, 60) - if err := i.lifetime.Add(merr.IsHealthyOrStopping); err != nil { - log.Warn("IndexNode not ready", zap.Error(err)) + if err := node.lifetime.Add(merr.IsHealthyOrStopping); err != nil { + log.Warn("DataNode not ready", zap.Error(err)) return &workerpb.QueryJobsV2Response{ Status: merr.Status(err), }, nil } - defer i.lifetime.Done() + defer node.lifetime.Done() switch req.GetJobType() { case indexpb.JobType_JobTypeIndexJob: - infos := make(map[UniqueID]*indexTaskInfo) - i.foreachIndexTaskInfo(func(ClusterID string, buildID UniqueID, info *indexTaskInfo) { + infos := make(map[typeutil.UniqueID]*index.IndexTaskInfo) + node.taskManager.ForeachIndexTaskInfo(func(ClusterID string, buildID typeutil.UniqueID, info *index.IndexTaskInfo) { if ClusterID == req.GetClusterID() { - infos[buildID] = &indexTaskInfo{ - state: info.state, - fileKeys: common.CloneStringList(info.fileKeys), - serializedSize: info.serializedSize, - memSize: info.memSize, - failReason: info.failReason, - currentIndexVersion: info.currentIndexVersion, - indexStoreVersion: info.indexStoreVersion, - currentScalarIndexVersion: info.currentScalarIndexVersion, + infos[buildID] = &index.IndexTaskInfo{ + State: info.State, + FileKeys: common.CloneStringList(info.FileKeys), + SerializedSize: info.SerializedSize, + MemSize: info.MemSize, + FailReason: info.FailReason, + CurrentIndexVersion: info.CurrentIndexVersion, + IndexStoreVersion: info.IndexStoreVersion, + CurrentScalarIndexVersion: info.CurrentScalarIndexVersion, } } }) @@ -464,14 +412,14 @@ func (i *IndexNode) QueryJobsV2(ctx context.Context, req *workerpb.QueryJobsV2Re SerializedSize: 0, }) if info, ok := infos[buildID]; ok { - results[i].State = info.state - results[i].IndexFileKeys = info.fileKeys - results[i].SerializedSize = info.serializedSize - results[i].MemSize = info.memSize - results[i].FailReason = info.failReason - results[i].CurrentIndexVersion = info.currentIndexVersion - results[i].IndexStoreVersion = info.indexStoreVersion - results[i].CurrentScalarIndexVersion = info.currentScalarIndexVersion + results[i].State = info.State + results[i].IndexFileKeys = info.FileKeys + results[i].SerializedSize = info.SerializedSize + results[i].MemSize = info.MemSize + results[i].FailReason = info.FailReason + results[i].CurrentIndexVersion = info.CurrentIndexVersion + results[i].IndexStoreVersion = info.IndexStoreVersion + results[i].CurrentScalarIndexVersion = info.CurrentScalarIndexVersion } } log.Debug("query index jobs result success", zap.Any("results", results)) @@ -487,13 +435,13 @@ func (i *IndexNode) QueryJobsV2(ctx context.Context, req *workerpb.QueryJobsV2Re case indexpb.JobType_JobTypeAnalyzeJob: results := make([]*workerpb.AnalyzeResult, 0, len(req.GetTaskIDs())) for _, taskID := range req.GetTaskIDs() { - info := i.getAnalyzeTaskInfo(req.GetClusterID(), taskID) + info := node.taskManager.GetAnalyzeTaskInfo(req.GetClusterID(), taskID) if info != nil { results = append(results, &workerpb.AnalyzeResult{ TaskID: taskID, - State: info.state, - FailReason: info.failReason, - CentroidsFile: info.centroidsFile, + State: info.State, + FailReason: info.FailReason, + CentroidsFile: info.CentroidsFile, }) } } @@ -510,21 +458,21 @@ func (i *IndexNode) QueryJobsV2(ctx context.Context, req *workerpb.QueryJobsV2Re case indexpb.JobType_JobTypeStatsJob: results := make([]*workerpb.StatsResult, 0, len(req.GetTaskIDs())) for _, taskID := range req.GetTaskIDs() { - info := i.getStatsTaskInfo(req.GetClusterID(), taskID) + info := node.taskManager.GetStatsTaskInfo(req.GetClusterID(), taskID) if info != nil { results = append(results, &workerpb.StatsResult{ TaskID: taskID, - State: info.state, - FailReason: info.failReason, - CollectionID: info.collID, - PartitionID: info.partID, - SegmentID: info.segID, - Channel: info.insertChannel, - InsertLogs: info.insertLogs, - StatsLogs: info.statsLogs, - TextStatsLogs: info.textStatsLogs, - Bm25Logs: info.bm25Logs, - NumRows: info.numRows, + State: info.State, + FailReason: info.FailReason, + CollectionID: info.CollID, + PartitionID: info.PartID, + SegmentID: info.SegID, + Channel: info.InsertChannel, + InsertLogs: info.InsertLogs, + StatsLogs: info.StatsLogs, + TextStatsLogs: info.TextStatsLogs, + Bm25Logs: info.Bm25Logs, + NumRows: info.NumRows, }) } } @@ -539,69 +487,69 @@ func (i *IndexNode) QueryJobsV2(ctx context.Context, req *workerpb.QueryJobsV2Re }, }, nil default: - log.Warn("IndexNode receive querying unknown type jobs") + log.Warn("DataNode receive querying unknown type jobs") return &workerpb.QueryJobsV2Response{ - Status: merr.Status(fmt.Errorf("IndexNode receive querying unknown type jobs")), + Status: merr.Status(fmt.Errorf("DataNode receive querying unknown type jobs")), }, nil } } -func (i *IndexNode) DropJobsV2(ctx context.Context, req *workerpb.DropJobsV2Request) (*commonpb.Status, error) { +func (node *DataNode) DropJobsV2(ctx context.Context, req *workerpb.DropJobsV2Request) (*commonpb.Status, error) { log := log.Ctx(ctx).With(zap.String("clusterID", req.GetClusterID()), zap.Int64s("taskIDs", req.GetTaskIDs()), zap.String("jobType", req.GetJobType().String()), ) - if err := i.lifetime.Add(merr.IsHealthyOrStopping); err != nil { - log.Warn("IndexNode not ready", zap.Error(err)) + if err := node.lifetime.Add(merr.IsHealthyOrStopping); err != nil { + log.Warn("DataNode not ready", zap.Error(err)) return merr.Status(err), nil } - defer i.lifetime.Done() + defer node.lifetime.Done() - log.Info("IndexNode receive DropJobs request") + log.Info("DataNode receive DropJobs request") switch req.GetJobType() { case indexpb.JobType_JobTypeIndexJob: - keys := make([]taskKey, 0, len(req.GetTaskIDs())) + keys := make([]index.Key, 0, len(req.GetTaskIDs())) for _, buildID := range req.GetTaskIDs() { - keys = append(keys, taskKey{ClusterID: req.GetClusterID(), TaskID: buildID}) + keys = append(keys, index.Key{ClusterID: req.GetClusterID(), TaskID: buildID}) } - infos := i.deleteIndexTaskInfos(ctx, keys) + infos := node.taskManager.DeleteIndexTaskInfos(ctx, keys) for _, info := range infos { - if info.cancel != nil { - info.cancel() + if info.Cancel != nil { + info.Cancel() } } log.Info("drop index build jobs success") return merr.Success(), nil case indexpb.JobType_JobTypeAnalyzeJob: - keys := make([]taskKey, 0, len(req.GetTaskIDs())) + keys := make([]index.Key, 0, len(req.GetTaskIDs())) for _, taskID := range req.GetTaskIDs() { - keys = append(keys, taskKey{ClusterID: req.GetClusterID(), TaskID: taskID}) + keys = append(keys, index.Key{ClusterID: req.GetClusterID(), TaskID: taskID}) } - infos := i.deleteAnalyzeTaskInfos(ctx, keys) + infos := node.taskManager.DeleteAnalyzeTaskInfos(ctx, keys) for _, info := range infos { - if info.cancel != nil { - info.cancel() + if info.Cancel != nil { + info.Cancel() } } log.Info("drop analyze jobs success") return merr.Success(), nil case indexpb.JobType_JobTypeStatsJob: - keys := make([]taskKey, 0, len(req.GetTaskIDs())) + keys := make([]index.Key, 0, len(req.GetTaskIDs())) for _, taskID := range req.GetTaskIDs() { - keys = append(keys, taskKey{ClusterID: req.GetClusterID(), TaskID: taskID}) + keys = append(keys, index.Key{ClusterID: req.GetClusterID(), TaskID: taskID}) } - infos := i.deleteStatsTaskInfos(ctx, keys) + infos := node.taskManager.DeleteStatsTaskInfos(ctx, keys) for _, info := range infos { - if info.cancel != nil { - info.cancel() + if info.Cancel != nil { + info.Cancel() } } log.Info("drop stats jobs success") return merr.Success(), nil default: - log.Warn("IndexNode receive dropping unknown type jobs") - return merr.Status(fmt.Errorf("IndexNode receive dropping unknown type jobs")), nil + log.Warn("DataNode receive dropping unknown type jobs") + return merr.Status(fmt.Errorf("DataNode receive dropping unknown type jobs")), nil } } diff --git a/internal/indexnode/indexnode_test.go b/internal/datanode/index_services_test.go similarity index 66% rename from internal/indexnode/indexnode_test.go rename to internal/datanode/index_services_test.go index 95033d758b..533b0f1cc2 100644 --- a/internal/indexnode/indexnode_test.go +++ b/internal/datanode/index_services_test.go @@ -14,119 +14,57 @@ // See the License for the specific language governing permissions and // limitations under the License. -package indexnode +package datanode import ( "context" - "os" + "fmt" "strconv" "testing" "time" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" "github.com/milvus-io/milvus-proto/go-api/v2/schemapb" + "github.com/milvus-io/milvus/internal/datanode/index" "github.com/milvus-io/milvus/internal/metastore/kv/binlog" + "github.com/milvus-io/milvus/internal/mocks" "github.com/milvus-io/milvus/internal/storage" + "github.com/milvus-io/milvus/internal/util/dependency" + "github.com/milvus-io/milvus/pkg/v2/common" "github.com/milvus-io/milvus/pkg/v2/proto/datapb" + "github.com/milvus-io/milvus/pkg/v2/proto/etcdpb" "github.com/milvus-io/milvus/pkg/v2/proto/indexpb" "github.com/milvus-io/milvus/pkg/v2/proto/workerpb" "github.com/milvus-io/milvus/pkg/v2/util/merr" "github.com/milvus-io/milvus/pkg/v2/util/paramtable" + "github.com/milvus-io/milvus/pkg/v2/util/typeutil" ) -func TestComponentState(t *testing.T) { - var ( - factory = &mockFactory{ - chunkMgr: &mockChunkmgr{}, - } - ctx = context.TODO() - ) - paramtable.Init() - in := NewIndexNode(ctx, factory) - in.SetEtcdClient(getEtcdClient()) - state, err := in.GetComponentStates(ctx, nil) - assert.NoError(t, err) - assert.Equal(t, state.GetStatus().GetErrorCode(), commonpb.ErrorCode_Success) - assert.Equal(t, state.State.StateCode, commonpb.StateCode_Abnormal) - - assert.Nil(t, in.Init()) - state, err = in.GetComponentStates(ctx, nil) - assert.NoError(t, err) - assert.Equal(t, state.GetStatus().GetErrorCode(), commonpb.ErrorCode_Success) - assert.Equal(t, state.State.StateCode, commonpb.StateCode_Initializing) - - assert.Nil(t, in.Start()) - state, err = in.GetComponentStates(ctx, nil) - assert.NoError(t, err) - assert.Equal(t, state.GetStatus().GetErrorCode(), commonpb.ErrorCode_Success) - assert.Equal(t, state.State.StateCode, commonpb.StateCode_Healthy) - - assert.Nil(t, in.Stop()) - assert.Nil(t, in.Stop()) - state, err = in.GetComponentStates(ctx, nil) - assert.NoError(t, err) - assert.Equal(t, state.GetStatus().GetErrorCode(), commonpb.ErrorCode_Success) - assert.Equal(t, state.State.StateCode, commonpb.StateCode_Abnormal) -} - -func TestGetTimeTickChannel(t *testing.T) { - var ( - factory = &mockFactory{ - chunkMgr: &mockChunkmgr{}, - } - ctx = context.TODO() - ) - paramtable.Init() - in := NewIndexNode(ctx, factory) - ret, err := in.GetTimeTickChannel(ctx, nil) - assert.NoError(t, err) - assert.Equal(t, ret.GetStatus().GetErrorCode(), commonpb.ErrorCode_Success) -} - -func TestGetStatisticChannel(t *testing.T) { - var ( - factory = &mockFactory{ - chunkMgr: &mockChunkmgr{}, - } - ctx = context.TODO() - ) - paramtable.Init() - in := NewIndexNode(ctx, factory) - - ret, err := in.GetStatisticsChannel(ctx, nil) - assert.NoError(t, err) - assert.Equal(t, ret.GetStatus().GetErrorCode(), commonpb.ErrorCode_Success) -} - func TestIndexTaskWhenStoppingNode(t *testing.T) { - var ( - factory = &mockFactory{ - chunkMgr: &mockChunkmgr{}, - } - ctx = context.TODO() - ) + ctx := context.TODO() paramtable.Init() - in := NewIndexNode(ctx, factory) + manager := index.NewTaskManager(ctx) - in.loadOrStoreIndexTask("cluster-1", 1, &indexTaskInfo{ - state: commonpb.IndexState_InProgress, + manager.LoadOrStoreIndexTask("cluster-1", 1, &index.IndexTaskInfo{ + State: commonpb.IndexState_InProgress, }) - in.loadOrStoreIndexTask("cluster-2", 2, &indexTaskInfo{ - state: commonpb.IndexState_Finished, + manager.LoadOrStoreIndexTask("cluster-2", 2, &index.IndexTaskInfo{ + State: commonpb.IndexState_Finished, }) - assert.True(t, in.hasInProgressTask()) + assert.True(t, manager.HasInProgressTask()) go func() { time.Sleep(2 * time.Second) - in.storeIndexTaskState("cluster-1", 1, commonpb.IndexState_Finished, "") + manager.StoreIndexTaskState("cluster-1", 1, commonpb.IndexState_Finished, "") }() noTaskChan := make(chan struct{}) go func() { - in.waitTaskFinish() + manager.WaitTaskFinish() close(noTaskChan) }() select { @@ -136,46 +74,7 @@ func TestIndexTaskWhenStoppingNode(t *testing.T) { } } -func TestGetSetAddress(t *testing.T) { - var ( - factory = &mockFactory{ - chunkMgr: &mockChunkmgr{}, - } - ctx = context.TODO() - ) - paramtable.Init() - in := NewIndexNode(ctx, factory) - in.SetAddress("address") - assert.Equal(t, "address", in.GetAddress()) -} - -func TestInitErr(t *testing.T) { - // var ( - // factory = &mockFactory{} - // ctx = context.TODO() - // ) - // in, err := NewIndexNode(ctx, factory) - // assert.NoError(t, err) - // in.SetEtcdClient(getEtcdClient()) - // assert.Error(t, in.Init()) -} - -func setup() { - startEmbedEtcd() -} - -func teardown() { - stopEmbedEtcd() -} - -func TestMain(m *testing.M) { - setup() - code := m.Run() - teardown() - os.Exit(code) -} - -type IndexNodeSuite struct { +type IndexServiceSuite struct { suite.Suite collID int64 @@ -184,18 +83,18 @@ type IndexNodeSuite struct { fieldID int64 logID int64 numRows int64 - data []*Blob - deleteData []*Blob - in *IndexNode + data []*storage.Blob + deleteData []*storage.Blob + in *DataNode storageConfig *indexpb.StorageConfig cm storage.ChunkManager } -func Test_IndexNodeSuite(t *testing.T) { - suite.Run(t, new(IndexNodeSuite)) +func Test_IndexServiceSuite(t *testing.T) { + suite.Run(t, new(IndexServiceSuite)) } -func (s *IndexNodeSuite) SetupTest() { +func (s *IndexServiceSuite) SetupTest() { s.collID = 1 s.partID = 2 s.segID = 3 @@ -203,7 +102,7 @@ func (s *IndexNodeSuite) SetupTest() { s.logID = 10000 s.numRows = 3000 paramtable.Init() - Params.MinioCfg.RootPath.SwapTempValue("indexnode-ut") + paramtable.Get().MinioCfg.RootPath.SwapTempValue("index-service-ut") var err error s.data, err = generateTestData(s.collID, s.partID, s.segID, int(s.numRows)) @@ -213,30 +112,38 @@ func (s *IndexNodeSuite) SetupTest() { s.NoError(err) s.storageConfig = &indexpb.StorageConfig{ - Address: Params.MinioCfg.Address.GetValue(), - AccessKeyID: Params.MinioCfg.AccessKeyID.GetValue(), - SecretAccessKey: Params.MinioCfg.SecretAccessKey.GetValue(), - UseSSL: Params.MinioCfg.UseSSL.GetAsBool(), - SslCACert: Params.MinioCfg.SslCACert.GetValue(), - BucketName: Params.MinioCfg.BucketName.GetValue(), - RootPath: Params.MinioCfg.RootPath.GetValue(), - UseIAM: Params.MinioCfg.UseIAM.GetAsBool(), - IAMEndpoint: Params.MinioCfg.IAMEndpoint.GetValue(), - StorageType: Params.CommonCfg.StorageType.GetValue(), - Region: Params.MinioCfg.Region.GetValue(), - UseVirtualHost: Params.MinioCfg.UseVirtualHost.GetAsBool(), - CloudProvider: Params.MinioCfg.CloudProvider.GetValue(), - RequestTimeoutMs: Params.MinioCfg.RequestTimeoutMs.GetAsInt64(), - GcpCredentialJSON: Params.MinioCfg.GcpCredentialJSON.GetValue(), + Address: paramtable.Get().MinioCfg.Address.GetValue(), + AccessKeyID: paramtable.Get().MinioCfg.AccessKeyID.GetValue(), + SecretAccessKey: paramtable.Get().MinioCfg.SecretAccessKey.GetValue(), + UseSSL: paramtable.Get().MinioCfg.UseSSL.GetAsBool(), + SslCACert: paramtable.Get().MinioCfg.SslCACert.GetValue(), + BucketName: paramtable.Get().MinioCfg.BucketName.GetValue(), + RootPath: paramtable.Get().MinioCfg.RootPath.GetValue(), + UseIAM: paramtable.Get().MinioCfg.UseIAM.GetAsBool(), + IAMEndpoint: paramtable.Get().MinioCfg.IAMEndpoint.GetValue(), + StorageType: paramtable.Get().CommonCfg.StorageType.GetValue(), + Region: paramtable.Get().MinioCfg.Region.GetValue(), + UseVirtualHost: paramtable.Get().MinioCfg.UseVirtualHost.GetAsBool(), + CloudProvider: paramtable.Get().MinioCfg.CloudProvider.GetValue(), + RequestTimeoutMs: paramtable.Get().MinioCfg.RequestTimeoutMs.GetAsInt64(), + GcpCredentialJSON: paramtable.Get().MinioCfg.GcpCredentialJSON.GetValue(), } var ( - factory = &mockFactory{ - chunkMgr: &mockChunkmgr{}, - } - ctx = context.TODO() + factory = dependency.NewMockFactory(s.T()) + ctx = context.TODO() ) - s.in = NewIndexNode(ctx, factory) + + cm := mocks.NewChunkManager(s.T()) + + factory.EXPECT().Init(mock.Anything).Return() + factory.EXPECT().NewPersistentStorageChunkManager(mock.Anything).Return(cm, nil) + + s.in = NewDataNode(ctx, factory) + + dc := mocks.NewMockDataCoordClient(s.T()) + dc.EXPECT().ReportDataNodeTtMsgs(mock.Anything, mock.Anything).Return(nil, nil).Maybe() + s.in.dataCoord = dc err = s.in.Init() s.NoError(err) @@ -263,16 +170,16 @@ func (s *IndexNodeSuite) SetupTest() { } } -func (s *IndexNodeSuite) TearDownSuite() { - err := s.cm.RemoveWithPrefix(context.Background(), "indexnode-ut") +func (s *IndexServiceSuite) TearDownSuite() { + err := s.cm.RemoveWithPrefix(context.Background(), "index-service-ut") s.NoError(err) - Params.MinioCfg.RootPath.SwapTempValue("files") + paramtable.Get().MinioCfg.RootPath.SwapTempValue("files") err = s.in.Stop() s.NoError(err) } -func (s *IndexNodeSuite) Test_CreateIndexJob_Compatibility() { +func (s *IndexServiceSuite) Test_CreateIndexJob_Compatibility() { s.Run("create vec index", func() { ctx := context.Background() @@ -282,7 +189,7 @@ func (s *IndexNodeSuite) Test_CreateIndexJob_Compatibility() { s.NoError(err) req := &workerpb.CreateJobRequest{ ClusterID: "cluster1", - IndexFilePrefix: "indexnode-ut/index_files", + IndexFilePrefix: "index-service-ut/index_files", BuildID: buildID, DataPaths: []string{dataPath}, IndexVersion: 1, @@ -343,7 +250,7 @@ func (s *IndexNodeSuite) Test_CreateIndexJob_Compatibility() { buildID := int64(2) req := &workerpb.CreateJobRequest{ ClusterID: "cluster1", - IndexFilePrefix: "indexnode-ut/index_files", + IndexFilePrefix: "index-service-ut/index_files", BuildID: buildID, DataPaths: nil, IndexVersion: 1, @@ -412,7 +319,7 @@ func (s *IndexNodeSuite) Test_CreateIndexJob_Compatibility() { buildID := int64(3) req := &workerpb.CreateJobRequest{ ClusterID: "cluster1", - IndexFilePrefix: "indexnode-ut/index_files", + IndexFilePrefix: "index-service-ut/index_files", BuildID: buildID, IndexVersion: 1, StorageConfig: s.storageConfig, @@ -485,7 +392,7 @@ func (s *IndexNodeSuite) Test_CreateIndexJob_Compatibility() { }) } -func (s *IndexNodeSuite) Test_CreateIndexJob_ScalarIndex() { +func (s *IndexServiceSuite) Test_CreateIndexJob_ScalarIndex() { ctx := context.Background() s.Run("int64 inverted", func() { @@ -495,7 +402,7 @@ func (s *IndexNodeSuite) Test_CreateIndexJob_ScalarIndex() { s.NoError(err) req := &workerpb.CreateJobRequest{ ClusterID: "cluster1", - IndexFilePrefix: "indexnode-ut/index_files", + IndexFilePrefix: "index-service-ut/index_files", BuildID: buildID, DataPaths: []string{dataPath}, IndexVersion: 1, @@ -547,7 +454,7 @@ func (s *IndexNodeSuite) Test_CreateIndexJob_ScalarIndex() { }) } -func (s *IndexNodeSuite) Test_CreateAnalyzeTask() { +func (s *IndexServiceSuite) Test_CreateAnalyzeTask() { ctx := context.Background() s.Run("normal case", func() { @@ -618,7 +525,7 @@ func (s *IndexNodeSuite) Test_CreateAnalyzeTask() { }) } -func (s *IndexNodeSuite) Test_CreateStatsTask() { +func (s *IndexServiceSuite) Test_CreateStatsTask() { ctx := context.Background() fieldBinlogs := make([]*datapb.FieldBinlog, 0) @@ -782,3 +689,165 @@ func (s *IndexNodeSuite) Test_CreateStatsTask() { s.NoError(err) }) } + +func generateTestSchema() *schemapb.CollectionSchema { + schema := &schemapb.CollectionSchema{Fields: []*schemapb.FieldSchema{ + {FieldID: common.TimeStampField, Name: "ts", DataType: schemapb.DataType_Int64}, + {FieldID: common.RowIDField, Name: "rowid", DataType: schemapb.DataType_Int64}, + {FieldID: 100, Name: "bool", DataType: schemapb.DataType_Bool}, + {FieldID: 101, Name: "int8", DataType: schemapb.DataType_Int8}, + {FieldID: 102, Name: "int16", DataType: schemapb.DataType_Int16}, + {FieldID: 103, Name: "int64", DataType: schemapb.DataType_Int64, IsPrimaryKey: true}, + {FieldID: 104, Name: "float", DataType: schemapb.DataType_Float}, + {FieldID: 105, Name: "double", DataType: schemapb.DataType_Double}, + {FieldID: 106, Name: "varchar", DataType: schemapb.DataType_VarChar}, + {FieldID: 107, Name: "string", DataType: schemapb.DataType_String}, + {FieldID: 108, Name: "array", DataType: schemapb.DataType_Array}, + {FieldID: 109, Name: "json", DataType: schemapb.DataType_JSON}, + {FieldID: 110, Name: "int32", DataType: schemapb.DataType_Int32}, + {FieldID: 111, Name: "floatVector", DataType: schemapb.DataType_FloatVector, TypeParams: []*commonpb.KeyValuePair{ + {Key: common.DimKey, Value: "8"}, + }}, + {FieldID: 112, Name: "binaryVector", DataType: schemapb.DataType_BinaryVector, TypeParams: []*commonpb.KeyValuePair{ + {Key: common.DimKey, Value: "8"}, + }}, + {FieldID: 113, Name: "float16Vector", DataType: schemapb.DataType_Float16Vector, TypeParams: []*commonpb.KeyValuePair{ + {Key: common.DimKey, Value: "8"}, + }}, + {FieldID: 114, Name: "bf16Vector", DataType: schemapb.DataType_BFloat16Vector, TypeParams: []*commonpb.KeyValuePair{ + {Key: common.DimKey, Value: "8"}, + }}, + {FieldID: 115, Name: "sparseFloatVector", DataType: schemapb.DataType_SparseFloatVector, TypeParams: []*commonpb.KeyValuePair{ + {Key: common.DimKey, Value: "28433"}, + }}, + }} + + return schema +} + +func generateTestData(collID, partID, segID int64, num int) ([]*storage.Blob, error) { + insertCodec := storage.NewInsertCodecWithSchema(&etcdpb.CollectionMeta{ID: collID, Schema: generateTestSchema()}) + + var ( + field0 []int64 + field1 []int64 + + field10 []bool + field11 []int8 + field12 []int16 + field13 []int64 + field14 []float32 + field15 []float64 + field16 []string + field17 []string + field18 []*schemapb.ScalarField + field19 [][]byte + + field101 []int32 + field102 []float32 + field103 []byte + + field104 []byte + field105 []byte + field106 [][]byte + ) + + for i := 1; i <= num; i++ { + field0 = append(field0, int64(i)) + field1 = append(field1, int64(i)) + field10 = append(field10, true) + field11 = append(field11, int8(i)) + field12 = append(field12, int16(i)) + field13 = append(field13, int64(i)) + field14 = append(field14, float32(i)) + field15 = append(field15, float64(i)) + field16 = append(field16, fmt.Sprint(i)) + field17 = append(field17, fmt.Sprint(i)) + + arr := &schemapb.ScalarField{ + Data: &schemapb.ScalarField_IntData{ + IntData: &schemapb.IntArray{Data: []int32{int32(i), int32(i), int32(i)}}, + }, + } + field18 = append(field18, arr) + + field19 = append(field19, []byte{byte(i)}) + field101 = append(field101, int32(i)) + + f102 := make([]float32, 8) + for j := range f102 { + f102[j] = float32(i) + } + + field102 = append(field102, f102...) + field103 = append(field103, 0xff) + + f104 := make([]byte, 16) + for j := range f104 { + f104[j] = byte(i) + } + field104 = append(field104, f104...) + field105 = append(field105, f104...) + + field106 = append(field106, typeutil.CreateSparseFloatRow([]uint32{0, uint32(18 * i), uint32(284 * i)}, []float32{1.1, 0.3, 2.4})) + } + + data := &storage.InsertData{Data: map[int64]storage.FieldData{ + common.RowIDField: &storage.Int64FieldData{Data: field0}, + common.TimeStampField: &storage.Int64FieldData{Data: field1}, + + 100: &storage.BoolFieldData{Data: field10}, + 101: &storage.Int8FieldData{Data: field11}, + 102: &storage.Int16FieldData{Data: field12}, + 103: &storage.Int64FieldData{Data: field13}, + 104: &storage.FloatFieldData{Data: field14}, + 105: &storage.DoubleFieldData{Data: field15}, + 106: &storage.StringFieldData{Data: field16}, + 107: &storage.StringFieldData{Data: field17}, + 108: &storage.ArrayFieldData{Data: field18}, + 109: &storage.JSONFieldData{Data: field19}, + 110: &storage.Int32FieldData{Data: field101}, + 111: &storage.FloatVectorFieldData{ + Data: field102, + Dim: 8, + }, + 112: &storage.BinaryVectorFieldData{ + Data: field103, + Dim: 8, + }, + 113: &storage.Float16VectorFieldData{ + Data: field104, + Dim: 8, + }, + 114: &storage.BFloat16VectorFieldData{ + Data: field105, + Dim: 8, + }, + 115: &storage.SparseFloatVectorFieldData{ + SparseFloatArray: schemapb.SparseFloatArray{ + Dim: 28433, + Contents: field106, + }, + }, + }} + + blobs, err := insertCodec.Serialize(partID, segID, data) + return blobs, err +} + +func generateDeleteData(collID, partID, segID int64, num int) ([]*storage.Blob, error) { + pks := make([]storage.PrimaryKey, 0, num) + tss := make([]storage.Timestamp, 0, num) + for i := 1; i <= num; i++ { + pks = append(pks, storage.NewInt64PrimaryKey(int64(i))) + tss = append(tss, storage.Timestamp(i+1)) + } + + deleteCodec := storage.NewDeleteCodec() + blob, err := deleteCodec.Serialize(collID, partID, segID, &storage.DeleteData{ + Pks: pks, + Tss: tss, + RowCount: int64(num), + }) + return []*storage.Blob{blob}, err +} diff --git a/internal/datanode/metrics_info.go b/internal/datanode/metrics_info.go index 207a42194c..db2f5bcbb0 100644 --- a/internal/datanode/metrics_info.go +++ b/internal/datanode/metrics_info.go @@ -111,6 +111,8 @@ func (node *DataNode) getSystemInfoMetrics(ctx context.Context, _ *milvuspb.GetM ID: node.GetSession().ServerID, }, SystemConfigurations: metricsinfo.DataNodeConfiguration{ + MinioBucketName: Params.MinioCfg.BucketName.GetValue(), + SimdType: Params.CommonCfg.SimdType.GetValue(), FlushInsertBufferSize: Params.DataNodeCfg.FlushInsertBufferSize.GetAsInt64(), }, QuotaMetrics: quotaMetrics, diff --git a/internal/datanode/services.go b/internal/datanode/services.go index bb277b6963..08ffe9ccd3 100644 --- a/internal/datanode/services.go +++ b/internal/datanode/services.go @@ -61,7 +61,7 @@ func (node *DataNode) WatchDmChannels(ctx context.Context, in *datapb.WatchDmCha // GetComponentStates will return current state of DataNode func (node *DataNode) GetComponentStates(ctx context.Context, req *milvuspb.GetComponentStatesRequest) (*milvuspb.ComponentStates, error) { nodeID := common.NotRegisteredID - state := node.stateCode.Load().(commonpb.StateCode) + state := node.GetStateCode() log.Ctx(ctx).Debug("DataNode current state", zap.String("State", state.String())) if node.GetSession() != nil && node.session.Registered() { nodeID = node.GetSession().ServerID @@ -71,7 +71,7 @@ func (node *DataNode) GetComponentStates(ctx context.Context, req *milvuspb.GetC // NodeID: Params.NodeID, // will race with DataNode.Register() NodeID: nodeID, Role: node.Role, - StateCode: node.stateCode.Load().(commonpb.StateCode), + StateCode: state, }, SubcomponentStates: make([]*milvuspb.ComponentInfo, 0), Status: merr.Success(), diff --git a/internal/datanode/services_test.go b/internal/datanode/services_test.go index 9d9e52284d..f31eb938ef 100644 --- a/internal/datanode/services_test.go +++ b/internal/datanode/services_test.go @@ -47,6 +47,7 @@ import ( "github.com/milvus-io/milvus/pkg/v2/proto/datapb" "github.com/milvus-io/milvus/pkg/v2/proto/internalpb" "github.com/milvus-io/milvus/pkg/v2/util/etcd" + "github.com/milvus-io/milvus/pkg/v2/util/lifetime" "github.com/milvus-io/milvus/pkg/v2/util/merr" "github.com/milvus-io/milvus/pkg/v2/util/metricsinfo" "github.com/milvus-io/milvus/pkg/v2/util/paramtable" @@ -212,7 +213,7 @@ func (s *DataNodeServicesSuite) TestGetCompactionState() { }) s.Run("unhealthy", func() { - node := &DataNode{} + node := &DataNode{lifetime: lifetime.NewLifetime(commonpb.StateCode_Abnormal)} node.UpdateStateCode(commonpb.StateCode_Abnormal) resp, _ := node.GetCompactionState(s.ctx, nil) s.Assert().Equal(merr.Code(merr.ErrServiceNotReady), resp.GetStatus().GetCode()) @@ -225,7 +226,7 @@ func (s *DataNodeServicesSuite) TestCompaction() { s.Run("service_not_ready", func() { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - node := &DataNode{} + node := &DataNode{lifetime: lifetime.NewLifetime(commonpb.StateCode_Abnormal)} node.UpdateStateCode(commonpb.StateCode_Abnormal) req := &datapb.CompactionPlan{ PlanID: 1000, @@ -383,7 +384,7 @@ func (s *DataNodeServicesSuite) TestFlushSegments() { s.Run("service_not_ready", func() { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - node := &DataNode{} + node := &DataNode{lifetime: lifetime.NewLifetime(commonpb.StateCode_Abnormal)} node.UpdateStateCode(commonpb.StateCode_Abnormal) req := &datapb.FlushSegmentsRequest{ Base: &commonpb.MsgBase{ @@ -469,15 +470,15 @@ func (s *DataNodeServicesSuite) TestShowConfigurations() { } // test closed server - node := &DataNode{} + node := &DataNode{lifetime: lifetime.NewLifetime(commonpb.StateCode_Abnormal)} node.SetSession(&sessionutil.Session{SessionRaw: sessionutil.SessionRaw{ServerID: 1}}) - node.stateCode.Store(commonpb.StateCode_Abnormal) + node.UpdateStateCode(commonpb.StateCode_Abnormal) resp, err := node.ShowConfigurations(s.ctx, req) s.Assert().NoError(err) s.Assert().False(merr.Ok(resp.GetStatus())) - node.stateCode.Store(commonpb.StateCode_Healthy) + node.UpdateStateCode(commonpb.StateCode_Healthy) resp, err = node.ShowConfigurations(s.ctx, req) s.Assert().NoError(err) s.Assert().True(merr.Ok(resp.GetStatus())) @@ -491,12 +492,12 @@ func (s *DataNodeServicesSuite) TestGetMetrics() { node.SetSession(&sessionutil.Session{SessionRaw: sessionutil.SessionRaw{ServerID: 1}}) node.flowgraphManager = pipeline.NewFlowgraphManager() // server is closed - node.stateCode.Store(commonpb.StateCode_Abnormal) + node.UpdateStateCode(commonpb.StateCode_Abnormal) resp, err := node.GetMetrics(s.ctx, &milvuspb.GetMetricsRequest{}) s.Assert().NoError(err) s.Assert().False(merr.Ok(resp.GetStatus())) - node.stateCode.Store(commonpb.StateCode_Healthy) + node.UpdateStateCode(commonpb.StateCode_Healthy) // failed to parse metric type invalidRequest := "invalid request" diff --git a/internal/distributed/datanode/client/client.go b/internal/distributed/datanode/client/client.go index a51d0d202a..b8339988e6 100644 --- a/internal/distributed/datanode/client/client.go +++ b/internal/distributed/datanode/client/client.go @@ -32,6 +32,7 @@ import ( "github.com/milvus-io/milvus/pkg/v2/log" "github.com/milvus-io/milvus/pkg/v2/proto/datapb" "github.com/milvus-io/milvus/pkg/v2/proto/internalpb" + "github.com/milvus-io/milvus/pkg/v2/proto/workerpb" "github.com/milvus-io/milvus/pkg/v2/util/commonpbutil" "github.com/milvus-io/milvus/pkg/v2/util/funcutil" "github.com/milvus-io/milvus/pkg/v2/util/paramtable" @@ -40,9 +41,14 @@ import ( var Params *paramtable.ComponentParam = paramtable.Get() +type DataNodeClient struct { + datapb.DataNodeClient + workerpb.IndexNodeClient +} + // Client is the grpc client for DataNode type Client struct { - grpcClient grpcclient.GrpcClient[datapb.DataNodeClient] + grpcClient grpcclient.GrpcClient[DataNodeClient] sess *sessionutil.Session addr string serverID int64 @@ -50,7 +56,7 @@ type Client struct { } // NewClient creates a client for DataNode. -func NewClient(ctx context.Context, addr string, serverID int64) (types.DataNodeClient, error) { +func NewClient(ctx context.Context, addr string, serverID int64, encryption bool) (types.DataNodeClient, error) { if addr == "" { return nil, fmt.Errorf("address is empty") } @@ -64,7 +70,7 @@ func NewClient(ctx context.Context, addr string, serverID int64) (types.DataNode config := &Params.DataNodeGrpcClientCfg client := &Client{ addr: addr, - grpcClient: grpcclient.NewClientBase[datapb.DataNodeClient](config, "milvus.proto.data.DataNode"), + grpcClient: grpcclient.NewClientBase[DataNodeClient](config, "milvus.proto.data.DataNode"), sess: sess, serverID: serverID, ctx: ctx, @@ -76,6 +82,10 @@ func NewClient(ctx context.Context, addr string, serverID int64) (types.DataNode client.grpcClient.SetNodeID(serverID) client.grpcClient.SetSession(sess) + if encryption { + client.grpcClient.EnableEncryption() + } + if Params.InternalTLSCfg.InternalTLSEnabled.GetAsBool() { client.grpcClient.EnableEncryption() cp, err := utils.CreateCertPoolforClient(Params.InternalTLSCfg.InternalTLSCaPemPath.GetValue(), "DataNode") @@ -95,16 +105,19 @@ func (c *Client) Close() error { return c.grpcClient.Close() } -func (c *Client) newGrpcClient(cc *grpc.ClientConn) datapb.DataNodeClient { - return datapb.NewDataNodeClient(cc) +func (c *Client) newGrpcClient(cc *grpc.ClientConn) DataNodeClient { + return DataNodeClient{ + DataNodeClient: datapb.NewDataNodeClient(cc), + IndexNodeClient: workerpb.NewIndexNodeClient(cc), + } } func (c *Client) getAddr() (string, error) { return c.addr, nil } -func wrapGrpcCall[T any](ctx context.Context, c *Client, call func(grpcClient datapb.DataNodeClient) (*T, error)) (*T, error) { - ret, err := c.grpcClient.ReCall(ctx, func(client datapb.DataNodeClient) (any, error) { +func wrapGrpcCall[T any](ctx context.Context, c *Client, call func(grpcClient DataNodeClient) (*T, error)) (*T, error) { + ret, err := c.grpcClient.ReCall(ctx, func(client DataNodeClient) (any, error) { if !funcutil.CheckCtxValid(ctx) { return nil, ctx.Err() } @@ -118,7 +131,7 @@ func wrapGrpcCall[T any](ctx context.Context, c *Client, call func(grpcClient da // GetComponentStates returns ComponentStates func (c *Client) GetComponentStates(ctx context.Context, req *milvuspb.GetComponentStatesRequest, opts ...grpc.CallOption) (*milvuspb.ComponentStates, error) { - return wrapGrpcCall(ctx, c, func(client datapb.DataNodeClient) (*milvuspb.ComponentStates, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*milvuspb.ComponentStates, error) { return client.GetComponentStates(ctx, &milvuspb.GetComponentStatesRequest{}) }) } @@ -126,7 +139,7 @@ func (c *Client) GetComponentStates(ctx context.Context, req *milvuspb.GetCompon // GetStatisticsChannel return the statistics channel in string // Statistics channel contains statistics infos of query nodes, such as segment infos, memory infos func (c *Client) GetStatisticsChannel(ctx context.Context, req *internalpb.GetStatisticsChannelRequest, opts ...grpc.CallOption) (*milvuspb.StringResponse, error) { - return wrapGrpcCall(ctx, c, func(client datapb.DataNodeClient) (*milvuspb.StringResponse, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*milvuspb.StringResponse, error) { return client.GetStatisticsChannel(ctx, &internalpb.GetStatisticsChannelRequest{}) }) } @@ -138,7 +151,7 @@ func (c *Client) WatchDmChannels(ctx context.Context, req *datapb.WatchDmChannel commonpbutil.UpdateMsgBase( req.GetBase(), commonpbutil.FillMsgBaseFromClient(c.serverID)) - return wrapGrpcCall(ctx, c, func(client datapb.DataNodeClient) (*commonpb.Status, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*commonpb.Status, error) { return client.WatchDmChannels(ctx, req) }) } @@ -160,7 +173,7 @@ func (c *Client) FlushSegments(ctx context.Context, req *datapb.FlushSegmentsReq commonpbutil.UpdateMsgBase( req.GetBase(), commonpbutil.FillMsgBaseFromClient(c.serverID)) - return wrapGrpcCall(ctx, c, func(client datapb.DataNodeClient) (*commonpb.Status, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*commonpb.Status, error) { return client.FlushSegments(ctx, req) }) } @@ -171,7 +184,7 @@ func (c *Client) ShowConfigurations(ctx context.Context, req *internalpb.ShowCon commonpbutil.UpdateMsgBase( req.GetBase(), commonpbutil.FillMsgBaseFromClient(c.serverID)) - return wrapGrpcCall(ctx, c, func(client datapb.DataNodeClient) (*internalpb.ShowConfigurationsResponse, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*internalpb.ShowConfigurationsResponse, error) { return client.ShowConfigurations(ctx, req) }) } @@ -182,14 +195,14 @@ func (c *Client) GetMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest commonpbutil.UpdateMsgBase( req.GetBase(), commonpbutil.FillMsgBaseFromClient(c.serverID)) - return wrapGrpcCall(ctx, c, func(client datapb.DataNodeClient) (*milvuspb.GetMetricsResponse, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*milvuspb.GetMetricsResponse, error) { return client.GetMetrics(ctx, req) }) } // CompactionV2 return compaction by given plan func (c *Client) CompactionV2(ctx context.Context, req *datapb.CompactionPlan, opts ...grpc.CallOption) (*commonpb.Status, error) { - return wrapGrpcCall(ctx, c, func(client datapb.DataNodeClient) (*commonpb.Status, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*commonpb.Status, error) { return client.CompactionV2(ctx, req) }) } @@ -199,7 +212,7 @@ func (c *Client) GetCompactionState(ctx context.Context, req *datapb.CompactionS commonpbutil.UpdateMsgBase( req.GetBase(), commonpbutil.FillMsgBaseFromClient(c.serverID)) - return wrapGrpcCall(ctx, c, func(client datapb.DataNodeClient) (*datapb.CompactionStateResponse, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*datapb.CompactionStateResponse, error) { return client.GetCompactionState(ctx, req) }) } @@ -209,75 +222,121 @@ func (c *Client) ResendSegmentStats(ctx context.Context, req *datapb.ResendSegme commonpbutil.UpdateMsgBase( req.GetBase(), commonpbutil.FillMsgBaseFromClient(c.serverID)) - return wrapGrpcCall(ctx, c, func(client datapb.DataNodeClient) (*datapb.ResendSegmentStatsResponse, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*datapb.ResendSegmentStatsResponse, error) { return client.ResendSegmentStats(ctx, req) }) } // SyncSegments is the DataNode client side code for SyncSegments call. func (c *Client) SyncSegments(ctx context.Context, req *datapb.SyncSegmentsRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { - return wrapGrpcCall(ctx, c, func(client datapb.DataNodeClient) (*commonpb.Status, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*commonpb.Status, error) { return client.SyncSegments(ctx, req) }) } // FlushChannels notifies DataNode to sync all the segments belongs to the target channels. func (c *Client) FlushChannels(ctx context.Context, req *datapb.FlushChannelsRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { - return wrapGrpcCall(ctx, c, func(client datapb.DataNodeClient) (*commonpb.Status, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*commonpb.Status, error) { return client.FlushChannels(ctx, req) }) } func (c *Client) NotifyChannelOperation(ctx context.Context, req *datapb.ChannelOperationsRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { - return wrapGrpcCall(ctx, c, func(client datapb.DataNodeClient) (*commonpb.Status, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*commonpb.Status, error) { return client.NotifyChannelOperation(ctx, req) }) } func (c *Client) CheckChannelOperationProgress(ctx context.Context, req *datapb.ChannelWatchInfo, opts ...grpc.CallOption) (*datapb.ChannelOperationProgressResponse, error) { - return wrapGrpcCall(ctx, c, func(client datapb.DataNodeClient) (*datapb.ChannelOperationProgressResponse, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*datapb.ChannelOperationProgressResponse, error) { return client.CheckChannelOperationProgress(ctx, req) }) } func (c *Client) PreImport(ctx context.Context, req *datapb.PreImportRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { - return wrapGrpcCall(ctx, c, func(client datapb.DataNodeClient) (*commonpb.Status, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*commonpb.Status, error) { return client.PreImport(ctx, req) }) } func (c *Client) ImportV2(ctx context.Context, req *datapb.ImportRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { - return wrapGrpcCall(ctx, c, func(client datapb.DataNodeClient) (*commonpb.Status, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*commonpb.Status, error) { return client.ImportV2(ctx, req) }) } func (c *Client) QueryPreImport(ctx context.Context, req *datapb.QueryPreImportRequest, opts ...grpc.CallOption) (*datapb.QueryPreImportResponse, error) { - return wrapGrpcCall(ctx, c, func(client datapb.DataNodeClient) (*datapb.QueryPreImportResponse, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*datapb.QueryPreImportResponse, error) { return client.QueryPreImport(ctx, req) }) } func (c *Client) QueryImport(ctx context.Context, req *datapb.QueryImportRequest, opts ...grpc.CallOption) (*datapb.QueryImportResponse, error) { - return wrapGrpcCall(ctx, c, func(client datapb.DataNodeClient) (*datapb.QueryImportResponse, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*datapb.QueryImportResponse, error) { return client.QueryImport(ctx, req) }) } func (c *Client) DropImport(ctx context.Context, req *datapb.DropImportRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { - return wrapGrpcCall(ctx, c, func(client datapb.DataNodeClient) (*commonpb.Status, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*commonpb.Status, error) { return client.DropImport(ctx, req) }) } func (c *Client) QuerySlot(ctx context.Context, req *datapb.QuerySlotRequest, opts ...grpc.CallOption) (*datapb.QuerySlotResponse, error) { - return wrapGrpcCall(ctx, c, func(client datapb.DataNodeClient) (*datapb.QuerySlotResponse, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*datapb.QuerySlotResponse, error) { return client.QuerySlot(ctx, req) }) } func (c *Client) DropCompactionPlan(ctx context.Context, req *datapb.DropCompactionPlanRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { - return wrapGrpcCall(ctx, c, func(client datapb.DataNodeClient) (*commonpb.Status, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*commonpb.Status, error) { return client.DropCompactionPlan(ctx, req) }) } + +// CreateJob sends the build index request to IndexNode. +func (c *Client) CreateJob(ctx context.Context, req *workerpb.CreateJobRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*commonpb.Status, error) { + return client.CreateJob(ctx, req) + }) +} + +// QueryJobs query the task info of the index task. +func (c *Client) QueryJobs(ctx context.Context, req *workerpb.QueryJobsRequest, opts ...grpc.CallOption) (*workerpb.QueryJobsResponse, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*workerpb.QueryJobsResponse, error) { + return client.QueryJobs(ctx, req) + }) +} + +// DropJobs query the task info of the index task. +func (c *Client) DropJobs(ctx context.Context, req *workerpb.DropJobsRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*commonpb.Status, error) { + return client.DropJobs(ctx, req) + }) +} + +// GetJobStats query the task info of the index task. +func (c *Client) GetJobStats(ctx context.Context, req *workerpb.GetJobStatsRequest, opts ...grpc.CallOption) (*workerpb.GetJobStatsResponse, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*workerpb.GetJobStatsResponse, error) { + return client.GetJobStats(ctx, req) + }) +} + +func (c *Client) CreateJobV2(ctx context.Context, req *workerpb.CreateJobV2Request, opts ...grpc.CallOption) (*commonpb.Status, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*commonpb.Status, error) { + return client.CreateJobV2(ctx, req) + }) +} + +func (c *Client) QueryJobsV2(ctx context.Context, req *workerpb.QueryJobsV2Request, opts ...grpc.CallOption) (*workerpb.QueryJobsV2Response, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*workerpb.QueryJobsV2Response, error) { + return client.QueryJobsV2(ctx, req) + }) +} + +func (c *Client) DropJobsV2(ctx context.Context, req *workerpb.DropJobsV2Request, opt ...grpc.CallOption) (*commonpb.Status, error) { + return wrapGrpcCall(ctx, c, func(client DataNodeClient) (*commonpb.Status, error) { + return client.DropJobsV2(ctx, req) + }) +} diff --git a/internal/distributed/datanode/client/client_test.go b/internal/distributed/datanode/client/client_test.go index 79e3c2f2c2..5469546dc3 100644 --- a/internal/distributed/datanode/client/client_test.go +++ b/internal/distributed/datanode/client/client_test.go @@ -18,25 +18,29 @@ package grpcdatanodeclient import ( "context" + "errors" "testing" - "github.com/cockroachdb/errors" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" "google.golang.org/grpc" - "github.com/milvus-io/milvus/internal/util/mock" - "github.com/milvus-io/milvus/pkg/v2/proto/datapb" + "github.com/milvus-io/milvus/internal/mocks" + mock2 "github.com/milvus-io/milvus/internal/util/mock" + "github.com/milvus-io/milvus/pkg/v2/proto/internalpb" + "github.com/milvus-io/milvus/pkg/v2/proto/workerpb" + "github.com/milvus-io/milvus/pkg/v2/util/metricsinfo" "github.com/milvus-io/milvus/pkg/v2/util/paramtable" ) func Test_NewClient(t *testing.T) { paramtable.Init() ctx := context.Background() - client, err := NewClient(ctx, "", 1) + client, err := NewClient(ctx, "", 1, false) assert.Nil(t, client) assert.Error(t, err) - client, err = NewClient(ctx, "test", 2) + client, err = NewClient(ctx, "test", 2, false) assert.NoError(t, err) assert.NotNil(t, client) @@ -88,35 +92,44 @@ func Test_NewClient(t *testing.T) { retCheck(retNotNil, r14, err) } - client.(*Client).grpcClient = &mock.GRPCClientBase[datapb.DataNodeClient]{ + client.(*Client).grpcClient = &mock2.GRPCClientBase[DataNodeClient]{ GetGrpcClientErr: errors.New("dummy"), } - newFunc1 := func(cc *grpc.ClientConn) datapb.DataNodeClient { - return &mock.GrpcDataNodeClient{Err: nil} + newFunc1 := func(cc *grpc.ClientConn) DataNodeClient { + return DataNodeClient{ + DataNodeClient: &mock2.GrpcDataNodeClient{Err: nil}, + IndexNodeClient: &mock2.GrpcDataNodeClient{Err: nil}, + } } client.(*Client).grpcClient.SetNewGrpcClientFunc(newFunc1) checkFunc(false) - client.(*Client).grpcClient = &mock.GRPCClientBase[datapb.DataNodeClient]{ + client.(*Client).grpcClient = &mock2.GRPCClientBase[DataNodeClient]{ GetGrpcClientErr: nil, } - newFunc2 := func(cc *grpc.ClientConn) datapb.DataNodeClient { - return &mock.GrpcDataNodeClient{Err: errors.New("dummy")} + newFunc2 := func(cc *grpc.ClientConn) DataNodeClient { + return DataNodeClient{ + DataNodeClient: &mock2.GrpcDataNodeClient{Err: errors.New("dummy")}, + IndexNodeClient: &mock2.GrpcDataNodeClient{Err: errors.New("dummy")}, + } } client.(*Client).grpcClient.SetNewGrpcClientFunc(newFunc2) checkFunc(false) - client.(*Client).grpcClient = &mock.GRPCClientBase[datapb.DataNodeClient]{ + client.(*Client).grpcClient = &mock2.GRPCClientBase[DataNodeClient]{ GetGrpcClientErr: nil, } - newFunc3 := func(cc *grpc.ClientConn) datapb.DataNodeClient { - return &mock.GrpcDataNodeClient{Err: nil} + newFunc3 := func(cc *grpc.ClientConn) DataNodeClient { + return DataNodeClient{ + DataNodeClient: &mock2.GrpcDataNodeClient{Err: nil}, + IndexNodeClient: &mock2.GrpcDataNodeClient{Err: nil}, + } } client.(*Client).grpcClient.SetNewGrpcClientFunc(newFunc3) @@ -125,3 +138,119 @@ func Test_NewClient(t *testing.T) { err = client.Close() assert.NoError(t, err) } + +func TestIndexClient(t *testing.T) { + paramtable.Init() + ctx := context.Background() + client, err := NewClient(ctx, "localhost:1234", 1, false) + assert.NoError(t, err) + assert.NotNil(t, client) + + mockIN := mocks.NewMockDataNodeClient(t) + mockDN := mocks.NewMockDataNodeClient(t) + mockNode := DataNodeClient{ + DataNodeClient: mockDN, + IndexNodeClient: mockIN, + } + + mockGrpcClient := mocks.NewMockGrpcClient[DataNodeClient](t) + mockGrpcClient.EXPECT().Close().Return(nil) + mockGrpcClient.EXPECT().ReCall(mock.Anything, mock.Anything). + RunAndReturn(func(ctx context.Context, f func(nodeClient DataNodeClient) (interface{}, error)) (interface{}, error) { + return f(mockNode) + }) + client.(*Client).grpcClient = mockGrpcClient + + t.Run("GetComponentStates", func(t *testing.T) { + mockDN.EXPECT().GetComponentStates(mock.Anything, mock.Anything).Return(nil, nil) + _, err := client.GetComponentStates(ctx, nil) + assert.NoError(t, err) + }) + + t.Run("GetStatisticsChannel", func(t *testing.T) { + mockDN.EXPECT().GetStatisticsChannel(mock.Anything, mock.Anything).Return(nil, nil) + _, err := client.GetStatisticsChannel(ctx, nil) + assert.NoError(t, err) + }) + + t.Run("CreatJob", func(t *testing.T) { + mockIN.EXPECT().CreateJob(mock.Anything, mock.Anything).Return(nil, nil) + + req := &workerpb.CreateJobRequest{ + ClusterID: "0", + BuildID: 0, + } + _, err := client.CreateJob(ctx, req) + assert.NoError(t, err) + }) + + t.Run("QueryJob", func(t *testing.T) { + mockIN.EXPECT().QueryJobs(mock.Anything, mock.Anything).Return(nil, nil) + + req := &workerpb.QueryJobsRequest{} + _, err := client.QueryJobs(ctx, req) + assert.NoError(t, err) + }) + + t.Run("DropJob", func(t *testing.T) { + mockIN.EXPECT().DropJobs(mock.Anything, mock.Anything).Return(nil, nil) + + req := &workerpb.DropJobsRequest{} + _, err := client.DropJobs(ctx, req) + assert.NoError(t, err) + }) + + t.Run("ShowConfigurations", func(t *testing.T) { + mockDN.EXPECT().ShowConfigurations(mock.Anything, mock.Anything).Return(nil, nil) + + req := &internalpb.ShowConfigurationsRequest{ + Pattern: "", + } + _, err := client.ShowConfigurations(ctx, req) + assert.NoError(t, err) + }) + + t.Run("GetMetrics", func(t *testing.T) { + mockDN.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(nil, nil) + + req, err := metricsinfo.ConstructRequestByMetricType(metricsinfo.SystemInfoMetrics) + assert.NoError(t, err) + _, err = client.GetMetrics(ctx, req) + assert.NoError(t, err) + }) + + t.Run("GetJobStats", func(t *testing.T) { + mockIN.EXPECT().GetJobStats(mock.Anything, mock.Anything).Return(nil, nil) + + req := &workerpb.GetJobStatsRequest{} + _, err := client.GetJobStats(ctx, req) + assert.NoError(t, err) + }) + + t.Run("CreateJobV2", func(t *testing.T) { + mockIN.EXPECT().CreateJobV2(mock.Anything, mock.Anything).Return(nil, nil) + + req := &workerpb.CreateJobV2Request{} + _, err := client.CreateJobV2(ctx, req) + assert.NoError(t, err) + }) + + t.Run("QueryJobsV2", func(t *testing.T) { + mockIN.EXPECT().QueryJobsV2(mock.Anything, mock.Anything).Return(nil, nil) + + req := &workerpb.QueryJobsV2Request{} + _, err := client.QueryJobsV2(ctx, req) + assert.NoError(t, err) + }) + + t.Run("DropJobsV2", func(t *testing.T) { + mockIN.EXPECT().DropJobsV2(mock.Anything, mock.Anything).Return(nil, nil) + + req := &workerpb.DropJobsV2Request{} + _, err := client.DropJobsV2(ctx, req) + assert.NoError(t, err) + }) + + err = client.Close() + assert.NoError(t, err) +} diff --git a/internal/distributed/datanode/service.go b/internal/distributed/datanode/service.go index 6502a0471d..62380ea639 100644 --- a/internal/distributed/datanode/service.go +++ b/internal/distributed/datanode/service.go @@ -42,6 +42,7 @@ import ( "github.com/milvus-io/milvus/pkg/v2/log" "github.com/milvus-io/milvus/pkg/v2/proto/datapb" "github.com/milvus-io/milvus/pkg/v2/proto/internalpb" + "github.com/milvus-io/milvus/pkg/v2/proto/workerpb" "github.com/milvus-io/milvus/pkg/v2/tracer" "github.com/milvus-io/milvus/pkg/v2/util/etcd" "github.com/milvus-io/milvus/pkg/v2/util/funcutil" @@ -160,6 +161,7 @@ func (s *Server) startGrpcLoop() { grpcOpts = append(grpcOpts, utils.EnableInternalTLS("DataNode")) s.grpcServer = grpc.NewServer(grpcOpts...) datapb.RegisterDataNodeServer(s.grpcServer, s) + workerpb.RegisterIndexNodeServer(s.grpcServer, s) ctx, cancel := context.WithCancel(s.ctx) defer cancel() @@ -410,3 +412,35 @@ func (s *Server) QuerySlot(ctx context.Context, req *datapb.QuerySlotRequest) (* func (s *Server) DropCompactionPlan(ctx context.Context, req *datapb.DropCompactionPlanRequest) (*commonpb.Status, error) { return s.datanode.DropCompactionPlan(ctx, req) } + +// CreateJob sends the create index request to DataNode. +func (s *Server) CreateJob(ctx context.Context, req *workerpb.CreateJobRequest) (*commonpb.Status, error) { + return s.datanode.CreateJob(ctx, req) +} + +// QueryJobs queries index jobs statues +func (s *Server) QueryJobs(ctx context.Context, req *workerpb.QueryJobsRequest) (*workerpb.QueryJobsResponse, error) { + return s.datanode.QueryJobs(ctx, req) +} + +// DropJobs drops index build jobs +func (s *Server) DropJobs(ctx context.Context, req *workerpb.DropJobsRequest) (*commonpb.Status, error) { + return s.datanode.DropJobs(ctx, req) +} + +// GetJobStats gets job's statistics +func (s *Server) GetJobStats(ctx context.Context, req *workerpb.GetJobStatsRequest) (*workerpb.GetJobStatsResponse, error) { + return s.datanode.GetJobStats(ctx, req) +} + +func (s *Server) CreateJobV2(ctx context.Context, request *workerpb.CreateJobV2Request) (*commonpb.Status, error) { + return s.datanode.CreateJobV2(ctx, request) +} + +func (s *Server) QueryJobsV2(ctx context.Context, request *workerpb.QueryJobsV2Request) (*workerpb.QueryJobsV2Response, error) { + return s.datanode.QueryJobsV2(ctx, request) +} + +func (s *Server) DropJobsV2(ctx context.Context, request *workerpb.DropJobsV2Request) (*commonpb.Status, error) { + return s.datanode.DropJobsV2(ctx, request) +} diff --git a/internal/distributed/datanode/service_test.go b/internal/distributed/datanode/service_test.go index 75f6a9d32b..12a3327c5f 100644 --- a/internal/distributed/datanode/service_test.go +++ b/internal/distributed/datanode/service_test.go @@ -18,12 +18,11 @@ package grpcdatanode import ( "context" + "fmt" "testing" - "github.com/cockroachdb/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - clientv3 "go.etcd.io/etcd/client/v3" "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" @@ -31,161 +30,12 @@ import ( "github.com/milvus-io/milvus/internal/types" "github.com/milvus-io/milvus/pkg/v2/proto/datapb" "github.com/milvus-io/milvus/pkg/v2/proto/internalpb" + "github.com/milvus-io/milvus/pkg/v2/proto/workerpb" "github.com/milvus-io/milvus/pkg/v2/util/merr" + "github.com/milvus-io/milvus/pkg/v2/util/metricsinfo" "github.com/milvus-io/milvus/pkg/v2/util/paramtable" - "github.com/milvus-io/milvus/pkg/v2/util/typeutil" ) -// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -type MockDataNode struct { - nodeID typeutil.UniqueID - - stateCode commonpb.StateCode - states *milvuspb.ComponentStates - status *commonpb.Status - err error - initErr error - startErr error - stopErr error - regErr error - strResp *milvuspb.StringResponse - configResp *internalpb.ShowConfigurationsResponse - metricResp *milvuspb.GetMetricsResponse - resendResp *datapb.ResendSegmentStatsResponse - compactionResp *datapb.CompactionStateResponse -} - -func (m *MockDataNode) Init() error { - return m.initErr -} - -func (m *MockDataNode) Start() error { - return m.startErr -} - -func (m *MockDataNode) Stop() error { - return m.stopErr -} - -func (m *MockDataNode) Register() error { - return m.regErr -} - -func (m *MockDataNode) SetNodeID(id typeutil.UniqueID) { - m.nodeID = id -} - -func (m *MockDataNode) UpdateStateCode(code commonpb.StateCode) { - m.stateCode = code -} - -func (m *MockDataNode) GetStateCode() commonpb.StateCode { - return m.stateCode -} - -func (m *MockDataNode) SetAddress(address string) { -} - -func (m *MockDataNode) GetAddress() string { - return "" -} - -func (m *MockDataNode) GetNodeID() int64 { - return 2 -} - -func (m *MockDataNode) SetRootCoordClient(rc types.RootCoordClient) error { - return m.err -} - -func (m *MockDataNode) SetDataCoordClient(dc types.DataCoordClient) error { - return m.err -} - -func (m *MockDataNode) GetComponentStates(ctx context.Context, req *milvuspb.GetComponentStatesRequest) (*milvuspb.ComponentStates, error) { - return m.states, m.err -} - -func (m *MockDataNode) GetStatisticsChannel(ctx context.Context, req *internalpb.GetStatisticsChannelRequest) (*milvuspb.StringResponse, error) { - return m.strResp, m.err -} - -func (m *MockDataNode) WatchDmChannels(ctx context.Context, req *datapb.WatchDmChannelsRequest) (*commonpb.Status, error) { - return m.status, m.err -} - -func (m *MockDataNode) FlushSegments(ctx context.Context, req *datapb.FlushSegmentsRequest) (*commonpb.Status, error) { - return m.status, m.err -} - -func (m *MockDataNode) ShowConfigurations(ctx context.Context, req *internalpb.ShowConfigurationsRequest) (*internalpb.ShowConfigurationsResponse, error) { - return m.configResp, m.err -} - -func (m *MockDataNode) GetMetrics(ctx context.Context, request *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) { - return m.metricResp, m.err -} - -func (m *MockDataNode) CompactionV2(ctx context.Context, req *datapb.CompactionPlan) (*commonpb.Status, error) { - return m.status, m.err -} - -func (m *MockDataNode) GetCompactionState(ctx context.Context, req *datapb.CompactionStateRequest) (*datapb.CompactionStateResponse, error) { - return m.compactionResp, m.err -} - -func (m *MockDataNode) SetEtcdClient(client *clientv3.Client) { -} - -func (m *MockDataNode) ResendSegmentStats(ctx context.Context, req *datapb.ResendSegmentStatsRequest) (*datapb.ResendSegmentStatsResponse, error) { - return m.resendResp, m.err -} - -func (m *MockDataNode) SyncSegments(ctx context.Context, req *datapb.SyncSegmentsRequest) (*commonpb.Status, error) { - return m.status, m.err -} - -func (m *MockDataNode) FlushChannels(ctx context.Context, req *datapb.FlushChannelsRequest) (*commonpb.Status, error) { - return m.status, m.err -} - -func (m *MockDataNode) NotifyChannelOperation(ctx context.Context, req *datapb.ChannelOperationsRequest) (*commonpb.Status, error) { - return m.status, m.err -} - -func (m *MockDataNode) CheckChannelOperationProgress(ctx context.Context, req *datapb.ChannelWatchInfo) (*datapb.ChannelOperationProgressResponse, error) { - return &datapb.ChannelOperationProgressResponse{}, m.err -} - -func (m *MockDataNode) PreImport(ctx context.Context, req *datapb.PreImportRequest) (*commonpb.Status, error) { - return m.status, m.err -} - -func (m *MockDataNode) ImportV2(ctx context.Context, req *datapb.ImportRequest) (*commonpb.Status, error) { - return m.status, m.err -} - -func (m *MockDataNode) QueryPreImport(ctx context.Context, req *datapb.QueryPreImportRequest) (*datapb.QueryPreImportResponse, error) { - return &datapb.QueryPreImportResponse{}, m.err -} - -func (m *MockDataNode) QueryImport(ctx context.Context, req *datapb.QueryImportRequest) (*datapb.QueryImportResponse, error) { - return &datapb.QueryImportResponse{}, m.err -} - -func (m *MockDataNode) DropImport(ctx context.Context, req *datapb.DropImportRequest) (*commonpb.Status, error) { - return m.status, m.err -} - -func (m *MockDataNode) QuerySlot(ctx context.Context, req *datapb.QuerySlotRequest) (*datapb.QuerySlotResponse, error) { - return &datapb.QuerySlotResponse{}, m.err -} - -func (m *MockDataNode) DropCompactionPlan(ctx context.Context, req *datapb.DropCompactionPlanRequest) (*commonpb.Status, error) { - return m.status, m.err -} - -// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// func Test_NewServer(t *testing.T) { paramtable.Init() ctx := context.Background() @@ -226,7 +76,17 @@ func Test_NewServer(t *testing.T) { } t.Run("Run", func(t *testing.T) { - server.datanode = &MockDataNode{} + datanode := mocks.NewMockDataNode(t) + datanode.EXPECT().SetEtcdClient(mock.Anything).Return() + datanode.EXPECT().SetAddress(mock.Anything).Return() + datanode.EXPECT().SetRootCoordClient(mock.Anything).Return(nil) + datanode.EXPECT().SetDataCoordClient(mock.Anything).Return(nil) + datanode.EXPECT().UpdateStateCode(mock.Anything).Return() + datanode.EXPECT().Register().Return(nil) + datanode.EXPECT().Init().Return(nil) + datanode.EXPECT().Start().Return(nil) + datanode.EXPECT().GetStateCode().Return(commonpb.StateCode_Healthy) + server.datanode = datanode err = server.Prepare() assert.NoError(t, err) err = server.Run() @@ -234,104 +94,108 @@ func Test_NewServer(t *testing.T) { }) t.Run("GetComponentStates", func(t *testing.T) { - server.datanode = &MockDataNode{ - states: &milvuspb.ComponentStates{}, - } + datanode := mocks.NewMockDataNode(t) + datanode.EXPECT().GetComponentStates(mock.Anything, mock.Anything). + Return(&milvuspb.ComponentStates{State: &milvuspb.ComponentInfo{StateCode: commonpb.StateCode_Healthy}}, nil) + server.datanode = datanode states, err := server.GetComponentStates(ctx, nil) assert.NoError(t, err) assert.NotNil(t, states) }) t.Run("GetStatisticsChannel", func(t *testing.T) { - server.datanode = &MockDataNode{ - strResp: &milvuspb.StringResponse{}, - } + datanode := mocks.NewMockDataNode(t) + datanode.EXPECT().GetStatisticsChannel(mock.Anything, mock.Anything). + Return(&milvuspb.StringResponse{Status: merr.Success()}, nil) + server.datanode = datanode states, err := server.GetStatisticsChannel(ctx, nil) assert.NoError(t, err) assert.NotNil(t, states) }) t.Run("WatchDmChannels", func(t *testing.T) { - server.datanode = &MockDataNode{ - status: &commonpb.Status{}, - } + datanode := mocks.NewMockDataNode(t) + datanode.EXPECT().WatchDmChannels(mock.Anything, mock.Anything).Return(merr.Success(), nil) + server.datanode = datanode states, err := server.WatchDmChannels(ctx, nil) assert.NoError(t, err) assert.NotNil(t, states) }) t.Run("FlushSegments", func(t *testing.T) { - server.datanode = &MockDataNode{ - status: &commonpb.Status{}, - } + datanode := mocks.NewMockDataNode(t) + datanode.EXPECT().GetStateCode().Return(commonpb.StateCode_Healthy) + datanode.EXPECT().FlushSegments(mock.Anything, mock.Anything).Return(merr.Success(), nil) + server.datanode = datanode states, err := server.FlushSegments(ctx, nil) assert.NoError(t, err) assert.NotNil(t, states) }) t.Run("ShowConfigurations", func(t *testing.T) { - server.datanode = &MockDataNode{ - configResp: &internalpb.ShowConfigurationsResponse{}, - } + datanode := mocks.NewMockDataNode(t) + datanode.EXPECT().ShowConfigurations(mock.Anything, mock.Anything).Return(&internalpb.ShowConfigurationsResponse{}, nil) + server.datanode = datanode resp, err := server.ShowConfigurations(ctx, nil) assert.NoError(t, err) assert.NotNil(t, resp) }) t.Run("GetMetrics", func(t *testing.T) { - server.datanode = &MockDataNode{ - metricResp: &milvuspb.GetMetricsResponse{}, - } + datanode := mocks.NewMockDataNode(t) + datanode.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(&milvuspb.GetMetricsResponse{}, nil) + server.datanode = datanode resp, err := server.GetMetrics(ctx, nil) assert.NoError(t, err) assert.NotNil(t, resp) }) t.Run("Compaction", func(t *testing.T) { - server.datanode = &MockDataNode{ - status: &commonpb.Status{}, - } + datanode := mocks.NewMockDataNode(t) + datanode.EXPECT().CompactionV2(mock.Anything, mock.Anything).Return(merr.Success(), nil) + server.datanode = datanode resp, err := server.CompactionV2(ctx, nil) assert.NoError(t, err) assert.NotNil(t, resp) }) t.Run("ResendSegmentStats", func(t *testing.T) { - server.datanode = &MockDataNode{ - resendResp: &datapb.ResendSegmentStatsResponse{}, - } + datanode := mocks.NewMockDataNode(t) + datanode.EXPECT().ResendSegmentStats(mock.Anything, mock.Anything).Return(&datapb.ResendSegmentStatsResponse{}, nil) + server.datanode = datanode resp, err := server.ResendSegmentStats(ctx, nil) assert.NoError(t, err) assert.NotNil(t, resp) }) t.Run("NotifyChannelOperation", func(t *testing.T) { - server.datanode = &MockDataNode{ - status: &commonpb.Status{}, - } + datanode := mocks.NewMockDataNode(t) + datanode.EXPECT().NotifyChannelOperation(mock.Anything, mock.Anything).Return(merr.Success(), nil) + server.datanode = datanode resp, err := server.NotifyChannelOperation(ctx, nil) assert.NoError(t, err) assert.NotNil(t, resp) }) t.Run("CheckChannelOperationProgress", func(t *testing.T) { - server.datanode = &MockDataNode{ - status: &commonpb.Status{}, - } + datanode := mocks.NewMockDataNode(t) + datanode.EXPECT().CheckChannelOperationProgress(mock.Anything, mock.Anything).Return(&datapb.ChannelOperationProgressResponse{}, nil) + server.datanode = datanode resp, err := server.CheckChannelOperationProgress(ctx, nil) assert.NoError(t, err) assert.NotNil(t, resp) }) t.Run("DropCompactionPlans", func(t *testing.T) { - server.datanode = &MockDataNode{ - status: &commonpb.Status{}, - } + datanode := mocks.NewMockDataNode(t) + datanode.EXPECT().DropCompactionPlan(mock.Anything, mock.Anything).Return(merr.Success(), nil) + server.datanode = datanode resp, err := server.DropCompactionPlan(ctx, nil) assert.NoError(t, err) assert.NotNil(t, resp) }) + server.datanode.(*mocks.MockDataNode).EXPECT().Stop().Return(nil) err = server.Stop() assert.NoError(t, err) } @@ -376,26 +240,205 @@ func Test_Run(t *testing.T) { return mockDataCoord, nil } - server.datanode = &MockDataNode{ - regErr: errors.New("error"), - } + datanode := mocks.NewMockDataNode(t) + datanode.EXPECT().SetEtcdClient(mock.Anything).Return() + datanode.EXPECT().SetAddress(mock.Anything).Return() + datanode.EXPECT().SetRootCoordClient(mock.Anything).Return(nil) + datanode.EXPECT().SetDataCoordClient(mock.Anything).Return(nil) + datanode.EXPECT().UpdateStateCode(mock.Anything).Return() + datanode.EXPECT().Init().Return(fmt.Errorf("mock err")) + server.datanode = datanode err = server.Prepare() assert.NoError(t, err) err = server.Run() assert.Error(t, err) - server.datanode = &MockDataNode{ - startErr: errors.New("error"), - } + datanode = mocks.NewMockDataNode(t) + datanode.EXPECT().SetEtcdClient(mock.Anything).Return() + datanode.EXPECT().SetAddress(mock.Anything).Return() + datanode.EXPECT().SetRootCoordClient(mock.Anything).Return(nil) + datanode.EXPECT().SetDataCoordClient(mock.Anything).Return(nil) + datanode.EXPECT().UpdateStateCode(mock.Anything).Return() + datanode.EXPECT().Register().Return(nil) + datanode.EXPECT().Init().Return(nil) + datanode.EXPECT().Start().Return(nil) + datanode.EXPECT().GetStateCode().Return(commonpb.StateCode_Healthy) + server.datanode = datanode err = server.Run() - assert.Error(t, err) + assert.NoError(t, err) +} - server.datanode = &MockDataNode{ - initErr: errors.New("error"), +func TestIndexService(t *testing.T) { + paramtable.Init() + ctx := context.Background() + server, err := NewServer(ctx, nil) + assert.NoError(t, err) + assert.NotNil(t, server) + + mockRootCoord := mocks.NewMockRootCoordClient(t) + mockRootCoord.EXPECT().GetComponentStates(mock.Anything, mock.Anything, mock.Anything).Return(&milvuspb.ComponentStates{ + State: &milvuspb.ComponentInfo{ + StateCode: commonpb.StateCode_Healthy, + }, + Status: merr.Success(), + SubcomponentStates: []*milvuspb.ComponentInfo{ + { + StateCode: commonpb.StateCode_Healthy, + }, + }, + }, nil) + server.newRootCoordClient = func() (types.RootCoordClient, error) { + return mockRootCoord, nil + } + + mockDataCoord := mocks.NewMockDataCoordClient(t) + mockDataCoord.EXPECT().GetComponentStates(mock.Anything, mock.Anything, mock.Anything).Return(&milvuspb.ComponentStates{ + State: &milvuspb.ComponentInfo{ + StateCode: commonpb.StateCode_Healthy, + }, + Status: merr.Success(), + SubcomponentStates: []*milvuspb.ComponentInfo{ + { + StateCode: commonpb.StateCode_Healthy, + }, + }, + }, nil) + server.newDataCoordClient = func() (types.DataCoordClient, error) { + return mockDataCoord, nil } + + dn := mocks.NewMockDataNode(t) + dn.EXPECT().SetEtcdClient(mock.Anything).Return() + dn.EXPECT().SetAddress(mock.Anything).Return() + dn.EXPECT().SetRootCoordClient(mock.Anything).Return(nil) + dn.EXPECT().SetDataCoordClient(mock.Anything).Return(nil) + dn.EXPECT().UpdateStateCode(mock.Anything).Return() + dn.EXPECT().Register().Return(nil) + dn.EXPECT().Init().Return(nil) + dn.EXPECT().Start().Return(nil) + dn.EXPECT().GetStateCode().Return(commonpb.StateCode_Healthy) + server.datanode = dn + err = server.Prepare() + assert.NoError(t, err) err = server.Run() - assert.Error(t, err) + assert.NoError(t, err) + + t.Run("GetComponentStates", func(t *testing.T) { + dn.EXPECT().GetComponentStates(mock.Anything, mock.Anything).Return(&milvuspb.ComponentStates{ + State: &milvuspb.ComponentInfo{ + StateCode: commonpb.StateCode_Healthy, + }, + }, nil) + req := &milvuspb.GetComponentStatesRequest{} + states, err := server.GetComponentStates(ctx, req) + assert.NoError(t, err) + assert.Equal(t, commonpb.StateCode_Healthy, states.State.StateCode) + }) + + t.Run("GetStatisticsChannel", func(t *testing.T) { + dn.EXPECT().GetStatisticsChannel(mock.Anything, mock.Anything).Return(&milvuspb.StringResponse{ + Status: merr.Success(), + }, nil) + req := &internalpb.GetStatisticsChannelRequest{} + resp, err := server.GetStatisticsChannel(ctx, req) + assert.NoError(t, err) + assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode()) + }) + + t.Run("CreateJob", func(t *testing.T) { + dn.EXPECT().CreateJob(mock.Anything, mock.Anything).Return(merr.Success(), nil) + req := &workerpb.CreateJobRequest{ + ClusterID: "", + BuildID: 0, + IndexID: 0, + DataPaths: []string{}, + } + resp, err := server.CreateJob(ctx, req) + assert.NoError(t, err) + assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode) + }) + + t.Run("QueryJob", func(t *testing.T) { + dn.EXPECT().QueryJobs(mock.Anything, mock.Anything).Return(&workerpb.QueryJobsResponse{ + Status: merr.Success(), + }, nil) + req := &workerpb.QueryJobsRequest{} + resp, err := server.QueryJobs(ctx, req) + assert.NoError(t, err) + assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode()) + }) + + t.Run("DropJobs", func(t *testing.T) { + dn.EXPECT().DropJobs(mock.Anything, mock.Anything).Return(merr.Success(), nil) + req := &workerpb.DropJobsRequest{} + resp, err := server.DropJobs(ctx, req) + assert.NoError(t, err) + assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode) + }) + + t.Run("ShowConfigurations", func(t *testing.T) { + dn.EXPECT().ShowConfigurations(mock.Anything, mock.Anything).Return(&internalpb.ShowConfigurationsResponse{ + Status: merr.Success(), + }, nil) + req := &internalpb.ShowConfigurationsRequest{ + Pattern: "", + } + resp, err := server.ShowConfigurations(ctx, req) + assert.NoError(t, err) + assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode()) + }) + + t.Run("GetMetrics", func(t *testing.T) { + dn.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(&milvuspb.GetMetricsResponse{ + Status: merr.Success(), + }, nil) + req, err := metricsinfo.ConstructRequestByMetricType(metricsinfo.SystemInfoMetrics) + assert.NoError(t, err) + resp, err := server.GetMetrics(ctx, req) + assert.NoError(t, err) + assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode()) + }) + + t.Run("GetTaskSlots", func(t *testing.T) { + dn.EXPECT().GetJobStats(mock.Anything, mock.Anything).Return(&workerpb.GetJobStatsResponse{ + Status: merr.Success(), + }, nil) + req := &workerpb.GetJobStatsRequest{} + resp, err := server.GetJobStats(ctx, req) + assert.NoError(t, err) + assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode()) + }) + + t.Run("CreateJobV2", func(t *testing.T) { + dn.EXPECT().CreateJobV2(mock.Anything, mock.Anything).Return(merr.Success(), nil) + req := &workerpb.CreateJobV2Request{} + resp, err := server.CreateJobV2(ctx, req) + assert.NoError(t, err) + assert.Equal(t, commonpb.ErrorCode_Success, resp.GetErrorCode()) + }) + + t.Run("QueryJobsV2", func(t *testing.T) { + dn.EXPECT().QueryJobsV2(mock.Anything, mock.Anything).Return(&workerpb.QueryJobsV2Response{ + Status: merr.Success(), + }, nil) + req := &workerpb.QueryJobsV2Request{} + resp, err := server.QueryJobsV2(ctx, req) + assert.NoError(t, err) + assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode()) + }) + + t.Run("DropJobsV2", func(t *testing.T) { + dn.EXPECT().DropJobsV2(mock.Anything, mock.Anything).Return(merr.Success(), nil) + req := &workerpb.DropJobsV2Request{} + resp, err := server.DropJobsV2(ctx, req) + assert.NoError(t, err) + assert.Equal(t, commonpb.ErrorCode_Success, resp.GetErrorCode()) + }) + + server.datanode.(*mocks.MockDataNode).EXPECT().Stop().Return(nil) + err = server.Stop() + assert.NoError(t, err) } diff --git a/internal/distributed/indexnode/client/client.go b/internal/distributed/indexnode/client/client.go deleted file mode 100644 index 8d6037c732..0000000000 --- a/internal/distributed/indexnode/client/client.go +++ /dev/null @@ -1,194 +0,0 @@ -// 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. - -package grpcindexnodeclient - -import ( - "context" - "fmt" - - "go.uber.org/zap" - "google.golang.org/grpc" - - "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" - "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" - "github.com/milvus-io/milvus/internal/distributed/utils" - "github.com/milvus-io/milvus/internal/types" - "github.com/milvus-io/milvus/internal/util/grpcclient" - "github.com/milvus-io/milvus/internal/util/sessionutil" - "github.com/milvus-io/milvus/pkg/v2/log" - "github.com/milvus-io/milvus/pkg/v2/proto/internalpb" - "github.com/milvus-io/milvus/pkg/v2/proto/workerpb" - "github.com/milvus-io/milvus/pkg/v2/util/commonpbutil" - "github.com/milvus-io/milvus/pkg/v2/util/funcutil" - "github.com/milvus-io/milvus/pkg/v2/util/paramtable" - "github.com/milvus-io/milvus/pkg/v2/util/typeutil" -) - -var Params *paramtable.ComponentParam = paramtable.Get() - -// Client is the grpc client of IndexNode. -type Client struct { - grpcClient grpcclient.GrpcClient[workerpb.IndexNodeClient] - addr string - sess *sessionutil.Session -} - -// NewClient creates a new IndexNode client. -func NewClient(ctx context.Context, addr string, nodeID int64, encryption bool) (types.IndexNodeClient, error) { - if addr == "" { - return nil, fmt.Errorf("address is empty") - } - sess := sessionutil.NewSession(ctx) - if sess == nil { - err := fmt.Errorf("new session error, maybe can not connect to etcd") - log.Ctx(ctx).Debug("IndexNodeClient New Etcd Session failed", zap.Error(err)) - return nil, err - } - config := &Params.IndexNodeGrpcClientCfg - client := &Client{ - addr: addr, - grpcClient: grpcclient.NewClientBase[workerpb.IndexNodeClient](config, "milvus.proto.index.IndexNode"), - sess: sess, - } - // node shall specify node id - client.grpcClient.SetRole(fmt.Sprintf("%s-%d", typeutil.IndexNodeRole, nodeID)) - client.grpcClient.SetGetAddrFunc(client.getAddr) - client.grpcClient.SetNewGrpcClientFunc(client.newGrpcClient) - client.grpcClient.SetNodeID(nodeID) - client.grpcClient.SetSession(sess) - if encryption { - client.grpcClient.EnableEncryption() - } - if Params.InternalTLSCfg.InternalTLSEnabled.GetAsBool() { - client.grpcClient.EnableEncryption() - cp, err := utils.CreateCertPoolforClient(Params.InternalTLSCfg.InternalTLSCaPemPath.GetValue(), "IndexNode") - if err != nil { - log.Ctx(ctx).Error("Failed to create cert pool for IndexNode client") - return nil, err - } - client.grpcClient.SetInternalTLSCertPool(cp) - client.grpcClient.SetInternalTLSServerName(Params.InternalTLSCfg.InternalTLSSNI.GetValue()) - } - return client, nil -} - -// Close stops IndexNode's grpc client. -func (c *Client) Close() error { - return c.grpcClient.Close() -} - -func (c *Client) newGrpcClient(cc *grpc.ClientConn) workerpb.IndexNodeClient { - return workerpb.NewIndexNodeClient(cc) -} - -func (c *Client) getAddr() (string, error) { - return c.addr, nil -} - -func wrapGrpcCall[T any](ctx context.Context, c *Client, call func(indexClient workerpb.IndexNodeClient) (*T, error)) (*T, error) { - ret, err := c.grpcClient.ReCall(ctx, func(client workerpb.IndexNodeClient) (any, error) { - if !funcutil.CheckCtxValid(ctx) { - return nil, ctx.Err() - } - return call(client) - }) - if err != nil || ret == nil { - return nil, err - } - return ret.(*T), err -} - -// GetComponentStates gets the component states of IndexNode. -func (c *Client) GetComponentStates(ctx context.Context, req *milvuspb.GetComponentStatesRequest, opts ...grpc.CallOption) (*milvuspb.ComponentStates, error) { - return wrapGrpcCall(ctx, c, func(client workerpb.IndexNodeClient) (*milvuspb.ComponentStates, error) { - return client.GetComponentStates(ctx, &milvuspb.GetComponentStatesRequest{}) - }) -} - -func (c *Client) GetStatisticsChannel(ctx context.Context, req *internalpb.GetStatisticsChannelRequest, opts ...grpc.CallOption) (*milvuspb.StringResponse, error) { - return wrapGrpcCall(ctx, c, func(client workerpb.IndexNodeClient) (*milvuspb.StringResponse, error) { - return client.GetStatisticsChannel(ctx, &internalpb.GetStatisticsChannelRequest{}) - }) -} - -// CreateJob sends the build index request to IndexNode. -func (c *Client) CreateJob(ctx context.Context, req *workerpb.CreateJobRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { - return wrapGrpcCall(ctx, c, func(client workerpb.IndexNodeClient) (*commonpb.Status, error) { - return client.CreateJob(ctx, req) - }) -} - -// QueryJobs query the task info of the index task. -func (c *Client) QueryJobs(ctx context.Context, req *workerpb.QueryJobsRequest, opts ...grpc.CallOption) (*workerpb.QueryJobsResponse, error) { - return wrapGrpcCall(ctx, c, func(client workerpb.IndexNodeClient) (*workerpb.QueryJobsResponse, error) { - return client.QueryJobs(ctx, req) - }) -} - -// DropJobs query the task info of the index task. -func (c *Client) DropJobs(ctx context.Context, req *workerpb.DropJobsRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { - return wrapGrpcCall(ctx, c, func(client workerpb.IndexNodeClient) (*commonpb.Status, error) { - return client.DropJobs(ctx, req) - }) -} - -// GetJobStats query the task info of the index task. -func (c *Client) GetJobStats(ctx context.Context, req *workerpb.GetJobStatsRequest, opts ...grpc.CallOption) (*workerpb.GetJobStatsResponse, error) { - return wrapGrpcCall(ctx, c, func(client workerpb.IndexNodeClient) (*workerpb.GetJobStatsResponse, error) { - return client.GetJobStats(ctx, req) - }) -} - -// ShowConfigurations gets specified configurations para of IndexNode -func (c *Client) ShowConfigurations(ctx context.Context, req *internalpb.ShowConfigurationsRequest, opts ...grpc.CallOption) (*internalpb.ShowConfigurationsResponse, error) { - req = typeutil.Clone(req) - commonpbutil.UpdateMsgBase( - req.GetBase(), - commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID())) - return wrapGrpcCall(ctx, c, func(client workerpb.IndexNodeClient) (*internalpb.ShowConfigurationsResponse, error) { - return client.ShowConfigurations(ctx, req) - }) -} - -// GetMetrics gets the metrics info of IndexNode. -func (c *Client) GetMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest, opts ...grpc.CallOption) (*milvuspb.GetMetricsResponse, error) { - req = typeutil.Clone(req) - commonpbutil.UpdateMsgBase( - req.GetBase(), - commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID())) - return wrapGrpcCall(ctx, c, func(client workerpb.IndexNodeClient) (*milvuspb.GetMetricsResponse, error) { - return client.GetMetrics(ctx, req) - }) -} - -func (c *Client) CreateJobV2(ctx context.Context, req *workerpb.CreateJobV2Request, opts ...grpc.CallOption) (*commonpb.Status, error) { - return wrapGrpcCall(ctx, c, func(client workerpb.IndexNodeClient) (*commonpb.Status, error) { - return client.CreateJobV2(ctx, req) - }) -} - -func (c *Client) QueryJobsV2(ctx context.Context, req *workerpb.QueryJobsV2Request, opts ...grpc.CallOption) (*workerpb.QueryJobsV2Response, error) { - return wrapGrpcCall(ctx, c, func(client workerpb.IndexNodeClient) (*workerpb.QueryJobsV2Response, error) { - return client.QueryJobsV2(ctx, req) - }) -} - -func (c *Client) DropJobsV2(ctx context.Context, req *workerpb.DropJobsV2Request, opt ...grpc.CallOption) (*commonpb.Status, error) { - return wrapGrpcCall(ctx, c, func(client workerpb.IndexNodeClient) (*commonpb.Status, error) { - return client.DropJobsV2(ctx, req) - }) -} diff --git a/internal/distributed/indexnode/client/client_test.go b/internal/distributed/indexnode/client/client_test.go deleted file mode 100644 index afed40c903..0000000000 --- a/internal/distributed/indexnode/client/client_test.go +++ /dev/null @@ -1,179 +0,0 @@ -// 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. - -package grpcindexnodeclient - -import ( - "context" - "math/rand" - "os" - "strings" - "testing" - "time" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" - "go.uber.org/zap" - - "github.com/milvus-io/milvus/internal/mocks" - "github.com/milvus-io/milvus/pkg/v2/log" - "github.com/milvus-io/milvus/pkg/v2/proto/internalpb" - "github.com/milvus-io/milvus/pkg/v2/proto/workerpb" - "github.com/milvus-io/milvus/pkg/v2/util/etcd" - "github.com/milvus-io/milvus/pkg/v2/util/metricsinfo" - "github.com/milvus-io/milvus/pkg/v2/util/paramtable" -) - -func TestMain(m *testing.M) { - // init embed etcd - embedetcdServer, tempDir, err := etcd.StartTestEmbedEtcdServer() - if err != nil { - log.Fatal("failed to start embed etcd server", zap.Error(err)) - } - defer os.RemoveAll(tempDir) - defer embedetcdServer.Close() - - addrs := etcd.GetEmbedEtcdEndpoints(embedetcdServer) - - paramtable.Init() - paramtable.Get().Save(Params.EtcdCfg.Endpoints.Key, strings.Join(addrs, ",")) - - rand.Seed(time.Now().UnixNano()) - os.Exit(m.Run()) -} - -func Test_NewClient(t *testing.T) { - ctx := context.Background() - client, err := NewClient(ctx, "", 1, false) - assert.Nil(t, client) - assert.Error(t, err) - - client, err = NewClient(ctx, "localhost:1234", 1, false) - assert.NotNil(t, client) - assert.NoError(t, err) - - err = client.Close() - assert.NoError(t, err) -} - -func TestIndexNodeClient(t *testing.T) { - ctx := context.Background() - client, err := NewClient(ctx, "localhost:1234", 1, false) - assert.NoError(t, err) - assert.NotNil(t, client) - - mockIN := mocks.NewMockIndexNodeClient(t) - - mockGrpcClient := mocks.NewMockGrpcClient[workerpb.IndexNodeClient](t) - mockGrpcClient.EXPECT().Close().Return(nil) - mockGrpcClient.EXPECT().ReCall(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, f func(nodeClient workerpb.IndexNodeClient) (interface{}, error)) (interface{}, error) { - return f(mockIN) - }) - client.(*Client).grpcClient = mockGrpcClient - - t.Run("GetComponentStates", func(t *testing.T) { - mockIN.EXPECT().GetComponentStates(mock.Anything, mock.Anything).Return(nil, nil) - _, err := client.GetComponentStates(ctx, nil) - assert.NoError(t, err) - }) - - t.Run("GetStatisticsChannel", func(t *testing.T) { - mockIN.EXPECT().GetStatisticsChannel(mock.Anything, mock.Anything).Return(nil, nil) - _, err := client.GetStatisticsChannel(ctx, nil) - assert.NoError(t, err) - }) - - t.Run("CreatJob", func(t *testing.T) { - mockIN.EXPECT().CreateJob(mock.Anything, mock.Anything).Return(nil, nil) - - req := &workerpb.CreateJobRequest{ - ClusterID: "0", - BuildID: 0, - } - _, err := client.CreateJob(ctx, req) - assert.NoError(t, err) - }) - - t.Run("QueryJob", func(t *testing.T) { - mockIN.EXPECT().QueryJobs(mock.Anything, mock.Anything).Return(nil, nil) - - req := &workerpb.QueryJobsRequest{} - _, err := client.QueryJobs(ctx, req) - assert.NoError(t, err) - }) - - t.Run("DropJob", func(t *testing.T) { - mockIN.EXPECT().DropJobs(mock.Anything, mock.Anything).Return(nil, nil) - - req := &workerpb.DropJobsRequest{} - _, err := client.DropJobs(ctx, req) - assert.NoError(t, err) - }) - - t.Run("ShowConfigurations", func(t *testing.T) { - mockIN.EXPECT().ShowConfigurations(mock.Anything, mock.Anything).Return(nil, nil) - - req := &internalpb.ShowConfigurationsRequest{ - Pattern: "", - } - _, err := client.ShowConfigurations(ctx, req) - assert.NoError(t, err) - }) - - t.Run("GetMetrics", func(t *testing.T) { - mockIN.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(nil, nil) - - req, err := metricsinfo.ConstructRequestByMetricType(metricsinfo.SystemInfoMetrics) - assert.NoError(t, err) - _, err = client.GetMetrics(ctx, req) - assert.NoError(t, err) - }) - - t.Run("GetJobStats", func(t *testing.T) { - mockIN.EXPECT().GetJobStats(mock.Anything, mock.Anything).Return(nil, nil) - - req := &workerpb.GetJobStatsRequest{} - _, err := client.GetJobStats(ctx, req) - assert.NoError(t, err) - }) - - t.Run("CreateJobV2", func(t *testing.T) { - mockIN.EXPECT().CreateJobV2(mock.Anything, mock.Anything).Return(nil, nil) - - req := &workerpb.CreateJobV2Request{} - _, err := client.CreateJobV2(ctx, req) - assert.NoError(t, err) - }) - - t.Run("QueryJobsV2", func(t *testing.T) { - mockIN.EXPECT().QueryJobsV2(mock.Anything, mock.Anything).Return(nil, nil) - - req := &workerpb.QueryJobsV2Request{} - _, err := client.QueryJobsV2(ctx, req) - assert.NoError(t, err) - }) - - t.Run("DropJobsV2", func(t *testing.T) { - mockIN.EXPECT().DropJobsV2(mock.Anything, mock.Anything).Return(nil, nil) - - req := &workerpb.DropJobsV2Request{} - _, err := client.DropJobsV2(ctx, req) - assert.NoError(t, err) - }) - - err = client.Close() - assert.NoError(t, err) -} diff --git a/internal/distributed/indexnode/service.go b/internal/distributed/indexnode/service.go deleted file mode 100644 index f0f02af630..0000000000 --- a/internal/distributed/indexnode/service.go +++ /dev/null @@ -1,329 +0,0 @@ -// 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. - -package grpcindexnode - -import ( - "context" - "strconv" - "sync" - "time" - - grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" - clientv3 "go.etcd.io/etcd/client/v3" - "go.uber.org/atomic" - "go.uber.org/zap" - "google.golang.org/grpc" - "google.golang.org/grpc/keepalive" - - "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" - "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" - "github.com/milvus-io/milvus/internal/distributed/utils" - "github.com/milvus-io/milvus/internal/indexnode" - "github.com/milvus-io/milvus/internal/types" - "github.com/milvus-io/milvus/internal/util/dependency" - _ "github.com/milvus-io/milvus/internal/util/grpcclient" - "github.com/milvus-io/milvus/pkg/v2/log" - "github.com/milvus-io/milvus/pkg/v2/proto/internalpb" - "github.com/milvus-io/milvus/pkg/v2/proto/workerpb" - "github.com/milvus-io/milvus/pkg/v2/tracer" - "github.com/milvus-io/milvus/pkg/v2/util/etcd" - "github.com/milvus-io/milvus/pkg/v2/util/funcutil" - "github.com/milvus-io/milvus/pkg/v2/util/interceptor" - "github.com/milvus-io/milvus/pkg/v2/util/logutil" - "github.com/milvus-io/milvus/pkg/v2/util/netutil" - "github.com/milvus-io/milvus/pkg/v2/util/paramtable" -) - -// Server is the grpc wrapper of IndexNode. -type Server struct { - indexnode types.IndexNodeComponent - - grpcServer *grpc.Server - listener *netutil.NetListener - grpcErrChan chan error - - serverID atomic.Int64 - - loopCtx context.Context - loopCancel func() - grpcWG sync.WaitGroup - - etcdCli *clientv3.Client -} - -func (s *Server) Prepare() error { - listener, err := netutil.NewListener( - netutil.OptIP(paramtable.Get().IndexNodeGrpcServerCfg.IP), - netutil.OptHighPriorityToUsePort(paramtable.Get().IndexNodeGrpcServerCfg.Port.GetAsInt()), - ) - if err != nil { - log.Ctx(s.loopCtx).Warn("IndexNode fail to create net listener", zap.Error(err)) - return err - } - s.listener = listener - log.Ctx(s.loopCtx).Info("IndexNode listen on", zap.String("address", listener.Addr().String()), zap.Int("port", listener.Port())) - paramtable.Get().Save( - paramtable.Get().IndexNodeGrpcServerCfg.Port.Key, - strconv.FormatInt(int64(listener.Port()), 10)) - return nil -} - -// Run initializes and starts IndexNode's grpc service. -func (s *Server) Run() error { - if err := s.init(); err != nil { - return err - } - log.Ctx(s.loopCtx).Debug("IndexNode init done ...") - if err := s.start(); err != nil { - return err - } - log.Ctx(s.loopCtx).Debug("IndexNode start done ...") - return nil -} - -// startGrpcLoop starts the grep loop of IndexNode component. -func (s *Server) startGrpcLoop() { - defer s.grpcWG.Done() - - Params := ¶mtable.Get().IndexNodeGrpcServerCfg - - ctx, cancel := context.WithCancel(s.loopCtx) - defer cancel() - - kaep := keepalive.EnforcementPolicy{ - MinTime: 5 * time.Second, // If a client pings more than once every 5 seconds, terminate the connection - PermitWithoutStream: true, // Allow pings even when there are no active streams - } - - kasp := keepalive.ServerParameters{ - Time: 60 * time.Second, // Ping the client if it is idle for 60 seconds to ensure the connection is still active - Timeout: 10 * time.Second, // Wait 10 second for the ping ack before assuming the connection is dead - } - - grpcOpts := []grpc.ServerOption{ - grpc.KeepaliveEnforcementPolicy(kaep), - grpc.KeepaliveParams(kasp), - grpc.MaxRecvMsgSize(Params.ServerMaxRecvSize.GetAsInt()), - grpc.MaxSendMsgSize(Params.ServerMaxSendSize.GetAsInt()), - grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer( - logutil.UnaryTraceLoggerInterceptor, - interceptor.ClusterValidationUnaryServerInterceptor(), - interceptor.ServerIDValidationUnaryServerInterceptor(func() int64 { - if s.serverID.Load() == 0 { - s.serverID.Store(paramtable.GetNodeID()) - } - return s.serverID.Load() - }), - )), - grpc.StreamInterceptor(grpc_middleware.ChainStreamServer( - logutil.StreamTraceLoggerInterceptor, - interceptor.ClusterValidationStreamServerInterceptor(), - interceptor.ServerIDValidationStreamServerInterceptor(func() int64 { - if s.serverID.Load() == 0 { - s.serverID.Store(paramtable.GetNodeID()) - } - return s.serverID.Load() - }), - )), - grpc.StatsHandler(tracer.GetDynamicOtelGrpcServerStatsHandler()), - } - - grpcOpts = append(grpcOpts, utils.EnableInternalTLS("IndexNode")) - s.grpcServer = grpc.NewServer(grpcOpts...) - workerpb.RegisterIndexNodeServer(s.grpcServer, s) - go funcutil.CheckGrpcReady(ctx, s.grpcErrChan) - if err := s.grpcServer.Serve(s.listener); err != nil { - s.grpcErrChan <- err - } -} - -// init initializes IndexNode's grpc service. -func (s *Server) init() error { - etcdConfig := ¶mtable.Get().EtcdCfg - var err error - log := log.Ctx(s.loopCtx) - - defer func() { - if err != nil { - err = s.Stop() - if err != nil { - log.Error("IndexNode Init failed, and Stop failed") - } - } - }() - - s.grpcWG.Add(1) - go s.startGrpcLoop() - // wait for grpc server loop start - err = <-s.grpcErrChan - if err != nil { - log.Error("IndexNode", zap.Error(err)) - return err - } - - var etcdCli *clientv3.Client - etcdCli, err = etcd.CreateEtcdClient( - etcdConfig.UseEmbedEtcd.GetAsBool(), - etcdConfig.EtcdEnableAuth.GetAsBool(), - etcdConfig.EtcdAuthUserName.GetValue(), - etcdConfig.EtcdAuthPassword.GetValue(), - etcdConfig.EtcdUseSSL.GetAsBool(), - etcdConfig.Endpoints.GetAsStrings(), - etcdConfig.EtcdTLSCert.GetValue(), - etcdConfig.EtcdTLSKey.GetValue(), - etcdConfig.EtcdTLSCACert.GetValue(), - etcdConfig.EtcdTLSMinVersion.GetValue()) - if err != nil { - log.Debug("IndexNode connect to etcd failed", zap.Error(err)) - return err - } - s.etcdCli = etcdCli - s.indexnode.SetEtcdClient(etcdCli) - s.indexnode.SetAddress(s.listener.Address()) - err = s.indexnode.Init() - if err != nil { - log.Error("IndexNode Init failed", zap.Error(err)) - return err - } - - return nil -} - -// start starts IndexNode's grpc service. -func (s *Server) start() error { - log := log.Ctx(s.loopCtx) - err := s.indexnode.Start() - if err != nil { - return err - } - err = s.indexnode.Register() - if err != nil { - log.Error("IndexNode Register etcd failed", zap.Error(err)) - return err - } - log.Debug("IndexNode Register etcd success") - return nil -} - -// Stop stops IndexNode's grpc service. -func (s *Server) Stop() (err error) { - logger := log.Ctx(s.loopCtx) - if s.listener != nil { - logger = logger.With(zap.String("address", s.listener.Address())) - } - logger.Info("IndexNode stopping") - defer func() { - logger.Info("IndexNode stopped", zap.Error(err)) - }() - - if s.indexnode != nil { - err := s.indexnode.Stop() - if err != nil { - log.Error("failed to close indexnode", zap.Error(err)) - return err - } - } - if s.etcdCli != nil { - defer s.etcdCli.Close() - } - if s.grpcServer != nil { - utils.GracefulStopGRPCServer(s.grpcServer) - } - s.grpcWG.Wait() - - s.loopCancel() - if s.listener != nil { - s.listener.Close() - } - return nil -} - -// setServer sets the IndexNode's instance. -func (s *Server) setServer(indexNode types.IndexNodeComponent) error { - s.indexnode = indexNode - return nil -} - -// SetEtcdClient sets the etcd client for QueryNode component. -func (s *Server) SetEtcdClient(etcdCli *clientv3.Client) { - s.indexnode.SetEtcdClient(etcdCli) -} - -// GetComponentStates gets the component states of IndexNode. -func (s *Server) GetComponentStates(ctx context.Context, req *milvuspb.GetComponentStatesRequest) (*milvuspb.ComponentStates, error) { - return s.indexnode.GetComponentStates(ctx, req) -} - -// GetStatisticsChannel gets the statistics channel of IndexNode. -func (s *Server) GetStatisticsChannel(ctx context.Context, req *internalpb.GetStatisticsChannelRequest) (*milvuspb.StringResponse, error) { - return s.indexnode.GetStatisticsChannel(ctx, req) -} - -// CreateJob sends the create index request to IndexNode. -func (s *Server) CreateJob(ctx context.Context, req *workerpb.CreateJobRequest) (*commonpb.Status, error) { - return s.indexnode.CreateJob(ctx, req) -} - -// QueryJobs querys index jobs statues -func (s *Server) QueryJobs(ctx context.Context, req *workerpb.QueryJobsRequest) (*workerpb.QueryJobsResponse, error) { - return s.indexnode.QueryJobs(ctx, req) -} - -// DropJobs drops index build jobs -func (s *Server) DropJobs(ctx context.Context, req *workerpb.DropJobsRequest) (*commonpb.Status, error) { - return s.indexnode.DropJobs(ctx, req) -} - -// GetJobNum gets indexnode's job statisctics -func (s *Server) GetJobStats(ctx context.Context, req *workerpb.GetJobStatsRequest) (*workerpb.GetJobStatsResponse, error) { - return s.indexnode.GetJobStats(ctx, req) -} - -// ShowConfigurations gets specified configurations para of IndexNode -func (s *Server) ShowConfigurations(ctx context.Context, req *internalpb.ShowConfigurationsRequest) (*internalpb.ShowConfigurationsResponse, error) { - return s.indexnode.ShowConfigurations(ctx, req) -} - -// GetMetrics gets the metrics info of IndexNode. -func (s *Server) GetMetrics(ctx context.Context, request *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) { - return s.indexnode.GetMetrics(ctx, request) -} - -func (s *Server) CreateJobV2(ctx context.Context, request *workerpb.CreateJobV2Request) (*commonpb.Status, error) { - return s.indexnode.CreateJobV2(ctx, request) -} - -func (s *Server) QueryJobsV2(ctx context.Context, request *workerpb.QueryJobsV2Request) (*workerpb.QueryJobsV2Response, error) { - return s.indexnode.QueryJobsV2(ctx, request) -} - -func (s *Server) DropJobsV2(ctx context.Context, request *workerpb.DropJobsV2Request) (*commonpb.Status, error) { - return s.indexnode.DropJobsV2(ctx, request) -} - -// NewServer create a new IndexNode grpc server. -func NewServer(ctx context.Context, factory dependency.Factory) (*Server, error) { - ctx1, cancel := context.WithCancel(ctx) - node := indexnode.NewIndexNode(ctx1, factory) - - return &Server{ - loopCtx: ctx1, - loopCancel: cancel, - indexnode: node, - grpcErrChan: make(chan error), - }, nil -} diff --git a/internal/distributed/indexnode/service_test.go b/internal/distributed/indexnode/service_test.go deleted file mode 100644 index 7543ea7ad8..0000000000 --- a/internal/distributed/indexnode/service_test.go +++ /dev/null @@ -1,174 +0,0 @@ -// 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. - -package grpcindexnode - -import ( - "context" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" - - "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" - "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" - "github.com/milvus-io/milvus/internal/mocks" - "github.com/milvus-io/milvus/internal/util/dependency" - "github.com/milvus-io/milvus/pkg/v2/proto/internalpb" - "github.com/milvus-io/milvus/pkg/v2/proto/workerpb" - "github.com/milvus-io/milvus/pkg/v2/util/merr" - "github.com/milvus-io/milvus/pkg/v2/util/metricsinfo" - "github.com/milvus-io/milvus/pkg/v2/util/paramtable" -) - -func TestIndexNodeServer(t *testing.T) { - paramtable.Init() - ctx := context.Background() - factory := dependency.NewDefaultFactory(true) - server, err := NewServer(ctx, factory) - assert.NoError(t, err) - assert.NotNil(t, server) - - inm := mocks.NewMockIndexNode(t) - inm.EXPECT().SetEtcdClient(mock.Anything).Return() - inm.EXPECT().SetAddress(mock.Anything).Return() - inm.EXPECT().Start().Return(nil) - inm.EXPECT().Init().Return(nil) - inm.EXPECT().Register().Return(nil) - inm.EXPECT().Stop().Return(nil) - err = server.setServer(inm) - assert.NoError(t, err) - - err = server.Prepare() - assert.NoError(t, err) - err = server.Run() - assert.NoError(t, err) - - t.Run("GetComponentStates", func(t *testing.T) { - inm.EXPECT().GetComponentStates(mock.Anything, mock.Anything).Return(&milvuspb.ComponentStates{ - State: &milvuspb.ComponentInfo{ - StateCode: commonpb.StateCode_Healthy, - }, - }, nil) - req := &milvuspb.GetComponentStatesRequest{} - states, err := server.GetComponentStates(ctx, req) - assert.NoError(t, err) - assert.Equal(t, commonpb.StateCode_Healthy, states.State.StateCode) - }) - - t.Run("GetStatisticsChannel", func(t *testing.T) { - inm.EXPECT().GetStatisticsChannel(mock.Anything, mock.Anything).Return(&milvuspb.StringResponse{ - Status: merr.Success(), - }, nil) - req := &internalpb.GetStatisticsChannelRequest{} - resp, err := server.GetStatisticsChannel(ctx, req) - assert.NoError(t, err) - assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode()) - }) - - t.Run("CreateJob", func(t *testing.T) { - inm.EXPECT().CreateJob(mock.Anything, mock.Anything).Return(merr.Success(), nil) - req := &workerpb.CreateJobRequest{ - ClusterID: "", - BuildID: 0, - IndexID: 0, - DataPaths: []string{}, - } - resp, err := server.CreateJob(ctx, req) - assert.NoError(t, err) - assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode) - }) - - t.Run("QueryJob", func(t *testing.T) { - inm.EXPECT().QueryJobs(mock.Anything, mock.Anything).Return(&workerpb.QueryJobsResponse{ - Status: merr.Success(), - }, nil) - req := &workerpb.QueryJobsRequest{} - resp, err := server.QueryJobs(ctx, req) - assert.NoError(t, err) - assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode()) - }) - - t.Run("DropJobs", func(t *testing.T) { - inm.EXPECT().DropJobs(mock.Anything, mock.Anything).Return(merr.Success(), nil) - req := &workerpb.DropJobsRequest{} - resp, err := server.DropJobs(ctx, req) - assert.NoError(t, err) - assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode) - }) - - t.Run("ShowConfigurations", func(t *testing.T) { - inm.EXPECT().ShowConfigurations(mock.Anything, mock.Anything).Return(&internalpb.ShowConfigurationsResponse{ - Status: merr.Success(), - }, nil) - req := &internalpb.ShowConfigurationsRequest{ - Pattern: "", - } - resp, err := server.ShowConfigurations(ctx, req) - assert.NoError(t, err) - assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode()) - }) - - t.Run("GetMetrics", func(t *testing.T) { - inm.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(&milvuspb.GetMetricsResponse{ - Status: merr.Success(), - }, nil) - req, err := metricsinfo.ConstructRequestByMetricType(metricsinfo.SystemInfoMetrics) - assert.NoError(t, err) - resp, err := server.GetMetrics(ctx, req) - assert.NoError(t, err) - assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode()) - }) - - t.Run("GetTaskSlots", func(t *testing.T) { - inm.EXPECT().GetJobStats(mock.Anything, mock.Anything).Return(&workerpb.GetJobStatsResponse{ - Status: merr.Success(), - }, nil) - req := &workerpb.GetJobStatsRequest{} - resp, err := server.GetJobStats(ctx, req) - assert.NoError(t, err) - assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode()) - }) - - t.Run("CreateJobV2", func(t *testing.T) { - inm.EXPECT().CreateJobV2(mock.Anything, mock.Anything).Return(merr.Success(), nil) - req := &workerpb.CreateJobV2Request{} - resp, err := server.CreateJobV2(ctx, req) - assert.NoError(t, err) - assert.Equal(t, commonpb.ErrorCode_Success, resp.GetErrorCode()) - }) - - t.Run("QueryJobsV2", func(t *testing.T) { - inm.EXPECT().QueryJobsV2(mock.Anything, mock.Anything).Return(&workerpb.QueryJobsV2Response{ - Status: merr.Success(), - }, nil) - req := &workerpb.QueryJobsV2Request{} - resp, err := server.QueryJobsV2(ctx, req) - assert.NoError(t, err) - assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode()) - }) - - t.Run("DropJobsV2", func(t *testing.T) { - inm.EXPECT().DropJobsV2(mock.Anything, mock.Anything).Return(merr.Success(), nil) - req := &workerpb.DropJobsV2Request{} - resp, err := server.DropJobsV2(ctx, req) - assert.NoError(t, err) - assert.Equal(t, commonpb.ErrorCode_Success, resp.GetErrorCode()) - }) - - err = server.Stop() - assert.NoError(t, err) -} diff --git a/internal/indexnode/OWNERS b/internal/indexnode/OWNERS deleted file mode 100644 index 6a36f0e78d..0000000000 --- a/internal/indexnode/OWNERS +++ /dev/null @@ -1,12 +0,0 @@ -# order by contributions -reviewers: - - czs007 - - DragonDriver - - xiaocai2333 - - bigsheeper - - scsven - -approvers: - - maintainers - - diff --git a/internal/indexnode/chunkmgr_mock.go b/internal/indexnode/chunkmgr_mock.go deleted file mode 100644 index bc17acf597..0000000000 --- a/internal/indexnode/chunkmgr_mock.go +++ /dev/null @@ -1,264 +0,0 @@ -package indexnode - -import ( - "context" - "fmt" - "math/rand" - "sync" - "time" - - "golang.org/x/exp/mmap" - - "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" - "github.com/milvus-io/milvus-proto/go-api/v2/schemapb" - "github.com/milvus-io/milvus/internal/storage" - "github.com/milvus-io/milvus/pkg/v2/common" - "github.com/milvus-io/milvus/pkg/v2/mq/msgstream" - "github.com/milvus-io/milvus/pkg/v2/proto/etcdpb" - "github.com/milvus-io/milvus/pkg/v2/proto/indexpb" - "github.com/milvus-io/milvus/pkg/v2/util/paramtable" -) - -func init() { - rand.Seed(time.Now().UnixNano()) -} - -const ( - vecFieldID = 101 -) - -var ( - errNotImplErr = fmt.Errorf("not implemented error") - - collschema = &schemapb.CollectionSchema{ - Name: "mock_collection", - Description: "mock", - AutoID: false, - Fields: []*schemapb.FieldSchema{ - { - FieldID: 0, - Name: "int64", - IsPrimaryKey: true, - Description: "", - DataType: schemapb.DataType_Int64, - AutoID: false, - }, - { - FieldID: vecFieldID, - Name: "vector", - IsPrimaryKey: false, - Description: "", - DataType: schemapb.DataType_FloatVector, - AutoID: false, - }, - }, - } - - collMeta = &etcdpb.CollectionMeta{ - Schema: &schemapb.CollectionSchema{ - Name: "mock_index", - Description: "mock", - AutoID: false, - Fields: []*schemapb.FieldSchema{ - { - FieldID: vecFieldID, - Name: "vector", - IsPrimaryKey: false, - Description: "", - DataType: schemapb.DataType_FloatVector, - AutoID: false, - TypeParams: []*commonpb.KeyValuePair{ - {Key: common.DimKey, Value: "8"}, - }, - }, - }, - }, - } -) - -var mockChunkMgrIns = &mockChunkmgr{} - -type mockStorageFactory struct{} - -func (m *mockStorageFactory) NewChunkManager(context.Context, *indexpb.StorageConfig) (storage.ChunkManager, error) { - return mockChunkMgrIns, nil -} - -type mockChunkmgr struct { - segmentData sync.Map - indexedData sync.Map -} - -var _ storage.ChunkManager = &mockChunkmgr{} - -// var _ dependency.Factory = &mockFactory{} - -func (c *mockChunkmgr) RootPath() string { - return "" -} - -func (c *mockChunkmgr) Path(ctx context.Context, filePath string) (string, error) { - // TODO - return filePath, errNotImplErr -} - -func (c *mockChunkmgr) Size(ctx context.Context, filePath string) (int64, error) { - // TODO - return 0, errNotImplErr -} - -func (c *mockChunkmgr) Write(ctx context.Context, filePath string, content []byte) error { - c.indexedData.Store(filePath, content) - return nil -} - -func (c *mockChunkmgr) MultiWrite(ctx context.Context, contents map[string][]byte) error { - // TODO - return errNotImplErr -} - -func (c *mockChunkmgr) Exist(ctx context.Context, filePath string) (bool, error) { - // TODO - return false, errNotImplErr -} - -func (c *mockChunkmgr) Read(ctx context.Context, filePath string) ([]byte, error) { - value, ok := c.segmentData.Load(filePath) - if !ok { - return nil, fmt.Errorf("data not exists") - } - return value.(*storage.Blob).Value, nil -} - -func (c *mockChunkmgr) Reader(ctx context.Context, filePath string) (storage.FileReader, error) { - // TODO - return nil, errNotImplErr -} - -func (c *mockChunkmgr) MultiRead(ctx context.Context, filePaths []string) ([][]byte, error) { - // TODO - return nil, errNotImplErr -} - -func (c *mockChunkmgr) WalkWithPrefix(ctx context.Context, prefix string, recursive bool, walkFunc storage.ChunkObjectWalkFunc) error { - return errNotImplErr -} - -func (c *mockChunkmgr) Mmap(ctx context.Context, filePath string) (*mmap.ReaderAt, error) { - // TODO - return nil, errNotImplErr -} - -func (c *mockChunkmgr) ReadAt(ctx context.Context, filePath string, off int64, length int64) ([]byte, error) { - // TODO - return nil, errNotImplErr -} - -func (c *mockChunkmgr) Remove(ctx context.Context, filePath string) error { - // TODO - return errNotImplErr -} - -func (c *mockChunkmgr) MultiRemove(ctx context.Context, filePaths []string) error { - // TODO - return errNotImplErr -} - -func (c *mockChunkmgr) RemoveWithPrefix(ctx context.Context, prefix string) error { - // TODO - return errNotImplErr -} - -func (c *mockChunkmgr) mockFieldData(numrows, dim int, collectionID, partitionID, segmentID int64) { - idList := make([]int64, 0, numrows) - tsList := make([]int64, 0, numrows) - ts0 := time.Now().Unix() - for i := 0; i < numrows; i++ { - idList = append(idList, int64(i)+1) - tsList = append(tsList, ts0+int64(i)) - } - vecs := randomFloats(numrows, dim) - idField := storage.Int64FieldData{ - Data: idList, - } - tsField := storage.Int64FieldData{ - Data: tsList, - } - vecField := storage.FloatVectorFieldData{ - Data: vecs, - Dim: dim, - } - insertData := &storage.InsertData{ - Data: map[int64]storage.FieldData{ - common.TimeStampField: &tsField, - common.RowIDField: &idField, - vecFieldID: &vecField, - }, - } - insertCodec := &storage.InsertCodec{ - Schema: collMeta, - } - blobs, err := insertCodec.Serialize(partitionID, segmentID, insertData) - if err != nil { - panic(err) - } - if len(blobs) != 1 { - panic("invalid blobs") - } - c.segmentData.Store(dataPath(collectionID, partitionID, segmentID), blobs[0]) -} - -func NewMockChunkManager() *mockChunkmgr { - return &mockChunkmgr{} -} - -type mockFactory struct { - chunkMgr *mockChunkmgr -} - -func (f *mockFactory) NewCacheStorageChunkManager(context.Context) (storage.ChunkManager, error) { - return nil, errNotImplErr -} - -func (f *mockFactory) NewPersistentStorageChunkManager(context.Context) (storage.ChunkManager, error) { - if f.chunkMgr != nil { - return f.chunkMgr, nil - } - return nil, fmt.Errorf("factory not inited") -} - -func (f *mockFactory) Init(*paramtable.ComponentParam) { - // do nothing -} - -func (f *mockFactory) NewMsgStream(context.Context) (msgstream.MsgStream, error) { - // TOD - return nil, errNotImplErr -} - -func (f *mockFactory) NewTtMsgStream(context.Context) (msgstream.MsgStream, error) { - // TODO - return nil, errNotImplErr -} - -func (f *mockFactory) NewMsgStreamDisposer(ctx context.Context) func([]string, string) error { - // TODO - return nil -} - -func randomFloats(rows, dim int) []float32 { - vecs := make([]float32, 0, rows) - - for i := 0; i < rows; i++ { - vec := make([]float32, 0, dim) - for j := 0; j < dim; j++ { - vec = append(vec, rand.Float32()) - } - vecs = append(vecs, vec...) - } - return vecs -} - -func dataPath(collectionID, partitionID, segmentID int64) string { - return fmt.Sprintf("%d-%d-%d", collectionID, partitionID, segmentID) -} diff --git a/internal/indexnode/etcd_mock.go b/internal/indexnode/etcd_mock.go deleted file mode 100644 index bf7039b266..0000000000 --- a/internal/indexnode/etcd_mock.go +++ /dev/null @@ -1,64 +0,0 @@ -package indexnode - -import ( - "fmt" - "net/url" - "os" - "sync" - - clientv3 "go.etcd.io/etcd/client/v3" - "go.etcd.io/etcd/server/v3/embed" - "go.etcd.io/etcd/server/v3/etcdserver/api/v3client" -) - -const ( - etcdListenPort = 2389 - etcdPeerPort = 2390 -) - -var ( - startSvr sync.Once - stopSvr sync.Once - etcdSvr *embed.Etcd -) - -func startEmbedEtcd() { - startSvr.Do(func() { - dir, err := os.MkdirTemp(os.TempDir(), "milvus_ut_etcd") - if err != nil { - panic(err) - } - - config := embed.NewConfig() - config.Dir = dir - - config.LogLevel = "warn" - config.LogOutputs = []string{"default"} - u, err := url.Parse(fmt.Sprintf("http://localhost:%d", etcdListenPort)) - if err != nil { - panic(err) - } - config.LCUrls = []url.URL{*u} - - u, err = url.Parse(fmt.Sprintf("http://localhost:%d", etcdPeerPort)) - if err != nil { - panic(err) - } - config.LPUrls = []url.URL{*u} - etcdSvr, err = embed.StartEtcd(config) - if err != nil { - panic(err) - } - }) -} - -func stopEmbedEtcd() { - stopSvr.Do(func() { - etcdSvr.Close() - os.RemoveAll(etcdSvr.Config().Dir) - }) -} - -func getEtcdClient() *clientv3.Client { - return v3client.New(etcdSvr.Server) -} diff --git a/internal/indexnode/index_test.go b/internal/indexnode/index_test.go deleted file mode 100644 index 487525242f..0000000000 --- a/internal/indexnode/index_test.go +++ /dev/null @@ -1,185 +0,0 @@ -package indexnode - -import ( - "fmt" - "math/rand" - - "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" - "github.com/milvus-io/milvus-proto/go-api/v2/schemapb" - "github.com/milvus-io/milvus/internal/storage" - "github.com/milvus-io/milvus/pkg/v2/common" - "github.com/milvus-io/milvus/pkg/v2/proto/etcdpb" - "github.com/milvus-io/milvus/pkg/v2/util/typeutil" -) - -func generateFloatVectors(nb, dim int) []float32 { - vectors := make([]float32, 0) - for i := 0; i < nb; i++ { - for j := 0; j < dim; j++ { - vectors = append(vectors, rand.Float32()) - } - } - return vectors -} - -func generateTestSchema() *schemapb.CollectionSchema { - schema := &schemapb.CollectionSchema{Fields: []*schemapb.FieldSchema{ - {FieldID: common.TimeStampField, Name: "ts", DataType: schemapb.DataType_Int64}, - {FieldID: common.RowIDField, Name: "rowid", DataType: schemapb.DataType_Int64}, - {FieldID: 100, Name: "bool", DataType: schemapb.DataType_Bool}, - {FieldID: 101, Name: "int8", DataType: schemapb.DataType_Int8}, - {FieldID: 102, Name: "int16", DataType: schemapb.DataType_Int16}, - {FieldID: 103, Name: "int64", DataType: schemapb.DataType_Int64, IsPrimaryKey: true}, - {FieldID: 104, Name: "float", DataType: schemapb.DataType_Float}, - {FieldID: 105, Name: "double", DataType: schemapb.DataType_Double}, - {FieldID: 106, Name: "varchar", DataType: schemapb.DataType_VarChar}, - {FieldID: 107, Name: "string", DataType: schemapb.DataType_String}, - {FieldID: 108, Name: "array", DataType: schemapb.DataType_Array}, - {FieldID: 109, Name: "json", DataType: schemapb.DataType_JSON}, - {FieldID: 110, Name: "int32", DataType: schemapb.DataType_Int32}, - {FieldID: 111, Name: "floatVector", DataType: schemapb.DataType_FloatVector, TypeParams: []*commonpb.KeyValuePair{ - {Key: common.DimKey, Value: "8"}, - }}, - {FieldID: 112, Name: "binaryVector", DataType: schemapb.DataType_BinaryVector, TypeParams: []*commonpb.KeyValuePair{ - {Key: common.DimKey, Value: "8"}, - }}, - {FieldID: 113, Name: "float16Vector", DataType: schemapb.DataType_Float16Vector, TypeParams: []*commonpb.KeyValuePair{ - {Key: common.DimKey, Value: "8"}, - }}, - {FieldID: 114, Name: "bf16Vector", DataType: schemapb.DataType_BFloat16Vector, TypeParams: []*commonpb.KeyValuePair{ - {Key: common.DimKey, Value: "8"}, - }}, - {FieldID: 115, Name: "sparseFloatVector", DataType: schemapb.DataType_SparseFloatVector, TypeParams: []*commonpb.KeyValuePair{ - {Key: common.DimKey, Value: "28433"}, - }}, - }} - - return schema -} - -func generateTestData(collID, partID, segID int64, num int) ([]*Blob, error) { - insertCodec := storage.NewInsertCodecWithSchema(&etcdpb.CollectionMeta{ID: collID, Schema: generateTestSchema()}) - - var ( - field0 []int64 - field1 []int64 - - field10 []bool - field11 []int8 - field12 []int16 - field13 []int64 - field14 []float32 - field15 []float64 - field16 []string - field17 []string - field18 []*schemapb.ScalarField - field19 [][]byte - - field101 []int32 - field102 []float32 - field103 []byte - - field104 []byte - field105 []byte - field106 [][]byte - ) - - for i := 1; i <= num; i++ { - field0 = append(field0, int64(i)) - field1 = append(field1, int64(i)) - field10 = append(field10, true) - field11 = append(field11, int8(i)) - field12 = append(field12, int16(i)) - field13 = append(field13, int64(i)) - field14 = append(field14, float32(i)) - field15 = append(field15, float64(i)) - field16 = append(field16, fmt.Sprint(i)) - field17 = append(field17, fmt.Sprint(i)) - - arr := &schemapb.ScalarField{ - Data: &schemapb.ScalarField_IntData{ - IntData: &schemapb.IntArray{Data: []int32{int32(i), int32(i), int32(i)}}, - }, - } - field18 = append(field18, arr) - - field19 = append(field19, []byte{byte(i)}) - field101 = append(field101, int32(i)) - - f102 := make([]float32, 8) - for j := range f102 { - f102[j] = float32(i) - } - - field102 = append(field102, f102...) - field103 = append(field103, 0xff) - - f104 := make([]byte, 16) - for j := range f104 { - f104[j] = byte(i) - } - field104 = append(field104, f104...) - field105 = append(field105, f104...) - - field106 = append(field106, typeutil.CreateSparseFloatRow([]uint32{0, uint32(18 * i), uint32(284 * i)}, []float32{1.1, 0.3, 2.4})) - } - - data := &storage.InsertData{Data: map[int64]storage.FieldData{ - common.RowIDField: &storage.Int64FieldData{Data: field0}, - common.TimeStampField: &storage.Int64FieldData{Data: field1}, - - 100: &storage.BoolFieldData{Data: field10}, - 101: &storage.Int8FieldData{Data: field11}, - 102: &storage.Int16FieldData{Data: field12}, - 103: &storage.Int64FieldData{Data: field13}, - 104: &storage.FloatFieldData{Data: field14}, - 105: &storage.DoubleFieldData{Data: field15}, - 106: &storage.StringFieldData{Data: field16}, - 107: &storage.StringFieldData{Data: field17}, - 108: &storage.ArrayFieldData{Data: field18}, - 109: &storage.JSONFieldData{Data: field19}, - 110: &storage.Int32FieldData{Data: field101}, - 111: &storage.FloatVectorFieldData{ - Data: field102, - Dim: 8, - }, - 112: &storage.BinaryVectorFieldData{ - Data: field103, - Dim: 8, - }, - 113: &storage.Float16VectorFieldData{ - Data: field104, - Dim: 8, - }, - 114: &storage.BFloat16VectorFieldData{ - Data: field105, - Dim: 8, - }, - 115: &storage.SparseFloatVectorFieldData{ - SparseFloatArray: schemapb.SparseFloatArray{ - Dim: 28433, - Contents: field106, - }, - }, - }} - - blobs, err := insertCodec.Serialize(partID, segID, data) - return blobs, err -} - -func generateDeleteData(collID, partID, segID int64, num int) ([]*Blob, error) { - pks := make([]storage.PrimaryKey, 0, num) - tss := make([]storage.Timestamp, 0, num) - for i := 1; i <= num; i++ { - pks = append(pks, storage.NewInt64PrimaryKey(int64(i))) - tss = append(tss, storage.Timestamp(i+1)) - } - - deleteCodec := storage.NewDeleteCodec() - blob, err := deleteCodec.Serialize(collID, partID, segID, &storage.DeleteData{ - Pks: pks, - Tss: tss, - RowCount: int64(num), - }) - return []*Blob{blob}, err -} diff --git a/internal/indexnode/indexnode.go b/internal/indexnode/indexnode.go deleted file mode 100644 index 33696c516e..0000000000 --- a/internal/indexnode/indexnode.go +++ /dev/null @@ -1,400 +0,0 @@ -// 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. - -package indexnode - -/* -#cgo pkg-config: milvus_core - -#include -#include -#include "common/init_c.h" -#include "segcore/segcore_init_c.h" -#include "indexbuilder/init_c.h" -*/ -import "C" - -import ( - "context" - "fmt" - "math/rand" - "os" - "path" - "path/filepath" - "sync" - "time" - "unsafe" - - "github.com/cockroachdb/errors" - clientv3 "go.etcd.io/etcd/client/v3" - "go.uber.org/zap" - - "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" - "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" - "github.com/milvus-io/milvus/internal/flushcommon/io" - "github.com/milvus-io/milvus/internal/types" - "github.com/milvus-io/milvus/internal/util/dependency" - "github.com/milvus-io/milvus/internal/util/initcore" - "github.com/milvus-io/milvus/internal/util/sessionutil" - "github.com/milvus-io/milvus/pkg/v2/common" - "github.com/milvus-io/milvus/pkg/v2/log" - "github.com/milvus-io/milvus/pkg/v2/metrics" - "github.com/milvus-io/milvus/pkg/v2/proto/internalpb" - "github.com/milvus-io/milvus/pkg/v2/util/expr" - "github.com/milvus-io/milvus/pkg/v2/util/hardware" - "github.com/milvus-io/milvus/pkg/v2/util/lifetime" - "github.com/milvus-io/milvus/pkg/v2/util/merr" - "github.com/milvus-io/milvus/pkg/v2/util/paramtable" - "github.com/milvus-io/milvus/pkg/v2/util/typeutil" -) - -// TODO add comments -// UniqueID is an alias of int64, is used as a unique identifier for the request. -type UniqueID = typeutil.UniqueID - -// make sure IndexNode implements types.IndexNode -var _ types.IndexNode = (*IndexNode)(nil) - -// make sure IndexNode implements types.IndexNodeComponent -var _ types.IndexNodeComponent = (*IndexNode)(nil) - -// Params is a GlobalParamTable singleton of indexnode -var Params *paramtable.ComponentParam = paramtable.Get() - -func getCurrentIndexVersion(v int32) int32 { - cCurrent := int32(C.GetCurrentIndexVersion()) - if cCurrent < v { - return cCurrent - } - return v -} - -func getCurrentScalarIndexVersion(v int32) int32 { - cCurrent := common.CurrentScalarIndexEngineVersion - if cCurrent < v { - return cCurrent - } - return v -} - -type taskKey struct { - ClusterID string - TaskID UniqueID -} - -// IndexNode is a component that executes the task of building indexes. -type IndexNode struct { - lifetime lifetime.Lifetime[commonpb.StateCode] - - loopCtx context.Context - loopCancel func() - - sched *TaskScheduler - - once sync.Once - stopOnce sync.Once - - factory dependency.Factory - storageFactory StorageFactory - session *sessionutil.Session - - etcdCli *clientv3.Client - address string - - binlogIO io.BinlogIO - - initOnce sync.Once - stateLock sync.Mutex - indexTasks map[taskKey]*indexTaskInfo - analyzeTasks map[taskKey]*analyzeTaskInfo - statsTasks map[taskKey]*statsTaskInfo -} - -// NewIndexNode creates a new IndexNode component. -func NewIndexNode(ctx context.Context, factory dependency.Factory) *IndexNode { - log.Ctx(ctx).Debug("New IndexNode ...") - rand.Seed(time.Now().UnixNano()) - ctx1, cancel := context.WithCancel(ctx) - b := &IndexNode{ - loopCtx: ctx1, - loopCancel: cancel, - factory: factory, - storageFactory: NewChunkMgrFactory(), - indexTasks: make(map[taskKey]*indexTaskInfo), - analyzeTasks: make(map[taskKey]*analyzeTaskInfo), - statsTasks: make(map[taskKey]*statsTaskInfo), - lifetime: lifetime.NewLifetime(commonpb.StateCode_Abnormal), - } - sc := NewTaskScheduler(b.loopCtx) - - b.sched = sc - expr.Register("indexnode", b) - return b -} - -// Register register index node at etcd. -func (i *IndexNode) Register() error { - i.session.Register() - - metrics.NumNodes.WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), typeutil.IndexNodeRole).Inc() - // start liveness check - i.session.LivenessCheck(i.loopCtx, func() { - log.Ctx(i.loopCtx).Error("Index Node disconnected from etcd, process will exit", zap.Int64("Server Id", i.session.ServerID)) - os.Exit(1) - }) - return nil -} - -func (i *IndexNode) initSegcore() { - cGlogConf := C.CString(path.Join(paramtable.GetBaseTable().GetConfigDir(), paramtable.DefaultGlogConf)) - C.IndexBuilderInit(cGlogConf) - C.free(unsafe.Pointer(cGlogConf)) - - // override index builder SIMD type - cSimdType := C.CString(Params.CommonCfg.SimdType.GetValue()) - C.IndexBuilderSetSimdType(cSimdType) - C.free(unsafe.Pointer(cSimdType)) - - // override segcore index slice size - cIndexSliceSize := C.int64_t(Params.CommonCfg.IndexSliceSize.GetAsInt64()) - C.InitIndexSliceSize(cIndexSliceSize) - - // set up thread pool for different priorities - cHighPriorityThreadCoreCoefficient := C.int64_t(paramtable.Get().CommonCfg.HighPriorityThreadCoreCoefficient.GetAsInt64()) - C.InitHighPriorityThreadCoreCoefficient(cHighPriorityThreadCoreCoefficient) - cMiddlePriorityThreadCoreCoefficient := C.int64_t(paramtable.Get().CommonCfg.MiddlePriorityThreadCoreCoefficient.GetAsInt64()) - C.InitMiddlePriorityThreadCoreCoefficient(cMiddlePriorityThreadCoreCoefficient) - cLowPriorityThreadCoreCoefficient := C.int64_t(paramtable.Get().CommonCfg.LowPriorityThreadCoreCoefficient.GetAsInt64()) - C.InitLowPriorityThreadCoreCoefficient(cLowPriorityThreadCoreCoefficient) - - cCPUNum := C.int(hardware.GetCPUNum()) - C.InitCpuNum(cCPUNum) - - cKnowhereThreadPoolSize := C.uint32_t(hardware.GetCPUNum() * paramtable.DefaultKnowhereThreadPoolNumRatioInBuild) - if paramtable.GetRole() == typeutil.StandaloneRole { - threadPoolSize := int(float64(hardware.GetCPUNum()) * Params.CommonCfg.BuildIndexThreadPoolRatio.GetAsFloat()) - if threadPoolSize < 1 { - threadPoolSize = 1 - } - cKnowhereThreadPoolSize = C.uint32_t(threadPoolSize) - } - C.SegcoreSetKnowhereBuildThreadPoolNum(cKnowhereThreadPoolSize) - - localDataRootPath := filepath.Join(Params.LocalStorageCfg.Path.GetValue(), typeutil.IndexNodeRole) - initcore.InitLocalChunkManager(localDataRootPath) - cGpuMemoryPoolInitSize := C.uint32_t(paramtable.Get().GpuConfig.InitSize.GetAsUint32()) - cGpuMemoryPoolMaxSize := C.uint32_t(paramtable.Get().GpuConfig.MaxSize.GetAsUint32()) - C.SegcoreSetKnowhereGpuMemoryPoolSize(cGpuMemoryPoolInitSize, cGpuMemoryPoolMaxSize) -} - -func (i *IndexNode) CloseSegcore() { - initcore.CleanGlogManager() -} - -func (i *IndexNode) initSession() error { - i.session = sessionutil.NewSession(i.loopCtx, sessionutil.WithEnableDisk(Params.IndexNodeCfg.EnableDisk.GetAsBool())) - if i.session == nil { - return errors.New("failed to initialize session") - } - i.session.Init(typeutil.IndexNodeRole, i.address, false, true) - sessionutil.SaveServerInfo(typeutil.IndexNodeRole, i.session.ServerID) - return nil -} - -// Init initializes the IndexNode component. -func (i *IndexNode) Init() error { - var initErr error - i.initOnce.Do(func() { - i.UpdateStateCode(commonpb.StateCode_Initializing) - log.Info("IndexNode init", zap.String("state", i.lifetime.GetState().String())) - err := i.initSession() - if err != nil { - log.Error("failed to init session", zap.Error(err)) - initErr = err - return - } - log.Info("IndexNode init session successful", zap.Int64("serverID", i.session.ServerID)) - - i.initSegcore() - }) - - log.Info("init index node done", zap.Int64("nodeID", paramtable.GetNodeID()), zap.String("Address", i.address)) - return initErr -} - -// Start starts the IndexNode component. -func (i *IndexNode) Start() error { - var startErr error - i.once.Do(func() { - startErr = i.sched.Start() - - i.UpdateStateCode(commonpb.StateCode_Healthy) - log.Info("IndexNode", zap.String("State", i.lifetime.GetState().String())) - }) - - log.Info("IndexNode start finished", zap.Error(startErr)) - return startErr -} - -func (i *IndexNode) deleteAllTasks() { - deletedIndexTasks := i.deleteAllIndexTasks() - for _, t := range deletedIndexTasks { - if t.cancel != nil { - t.cancel() - } - } - deletedAnalyzeTasks := i.deleteAllAnalyzeTasks() - for _, t := range deletedAnalyzeTasks { - if t.cancel != nil { - t.cancel() - } - } - deletedStatsTasks := i.deleteAllStatsTasks() - for _, t := range deletedStatsTasks { - if t.cancel != nil { - t.cancel() - } - } -} - -// Stop closes the server. -func (i *IndexNode) Stop() error { - i.stopOnce.Do(func() { - i.UpdateStateCode(commonpb.StateCode_Stopping) - log.Info("Index node stopping") - err := i.session.GoingStop() - if err != nil { - log.Warn("session fail to go stopping state", zap.Error(err)) - } else { - i.waitTaskFinish() - } - - // https://github.com/milvus-io/milvus/issues/12282 - i.UpdateStateCode(commonpb.StateCode_Abnormal) - i.lifetime.Wait() - log.Info("Index node abnormal") - // cleanup all running tasks - i.deleteAllTasks() - - if i.sched != nil { - i.sched.Close() - } - if i.session != nil { - i.session.Stop() - } - - i.CloseSegcore() - i.loopCancel() - log.Info("Index node stopped.") - }) - return nil -} - -// UpdateStateCode updates the component state of IndexNode. -func (i *IndexNode) UpdateStateCode(code commonpb.StateCode) { - i.lifetime.SetState(code) -} - -// SetEtcdClient assigns parameter client to its member etcdCli -func (i *IndexNode) SetEtcdClient(client *clientv3.Client) { - i.etcdCli = client -} - -// GetComponentStates gets the component states of IndexNode. -func (i *IndexNode) GetComponentStates(ctx context.Context, req *milvuspb.GetComponentStatesRequest) (*milvuspb.ComponentStates, error) { - log.RatedInfo(10, "get IndexNode components states ...") - nodeID := common.NotRegisteredID - if i.session != nil && i.session.Registered() { - nodeID = i.session.ServerID - } - stateInfo := &milvuspb.ComponentInfo{ - // NodeID: Params.NodeID, // will race with i.Register() - NodeID: nodeID, - Role: typeutil.IndexNodeRole, - StateCode: i.lifetime.GetState(), - } - - ret := &milvuspb.ComponentStates{ - State: stateInfo, - SubcomponentStates: nil, // todo add subcomponents states - Status: merr.Success(), - } - - log.RatedInfo(10, "IndexNode Component states", - zap.String("State", ret.State.String()), - zap.String("Status", ret.GetStatus().GetErrorCode().String()), - zap.Any("SubcomponentStates", ret.SubcomponentStates)) - return ret, nil -} - -// GetTimeTickChannel gets the time tick channel of IndexNode. -func (i *IndexNode) GetTimeTickChannel(ctx context.Context, req *internalpb.GetTimeTickChannelRequest) (*milvuspb.StringResponse, error) { - log.RatedInfo(10, "get IndexNode time tick channel ...") - - return &milvuspb.StringResponse{ - Status: merr.Success(), - }, nil -} - -// GetStatisticsChannel gets the statistics channel of IndexNode. -func (i *IndexNode) GetStatisticsChannel(ctx context.Context, req *internalpb.GetStatisticsChannelRequest) (*milvuspb.StringResponse, error) { - log.RatedInfo(10, "get IndexNode statistics channel ...") - return &milvuspb.StringResponse{ - Status: merr.Success(), - }, nil -} - -func (i *IndexNode) GetNodeID() int64 { - return paramtable.GetNodeID() -} - -// ShowConfigurations returns the configurations of indexNode matching req.Pattern -func (i *IndexNode) ShowConfigurations(ctx context.Context, req *internalpb.ShowConfigurationsRequest) (*internalpb.ShowConfigurationsResponse, error) { - if err := i.lifetime.Add(merr.IsHealthyOrStopping); err != nil { - log.Warn("IndexNode.ShowConfigurations failed", - zap.Int64("nodeId", paramtable.GetNodeID()), - zap.String("req", req.Pattern), - zap.Error(err)) - - return &internalpb.ShowConfigurationsResponse{ - Status: merr.Status(err), - Configuations: nil, - }, nil - } - defer i.lifetime.Done() - - configList := make([]*commonpb.KeyValuePair, 0) - for key, value := range Params.GetComponentConfigurations("indexnode", req.Pattern) { - configList = append(configList, - &commonpb.KeyValuePair{ - Key: key, - Value: value, - }) - } - - return &internalpb.ShowConfigurationsResponse{ - Status: merr.Success(), - Configuations: configList, - }, nil -} - -func (i *IndexNode) SetAddress(address string) { - i.address = address -} - -func (i *IndexNode) GetAddress() string { - return i.address -} diff --git a/internal/indexnode/indexnode_component_mock.go b/internal/indexnode/indexnode_component_mock.go deleted file mode 100644 index 5013b5019f..0000000000 --- a/internal/indexnode/indexnode_component_mock.go +++ /dev/null @@ -1,42 +0,0 @@ -package indexnode - -import ( - "context" - - "github.com/milvus-io/milvus/internal/types" - "github.com/milvus-io/milvus/pkg/v2/util/paramtable" -) - -type mockIndexNodeComponent struct { - *IndexNode -} - -var _ types.IndexNodeComponent = &mockIndexNodeComponent{} - -func NewMockIndexNodeComponent(ctx context.Context) (types.IndexNodeComponent, error) { - paramtable.Init() - factory := &mockFactory{ - chunkMgr: &mockChunkmgr{}, - } - - node := NewIndexNode(ctx, factory) - - startEmbedEtcd() - etcdCli := getEtcdClient() - node.SetEtcdClient(etcdCli) - node.storageFactory = &mockStorageFactory{} - if err := node.Init(); err != nil { - return nil, err - } - - if err := node.Start(); err != nil { - return nil, err - } - - if err := node.Register(); err != nil { - return nil, err - } - return &mockIndexNodeComponent{ - IndexNode: node, - }, nil -} diff --git a/internal/indexnode/indexnode_service_test.go b/internal/indexnode/indexnode_service_test.go deleted file mode 100644 index d78e19d573..0000000000 --- a/internal/indexnode/indexnode_service_test.go +++ /dev/null @@ -1,233 +0,0 @@ -// 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. - -package indexnode - -import ( - "context" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/suite" - - "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" - "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" - "github.com/milvus-io/milvus/pkg/v2/proto/indexpb" - "github.com/milvus-io/milvus/pkg/v2/proto/internalpb" - "github.com/milvus-io/milvus/pkg/v2/proto/workerpb" - "github.com/milvus-io/milvus/pkg/v2/util/merr" - "github.com/milvus-io/milvus/pkg/v2/util/metricsinfo" -) - -func TestAbnormalIndexNode(t *testing.T) { - in, err := NewMockIndexNodeComponent(context.TODO()) - assert.NoError(t, err) - assert.Nil(t, in.Stop()) - ctx := context.TODO() - status, err := in.CreateJob(ctx, &workerpb.CreateJobRequest{}) - assert.NoError(t, err) - assert.ErrorIs(t, merr.Error(status), merr.ErrServiceNotReady) - - qresp, err := in.QueryJobs(ctx, &workerpb.QueryJobsRequest{}) - assert.NoError(t, err) - assert.ErrorIs(t, merr.Error(qresp.GetStatus()), merr.ErrServiceNotReady) - - status, err = in.DropJobs(ctx, &workerpb.DropJobsRequest{}) - assert.NoError(t, err) - assert.ErrorIs(t, merr.Error(status), merr.ErrServiceNotReady) - - jobNumRsp, err := in.GetJobStats(ctx, &workerpb.GetJobStatsRequest{}) - assert.NoError(t, err) - assert.ErrorIs(t, merr.Error(jobNumRsp.GetStatus()), merr.ErrServiceNotReady) - - metricsResp, err := in.GetMetrics(ctx, &milvuspb.GetMetricsRequest{}) - err = merr.CheckRPCCall(metricsResp, err) - assert.ErrorIs(t, err, merr.ErrServiceNotReady) - - configurationResp, err := in.ShowConfigurations(ctx, &internalpb.ShowConfigurationsRequest{}) - err = merr.CheckRPCCall(configurationResp, err) - assert.ErrorIs(t, err, merr.ErrServiceNotReady) -} - -func TestGetMetrics(t *testing.T) { - var ( - ctx = context.TODO() - metricReq, _ = metricsinfo.ConstructRequestByMetricType(metricsinfo.SystemInfoMetrics) - ) - in, err := NewMockIndexNodeComponent(ctx) - assert.NoError(t, err) - defer in.Stop() - resp, err := in.GetMetrics(ctx, metricReq) - assert.NoError(t, err) - assert.True(t, merr.Ok(resp.GetStatus())) - t.Logf("Component: %s, Metrics: %s", resp.ComponentName, resp.Response) -} - -func TestGetMetricsError(t *testing.T) { - ctx := context.TODO() - - in, err := NewMockIndexNodeComponent(ctx) - assert.NoError(t, err) - defer in.Stop() - errReq := &milvuspb.GetMetricsRequest{ - Request: `{"metric_typ": "system_info"}`, - } - resp, err := in.GetMetrics(ctx, errReq) - assert.NoError(t, err) - assert.Equal(t, resp.GetStatus().GetErrorCode(), commonpb.ErrorCode_UnexpectedError) - - unsupportedReq := &milvuspb.GetMetricsRequest{ - Request: `{"metric_type": "application_info"}`, - } - resp, err = in.GetMetrics(ctx, unsupportedReq) - assert.NoError(t, err) - assert.ErrorIs(t, merr.Error(resp.GetStatus()), merr.ErrMetricNotFound) -} - -func TestMockFieldData(t *testing.T) { - chunkMgr := NewMockChunkManager() - - chunkMgr.mockFieldData(100000, 8, 0, 0, 1) -} - -type IndexNodeServiceSuite struct { - suite.Suite - cluster string - collectionID int64 - partitionID int64 - taskID int64 - fieldID int64 - segmentID int64 -} - -func (suite *IndexNodeServiceSuite) SetupTest() { - suite.cluster = "test_cluster" - suite.collectionID = 100 - suite.partitionID = 102 - suite.taskID = 11111 - suite.fieldID = 103 - suite.segmentID = 104 -} - -func (suite *IndexNodeServiceSuite) Test_AbnormalIndexNode() { - in, err := NewMockIndexNodeComponent(context.TODO()) - suite.NoError(err) - suite.Nil(in.Stop()) - - ctx := context.TODO() - status, err := in.CreateJob(ctx, &workerpb.CreateJobRequest{}) - suite.NoError(err) - suite.ErrorIs(merr.Error(status), merr.ErrServiceNotReady) - - qresp, err := in.QueryJobs(ctx, &workerpb.QueryJobsRequest{}) - suite.NoError(err) - suite.ErrorIs(merr.Error(qresp.GetStatus()), merr.ErrServiceNotReady) - - status, err = in.DropJobs(ctx, &workerpb.DropJobsRequest{}) - suite.NoError(err) - suite.ErrorIs(merr.Error(status), merr.ErrServiceNotReady) - - jobNumRsp, err := in.GetJobStats(ctx, &workerpb.GetJobStatsRequest{}) - suite.NoError(err) - suite.ErrorIs(merr.Error(jobNumRsp.GetStatus()), merr.ErrServiceNotReady) - - metricsResp, err := in.GetMetrics(ctx, &milvuspb.GetMetricsRequest{}) - err = merr.CheckRPCCall(metricsResp, err) - suite.ErrorIs(err, merr.ErrServiceNotReady) - - configurationResp, err := in.ShowConfigurations(ctx, &internalpb.ShowConfigurationsRequest{}) - err = merr.CheckRPCCall(configurationResp, err) - suite.ErrorIs(err, merr.ErrServiceNotReady) - - status, err = in.CreateJobV2(ctx, &workerpb.CreateJobV2Request{}) - err = merr.CheckRPCCall(status, err) - suite.ErrorIs(err, merr.ErrServiceNotReady) - - queryAnalyzeResultResp, err := in.QueryJobsV2(ctx, &workerpb.QueryJobsV2Request{}) - err = merr.CheckRPCCall(queryAnalyzeResultResp, err) - suite.ErrorIs(err, merr.ErrServiceNotReady) - - dropAnalyzeTasksResp, err := in.DropJobsV2(ctx, &workerpb.DropJobsV2Request{}) - err = merr.CheckRPCCall(dropAnalyzeTasksResp, err) - suite.ErrorIs(err, merr.ErrServiceNotReady) -} - -func (suite *IndexNodeServiceSuite) Test_Method() { - ctx := context.TODO() - in, err := NewMockIndexNodeComponent(context.TODO()) - suite.NoError(err) - suite.NoError(in.Stop()) - - in.UpdateStateCode(commonpb.StateCode_Healthy) - - suite.Run("CreateJobV2", func() { - req := &workerpb.AnalyzeRequest{ - ClusterID: suite.cluster, - TaskID: suite.taskID, - CollectionID: suite.collectionID, - PartitionID: suite.partitionID, - FieldID: suite.fieldID, - SegmentStats: map[int64]*indexpb.SegmentStats{ - suite.segmentID: { - ID: suite.segmentID, - NumRows: 1024, - LogIDs: []int64{1, 2, 3}, - }, - }, - Version: 1, - StorageConfig: nil, - } - - resp, err := in.CreateJobV2(ctx, &workerpb.CreateJobV2Request{ - ClusterID: suite.cluster, - TaskID: suite.taskID, - JobType: indexpb.JobType_JobTypeAnalyzeJob, - Request: &workerpb.CreateJobV2Request_AnalyzeRequest{ - AnalyzeRequest: req, - }, - }) - err = merr.CheckRPCCall(resp, err) - suite.NoError(err) - }) - - suite.Run("QueryJobsV2", func() { - req := &workerpb.QueryJobsV2Request{ - ClusterID: suite.cluster, - TaskIDs: []int64{suite.taskID}, - JobType: indexpb.JobType_JobTypeIndexJob, - } - - resp, err := in.QueryJobsV2(ctx, req) - err = merr.CheckRPCCall(resp, err) - suite.NoError(err) - }) - - suite.Run("DropJobsV2", func() { - req := &workerpb.DropJobsV2Request{ - ClusterID: suite.cluster, - TaskIDs: []int64{suite.taskID}, - JobType: indexpb.JobType_JobTypeIndexJob, - } - - resp, err := in.DropJobsV2(ctx, req) - err = merr.CheckRPCCall(resp, err) - suite.NoError(err) - }) -} - -func Test_IndexNodeServiceSuite(t *testing.T) { - suite.Run(t, new(IndexNodeServiceSuite)) -} diff --git a/internal/indexnode/metrics_info.go b/internal/indexnode/metrics_info.go deleted file mode 100644 index e454c867b5..0000000000 --- a/internal/indexnode/metrics_info.go +++ /dev/null @@ -1,93 +0,0 @@ -// 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. - -package indexnode - -import ( - "context" - - "go.uber.org/zap" - - "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" - "github.com/milvus-io/milvus/pkg/v2/log" - "github.com/milvus-io/milvus/pkg/v2/util/hardware" - "github.com/milvus-io/milvus/pkg/v2/util/merr" - "github.com/milvus-io/milvus/pkg/v2/util/metricsinfo" - "github.com/milvus-io/milvus/pkg/v2/util/paramtable" - "github.com/milvus-io/milvus/pkg/v2/util/typeutil" -) - -// TODO(dragondriver): maybe IndexNode should be an interface so that we can mock it in the test cases -func getSystemInfoMetrics( - ctx context.Context, - req *milvuspb.GetMetricsRequest, - node *IndexNode, -) (*milvuspb.GetMetricsResponse, error) { - // TODO(dragondriver): add more metrics - - used, total, err := hardware.GetDiskUsage(paramtable.Get().LocalStorageCfg.Path.GetValue()) - if err != nil { - log.Ctx(ctx).Warn("get disk usage failed", zap.Error(err)) - } - - iowait, err := hardware.GetIOWait() - if err != nil { - log.Ctx(ctx).Warn("get iowait failed", zap.Error(err)) - } - - nodeInfos := metricsinfo.IndexNodeInfos{ - BaseComponentInfos: metricsinfo.BaseComponentInfos{ - Name: metricsinfo.ConstructComponentName(typeutil.IndexNodeRole, paramtable.GetNodeID()), - - HardwareInfos: metricsinfo.HardwareMetrics{ - IP: node.session.Address, - CPUCoreCount: hardware.GetCPUNum(), - CPUCoreUsage: hardware.GetCPUUsage(), - Memory: hardware.GetMemoryCount(), - MemoryUsage: hardware.GetUsedMemoryCount(), - Disk: total, - DiskUsage: used, - IOWaitPercentage: iowait, - }, - SystemInfo: metricsinfo.DeployMetrics{}, - CreatedTime: paramtable.GetCreateTime().String(), - UpdatedTime: paramtable.GetUpdateTime().String(), - Type: typeutil.IndexNodeRole, - ID: node.session.ServerID, - }, - SystemConfigurations: metricsinfo.IndexNodeConfiguration{ - MinioBucketName: Params.MinioCfg.BucketName.GetValue(), - SimdType: Params.CommonCfg.SimdType.GetValue(), - }, - } - - metricsinfo.FillDeployMetricsWithEnv(&nodeInfos.SystemInfo) - - resp, err := metricsinfo.MarshalComponentInfos(nodeInfos) - if err != nil { - return &milvuspb.GetMetricsResponse{ - Status: merr.Status(err), - Response: "", - ComponentName: metricsinfo.ConstructComponentName(typeutil.IndexNodeRole, paramtable.GetNodeID()), - }, nil - } - - return &milvuspb.GetMetricsResponse{ - Status: merr.Success(), - Response: resp, - ComponentName: metricsinfo.ConstructComponentName(typeutil.IndexNodeRole, paramtable.GetNodeID()), - }, nil -} diff --git a/internal/indexnode/metrics_info_test.go b/internal/indexnode/metrics_info_test.go deleted file mode 100644 index d80ff19f7d..0000000000 --- a/internal/indexnode/metrics_info_test.go +++ /dev/null @@ -1,27 +0,0 @@ -// 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. - -package indexnode - -import ( - "testing" - - "github.com/milvus-io/milvus/pkg/v2/log" -) - -func TestGetSystemInfoMetrics(t *testing.T) { - log.Info("TestGetSystemInfoMetrics, todo") -} diff --git a/internal/indexnode/taskinfo_ops.go b/internal/indexnode/taskinfo_ops.go deleted file mode 100644 index 20282ba37c..0000000000 --- a/internal/indexnode/taskinfo_ops.go +++ /dev/null @@ -1,449 +0,0 @@ -// 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. - -package indexnode - -import ( - "context" - "time" - - "go.uber.org/zap" - - "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" - "github.com/milvus-io/milvus/pkg/v2/common" - "github.com/milvus-io/milvus/pkg/v2/log" - "github.com/milvus-io/milvus/pkg/v2/proto/datapb" - "github.com/milvus-io/milvus/pkg/v2/proto/indexpb" -) - -type indexTaskInfo struct { - cancel context.CancelFunc - state commonpb.IndexState - fileKeys []string - serializedSize uint64 - memSize uint64 - failReason string - currentIndexVersion int32 - indexStoreVersion int64 - currentScalarIndexVersion int32 - - // task statistics - statistic *indexpb.JobInfo -} - -func (i *IndexNode) loadOrStoreIndexTask(ClusterID string, buildID UniqueID, info *indexTaskInfo) *indexTaskInfo { - i.stateLock.Lock() - defer i.stateLock.Unlock() - key := taskKey{ClusterID: ClusterID, TaskID: buildID} - oldInfo, ok := i.indexTasks[key] - if ok { - return oldInfo - } - i.indexTasks[key] = info - return nil -} - -func (i *IndexNode) loadIndexTaskState(ClusterID string, buildID UniqueID) commonpb.IndexState { - key := taskKey{ClusterID: ClusterID, TaskID: buildID} - i.stateLock.Lock() - defer i.stateLock.Unlock() - task, ok := i.indexTasks[key] - if !ok { - return commonpb.IndexState_IndexStateNone - } - return task.state -} - -func (i *IndexNode) storeIndexTaskState(ClusterID string, buildID UniqueID, state commonpb.IndexState, failReason string) { - key := taskKey{ClusterID: ClusterID, TaskID: buildID} - i.stateLock.Lock() - defer i.stateLock.Unlock() - if task, ok := i.indexTasks[key]; ok { - log.Ctx(i.loopCtx).Debug("IndexNode store task state", zap.String("clusterID", ClusterID), zap.Int64("buildID", buildID), - zap.String("state", state.String()), zap.String("fail reason", failReason)) - task.state = state - task.failReason = failReason - } -} - -func (i *IndexNode) foreachIndexTaskInfo(fn func(ClusterID string, buildID UniqueID, info *indexTaskInfo)) { - i.stateLock.Lock() - defer i.stateLock.Unlock() - for key, info := range i.indexTasks { - fn(key.ClusterID, key.TaskID, info) - } -} - -func (i *IndexNode) storeIndexFilesAndStatistic( - ClusterID string, - buildID UniqueID, - fileKeys []string, - serializedSize uint64, - memSize uint64, - currentIndexVersion int32, - currentScalarIndexVersion int32, -) { - key := taskKey{ClusterID: ClusterID, TaskID: buildID} - i.stateLock.Lock() - defer i.stateLock.Unlock() - if info, ok := i.indexTasks[key]; ok { - info.fileKeys = common.CloneStringList(fileKeys) - info.serializedSize = serializedSize - info.memSize = memSize - info.currentIndexVersion = currentIndexVersion - info.currentScalarIndexVersion = currentScalarIndexVersion - return - } -} - -func (i *IndexNode) deleteIndexTaskInfos(ctx context.Context, keys []taskKey) []*indexTaskInfo { - i.stateLock.Lock() - defer i.stateLock.Unlock() - deleted := make([]*indexTaskInfo, 0, len(keys)) - for _, key := range keys { - info, ok := i.indexTasks[key] - if ok { - deleted = append(deleted, info) - delete(i.indexTasks, key) - log.Ctx(ctx).Info("delete task infos", - zap.String("cluster_id", key.ClusterID), zap.Int64("build_id", key.TaskID)) - } - } - return deleted -} - -func (i *IndexNode) deleteAllIndexTasks() []*indexTaskInfo { - i.stateLock.Lock() - deletedTasks := i.indexTasks - i.indexTasks = make(map[taskKey]*indexTaskInfo) - i.stateLock.Unlock() - - deleted := make([]*indexTaskInfo, 0, len(deletedTasks)) - for _, info := range deletedTasks { - deleted = append(deleted, info) - } - return deleted -} - -type analyzeTaskInfo struct { - cancel context.CancelFunc - state indexpb.JobState - failReason string - centroidsFile string -} - -func (i *IndexNode) loadOrStoreAnalyzeTask(clusterID string, taskID UniqueID, info *analyzeTaskInfo) *analyzeTaskInfo { - i.stateLock.Lock() - defer i.stateLock.Unlock() - key := taskKey{ClusterID: clusterID, TaskID: taskID} - oldInfo, ok := i.analyzeTasks[key] - if ok { - return oldInfo - } - i.analyzeTasks[key] = info - return nil -} - -func (i *IndexNode) loadAnalyzeTaskState(clusterID string, taskID UniqueID) indexpb.JobState { - key := taskKey{ClusterID: clusterID, TaskID: taskID} - i.stateLock.Lock() - defer i.stateLock.Unlock() - task, ok := i.analyzeTasks[key] - if !ok { - return indexpb.JobState_JobStateNone - } - return task.state -} - -func (i *IndexNode) storeAnalyzeTaskState(clusterID string, taskID UniqueID, state indexpb.JobState, failReason string) { - key := taskKey{ClusterID: clusterID, TaskID: taskID} - i.stateLock.Lock() - defer i.stateLock.Unlock() - if task, ok := i.analyzeTasks[key]; ok { - log.Info("IndexNode store analyze task state", zap.String("clusterID", clusterID), zap.Int64("TaskID", taskID), - zap.String("state", state.String()), zap.String("fail reason", failReason)) - task.state = state - task.failReason = failReason - } -} - -func (i *IndexNode) foreachAnalyzeTaskInfo(fn func(clusterID string, taskID UniqueID, info *analyzeTaskInfo)) { - i.stateLock.Lock() - defer i.stateLock.Unlock() - for key, info := range i.analyzeTasks { - fn(key.ClusterID, key.TaskID, info) - } -} - -func (i *IndexNode) storeAnalyzeFilesAndStatistic( - ClusterID string, - taskID UniqueID, - centroidsFile string, -) { - key := taskKey{ClusterID: ClusterID, TaskID: taskID} - i.stateLock.Lock() - defer i.stateLock.Unlock() - if info, ok := i.analyzeTasks[key]; ok { - info.centroidsFile = centroidsFile - return - } -} - -func (i *IndexNode) getAnalyzeTaskInfo(clusterID string, taskID UniqueID) *analyzeTaskInfo { - i.stateLock.Lock() - defer i.stateLock.Unlock() - - if info, ok := i.analyzeTasks[taskKey{ClusterID: clusterID, TaskID: taskID}]; ok { - return &analyzeTaskInfo{ - cancel: info.cancel, - state: info.state, - failReason: info.failReason, - centroidsFile: info.centroidsFile, - } - } - return nil -} - -func (i *IndexNode) deleteAnalyzeTaskInfos(ctx context.Context, keys []taskKey) []*analyzeTaskInfo { - i.stateLock.Lock() - defer i.stateLock.Unlock() - deleted := make([]*analyzeTaskInfo, 0, len(keys)) - for _, key := range keys { - info, ok := i.analyzeTasks[key] - if ok { - deleted = append(deleted, info) - delete(i.analyzeTasks, key) - log.Ctx(ctx).Info("delete analyze task infos", - zap.String("clusterID", key.ClusterID), zap.Int64("TaskID", key.TaskID)) - } - } - return deleted -} - -func (i *IndexNode) deleteAllAnalyzeTasks() []*analyzeTaskInfo { - i.stateLock.Lock() - deletedTasks := i.analyzeTasks - i.analyzeTasks = make(map[taskKey]*analyzeTaskInfo) - i.stateLock.Unlock() - - deleted := make([]*analyzeTaskInfo, 0, len(deletedTasks)) - for _, info := range deletedTasks { - deleted = append(deleted, info) - } - return deleted -} - -func (i *IndexNode) hasInProgressTask() bool { - i.stateLock.Lock() - defer i.stateLock.Unlock() - for _, info := range i.indexTasks { - if info.state == commonpb.IndexState_InProgress { - return true - } - } - - for _, info := range i.analyzeTasks { - if info.state == indexpb.JobState_JobStateInProgress { - return true - } - } - return false -} - -func (i *IndexNode) waitTaskFinish() { - if !i.hasInProgressTask() { - return - } - - gracefulTimeout := &Params.IndexNodeCfg.GracefulStopTimeout - ticker := time.NewTicker(time.Second) - defer ticker.Stop() - - timeoutCtx, cancel := context.WithTimeout(i.loopCtx, gracefulTimeout.GetAsDuration(time.Second)) - defer cancel() - for { - select { - case <-ticker.C: - if !i.hasInProgressTask() { - return - } - case <-timeoutCtx.Done(): - log.Warn("timeout, the index node has some progress task") - for _, info := range i.indexTasks { - if info.state == commonpb.IndexState_InProgress { - log.Warn("progress task", zap.Any("info", info)) - } - } - for _, info := range i.analyzeTasks { - if info.state == indexpb.JobState_JobStateInProgress { - log.Warn("progress task", zap.Any("info", info)) - } - } - return - } - } -} - -type statsTaskInfo struct { - cancel context.CancelFunc - state indexpb.JobState - failReason string - collID UniqueID - partID UniqueID - segID UniqueID - insertChannel string - numRows int64 - insertLogs []*datapb.FieldBinlog - statsLogs []*datapb.FieldBinlog - textStatsLogs map[int64]*datapb.TextIndexStats - bm25Logs []*datapb.FieldBinlog -} - -func (i *IndexNode) loadOrStoreStatsTask(clusterID string, taskID UniqueID, info *statsTaskInfo) *statsTaskInfo { - i.stateLock.Lock() - defer i.stateLock.Unlock() - key := taskKey{ClusterID: clusterID, TaskID: taskID} - oldInfo, ok := i.statsTasks[key] - if ok { - return oldInfo - } - i.statsTasks[key] = info - return nil -} - -func (i *IndexNode) getStatsTaskState(clusterID string, taskID UniqueID) indexpb.JobState { - key := taskKey{ClusterID: clusterID, TaskID: taskID} - i.stateLock.Lock() - defer i.stateLock.Unlock() - task, ok := i.statsTasks[key] - if !ok { - return indexpb.JobState_JobStateNone - } - return task.state -} - -func (i *IndexNode) storeStatsTaskState(clusterID string, taskID UniqueID, state indexpb.JobState, failReason string) { - key := taskKey{ClusterID: clusterID, TaskID: taskID} - i.stateLock.Lock() - defer i.stateLock.Unlock() - if task, ok := i.statsTasks[key]; ok { - log.Info("IndexNode store stats task state", zap.String("clusterID", clusterID), zap.Int64("TaskID", taskID), - zap.String("state", state.String()), zap.String("fail reason", failReason)) - task.state = state - task.failReason = failReason - } -} - -func (i *IndexNode) storePKSortStatsResult( - ClusterID string, - taskID UniqueID, - collID UniqueID, - partID UniqueID, - segID UniqueID, - channel string, - numRows int64, - insertLogs []*datapb.FieldBinlog, - statsLogs []*datapb.FieldBinlog, - bm25Logs []*datapb.FieldBinlog, -) { - key := taskKey{ClusterID: ClusterID, TaskID: taskID} - i.stateLock.Lock() - defer i.stateLock.Unlock() - if info, ok := i.statsTasks[key]; ok { - info.collID = collID - info.partID = partID - info.segID = segID - info.insertChannel = channel - info.numRows = numRows - info.insertLogs = insertLogs - info.statsLogs = statsLogs - info.bm25Logs = bm25Logs - return - } -} - -func (i *IndexNode) storeStatsTextIndexResult( - ClusterID string, - taskID UniqueID, - collID UniqueID, - partID UniqueID, - segID UniqueID, - channel string, - texIndexLogs map[int64]*datapb.TextIndexStats, -) { - key := taskKey{ClusterID: ClusterID, TaskID: taskID} - i.stateLock.Lock() - defer i.stateLock.Unlock() - if info, ok := i.statsTasks[key]; ok { - info.textStatsLogs = texIndexLogs - info.segID = segID - info.collID = collID - info.partID = partID - info.insertChannel = channel - } -} - -func (i *IndexNode) getStatsTaskInfo(clusterID string, taskID UniqueID) *statsTaskInfo { - i.stateLock.Lock() - defer i.stateLock.Unlock() - - if info, ok := i.statsTasks[taskKey{ClusterID: clusterID, TaskID: taskID}]; ok { - return &statsTaskInfo{ - cancel: info.cancel, - state: info.state, - failReason: info.failReason, - collID: info.collID, - partID: info.partID, - segID: info.segID, - insertChannel: info.insertChannel, - numRows: info.numRows, - insertLogs: info.insertLogs, - statsLogs: info.statsLogs, - textStatsLogs: info.textStatsLogs, - bm25Logs: info.bm25Logs, - } - } - return nil -} - -func (i *IndexNode) deleteStatsTaskInfos(ctx context.Context, keys []taskKey) []*statsTaskInfo { - i.stateLock.Lock() - defer i.stateLock.Unlock() - deleted := make([]*statsTaskInfo, 0, len(keys)) - for _, key := range keys { - info, ok := i.statsTasks[key] - if ok { - deleted = append(deleted, info) - delete(i.statsTasks, key) - log.Ctx(ctx).Info("delete stats task infos", - zap.String("clusterID", key.ClusterID), zap.Int64("TaskID", key.TaskID)) - } - } - return deleted -} - -func (i *IndexNode) deleteAllStatsTasks() []*statsTaskInfo { - i.stateLock.Lock() - deletedTasks := i.statsTasks - i.statsTasks = make(map[taskKey]*statsTaskInfo) - i.stateLock.Unlock() - - deleted := make([]*statsTaskInfo, 0, len(deletedTasks)) - for _, info := range deletedTasks { - deleted = append(deleted, info) - } - return deleted -} diff --git a/internal/mocks/mock_datacoord.go b/internal/mocks/mock_datacoord.go index fa06349688..915d4dfac8 100644 --- a/internal/mocks/mock_datacoord.go +++ b/internal/mocks/mock_datacoord.go @@ -2821,39 +2821,6 @@ func (_c *MockDataCoord_SetEtcdClient_Call) RunAndReturn(run func(*clientv3.Clie return _c } -// SetIndexNodeCreator provides a mock function with given fields: _a0 -func (_m *MockDataCoord) SetIndexNodeCreator(_a0 func(context.Context, string, int64) (types.IndexNodeClient, error)) { - _m.Called(_a0) -} - -// MockDataCoord_SetIndexNodeCreator_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetIndexNodeCreator' -type MockDataCoord_SetIndexNodeCreator_Call struct { - *mock.Call -} - -// SetIndexNodeCreator is a helper method to define mock.On call -// - _a0 func(context.Context , string , int64)(types.IndexNodeClient , error) -func (_e *MockDataCoord_Expecter) SetIndexNodeCreator(_a0 interface{}) *MockDataCoord_SetIndexNodeCreator_Call { - return &MockDataCoord_SetIndexNodeCreator_Call{Call: _e.mock.On("SetIndexNodeCreator", _a0)} -} - -func (_c *MockDataCoord_SetIndexNodeCreator_Call) Run(run func(_a0 func(context.Context, string, int64) (types.IndexNodeClient, error))) *MockDataCoord_SetIndexNodeCreator_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(func(context.Context, string, int64) (types.IndexNodeClient, error))) - }) - return _c -} - -func (_c *MockDataCoord_SetIndexNodeCreator_Call) Return() *MockDataCoord_SetIndexNodeCreator_Call { - _c.Call.Return() - return _c -} - -func (_c *MockDataCoord_SetIndexNodeCreator_Call) RunAndReturn(run func(func(context.Context, string, int64) (types.IndexNodeClient, error))) *MockDataCoord_SetIndexNodeCreator_Call { - _c.Call.Return(run) - return _c -} - // SetRootCoordClient provides a mock function with given fields: rootCoord func (_m *MockDataCoord) SetRootCoordClient(rootCoord types.RootCoordClient) { _m.Called(rootCoord) diff --git a/internal/mocks/mock_datanode.go b/internal/mocks/mock_datanode.go index 9c3d6aac90..ba02d94fe4 100644 --- a/internal/mocks/mock_datanode.go +++ b/internal/mocks/mock_datanode.go @@ -17,6 +17,8 @@ import ( mock "github.com/stretchr/testify/mock" types "github.com/milvus-io/milvus/internal/types" + + workerpb "github.com/milvus-io/milvus/pkg/v2/proto/workerpb" ) // MockDataNode is an autogenerated mock type for the DataNodeComponent type @@ -150,6 +152,124 @@ func (_c *MockDataNode_CompactionV2_Call) RunAndReturn(run func(context.Context, return _c } +// CreateJob provides a mock function with given fields: _a0, _a1 +func (_m *MockDataNode) CreateJob(_a0 context.Context, _a1 *workerpb.CreateJobRequest) (*commonpb.Status, error) { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for CreateJob") + } + + var r0 *commonpb.Status + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.CreateJobRequest) (*commonpb.Status, error)); ok { + return rf(_a0, _a1) + } + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.CreateJobRequest) *commonpb.Status); ok { + r0 = rf(_a0, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*commonpb.Status) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *workerpb.CreateJobRequest) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataNode_CreateJob_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateJob' +type MockDataNode_CreateJob_Call struct { + *mock.Call +} + +// CreateJob is a helper method to define mock.On call +// - _a0 context.Context +// - _a1 *workerpb.CreateJobRequest +func (_e *MockDataNode_Expecter) CreateJob(_a0 interface{}, _a1 interface{}) *MockDataNode_CreateJob_Call { + return &MockDataNode_CreateJob_Call{Call: _e.mock.On("CreateJob", _a0, _a1)} +} + +func (_c *MockDataNode_CreateJob_Call) Run(run func(_a0 context.Context, _a1 *workerpb.CreateJobRequest)) *MockDataNode_CreateJob_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*workerpb.CreateJobRequest)) + }) + return _c +} + +func (_c *MockDataNode_CreateJob_Call) Return(_a0 *commonpb.Status, _a1 error) *MockDataNode_CreateJob_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataNode_CreateJob_Call) RunAndReturn(run func(context.Context, *workerpb.CreateJobRequest) (*commonpb.Status, error)) *MockDataNode_CreateJob_Call { + _c.Call.Return(run) + return _c +} + +// CreateJobV2 provides a mock function with given fields: _a0, _a1 +func (_m *MockDataNode) CreateJobV2(_a0 context.Context, _a1 *workerpb.CreateJobV2Request) (*commonpb.Status, error) { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for CreateJobV2") + } + + var r0 *commonpb.Status + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.CreateJobV2Request) (*commonpb.Status, error)); ok { + return rf(_a0, _a1) + } + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.CreateJobV2Request) *commonpb.Status); ok { + r0 = rf(_a0, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*commonpb.Status) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *workerpb.CreateJobV2Request) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataNode_CreateJobV2_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateJobV2' +type MockDataNode_CreateJobV2_Call struct { + *mock.Call +} + +// CreateJobV2 is a helper method to define mock.On call +// - _a0 context.Context +// - _a1 *workerpb.CreateJobV2Request +func (_e *MockDataNode_Expecter) CreateJobV2(_a0 interface{}, _a1 interface{}) *MockDataNode_CreateJobV2_Call { + return &MockDataNode_CreateJobV2_Call{Call: _e.mock.On("CreateJobV2", _a0, _a1)} +} + +func (_c *MockDataNode_CreateJobV2_Call) Run(run func(_a0 context.Context, _a1 *workerpb.CreateJobV2Request)) *MockDataNode_CreateJobV2_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*workerpb.CreateJobV2Request)) + }) + return _c +} + +func (_c *MockDataNode_CreateJobV2_Call) Return(_a0 *commonpb.Status, _a1 error) *MockDataNode_CreateJobV2_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataNode_CreateJobV2_Call) RunAndReturn(run func(context.Context, *workerpb.CreateJobV2Request) (*commonpb.Status, error)) *MockDataNode_CreateJobV2_Call { + _c.Call.Return(run) + return _c +} + // DropCompactionPlan provides a mock function with given fields: _a0, _a1 func (_m *MockDataNode) DropCompactionPlan(_a0 context.Context, _a1 *datapb.DropCompactionPlanRequest) (*commonpb.Status, error) { ret := _m.Called(_a0, _a1) @@ -268,6 +388,124 @@ func (_c *MockDataNode_DropImport_Call) RunAndReturn(run func(context.Context, * return _c } +// DropJobs provides a mock function with given fields: _a0, _a1 +func (_m *MockDataNode) DropJobs(_a0 context.Context, _a1 *workerpb.DropJobsRequest) (*commonpb.Status, error) { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for DropJobs") + } + + var r0 *commonpb.Status + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.DropJobsRequest) (*commonpb.Status, error)); ok { + return rf(_a0, _a1) + } + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.DropJobsRequest) *commonpb.Status); ok { + r0 = rf(_a0, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*commonpb.Status) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *workerpb.DropJobsRequest) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataNode_DropJobs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DropJobs' +type MockDataNode_DropJobs_Call struct { + *mock.Call +} + +// DropJobs is a helper method to define mock.On call +// - _a0 context.Context +// - _a1 *workerpb.DropJobsRequest +func (_e *MockDataNode_Expecter) DropJobs(_a0 interface{}, _a1 interface{}) *MockDataNode_DropJobs_Call { + return &MockDataNode_DropJobs_Call{Call: _e.mock.On("DropJobs", _a0, _a1)} +} + +func (_c *MockDataNode_DropJobs_Call) Run(run func(_a0 context.Context, _a1 *workerpb.DropJobsRequest)) *MockDataNode_DropJobs_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*workerpb.DropJobsRequest)) + }) + return _c +} + +func (_c *MockDataNode_DropJobs_Call) Return(_a0 *commonpb.Status, _a1 error) *MockDataNode_DropJobs_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataNode_DropJobs_Call) RunAndReturn(run func(context.Context, *workerpb.DropJobsRequest) (*commonpb.Status, error)) *MockDataNode_DropJobs_Call { + _c.Call.Return(run) + return _c +} + +// DropJobsV2 provides a mock function with given fields: _a0, _a1 +func (_m *MockDataNode) DropJobsV2(_a0 context.Context, _a1 *workerpb.DropJobsV2Request) (*commonpb.Status, error) { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for DropJobsV2") + } + + var r0 *commonpb.Status + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.DropJobsV2Request) (*commonpb.Status, error)); ok { + return rf(_a0, _a1) + } + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.DropJobsV2Request) *commonpb.Status); ok { + r0 = rf(_a0, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*commonpb.Status) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *workerpb.DropJobsV2Request) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataNode_DropJobsV2_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DropJobsV2' +type MockDataNode_DropJobsV2_Call struct { + *mock.Call +} + +// DropJobsV2 is a helper method to define mock.On call +// - _a0 context.Context +// - _a1 *workerpb.DropJobsV2Request +func (_e *MockDataNode_Expecter) DropJobsV2(_a0 interface{}, _a1 interface{}) *MockDataNode_DropJobsV2_Call { + return &MockDataNode_DropJobsV2_Call{Call: _e.mock.On("DropJobsV2", _a0, _a1)} +} + +func (_c *MockDataNode_DropJobsV2_Call) Run(run func(_a0 context.Context, _a1 *workerpb.DropJobsV2Request)) *MockDataNode_DropJobsV2_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*workerpb.DropJobsV2Request)) + }) + return _c +} + +func (_c *MockDataNode_DropJobsV2_Call) Return(_a0 *commonpb.Status, _a1 error) *MockDataNode_DropJobsV2_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataNode_DropJobsV2_Call) RunAndReturn(run func(context.Context, *workerpb.DropJobsV2Request) (*commonpb.Status, error)) *MockDataNode_DropJobsV2_Call { + _c.Call.Return(run) + return _c +} + // FlushChannels provides a mock function with given fields: _a0, _a1 func (_m *MockDataNode) FlushChannels(_a0 context.Context, _a1 *datapb.FlushChannelsRequest) (*commonpb.Status, error) { ret := _m.Called(_a0, _a1) @@ -549,6 +787,65 @@ func (_c *MockDataNode_GetComponentStates_Call) RunAndReturn(run func(context.Co return _c } +// GetJobStats provides a mock function with given fields: _a0, _a1 +func (_m *MockDataNode) GetJobStats(_a0 context.Context, _a1 *workerpb.GetJobStatsRequest) (*workerpb.GetJobStatsResponse, error) { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for GetJobStats") + } + + var r0 *workerpb.GetJobStatsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.GetJobStatsRequest) (*workerpb.GetJobStatsResponse, error)); ok { + return rf(_a0, _a1) + } + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.GetJobStatsRequest) *workerpb.GetJobStatsResponse); ok { + r0 = rf(_a0, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*workerpb.GetJobStatsResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *workerpb.GetJobStatsRequest) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataNode_GetJobStats_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetJobStats' +type MockDataNode_GetJobStats_Call struct { + *mock.Call +} + +// GetJobStats is a helper method to define mock.On call +// - _a0 context.Context +// - _a1 *workerpb.GetJobStatsRequest +func (_e *MockDataNode_Expecter) GetJobStats(_a0 interface{}, _a1 interface{}) *MockDataNode_GetJobStats_Call { + return &MockDataNode_GetJobStats_Call{Call: _e.mock.On("GetJobStats", _a0, _a1)} +} + +func (_c *MockDataNode_GetJobStats_Call) Run(run func(_a0 context.Context, _a1 *workerpb.GetJobStatsRequest)) *MockDataNode_GetJobStats_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*workerpb.GetJobStatsRequest)) + }) + return _c +} + +func (_c *MockDataNode_GetJobStats_Call) Return(_a0 *workerpb.GetJobStatsResponse, _a1 error) *MockDataNode_GetJobStats_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataNode_GetJobStats_Call) RunAndReturn(run func(context.Context, *workerpb.GetJobStatsRequest) (*workerpb.GetJobStatsResponse, error)) *MockDataNode_GetJobStats_Call { + _c.Call.Return(run) + return _c +} + // GetMetrics provides a mock function with given fields: _a0, _a1 func (_m *MockDataNode) GetMetrics(_a0 context.Context, _a1 *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) { ret := _m.Called(_a0, _a1) @@ -1038,6 +1335,124 @@ func (_c *MockDataNode_QueryImport_Call) RunAndReturn(run func(context.Context, return _c } +// QueryJobs provides a mock function with given fields: _a0, _a1 +func (_m *MockDataNode) QueryJobs(_a0 context.Context, _a1 *workerpb.QueryJobsRequest) (*workerpb.QueryJobsResponse, error) { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for QueryJobs") + } + + var r0 *workerpb.QueryJobsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.QueryJobsRequest) (*workerpb.QueryJobsResponse, error)); ok { + return rf(_a0, _a1) + } + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.QueryJobsRequest) *workerpb.QueryJobsResponse); ok { + r0 = rf(_a0, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*workerpb.QueryJobsResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *workerpb.QueryJobsRequest) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataNode_QueryJobs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'QueryJobs' +type MockDataNode_QueryJobs_Call struct { + *mock.Call +} + +// QueryJobs is a helper method to define mock.On call +// - _a0 context.Context +// - _a1 *workerpb.QueryJobsRequest +func (_e *MockDataNode_Expecter) QueryJobs(_a0 interface{}, _a1 interface{}) *MockDataNode_QueryJobs_Call { + return &MockDataNode_QueryJobs_Call{Call: _e.mock.On("QueryJobs", _a0, _a1)} +} + +func (_c *MockDataNode_QueryJobs_Call) Run(run func(_a0 context.Context, _a1 *workerpb.QueryJobsRequest)) *MockDataNode_QueryJobs_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*workerpb.QueryJobsRequest)) + }) + return _c +} + +func (_c *MockDataNode_QueryJobs_Call) Return(_a0 *workerpb.QueryJobsResponse, _a1 error) *MockDataNode_QueryJobs_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataNode_QueryJobs_Call) RunAndReturn(run func(context.Context, *workerpb.QueryJobsRequest) (*workerpb.QueryJobsResponse, error)) *MockDataNode_QueryJobs_Call { + _c.Call.Return(run) + return _c +} + +// QueryJobsV2 provides a mock function with given fields: _a0, _a1 +func (_m *MockDataNode) QueryJobsV2(_a0 context.Context, _a1 *workerpb.QueryJobsV2Request) (*workerpb.QueryJobsV2Response, error) { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for QueryJobsV2") + } + + var r0 *workerpb.QueryJobsV2Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.QueryJobsV2Request) (*workerpb.QueryJobsV2Response, error)); ok { + return rf(_a0, _a1) + } + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.QueryJobsV2Request) *workerpb.QueryJobsV2Response); ok { + r0 = rf(_a0, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*workerpb.QueryJobsV2Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *workerpb.QueryJobsV2Request) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataNode_QueryJobsV2_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'QueryJobsV2' +type MockDataNode_QueryJobsV2_Call struct { + *mock.Call +} + +// QueryJobsV2 is a helper method to define mock.On call +// - _a0 context.Context +// - _a1 *workerpb.QueryJobsV2Request +func (_e *MockDataNode_Expecter) QueryJobsV2(_a0 interface{}, _a1 interface{}) *MockDataNode_QueryJobsV2_Call { + return &MockDataNode_QueryJobsV2_Call{Call: _e.mock.On("QueryJobsV2", _a0, _a1)} +} + +func (_c *MockDataNode_QueryJobsV2_Call) Run(run func(_a0 context.Context, _a1 *workerpb.QueryJobsV2Request)) *MockDataNode_QueryJobsV2_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*workerpb.QueryJobsV2Request)) + }) + return _c +} + +func (_c *MockDataNode_QueryJobsV2_Call) Return(_a0 *workerpb.QueryJobsV2Response, _a1 error) *MockDataNode_QueryJobsV2_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataNode_QueryJobsV2_Call) RunAndReturn(run func(context.Context, *workerpb.QueryJobsV2Request) (*workerpb.QueryJobsV2Response, error)) *MockDataNode_QueryJobsV2_Call { + _c.Call.Return(run) + return _c +} + // QueryPreImport provides a mock function with given fields: _a0, _a1 func (_m *MockDataNode) QueryPreImport(_a0 context.Context, _a1 *datapb.QueryPreImportRequest) (*datapb.QueryPreImportResponse, error) { ret := _m.Called(_a0, _a1) diff --git a/internal/mocks/mock_datanode_client.go b/internal/mocks/mock_datanode_client.go index 948db62946..36e3a3ce86 100644 --- a/internal/mocks/mock_datanode_client.go +++ b/internal/mocks/mock_datanode_client.go @@ -16,6 +16,8 @@ import ( milvuspb "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" mock "github.com/stretchr/testify/mock" + + workerpb "github.com/milvus-io/milvus/pkg/v2/proto/workerpb" ) // MockDataNodeClient is an autogenerated mock type for the DataNodeClient type @@ -224,6 +226,154 @@ func (_c *MockDataNodeClient_CompactionV2_Call) RunAndReturn(run func(context.Co return _c } +// CreateJob provides a mock function with given fields: ctx, in, opts +func (_m *MockDataNodeClient) CreateJob(ctx context.Context, in *workerpb.CreateJobRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateJob") + } + + var r0 *commonpb.Status + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.CreateJobRequest, ...grpc.CallOption) (*commonpb.Status, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.CreateJobRequest, ...grpc.CallOption) *commonpb.Status); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*commonpb.Status) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *workerpb.CreateJobRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataNodeClient_CreateJob_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateJob' +type MockDataNodeClient_CreateJob_Call struct { + *mock.Call +} + +// CreateJob is a helper method to define mock.On call +// - ctx context.Context +// - in *workerpb.CreateJobRequest +// - opts ...grpc.CallOption +func (_e *MockDataNodeClient_Expecter) CreateJob(ctx interface{}, in interface{}, opts ...interface{}) *MockDataNodeClient_CreateJob_Call { + return &MockDataNodeClient_CreateJob_Call{Call: _e.mock.On("CreateJob", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *MockDataNodeClient_CreateJob_Call) Run(run func(ctx context.Context, in *workerpb.CreateJobRequest, opts ...grpc.CallOption)) *MockDataNodeClient_CreateJob_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*workerpb.CreateJobRequest), variadicArgs...) + }) + return _c +} + +func (_c *MockDataNodeClient_CreateJob_Call) Return(_a0 *commonpb.Status, _a1 error) *MockDataNodeClient_CreateJob_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataNodeClient_CreateJob_Call) RunAndReturn(run func(context.Context, *workerpb.CreateJobRequest, ...grpc.CallOption) (*commonpb.Status, error)) *MockDataNodeClient_CreateJob_Call { + _c.Call.Return(run) + return _c +} + +// CreateJobV2 provides a mock function with given fields: ctx, in, opts +func (_m *MockDataNodeClient) CreateJobV2(ctx context.Context, in *workerpb.CreateJobV2Request, opts ...grpc.CallOption) (*commonpb.Status, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateJobV2") + } + + var r0 *commonpb.Status + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.CreateJobV2Request, ...grpc.CallOption) (*commonpb.Status, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.CreateJobV2Request, ...grpc.CallOption) *commonpb.Status); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*commonpb.Status) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *workerpb.CreateJobV2Request, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataNodeClient_CreateJobV2_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateJobV2' +type MockDataNodeClient_CreateJobV2_Call struct { + *mock.Call +} + +// CreateJobV2 is a helper method to define mock.On call +// - ctx context.Context +// - in *workerpb.CreateJobV2Request +// - opts ...grpc.CallOption +func (_e *MockDataNodeClient_Expecter) CreateJobV2(ctx interface{}, in interface{}, opts ...interface{}) *MockDataNodeClient_CreateJobV2_Call { + return &MockDataNodeClient_CreateJobV2_Call{Call: _e.mock.On("CreateJobV2", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *MockDataNodeClient_CreateJobV2_Call) Run(run func(ctx context.Context, in *workerpb.CreateJobV2Request, opts ...grpc.CallOption)) *MockDataNodeClient_CreateJobV2_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*workerpb.CreateJobV2Request), variadicArgs...) + }) + return _c +} + +func (_c *MockDataNodeClient_CreateJobV2_Call) Return(_a0 *commonpb.Status, _a1 error) *MockDataNodeClient_CreateJobV2_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataNodeClient_CreateJobV2_Call) RunAndReturn(run func(context.Context, *workerpb.CreateJobV2Request, ...grpc.CallOption) (*commonpb.Status, error)) *MockDataNodeClient_CreateJobV2_Call { + _c.Call.Return(run) + return _c +} + // DropCompactionPlan provides a mock function with given fields: ctx, in, opts func (_m *MockDataNodeClient) DropCompactionPlan(ctx context.Context, in *datapb.DropCompactionPlanRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { _va := make([]interface{}, len(opts)) @@ -372,6 +522,154 @@ func (_c *MockDataNodeClient_DropImport_Call) RunAndReturn(run func(context.Cont return _c } +// DropJobs provides a mock function with given fields: ctx, in, opts +func (_m *MockDataNodeClient) DropJobs(ctx context.Context, in *workerpb.DropJobsRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for DropJobs") + } + + var r0 *commonpb.Status + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.DropJobsRequest, ...grpc.CallOption) (*commonpb.Status, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.DropJobsRequest, ...grpc.CallOption) *commonpb.Status); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*commonpb.Status) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *workerpb.DropJobsRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataNodeClient_DropJobs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DropJobs' +type MockDataNodeClient_DropJobs_Call struct { + *mock.Call +} + +// DropJobs is a helper method to define mock.On call +// - ctx context.Context +// - in *workerpb.DropJobsRequest +// - opts ...grpc.CallOption +func (_e *MockDataNodeClient_Expecter) DropJobs(ctx interface{}, in interface{}, opts ...interface{}) *MockDataNodeClient_DropJobs_Call { + return &MockDataNodeClient_DropJobs_Call{Call: _e.mock.On("DropJobs", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *MockDataNodeClient_DropJobs_Call) Run(run func(ctx context.Context, in *workerpb.DropJobsRequest, opts ...grpc.CallOption)) *MockDataNodeClient_DropJobs_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*workerpb.DropJobsRequest), variadicArgs...) + }) + return _c +} + +func (_c *MockDataNodeClient_DropJobs_Call) Return(_a0 *commonpb.Status, _a1 error) *MockDataNodeClient_DropJobs_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataNodeClient_DropJobs_Call) RunAndReturn(run func(context.Context, *workerpb.DropJobsRequest, ...grpc.CallOption) (*commonpb.Status, error)) *MockDataNodeClient_DropJobs_Call { + _c.Call.Return(run) + return _c +} + +// DropJobsV2 provides a mock function with given fields: ctx, in, opts +func (_m *MockDataNodeClient) DropJobsV2(ctx context.Context, in *workerpb.DropJobsV2Request, opts ...grpc.CallOption) (*commonpb.Status, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for DropJobsV2") + } + + var r0 *commonpb.Status + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.DropJobsV2Request, ...grpc.CallOption) (*commonpb.Status, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.DropJobsV2Request, ...grpc.CallOption) *commonpb.Status); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*commonpb.Status) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *workerpb.DropJobsV2Request, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataNodeClient_DropJobsV2_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DropJobsV2' +type MockDataNodeClient_DropJobsV2_Call struct { + *mock.Call +} + +// DropJobsV2 is a helper method to define mock.On call +// - ctx context.Context +// - in *workerpb.DropJobsV2Request +// - opts ...grpc.CallOption +func (_e *MockDataNodeClient_Expecter) DropJobsV2(ctx interface{}, in interface{}, opts ...interface{}) *MockDataNodeClient_DropJobsV2_Call { + return &MockDataNodeClient_DropJobsV2_Call{Call: _e.mock.On("DropJobsV2", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *MockDataNodeClient_DropJobsV2_Call) Run(run func(ctx context.Context, in *workerpb.DropJobsV2Request, opts ...grpc.CallOption)) *MockDataNodeClient_DropJobsV2_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*workerpb.DropJobsV2Request), variadicArgs...) + }) + return _c +} + +func (_c *MockDataNodeClient_DropJobsV2_Call) Return(_a0 *commonpb.Status, _a1 error) *MockDataNodeClient_DropJobsV2_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataNodeClient_DropJobsV2_Call) RunAndReturn(run func(context.Context, *workerpb.DropJobsV2Request, ...grpc.CallOption) (*commonpb.Status, error)) *MockDataNodeClient_DropJobsV2_Call { + _c.Call.Return(run) + return _c +} + // FlushChannels provides a mock function with given fields: ctx, in, opts func (_m *MockDataNodeClient) FlushChannels(ctx context.Context, in *datapb.FlushChannelsRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { _va := make([]interface{}, len(opts)) @@ -668,6 +966,80 @@ func (_c *MockDataNodeClient_GetComponentStates_Call) RunAndReturn(run func(cont return _c } +// GetJobStats provides a mock function with given fields: ctx, in, opts +func (_m *MockDataNodeClient) GetJobStats(ctx context.Context, in *workerpb.GetJobStatsRequest, opts ...grpc.CallOption) (*workerpb.GetJobStatsResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetJobStats") + } + + var r0 *workerpb.GetJobStatsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.GetJobStatsRequest, ...grpc.CallOption) (*workerpb.GetJobStatsResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.GetJobStatsRequest, ...grpc.CallOption) *workerpb.GetJobStatsResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*workerpb.GetJobStatsResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *workerpb.GetJobStatsRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataNodeClient_GetJobStats_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetJobStats' +type MockDataNodeClient_GetJobStats_Call struct { + *mock.Call +} + +// GetJobStats is a helper method to define mock.On call +// - ctx context.Context +// - in *workerpb.GetJobStatsRequest +// - opts ...grpc.CallOption +func (_e *MockDataNodeClient_Expecter) GetJobStats(ctx interface{}, in interface{}, opts ...interface{}) *MockDataNodeClient_GetJobStats_Call { + return &MockDataNodeClient_GetJobStats_Call{Call: _e.mock.On("GetJobStats", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *MockDataNodeClient_GetJobStats_Call) Run(run func(ctx context.Context, in *workerpb.GetJobStatsRequest, opts ...grpc.CallOption)) *MockDataNodeClient_GetJobStats_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*workerpb.GetJobStatsRequest), variadicArgs...) + }) + return _c +} + +func (_c *MockDataNodeClient_GetJobStats_Call) Return(_a0 *workerpb.GetJobStatsResponse, _a1 error) *MockDataNodeClient_GetJobStats_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataNodeClient_GetJobStats_Call) RunAndReturn(run func(context.Context, *workerpb.GetJobStatsRequest, ...grpc.CallOption) (*workerpb.GetJobStatsResponse, error)) *MockDataNodeClient_GetJobStats_Call { + _c.Call.Return(run) + return _c +} + // GetMetrics provides a mock function with given fields: ctx, in, opts func (_m *MockDataNodeClient) GetMetrics(ctx context.Context, in *milvuspb.GetMetricsRequest, opts ...grpc.CallOption) (*milvuspb.GetMetricsResponse, error) { _va := make([]interface{}, len(opts)) @@ -1112,6 +1484,154 @@ func (_c *MockDataNodeClient_QueryImport_Call) RunAndReturn(run func(context.Con return _c } +// QueryJobs provides a mock function with given fields: ctx, in, opts +func (_m *MockDataNodeClient) QueryJobs(ctx context.Context, in *workerpb.QueryJobsRequest, opts ...grpc.CallOption) (*workerpb.QueryJobsResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for QueryJobs") + } + + var r0 *workerpb.QueryJobsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.QueryJobsRequest, ...grpc.CallOption) (*workerpb.QueryJobsResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.QueryJobsRequest, ...grpc.CallOption) *workerpb.QueryJobsResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*workerpb.QueryJobsResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *workerpb.QueryJobsRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataNodeClient_QueryJobs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'QueryJobs' +type MockDataNodeClient_QueryJobs_Call struct { + *mock.Call +} + +// QueryJobs is a helper method to define mock.On call +// - ctx context.Context +// - in *workerpb.QueryJobsRequest +// - opts ...grpc.CallOption +func (_e *MockDataNodeClient_Expecter) QueryJobs(ctx interface{}, in interface{}, opts ...interface{}) *MockDataNodeClient_QueryJobs_Call { + return &MockDataNodeClient_QueryJobs_Call{Call: _e.mock.On("QueryJobs", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *MockDataNodeClient_QueryJobs_Call) Run(run func(ctx context.Context, in *workerpb.QueryJobsRequest, opts ...grpc.CallOption)) *MockDataNodeClient_QueryJobs_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*workerpb.QueryJobsRequest), variadicArgs...) + }) + return _c +} + +func (_c *MockDataNodeClient_QueryJobs_Call) Return(_a0 *workerpb.QueryJobsResponse, _a1 error) *MockDataNodeClient_QueryJobs_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataNodeClient_QueryJobs_Call) RunAndReturn(run func(context.Context, *workerpb.QueryJobsRequest, ...grpc.CallOption) (*workerpb.QueryJobsResponse, error)) *MockDataNodeClient_QueryJobs_Call { + _c.Call.Return(run) + return _c +} + +// QueryJobsV2 provides a mock function with given fields: ctx, in, opts +func (_m *MockDataNodeClient) QueryJobsV2(ctx context.Context, in *workerpb.QueryJobsV2Request, opts ...grpc.CallOption) (*workerpb.QueryJobsV2Response, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for QueryJobsV2") + } + + var r0 *workerpb.QueryJobsV2Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.QueryJobsV2Request, ...grpc.CallOption) (*workerpb.QueryJobsV2Response, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *workerpb.QueryJobsV2Request, ...grpc.CallOption) *workerpb.QueryJobsV2Response); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*workerpb.QueryJobsV2Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *workerpb.QueryJobsV2Request, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataNodeClient_QueryJobsV2_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'QueryJobsV2' +type MockDataNodeClient_QueryJobsV2_Call struct { + *mock.Call +} + +// QueryJobsV2 is a helper method to define mock.On call +// - ctx context.Context +// - in *workerpb.QueryJobsV2Request +// - opts ...grpc.CallOption +func (_e *MockDataNodeClient_Expecter) QueryJobsV2(ctx interface{}, in interface{}, opts ...interface{}) *MockDataNodeClient_QueryJobsV2_Call { + return &MockDataNodeClient_QueryJobsV2_Call{Call: _e.mock.On("QueryJobsV2", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *MockDataNodeClient_QueryJobsV2_Call) Run(run func(ctx context.Context, in *workerpb.QueryJobsV2Request, opts ...grpc.CallOption)) *MockDataNodeClient_QueryJobsV2_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*workerpb.QueryJobsV2Request), variadicArgs...) + }) + return _c +} + +func (_c *MockDataNodeClient_QueryJobsV2_Call) Return(_a0 *workerpb.QueryJobsV2Response, _a1 error) *MockDataNodeClient_QueryJobsV2_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataNodeClient_QueryJobsV2_Call) RunAndReturn(run func(context.Context, *workerpb.QueryJobsV2Request, ...grpc.CallOption) (*workerpb.QueryJobsV2Response, error)) *MockDataNodeClient_QueryJobsV2_Call { + _c.Call.Return(run) + return _c +} + // QueryPreImport provides a mock function with given fields: ctx, in, opts func (_m *MockDataNodeClient) QueryPreImport(ctx context.Context, in *datapb.QueryPreImportRequest, opts ...grpc.CallOption) (*datapb.QueryPreImportResponse, error) { _va := make([]interface{}, len(opts)) diff --git a/internal/mocks/mock_indexnode.go b/internal/mocks/mock_indexnode.go deleted file mode 100644 index 3f726a49c2..0000000000 --- a/internal/mocks/mock_indexnode.go +++ /dev/null @@ -1,1018 +0,0 @@ -// Code generated by mockery v2.46.0. DO NOT EDIT. - -package mocks - -import ( - context "context" - - commonpb "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" - clientv3 "go.etcd.io/etcd/client/v3" - - internalpb "github.com/milvus-io/milvus/pkg/v2/proto/internalpb" - - milvuspb "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" - - mock "github.com/stretchr/testify/mock" - - workerpb "github.com/milvus-io/milvus/pkg/v2/proto/workerpb" -) - -// MockIndexNode is an autogenerated mock type for the IndexNodeComponent type -type MockIndexNode struct { - mock.Mock -} - -type MockIndexNode_Expecter struct { - mock *mock.Mock -} - -func (_m *MockIndexNode) EXPECT() *MockIndexNode_Expecter { - return &MockIndexNode_Expecter{mock: &_m.Mock} -} - -// CreateJob provides a mock function with given fields: _a0, _a1 -func (_m *MockIndexNode) CreateJob(_a0 context.Context, _a1 *workerpb.CreateJobRequest) (*commonpb.Status, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for CreateJob") - } - - var r0 *commonpb.Status - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.CreateJobRequest) (*commonpb.Status, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.CreateJobRequest) *commonpb.Status); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*commonpb.Status) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *workerpb.CreateJobRequest) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNode_CreateJob_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateJob' -type MockIndexNode_CreateJob_Call struct { - *mock.Call -} - -// CreateJob is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 *workerpb.CreateJobRequest -func (_e *MockIndexNode_Expecter) CreateJob(_a0 interface{}, _a1 interface{}) *MockIndexNode_CreateJob_Call { - return &MockIndexNode_CreateJob_Call{Call: _e.mock.On("CreateJob", _a0, _a1)} -} - -func (_c *MockIndexNode_CreateJob_Call) Run(run func(_a0 context.Context, _a1 *workerpb.CreateJobRequest)) *MockIndexNode_CreateJob_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*workerpb.CreateJobRequest)) - }) - return _c -} - -func (_c *MockIndexNode_CreateJob_Call) Return(_a0 *commonpb.Status, _a1 error) *MockIndexNode_CreateJob_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNode_CreateJob_Call) RunAndReturn(run func(context.Context, *workerpb.CreateJobRequest) (*commonpb.Status, error)) *MockIndexNode_CreateJob_Call { - _c.Call.Return(run) - return _c -} - -// CreateJobV2 provides a mock function with given fields: _a0, _a1 -func (_m *MockIndexNode) CreateJobV2(_a0 context.Context, _a1 *workerpb.CreateJobV2Request) (*commonpb.Status, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for CreateJobV2") - } - - var r0 *commonpb.Status - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.CreateJobV2Request) (*commonpb.Status, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.CreateJobV2Request) *commonpb.Status); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*commonpb.Status) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *workerpb.CreateJobV2Request) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNode_CreateJobV2_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateJobV2' -type MockIndexNode_CreateJobV2_Call struct { - *mock.Call -} - -// CreateJobV2 is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 *workerpb.CreateJobV2Request -func (_e *MockIndexNode_Expecter) CreateJobV2(_a0 interface{}, _a1 interface{}) *MockIndexNode_CreateJobV2_Call { - return &MockIndexNode_CreateJobV2_Call{Call: _e.mock.On("CreateJobV2", _a0, _a1)} -} - -func (_c *MockIndexNode_CreateJobV2_Call) Run(run func(_a0 context.Context, _a1 *workerpb.CreateJobV2Request)) *MockIndexNode_CreateJobV2_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*workerpb.CreateJobV2Request)) - }) - return _c -} - -func (_c *MockIndexNode_CreateJobV2_Call) Return(_a0 *commonpb.Status, _a1 error) *MockIndexNode_CreateJobV2_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNode_CreateJobV2_Call) RunAndReturn(run func(context.Context, *workerpb.CreateJobV2Request) (*commonpb.Status, error)) *MockIndexNode_CreateJobV2_Call { - _c.Call.Return(run) - return _c -} - -// DropJobs provides a mock function with given fields: _a0, _a1 -func (_m *MockIndexNode) DropJobs(_a0 context.Context, _a1 *workerpb.DropJobsRequest) (*commonpb.Status, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for DropJobs") - } - - var r0 *commonpb.Status - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.DropJobsRequest) (*commonpb.Status, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.DropJobsRequest) *commonpb.Status); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*commonpb.Status) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *workerpb.DropJobsRequest) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNode_DropJobs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DropJobs' -type MockIndexNode_DropJobs_Call struct { - *mock.Call -} - -// DropJobs is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 *workerpb.DropJobsRequest -func (_e *MockIndexNode_Expecter) DropJobs(_a0 interface{}, _a1 interface{}) *MockIndexNode_DropJobs_Call { - return &MockIndexNode_DropJobs_Call{Call: _e.mock.On("DropJobs", _a0, _a1)} -} - -func (_c *MockIndexNode_DropJobs_Call) Run(run func(_a0 context.Context, _a1 *workerpb.DropJobsRequest)) *MockIndexNode_DropJobs_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*workerpb.DropJobsRequest)) - }) - return _c -} - -func (_c *MockIndexNode_DropJobs_Call) Return(_a0 *commonpb.Status, _a1 error) *MockIndexNode_DropJobs_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNode_DropJobs_Call) RunAndReturn(run func(context.Context, *workerpb.DropJobsRequest) (*commonpb.Status, error)) *MockIndexNode_DropJobs_Call { - _c.Call.Return(run) - return _c -} - -// DropJobsV2 provides a mock function with given fields: _a0, _a1 -func (_m *MockIndexNode) DropJobsV2(_a0 context.Context, _a1 *workerpb.DropJobsV2Request) (*commonpb.Status, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for DropJobsV2") - } - - var r0 *commonpb.Status - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.DropJobsV2Request) (*commonpb.Status, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.DropJobsV2Request) *commonpb.Status); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*commonpb.Status) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *workerpb.DropJobsV2Request) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNode_DropJobsV2_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DropJobsV2' -type MockIndexNode_DropJobsV2_Call struct { - *mock.Call -} - -// DropJobsV2 is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 *workerpb.DropJobsV2Request -func (_e *MockIndexNode_Expecter) DropJobsV2(_a0 interface{}, _a1 interface{}) *MockIndexNode_DropJobsV2_Call { - return &MockIndexNode_DropJobsV2_Call{Call: _e.mock.On("DropJobsV2", _a0, _a1)} -} - -func (_c *MockIndexNode_DropJobsV2_Call) Run(run func(_a0 context.Context, _a1 *workerpb.DropJobsV2Request)) *MockIndexNode_DropJobsV2_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*workerpb.DropJobsV2Request)) - }) - return _c -} - -func (_c *MockIndexNode_DropJobsV2_Call) Return(_a0 *commonpb.Status, _a1 error) *MockIndexNode_DropJobsV2_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNode_DropJobsV2_Call) RunAndReturn(run func(context.Context, *workerpb.DropJobsV2Request) (*commonpb.Status, error)) *MockIndexNode_DropJobsV2_Call { - _c.Call.Return(run) - return _c -} - -// GetAddress provides a mock function with given fields: -func (_m *MockIndexNode) GetAddress() string { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetAddress") - } - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// MockIndexNode_GetAddress_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetAddress' -type MockIndexNode_GetAddress_Call struct { - *mock.Call -} - -// GetAddress is a helper method to define mock.On call -func (_e *MockIndexNode_Expecter) GetAddress() *MockIndexNode_GetAddress_Call { - return &MockIndexNode_GetAddress_Call{Call: _e.mock.On("GetAddress")} -} - -func (_c *MockIndexNode_GetAddress_Call) Run(run func()) *MockIndexNode_GetAddress_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockIndexNode_GetAddress_Call) Return(_a0 string) *MockIndexNode_GetAddress_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockIndexNode_GetAddress_Call) RunAndReturn(run func() string) *MockIndexNode_GetAddress_Call { - _c.Call.Return(run) - return _c -} - -// GetComponentStates provides a mock function with given fields: _a0, _a1 -func (_m *MockIndexNode) GetComponentStates(_a0 context.Context, _a1 *milvuspb.GetComponentStatesRequest) (*milvuspb.ComponentStates, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for GetComponentStates") - } - - var r0 *milvuspb.ComponentStates - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *milvuspb.GetComponentStatesRequest) (*milvuspb.ComponentStates, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, *milvuspb.GetComponentStatesRequest) *milvuspb.ComponentStates); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*milvuspb.ComponentStates) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *milvuspb.GetComponentStatesRequest) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNode_GetComponentStates_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetComponentStates' -type MockIndexNode_GetComponentStates_Call struct { - *mock.Call -} - -// GetComponentStates is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 *milvuspb.GetComponentStatesRequest -func (_e *MockIndexNode_Expecter) GetComponentStates(_a0 interface{}, _a1 interface{}) *MockIndexNode_GetComponentStates_Call { - return &MockIndexNode_GetComponentStates_Call{Call: _e.mock.On("GetComponentStates", _a0, _a1)} -} - -func (_c *MockIndexNode_GetComponentStates_Call) Run(run func(_a0 context.Context, _a1 *milvuspb.GetComponentStatesRequest)) *MockIndexNode_GetComponentStates_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*milvuspb.GetComponentStatesRequest)) - }) - return _c -} - -func (_c *MockIndexNode_GetComponentStates_Call) Return(_a0 *milvuspb.ComponentStates, _a1 error) *MockIndexNode_GetComponentStates_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNode_GetComponentStates_Call) RunAndReturn(run func(context.Context, *milvuspb.GetComponentStatesRequest) (*milvuspb.ComponentStates, error)) *MockIndexNode_GetComponentStates_Call { - _c.Call.Return(run) - return _c -} - -// GetJobStats provides a mock function with given fields: _a0, _a1 -func (_m *MockIndexNode) GetJobStats(_a0 context.Context, _a1 *workerpb.GetJobStatsRequest) (*workerpb.GetJobStatsResponse, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for GetJobStats") - } - - var r0 *workerpb.GetJobStatsResponse - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.GetJobStatsRequest) (*workerpb.GetJobStatsResponse, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.GetJobStatsRequest) *workerpb.GetJobStatsResponse); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*workerpb.GetJobStatsResponse) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *workerpb.GetJobStatsRequest) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNode_GetJobStats_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetJobStats' -type MockIndexNode_GetJobStats_Call struct { - *mock.Call -} - -// GetJobStats is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 *workerpb.GetJobStatsRequest -func (_e *MockIndexNode_Expecter) GetJobStats(_a0 interface{}, _a1 interface{}) *MockIndexNode_GetJobStats_Call { - return &MockIndexNode_GetJobStats_Call{Call: _e.mock.On("GetJobStats", _a0, _a1)} -} - -func (_c *MockIndexNode_GetJobStats_Call) Run(run func(_a0 context.Context, _a1 *workerpb.GetJobStatsRequest)) *MockIndexNode_GetJobStats_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*workerpb.GetJobStatsRequest)) - }) - return _c -} - -func (_c *MockIndexNode_GetJobStats_Call) Return(_a0 *workerpb.GetJobStatsResponse, _a1 error) *MockIndexNode_GetJobStats_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNode_GetJobStats_Call) RunAndReturn(run func(context.Context, *workerpb.GetJobStatsRequest) (*workerpb.GetJobStatsResponse, error)) *MockIndexNode_GetJobStats_Call { - _c.Call.Return(run) - return _c -} - -// GetMetrics provides a mock function with given fields: _a0, _a1 -func (_m *MockIndexNode) GetMetrics(_a0 context.Context, _a1 *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for GetMetrics") - } - - var r0 *milvuspb.GetMetricsResponse - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, *milvuspb.GetMetricsRequest) *milvuspb.GetMetricsResponse); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*milvuspb.GetMetricsResponse) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *milvuspb.GetMetricsRequest) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNode_GetMetrics_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetMetrics' -type MockIndexNode_GetMetrics_Call struct { - *mock.Call -} - -// GetMetrics is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 *milvuspb.GetMetricsRequest -func (_e *MockIndexNode_Expecter) GetMetrics(_a0 interface{}, _a1 interface{}) *MockIndexNode_GetMetrics_Call { - return &MockIndexNode_GetMetrics_Call{Call: _e.mock.On("GetMetrics", _a0, _a1)} -} - -func (_c *MockIndexNode_GetMetrics_Call) Run(run func(_a0 context.Context, _a1 *milvuspb.GetMetricsRequest)) *MockIndexNode_GetMetrics_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*milvuspb.GetMetricsRequest)) - }) - return _c -} - -func (_c *MockIndexNode_GetMetrics_Call) Return(_a0 *milvuspb.GetMetricsResponse, _a1 error) *MockIndexNode_GetMetrics_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNode_GetMetrics_Call) RunAndReturn(run func(context.Context, *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error)) *MockIndexNode_GetMetrics_Call { - _c.Call.Return(run) - return _c -} - -// GetStatisticsChannel provides a mock function with given fields: _a0, _a1 -func (_m *MockIndexNode) GetStatisticsChannel(_a0 context.Context, _a1 *internalpb.GetStatisticsChannelRequest) (*milvuspb.StringResponse, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for GetStatisticsChannel") - } - - var r0 *milvuspb.StringResponse - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *internalpb.GetStatisticsChannelRequest) (*milvuspb.StringResponse, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, *internalpb.GetStatisticsChannelRequest) *milvuspb.StringResponse); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*milvuspb.StringResponse) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *internalpb.GetStatisticsChannelRequest) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNode_GetStatisticsChannel_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetStatisticsChannel' -type MockIndexNode_GetStatisticsChannel_Call struct { - *mock.Call -} - -// GetStatisticsChannel is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 *internalpb.GetStatisticsChannelRequest -func (_e *MockIndexNode_Expecter) GetStatisticsChannel(_a0 interface{}, _a1 interface{}) *MockIndexNode_GetStatisticsChannel_Call { - return &MockIndexNode_GetStatisticsChannel_Call{Call: _e.mock.On("GetStatisticsChannel", _a0, _a1)} -} - -func (_c *MockIndexNode_GetStatisticsChannel_Call) Run(run func(_a0 context.Context, _a1 *internalpb.GetStatisticsChannelRequest)) *MockIndexNode_GetStatisticsChannel_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*internalpb.GetStatisticsChannelRequest)) - }) - return _c -} - -func (_c *MockIndexNode_GetStatisticsChannel_Call) Return(_a0 *milvuspb.StringResponse, _a1 error) *MockIndexNode_GetStatisticsChannel_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNode_GetStatisticsChannel_Call) RunAndReturn(run func(context.Context, *internalpb.GetStatisticsChannelRequest) (*milvuspb.StringResponse, error)) *MockIndexNode_GetStatisticsChannel_Call { - _c.Call.Return(run) - return _c -} - -// Init provides a mock function with given fields: -func (_m *MockIndexNode) Init() error { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Init") - } - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockIndexNode_Init_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Init' -type MockIndexNode_Init_Call struct { - *mock.Call -} - -// Init is a helper method to define mock.On call -func (_e *MockIndexNode_Expecter) Init() *MockIndexNode_Init_Call { - return &MockIndexNode_Init_Call{Call: _e.mock.On("Init")} -} - -func (_c *MockIndexNode_Init_Call) Run(run func()) *MockIndexNode_Init_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockIndexNode_Init_Call) Return(_a0 error) *MockIndexNode_Init_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockIndexNode_Init_Call) RunAndReturn(run func() error) *MockIndexNode_Init_Call { - _c.Call.Return(run) - return _c -} - -// QueryJobs provides a mock function with given fields: _a0, _a1 -func (_m *MockIndexNode) QueryJobs(_a0 context.Context, _a1 *workerpb.QueryJobsRequest) (*workerpb.QueryJobsResponse, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for QueryJobs") - } - - var r0 *workerpb.QueryJobsResponse - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.QueryJobsRequest) (*workerpb.QueryJobsResponse, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.QueryJobsRequest) *workerpb.QueryJobsResponse); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*workerpb.QueryJobsResponse) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *workerpb.QueryJobsRequest) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNode_QueryJobs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'QueryJobs' -type MockIndexNode_QueryJobs_Call struct { - *mock.Call -} - -// QueryJobs is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 *workerpb.QueryJobsRequest -func (_e *MockIndexNode_Expecter) QueryJobs(_a0 interface{}, _a1 interface{}) *MockIndexNode_QueryJobs_Call { - return &MockIndexNode_QueryJobs_Call{Call: _e.mock.On("QueryJobs", _a0, _a1)} -} - -func (_c *MockIndexNode_QueryJobs_Call) Run(run func(_a0 context.Context, _a1 *workerpb.QueryJobsRequest)) *MockIndexNode_QueryJobs_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*workerpb.QueryJobsRequest)) - }) - return _c -} - -func (_c *MockIndexNode_QueryJobs_Call) Return(_a0 *workerpb.QueryJobsResponse, _a1 error) *MockIndexNode_QueryJobs_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNode_QueryJobs_Call) RunAndReturn(run func(context.Context, *workerpb.QueryJobsRequest) (*workerpb.QueryJobsResponse, error)) *MockIndexNode_QueryJobs_Call { - _c.Call.Return(run) - return _c -} - -// QueryJobsV2 provides a mock function with given fields: _a0, _a1 -func (_m *MockIndexNode) QueryJobsV2(_a0 context.Context, _a1 *workerpb.QueryJobsV2Request) (*workerpb.QueryJobsV2Response, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for QueryJobsV2") - } - - var r0 *workerpb.QueryJobsV2Response - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.QueryJobsV2Request) (*workerpb.QueryJobsV2Response, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.QueryJobsV2Request) *workerpb.QueryJobsV2Response); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*workerpb.QueryJobsV2Response) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *workerpb.QueryJobsV2Request) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNode_QueryJobsV2_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'QueryJobsV2' -type MockIndexNode_QueryJobsV2_Call struct { - *mock.Call -} - -// QueryJobsV2 is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 *workerpb.QueryJobsV2Request -func (_e *MockIndexNode_Expecter) QueryJobsV2(_a0 interface{}, _a1 interface{}) *MockIndexNode_QueryJobsV2_Call { - return &MockIndexNode_QueryJobsV2_Call{Call: _e.mock.On("QueryJobsV2", _a0, _a1)} -} - -func (_c *MockIndexNode_QueryJobsV2_Call) Run(run func(_a0 context.Context, _a1 *workerpb.QueryJobsV2Request)) *MockIndexNode_QueryJobsV2_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*workerpb.QueryJobsV2Request)) - }) - return _c -} - -func (_c *MockIndexNode_QueryJobsV2_Call) Return(_a0 *workerpb.QueryJobsV2Response, _a1 error) *MockIndexNode_QueryJobsV2_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNode_QueryJobsV2_Call) RunAndReturn(run func(context.Context, *workerpb.QueryJobsV2Request) (*workerpb.QueryJobsV2Response, error)) *MockIndexNode_QueryJobsV2_Call { - _c.Call.Return(run) - return _c -} - -// Register provides a mock function with given fields: -func (_m *MockIndexNode) Register() error { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Register") - } - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockIndexNode_Register_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Register' -type MockIndexNode_Register_Call struct { - *mock.Call -} - -// Register is a helper method to define mock.On call -func (_e *MockIndexNode_Expecter) Register() *MockIndexNode_Register_Call { - return &MockIndexNode_Register_Call{Call: _e.mock.On("Register")} -} - -func (_c *MockIndexNode_Register_Call) Run(run func()) *MockIndexNode_Register_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockIndexNode_Register_Call) Return(_a0 error) *MockIndexNode_Register_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockIndexNode_Register_Call) RunAndReturn(run func() error) *MockIndexNode_Register_Call { - _c.Call.Return(run) - return _c -} - -// SetAddress provides a mock function with given fields: address -func (_m *MockIndexNode) SetAddress(address string) { - _m.Called(address) -} - -// MockIndexNode_SetAddress_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetAddress' -type MockIndexNode_SetAddress_Call struct { - *mock.Call -} - -// SetAddress is a helper method to define mock.On call -// - address string -func (_e *MockIndexNode_Expecter) SetAddress(address interface{}) *MockIndexNode_SetAddress_Call { - return &MockIndexNode_SetAddress_Call{Call: _e.mock.On("SetAddress", address)} -} - -func (_c *MockIndexNode_SetAddress_Call) Run(run func(address string)) *MockIndexNode_SetAddress_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c -} - -func (_c *MockIndexNode_SetAddress_Call) Return() *MockIndexNode_SetAddress_Call { - _c.Call.Return() - return _c -} - -func (_c *MockIndexNode_SetAddress_Call) RunAndReturn(run func(string)) *MockIndexNode_SetAddress_Call { - _c.Call.Return(run) - return _c -} - -// SetEtcdClient provides a mock function with given fields: etcdClient -func (_m *MockIndexNode) SetEtcdClient(etcdClient *clientv3.Client) { - _m.Called(etcdClient) -} - -// MockIndexNode_SetEtcdClient_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetEtcdClient' -type MockIndexNode_SetEtcdClient_Call struct { - *mock.Call -} - -// SetEtcdClient is a helper method to define mock.On call -// - etcdClient *clientv3.Client -func (_e *MockIndexNode_Expecter) SetEtcdClient(etcdClient interface{}) *MockIndexNode_SetEtcdClient_Call { - return &MockIndexNode_SetEtcdClient_Call{Call: _e.mock.On("SetEtcdClient", etcdClient)} -} - -func (_c *MockIndexNode_SetEtcdClient_Call) Run(run func(etcdClient *clientv3.Client)) *MockIndexNode_SetEtcdClient_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*clientv3.Client)) - }) - return _c -} - -func (_c *MockIndexNode_SetEtcdClient_Call) Return() *MockIndexNode_SetEtcdClient_Call { - _c.Call.Return() - return _c -} - -func (_c *MockIndexNode_SetEtcdClient_Call) RunAndReturn(run func(*clientv3.Client)) *MockIndexNode_SetEtcdClient_Call { - _c.Call.Return(run) - return _c -} - -// ShowConfigurations provides a mock function with given fields: _a0, _a1 -func (_m *MockIndexNode) ShowConfigurations(_a0 context.Context, _a1 *internalpb.ShowConfigurationsRequest) (*internalpb.ShowConfigurationsResponse, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for ShowConfigurations") - } - - var r0 *internalpb.ShowConfigurationsResponse - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *internalpb.ShowConfigurationsRequest) (*internalpb.ShowConfigurationsResponse, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, *internalpb.ShowConfigurationsRequest) *internalpb.ShowConfigurationsResponse); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*internalpb.ShowConfigurationsResponse) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *internalpb.ShowConfigurationsRequest) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNode_ShowConfigurations_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ShowConfigurations' -type MockIndexNode_ShowConfigurations_Call struct { - *mock.Call -} - -// ShowConfigurations is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 *internalpb.ShowConfigurationsRequest -func (_e *MockIndexNode_Expecter) ShowConfigurations(_a0 interface{}, _a1 interface{}) *MockIndexNode_ShowConfigurations_Call { - return &MockIndexNode_ShowConfigurations_Call{Call: _e.mock.On("ShowConfigurations", _a0, _a1)} -} - -func (_c *MockIndexNode_ShowConfigurations_Call) Run(run func(_a0 context.Context, _a1 *internalpb.ShowConfigurationsRequest)) *MockIndexNode_ShowConfigurations_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*internalpb.ShowConfigurationsRequest)) - }) - return _c -} - -func (_c *MockIndexNode_ShowConfigurations_Call) Return(_a0 *internalpb.ShowConfigurationsResponse, _a1 error) *MockIndexNode_ShowConfigurations_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNode_ShowConfigurations_Call) RunAndReturn(run func(context.Context, *internalpb.ShowConfigurationsRequest) (*internalpb.ShowConfigurationsResponse, error)) *MockIndexNode_ShowConfigurations_Call { - _c.Call.Return(run) - return _c -} - -// Start provides a mock function with given fields: -func (_m *MockIndexNode) Start() error { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Start") - } - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockIndexNode_Start_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Start' -type MockIndexNode_Start_Call struct { - *mock.Call -} - -// Start is a helper method to define mock.On call -func (_e *MockIndexNode_Expecter) Start() *MockIndexNode_Start_Call { - return &MockIndexNode_Start_Call{Call: _e.mock.On("Start")} -} - -func (_c *MockIndexNode_Start_Call) Run(run func()) *MockIndexNode_Start_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockIndexNode_Start_Call) Return(_a0 error) *MockIndexNode_Start_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockIndexNode_Start_Call) RunAndReturn(run func() error) *MockIndexNode_Start_Call { - _c.Call.Return(run) - return _c -} - -// Stop provides a mock function with given fields: -func (_m *MockIndexNode) Stop() error { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Stop") - } - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockIndexNode_Stop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Stop' -type MockIndexNode_Stop_Call struct { - *mock.Call -} - -// Stop is a helper method to define mock.On call -func (_e *MockIndexNode_Expecter) Stop() *MockIndexNode_Stop_Call { - return &MockIndexNode_Stop_Call{Call: _e.mock.On("Stop")} -} - -func (_c *MockIndexNode_Stop_Call) Run(run func()) *MockIndexNode_Stop_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockIndexNode_Stop_Call) Return(_a0 error) *MockIndexNode_Stop_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockIndexNode_Stop_Call) RunAndReturn(run func() error) *MockIndexNode_Stop_Call { - _c.Call.Return(run) - return _c -} - -// UpdateStateCode provides a mock function with given fields: stateCode -func (_m *MockIndexNode) UpdateStateCode(stateCode commonpb.StateCode) { - _m.Called(stateCode) -} - -// MockIndexNode_UpdateStateCode_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateStateCode' -type MockIndexNode_UpdateStateCode_Call struct { - *mock.Call -} - -// UpdateStateCode is a helper method to define mock.On call -// - stateCode commonpb.StateCode -func (_e *MockIndexNode_Expecter) UpdateStateCode(stateCode interface{}) *MockIndexNode_UpdateStateCode_Call { - return &MockIndexNode_UpdateStateCode_Call{Call: _e.mock.On("UpdateStateCode", stateCode)} -} - -func (_c *MockIndexNode_UpdateStateCode_Call) Run(run func(stateCode commonpb.StateCode)) *MockIndexNode_UpdateStateCode_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(commonpb.StateCode)) - }) - return _c -} - -func (_c *MockIndexNode_UpdateStateCode_Call) Return() *MockIndexNode_UpdateStateCode_Call { - _c.Call.Return() - return _c -} - -func (_c *MockIndexNode_UpdateStateCode_Call) RunAndReturn(run func(commonpb.StateCode)) *MockIndexNode_UpdateStateCode_Call { - _c.Call.Return(run) - return _c -} - -// NewMockIndexNode creates a new instance of MockIndexNode. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockIndexNode(t interface { - mock.TestingT - Cleanup(func()) -}) *MockIndexNode { - mock := &MockIndexNode{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/internal/mocks/mock_indexnode_client.go b/internal/mocks/mock_indexnode_client.go deleted file mode 100644 index 5090a8944d..0000000000 --- a/internal/mocks/mock_indexnode_client.go +++ /dev/null @@ -1,905 +0,0 @@ -// Code generated by mockery v2.46.0. DO NOT EDIT. - -package mocks - -import ( - context "context" - - commonpb "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" - - grpc "google.golang.org/grpc" - - internalpb "github.com/milvus-io/milvus/pkg/v2/proto/internalpb" - - milvuspb "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" - - mock "github.com/stretchr/testify/mock" - - workerpb "github.com/milvus-io/milvus/pkg/v2/proto/workerpb" -) - -// MockIndexNodeClient is an autogenerated mock type for the IndexNodeClient type -type MockIndexNodeClient struct { - mock.Mock -} - -type MockIndexNodeClient_Expecter struct { - mock *mock.Mock -} - -func (_m *MockIndexNodeClient) EXPECT() *MockIndexNodeClient_Expecter { - return &MockIndexNodeClient_Expecter{mock: &_m.Mock} -} - -// Close provides a mock function with given fields: -func (_m *MockIndexNodeClient) Close() error { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Close") - } - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockIndexNodeClient_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close' -type MockIndexNodeClient_Close_Call struct { - *mock.Call -} - -// Close is a helper method to define mock.On call -func (_e *MockIndexNodeClient_Expecter) Close() *MockIndexNodeClient_Close_Call { - return &MockIndexNodeClient_Close_Call{Call: _e.mock.On("Close")} -} - -func (_c *MockIndexNodeClient_Close_Call) Run(run func()) *MockIndexNodeClient_Close_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockIndexNodeClient_Close_Call) Return(_a0 error) *MockIndexNodeClient_Close_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockIndexNodeClient_Close_Call) RunAndReturn(run func() error) *MockIndexNodeClient_Close_Call { - _c.Call.Return(run) - return _c -} - -// CreateJob provides a mock function with given fields: ctx, in, opts -func (_m *MockIndexNodeClient) CreateJob(ctx context.Context, in *workerpb.CreateJobRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for CreateJob") - } - - var r0 *commonpb.Status - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.CreateJobRequest, ...grpc.CallOption) (*commonpb.Status, error)); ok { - return rf(ctx, in, opts...) - } - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.CreateJobRequest, ...grpc.CallOption) *commonpb.Status); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*commonpb.Status) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *workerpb.CreateJobRequest, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNodeClient_CreateJob_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateJob' -type MockIndexNodeClient_CreateJob_Call struct { - *mock.Call -} - -// CreateJob is a helper method to define mock.On call -// - ctx context.Context -// - in *workerpb.CreateJobRequest -// - opts ...grpc.CallOption -func (_e *MockIndexNodeClient_Expecter) CreateJob(ctx interface{}, in interface{}, opts ...interface{}) *MockIndexNodeClient_CreateJob_Call { - return &MockIndexNodeClient_CreateJob_Call{Call: _e.mock.On("CreateJob", - append([]interface{}{ctx, in}, opts...)...)} -} - -func (_c *MockIndexNodeClient_CreateJob_Call) Run(run func(ctx context.Context, in *workerpb.CreateJobRequest, opts ...grpc.CallOption)) *MockIndexNodeClient_CreateJob_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]grpc.CallOption, len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(grpc.CallOption) - } - } - run(args[0].(context.Context), args[1].(*workerpb.CreateJobRequest), variadicArgs...) - }) - return _c -} - -func (_c *MockIndexNodeClient_CreateJob_Call) Return(_a0 *commonpb.Status, _a1 error) *MockIndexNodeClient_CreateJob_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNodeClient_CreateJob_Call) RunAndReturn(run func(context.Context, *workerpb.CreateJobRequest, ...grpc.CallOption) (*commonpb.Status, error)) *MockIndexNodeClient_CreateJob_Call { - _c.Call.Return(run) - return _c -} - -// CreateJobV2 provides a mock function with given fields: ctx, in, opts -func (_m *MockIndexNodeClient) CreateJobV2(ctx context.Context, in *workerpb.CreateJobV2Request, opts ...grpc.CallOption) (*commonpb.Status, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for CreateJobV2") - } - - var r0 *commonpb.Status - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.CreateJobV2Request, ...grpc.CallOption) (*commonpb.Status, error)); ok { - return rf(ctx, in, opts...) - } - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.CreateJobV2Request, ...grpc.CallOption) *commonpb.Status); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*commonpb.Status) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *workerpb.CreateJobV2Request, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNodeClient_CreateJobV2_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateJobV2' -type MockIndexNodeClient_CreateJobV2_Call struct { - *mock.Call -} - -// CreateJobV2 is a helper method to define mock.On call -// - ctx context.Context -// - in *workerpb.CreateJobV2Request -// - opts ...grpc.CallOption -func (_e *MockIndexNodeClient_Expecter) CreateJobV2(ctx interface{}, in interface{}, opts ...interface{}) *MockIndexNodeClient_CreateJobV2_Call { - return &MockIndexNodeClient_CreateJobV2_Call{Call: _e.mock.On("CreateJobV2", - append([]interface{}{ctx, in}, opts...)...)} -} - -func (_c *MockIndexNodeClient_CreateJobV2_Call) Run(run func(ctx context.Context, in *workerpb.CreateJobV2Request, opts ...grpc.CallOption)) *MockIndexNodeClient_CreateJobV2_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]grpc.CallOption, len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(grpc.CallOption) - } - } - run(args[0].(context.Context), args[1].(*workerpb.CreateJobV2Request), variadicArgs...) - }) - return _c -} - -func (_c *MockIndexNodeClient_CreateJobV2_Call) Return(_a0 *commonpb.Status, _a1 error) *MockIndexNodeClient_CreateJobV2_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNodeClient_CreateJobV2_Call) RunAndReturn(run func(context.Context, *workerpb.CreateJobV2Request, ...grpc.CallOption) (*commonpb.Status, error)) *MockIndexNodeClient_CreateJobV2_Call { - _c.Call.Return(run) - return _c -} - -// DropJobs provides a mock function with given fields: ctx, in, opts -func (_m *MockIndexNodeClient) DropJobs(ctx context.Context, in *workerpb.DropJobsRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for DropJobs") - } - - var r0 *commonpb.Status - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.DropJobsRequest, ...grpc.CallOption) (*commonpb.Status, error)); ok { - return rf(ctx, in, opts...) - } - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.DropJobsRequest, ...grpc.CallOption) *commonpb.Status); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*commonpb.Status) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *workerpb.DropJobsRequest, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNodeClient_DropJobs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DropJobs' -type MockIndexNodeClient_DropJobs_Call struct { - *mock.Call -} - -// DropJobs is a helper method to define mock.On call -// - ctx context.Context -// - in *workerpb.DropJobsRequest -// - opts ...grpc.CallOption -func (_e *MockIndexNodeClient_Expecter) DropJobs(ctx interface{}, in interface{}, opts ...interface{}) *MockIndexNodeClient_DropJobs_Call { - return &MockIndexNodeClient_DropJobs_Call{Call: _e.mock.On("DropJobs", - append([]interface{}{ctx, in}, opts...)...)} -} - -func (_c *MockIndexNodeClient_DropJobs_Call) Run(run func(ctx context.Context, in *workerpb.DropJobsRequest, opts ...grpc.CallOption)) *MockIndexNodeClient_DropJobs_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]grpc.CallOption, len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(grpc.CallOption) - } - } - run(args[0].(context.Context), args[1].(*workerpb.DropJobsRequest), variadicArgs...) - }) - return _c -} - -func (_c *MockIndexNodeClient_DropJobs_Call) Return(_a0 *commonpb.Status, _a1 error) *MockIndexNodeClient_DropJobs_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNodeClient_DropJobs_Call) RunAndReturn(run func(context.Context, *workerpb.DropJobsRequest, ...grpc.CallOption) (*commonpb.Status, error)) *MockIndexNodeClient_DropJobs_Call { - _c.Call.Return(run) - return _c -} - -// DropJobsV2 provides a mock function with given fields: ctx, in, opts -func (_m *MockIndexNodeClient) DropJobsV2(ctx context.Context, in *workerpb.DropJobsV2Request, opts ...grpc.CallOption) (*commonpb.Status, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for DropJobsV2") - } - - var r0 *commonpb.Status - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.DropJobsV2Request, ...grpc.CallOption) (*commonpb.Status, error)); ok { - return rf(ctx, in, opts...) - } - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.DropJobsV2Request, ...grpc.CallOption) *commonpb.Status); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*commonpb.Status) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *workerpb.DropJobsV2Request, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNodeClient_DropJobsV2_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DropJobsV2' -type MockIndexNodeClient_DropJobsV2_Call struct { - *mock.Call -} - -// DropJobsV2 is a helper method to define mock.On call -// - ctx context.Context -// - in *workerpb.DropJobsV2Request -// - opts ...grpc.CallOption -func (_e *MockIndexNodeClient_Expecter) DropJobsV2(ctx interface{}, in interface{}, opts ...interface{}) *MockIndexNodeClient_DropJobsV2_Call { - return &MockIndexNodeClient_DropJobsV2_Call{Call: _e.mock.On("DropJobsV2", - append([]interface{}{ctx, in}, opts...)...)} -} - -func (_c *MockIndexNodeClient_DropJobsV2_Call) Run(run func(ctx context.Context, in *workerpb.DropJobsV2Request, opts ...grpc.CallOption)) *MockIndexNodeClient_DropJobsV2_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]grpc.CallOption, len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(grpc.CallOption) - } - } - run(args[0].(context.Context), args[1].(*workerpb.DropJobsV2Request), variadicArgs...) - }) - return _c -} - -func (_c *MockIndexNodeClient_DropJobsV2_Call) Return(_a0 *commonpb.Status, _a1 error) *MockIndexNodeClient_DropJobsV2_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNodeClient_DropJobsV2_Call) RunAndReturn(run func(context.Context, *workerpb.DropJobsV2Request, ...grpc.CallOption) (*commonpb.Status, error)) *MockIndexNodeClient_DropJobsV2_Call { - _c.Call.Return(run) - return _c -} - -// GetComponentStates provides a mock function with given fields: ctx, in, opts -func (_m *MockIndexNodeClient) GetComponentStates(ctx context.Context, in *milvuspb.GetComponentStatesRequest, opts ...grpc.CallOption) (*milvuspb.ComponentStates, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for GetComponentStates") - } - - var r0 *milvuspb.ComponentStates - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *milvuspb.GetComponentStatesRequest, ...grpc.CallOption) (*milvuspb.ComponentStates, error)); ok { - return rf(ctx, in, opts...) - } - if rf, ok := ret.Get(0).(func(context.Context, *milvuspb.GetComponentStatesRequest, ...grpc.CallOption) *milvuspb.ComponentStates); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*milvuspb.ComponentStates) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *milvuspb.GetComponentStatesRequest, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNodeClient_GetComponentStates_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetComponentStates' -type MockIndexNodeClient_GetComponentStates_Call struct { - *mock.Call -} - -// GetComponentStates is a helper method to define mock.On call -// - ctx context.Context -// - in *milvuspb.GetComponentStatesRequest -// - opts ...grpc.CallOption -func (_e *MockIndexNodeClient_Expecter) GetComponentStates(ctx interface{}, in interface{}, opts ...interface{}) *MockIndexNodeClient_GetComponentStates_Call { - return &MockIndexNodeClient_GetComponentStates_Call{Call: _e.mock.On("GetComponentStates", - append([]interface{}{ctx, in}, opts...)...)} -} - -func (_c *MockIndexNodeClient_GetComponentStates_Call) Run(run func(ctx context.Context, in *milvuspb.GetComponentStatesRequest, opts ...grpc.CallOption)) *MockIndexNodeClient_GetComponentStates_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]grpc.CallOption, len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(grpc.CallOption) - } - } - run(args[0].(context.Context), args[1].(*milvuspb.GetComponentStatesRequest), variadicArgs...) - }) - return _c -} - -func (_c *MockIndexNodeClient_GetComponentStates_Call) Return(_a0 *milvuspb.ComponentStates, _a1 error) *MockIndexNodeClient_GetComponentStates_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNodeClient_GetComponentStates_Call) RunAndReturn(run func(context.Context, *milvuspb.GetComponentStatesRequest, ...grpc.CallOption) (*milvuspb.ComponentStates, error)) *MockIndexNodeClient_GetComponentStates_Call { - _c.Call.Return(run) - return _c -} - -// GetJobStats provides a mock function with given fields: ctx, in, opts -func (_m *MockIndexNodeClient) GetJobStats(ctx context.Context, in *workerpb.GetJobStatsRequest, opts ...grpc.CallOption) (*workerpb.GetJobStatsResponse, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for GetJobStats") - } - - var r0 *workerpb.GetJobStatsResponse - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.GetJobStatsRequest, ...grpc.CallOption) (*workerpb.GetJobStatsResponse, error)); ok { - return rf(ctx, in, opts...) - } - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.GetJobStatsRequest, ...grpc.CallOption) *workerpb.GetJobStatsResponse); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*workerpb.GetJobStatsResponse) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *workerpb.GetJobStatsRequest, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNodeClient_GetJobStats_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetJobStats' -type MockIndexNodeClient_GetJobStats_Call struct { - *mock.Call -} - -// GetJobStats is a helper method to define mock.On call -// - ctx context.Context -// - in *workerpb.GetJobStatsRequest -// - opts ...grpc.CallOption -func (_e *MockIndexNodeClient_Expecter) GetJobStats(ctx interface{}, in interface{}, opts ...interface{}) *MockIndexNodeClient_GetJobStats_Call { - return &MockIndexNodeClient_GetJobStats_Call{Call: _e.mock.On("GetJobStats", - append([]interface{}{ctx, in}, opts...)...)} -} - -func (_c *MockIndexNodeClient_GetJobStats_Call) Run(run func(ctx context.Context, in *workerpb.GetJobStatsRequest, opts ...grpc.CallOption)) *MockIndexNodeClient_GetJobStats_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]grpc.CallOption, len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(grpc.CallOption) - } - } - run(args[0].(context.Context), args[1].(*workerpb.GetJobStatsRequest), variadicArgs...) - }) - return _c -} - -func (_c *MockIndexNodeClient_GetJobStats_Call) Return(_a0 *workerpb.GetJobStatsResponse, _a1 error) *MockIndexNodeClient_GetJobStats_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNodeClient_GetJobStats_Call) RunAndReturn(run func(context.Context, *workerpb.GetJobStatsRequest, ...grpc.CallOption) (*workerpb.GetJobStatsResponse, error)) *MockIndexNodeClient_GetJobStats_Call { - _c.Call.Return(run) - return _c -} - -// GetMetrics provides a mock function with given fields: ctx, in, opts -func (_m *MockIndexNodeClient) GetMetrics(ctx context.Context, in *milvuspb.GetMetricsRequest, opts ...grpc.CallOption) (*milvuspb.GetMetricsResponse, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for GetMetrics") - } - - var r0 *milvuspb.GetMetricsResponse - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *milvuspb.GetMetricsRequest, ...grpc.CallOption) (*milvuspb.GetMetricsResponse, error)); ok { - return rf(ctx, in, opts...) - } - if rf, ok := ret.Get(0).(func(context.Context, *milvuspb.GetMetricsRequest, ...grpc.CallOption) *milvuspb.GetMetricsResponse); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*milvuspb.GetMetricsResponse) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *milvuspb.GetMetricsRequest, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNodeClient_GetMetrics_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetMetrics' -type MockIndexNodeClient_GetMetrics_Call struct { - *mock.Call -} - -// GetMetrics is a helper method to define mock.On call -// - ctx context.Context -// - in *milvuspb.GetMetricsRequest -// - opts ...grpc.CallOption -func (_e *MockIndexNodeClient_Expecter) GetMetrics(ctx interface{}, in interface{}, opts ...interface{}) *MockIndexNodeClient_GetMetrics_Call { - return &MockIndexNodeClient_GetMetrics_Call{Call: _e.mock.On("GetMetrics", - append([]interface{}{ctx, in}, opts...)...)} -} - -func (_c *MockIndexNodeClient_GetMetrics_Call) Run(run func(ctx context.Context, in *milvuspb.GetMetricsRequest, opts ...grpc.CallOption)) *MockIndexNodeClient_GetMetrics_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]grpc.CallOption, len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(grpc.CallOption) - } - } - run(args[0].(context.Context), args[1].(*milvuspb.GetMetricsRequest), variadicArgs...) - }) - return _c -} - -func (_c *MockIndexNodeClient_GetMetrics_Call) Return(_a0 *milvuspb.GetMetricsResponse, _a1 error) *MockIndexNodeClient_GetMetrics_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNodeClient_GetMetrics_Call) RunAndReturn(run func(context.Context, *milvuspb.GetMetricsRequest, ...grpc.CallOption) (*milvuspb.GetMetricsResponse, error)) *MockIndexNodeClient_GetMetrics_Call { - _c.Call.Return(run) - return _c -} - -// GetStatisticsChannel provides a mock function with given fields: ctx, in, opts -func (_m *MockIndexNodeClient) GetStatisticsChannel(ctx context.Context, in *internalpb.GetStatisticsChannelRequest, opts ...grpc.CallOption) (*milvuspb.StringResponse, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for GetStatisticsChannel") - } - - var r0 *milvuspb.StringResponse - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *internalpb.GetStatisticsChannelRequest, ...grpc.CallOption) (*milvuspb.StringResponse, error)); ok { - return rf(ctx, in, opts...) - } - if rf, ok := ret.Get(0).(func(context.Context, *internalpb.GetStatisticsChannelRequest, ...grpc.CallOption) *milvuspb.StringResponse); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*milvuspb.StringResponse) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *internalpb.GetStatisticsChannelRequest, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNodeClient_GetStatisticsChannel_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetStatisticsChannel' -type MockIndexNodeClient_GetStatisticsChannel_Call struct { - *mock.Call -} - -// GetStatisticsChannel is a helper method to define mock.On call -// - ctx context.Context -// - in *internalpb.GetStatisticsChannelRequest -// - opts ...grpc.CallOption -func (_e *MockIndexNodeClient_Expecter) GetStatisticsChannel(ctx interface{}, in interface{}, opts ...interface{}) *MockIndexNodeClient_GetStatisticsChannel_Call { - return &MockIndexNodeClient_GetStatisticsChannel_Call{Call: _e.mock.On("GetStatisticsChannel", - append([]interface{}{ctx, in}, opts...)...)} -} - -func (_c *MockIndexNodeClient_GetStatisticsChannel_Call) Run(run func(ctx context.Context, in *internalpb.GetStatisticsChannelRequest, opts ...grpc.CallOption)) *MockIndexNodeClient_GetStatisticsChannel_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]grpc.CallOption, len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(grpc.CallOption) - } - } - run(args[0].(context.Context), args[1].(*internalpb.GetStatisticsChannelRequest), variadicArgs...) - }) - return _c -} - -func (_c *MockIndexNodeClient_GetStatisticsChannel_Call) Return(_a0 *milvuspb.StringResponse, _a1 error) *MockIndexNodeClient_GetStatisticsChannel_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNodeClient_GetStatisticsChannel_Call) RunAndReturn(run func(context.Context, *internalpb.GetStatisticsChannelRequest, ...grpc.CallOption) (*milvuspb.StringResponse, error)) *MockIndexNodeClient_GetStatisticsChannel_Call { - _c.Call.Return(run) - return _c -} - -// QueryJobs provides a mock function with given fields: ctx, in, opts -func (_m *MockIndexNodeClient) QueryJobs(ctx context.Context, in *workerpb.QueryJobsRequest, opts ...grpc.CallOption) (*workerpb.QueryJobsResponse, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for QueryJobs") - } - - var r0 *workerpb.QueryJobsResponse - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.QueryJobsRequest, ...grpc.CallOption) (*workerpb.QueryJobsResponse, error)); ok { - return rf(ctx, in, opts...) - } - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.QueryJobsRequest, ...grpc.CallOption) *workerpb.QueryJobsResponse); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*workerpb.QueryJobsResponse) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *workerpb.QueryJobsRequest, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNodeClient_QueryJobs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'QueryJobs' -type MockIndexNodeClient_QueryJobs_Call struct { - *mock.Call -} - -// QueryJobs is a helper method to define mock.On call -// - ctx context.Context -// - in *workerpb.QueryJobsRequest -// - opts ...grpc.CallOption -func (_e *MockIndexNodeClient_Expecter) QueryJobs(ctx interface{}, in interface{}, opts ...interface{}) *MockIndexNodeClient_QueryJobs_Call { - return &MockIndexNodeClient_QueryJobs_Call{Call: _e.mock.On("QueryJobs", - append([]interface{}{ctx, in}, opts...)...)} -} - -func (_c *MockIndexNodeClient_QueryJobs_Call) Run(run func(ctx context.Context, in *workerpb.QueryJobsRequest, opts ...grpc.CallOption)) *MockIndexNodeClient_QueryJobs_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]grpc.CallOption, len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(grpc.CallOption) - } - } - run(args[0].(context.Context), args[1].(*workerpb.QueryJobsRequest), variadicArgs...) - }) - return _c -} - -func (_c *MockIndexNodeClient_QueryJobs_Call) Return(_a0 *workerpb.QueryJobsResponse, _a1 error) *MockIndexNodeClient_QueryJobs_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNodeClient_QueryJobs_Call) RunAndReturn(run func(context.Context, *workerpb.QueryJobsRequest, ...grpc.CallOption) (*workerpb.QueryJobsResponse, error)) *MockIndexNodeClient_QueryJobs_Call { - _c.Call.Return(run) - return _c -} - -// QueryJobsV2 provides a mock function with given fields: ctx, in, opts -func (_m *MockIndexNodeClient) QueryJobsV2(ctx context.Context, in *workerpb.QueryJobsV2Request, opts ...grpc.CallOption) (*workerpb.QueryJobsV2Response, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for QueryJobsV2") - } - - var r0 *workerpb.QueryJobsV2Response - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.QueryJobsV2Request, ...grpc.CallOption) (*workerpb.QueryJobsV2Response, error)); ok { - return rf(ctx, in, opts...) - } - if rf, ok := ret.Get(0).(func(context.Context, *workerpb.QueryJobsV2Request, ...grpc.CallOption) *workerpb.QueryJobsV2Response); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*workerpb.QueryJobsV2Response) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *workerpb.QueryJobsV2Request, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNodeClient_QueryJobsV2_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'QueryJobsV2' -type MockIndexNodeClient_QueryJobsV2_Call struct { - *mock.Call -} - -// QueryJobsV2 is a helper method to define mock.On call -// - ctx context.Context -// - in *workerpb.QueryJobsV2Request -// - opts ...grpc.CallOption -func (_e *MockIndexNodeClient_Expecter) QueryJobsV2(ctx interface{}, in interface{}, opts ...interface{}) *MockIndexNodeClient_QueryJobsV2_Call { - return &MockIndexNodeClient_QueryJobsV2_Call{Call: _e.mock.On("QueryJobsV2", - append([]interface{}{ctx, in}, opts...)...)} -} - -func (_c *MockIndexNodeClient_QueryJobsV2_Call) Run(run func(ctx context.Context, in *workerpb.QueryJobsV2Request, opts ...grpc.CallOption)) *MockIndexNodeClient_QueryJobsV2_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]grpc.CallOption, len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(grpc.CallOption) - } - } - run(args[0].(context.Context), args[1].(*workerpb.QueryJobsV2Request), variadicArgs...) - }) - return _c -} - -func (_c *MockIndexNodeClient_QueryJobsV2_Call) Return(_a0 *workerpb.QueryJobsV2Response, _a1 error) *MockIndexNodeClient_QueryJobsV2_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNodeClient_QueryJobsV2_Call) RunAndReturn(run func(context.Context, *workerpb.QueryJobsV2Request, ...grpc.CallOption) (*workerpb.QueryJobsV2Response, error)) *MockIndexNodeClient_QueryJobsV2_Call { - _c.Call.Return(run) - return _c -} - -// ShowConfigurations provides a mock function with given fields: ctx, in, opts -func (_m *MockIndexNodeClient) ShowConfigurations(ctx context.Context, in *internalpb.ShowConfigurationsRequest, opts ...grpc.CallOption) (*internalpb.ShowConfigurationsResponse, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for ShowConfigurations") - } - - var r0 *internalpb.ShowConfigurationsResponse - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *internalpb.ShowConfigurationsRequest, ...grpc.CallOption) (*internalpb.ShowConfigurationsResponse, error)); ok { - return rf(ctx, in, opts...) - } - if rf, ok := ret.Get(0).(func(context.Context, *internalpb.ShowConfigurationsRequest, ...grpc.CallOption) *internalpb.ShowConfigurationsResponse); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*internalpb.ShowConfigurationsResponse) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *internalpb.ShowConfigurationsRequest, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockIndexNodeClient_ShowConfigurations_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ShowConfigurations' -type MockIndexNodeClient_ShowConfigurations_Call struct { - *mock.Call -} - -// ShowConfigurations is a helper method to define mock.On call -// - ctx context.Context -// - in *internalpb.ShowConfigurationsRequest -// - opts ...grpc.CallOption -func (_e *MockIndexNodeClient_Expecter) ShowConfigurations(ctx interface{}, in interface{}, opts ...interface{}) *MockIndexNodeClient_ShowConfigurations_Call { - return &MockIndexNodeClient_ShowConfigurations_Call{Call: _e.mock.On("ShowConfigurations", - append([]interface{}{ctx, in}, opts...)...)} -} - -func (_c *MockIndexNodeClient_ShowConfigurations_Call) Run(run func(ctx context.Context, in *internalpb.ShowConfigurationsRequest, opts ...grpc.CallOption)) *MockIndexNodeClient_ShowConfigurations_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]grpc.CallOption, len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(grpc.CallOption) - } - } - run(args[0].(context.Context), args[1].(*internalpb.ShowConfigurationsRequest), variadicArgs...) - }) - return _c -} - -func (_c *MockIndexNodeClient_ShowConfigurations_Call) Return(_a0 *internalpb.ShowConfigurationsResponse, _a1 error) *MockIndexNodeClient_ShowConfigurations_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockIndexNodeClient_ShowConfigurations_Call) RunAndReturn(run func(context.Context, *internalpb.ShowConfigurationsRequest, ...grpc.CallOption) (*internalpb.ShowConfigurationsResponse, error)) *MockIndexNodeClient_ShowConfigurations_Call { - _c.Call.Return(run) - return _c -} - -// NewMockIndexNodeClient creates a new instance of MockIndexNodeClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockIndexNodeClient(t interface { - mock.TestingT - Cleanup(func()) -}) *MockIndexNodeClient { - mock := &MockIndexNodeClient{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/internal/proxy/metrics_info.go b/internal/proxy/metrics_info.go index 0e61f2b1f6..f6b25360a3 100644 --- a/internal/proxy/metrics_info.go +++ b/internal/proxy/metrics_info.go @@ -359,24 +359,6 @@ func getSystemInfoMetrics( }) } - // add data nodes to system topology graph - for _, indexNode := range dataCoordTopology.Cluster.ConnectedIndexNodes { - node := indexNode - identifier := int(node.ID) - identifierMap[indexNode.Name] = identifier - indexNodeTopologyNode := metricsinfo.SystemTopologyNode{ - Identifier: identifier, - Connected: nil, - Infos: &node, - } - systemTopology.NodesInfo = append(systemTopology.NodesInfo, indexNodeTopologyNode) - dataCoordTopologyNode.Connected = append(dataCoordTopologyNode.Connected, metricsinfo.ConnectionEdge{ - ConnectedIdentifier: identifier, - Type: metricsinfo.CoordConnectToNode, - TargetType: typeutil.IndexNodeRole, - }) - } - // add DataCoord to system topology graph systemTopology.NodesInfo = append(systemTopology.NodesInfo, dataCoordTopologyNode) } diff --git a/internal/proxy/metrics_info_test.go b/internal/proxy/metrics_info_test.go index 61497ca792..7fa1892941 100644 --- a/internal/proxy/metrics_info_test.go +++ b/internal/proxy/metrics_info_test.go @@ -159,8 +159,7 @@ func getMockProxyRequestMetrics() *Proxy { }, SystemConfigurations: metricsinfo.DataCoordConfiguration{}, }, - ConnectedDataNodes: make([]metricsinfo.DataNodeInfos, 0), - ConnectedIndexNodes: make([]metricsinfo.IndexNodeInfos, 0), + ConnectedDataNodes: make([]metricsinfo.DataNodeInfos, 0), } infos := metricsinfo.DataNodeInfos{ @@ -169,11 +168,11 @@ func getMockProxyRequestMetrics() *Proxy { } clusterTopology.ConnectedDataNodes = append(clusterTopology.ConnectedDataNodes, infos) - indexNodeInfos := metricsinfo.IndexNodeInfos{ + indexNodeInfos := metricsinfo.DataNodeInfos{ BaseComponentInfos: metricsinfo.BaseComponentInfos{}, - SystemConfigurations: metricsinfo.IndexNodeConfiguration{}, + SystemConfigurations: metricsinfo.DataNodeConfiguration{}, } - clusterTopology.ConnectedIndexNodes = append(clusterTopology.ConnectedIndexNodes, indexNodeInfos) + clusterTopology.ConnectedDataNodes = append(clusterTopology.ConnectedDataNodes, indexNodeInfos) coordTopology := metricsinfo.DataCoordTopology{ Cluster: clusterTopology, diff --git a/internal/proxy/proxy_test.go b/internal/proxy/proxy_test.go index a8c035c05c..97874422f0 100644 --- a/internal/proxy/proxy_test.go +++ b/internal/proxy/proxy_test.go @@ -48,7 +48,6 @@ import ( grpcdatacoordclient "github.com/milvus-io/milvus/internal/distributed/datacoord" grpcdatacoordclient2 "github.com/milvus-io/milvus/internal/distributed/datacoord/client" grpcdatanode "github.com/milvus-io/milvus/internal/distributed/datanode" - grpcindexnode "github.com/milvus-io/milvus/internal/distributed/indexnode" grpcquerycoord "github.com/milvus-io/milvus/internal/distributed/querycoord" grpcquerycoordclient "github.com/milvus-io/milvus/internal/distributed/querycoord/client" grpcquerynode "github.com/milvus-io/milvus/internal/distributed/querynode" @@ -230,45 +229,6 @@ func runDataNode(ctx context.Context, localMsg bool, alias string) *grpcdatanode return dn } -func runIndexNode(ctx context.Context, localMsg bool, alias string) *grpcindexnode.Server { - var in *grpcindexnode.Server - var wg sync.WaitGroup - - wg.Add(1) - go func() { - defer wg.Done() - factory := dependency.MockDefaultFactory(localMsg, Params) - var err error - in, err = grpcindexnode.NewServer(ctx, factory) - if err != nil { - panic(err) - } - etcd, err := etcd.GetEtcdClient( - Params.EtcdCfg.UseEmbedEtcd.GetAsBool(), - Params.EtcdCfg.EtcdUseSSL.GetAsBool(), - Params.EtcdCfg.Endpoints.GetAsStrings(), - Params.EtcdCfg.EtcdTLSCert.GetValue(), - Params.EtcdCfg.EtcdTLSKey.GetValue(), - Params.EtcdCfg.EtcdTLSCACert.GetValue(), - Params.EtcdCfg.EtcdTLSMinVersion.GetValue()) - if err != nil { - panic(err) - } - in.SetEtcdClient(etcd) - if err = in.Prepare(); err != nil { - panic(err) - } - err = in.Run() - if err != nil { - panic(err) - } - }() - wg.Wait() - - metrics.RegisterIndexNode(Registry) - return in -} - type proxyTestServer struct { *Proxy grpcServer *grpc.Server @@ -379,7 +339,6 @@ func TestProxy(t *testing.T) { params.ProxyGrpcServerCfg.IP = "localhost" params.QueryNodeGrpcServerCfg.IP = "localhost" params.DataNodeGrpcServerCfg.IP = "localhost" - params.IndexNodeGrpcServerCfg.IP = "localhost" params.StreamingNodeGrpcServerCfg.IP = "localhost" path := "/tmp/milvus/rocksmq" + funcutil.GenRandomStr() @@ -409,9 +368,6 @@ func TestProxy(t *testing.T) { qn := runQueryNode(ctx, localMsg, alias) log.Info("running QueryNode ...") - in := runIndexNode(ctx, localMsg, alias) - log.Info("running IndexNode ...") - time.Sleep(10 * time.Millisecond) proxy, err := NewProxy(ctx, factory) @@ -479,7 +435,7 @@ func TestProxy(t *testing.T) { assert.NoError(t, err) log.Info("Register proxy done") defer func() { - a := []any{rc, dc, qc, qn, in, dn, proxy} + a := []any{rc, dc, qc, qn, dn, proxy} fmt.Println(len(a)) // HINT: the order of stopping service refers to the `roles.go` file log.Info("start to stop the services") @@ -507,12 +463,6 @@ func TestProxy(t *testing.T) { log.Info("stop query node") } - { - err := in.Stop() - assert.NoError(t, err) - log.Info("stop IndexNode") - } - { err := dn.Stop() assert.NoError(t, err) diff --git a/internal/types/types.go b/internal/types/types.go index 79fa9d631c..ceeae9e524 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -55,12 +55,14 @@ type Component interface { type DataNodeClient interface { io.Closer datapb.DataNodeClient + workerpb.IndexNodeClient } // DataNode is the interface `datanode` package implements type DataNode interface { Component datapb.DataNodeServer + workerpb.IndexNodeServer } // DataNodeComponent is used by grpc server of DataNode @@ -133,35 +135,6 @@ type DataCoordComponent interface { // SetDataNodeCreator set DataNode client creator func for DataCoord SetDataNodeCreator(func(context.Context, string, int64) (DataNodeClient, error)) - - // SetIndexNodeCreator set Index client creator func for DataCoord - SetIndexNodeCreator(func(context.Context, string, int64) (IndexNodeClient, error)) -} - -// IndexNodeClient is the client interface for indexnode server -type IndexNodeClient interface { - io.Closer - workerpb.IndexNodeClient -} - -// IndexNode is the interface `indexnode` package implements -type IndexNode interface { - Component - workerpb.IndexNodeServer -} - -// IndexNodeComponent is used by grpc server of IndexNode -type IndexNodeComponent interface { - IndexNode - - SetAddress(address string) - GetAddress() string - // SetEtcdClient set etcd client for IndexNodeComponent - SetEtcdClient(etcdClient *clientv3.Client) - - // UpdateStateCode updates state code for IndexNodeComponent - // `stateCode` is current statement of this QueryCoord, indicating whether it's healthy. - UpdateStateCode(stateCode commonpb.StateCode) } // RootCoordClient is the client interface for rootcoord server @@ -254,10 +227,6 @@ type ProxyComponent interface { // `dataCoord` is a client of data coordinator. SetDataCoordClient(dataCoord DataCoordClient) - // SetIndexCoordClient set IndexCoord for Proxy - // `indexCoord` is a client of index coordinator. - // SetIndexCoordClient(indexCoord IndexCoord) - // SetQueryCoordClient set QueryCoord for Proxy // `queryCoord` is a client of query coordinator. SetQueryCoordClient(queryCoord QueryCoordClient) diff --git a/internal/util/mock/grpc_datanode_client.go b/internal/util/mock/grpc_datanode_client.go index 59d1997973..d22286fa2d 100644 --- a/internal/util/mock/grpc_datanode_client.go +++ b/internal/util/mock/grpc_datanode_client.go @@ -25,6 +25,7 @@ import ( "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" "github.com/milvus-io/milvus/pkg/v2/proto/datapb" "github.com/milvus-io/milvus/pkg/v2/proto/internalpb" + "github.com/milvus-io/milvus/pkg/v2/proto/workerpb" ) var _ datapb.DataNodeClient = &GrpcDataNodeClient{} @@ -33,6 +34,34 @@ type GrpcDataNodeClient struct { Err error } +func (m *GrpcDataNodeClient) CreateJob(ctx context.Context, in *workerpb.CreateJobRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { + return &commonpb.Status{}, m.Err +} + +func (m *GrpcDataNodeClient) QueryJobs(ctx context.Context, in *workerpb.QueryJobsRequest, opts ...grpc.CallOption) (*workerpb.QueryJobsResponse, error) { + return &workerpb.QueryJobsResponse{}, m.Err +} + +func (m *GrpcDataNodeClient) DropJobs(ctx context.Context, in *workerpb.DropJobsRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { + return &commonpb.Status{}, m.Err +} + +func (m *GrpcDataNodeClient) GetJobStats(ctx context.Context, in *workerpb.GetJobStatsRequest, opts ...grpc.CallOption) (*workerpb.GetJobStatsResponse, error) { + return &workerpb.GetJobStatsResponse{}, m.Err +} + +func (m *GrpcDataNodeClient) CreateJobV2(ctx context.Context, in *workerpb.CreateJobV2Request, opts ...grpc.CallOption) (*commonpb.Status, error) { + return &commonpb.Status{}, m.Err +} + +func (m *GrpcDataNodeClient) QueryJobsV2(ctx context.Context, in *workerpb.QueryJobsV2Request, opts ...grpc.CallOption) (*workerpb.QueryJobsV2Response, error) { + return &workerpb.QueryJobsV2Response{}, m.Err +} + +func (m *GrpcDataNodeClient) DropJobsV2(ctx context.Context, in *workerpb.DropJobsV2Request, opts ...grpc.CallOption) (*commonpb.Status, error) { + return &commonpb.Status{}, m.Err +} + func (m *GrpcDataNodeClient) GetComponentStates(ctx context.Context, in *milvuspb.GetComponentStatesRequest, opts ...grpc.CallOption) (*milvuspb.ComponentStates, error) { return &milvuspb.ComponentStates{}, m.Err } diff --git a/pkg/metrics/datanode_metrics.go b/pkg/metrics/datanode_metrics.go index d20312ee7e..5646fd39c6 100644 --- a/pkg/metrics/datanode_metrics.go +++ b/pkg/metrics/datanode_metrics.go @@ -242,6 +242,81 @@ var ( Name: "compaction_missing_delete_count", Help: "Number of missing deletes in compaction", }, []string{collectionIDLabelName}) + + // index service metrics + // unit second, from 1ms to 2hrs + indexBucket = []float64{0.001, 0.1, 0.5, 1, 5, 10, 20, 50, 100, 250, 500, 1000, 3600, 5000, 10000} + + DataNodeBuildIndexTaskCounter = prometheus.NewCounterVec( + prometheus.CounterOpts{ + Namespace: milvusNamespace, + Subsystem: typeutil.IndexNodeRole, + Name: "index_task_count", + Help: "number of tasks that index node received", + }, []string{nodeIDLabelName, statusLabelName}) + + DataNodeLoadFieldLatency = prometheus.NewHistogramVec( + prometheus.HistogramOpts{ + Namespace: milvusNamespace, + Subsystem: typeutil.IndexNodeRole, + Name: "load_field_latency", + Help: "latency of loading the field data", + Buckets: indexBucket, + }, []string{nodeIDLabelName}) + + DataNodeDecodeFieldLatency = prometheus.NewHistogramVec( + prometheus.HistogramOpts{ + Namespace: milvusNamespace, + Subsystem: typeutil.IndexNodeRole, + Name: "decode_field_latency", + Help: "latency of decode field data", + Buckets: indexBucket, + }, []string{nodeIDLabelName}) + + DataNodeKnowhereBuildIndexLatency = prometheus.NewHistogramVec( + prometheus.HistogramOpts{ + Namespace: milvusNamespace, + Subsystem: typeutil.IndexNodeRole, + Name: "knowhere_build_index_latency", + Help: "latency of building the index by knowhere", + Buckets: indexBucket, + }, []string{nodeIDLabelName}) + + DataNodeEncodeIndexFileLatency = prometheus.NewHistogramVec( + prometheus.HistogramOpts{ + Namespace: milvusNamespace, + Subsystem: typeutil.IndexNodeRole, + Name: "encode_index_latency", + Help: "latency of encoding the index file", + Buckets: indexBucket, + }, []string{nodeIDLabelName}) + + DataNodeSaveIndexFileLatency = prometheus.NewHistogramVec( + prometheus.HistogramOpts{ + Namespace: milvusNamespace, + Subsystem: typeutil.IndexNodeRole, + Name: "save_index_latency", + Help: "latency of saving the index file", + Buckets: indexBucket, + }, []string{nodeIDLabelName}) + + DataNodeIndexTaskLatencyInQueue = prometheus.NewHistogramVec( + prometheus.HistogramOpts{ + Namespace: milvusNamespace, + Subsystem: typeutil.IndexNodeRole, + Name: "index_task_latency_in_queue", + Help: "latency of index task in queue", + Buckets: buckets, + }, []string{nodeIDLabelName}) + + DataNodeBuildIndexLatency = prometheus.NewHistogramVec( + prometheus.HistogramOpts{ + Namespace: milvusNamespace, + Subsystem: typeutil.IndexNodeRole, + Name: "build_index_latency", + Help: "latency of build index for segment", + Buckets: indexBucket, + }, []string{nodeIDLabelName}) ) // RegisterDataNode registers DataNode metrics @@ -271,6 +346,16 @@ func RegisterDataNode(registry *prometheus.Registry) { // deprecated metrics registry.MustRegister(DataNodeForwardDeleteMsgTimeTaken) registry.MustRegister(DataNodeNumProducers) + + // index metrics + registry.MustRegister(DataNodeBuildIndexTaskCounter) + registry.MustRegister(DataNodeLoadFieldLatency) + registry.MustRegister(DataNodeDecodeFieldLatency) + registry.MustRegister(DataNodeKnowhereBuildIndexLatency) + registry.MustRegister(DataNodeEncodeIndexFileLatency) + registry.MustRegister(DataNodeSaveIndexFileLatency) + registry.MustRegister(DataNodeIndexTaskLatencyInQueue) + registry.MustRegister(DataNodeBuildIndexLatency) } func CleanupDataNodeCollectionMetrics(nodeID int64, collectionID int64, channel string) { diff --git a/pkg/metrics/indexnode_metrics.go b/pkg/metrics/indexnode_metrics.go deleted file mode 100644 index 44c5b3b13f..0000000000 --- a/pkg/metrics/indexnode_metrics.go +++ /dev/null @@ -1,111 +0,0 @@ -// 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. - -package metrics - -import ( - "github.com/prometheus/client_golang/prometheus" - - "github.com/milvus-io/milvus/pkg/v2/util/typeutil" -) - -var ( - // unit second, from 1ms to 2hrs - indexBucket = []float64{0.001, 0.1, 0.5, 1, 5, 10, 20, 50, 100, 250, 500, 1000, 3600, 5000, 10000} - - IndexNodeBuildIndexTaskCounter = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Namespace: milvusNamespace, - Subsystem: typeutil.IndexNodeRole, - Name: "index_task_count", - Help: "number of tasks that index node received", - }, []string{nodeIDLabelName, statusLabelName}) - - IndexNodeLoadFieldLatency = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Namespace: milvusNamespace, - Subsystem: typeutil.IndexNodeRole, - Name: "load_field_latency", - Help: "latency of loading the field data", - Buckets: indexBucket, - }, []string{nodeIDLabelName}) - - IndexNodeDecodeFieldLatency = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Namespace: milvusNamespace, - Subsystem: typeutil.IndexNodeRole, - Name: "decode_field_latency", - Help: "latency of decode field data", - Buckets: indexBucket, - }, []string{nodeIDLabelName}) - - IndexNodeKnowhereBuildIndexLatency = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Namespace: milvusNamespace, - Subsystem: typeutil.IndexNodeRole, - Name: "knowhere_build_index_latency", - Help: "latency of building the index by knowhere", - Buckets: indexBucket, - }, []string{nodeIDLabelName}) - - IndexNodeEncodeIndexFileLatency = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Namespace: milvusNamespace, - Subsystem: typeutil.IndexNodeRole, - Name: "encode_index_latency", - Help: "latency of encoding the index file", - Buckets: indexBucket, - }, []string{nodeIDLabelName}) - - IndexNodeSaveIndexFileLatency = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Namespace: milvusNamespace, - Subsystem: typeutil.IndexNodeRole, - Name: "save_index_latency", - Help: "latency of saving the index file", - Buckets: indexBucket, - }, []string{nodeIDLabelName}) - - IndexNodeIndexTaskLatencyInQueue = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Namespace: milvusNamespace, - Subsystem: typeutil.IndexNodeRole, - Name: "index_task_latency_in_queue", - Help: "latency of index task in queue", - Buckets: buckets, - }, []string{nodeIDLabelName}) - - IndexNodeBuildIndexLatency = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Namespace: milvusNamespace, - Subsystem: typeutil.IndexNodeRole, - Name: "build_index_latency", - Help: "latency of build index for segment", - Buckets: indexBucket, - }, []string{nodeIDLabelName}) -) - -// RegisterIndexNode registers IndexNode metrics -func RegisterIndexNode(registry *prometheus.Registry) { - registry.MustRegister(IndexNodeBuildIndexTaskCounter) - registry.MustRegister(IndexNodeLoadFieldLatency) - registry.MustRegister(IndexNodeDecodeFieldLatency) - registry.MustRegister(IndexNodeKnowhereBuildIndexLatency) - registry.MustRegister(IndexNodeEncodeIndexFileLatency) - registry.MustRegister(IndexNodeSaveIndexFileLatency) - registry.MustRegister(IndexNodeIndexTaskLatencyInQueue) - registry.MustRegister(IndexNodeBuildIndexLatency) -} diff --git a/pkg/metrics/metrics_test.go b/pkg/metrics/metrics_test.go index d0ef28a0a3..d89d08d088 100644 --- a/pkg/metrics/metrics_test.go +++ b/pkg/metrics/metrics_test.go @@ -31,7 +31,6 @@ func TestRegisterMetrics(t *testing.T) { RegisterRootCoord(r) RegisterDataNode(r) RegisterDataCoord(r) - RegisterIndexNode(r) RegisterProxy(r) RegisterQueryNode(r) RegisterQueryCoord(r) diff --git a/pkg/proto/worker.proto b/pkg/proto/worker.proto index c1ec92552d..481f0e0c39 100644 --- a/pkg/proto/worker.proto +++ b/pkg/proto/worker.proto @@ -13,12 +13,6 @@ import "index_coord.proto"; service IndexNode { - rpc GetComponentStates(milvus.GetComponentStatesRequest) - returns (milvus.ComponentStates) { - } - rpc GetStatisticsChannel(internal.GetStatisticsChannelRequest) - returns (milvus.StringResponse) { - } rpc CreateJob(CreateJobRequest) returns (common.Status) { } rpc QueryJobs(QueryJobsRequest) returns (QueryJobsResponse) { @@ -27,15 +21,6 @@ service IndexNode { } rpc GetJobStats(GetJobStatsRequest) returns (GetJobStatsResponse) { } - - rpc ShowConfigurations(internal.ShowConfigurationsRequest) - returns (internal.ShowConfigurationsResponse) { - } - // https://wiki.lfaidata.foundation/display/MIL/MEP+8+--+Add+metrics+for+proxy - rpc GetMetrics(milvus.GetMetricsRequest) - returns (milvus.GetMetricsResponse) { - } - rpc CreateJobV2(CreateJobV2Request) returns (common.Status) { } rpc QueryJobsV2(QueryJobsV2Request) returns (QueryJobsV2Response) { diff --git a/pkg/proto/workerpb/worker.pb.go b/pkg/proto/workerpb/worker.pb.go index 75f5f9605d..5ee88e8e30 100644 --- a/pkg/proto/workerpb/worker.pb.go +++ b/pkg/proto/workerpb/worker.pb.go @@ -8,11 +8,11 @@ package workerpb import ( commonpb "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" - milvuspb "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" + _ "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" schemapb "github.com/milvus-io/milvus-proto/go-api/v2/schemapb" datapb "github.com/milvus-io/milvus/pkg/v2/proto/datapb" indexpb "github.com/milvus-io/milvus/pkg/v2/proto/indexpb" - internalpb "github.com/milvus-io/milvus/pkg/v2/proto/internalpb" + _ "github.com/milvus-io/milvus/pkg/v2/proto/internalpb" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -2153,78 +2153,50 @@ var file_worker_proto_rawDesc = []byte{ 0x12, 0x36, 0x0a, 0x08, 0x6a, 0x6f, 0x62, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x4a, 0x6f, 0x62, 0x54, 0x79, 0x70, 0x65, 0x52, - 0x07, 0x6a, 0x6f, 0x62, 0x54, 0x79, 0x70, 0x65, 0x32, 0xb6, 0x08, 0x0a, 0x09, 0x49, 0x6e, 0x64, - 0x65, 0x78, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x6c, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, - 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x73, 0x12, 0x2e, 0x2e, 0x6d, - 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x69, 0x6c, 0x76, - 0x75, 0x73, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x53, - 0x74, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x6d, - 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x69, 0x6c, 0x76, - 0x75, 0x73, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x73, 0x22, 0x00, 0x12, 0x71, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x69, - 0x73, 0x74, 0x69, 0x63, 0x73, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x32, 0x2e, 0x6d, - 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, - 0x63, 0x73, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x23, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, - 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x50, 0x0a, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x4a, 0x6f, 0x62, 0x12, 0x24, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6d, 0x69, 0x6c, - 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, - 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x00, 0x12, 0x5a, 0x0a, 0x09, 0x51, 0x75, 0x65, - 0x72, 0x79, 0x4a, 0x6f, 0x62, 0x73, 0x12, 0x24, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x51, 0x75, 0x65, 0x72, - 0x79, 0x4a, 0x6f, 0x62, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x6d, - 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x69, 0x6e, 0x64, 0x65, - 0x78, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4a, 0x6f, 0x62, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4e, 0x0a, 0x08, 0x44, 0x72, 0x6f, 0x70, 0x4a, 0x6f, 0x62, - 0x73, 0x12, 0x23, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x4a, 0x6f, 0x62, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x22, 0x00, 0x12, 0x60, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x4a, 0x6f, 0x62, 0x53, - 0x74, 0x61, 0x74, 0x73, 0x12, 0x26, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x47, 0x65, 0x74, 0x4a, 0x6f, 0x62, - 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x6d, - 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x69, 0x6e, 0x64, 0x65, - 0x78, 0x2e, 0x47, 0x65, 0x74, 0x4a, 0x6f, 0x62, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x7b, 0x0a, 0x12, 0x53, 0x68, 0x6f, 0x77, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x30, 0x2e, - 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x53, 0x68, 0x6f, 0x77, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x31, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x53, 0x68, 0x6f, 0x77, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x12, 0x5f, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x4d, 0x65, 0x74, 0x72, 0x69, - 0x63, 0x73, 0x12, 0x26, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x47, 0x65, 0x74, 0x4d, 0x65, 0x74, 0x72, - 0x69, 0x63, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x6d, 0x69, 0x6c, - 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, - 0x2e, 0x47, 0x65, 0x74, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x54, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4a, - 0x6f, 0x62, 0x56, 0x32, 0x12, 0x26, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x4a, 0x6f, 0x62, 0x56, 0x32, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6d, - 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x6f, 0x6e, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x00, 0x12, 0x60, 0x0a, 0x0b, 0x51, - 0x75, 0x65, 0x72, 0x79, 0x4a, 0x6f, 0x62, 0x73, 0x56, 0x32, 0x12, 0x26, 0x2e, 0x6d, 0x69, 0x6c, - 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, - 0x51, 0x75, 0x65, 0x72, 0x79, 0x4a, 0x6f, 0x62, 0x73, 0x56, 0x32, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4a, 0x6f, 0x62, - 0x73, 0x56, 0x32, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x52, 0x0a, - 0x0a, 0x44, 0x72, 0x6f, 0x70, 0x4a, 0x6f, 0x62, 0x73, 0x56, 0x32, 0x12, 0x25, 0x2e, 0x6d, 0x69, + 0x07, 0x6a, 0x6f, 0x62, 0x54, 0x79, 0x70, 0x65, 0x32, 0xf7, 0x04, 0x0a, 0x09, 0x49, 0x6e, 0x64, + 0x65, 0x78, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x50, 0x0a, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x4a, 0x6f, 0x62, 0x12, 0x24, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4a, + 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6d, 0x69, 0x6c, 0x76, + 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x00, 0x12, 0x5a, 0x0a, 0x09, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x4a, 0x6f, 0x62, 0x73, 0x12, 0x24, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, + 0x4a, 0x6f, 0x62, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, - 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x4a, 0x6f, 0x62, 0x73, 0x56, 0x32, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, - 0x00, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2d, 0x69, 0x6f, 0x2f, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, - 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x77, 0x6f, - 0x72, 0x6b, 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4a, 0x6f, 0x62, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x4e, 0x0a, 0x08, 0x44, 0x72, 0x6f, 0x70, 0x4a, 0x6f, 0x62, 0x73, + 0x12, 0x23, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x4a, 0x6f, 0x62, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x22, 0x00, 0x12, 0x60, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x4a, 0x6f, 0x62, 0x53, 0x74, + 0x61, 0x74, 0x73, 0x12, 0x26, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x47, 0x65, 0x74, 0x4a, 0x6f, 0x62, 0x53, + 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x6d, 0x69, + 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, + 0x2e, 0x47, 0x65, 0x74, 0x4a, 0x6f, 0x62, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x54, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x4a, 0x6f, 0x62, 0x56, 0x32, 0x12, 0x26, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x4a, 0x6f, 0x62, 0x56, 0x32, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, + 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, + 0x6d, 0x6f, 0x6e, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x00, 0x12, 0x60, 0x0a, 0x0b, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x4a, 0x6f, 0x62, 0x73, 0x56, 0x32, 0x12, 0x26, 0x2e, 0x6d, 0x69, + 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, + 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4a, 0x6f, 0x62, 0x73, 0x56, 0x32, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4a, 0x6f, + 0x62, 0x73, 0x56, 0x32, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x52, + 0x0a, 0x0a, 0x44, 0x72, 0x6f, 0x70, 0x4a, 0x6f, 0x62, 0x73, 0x56, 0x32, 0x12, 0x25, 0x2e, 0x6d, + 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x69, 0x6e, 0x64, 0x65, + 0x78, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x4a, 0x6f, 0x62, 0x73, 0x56, 0x32, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x22, 0x00, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x6d, 0x69, 0x6c, 0x76, 0x75, 0x73, 0x2d, 0x69, 0x6f, 0x2f, 0x6d, 0x69, 0x6c, 0x76, 0x75, + 0x73, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x77, + 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2241,49 +2213,41 @@ func file_worker_proto_rawDescGZIP() []byte { var file_worker_proto_msgTypes = make([]protoimpl.MessageInfo, 20) var file_worker_proto_goTypes = []interface{}{ - (*CreateJobRequest)(nil), // 0: milvus.proto.index.CreateJobRequest - (*QueryJobsRequest)(nil), // 1: milvus.proto.index.QueryJobsRequest - (*QueryJobsResponse)(nil), // 2: milvus.proto.index.QueryJobsResponse - (*DropJobsRequest)(nil), // 3: milvus.proto.index.DropJobsRequest - (*GetJobStatsRequest)(nil), // 4: milvus.proto.index.GetJobStatsRequest - (*GetJobStatsResponse)(nil), // 5: milvus.proto.index.GetJobStatsResponse - (*AnalyzeRequest)(nil), // 6: milvus.proto.index.AnalyzeRequest - (*CreateStatsRequest)(nil), // 7: milvus.proto.index.CreateStatsRequest - (*CreateJobV2Request)(nil), // 8: milvus.proto.index.CreateJobV2Request - (*QueryJobsV2Request)(nil), // 9: milvus.proto.index.QueryJobsV2Request - (*IndexTaskInfo)(nil), // 10: milvus.proto.index.IndexTaskInfo - (*IndexJobResults)(nil), // 11: milvus.proto.index.IndexJobResults - (*AnalyzeResult)(nil), // 12: milvus.proto.index.AnalyzeResult - (*AnalyzeResults)(nil), // 13: milvus.proto.index.AnalyzeResults - (*StatsResult)(nil), // 14: milvus.proto.index.StatsResult - (*StatsResults)(nil), // 15: milvus.proto.index.StatsResults - (*QueryJobsV2Response)(nil), // 16: milvus.proto.index.QueryJobsV2Response - (*DropJobsV2Request)(nil), // 17: milvus.proto.index.DropJobsV2Request - nil, // 18: milvus.proto.index.AnalyzeRequest.SegmentStatsEntry - nil, // 19: milvus.proto.index.StatsResult.TextStatsLogsEntry - (*indexpb.StorageConfig)(nil), // 20: milvus.proto.index.StorageConfig - (*commonpb.KeyValuePair)(nil), // 21: milvus.proto.common.KeyValuePair - (schemapb.DataType)(0), // 22: milvus.proto.schema.DataType - (*indexpb.OptionalFieldInfo)(nil), // 23: milvus.proto.index.OptionalFieldInfo - (*schemapb.FieldSchema)(nil), // 24: milvus.proto.schema.FieldSchema - (*commonpb.Status)(nil), // 25: milvus.proto.common.Status - (*indexpb.JobInfo)(nil), // 26: milvus.proto.index.JobInfo - (*datapb.FieldBinlog)(nil), // 27: milvus.proto.data.FieldBinlog - (*schemapb.CollectionSchema)(nil), // 28: milvus.proto.schema.CollectionSchema - (indexpb.StatsSubJob)(0), // 29: milvus.proto.index.StatsSubJob - (indexpb.JobType)(0), // 30: milvus.proto.index.JobType - (commonpb.IndexState)(0), // 31: milvus.proto.common.IndexState - (indexpb.JobState)(0), // 32: milvus.proto.index.JobState - (*indexpb.SegmentStats)(nil), // 33: milvus.proto.index.SegmentStats - (*datapb.TextIndexStats)(nil), // 34: milvus.proto.data.TextIndexStats - (*milvuspb.GetComponentStatesRequest)(nil), // 35: milvus.proto.milvus.GetComponentStatesRequest - (*internalpb.GetStatisticsChannelRequest)(nil), // 36: milvus.proto.internal.GetStatisticsChannelRequest - (*internalpb.ShowConfigurationsRequest)(nil), // 37: milvus.proto.internal.ShowConfigurationsRequest - (*milvuspb.GetMetricsRequest)(nil), // 38: milvus.proto.milvus.GetMetricsRequest - (*milvuspb.ComponentStates)(nil), // 39: milvus.proto.milvus.ComponentStates - (*milvuspb.StringResponse)(nil), // 40: milvus.proto.milvus.StringResponse - (*internalpb.ShowConfigurationsResponse)(nil), // 41: milvus.proto.internal.ShowConfigurationsResponse - (*milvuspb.GetMetricsResponse)(nil), // 42: milvus.proto.milvus.GetMetricsResponse + (*CreateJobRequest)(nil), // 0: milvus.proto.index.CreateJobRequest + (*QueryJobsRequest)(nil), // 1: milvus.proto.index.QueryJobsRequest + (*QueryJobsResponse)(nil), // 2: milvus.proto.index.QueryJobsResponse + (*DropJobsRequest)(nil), // 3: milvus.proto.index.DropJobsRequest + (*GetJobStatsRequest)(nil), // 4: milvus.proto.index.GetJobStatsRequest + (*GetJobStatsResponse)(nil), // 5: milvus.proto.index.GetJobStatsResponse + (*AnalyzeRequest)(nil), // 6: milvus.proto.index.AnalyzeRequest + (*CreateStatsRequest)(nil), // 7: milvus.proto.index.CreateStatsRequest + (*CreateJobV2Request)(nil), // 8: milvus.proto.index.CreateJobV2Request + (*QueryJobsV2Request)(nil), // 9: milvus.proto.index.QueryJobsV2Request + (*IndexTaskInfo)(nil), // 10: milvus.proto.index.IndexTaskInfo + (*IndexJobResults)(nil), // 11: milvus.proto.index.IndexJobResults + (*AnalyzeResult)(nil), // 12: milvus.proto.index.AnalyzeResult + (*AnalyzeResults)(nil), // 13: milvus.proto.index.AnalyzeResults + (*StatsResult)(nil), // 14: milvus.proto.index.StatsResult + (*StatsResults)(nil), // 15: milvus.proto.index.StatsResults + (*QueryJobsV2Response)(nil), // 16: milvus.proto.index.QueryJobsV2Response + (*DropJobsV2Request)(nil), // 17: milvus.proto.index.DropJobsV2Request + nil, // 18: milvus.proto.index.AnalyzeRequest.SegmentStatsEntry + nil, // 19: milvus.proto.index.StatsResult.TextStatsLogsEntry + (*indexpb.StorageConfig)(nil), // 20: milvus.proto.index.StorageConfig + (*commonpb.KeyValuePair)(nil), // 21: milvus.proto.common.KeyValuePair + (schemapb.DataType)(0), // 22: milvus.proto.schema.DataType + (*indexpb.OptionalFieldInfo)(nil), // 23: milvus.proto.index.OptionalFieldInfo + (*schemapb.FieldSchema)(nil), // 24: milvus.proto.schema.FieldSchema + (*commonpb.Status)(nil), // 25: milvus.proto.common.Status + (*indexpb.JobInfo)(nil), // 26: milvus.proto.index.JobInfo + (*datapb.FieldBinlog)(nil), // 27: milvus.proto.data.FieldBinlog + (*schemapb.CollectionSchema)(nil), // 28: milvus.proto.schema.CollectionSchema + (indexpb.StatsSubJob)(0), // 29: milvus.proto.index.StatsSubJob + (indexpb.JobType)(0), // 30: milvus.proto.index.JobType + (commonpb.IndexState)(0), // 31: milvus.proto.common.IndexState + (indexpb.JobState)(0), // 32: milvus.proto.index.JobState + (*indexpb.SegmentStats)(nil), // 33: milvus.proto.index.SegmentStats + (*datapb.TextIndexStats)(nil), // 34: milvus.proto.data.TextIndexStats } var file_worker_proto_depIdxs = []int32{ 20, // 0: milvus.proto.index.CreateJobRequest.storage_config:type_name -> milvus.proto.index.StorageConfig @@ -2327,30 +2291,22 @@ var file_worker_proto_depIdxs = []int32{ 30, // 38: milvus.proto.index.DropJobsV2Request.job_type:type_name -> milvus.proto.index.JobType 33, // 39: milvus.proto.index.AnalyzeRequest.SegmentStatsEntry.value:type_name -> milvus.proto.index.SegmentStats 34, // 40: milvus.proto.index.StatsResult.TextStatsLogsEntry.value:type_name -> milvus.proto.data.TextIndexStats - 35, // 41: milvus.proto.index.IndexNode.GetComponentStates:input_type -> milvus.proto.milvus.GetComponentStatesRequest - 36, // 42: milvus.proto.index.IndexNode.GetStatisticsChannel:input_type -> milvus.proto.internal.GetStatisticsChannelRequest - 0, // 43: milvus.proto.index.IndexNode.CreateJob:input_type -> milvus.proto.index.CreateJobRequest - 1, // 44: milvus.proto.index.IndexNode.QueryJobs:input_type -> milvus.proto.index.QueryJobsRequest - 3, // 45: milvus.proto.index.IndexNode.DropJobs:input_type -> milvus.proto.index.DropJobsRequest - 4, // 46: milvus.proto.index.IndexNode.GetJobStats:input_type -> milvus.proto.index.GetJobStatsRequest - 37, // 47: milvus.proto.index.IndexNode.ShowConfigurations:input_type -> milvus.proto.internal.ShowConfigurationsRequest - 38, // 48: milvus.proto.index.IndexNode.GetMetrics:input_type -> milvus.proto.milvus.GetMetricsRequest - 8, // 49: milvus.proto.index.IndexNode.CreateJobV2:input_type -> milvus.proto.index.CreateJobV2Request - 9, // 50: milvus.proto.index.IndexNode.QueryJobsV2:input_type -> milvus.proto.index.QueryJobsV2Request - 17, // 51: milvus.proto.index.IndexNode.DropJobsV2:input_type -> milvus.proto.index.DropJobsV2Request - 39, // 52: milvus.proto.index.IndexNode.GetComponentStates:output_type -> milvus.proto.milvus.ComponentStates - 40, // 53: milvus.proto.index.IndexNode.GetStatisticsChannel:output_type -> milvus.proto.milvus.StringResponse - 25, // 54: milvus.proto.index.IndexNode.CreateJob:output_type -> milvus.proto.common.Status - 2, // 55: milvus.proto.index.IndexNode.QueryJobs:output_type -> milvus.proto.index.QueryJobsResponse - 25, // 56: milvus.proto.index.IndexNode.DropJobs:output_type -> milvus.proto.common.Status - 5, // 57: milvus.proto.index.IndexNode.GetJobStats:output_type -> milvus.proto.index.GetJobStatsResponse - 41, // 58: milvus.proto.index.IndexNode.ShowConfigurations:output_type -> milvus.proto.internal.ShowConfigurationsResponse - 42, // 59: milvus.proto.index.IndexNode.GetMetrics:output_type -> milvus.proto.milvus.GetMetricsResponse - 25, // 60: milvus.proto.index.IndexNode.CreateJobV2:output_type -> milvus.proto.common.Status - 16, // 61: milvus.proto.index.IndexNode.QueryJobsV2:output_type -> milvus.proto.index.QueryJobsV2Response - 25, // 62: milvus.proto.index.IndexNode.DropJobsV2:output_type -> milvus.proto.common.Status - 52, // [52:63] is the sub-list for method output_type - 41, // [41:52] is the sub-list for method input_type + 0, // 41: milvus.proto.index.IndexNode.CreateJob:input_type -> milvus.proto.index.CreateJobRequest + 1, // 42: milvus.proto.index.IndexNode.QueryJobs:input_type -> milvus.proto.index.QueryJobsRequest + 3, // 43: milvus.proto.index.IndexNode.DropJobs:input_type -> milvus.proto.index.DropJobsRequest + 4, // 44: milvus.proto.index.IndexNode.GetJobStats:input_type -> milvus.proto.index.GetJobStatsRequest + 8, // 45: milvus.proto.index.IndexNode.CreateJobV2:input_type -> milvus.proto.index.CreateJobV2Request + 9, // 46: milvus.proto.index.IndexNode.QueryJobsV2:input_type -> milvus.proto.index.QueryJobsV2Request + 17, // 47: milvus.proto.index.IndexNode.DropJobsV2:input_type -> milvus.proto.index.DropJobsV2Request + 25, // 48: milvus.proto.index.IndexNode.CreateJob:output_type -> milvus.proto.common.Status + 2, // 49: milvus.proto.index.IndexNode.QueryJobs:output_type -> milvus.proto.index.QueryJobsResponse + 25, // 50: milvus.proto.index.IndexNode.DropJobs:output_type -> milvus.proto.common.Status + 5, // 51: milvus.proto.index.IndexNode.GetJobStats:output_type -> milvus.proto.index.GetJobStatsResponse + 25, // 52: milvus.proto.index.IndexNode.CreateJobV2:output_type -> milvus.proto.common.Status + 16, // 53: milvus.proto.index.IndexNode.QueryJobsV2:output_type -> milvus.proto.index.QueryJobsV2Response + 25, // 54: milvus.proto.index.IndexNode.DropJobsV2:output_type -> milvus.proto.common.Status + 48, // [48:55] is the sub-list for method output_type + 41, // [41:48] is the sub-list for method input_type 41, // [41:41] is the sub-list for extension type_name 41, // [41:41] is the sub-list for extension extendee 0, // [0:41] is the sub-list for field type_name diff --git a/pkg/proto/workerpb/worker_grpc.pb.go b/pkg/proto/workerpb/worker_grpc.pb.go index a8af47a7b3..14412393b3 100644 --- a/pkg/proto/workerpb/worker_grpc.pb.go +++ b/pkg/proto/workerpb/worker_grpc.pb.go @@ -9,8 +9,6 @@ package workerpb import ( context "context" commonpb "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" - milvuspb "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" - internalpb "github.com/milvus-io/milvus/pkg/v2/proto/internalpb" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -22,32 +20,23 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - IndexNode_GetComponentStates_FullMethodName = "/milvus.proto.index.IndexNode/GetComponentStates" - IndexNode_GetStatisticsChannel_FullMethodName = "/milvus.proto.index.IndexNode/GetStatisticsChannel" - IndexNode_CreateJob_FullMethodName = "/milvus.proto.index.IndexNode/CreateJob" - IndexNode_QueryJobs_FullMethodName = "/milvus.proto.index.IndexNode/QueryJobs" - IndexNode_DropJobs_FullMethodName = "/milvus.proto.index.IndexNode/DropJobs" - IndexNode_GetJobStats_FullMethodName = "/milvus.proto.index.IndexNode/GetJobStats" - IndexNode_ShowConfigurations_FullMethodName = "/milvus.proto.index.IndexNode/ShowConfigurations" - IndexNode_GetMetrics_FullMethodName = "/milvus.proto.index.IndexNode/GetMetrics" - IndexNode_CreateJobV2_FullMethodName = "/milvus.proto.index.IndexNode/CreateJobV2" - IndexNode_QueryJobsV2_FullMethodName = "/milvus.proto.index.IndexNode/QueryJobsV2" - IndexNode_DropJobsV2_FullMethodName = "/milvus.proto.index.IndexNode/DropJobsV2" + IndexNode_CreateJob_FullMethodName = "/milvus.proto.index.IndexNode/CreateJob" + IndexNode_QueryJobs_FullMethodName = "/milvus.proto.index.IndexNode/QueryJobs" + IndexNode_DropJobs_FullMethodName = "/milvus.proto.index.IndexNode/DropJobs" + IndexNode_GetJobStats_FullMethodName = "/milvus.proto.index.IndexNode/GetJobStats" + IndexNode_CreateJobV2_FullMethodName = "/milvus.proto.index.IndexNode/CreateJobV2" + IndexNode_QueryJobsV2_FullMethodName = "/milvus.proto.index.IndexNode/QueryJobsV2" + IndexNode_DropJobsV2_FullMethodName = "/milvus.proto.index.IndexNode/DropJobsV2" ) // IndexNodeClient is the client API for IndexNode service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type IndexNodeClient interface { - GetComponentStates(ctx context.Context, in *milvuspb.GetComponentStatesRequest, opts ...grpc.CallOption) (*milvuspb.ComponentStates, error) - GetStatisticsChannel(ctx context.Context, in *internalpb.GetStatisticsChannelRequest, opts ...grpc.CallOption) (*milvuspb.StringResponse, error) CreateJob(ctx context.Context, in *CreateJobRequest, opts ...grpc.CallOption) (*commonpb.Status, error) QueryJobs(ctx context.Context, in *QueryJobsRequest, opts ...grpc.CallOption) (*QueryJobsResponse, error) DropJobs(ctx context.Context, in *DropJobsRequest, opts ...grpc.CallOption) (*commonpb.Status, error) GetJobStats(ctx context.Context, in *GetJobStatsRequest, opts ...grpc.CallOption) (*GetJobStatsResponse, error) - ShowConfigurations(ctx context.Context, in *internalpb.ShowConfigurationsRequest, opts ...grpc.CallOption) (*internalpb.ShowConfigurationsResponse, error) - // https://wiki.lfaidata.foundation/display/MIL/MEP+8+--+Add+metrics+for+proxy - GetMetrics(ctx context.Context, in *milvuspb.GetMetricsRequest, opts ...grpc.CallOption) (*milvuspb.GetMetricsResponse, error) CreateJobV2(ctx context.Context, in *CreateJobV2Request, opts ...grpc.CallOption) (*commonpb.Status, error) QueryJobsV2(ctx context.Context, in *QueryJobsV2Request, opts ...grpc.CallOption) (*QueryJobsV2Response, error) DropJobsV2(ctx context.Context, in *DropJobsV2Request, opts ...grpc.CallOption) (*commonpb.Status, error) @@ -61,24 +50,6 @@ func NewIndexNodeClient(cc grpc.ClientConnInterface) IndexNodeClient { return &indexNodeClient{cc} } -func (c *indexNodeClient) GetComponentStates(ctx context.Context, in *milvuspb.GetComponentStatesRequest, opts ...grpc.CallOption) (*milvuspb.ComponentStates, error) { - out := new(milvuspb.ComponentStates) - err := c.cc.Invoke(ctx, IndexNode_GetComponentStates_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *indexNodeClient) GetStatisticsChannel(ctx context.Context, in *internalpb.GetStatisticsChannelRequest, opts ...grpc.CallOption) (*milvuspb.StringResponse, error) { - out := new(milvuspb.StringResponse) - err := c.cc.Invoke(ctx, IndexNode_GetStatisticsChannel_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *indexNodeClient) CreateJob(ctx context.Context, in *CreateJobRequest, opts ...grpc.CallOption) (*commonpb.Status, error) { out := new(commonpb.Status) err := c.cc.Invoke(ctx, IndexNode_CreateJob_FullMethodName, in, out, opts...) @@ -115,24 +86,6 @@ func (c *indexNodeClient) GetJobStats(ctx context.Context, in *GetJobStatsReques return out, nil } -func (c *indexNodeClient) ShowConfigurations(ctx context.Context, in *internalpb.ShowConfigurationsRequest, opts ...grpc.CallOption) (*internalpb.ShowConfigurationsResponse, error) { - out := new(internalpb.ShowConfigurationsResponse) - err := c.cc.Invoke(ctx, IndexNode_ShowConfigurations_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *indexNodeClient) GetMetrics(ctx context.Context, in *milvuspb.GetMetricsRequest, opts ...grpc.CallOption) (*milvuspb.GetMetricsResponse, error) { - out := new(milvuspb.GetMetricsResponse) - err := c.cc.Invoke(ctx, IndexNode_GetMetrics_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *indexNodeClient) CreateJobV2(ctx context.Context, in *CreateJobV2Request, opts ...grpc.CallOption) (*commonpb.Status, error) { out := new(commonpb.Status) err := c.cc.Invoke(ctx, IndexNode_CreateJobV2_FullMethodName, in, out, opts...) @@ -164,15 +117,10 @@ func (c *indexNodeClient) DropJobsV2(ctx context.Context, in *DropJobsV2Request, // All implementations should embed UnimplementedIndexNodeServer // for forward compatibility type IndexNodeServer interface { - GetComponentStates(context.Context, *milvuspb.GetComponentStatesRequest) (*milvuspb.ComponentStates, error) - GetStatisticsChannel(context.Context, *internalpb.GetStatisticsChannelRequest) (*milvuspb.StringResponse, error) CreateJob(context.Context, *CreateJobRequest) (*commonpb.Status, error) QueryJobs(context.Context, *QueryJobsRequest) (*QueryJobsResponse, error) DropJobs(context.Context, *DropJobsRequest) (*commonpb.Status, error) GetJobStats(context.Context, *GetJobStatsRequest) (*GetJobStatsResponse, error) - ShowConfigurations(context.Context, *internalpb.ShowConfigurationsRequest) (*internalpb.ShowConfigurationsResponse, error) - // https://wiki.lfaidata.foundation/display/MIL/MEP+8+--+Add+metrics+for+proxy - GetMetrics(context.Context, *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) CreateJobV2(context.Context, *CreateJobV2Request) (*commonpb.Status, error) QueryJobsV2(context.Context, *QueryJobsV2Request) (*QueryJobsV2Response, error) DropJobsV2(context.Context, *DropJobsV2Request) (*commonpb.Status, error) @@ -182,12 +130,6 @@ type IndexNodeServer interface { type UnimplementedIndexNodeServer struct { } -func (UnimplementedIndexNodeServer) GetComponentStates(context.Context, *milvuspb.GetComponentStatesRequest) (*milvuspb.ComponentStates, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetComponentStates not implemented") -} -func (UnimplementedIndexNodeServer) GetStatisticsChannel(context.Context, *internalpb.GetStatisticsChannelRequest) (*milvuspb.StringResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetStatisticsChannel not implemented") -} func (UnimplementedIndexNodeServer) CreateJob(context.Context, *CreateJobRequest) (*commonpb.Status, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateJob not implemented") } @@ -200,12 +142,6 @@ func (UnimplementedIndexNodeServer) DropJobs(context.Context, *DropJobsRequest) func (UnimplementedIndexNodeServer) GetJobStats(context.Context, *GetJobStatsRequest) (*GetJobStatsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetJobStats not implemented") } -func (UnimplementedIndexNodeServer) ShowConfigurations(context.Context, *internalpb.ShowConfigurationsRequest) (*internalpb.ShowConfigurationsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ShowConfigurations not implemented") -} -func (UnimplementedIndexNodeServer) GetMetrics(context.Context, *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetMetrics not implemented") -} func (UnimplementedIndexNodeServer) CreateJobV2(context.Context, *CreateJobV2Request) (*commonpb.Status, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateJobV2 not implemented") } @@ -227,42 +163,6 @@ func RegisterIndexNodeServer(s grpc.ServiceRegistrar, srv IndexNodeServer) { s.RegisterService(&IndexNode_ServiceDesc, srv) } -func _IndexNode_GetComponentStates_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(milvuspb.GetComponentStatesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(IndexNodeServer).GetComponentStates(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: IndexNode_GetComponentStates_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IndexNodeServer).GetComponentStates(ctx, req.(*milvuspb.GetComponentStatesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _IndexNode_GetStatisticsChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(internalpb.GetStatisticsChannelRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(IndexNodeServer).GetStatisticsChannel(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: IndexNode_GetStatisticsChannel_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IndexNodeServer).GetStatisticsChannel(ctx, req.(*internalpb.GetStatisticsChannelRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _IndexNode_CreateJob_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(CreateJobRequest) if err := dec(in); err != nil { @@ -335,42 +235,6 @@ func _IndexNode_GetJobStats_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } -func _IndexNode_ShowConfigurations_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(internalpb.ShowConfigurationsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(IndexNodeServer).ShowConfigurations(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: IndexNode_ShowConfigurations_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IndexNodeServer).ShowConfigurations(ctx, req.(*internalpb.ShowConfigurationsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _IndexNode_GetMetrics_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(milvuspb.GetMetricsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(IndexNodeServer).GetMetrics(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: IndexNode_GetMetrics_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IndexNodeServer).GetMetrics(ctx, req.(*milvuspb.GetMetricsRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _IndexNode_CreateJobV2_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(CreateJobV2Request) if err := dec(in); err != nil { @@ -432,14 +296,6 @@ var IndexNode_ServiceDesc = grpc.ServiceDesc{ ServiceName: "milvus.proto.index.IndexNode", HandlerType: (*IndexNodeServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "GetComponentStates", - Handler: _IndexNode_GetComponentStates_Handler, - }, - { - MethodName: "GetStatisticsChannel", - Handler: _IndexNode_GetStatisticsChannel_Handler, - }, { MethodName: "CreateJob", Handler: _IndexNode_CreateJob_Handler, @@ -456,14 +312,6 @@ var IndexNode_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetJobStats", Handler: _IndexNode_GetJobStats_Handler, }, - { - MethodName: "ShowConfigurations", - Handler: _IndexNode_ShowConfigurations_Handler, - }, - { - MethodName: "GetMetrics", - Handler: _IndexNode_GetMetrics_Handler, - }, { MethodName: "CreateJobV2", Handler: _IndexNode_CreateJobV2_Handler, diff --git a/pkg/util/metricsinfo/metrics_info.go b/pkg/util/metricsinfo/metrics_info.go index a1f6099fc0..76619cdcdd 100644 --- a/pkg/util/metricsinfo/metrics_info.go +++ b/pkg/util/metricsinfo/metrics_info.go @@ -277,32 +277,12 @@ type ProxyInfos struct { QuotaMetrics *ProxyQuotaMetrics `json:"quota_metrics"` } -// IndexNodeConfiguration records the configuration of IndexNode. -type IndexNodeConfiguration struct { +// DataNodeConfiguration records the configuration of DataNode. +type DataNodeConfiguration struct { MinioBucketName string `json:"minio_bucket_name"` SimdType string `json:"simd_type"` -} -// IndexNodeInfos implements ComponentInfos -type IndexNodeInfos struct { - BaseComponentInfos - SystemConfigurations IndexNodeConfiguration `json:"system_configurations"` -} - -// IndexCoordConfiguration records the configuration of IndexCoord. -type IndexCoordConfiguration struct { - MinioBucketName string `json:"minio_bucket_name"` -} - -// IndexCoordInfos implements ComponentInfos -type IndexCoordInfos struct { - BaseComponentInfos - SystemConfigurations IndexCoordConfiguration `json:"system_configurations"` -} - -// DataNodeConfiguration records the configuration of DataNode. -type DataNodeConfiguration struct { FlushInsertBufferSize int64 `json:"flush_insert_buffer_size"` } diff --git a/pkg/util/metricsinfo/metrics_info_test.go b/pkg/util/metricsinfo/metrics_info_test.go index bfdae912ad..573b84675f 100644 --- a/pkg/util/metricsinfo/metrics_info_test.go +++ b/pkg/util/metricsinfo/metrics_info_test.go @@ -141,49 +141,6 @@ func TestQueryCoordInfos_Codec(t *testing.T) { assert.Equal(t, infos1, infos2) } -func TestIndexNodeInfos_Codec(t *testing.T) { - infos1 := IndexNodeInfos{ - BaseComponentInfos: BaseComponentInfos{ - HasError: false, - ErrorReason: "", - Name: ConstructComponentName(typeutil.IndexNodeRole, 1), - HardwareInfos: HardwareMetrics{ - IP: "193.168.1.2", - CPUCoreCount: 4, - CPUCoreUsage: 0.5, - Memory: 32 * 1024, - MemoryUsage: 4 * 1024, - Disk: 100 * 1024, - DiskUsage: 2 * 1024, - }, - SystemInfo: DeployMetrics{ - SystemVersion: "8b1ae98fa97ce1c7ba853e8b9ff1c7ce24458dc1", - DeployMode: ClusterDeployMode, - BuildVersion: "2.0.0-rc8", - BuildTime: "2021-11-24, 11:37:25", - UsedGoVersion: "go version go1.16.9 linux/amd64", - }, - CreatedTime: time.Now().String(), - UpdatedTime: time.Now().String(), - Type: typeutil.IndexNodeRole, - ID: 1, - }, - SystemConfigurations: IndexNodeConfiguration{ - MinioBucketName: "a-bucket", - - SimdType: "auto", - }, - } - s, err := MarshalComponentInfos(infos1) - assert.Equal(t, nil, err) - log.Info("TestIndexNodeInfos_Codec", - zap.String("marshaled_result", s)) - var infos2 IndexNodeInfos - err = UnmarshalComponentInfos(s, &infos2) - assert.Equal(t, nil, err) - assert.Equal(t, infos1, infos2) -} - func TestDataNodeInfos_Codec(t *testing.T) { infos1 := DataNodeInfos{ BaseComponentInfos: BaseComponentInfos{ diff --git a/pkg/util/metricsinfo/topology.go b/pkg/util/metricsinfo/topology.go index 2e68328608..786d1ebff0 100644 --- a/pkg/util/metricsinfo/topology.go +++ b/pkg/util/metricsinfo/topology.go @@ -81,23 +81,10 @@ type QueryCoordTopology struct { Connections ConnTopology `json:"connections"` } -// IndexClusterTopology shows the topology between IndexCoord and IndexNodes -type IndexClusterTopology struct { - Self IndexCoordInfos `json:"self"` - ConnectedNodes []IndexNodeInfos `json:"connected_nodes"` -} - -// IndexCoordTopology shows the whole metrics of index cluster -type IndexCoordTopology struct { - Cluster IndexClusterTopology `json:"cluster"` - Connections ConnTopology `json:"connections"` -} - // DataClusterTopology shows the topology between DataCoord and DataNodes type DataClusterTopology struct { - Self DataCoordInfos `json:"self"` - ConnectedDataNodes []DataNodeInfos `json:"connected_data_nodes"` - ConnectedIndexNodes []IndexNodeInfos `json:"connected_index_nodes"` + Self DataCoordInfos `json:"self"` + ConnectedDataNodes []DataNodeInfos `json:"connected_data_nodes"` } // DataCoordTopology shows the whole metrics of index cluster diff --git a/pkg/util/metricsinfo/topology_test.go b/pkg/util/metricsinfo/topology_test.go index fa49672e77..07133b8f6e 100644 --- a/pkg/util/metricsinfo/topology_test.go +++ b/pkg/util/metricsinfo/topology_test.go @@ -147,8 +147,6 @@ func TestDataClusterTopology_Codec(t *testing.T) { ID: 3, }, }, - }, - ConnectedIndexNodes: []IndexNodeInfos{ { BaseComponentInfos: BaseComponentInfos{ Name: ConstructComponentName(typeutil.IndexNodeRole, 4), @@ -172,13 +170,9 @@ func TestDataClusterTopology_Codec(t *testing.T) { assert.Equal(t, nil, err) assert.Equal(t, topology1.Self, topology2.Self) assert.Equal(t, len(topology1.ConnectedDataNodes), len(topology2.ConnectedDataNodes)) - assert.Equal(t, len(topology1.ConnectedIndexNodes), len(topology2.ConnectedIndexNodes)) for i := range topology1.ConnectedDataNodes { assert.Equal(t, topology1.ConnectedDataNodes[i], topology2.ConnectedDataNodes[i]) } - for i := range topology1.ConnectedIndexNodes { - assert.Equal(t, topology1.ConnectedIndexNodes[i], topology2.ConnectedIndexNodes[i]) - } } func TestDataCoordTopology_Codec(t *testing.T) { @@ -203,8 +197,6 @@ func TestDataCoordTopology_Codec(t *testing.T) { ID: 3, }, }, - }, - ConnectedIndexNodes: []IndexNodeInfos{ { BaseComponentInfos: BaseComponentInfos{ Name: ConstructComponentName(typeutil.IndexNodeRole, 4), @@ -237,13 +229,9 @@ func TestDataCoordTopology_Codec(t *testing.T) { assert.Equal(t, nil, err) assert.Equal(t, topology1.Cluster.Self, topology2.Cluster.Self) assert.Equal(t, len(topology1.Cluster.ConnectedDataNodes), len(topology2.Cluster.ConnectedDataNodes)) - assert.Equal(t, len(topology1.Cluster.ConnectedIndexNodes), len(topology2.Cluster.ConnectedIndexNodes)) for i := range topology1.Cluster.ConnectedDataNodes { assert.Equal(t, topology1.Cluster.ConnectedDataNodes[i], topology2.Cluster.ConnectedDataNodes[i]) } - for i := range topology1.Cluster.ConnectedIndexNodes { - assert.Equal(t, topology1.Cluster.ConnectedIndexNodes[i], topology2.Cluster.ConnectedIndexNodes[i]) - } assert.Equal(t, topology1.Connections.Name, topology2.Connections.Name) assert.Equal(t, len(topology1.Connections.ConnectedComponents), len(topology1.Connections.ConnectedComponents)) for i := range topology1.Connections.ConnectedComponents { diff --git a/pkg/util/paramtable/component_param.go b/pkg/util/paramtable/component_param.go index a69b0fde50..791ac1b95d 100644 --- a/pkg/util/paramtable/component_param.go +++ b/pkg/util/paramtable/component_param.go @@ -78,7 +78,6 @@ type ComponentParam struct { QueryNodeCfg queryNodeConfig DataCoordCfg dataCoordConfig DataNodeCfg dataNodeConfig - IndexNodeCfg indexNodeConfig KnowhereConfig knowhereConfig HTTPCfg httpConfig LogCfg logConfig @@ -94,7 +93,6 @@ type ComponentParam struct { QueryNodeGrpcServerCfg GrpcServerConfig DataCoordGrpcServerCfg GrpcServerConfig DataNodeGrpcServerCfg GrpcServerConfig - IndexNodeGrpcServerCfg GrpcServerConfig StreamingNodeGrpcServerCfg GrpcServerConfig RootCoordGrpcClientCfg GrpcClientConfig @@ -103,7 +101,6 @@ type ComponentParam struct { QueryNodeGrpcClientCfg GrpcClientConfig DataCoordGrpcClientCfg GrpcClientConfig DataNodeGrpcClientCfg GrpcClientConfig - IndexNodeGrpcClientCfg GrpcClientConfig StreamingCoordGrpcClientCfg GrpcClientConfig StreamingNodeGrpcClientCfg GrpcClientConfig IntegrationTestCfg integrationTestConfig @@ -134,7 +131,6 @@ func (p *ComponentParam) init(bt *BaseTable) { p.QueryNodeCfg.init(bt) p.DataCoordCfg.init(bt) p.DataNodeCfg.init(bt) - p.IndexNodeCfg.init(bt) p.StreamingCfg.init(bt) p.HTTPCfg.init(bt) p.LogCfg.init(bt) @@ -152,7 +148,6 @@ func (p *ComponentParam) init(bt *BaseTable) { p.QueryNodeGrpcServerCfg.Init("queryNode", bt) p.DataCoordGrpcServerCfg.Init("dataCoord", bt) p.DataNodeGrpcServerCfg.Init("dataNode", bt) - p.IndexNodeGrpcServerCfg.Init("indexNode", bt) p.StreamingNodeGrpcServerCfg.Init("streamingNode", bt) p.RootCoordGrpcClientCfg.Init("rootCoord", bt) @@ -161,7 +156,6 @@ func (p *ComponentParam) init(bt *BaseTable) { p.QueryNodeGrpcClientCfg.Init("queryNode", bt) p.DataCoordGrpcClientCfg.Init("dataCoord", bt) p.DataNodeGrpcClientCfg.Init("dataNode", bt) - p.IndexNodeGrpcClientCfg.Init("indexNode", bt) p.StreamingCoordGrpcClientCfg.Init("streamingCoord", bt) p.StreamingNodeGrpcClientCfg.Init("streamingNode", bt) @@ -4585,6 +4579,12 @@ type dataNodeConfig struct { BloomFilterApplyParallelFactor ParamItem `refreshable:"true"` DeltalogFormat ParamItem `refreshable:"false"` + + // index services config + BuildParallel ParamItem `refreshable:"false"` + EnableDisk ParamItem `refreshable:"false"` + DiskCapacityLimit ParamItem `refreshable:"true"` + MaxDiskUsagePercentage ParamItem `refreshable:"true"` } func (p *dataNodeConfig) init(base *BaseTable) { @@ -4977,21 +4977,7 @@ if this parameter <= 0, will set it as 10`, Export: true, } p.DeltalogFormat.Init(base.mgr) -} -// ///////////////////////////////////////////////////////////////////////////// -// --- indexnode --- -type indexNodeConfig struct { - BuildParallel ParamItem `refreshable:"false"` - // enable disk - EnableDisk ParamItem `refreshable:"false"` - DiskCapacityLimit ParamItem `refreshable:"true"` - MaxDiskUsagePercentage ParamItem `refreshable:"true"` - - GracefulStopTimeout ParamItem `refreshable:"true"` -} - -func (p *indexNodeConfig) init(base *BaseTable) { p.BuildParallel = ParamItem{ Key: "indexNode.scheduler.buildParallel", Version: "2.0.0", @@ -5005,7 +4991,7 @@ func (p *indexNodeConfig) init(base *BaseTable) { Version: "2.2.0", DefaultValue: "false", PanicIfEmpty: true, - Doc: "enable index node build disk vector index", + Doc: "enable build disk vector index", Export: true, } p.EnableDisk.Init(base.mgr) @@ -5045,14 +5031,6 @@ func (p *indexNodeConfig) init(base *BaseTable) { Export: true, } p.MaxDiskUsagePercentage.Init(base.mgr) - - p.GracefulStopTimeout = ParamItem{ - Key: "indexNode.gracefulStopTimeout", - Version: "2.2.1", - FallbackKeys: []string{"common.gracefulStopTimeout"}, - Doc: "seconds. force stop node without graceful stop", - } - p.GracefulStopTimeout.Init(base.mgr) } type streamingConfig struct { diff --git a/pkg/util/paramtable/component_param_test.go b/pkg/util/paramtable/component_param_test.go index 1134438418..40fe622bc5 100644 --- a/pkg/util/paramtable/component_param_test.go +++ b/pkg/util/paramtable/component_param_test.go @@ -63,7 +63,7 @@ func TestComponentParam(t *testing.T) { assert.Equal(t, Params.GracefulStopTimeout.GetAsInt64(), int64(DefaultGracefulStopTimeout)) assert.Equal(t, params.QueryNodeCfg.GracefulStopTimeout.GetAsInt64(), Params.GracefulStopTimeout.GetAsInt64()) - assert.Equal(t, params.IndexNodeCfg.GracefulStopTimeout.GetAsInt64(), Params.GracefulStopTimeout.GetAsInt64()) + assert.Equal(t, params.DataNodeCfg.GracefulStopTimeout.GetAsInt64(), Params.GracefulStopTimeout.GetAsInt64()) t.Logf("default grafeful stop timeout = %d", Params.GracefulStopTimeout.GetAsInt()) params.Save(Params.GracefulStopTimeout.Key, "50") assert.Equal(t, Params.GracefulStopTimeout.GetAsInt64(), int64(50)) @@ -611,15 +611,6 @@ func TestComponentParam(t *testing.T) { assert.Equal(t, 2, Params.BloomFilterApplyParallelFactor.GetAsInt()) }) - t.Run("test indexNodeConfig", func(t *testing.T) { - Params := ¶ms.IndexNodeCfg - params.Save(Params.GracefulStopTimeout.Key, "50") - assert.Equal(t, Params.GracefulStopTimeout.GetAsInt64(), int64(50)) - - params.Save("indexnode.gracefulStopTimeout", "100") - assert.Equal(t, 100*time.Second, Params.GracefulStopTimeout.GetAsDuration(time.Second)) - }) - t.Run("test streamingConfig", func(t *testing.T) { assert.Equal(t, 1*time.Minute, params.StreamingCfg.WALBalancerTriggerInterval.GetAsDurationByParse()) assert.Equal(t, 50*time.Millisecond, params.StreamingCfg.WALBalancerBackoffInitialInterval.GetAsDurationByParse()) @@ -678,8 +669,8 @@ func TestCachedParam(t *testing.T) { Init() params := Get() - assert.True(t, params.IndexNodeCfg.EnableDisk.GetAsBool()) - assert.True(t, params.IndexNodeCfg.EnableDisk.GetAsBool()) + assert.True(t, params.DataNodeCfg.EnableDisk.GetAsBool()) + assert.True(t, params.DataNodeCfg.EnableDisk.GetAsBool()) assert.Equal(t, 256*1024*1024, params.QueryCoordGrpcServerCfg.ServerMaxRecvSize.GetAsInt()) assert.Equal(t, 256*1024*1024, params.QueryCoordGrpcServerCfg.ServerMaxRecvSize.GetAsInt()) diff --git a/scripts/run_docker.sh b/scripts/run_docker.sh index 2d55c7bfb7..1c5e2aa6c0 100755 --- a/scripts/run_docker.sh +++ b/scripts/run_docker.sh @@ -22,12 +22,6 @@ nohup docker compose -p milvus up rootcoord > ~/rootcoord_docker.log 2>&1 & echo "starting proxy docker" nohup docker compose -p milvus up proxy > ~/proxy_docker.log 2>&1 & -echo "starting indexcoord docker" -nohup docker compose -p milvus up indexcoord > ~/indexcoord_docker.log 2>&1 & - -echo "starting indexnode docker" -nohup docker compose -p milvus up indexnode > ~/indexnode_docker.log 2>&1 & - echo "starting querycoord docker" nohup docker compose -p milvus up querycoord > ~/querycoord_docker.log 2>&1 & diff --git a/scripts/run_go_unittest.sh b/scripts/run_go_unittest.sh index 3aac96fa90..0a91946364 100755 --- a/scripts/run_go_unittest.sh +++ b/scripts/run_go_unittest.sh @@ -132,11 +132,6 @@ go test -race -cover -tags dynamic,test "${MILVUS_DIR}/distributed/datanode/..." } -function test_indexnode() -{ -go test -race -cover -tags dynamic,test "${MILVUS_DIR}/indexnode/..." -failfast -count=1 -ldflags="-r ${RPATH}" -} - function test_rootcoord() { go test -race -cover -tags dynamic,test "${MILVUS_DIR}/distributed/rootcoord/..." -failfast -count=1 -ldflags="-r ${RPATH}" @@ -181,7 +176,6 @@ function test_all() test_proxy test_querynode test_datanode -test_indexnode test_rootcoord test_querycoord test_datacoord @@ -209,9 +203,6 @@ case "${TEST_TAG}" in datanode) test_datanode ;; - indexnode) - test_indexnode - ;; rootcoord) test_rootcoord ;; diff --git a/scripts/start_cluster.sh b/scripts/start_cluster.sh index 8cc0eaecd1..678a9c8471 100755 --- a/scripts/start_cluster.sh +++ b/scripts/start_cluster.sh @@ -39,8 +39,5 @@ nohup ./bin/milvus run proxy --run-with-subprocess > /tmp/proxy.log 2>&1 & echo "Starting querynode..." nohup ./bin/milvus run querynode --run-with-subprocess > /tmp/querynode.log 2>&1 & -echo "Starting indexnode..." -nohup ./bin/milvus run indexnode --run-with-subprocess > /tmp/indexnode.log 2>&1 & - echo "Starting streamingnode..." nohup ./bin/milvus run streamingnode --run-with-subprocess > /tmp/streamingnode.log 2>&1 & diff --git a/tests/_helm/values/e2e/distributed b/tests/_helm/values/e2e/distributed index 2b8208009c..00b68eab32 100644 --- a/tests/_helm/values/e2e/distributed +++ b/tests/_helm/values/e2e/distributed @@ -52,6 +52,7 @@ image: repository: harbor.milvus.io/milvus/milvus tag: PR-35426-20240812-46dadb120 indexCoordinator: + enabled: false gc: interval: 1 resources: @@ -61,6 +62,7 @@ indexCoordinator: cpu: "0.1" memory: 50Mi indexNode: + enabled: false disk: enabled: true resources: diff --git a/tests/_helm/values/e2e/standalone b/tests/_helm/values/e2e/standalone index 568bc393e7..32623874af 100644 --- a/tests/_helm/values/e2e/standalone +++ b/tests/_helm/values/e2e/standalone @@ -52,6 +52,7 @@ image: repository: harbor.milvus.io/milvus/milvus tag: PR-35402-20240812-402f716b5 indexCoordinator: + enabled: false gc: interval: 1 resources: @@ -61,6 +62,7 @@ indexCoordinator: cpu: "0.1" memory: 50Mi indexNode: + enabled: false disk: enabled: true resources: diff --git a/tests/_helm/values/e2e/standalone-kafka-mmap b/tests/_helm/values/e2e/standalone-kafka-mmap index 95baee2b47..e61e8df110 100644 --- a/tests/_helm/values/e2e/standalone-kafka-mmap +++ b/tests/_helm/values/e2e/standalone-kafka-mmap @@ -52,6 +52,7 @@ image: repository: harbor.milvus.io/milvus/milvus tag: PR-35426-20240812-46dadb120 indexCoordinator: + enabled: false gc: interval: 1 resources: @@ -61,6 +62,7 @@ indexCoordinator: cpu: "0.1" memory: 50Mi indexNode: + enabled: false disk: enabled: true resources: diff --git a/tests/_helm/values/e2e/standalone-one-pod b/tests/_helm/values/e2e/standalone-one-pod index 73953f908b..235a11c92e 100644 --- a/tests/_helm/values/e2e/standalone-one-pod +++ b/tests/_helm/values/e2e/standalone-one-pod @@ -32,6 +32,7 @@ image: repository: harbor.milvus.io/milvus/milvus tag: PR-35432-20240812-71a1562ea indexCoordinator: + enabled: false gc: interval: 1 extraConfigFiles: @@ -43,6 +44,7 @@ extraConfigFiles: scheduler: buildParallel: 4 indexNode: + enabled: false disk: enabled: true metrics: diff --git a/tests/_helm/values/nightly/distributed-kafka b/tests/_helm/values/nightly/distributed-kafka index fb77ef9f67..cfcf7dd2bf 100644 --- a/tests/_helm/values/nightly/distributed-kafka +++ b/tests/_helm/values/nightly/distributed-kafka @@ -28,11 +28,13 @@ image: repository: harbor.milvus.io/milvus/milvus tag: nightly-20240821-ed4eaff indexCoordinator: + enabled: false gc: interval: 1 profiling: enabled: true indexNode: + enabled: false disk: enabled: true profiling: diff --git a/tests/_helm/values/nightly/distributed-pulsar b/tests/_helm/values/nightly/distributed-pulsar index 0775d3ff6b..e8d2202404 100644 --- a/tests/_helm/values/nightly/distributed-pulsar +++ b/tests/_helm/values/nightly/distributed-pulsar @@ -28,11 +28,13 @@ image: repository: harbor.milvus.io/milvus/milvus tag: nightly-20240821-ed4eaff indexCoordinator: + enabled: false gc: interval: 1 profiling: enabled: true indexNode: + enabled: false disk: enabled: true profiling: diff --git a/tests/_helm/values/nightly/standalone b/tests/_helm/values/nightly/standalone index 11e7f76810..f48b373ed4 100644 --- a/tests/_helm/values/nightly/standalone +++ b/tests/_helm/values/nightly/standalone @@ -27,11 +27,13 @@ image: repository: harbor.milvus.io/milvus/milvus tag: nightly-20240821-ed4eaff indexCoordinator: + enabled: false gc: interval: 1 profiling: enabled: true indexNode: + enabled: false disk: enabled: true profiling: diff --git a/tests/_helm/values/nightly/standalone-authentication b/tests/_helm/values/nightly/standalone-authentication index 68ef65f250..9a52431861 100644 --- a/tests/_helm/values/nightly/standalone-authentication +++ b/tests/_helm/values/nightly/standalone-authentication @@ -27,11 +27,13 @@ image: repository: harbor.milvus.io/milvus/milvus tag: nightly-20240821-ed4eaff indexCoordinator: + enabled: false gc: interval: 1 profiling: enabled: true indexNode: + enabled: false disk: enabled: true profiling: diff --git a/tests/_helm/values/nightly/standalone-one-pod b/tests/_helm/values/nightly/standalone-one-pod index 589c2d5f58..c8f09c10e1 100644 --- a/tests/_helm/values/nightly/standalone-one-pod +++ b/tests/_helm/values/nightly/standalone-one-pod @@ -45,11 +45,13 @@ image: repository: harbor.milvus.io/milvus/milvus tag: nightly-20240821-ed4eaff indexCoordinator: + enabled: false gc: interval: 1 profiling: enabled: true indexNode: + enabled: false disk: enabled: true profiling: diff --git a/tests/integration/crossclusterrouting/cross_cluster_routing_test.go b/tests/integration/crossclusterrouting/cross_cluster_routing_test.go index 41690f8030..553380ea4c 100644 --- a/tests/integration/crossclusterrouting/cross_cluster_routing_test.go +++ b/tests/integration/crossclusterrouting/cross_cluster_routing_test.go @@ -31,7 +31,6 @@ import ( "github.com/milvus-io/milvus/pkg/v2/proto/datapb" "github.com/milvus-io/milvus/pkg/v2/proto/proxypb" "github.com/milvus-io/milvus/pkg/v2/proto/querypb" - "github.com/milvus-io/milvus/pkg/v2/proto/workerpb" "github.com/milvus-io/milvus/pkg/v2/util/commonpbutil" "github.com/milvus-io/milvus/pkg/v2/util/merr" "github.com/milvus-io/milvus/pkg/v2/util/paramtable" @@ -139,16 +138,6 @@ func (s *CrossClusterRoutingSuite) TestCrossClusterRouting() { } return false }, waitFor, duration) - - // test indexNode - s.Eventually(func() bool { - resp, err := s.Cluster.IndexNodeClient.CreateJob(s.Cluster.GetContext(), &workerpb.CreateJobRequest{}) - s.Suite.T().Logf("resp: %s, err: %s", resp, err) - if err != nil { - return strings.Contains(err.Error(), merr.ErrServiceUnavailable.Error()) - } - return false - }, waitFor, duration) } func TestCrossClusterRoutingSuite(t *testing.T) { diff --git a/tests/integration/minicluster_v2.go b/tests/integration/minicluster_v2.go index b817572271..a9072122b0 100644 --- a/tests/integration/minicluster_v2.go +++ b/tests/integration/minicluster_v2.go @@ -42,8 +42,6 @@ import ( grpcdatacoordclient "github.com/milvus-io/milvus/internal/distributed/datacoord/client" grpcdatanode "github.com/milvus-io/milvus/internal/distributed/datanode" grpcdatanodeclient "github.com/milvus-io/milvus/internal/distributed/datanode/client" - grpcindexnode "github.com/milvus-io/milvus/internal/distributed/indexnode" - grpcindexnodeclient "github.com/milvus-io/milvus/internal/distributed/indexnode/client" grpcproxy "github.com/milvus-io/milvus/internal/distributed/proxy" grpcproxyclient "github.com/milvus-io/milvus/internal/distributed/proxy/client" grpcquerycoord "github.com/milvus-io/milvus/internal/distributed/querycoord" @@ -118,12 +116,10 @@ type MiniClusterV2 struct { ProxyClient types.ProxyClient DataNodeClient types.DataNodeClient QueryNodeClient types.QueryNodeClient - IndexNodeClient types.IndexNodeClient DataNode *grpcdatanode.Server StreamingNode *streamingnode.Server QueryNode *grpcquerynode.Server - IndexNode *grpcindexnode.Server MetaWatcher MetaWatcher ptmu sync.Mutex @@ -192,14 +188,12 @@ func StartMiniClusterV2(ctx context.Context, opts ...OptionV2) (*MiniClusterV2, params.ProxyGrpcServerCfg.IP = "localhost" params.QueryNodeGrpcServerCfg.IP = "localhost" params.DataNodeGrpcServerCfg.IP = "localhost" - params.IndexNodeGrpcServerCfg.IP = "localhost" params.StreamingNodeGrpcServerCfg.IP = "localhost" params.Save(params.RootCoordGrpcServerCfg.Port.Key, fmt.Sprint(ports[0])) params.Save(params.DataCoordGrpcServerCfg.Port.Key, fmt.Sprint(ports[1])) params.Save(params.QueryCoordGrpcServerCfg.Port.Key, fmt.Sprint(ports[2])) params.Save(params.DataNodeGrpcServerCfg.Port.Key, fmt.Sprint(ports[3])) params.Save(params.QueryNodeGrpcServerCfg.Port.Key, fmt.Sprint(ports[4])) - params.Save(params.IndexNodeGrpcServerCfg.Port.Key, fmt.Sprint(ports[5])) params.Save(params.ProxyGrpcServerCfg.Port.Key, fmt.Sprint(ports[6])) // setup clients @@ -220,7 +214,7 @@ func StartMiniClusterV2(ctx context.Context, opts ...OptionV2) (*MiniClusterV2, if err != nil { return nil, err } - cluster.DataNodeClient, err = grpcdatanodeclient.NewClient(ctx, paramtable.Get().DataNodeGrpcClientCfg.GetAddress(), 0) + cluster.DataNodeClient, err = grpcdatanodeclient.NewClient(ctx, paramtable.Get().DataNodeGrpcClientCfg.GetAddress(), 0, false) if err != nil { return nil, err } @@ -228,10 +222,6 @@ func StartMiniClusterV2(ctx context.Context, opts ...OptionV2) (*MiniClusterV2, if err != nil { return nil, err } - cluster.IndexNodeClient, err = grpcindexnodeclient.NewClient(ctx, paramtable.Get().IndexNodeGrpcClientCfg.GetAddress(), 0, false) - if err != nil { - return nil, err - } // setup servers cluster.factory = dependency.MockDefaultFactory(true, params) @@ -271,10 +261,6 @@ func StartMiniClusterV2(ctx context.Context, opts ...OptionV2) (*MiniClusterV2, if err != nil { return nil, err } - cluster.IndexNode, err = grpcindexnode.NewServer(ctx, cluster.factory) - if err != nil { - return nil, err - } return cluster, nil } @@ -355,7 +341,6 @@ func (cluster *MiniClusterV2) Start() error { runComponent(cluster.QueryCoord) runComponent(cluster.DataNode) runComponent(cluster.QueryNode) - runComponent(cluster.IndexNode) runComponent(cluster.Proxy) ctx2, cancel := context.WithTimeout(context.Background(), time.Second*120) @@ -496,9 +481,6 @@ func (cluster *MiniClusterV2) Stop() error { cluster.StopAllStreamingNodes() cluster.StopAllQueryNodes() - cluster.IndexNode.Stop() - log.Info("mini cluster indexNode stopped") - cluster.EtcdCli.KV.Delete(cluster.ctx, params.EtcdCfg.RootPath.GetValue(), clientv3.WithPrefix()) defer cluster.EtcdCli.Close() diff --git a/tests/python_client/bulk_insert/test_bulk_insert_api.py b/tests/python_client/bulk_insert/test_bulk_insert_api.py index f7541d6232..2b62d1478a 100644 --- a/tests/python_client/bulk_insert/test_bulk_insert_api.py +++ b/tests/python_client/bulk_insert/test_bulk_insert_api.py @@ -68,7 +68,7 @@ class TestcaseBaseBulkInsert(TestcaseBase): minio_ip = list(minio_ip_pod_pair.keys())[0] minio_port = "9000" self.minio_endpoint = f"{minio_ip}:{minio_port}" - self.bucket_name = ms.index_nodes[0]["infos"]["system_configurations"][ + self.bucket_name = ms.data_nodes[0]["infos"]["system_configurations"][ "minio_bucket_name" ] diff --git a/tests/python_client/bulk_insert/test_bulk_insert_bench.py b/tests/python_client/bulk_insert/test_bulk_insert_bench.py index 142a0e9f26..66e92c9068 100644 --- a/tests/python_client/bulk_insert/test_bulk_insert_bench.py +++ b/tests/python_client/bulk_insert/test_bulk_insert_bench.py @@ -215,7 +215,7 @@ class TestcaseBaseBulkInsert(TestcaseBase): ms = MilvusSys() minio_port = "9000" self.minio_endpoint = f"{minio_host}:{minio_port}" - self.bucket_name = ms.index_nodes[0]["infos"]["system_configurations"][ + self.bucket_name = ms.data_nodes[0]["infos"]["system_configurations"][ "minio_bucket_name" ] diff --git a/tests/python_client/bulk_insert/test_bulk_insert_perf.py b/tests/python_client/bulk_insert/test_bulk_insert_perf.py index f9c62d7e8b..8c18c7a140 100644 --- a/tests/python_client/bulk_insert/test_bulk_insert_perf.py +++ b/tests/python_client/bulk_insert/test_bulk_insert_perf.py @@ -104,7 +104,7 @@ class TestChaos(TestChaosBase): minio_ip = list(minio_ip_pod_pair.keys())[0] minio_port = "9000" minio_endpoint = f"{minio_ip}:{minio_port}" - bucket_name = ms.index_nodes[0]["infos"]["system_configurations"]["minio_bucket_name"] + bucket_name = ms.data_nodes[0]["infos"]["system_configurations"]["minio_bucket_name"] schema = cf.gen_bulk_insert_collection_schema(dim=dim, with_varchar_field=with_varchar_field) data = cf.gen_default_list_data_for_bulk_insert(nb=nb, varchar_len=varchar_len, with_varchar_field=with_varchar_field) diff --git a/tests/python_client/bulk_insert/test_bulk_insert_task_clean.py b/tests/python_client/bulk_insert/test_bulk_insert_task_clean.py index b6f0f35291..0012bd0195 100644 --- a/tests/python_client/bulk_insert/test_bulk_insert_task_clean.py +++ b/tests/python_client/bulk_insert/test_bulk_insert_task_clean.py @@ -65,7 +65,7 @@ class TestcaseBaseBulkInsert(TestcaseBase): minio_ip = list(minio_ip_pod_pair.keys())[0] minio_port = "9000" self.minio_endpoint = f"{minio_ip}:{minio_port}" - self.bucket_name = ms.index_nodes[0]["infos"]["system_configurations"][ + self.bucket_name = ms.data_nodes[0]["infos"]["system_configurations"][ "minio_bucket_name" ] diff --git a/tests/python_client/bulk_insert/test_bulk_insert_with_requests.py b/tests/python_client/bulk_insert/test_bulk_insert_with_requests.py index 7506b52958..1024749df3 100644 --- a/tests/python_client/bulk_insert/test_bulk_insert_with_requests.py +++ b/tests/python_client/bulk_insert/test_bulk_insert_with_requests.py @@ -109,7 +109,7 @@ class TestChaos(TestChaosBase): minio_ip = list(minio_ip_pod_pair.keys())[0] minio_port = "9000" minio_endpoint = f"{minio_ip}:{minio_port}" - bucket_name = ms.index_nodes[0]["infos"]["system_configurations"]["minio_bucket_name"] + bucket_name = ms.data_nodes[0]["infos"]["system_configurations"]["minio_bucket_name"] schema = cf.gen_default_collection_schema() data = cf.gen_default_list_data_for_bulk_insert(nb=nb) fields_name = [field.name for field in schema.fields] diff --git a/tests/python_client/chaos/checker.py b/tests/python_client/chaos/checker.py index c574f5c3fc..34b5f34851 100644 --- a/tests/python_client/chaos/checker.py +++ b/tests/python_client/chaos/checker.py @@ -340,7 +340,7 @@ class Checker: self.files = [] self.word_freq = Counter() self.ms = MilvusSys() - self.bucket_name = self.ms.index_nodes[0]["infos"]["system_configurations"]["minio_bucket_name"] + self.bucket_name = self.ms.data_nodes[0]["infos"]["system_configurations"]["minio_bucket_name"] self.db_wrap = ApiDatabaseWrapper() self.c_wrap = ApiCollectionWrapper() self.p_wrap = ApiPartitionWrapper() diff --git a/tests/python_client/chaos/test_chaos_bulk_insert.py b/tests/python_client/chaos/test_chaos_bulk_insert.py index 436957516b..50818acbb2 100644 --- a/tests/python_client/chaos/test_chaos_bulk_insert.py +++ b/tests/python_client/chaos/test_chaos_bulk_insert.py @@ -109,7 +109,7 @@ class TestChaos(TestChaosBase): minio_ip = list(minio_ip_pod_pair.keys())[0] minio_port = "9000" minio_endpoint = f"{minio_ip}:{minio_port}" - bucket_name = ms.index_nodes[0]["infos"]["system_configurations"]["minio_bucket_name"] + bucket_name = ms.data_nodes[0]["infos"]["system_configurations"]["minio_bucket_name"] schema = cf.gen_default_collection_schema() data = cf.gen_default_list_data_for_bulk_insert(nb=nb) fields_name = [field.name for field in schema.fields] diff --git a/tests/python_client/chaos/test_load_with_checker.py b/tests/python_client/chaos/test_load_with_checker.py index 724c467ba5..b2358ce732 100644 --- a/tests/python_client/chaos/test_load_with_checker.py +++ b/tests/python_client/chaos/test_load_with_checker.py @@ -82,7 +82,7 @@ class TestChaos(TestChaosBase): minio_ip = list(minio_ip_pod_pair.keys())[0] minio_port = "9000" minio_endpoint = f"{minio_ip}:{minio_port}" - bucket_name = ms.index_nodes[0]["infos"]["system_configurations"]["minio_bucket_name"] + bucket_name = ms.data_nodes[0]["infos"]["system_configurations"]["minio_bucket_name"] schema = cf.gen_default_collection_schema() data = cf.gen_default_list_data_for_bulk_insert(nb=nb) fields_name = [field.name for field in schema.fields] diff --git a/tests/python_client/chaos/testcases/test_single_request_operation.py b/tests/python_client/chaos/testcases/test_single_request_operation.py index 9041c1d640..34a286d2fc 100644 --- a/tests/python_client/chaos/testcases/test_single_request_operation.py +++ b/tests/python_client/chaos/testcases/test_single_request_operation.py @@ -66,7 +66,7 @@ class TestOperations(TestBase): self.enable_import = enable_import self.minio_endpoint = f"{minio_host}:9000" self.ms = MilvusSys() - self.bucket_name = self.ms.index_nodes[0]["infos"]["system_configurations"]["minio_bucket_name"] + self.bucket_name = self.ms.data_nodes[0]["infos"]["system_configurations"]["minio_bucket_name"] def init_health_checkers(self, collection_name=None): c_name = collection_name diff --git a/tests/python_client/common/milvus_sys.py b/tests/python_client/common/milvus_sys.py index 7fc7ec5d6a..8e73e0f053 100644 --- a/tests/python_client/common/milvus_sys.py +++ b/tests/python_client/common/milvus_sys.py @@ -83,15 +83,6 @@ class MilvusSys: data_nodes.append(node) return data_nodes - @property - def index_nodes(self): - """get all index nodes in Milvus deployment""" - index_nodes = [] - for node in self.nodes: - if 'indexnode' == node.get('infos').get('type'): - index_nodes.append(node) - return index_nodes - @property def proxy_nodes(self): """get all proxy nodes in Milvus deployment""" diff --git a/tests/python_client/testcases/test_bulk_insert.py b/tests/python_client/testcases/test_bulk_insert.py index 4024a4c1b6..fc8ed92180 100644 --- a/tests/python_client/testcases/test_bulk_insert.py +++ b/tests/python_client/testcases/test_bulk_insert.py @@ -58,7 +58,7 @@ class TestcaseBaseBulkInsert(TestcaseBase): ms = MilvusSys() minio_port = "9000" self.minio_endpoint = f"{minio_host}:{minio_port}" - self.bucket_name = ms.index_nodes[0]["infos"]["system_configurations"][ + self.bucket_name = ms.data_nodes[0]["infos"]["system_configurations"][ "minio_bucket_name" ] diff --git a/tests/scripts/values/ci/pr-4am.yaml b/tests/scripts/values/ci/pr-4am.yaml index b46b5dfb64..dc4a0d729b 100644 --- a/tests/scripts/values/ci/pr-4am.yaml +++ b/tests/scripts/values/ci/pr-4am.yaml @@ -53,6 +53,7 @@ queryNode: limits: cpu: "2" indexCoordinator: + enabled: "false" resources: requests: cpu: "0.1" @@ -60,6 +61,7 @@ indexCoordinator: limits: cpu: "1" indexNode: + enabled: "false" resources: requests: cpu: "0.5" diff --git a/tests/scripts/values/ci/pr-arm.yaml b/tests/scripts/values/ci/pr-arm.yaml index 9327ae6113..846c2e1209 100644 --- a/tests/scripts/values/ci/pr-arm.yaml +++ b/tests/scripts/values/ci/pr-arm.yaml @@ -40,6 +40,7 @@ queryNode: limits: cpu: "2" indexCoordinator: + enabled: "false" resources: requests: cpu: "0.1" @@ -47,6 +48,7 @@ indexCoordinator: limits: cpu: "1" indexNode: + enabled: "false" resources: requests: cpu: "0.5" diff --git a/tests/scripts/values/ci/pr-gpu.yaml b/tests/scripts/values/ci/pr-gpu.yaml index b677b8f1e3..1ee00453fb 100644 --- a/tests/scripts/values/ci/pr-gpu.yaml +++ b/tests/scripts/values/ci/pr-gpu.yaml @@ -34,12 +34,14 @@ queryNode: nvidia.com/gpu: 1 indexCoordinator: + enabled: "false" resources: requests: cpu: "0.1" memory: "50Mi" indexNode: + enabled: "false" nodeSelector: nvidia.com/gpu.present: 'true' extraEnv: diff --git a/tests/scripts/values/ci/pr.yaml b/tests/scripts/values/ci/pr.yaml index a93300c283..049565d0ac 100644 --- a/tests/scripts/values/ci/pr.yaml +++ b/tests/scripts/values/ci/pr.yaml @@ -47,19 +47,13 @@ queryNode: limits: cpu: "2" indexCoordinator: + enabled: "false" resources: requests: cpu: "0.1" memory: "50Mi" limits: cpu: "1" -indexNode: - resources: - requests: - cpu: "0.5" - memory: "500Mi" - limits: - cpu: "2" dataCoordinator: resources: requests: @@ -67,6 +61,14 @@ dataCoordinator: memory: "50Mi" limits: cpu: "1" +indexNode: + enabled: "false" + resources: + requests: + cpu: "0.5" + memory: "500Mi" + limits: + cpu: "2" dataNode: resources: requests: diff --git a/tests/scripts/values/pr.yaml b/tests/scripts/values/pr.yaml index 63b11050b8..d6d7e011d1 100644 --- a/tests/scripts/values/pr.yaml +++ b/tests/scripts/values/pr.yaml @@ -27,11 +27,13 @@ queryNode: cpu: "2" memory: "500Mi" indexCoordinator: + enabled: "false" resources: requests: cpu: "0.1" memory: "50Mi" indexNode: + enabled: "false" resources: requests: cpu: "4" diff --git a/tests/scripts/values/qa/pr.yaml b/tests/scripts/values/qa/pr.yaml index b075a0807b..535268d1b1 100644 --- a/tests/scripts/values/qa/pr.yaml +++ b/tests/scripts/values/qa/pr.yaml @@ -27,11 +27,13 @@ queryNode: cpu: "2" memory: "500Mi" indexCoordinator: + enabled: "false" resources: requests: cpu: "0.1" memory: "50Mi" indexNode: + enabled: "false" resources: requests: cpu: "4"