mirror of https://github.com/minio/minio.git
xl: getPartsMetadata fetch parts and decode in go-routine. (#1569)
Ref #1516
This commit is contained in:
parent
eec41c369c
commit
0db3218d5d
|
@ -19,6 +19,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
slashpath "path"
|
slashpath "path"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
@ -117,23 +118,29 @@ func (xl XL) getPartsMetadata(volume, path string) ([]xlMetaV1, []error) {
|
||||||
errs := make([]error, len(xl.storageDisks))
|
errs := make([]error, len(xl.storageDisks))
|
||||||
metadataArray := make([]xlMetaV1, len(xl.storageDisks))
|
metadataArray := make([]xlMetaV1, len(xl.storageDisks))
|
||||||
xlMetaV1FilePath := slashpath.Join(path, xlMetaV1File)
|
xlMetaV1FilePath := slashpath.Join(path, xlMetaV1File)
|
||||||
|
var wg = &sync.WaitGroup{}
|
||||||
for index, disk := range xl.storageDisks {
|
for index, disk := range xl.storageDisks {
|
||||||
offset := int64(0)
|
wg.Add(1)
|
||||||
metadataReader, err := disk.ReadFile(volume, xlMetaV1FilePath, offset)
|
go func(index int, disk StorageAPI) {
|
||||||
if err != nil {
|
defer wg.Done()
|
||||||
errs[index] = err
|
offset := int64(0)
|
||||||
continue
|
metadataReader, err := disk.ReadFile(volume, xlMetaV1FilePath, offset)
|
||||||
}
|
if err != nil {
|
||||||
defer metadataReader.Close()
|
errs[index] = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer metadataReader.Close()
|
||||||
|
|
||||||
metadata, err := xlMetaV1Decode(metadataReader)
|
metadata, err := xlMetaV1Decode(metadataReader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Unable to parse file.json, set error.
|
// Unable to parse file.json, set error.
|
||||||
errs[index] = err
|
errs[index] = err
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
metadataArray[index] = metadata
|
metadataArray[index] = metadata
|
||||||
|
}(index, disk)
|
||||||
}
|
}
|
||||||
|
wg.Wait()
|
||||||
return metadataArray, errs
|
return metadataArray, errs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue