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
import (
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/minio/minio-xl/pkg/probe"
"github.com/minio/minio/pkg/disk"
"github.com/minio/minio/pkg/ioutils"
)
/// Bucket Operations
@ -71,14 +69,9 @@ func (fs Filesystem) DeleteBucket(bucket string) *probe.Error {
// ListBuckets - Get service.
func (fs Filesystem) ListBuckets() ([]BucketMetadata, *probe.Error) {
files, err := ioutils.ReadDirN(fs.path, fs.maxBuckets)
if err != nil && err != io.EOF {
return []BucketMetadata{}, probe.NewError(err)
}
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)
files, e := ioutil.ReadDir(fs.path)
if e != nil {
return []BucketMetadata{}, probe.NewError(e)
}
var metadataList []BucketMetadata
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
// compatible way for all operating systems.
func (fs Filesystem) denormalizeBucket(bucket string) string {
buckets, e := ioutils.ReadDirNamesN(fs.path, fs.maxBuckets)
buckets, e := ioutil.ReadDir(fs.path)
if e != nil {
return bucket
}
for _, b := range buckets {
// Verify if lowercase version of the bucket is equal to the
// incoming bucket, then use the proper name.
if strings.ToLower(b) == bucket {
return b
if strings.ToLower(b.Name()) == bucket {
return b.Name()
}
}
return bucket

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

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

@ -143,7 +143,7 @@ func getNewWebAPI(conf cloudServerConfig) *WebAPI {
// getNewCloudStorageAPI instantiate a new 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)
return CloudStorageAPI{

@ -34,8 +34,14 @@ import (
)
var serverCmd = cli.Command{
Name: "server",
Usage: "Start Minio cloud storage server.",
Name: "server",
Usage: "Start Minio cloud storage server.",
Flags: []cli.Flag{
cli.StringFlag{
Name: "min-free-disk, M",
Value: "5%",
},
},
Action: serverMain,
CustomHelpTemplate: `NAME:
minio {{.Name}} - {{.Usage}}
@ -43,8 +49,9 @@ var serverCmd = cli.Command{
USAGE:
minio {{.Name}} [OPTION VALUE] PATH
OPTION = min-free-disk VALUE = NN% [DEFAULT: 10%]
OPTIONS:
{{range .Flags}}{{.}}
{{end}}
EXAMPLES:
1. Start minio server on Linux.
$ minio {{.Name}} /home/shared
@ -56,10 +63,7 @@ EXAMPLES:
$ minio --address 192.168.1.101:9000 {{.Name}} /home/shared
4. Start minio server with minimum free disk threshold to 5%
$ 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
$ minio {{.Name}} --min-free-disk 5% /home/shared/Pictures
`,
}
@ -266,7 +270,7 @@ func checkServerSyntax(c *cli.Context) {
if !c.Args().Present() || c.Args().First() == "help" {
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)
}
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)
}
var minFreeDisk int64
var maxBuckets int
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
}
}
minFreeDisk, err := parsePercentToInt(c.String("min-free-disk"), 64)
fatalIf(err.Trace(c.String("min-free-disk")), "Invalid minium free disk size "+c.String("min-free-disk")+" passed.", nil)
path := strings.TrimSpace(c.Args().Last())
// Last argument is always path
@ -335,7 +307,6 @@ func serverMain(c *cli.Context) {
SecretAccessKey: conf.Credentials.SecretAccessKey,
Path: path,
MinFreeDisk: minFreeDisk,
MaxBuckets: maxBuckets,
TLS: tls,
CertFile: certFile,
KeyFile: keyFile,

Loading…
Cancel
Save