XL: Remove usage of reduceErr and make it isQuorum verification. (#1909)

Fixes #1908
This commit is contained in:
Harshavardhana
2016-06-18 00:27:51 +05:30
committed by GitHub
parent 7f38f46e20
commit 8c0942bf0d
11 changed files with 279 additions and 285 deletions
+25
View File
@@ -24,6 +24,31 @@ import (
"time"
)
// Validates if we have quorum based on the errors with errDiskNotFound.
func isQuorum(errs []error, minQuorumCount int) bool {
var diskFoundCount int
for _, err := range errs {
if err == errDiskNotFound {
continue
}
diskFoundCount++
}
return diskFoundCount >= minQuorumCount
}
// Similar to 'len(slice)' but returns the actual elements count
// skipping the unallocated elements.
func diskCount(disks []StorageAPI) int {
diskCount := 0
for _, disk := range disks {
if disk == nil {
continue
}
diskCount++
}
return diskCount
}
// randInts - uses Knuth Fisher-Yates shuffle algorithm for generating uniform shuffling.
func randInts(count int) []int {
rand.Seed(time.Now().UTC().UnixNano()) // Seed with current time.