forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
structs.go
236 lines (193 loc) · 5.33 KB
/
structs.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
// Copyright 2012, Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package actionnode
import (
"fmt"
"github.com/youtube/vitess/go/vt/key"
myproto "github.com/youtube/vitess/go/vt/mysqlctl/proto"
"github.com/youtube/vitess/go/vt/topo"
)
/*
This file defines all the payload structures for the ActionNode objects.
The naming conventions are:
- a structure used for Args only is suffixed by 'Args'.
- a structure used for Reply only is suffixed by 'Reply'.
- a structure used for both Args and Reply is suffixed by 'Data'.
Note it's OK to rename the structures as the type name is not saved in json.
*/
// tablet action node structures
type RestartSlaveData struct {
ReplicationState *myproto.ReplicationState
WaitPosition *myproto.ReplicationPosition
TimePromoted int64 // used to verify replication - a row will be inserted with this timestamp
Parent topo.TabletAlias
Force bool
}
func (rsd *RestartSlaveData) String() string {
return fmt.Sprintf("RestartSlaveData{ReplicationState:%#v WaitPosition:%#v TimePromoted:%v Parent:%v Force:%v}", rsd.ReplicationState, rsd.WaitPosition, rsd.TimePromoted, rsd.Parent, rsd.Force)
}
type SlaveWasRestartedArgs struct {
Parent topo.TabletAlias
}
type SnapshotArgs struct {
Concurrency int
ServerMode bool
}
type SnapshotReply struct {
ParentAlias topo.TabletAlias
ManifestPath string
// these two are only used for ServerMode=true full snapshot
SlaveStartRequired bool
ReadOnly bool
}
type MultiSnapshotReply struct {
ParentAlias topo.TabletAlias
ManifestPaths []string
}
type SnapshotSourceEndArgs struct {
SlaveStartRequired bool
ReadOnly bool
}
type MultiSnapshotArgs struct {
KeyRanges []key.KeyRange
Tables []string
ExcludeTables []string
Concurrency int
SkipSlaveRestart bool
MaximumFilesize uint64
}
type MultiRestoreArgs struct {
SrcTabletAliases []topo.TabletAlias
Concurrency int
FetchConcurrency int
InsertTableConcurrency int
FetchRetryCount int
Strategy string
}
type ReserveForRestoreArgs struct {
SrcTabletAlias topo.TabletAlias
}
type RestoreArgs struct {
SrcTabletAlias topo.TabletAlias
SrcFilePath string
ParentAlias topo.TabletAlias
FetchConcurrency int
FetchRetryCount int
WasReserved bool
DontWaitForSlaveStart bool
}
// shard action node structures
type ApplySchemaShardArgs struct {
MasterTabletAlias topo.TabletAlias
Change string
Simple bool
}
type SetShardServedTypesArgs struct {
ServedTypes []topo.TabletType
}
type MigrateServedTypesArgs struct {
ServedType topo.TabletType
}
// keyspace action node structures
type ApplySchemaKeyspaceArgs struct {
Change string
Simple bool
}
type MigrateServedFromArgs struct {
ServedType topo.TabletType
}
// methods to build the shard action nodes
func ReparentShard(tabletAlias topo.TabletAlias) *ActionNode {
return (&ActionNode{
Action: SHARD_ACTION_REPARENT,
Args: &tabletAlias,
}).SetGuid()
}
func ShardExternallyReparented(tabletAlias topo.TabletAlias) *ActionNode {
return (&ActionNode{
Action: SHARD_ACTION_EXTERNALLY_REPARENTED,
Args: &tabletAlias,
}).SetGuid()
}
func RebuildShard() *ActionNode {
return (&ActionNode{
Action: SHARD_ACTION_REBUILD,
}).SetGuid()
}
func CheckShard() *ActionNode {
return (&ActionNode{
Action: SHARD_ACTION_CHECK,
}).SetGuid()
}
func ApplySchemaShard(masterTabletAlias topo.TabletAlias, change string, simple bool) *ActionNode {
return (&ActionNode{
Action: SHARD_ACTION_APPLY_SCHEMA,
Args: &ApplySchemaShardArgs{
MasterTabletAlias: masterTabletAlias,
Change: change,
Simple: simple,
},
}).SetGuid()
}
func SetShardServedTypes(servedTypes []topo.TabletType) *ActionNode {
return (&ActionNode{
Action: SHARD_ACTION_SET_SERVED_TYPES,
Args: &SetShardServedTypesArgs{
ServedTypes: servedTypes,
},
}).SetGuid()
}
func ShardMultiRestore(args *MultiRestoreArgs) *ActionNode {
return (&ActionNode{
Action: SHARD_ACTION_MULTI_RESTORE,
Args: args,
}).SetGuid()
}
func MigrateServedTypes(servedType topo.TabletType) *ActionNode {
return (&ActionNode{
Action: SHARD_ACTION_MIGRATE_SERVED_TYPES,
Args: &MigrateServedTypesArgs{
ServedType: servedType,
},
}).SetGuid()
}
func UpdateShard() *ActionNode {
return (&ActionNode{
Action: SHARD_ACTION_UPDATE_SHARD,
}).SetGuid()
}
// methods to build the keyspace action nodes
func RebuildKeyspace() *ActionNode {
return (&ActionNode{
Action: KEYSPACE_ACTION_REBUILD,
}).SetGuid()
}
func SetKeyspaceShardingInfo() *ActionNode {
return (&ActionNode{
Action: KEYSPACE_ACTION_SET_SHARDING_INFO,
}).SetGuid()
}
func ApplySchemaKeyspace(change string, simple bool) *ActionNode {
return (&ActionNode{
Action: KEYSPACE_ACTION_APPLY_SCHEMA,
Args: &ApplySchemaKeyspaceArgs{
Change: change,
Simple: simple,
},
}).SetGuid()
}
func MigrateServedFrom(servedType topo.TabletType) *ActionNode {
return (&ActionNode{
Action: KEYSPACE_ACTION_MIGRATE_SERVED_FROM,
Args: &MigrateServedFromArgs{
ServedType: servedType,
},
}).SetGuid()
}
//methods to build the serving shard action nodes
func RebuildSrvShard() *ActionNode {
return (&ActionNode{
Action: SRV_SHARD_ACTION_REBUILD,
}).SetGuid()
}