2011-05-23 04:22:21 +00:00
|
|
|
/*
|
|
|
|
Copyright 2011 Google Inc.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2013-07-08 01:52:14 +00:00
|
|
|
/*
|
|
|
|
Package replica registers the "replica" blobserver storage type,
|
|
|
|
providing synchronous replication to one more backends.
|
|
|
|
|
|
|
|
Writes wait for minWritesForSuccess (default: all). Reads are
|
|
|
|
attempted in order and not load-balanced, randomized, or raced by
|
|
|
|
default.
|
|
|
|
|
|
|
|
Example config:
|
|
|
|
|
|
|
|
"/repl/": {
|
|
|
|
"handler": "storage-replica",
|
|
|
|
"handlerArgs": {
|
|
|
|
"backends": ["/b1/", "/b2/", "/b3/"],
|
|
|
|
"minWritesForSuccess": 2
|
|
|
|
}
|
|
|
|
},
|
|
|
|
*/
|
2011-05-23 04:22:21 +00:00
|
|
|
package replica
|
|
|
|
|
|
|
|
import (
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
"errors"
|
2011-05-23 04:22:21 +00:00
|
|
|
"fmt"
|
|
|
|
"io"
|
2011-10-27 21:27:09 +00:00
|
|
|
"io/ioutil"
|
2011-05-23 04:22:21 +00:00
|
|
|
"log"
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
"net/http"
|
2011-05-23 04:22:21 +00:00
|
|
|
|
2013-08-04 02:54:30 +00:00
|
|
|
"camlistore.org/pkg/blob"
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
"camlistore.org/pkg/blobserver"
|
|
|
|
"camlistore.org/pkg/jsonconfig"
|
2011-05-23 04:22:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const buffered = 8
|
|
|
|
|
|
|
|
type replicaStorage struct {
|
2013-09-08 23:35:56 +00:00
|
|
|
// Replicas for writing:
|
2011-05-23 04:22:21 +00:00
|
|
|
replicaPrefixes []string
|
|
|
|
replicas []blobserver.Storage
|
|
|
|
|
2013-09-08 23:35:56 +00:00
|
|
|
// Replicas for reading:
|
|
|
|
readPrefixes []string
|
|
|
|
readReplicas []blobserver.Storage
|
|
|
|
|
2011-05-23 04:22:21 +00:00
|
|
|
// Minimum number of writes that must succeed before
|
|
|
|
// acknowledging success to the client.
|
|
|
|
minWritesForSuccess int
|
2011-10-28 05:08:55 +00:00
|
|
|
|
|
|
|
ctx *http.Request // optional per-request context
|
2011-05-23 04:22:21 +00:00
|
|
|
}
|
|
|
|
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
func newFromConfig(ld blobserver.Loader, config jsonconfig.Obj) (storage blobserver.Storage, err error) {
|
2011-05-23 04:22:21 +00:00
|
|
|
sto := &replicaStorage{
|
2013-08-21 20:57:28 +00:00
|
|
|
replicaPrefixes: config.RequiredList("backends"),
|
2013-09-08 23:35:56 +00:00
|
|
|
readPrefixes: config.OptionalList("readBackends"),
|
2011-05-23 04:22:21 +00:00
|
|
|
}
|
|
|
|
nReplicas := len(sto.replicaPrefixes)
|
|
|
|
sto.minWritesForSuccess = config.OptionalInt("minWritesForSuccess", nReplicas)
|
|
|
|
if err := config.Validate(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if nReplicas == 0 {
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
return nil, errors.New("replica: need at least one replica")
|
2011-05-23 04:22:21 +00:00
|
|
|
}
|
|
|
|
if sto.minWritesForSuccess == 0 {
|
|
|
|
sto.minWritesForSuccess = nReplicas
|
|
|
|
}
|
2013-09-08 23:35:56 +00:00
|
|
|
// readPrefixes defaults to the write prefixes.
|
|
|
|
if len(sto.readPrefixes) == 0 {
|
|
|
|
sto.readPrefixes = sto.replicaPrefixes
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, prefix := range sto.replicaPrefixes {
|
|
|
|
s, err := ld.GetStorage(prefix)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
sto.replicas = append(sto.replicas, s)
|
|
|
|
}
|
|
|
|
for _, prefix := range sto.readPrefixes {
|
|
|
|
s, err := ld.GetStorage(prefix)
|
2011-05-23 04:22:21 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2013-09-08 23:35:56 +00:00
|
|
|
sto.readReplicas = append(sto.readReplicas, s)
|
2011-05-23 04:22:21 +00:00
|
|
|
}
|
|
|
|
return sto, nil
|
|
|
|
}
|
|
|
|
|
2013-08-04 02:54:30 +00:00
|
|
|
func (sto *replicaStorage) FetchStreaming(b blob.Ref) (file io.ReadCloser, size int64, err error) {
|
2013-09-08 23:35:56 +00:00
|
|
|
// TODO: race these? first to respond?
|
|
|
|
for _, replica := range sto.readReplicas {
|
2011-05-23 04:22:21 +00:00
|
|
|
file, size, err = replica.FetchStreaming(b)
|
|
|
|
if err == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2013-09-08 23:35:56 +00:00
|
|
|
// StatBlobs stats all read replicas.
|
2013-08-21 20:57:28 +00:00
|
|
|
func (sto *replicaStorage) StatBlobs(dest chan<- blob.SizedRef, blobs []blob.Ref) error {
|
2013-09-08 23:06:59 +00:00
|
|
|
need := make(map[blob.Ref]bool)
|
2011-05-23 04:22:21 +00:00
|
|
|
for _, br := range blobs {
|
2013-09-08 23:06:59 +00:00
|
|
|
need[br] = true
|
2011-05-23 04:22:21 +00:00
|
|
|
}
|
|
|
|
|
2013-08-04 02:54:30 +00:00
|
|
|
ch := make(chan blob.SizedRef, buffered)
|
2013-09-08 23:06:59 +00:00
|
|
|
donec := make(chan bool)
|
2011-05-23 04:22:21 +00:00
|
|
|
|
|
|
|
go func() {
|
|
|
|
for sb := range ch {
|
2013-09-08 23:06:59 +00:00
|
|
|
if need[sb.Ref] {
|
2011-05-23 04:22:21 +00:00
|
|
|
dest <- sb
|
2013-09-08 23:06:59 +00:00
|
|
|
delete(need, sb.Ref)
|
2011-05-23 04:22:21 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-08 23:06:59 +00:00
|
|
|
donec <- true
|
2011-05-23 04:22:21 +00:00
|
|
|
}()
|
|
|
|
|
2013-09-08 23:06:59 +00:00
|
|
|
errc := make(chan error, buffered)
|
2011-05-23 04:22:21 +00:00
|
|
|
statReplica := func(s blobserver.Storage) {
|
2013-09-08 23:06:59 +00:00
|
|
|
errc <- s.StatBlobs(ch, blobs)
|
2011-05-23 04:22:21 +00:00
|
|
|
}
|
|
|
|
|
2013-09-08 23:35:56 +00:00
|
|
|
for _, replica := range sto.readReplicas {
|
2011-05-23 04:22:21 +00:00
|
|
|
go statReplica(replica)
|
|
|
|
}
|
|
|
|
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
var retErr error
|
2013-09-08 23:35:56 +00:00
|
|
|
for _ = range sto.readReplicas {
|
2013-09-08 23:06:59 +00:00
|
|
|
if err := <-errc; err != nil {
|
2011-05-23 04:22:21 +00:00
|
|
|
retErr = err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(ch)
|
2013-09-08 23:06:59 +00:00
|
|
|
<-donec
|
2011-05-23 04:22:21 +00:00
|
|
|
|
|
|
|
// Safe to access need map now; as helper goroutine is
|
|
|
|
// done with it.
|
|
|
|
if len(need) == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return retErr
|
|
|
|
}
|
|
|
|
|
|
|
|
type sizedBlobAndError struct {
|
2013-08-04 02:54:30 +00:00
|
|
|
sb blob.SizedRef
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
err error
|
2011-05-23 04:22:21 +00:00
|
|
|
}
|
|
|
|
|
2013-08-04 02:54:30 +00:00
|
|
|
func (sto *replicaStorage) ReceiveBlob(b blob.Ref, source io.Reader) (_ blob.SizedRef, err error) {
|
2011-05-23 04:22:21 +00:00
|
|
|
nReplicas := len(sto.replicas)
|
|
|
|
rpipe, wpipe, writer := make([]*io.PipeReader, nReplicas), make([]*io.PipeWriter, nReplicas), make([]io.Writer, nReplicas)
|
|
|
|
for idx := range sto.replicas {
|
|
|
|
rpipe[idx], wpipe[idx] = io.Pipe()
|
|
|
|
writer[idx] = wpipe[idx]
|
|
|
|
// TODO: deal with slow/hung clients. this scheme of pipes +
|
|
|
|
// multiwriter (even with a bufio.Writer thrown in) isn't
|
|
|
|
// sufficient to guarantee forward progress. perhaps something
|
|
|
|
// like &MoveOrDieWriter{Writer: wpipe[idx], HeartbeatSec: 10}
|
|
|
|
}
|
|
|
|
upResult := make(chan sizedBlobAndError, nReplicas)
|
2013-08-21 20:57:28 +00:00
|
|
|
uploadToReplica := func(source io.Reader, dst blobserver.BlobReceiver) {
|
|
|
|
sb, err := blobserver.Receive(dst, b, source)
|
2011-10-27 21:27:09 +00:00
|
|
|
if err != nil {
|
|
|
|
io.Copy(ioutil.Discard, source)
|
|
|
|
}
|
2011-05-23 04:22:21 +00:00
|
|
|
upResult <- sizedBlobAndError{sb, err}
|
|
|
|
}
|
2013-08-21 20:57:28 +00:00
|
|
|
for idx, replica := range sto.replicas {
|
2011-05-23 04:22:21 +00:00
|
|
|
go uploadToReplica(rpipe[idx], replica)
|
|
|
|
}
|
|
|
|
size, err := io.Copy(io.MultiWriter(writer...), source)
|
|
|
|
if err != nil {
|
2013-09-08 19:37:07 +00:00
|
|
|
for i := range wpipe {
|
|
|
|
wpipe[i].CloseWithError(err)
|
|
|
|
}
|
2011-05-23 04:22:21 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
for idx := range sto.replicas {
|
|
|
|
wpipe[idx].Close()
|
|
|
|
}
|
2011-10-27 21:27:09 +00:00
|
|
|
nSuccess, nFailures := 0, 0
|
2011-05-23 04:22:21 +00:00
|
|
|
for _ = range sto.replicas {
|
2011-10-27 21:27:09 +00:00
|
|
|
res := <-upResult
|
|
|
|
switch {
|
2011-05-23 04:22:21 +00:00
|
|
|
case res.err == nil && res.sb.Size == size:
|
|
|
|
nSuccess++
|
|
|
|
if nSuccess == sto.minWritesForSuccess {
|
|
|
|
return res.sb, nil
|
|
|
|
}
|
|
|
|
case res.err == nil:
|
2011-10-27 21:27:09 +00:00
|
|
|
nFailures++
|
2011-05-23 04:22:21 +00:00
|
|
|
err = fmt.Errorf("replica: upload shard reported size %d, expected %d", res.sb.Size, size)
|
|
|
|
default:
|
2011-10-27 21:27:09 +00:00
|
|
|
nFailures++
|
2011-05-23 04:22:21 +00:00
|
|
|
err = res.err
|
|
|
|
}
|
|
|
|
}
|
2011-10-27 21:27:09 +00:00
|
|
|
if nFailures > 0 {
|
|
|
|
log.Printf("replica: receiving blob, %d successes, %d failures; last error = %v",
|
|
|
|
nSuccess, nFailures, err)
|
|
|
|
}
|
2011-05-23 04:22:21 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2013-08-04 02:54:30 +00:00
|
|
|
func (sto *replicaStorage) RemoveBlobs(blobs []blob.Ref) error {
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
errch := make(chan error, buffered)
|
2011-05-23 04:22:21 +00:00
|
|
|
removeFrom := func(s blobserver.Storage) {
|
2011-09-29 02:37:28 +00:00
|
|
|
errch <- s.RemoveBlobs(blobs)
|
2011-05-23 04:22:21 +00:00
|
|
|
}
|
|
|
|
for _, replica := range sto.replicas {
|
|
|
|
go removeFrom(replica)
|
|
|
|
}
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
var reterr error
|
2011-05-23 04:22:21 +00:00
|
|
|
nSuccess := 0
|
|
|
|
for _ = range errch {
|
|
|
|
if err := <-errch; err != nil {
|
|
|
|
reterr = err
|
|
|
|
} else {
|
|
|
|
nSuccess++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if nSuccess > 0 {
|
|
|
|
// TODO: decide on the return value. for now this is best
|
|
|
|
// effort and we return nil if any of the blobservers said
|
|
|
|
// success. maybe a bit weird, though.
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return reterr
|
|
|
|
}
|
|
|
|
|
2013-08-21 20:57:28 +00:00
|
|
|
func (sto *replicaStorage) EnumerateBlobs(dest chan<- blob.SizedRef, after string, limit int) error {
|
2013-09-08 23:35:56 +00:00
|
|
|
return blobserver.MergedEnumerate(dest, sto.readReplicas, after, limit)
|
2011-05-23 04:22:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
blobserver.RegisterStorageConstructor("replica", blobserver.StorageConstructor(newFromConfig))
|
|
|
|
}
|