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

add selfcontained raftexample #67

Closed
wants to merge 9 commits into from
Closed

Conversation

Elbehery
Copy link
Member

@Elbehery Elbehery commented Jun 1, 2023

resolves #2

Signed-off-by: Mustafa Elbehery [email protected]

@Elbehery Elbehery changed the title add selfcontained raftexample WIP: add selfcontained raftexample Jun 1, 2023
@Elbehery
Copy link
Member Author

Elbehery commented Jun 1, 2023

@ahrtr @ptabor @serathius PTAL

@Elbehery
Copy link
Member Author

Elbehery commented Jun 1, 2023

I ran the one instance locally and it is as expected

mustafa@mustafas-MacBook-Pro raftexample % ./raftexample --id 1 --cluster http://127.0.0.1:12379 --port 12380

2023/06/01 10:38:28 replaying WAL of member 1
2023/06/01 10:38:28 loading WAL at term 0 and index 0
raft2023/06/01 10:38:28 INFO: 1 switched to configuration voters=()
raft2023/06/01 10:38:28 INFO: 1 became follower at term 2
raft2023/06/01 10:38:28 INFO: newRaft 1 [peers: [], term: 2, commit: 1, applied: 0, lastindex: 2, lastterm: 2]
raft2023/06/01 10:38:28 INFO: 1 switched to configuration voters=(1)
raft2023/06/01 10:38:29 INFO: 1 is starting a new election at term 2
raft2023/06/01 10:38:29 INFO: 1 became candidate at term 3
raft2023/06/01 10:38:29 INFO: 1 received MsgVoteResp from 1 at term 3
raft2023/06/01 10:38:29 INFO: 1 has received 1 MsgVoteResp votes and 0 vote rejections
raft2023/06/01 10:38:29 INFO: 1 became leader at term 3
raft2023/06/01 10:38:29 INFO: raft.node: 1 elected leader 1 at term 3

@Elbehery
Copy link
Member Author

Elbehery commented Jun 1, 2023

used goreman to run a cluster

