Skip to content

Commit

Permalink
(fix)convert Ehinese comments to English comments. (sofastack#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
zongtanghu authored Apr 29, 2020
1 parent 82f618e commit 5c9bfe3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,29 +70,31 @@ public long getMaxSlot() {

public AtomicRangeGroup(String dataPath, String groupId, PeerId serverId, long minSlot, long maxSlot,
NodeOptions nodeOptions, RpcServer rpcServer) throws IOException {
//初始化路径
// Init file path
FileUtils.forceMkdir(new File(dataPath));
this.minSlot = minSlot;
this.maxSlot = maxSlot;

//初始化状态机
// Init statemachine
this.fsm = new AtomicStateMachine();
//设置状态机到启动参数

// Set statemachine to bootstrap options
nodeOptions.setFsm(this.fsm);
nodeOptions.setEnableMetrics(true);
nodeOptions.getRaftOptions().setReplicatorPipeline(true);
nodeOptions.getRaftOptions().setSync(true);
nodeOptions.getRaftOptions().setReadOnlyOptions(ReadOnlyOption.ReadOnlySafe);
//设置存储路径
//日志,必须

// Set the data path
// Log, required
nodeOptions.setLogUri(dataPath + File.separator + "log");
//元信息,必须
// Metadata, required
nodeOptions.setRaftMetaUri(dataPath + File.separator + "raft_meta");
//snapshot,可选,一般都推荐.
// Snapshot, not required, but recommend
nodeOptions.setSnapshotUri(dataPath + File.separator + "snapshot");
//初始化 raft group 服务框架
// Init raft group service framework
this.raftGroupService = new RaftGroupService(groupId, serverId, nodeOptions, rpcServer);
//启动
// Startup node
this.node = this.raftGroupService.start();

final ConsoleReporter reporter = ConsoleReporter.forRegistry(node.getNodeMetrics().getMetricRegistry())
Expand Down Expand Up @@ -154,14 +156,13 @@ public BooleanCommand redirect() {
public static AtomicRangeGroup start(StartupConf conf, RpcServer rpcServer) throws IOException {

final NodeOptions nodeOptions = new NodeOptions();
//为了测试,调整 snapshot 间隔等参数
//设置选举超时时间为 1 秒
// Set election timeout to 1 second
nodeOptions.setElectionTimeoutMs(1000);
//关闭 CLI 服务。
// Close cli service
nodeOptions.setDisableCli(false);
//每隔30秒做一次 snapshot
// A snapshot saving would be triggered every 30 seconds
// nodeOptions.setSnapshotIntervalSecs(30);
//解析参数
// Parsing Options
final PeerId serverId = new PeerId();
if (!serverId.parse(conf.getServerAddress())) {
throw new IllegalArgumentException("Fail to parse serverId:" + conf.getServerAddress());
Expand All @@ -170,9 +171,9 @@ public static AtomicRangeGroup start(StartupConf conf, RpcServer rpcServer) thro
if (!initConf.parse(conf.getConf())) {
throw new IllegalArgumentException("Fail to parse initConf:" + conf.getConf());
}
//设置初始集群配置
// Set the initial cluster configuration
nodeOptions.setInitialConf(initConf);
//启动
// Startup node
final AtomicRangeGroup node = new AtomicRangeGroup(conf.getDataPath(), conf.getGroupId(), serverId,
conf.getMinSlot(), conf.getMaxSlot(), nodeOptions, rpcServer);
LOG.info("Started range node[{}-{}] at port:{}", conf.getMinSlot(), conf.getMaxSlot(), node.getNode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public String getPath() {

/**
* Save value to snapshot file.
* @param value
* @param values
* @return
*/
public boolean save(Map<String, Long> values) {
Expand Down

0 comments on commit 5c9bfe3

Please sign in to comment.