-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementing Raw Node Interface should be a 4-tier title #186
base: course
Are you sure you want to change the base?
Conversation
Otherwise people may be confused at the structure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does should be 3-tier which is same level of Implement Raft Algorithm
. why do you think it should be a 4-tier title?
Because test project2aa and project2ab are under a 4-tier title, so should project2ac. Well, it's just a suggestion, currently it also make sense but just a little be confused. Or maybe add another 4-tier under "implement raw node interface". |
Have no better title of another 4-tier under "implement raw node interface". Do you any? |
Updated some suggestion. |
@@ -28,19 +28,21 @@ This part can be broken down into 3 steps, including: | |||
|
|||
`raft.Raft` in `raft/raft.go` provides the core of the Raft algorithm including message handling, driving the logic clock, etc. For more implementation guides, please check `raft/doc.go` which contains an overview design and what these `MessageTypes` are responsible for. | |||
|
|||
#### Leader election | |||
#### Leader election (project2aa) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#### Leader election (project2aa) | |
#### Leader election |
|
||
To implement leader election, you may want to start with `raft.Raft.tick()` which is used to advance the internal logical clock by a single tick and hence drive the election timeout or heartbeat timeout. You don’t need to care about the message sending and receiving logic now. If you need to send out a message, just push it to `raft.Raft.msgs` and all messages the raft received will be passed to `raft.Raft.Step()`. The test code will get the messages from `raft.Raft.msgs` and pass response messages through `raft.Raft.Step()`. The `raft.Raft.Step()` is the entrance of message handling, you should handle messages like `MsgRequestVote`, `MsgHeartbeat` and their response. And please also implement test stub functions and get them called properly like `raft.Raft.becomeXXX` which used to update the raft internal state when the raft’s role changes. | ||
|
||
You can run `make project2aa` to test the implementation, and see some hints at the end of this part. | ||
|
||
#### Log replication | ||
#### Log replication (project2ab) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#### Log replication (project2ab) | |
#### Log replication |
|
||
To implement log replication, you may want to start with handling `MsgAppend` and `MsgAppendResponse` on both the sender and receiver side. Checkout `raft.RaftLog` in `raft/log.go` which is a helper struct that help you manage the raft log, in here you also need to interact with the upper application by the `Storage` interface defined in `raft/storage.go` to get the persisted data like log entries and snapshot. | ||
|
||
You can run `make project2ab` to test the implementation, and see some hints at the end of this part. | ||
|
||
### Implement the raw node interface | ||
### Raw node interface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### Raw node interface | |
### Implement Raw node interface |
### Implement the raw node interface | ||
### Raw node interface | ||
|
||
#### Implement the raw node interface (project2ac) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#### Implement the raw node interface (project2ac) | |
### Implement the raw node interface (project2ac) | |
`raft.RawNode` in `raft/rawnode.go` is the interface we interact with the upper application, `raft.RawNode` contains `raft.Raft` and provide some wrapper functions like `RawNode.Tick()`and `RawNode.Step()`. It also provides `RawNode.Propose()` to let the upper application propose new raft logs. | |
#### Raft Ready |
How about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should be better now.
|
Implement raw node interace
should be on the same level of other parts in proj2a.