forked from pingcap/dm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdmmaster.proto
461 lines (385 loc) · 11.8 KB
/
dmmaster.proto
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
syntax = "proto3";
package pb;
import "dmworker.proto"; // refine if needed
import "google/api/annotations.proto";
service Master {
rpc StartTask (StartTaskRequest) returns (StartTaskResponse) {
option (google.api.http) = {
post: "/apis/v1alpha1/tasks"
body: "*"
};
}
rpc OperateTask (OperateTaskRequest) returns (OperateTaskResponse) {
option (google.api.http) = {
put: "/apis/v1alpha1/tasks/{name}"
body: "*"
};
}
rpc UpdateTask (UpdateTaskRequest) returns (UpdateTaskResponse) {}
rpc QueryStatus (QueryStatusListRequest) returns (QueryStatusListResponse) {
option (google.api.http) = {
get: "/apis/v1alpha1/status/{name}"
};
}
// show un-resolved DDL locks
rpc ShowDDLLocks (ShowDDLLocksRequest) returns (ShowDDLLocksResponse) {}
// used by dmctl to manually unlock DDL lock
rpc UnlockDDLLock (UnlockDDLLockRequest) returns (UnlockDDLLockResponse) {}
// OperateWorkerRelayTask requests some dm-workers to operate relay unit
rpc OperateWorkerRelayTask (OperateWorkerRelayRequest) returns (OperateWorkerRelayResponse) {}
// PurgeWorkerRelay purges relay log files for some dm-workers
rpc PurgeWorkerRelay(PurgeWorkerRelayRequest) returns (PurgeWorkerRelayResponse) {}
// CheckTask checks legality of task configuration
rpc CheckTask(CheckTaskRequest) returns (CheckTaskResponse) {}
// Operate an upstream MySQL source.
rpc OperateSource(OperateSourceRequest) returns (OperateSourceResponse) {
option (google.api.http) = {
put: "/apis/v1alpha1/sources"
body: "*"
};
}
// RegisterWorker register the dm-workers.
rpc RegisterWorker(RegisterWorkerRequest) returns(RegisterWorkerResponse) {}
// OfflineMember offline the dm cluster's members (master/worker).
rpc OfflineMember(OfflineMemberRequest) returns(OfflineMemberResponse) {
option (google.api.http) = {
delete: "/apis/v1alpha1/members/{type}/{name}"
};
}
// OperateLeader do some operate on master:
// - evict leader: make the master resign if it is leader, and will not campaign the leader again
// - cancel evict leader: the master can campaign leader again.
rpc OperateLeader(OperateLeaderRequest) returns(OperateLeaderResponse) {
option (google.api.http) = {
put: "/apis/v1alpha1/leader/{op}"
body: "*"
};
}
// ListMember list member information
rpc ListMember(ListMemberRequest) returns(ListMemberResponse) {
option (google.api.http) = {
get: "/apis/v1alpha1/members"
};
}
rpc OperateSchema(OperateSchemaRequest) returns(OperateSchemaResponse) {
option (google.api.http) = {
put: "/apis/v1alpha1/schema"
body: "*"
};
}
rpc GetSubTaskCfg(GetSubTaskCfgRequest) returns(GetSubTaskCfgResponse) {
option (google.api.http) = {
get: "/apis/v1alpha1/subtasks/{name}"
};
}
// GetCfg get config
rpc GetCfg(GetCfgRequest) returns(GetCfgResponse) {
option (google.api.http) = {
get: "/apis/v1alpha1/tasks/{name}"
};
}
rpc HandleError(HandleErrorRequest) returns(HandleErrorResponse) {
option (google.api.http) = {
put: "/apis/v1alpha1/errors"
body: "*"
};
}
rpc GetMasterCfg(GetMasterCfgRequest) returns(GetMasterCfgResponse) {}
rpc TransferSource(TransferSourceRequest) returns(TransferSourceResponse) {}
rpc OperateRelay(OperateRelayRequest) returns(OperateRelayResponse) {}
}
message StartTaskRequest {
string task = 1; // task's configuration, yaml format
repeated string sources = 2; // mysql source need to do start task, empty for all sources defiend in the task config
bool removeMeta = 3; // whether to remove meta data for this task or not
}
message StartTaskResponse {
bool result = 1;
string msg = 2;
repeated CommonWorkerResponse sources = 3;
}
message OperateTaskRequest {
TaskOp op = 1; // Stop / Pause / Resume
string name = 2; // task's name
repeated string sources = 3; // sources need to do operation, empty for matched sources in processing the task
}
message OperateTaskResponse {
TaskOp op = 1;
bool result = 2;
string msg = 3;
repeated CommonWorkerResponse sources = 4;
}
// UpdateTaskRequest used to update task after it has beed started
// task: task's configuration, yaml format
// now, only support to update config for routes, filters, column-mappings, block-allow-list
// support update partial config for syncer, loader, etc later
// sources need to do update, empty for all sources in processing the task
message UpdateTaskRequest {
string task = 1;
repeated string sources = 2;
}
message UpdateTaskResponse {
bool result = 1;
string msg = 2;
repeated CommonWorkerResponse sources = 3;
}
message QueryStatusListRequest {
string name = 1; // task's name, empty for all tasks
repeated string sources = 2; // sources need to query, empty for all sources
}
message QueryStatusListResponse {
bool result = 1;
string msg = 2;
repeated QueryStatusResponse sources = 3;
}
// ShowDDLLocksRequest used to query DDL locks which are un-resolved
// task: task's name, empty for all tasks
// sources: source need to query, empty for all sources
// any DDL lock in which the source is synced or unsynced will return
// if specify task and sources both, and sources not doing the task , it will return empty DDL locks
message ShowDDLLocksRequest {
string task = 1;
repeated string sources = 2; // sources need to query, empty for all sources
}
// DDLLock represents a DDL lock info (I known the name confused with DDLLockInfo, any suggestion?)
// it been sent from dm-master to dmctl
// ID: DDL lock generated ID
// task: lock's corresponding task name
// mode: the shard DDL mode, `pessimistic` or `optimistic`.
// owner: lock's owner, a dm-worker
// DDL: DDL statement
// synced: already synced dm-workers
// unsynced: pending to sync dm-workers
message DDLLock {
string ID = 1;
string task = 2;
string mode = 3;
string owner = 4;
repeated string DDLs = 5;
repeated string synced = 6;
repeated string unsynced = 7;
}
message ShowDDLLocksResponse {
bool result = 1;
string msg = 2;
repeated DDLLock locks = 3; // all un-resolved DDL locks
}
// UnlockDDLLockRequest used to unlock (resolve) DDL lock manually
// ID: DDL lock ID
// replaceOwner: dm-worker used to replace the original DDL lock's owner
// forceRemove: force to remove the DDL lock even fail to execute the DDL for the owner.
message UnlockDDLLockRequest {
string ID = 1;
string replaceOwner = 2;
bool forceRemove = 3;
}
message UnlockDDLLockResponse {
bool result = 1;
string msg = 2;
}
// OperateWorkerRelayRequest represents a request for some dm-workers to operate relay unit
message OperateWorkerRelayRequest {
RelayOp op = 1; // Stop / Pause / Resume
repeated string sources = 2;
}
message OperateWorkerRelayResponse {
RelayOp op = 1;
bool result = 2;
string msg = 3;
repeated CommonWorkerResponse sources = 4;
}
// PurgeWorkerRelayRequest represents a request to purge relay log files for some dm-workers
// workers: dm-workers need to purge relay log files
// inactive: whether purge inactive relay log files
// time: whether purge relay log files before this time, the number of seconds elapsed since January 1, 1970 UTC
// filename: whether purge relay log files before this filename
// subDir: specify relay sub directory for @filename
message PurgeWorkerRelayRequest {
repeated string sources = 1;
bool inactive = 2;
int64 time = 3;
string filename = 4;
string subDir = 5;
}
message PurgeWorkerRelayResponse {
bool result = 1;
string msg = 2;
repeated CommonWorkerResponse sources = 3;
}
message CheckTaskRequest {
string task = 1; // task's configuration, yaml format
int64 errCnt = 2; // max error count to display
int64 warnCnt = 3; // max warn count to display
}
message CheckTaskResponse {
bool result = 1;
string msg = 2;
}
enum SourceOp {
InvalidSourceOp = 0;
StartSource = 1;
UpdateSource = 2;
StopSource = 3;
ShowSource = 4;
}
message OperateSourceRequest {
SourceOp op = 1;
repeated string config = 2;
repeated string sourceID = 3;
}
message OperateSourceResponse {
bool result = 1;
string msg = 2;
repeated CommonWorkerResponse sources = 3;
}
message RegisterWorkerRequest {
string name = 1;
string address = 2;
}
message RegisterWorkerResponse {
bool result = 1;
string msg = 2;
}
message OfflineMemberRequest {
string type = 1;
string name = 2;
}
message OfflineMemberResponse {
bool result = 1;
string msg = 2;
}
enum LeaderOp {
InvalidLeaderOp = 0;
EvictLeaderOp = 1;
CancelEvictLeaderOp = 2;
}
message OperateLeaderRequest {
LeaderOp op = 1;
}
message OperateLeaderResponse {
bool result = 1;
string msg = 2;
}
message MasterInfo {
string name = 1;
uint64 memberID = 2;
bool alive = 3;
repeated string peerURLs = 4;
repeated string clientURLs = 5;
}
message WorkerInfo {
string name = 1;
string addr = 2;
string stage = 3;
string source = 4;
}
message ListLeaderMember {
string msg = 1;
string name = 2;
string addr = 3;
}
message ListMasterMember {
string msg = 1;
repeated MasterInfo masters = 2;
}
message ListWorkerMember {
string msg = 1;
repeated WorkerInfo workers = 2;
}
message Members {
oneof member {
ListLeaderMember leader = 1;
ListMasterMember master = 2;
ListWorkerMember worker = 3;
}
}
message ListMemberRequest {
bool leader = 1;
bool master = 2;
bool worker = 3;
repeated string names = 4;
}
message ListMemberResponse {
bool result = 1;
string msg = 2;
repeated Members members = 3;
}
message OperateSchemaRequest {
SchemaOp op = 1; // operation type
string task = 2; // task name
repeated string sources = 3; // source ID list
string database = 4; // database name
string table = 5; // table name
string schema = 6; // schema content, a `CREATE TABLE` statement
bool flush = 7; // flush table info and checkpoint
bool sync = 8; // sync the table info to master
}
message OperateSchemaResponse {
bool result = 1;
string msg = 2;
repeated CommonWorkerResponse sources = 3;
}
message GetSubTaskCfgRequest {
// the task name
string name = 1;
}
message GetSubTaskCfgResponse {
bool result = 1;
string msg = 2;
repeated string cfgs = 3;
}
enum CfgType {
InvalidType = 0;
TaskType = 1;
MasterType = 2;
WorkerType = 3;
SourceType = 4;
}
message GetCfgRequest {
CfgType type = 1; // the config type
string name = 2; // the config name
}
message GetCfgResponse {
bool result = 1;
string msg = 2;
string cfg = 3;
}
message GetMasterCfgRequest {
}
message GetMasterCfgResponse {
string cfg = 1;
}
message HandleErrorRequest {
ErrorOp op = 1; // operation type
string task = 2; // the task name
repeated string sources = 3; // source ID list
string binlogPos = 4; // binlog-pos (that's file:pos format)
repeated string sqls = 5; // sqls (use for replace)
}
message HandleErrorResponse {
bool result = 1;
string msg = 2;
repeated CommonWorkerResponse sources = 3;
}
message TransferSourceRequest {
string source = 1;
string worker = 2;
}
message TransferSourceResponse {
bool result = 1;
string msg = 2;
}
message OperateRelayRequest {
RelayOpV2 op = 1;
string source = 2;
repeated string worker = 3;
}
message OperateRelayResponse {
bool result = 1;
string msg = 2;
}
enum RelayOpV2 {
InvalidRelayOpV2 = 0;
StartRelayV2 = 1;
StopRelayV2 = 2;
}