1
0
Fork 0
mirror of https://github.com/chrislusf/seaweedfs synced 2024-06-26 12:29:37 +02:00

disk type can be generic tags

This commit is contained in:
Chris Lu 2021-02-13 13:50:14 -08:00
parent 712b3e9e53
commit 4bd8a692d8
7 changed files with 15 additions and 26 deletions

View file

@ -169,11 +169,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {
mountRoot = mountRoot[0 : len(mountRoot)-1]
}
diskType, err := storage.ToDiskType(*option.diskType)
if err != nil {
fmt.Printf("failed to parse volume type: %v\n", err)
return false
}
diskType := storage.ToDiskType(*option.diskType)
seaweedFileSystem := filesys.NewSeaweedFileSystem(&filesys.Option{
MountDirectory: dir,

View file

@ -173,11 +173,7 @@ func (v VolumeServerOptions) startVolumeServer(volumeFolders, maxVolumeCounts, v
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)
}
diskTypes = append(diskTypes, storage.ToDiskType(diskTypeString))
}
if len(diskTypes) == 1 && len(v.folders) > 1 {
for i := 0; i < len(v.folders)-1; i++ {

View file

@ -61,10 +61,7 @@ func (ms *MasterServer) Assign(ctx context.Context, req *master_pb.AssignRequest
if err != nil {
return nil, err
}
diskType, err := storage.ToDiskType(req.DiskType)
if err != nil {
return nil, err
}
diskType := storage.ToDiskType(req.DiskType)
option := &topology.VolumeGrowOption{
Collection: req.Collection,

View file

@ -158,10 +158,7 @@ func (ms *MasterServer) getVolumeGrowOption(r *http.Request) (*topology.VolumeGr
if err != nil {
return nil, err
}
diskType, err := storage.ToDiskType(r.FormValue("disk"))
if err != nil {
return nil, err
}
diskType := storage.ToDiskType(r.FormValue("disk"))
preallocate := ms.preallocateSize
if r.FormValue("preallocate") != "" {

View file

@ -1,6 +1,8 @@
package storage
import "fmt"
import (
"strings"
)
type DiskType string
@ -9,7 +11,8 @@ const (
SsdType = "ssd"
)
func ToDiskType(vt string) (diskType DiskType, err error) {
func ToDiskType(vt string) (diskType DiskType) {
vt = strings.ToLower(vt)
diskType = HardDriveType
switch vt {
case "", "hdd":
@ -17,7 +20,7 @@ func ToDiskType(vt string) (diskType DiskType, err error) {
case "ssd":
diskType = SsdType
default:
err = fmt.Errorf("parse DiskType %s: expecting hdd or ssd\n", vt)
diskType = DiskType(vt)
}
return
}

View file

@ -188,14 +188,14 @@ func (t *Topology) DeleteLayout(collectionName string, rp *super_block.ReplicaPl
}
func (t *Topology) RegisterVolumeLayout(v storage.VolumeInfo, dn *DataNode) {
diskType, _ := storage.ToDiskType(v.DiskType)
diskType := storage.ToDiskType(v.DiskType)
vl := t.GetVolumeLayout(v.Collection, v.ReplicaPlacement, v.Ttl, diskType)
vl.RegisterVolume(&v, dn)
vl.EnsureCorrectWritables(&v)
}
func (t *Topology) UnRegisterVolumeLayout(v storage.VolumeInfo, dn *DataNode) {
glog.Infof("removing volume info: %+v", v)
diskType, _ := storage.ToDiskType(v.DiskType)
diskType := storage.ToDiskType(v.DiskType)
volumeLayout := t.GetVolumeLayout(v.Collection, v.ReplicaPlacement, v.Ttl, diskType)
volumeLayout.UnRegisterVolume(&v, dn)
if volumeLayout.isEmpty() {
@ -235,7 +235,7 @@ func (t *Topology) SyncDataNodeRegistration(volumes []*master_pb.VolumeInformati
t.UnRegisterVolumeLayout(v, dn)
}
for _, v := range changedVolumes {
diskType, _ := storage.ToDiskType(v.DiskType)
diskType := storage.ToDiskType(v.DiskType)
vl := t.GetVolumeLayout(v.Collection, v.ReplicaPlacement, v.Ttl, diskType)
vl.EnsureCorrectWritables(&v)
}

View file

@ -37,7 +37,7 @@ func (t *Topology) StartRefreshWritableVolumes(grpcDialOption grpc.DialOption, g
}()
}
func (t *Topology) SetVolumeCapacityFull(volumeInfo storage.VolumeInfo) bool {
diskType, _ := storage.ToDiskType(volumeInfo.DiskType)
diskType := storage.ToDiskType(volumeInfo.DiskType)
vl := t.GetVolumeLayout(volumeInfo.Collection, volumeInfo.ReplicaPlacement, volumeInfo.Ttl, diskType)
if !vl.SetVolumeCapacityFull(volumeInfo.Id) {
return false
@ -56,7 +56,7 @@ func (t *Topology) SetVolumeCapacityFull(volumeInfo storage.VolumeInfo) bool {
func (t *Topology) UnRegisterDataNode(dn *DataNode) {
for _, v := range dn.GetVolumes() {
glog.V(0).Infoln("Removing Volume", v.Id, "from the dead volume server", dn.Id())
diskType, _ := storage.ToDiskType(v.DiskType)
diskType := storage.ToDiskType(v.DiskType)
vl := t.GetVolumeLayout(v.Collection, v.ReplicaPlacement, v.Ttl, diskType)
vl.SetVolumeUnavailable(dn, v.Id)
}