-
Notifications
You must be signed in to change notification settings - Fork 526
/
Copy pathnameserver2.proto
647 lines (547 loc) · 17.8 KB
/
nameserver2.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
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
/*
* Copyright (c) 2020 NetEase 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.
*/
syntax="proto2";
import "proto/common.proto";
package curve.mds;
option cc_generic_services = true;
option go_package = "proto/nameserver2";
// fileinfo
enum FileType {
INODE_DIRECTORY = 0;
INODE_PAGEFILE = 1;
INODE_APPENDFILE = 2;
INODE_APPENDECFILE = 3;
INODE_SNAPSHOT_PAGEFILE = 4;
};
enum FileStatus {
// 文件创建完成
kFileCreated = 0;
// 文件删除中
kFileDeleting = 1;
// 文件正在克隆
kFileCloning = 2;
// 文件元数据安装完毕
kFileCloneMetaInstalled = 3;
// 文件克隆完成
kFileCloned = 4;
// 文件正在被克隆
kFileBeingCloned = 5;
}
enum ThrottleType {
IOPS_TOTAL = 1;
IOPS_READ = 2;
IOPS_WRITE = 3;
BPS_TOTAL = 4;
BPS_READ = 5;
BPS_WRITE = 6;
}
message ThrottleParams {
required ThrottleType type = 1;
required uint64 limit = 2;
optional uint64 burst = 3;
optional uint64 burstLength = 4;
}
message FileThrottleParams {
repeated ThrottleParams throttleParams = 1;
}
message FileInfo {
optional uint64 id = 1;
optional string fileName = 2;
optional uint64 parentId = 3;
optional FileType fileType = 4;
optional string owner = 5;
optional uint32 chunkSize = 6;
optional uint32 segmentSize = 7;
optional uint64 length = 8;
optional uint64 ctime = 9;
optional uint64 seqNum = 10;
optional FileStatus fileStatus = 11;
//用于文件转移到回收站的情况下恢复场景下的使用,
//RecycleBin(回收站)目录下使用/其他场景下不使用
optional string originalFullPathName = 12;
// cloneSource 当前用于存放克隆源(当前主要用于curvefs)
// 后期可以考虑存放 s3相关信息
optional string cloneSource = 13;
// cloneLength 克隆源文件的长度,用于clone过程中进行extent
optional uint64 cloneLength = 14;
optional uint64 stripeUnit = 15;
optional uint64 stripeCount = 16;
optional FileThrottleParams throttleParams = 17;
optional uint64 epoch = 18;
}
// status code
enum StatusCode {
// 执行成功
kOK = 0;
// 文件已存在
kFileExists = 101;
// 文件不存在
kFileNotExists = 102;
// 非目录类型
kNotDirectory = 103;
// 传入参数错误
kParaError = 104;
// 缩小文件,目前不支持缩小文件
kShrinkBiggerFile = 105;
// 扩容单位错误,非segment size整数倍
kExtentUnitError = 106;
// segment未分配
kSegmentNotAllocated = 107;
// segment分配失败
kSegmentAllocateError = 108;
// 目录不存在
kDirNotExist = 109;
// 功能不支持
kNotSupported = 110;
// owner认证失败
kOwnerAuthFail = 111;
// 目录非空
kDirNotEmpty = 112;
// 文件已处于快照中
kFileUnderSnapShot = 120;
// 文件不在快照中
kFileNotUnderSnapShot = 121;
// 快照删除中
kSnapshotDeleting = 122;
// 快照文件不存在
kSnapshotFileNotExists = 123;
// 快照文件删除失败
kSnapshotFileDeleteError = 124;
// session不存在
kSessionNotExist = 125;
// 文件已被占用
kFileOccupied = 126;
kCloneFileNameIllegal = 127;
kCloneStatusNotMatch = 128;
// 文件删除失败
kCommonFileDeleteError = 129;
// 文件id不匹配
kFileIdNotMatch = 130;
// 文件在删除中
kFileUnderDeleting = 131;
// 文件长度不符合要求
kFileLengthNotSupported = 132;
// 文件正在被克隆
kDeleteFileBeingCloned = 133;
// client版本不匹配
kClientVersionNotMatch = 134;
// snapshot功能禁用中
kSnapshotFrozen = 135;
// 快照克隆服务连不上
kSnapshotCloneConnectFail = 136;
// 快照克隆服务未初始化
kSnapshotCloneServerNotInit = 137;
// recover file status is CloneMetaInstalled
kRecoverFileCloneMetaInstalled = 138;
// recover file fail
kRecoverFileError = 139;
// epoch too old
kEpochTooOld = 140;
// 元数据存储错误
kStorageError = 501;
// 内部错误
KInternalError = 502;
};
//chunkinfo
message PageFileChunkInfo {
required uint32 copysetID = 3;
required uint64 chunkID = 2;
}
message PageFileSegment {
required uint32 logicalPoolID = 1;
required uint32 segmentSize = 3;
required uint32 chunkSize = 4;
required uint64 startOffset = 2;
repeated PageFileChunkInfo chunks = 5;
}
message DiscardSegmentInfo {
required FileInfo fileInfo = 1;
required PageFileSegment pageFileSegment = 2;
}
message CreateFileRequest {
required string fileName = 1;
required FileType fileType = 3;
optional uint64 fileLength = 4;
required string owner = 2;
optional string signature = 5;
required uint64 date = 6;
optional uint64 stripeUnit = 7;
optional uint64 stripeCount = 8;
};
message CreateFileResponse {
required StatusCode statusCode = 1;
}
message DeleteFileRequest {
required string fileName = 1;
required string owner = 2;
optional string signature = 3;
required uint64 date = 4;
optional uint64 fileId = 5;
optional bool forceDelete = 6;
};
message DeleteFileResponse {
required StatusCode statusCode = 1;
}
message RecoverFileRequest {
required string fileName = 1;
required string owner = 2;
optional string signature = 3;
required uint64 date = 4;
optional uint64 fileId = 5;
};
message RecoverFileResponse {
required StatusCode statusCode = 1;
}
message GetFileInfoRequest {
required string fileName = 1;
required string owner = 2;
optional string signature = 3;
required uint64 date = 4;
}
message GetFileInfoResponse {
required StatusCode statusCode = 1;
optional FileInfo fileInfo = 2;
}
message GetOrAllocateSegmentRequest {
required string fileName = 1;
required uint64 offset = 3;
required bool allocateIfNotExist = 4;
optional uint64 seqNum = 5;
required string owner = 2;
optional string signature = 6;
required uint64 date = 7;
optional uint64 epoch = 8;
}
message GetOrAllocateSegmentResponse {
required StatusCode statusCode = 1;
optional PageFileSegment pageFileSegment = 2;
}
message DeAllocateSegmentRequest {
required string fileName = 1;
required string owner = 2;
required uint64 offset = 3;
optional string signature = 4;
required uint64 date = 5;
}
message DeAllocateSegmentResponse {
required StatusCode statusCode = 1;
}
message RenameFileRequest {
required string oldFileName = 1;
required string newFileName = 2;
required string owner = 3;
optional string signature = 4;
required uint64 date = 7;
optional uint64 oldFileID = 5;
optional uint64 newFileID = 6;
}
message RenameFileResponse {
required StatusCode statusCode = 1;
}
message ExtendFileRequest {
required string fileName = 1;
required uint64 newSize = 3;
required string owner = 2;
optional string signature = 4;
required uint64 date = 5;
}
message ExtendFileResponse {
required StatusCode statusCode = 1;
}
message ChangeOwnerRequest {
// 需要变更owner的文件的fileName
required string fileName = 1;
// 希望文件owner变更后的新的owner
required string newOwner = 2;
// ChangerOwner接口只能通过root权限进行调用,需要传入root权限的owner
required string rootOwner = 3;
// 对root身份进行校验的的signature
required string signature = 4;
// 用来在mds端重新计算signature
required uint64 date = 5;
}
// 返回ChangeOwner的执行结果,成功返回statusCode::kOK
// 失败可能返回kFileNotExists、kOwnerAuthFail、kFileOccupied、kStorageError等,可能返回的错误码将来继续补充
message ChangeOwnerResponse {
required StatusCode statusCode = 1;
}
message ListDirRequest {
required string fileName = 1;
required string owner = 2;
optional string signature = 3;
required uint64 date = 4;
}
message ListDirResponse {
required StatusCode statusCode = 1;
repeated FileInfo fileInfo = 2;
}
// create snapshot
message CreateSnapShotRequest {
required string fileName = 1;
required string owner = 2;
optional string signature = 3;
required uint64 date = 4;
}
message CreateSnapShotResponse {
required StatusCode statusCode = 1;
optional FileInfo snapShotFileInfo = 2;
}
// list snapshots
message ListSnapShotFileInfoRequest {
required string fileName = 1;
repeated uint64 seq = 3;
required string owner = 2;
optional string signature = 4;
required uint64 date = 5;
}
message ListSnapShotFileInfoResponse {
required StatusCode statusCode = 1;
repeated FileInfo fileInfo = 2;
}
// delete snapshot
message DeleteSnapShotRequest {
required string fileName = 1;
required uint64 seq = 3;
required string owner = 2;
optional string signature = 4;
required uint64 date = 5;
}
message DeleteSnapShotResponse {
required StatusCode statusCode = 1;
}
// check snapshot status
message CheckSnapShotStatusRequest {
required string fileName = 1;
required uint64 seq = 3;
required string owner = 2;
optional string signature = 4;
required uint64 date = 5;
}
// statusCode为kOK时,fileStatus和progress才会赋值
// 只有fileStatus是kFileDeleting时,progress表示快照文件删除进度,否则progress返回0
message CheckSnapShotStatusResponse {
required StatusCode statusCode = 1;
optional FileStatus fileStatus = 2;
optional uint32 progress = 3;
}
// session rpcs
enum SessionStatus {
kSessionOK = 0;
kSessionStaled = 1;
kSessionDeleted = 2;
};
message ProtoSession {
required string sessionID = 1;
required uint32 leaseTime = 2;
required uint64 createTime = 3;
required SessionStatus sessionStatus = 4;
// other useful infos
};
message CloneSourceSegment {
required uint64 segmentSize = 1;
repeated uint64 allocatedSegmentOffset = 2;
}
message OpenFileRequest {
required string fileName = 1;
required string owner = 2;
optional string signature = 3;
required uint64 date = 4;
optional string clientVersion = 5;
};
// statusCode返回值,详见StatusCode定义:
// StatusCode::kOK
// StatusCode::kFileNotExists
// StatusCode::kStorageError
// StatusCode::kFileOccupied
// StatusCode::KInternalError
message OpenFileResponse {
required StatusCode statusCode = 1;
optional ProtoSession protoSession = 2;
optional FileInfo fileInfo = 3;
optional CloneSourceSegment cloneSourceSegment = 4;
};
message CloseFileRequest {
required string fileName = 1;
required string sessionID = 2;
required string owner = 3;
optional string signature = 4;
required uint64 date = 5;
optional string clientIP = 6;
optional uint32 clientPort = 7;
};
// statusCode返回值,详见StatusCode定义:
// StatusCode::kOK
// StatusCode::kFileNotExists
// StatusCode::kStorageError
// StatusCode::kSessionNotExist
// StatusCode::KInternalError
message CloseFileResponse {
required StatusCode statusCode = 1;
}
message ReFreshSessionRequest {
required string fileName = 1;
required string sessionID = 2;
required string owner = 3;
required uint64 date = 4; //current time
optional string signature = 5;
optional string clientVersion = 6;
optional string clientIP = 7;
optional uint32 clientPort = 8;
}
// statusCode返回值,详见StatusCode定义:
// StatusCode::kOK
// StatusCode::kFileNotExists
// StatusCode::kStorageError
// StatusCode::kSessionNotExist
message ReFreshSessionResponse {
required StatusCode statusCode = 1;
required string sessionID = 2;
optional FileInfo fileInfo = 3;
optional ProtoSession protoSession = 4;
};
message CreateCloneFileRequest {
required string fileName = 1;
required FileType fileType = 2;
required uint64 fileLength = 3;
required uint64 seq = 4;
required uint32 chunksize = 5;
required string owner = 6;
optional string signature = 7;
required uint64 date =8;
required string cloneSource = 9;
optional uint64 stripeUnit = 10;
optional uint64 stripeCount = 11;
}
message CreateCloneFileResponse {
required StatusCode statusCode = 1;
optional FileInfo fileInfo = 2;
}
message SetCloneFileStatusRequest {
required string fileName = 1;
optional uint64 fileID = 2;
required FileStatus fileStatus = 3;
required string owner = 4;
optional string signature = 5;
required uint64 date = 6;
}
message SetCloneFileStatusResponse {
required StatusCode statusCode = 1;
}
message GetAllocatedSizeRequest {
required string fileName = 1;
}
message GetAllocatedSizeResponse {
required StatusCode statusCode = 1;
// 文件或目录的分配大小
optional uint64 allocatedSize = 2;
// key是逻辑池id,value是分配大小
map<uint32, uint64> allocSizeMap = 3;
}
message GetFileSizeRequest {
required string fileName = 1;
}
message GetFileSizeResponse {
required StatusCode statusCode = 1;
// 文件或目录的file length
optional uint64 fileSize = 2;
}
message ClientInfo {
required string ip = 1;
required uint32 port = 2;
}
message ListClientRequest {
optional bool listAllClient = 1;
}
message ListClientResponse {
required StatusCode statusCode = 1;
repeated ClientInfo clientInfos = 2;
}
message FindFileMountPointRequest {
required string fileName = 1;
}
message FindFileMountPointResponse {
required StatusCode statusCode = 1;
repeated ClientInfo clientInfo = 2;
}
message ListVolumesOnCopysetsRequest {
repeated common.CopysetInfo copysets = 1;
}
message ListVolumesOnCopysetsResponse {
required StatusCode statusCode = 1;
repeated string fileNames = 2;
}
message UpdateFileThrottleParamsRequest {
required string fileName = 1;
required string owner = 2;
optional string signature = 3;
required uint64 date = 4;
required ThrottleParams throttleParams = 5;
}
message UpdateFileThrottleParamsResponse {
required StatusCode statusCode = 1;
}
message IncreaseFileEpochRequest {
required string fileName = 1;
required string owner = 2;
optional string signature = 3;
required uint64 date = 4;
}
message IncreaseFileEpochResponse {
required StatusCode statusCode = 1;
optional FileInfo fileInfo = 2;
repeated common.ChunkServerLocation csLocs = 3;
}
service CurveFSService {
// basic rpcs
rpc CreateFile(CreateFileRequest) returns (CreateFileResponse);
rpc DeleteFile(DeleteFileRequest) returns (DeleteFileResponse);
rpc RecoverFile(RecoverFileRequest) returns (RecoverFileResponse);
rpc GetFileInfo(GetFileInfoRequest) returns (GetFileInfoResponse);
rpc GetOrAllocateSegment(GetOrAllocateSegmentRequest)
returns (GetOrAllocateSegmentResponse);
rpc DeAllocateSegment(DeAllocateSegmentRequest) returns (DeAllocateSegmentResponse);
rpc RenameFile(RenameFileRequest) returns (RenameFileResponse);
rpc ExtendFile(ExtendFileRequest) returns (ExtendFileResponse);
rpc ChangeOwner(ChangeOwnerRequest) returns (ChangeOwnerResponse);
rpc ListDir(ListDirRequest) returns (ListDirResponse);
rpc IncreaseFileEpoch(IncreaseFileEpochRequest) returns (IncreaseFileEpochResponse);
// snapshot rpcs
rpc CreateSnapShot(CreateSnapShotRequest)
returns (CreateSnapShotResponse);
rpc ListSnapShot(ListSnapShotFileInfoRequest)
returns (ListSnapShotFileInfoResponse);
rpc DeleteSnapShot(DeleteSnapShotRequest)
returns (DeleteSnapShotResponse);
rpc CheckSnapShotStatus(CheckSnapShotStatusRequest)
returns (CheckSnapShotStatusResponse);
rpc GetSnapShotFileSegment(GetOrAllocateSegmentRequest)
returns (GetOrAllocateSegmentResponse);
// session rpcs
rpc OpenFile(OpenFileRequest) returns (OpenFileResponse);
rpc CloseFile(CloseFileRequest) returns (CloseFileResponse);
rpc RefreshSession(ReFreshSessionRequest)
returns (ReFreshSessionResponse);
// clone rpcs
rpc CreateCloneFile(CreateCloneFileRequest) returns (CreateCloneFileResponse);
rpc SetCloneFileStatus(SetCloneFileStatusRequest) returns (SetCloneFileStatusResponse);
// curve status
rpc GetAllocatedSize(GetAllocatedSizeRequest) returns (GetAllocatedSizeResponse);
rpc GetFileSize(GetFileSizeRequest) returns (GetFileSizeResponse);
rpc ListClient(ListClientRequest) returns (ListClientResponse);
rpc FindFileMountPoint(FindFileMountPointRequest) returns (FindFileMountPointResponse);
rpc ListVolumesOnCopysets(ListVolumesOnCopysetsRequest) returns (ListVolumesOnCopysetsResponse);
rpc UpdateFileThrottleParams(UpdateFileThrottleParamsRequest) returns (UpdateFileThrottleParamsResponse);
}