server: Remove max-buckets option and now max buckets is unlimited.

minio server max-buckets option removed. min-free-disk option is
now a flag.
master
Harshavardhana 9 years ago
parent e7fec22224
commit f4c8120cf9
  1. 21
      pkg/fs/fs-bucket.go
  2. 5
      pkg/fs/fs.go
  3. 2
      pkg/fs/fs_test.go
  4. 2
      routers.go
  5. 59
      server-main.go

@ -17,15 +17,13 @@
package fs package fs
import ( import (
"fmt" "io/ioutil"
"io"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/minio/minio-xl/pkg/probe" "github.com/minio/minio-xl/pkg/probe"
"github.com/minio/minio/pkg/disk" "github.com/minio/minio/pkg/disk"
"github.com/minio/minio/pkg/ioutils"
) )
/// Bucket Operations /// Bucket Operations
@ -71,14 +69,9 @@ func (fs Filesystem) DeleteBucket(bucket string) *probe.Error {
// ListBuckets - Get service. // ListBuckets - Get service.
func (fs Filesystem) ListBuckets() ([]BucketMetadata, *probe.Error) { func (fs Filesystem) ListBuckets() ([]BucketMetadata, *probe.Error) {
files, err := ioutils.ReadDirN(fs.path, fs.maxBuckets) files, e := ioutil.ReadDir(fs.path)
if err != nil && err != io.EOF { if e != nil {
return []BucketMetadata{}, probe.NewError(err) return []BucketMetadata{}, probe.NewError(e)
}
if err == io.EOF {
// This message is printed if there are more than 1000 buckets
// and we saw io.EOF.
fmt.Printf("More buckets found, truncating the bucket list to %d entries only.", fs.maxBuckets)
} }
var metadataList []BucketMetadata var metadataList []BucketMetadata
for _, file := range files { for _, file := range files {
@ -184,15 +177,15 @@ func (fs Filesystem) MakeBucket(bucket, acl string) *probe.Error {
// corresponding valid bucketnames on the backend in a platform // corresponding valid bucketnames on the backend in a platform
// compatible way for all operating systems. // compatible way for all operating systems.
func (fs Filesystem) denormalizeBucket(bucket string) string { func (fs Filesystem) denormalizeBucket(bucket string) string {
buckets, e := ioutils.ReadDirNamesN(fs.path, fs.maxBuckets) buckets, e := ioutil.ReadDir(fs.path)
if e != nil { if e != nil {
return bucket return bucket
} }
for _, b := range buckets { for _, b := range buckets {
// Verify if lowercase version of the bucket is equal to the // Verify if lowercase version of the bucket is equal to the
// incoming bucket, then use the proper name. // incoming bucket, then use the proper name.
if strings.ToLower(b) == bucket { if strings.ToLower(b.Name()) == bucket {
return b return b.Name()
} }
} }
return bucket return bucket

@ -29,7 +29,6 @@ import (
type Filesystem struct { type Filesystem struct {
path string path string
minFreeDisk int64 minFreeDisk int64
maxBuckets int
rwLock *sync.RWMutex rwLock *sync.RWMutex
multiparts *Multiparts multiparts *Multiparts
buckets *Buckets buckets *Buckets
@ -59,7 +58,7 @@ type Multiparts struct {
} }
// New instantiate a new donut // New instantiate a new donut
func New(rootPath string, minFreeDisk int64, maxBuckets int) (Filesystem, *probe.Error) { func New(rootPath string, minFreeDisk int64) (Filesystem, *probe.Error) {
setFSBucketsMetadataPath(filepath.Join(rootPath, "$buckets.json")) setFSBucketsMetadataPath(filepath.Join(rootPath, "$buckets.json"))
setFSMultipartsMetadataPath(filepath.Join(rootPath, "$multiparts-session.json")) setFSMultipartsMetadataPath(filepath.Join(rootPath, "$multiparts-session.json"))
@ -104,8 +103,6 @@ func New(rootPath string, minFreeDisk int64, maxBuckets int) (Filesystem, *probe
fs.buckets = buckets fs.buckets = buckets
/// Defaults /// Defaults
// maximum buckets to be listed from list buckets.
fs.maxBuckets = maxBuckets
// minium free disk required for i/o operations to succeed. // minium free disk required for i/o operations to succeed.
fs.minFreeDisk = minFreeDisk fs.minFreeDisk = minFreeDisk

@ -36,7 +36,7 @@ func (s *MySuite) TestAPISuite(c *C) {
path, e := ioutil.TempDir(os.TempDir(), "minio-") path, e := ioutil.TempDir(os.TempDir(), "minio-")
c.Check(e, IsNil) c.Check(e, IsNil)
storageList = append(storageList, path) storageList = append(storageList, path)
store, err := New(path, 0, 1000) store, err := New(path, 0)
c.Check(err, IsNil) c.Check(err, IsNil)
return store return store
} }

@ -143,7 +143,7 @@ func getNewWebAPI(conf cloudServerConfig) *WebAPI {
// getNewCloudStorageAPI instantiate a new CloudStorageAPI. // getNewCloudStorageAPI instantiate a new CloudStorageAPI.
func getNewCloudStorageAPI(conf cloudServerConfig) CloudStorageAPI { func getNewCloudStorageAPI(conf cloudServerConfig) CloudStorageAPI {
fs, err := fs.New(conf.Path, conf.MinFreeDisk, conf.MaxBuckets) fs, err := fs.New(conf.Path, conf.MinFreeDisk)
fatalIf(err.Trace(), "Initializing filesystem failed.", nil) fatalIf(err.Trace(), "Initializing filesystem failed.", nil)
return CloudStorageAPI{ return CloudStorageAPI{

@ -34,8 +34,14 @@ import (
) )
var serverCmd = cli.Command{ var serverCmd = cli.Command{
Name: "server", Name: "server",
Usage: "Start Minio cloud storage server.", Usage: "Start Minio cloud storage server.",
Flags: []cli.Flag{
cli.StringFlag{
Name: "min-free-disk, M",
Value: "5%",
},
},
Action: serverMain, Action: serverMain,
CustomHelpTemplate: `NAME: CustomHelpTemplate: `NAME:
minio {{.Name}} - {{.Usage}} minio {{.Name}} - {{.Usage}}
@ -43,8 +49,9 @@ var serverCmd = cli.Command{
USAGE: USAGE:
minio {{.Name}} [OPTION VALUE] PATH minio {{.Name}} [OPTION VALUE] PATH
OPTION = min-free-disk VALUE = NN% [DEFAULT: 10%] OPTIONS:
{{range .Flags}}{{.}}
{{end}}
EXAMPLES: EXAMPLES:
1. Start minio server on Linux. 1. Start minio server on Linux.
$ minio {{.Name}} /home/shared $ minio {{.Name}} /home/shared
@ -56,10 +63,7 @@ EXAMPLES:
$ minio --address 192.168.1.101:9000 {{.Name}} /home/shared $ minio --address 192.168.1.101:9000 {{.Name}} /home/shared
4. Start minio server with minimum free disk threshold to 5% 4. Start minio server with minimum free disk threshold to 5%
$ minio {{.Name}} min-free-disk 5% /home/shared/Pictures $ minio {{.Name}} --min-free-disk 5% /home/shared/Pictures
5. Start minio server with minimum free disk threshold to 15% and support upto 2000 buckets.
$ minio {{.Name}} min-free-disk 15% /home/shared/Documents max-buckets 2000
`, `,
} }
@ -266,7 +270,7 @@ func checkServerSyntax(c *cli.Context) {
if !c.Args().Present() || c.Args().First() == "help" { if !c.Args().Present() || c.Args().First() == "help" {
cli.ShowCommandHelpAndExit(c, "server", 1) cli.ShowCommandHelpAndExit(c, "server", 1)
} }
if len(c.Args()) > 5 { if len(c.Args()) > 1 {
fatalIf(probe.NewError(errInvalidArgument), "Unnecessary arguments passed. Please refer ‘mc server help’", nil) fatalIf(probe.NewError(errInvalidArgument), "Unnecessary arguments passed. Please refer ‘mc server help’", nil)
} }
path := strings.TrimSpace(c.Args().Last()) path := strings.TrimSpace(c.Args().Last())
@ -287,40 +291,8 @@ func serverMain(c *cli.Context) {
fatalIf(probe.NewError(errInvalidArgument), "Both certificate and key are required to enable https.", nil) fatalIf(probe.NewError(errInvalidArgument), "Both certificate and key are required to enable https.", nil)
} }
var minFreeDisk int64 minFreeDisk, err := parsePercentToInt(c.String("min-free-disk"), 64)
var maxBuckets int fatalIf(err.Trace(c.String("min-free-disk")), "Invalid minium free disk size "+c.String("min-free-disk")+" passed.", nil)
minFreeDiskSet := false
maxBucketsSet := false
// Default
minFreeDisk = 10
maxBuckets = 1000
args := c.Args()
for len(args) >= 2 {
switch args.First() {
case "min-free-disk":
if minFreeDiskSet {
fatalIf(probe.NewError(errInvalidArgument), "Minimum free disk should be set only once.", nil)
}
args = args.Tail()
minFreeDisk, err = parsePercentToInt(args.First(), 64)
fatalIf(err.Trace(args.First()), "Invalid minium free disk size "+args.First()+" passed.", nil)
args = args.Tail()
minFreeDiskSet = true
case "max-buckets":
if maxBucketsSet {
fatalIf(probe.NewError(errInvalidArgument), "Maximum buckets should be set only once.", nil)
}
args = args.Tail()
var e error
maxBuckets, e = strconv.Atoi(args.First())
fatalIf(probe.NewError(e), "Invalid max buckets "+args.First()+" passed.", nil)
args = args.Tail()
maxBucketsSet = true
default:
cli.ShowCommandHelpAndExit(c, "server", 1) // last argument is exit code
}
}
path := strings.TrimSpace(c.Args().Last()) path := strings.TrimSpace(c.Args().Last())
// Last argument is always path // Last argument is always path
@ -335,7 +307,6 @@ func serverMain(c *cli.Context) {
SecretAccessKey: conf.Credentials.SecretAccessKey, SecretAccessKey: conf.Credentials.SecretAccessKey,
Path: path, Path: path,
MinFreeDisk: minFreeDisk, MinFreeDisk: minFreeDisk,
MaxBuckets: maxBuckets,
TLS: tls, TLS: tls,
CertFile: certFile, CertFile: certFile,
KeyFile: keyFile, KeyFile: keyFile,

Loading…
Cancel
Save