2015-10-16 14:26:01 -04:00
|
|
|
/*
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
|
|
|
* Minio Cloud Storage, (C) 2015, 2016 Minio, Inc.
|
2015-10-16 14:26:01 -04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package fs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2015-12-06 17:31:20 -05:00
|
|
|
"path/filepath"
|
2015-10-16 14:26:01 -04:00
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
|
2016-02-10 19:40:09 -05:00
|
|
|
"github.com/minio/minio/pkg/probe"
|
2015-10-16 14:26:01 -04:00
|
|
|
)
|
|
|
|
|
2016-02-18 03:38:58 -05:00
|
|
|
// ListObjectParams - list object params used for list object map
|
|
|
|
type ListObjectParams struct {
|
|
|
|
bucket string
|
|
|
|
delimiter string
|
|
|
|
marker string
|
|
|
|
prefix string
|
|
|
|
}
|
|
|
|
|
2015-10-17 22:17:33 -04:00
|
|
|
// Filesystem - local variables
|
|
|
|
type Filesystem struct {
|
2016-02-18 03:38:58 -05:00
|
|
|
path string
|
|
|
|
minFreeDisk int64
|
|
|
|
rwLock *sync.RWMutex
|
|
|
|
multiparts *Multiparts
|
|
|
|
listObjectMap map[ListObjectParams][]ObjectInfoChannel
|
|
|
|
listObjectMapMutex *sync.Mutex
|
|
|
|
}
|
|
|
|
|
|
|
|
func (fs *Filesystem) pushListObjectCh(params ListObjectParams, ch ObjectInfoChannel) {
|
|
|
|
fs.listObjectMapMutex.Lock()
|
|
|
|
defer fs.listObjectMapMutex.Unlock()
|
|
|
|
|
|
|
|
channels := []ObjectInfoChannel{ch}
|
|
|
|
if _, ok := fs.listObjectMap[params]; ok {
|
|
|
|
channels = append(fs.listObjectMap[params], ch)
|
|
|
|
}
|
|
|
|
|
|
|
|
fs.listObjectMap[params] = channels
|
|
|
|
}
|
|
|
|
|
|
|
|
func (fs *Filesystem) popListObjectCh(params ListObjectParams) *ObjectInfoChannel {
|
|
|
|
fs.listObjectMapMutex.Lock()
|
|
|
|
defer fs.listObjectMapMutex.Unlock()
|
|
|
|
|
|
|
|
if channels, ok := fs.listObjectMap[params]; ok {
|
|
|
|
for i, channel := range channels {
|
|
|
|
if !channel.IsTimedOut() {
|
|
|
|
chs := channels[i+1:]
|
|
|
|
if len(chs) > 0 {
|
|
|
|
fs.listObjectMap[params] = chs
|
|
|
|
} else {
|
|
|
|
delete(fs.listObjectMap, params)
|
|
|
|
}
|
|
|
|
|
|
|
|
return &channel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// As all channels are timed out, delete the map entry
|
|
|
|
delete(fs.listObjectMap, params)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
2015-11-01 23:56:54 -05:00
|
|
|
}
|
|
|
|
|
2015-10-16 14:26:01 -04:00
|
|
|
// MultipartSession holds active session information
|
|
|
|
type MultipartSession struct {
|
|
|
|
TotalParts int
|
2016-02-05 23:05:56 -05:00
|
|
|
ObjectName string
|
2015-10-16 14:26:01 -04:00
|
|
|
UploadID string
|
|
|
|
Initiated time.Time
|
2016-02-05 19:47:31 -05:00
|
|
|
Parts []PartMetadata
|
2015-10-16 14:26:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Multiparts collection of many parts
|
|
|
|
type Multiparts struct {
|
|
|
|
Version string `json:"version"`
|
|
|
|
ActiveSession map[string]*MultipartSession `json:"activeSessions"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// New instantiate a new donut
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
|
|
|
func New(rootPath string) (Filesystem, *probe.Error) {
|
2016-02-05 05:15:48 -05:00
|
|
|
setFSMultipartsMetadataPath(filepath.Join(rootPath, "$multiparts-session.json"))
|
2015-12-06 17:31:20 -05:00
|
|
|
|
2015-10-16 14:26:01 -04:00
|
|
|
var err *probe.Error
|
|
|
|
// load multiparts session from disk
|
|
|
|
var multiparts *Multiparts
|
|
|
|
multiparts, err = loadMultipartsSession()
|
|
|
|
if err != nil {
|
|
|
|
if os.IsNotExist(err.ToGoError()) {
|
|
|
|
multiparts = &Multiparts{
|
|
|
|
Version: "1",
|
|
|
|
ActiveSession: make(map[string]*MultipartSession),
|
|
|
|
}
|
2016-02-18 20:16:41 -05:00
|
|
|
if err = saveMultipartsSession(*multiparts); err != nil {
|
2015-10-17 22:17:33 -04:00
|
|
|
return Filesystem{}, err.Trace()
|
2015-10-16 14:26:01 -04:00
|
|
|
}
|
|
|
|
} else {
|
2015-10-17 22:17:33 -04:00
|
|
|
return Filesystem{}, err.Trace()
|
2015-10-16 14:26:01 -04:00
|
|
|
}
|
|
|
|
}
|
2016-02-04 23:40:58 -05:00
|
|
|
|
|
|
|
fs := Filesystem{
|
|
|
|
rwLock: &sync.RWMutex{},
|
|
|
|
}
|
2016-01-19 20:49:48 -05:00
|
|
|
fs.path = rootPath
|
|
|
|
fs.multiparts = multiparts
|
accessPolicy: Implement Put, Get, Delete access policy.
This patch implements Get,Put,Delete bucket policies
Supporting - http://docs.aws.amazon.com/AmazonS3/latest/dev/access-policy-language-overview.html
Currently supports following actions.
"*": true,
"s3:*": true,
"s3:GetObject": true,
"s3:ListBucket": true,
"s3:PutObject": true,
"s3:CreateBucket": true,
"s3:GetBucketLocation": true,
"s3:DeleteBucket": true,
"s3:DeleteObject": true,
"s3:AbortMultipartUpload": true,
"s3:ListBucketMultipartUploads": true,
"s3:ListMultipartUploadParts": true,
following conditions for "StringEquals" and "StringNotEquals"
"s3:prefix", "s3:max-keys"
2016-02-03 19:46:56 -05:00
|
|
|
|
2016-01-25 02:03:38 -05:00
|
|
|
/// Defaults
|
|
|
|
|
|
|
|
// minium free disk required for i/o operations to succeed.
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
|
|
|
fs.minFreeDisk = 5
|
2016-01-25 02:03:38 -05:00
|
|
|
|
2016-02-18 03:38:58 -05:00
|
|
|
fs.listObjectMap = make(map[ListObjectParams][]ObjectInfoChannel)
|
|
|
|
fs.listObjectMapMutex = &sync.Mutex{}
|
|
|
|
|
2016-01-25 02:03:38 -05:00
|
|
|
// Return here.
|
|
|
|
return fs, nil
|
2015-10-16 14:26:01 -04:00
|
|
|
}
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
|
|
|
|
|
|
|
// GetRootPath - get root path.
|
|
|
|
func (fs Filesystem) GetRootPath() string {
|
|
|
|
return fs.path
|
|
|
|
}
|