зеркало из https://github.com/github/vitess-gh.git
Now using proto.TabletType in tm RPC.
This commit is contained in:
Родитель
50a8ebb0d5
Коммит
e3fcf35b2a
|
@ -42,7 +42,7 @@ type RPCAgent interface {
|
|||
|
||||
SetReadOnly(ctx context.Context, rdonly bool) error
|
||||
|
||||
ChangeType(ctx context.Context, tabletType topo.TabletType) error
|
||||
ChangeType(ctx context.Context, tabletType pb.TabletType) error
|
||||
|
||||
Scrap(ctx context.Context) error
|
||||
|
||||
|
@ -52,7 +52,7 @@ type RPCAgent interface {
|
|||
|
||||
RefreshState(ctx context.Context)
|
||||
|
||||
RunHealthCheck(ctx context.Context, targetTabletType topo.TabletType)
|
||||
RunHealthCheck(ctx context.Context, targetTabletType pb.TabletType)
|
||||
|
||||
ReloadSchema(ctx context.Context)
|
||||
|
||||
|
@ -155,8 +155,8 @@ func (agent *ActionAgent) SetReadOnly(ctx context.Context, rdonly bool) error {
|
|||
|
||||
// ChangeType changes the tablet type
|
||||
// Should be called under RPCWrapLockAction.
|
||||
func (agent *ActionAgent) ChangeType(ctx context.Context, tabletType topo.TabletType) error {
|
||||
return topotools.ChangeType(ctx, agent.TopoServer, agent.TabletAlias, topo.TabletTypeToProto(tabletType), nil)
|
||||
func (agent *ActionAgent) ChangeType(ctx context.Context, tabletType pb.TabletType) error {
|
||||
return topotools.ChangeType(ctx, agent.TopoServer, agent.TabletAlias, tabletType, nil)
|
||||
}
|
||||
|
||||
// Scrap scraps the live running tablet
|
||||
|
@ -185,8 +185,8 @@ func (agent *ActionAgent) RefreshState(ctx context.Context) {
|
|||
|
||||
// RunHealthCheck will manually run the health check on the tablet
|
||||
// Should be called under RPCWrap.
|
||||
func (agent *ActionAgent) RunHealthCheck(ctx context.Context, targetTabletType topo.TabletType) {
|
||||
agent.runHealthCheck(topo.TabletTypeToProto(targetTabletType))
|
||||
func (agent *ActionAgent) RunHealthCheck(ctx context.Context, targetTabletType pb.TabletType) {
|
||||
agent.runHealthCheck(targetTabletType)
|
||||
}
|
||||
|
||||
// ReloadSchema will reload the schema
|
||||
|
|
|
@ -271,9 +271,9 @@ func agentRPCTestSetReadOnlyPanic(ctx context.Context, t *testing.T, client tmcl
|
|||
expectRPCWrapLockActionPanic(t, err)
|
||||
}
|
||||
|
||||
var testChangeTypeValue = topo.TYPE_REPLICA
|
||||
var testChangeTypeValue = pb.TabletType_REPLICA
|
||||
|
||||
func (fra *fakeRPCAgent) ChangeType(ctx context.Context, tabletType topo.TabletType) error {
|
||||
func (fra *fakeRPCAgent) ChangeType(ctx context.Context, tabletType pb.TabletType) error {
|
||||
if fra.panics {
|
||||
panic(fmt.Errorf("test-triggered panic"))
|
||||
}
|
||||
|
@ -394,9 +394,9 @@ func agentRPCTestRefreshStatePanic(ctx context.Context, t *testing.T, client tmc
|
|||
expectRPCWrapLockActionPanic(t, err)
|
||||
}
|
||||
|
||||
var testRunHealthCheckValue = topo.TYPE_RDONLY
|
||||
var testRunHealthCheckValue = pb.TabletType_RDONLY
|
||||
|
||||
func (fra *fakeRPCAgent) RunHealthCheck(ctx context.Context, targetTabletType topo.TabletType) {
|
||||
func (fra *fakeRPCAgent) RunHealthCheck(ctx context.Context, targetTabletType pb.TabletType) {
|
||||
if fra.panics {
|
||||
panic(fmt.Errorf("test-triggered panic"))
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ func (client *FakeTabletManagerClient) SetReadWrite(ctx context.Context, tablet
|
|||
}
|
||||
|
||||
// ChangeType is part of the tmclient.TabletManagerClient interface
|
||||
func (client *FakeTabletManagerClient) ChangeType(ctx context.Context, tablet *topo.TabletInfo, dbType topo.TabletType) error {
|
||||
func (client *FakeTabletManagerClient) ChangeType(ctx context.Context, tablet *topo.TabletInfo, dbType pb.TabletType) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ func (client *FakeTabletManagerClient) RefreshState(ctx context.Context, tablet
|
|||
}
|
||||
|
||||
// RunHealthCheck is part of the tmclient.TabletManagerClient interface
|
||||
func (client *FakeTabletManagerClient) RunHealthCheck(ctx context.Context, tablet *topo.TabletInfo, targetTabletType topo.TabletType) error {
|
||||
func (client *FakeTabletManagerClient) RunHealthCheck(ctx context.Context, tablet *topo.TabletInfo, targetTabletType pb.TabletType) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ func (client *GoRPCTabletManagerClient) SetReadWrite(ctx context.Context, tablet
|
|||
}
|
||||
|
||||
// ChangeType is part of the tmclient.TabletManagerClient interface
|
||||
func (client *GoRPCTabletManagerClient) ChangeType(ctx context.Context, tablet *topo.TabletInfo, dbType topo.TabletType) error {
|
||||
func (client *GoRPCTabletManagerClient) ChangeType(ctx context.Context, tablet *topo.TabletInfo, dbType pb.TabletType) error {
|
||||
return client.rpcCallTablet(ctx, tablet, actionnode.TabletActionChangeType, &dbType, &rpc.Unused{})
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ func (client *GoRPCTabletManagerClient) RefreshState(ctx context.Context, tablet
|
|||
}
|
||||
|
||||
// RunHealthCheck is part of the tmclient.TabletManagerClient interface
|
||||
func (client *GoRPCTabletManagerClient) RunHealthCheck(ctx context.Context, tablet *topo.TabletInfo, targetTabletType topo.TabletType) error {
|
||||
func (client *GoRPCTabletManagerClient) RunHealthCheck(ctx context.Context, tablet *topo.TabletInfo, targetTabletType pb.TabletType) error {
|
||||
return client.rpcCallTablet(ctx, tablet, actionnode.TabletActionRunHealthCheck, &targetTabletType, &rpc.Unused{})
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,9 @@ import (
|
|||
"github.com/youtube/vitess/go/vt/tabletmanager"
|
||||
"github.com/youtube/vitess/go/vt/tabletmanager/actionnode"
|
||||
"github.com/youtube/vitess/go/vt/tabletmanager/gorpcproto"
|
||||
"github.com/youtube/vitess/go/vt/topo"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
pb "github.com/youtube/vitess/go/vt/proto/topodata"
|
||||
)
|
||||
|
||||
// TabletManager is the Go RPC implementation of the RPC service
|
||||
|
@ -105,7 +106,7 @@ func (tm *TabletManager) SetReadWrite(ctx context.Context, args *rpc.Unused, rep
|
|||
}
|
||||
|
||||
// ChangeType wraps RPCAgent.ChangeType
|
||||
func (tm *TabletManager) ChangeType(ctx context.Context, args *topo.TabletType, reply *rpc.Unused) error {
|
||||
func (tm *TabletManager) ChangeType(ctx context.Context, args *pb.TabletType, reply *rpc.Unused) error {
|
||||
ctx = callinfo.RPCWrapCallInfo(ctx)
|
||||
return tm.agent.RPCWrapLockAction(ctx, actionnode.TabletActionChangeType, args, reply, true, func() error {
|
||||
return tm.agent.ChangeType(ctx, *args)
|
||||
|
@ -130,7 +131,7 @@ func (tm *TabletManager) RefreshState(ctx context.Context, args *rpc.Unused, rep
|
|||
}
|
||||
|
||||
// RunHealthCheck wraps RPCAgent.RunHealthCheck
|
||||
func (tm *TabletManager) RunHealthCheck(ctx context.Context, args *topo.TabletType, reply *rpc.Unused) error {
|
||||
func (tm *TabletManager) RunHealthCheck(ctx context.Context, args *pb.TabletType, reply *rpc.Unused) error {
|
||||
ctx = callinfo.RPCWrapCallInfo(ctx)
|
||||
return tm.agent.RPCWrap(ctx, actionnode.TabletActionRunHealthCheck, args, reply, func() error {
|
||||
tm.agent.RunHealthCheck(ctx, *args)
|
||||
|
|
|
@ -183,14 +183,14 @@ func (client *Client) SetReadWrite(ctx context.Context, tablet *topo.TabletInfo)
|
|||
}
|
||||
|
||||
// ChangeType is part of the tmclient.TabletManagerClient interface
|
||||
func (client *Client) ChangeType(ctx context.Context, tablet *topo.TabletInfo, dbType topo.TabletType) error {
|
||||
func (client *Client) ChangeType(ctx context.Context, tablet *topo.TabletInfo, dbType pbt.TabletType) error {
|
||||
cc, c, err := client.dial(ctx, tablet)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer cc.Close()
|
||||
_, err = c.ChangeType(ctx, &pb.ChangeTypeRequest{
|
||||
TabletType: topo.TabletTypeToProto(dbType),
|
||||
TabletType: dbType,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
@ -218,14 +218,14 @@ func (client *Client) RefreshState(ctx context.Context, tablet *topo.TabletInfo)
|
|||
}
|
||||
|
||||
// RunHealthCheck is part of the tmclient.TabletManagerClient interface
|
||||
func (client *Client) RunHealthCheck(ctx context.Context, tablet *topo.TabletInfo, targetTabletType topo.TabletType) error {
|
||||
func (client *Client) RunHealthCheck(ctx context.Context, tablet *topo.TabletInfo, targetTabletType pbt.TabletType) error {
|
||||
cc, c, err := client.dial(ctx, tablet)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer cc.Close()
|
||||
_, err = c.RunHealthCheck(ctx, &pb.RunHealthCheckRequest{
|
||||
TabletType: topo.TabletTypeToProto(targetTabletType),
|
||||
TabletType: targetTabletType,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
"github.com/youtube/vitess/go/vt/servenv"
|
||||
"github.com/youtube/vitess/go/vt/tabletmanager"
|
||||
"github.com/youtube/vitess/go/vt/tabletmanager/actionnode"
|
||||
"github.com/youtube/vitess/go/vt/topo"
|
||||
|
||||
pb "github.com/youtube/vitess/go/vt/proto/tabletmanagerdata"
|
||||
pbs "github.com/youtube/vitess/go/vt/proto/tabletmanagerservice"
|
||||
|
@ -115,7 +114,7 @@ func (s *server) ChangeType(ctx context.Context, request *pb.ChangeTypeRequest)
|
|||
ctx = callinfo.GRPCCallInfo(ctx)
|
||||
response := &pb.ChangeTypeResponse{}
|
||||
return response, s.agent.RPCWrapLockAction(ctx, actionnode.TabletActionChangeType, request, response, true, func() error {
|
||||
return s.agent.ChangeType(ctx, topo.ProtoToTabletType(request.TabletType))
|
||||
return s.agent.ChangeType(ctx, request.TabletType)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -140,7 +139,7 @@ func (s *server) RunHealthCheck(ctx context.Context, request *pb.RunHealthCheckR
|
|||
ctx = callinfo.GRPCCallInfo(ctx)
|
||||
response := &pb.RunHealthCheckResponse{}
|
||||
return response, s.agent.RPCWrap(ctx, actionnode.TabletActionRunHealthCheck, request, response, func() error {
|
||||
s.agent.RunHealthCheck(ctx, topo.ProtoToTabletType(request.TabletType))
|
||||
s.agent.RunHealthCheck(ctx, request.TabletType)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ type TabletManagerClient interface {
|
|||
SetReadWrite(ctx context.Context, tablet *topo.TabletInfo) error
|
||||
|
||||
// ChangeType asks the remote tablet to change its type
|
||||
ChangeType(ctx context.Context, tablet *topo.TabletInfo, dbType topo.TabletType) error
|
||||
ChangeType(ctx context.Context, tablet *topo.TabletInfo, dbType pb.TabletType) error
|
||||
|
||||
// Scrap scraps the live running tablet
|
||||
Scrap(ctx context.Context, tablet *topo.TabletInfo) error
|
||||
|
@ -69,7 +69,7 @@ type TabletManagerClient interface {
|
|||
RefreshState(ctx context.Context, tablet *topo.TabletInfo) error
|
||||
|
||||
// RunHealthCheck asks the remote tablet to run a health check cycle
|
||||
RunHealthCheck(ctx context.Context, tablet *topo.TabletInfo, targetTabletType topo.TabletType) error
|
||||
RunHealthCheck(ctx context.Context, tablet *topo.TabletInfo, targetTabletType pb.TabletType) error
|
||||
|
||||
// ReloadSchema asks the remote tablet to reload its schema
|
||||
ReloadSchema(ctx context.Context, tablet *topo.TabletInfo) error
|
||||
|
|
|
@ -915,7 +915,7 @@ func commandRunHealthCheck(ctx context.Context, wr *wrangler.Wrangler, subFlags
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return wr.TabletManagerClient().RunHealthCheck(ctx, tabletInfo, topo.ProtoToTabletType(servedType))
|
||||
return wr.TabletManagerClient().RunHealthCheck(ctx, tabletInfo, servedType)
|
||||
}
|
||||
|
||||
func commandSleep(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error {
|
||||
|
|
|
@ -216,7 +216,7 @@ func (wr *Wrangler) ChangeTypeNoRebuild(ctx context.Context, tabletAlias *pb.Tab
|
|||
return false, "", "", "", err
|
||||
}
|
||||
} else {
|
||||
if err := wr.tmc.ChangeType(ctx, ti, topo.ProtoToTabletType(tabletType)); err != nil {
|
||||
if err := wr.tmc.ChangeType(ctx, ti, tabletType); err != nil {
|
||||
return false, "", "", "", err
|
||||
}
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ func (wr *Wrangler) changeTypeInternal(ctx context.Context, tabletAlias *pb.Tabl
|
|||
rebuildRequired := ti.IsInServingGraph()
|
||||
|
||||
// change the type
|
||||
if err := wr.tmc.ChangeType(ctx, ti, topo.ProtoToTabletType(dbType)); err != nil {
|
||||
if err := wr.tmc.ChangeType(ctx, ti, dbType); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче