From 0ed440e15ad0f57ee7a4ed76c7a0f37481818037 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 3 Apr 2015 19:08:25 -0700 Subject: [PATCH] Update donut to minio-io/donut --- Godeps/Godeps.json | 2 +- .../github.com/minio-io/donut/bucket_internal.go | 15 +++++++-------- .../src/github.com/minio-io/donut/donut.go | 4 ---- .../src/github.com/minio-io/donut/rebalance.go | 14 ++++++++++++++ 4 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 Godeps/_workspace/src/github.com/minio-io/donut/rebalance.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 8c23629f..dd58ce41 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -28,7 +28,7 @@ }, { "ImportPath": "github.com/minio-io/donut", - "Rev": "e31777817d0808395d6ce01fca5673929c8f7cc9" + "Rev": "aac8dddef7aebd6e2e5953038b2f4a0cb08768ee" }, { "ImportPath": "github.com/minio-io/erasure", diff --git a/Godeps/_workspace/src/github.com/minio-io/donut/bucket_internal.go b/Godeps/_workspace/src/github.com/minio-io/donut/bucket_internal.go index 39fd604f..c4b2ae15 100644 --- a/Godeps/_workspace/src/github.com/minio-io/donut/bucket_internal.go +++ b/Godeps/_workspace/src/github.com/minio-io/donut/bucket_internal.go @@ -43,6 +43,11 @@ func (b bucket) getDataAndParity(totalWriters int) (k uint8, m uint8, err error) } func (b bucket) getObject(objectName string, writer *io.PipeWriter, donutObjectMetadata map[string]string) { + expectedMd5sum, err := hex.DecodeString(donutObjectMetadata["md5"]) + if err != nil { + writer.CloseWithError(err) + return + } readers, err := b.getDiskReaders(objectName, "data") if err != nil { writer.CloseWithError(err) @@ -87,14 +92,8 @@ func (b bucket) getObject(objectName string, writer *io.PipeWriter, donutObjectM return } } - expectedMd5sum, err := hex.DecodeString(donutObjectMetadata["md5"]) - if err != nil { - writer.CloseWithError(err) - return - } - - actualMd5sum := hasher.Sum(nil) - if bytes.Compare(expectedMd5sum, actualMd5sum) != 0 { + // check if decodedData md5sum matches + if !bytes.Equal(expectedMd5sum, hasher.Sum(nil)) { writer.CloseWithError(errors.New("checksum mismatch")) return } diff --git a/Godeps/_workspace/src/github.com/minio-io/donut/donut.go b/Godeps/_workspace/src/github.com/minio-io/donut/donut.go index 446223ac..c9955078 100644 --- a/Godeps/_workspace/src/github.com/minio-io/donut/donut.go +++ b/Godeps/_workspace/src/github.com/minio-io/donut/donut.go @@ -146,10 +146,6 @@ func (d donut) Heal() error { return errors.New("Not Implemented") } -func (d donut) Rebalance() error { - return errors.New("Not Implemented") -} - func (d donut) Info() (nodeDiskMap map[string][]string, err error) { nodeDiskMap = make(map[string][]string) for nodeName, node := range d.nodes { diff --git a/Godeps/_workspace/src/github.com/minio-io/donut/rebalance.go b/Godeps/_workspace/src/github.com/minio-io/donut/rebalance.go new file mode 100644 index 00000000..e3fc3ce6 --- /dev/null +++ b/Godeps/_workspace/src/github.com/minio-io/donut/rebalance.go @@ -0,0 +1,14 @@ +package donut + +import "fmt" + +func (d donut) Rebalance() error { + for _, node := range d.nodes { + disks, err := node.ListDisks() + if err != nil { + return err + } + fmt.Println(len(disks)) + } + return nil +}