mustafa@mustafas-MacBook-Pro raftexample % goreman start
10:40:12 raftexample1 | Starting raftexample1 on port 5000
10:40:12 raftexample3 | Starting raftexample3 on port 5200
10:40:12 raftexample2 | Starting raftexample2 on port 5100
10:40:12 raftexample2 | 2023/06/01 10:40:12 replaying WAL of member 2
10:40:12 raftexample3 | 2023/06/01 10:40:12 replaying WAL of member 3
10:40:12 raftexample1 | 2023/06/01 10:40:12 replaying WAL of member 1
10:40:12 raftexample1 | 2023/06/01 10:40:12 loading WAL at term 0 and index 0
10:40:12 raftexample1 | raft2023/06/01 10:40:12 INFO: 1 switched to configuration voters=()
10:40:12 raftexample1 | raft2023/06/01 10:40:12 INFO: 1 became follower at term 3
10:40:12 raftexample1 | raft2023/06/01 10:40:12 INFO: newRaft 1 [peers: [], term: 3, commit: 1, applied: 0, lastindex: 3, lastterm: 3]
10:40:12 raftexample1 | {"level":"info","msg":"starting remote peer","remote-peer-id":"2"}
10:40:12 raftexample1 | {"level":"info","msg":"started HTTP pipelining with remote peer","local-member-id":"1","remote-peer-id":"2"}
10:40:12 raftexample1 | {"level":"info","msg":"started stream writer with remote peer","local-member-id":"1","remote-peer-id":"2"}
10:40:12 raftexample1 | {"level":"info","msg":"started stream writer with remote peer","local-member-id":"1","remote-peer-id":"2"}
10:40:12 raftexample1 | {"level":"info","msg":"started remote peer","remote-peer-id":"2"}
10:40:12 raftexample1 | {"level":"info","msg":"started stream reader with remote peer","stream-reader-type":"stream MsgApp v2","local-member-id":"1","remote-peer-id":"2"}
10:40:12 raftexample1 | {"level":"info","msg":"added remote peer","local-member-id":"1","remote-peer-id":"2","remote-peer-urls":["http://127.0.0.1:22379"]}
10:40:12 raftexample1 | {"level":"info","msg":"starting remote peer","remote-peer-id":"3"}
10:40:12 raftexample1 | {"level":"info","msg":"started HTTP pipelining with remote peer","local-member-id":"1","remote-peer-id":"3"}
10:40:12 raftexample1 | {"level":"debug","msg":"dial stream reader","from":"1","to":"2","address":"http://127.0.0.1:22379/raft/stream/msgapp/1"}
10:40:12 raftexample1 | {"level":"info","msg":"started stream writer with remote peer","local-member-id":"1","remote-peer-id":"3"}
10:40:12 raftexample1 | {"level":"info","msg":"started stream writer with remote peer","local-member-id":"1","remote-peer-id":"3"}
10:40:12 raftexample1 | {"level":"info","msg":"started remote peer","remote-peer-id":"3"}
10:40:12 raftexample1 | {"level":"info","msg":"added remote peer","local-member-id":"1","remote-peer-id":"3","remote-peer-urls":["http://127.0.0.1:32379"]}
10:40:12 raftexample1 | raft2023/06/01 10:40:12 INFO: 1 switched to configuration voters=(1)
10:40:12 raftexample1 | {"level":"info","msg":"started stream reader with remote peer","stream-reader-type":"stream MsgApp v2","local-member-id":"1","remote-peer-id":"3"}
10:40:12 raftexample1 | {"level":"info","msg":"started stream reader with remote peer","stream-reader-type":"stream Message","local-member-id":"1","remote-peer-id":"2"}
10:40:12 raftexample1 | {"level":"debug","msg":"dial stream reader","from":"1","to":"2","address":"http://127.0.0.1:22379/raft/stream/message/1"}
10:40:12 raftexample1 | {"level":"debug","msg":"dial stream reader","from":"1","to":"3","address":"http://127.0.0.1:32379/raft/stream/msgapp/1"}
10:40:12 raftexample1 | {"level":"info","msg":"started stream reader with remote peer","stream-reader-type":"stream Message","local-member-id":"1","remote-peer-id":"3"}
10:40:12 raftexample1 | {"level":"debug","msg":"dial stream reader","from":"1","to":"3","address":"http://127.0.0.1:32379/raft/stream/message/1"}
10:40:12 raftexample1 | {"level":"debug","msg":"peer deactivated again","peer-id":"2","error":"failed to dial 2 on stream MsgApp v2 (dial tcp 127.0.0.1:22379: connect: connection refused)"}
10:40:12 raftexample1 | {"level":"debug","msg":"dial stream reader","from":"1","to":"2","address":"http://127.0.0.1:22379/raft/stream/msgapp/1"}
10:40:12 raftexample1 | {"level":"debug","msg":"peer deactivated again","peer-id":"2","error":"failed to dial 2 on stream MsgApp v2 (dial tcp 127.0.0.1:22379: connect: connection refused)"}
10:40:12 raftexample1 | {"level":"debug","msg":"peer deactivated again","peer-id":"3","error":"failed to dial 3 on stream MsgApp v2 (dial tcp 127.0.0.1:32379: connect: connection refused)"}
10:40:12 raftexample1 | {"level":"debug","msg":"dial stream reader","from":"1","to":"3","address":"http://127.0.0.1:32379/raft/stream/msgapp/1"}
10:40:12 raftexample1 | {"level":"debug","msg":"peer deactivated again","peer-id":"3","error":"failed to dial 3 on stream Message (dial tcp 127.0.0.1:32379: connect: connection refused)"}
10:40:12 raftexample1 | {"level":"debug","msg":"dial stream reader","from":"1","to":"3","address":"http://127.0.0.1:32379/raft/stream/message/1"}
10:40:12 raftexample1 | {"level":"debug","msg":"peer deactivated again","peer-id":"3","error":"failed to dial 3 on stream MsgApp v2 (dial tcp 127.0.0.1:32379: connect: connection refused)"}
10:40:12 raftexample1 | {"level":"debug","msg":"peer deactivated again","peer-id":"3","error":"failed to dial 3 on stream Message (dial tcp 127.0.0.1:32379: connect: connection refused)"}
10:40:12 raftexample1 | {"level":"debug","msg":"peer deactivated again","peer-id":"2","error":"failed to dial 2 on stream Message (dial tcp 127.0.0.1:22379: connect: connection refused)"}
10:40:12 raftexample1 | {"level":"debug","msg":"dial stream reader","from":"1","to":"2","address":"http://127.0.0.1:22379/raft/stream/message/1"}
10:40:12 raftexample1 | {"level":"debug","msg":"peer deactivated again","peer-id":"2","error":"failed to dial 2 on stream Message (dial tcp 127.0.0.1:22379: connect: connection refused)"}
10:40:12 raftexample1 | {"level":"debug","msg":"dial stream reader","from":"1","to":"2","address":"http://127.0.0.1:22379/raft/stream/msgapp/1"}
10:40:12 raftexample1 | {"level":"debug","msg":"dial stream reader","from":"1","to":"3","address":"http://127.0.0.1:32379/raft/stream/msgapp/1"}
10:40:12 raftexample1 | {"level":"debug","msg":"peer deactivated again","peer-id":"2","error":"failed to dial 2 on stream MsgApp v2 (dial tcp 127.0.0.1:22379: connect: connection refused)"}
10:40:12 raftexample1 | {"level":"debug","msg":"dial stream reader","from":"1","to":"3","address":"http://127.0.0.1:32379/raft/stream/message/1"}
10:40:12 raftexample1 | {"level":"debug","msg":"peer deactivated again","peer-id":"3","error":"failed to dial 3 on stream MsgApp v2 (dial tcp 127.0.0.1:32379: connect: connection refused)"}
10:40:12 raftexample1 | {"level":"debug","msg":"peer deactivated again","peer-id":"3","error":"failed to dial 3 on stream Message (dial tcp 127.0.0.1:32379: connect: connection refused)"}
10:40:12 raftexample1 | {"level":"debug","msg":"dial stream reader","from":"1","to":"2","address":"http://127.0.0.1:22379/raft/stream/message/1"}
10:40:12 raftexample1 | {"level":"debug","msg":"peer deactivated again","peer-id":"2","error":"failed to dial 2 on stream Message (dial tcp 127.0.0.1:22379: connect: connection refused)"}
10:40:12 raftexample3 | 2023/06/01 10:40:12 loading WAL at term 0 and index 0
10:40:12 raftexample3 | raft2023/06/01 10:40:12 INFO: 3 switched to configuration voters=()
10:40:12 raftexample3 | raft2023/06/01 10:40:12 INFO: 3 became follower at term 0
10:40:12 raftexample3 | raft2023/06/01 10:40:12 INFO: newRaft 3 [peers: [], term: 0, commit: 0, applied: 0, lastindex: 0, lastterm: 0]
10:40:12 raftexample3 | raft2023/06/01 10:40:12 INFO: 3 became follower at term 1
10:40:12 raftexample3 | raft2023/06/01 10:40:12 INFO: 3 switched to configuration voters=(1)
10:40:12 raftexample3 | raft2023/06/01 10:40:12 INFO: 3 switched to configuration voters=(1 2)
10:40:12 raftexample3 | raft2023/06/01 10:40:12 INFO: 3 switched to configuration voters=(1 2 3)
10:40:12 raftexample3 | {"level":"info","msg":"starting remote peer","remote-peer-id":"1"}
10:40:12 raftexample3 | {"level":"info","msg":"started HTTP pipelining with remote peer","local-member-id":"3","remote-peer-id":"1"}
10:40:12 raftexample3 | {"level":"info","msg":"started stream writer with remote peer","local-member-id":"3","remote-peer-id":"1"}
10:40:12 raftexample3 | {"level":"info","msg":"started remote peer","remote-peer-id":"1"}
10:40:12 raftexample3 | {"level":"info","msg":"added remote peer","local-member-id":"3","remote-peer-id":"1","remote-peer-urls":["http://127.0.0.1:12379"]}
10:40:12 raftexample3 | {"level":"info","msg":"starting remote peer","remote-peer-id":"2"}
10:40:12 raftexample3 | {"level":"info","msg":"started HTTP pipelining with remote peer","local-member-id":"3","remote-peer-id":"2"}
10:40:12 raftexample3 | {"level":"info","msg":"started stream writer with remote peer","local-member-id":"3","remote-peer-id":"2"}
10:40:12 raftexample3 | {"level":"info","msg":"started stream writer with remote peer","local-member-id":"3","remote-peer-id":"1"}
10:40:12 raftexample3 | {"level":"info","msg":"started stream reader with remote peer","stream-reader-type":"stream Message","local-member-id":"3","remote-peer-id":"1"}
10:40:12 raftexample3 | {"level":"info","msg":"started stream reader with remote peer","stream-reader-type":"stream MsgApp v2","local-member-id":"3","remote-peer-id":"1"}
10:40:12 raftexample3 | {"level":"info","msg":"started stream writer with remote peer","local-member-id":"3","remote-peer-id":"2"}
10:40:12 raftexample3 | {"level":"debug","msg":"dial stream reader","from":"3","to":"1","address":"http://127.0.0.1:12379/raft/stream/msgapp/3"}
10:40:12 raftexample3 | {"level":"debug","msg":"dial stream reader","from":"3","to":"1","address":"http://127.0.0.1:12379/raft/stream/message/3"}
10:40:12 raftexample3 | {"level":"info","msg":"started remote peer","remote-peer-id":"2"}
10:40:12 raftexample3 | {"level":"info","msg":"started stream reader with remote peer","stream-reader-type":"stream MsgApp v2","local-member-id":"3","remote-peer-id":"2"}
10:40:12 raftexample3 | {"level":"debug","msg":"dial stream reader","from":"3","to":"2","address":"http://127.0.0.1:22379/raft/stream/msgapp/3"}
10:40:12 raftexample3 | {"level":"info","msg":"started stream reader with remote peer","stream-reader-type":"stream Message","local-member-id":"3","remote-peer-id":"2"}
10:40:12 raftexample3 | {"level":"debug","msg":"dial stream reader","from":"3","to":"2","address":"http://127.0.0.1:22379/raft/stream/message/3"}
10:40:12 raftexample3 | {"level":"info","msg":"added remote peer","local-member-id":"3","remote-peer-id":"2","remote-peer-urls":["http://127.0.0.1:22379"]}
10:40:12 raftexample3 | {"level":"debug","msg":"peer deactivated again","peer-id":"2","error":"failed to dial 2 on stream MsgApp v2 (dial tcp 127.0.0.1:22379: connect: connection refused)"}
10:40:12 raftexample3 | {"level":"debug","msg":"dial stream reader","from":"3","to":"2","address":"http://127.0.0.1:22379/raft/stream/msgapp/3"}
10:40:12 raftexample3 | {"level":"debug","msg":"peer deactivated again","peer-id":"2","error":"failed to dial 2 on stream Message (dial tcp 127.0.0.1:22379: connect: connection refused)"}
10:40:12 raftexample3 | {"level":"debug","msg":"dial stream reader","from":"3","to":"2","address":"http://127.0.0.1:22379/raft/stream/message/3"}
10:40:12 raftexample3 | {"level":"debug","msg":"peer deactivated again","peer-id":"2","error":"failed to dial 2 on stream MsgApp v2 (dial tcp 127.0.0.1:22379: connect: connection refused)"}
10:40:12 raftexample3 | {"level":"debug","msg":"peer deactivated again","peer-id":"2","error":"failed to dial 2 on stream Message (dial tcp 127.0.0.1:22379: connect: connection refused)"}
10:40:12 raftexample1 | {"level":"info","msg":"set message encoder","from":"1","to":"3","stream-type":"stream MsgApp v2"}
10:40:12 raftexample1 | {"level":"info","msg":"peer became active","peer-id":"3"}
10:40:12 raftexample1 | {"level":"info","msg":"set message encoder","from":"1","to":"3","stream-type":"stream Message"}
10:40:12 raftexample1 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-writer-type":"stream MsgApp v2","local-member-id":"1","remote-peer-id":"3"}
10:40:12 raftexample1 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-writer-type":"stream Message","local-member-id":"1","remote-peer-id":"3"}
10:40:12 raftexample3 | {"level":"info","msg":"peer became active","peer-id":"1"}
10:40:12 raftexample3 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-reader-type":"stream Message","local-member-id":"3","remote-peer-id":"1"}
10:40:12 raftexample3 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-reader-type":"stream MsgApp v2","local-member-id":"3","remote-peer-id":"1"}
10:40:12 raftexample2 | 2023/06/01 10:40:12 loading WAL at term 0 and index 0
10:40:12 raftexample2 | raft2023/06/01 10:40:12 INFO: 2 switched to configuration voters=()
10:40:12 raftexample2 | raft2023/06/01 10:40:12 INFO: 2 became follower at term 0
10:40:12 raftexample2 | raft2023/06/01 10:40:12 INFO: newRaft 2 [peers: [], term: 0, commit: 0, applied: 0, lastindex: 0, lastterm: 0]
10:40:12 raftexample2 | raft2023/06/01 10:40:12 INFO: 2 became follower at term 1
10:40:12 raftexample2 | raft2023/06/01 10:40:12 INFO: 2 switched to configuration voters=(1)
10:40:12 raftexample2 | raft2023/06/01 10:40:12 INFO: 2 switched to configuration voters=(1 2)
10:40:12 raftexample2 | raft2023/06/01 10:40:12 INFO: 2 switched to configuration voters=(1 2 3)
10:40:12 raftexample2 | {"level":"info","msg":"starting remote peer","remote-peer-id":"1"}
10:40:12 raftexample2 | {"level":"info","msg":"started HTTP pipelining with remote peer","local-member-id":"2","remote-peer-id":"1"}
10:40:12 raftexample2 | {"level":"info","msg":"started stream writer with remote peer","local-member-id":"2","remote-peer-id":"1"}
10:40:12 raftexample2 | {"level":"info","msg":"started stream writer with remote peer","local-member-id":"2","remote-peer-id":"1"}
10:40:12 raftexample2 | {"level":"info","msg":"started remote peer","remote-peer-id":"1"}
10:40:12 raftexample2 | {"level":"info","msg":"started stream reader with remote peer","stream-reader-type":"stream MsgApp v2","local-member-id":"2","remote-peer-id":"1"}
10:40:12 raftexample2 | {"level":"debug","msg":"dial stream reader","from":"2","to":"1","address":"http://127.0.0.1:12379/raft/stream/msgapp/2"}
10:40:12 raftexample2 | {"level":"info","msg":"added remote peer","local-member-id":"2","remote-peer-id":"1","remote-peer-urls":["http://127.0.0.1:12379"]}
10:40:12 raftexample2 | {"level":"info","msg":"starting remote peer","remote-peer-id":"3"}
10:40:12 raftexample2 | {"level":"info","msg":"started stream reader with remote peer","stream-reader-type":"stream Message","local-member-id":"2","remote-peer-id":"1"}
10:40:12 raftexample2 | {"level":"debug","msg":"dial stream reader","from":"2","to":"1","address":"http://127.0.0.1:12379/raft/stream/message/2"}
10:40:12 raftexample2 | {"level":"info","msg":"started HTTP pipelining with remote peer","local-member-id":"2","remote-peer-id":"3"}
10:40:12 raftexample2 | {"level":"info","msg":"started stream writer with remote peer","local-member-id":"2","remote-peer-id":"3"}
10:40:12 raftexample2 | {"level":"info","msg":"started stream writer with remote peer","local-member-id":"2","remote-peer-id":"3"}
10:40:12 raftexample1 | {"level":"info","msg":"set message encoder","from":"1","to":"2","stream-type":"stream MsgApp v2"}
10:40:12 raftexample1 | {"level":"info","msg":"peer became active","peer-id":"2"}
10:40:12 raftexample1 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-writer-type":"stream MsgApp v2","local-member-id":"1","remote-peer-id":"2"}
10:40:12 raftexample1 | {"level":"info","msg":"set message encoder","from":"1","to":"2","stream-type":"stream Message"}
10:40:12 raftexample1 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-writer-type":"stream Message","local-member-id":"1","remote-peer-id":"2"}
10:40:12 raftexample2 | {"level":"info","msg":"peer became active","peer-id":"1"}
10:40:12 raftexample2 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-reader-type":"stream MsgApp v2","local-member-id":"2","remote-peer-id":"1"}
10:40:12 raftexample2 | {"level":"info","msg":"started remote peer","remote-peer-id":"3"}
10:40:12 raftexample2 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-reader-type":"stream Message","local-member-id":"2","remote-peer-id":"1"}
10:40:12 raftexample2 | {"level":"info","msg":"added remote peer","local-member-id":"2","remote-peer-id":"3","remote-peer-urls":["http://127.0.0.1:32379"]}
10:40:12 raftexample2 | {"level":"info","msg":"started stream reader with remote peer","stream-reader-type":"stream MsgApp v2","local-member-id":"2","remote-peer-id":"3"}
10:40:12 raftexample2 | {"level":"debug","msg":"dial stream reader","from":"2","to":"3","address":"http://127.0.0.1:32379/raft/stream/msgapp/2"}
10:40:12 raftexample2 | {"level":"info","msg":"started stream reader with remote peer","stream-reader-type":"stream Message","local-member-id":"2","remote-peer-id":"3"}
10:40:12 raftexample2 | {"level":"debug","msg":"dial stream reader","from":"2","to":"3","address":"http://127.0.0.1:32379/raft/stream/message/2"}
10:40:12 raftexample3 | {"level":"info","msg":"set message encoder","from":"3","to":"2","stream-type":"stream Message"}
10:40:12 raftexample3 | {"level":"info","msg":"peer became active","peer-id":"2"}
10:40:12 raftexample3 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-writer-type":"stream Message","local-member-id":"3","remote-peer-id":"2"}
10:40:12 raftexample3 | {"level":"info","msg":"set message encoder","from":"3","to":"2","stream-type":"stream MsgApp v2"}
10:40:12 raftexample3 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-writer-type":"stream MsgApp v2","local-member-id":"3","remote-peer-id":"2"}
10:40:12 raftexample2 | {"level":"info","msg":"peer became active","peer-id":"3"}
10:40:12 raftexample2 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-reader-type":"stream MsgApp v2","local-member-id":"2","remote-peer-id":"3"}
10:40:12 raftexample2 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-reader-type":"stream Message","local-member-id":"2","remote-peer-id":"3"}
10:40:12 raftexample3 | raft2023/06/01 10:40:12 INFO: 3 switched to configuration voters=(1 2 3)
10:40:12 raftexample3 | raft2023/06/01 10:40:12 INFO: 3 switched to configuration voters=(1 2 3)
10:40:12 raftexample3 | raft2023/06/01 10:40:12 INFO: 3 switched to configuration voters=(1 2 3)
10:40:12 raftexample1 | {"level":"debug","msg":"dial stream reader","from":"1","to":"2","address":"http://127.0.0.1:22379/raft/stream/msgapp/1"}
10:40:12 raftexample1 | {"level":"debug","msg":"dial stream reader","from":"1","to":"3","address":"http://127.0.0.1:32379/raft/stream/message/1"}
10:40:12 raftexample1 | {"level":"debug","msg":"dial stream reader","from":"1","to":"3","address":"http://127.0.0.1:32379/raft/stream/msgapp/1"}
10:40:12 raftexample1 | {"level":"debug","msg":"dial stream reader","from":"1","to":"2","address":"http://127.0.0.1:22379/raft/stream/message/1"}
10:40:12 raftexample1 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-reader-type":"stream MsgApp v2","local-member-id":"1","remote-peer-id":"2"}
10:40:12 raftexample2 | {"level":"info","msg":"set message encoder","from":"2","to":"1","stream-type":"stream MsgApp v2"}
10:40:12 raftexample2 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-writer-type":"stream MsgApp v2","local-member-id":"2","remote-peer-id":"1"}
10:40:12 raftexample3 | {"level":"info","msg":"set message encoder","from":"3","to":"1","stream-type":"stream Message"}
10:40:12 raftexample3 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-writer-type":"stream Message","local-member-id":"3","remote-peer-id":"1"}
10:40:12 raftexample1 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-reader-type":"stream Message","local-member-id":"1","remote-peer-id":"3"}
10:40:12 raftexample1 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-reader-type":"stream MsgApp v2","local-member-id":"1","remote-peer-id":"3"}
10:40:12 raftexample3 | {"level":"info","msg":"set message encoder","from":"3","to":"1","stream-type":"stream MsgApp v2"}
10:40:12 raftexample3 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-writer-type":"stream MsgApp v2","local-member-id":"3","remote-peer-id":"1"}
10:40:12 raftexample2 | {"level":"info","msg":"set message encoder","from":"2","to":"1","stream-type":"stream Message"}
10:40:12 raftexample2 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-writer-type":"stream Message","local-member-id":"2","remote-peer-id":"1"}
10:40:12 raftexample1 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-reader-type":"stream Message","local-member-id":"1","remote-peer-id":"2"}
10:40:12 raftexample2 | raft2023/06/01 10:40:12 INFO: 2 switched to configuration voters=(1 2 3)
10:40:12 raftexample2 | raft2023/06/01 10:40:12 INFO: 2 switched to configuration voters=(1 2 3)
10:40:12 raftexample2 | raft2023/06/01 10:40:12 INFO: 2 switched to configuration voters=(1 2 3)
10:40:12 raftexample3 | {"level":"debug","msg":"dial stream reader","from":"3","to":"2","address":"http://127.0.0.1:22379/raft/stream/message/3"}
10:40:12 raftexample3 | {"level":"debug","msg":"dial stream reader","from":"3","to":"2","address":"http://127.0.0.1:22379/raft/stream/msgapp/3"}
10:40:12 raftexample3 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-reader-type":"stream MsgApp v2","local-member-id":"3","remote-peer-id":"2"}
10:40:12 raftexample2 | {"level":"info","msg":"set message encoder","from":"2","to":"3","stream-type":"stream MsgApp v2"}
10:40:12 raftexample2 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-writer-type":"stream MsgApp v2","local-member-id":"2","remote-peer-id":"3"}
10:40:12 raftexample2 | {"level":"info","msg":"set message encoder","from":"2","to":"3","stream-type":"stream Message"}
10:40:12 raftexample2 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-writer-type":"stream Message","local-member-id":"2","remote-peer-id":"3"}
10:40:12 raftexample3 | {"level":"info","msg":"established TCP streaming connection with remote peer","stream-reader-type":"stream Message","local-member-id":"3","remote-peer-id":"2"}
10:40:13 raftexample3 | raft2023/06/01 10:40:13 INFO: 3 is starting a new election at term 1
10:40:13 raftexample3 | raft2023/06/01 10:40:13 INFO: 3 became candidate at term 2
10:40:13 raftexample3 | raft2023/06/01 10:40:13 INFO: 3 [logterm: 1, index: 3] sent MsgVote request to 1 at term 2
10:40:13 raftexample3 | raft2023/06/01 10:40:13 INFO: 3 [logterm: 1, index: 3] sent MsgVote request to 2 at term 2
10:40:13 raftexample3 | raft2023/06/01 10:40:13 INFO: 3 received MsgVoteResp from 3 at term 2
10:40:13 raftexample3 | raft2023/06/01 10:40:13 INFO: 3 has received 1 MsgVoteResp votes and 0 vote rejections
10:40:13 raftexample2 | raft2023/06/01 10:40:13 INFO: 2 is starting a new election at term 1
10:40:13 raftexample2 | raft2023/06/01 10:40:13 INFO: 2 became candidate at term 2
10:40:13 raftexample1 | raft2023/06/01 10:40:13 INFO: 1 [term: 3] ignored a MsgVote message with lower term from 3 [term: 2]
10:40:13 raftexample2 | raft2023/06/01 10:40:13 INFO: 2 [logterm: 1, index: 3] sent MsgVote request to 1 at term 2
10:40:13 raftexample2 | raft2023/06/01 10:40:13 INFO: 2 [logterm: 1, index: 3] sent MsgVote request to 3 at term 2
10:40:13 raftexample2 | raft2023/06/01 10:40:13 INFO: 2 [logterm: 1, index: 3, vote: 2] rejected MsgVote from 3 [logterm: 1, index: 3] at term 2
10:40:13 raftexample2 | raft2023/06/01 10:40:13 INFO: 2 received MsgVoteResp from 2 at term 2
10:40:13 raftexample2 | raft2023/06/01 10:40:13 INFO: 2 has received 1 MsgVoteResp votes and 0 vote rejections
10:40:13 raftexample1 | raft2023/06/01 10:40:13 INFO: 1 [term: 3] ignored a MsgVote message with lower term from 2 [term: 2]
10:40:13 raftexample3 | raft2023/06/01 10:40:13 INFO: 3 [logterm: 1, index: 3, vote: 3] rejected MsgVote from 2 [logterm: 1, index: 3] at term 2
10:40:13 raftexample3 | raft2023/06/01 10:40:13 INFO: 3 received MsgVoteResp rejection from 2 at term 2
10:40:13 raftexample3 | raft2023/06/01 10:40:13 INFO: 3 has received 1 MsgVoteResp votes and 1 vote rejections
10:40:13 raftexample2 | raft2023/06/01 10:40:13 INFO: 2 received MsgVoteResp rejection from 3 at term 2
10:40:13 raftexample2 | raft2023/06/01 10:40:13 INFO: 2 has received 1 MsgVoteResp votes and 1 vote rejections
10:40:13 raftexample1 | raft2023/06/01 10:40:13 INFO: 1 is starting a new election at term 3
10:40:13 raftexample1 | raft2023/06/01 10:40:13 INFO: 1 became candidate at term 4
10:40:13 raftexample1 | raft2023/06/01 10:40:13 INFO: 1 received MsgVoteResp from 1 at term 4
10:40:13 raftexample1 | raft2023/06/01 10:40:13 INFO: 1 has received 1 MsgVoteResp votes and 0 vote rejections
10:40:13 raftexample1 | raft2023/06/01 10:40:13 INFO: 1 became leader at term 4
10:40:13 raftexample1 | raft2023/06/01 10:40:13 INFO: raft.node: 1 elected leader 1 at term 4
10:40:14 raftexample2 | raft2023/06/01 10:40:14 INFO: 2 is starting a new election at term 2
10:40:14 raftexample2 | raft2023/06/01 10:40:14 INFO: 2 became candidate at term 3
10:40:14 raftexample2 | raft2023/06/01 10:40:14 INFO: 2 [logterm: 1, index: 3] sent MsgVote request to 1 at term 3
10:40:14 raftexample2 | raft2023/06/01 10:40:14 INFO: 2 [logterm: 1, index: 3] sent MsgVote request to 3 at term 3
10:40:15 raftexample2 | raft2023/06/01 10:40:15 INFO: 2 received MsgVoteResp from 2 at term 3
10:40:15 raftexample2 | raft2023/06/01 10:40:15 INFO: 2 has received 1 MsgVoteResp votes and 0 vote rejections
10:40:15 raftexample3 | raft2023/06/01 10:40:15 INFO: 3 [term: 2] received a MsgVote message with higher term from 2 [term: 3]
10:40:15 raftexample3 | raft2023/06/01 10:40:15 INFO: 3 became follower at term 3
10:40:15 raftexample3 | raft2023/06/01 10:40:15 INFO: 3 [logterm: 1, index: 3, vote: 0] cast MsgVote for 2 [logterm: 1, index: 3] at term 3
10:40:15 raftexample1 | raft2023/06/01 10:40:15 INFO: 1 [term: 4] ignored a MsgVote message with lower term from 2 [term: 3]
10:40:15 raftexample2 | raft2023/06/01 10:40:15 INFO: 2 received MsgVoteResp from 3 at term 3
10:40:15 raftexample2 | raft2023/06/01 10:40:15 INFO: 2 has received 2 MsgVoteResp votes and 0 vote rejections
10:40:15 raftexample2 | raft2023/06/01 10:40:15 INFO: 2 became leader at term 3
10:40:15 raftexample2 | raft2023/06/01 10:40:15 INFO: raft.node: 2 elected leader 2 at term 3
10:40:15 raftexample1 | raft2023/06/01 10:40:15 INFO: 1 [term: 4] ignored a MsgApp message with lower term from 2 [term: 3]
10:40:15 raftexample3 | raft2023/06/01 10:40:15 INFO: raft.node: 3 elected leader 2 at term 3
10:40:15 raftexample1 | raft2023/06/01 10:40:15 INFO: 1 [term: 4] ignored a MsgHeartbeat message with lower term from 2 [term: 3]
10:40:15 raftexample1 | raft2023/06/01 10:40:15 INFO: 1 [term: 4] ignored a MsgHeartbeat message with lower term from 2 [term: 3]
10:40:15 raftexample1 | raft2023/06/01 10:40:15 INFO: 1 [term: 4] ignored a MsgHeartbeat message with lower term from 2 [term: 3]
10:40:15 raftexample1 | raft2023/06/01 10:40:15 INFO: 1 [term: 4] ignored a MsgHeartbeat message with lower term from 2 [term: 3]
10:40:15 raftexample1 | raft2023/06/01 10:40:15 INFO: 1 [term: 4] ignored a MsgHeartbeat message with lower term from 2 [term: 3]
10:40:15 raftexample1 | raft2023/06/01 10:40:15 INFO: 1 [term: 4] ignored a MsgHeartbeat message with lower term from 2 [term: 3]
10:40:15 raftexample1 | raft2023/06/01 10:40:15 INFO: 1 [term: 4] ignored a MsgHeartbeat message with lower term from 2 [term: 3]
10:40:15 raftexample1 | raft2023/06/01 10:40:15 INFO: 1 [term: 4] ignored a MsgHeartbeat message with lower term from 2 [term: 3]
10:40:15 raftexample1 | raft2023/06/01 10:40:15 INFO: 1 [term: 4] ignored a MsgHeartbeat message with lower term from 2 [term: 3]
10:40:15 raftexample1 | raft2023/06/01 10:40:15 INFO: 1 [term: 4] ignored a MsgHeartbeat message with lower term from 2 [term: 3]
10:40:16 raftexample1 | raft2023/06/01 10:40:16 INFO: 1 [term: 4] ignored a MsgHeartbeat message with lower term from 2 [term: 3]
10:40:16 raftexample1 | raft2023/06/01 10:40:16 INFO: 1 [term: 4] ignored a MsgHeartbeat message with lower term from 2 [term: 3]
10:40:16 raftexample1 | raft2023/06/01 10:40:16 INFO: 1 [term: 4] ignored a MsgHeartbeat message with lower term from 2 [term: 3]
10:40:16 raftexample1 | raft2023/06/01 10:40:16 INFO: 1 [term: 4] ignored a MsgHeartbeat message with lower term from 2 [term: 3]
10:40:16 raftexample1 | raft2023/06/01 10:40:16 INFO: 1 [term: 4] ignored a MsgHeartbeat message with lower term from 2 [term: 3]
10:40:16 raftexample1 | raft2023/06/01 10:40:16 INFO: 1 [term: 4] 

