diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 29662152..b6b71d3d 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -27,8 +27,12 @@ "Rev": "1ee5c115af7856a16f133e2f2d3d9f91895c2ddb" }, { - "ImportPath": "github.com/minio-io/iodine", - "Rev": "8c8985d5a45e388dccb5ca280c897672abb18278" + "ImportPath": "github.com/minio-io/donut", + "Rev": "6590e6727612b90b4373e4f42b898ee159251cde" + }, + { + "ImportPath": "github.com/minio-io/erasure", + "Rev": "6e3a142ee5ce194be6339cdde8e89c094b2ec7fd" }, { "ImportPath": "github.com/minio-io/minio/pkg/utils/split", diff --git a/Godeps/_workspace/src/github.com/minio-io/donut/.gitignore b/Godeps/_workspace/src/github.com/minio-io/donut/.gitignore new file mode 100644 index 00000000..144114ec --- /dev/null +++ b/Godeps/_workspace/src/github.com/minio-io/donut/.gitignore @@ -0,0 +1,2 @@ +donut +build-constants.go \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/minio-io/donut/Godeps/Godeps.json b/Godeps/_workspace/src/github.com/minio-io/donut/Godeps/Godeps.json new file mode 100644 index 00000000..69f1022b --- /dev/null +++ b/Godeps/_workspace/src/github.com/minio-io/donut/Godeps/Godeps.json @@ -0,0 +1,22 @@ +{ + "ImportPath": "github.com/minio-io/donut", + "GoVersion": "go1.4", + "Packages": [ + "./..." + ], + "Deps": [ + { + "ImportPath": "github.com/minio-io/cli", + "Comment": "1.2.0-99-g1ee5c11", + "Rev": "1ee5c115af7856a16f133e2f2d3d9f91895c2ddb" + }, + { + "ImportPath": "github.com/minio-io/erasure", + "Rev": "6e3a142ee5ce194be6339cdde8e89c094b2ec7fd" + }, + { + "ImportPath": "github.com/minio-io/minio/pkg/utils/split", + "Rev": "936520e6e0fc5dd4ce8d04504ee991084555e57a" + } + ] +} diff --git a/Godeps/_workspace/src/github.com/minio-io/donut/Godeps/Readme b/Godeps/_workspace/src/github.com/minio-io/donut/Godeps/Readme new file mode 100644 index 00000000..4cdaa53d --- /dev/null +++ b/Godeps/_workspace/src/github.com/minio-io/donut/Godeps/Readme @@ -0,0 +1,5 @@ +This directory tree is generated automatically by godep. + +Please do not edit. + +See https://github.com/tools/godep for more information. diff --git a/pkg/encoding/erasure/LICENSE.MINIO b/Godeps/_workspace/src/github.com/minio-io/donut/LICENSE similarity index 100% rename from pkg/encoding/erasure/LICENSE.MINIO rename to Godeps/_workspace/src/github.com/minio-io/donut/LICENSE diff --git a/Godeps/_workspace/src/github.com/minio-io/donut/Makefile b/Godeps/_workspace/src/github.com/minio-io/donut/Makefile new file mode 100644 index 00000000..8475b24e --- /dev/null +++ b/Godeps/_workspace/src/github.com/minio-io/donut/Makefile @@ -0,0 +1,71 @@ +MINIOPATH=$(GOPATH)/src/github.com/minio-io/donut + +all: getdeps install + +checkdeps: + @echo "Checking deps:" + @(env bash $(PWD)/buildscripts/checkdeps.sh) + +checkgopath: + @echo "Checking if project is at ${MINIOPATH}" + @if [ ! -d ${MINIOPATH} ]; then echo "Project not found in $GOPATH, please follow instructions provided at https://github.com/Minio-io/minio/blob/master/CONTRIBUTING.md#setup-your-minio-github-repository" && exit 1; fi + +getdeps: checkdeps checkgopath + @go get github.com/tools/godep && echo "Installed godep:" + @go get github.com/golang/lint/golint && echo "Installed golint:" + @go get golang.org/x/tools/cmd/vet && echo "Installed vet:" + @go get github.com/fzipp/gocyclo && echo "Installed gocyclo:" + +verifiers: getdeps vet fmt lint cyclo + +vet: + @echo "Running $@:" + @go vet ./... +fmt: + @echo "Running $@:" + @test -z "$$(gofmt -s -l . | grep -v Godeps/_workspace/src/ | tee /dev/stderr)" || \ + echo "+ please format Go code with 'gofmt -s'" +lint: + @echo "Running $@:" + @test -z "$$(golint ./... | grep -v Godeps/_workspace/src/ | tee /dev/stderr)" + +cyclo: + @echo "Running $@:" + @test -z "$$(gocyclo -over 15 . | grep -v Godeps/_workspace/src/ | tee /dev/stderr)" + +pre-build: + @echo "Running pre-build:" + @(env bash $(PWD)/buildscripts/git-commit-id.sh) + + +build-all: getdeps verifiers + @echo "Building Libraries:" + @godep go generate github.com/minio-io/erasure + @godep go generate ./... + @godep go build ./... + +test-all: pre-build build-all + @echo "Running Test Suites:" + @godep go test -race ./... + +save: restore + @godep save ./... + +restore: + @godep restore + +env: + @godep go env + +docs-deploy: + @mkdocs gh-deploy --clean + +install: test-all + @echo "Installing donut-cli:" + @godep go install github.com/minio-io/donut/cmd/donut-cli + @mkdir -p $(HOME)/.minio/donut + +clean: + @rm -fv cover.out + @rm -fv erasure/*.syso + @rm -fv build-constants.go diff --git a/Godeps/_workspace/src/github.com/minio-io/donut/README.md b/Godeps/_workspace/src/github.com/minio-io/donut/README.md new file mode 100644 index 00000000..9d977f17 --- /dev/null +++ b/Godeps/_workspace/src/github.com/minio-io/donut/README.md @@ -0,0 +1,3 @@ +# Donut + +donut - Donut (do not delete) on disk format implementation released under [Apache license v2](./LICENSE). diff --git a/pkg/storage/donut/bucket.go b/Godeps/_workspace/src/github.com/minio-io/donut/bucket.go similarity index 100% rename from pkg/storage/donut/bucket.go rename to Godeps/_workspace/src/github.com/minio-io/donut/bucket.go diff --git a/pkg/storage/donut/bucket_internal.go b/Godeps/_workspace/src/github.com/minio-io/donut/bucket_internal.go similarity index 100% rename from pkg/storage/donut/bucket_internal.go rename to Godeps/_workspace/src/github.com/minio-io/donut/bucket_internal.go diff --git a/Godeps/_workspace/src/github.com/minio-io/donut/buildscripts/checkdeps.sh b/Godeps/_workspace/src/github.com/minio-io/donut/buildscripts/checkdeps.sh new file mode 100644 index 00000000..3d78c044 --- /dev/null +++ b/Godeps/_workspace/src/github.com/minio-io/donut/buildscripts/checkdeps.sh @@ -0,0 +1,201 @@ +#!/usr/bin/env bash +# +# Minio Commander, (C) 2015 Minio, Inc. +# +# 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. +# + +_init() { + ## Minimum required versions for build dependencies + GCC_VERSION="4.0" + CLANG_VERSION="3.5" + YASM_VERSION="1.2.0" + GIT_VERSION="1.0" + GO_VERSION="1.4" + OSX_VERSION="10.8" + UNAME=$(uname -sm) + + ## Check all dependencies are present + MISSING="" +} + +### +# +# Takes two arguments +# arg1: version number in `x.x.x` format +# arg2: version number in `x.x.x` format +# +# example: check_version "$version1" "$version2" +# +# returns: +# 0 - Installed version is equal to required +# 1 - Installed version is greater than required +# 2 - Installed version is lesser than required +# 3 - If args have length zero +# +#### +check_version () { + ## validate args + [[ -z "$1" ]] && return 3 + [[ -z "$2" ]] && return 3 + + if [[ $1 == $2 ]]; then + return 0 + fi + + local IFS=. + local i ver1=($1) ver2=($2) + # fill empty fields in ver1 with zeros + for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do + ver1[i]=0 + done + for ((i=0; i<${#ver1[@]}; i++)); do + if [[ -z ${ver2[i]} ]]; then + # fill empty fields in ver2 with zeros + ver2[i]=0 + fi + if ((10#${ver1[i]} > 10#${ver2[i]})); then + + return 1 + fi + if ((10#${ver1[i]} < 10#${ver2[i]})); then + ## Installed version is lesser than required - Bad condition + return 2 + fi + done + return 0 +} + +check_golang_env() { + echo ${GOROOT:?} 2>&1 >/dev/null + if [ $? -eq 1 ]; then + echo "ERROR" + echo "GOROOT environment variable missing, please refer to Go installation document" + echo "https://github.com/Minio-io/minio/blob/master/BUILDDEPS.md#install-go-13" + exit 1 + fi + + echo ${GOPATH:?} 2>&1 >/dev/null + if [ $? -eq 1 ]; then + echo "ERROR" + echo "GOPATH environment variable missing, please refer to Go installation document" + echo "https://github.com/Minio-io/minio/blob/master/BUILDDEPS.md#install-go-13" + exit 1 + fi +} + +is_supported_os() { + case ${UNAME%% *} in + "Linux") + os="linux" + ;; + "Darwin") + osx_host_version=$(env sw_vers -productVersion) + check_version "${osx_host_version}" "${OSX_VERSION}" + [[ $? -ge 2 ]] && die "Minimum OSX version supported is ${OSX_VERSION}" + ;; + "*") + echo "Exiting.. unsupported operating system found" + exit 1; + esac +} + +is_supported_arch() { + local supported + case ${UNAME##* } in + "x86_64") + supported=1 + ;; + *) + supported=0 + ;; + esac + if [ $supported -eq 0 ]; then + echo "Invalid arch: ${UNAME} not supported, please use x86_64/amd64" + exit 1; + fi +} + +check_deps() { + check_version "$(env go version 2>/dev/null | sed 's/^.* go\([0-9.]*\).*$/\1/')" "${GO_VERSION}" + if [ $? -ge 2 ]; then + MISSING="${MISSING} golang(1.4)" + fi + + check_version "$(env git --version 2>/dev/null | sed -e 's/^.* \([0-9.\].*\).*$/\1/' -e 's/^\([0-9.\]*\).*/\1/g')" "${GIT_VERSION}" + if [ $? -ge 2 ]; then + MISSING="${MISSING} git" + fi + + case ${UNAME%% *} in + "Linux") + check_version "$(env gcc --version 2>/dev/null | sed 's/^.* \([0-9.]*\).*$/\1/' | head -1)" "${GCC_VERSION}" + if [ $? -ge 2 ]; then + MISSING="${MISSING} build-essential" + fi + ;; + "Darwin") + check_version "$(env gcc --version 2>/dev/null | sed 's/^.* \([0-9.]*\).*$/\1/' | head -1)" "${CLANG_VERSION}" + if [ $? -ge 2 ]; then + MISSING="${MISSING} xcode-cli" + fi + ;; + "*") + ;; + esac + + check_version "$(env yasm --version 2>/dev/null | sed 's/^.* \([0-9.]*\).*$/\1/' | head -1)" "${YASM_VERSION}" + if [ $? -ge 2 ]; then + MISSING="${MISSING} yasm(1.2.0)" + fi + + env mkdocs help >/dev/null 2>&1 + if [ $? -ne 0 ]; then + MISSING="${MISSING} mkdocs" + fi +} + +main() { + echo -n "Check for supported arch.. " + is_supported_arch + + echo -n "Check for supported os.. " + is_supported_os + + echo -n "Checking if proper environment variables are set.. " + check_golang_env + + echo "Done" + echo "Using GOPATH=${GOPATH} and GOROOT=${GOROOT}" + + echo -n "Checking dependencies for Minio.. " + check_deps + + ## If dependencies are missing, warn the user and abort + if [ "x${MISSING}" != "x" ]; then + echo "ERROR" + echo + echo "The following build tools are missing:" + echo + echo "** ${MISSING} **" + echo + echo "Please install them " + echo "${MISSING}" + echo + echo "Follow https://github.com/Minio-io/minio/blob/master/BUILDDEPS.md for further instructions" + exit 1 + fi + echo "Done" +} + +_init && main "$@" diff --git a/Godeps/_workspace/src/github.com/minio-io/donut/buildscripts/git-commit-id.sh b/Godeps/_workspace/src/github.com/minio-io/donut/buildscripts/git-commit-id.sh new file mode 100644 index 00000000..bdcc7639 --- /dev/null +++ b/Godeps/_workspace/src/github.com/minio-io/donut/buildscripts/git-commit-id.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +CONST_FILE=${PWD}/cmd/donut-cli/build-constants.go + +cat > $CONST_FILE < is needed for attach") + } + if _, ok := mcDonutConfigData.Donuts[donutName]; !ok { + log.Fatalf("Requested donut name %s does not exist, please use ``mc donut make`` first\n", donutName) + } + if _, ok := mcDonutConfigData.Donuts[donutName].Node["localhost"]; !ok { + log.Fatalln("Corrupted donut config, please consult donut experts") + } + activeDisks := mcDonutConfigData.Donuts[donutName].Node["localhost"].ActiveDisks + inactiveDisks := mcDonutConfigData.Donuts[donutName].Node["localhost"].InactiveDisks + for _, disk := range disks { + activeDisks = appendUniq(activeDisks, disk) + inactiveDisks = deleteFromSlice(inactiveDisks, disk) + } + + mcDonutConfigData.Donuts[donutName].Node["localhost"] = nodeConfig{ + ActiveDisks: activeDisks, + InactiveDisks: inactiveDisks, + } + if err := saveDonutConfig(mcDonutConfigData); err != nil { + log.Fatalln(err) + } +} diff --git a/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-common.go b/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-common.go new file mode 100644 index 00000000..1105f9d4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-common.go @@ -0,0 +1,101 @@ +/* + * Minimalist Object Storage, (C) 2015 Minio, Inc. + * + * 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 main + +import ( + "strings" + + "net/url" +) + +// url2Object converts URL to bucket and objectname +func url2Object(urlStr string) (bucketName, objectName string, err error) { + u, err := url.Parse(urlStr) + if u.Path == "" { + // No bucket name passed. It is a valid case + return "", "", nil + } + splits := strings.SplitN(u.Path, "/", 3) + switch len(splits) { + case 0, 1: + bucketName = "" + objectName = "" + case 2: + bucketName = splits[1] + objectName = "" + case 3: + bucketName = splits[1] + objectName = splits[2] + } + return bucketName, objectName, nil +} + +func isStringInSlice(items []string, item string) bool { + for _, s := range items { + if s == item { + return true + } + } + return false +} + +func deleteFromSlice(items []string, item string) []string { + var newitems []string + for _, s := range items { + if s == item { + continue + } + newitems = append(newitems, s) + } + return newitems +} + +func appendUniq(slice []string, i string) []string { + for _, ele := range slice { + if ele == i { + return slice + } + } + return append(slice, i) +} + +// Is alphanumeric? +func isalnum(c rune) bool { + return '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' +} + +// isValidDonutName - verify donutName to be valid +func isValidDonutName(donutName string) bool { + if len(donutName) > 1024 || len(donutName) == 0 { + return false + } + for _, char := range donutName { + if isalnum(char) { + continue + } + switch char { + case '-': + case '.': + case '_': + case '~': + continue + default: + return false + } + } + return true +} diff --git a/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-config.go b/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-config.go new file mode 100644 index 00000000..f5aada16 --- /dev/null +++ b/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-config.go @@ -0,0 +1,105 @@ +/* + * Minimalist Object Storage, (C) 2015 Minio, Inc. + * + * 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 main + +import ( + "fmt" + "log" + "os" + "os/user" + "path" + + "encoding/json" + "io/ioutil" +) + +const ( + donutConfigDir = ".minio/donut" + donutConfigFilename = "donuts.json" +) + +type nodeConfig struct { + ActiveDisks []string + InactiveDisks []string +} + +type donutConfig struct { + Node map[string]nodeConfig +} + +type mcDonutConfig struct { + Donuts map[string]donutConfig +} + +func getDonutConfigDir() string { + u, err := user.Current() + if err != nil { + msg := fmt.Sprintf("Unable to obtain user's home directory. \nError: %s", err) + log.Fatalln(msg) + } + + return path.Join(u.HomeDir, donutConfigDir) +} + +func getDonutConfigFilename() string { + return path.Join(getDonutConfigDir(), "donuts.json") +} + +// saveDonutConfig writes configuration data in json format to donut config file. +func saveDonutConfig(donutConfigData *mcDonutConfig) error { + jsonConfig, err := json.MarshalIndent(donutConfigData, "", "\t") + if err != nil { + return err + } + + err = os.MkdirAll(getDonutConfigDir(), 0755) + if !os.IsExist(err) && err != nil { + return err + } + + configFile, err := os.OpenFile(getDonutConfigFilename(), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) + if err != nil { + return err + } + defer configFile.Close() + + _, err = configFile.Write(jsonConfig) + if err != nil { + return err + } + return nil +} + +func loadDonutConfig() (donutConfigData *mcDonutConfig, err error) { + configFile := getDonutConfigFilename() + _, err = os.Stat(configFile) + if err != nil { + return nil, err + } + + configBytes, err := ioutil.ReadFile(configFile) + if err != nil { + return nil, err + } + + err = json.Unmarshal(configBytes, &donutConfigData) + if err != nil { + return nil, err + } + + return donutConfigData, nil +} diff --git a/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-detach-disk.go b/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-detach-disk.go new file mode 100644 index 00000000..1f6ab79c --- /dev/null +++ b/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-detach-disk.go @@ -0,0 +1,66 @@ +/* + * Minimalist Object Storage, (C) 2015 Minio, Inc. + * + * 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 main + +import ( + "fmt" + "log" + + "github.com/minio-io/cli" +) + +func doDetachDiskCmd(c *cli.Context) { + if !c.Args().Present() { + log.Fatalln("no args?") + } + disks := c.Args() + mcDonutConfigData, err := loadDonutConfig() + if err != nil { + log.Fatalln(err.Error()) + } + donutName := c.String("name") + if donutName == "" { + log.Fatalln("Invalid --donut is needed for attach") + } + if _, ok := mcDonutConfigData.Donuts[donutName]; !ok { + msg := fmt.Sprintf("Requested donut name <%s> does not exist, please use ``mc donut make`` first", donutName) + log.Fatalln(msg) + } + if _, ok := mcDonutConfigData.Donuts[donutName].Node["localhost"]; !ok { + msg := fmt.Sprintf("Corrupted donut config, please consult donut experts") + log.Fatalln(msg) + } + + inactiveDisks := mcDonutConfigData.Donuts[donutName].Node["localhost"].InactiveDisks + activeDisks := mcDonutConfigData.Donuts[donutName].Node["localhost"].ActiveDisks + for _, disk := range disks { + if isStringInSlice(activeDisks, disk) { + activeDisks = deleteFromSlice(activeDisks, disk) + inactiveDisks = appendUniq(inactiveDisks, disk) + } else { + msg := fmt.Sprintf("Cannot detach disk: <%s>, not part of donut <%s>", disk, donutName) + log.Println(msg) + } + } + mcDonutConfigData.Donuts[donutName].Node["localhost"] = nodeConfig{ + ActiveDisks: activeDisks, + InactiveDisks: inactiveDisks, + } + if err := saveDonutConfig(mcDonutConfigData); err != nil { + log.Fatalln(err.Error()) + } +} diff --git a/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-make.go b/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-make.go new file mode 100644 index 00000000..8e0d06a5 --- /dev/null +++ b/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-make.go @@ -0,0 +1,80 @@ +/* + * Minimalist Object Storage, (C) 2015 Minio, Inc. + * + * 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 main + +import ( + "fmt" + "log" + "os" + + "github.com/minio-io/cli" +) + +func newDonutConfig(donutName string) (*mcDonutConfig, error) { + mcDonutConfigData := new(mcDonutConfig) + mcDonutConfigData.Donuts = make(map[string]donutConfig) + mcDonutConfigData.Donuts[donutName] = donutConfig{ + Node: make(map[string]nodeConfig), + } + mcDonutConfigData.Donuts[donutName].Node["localhost"] = nodeConfig{ + ActiveDisks: make([]string, 0), + InactiveDisks: make([]string, 0), + } + return mcDonutConfigData, nil +} + +// doMakeDonutCmd creates a new donut +func doMakeDonutCmd(c *cli.Context) { + if !c.Args().Present() { + log.Fatalln("no args?") + } + if len(c.Args()) != 1 { + log.Fatalln("invalid number of args") + } + donutName := c.Args().First() + if !isValidDonutName(donutName) { + log.Fatalln("Invalid donutName") + } + mcDonutConfigData, err := loadDonutConfig() + if os.IsNotExist(err) { + mcDonutConfigData, err = newDonutConfig(donutName) + if err != nil { + log.Fatalln(err) + } + if err := saveDonutConfig(mcDonutConfigData); err != nil { + log.Fatalln(err) + } + return + } else if err != nil { + log.Fatalln(err) + } + if _, ok := mcDonutConfigData.Donuts[donutName]; !ok { + mcDonutConfigData.Donuts[donutName] = donutConfig{ + Node: make(map[string]nodeConfig), + } + mcDonutConfigData.Donuts[donutName].Node["localhost"] = nodeConfig{ + ActiveDisks: make([]string, 0), + InactiveDisks: make([]string, 0), + } + if err := saveDonutConfig(mcDonutConfigData); err != nil { + log.Fatalln(err) + } + } else { + msg := fmt.Sprintf("donut: %s already exists", donutName) + log.Println(msg) + } +} diff --git a/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-mb.go b/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-mb.go new file mode 100644 index 00000000..d96d73a1 --- /dev/null +++ b/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-mb.go @@ -0,0 +1,59 @@ +/* + * Minimalist Object Storage, (C) 2014,2015 Minio, Inc. + * + * 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 main + +import ( + "fmt" + "log" + "strings" + + "net/url" + + "github.com/minio-io/cli" + "github.com/minio-io/donut" +) + +// doMakeDonutBucketCmd creates a new bucket +func doMakeDonutBucketCmd(c *cli.Context) { + if !c.Args().Present() { + log.Fatalln("no args?") + } + urlArg1, err := url.Parse(c.Args().First()) + if err != nil { + log.Fatalln(err) + } + mcDonutConfigData, err := loadDonutConfig() + if err != nil { + log.Fatalln(err) + } + if _, ok := mcDonutConfigData.Donuts[urlArg1.Host]; !ok { + msg := fmt.Sprintf("requested donut: <%s> does not exist", urlArg1.Host) + log.Fatalln(msg) + } + nodes := make(map[string][]string) + for k, v := range mcDonutConfigData.Donuts[urlArg1.Host].Node { + nodes[k] = v.ActiveDisks + } + d, err := donut.NewDonut(urlArg1.Host, nodes) + if err != nil { + log.Fatalln(err) + } + err = d.MakeBucket(strings.TrimPrefix(urlArg1.Path, "/")) + if err != nil { + log.Fatalln(err) + } +} diff --git a/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-options.go b/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-options.go new file mode 100644 index 00000000..f3d73d79 --- /dev/null +++ b/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-options.go @@ -0,0 +1,82 @@ +/* + * Minimalist Object Storage, (C) 2015 Minio, Inc. + * + * 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 main + +import ( + "github.com/minio-io/cli" +) + +var makeDonutCmd = cli.Command{ + Name: "make", + Usage: "make donut", + Description: "Make a new donut", + Action: doMakeDonutCmd, +} + +var attachDiskCmd = cli.Command{ + Name: "attach", + Usage: "attach disk", + Description: "Attach disk to an existing donut", + Action: doAttachDiskCmd, + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "name", + Usage: "Donut name", + }, + }, +} + +var detachDiskCmd = cli.Command{ + Name: "detach", + Usage: "detach disk", + Description: "Detach disk from an existing donut", + Action: doDetachDiskCmd, + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "name", + Usage: "Donut name", + }, + }, +} + +var healDonutCmd = cli.Command{ + Name: "heal", + Usage: "heal donut", + Description: "Heal donut with any errors", + Action: doHealDonutCmd, +} + +var rebalanceDonutCmd = cli.Command{ + Name: "rebalance", + Usage: "rebalance donut", + Description: "Rebalance data on donut after adding disks", + Action: doRebalanceDonutCmd, +} + +var donutOptions = []cli.Command{ + makeDonutCmd, + attachDiskCmd, + detachDiskCmd, + healDonutCmd, + rebalanceDonutCmd, +} + +func doHealDonutCmd(c *cli.Context) { +} + +func doRebalanceDonutCmd(c *cli.Context) { +} diff --git a/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut.go b/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut.go new file mode 100644 index 00000000..21cb1d53 --- /dev/null +++ b/Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut.go @@ -0,0 +1,33 @@ +/* + * Minimalist Object Storage, (C) 2014,2015 Minio, Inc. + * + * 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 main + +import ( + "os" + + "github.com/minio-io/cli" +) + +func main() { + app := cli.NewApp() + app.Usage = "" + app.Version = gitCommitHash + app.Commands = donutOptions + app.Author = "Minio.io" + app.EnableBashCompletion = true + app.Run(os.Args) +} diff --git a/pkg/storage/donut/disk.go b/Godeps/_workspace/src/github.com/minio-io/donut/disk.go similarity index 100% rename from pkg/storage/donut/disk.go rename to Godeps/_workspace/src/github.com/minio-io/donut/disk.go diff --git a/pkg/storage/donut/donut.go b/Godeps/_workspace/src/github.com/minio-io/donut/donut.go similarity index 100% rename from pkg/storage/donut/donut.go rename to Godeps/_workspace/src/github.com/minio-io/donut/donut.go diff --git a/pkg/storage/donut/erasure.go b/Godeps/_workspace/src/github.com/minio-io/donut/erasure.go similarity index 96% rename from pkg/storage/donut/erasure.go rename to Godeps/_workspace/src/github.com/minio-io/donut/erasure.go index 85883512..e6288d74 100644 --- a/pkg/storage/donut/erasure.go +++ b/Godeps/_workspace/src/github.com/minio-io/donut/erasure.go @@ -3,7 +3,7 @@ package donut import ( "errors" - encoding "github.com/minio-io/mc/pkg/encoding/erasure" + encoding "github.com/minio-io/erasure" ) type encoder struct { diff --git a/pkg/storage/donut/interfaces.go b/Godeps/_workspace/src/github.com/minio-io/donut/interfaces.go similarity index 100% rename from pkg/storage/donut/interfaces.go rename to Godeps/_workspace/src/github.com/minio-io/donut/interfaces.go diff --git a/pkg/storage/donut/node.go b/Godeps/_workspace/src/github.com/minio-io/donut/node.go similarity index 100% rename from pkg/storage/donut/node.go rename to Godeps/_workspace/src/github.com/minio-io/donut/node.go diff --git a/pkg/storage/donut/object.go b/Godeps/_workspace/src/github.com/minio-io/donut/object.go similarity index 100% rename from pkg/storage/donut/object.go rename to Godeps/_workspace/src/github.com/minio-io/donut/object.go diff --git a/pkg/encoding/erasure/.gitignore b/Godeps/_workspace/src/github.com/minio-io/erasure/.gitignore similarity index 100% rename from pkg/encoding/erasure/.gitignore rename to Godeps/_workspace/src/github.com/minio-io/erasure/.gitignore diff --git a/pkg/encoding/erasure/BUILDDEPS.md b/Godeps/_workspace/src/github.com/minio-io/erasure/BUILDDEPS.md similarity index 100% rename from pkg/encoding/erasure/BUILDDEPS.md rename to Godeps/_workspace/src/github.com/minio-io/erasure/BUILDDEPS.md diff --git a/pkg/encoding/erasure/CONTRIBUTING.md b/Godeps/_workspace/src/github.com/minio-io/erasure/CONTRIBUTING.md similarity index 100% rename from pkg/encoding/erasure/CONTRIBUTING.md rename to Godeps/_workspace/src/github.com/minio-io/erasure/CONTRIBUTING.md diff --git a/pkg/encoding/erasure/LICENSE.INTEL b/Godeps/_workspace/src/github.com/minio-io/erasure/LICENSE.INTEL similarity index 100% rename from pkg/encoding/erasure/LICENSE.INTEL rename to Godeps/_workspace/src/github.com/minio-io/erasure/LICENSE.INTEL diff --git a/Godeps/_workspace/src/github.com/minio-io/iodine/LICENSE b/Godeps/_workspace/src/github.com/minio-io/erasure/LICENSE.MINIO similarity index 99% rename from Godeps/_workspace/src/github.com/minio-io/iodine/LICENSE rename to Godeps/_workspace/src/github.com/minio-io/erasure/LICENSE.MINIO index e06d2081..d6456956 100644 --- a/Godeps/_workspace/src/github.com/minio-io/iodine/LICENSE +++ b/Godeps/_workspace/src/github.com/minio-io/erasure/LICENSE.MINIO @@ -1,4 +1,5 @@ -Apache License + + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -178,7 +179,7 @@ Apache License APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" + boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a @@ -186,7 +187,7 @@ Apache License same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright {yyyy} {name of copyright owner} + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -199,4 +200,3 @@ Apache License 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. - diff --git a/pkg/encoding/erasure/README.md b/Godeps/_workspace/src/github.com/minio-io/erasure/README.md similarity index 100% rename from pkg/encoding/erasure/README.md rename to Godeps/_workspace/src/github.com/minio-io/erasure/README.md diff --git a/pkg/encoding/erasure/RELEASE-NOTES.INTEL b/Godeps/_workspace/src/github.com/minio-io/erasure/RELEASE-NOTES.INTEL similarity index 100% rename from pkg/encoding/erasure/RELEASE-NOTES.INTEL rename to Godeps/_workspace/src/github.com/minio-io/erasure/RELEASE-NOTES.INTEL diff --git a/pkg/encoding/erasure/RELEASE-NOTES.MINIO b/Godeps/_workspace/src/github.com/minio-io/erasure/RELEASE-NOTES.MINIO similarity index 100% rename from pkg/encoding/erasure/RELEASE-NOTES.MINIO rename to Godeps/_workspace/src/github.com/minio-io/erasure/RELEASE-NOTES.MINIO diff --git a/pkg/encoding/erasure/cauchy_test.go b/Godeps/_workspace/src/github.com/minio-io/erasure/cauchy_test.go similarity index 100% rename from pkg/encoding/erasure/cauchy_test.go rename to Godeps/_workspace/src/github.com/minio-io/erasure/cauchy_test.go diff --git a/pkg/encoding/erasure/ctypes.go b/Godeps/_workspace/src/github.com/minio-io/erasure/ctypes.go similarity index 100% rename from pkg/encoding/erasure/ctypes.go rename to Godeps/_workspace/src/github.com/minio-io/erasure/ctypes.go diff --git a/pkg/encoding/erasure/doc.go b/Godeps/_workspace/src/github.com/minio-io/erasure/doc.go similarity index 100% rename from pkg/encoding/erasure/doc.go rename to Godeps/_workspace/src/github.com/minio-io/erasure/doc.go diff --git a/pkg/encoding/erasure/docs/isa-l_open_src_2.10.pdf b/Godeps/_workspace/src/github.com/minio-io/erasure/docs/isa-l_open_src_2.10.pdf similarity index 100% rename from pkg/encoding/erasure/docs/isa-l_open_src_2.10.pdf rename to Godeps/_workspace/src/github.com/minio-io/erasure/docs/isa-l_open_src_2.10.pdf diff --git a/pkg/encoding/erasure/ec-base.c b/Godeps/_workspace/src/github.com/minio-io/erasure/ec-base.c similarity index 100% rename from pkg/encoding/erasure/ec-base.c rename to Godeps/_workspace/src/github.com/minio-io/erasure/ec-base.c diff --git a/pkg/encoding/erasure/ec-base.h b/Godeps/_workspace/src/github.com/minio-io/erasure/ec-base.h similarity index 100% rename from pkg/encoding/erasure/ec-base.h rename to Godeps/_workspace/src/github.com/minio-io/erasure/ec-base.h diff --git a/pkg/encoding/erasure/ec-code.h b/Godeps/_workspace/src/github.com/minio-io/erasure/ec-code.h similarity index 100% rename from pkg/encoding/erasure/ec-code.h rename to Godeps/_workspace/src/github.com/minio-io/erasure/ec-code.h diff --git a/pkg/encoding/erasure/ec-common.h b/Godeps/_workspace/src/github.com/minio-io/erasure/ec-common.h similarity index 96% rename from pkg/encoding/erasure/ec-common.h rename to Godeps/_workspace/src/github.com/minio-io/erasure/ec-common.h index 58827478..22d08f1a 100644 --- a/pkg/encoding/erasure/ec-common.h +++ b/Godeps/_workspace/src/github.com/minio-io/erasure/ec-common.h @@ -1,5 +1,5 @@ /* - * Minimalist Object Storage, (C) 2014 Minio, Inc. + * Mini Object Storage, (C) 2014 Minio, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/pkg/encoding/erasure/ec-ctypes.h b/Godeps/_workspace/src/github.com/minio-io/erasure/ec-ctypes.h similarity index 100% rename from pkg/encoding/erasure/ec-ctypes.h rename to Godeps/_workspace/src/github.com/minio-io/erasure/ec-ctypes.h diff --git a/pkg/encoding/erasure/ec-decode.c b/Godeps/_workspace/src/github.com/minio-io/erasure/ec-decode.c similarity index 100% rename from pkg/encoding/erasure/ec-decode.c rename to Godeps/_workspace/src/github.com/minio-io/erasure/ec-decode.c diff --git a/pkg/encoding/erasure/ec-encode.c b/Godeps/_workspace/src/github.com/minio-io/erasure/ec-encode.c similarity index 100% rename from pkg/encoding/erasure/ec-encode.c rename to Godeps/_workspace/src/github.com/minio-io/erasure/ec-encode.c diff --git a/pkg/encoding/erasure/ec-highlevel-func.c b/Godeps/_workspace/src/github.com/minio-io/erasure/ec-highlevel-func.c similarity index 100% rename from pkg/encoding/erasure/ec-highlevel-func.c rename to Godeps/_workspace/src/github.com/minio-io/erasure/ec-highlevel-func.c diff --git a/pkg/encoding/erasure/ec-multibinary.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/ec-multibinary.asm similarity index 100% rename from pkg/encoding/erasure/ec-multibinary.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/ec-multibinary.asm diff --git a/pkg/encoding/erasure/ec-reg-sizes.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/ec-reg-sizes.asm similarity index 100% rename from pkg/encoding/erasure/ec-reg-sizes.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/ec-reg-sizes.asm diff --git a/pkg/encoding/erasure/ec-vect-mul.h b/Godeps/_workspace/src/github.com/minio-io/erasure/ec-vect-mul.h similarity index 100% rename from pkg/encoding/erasure/ec-vect-mul.h rename to Godeps/_workspace/src/github.com/minio-io/erasure/ec-vect-mul.h diff --git a/pkg/encoding/erasure/erasure_decode.go b/Godeps/_workspace/src/github.com/minio-io/erasure/erasure_decode.go similarity index 100% rename from pkg/encoding/erasure/erasure_decode.go rename to Godeps/_workspace/src/github.com/minio-io/erasure/erasure_decode.go diff --git a/pkg/encoding/erasure/erasure_encode.go b/Godeps/_workspace/src/github.com/minio-io/erasure/erasure_encode.go similarity index 100% rename from pkg/encoding/erasure/erasure_encode.go rename to Godeps/_workspace/src/github.com/minio-io/erasure/erasure_encode.go diff --git a/pkg/encoding/erasure/erasure_yasm_darwin.go b/Godeps/_workspace/src/github.com/minio-io/erasure/erasure_yasm_darwin.go similarity index 100% rename from pkg/encoding/erasure/erasure_yasm_darwin.go rename to Godeps/_workspace/src/github.com/minio-io/erasure/erasure_yasm_darwin.go diff --git a/pkg/encoding/erasure/erasure_yasm_linux.go b/Godeps/_workspace/src/github.com/minio-io/erasure/erasure_yasm_linux.go similarity index 100% rename from pkg/encoding/erasure/erasure_yasm_linux.go rename to Godeps/_workspace/src/github.com/minio-io/erasure/erasure_yasm_linux.go diff --git a/pkg/encoding/erasure/erasure_yasm_windows.go b/Godeps/_workspace/src/github.com/minio-io/erasure/erasure_yasm_windows.go similarity index 100% rename from pkg/encoding/erasure/erasure_yasm_windows.go rename to Godeps/_workspace/src/github.com/minio-io/erasure/erasure_yasm_windows.go diff --git a/pkg/encoding/erasure/gf-2vect-dot-prod-avx.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/gf-2vect-dot-prod-avx.asm similarity index 100% rename from pkg/encoding/erasure/gf-2vect-dot-prod-avx.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/gf-2vect-dot-prod-avx.asm diff --git a/pkg/encoding/erasure/gf-2vect-dot-prod-avx2.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/gf-2vect-dot-prod-avx2.asm similarity index 100% rename from pkg/encoding/erasure/gf-2vect-dot-prod-avx2.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/gf-2vect-dot-prod-avx2.asm diff --git a/pkg/encoding/erasure/gf-2vect-dot-prod-sse.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/gf-2vect-dot-prod-sse.asm similarity index 100% rename from pkg/encoding/erasure/gf-2vect-dot-prod-sse.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/gf-2vect-dot-prod-sse.asm diff --git a/pkg/encoding/erasure/gf-3vect-dot-prod-avx.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/gf-3vect-dot-prod-avx.asm similarity index 100% rename from pkg/encoding/erasure/gf-3vect-dot-prod-avx.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/gf-3vect-dot-prod-avx.asm diff --git a/pkg/encoding/erasure/gf-3vect-dot-prod-avx2.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/gf-3vect-dot-prod-avx2.asm similarity index 100% rename from pkg/encoding/erasure/gf-3vect-dot-prod-avx2.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/gf-3vect-dot-prod-avx2.asm diff --git a/pkg/encoding/erasure/gf-3vect-dot-prod-sse.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/gf-3vect-dot-prod-sse.asm similarity index 100% rename from pkg/encoding/erasure/gf-3vect-dot-prod-sse.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/gf-3vect-dot-prod-sse.asm diff --git a/pkg/encoding/erasure/gf-4vect-dot-prod-avx.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/gf-4vect-dot-prod-avx.asm similarity index 100% rename from pkg/encoding/erasure/gf-4vect-dot-prod-avx.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/gf-4vect-dot-prod-avx.asm diff --git a/pkg/encoding/erasure/gf-4vect-dot-prod-avx2.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/gf-4vect-dot-prod-avx2.asm similarity index 100% rename from pkg/encoding/erasure/gf-4vect-dot-prod-avx2.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/gf-4vect-dot-prod-avx2.asm diff --git a/pkg/encoding/erasure/gf-4vect-dot-prod-sse.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/gf-4vect-dot-prod-sse.asm similarity index 100% rename from pkg/encoding/erasure/gf-4vect-dot-prod-sse.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/gf-4vect-dot-prod-sse.asm diff --git a/pkg/encoding/erasure/gf-5vect-dot-prod-avx.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/gf-5vect-dot-prod-avx.asm similarity index 100% rename from pkg/encoding/erasure/gf-5vect-dot-prod-avx.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/gf-5vect-dot-prod-avx.asm diff --git a/pkg/encoding/erasure/gf-5vect-dot-prod-avx2.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/gf-5vect-dot-prod-avx2.asm similarity index 100% rename from pkg/encoding/erasure/gf-5vect-dot-prod-avx2.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/gf-5vect-dot-prod-avx2.asm diff --git a/pkg/encoding/erasure/gf-5vect-dot-prod-sse.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/gf-5vect-dot-prod-sse.asm similarity index 100% rename from pkg/encoding/erasure/gf-5vect-dot-prod-sse.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/gf-5vect-dot-prod-sse.asm diff --git a/pkg/encoding/erasure/gf-6vect-dot-prod-avx.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/gf-6vect-dot-prod-avx.asm similarity index 100% rename from pkg/encoding/erasure/gf-6vect-dot-prod-avx.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/gf-6vect-dot-prod-avx.asm diff --git a/pkg/encoding/erasure/gf-6vect-dot-prod-avx2.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/gf-6vect-dot-prod-avx2.asm similarity index 100% rename from pkg/encoding/erasure/gf-6vect-dot-prod-avx2.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/gf-6vect-dot-prod-avx2.asm diff --git a/pkg/encoding/erasure/gf-6vect-dot-prod-sse.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/gf-6vect-dot-prod-sse.asm similarity index 100% rename from pkg/encoding/erasure/gf-6vect-dot-prod-sse.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/gf-6vect-dot-prod-sse.asm diff --git a/pkg/encoding/erasure/gf-vect-dot-prod-avx.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/gf-vect-dot-prod-avx.asm similarity index 100% rename from pkg/encoding/erasure/gf-vect-dot-prod-avx.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/gf-vect-dot-prod-avx.asm diff --git a/pkg/encoding/erasure/gf-vect-dot-prod-avx2.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/gf-vect-dot-prod-avx2.asm similarity index 100% rename from pkg/encoding/erasure/gf-vect-dot-prod-avx2.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/gf-vect-dot-prod-avx2.asm diff --git a/pkg/encoding/erasure/gf-vect-dot-prod-sse.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/gf-vect-dot-prod-sse.asm similarity index 100% rename from pkg/encoding/erasure/gf-vect-dot-prod-sse.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/gf-vect-dot-prod-sse.asm diff --git a/pkg/encoding/erasure/gf-vect-mul-avx.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/gf-vect-mul-avx.asm similarity index 100% rename from pkg/encoding/erasure/gf-vect-mul-avx.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/gf-vect-mul-avx.asm diff --git a/pkg/encoding/erasure/gf-vect-mul-sse.asm b/Godeps/_workspace/src/github.com/minio-io/erasure/gf-vect-mul-sse.asm similarity index 100% rename from pkg/encoding/erasure/gf-vect-mul-sse.asm rename to Godeps/_workspace/src/github.com/minio-io/erasure/gf-vect-mul-sse.asm diff --git a/pkg/encoding/erasure/stdint.go b/Godeps/_workspace/src/github.com/minio-io/erasure/stdint.go similarity index 100% rename from pkg/encoding/erasure/stdint.go rename to Godeps/_workspace/src/github.com/minio-io/erasure/stdint.go diff --git a/pkg/encoding/erasure/vandermonde_test.go b/Godeps/_workspace/src/github.com/minio-io/erasure/vandermonde_test.go similarity index 100% rename from pkg/encoding/erasure/vandermonde_test.go rename to Godeps/_workspace/src/github.com/minio-io/erasure/vandermonde_test.go diff --git a/Godeps/_workspace/src/github.com/minio-io/iodine/.gitignore b/Godeps/_workspace/src/github.com/minio-io/iodine/.gitignore deleted file mode 100644 index daf913b1..00000000 --- a/Godeps/_workspace/src/github.com/minio-io/iodine/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test -*.prof diff --git a/Godeps/_workspace/src/github.com/minio-io/iodine/README.md b/Godeps/_workspace/src/github.com/minio-io/iodine/README.md deleted file mode 100644 index d7391ea4..00000000 --- a/Godeps/_workspace/src/github.com/minio-io/iodine/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# iodine -Iodine is an error logging framework for tracing errors. diff --git a/Godeps/_workspace/src/github.com/minio-io/iodine/iodine.go b/Godeps/_workspace/src/github.com/minio-io/iodine/iodine.go deleted file mode 100644 index a1fd95b2..00000000 --- a/Godeps/_workspace/src/github.com/minio-io/iodine/iodine.go +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Iodine, (C) 2015 Minio, Inc. - * - * 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 iodine - -import ( - "bytes" - "encoding/json" - "fmt" - "os" - "path" - "runtime" - "strconv" - "strings" - "sync" -) - -// WrappedError is the iodine error which contains a pointer to the original error -// and stack traces. -type WrappedError struct { - EmbeddedError error `json:"-"` - ErrorMessage string - - Stack []StackEntry -} - -// StackEntry contains the entry in the stack trace -type StackEntry struct { - Host string - File string - Line int - Data map[string]string -} - -var gopath string - -var globalState = struct { - sync.RWMutex - m map[string]string -}{m: make(map[string]string)} - -// SetGlobalState - set global state -func SetGlobalState(key, value string) { - globalState.Lock() - globalState.m[key] = value - globalState.Unlock() -} - -// ClearGlobalState - clear info in globalState struct -func ClearGlobalState() { - globalState.Lock() - for k := range globalState.m { - delete(globalState.m, k) - } - globalState.Unlock() -} - -// GetGlobalState - get map from globalState struct -func GetGlobalState() map[string]string { - result := make(map[string]string) - globalState.RLock() - for k, v := range globalState.m { - result[k] = v - } - globalState.RUnlock() - return result -} - -// GetGlobalStateKey - get value for key from globalState struct -func GetGlobalStateKey(k string) string { - result, ok := globalState.m[k] - if !ok { - return "" - } - return result -} - -// Error - instantiate an error, turning it into an iodine error. -// Adds an initial stack trace. -func Error(err error, data map[string]string) error { - if err != nil { - entry := createStackEntry() - var newErr WrappedError - - // check if error is wrapped - switch typedError := err.(type) { - case WrappedError: - { - newErr = typedError - } - default: - { - newErr = WrappedError{ - EmbeddedError: err, - ErrorMessage: err.Error(), - Stack: []StackEntry{}, - } - } - } - for k, v := range data { - entry.Data[k] = v - } - newErr.Stack = append(newErr.Stack, entry) - return newErr - } - return nil -} - -// createStackEntry - create stack entries -func createStackEntry() StackEntry { - host, _ := os.Hostname() - _, file, line, _ := runtime.Caller(2) - file = strings.TrimPrefix(file, gopath) // trim gopath from file - - data := GetGlobalState() - for k, v := range getSystemData() { - data[k] = v - } - - entry := StackEntry{ - Host: host, - File: file, - Line: line, - Data: data, - } - return entry -} - -func getSystemData() map[string]string { - host, err := os.Hostname() - if err != nil { - host = "" - } - memstats := &runtime.MemStats{} - runtime.ReadMemStats(memstats) - return map[string]string{ - "sys.host": host, - "sys.os": runtime.GOOS, - "sys.arch": runtime.GOARCH, - "sys.go": runtime.Version(), - "sys.cpus": strconv.Itoa(runtime.NumCPU()), - "sys.mem.used": strconv.FormatUint(memstats.Alloc, 10), - "sys.mem.allocated": strconv.FormatUint(memstats.TotalAlloc, 10), - "sys.mem.heap.used": strconv.FormatUint(memstats.HeapAlloc, 10), - "sys.mem.heap.allocated": strconv.FormatUint(memstats.HeapSys, 10), - } -} - -// Annotate an error with a stack entry and returns itself -//func (err *WrappedError) Annotate(info map[string]string) *WrappedError { -// entry := createStackEntry() -// for k, v := range info { -// entry.Data[k] = v -// } -// err.Stack = append(err.Stack, entry) -// return err -//} - -// EmitJSON writes JSON output for the error -func (err WrappedError) EmitJSON() ([]byte, error) { - return json.Marshal(err) -} - -// EmitHumanReadable returns a human readable error message -func (err WrappedError) EmitHumanReadable() string { - var errorBuffer bytes.Buffer - fmt.Fprintln(&errorBuffer, err.ErrorMessage) - for i, entry := range err.Stack { - fmt.Fprintln(&errorBuffer, "-", i, entry.Host+":"+entry.File+":"+strconv.Itoa(entry.Line), entry.Data) - } - return string(errorBuffer.Bytes()) -} - -// Emits the original error message -func (err WrappedError) Error() string { - return err.EmitHumanReadable() -} - -func init() { - _, iodineFile, _, _ := runtime.Caller(0) - iodineFile = path.Dir(iodineFile) // trim iodine.go - iodineFile = path.Dir(iodineFile) // trim iodine - iodineFile = path.Dir(iodineFile) // trim minio-io - gopath = path.Dir(iodineFile) + "/" // trim github.com -} diff --git a/Godeps/_workspace/src/github.com/minio-io/iodine/iodine_test.go b/Godeps/_workspace/src/github.com/minio-io/iodine/iodine_test.go deleted file mode 100644 index 3aa7b39f..00000000 --- a/Godeps/_workspace/src/github.com/minio-io/iodine/iodine_test.go +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Iodine, (C) 2015 Minio, Inc. - * - * 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 iodine - -import ( - "bytes" - "encoding/json" - "errors" - "testing" -) - -func TestIodine(t *testing.T) { - iodineError := Error(errors.New("Hello"), nil) - iodineError = Error(iodineError, nil) - iodineError = Error(iodineError, nil) - iodineError = Error(iodineError, nil) - switch typedError := iodineError.(type) { - case WrappedError: - { - if len(typedError.Stack) != 4 { - t.Fail() - } - jsonResult, err := typedError.EmitJSON() - if err != nil { - t.Fail() - } - var prettyBuffer bytes.Buffer - json.Indent(&prettyBuffer, jsonResult, "", " ") - if prettyBuffer.String() == "" { - t.Fail() - } - } - default: - { - t.Fail() - } - } -} - -func TestState(t *testing.T) { - SetGlobalState("hello", "world") - result := GetGlobalStateKey("hello") - if result != "world" { - t.Error("global state not set: hello->world") - t.Fail() - } - ClearGlobalState() - if len(GetGlobalState()) != 0 { - t.Fail() - } - SetGlobalState("foo", "bar") - err := Error(errors.New("a simple error"), nil) - switch typedError := err.(type) { - case WrappedError: - { - if res, ok := typedError.Stack[0].Data["foo"]; ok { - if res != "bar" { - t.Error("global state not set: foo->bar") - } - } else { - t.Fail() - } - typedError = Error(typedError, map[string]string{"foo2": "bar2"}).(WrappedError) - if res, ok := typedError.Stack[0].Data["foo"]; ok { - if res != "bar" { - t.Error("annotate should not modify previous data entries") - } - } else { - t.Error("annotate should not remove previous data entries") - } - if res, ok := typedError.Stack[1].Data["foo"]; ok { - if res != "bar" { - t.Error("global state should set value properly in annotate") - } - } else { - t.Error("global state should set key properly in annotate") - } - if res, ok := typedError.Stack[1].Data["foo2"]; ok { - if res != "bar2" { - // typedError = Error(typedError, nil).(WrappedError) - t.Error("foo2 -> bar should be set") - } - } else { - // typedError = Error(typedError, nil).(WrappedError) - t.Error("foo2 should be set") - } - } - } -} diff --git a/Makefile b/Makefile index 27cac29e..da356dc6 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,7 @@ pre-build: build-all: getdeps verifiers @echo "Building Libraries:" + @godep go generate github.com/minio-io/erasure @godep go generate ./... @godep go build ./... @@ -61,10 +62,9 @@ docs-deploy: install: test-all @echo "Installing mc:" - @godep go install github.com/minio-io/mc + @godep go install github.com/minio-io/mc @mkdir -p $(HOME)/.minio/mc clean: @rm -fv cover.out - @rm -fv pkg/encoding/erasure/*.syso @rm -fv build-constants.go