Merge pull request #630 from harshavardhana/pr_out_misc_changes_before_capturing_proper_video

This commit is contained in:
Harshavardhana 2015-06-03 18:31:16 -07:00
commit 23861fa6a7
6 changed files with 61 additions and 47 deletions

38
main.go
View File

@ -28,7 +28,6 @@ import (
"github.com/dustin/go-humanize" "github.com/dustin/go-humanize"
"github.com/minio/cli" "github.com/minio/cli"
"github.com/minio/minio/pkg/featureflags"
"github.com/minio/minio/pkg/iodine" "github.com/minio/minio/pkg/iodine"
"github.com/minio/minio/pkg/server" "github.com/minio/minio/pkg/server"
"github.com/minio/minio/pkg/server/httpserver" "github.com/minio/minio/pkg/server/httpserver"
@ -113,15 +112,17 @@ EXAMPLES:
var flags = []cli.Flag{ var flags = []cli.Flag{
cli.StringFlag{ cli.StringFlag{
Name: "api-address", Name: "address",
Value: ":9000", Value: ":9000",
Usage: "address for incoming API requests", Usage: "ADDRESS:PORT for object storage access",
},
cli.StringFlag{
Name: "web-address",
Value: ":9001",
Usage: "address for incoming Management UI requests",
}, },
/*
cli.StringFlag{
Name: "address-mgmt",
Value: ":9001",
Usage: "ADDRESS:PORT for management console access",
},
*/
cli.StringFlag{ cli.StringFlag{
Name: "cert", Name: "cert",
Hide: true, Hide: true,
@ -209,8 +210,8 @@ func runMemory(c *cli.Context) {
Expiration: expiration, Expiration: expiration,
} }
apiServer := memoryDriver.GetStartServerFunc() apiServer := memoryDriver.GetStartServerFunc()
webServer := getWebServerConfigFunc(c) // webServer := getWebServerConfigFunc(c)
servers := []server.StartServerFunc{apiServer, webServer} servers := []server.StartServerFunc{apiServer} //, webServer}
server.StartMinio(servers) server.StartMinio(servers)
} }
@ -238,8 +239,8 @@ func runDonut(c *cli.Context) {
Paths: paths, Paths: paths,
} }
apiServer := donutDriver.GetStartServerFunc() apiServer := donutDriver.GetStartServerFunc()
webServer := getWebServerConfigFunc(c) // webServer := getWebServerConfigFunc(c)
servers := []server.StartServerFunc{apiServer, webServer} servers := []server.StartServerFunc{apiServer} //, webServer}
server.StartMinio(servers) server.StartMinio(servers)
} }
@ -253,8 +254,8 @@ func runFilesystem(c *cli.Context) {
Path: c.Args()[0], Path: c.Args()[0],
} }
apiServer := fsDriver.GetStartServerFunc() apiServer := fsDriver.GetStartServerFunc()
webServer := getWebServerConfigFunc(c) // webServer := getWebServerConfigFunc(c)
servers := []server.StartServerFunc{apiServer, webServer} servers := []server.StartServerFunc{apiServer} //, webServer}
server.StartMinio(servers) server.StartMinio(servers)
} }
@ -266,16 +267,17 @@ func getAPIServerConfig(c *cli.Context) httpserver.Config {
} }
tls := (certFile != "" && keyFile != "") tls := (certFile != "" && keyFile != "")
return httpserver.Config{ return httpserver.Config{
Address: c.GlobalString("api-address"), Address: c.GlobalString("address"),
TLS: tls, TLS: tls,
CertFile: certFile, CertFile: certFile,
KeyFile: keyFile, KeyFile: keyFile,
} }
} }
/*
func getWebServerConfigFunc(c *cli.Context) server.StartServerFunc { func getWebServerConfigFunc(c *cli.Context) server.StartServerFunc {
config := httpserver.Config{ config := httpserver.Config{
Address: c.GlobalString("web-address"), Address: c.GlobalString("address-mgmt"),
TLS: false, TLS: false,
CertFile: "", CertFile: "",
KeyFile: "", KeyFile: "",
@ -285,6 +287,7 @@ func getWebServerConfigFunc(c *cli.Context) server.StartServerFunc {
} }
return webDrivers.GetStartServerFunc() return webDrivers.GetStartServerFunc()
} }
*/
// Build date // Build date
var BuildDate string var BuildDate string
@ -328,9 +331,6 @@ func getSystemData() map[string]string {
var Version = mustHashBinarySelf() var Version = mustHashBinarySelf()
func main() { func main() {
// enable features
featureflags.Enable(featureflags.MultipartPutObject)
// set up iodine // set up iodine
iodine.SetGlobalState("minio.version", Version) iodine.SetGlobalState("minio.version", Version)
iodine.SetGlobalState("minio.starttime", time.Now().Format(time.RFC3339)) iodine.SetGlobalState("minio.starttime", time.Now().Format(time.RFC3339))

View File

@ -208,7 +208,7 @@ func (h validateAuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Ignore resources handler is wrapper handler used for API request resource validation // Ignore resources handler is wrapper handler used for API request resource validation
// Since we do not support all the S3 queries, it is necessary for us to throw back a // Since we do not support all the S3 queries, it is necessary for us to throw back a
// valid error message indicating such a feature to have been not implemented. // valid error message indicating such a feature is not implemented.
func ignoreResourcesHandler(h http.Handler) http.Handler { func ignoreResourcesHandler(h http.Handler) http.Handler {
return resourceHandler{h} return resourceHandler{h}
} }

View File

@ -17,13 +17,11 @@
package api package api
import ( import (
"log"
"net/http" "net/http"
router "github.com/gorilla/mux" router "github.com/gorilla/mux"
"github.com/minio/minio/pkg/api/logging" "github.com/minio/minio/pkg/api/logging"
"github.com/minio/minio/pkg/api/quota" "github.com/minio/minio/pkg/api/quota"
"github.com/minio/minio/pkg/featureflags"
"github.com/minio/minio/pkg/storage/drivers" "github.com/minio/minio/pkg/storage/drivers"
) )
@ -44,14 +42,11 @@ func HTTPHandler(driver drivers.Driver) http.Handler {
mux.HandleFunc("/{bucket}", api.putBucketHandler).Methods("PUT") mux.HandleFunc("/{bucket}", api.putBucketHandler).Methods("PUT")
mux.HandleFunc("/{bucket}", api.headBucketHandler).Methods("HEAD") mux.HandleFunc("/{bucket}", api.headBucketHandler).Methods("HEAD")
mux.HandleFunc("/{bucket}/{object:.*}", api.headObjectHandler).Methods("HEAD") mux.HandleFunc("/{bucket}/{object:.*}", api.headObjectHandler).Methods("HEAD")
if featureflags.Get(featureflags.MultipartPutObject) { mux.HandleFunc("/{bucket}/{object:.*}", api.putObjectPartHandler).Queries("partNumber", "{partNumber:[0-9]+}", "uploadId", "{uploadId:.*}").Methods("PUT")
log.Println("Enabling feature", featureflags.MultipartPutObject) mux.HandleFunc("/{bucket}/{object:.*}", api.listObjectPartsHandler).Queries("uploadId", "{uploadId:.*}").Methods("GET")
mux.HandleFunc("/{bucket}/{object:.*}", api.putObjectPartHandler).Queries("partNumber", "{partNumber:[0-9]+}", "uploadId", "{uploadId:.*}").Methods("PUT") mux.HandleFunc("/{bucket}/{object:.*}", api.completeMultipartUploadHandler).Queries("uploadId", "{uploadId:.*}").Methods("POST")
mux.HandleFunc("/{bucket}/{object:.*}", api.listObjectPartsHandler).Queries("uploadId", "{uploadId:.*}").Methods("GET") mux.HandleFunc("/{bucket}/{object:.*}", api.newMultipartUploadHandler).Methods("POST")
mux.HandleFunc("/{bucket}/{object:.*}", api.completeMultipartUploadHandler).Queries("uploadId", "{uploadId:.*}").Methods("POST") mux.HandleFunc("/{bucket}/{object:.*}", api.abortMultipartUploadHandler).Queries("uploadId", "{uploadId:.*}").Methods("DELETE")
mux.HandleFunc("/{bucket}/{object:.*}", api.newMultipartUploadHandler).Methods("POST")
mux.HandleFunc("/{bucket}/{object:.*}", api.abortMultipartUploadHandler).Queries("uploadId", "{uploadId:.*}").Methods("DELETE")
}
mux.HandleFunc("/{bucket}/{object:.*}", api.getObjectHandler).Methods("GET") mux.HandleFunc("/{bucket}/{object:.*}", api.getObjectHandler).Methods("GET")
mux.HandleFunc("/{bucket}/{object:.*}", api.putObjectHandler).Methods("PUT") mux.HandleFunc("/{bucket}/{object:.*}", api.putObjectHandler).Methods("PUT")

View File

@ -32,7 +32,6 @@ import (
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"github.com/minio/minio/pkg/featureflags"
"github.com/minio/minio/pkg/storage/drivers" "github.com/minio/minio/pkg/storage/drivers"
"github.com/minio/minio/pkg/storage/drivers/donut" "github.com/minio/minio/pkg/storage/drivers/donut"
"github.com/minio/minio/pkg/storage/drivers/fs" "github.com/minio/minio/pkg/storage/drivers/fs"
@ -1456,7 +1455,6 @@ func (s *MySuite) TestObjectMultipartAbort(c *C) {
} }
driver := s.Driver driver := s.Driver
typedDriver := s.MockDriver typedDriver := s.MockDriver
featureflags.Enable(featureflags.MultipartPutObject)
httpHandler := HTTPHandler(driver) httpHandler := HTTPHandler(driver)
testServer := httptest.NewServer(httpHandler) testServer := httptest.NewServer(httpHandler)
@ -1540,7 +1538,6 @@ func (s *MySuite) TestBucketMultipartList(c *C) {
} }
driver := s.Driver driver := s.Driver
typedDriver := s.MockDriver typedDriver := s.MockDriver
featureflags.Enable(featureflags.MultipartPutObject)
httpHandler := HTTPHandler(driver) httpHandler := HTTPHandler(driver)
testServer := httptest.NewServer(httpHandler) testServer := httptest.NewServer(httpHandler)
@ -1630,7 +1627,6 @@ func (s *MySuite) TestObjectMultipartList(c *C) {
} }
driver := s.Driver driver := s.Driver
typedDriver := s.MockDriver typedDriver := s.MockDriver
featureflags.Enable(featureflags.MultipartPutObject)
httpHandler := HTTPHandler(driver) httpHandler := HTTPHandler(driver)
testServer := httptest.NewServer(httpHandler) testServer := httptest.NewServer(httpHandler)
@ -1715,7 +1711,6 @@ func (s *MySuite) TestObjectMultipart(c *C) {
} }
driver := s.Driver driver := s.Driver
typedDriver := s.MockDriver typedDriver := s.MockDriver
featureflags.Enable(featureflags.MultipartPutObject)
httpHandler := HTTPHandler(driver) httpHandler := HTTPHandler(driver)
testServer := httptest.NewServer(httpHandler) testServer := httptest.NewServer(httpHandler)

View File

@ -17,9 +17,10 @@
package httpserver package httpserver
import ( import (
"fmt"
"net"
"net/http" "net/http"
"strings"
"github.com/minio/minio/pkg/utils/log"
) )
// Config - http server config // Config - http server config
@ -52,12 +53,35 @@ func start(ctrlChannel <-chan string, errorChannel chan<- error,
Handler: router, Handler: router,
MaxHeaderBytes: 1 << 20, MaxHeaderBytes: 1 << 20,
} }
log.Println("Starting HTTP Server on:", config.Address)
host, port, err := net.SplitHostPort(config.Address)
errorChannel <- err
var hosts []string
switch {
case host != "":
hosts = append(hosts, host)
default:
addrs, err := net.InterfaceAddrs()
errorChannel <- err
for _, addr := range addrs {
if addr.Network() == "ip+net" {
h := strings.Split(addr.String(), "/")[0]
if ip := net.ParseIP(h); ip.To4() != nil {
hosts = append(hosts, h)
}
}
}
}
switch { switch {
default: default:
for _, host := range hosts {
fmt.Printf("Starting minio server on: http://%s:%s\n", host, port)
}
err = httpServer.ListenAndServe() err = httpServer.ListenAndServe()
case config.TLS == true: case config.TLS == true:
fmt.Printf("Starting minio server on: https://%s:%s\n", host, port)
httpServer.TLSConfig = getDefaultTLSConfig() httpServer.TLSConfig = getDefaultTLSConfig()
err = httpServer.ListenAndServeTLS(config.CertFile, config.KeyFile) err = httpServer.ListenAndServeTLS(config.CertFile, config.KeyFile)
} }

View File

@ -32,14 +32,14 @@ import (
"github.com/minio/minio/pkg/utils/log" "github.com/minio/minio/pkg/utils/log"
) )
// MemoryFactory is used to build memory api servers // MemoryFactory is used to build memory api server
type MemoryFactory struct { type MemoryFactory struct {
httpserver.Config httpserver.Config
MaxMemory uint64 MaxMemory uint64
Expiration time.Duration Expiration time.Duration
} }
// GetStartServerFunc builds memory api servers // GetStartServerFunc builds memory api server
func (f MemoryFactory) GetStartServerFunc() StartServerFunc { func (f MemoryFactory) GetStartServerFunc() StartServerFunc {
return func() (chan<- string, <-chan error) { return func() (chan<- string, <-chan error) {
_, _, driver := memory.Start(f.MaxMemory, f.Expiration) _, _, driver := memory.Start(f.MaxMemory, f.Expiration)
@ -48,13 +48,13 @@ func (f MemoryFactory) GetStartServerFunc() StartServerFunc {
} }
} }
// FilesystemFactory is used to build filesystem api servers // FilesystemFactory is used to build filesystem api server
type FilesystemFactory struct { type FilesystemFactory struct {
httpserver.Config httpserver.Config
Path string Path string
} }
// GetStartServerFunc builds memory api servers // GetStartServerFunc builds memory api server
func (f FilesystemFactory) GetStartServerFunc() StartServerFunc { func (f FilesystemFactory) GetStartServerFunc() StartServerFunc {
return func() (chan<- string, <-chan error) { return func() (chan<- string, <-chan error) {
_, _, driver := fs.Start(f.Path) _, _, driver := fs.Start(f.Path)
@ -63,12 +63,12 @@ func (f FilesystemFactory) GetStartServerFunc() StartServerFunc {
} }
} }
// WebFactory is used to build web cli servers // WebFactory is used to build web cli server
type WebFactory struct { type WebFactory struct {
httpserver.Config httpserver.Config
} }
// GetStartServerFunc builds web cli servers // GetStartServerFunc builds web cli server
func (f WebFactory) GetStartServerFunc() StartServerFunc { func (f WebFactory) GetStartServerFunc() StartServerFunc {
return func() (chan<- string, <-chan error) { return func() (chan<- string, <-chan error) {
ctrl, status, _ := httpserver.Start(web.HTTPHandler(), f.Config) ctrl, status, _ := httpserver.Start(web.HTTPHandler(), f.Config)
@ -76,13 +76,13 @@ func (f WebFactory) GetStartServerFunc() StartServerFunc {
} }
} }
// DonutFactory is used to build donut api servers // DonutFactory is used to build donut api server
type DonutFactory struct { type DonutFactory struct {
httpserver.Config httpserver.Config
Paths []string Paths []string
} }
// GetStartServerFunc DonutFactory builds donut api servers // GetStartServerFunc DonutFactory builds donut api server
func (f DonutFactory) GetStartServerFunc() StartServerFunc { func (f DonutFactory) GetStartServerFunc() StartServerFunc {
return func() (chan<- string, <-chan error) { return func() (chan<- string, <-chan error) {
_, _, driver := donut.Start(f.Paths) _, _, driver := donut.Start(f.Paths)
@ -94,7 +94,7 @@ func (f DonutFactory) GetStartServerFunc() StartServerFunc {
// StartServerFunc describes a function that can be used to start a server with StartMinio // StartServerFunc describes a function that can be used to start a server with StartMinio
type StartServerFunc func() (chan<- string, <-chan error) type StartServerFunc func() (chan<- string, <-chan error)
// StartMinio starts minio servers // StartMinio starts minio server
func StartMinio(servers []StartServerFunc) { func StartMinio(servers []StartServerFunc) {
var ctrlChannels []chan<- string var ctrlChannels []chan<- string
var errChannels []<-chan error var errChannels []<-chan error