You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.5 KiB
58 lines
1.5 KiB
10 years ago
|
/*
|
||
|
* 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.
|
||
|
*/
|
||
|
|
||
10 years ago
|
package donut
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
"strings"
|
||
10 years ago
|
|
||
10 years ago
|
"github.com/minio/minio/pkg/donut/disk"
|
||
10 years ago
|
"github.com/minio/minio/pkg/iodine"
|
||
10 years ago
|
)
|
||
|
|
||
10 years ago
|
// Rebalance -
|
||
10 years ago
|
func (donut API) Rebalance() error {
|
||
10 years ago
|
var totalOffSetLength int
|
||
10 years ago
|
var newDisks []disk.Disk
|
||
10 years ago
|
var existingDirs []os.FileInfo
|
||
10 years ago
|
for _, node := range donut.nodes {
|
||
10 years ago
|
disks, err := node.ListDisks()
|
||
|
if err != nil {
|
||
10 years ago
|
return iodine.New(err, nil)
|
||
10 years ago
|
}
|
||
|
totalOffSetLength = len(disks)
|
||
|
fmt.Println(totalOffSetLength)
|
||
|
for _, disk := range disks {
|
||
10 years ago
|
dirs, err := disk.ListDir(donut.config.DonutName)
|
||
10 years ago
|
if err != nil {
|
||
10 years ago
|
return iodine.New(err, nil)
|
||
10 years ago
|
}
|
||
|
if len(dirs) == 0 {
|
||
|
newDisks = append(newDisks, disk)
|
||
|
}
|
||
|
existingDirs = append(existingDirs, dirs...)
|
||
|
}
|
||
|
}
|
||
|
for _, dir := range existingDirs {
|
||
|
splits := strings.Split(dir.Name(), "$")
|
||
|
bucketName, segment, offset := splits[0], splits[1], splits[2]
|
||
|
fmt.Println(bucketName, segment, offset)
|
||
|
}
|
||
|
return nil
|
||
|
}
|