Skip to content

Commit

Permalink
fix the simple non-api changing gometalint issues
Browse files Browse the repository at this point in the history
Change-Id: I734562a4ef41b2252d55281895c4fa6aba4e9745
Reviewed-on: http://review.couchbase.org/76174
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Steve Yen <steve.yen@gmail.com>
  • Loading branch information
mschoch committed Apr 2, 2017
1 parent 5393f71 commit 5cd1345
Show file tree
Hide file tree
Showing 4 changed files with 676 additions and 672 deletions.
72 changes: 36 additions & 36 deletions moves_test.go
Expand Up @@ -19,108 +19,108 @@ func TestFindStateChanges(t *testing.T) {
{0, 0, "master",
[]string{"master", "replica"},
map[string][]string{
"master": []string{"a"},
"replica": []string{"b", "c"},
"master": {"a"},
"replica": {"b", "c"},
},
map[string][]string{
"master": []string{"a"},
"replica": []string{"b", "c"},
"master": {"a"},
"replica": {"b", "c"},
},
nil,
},
{1, 2, "master",
[]string{"master", "replica"},
map[string][]string{
"master": []string{"a"},
"replica": []string{"b", "c"},
"master": {"a"},
"replica": {"b", "c"},
},
map[string][]string{
"master": []string{"a"},
"replica": []string{"b", "c"},
"master": {"a"},
"replica": {"b", "c"},
},
nil,
},
{0, 0, "master",
[]string{"master", "replica"},
map[string][]string{
"master": []string{},
"replica": []string{"a"},
"master": {},
"replica": {"a"},
},
map[string][]string{
"master": []string{"a"},
"replica": []string{},
"master": {"a"},
"replica": {},
},
nil,
},
{1, 2, "master",
[]string{"master", "replica"},
map[string][]string{
"master": []string{},
"replica": []string{"a"},
"master": {},
"replica": {"a"},
},
map[string][]string{
"master": []string{"a"},
"replica": []string{},
"master": {"a"},
"replica": {},
},
[]string{"a"},
},
{0, 1, "replica",
[]string{"master", "replica"},
map[string][]string{
"master": []string{"a"},
"replica": []string{},
"master": {"a"},
"replica": {},
},
map[string][]string{
"master": []string{},
"replica": []string{"a"},
"master": {},
"replica": {"a"},
},
[]string{"a"},
},
{1, 2, "replica",
[]string{"master", "replica"},
map[string][]string{
"master": []string{"a"},
"replica": []string{},
"master": {"a"},
"replica": {},
},
map[string][]string{
"master": []string{},
"replica": []string{"a"},
"master": {},
"replica": {"a"},
},
nil,
},
{1, 2, "replica",
[]string{"master", "replica"},
map[string][]string{
"master": []string{},
"replica": []string{"a"},
"master": {},
"replica": {"a"},
},
map[string][]string{
"master": []string{},
"replica": []string{},
"master": {},
"replica": {},
},
nil,
},
{1, 2, "master",
[]string{"master", "replica"},
map[string][]string{
"master": []string{"a"},
"replica": []string{"b", "c", "d"},
"master": {"a"},
"replica": {"b", "c", "d"},
},
map[string][]string{
"master": []string{"b"},
"replica": []string{"a", "c", "d"},
"master": {"b"},
"replica": {"a", "c", "d"},
},
[]string{"b"},
},
{1, 2, "master",
[]string{"master", "replica"},
map[string][]string{
"master": []string{"a"},
"replica": []string{"b", "c", "d"},
"master": {"a"},
"replica": {"b", "c", "d"},
},
map[string][]string{
"master": []string{"x"},
"replica": []string{"a", "c", "d"},
"master": {"x"},
"replica": {"a", "c", "d"},
},
nil,
},
Expand Down
28 changes: 16 additions & 12 deletions orchestrate.go
Expand Up @@ -17,7 +17,10 @@ import (
"sync"
)

// ErrorStopped is returned when an operation was stopped
var ErrorStopped = errors.New("stopped")

// ErrorInterrupt is returned when an operation was interrupted
var ErrorInterrupt = errors.New("interrupt")

/*
Expand Down Expand Up @@ -185,6 +188,7 @@ func LowestWeightPartitionMoveForNode(
return r
}

// MoveOpWeight sets the weight associated with each op
var MoveOpWeight = map[string]int{
"promote": 1,
"demote": 2,
Expand Down Expand Up @@ -223,7 +227,7 @@ type partitionMoveReq struct {

// ------------------------------------------

// OrchestratorMoves asynchronously begins reassigning partitions
// OrchestrateMoves asynchronously begins reassigning partitions
// amongst nodes in order to transition from the begMap to the endMap
// state, invoking the assignPartition() to affect changes.
// Additionally, the caller must read the progress channel until it's
Expand Down Expand Up @@ -337,7 +341,7 @@ func OrchestrateMoves(
return o, nil
}

// Stop() asynchronously requests the orchestrator to stop, where the
// Stop asynchronously requests the orchestrator to stop, where the
// caller will eventually see a closed progress channel.
func (o *Orchestrator) Stop() {
o.m.Lock()
Expand All @@ -349,7 +353,7 @@ func (o *Orchestrator) Stop() {
o.m.Unlock()
}

// ProgressCh() returns a channel that is updated occassionally when
// ProgressCh returns a channel that is updated occasionally when
// the orchestrator has made some progress on one or more partition
// reassignments, or has reached an error. The channel is closed by
// the orchestrator when it is finished, either naturally, or due to
Expand All @@ -359,7 +363,7 @@ func (o *Orchestrator) ProgressCh() chan OrchestratorProgress {
return o.progressCh
}

// PauseNewAssignments() disallows the orchestrator from starting any
// PauseNewAssignments disallows the orchestrator from starting any
// new assignments of partitions to nodes. Any inflight partition
// moves will continue to be finished. The caller can monitor the
// ProgressCh to determine when to pause and/or resume partition
Expand Down Expand Up @@ -434,12 +438,12 @@ func (o *Orchestrator) moverLoop(stopCh chan struct{},
case <-stopCh:
return nil

case partitionMoveReq, ok := <-partitionMoveReqCh:
case partitionMoveReqVal, ok := <-partitionMoveReqCh:
if !ok {
return nil
}

partitionMove := partitionMoveReq.partitionMove
partitionMove := partitionMoveReqVal.partitionMove
partition := partitionMove.Partition
state := partitionMove.State

Expand All @@ -458,17 +462,17 @@ func (o *Orchestrator) moverLoop(stopCh chan struct{},
}
})

if partitionMoveReq.doneCh != nil {
if partitionMoveReqVal.doneCh != nil {
if err != nil {
select {
case <-stopCh:
// NO-OP.
case partitionMoveReq.doneCh <- err:
case partitionMoveReqVal.doneCh <- err:
// NO-OP.
}
}

close(partitionMoveReq.doneCh)
close(partitionMoveReqVal.doneCh)
}
}
}
Expand All @@ -489,7 +493,7 @@ func (o *Orchestrator) runSupplyMoves(stopCh chan struct{},
o.m.Lock()

// The availableMoves is keyed by node name.
availableMoves := o.findAvailableMoves_unlocked()
availableMoves := o.findAvailableMovesUnlocked()

pauseCh := o.pauseCh

Expand Down Expand Up @@ -693,9 +697,9 @@ func (o *Orchestrator) updateProgress(f func()) {
o.progressCh <- progress
}

// findAvailableMoves_unlocked returns the next round of available
// findAvailableMovesUnlocked returns the next round of available
// moves.
func (o *Orchestrator) findAvailableMoves_unlocked() (
func (o *Orchestrator) findAvailableMovesUnlocked() (
availableMoves map[string][]*NextMoves) {
// The availableMoves is keyed by node name.
availableMoves = map[string][]*NextMoves{}
Expand Down

0 comments on commit 5cd1345

Please sign in to comment.