mgkanani / raft Goto Github PK
View Code? Open in Web Editor NEWraft implementation
raft implementation
Approaches I have used to perform this are listed below:-
There are 5 servers, i have used in configuration.
1)Server-1 and Server-2 are listening on 127.0.0.1 and Server-3,S-4 and Server-5 are listening on 10.99.99.137. Then used firewall iptables
to stop communicating these two networks, by filtering based on ipaddr of src and dest. But this did not work because the OS knows that Both are lying within it, so when S-1(/ S-2) connects to S-3(/S-4/S-5) then it will use socket with address-port 10.99.99.137:xxxxx. This i have found using netstat
command. I also stopped the communication between 2-interfaces (eth0
and lo
) but this also failed due to same reason.
2)I tried to eth1(/wlan0)
instead of lo
, but this also failed due to above result.
3)Then I ran this on two different machines. and just remove LAN-cable, after some time attached it(Actually this seems obvious for this experiment but i have installed zmq4 on only one machine so at last i have to install it on other).
During this experiments i found some bugs like Servers timedout every time though they were not failed to listen
and
Use of isLeader() to decide whether leader already exists or not , This will works perfectly(unnoticed) for all servers are running under one process but this never happen in real
.
I have solved these bugs.
In 3rd setup,filtering usingiptables
undoubtedly works perfectly but removing cable is more easier to do.
Thank you.
-Mahendra
:-D
This is a review for assignment 3.
I loved the fact that you tested on multiple machines and attempted to induce all kinds of faults. Good job.
Back to basics though. By "testing should be automated", I mean "automatic verification". It is one thing to induce faults, but equally important to verify automatically whether the code is running as expected; that means doing something with the testing.T parameter in TestRaft(). This is usually tougher than the code being tested.
Servers and testing should always run silent. Logging should be done under an if-clause, and turned on only when debugging or monitoring something specific.
raft.Start() -- A service should start on its own; it shouldn't require prodding from a test or some external bit of code to start.
In Start(), a more compact replacement for the if-then-else- logic is
switch serve.ServState.my_state {
case follower: ...
case leader: ...
case candidate: ...
}
I'm using consts follower, leader, candidate instead of 0, 1, 2
I'm not sure if splitting ServState into a separate struct buys you much. Also, what is the purpose of RaftType?
isLeader(). A more compact version is return raft.Leader > 0
.
Is the time.Sleep() at line 180 a hook for the test framework to induce faults? If so, the name of the channel should be more appropriate; not 'ch'.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.