aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-12-13 22:49:56 -0800
committerChris Lu <chris.lu@gmail.com>2020-12-13 22:49:56 -0800
commitf6a419c26caf6356df1a099c5a900b158807b5a4 (patch)
treebbe4116c6800e5a93cfd2214725ec25041523d3d
parent7c52a3594219fa0957e39a32917cffd0ea479f72 (diff)
downloadseaweedfs-f6a419c26caf6356df1a099c5a900b158807b5a4.tar.xz
seaweedfs-f6a419c26caf6356df1a099c5a900b158807b5a4.zip
disk type configurable for each folder
-rw-r--r--weed/command/volume.go26
-rw-r--r--weed/server/volume_server.go6
-rw-r--r--weed/storage/store.go4
3 files changed, 24 insertions, 12 deletions
diff --git a/weed/command/volume.go b/weed/command/volume.go
index 02d8eb50c..b90dc5967 100644
--- a/weed/command/volume.go
+++ b/weed/command/volume.go
@@ -169,6 +169,25 @@ func (v VolumeServerOptions) startVolumeServer(volumeFolders, maxVolumeCounts, v
glog.Fatalf("%d directories by -dir, but only %d minFreeSpacePercent is set by -minFreeSpacePercent", len(v.folders), len(v.minFreeSpacePercents))
}
+ // set disk types
+ var diskTypes []storage.DiskType
+ diskTypeStrings := strings.Split(*v.diskType, ",")
+ for _, diskTypeString := range diskTypeStrings {
+ if diskType, err := storage.ToDiskType(diskTypeString); err == nil {
+ diskTypes = append(diskTypes, diskType)
+ } else {
+ glog.Fatalf("failed to parse volume type: %v", err)
+ }
+ }
+ if len(diskTypes) == 1 && len(v.folders) > 1 {
+ for i := 0; i < len(v.folders)-1; i++ {
+ diskTypes = append(diskTypes, diskTypes[0])
+ }
+ }
+ if len(v.folders) != len(diskTypes) {
+ glog.Fatalf("%d directories by -dir, but only %d disk types is set by -disk", len(v.folders), len(diskTypes))
+ }
+
// security related white list configuration
if volumeWhiteListOption != "" {
v.whiteList = strings.Split(volumeWhiteListOption, ",")
@@ -212,14 +231,9 @@ func (v VolumeServerOptions) startVolumeServer(volumeFolders, maxVolumeCounts, v
masters := *v.masters
- diskType, err := storage.ToDiskType(*v.diskType)
- if err != nil {
- glog.Fatalf("failed to parse volume type: %v", err)
- }
-
volumeServer := weed_server.NewVolumeServer(volumeMux, publicVolumeMux,
*v.ip, *v.port, *v.publicUrl,
- v.folders, v.folderMaxLimits, v.minFreeSpacePercents, diskType,
+ v.folders, v.folderMaxLimits, v.minFreeSpacePercents, diskTypes,
*v.idxFolder,
volumeNeedleMapKind,
strings.Split(masters, ","), 5, *v.dataCenter, *v.rack,
diff --git a/weed/server/volume_server.go b/weed/server/volume_server.go
index f88c84184..7c731763b 100644
--- a/weed/server/volume_server.go
+++ b/weed/server/volume_server.go
@@ -20,7 +20,6 @@ type VolumeServer struct {
pulseSeconds int
dataCenter string
rack string
- DiskType storage.DiskType
store *storage.Store
guard *security.Guard
grpcDialOption grpc.DialOption
@@ -38,7 +37,7 @@ type VolumeServer struct {
func NewVolumeServer(adminMux, publicMux *http.ServeMux, ip string,
port int, publicUrl string,
- folders []string, maxCounts []int, minFreeSpacePercents []float32, diskType storage.DiskType,
+ folders []string, maxCounts []int, minFreeSpacePercents []float32, diskTypes []storage.DiskType,
idxFolder string,
needleMapKind storage.NeedleMapType,
masterNodes []string, pulseSeconds int,
@@ -64,7 +63,6 @@ func NewVolumeServer(adminMux, publicMux *http.ServeMux, ip string,
pulseSeconds: pulseSeconds,
dataCenter: dataCenter,
rack: rack,
- DiskType: diskType,
needleMapKind: needleMapKind,
FixJpgOrientation: fixJpgOrientation,
ReadRedirect: readRedirect,
@@ -78,7 +76,7 @@ func NewVolumeServer(adminMux, publicMux *http.ServeMux, ip string,
vs.checkWithMaster()
- vs.store = storage.NewStore(vs.grpcDialOption, port, ip, publicUrl, folders, maxCounts, minFreeSpacePercents, idxFolder, vs.needleMapKind, vs.DiskType)
+ vs.store = storage.NewStore(vs.grpcDialOption, port, ip, publicUrl, folders, maxCounts, minFreeSpacePercents, idxFolder, vs.needleMapKind, diskTypes)
vs.guard = security.NewGuard(whiteList, signingKey, expiresAfterSec, readSigningKey, readExpiresAfterSec)
handleStaticResources(adminMux)
diff --git a/weed/storage/store.go b/weed/storage/store.go
index 1b1c771df..fc524876d 100644
--- a/weed/storage/store.go
+++ b/weed/storage/store.go
@@ -52,11 +52,11 @@ func (s *Store) String() (str string) {
return
}
-func NewStore(grpcDialOption grpc.DialOption, port int, ip, publicUrl string, dirnames []string, maxVolumeCounts []int, minFreeSpacePercents []float32, idxFolder string, needleMapKind NeedleMapType, diskType DiskType) (s *Store) {
+func NewStore(grpcDialOption grpc.DialOption, port int, ip, publicUrl string, dirnames []string, maxVolumeCounts []int, minFreeSpacePercents []float32, idxFolder string, needleMapKind NeedleMapType, diskTypes []DiskType) (s *Store) {
s = &Store{grpcDialOption: grpcDialOption, Port: port, Ip: ip, PublicUrl: publicUrl, NeedleMapType: needleMapKind}
s.Locations = make([]*DiskLocation, 0)
for i := 0; i < len(dirnames); i++ {
- location := NewDiskLocation(dirnames[i], maxVolumeCounts[i], minFreeSpacePercents[i], idxFolder, diskType)
+ location := NewDiskLocation(dirnames[i], maxVolumeCounts[i], minFreeSpacePercents[i], idxFolder, diskTypes[i])
location.loadExistingVolumes(needleMapKind)
s.Locations = append(s.Locations, location)
stats.VolumeServerMaxVolumeCounter.Add(float64(maxVolumeCounts[i]))