Browse Source

support customizable disk type

pull/1804/head
Chris Lu 4 years ago
parent
commit
7ce647f27e
  1. 6
      docker/compose/local-cluster-compose.yml
  2. 4
      weed/server/volume_server_handlers_admin.go
  3. 2
      weed/server/volume_server_handlers_ui.go
  4. 4
      weed/server/volume_server_ui/templates.go
  5. 7
      weed/storage/disk_location.go
  6. 1
      weed/storage/store.go
  7. 7
      weed/storage/volume_disk_type.go

6
docker/compose/local-cluster-compose.yml

@ -24,7 +24,7 @@ services:
ports: ports:
- 8080:8080 - 8080:8080
- 18080:18080 - 18080:18080
command: 'volume -mserver="master0:9333,master1:9334,master2:9335" -port=8080 -ip=volume1 -publicUrl=localhost:8080'
command: 'volume -mserver="master0:9333,master1:9334,master2:9335" -port=8080 -ip=volume1 -publicUrl=localhost:8080 -preStopSeconds=1 -disk=ssd1'
depends_on: depends_on:
- master0 - master0
- master1 - master1
@ -34,7 +34,7 @@ services:
ports: ports:
- 8082:8082 - 8082:8082
- 18082:18082 - 18082:18082
command: 'volume -mserver="master0:9333,master1:9334,master2:9335" -port=8082 -ip=volume2 -publicUrl=localhost:8082'
command: 'volume -mserver="master0:9333,master1:9334,master2:9335" -port=8082 -ip=volume2 -publicUrl=localhost:8082 -preStopSeconds=1 -disk=ssd1'
depends_on: depends_on:
- master0 - master0
- master1 - master1
@ -44,7 +44,7 @@ services:
ports: ports:
- 8083:8083 - 8083:8083
- 18083:18083 - 18083:18083
command: 'volume -mserver="master0:9333,master1:9334,master2:9335" -port=8083 -ip=volume3 -publicUrl=localhost:8083'
command: 'volume -mserver="master0:9333,master1:9334,master2:9335" -port=8083 -ip=volume3 -publicUrl=localhost:8083 -preStopSeconds=1'
depends_on: depends_on:
- master0 - master0
- master1 - master1

4
weed/server/volume_server_handlers_admin.go

@ -17,7 +17,7 @@ func (vs *VolumeServer) statusHandler(w http.ResponseWriter, r *http.Request) {
for _, loc := range vs.store.Locations { for _, loc := range vs.store.Locations {
if dir, e := filepath.Abs(loc.Directory); e == nil { if dir, e := filepath.Abs(loc.Directory); e == nil {
newDiskStatus := stats.NewDiskStatus(dir) newDiskStatus := stats.NewDiskStatus(dir)
newDiskStatus.DiskType = loc.GetDiskType()
newDiskStatus.DiskType = loc.DiskType.String()
ds = append(ds, newDiskStatus) ds = append(ds, newDiskStatus)
} }
} }
@ -34,7 +34,7 @@ func (vs *VolumeServer) statsDiskHandler(w http.ResponseWriter, r *http.Request)
for _, loc := range vs.store.Locations { for _, loc := range vs.store.Locations {
if dir, e := filepath.Abs(loc.Directory); e == nil { if dir, e := filepath.Abs(loc.Directory); e == nil {
newDiskStatus := stats.NewDiskStatus(dir) newDiskStatus := stats.NewDiskStatus(dir)
newDiskStatus.DiskType = loc.GetDiskType()
newDiskStatus.DiskType = loc.DiskType.String()
ds = append(ds, newDiskStatus) ds = append(ds, newDiskStatus)
} }
} }

2
weed/server/volume_server_handlers_ui.go

@ -20,7 +20,7 @@ func (vs *VolumeServer) uiStatusHandler(w http.ResponseWriter, r *http.Request)
for _, loc := range vs.store.Locations { for _, loc := range vs.store.Locations {
if dir, e := filepath.Abs(loc.Directory); e == nil { if dir, e := filepath.Abs(loc.Directory); e == nil {
newDiskStatus := stats.NewDiskStatus(dir) newDiskStatus := stats.NewDiskStatus(dir)
newDiskStatus.DiskType = loc.GetDiskType()
newDiskStatus.DiskType = loc.DiskType.String()
ds = append(ds, newDiskStatus) ds = append(ds, newDiskStatus)
} }
} }

4
weed/server/volume_server_ui/templates.go

@ -69,7 +69,7 @@ var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(`<!DOC
<thead> <thead>
<tr> <tr>
<th>Path</th> <th>Path</th>
<th>Type</th>
<th>Disk</th>
<th>Total</th> <th>Total</th>
<th>Free</th> <th>Free</th>
<th>Usage</th> <th>Usage</th>
@ -129,6 +129,7 @@ var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(`<!DOC
<tr> <tr>
<th>Id</th> <th>Id</th>
<th>Collection</th> <th>Collection</th>
<th>Disk</th>
<th>Data Size</th> <th>Data Size</th>
<th>Files</th> <th>Files</th>
<th>Trash</th> <th>Trash</th>
@ -141,6 +142,7 @@ var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(`<!DOC
<tr> <tr>
<td><code>{{ .Id }}</code></td> <td><code>{{ .Id }}</code></td>
<td>{{ .Collection }}</td> <td>{{ .Collection }}</td>
<td>{{ .DiskType }}</td>
<td>{{ bytesToHumanReadable .Size }}</td> <td>{{ bytesToHumanReadable .Size }}</td>
<td>{{ .FileCount }}</td> <td>{{ .FileCount }}</td>
<td>{{ .DeleteCount }} / {{bytesToHumanReadable .DeletedByteCount}}</td> <td>{{ .DeleteCount }} / {{bytesToHumanReadable .DeletedByteCount}}</td>

7
weed/storage/disk_location.go

@ -373,10 +373,3 @@ func (l *DiskLocation) CheckDiskSpace() {
} }
} }
func (l *DiskLocation) GetDiskType() string {
if l.DiskType == SsdType {
return "SSD"
}
return "HDD"
}

1
weed/storage/store.go

@ -173,6 +173,7 @@ func collectStatForOneVolume(vid needle.VolumeId, v *Volume) (s *VolumeInfo) {
ReadOnly: v.IsReadOnly(), ReadOnly: v.IsReadOnly(),
Ttl: v.Ttl, Ttl: v.Ttl,
CompactRevision: uint32(v.CompactionRevision), CompactRevision: uint32(v.CompactionRevision),
DiskType: v.DiskType().String(),
} }
s.RemoteStorageName, s.RemoteStorageKey = v.RemoteStorageNameKey() s.RemoteStorageName, s.RemoteStorageKey = v.RemoteStorageNameKey()

7
weed/storage/volume_disk_type.go

@ -24,3 +24,10 @@ func ToDiskType(vt string) (diskType DiskType) {
} }
return return
} }
func (diskType DiskType) String() string{
if diskType == "" {
return "hdd"
}
return string(diskType)
}
Loading…
Cancel
Save