mirror of
https://github.com/minio/minio.git
synced 2024-12-28 08:05:55 -05:00
Merge pull request #478 from harshavardhana/pr_out_donut_mode_will_now_take_multiple_paths_as_argument_updated_docs_as_well
This commit is contained in:
commit
a216bf836a
22
main.go
22
main.go
@ -94,6 +94,9 @@ EXAMPLES:
|
|||||||
2. Create a temporary donut volume under "/tmp"
|
2. Create a temporary donut volume under "/tmp"
|
||||||
$ minio mode {{.Name}} /tmp
|
$ minio mode {{.Name}} /tmp
|
||||||
|
|
||||||
|
3. Create a donut volume under collection of paths
|
||||||
|
$ minio mode {{.Name}} /mnt/backup2014feb /mnt/backup2014feb
|
||||||
|
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +138,7 @@ func (f webFactory) getStartServerFunc() startServerFunc {
|
|||||||
|
|
||||||
type donutFactory struct {
|
type donutFactory struct {
|
||||||
server.Config
|
server.Config
|
||||||
path string
|
paths []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f donutFactory) getStartServerFunc() startServerFunc {
|
func (f donutFactory) getStartServerFunc() startServerFunc {
|
||||||
@ -146,7 +149,7 @@ func (f donutFactory) getStartServerFunc() startServerFunc {
|
|||||||
httpConfig.CertFile = f.CertFile
|
httpConfig.CertFile = f.CertFile
|
||||||
httpConfig.KeyFile = f.KeyFile
|
httpConfig.KeyFile = f.KeyFile
|
||||||
httpConfig.Websocket = false
|
httpConfig.Websocket = false
|
||||||
_, _, driver := donut.Start(f.path)
|
_, _, driver := donut.Start(f.paths)
|
||||||
ctrl, status, _ := httpserver.Start(api.HTTPHandler(f.Domain, driver), httpConfig)
|
ctrl, status, _ := httpserver.Start(api.HTTPHandler(f.Domain, driver), httpConfig)
|
||||||
return ctrl, status
|
return ctrl, status
|
||||||
}
|
}
|
||||||
@ -223,14 +226,21 @@ func runDonut(c *cli.Context) {
|
|||||||
if len(c.Args()) < 1 {
|
if len(c.Args()) < 1 {
|
||||||
cli.ShowCommandHelpAndExit(c, "donut", 1) // last argument is exit code
|
cli.ShowCommandHelpAndExit(c, "donut", 1) // last argument is exit code
|
||||||
}
|
}
|
||||||
p := c.Args().First()
|
|
||||||
if strings.TrimSpace(p) == "" {
|
// supporting multiple paths
|
||||||
p = path.Join(u.HomeDir, "minio-storage", "donut")
|
var paths []string
|
||||||
|
if strings.TrimSpace(c.Args().First()) == "" {
|
||||||
|
p := path.Join(u.HomeDir, "minio-storage", "donut")
|
||||||
|
paths = append(paths, p)
|
||||||
|
} else {
|
||||||
|
for _, arg := range c.Args() {
|
||||||
|
paths = append(paths, strings.TrimSpace(arg))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
apiServerConfig := getAPIServerConfig(c)
|
apiServerConfig := getAPIServerConfig(c)
|
||||||
donutDriver := donutFactory{
|
donutDriver := donutFactory{
|
||||||
Config: apiServerConfig,
|
Config: apiServerConfig,
|
||||||
path: p,
|
paths: paths,
|
||||||
}
|
}
|
||||||
apiServer := donutDriver.getStartServerFunc()
|
apiServer := donutDriver.getStartServerFunc()
|
||||||
webServer := getWebServerConfigFunc(c)
|
webServer := getWebServerConfigFunc(c)
|
||||||
|
@ -70,7 +70,9 @@ var _ = Suite(&MySuite{
|
|||||||
var _ = Suite(&MySuite{
|
var _ = Suite(&MySuite{
|
||||||
initDriver: func() (drivers.Driver, string) {
|
initDriver: func() (drivers.Driver, string) {
|
||||||
root, _ := ioutil.TempDir(os.TempDir(), "minio-api")
|
root, _ := ioutil.TempDir(os.TempDir(), "minio-api")
|
||||||
_, _, driver := donut.Start(root)
|
var roots []string
|
||||||
|
roots = append(roots, root)
|
||||||
|
_, _, driver := donut.Start(roots)
|
||||||
return driver, root
|
return driver, root
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -38,7 +38,7 @@ import (
|
|||||||
// donutDriver - creates a new single disk drivers driver using donut
|
// donutDriver - creates a new single disk drivers driver using donut
|
||||||
type donutDriver struct {
|
type donutDriver struct {
|
||||||
donut donut.Donut
|
donut donut.Donut
|
||||||
path string
|
paths []string
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -47,9 +47,9 @@ const (
|
|||||||
|
|
||||||
// This is a dummy nodeDiskMap which is going to be deprecated soon
|
// This is a dummy nodeDiskMap which is going to be deprecated soon
|
||||||
// once the Management API is standardized, this map is useful for now
|
// once the Management API is standardized, this map is useful for now
|
||||||
// to show multi disk API correctness behavior.
|
// to show multi disk API correctness and parity calculation
|
||||||
//
|
//
|
||||||
// This should be obtained from donut configuration file
|
// Ideally this should be obtained from per node configuration file
|
||||||
func createNodeDiskMap(p string) map[string][]string {
|
func createNodeDiskMap(p string) map[string][]string {
|
||||||
nodes := make(map[string][]string)
|
nodes := make(map[string][]string)
|
||||||
nodes["localhost"] = make([]string, 16)
|
nodes["localhost"] = make([]string, 16)
|
||||||
@ -65,24 +65,51 @@ func createNodeDiskMap(p string) map[string][]string {
|
|||||||
return nodes
|
return nodes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is a dummy nodeDiskMap which is going to be deprecated soon
|
||||||
|
// once the Management API is standardized, and we have way of adding
|
||||||
|
// and removing disks. This is useful for now to take inputs from CLI
|
||||||
|
func createNodeDiskMapFromSlice(paths []string) map[string][]string {
|
||||||
|
diskPaths := make([]string, len(paths))
|
||||||
|
nodes := make(map[string][]string)
|
||||||
|
for i, p := range paths {
|
||||||
|
diskPath := path.Join(p, strconv.Itoa(i))
|
||||||
|
if _, err := os.Stat(diskPath); err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
os.MkdirAll(diskPath, 0700)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diskPaths[i] = diskPath
|
||||||
|
}
|
||||||
|
nodes["localhost"] = diskPaths
|
||||||
|
return nodes
|
||||||
|
}
|
||||||
|
|
||||||
// Start a single disk subsystem
|
// Start a single disk subsystem
|
||||||
func Start(path string) (chan<- string, <-chan error, drivers.Driver) {
|
func Start(paths []string) (chan<- string, <-chan error, drivers.Driver) {
|
||||||
ctrlChannel := make(chan string)
|
ctrlChannel := make(chan string)
|
||||||
errorChannel := make(chan error)
|
errorChannel := make(chan error)
|
||||||
errParams := map[string]string{"path": path}
|
|
||||||
|
|
||||||
// Soon to be user configurable, when Management API
|
// Soon to be user configurable, when Management API is available
|
||||||
// is finished we remove "default" to something
|
// we should remove "default" to something which is passed down
|
||||||
// which is passed down from configuration
|
// from configuration paramters
|
||||||
donut, err := donut.NewDonut("default", createNodeDiskMap(path))
|
var d donut.Donut
|
||||||
if err != nil {
|
var err error
|
||||||
err = iodine.New(err, errParams)
|
if len(paths) == 1 {
|
||||||
log.Error.Println(err)
|
d, err = donut.NewDonut("default", createNodeDiskMap(paths[0]))
|
||||||
|
if err != nil {
|
||||||
|
err = iodine.New(err, nil)
|
||||||
|
log.Error.Println(err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
d, err = donut.NewDonut("default", createNodeDiskMapFromSlice(paths))
|
||||||
|
if err != nil {
|
||||||
|
err = iodine.New(err, nil)
|
||||||
|
log.Error.Println(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s := new(donutDriver)
|
s := new(donutDriver)
|
||||||
s.donut = donut
|
s.donut = d
|
||||||
s.path = path
|
s.paths = paths
|
||||||
|
|
||||||
go start(ctrlChannel, errorChannel, s)
|
go start(ctrlChannel, errorChannel, s)
|
||||||
return ctrlChannel, errorChannel, s
|
return ctrlChannel, errorChannel, s
|
||||||
@ -143,7 +170,7 @@ func (d donutDriver) GetBucketMetadata(bucketName string) (drivers.BucketMetadat
|
|||||||
}
|
}
|
||||||
acl, ok := metadata["acl"]
|
acl, ok := metadata["acl"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return drivers.BucketMetadata{}, iodine.New(drivers.BackendCorrupted{Path: d.path}, nil)
|
return drivers.BucketMetadata{}, iodine.New(drivers.BackendCorrupted{}, nil)
|
||||||
}
|
}
|
||||||
bucketMetadata := drivers.BucketMetadata{
|
bucketMetadata := drivers.BucketMetadata{
|
||||||
Name: metadata["name"],
|
Name: metadata["name"],
|
||||||
|
@ -32,13 +32,14 @@ type MySuite struct{}
|
|||||||
var _ = Suite(&MySuite{})
|
var _ = Suite(&MySuite{})
|
||||||
|
|
||||||
func (s *MySuite) TestAPISuite(c *C) {
|
func (s *MySuite) TestAPISuite(c *C) {
|
||||||
// c.Skip("Not Implemented")
|
|
||||||
var storageList []string
|
var storageList []string
|
||||||
create := func() drivers.Driver {
|
create := func() drivers.Driver {
|
||||||
path, err := ioutil.TempDir(os.TempDir(), "minio-fs-")
|
var paths []string
|
||||||
|
p, err := ioutil.TempDir(os.TempDir(), "minio-fs-")
|
||||||
c.Check(err, IsNil)
|
c.Check(err, IsNil)
|
||||||
storageList = append(storageList, path)
|
storageList = append(storageList, p)
|
||||||
_, _, store := Start(path) // TODO Make InMemory driver
|
paths = append(paths, p)
|
||||||
|
_, _, store := Start(paths)
|
||||||
return store
|
return store
|
||||||
}
|
}
|
||||||
drivers.APITestSuite(c, create)
|
drivers.APITestSuite(c, create)
|
||||||
|
Loading…
Reference in New Issue
Block a user