aboutsummaryrefslogtreecommitdiff
path: root/weed/storage/disk_location.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-02-02 15:37:23 -0800
committerChris Lu <chris.lu@gmail.com>2020-02-02 15:37:23 -0800
commit40ae533fa34ae6e40fa31d6007e533a23391a5d8 (patch)
tree7fe6ab2c8b30e7cc4df9cd42a67493198aa53ae5 /weed/storage/disk_location.go
parentfb19263a719b07d14f59cf8906c03a2a7d7ca3b8 (diff)
downloadseaweedfs-40ae533fa34ae6e40fa31d6007e533a23391a5d8.tar.xz
seaweedfs-40ae533fa34ae6e40fa31d6007e533a23391a5d8.zip
shell: add volume.configure.replication to change replication for a volume
fix https://github.com/chrislusf/seaweedfs/issues/1192
Diffstat (limited to 'weed/storage/disk_location.go')
-rw-r--r--weed/storage/disk_location.go30
1 files changed, 18 insertions, 12 deletions
diff --git a/weed/storage/disk_location.go b/weed/storage/disk_location.go
index e116fc715..a12a68cbc 100644
--- a/weed/storage/disk_location.go
+++ b/weed/storage/disk_location.go
@@ -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
+}