зеркало из https://github.com/github/vitess-gh.git
added skip_rebuild and v_schema to message types
keyspace existence check, and return updated vschema, handle skip_rebuild Signed-off-by: Alex Charis <alex.charis@shopify.com>
This commit is contained in:
Родитель
cb21654896
Коммит
335e880c8e
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -21,6 +21,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -80,6 +81,7 @@ func NewVtctldServer(ts *topo.Server) *VtctldServer {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// AddCellInfo is part of the vtctlservicepb.VtctldServer interface.
|
||||
func (s *VtctldServer) AddCellInfo(ctx context.Context, req *vtctldatapb.AddCellInfoRequest) (*vtctldatapb.AddCellInfoResponse, error) {
|
||||
if req.CellInfo.Root == "" {
|
||||
|
@ -128,6 +130,30 @@ func (s *VtctldServer) ApplyRoutingRules(ctx context.Context, req *vtctldatapb.A
|
|||
return resp, nil
|
||||
}
|
||||
|
||||
// ApplyVSchema is part of the vtctlservicepb.VtctldServer interface.
|
||||
func (s *VtctldServer) ApplyVSchema(ctx context.Context, req *vtctldatapb.ApplyVSchemaRequest) (*vtctldatapb.ApplyVSchemaResponse, error) {
|
||||
if _, err := s.ts.GetKeyspace(ctx, req.Keyspace); err != nil {
|
||||
if strings.Contains(err.Error(), "node doesn't exist") {
|
||||
return nil, fmt.Errorf("keyspace(%s) doesn't exist, check if the keyspace is initialized", req.Keyspace)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
if err := s.ts.SaveVSchema(ctx, req.Keyspace, req.VSchema); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !req.SkipRebuild {
|
||||
if err := s.ts.RebuildSrvVSchema(ctx, nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
updatedVS, err := s.ts.GetVSchema(ctx, req.Keyspace)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &vtctldatapb.ApplyVSchemaResponse{VSchema: updatedVS}, nil
|
||||
}
|
||||
|
||||
// ChangeTabletType is part of the vtctlservicepb.VtctldServer interface.
|
||||
func (s *VtctldServer) ChangeTabletType(ctx context.Context, req *vtctldatapb.ChangeTabletTypeRequest) (*vtctldatapb.ChangeTabletTypeResponse, error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, *topo.RemoteOperationTimeout)
|
||||
|
@ -919,15 +945,6 @@ func (s *VtctldServer) GetVSchema(ctx context.Context, req *vtctldatapb.GetVSche
|
|||
}, nil
|
||||
}
|
||||
|
||||
// ApplyVSchema is part of the vtctlservicepb.VtctldServer interface.
|
||||
func (s *VtctldServer) ApplyVSchema(ctx context.Context, req *vtctldatapb.ApplyVSchemaRequest) (*vtctldatapb.ApplyVSchemaResponse, error) {
|
||||
if err := s.ts.SaveVSchema(ctx, req.Keyspace, req.VSchema); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &vtctldatapb.ApplyVSchemaResponse{}, nil
|
||||
}
|
||||
|
||||
// GetWorkflows is part of the vtctlservicepb.VtctldServer interface.
|
||||
func (s *VtctldServer) GetWorkflows(ctx context.Context, req *vtctldatapb.GetWorkflowsRequest) (*vtctldatapb.GetWorkflowsResponse, error) {
|
||||
return s.ws.GetWorkflows(ctx, req)
|
||||
|
|
|
@ -127,6 +127,7 @@ message Workflow {
|
|||
|
||||
/* Request/response types for VtctldServer */
|
||||
|
||||
|
||||
message AddCellInfoRequest {
|
||||
string name = 1;
|
||||
topodata.CellInfo cell_info = 2;
|
||||
|
@ -158,6 +159,16 @@ message ApplyRoutingRulesRequest {
|
|||
message ApplyRoutingRulesResponse {
|
||||
}
|
||||
|
||||
message ApplyVSchemaRequest {
|
||||
string keyspace = 1;
|
||||
vschema.Keyspace v_schema = 2;
|
||||
bool skip_rebuild = 3;
|
||||
}
|
||||
|
||||
message ApplyVSchemaResponse {
|
||||
vschema.Keyspace v_schema = 1;
|
||||
}
|
||||
|
||||
message ChangeTabletTypeRequest {
|
||||
topodata.TabletAlias tablet_alias = 1;
|
||||
topodata.TabletType db_type = 2;
|
||||
|
@ -476,14 +487,6 @@ message GetVSchemaResponse {
|
|||
vschema.Keyspace v_schema = 1;
|
||||
}
|
||||
|
||||
message ApplyVSchemaRequest {
|
||||
string keyspace = 1;
|
||||
vschema.Keyspace v_schema = 2;
|
||||
}
|
||||
|
||||
message ApplyVSchemaResponse {
|
||||
}
|
||||
|
||||
message GetWorkflowsRequest {
|
||||
string keyspace = 1;
|
||||
bool active_only = 2;
|
||||
|
|
|
@ -43,6 +43,8 @@ service Vtctld {
|
|||
rpc AddCellsAlias(vtctldata.AddCellsAliasRequest) returns (vtctldata.AddCellsAliasResponse) {};
|
||||
// ApplyRoutingRules applies the VSchema routing rules.
|
||||
rpc ApplyRoutingRules(vtctldata.ApplyRoutingRulesRequest) returns (vtctldata.ApplyRoutingRulesResponse) {};
|
||||
// ApplyVSchema applies a vschema to a keyspace.
|
||||
rpc ApplyVSchema(vtctldata.ApplyVSchemaRequest) returns (vtctldata.ApplyVSchemaResponse) {};
|
||||
// ChangeTabletType changes the db type for the specified tablet, if possible.
|
||||
// This is used primarily to arrange replicas, and it will not convert a
|
||||
// primary. For that, use InitShardPrimary.
|
||||
|
@ -113,8 +115,6 @@ service Vtctld {
|
|||
rpc GetTablets(vtctldata.GetTabletsRequest) returns (vtctldata.GetTabletsResponse) {};
|
||||
// GetVSchema returns the vschema for a keyspace.
|
||||
rpc GetVSchema(vtctldata.GetVSchemaRequest) returns (vtctldata.GetVSchemaResponse) {};
|
||||
// ApplyVSchema applies a vschema to a keyspace.
|
||||
rpc ApplyVSchema(vtctldata.ApplyVSchemaRequest) returns (vtctldata.ApplyVSchemaResponse) {};
|
||||
// GetWorkflows returns a list of workflows for the given keyspace.
|
||||
rpc GetWorkflows(vtctldata.GetWorkflowsRequest) returns (vtctldata.GetWorkflowsResponse) {};
|
||||
// InitShardPrimary sets the initial primary for a shard. Will make all other
|
||||
|
|
Загрузка…
Ссылка в новой задаче