mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
disk type can be generic tags
This commit is contained in:
parent
712b3e9e53
commit
4bd8a692d8
|
@ -169,11 +169,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {
|
||||||
mountRoot = mountRoot[0 : len(mountRoot)-1]
|
mountRoot = mountRoot[0 : len(mountRoot)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
diskType, err := storage.ToDiskType(*option.diskType)
|
diskType := storage.ToDiskType(*option.diskType)
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("failed to parse volume type: %v\n", err)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
seaweedFileSystem := filesys.NewSeaweedFileSystem(&filesys.Option{
|
seaweedFileSystem := filesys.NewSeaweedFileSystem(&filesys.Option{
|
||||||
MountDirectory: dir,
|
MountDirectory: dir,
|
||||||
|
|
|
@ -173,11 +173,7 @@ func (v VolumeServerOptions) startVolumeServer(volumeFolders, maxVolumeCounts, v
|
||||||
var diskTypes []storage.DiskType
|
var diskTypes []storage.DiskType
|
||||||
diskTypeStrings := strings.Split(*v.diskType, ",")
|
diskTypeStrings := strings.Split(*v.diskType, ",")
|
||||||
for _, diskTypeString := range diskTypeStrings {
|
for _, diskTypeString := range diskTypeStrings {
|
||||||
if diskType, err := storage.ToDiskType(diskTypeString); err == nil {
|
diskTypes = append(diskTypes, storage.ToDiskType(diskTypeString))
|
||||||
diskTypes = append(diskTypes, diskType)
|
|
||||||
} else {
|
|
||||||
glog.Fatalf("failed to parse volume type: %v", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if len(diskTypes) == 1 && len(v.folders) > 1 {
|
if len(diskTypes) == 1 && len(v.folders) > 1 {
|
||||||
for i := 0; i < len(v.folders)-1; i++ {
|
for i := 0; i < len(v.folders)-1; i++ {
|
||||||
|
|
|
@ -61,10 +61,7 @@ func (ms *MasterServer) Assign(ctx context.Context, req *master_pb.AssignRequest
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
diskType, err := storage.ToDiskType(req.DiskType)
|
diskType := storage.ToDiskType(req.DiskType)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
option := &topology.VolumeGrowOption{
|
option := &topology.VolumeGrowOption{
|
||||||
Collection: req.Collection,
|
Collection: req.Collection,
|
||||||
|
|
|
@ -158,10 +158,7 @@ func (ms *MasterServer) getVolumeGrowOption(r *http.Request) (*topology.VolumeGr
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
diskType, err := storage.ToDiskType(r.FormValue("disk"))
|
diskType := storage.ToDiskType(r.FormValue("disk"))
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
preallocate := ms.preallocateSize
|
preallocate := ms.preallocateSize
|
||||||
if r.FormValue("preallocate") != "" {
|
if r.FormValue("preallocate") != "" {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package storage
|
package storage
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
type DiskType string
|
type DiskType string
|
||||||
|
|
||||||
|
@ -9,7 +11,8 @@ const (
|
||||||
SsdType = "ssd"
|
SsdType = "ssd"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ToDiskType(vt string) (diskType DiskType, err error) {
|
func ToDiskType(vt string) (diskType DiskType) {
|
||||||
|
vt = strings.ToLower(vt)
|
||||||
diskType = HardDriveType
|
diskType = HardDriveType
|
||||||
switch vt {
|
switch vt {
|
||||||
case "", "hdd":
|
case "", "hdd":
|
||||||
|
@ -17,7 +20,7 @@ func ToDiskType(vt string) (diskType DiskType, err error) {
|
||||||
case "ssd":
|
case "ssd":
|
||||||
diskType = SsdType
|
diskType = SsdType
|
||||||
default:
|
default:
|
||||||
err = fmt.Errorf("parse DiskType %s: expecting hdd or ssd\n", vt)
|
diskType = DiskType(vt)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
|
@ -188,14 +188,14 @@ func (t *Topology) DeleteLayout(collectionName string, rp *super_block.ReplicaPl
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Topology) RegisterVolumeLayout(v storage.VolumeInfo, dn *DataNode) {
|
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 := t.GetVolumeLayout(v.Collection, v.ReplicaPlacement, v.Ttl, diskType)
|
||||||
vl.RegisterVolume(&v, dn)
|
vl.RegisterVolume(&v, dn)
|
||||||
vl.EnsureCorrectWritables(&v)
|
vl.EnsureCorrectWritables(&v)
|
||||||
}
|
}
|
||||||
func (t *Topology) UnRegisterVolumeLayout(v storage.VolumeInfo, dn *DataNode) {
|
func (t *Topology) UnRegisterVolumeLayout(v storage.VolumeInfo, dn *DataNode) {
|
||||||
glog.Infof("removing volume info: %+v", v)
|
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 := t.GetVolumeLayout(v.Collection, v.ReplicaPlacement, v.Ttl, diskType)
|
||||||
volumeLayout.UnRegisterVolume(&v, dn)
|
volumeLayout.UnRegisterVolume(&v, dn)
|
||||||
if volumeLayout.isEmpty() {
|
if volumeLayout.isEmpty() {
|
||||||
|
@ -235,7 +235,7 @@ func (t *Topology) SyncDataNodeRegistration(volumes []*master_pb.VolumeInformati
|
||||||
t.UnRegisterVolumeLayout(v, dn)
|
t.UnRegisterVolumeLayout(v, dn)
|
||||||
}
|
}
|
||||||
for _, v := range changedVolumes {
|
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 := t.GetVolumeLayout(v.Collection, v.ReplicaPlacement, v.Ttl, diskType)
|
||||||
vl.EnsureCorrectWritables(&v)
|
vl.EnsureCorrectWritables(&v)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ func (t *Topology) StartRefreshWritableVolumes(grpcDialOption grpc.DialOption, g
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
func (t *Topology) SetVolumeCapacityFull(volumeInfo storage.VolumeInfo) bool {
|
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)
|
vl := t.GetVolumeLayout(volumeInfo.Collection, volumeInfo.ReplicaPlacement, volumeInfo.Ttl, diskType)
|
||||||
if !vl.SetVolumeCapacityFull(volumeInfo.Id) {
|
if !vl.SetVolumeCapacityFull(volumeInfo.Id) {
|
||||||
return false
|
return false
|
||||||
|
@ -56,7 +56,7 @@ func (t *Topology) SetVolumeCapacityFull(volumeInfo storage.VolumeInfo) bool {
|
||||||
func (t *Topology) UnRegisterDataNode(dn *DataNode) {
|
func (t *Topology) UnRegisterDataNode(dn *DataNode) {
|
||||||
for _, v := range dn.GetVolumes() {
|
for _, v := range dn.GetVolumes() {
|
||||||
glog.V(0).Infoln("Removing Volume", v.Id, "from the dead volume server", dn.Id())
|
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 := t.GetVolumeLayout(v.Collection, v.ReplicaPlacement, v.Ttl, diskType)
|
||||||
vl.SetVolumeUnavailable(dn, v.Id)
|
vl.SetVolumeUnavailable(dn, v.Id)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue