shell: add volume.configure.replication to change replication for a volume

fix https://github.com/chrislusf/seaweedfs/issues/1192
This commit is contained in:
Chris Lu
2020-02-02 15:37:23 -08:00
parent fb19263a71
commit 40ae533fa3
10 changed files with 536 additions and 252 deletions

View File

@@ -1,13 +1,12 @@
package storage
import (
"fmt"
"io/ioutil"
"os"
"strings"
"sync"
"fmt"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/storage/erasure_coding"
"github.com/chrislusf/seaweedfs/weed/storage/needle"
@@ -172,16 +171,10 @@ func (l *DiskLocation) deleteVolumeById(vid needle.VolumeId) (e error) {
}
func (l *DiskLocation) LoadVolume(vid needle.VolumeId, needleMapKind NeedleMapType) bool {
if fileInfos, err := ioutil.ReadDir(l.Directory); err == nil {
for _, fileInfo := range fileInfos {
volId, _, err := l.volumeIdFromPath(fileInfo)
if vid == volId && err == nil {
l.loadExistingVolume(fileInfo, needleMapKind)
return true
}
}
if fileInfo, found := l.LocateVolume(vid); found {
l.loadExistingVolume(fileInfo, needleMapKind)
return true
}
return false
}
@@ -217,7 +210,7 @@ func (l *DiskLocation) unmountVolumeByCollection(collectionName string) map[need
}
}
for k, _ := range deltaVols {
for k := range deltaVols {
delete(l.volumes, k)
}
return deltaVols
@@ -260,3 +253,16 @@ func (l *DiskLocation) Close() {
return
}
func (l *DiskLocation) LocateVolume(vid needle.VolumeId) (os.FileInfo, bool) {
if fileInfos, err := ioutil.ReadDir(l.Directory); err == nil {
for _, fileInfo := range fileInfos {
volId, _, err := l.volumeIdFromPath(fileInfo)
if vid == volId && err == nil {
return fileInfo, true
}
}
}
return nil, false
}