Simplify paxos.Consensus() call
This commit is contained in:
1 parent
720fdf714c
commit
2a244e5699
1 file changed
+4
-9
+4
-9
@@ -498,11 +498,6 @@ func (alloc *Allocator) string() string {
|
|||||||
return buf.String()
|
return buf.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (alloc *Allocator) consensus() []router.PeerName {
|
|
||||||
_, val := alloc.paxos.Consensus()
|
|
||||||
return val.Value
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure we are making progress towards an established ring
|
// Ensure we are making progress towards an established ring
|
||||||
func (alloc *Allocator) establishRing() {
|
func (alloc *Allocator) establishRing() {
|
||||||
if !alloc.ring.Empty() || alloc.paxosTicker != nil {
|
if !alloc.ring.Empty() || alloc.paxosTicker != nil {
|
||||||
@@ -510,10 +505,10 @@ func (alloc *Allocator) establishRing() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
alloc.propose()
|
alloc.propose()
|
||||||
if cons := alloc.consensus(); cons != nil {
|
if ok, cons := alloc.paxos.Consensus(); ok {
|
||||||
// If the quorum was 1, then proposing immediately
|
// If the quorum was 1, then proposing immediately
|
||||||
// leads to consensus
|
// leads to consensus
|
||||||
alloc.createRing(cons)
|
alloc.createRing(cons.Value)
|
||||||
} else {
|
} else {
|
||||||
// re-try until we get consensus
|
// re-try until we get consensus
|
||||||
alloc.paxosTicker = time.NewTicker(paxosInterval)
|
alloc.paxosTicker = time.NewTicker(paxosInterval)
|
||||||
@@ -622,8 +617,8 @@ func (alloc *Allocator) update(msg []byte) error {
|
|||||||
alloc.gossip.GossipBroadcast(alloc.Gossip())
|
alloc.gossip.GossipBroadcast(alloc.Gossip())
|
||||||
}
|
}
|
||||||
|
|
||||||
if cons := alloc.consensus(); cons != nil {
|
if ok, cons := alloc.paxos.Consensus(); ok {
|
||||||
alloc.createRing(cons)
|
alloc.createRing(cons.Value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user