aboutsummaryrefslogtreecommitdiff
path: root/weed/topology
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-03-07 06:12:57 -0800
committerChris Lu <chris.lu@gmail.com>2020-03-07 06:12:57 -0800
commit1ae83c29389c64fedabaa5e401154c5b57add40c (patch)
tree8a4aca03c68bdbeeb053570dd4430e70d1fb71a4 /weed/topology
parent564629444befcdd7f71dade1713199b212243226 (diff)
downloadseaweedfs-1ae83c29389c64fedabaa5e401154c5b57add40c.tar.xz
seaweedfs-1ae83c29389c64fedabaa5e401154c5b57add40c.zip
go fmt
Diffstat (limited to 'weed/topology')
-rw-r--r--weed/topology/node.go4
-rw-r--r--weed/topology/volume_growth_test.go4
2 files changed, 4 insertions, 4 deletions
diff --git a/weed/topology/node.go b/weed/topology/node.go
index 501a22623..ceeb96d60 100644
--- a/weed/topology/node.go
+++ b/weed/topology/node.go
@@ -85,11 +85,11 @@ func (n *NodeImpl) PickNodesByWeight(numberOfNodes int, filterFirstNodeFn func(d
//pick nodes randomly by weights, the node picked earlier has higher final weights
sortedCandidates := make([]Node, 0, len(candidates))
- for i:=0; i<len(candidates); i++ {
+ for i := 0; i < len(candidates); i++ {
weightsInterval := rand.Int63n(totalWeights)
lastWeights := int64(0)
for k, weights := range candidatesWeights {
- if (weightsInterval>=lastWeights) && (weightsInterval<lastWeights + weights) {
+ if (weightsInterval >= lastWeights) && (weightsInterval < lastWeights+weights) {
sortedCandidates = append(sortedCandidates, candidates[k])
candidatesWeights[k] = 0
totalWeights -= weights
diff --git a/weed/topology/volume_growth_test.go b/weed/topology/volume_growth_test.go
index 83671cd2b..6ff5be0eb 100644
--- a/weed/topology/volume_growth_test.go
+++ b/weed/topology/volume_growth_test.go
@@ -321,7 +321,7 @@ func TestFindEmptySlotsForOneVolumeScheduleByWeight(t *testing.T) {
distribution := map[NodeId]int{}
// assign 1000 volumes
- for i:=0;i<1000 ;i++ {
+ for i := 0; i < 1000; i++ {
servers, err := vg.findEmptySlotsForOneVolume(topo, volumeGrowOption)
if err != nil {
fmt.Println("finding empty slots error :", err)
@@ -339,4 +339,4 @@ func TestFindEmptySlotsForOneVolumeScheduleByWeight(t *testing.T) {
for k, v := range distribution {
fmt.Printf("%s : %d\n", k, v)
}
-} \ No newline at end of file
+}