forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpc_agent.go
128 lines (76 loc) · 4.35 KB
/
rpc_agent.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
Copyright 2017 Google Inc.
Licensed 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 tabletmanager
import (
"time"
"golang.org/x/net/context"
"vitess.io/vitess/go/vt/hook"
"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/mysqlctl/tmutils"
querypb "vitess.io/vitess/go/vt/proto/query"
replicationdatapb "vitess.io/vitess/go/vt/proto/replicationdata"
tabletmanagerdatapb "vitess.io/vitess/go/vt/proto/tabletmanagerdata"
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
)
// RPCAgent defines the interface implemented by the Agent for RPCs.
// It is useful for RPC implementations to test their full stack.
type RPCAgent interface {
// RPC calls
// Various read-only methods
Ping(ctx context.Context, args string) string
GetSchema(ctx context.Context, tables, excludeTables []string, includeViews bool) (*tabletmanagerdatapb.SchemaDefinition, error)
GetPermissions(ctx context.Context) (*tabletmanagerdatapb.Permissions, error)
// Various read-write methods
SetReadOnly(ctx context.Context, rdonly bool) error
ChangeType(ctx context.Context, tabletType topodatapb.TabletType) error
Sleep(ctx context.Context, duration time.Duration)
ExecuteHook(ctx context.Context, hk *hook.Hook) *hook.HookResult
RefreshState(ctx context.Context) error
RunHealthCheck(ctx context.Context)
IgnoreHealthError(ctx context.Context, pattern string) error
ReloadSchema(ctx context.Context, waitPosition string) error
PreflightSchema(ctx context.Context, changes []string) ([]*tabletmanagerdatapb.SchemaChangeResult, error)
ApplySchema(ctx context.Context, change *tmutils.SchemaChange) (*tabletmanagerdatapb.SchemaChangeResult, error)
ExecuteFetchAsDba(ctx context.Context, query []byte, dbName string, maxrows int, disableBinlogs bool, reloadSchema bool) (*querypb.QueryResult, error)
ExecuteFetchAsAllPrivs(ctx context.Context, query []byte, dbName string, maxrows int, reloadSchema bool) (*querypb.QueryResult, error)
ExecuteFetchAsApp(ctx context.Context, query []byte, maxrows int) (*querypb.QueryResult, error)
// Replication related methods
SlaveStatus(ctx context.Context) (*replicationdatapb.Status, error)
MasterPosition(ctx context.Context) (string, error)
StopSlave(ctx context.Context) error
StopSlaveMinimum(ctx context.Context, position string, waitTime time.Duration) (string, error)
StartSlave(ctx context.Context) error
TabletExternallyReparented(ctx context.Context, externalID string) error
GetSlaves(ctx context.Context) ([]string, error)
// VReplication API
VReplicationExec(ctx context.Context, query string) (*querypb.QueryResult, error)
VReplicationWaitForPos(ctx context.Context, id int, pos string) error
// Reparenting related functions
ResetReplication(ctx context.Context) error
InitMaster(ctx context.Context) (string, error)
PopulateReparentJournal(ctx context.Context, timeCreatedNS int64, actionName string, masterAlias *topodatapb.TabletAlias, pos string) error
InitSlave(ctx context.Context, parent *topodatapb.TabletAlias, replicationPosition string, timeCreatedNS int64) error
DemoteMaster(ctx context.Context) (string, error)
PromoteSlaveWhenCaughtUp(ctx context.Context, replicationPosition string) (string, error)
SlaveWasPromoted(ctx context.Context) error
SetMaster(ctx context.Context, parent *topodatapb.TabletAlias, timeCreatedNS int64, forceStartSlave bool) error
SlaveWasRestarted(ctx context.Context, parent *topodatapb.TabletAlias) error
StopReplicationAndGetStatus(ctx context.Context) (*replicationdatapb.Status, error)
PromoteSlave(ctx context.Context) (string, error)
// Backup / restore related methods
Backup(ctx context.Context, concurrency int, logger logutil.Logger) error
RestoreFromBackup(ctx context.Context, logger logutil.Logger) error
// HandleRPCPanic is to be called in a defer statement in each
// RPC input point.
HandleRPCPanic(ctx context.Context, name string, args, reply interface{}, verbose bool, err *error)
}