Merge pull request #663 from harshavardhana/pr_out_add_missing_strongly_typed_errors_for_donut
This commit is contained in:
commit
3e9141d22d
|
@ -16,11 +16,7 @@
|
|||
|
||||
package donut
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/minio/minio/pkg/iodine"
|
||||
)
|
||||
import "github.com/minio/minio/pkg/iodine"
|
||||
|
||||
// donut struct internal data
|
||||
type donut struct {
|
||||
|
@ -73,7 +69,7 @@ func (d donut) attachDonutNode(hostname string, disks []string) error {
|
|||
// NewDonut - instantiate a new donut
|
||||
func NewDonut(donutName string, nodeDiskMap map[string][]string) (Donut, error) {
|
||||
if donutName == "" || len(nodeDiskMap) == 0 {
|
||||
return nil, iodine.New(errors.New("invalid argument"), nil)
|
||||
return nil, iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
nodes := make(map[string]Node)
|
||||
buckets := make(map[string]Bucket)
|
||||
|
@ -84,7 +80,7 @@ func NewDonut(donutName string, nodeDiskMap map[string][]string) (Donut, error)
|
|||
}
|
||||
for k, v := range nodeDiskMap {
|
||||
if len(v) == 0 {
|
||||
return nil, iodine.New(errors.New("invalid number of disks per node"), nil)
|
||||
return nil, iodine.New(InvalidDisksArgument{}, nil)
|
||||
}
|
||||
err := d.attachDonutNode(k, v)
|
||||
if err != nil {
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package donut
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
@ -50,7 +49,7 @@ func NewBucket(bucketName, aclType, donutName string, nodes map[string]Node) (Bu
|
|||
"aclType": aclType,
|
||||
}
|
||||
if strings.TrimSpace(bucketName) == "" || strings.TrimSpace(donutName) == "" {
|
||||
return nil, nil, iodine.New(errors.New("invalid argument"), errParams)
|
||||
return nil, nil, iodine.New(InvalidArgument{}, errParams)
|
||||
}
|
||||
bucketMetadata := make(map[string]string)
|
||||
bucketMetadata["acl"] = aclType
|
||||
|
@ -92,7 +91,7 @@ func (b bucket) ListObjects() (map[string]Object, error) {
|
|||
}
|
||||
objectName, ok := newObjectMetadata["object"]
|
||||
if !ok {
|
||||
return nil, iodine.New(errors.New("object corrupted"), nil)
|
||||
return nil, iodine.New(ObjectCorrupted{Object: object.Name()}, nil)
|
||||
}
|
||||
b.objects[objectName] = newObject
|
||||
}
|
||||
|
@ -121,7 +120,7 @@ func (b bucket) GetObject(objectName string) (reader io.ReadCloser, size int64,
|
|||
return nil, 0, iodine.New(err, nil)
|
||||
}
|
||||
if objectName == "" || writer == nil || len(objectMetadata) == 0 {
|
||||
return nil, 0, iodine.New(errors.New("invalid argument"), nil)
|
||||
return nil, 0, iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
size, err = strconv.ParseInt(objectMetadata["size"], 10, 64)
|
||||
if err != nil {
|
||||
|
@ -140,7 +139,7 @@ func (b bucket) GetObject(objectName string) (reader io.ReadCloser, size int64,
|
|||
// PutObject - put a new object
|
||||
func (b bucket) PutObject(objectName string, objectData io.Reader, expectedMD5Sum string, metadata map[string]string) (string, error) {
|
||||
if objectName == "" || objectData == nil {
|
||||
return "", iodine.New(errors.New("invalid argument"), nil)
|
||||
return "", iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
writers, err := b.getDiskWriters(b.normalizeObjectName(objectName), "data")
|
||||
if err != nil {
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"hash"
|
||||
"io"
|
||||
|
@ -47,17 +46,17 @@ func (b bucket) isMD5SumEqual(expectedMD5Sum, actualMD5Sum string) error {
|
|||
return iodine.New(err, nil)
|
||||
}
|
||||
if !bytes.Equal(expectedMD5SumBytes, actualMD5SumBytes) {
|
||||
return iodine.New(errors.New("bad digest, md5sum mismatch"), nil)
|
||||
return iodine.New(BadDigest{}, nil)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return iodine.New(errors.New("invalid argument"), nil)
|
||||
return iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
|
||||
// writeObjectMetadata - write additional object metadata
|
||||
func (b bucket) writeObjectMetadata(objectName string, objectMetadata map[string]string) error {
|
||||
if len(objectMetadata) == 0 {
|
||||
return iodine.New(errors.New("invalid argument"), nil)
|
||||
return iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
objectMetadataWriters, err := b.getDiskWriters(objectName, objectMetadataConfig)
|
||||
if err != nil {
|
||||
|
@ -78,7 +77,7 @@ func (b bucket) writeObjectMetadata(objectName string, objectMetadata map[string
|
|||
// writeDonutObjectMetadata - write donut related object metadata
|
||||
func (b bucket) writeDonutObjectMetadata(objectName string, objectMetadata map[string]string) error {
|
||||
if len(objectMetadata) == 0 {
|
||||
return iodine.New(errors.New("invalid argument"), nil)
|
||||
return iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
objectMetadataWriters, err := b.getDiskWriters(objectName, donutObjectMetadataConfig)
|
||||
if err != nil {
|
||||
|
@ -112,12 +111,12 @@ func (b bucket) normalizeObjectName(objectName string) string {
|
|||
// getDataAndParity - calculate k, m (data and parity) values from number of disks
|
||||
func (b bucket) getDataAndParity(totalWriters int) (k uint8, m uint8, err error) {
|
||||
if totalWriters <= 1 {
|
||||
return 0, 0, iodine.New(errors.New("invalid argument"), nil)
|
||||
return 0, 0, iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
quotient := totalWriters / 2 // not using float or abs to let integer round off to lower value
|
||||
// quotient cannot be bigger than (255 / 2) = 127
|
||||
if quotient > 127 {
|
||||
return 0, 0, iodine.New(errors.New("parity over flow"), nil)
|
||||
return 0, 0, iodine.New(ParityOverflow{}, nil)
|
||||
}
|
||||
remainder := totalWriters % 2 // will be 1 for odd and 0 for even numbers
|
||||
k = uint8(quotient + remainder)
|
||||
|
@ -174,8 +173,7 @@ func (b bucket) readEncodedData(objectName string, writer *io.PipeWriter, donutO
|
|||
}
|
||||
technique, ok := donutObjectMetadata["sys.erasureTechnique"]
|
||||
if !ok {
|
||||
err := errors.New("missing erasure Technique")
|
||||
writer.CloseWithError(iodine.New(err, nil))
|
||||
writer.CloseWithError(iodine.New(MissingErasureTechnique{}, nil))
|
||||
return
|
||||
}
|
||||
encoder, err := NewEncoder(uint8(k), uint8(m), technique)
|
||||
|
@ -205,8 +203,7 @@ func (b bucket) readEncodedData(objectName string, writer *io.PipeWriter, donutO
|
|||
}
|
||||
// check if decodedData md5sum matches
|
||||
if !bytes.Equal(expectedMd5sum, hasher.Sum(nil)) {
|
||||
err := errors.New("checksum mismatch")
|
||||
writer.CloseWithError(iodine.New(err, nil))
|
||||
writer.CloseWithError(iodine.New(ChecksumMismatch{}, nil))
|
||||
return
|
||||
}
|
||||
writer.Close()
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
package donut
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"syscall"
|
||||
|
||||
"io/ioutil"
|
||||
|
@ -37,7 +37,7 @@ type disk struct {
|
|||
// NewDisk - instantiate new disk
|
||||
func NewDisk(diskPath string, diskOrder int) (Disk, error) {
|
||||
if diskPath == "" || diskOrder < 0 {
|
||||
return nil, iodine.New(errors.New("invalid argument"), nil)
|
||||
return nil, iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
s := syscall.Statfs_t{}
|
||||
err := syscall.Statfs(diskPath, &s)
|
||||
|
@ -61,7 +61,9 @@ func NewDisk(diskPath string, diskOrder int) (Disk, error) {
|
|||
d.filesystem["MountPoint"] = d.root
|
||||
return d, nil
|
||||
}
|
||||
return nil, iodine.New(errors.New("unsupported filesystem"), nil)
|
||||
return nil, iodine.New(UnsupportedFilesystem{
|
||||
Type: strconv.FormatInt(s.Type, 10),
|
||||
}, map[string]string{"Type": strconv.FormatInt(s.Type, 10)})
|
||||
}
|
||||
|
||||
// GetPath - get root disk path
|
||||
|
@ -126,7 +128,7 @@ func (d disk) ListFiles(dirname string) ([]os.FileInfo, error) {
|
|||
// MakeFile - create a file inside disk root path
|
||||
func (d disk) MakeFile(filename string) (*os.File, error) {
|
||||
if filename == "" {
|
||||
return nil, iodine.New(errors.New("Invalid argument"), nil)
|
||||
return nil, iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
filePath := filepath.Join(d.root, filename)
|
||||
// Create directories if they don't exist
|
||||
|
@ -143,7 +145,7 @@ func (d disk) MakeFile(filename string) (*os.File, error) {
|
|||
// OpenFile - read a file inside disk root path
|
||||
func (d disk) OpenFile(filename string) (*os.File, error) {
|
||||
if filename == "" {
|
||||
return nil, iodine.New(errors.New("Invalid argument"), nil)
|
||||
return nil, iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
dataFile, err := os.Open(filepath.Join(d.root, filename))
|
||||
if err != nil {
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
package donut
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"syscall"
|
||||
|
||||
"io/ioutil"
|
||||
|
@ -37,7 +37,7 @@ type disk struct {
|
|||
// NewDisk - instantiate new disk
|
||||
func NewDisk(diskPath string, diskOrder int) (Disk, error) {
|
||||
if diskPath == "" || diskOrder < 0 {
|
||||
return nil, iodine.New(errors.New("invalid argument"), nil)
|
||||
return nil, iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
s := syscall.Statfs_t{}
|
||||
err := syscall.Statfs(diskPath, &s)
|
||||
|
@ -61,7 +61,9 @@ func NewDisk(diskPath string, diskOrder int) (Disk, error) {
|
|||
d.filesystem["MountPoint"] = d.root
|
||||
return d, nil
|
||||
}
|
||||
return nil, iodine.New(errors.New("unsupported filesystem"), nil)
|
||||
return nil, iodine.New(UnsupportedFilesystem{
|
||||
Type: strconv.FormatInt(s.Type, 10),
|
||||
}, map[string]string{"Type": strconv.FormatInt(s.Type, 10)})
|
||||
}
|
||||
|
||||
// GetPath - get root disk path
|
||||
|
@ -126,7 +128,7 @@ func (d disk) ListFiles(dirname string) ([]os.FileInfo, error) {
|
|||
// MakeFile - create a file inside disk root path
|
||||
func (d disk) MakeFile(filename string) (*os.File, error) {
|
||||
if filename == "" {
|
||||
return nil, iodine.New(errors.New("Invalid argument"), nil)
|
||||
return nil, iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
filePath := filepath.Join(d.root, filename)
|
||||
// Create directories if they don't exist
|
||||
|
@ -143,7 +145,7 @@ func (d disk) MakeFile(filename string) (*os.File, error) {
|
|||
// OpenFile - read a file inside disk root path
|
||||
func (d disk) OpenFile(filename string) (*os.File, error) {
|
||||
if filename == "" {
|
||||
return nil, iodine.New(errors.New("Invalid argument"), nil)
|
||||
return nil, iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
dataFile, err := os.Open(filepath.Join(d.root, filename))
|
||||
if err != nil {
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package donut
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
encoding "github.com/minio/minio/pkg/erasure"
|
||||
|
@ -39,7 +38,7 @@ func getErasureTechnique(technique string) (encoding.Technique, error) {
|
|||
case technique == "Vandermonde":
|
||||
return encoding.Cauchy, nil
|
||||
default:
|
||||
return encoding.None, iodine.New(errors.New("Invalid erasure technique"), nil)
|
||||
return encoding.None, iodine.New(InvalidErasureTechnique{Technique: technique}, nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,7 +69,7 @@ func NewEncoder(k, m uint8, technique string) (Encoder, error) {
|
|||
// GetEncodedBlockLen - wrapper around erasure function with the same name
|
||||
func (e encoder) GetEncodedBlockLen(dataLength int) (int, error) {
|
||||
if dataLength <= 0 {
|
||||
return 0, iodine.New(errors.New("invalid argument"), nil)
|
||||
return 0, iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
return encoding.GetEncodedBlockLen(dataLength, e.k), nil
|
||||
}
|
||||
|
@ -78,7 +77,7 @@ func (e encoder) GetEncodedBlockLen(dataLength int) (int, error) {
|
|||
// Encode - erasure code input bytes
|
||||
func (e encoder) Encode(data []byte) (encodedData [][]byte, err error) {
|
||||
if data == nil {
|
||||
return nil, iodine.New(errors.New("invalid argument"), nil)
|
||||
return nil, iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
encodedData, err = e.encoder.Encode(data)
|
||||
if err != nil {
|
||||
|
|
140
pkg/storage/donut/donut_errors.go
Normal file
140
pkg/storage/donut/donut_errors.go
Normal file
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
* Minimalist Object Storage, (C) 2015 Minio, 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.
|
||||
*/
|
||||
|
||||
package donut
|
||||
|
||||
// InvalidArgument invalid argument
|
||||
type InvalidArgument struct{}
|
||||
|
||||
func (e InvalidArgument) Error() string {
|
||||
return "Invalid argument"
|
||||
}
|
||||
|
||||
// UnsupportedFilesystem unsupported filesystem type
|
||||
type UnsupportedFilesystem struct {
|
||||
Type string
|
||||
}
|
||||
|
||||
func (e UnsupportedFilesystem) Error() string {
|
||||
return "Unsupported filesystem: " + e.Type
|
||||
}
|
||||
|
||||
// BucketNotFound bucket does not exist
|
||||
type BucketNotFound struct {
|
||||
Bucket string
|
||||
}
|
||||
|
||||
func (e BucketNotFound) Error() string {
|
||||
return "Bucket not found: " + e.Bucket
|
||||
}
|
||||
|
||||
// ObjectExists object exists
|
||||
type ObjectExists struct {
|
||||
Object string
|
||||
}
|
||||
|
||||
func (e ObjectExists) Error() string {
|
||||
return "Object exists: " + e.Object
|
||||
}
|
||||
|
||||
// ObjectNotFound object does not exist
|
||||
type ObjectNotFound struct {
|
||||
Object string
|
||||
}
|
||||
|
||||
func (e ObjectNotFound) Error() string {
|
||||
return "Object not found: " + e.Object
|
||||
}
|
||||
|
||||
// ObjectCorrupted object found to be corrupted
|
||||
type ObjectCorrupted struct {
|
||||
Object string
|
||||
}
|
||||
|
||||
func (e ObjectCorrupted) Error() string {
|
||||
return "Object found corrupted: " + e.Object
|
||||
}
|
||||
|
||||
// BucketExists bucket exists
|
||||
type BucketExists struct {
|
||||
Bucket string
|
||||
}
|
||||
|
||||
func (e BucketExists) Error() string {
|
||||
return "Bucket exists: " + e.Bucket
|
||||
}
|
||||
|
||||
// CorruptedBackend backend found to be corrupted
|
||||
type CorruptedBackend struct {
|
||||
Backend string
|
||||
}
|
||||
|
||||
func (e CorruptedBackend) Error() string {
|
||||
return "Corrupted backend: " + e.Backend
|
||||
}
|
||||
|
||||
// NotImplemented function not implemented
|
||||
type NotImplemented struct {
|
||||
Function string
|
||||
}
|
||||
|
||||
func (e NotImplemented) Error() string {
|
||||
return "Not implemented: " + e.Function
|
||||
}
|
||||
|
||||
// InvalidDisksArgument invalid number of disks per node
|
||||
type InvalidDisksArgument struct{}
|
||||
|
||||
func (e InvalidDisksArgument) Error() string {
|
||||
return "Invalid number of disks per node"
|
||||
}
|
||||
|
||||
// BadDigest bad md5sum
|
||||
type BadDigest struct{}
|
||||
|
||||
func (e BadDigest) Error() string {
|
||||
return "Bad digest"
|
||||
}
|
||||
|
||||
// ParityOverflow parity over flow
|
||||
type ParityOverflow struct{}
|
||||
|
||||
func (e ParityOverflow) Error() string {
|
||||
return "Parity overflow"
|
||||
}
|
||||
|
||||
// ChecksumMismatch checksum mismatch
|
||||
type ChecksumMismatch struct{}
|
||||
|
||||
func (e ChecksumMismatch) Error() string {
|
||||
return "Checksum mismatch"
|
||||
}
|
||||
|
||||
// MissingErasureTechnique missing erasure technique
|
||||
type MissingErasureTechnique struct{}
|
||||
|
||||
func (e MissingErasureTechnique) Error() string {
|
||||
return "Missing erasure technique"
|
||||
}
|
||||
|
||||
// InvalidErasureTechnique invalid erasure technique
|
||||
type InvalidErasureTechnique struct {
|
||||
Technique string
|
||||
}
|
||||
|
||||
func (e InvalidErasureTechnique) Error() string {
|
||||
return "Invalid erasure technique: " + e.Technique
|
||||
}
|
|
@ -16,11 +16,7 @@
|
|||
|
||||
package donut
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/minio/minio/pkg/iodine"
|
||||
)
|
||||
import "github.com/minio/minio/pkg/iodine"
|
||||
|
||||
// node struct internal
|
||||
type node struct {
|
||||
|
@ -31,7 +27,7 @@ type node struct {
|
|||
// NewNode - instantiates a new node
|
||||
func NewNode(hostname string) (Node, error) {
|
||||
if hostname == "" {
|
||||
return nil, iodine.New(errors.New("invalid argument"), nil)
|
||||
return nil, iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
disks := make(map[string]Disk)
|
||||
n := node{
|
||||
|
@ -54,7 +50,7 @@ func (n node) ListDisks() (map[string]Disk, error) {
|
|||
// AttachDisk - attach a disk
|
||||
func (n node) AttachDisk(disk Disk) error {
|
||||
if disk == nil {
|
||||
return iodine.New(errors.New("Invalid argument"), nil)
|
||||
return iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
n.disks[disk.GetPath()] = disk
|
||||
return nil
|
||||
|
@ -68,10 +64,10 @@ func (n node) DetachDisk(disk Disk) error {
|
|||
|
||||
// SaveConfig - save node configuration
|
||||
func (n node) SaveConfig() error {
|
||||
return errors.New("Not Implemented")
|
||||
return iodine.New(NotImplemented{Function: "SaveConfig"}, nil)
|
||||
}
|
||||
|
||||
// LoadConfig - load node configuration from saved configs
|
||||
func (n node) LoadConfig() error {
|
||||
return errors.New("Not Implemented")
|
||||
return iodine.New(NotImplemented{Function: "LoadConfig"}, nil)
|
||||
}
|
||||
|
|
|
@ -18,9 +18,10 @@ package donut
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/minio/minio/pkg/iodine"
|
||||
)
|
||||
|
||||
// object internal struct
|
||||
|
@ -34,7 +35,7 @@ type object struct {
|
|||
// NewObject - instantiate a new object
|
||||
func NewObject(objectName, p string) (Object, error) {
|
||||
if objectName == "" {
|
||||
return nil, errors.New("invalid argument")
|
||||
return nil, iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
o := object{}
|
||||
o.name = objectName
|
||||
|
@ -46,10 +47,10 @@ func (o object) GetObjectMetadata() (map[string]string, error) {
|
|||
objectMetadata := make(map[string]string)
|
||||
objectMetadataBytes, err := ioutil.ReadFile(filepath.Join(o.objectPath, objectMetadataConfig))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, iodine.New(err, nil)
|
||||
}
|
||||
if err := json.Unmarshal(objectMetadataBytes, &objectMetadata); err != nil {
|
||||
return nil, err
|
||||
return nil, iodine.New(err, nil)
|
||||
}
|
||||
o.objectMetadata = objectMetadata
|
||||
return o.objectMetadata, nil
|
||||
|
@ -59,10 +60,10 @@ func (o object) GetDonutObjectMetadata() (map[string]string, error) {
|
|||
donutObjectMetadata := make(map[string]string)
|
||||
donutObjectMetadataBytes, err := ioutil.ReadFile(filepath.Join(o.objectPath, donutObjectMetadataConfig))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, iodine.New(err, nil)
|
||||
}
|
||||
if err := json.Unmarshal(donutObjectMetadataBytes, &donutObjectMetadata); err != nil {
|
||||
return nil, err
|
||||
return nil, iodine.New(err, nil)
|
||||
}
|
||||
o.donutObjectMetadata = donutObjectMetadata
|
||||
return o.donutObjectMetadata, nil
|
||||
|
|
|
@ -2,7 +2,6 @@ package donut
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/minio/minio/pkg/iodine"
|
||||
|
@ -10,7 +9,7 @@ import (
|
|||
|
||||
// Heal - heal a donut and fix bad data blocks
|
||||
func (d donut) Heal() error {
|
||||
return errors.New("Not Implemented")
|
||||
return iodine.New(NotImplemented{Function: "Heal"}, nil)
|
||||
}
|
||||
|
||||
// Info - return info about donut configuration
|
||||
|
@ -33,7 +32,7 @@ func (d donut) Info() (nodeDiskMap map[string][]string, err error) {
|
|||
// AttachNode - attach node
|
||||
func (d donut) AttachNode(node Node) error {
|
||||
if node == nil {
|
||||
return iodine.New(errors.New("invalid argument"), nil)
|
||||
return iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
d.nodes[node.GetNodeName()] = node
|
||||
return nil
|
||||
|
@ -72,5 +71,5 @@ func (d donut) SaveConfig() error {
|
|||
|
||||
// LoadConfig - load configuration
|
||||
func (d donut) LoadConfig() error {
|
||||
return errors.New("Not Implemented")
|
||||
return iodine.New(NotImplemented{Function: "LoadConfig"}, nil)
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package donut
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
@ -29,7 +28,7 @@ import (
|
|||
// MakeBucket - make a new bucket
|
||||
func (d donut) MakeBucket(bucket, acl string) error {
|
||||
if bucket == "" || strings.TrimSpace(bucket) == "" {
|
||||
return iodine.New(errors.New("invalid argument"), nil)
|
||||
return iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
return d.makeDonutBucket(bucket, acl)
|
||||
}
|
||||
|
@ -41,7 +40,7 @@ func (d donut) GetBucketMetadata(bucket string) (map[string]string, error) {
|
|||
return nil, iodine.New(err, nil)
|
||||
}
|
||||
if _, ok := d.buckets[bucket]; !ok {
|
||||
return nil, iodine.New(errors.New("bucket does not exist"), nil)
|
||||
return nil, iodine.New(BucketNotFound{Bucket: bucket}, nil)
|
||||
}
|
||||
metadata, err := d.getDonutBucketMetadata()
|
||||
if err != nil {
|
||||
|
@ -98,7 +97,7 @@ func (d donut) ListObjects(bucket, prefix, marker, delimiter string, maxkeys int
|
|||
return nil, nil, false, iodine.New(err, errParams)
|
||||
}
|
||||
if _, ok := d.buckets[bucket]; !ok {
|
||||
return nil, nil, false, iodine.New(errors.New("bucket does not exist"), errParams)
|
||||
return nil, nil, false, iodine.New(BucketNotFound{Bucket: bucket}, errParams)
|
||||
}
|
||||
objectList, err := d.buckets[bucket].ListObjects()
|
||||
if err != nil {
|
||||
|
@ -165,17 +164,17 @@ func (d donut) PutObject(bucket, object, expectedMD5Sum string, reader io.ReadCl
|
|||
"object": object,
|
||||
}
|
||||
if bucket == "" || strings.TrimSpace(bucket) == "" {
|
||||
return "", iodine.New(errors.New("invalid argument"), errParams)
|
||||
return "", iodine.New(InvalidArgument{}, errParams)
|
||||
}
|
||||
if object == "" || strings.TrimSpace(object) == "" {
|
||||
return "", iodine.New(errors.New("invalid argument"), errParams)
|
||||
return "", iodine.New(InvalidArgument{}, errParams)
|
||||
}
|
||||
err := d.getDonutBuckets()
|
||||
if err != nil {
|
||||
return "", iodine.New(err, errParams)
|
||||
}
|
||||
if _, ok := d.buckets[bucket]; !ok {
|
||||
return "", iodine.New(errors.New("bucket does not exist"), nil)
|
||||
return "", iodine.New(BucketNotFound{Bucket: bucket}, nil)
|
||||
}
|
||||
objectList, err := d.buckets[bucket].ListObjects()
|
||||
if err != nil {
|
||||
|
@ -183,7 +182,7 @@ func (d donut) PutObject(bucket, object, expectedMD5Sum string, reader io.ReadCl
|
|||
}
|
||||
for objectName := range objectList {
|
||||
if objectName == object {
|
||||
return "", iodine.New(errors.New("object exists"), nil)
|
||||
return "", iodine.New(ObjectExists{Object: object}, nil)
|
||||
}
|
||||
}
|
||||
md5sum, err := d.buckets[bucket].PutObject(object, reader, expectedMD5Sum, metadata)
|
||||
|
@ -200,17 +199,17 @@ func (d donut) GetObject(bucket, object string) (reader io.ReadCloser, size int6
|
|||
"object": object,
|
||||
}
|
||||
if bucket == "" || strings.TrimSpace(bucket) == "" {
|
||||
return nil, 0, iodine.New(errors.New("invalid argument"), errParams)
|
||||
return nil, 0, iodine.New(InvalidArgument{}, errParams)
|
||||
}
|
||||
if object == "" || strings.TrimSpace(object) == "" {
|
||||
return nil, 0, iodine.New(errors.New("invalid argument"), errParams)
|
||||
return nil, 0, iodine.New(InvalidArgument{}, errParams)
|
||||
}
|
||||
err = d.getDonutBuckets()
|
||||
if err != nil {
|
||||
return nil, 0, iodine.New(err, nil)
|
||||
}
|
||||
if _, ok := d.buckets[bucket]; !ok {
|
||||
return nil, 0, iodine.New(errors.New("bucket does not exist"), errParams)
|
||||
return nil, 0, iodine.New(BucketNotFound{Bucket: bucket}, errParams)
|
||||
}
|
||||
objectList, err := d.buckets[bucket].ListObjects()
|
||||
if err != nil {
|
||||
|
@ -221,7 +220,7 @@ func (d donut) GetObject(bucket, object string) (reader io.ReadCloser, size int6
|
|||
return d.buckets[bucket].GetObject(object)
|
||||
}
|
||||
}
|
||||
return nil, 0, iodine.New(errors.New("object not found"), nil)
|
||||
return nil, 0, iodine.New(ObjectNotFound{Object: object}, nil)
|
||||
}
|
||||
|
||||
// GetObjectMetadata - get object metadata
|
||||
|
@ -235,7 +234,7 @@ func (d donut) GetObjectMetadata(bucket, object string) (map[string]string, erro
|
|||
return nil, iodine.New(err, errParams)
|
||||
}
|
||||
if _, ok := d.buckets[bucket]; !ok {
|
||||
return nil, iodine.New(errors.New("bucket does not exist"), errParams)
|
||||
return nil, iodine.New(BucketNotFound{Bucket: bucket}, errParams)
|
||||
}
|
||||
objectList, err := d.buckets[bucket].ListObjects()
|
||||
if err != nil {
|
||||
|
@ -243,7 +242,7 @@ func (d donut) GetObjectMetadata(bucket, object string) (map[string]string, erro
|
|||
}
|
||||
donutObject, ok := objectList[object]
|
||||
if !ok {
|
||||
return nil, iodine.New(errors.New("object does not exist"), errParams)
|
||||
return nil, iodine.New(ObjectNotFound{Object: object}, errParams)
|
||||
}
|
||||
return donutObject.GetObjectMetadata()
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package donut
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
@ -111,7 +110,7 @@ func (d donut) makeDonutBucket(bucketName, acl string) error {
|
|||
return iodine.New(err, nil)
|
||||
}
|
||||
if _, ok := d.buckets[bucketName]; ok {
|
||||
return iodine.New(errors.New("bucket exists"), nil)
|
||||
return iodine.New(BucketExists{Bucket: bucketName}, nil)
|
||||
}
|
||||
bucket, bucketMetadata, err := NewBucket(bucketName, acl, d.name, d.nodes)
|
||||
if err != nil {
|
||||
|
@ -169,7 +168,7 @@ func (d donut) getDonutBuckets() error {
|
|||
for _, dir := range dirs {
|
||||
splitDir := strings.Split(dir.Name(), "$")
|
||||
if len(splitDir) < 3 {
|
||||
return iodine.New(errors.New("corrupted backend"), nil)
|
||||
return iodine.New(CorruptedBackend{Backend: dir.Name()}, nil)
|
||||
}
|
||||
bucketName := splitDir[0]
|
||||
// we dont need this NewBucket once we cache from makeDonutBucket()
|
||||
|
|
|
@ -29,8 +29,6 @@ import (
|
|||
|
||||
"io/ioutil"
|
||||
|
||||
"errors"
|
||||
|
||||
"github.com/minio/minio/pkg/iodine"
|
||||
"github.com/minio/minio/pkg/storage/donut"
|
||||
"github.com/minio/minio/pkg/storage/drivers"
|
||||
|
@ -430,25 +428,25 @@ func (d donutDriver) CreateObject(bucketName, objectName, contentType, expectedM
|
|||
}
|
||||
|
||||
func (d donutDriver) ListMultipartUploads(bucket string, resources drivers.BucketMultipartResourcesMetadata) (drivers.BucketMultipartResourcesMetadata, error) {
|
||||
return drivers.BucketMultipartResourcesMetadata{}, iodine.New(errors.New("Not Implemented"), nil)
|
||||
return drivers.BucketMultipartResourcesMetadata{}, iodine.New(drivers.APINotImplemented{API: "ListMultipartUploads"}, nil)
|
||||
}
|
||||
|
||||
func (d donutDriver) NewMultipartUpload(bucket, key, contentType string) (string, error) {
|
||||
return "", iodine.New(errors.New("Not Implemented"), nil)
|
||||
return "", iodine.New(drivers.APINotImplemented{API: "NewMultipartUpload"}, nil)
|
||||
}
|
||||
|
||||
func (d donutDriver) CreateObjectPart(bucket, key, uploadID string, partID int, contentType, expectedMD5Sum string, size int64, data io.Reader) (string, error) {
|
||||
return "", iodine.New(errors.New("Not Implemented"), nil)
|
||||
return "", iodine.New(drivers.APINotImplemented{API: "CreateObjectPart"}, nil)
|
||||
}
|
||||
|
||||
func (d donutDriver) CompleteMultipartUpload(bucket, key, uploadID string, parts map[int]string) (string, error) {
|
||||
return "", iodine.New(errors.New("Not Implemented"), nil)
|
||||
return "", iodine.New(drivers.APINotImplemented{API: "CompleteMultipartUpload"}, nil)
|
||||
}
|
||||
|
||||
func (d donutDriver) ListObjectParts(bucket, key string, resources drivers.ObjectResourcesMetadata) (drivers.ObjectResourcesMetadata, error) {
|
||||
return drivers.ObjectResourcesMetadata{}, iodine.New(errors.New("Not Implemented"), nil)
|
||||
return drivers.ObjectResourcesMetadata{}, iodine.New(drivers.APINotImplemented{API: "ListObjectParts"}, nil)
|
||||
}
|
||||
|
||||
func (d donutDriver) AbortMultipartUpload(bucket, key, uploadID string) error {
|
||||
return iodine.New(errors.New("Not Implemented"), nil)
|
||||
return iodine.New(drivers.APINotImplemented{API: "AbortMultipartUpload"}, nil)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue