Skip to content

Commit

Permalink
Merge "add Recommended Configuration" into feature
Browse files Browse the repository at this point in the history
  • Loading branch information
吴德妙 authored and Gerrit Code Review committed May 30, 2019
2 parents 80509c7 + 9200404 commit 98950c1
Show file tree
Hide file tree
Showing 17 changed files with 188 additions and 164 deletions.
4 changes: 2 additions & 2 deletions conf/chunkserver.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ copyset.check_term=true
copyset.disable_cli=false
copyset.log_applied_task=false
copyset.election_timeout_ms=5000
copyset.snapshot_interval=30
copyset.catchup_margin=50
copyset.snapshot_interval_s=1800
copyset.catchup_margin=20000
copyset.chunk_data_uri=local://./0/copysets
copyset.raft_log_uri=local://./0/copysets
copyset.raft_meta_uri=local://./0/copysets
Expand Down
2 changes: 1 addition & 1 deletion deploy/local/chunkserver/conf/chunkserver.conf.0
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ copyset.check_term=true
copyset.disable_cli=false
copyset.log_applied_task=false
copyset.election_timeout_ms=5000
copyset.snapshot_interval=30
copyset.snapshot_interval_s=30
copyset.catchup_margin=50
copyset.chunk_data_uri=local://./0/copysets
copyset.raft_log_uri=local://./0/copysets
Expand Down
2 changes: 1 addition & 1 deletion deploy/local/chunkserver/conf/chunkserver.conf.1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ copyset.check_term=true
copyset.disable_cli=false
copyset.log_applied_task=false
copyset.election_timeout_ms=5000
copyset.snapshot_interval=30
copyset.snapshot_interval_s=30
copyset.catchup_margin=50
copyset.chunk_data_uri=local://./1/copysets
copyset.raft_log_uri=local://./1/copysets
Expand Down
2 changes: 1 addition & 1 deletion deploy/local/chunkserver/conf/chunkserver.conf.2
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ copyset.check_term=true
copyset.disable_cli=false
copyset.log_applied_task=false
copyset.election_timeout_ms=5000
copyset.snapshot_interval=30
copyset.snapshot_interval_s=30
copyset.catchup_margin=50
copyset.chunk_data_uri=local://./2/copysets
copyset.raft_log_uri=local://./2/copysets
Expand Down
2 changes: 1 addition & 1 deletion deploy/local/chunkserver/conf/chunkserver.conf.docker1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ copyset.check_term=true
copyset.disable_cli=false
copyset.log_applied_task=false
copyset.election_timeout_ms=5000
copyset.snapshot_interval=30
copyset.snapshot_interval_s=30
copyset.catchup_margin=50
copyset.chunk_data_uri=local:///root/data/0/cs/data
copyset.raft_log_uri=local:///root/data/0/cs/log
Expand Down
2 changes: 1 addition & 1 deletion deploy/local/chunkserver/conf/chunkserver.conf.docker2
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ copyset.check_term=true
copyset.disable_cli=false
copyset.log_applied_task=false
copyset.election_timeout_ms=5000
copyset.snapshot_interval=30
copyset.snapshot_interval_s=30
copyset.catchup_margin=50
copyset.chunk_data_uri=local:///root/data/1/cs/data
copyset.raft_log_uri=local:///root/data/1/cs/log
Expand Down
2 changes: 1 addition & 1 deletion deploy/local/chunkserver/conf/chunkserver.conf.docker3
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ copyset.check_term=true
copyset.disable_cli=false
copyset.log_applied_task=false
copyset.election_timeout_ms=5000
copyset.snapshot_interval=30
copyset.snapshot_interval_s=30
copyset.catchup_margin=50
copyset.chunk_data_uri=local:///root/data/2/cs/data
copyset.raft_log_uri=local:///root/data/2/cs/log
Expand Down
2 changes: 1 addition & 1 deletion deploy/local/chunkserver/conf/chunkserver.conf.docker4
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ copyset.check_term=true
copyset.disable_cli=false
copyset.log_applied_task=false
copyset.election_timeout_ms=5000
copyset.snapshot_interval=30
copyset.snapshot_interval_s=30
copyset.catchup_margin=50
copyset.chunk_data_uri=local:///root/data/2/cs/data
copyset.raft_log_uri=local:///root/data/2/cs/log
Expand Down
2 changes: 1 addition & 1 deletion deploy/local/chunkserver/conf/chunkserver_docker.conf.0
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ copyset.check_term=true
copyset.disable_cli=false
copyset.log_applied_task=false
copyset.election_timeout_ms=5000
copyset.snapshot_interval=30
copyset.snapshot_interval_s=30
copyset.catchup_margin=50
copyset.chunk_data_uri=local:///root/data/0/cs/data
copyset.raft_log_uri=local:///root/data/0/cs/log
Expand Down
2 changes: 1 addition & 1 deletion deploy/local/chunkserver/conf/chunkserver_docker.conf.1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ copyset.check_term=true
copyset.disable_cli=false
copyset.log_applied_task=false
copyset.election_timeout_ms=5000
copyset.snapshot_interval=30
copyset.snapshot_interval_s=30
copyset.catchup_margin=50
copyset.chunk_data_uri=local:///root/data/1/cs/data
copyset.raft_log_uri=local:///root/data/1/cs/log
Expand Down
2 changes: 1 addition & 1 deletion deploy/local/chunkserver/conf/chunkserver_docker.conf.2
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ copyset.check_term=true
copyset.disable_cli=false
copyset.log_applied_task=false
copyset.election_timeout_ms=5000
copyset.snapshot_interval=30
copyset.snapshot_interval_s=30
copyset.catchup_margin=50
copyset.chunk_data_uri=local:///root/data/2/cs/data
copyset.raft_log_uri=local:///root/data/2/cs/log
Expand Down
186 changes: 94 additions & 92 deletions proto/chunk.proto
Original file line number Diff line number Diff line change
@@ -1,92 +1,94 @@
syntax = "proto2";
package curve.chunkserver;

option cc_generic_services = true;

// 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
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; // 未知 Op
};

// 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 clone chunk
};

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; // 其他错误
};

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 版本号
};

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 CreateCloneChunk (ChunkRequest) returns (ChunkResponse);
rpc RecoverChunk (ChunkRequest) returns (ChunkResponse);
};
syntax = "proto2";
package curve.chunkserver;

option cc_generic_services = true;

// 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; // 未知 Op
};

// 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 clone chunk
};

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; // 其他错误
};

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 版本号
};

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 CreateCloneChunk (ChunkRequest) returns (ChunkResponse);
rpc RecoverChunk (ChunkRequest) returns (ChunkResponse);
};
1 change: 1 addition & 0 deletions src/chunkserver/conf_epoch_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ using curve::fs::LocalFsFactory;

/**
* 配置版本序列化和反序列化的工具类
* TODO(wudemiao): 后期替换采用json编码
*/
class ConfEpochFile {
public:
Expand Down
6 changes: 6 additions & 0 deletions src/chunkserver/copyset_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ class CopysetNode : public braft::StateMachine,
*/
virtual bool IsLeaderTerm() const;

/**
* 返回当前的任期
* @return 当前的任期
*/
virtual uint64_t LeaderTerm() const;

/**
* 返回leader id
* @return
Expand Down
Loading

0 comments on commit 98950c1

Please sign in to comment.