milvus/internal/querynode/impl_utils.go
Bingyi Sun 626854cf0c
Refactor QueryCoord (#18836)
Signed-off-by: sunby <bingyi.sun@zilliz.com>
Co-authored-by: yah01 <yang.cen@zilliz.com>
Co-authored-by: Wei Liu <wei.liu@zilliz.com>
Co-authored-by: Congqi Xia <congqi.xia@zilliz.com>

Signed-off-by: sunby <bingyi.sun@zilliz.com>
Co-authored-by: sunby <bingyi.sun@zilliz.com>
Co-authored-by: yah01 <yang.cen@zilliz.com>
Co-authored-by: Wei Liu <wei.liu@zilliz.com>
Co-authored-by: Congqi Xia <congqi.xia@zilliz.com>
2022-09-15 18:48:32 +08:00

59 lines
1.5 KiB
Go

package querynode
import (
"context"
"github.com/milvus-io/milvus/internal/proto/commonpb"
"github.com/milvus-io/milvus/internal/proto/querypb"
)
func (node *QueryNode) TransferLoad(ctx context.Context, req *querypb.LoadSegmentsRequest) (*commonpb.Status, error) {
if len(req.GetInfos()) == 0 {
return &commonpb.Status{}, nil
}
shard := req.GetInfos()[0].GetInsertChannel()
shardCluster, ok := node.ShardClusterService.getShardCluster(shard)
if !ok {
return &commonpb.Status{
ErrorCode: commonpb.ErrorCode_NotShardLeader,
Reason: "shard cluster not found, the leader may have changed",
}, nil
}
req.NeedTransfer = false
err := shardCluster.loadSegments(ctx, req)
if err != nil {
return &commonpb.Status{
ErrorCode: commonpb.ErrorCode_UnexpectedError,
Reason: err.Error(),
}, nil
}
return &commonpb.Status{
ErrorCode: commonpb.ErrorCode_Success,
}, nil
}
func (node *QueryNode) TransferRelease(ctx context.Context, req *querypb.ReleaseSegmentsRequest) (*commonpb.Status, error) {
shardCluster, ok := node.ShardClusterService.getShardCluster(req.GetShard())
if !ok {
return &commonpb.Status{
ErrorCode: commonpb.ErrorCode_NotShardLeader,
Reason: "shard cluster not found, the leader may have changed",
}, nil
}
req.NeedTransfer = false
err := shardCluster.releaseSegments(ctx, req)
if err != nil {
return &commonpb.Status{
ErrorCode: commonpb.ErrorCode_UnexpectedError,
Reason: err.Error(),
}, nil
}
return &commonpb.Status{
ErrorCode: commonpb.ErrorCode_Success,
}, nil
}