|
|
@ -2,6 +2,7 @@ package donut |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"errors" |
|
|
|
"errors" |
|
|
|
|
|
|
|
"github.com/minio-io/iodine" |
|
|
|
"strconv" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
) |
|
|
|
) |
|
|
@ -12,7 +13,7 @@ type donutBucket struct { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// GetNodes - get list of associated nodes for a given bucket
|
|
|
|
// GetNodes - get list of associated nodes for a given bucket
|
|
|
|
func (b donutBucket) GetNodes() ([]string, error) { |
|
|
|
func (b donutBucket) GetNodes() ([]string, *iodine.Error) { |
|
|
|
var nodes []string |
|
|
|
var nodes []string |
|
|
|
for _, node := range b.nodes { |
|
|
|
for _, node := range b.nodes { |
|
|
|
nodes = append(nodes, node) |
|
|
|
nodes = append(nodes, node) |
|
|
@ -20,17 +21,17 @@ func (b donutBucket) GetNodes() ([]string, error) { |
|
|
|
return nodes, nil |
|
|
|
return nodes, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (b donutBucket) AddNode(nodeID, bucketID string) error { |
|
|
|
func (b donutBucket) AddNode(nodeID, bucketID string) *iodine.Error { |
|
|
|
tokens := strings.Split(bucketID, ":") |
|
|
|
tokens := strings.Split(bucketID, ":") |
|
|
|
if len(tokens) != 3 { |
|
|
|
if len(tokens) != 3 { |
|
|
|
return errors.New("Bucket ID malformed: " + bucketID) |
|
|
|
return iodine.New(errors.New("Bucket ID malformed: "+bucketID), map[string]string{"nodeID": nodeID, "bucketID": bucketID}) |
|
|
|
} |
|
|
|
} |
|
|
|
// bucketName := tokens[0]
|
|
|
|
// bucketName := tokens[0]
|
|
|
|
// aggregate := tokens[1]
|
|
|
|
// aggregate := tokens[1]
|
|
|
|
// aggregate := "0"
|
|
|
|
// aggregate := "0"
|
|
|
|
part, err := strconv.Atoi(tokens[2]) |
|
|
|
part, err := strconv.Atoi(tokens[2]) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return errors.New("Part malformed: " + tokens[2]) |
|
|
|
return iodine.New(errors.New("Part malformed: "+tokens[2]), map[string]string{"nodeID": nodeID, "bucketID": bucketID}) |
|
|
|
} |
|
|
|
} |
|
|
|
b.nodes[part] = nodeID |
|
|
|
b.nodes[part] = nodeID |
|
|
|
return nil |
|
|
|
return nil |
|
|
|