Skip to content
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

Open
wants to merge 7 commits into
base: course
Choose a base branch
from
Open

Implementing Raw Node Interface should be a 4-tier title #186

wants to merge 7 commits into from

Conversation

BowenXiao1999
Copy link

Implement raw node interace should be on the same level of other parts in proj2a.

@BowenXiao1999
Copy link
Author

Otherwise people may be confused at the structure

Copy link
Collaborator

@Connor1996 Connor1996 left a 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?

@BowenXiao1999
Copy link
Author

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".

@Connor1996
Copy link
Collaborator

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?

@BowenXiao1999
Copy link
Author

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#### 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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#### 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Raw node interface
### Implement Raw node interface

### Implement the raw node interface
### Raw node interface

#### Implement the raw node interface (project2ac)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#### 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?

Copy link
Author

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.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants