forked from opencurve/curve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopyset.proto
executable file
·103 lines (86 loc) · 3.97 KB
/
copyset.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
/*
* 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.chunkserver;
option cc_generic_services = true;
option go_package = "proto/copyset";
// copyset epoch message,用于epoch序列化和反序列化
message ConfEpoch {
required uint32 logicPoolId = 1;
required uint32 copysetId = 2;
required uint64 epoch = 3;
required uint32 checksum = 4;
}
message CopysetRequest {
// logicPoolId 实际上 uint16,但是 proto 没有 uint16
required uint32 logicPoolId = 1;
required uint32 copysetId = 2;
repeated string peerid = 3; // 当前复制组配置,可以为空
};
enum COPYSET_OP_STATUS {
COPYSET_OP_STATUS_SUCCESS = 0;
COPYSET_OP_STATUS_EXIST = 1; // copyset node 已经存在
COPYSET_OP_STATUS_COPYSET_NOTEXIST = 2;
COPYSET_OP_STATUS_FAILURE_UNKNOWN = 3;
COPYSET_OP_STATUS_COPYSET_IS_HEALTHY = 4;
};
message CopysetResponse {
optional COPYSET_OP_STATUS status = 1;
optional string redirect = 2; // 自己不是 leader,重定向给 leader
};
message Copyset {
required uint32 logicPoolId = 1;
required uint32 copysetId = 2;
repeated common.Peer peers = 3;
}
message CopysetRequest2 {
repeated Copyset copysets = 1;
};
message CopysetResponse2 {
optional COPYSET_OP_STATUS status = 1;
}
message CopysetStatusRequest {
required uint32 logicPoolId = 1;
required uint32 copysetId = 2;
required common.Peer peer = 3;
required bool queryHash = 4; // 考虑到计算copyset hash值是一个非常耗时的操作,所以设置一个bool变量可以选择不查
}
// 大部分字段只能是optional,因为copyset node可能不存在
message CopysetStatusResponse {
required COPYSET_OP_STATUS status = 1; // op状态
optional uint32 state = 2; // copyset状态
optional common.Peer peer = 3; // peer
optional common.Peer leader = 4; // leader
optional bool readOnly = 5; // 是否只读
optional int64 term = 6; // 当前任期
optional int64 committedIndex = 7; // 当前的committed index
optional int64 knownAppliedIndex = 8; // 当前copyset已知的applied index,当前peer可能未apply
optional int64 pendingIndex = 9; // 当前副本未决的op log index起始index
optional int64 pendingQueueSize = 10; // 当前副本未决的op log queue的长度
optional int64 applyingIndex = 11; // 当前副本正在apply的op log index
optional int64 firstIndex = 12; // 当前副本第一条op log index(包括盘和memory)
optional int64 lastIndex = 13; // 当前副本最后一条op log index(包括盘和memory)
optional int64 diskIndex = 14; // 当前副本已经持久化的最大op log index(不包含memory)
optional uint64 epoch = 15; // 当前copyset配置版本
optional string hash = 16; // 当前copyset的数据hash值
}
service CopysetService {
rpc CreateCopysetNode (CopysetRequest) returns (CopysetResponse);
rpc CreateCopysetNode2 (CopysetRequest2) returns (CopysetResponse2);
rpc DeleteBrokenCopyset(CopysetRequest) returns (CopysetResponse);
rpc GetCopysetStatus (CopysetStatusRequest) returns (CopysetStatusResponse);
};