mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-12-19 05:27:50 +08:00
[shell] use constant for hdd of type (#6337)
use constant for hdd of type
This commit is contained in:
parent
4f6c989309
commit
ff1392f7f4
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/seaweedfs/seaweedfs/weed/storage/types"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/seaweedfs/seaweedfs/weed/cluster"
|
"github.com/seaweedfs/seaweedfs/weed/cluster"
|
||||||
@ -79,7 +80,7 @@ func (c *commandClusterCheck) Do(args []string, commandEnv *CommandEnv, writer i
|
|||||||
|
|
||||||
if len(filers) > 0 {
|
if len(filers) > 0 {
|
||||||
genericDiskInfo, genericDiskInfoOk := topologyInfo.DiskInfos[""]
|
genericDiskInfo, genericDiskInfoOk := topologyInfo.DiskInfos[""]
|
||||||
hddDiskInfo, hddDiskInfoOk := topologyInfo.DiskInfos["hdd"]
|
hddDiskInfo, hddDiskInfoOk := topologyInfo.DiskInfos[types.HddType]
|
||||||
|
|
||||||
if !genericDiskInfoOk && !hddDiskInfoOk {
|
if !genericDiskInfoOk && !hddDiskInfoOk {
|
||||||
return fmt.Errorf("filer metadata logs need generic or hdd disk type to be defined")
|
return fmt.Errorf("filer metadata logs need generic or hdd disk type to be defined")
|
||||||
|
@ -265,7 +265,7 @@ func TestBalance(t *testing.T) {
|
|||||||
func TestVolumeSelection(t *testing.T) {
|
func TestVolumeSelection(t *testing.T) {
|
||||||
topologyInfo := parseOutput(topoData)
|
topologyInfo := parseOutput(topoData)
|
||||||
|
|
||||||
vids, err := collectVolumeIdsForTierChange(topologyInfo, 1000, types.ToDiskType("hdd"), "", 20.0, 0)
|
vids, err := collectVolumeIdsForTierChange(topologyInfo, 1000, types.ToDiskType(types.HddType), "", 20.0, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("collectVolumeIdsForTierChange: %v", err)
|
t.Errorf("collectVolumeIdsForTierChange: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/storage/erasure_coding"
|
"github.com/seaweedfs/seaweedfs/weed/storage/erasure_coding"
|
||||||
|
"github.com/seaweedfs/seaweedfs/weed/storage/types"
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@ -72,7 +73,7 @@ func diskInfosToString(diskInfos map[string]*master_pb.DiskInfo) string {
|
|||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
for diskType, diskInfo := range diskInfos {
|
for diskType, diskInfo := range diskInfos {
|
||||||
if diskType == "" {
|
if diskType == "" {
|
||||||
diskType = "hdd"
|
diskType = types.HddType
|
||||||
}
|
}
|
||||||
fmt.Fprintf(&buf, " %s(volume:%d/%d active:%d free:%d remote:%d)", diskType, diskInfo.VolumeCount, diskInfo.MaxVolumeCount, diskInfo.ActiveVolumeCount, diskInfo.FreeVolumeCount, diskInfo.RemoteVolumeCount)
|
fmt.Fprintf(&buf, " %s(volume:%d/%d active:%d free:%d remote:%d)", diskType, diskInfo.VolumeCount, diskInfo.MaxVolumeCount, diskInfo.ActiveVolumeCount, diskInfo.FreeVolumeCount, diskInfo.RemoteVolumeCount)
|
||||||
}
|
}
|
||||||
@ -162,7 +163,7 @@ func (c *commandVolumeList) writeDiskInfo(writer io.Writer, t *master_pb.DiskInf
|
|||||||
var s statistics
|
var s statistics
|
||||||
diskType := t.Type
|
diskType := t.Type
|
||||||
if diskType == "" {
|
if diskType == "" {
|
||||||
diskType = "hdd"
|
diskType = types.HddType
|
||||||
}
|
}
|
||||||
output(verbosityLevel >= 4, writer, " Disk %s(%s)\n", diskType, diskInfoToString(t))
|
output(verbosityLevel >= 4, writer, " Disk %s(%s)\n", diskType, diskInfoToString(t))
|
||||||
slices.SortFunc(t.VolumeInfos, func(a, b *master_pb.VolumeInformationMessage) int {
|
slices.SortFunc(t.VolumeInfos, func(a, b *master_pb.VolumeInformationMessage) int {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package storage
|
package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/seaweedfs/seaweedfs/weed/storage/types"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -40,7 +41,7 @@ func TestUnUsedSpace(t *testing.T) {
|
|||||||
Directory: "/test/",
|
Directory: "/test/",
|
||||||
DirectoryUuid: "1234",
|
DirectoryUuid: "1234",
|
||||||
IdxDirectory: "/test/",
|
IdxDirectory: "/test/",
|
||||||
DiskType: "hdd",
|
DiskType: types.HddType,
|
||||||
MaxVolumeCount: 0,
|
MaxVolumeCount: 0,
|
||||||
OriginalMaxVolumeCount: 0,
|
OriginalMaxVolumeCount: 0,
|
||||||
MinFreeSpace: minFreeSpace,
|
MinFreeSpace: minFreeSpace,
|
||||||
|
@ -8,6 +8,7 @@ type DiskType string
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
HardDriveType DiskType = ""
|
HardDriveType DiskType = ""
|
||||||
|
HddType = "hdd"
|
||||||
SsdType = "ssd"
|
SsdType = "ssd"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ func ToDiskType(vt string) (diskType DiskType) {
|
|||||||
vt = strings.ToLower(vt)
|
vt = strings.ToLower(vt)
|
||||||
diskType = HardDriveType
|
diskType = HardDriveType
|
||||||
switch vt {
|
switch vt {
|
||||||
case "", "hdd":
|
case "", HddType:
|
||||||
diskType = HardDriveType
|
diskType = HardDriveType
|
||||||
case "ssd":
|
case "ssd":
|
||||||
diskType = SsdType
|
diskType = SsdType
|
||||||
@ -34,7 +35,7 @@ func (diskType DiskType) String() string {
|
|||||||
|
|
||||||
func (diskType DiskType) ReadableString() string {
|
func (diskType DiskType) ReadableString() string {
|
||||||
if diskType == "" {
|
if diskType == "" {
|
||||||
return "hdd"
|
return HddType
|
||||||
}
|
}
|
||||||
return string(diskType)
|
return string(diskType)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user