@Elbehery Elbehery force-pushed the raft-example branch 2 times, most recently from ed5deb5 to da6bac1 Compare June 1, 2023 09:12
@Elbehery Elbehery changed the title WIP: add selfcontained raftexample add selfcontained raftexample Jun 1, 2023
Signed-off-by: Mustafa Elbehery <[email protected]>

Signed-off-by: Mustafa Elbehery <[email protected]>
Signed-off-by: Mustafa Elbehery <[email protected]>
Signed-off-by: Mustafa Elbehery <[email protected]>

Signed-off-by: Mustafa Elbehery <[email protected]>
Signed-off-by: Mustafa Elbehery <[email protected]>

Signed-off-by: Mustafa Elbehery <[email protected]>
Signed-off-by: Mustafa Elbehery <[email protected]>
 Signed-off-by: Mustafa Elbehery <[email protected]>

Signed-off-by: Mustafa Elbehery <[email protected]>
 Signed-off-by: Mustafa Elbehery <[email protected]>

Signed-off-by: Mustafa Elbehery <[email protected]>
Signed-off-by: Mustafa Elbehery <[email protected]>

Signed-off-by: Mustafa Elbehery <[email protected]>
Signed-off-by: Mustafa Elbehery <[email protected]>
@Elbehery
Copy link
Member Author

