2020-10-28 15:38:24 +08:00
|
|
|
package master
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-11-03 14:53:36 +08:00
|
|
|
"time"
|
|
|
|
|
2020-10-28 15:38:24 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb"
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/servicepb"
|
|
|
|
)
|
|
|
|
|
2020-10-29 09:31:08 +08:00
|
|
|
const slowThreshold = 5 * time.Millisecond
|
|
|
|
|
2020-10-29 12:39:41 +08:00
|
|
|
func (s *Master) CreateCollection(ctx context.Context, in *internalpb.CreateCollectionRequest) (*commonpb.Status, error) {
|
2020-10-28 15:38:24 +08:00
|
|
|
var t task = &createCollectionTask{
|
|
|
|
req: in,
|
|
|
|
baseTask: baseTask{
|
2020-11-20 17:10:24 +08:00
|
|
|
sch: s.scheduler,
|
2020-11-21 16:31:38 +08:00
|
|
|
mt: s.metaTable,
|
2020-11-20 17:10:24 +08:00
|
|
|
cv: make(chan error),
|
2020-10-28 15:38:24 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-11-14 13:06:41 +08:00
|
|
|
response := &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
}
|
|
|
|
|
2020-11-12 11:18:23 +08:00
|
|
|
var err = s.scheduler.Enqueue(t)
|
2020-10-29 12:39:41 +08:00
|
|
|
if err != nil {
|
2020-11-14 13:06:41 +08:00
|
|
|
response.Reason = "Enqueue failed: " + err.Error()
|
|
|
|
return response, nil
|
2020-10-28 15:38:24 +08:00
|
|
|
}
|
|
|
|
|
2020-10-29 12:39:41 +08:00
|
|
|
err = t.WaitToFinish(ctx)
|
|
|
|
if err != nil {
|
2020-11-14 13:06:41 +08:00
|
|
|
response.Reason = "Create collection failed: " + err.Error()
|
|
|
|
return response, nil
|
2020-10-28 15:38:24 +08:00
|
|
|
}
|
|
|
|
|
2020-11-14 13:06:41 +08:00
|
|
|
response.ErrorCode = commonpb.ErrorCode_SUCCESS
|
|
|
|
return response, nil
|
2020-10-28 15:38:24 +08:00
|
|
|
}
|
|
|
|
|
2020-10-29 12:39:41 +08:00
|
|
|
func (s *Master) DropCollection(ctx context.Context, in *internalpb.DropCollectionRequest) (*commonpb.Status, error) {
|
|
|
|
var t task = &dropCollectionTask{
|
|
|
|
req: in,
|
|
|
|
baseTask: baseTask{
|
2020-11-20 17:10:24 +08:00
|
|
|
sch: s.scheduler,
|
2020-11-21 16:31:38 +08:00
|
|
|
mt: s.metaTable,
|
2020-11-20 17:10:24 +08:00
|
|
|
cv: make(chan error),
|
2020-10-29 12:39:41 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-11-14 13:06:41 +08:00
|
|
|
response := &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
}
|
|
|
|
|
2020-11-12 11:18:23 +08:00
|
|
|
var err = s.scheduler.Enqueue(t)
|
2020-10-29 12:39:41 +08:00
|
|
|
if err != nil {
|
2020-11-14 13:06:41 +08:00
|
|
|
response.Reason = "Enqueue failed: " + err.Error()
|
|
|
|
return response, nil
|
2020-10-29 12:39:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
err = t.WaitToFinish(ctx)
|
|
|
|
if err != nil {
|
2020-11-14 13:06:41 +08:00
|
|
|
response.Reason = "Drop collection failed: " + err.Error()
|
|
|
|
return response, nil
|
2020-10-29 12:39:41 +08:00
|
|
|
}
|
|
|
|
|
2020-11-14 13:06:41 +08:00
|
|
|
response.ErrorCode = commonpb.ErrorCode_SUCCESS
|
|
|
|
return response, nil
|
2020-10-28 15:38:24 +08:00
|
|
|
}
|
|
|
|
|
2020-10-29 12:39:41 +08:00
|
|
|
func (s *Master) HasCollection(ctx context.Context, in *internalpb.HasCollectionRequest) (*servicepb.BoolResponse, error) {
|
|
|
|
var t task = &hasCollectionTask{
|
|
|
|
req: in,
|
|
|
|
baseTask: baseTask{
|
2020-11-20 17:10:24 +08:00
|
|
|
sch: s.scheduler,
|
2020-11-21 16:31:38 +08:00
|
|
|
mt: s.metaTable,
|
2020-11-20 17:10:24 +08:00
|
|
|
cv: make(chan error),
|
2020-10-29 12:39:41 +08:00
|
|
|
},
|
|
|
|
hasCollection: false,
|
|
|
|
}
|
|
|
|
|
2020-11-13 12:46:24 +08:00
|
|
|
st := &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
}
|
|
|
|
|
|
|
|
response := &servicepb.BoolResponse{
|
|
|
|
Status: st,
|
2020-11-13 15:44:02 +08:00
|
|
|
Value: false,
|
2020-11-13 12:46:24 +08:00
|
|
|
}
|
|
|
|
|
2020-11-12 11:18:23 +08:00
|
|
|
var err = s.scheduler.Enqueue(t)
|
2020-10-29 12:39:41 +08:00
|
|
|
if err != nil {
|
2020-11-14 13:06:41 +08:00
|
|
|
st.Reason = "Enqueue failed: " + err.Error()
|
2020-11-13 12:46:24 +08:00
|
|
|
return response, nil
|
2020-10-29 12:39:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
err = t.WaitToFinish(ctx)
|
|
|
|
if err != nil {
|
2020-11-14 13:06:41 +08:00
|
|
|
st.Reason = "Has collection failed: " + err.Error()
|
2020-11-13 12:46:24 +08:00
|
|
|
return response, nil
|
2020-10-29 12:39:41 +08:00
|
|
|
}
|
|
|
|
|
2020-11-13 12:46:24 +08:00
|
|
|
st.ErrorCode = commonpb.ErrorCode_SUCCESS
|
2020-11-13 15:44:02 +08:00
|
|
|
response.Value = t.(*hasCollectionTask).hasCollection
|
2020-11-13 12:46:24 +08:00
|
|
|
return response, nil
|
2020-10-28 15:38:24 +08:00
|
|
|
}
|
|
|
|
|
2020-10-29 12:39:41 +08:00
|
|
|
func (s *Master) DescribeCollection(ctx context.Context, in *internalpb.DescribeCollectionRequest) (*servicepb.CollectionDescription, error) {
|
|
|
|
var t task = &describeCollectionTask{
|
|
|
|
req: in,
|
|
|
|
baseTask: baseTask{
|
2020-11-20 17:10:24 +08:00
|
|
|
sch: s.scheduler,
|
2020-11-21 16:31:38 +08:00
|
|
|
mt: s.metaTable,
|
2020-11-20 17:10:24 +08:00
|
|
|
cv: make(chan error),
|
2020-10-28 15:38:24 +08:00
|
|
|
},
|
2020-10-29 12:39:41 +08:00
|
|
|
description: nil,
|
|
|
|
}
|
|
|
|
|
2020-11-14 13:06:41 +08:00
|
|
|
response := &servicepb.CollectionDescription{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
},
|
|
|
|
Schema: nil,
|
|
|
|
}
|
|
|
|
|
|
|
|
t.(*describeCollectionTask).description = response
|
|
|
|
|
2020-11-12 11:18:23 +08:00
|
|
|
var err = s.scheduler.Enqueue(t)
|
2020-10-29 12:39:41 +08:00
|
|
|
if err != nil {
|
2020-11-14 13:06:41 +08:00
|
|
|
response.Status.Reason = "Enqueue failed: " + err.Error()
|
|
|
|
return response, nil
|
2020-10-29 12:39:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
err = t.WaitToFinish(ctx)
|
|
|
|
if err != nil {
|
2020-11-14 13:06:41 +08:00
|
|
|
response.Status.Reason = "Describe collection failed: " + err.Error()
|
|
|
|
return response, nil
|
2020-10-29 12:39:41 +08:00
|
|
|
}
|
|
|
|
|
2020-11-14 13:06:41 +08:00
|
|
|
response.Status.ErrorCode = commonpb.ErrorCode_SUCCESS
|
|
|
|
return response, nil
|
2020-10-28 15:38:24 +08:00
|
|
|
}
|
|
|
|
|
2020-10-29 12:39:41 +08:00
|
|
|
func (s *Master) ShowCollections(ctx context.Context, in *internalpb.ShowCollectionRequest) (*servicepb.StringListResponse, error) {
|
|
|
|
var t task = &showCollectionsTask{
|
|
|
|
req: in,
|
|
|
|
baseTask: baseTask{
|
2020-11-20 17:10:24 +08:00
|
|
|
sch: s.scheduler,
|
2020-11-21 16:31:38 +08:00
|
|
|
mt: s.metaTable,
|
2020-11-20 17:10:24 +08:00
|
|
|
cv: make(chan error),
|
2020-10-28 15:38:24 +08:00
|
|
|
},
|
2020-10-29 12:39:41 +08:00
|
|
|
stringListResponse: nil,
|
|
|
|
}
|
|
|
|
|
2020-11-14 15:37:07 +08:00
|
|
|
response := &servicepb.StringListResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
Reason: "",
|
|
|
|
},
|
|
|
|
Values: nil,
|
|
|
|
}
|
|
|
|
|
|
|
|
t.(*showCollectionsTask).stringListResponse = response
|
|
|
|
|
2020-11-12 11:18:23 +08:00
|
|
|
var err = s.scheduler.Enqueue(t)
|
2020-10-29 12:39:41 +08:00
|
|
|
if err != nil {
|
2020-11-14 15:37:07 +08:00
|
|
|
response.Status.Reason = "Enqueue filed: " + err.Error()
|
|
|
|
return response, nil
|
2020-10-29 12:39:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
err = t.WaitToFinish(ctx)
|
|
|
|
if err != nil {
|
2020-11-14 15:37:07 +08:00
|
|
|
response.Status.Reason = "Show Collections failed: " + err.Error()
|
|
|
|
return response, nil
|
2020-10-29 12:39:41 +08:00
|
|
|
}
|
|
|
|
|
2020-11-14 15:37:07 +08:00
|
|
|
response.Status.ErrorCode = commonpb.ErrorCode_SUCCESS
|
|
|
|
return response, nil
|
2020-10-28 15:38:24 +08:00
|
|
|
}
|
|
|
|
|
2020-10-29 12:39:41 +08:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
func (s *Master) CreatePartition(ctx context.Context, in *internalpb.CreatePartitionRequest) (*commonpb.Status, error) {
|
|
|
|
var t task = &createPartitionTask{
|
|
|
|
req: in,
|
|
|
|
baseTask: baseTask{
|
2020-11-20 17:10:24 +08:00
|
|
|
sch: s.scheduler,
|
2020-11-21 16:31:38 +08:00
|
|
|
mt: s.metaTable,
|
2020-11-20 17:10:24 +08:00
|
|
|
cv: make(chan error),
|
2020-10-29 12:39:41 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-11-12 11:18:23 +08:00
|
|
|
var err = s.scheduler.Enqueue(t)
|
2020-10-29 12:39:41 +08:00
|
|
|
if err != nil {
|
|
|
|
return &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
Reason: "Enqueue failed",
|
2020-11-13 17:20:13 +08:00
|
|
|
}, nil
|
2020-10-29 12:39:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
err = t.WaitToFinish(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
Reason: "WaitToFinish failed",
|
2020-11-13 17:20:13 +08:00
|
|
|
}, nil
|
2020-10-29 12:39:41 +08:00
|
|
|
}
|
|
|
|
|
2020-10-28 15:38:24 +08:00
|
|
|
return &commonpb.Status{
|
2020-10-29 12:39:41 +08:00
|
|
|
ErrorCode: commonpb.ErrorCode_SUCCESS,
|
2020-10-28 15:38:24 +08:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2020-10-29 12:39:41 +08:00
|
|
|
func (s *Master) DropPartition(ctx context.Context, in *internalpb.DropPartitionRequest) (*commonpb.Status, error) {
|
|
|
|
var t task = &dropPartitionTask{
|
|
|
|
req: in,
|
|
|
|
baseTask: baseTask{
|
2020-11-20 17:10:24 +08:00
|
|
|
sch: s.scheduler,
|
2020-11-21 16:31:38 +08:00
|
|
|
mt: s.metaTable,
|
2020-11-20 17:10:24 +08:00
|
|
|
cv: make(chan error),
|
2020-10-29 12:39:41 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-11-12 11:18:23 +08:00
|
|
|
var err = s.scheduler.Enqueue(t)
|
2020-10-29 12:39:41 +08:00
|
|
|
if err != nil {
|
|
|
|
return &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
Reason: "Enqueue failed",
|
2020-11-13 17:20:13 +08:00
|
|
|
}, nil
|
2020-10-29 12:39:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
err = t.WaitToFinish(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
Reason: "WaitToFinish failed",
|
2020-11-13 17:20:13 +08:00
|
|
|
}, nil
|
2020-10-29 12:39:41 +08:00
|
|
|
}
|
|
|
|
|
2020-10-28 15:38:24 +08:00
|
|
|
return &commonpb.Status{
|
2020-10-29 12:39:41 +08:00
|
|
|
ErrorCode: commonpb.ErrorCode_SUCCESS,
|
2020-10-28 15:38:24 +08:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2020-10-29 12:39:41 +08:00
|
|
|
func (s *Master) HasPartition(ctx context.Context, in *internalpb.HasPartitionRequest) (*servicepb.BoolResponse, error) {
|
|
|
|
var t task = &hasPartitionTask{
|
|
|
|
req: in,
|
|
|
|
baseTask: baseTask{
|
2020-11-20 17:10:24 +08:00
|
|
|
sch: s.scheduler,
|
2020-11-21 16:31:38 +08:00
|
|
|
mt: s.metaTable,
|
2020-11-20 17:10:24 +08:00
|
|
|
cv: make(chan error),
|
2020-10-29 12:39:41 +08:00
|
|
|
},
|
|
|
|
hasPartition: false,
|
|
|
|
}
|
|
|
|
|
2020-11-12 11:18:23 +08:00
|
|
|
var err = s.scheduler.Enqueue(t)
|
2020-10-29 12:39:41 +08:00
|
|
|
if err != nil {
|
|
|
|
return &servicepb.BoolResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
Reason: "Enqueue failed",
|
|
|
|
},
|
|
|
|
Value: t.(*hasPartitionTask).hasPartition,
|
2020-11-13 17:20:13 +08:00
|
|
|
}, nil
|
2020-10-29 12:39:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
err = t.WaitToFinish(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return &servicepb.BoolResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
2020-12-03 19:00:11 +08:00
|
|
|
Reason: err.Error(),
|
2020-10-29 12:39:41 +08:00
|
|
|
},
|
|
|
|
Value: t.(*hasPartitionTask).hasPartition,
|
2020-11-13 17:20:13 +08:00
|
|
|
}, nil
|
2020-10-29 12:39:41 +08:00
|
|
|
}
|
|
|
|
|
2020-10-28 15:38:24 +08:00
|
|
|
return &servicepb.BoolResponse{
|
|
|
|
Status: &commonpb.Status{
|
2020-10-29 12:39:41 +08:00
|
|
|
ErrorCode: commonpb.ErrorCode_SUCCESS,
|
2020-10-28 15:38:24 +08:00
|
|
|
},
|
2020-10-29 12:39:41 +08:00
|
|
|
Value: t.(*hasPartitionTask).hasPartition,
|
2020-10-28 15:38:24 +08:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2020-10-29 12:39:41 +08:00
|
|
|
func (s *Master) DescribePartition(ctx context.Context, in *internalpb.DescribePartitionRequest) (*servicepb.PartitionDescription, error) {
|
|
|
|
var t task = &describePartitionTask{
|
|
|
|
req: in,
|
|
|
|
baseTask: baseTask{
|
2020-11-20 17:10:24 +08:00
|
|
|
sch: s.scheduler,
|
2020-11-21 16:31:38 +08:00
|
|
|
mt: s.metaTable,
|
2020-11-20 17:10:24 +08:00
|
|
|
cv: make(chan error),
|
2020-10-28 15:38:24 +08:00
|
|
|
},
|
2020-10-29 12:39:41 +08:00
|
|
|
description: nil,
|
|
|
|
}
|
|
|
|
|
2020-11-12 11:18:23 +08:00
|
|
|
var err = s.scheduler.Enqueue(t)
|
2020-10-29 12:39:41 +08:00
|
|
|
if err != nil {
|
2020-11-13 17:20:13 +08:00
|
|
|
return &servicepb.PartitionDescription{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
Reason: "Enqueue failed",
|
|
|
|
},
|
|
|
|
Name: in.PartitionName,
|
|
|
|
Statistics: nil,
|
|
|
|
}, nil
|
2020-10-29 12:39:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
err = t.WaitToFinish(ctx)
|
|
|
|
if err != nil {
|
2020-11-13 17:20:13 +08:00
|
|
|
return &servicepb.PartitionDescription{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
Reason: "WaitToFinish failed",
|
|
|
|
},
|
|
|
|
Name: in.PartitionName,
|
|
|
|
Statistics: nil,
|
|
|
|
}, nil
|
2020-10-29 12:39:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return t.(*describePartitionTask).description, nil
|
2020-10-28 15:38:24 +08:00
|
|
|
}
|
|
|
|
|
2020-10-29 12:39:41 +08:00
|
|
|
func (s *Master) ShowPartitions(ctx context.Context, in *internalpb.ShowPartitionRequest) (*servicepb.StringListResponse, error) {
|
|
|
|
var t task = &showPartitionTask{
|
|
|
|
req: in,
|
|
|
|
baseTask: baseTask{
|
2020-11-20 17:10:24 +08:00
|
|
|
sch: s.scheduler,
|
2020-11-21 16:31:38 +08:00
|
|
|
mt: s.metaTable,
|
2020-11-20 17:10:24 +08:00
|
|
|
cv: make(chan error),
|
2020-10-28 15:38:24 +08:00
|
|
|
},
|
2020-10-29 12:39:41 +08:00
|
|
|
stringListResponse: nil,
|
|
|
|
}
|
|
|
|
|
2020-11-12 11:18:23 +08:00
|
|
|
var err = s.scheduler.Enqueue(t)
|
2020-10-29 12:39:41 +08:00
|
|
|
if err != nil {
|
2020-11-14 13:06:41 +08:00
|
|
|
return &servicepb.StringListResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
Reason: "Enqueue failed",
|
|
|
|
},
|
|
|
|
Values: nil,
|
|
|
|
}, nil
|
2020-10-29 12:39:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
err = t.WaitToFinish(ctx)
|
|
|
|
if err != nil {
|
2020-11-14 13:06:41 +08:00
|
|
|
return &servicepb.StringListResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
Reason: "WaitToFinish failed",
|
|
|
|
},
|
|
|
|
Values: nil,
|
|
|
|
}, nil
|
2020-10-29 12:39:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return t.(*showPartitionTask).stringListResponse, nil
|
2020-10-28 15:38:24 +08:00
|
|
|
}
|
2020-10-29 09:31:08 +08:00
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
func (s *Master) GetSysConfigs(ctx context.Context, in *internalpb.SysConfigRequest) (*servicepb.SysConfigResponse, error) {
|
|
|
|
var t task = &getSysConfigsTask{
|
|
|
|
req: in,
|
|
|
|
configkv: s.kvBase,
|
|
|
|
baseTask: baseTask{
|
|
|
|
sch: s.scheduler,
|
|
|
|
mt: s.metaTable,
|
|
|
|
cv: make(chan error),
|
|
|
|
},
|
|
|
|
keys: []string{},
|
|
|
|
values: []string{},
|
|
|
|
}
|
|
|
|
|
|
|
|
response := &servicepb.SysConfigResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
var err = s.scheduler.Enqueue(t)
|
|
|
|
if err != nil {
|
|
|
|
response.Status.Reason = "Enqueue failed: " + err.Error()
|
|
|
|
return response, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
err = t.WaitToFinish(ctx)
|
|
|
|
if err != nil {
|
|
|
|
response.Status.Reason = "Get System Config failed: " + err.Error()
|
|
|
|
return response, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
response.Keys = t.(*getSysConfigsTask).keys
|
|
|
|
response.Values = t.(*getSysConfigsTask).values
|
|
|
|
response.Status.ErrorCode = commonpb.ErrorCode_SUCCESS
|
|
|
|
return response, nil
|
|
|
|
}
|
|
|
|
|
2020-10-29 09:31:08 +08:00
|
|
|
//----------------------------------------Internal GRPC Service--------------------------------
|
|
|
|
|
2020-11-03 14:53:36 +08:00
|
|
|
func (s *Master) AllocTimestamp(ctx context.Context, request *internalpb.TsoRequest) (*internalpb.TsoResponse, error) {
|
|
|
|
count := request.GetCount()
|
2020-11-20 17:10:24 +08:00
|
|
|
ts, err := s.tsoAllocator.Alloc(count)
|
2020-11-03 14:53:36 +08:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return &internalpb.TsoResponse{
|
|
|
|
Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR},
|
2020-11-14 14:39:52 +08:00
|
|
|
}, nil
|
2020-11-03 14:53:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
response := &internalpb.TsoResponse{
|
2020-11-14 15:26:14 +08:00
|
|
|
Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_SUCCESS},
|
2020-11-03 14:53:36 +08:00
|
|
|
Timestamp: ts,
|
|
|
|
Count: count,
|
|
|
|
}
|
|
|
|
|
|
|
|
return response, nil
|
|
|
|
}
|
|
|
|
|
2020-11-13 15:17:18 +08:00
|
|
|
func (s *Master) AllocID(ctx context.Context, request *internalpb.IDRequest) (*internalpb.IDResponse, error) {
|
2020-11-03 14:53:36 +08:00
|
|
|
count := request.GetCount()
|
2020-11-20 17:10:24 +08:00
|
|
|
ts, err := s.idAllocator.AllocOne()
|
2020-11-03 14:53:36 +08:00
|
|
|
|
|
|
|
if err != nil {
|
2020-11-13 15:17:18 +08:00
|
|
|
return &internalpb.IDResponse{
|
2020-11-03 14:53:36 +08:00
|
|
|
Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR},
|
2020-11-14 14:39:52 +08:00
|
|
|
}, nil
|
2020-11-03 14:53:36 +08:00
|
|
|
}
|
|
|
|
|
2020-11-13 15:17:18 +08:00
|
|
|
response := &internalpb.IDResponse{
|
2020-11-14 15:26:14 +08:00
|
|
|
Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_SUCCESS},
|
2020-11-13 15:17:18 +08:00
|
|
|
ID: ts,
|
2020-11-03 14:53:36 +08:00
|
|
|
Count: count,
|
|
|
|
}
|
|
|
|
|
|
|
|
return response, nil
|
|
|
|
}
|
2020-11-18 19:46:18 +08:00
|
|
|
|
|
|
|
func (s *Master) AssignSegmentID(ctx context.Context, request *internalpb.AssignSegIDRequest) (*internalpb.AssignSegIDResponse, error) {
|
2020-12-24 10:11:34 +08:00
|
|
|
segInfos, _ := s.segmentManager.AssignSegment(request.GetPerChannelReq())
|
2020-11-18 19:46:18 +08:00
|
|
|
return &internalpb.AssignSegIDResponse{
|
|
|
|
PerChannelAssignment: segInfos,
|
|
|
|
}, nil
|
|
|
|
}
|
2020-12-21 19:28:54 +08:00
|
|
|
|
2020-12-24 15:38:29 +08:00
|
|
|
func (s *Master) CreateIndex(ctx context.Context, req *internalpb.CreateIndexRequest) (*commonpb.Status, error) {
|
|
|
|
task := &createIndexTask{
|
|
|
|
baseTask: baseTask{
|
|
|
|
sch: s.scheduler,
|
|
|
|
mt: s.metaTable,
|
|
|
|
cv: make(chan error),
|
|
|
|
},
|
|
|
|
req: req,
|
|
|
|
indexBuildScheduler: s.indexBuildSch,
|
|
|
|
indexLoadScheduler: s.indexLoadSch,
|
|
|
|
segManager: s.segmentManager,
|
|
|
|
}
|
|
|
|
|
|
|
|
err := s.scheduler.Enqueue(task)
|
|
|
|
if err != nil {
|
|
|
|
return &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
Reason: "Enqueue failed: " + err.Error(),
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
err = task.WaitToFinish(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
Reason: "Create Index error: " + err.Error(),
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_SUCCESS,
|
|
|
|
Reason: "",
|
|
|
|
}, nil
|
2020-12-21 19:28:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Master) DescribeIndex(context.Context, *internalpb.DescribeIndexRequest) (*servicepb.DescribeIndexResponse, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Master) DescribeIndexProgress(context.Context, *internalpb.DescribeIndexProgressRequest) (*servicepb.BoolResponse, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|