@@ -88,7 +88,7 @@ func rebalance(cmd *cobra.Command, _ []string) {
88
88
// of rebalance plans. A rebalanceResults holds
89
89
// any relevant output along with metadata that
90
90
// hints at the quality of the output, such as
91
- // the resulting storage utlization range.
91
+ // the resulting storage utilization range.
92
92
type rebalanceResults struct {
93
93
storageRange float64
94
94
tolerance float64
@@ -107,7 +107,7 @@ func rebalance(cmd *cobra.Command, _ []string) {
107
107
tolFlag , _ := cmd .Flags ().GetFloat64 ("tolerance" )
108
108
var tol float64
109
109
110
- if tolFlag ! = 0.00 {
110
+ if tolFlag = = 0.00 {
111
111
tol = i
112
112
} else {
113
113
tol = tolFlag
@@ -155,7 +155,7 @@ func rebalance(cmd *cobra.Command, _ []string) {
155
155
// Populate the output.
156
156
resultsByRange = append (resultsByRange , rebalanceResults {
157
157
storageRange : params .brokers .StorageRange (),
158
- tolerance : i ,
158
+ tolerance : tol ,
159
159
partitionMap : partitionMap ,
160
160
relocations : params .relos ,
161
161
brokers : params .brokers ,
@@ -167,18 +167,17 @@ func rebalance(cmd *cobra.Command, _ []string) {
167
167
}
168
168
}
169
169
170
+ // Sort the rebalance results by range ascending.
170
171
sort .Slice (resultsByRange , func (i , j int ) bool {
171
172
return resultsByRange [i ].storageRange < resultsByRange [j ].storageRange
172
173
})
173
174
175
+ // Chose the results with the lowest range.
174
176
m := resultsByRange [0 ]
175
177
partitionMap , relos , brokers := m .partitionMap , m .relocations , m .brokers
176
178
177
- fmt .Printf ("xxx using a tolerance of %f\n " , m .tolerance )
178
-
179
- for i := range resultsByRange {
180
- fmt .Printf ("range for map %d: %f\n " , i , resultsByRange [i ].storageRange )
181
- }
179
+ // Print parameters used for rebalance decisions.
180
+ printRebalanceParams (cmd , brokersOrig , m .tolerance )
182
181
183
182
// Print planned relocations.
184
183
printPlannedRelocations (offloadTargets , relos , partitionMeta )
0 commit comments