@ptabor @ahrtr @serathius Hello ✋🏽

I have resolved the conflicts, would you kindly review ?

@ahrtr
Copy link
Member

ahrtr commented Jul 10, 2023

Please read #2 (comment), thx

@Elbehery
Copy link
Member Author

Thanks @ahrtr for your review

@mhagger Hello ✋🏽

Shall we refurbish etcd-io/etcd#15471 and remove any etcd related context ?

Also I think this is more appropriate to be created against https://github.com/etcd-io/raft, please correct me if I am wrong :)

@mhagger
Copy link

mhagger commented Jul 24, 2023

@Elbehery: In Elbehery#1 I created a new version of etcd-io/etcd#15471 on top of this PR. I've got another patch series that does more work on top of Elbehery#1, but I haven't created a PR yet because PRs on top of PRs on top of a PR in a fork against the upstream repository is starting to get pretty unwieldy.

I think that it would make sense to continue working incrementally on top of this branch until we have replaced all of the extraneous etcd code, and only then get final review and merge it into the main branch of etcd-io/raft. But it's going to take a lot of work, so it will only be practical if intermediate changes can get merged into this PR as we go. Do you have the capacity to work on this?

@Elbehery Elbehery mentioned this pull request Feb 5, 2024
@Elbehery
Copy link
Member Author

Elbehery commented Feb 5, 2024

replaced with #153

@Elbehery Elbehery closed this Feb 5, 2024
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.

Implement a self-contained raft example
3 participants