forked from opencurve/curve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chunk.proto
executable file
·164 lines (141 loc) · 6.74 KB
/
chunk.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
/*
* 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";
package curve.chunkserver;
option cc_generic_services = true;
option go_package = "proto/chunk";
// Qos 参数
message QosRequestParas {
optional uint32 clientId = 1;
optional int32 dmclockDelta = 2;
optional int32 dmclockRho = 3;
}
message QosResponseParas {
optional int32 phase = 1; // 0: 代表 reservation 阶段; 1: 代表 priority 阶段
optional int32 cost = 2; //
}
// For chunk
enum CHUNK_OP_TYPE {
CHUNK_OP_DELETE = 0; // 删除 chunk
CHUNK_OP_READ = 1; // 读 chunk
CHUNK_OP_WRITE = 2; // 写 chunk
CHUNK_OP_READ_SNAP = 3; // read chunk snapshot
// TODO(wudemiao): 后期替换成CHUNK_OP_DELETE_SNAP_OR_CORRECT_SN,
// 保证和chunkserver的接口一致
CHUNK_OP_DELETE_SNAP = 4; // delete chunk snapshot
CHUNK_OP_CREATE_CLONE = 5; // 创建clone chunk
CHUNK_OP_RECOVER = 6; // 恢复clone chunk
CHUNK_OP_PASTE = 7; // paste chunk 内部请求
CHUNK_OP_UNKNOWN = 8; // unknown Op
CHUNK_OP_SCAN = 9; // scan oprequest
};
// read/write 的实际数据在 rpc 的 attachment 中
message ChunkRequest {
required CHUNK_OP_TYPE opType = 1; // for all
required uint32 logicPoolId = 2; // for all // logicPoolId 实际上 uint16,但是 proto 没有 uint16
required uint32 copysetId = 3; // for all
required uint64 chunkId = 4; // for all
optional uint64 appliedIndex = 5; // for read
optional uint32 offset = 6; // for read/write
optional uint32 size = 7; // for read/write/clone 读取数据大小/写入数据大小/创建快照请求中表示请求创建的chunk大小
optional QosRequestParas deltaRho = 8; // for read/write
optional uint64 sn = 9; // for write/read snapshot 写请求中表示文件当前版本号,读快照请求中表示请求的chunk的版本号
optional uint64 correctedSn = 10; // for CreateCloneChunk/DeleteChunkSnapshotOrCorrectedSn 用于修改chunk的correctedSn
optional string location = 11; // for CreateCloneChunk
optional string cloneFileSource = 12; // for write/read
optional uint64 cloneFileOffset = 13; // for write/read
optional uint64 sendScanMapTimeoutMs = 14; // for scan chunk
optional uint32 sendScanMapRetryTimes= 15; // for scan chunk
optional uint64 sendScanMapRetryIntervalUs = 16; // for scan chunk
optional bool readMetaPage = 17; // for scan chunk
optional uint64 fileId = 18; // for io fence
optional uint64 epoch = 19; // for io fence
};
enum CHUNK_OP_STATUS {
CHUNK_OP_STATUS_SUCCESS = 0; // 成功
CHUNK_OP_STATUS_REDIRECTED = 1; // 不是 leader,重定向
CHUNK_OP_STATUS_DISK_FAIL = 2; // 磁盘返回错误
CHUNK_OP_STATUS_CRC_FAIL = 3; // CRC 校验失败
CHUNK_OP_STATUS_INVALID_REQUEST = 4; // 请求参数不对
CHUNK_OP_STATUS_NOSPACE = 5; // 空间不够
CHUNK_OP_STATUS_COPYSET_NOTEXIST = 6; // copyset 不存在
CHUNK_OP_STATUS_CHUNK_NOTEXIST = 7; // chunk或其快照文件不存在
CHUNK_OP_STATUS_FAILURE_UNKNOWN = 8; // 其他错误
CHUNK_OP_STATUS_OVERLOAD = 9; // 过载,表示服务端有过多请求未处理返回
CHUNK_OP_STATUS_BACKWARD = 10; // 请求的版本落后当前chunk的版本
CHUNK_OP_STATUS_CHUNK_EXIST = 11; // chunk已存在
CHUNK_OP_STATUS_EPOCH_TOO_OLD = 12; // request epoch too old
};
message ChunkResponse {
required CHUNK_OP_STATUS status = 1;
optional string redirect = 2; // 自己不是 leader,重定向给 leader
optional uint64 appliedIndex = 3; // 返回当前最新的 committedIndex, 注意 read 和 write 都要返回
optional QosResponseParas phaseCost = 4; // for read/write
optional uint64 chunkSn = 5; // for GetChunkInfo 表示chunk文件版本号,0表示不存在
optional uint64 snapSn = 6; // for GetChunkInfo 表示chunk文件快照的版本号,0表示不存在
};
message GetChunkInfoRequest {
required uint32 logicPoolId = 1;
required uint32 copysetId = 2;
required uint64 chunkId = 3;
};
message GetChunkInfoResponse {
required CHUNK_OP_STATUS status = 1;
optional string redirect = 2; // 自己不是 leader,重定向给 leader
repeated uint64 chunkSn = 3; // chunk 版本号 和 snapshot 版本号
};
message GetChunkHashRequest {
required uint32 logicPoolId = 1;
required uint32 copysetId = 2;
required uint64 chunkId = 3;
required uint32 offset = 4;
required uint32 length = 5;
};
message GetChunkHashResponse {
required CHUNK_OP_STATUS status = 1;
optional string hash = 2; // 能标志chunk数据状态的hash值,一般是crc32c
};
message CreateS3CloneChunkRequest {
required uint32 logicPoolId = 1;
required uint32 copysetId = 2;
required uint64 chunkId = 3;
optional uint64 correctedSn = 4;
optional string chunkLocationInfo = 5;
};
message CreateS3CloneChunkResponse {
required CHUNK_OP_STATUS status = 1;
optional string redirect = 2; // 自己不是 leader,重定向给 leader
};
message UpdateEpochRequest {
required uint64 fileId = 1;
required uint64 epoch = 2;
};
message UpdateEpochResponse {
required CHUNK_OP_STATUS status = 1;
};
service ChunkService {
rpc DeleteChunk (ChunkRequest) returns (ChunkResponse);
rpc ReadChunk (ChunkRequest) returns (ChunkResponse);
rpc WriteChunk (ChunkRequest) returns (ChunkResponse);
rpc ReadChunkSnapshot (ChunkRequest) returns (ChunkResponse);
rpc DeleteChunkSnapshotOrCorrectSn (ChunkRequest) returns (ChunkResponse);
rpc GetChunkInfo (GetChunkInfoRequest) returns (GetChunkInfoResponse);
rpc GetChunkHash (GetChunkHashRequest) returns (GetChunkHashResponse);
rpc CreateCloneChunk (ChunkRequest) returns (ChunkResponse);
rpc CreateS3CloneChunk(CreateS3CloneChunkRequest) returns(CreateS3CloneChunkResponse);
rpc RecoverChunk (ChunkRequest) returns (ChunkResponse);
rpc UpdateEpoch(UpdateEpochRequest) returns (UpdateEpochResponse);
};