Merge pull request #151 from xiangli-cmu/refactor_proto

WIP Refactor proto
Merge pull request #162 from xiangli-cmu/bug_fix

fix peer ae.response bug
Merge pull request #163 from xiangli-cmu/bug_fix

p.server instead of server
Merge pull request #164 from xiangli-cmu/bug_fix

bug fix
docs(server): add a comment explaining the NOPCommand
Merge pull request #165 from philips/add-comment-on-nop-command

docs(server): add a comment explaining the NOPCommand
fix(*.go): rename HeartbeatTimeout to HeartbeatInterval

While re-reading the etcd tuning guide I realized that perhaps it is a
bit of a misnomer to call this a "Timeout" since unlike the "Election
Timeout" there is no immediate consequence of it being missed.

Perhaps naming it interval would be better?
leader must stop all heartbeat routines before stepdown and truncate its log
Merge pull request #167 from xiangli-cmu/dev

more safety
Merge pull request #166 from philips/change-heartbeatTimeout-to-heartbeatInterval

fix(*.go): rename HeartbeatTimeout to HeartbeatInterval
merge with master
add conditions for state for loops
drop unused field in log
Merge pull request #170 from xiangli-cmu/cleanup_loops

Cleanup loops
refactor(peer): cleanup of some if boolean logic

I always get confused reading this code. Lets make it more clear, if
flush then flush; else don't flush.
fix(log): use Rlock in getEntriesAfter

getEntriesAfter only reads the log and doesn't make any motifications.
Using an RLock is safe here.
fix(server): release the server lock while stopping peers

Avoid a deadlock situation:

- Server is changing the term via setCurrentTerm() which also holds
  the server.Lock

- Peer is in the flush() routine and attempts to takes the server.Lock
  via p.server.Term() in sendAppendEntriesRequest()

The peer cannot take the lock because it is held by the server. The
server is waiting for the peer to shut down. Progress stops.
Merge pull request #175 from philips/cleanup-locks-in-peer

Cleanup locks in peer
Add EventDispatcher.RemoveEventListener().
Dispatch commit event.