Browse Source

disk type can be generic tags

pull/1804/head
Chris Lu 4 years ago
parent
commit
4bd8a692d8
  1. 6
      weed/command/mount_std.go
  2. 6
      weed/command/volume.go
  3. 5
      weed/server/master_grpc_server_volume.go
  4. 5
      weed/server/master_server_handlers_admin.go
  5. 9
      weed/storage/volume_disk_type.go
  6. 6
      weed/topology/topology.go
  7. 4
      weed/topology/topology_event_handling.go

6
weed/command/mount_std.go

@ -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,

6
weed/command/volume.go

@ -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++ {

5
weed/server/master_grpc_server_volume.go

@ -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,

5
weed/server/master_server_handlers_admin.go

@ -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") != "" {

9
weed/storage/volume_type.go → weed/storage/volume_disk_type.go

@ -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
}

6
weed/topology/topology.go

@ -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)
}

4
weed/topology/topology_event_handling.go

@ -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)
}

Loading…
Cancel
Save