32 Commits

Author SHA1 Message Date
Ben Darnell
64d9bcabf1 Add Storage.Term() method and hide the first entry from other methods.
The first entry in the log is a dummy which is used for matchTerm
but may not have an actual payload. This change permits Storage
implementations to treat this term value specially instead of
storing it as a dummy Entry.

Storage.FirstIndex() no longer includes the term-only entry.

This reverses a recent decision to create entry zero as initially
unstable; Storage implementations are now required to make
Term(0) == 0 and the first unstable entry is now index 1.
stableTo(0) is no longer allowed.
2014-11-17 16:54:12 -05:00
Ben Darnell
45e96be605 raft: PR feedback.
Removed Get prefix in method names, added assertions and fixed comments.
2014-11-14 13:53:42 -05:00
Ben Darnell
b29c512f50 Merge remote-tracking branch 'coreos/master' into log-storage-interface
* coreos/master: (27 commits)
  pkg/wait: move wait to pkg/wait
  etcdserver: do not add/remove/update local member to/from sender hub
  etcdserver: not record attributes when add member
  raft: add a test for proposeConfChange
  raft: block Stop() on n.done, support idempotency
  raft: add a test for node proposal
  integration: add increase cluster size test
  integration: remove unnecessary t.Testing argument
  raft: stop the node synchronously
  integration: fix test to propagate NewServer errors
  etcdserver: move peer URLs check to config
  etcdserver: ensure initial-advertise-peer-urls match initial-cluster
  raft: add a test for node.Tick
  raft: add comment string for TestNodeStart
  etcdserver: use member instead of node at etcd level
  raft: nodes return sorted ids
  raft: update unstable when calling stableTo with 0
  *: support updating advertise-peer-url Users might want to update the peerurl of the etcd member in several cases. For example, if the IP address of the physical machine etcd running on is changed, user need to update the adversite-pee-rurl accordingly. This commit makes etcd support updating the advertise-peer-url of its members.
  transport: create a tls listener only if the tlsInfo is not empty and the scheme is HTTPS
  etcdserver: use member pointer for all tests
  ...

Conflicts:
	etcdserver/server.go
	raft/log.go
	raft/log_test.go
	raft/node.go
2014-11-13 14:21:09 -05:00
Ben Darnell
147fd614ce The initial term=0 log entry is now initially unstable.
This entry is now persisted through the normal flow instead of appearing
in the stored log at creation time.  This is how things worked before
the Storage interface was introduced. (see coreos/etcd#1689)
2014-11-12 18:24:16 -05:00
Ben Darnell
76a3de9a33 Require a non-nil Storage parameter in newLog.
Callers must in general have a reference to their Storage objects to
transfer entries from Ready to Storage, so it doesn't make sense to
create a hidden Storage for them.

By explicitly creating Storage objects in tests we can remove a
few casts of raftLog's storage field.
2014-11-12 16:38:50 -05:00
Yicheng Qin
7dba92dd53 raft: update unstable when calling stableTo with 0
It should update unstable in this case because it may happen that raft
only writes entry 0 into stable storage.
2014-11-11 17:20:31 -08:00
Ben Darnell
25b6590547 raft: introduce log storage interface.
This change splits the raftLog.entries array into an in-memory
"unstable" list and a pluggable interface for retrieving entries that
have been persisted to disk. An in-memory implementation of this
interface is provided which behaves the same as the old version;
in a future commit etcdserver could replace the MemoryStorage with
one backed by the WAL.
2014-11-10 17:40:39 -05:00
Ben Darnell
21987c8701 raft: remove raftLog.resetUnstable and resetNextEnts
These methods are no longer used outside of tests and are redundant with
the new stableTo and appliedTo methods.
2014-11-06 17:18:00 -05:00
Xiang Li
738da2b3fa raft: fix a incorrect in testMaybeAppend 2014-10-29 14:57:39 -07:00
Xiang Li
14f4163e41 raft: add several test cases for testMaybeAppend 2014-10-29 14:35:13 -07:00
Xiang Li
ad1718a3e5 raft: add a test case for testLogMaybeAppend 2014-10-29 11:44:18 -07:00
Xiang Li
c6873c1eab raft: add tests for maybeappend 2014-10-28 15:07:49 -07:00
Xiang Li
460d6490ba raft: address issues in comments 2014-10-27 14:20:42 -07:00
Xiang Li
94f701cf95 raft: refactor isUpToDate and add a test 2014-10-25 20:34:14 -07:00
Xiang Li
90f26e4a56 raft: add test for findConflict 2014-10-25 18:58:11 -07:00
Jonathan Boulle
7a4d42166b *: add license header to all source files 2014-10-17 15:41:22 -07:00
Xiang Li
af5b8c6c44 raft: int64 -> uint64 2014-10-09 14:26:43 +08:00
Yicheng Qin
d31443f5a3 raftLog: compact applied entries only
compact MUST happen on entries that have been applied, or
1. it may screw up the log by setting wrong commitIndex
2. discard unapplied entries
2014-09-12 11:34:08 -07:00
Blake Mizerany
e8e588c67b raft: move protobufs into raftpb 2014-09-03 09:20:17 -07:00
Blake Mizerany
134a962222 raft: move raft2 to raft 2014-09-03 09:20:14 -07:00
Blake Mizerany
0453d09af6 raft: moved into new raft 2014-09-03 09:20:11 -07:00
Blake Mizerany
f03c3bce05 raft: seperate dequeuing from slicing 2014-09-03 09:20:11 -07:00
Yicheng Qin
ba63cf666d raft: add recover 2014-09-03 09:20:02 -07:00
Xiang Li
54b4f52e48 raft: add index to entry 2014-09-03 09:20:01 -07:00
Yicheng Qin
e850c644da raft: return offset for unstableEnts 2014-09-03 09:19:58 -07:00
Xiang Li
609e13a240 raft: add node.Unstable
Be able to return all unstable log entries. Application must store unstable
log entries before send out any messages after calling step.
2014-09-03 09:19:58 -07:00
Xiang Li
1288e1f39d raft: log->raftlog 2014-09-03 09:19:58 -07:00
Xiang Li
447d7dc51b raft: fix log append; add tests 2014-09-03 09:19:49 -07:00
Xiang Li
30f4d9faea raft: change index and term to int64 2014-09-03 09:05:14 -07:00
Xiang Li
2a11c1487c raft: sm.compact and sm.restore 2014-09-03 09:05:12 -07:00
Xiang Li
064004b899 raft: add log compact 2014-09-03 09:05:12 -07:00
Xiang Li
6a232dfc13 raft: add offset for log 2014-09-03 09:05:12 -07:00