[ARVADOS] updated: 5f93e6f5823e4ee2a25616037ace6ab6d416e581
git at public.curoverse.com
git at public.curoverse.com
Mon Dec 7 17:23:14 EST 2015
Summary of changes:
services/datamanager/collection/collection.go | 6 ++--
services/datamanager/datamanager.go | 34 +++++++++++--------
services/datamanager/summary/file.go | 49 +++++++++++++--------------
3 files changed, 44 insertions(+), 45 deletions(-)
via 5f93e6f5823e4ee2a25616037ace6ab6d416e581 (commit)
via 95e7cb1e1e813786b9399ef88031520717dd2dd5 (commit)
from ddd7a40445fa3940f95d8e3ece0dcbb9af5910bc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 5f93e6f5823e4ee2a25616037ace6ab6d416e581
Merge: ddd7a40 95e7cb1
Author: Tom Clegg <tom at curoverse.com>
Date: Mon Dec 7 17:31:06 2015 -0500
Merge branch '7937-ignored-error' refs #7937
commit 95e7cb1e1e813786b9399ef88031520717dd2dd5
Author: Tom Clegg <tom at curoverse.com>
Date: Sat Dec 5 03:47:04 2015 -0500
7937: Fix ignored error from GetKeepServersAndSummarize.
diff --git a/services/datamanager/collection/collection.go b/services/datamanager/collection/collection.go
index eecfff7..1229f29 100644
--- a/services/datamanager/collection/collection.go
+++ b/services/datamanager/collection/collection.go
@@ -38,7 +38,6 @@ type ReadCollections struct {
CollectionUUIDToIndex map[string]int
CollectionIndexToUUID []string
BlockToCollectionIndices map[blockdigest.DigestWithSize][]int
- Err error
}
// GetCollectionsParams params
@@ -93,10 +92,9 @@ func WriteHeapProfile() error {
}
// GetCollectionsAndSummarize gets collections from api and summarizes
-func GetCollectionsAndSummarize(params GetCollectionsParams) (results ReadCollections) {
- results, err := GetCollections(params)
+func GetCollectionsAndSummarize(params GetCollectionsParams) (results ReadCollections, err error) {
+ results, err = GetCollections(params)
if err != nil {
- results.Err = err
return
}
diff --git a/services/datamanager/datamanager.go b/services/datamanager/datamanager.go
index c1a5cbe..604a6db 100644
--- a/services/datamanager/datamanager.go
+++ b/services/datamanager/datamanager.go
@@ -108,10 +108,9 @@ func singlerun(arv arvadosclient.ArvadosClient) error {
dataFetcher = BuildDataFetcher(arv)
}
- dataFetcher(arvLogger, &readCollections, &keepServerInfo)
-
- if readCollections.Err != nil {
- return readCollections.Err
+ err = dataFetcher(arvLogger, &readCollections, &keepServerInfo)
+ if err != nil {
+ return err
}
err = summary.MaybeWriteData(arvLogger, readCollections, keepServerInfo)
@@ -182,30 +181,35 @@ func singlerun(arv arvadosclient.ArvadosClient) error {
// BuildDataFetcher returns a data fetcher that fetches data from remote servers.
func BuildDataFetcher(arv arvadosclient.ArvadosClient) summary.DataFetcher {
- return func(arvLogger *logger.Logger,
+ return func(
+ arvLogger *logger.Logger,
readCollections *collection.ReadCollections,
- keepServerInfo *keep.ReadServers) {
- collectionChannel := make(chan collection.ReadCollections)
-
+ keepServerInfo *keep.ReadServers,
+ ) error {
+ collDone := make(chan struct{})
+ var collErr error
go func() {
- collectionChannel <- collection.GetCollectionsAndSummarize(
+ *readCollections, collErr = collection.GetCollectionsAndSummarize(
collection.GetCollectionsParams{
Client: arv,
Logger: arvLogger,
BatchSize: 50})
+ collDone <- struct{}{}
}()
- var err error
- *keepServerInfo, err = keep.GetKeepServersAndSummarize(
+ var keepErr error
+ *keepServerInfo, keepErr = keep.GetKeepServersAndSummarize(
keep.GetKeepServersParams{
Client: arv,
Logger: arvLogger,
Limit: 1000})
- if err != nil {
- return
- }
+ <- collDone
- *readCollections = <-collectionChannel
+ // Return a nil error only if both parts succeeded.
+ if collErr != nil {
+ return collErr
+ }
+ return keepErr
}
}
diff --git a/services/datamanager/summary/file.go b/services/datamanager/summary/file.go
index 9f1eab6..6e463d7 100644
--- a/services/datamanager/summary/file.go
+++ b/services/datamanager/summary/file.go
@@ -28,7 +28,7 @@ var (
// DataFetcher to fetch data from keep servers
type DataFetcher func(arvLogger *logger.Logger,
readCollections *collection.ReadCollections,
- keepServerInfo *keep.ReadServers)
+ keepServerInfo *keep.ReadServers) error
func init() {
flag.StringVar(&WriteDataTo,
@@ -86,33 +86,30 @@ func ShouldReadData() bool {
// working with stale data.
func ReadData(arvLogger *logger.Logger,
readCollections *collection.ReadCollections,
- keepServerInfo *keep.ReadServers) {
+ keepServerInfo *keep.ReadServers) error {
if readDataFrom == "" {
- readCollections.Err = fmt.Errorf("ReadData() called with empty filename.")
- return
- } else {
- summaryFile, err := os.Open(readDataFrom)
- if err != nil {
- readCollections.Err = err
- return
- }
- defer summaryFile.Close()
+ return fmt.Errorf("ReadData() called with empty filename.")
+ }
+ summaryFile, err := os.Open(readDataFrom)
+ if err != nil {
+ return err
+ }
+ defer summaryFile.Close()
- dec := gob.NewDecoder(summaryFile)
- data := serializedData{}
- err = dec.Decode(&data)
- if err != nil {
- readCollections.Err = err
- return
- }
+ dec := gob.NewDecoder(summaryFile)
+ data := serializedData{}
+ err = dec.Decode(&data)
+ if err != nil {
+ return err
+ }
- // re-summarize data, so that we can update our summarizing
- // functions without needing to do all our network i/o
- data.ReadCollections.Summarize(arvLogger)
- data.KeepServerInfo.Summarize(arvLogger)
+ // re-summarize data, so that we can update our summarizing
+ // functions without needing to do all our network i/o
+ data.ReadCollections.Summarize(arvLogger)
+ data.KeepServerInfo.Summarize(arvLogger)
- *readCollections = data.ReadCollections
- *keepServerInfo = data.KeepServerInfo
- log.Printf("Read summary data from: %s", readDataFrom)
- }
+ *readCollections = data.ReadCollections
+ *keepServerInfo = data.KeepServerInfo
+ log.Printf("Read summary data from: %s", readDataFrom)
+ return nil
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list