com.github.wenweihu86.raft.proto.raft.proto Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of raft-java-core Show documentation
Show all versions of raft-java-core Show documentation
another Raft implementation for Java
The newest version!
syntax="proto3";
package raft;
option java_package = "com.github.wenweihu86.raft.proto";
option java_outer_classname = "RaftMessage";
enum ResCode {
RES_CODE_SUCCESS = 0;
RES_CODE_FAIL = 1;
RES_CODE_NOT_LEADER = 2;
}
enum EntryType {
ENTRY_TYPE_DATA = 0;
ENTRY_TYPE_CONFIGURATION= 1;
};
message EndPoint {
string host = 1;
uint32 port = 2;
}
message Server {
uint32 server_id = 1;
EndPoint end_point = 2;
}
message Configuration {
repeated Server servers = 1;
}
message LogMetaData {
uint64 current_term = 1;
uint32 voted_for = 2;
uint64 first_log_index = 3;
}
message SnapshotMetaData {
uint64 last_included_index = 1;
uint64 last_included_term = 2;
Configuration configuration = 3;
}
message LogEntry {
uint64 term = 1;
uint64 index = 2;
EntryType type = 3;
bytes data = 4;
};
message VoteRequest {
uint32 server_id = 1; // 请求选票的候选人的 Id
uint64 term = 2; // 候选人的任期号
uint64 last_log_term = 3; // 候选人的最后日志条目的任期号
uint64 last_log_index = 4; // 候选人最后日志条目的索引值
};
message VoteResponse {
uint64 term = 1; // 当前任期号,以便于候选人去更新自己的任期号
bool granted = 2; // 候选人赢得了此张选票时为真
};
message AppendEntriesRequest {
uint32 server_id = 1; // 领导人的Id
uint64 term = 2; // 领导人的任期号
uint64 prev_log_index = 3; // 新的日志条目紧随之前的索引值
uint64 prev_log_term = 4; // prev_log_index条目的任期号
repeated LogEntry entries = 5; // 准备存储的日志条目(表示心跳时为空)
uint64 commit_index = 6; // 领导人已经提交的日志的索引值
};
message AppendEntriesResponse {
ResCode res_code = 1; // 跟随者包含了匹配上 prevLogIndex 和 prevLogTerm 的日志时为真
uint64 term = 2; // 当前的任期号,用于领导人去更新自己
uint64 last_log_index = 3;
};
message InstallSnapshotRequest {
uint32 server_id = 1;
uint64 term = 2;
SnapshotMetaData snapshot_meta_data = 3;
string file_name = 4;
uint64 offset = 5;
bytes data = 6;
bool is_first = 7;
bool is_last = 8;
}
message InstallSnapshotResponse {
ResCode res_code = 1;
uint64 term = 2;
}
message GetLeaderRequest {
}
message GetLeaderResponse {
ResCode res_code = 1;
string res_msg = 2;
EndPoint leader = 3;
}
message AddPeersRequest {
repeated Server servers = 1;
}
message AddPeersResponse {
ResCode res_code = 1;
string res_msg = 2;
}
message RemovePeersRequest {
repeated Server servers = 1;
}
message RemovePeersResponse {
ResCode res_code = 1;
string res_msg = 2;
}
message GetConfigurationRequest {
}
message GetConfigurationResponse {
ResCode res_code = 1;
string res_msg = 2;
repeated Server servers = 3;
Server leader = 4;
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy