-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Remove CmdID from InternalRaftCommand and pass it to raft separately. #211
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
+13 −0 | Documentation/0.5/admin_guide.md | |
+28 −5 | Documentation/0.5/other_apis.md | |
+6 −2 | Documentation/0.5/runtime-configuration.md | |
+3 −3 | etcdserver/etcdhttp/client_test.go | |
+34 −29 | etcdserver/server.go | |
+12 −23 | etcdserver/server_test.go | |
+5 −3 | raft/node.go | |
+7 −8 | raft/node_test.go | |
+91 −105 | raft/raft.go | |
+11 −5 | snap/snapshotter.go | |
+20 −0 | snap/snapshotter_test.go |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,10 +21,17 @@ import ( | |
"testing" | ||
"time" | ||
|
||
"github.com/cockroachdb/cockroach/util" | ||
"github.com/cockroachdb/cockroach/util/log" | ||
"github.com/coreos/etcd/raft/raftpb" | ||
) | ||
|
||
var rand = util.NewPseudoRand() | ||
|
||
func makeCommandID() []byte { | ||
return []byte(util.RandString(rand, commandIDLen)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RandString actually leaves a lot of bits on the floor and is extraordinarily inefficient if all we're trying to do is generate 16 bytes. Let's just get two random int64s and append them using:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh forget it...this is just test code. |
||
} | ||
|
||
type testCluster struct { | ||
t *testing.T | ||
nodes []*state | ||
|
@@ -130,7 +137,7 @@ func TestCommand(t *testing.T) { | |
cluster.waitForElection(0) | ||
|
||
// Submit a command to the leader | ||
cluster.nodes[0].SubmitCommand(groupID, []byte("command")) | ||
cluster.nodes[0].SubmitCommand(groupID, makeCommandID(), []byte("command")) | ||
|
||
// The command will be committed on each node. | ||
for i, events := range cluster.events { | ||
|
@@ -156,7 +163,7 @@ func TestSlowStorage(t *testing.T) { | |
cluster.storages[2].Block() | ||
|
||
// Submit a command to the leader | ||
cluster.nodes[0].SubmitCommand(groupID, []byte("command")) | ||
cluster.nodes[0].SubmitCommand(groupID, makeCommandID(), []byte("command")) | ||
|
||
// Even with the third node blocked, the other nodes can make progress. | ||
for i := 0; i < 2; i++ { | ||
|
@@ -196,7 +203,8 @@ func TestMembershipChange(t *testing.T) { | |
|
||
// Add each of the other three nodes to the cluster. | ||
for i := 1; i < 4; i++ { | ||
err := cluster.nodes[0].ChangeGroupMembership(groupID, raftpb.ConfChangeAddNode, | ||
err := cluster.nodes[0].ChangeGroupMembership(groupID, makeCommandID(), | ||
raftpb.ConfChangeAddNode, | ||
cluster.nodes[i].nodeID) | ||
if err != nil { | ||
t.Fatal(err) | ||
|
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.
Let's make the first version a const up with commandIDLen and explicitly append it here.
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.
Done