From a09986baa2b3d6bc3d463fc0524114822fc7eb15 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 12 Apr 2016 13:31:30 +0100 Subject: [PATCH] Rename consense -> prime --- ipam/allocator.go | 16 ++++++++-------- ipam/http.go | 4 ++-- ipam/{consense.go => prime.go} | 8 ++++---- site/ipam.md | 2 +- test/335_rmpeer_3_test.sh | 4 ++-- weave | 6 +++--- 6 files changed, 20 insertions(+), 20 deletions(-) rename ipam/{consense.go => prime.go} (55%) diff --git a/ipam/allocator.go b/ipam/allocator.go index 51e42a5b..b7aaae1c 100644 --- a/ipam/allocator.go +++ b/ipam/allocator.go @@ -56,7 +56,7 @@ type Allocator struct { nicknames map[mesh.PeerName]string // so we can map nicknames for rmpeer pendingAllocates []operation // held until we get some free space pendingClaims []operation // held until we know who owns the space - pendingConsenses []operation // held until consensus achieved + pendingPrimes []operation // held while our ring is empty dead map[string]time.Time // containers we heard were dead, and when db db.DB // persistence gossip mesh.Gossip // our link to the outside world for sending messages @@ -193,8 +193,8 @@ func (alloc *Allocator) tryOps(ops *[]operation) { // Try all pending operations func (alloc *Allocator) tryPendingOps() { - // Unblock pending consenses first - alloc.tryOps(&alloc.pendingConsenses) + // Unblock pending primes first + alloc.tryOps(&alloc.pendingPrimes) // Process existing claims before servicing new allocations alloc.tryOps(&alloc.pendingClaims) alloc.tryOps(&alloc.pendingAllocates) @@ -223,11 +223,11 @@ func (e *errorCancelled) Error() string { // Actor client API -// Consense (Sync) - wait for consensus -func (alloc *Allocator) Consense() { +// Prime (Sync) - wait for consensus +func (alloc *Allocator) Prime() { resultChan := make(chan struct{}) - op := &consense{resultChan: resultChan} - alloc.doOperation(op, &alloc.pendingConsenses) + op := &prime{resultChan: resultChan} + alloc.doOperation(op, &alloc.pendingPrimes) <-resultChan } @@ -381,7 +381,7 @@ func (alloc *Allocator) Shutdown() { alloc.shuttingDown = true alloc.cancelOps(&alloc.pendingClaims) alloc.cancelOps(&alloc.pendingAllocates) - alloc.cancelOps(&alloc.pendingConsenses) + alloc.cancelOps(&alloc.pendingPrimes) if heir := alloc.pickPeerForTransfer(); heir != mesh.UnknownPeerName { alloc.ring.Transfer(alloc.ourName, heir) alloc.space.Clear() diff --git a/ipam/http.go b/ipam/http.go index 7330b96c..6fd6a528 100644 --- a/ipam/http.go +++ b/ipam/http.go @@ -82,8 +82,8 @@ func (alloc *Allocator) HandleHTTP(router *mux.Router, defaultSubnet address.CID } }) - router.Methods("GET").Path("/consensus").HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - alloc.Consense() + router.Methods("GET").Path("/ring").HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + alloc.Prime() }) router.Methods("GET").Path("/ip/{id}/{ip}/{prefixlen}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) { diff --git a/ipam/consense.go b/ipam/prime.go similarity index 55% rename from ipam/consense.go rename to ipam/prime.go index a4e36c15..6b9cff4d 100644 --- a/ipam/consense.go +++ b/ipam/prime.go @@ -1,10 +1,10 @@ package ipam -type consense struct { +type prime struct { resultChan chan<- struct{} } -func (c *consense) Try(alloc *Allocator) bool { +func (c *prime) Try(alloc *Allocator) bool { if !alloc.ring.Empty() { close(c.resultChan) return true @@ -15,10 +15,10 @@ func (c *consense) Try(alloc *Allocator) bool { return false } -func (c *consense) Cancel() { +func (c *prime) Cancel() { close(c.resultChan) } -func (c *consense) ForContainer(ident string) bool { +func (c *prime) ForContainer(ident string) bool { return false } diff --git a/site/ipam.md b/site/ipam.md index 829c29c9..4dfca0ae 100644 --- a/site/ipam.md +++ b/site/ipam.md @@ -147,7 +147,7 @@ existing cluster) it is desirable to ensure that a node has successfully joined and is ready to allocate IP addresses. An administrative command is provided for this purpose: - host1$ weave consense + host1$ weave prime This operation will block until the node on which it is run has joined successfully. diff --git a/test/335_rmpeer_3_test.sh b/test/335_rmpeer_3_test.sh index bcd7adbc..fddd8253 100755 --- a/test/335_rmpeer_3_test.sh +++ b/test/335_rmpeer_3_test.sh @@ -9,9 +9,9 @@ weave_on $HOST1 launch PEER1=$(weave_on $HOST1 report -f '{{.Router.Name}}') start_container $HOST1 weave_on $HOST2 launch $HOST1 -weave_on $HOST2 consense +weave_on $HOST2 prime weave_on $HOST3 launch $HOST1 -weave_on $HOST3 consense +weave_on $HOST3 prime # nuke 1st peer docker_on $HOST1 kill weave diff --git a/weave b/weave index 964a666a..f51e02e8 100755 --- a/weave +++ b/weave @@ -52,7 +52,7 @@ weave launch [--rewrite-inspect] launch-plugin [--no-multicast-route] -weave consense +weave prime weave env [--restore] config @@ -2252,8 +2252,8 @@ EOF echo "The 'stop-dns command has been removed; DNS is stopped as part of 'stop' and 'stop-router'." >&2 exit 0 ;; - consense) - call_weave GET /consensus + prime) + call_weave GET /ring ;; *) echo "Unknown weave command '$COMMAND'" >&2