minio/pkg/storage/donut/bucketdriver.go

36 lines
674 B
Go
Raw Normal View History

package donut
2015-03-24 22:58:03 -04:00
import (
"errors"
"strconv"
"strings"
)
type bucketDriver struct {
2015-03-24 22:58:03 -04:00
nodes []string
}
2015-03-22 05:53:21 -04:00
func (b bucketDriver) GetNodes() ([]string, error) {
var nodes []string
2015-03-22 05:53:21 -04:00
for _, node := range b.nodes {
nodes = append(nodes, node)
}
return nodes, nil
}
2015-03-24 22:58:03 -04:00
func (b bucketDriver) AddNode(nodeID, bucketID string) error {
tokens := strings.Split(bucketID, ":")
if len(tokens) != 3 {
return errors.New("Bucket ID malformed: " + bucketID)
}
// bucketName := tokens[0]
// aggregate := tokens[1]
// aggregate := "0"
part, err := strconv.Atoi(tokens[2])
if err != nil {
return errors.New("Part malformed: " + tokens[2])
}
b.nodes[part] = nodeID
return nil
}