mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-08 15:41:15 +02:00
A master decides nothing from it. Every caller that read it was asking whether a volume is remote, which the backend name answers, and the value itself is reported on demand by the server holding the volume, through the volume info in ReadVolumeFileStatus. It is also the one string here that cannot be shared: unique per volume, so unlike the collection and backend names it carries its own characters for every volume a master tracks. VolumeInfo goes from 136 bytes to 120. 800k volumes registered from a heartbeat that has been over the wire go from 214 to 163 B/volume when tiered. The volume server's own status page keeps showing the key, now read from the volume it holds rather than relayed through a master, which is also where the other volume server implementation reads it. The heartbeat digest drops it on the same grounds: a change to something the master does not hold cannot make its copy stale. Both implementations and their shared vectors move together, and the field-coverage test now names what is deliberately not retained rather than being loosened.
75 lines
2.2 KiB
Go
75 lines
2.2 KiB
Go
package weed_server
|
|
|
|
import (
|
|
"net/http"
|
|
"path/filepath"
|
|
"time"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/glog"
|
|
"github.com/seaweedfs/seaweedfs/weed/pb"
|
|
"github.com/seaweedfs/seaweedfs/weed/util/version"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
|
|
ui "github.com/seaweedfs/seaweedfs/weed/server/volume_server_ui"
|
|
"github.com/seaweedfs/seaweedfs/weed/stats"
|
|
"github.com/seaweedfs/seaweedfs/weed/storage"
|
|
)
|
|
|
|
// remoteVolumeRow carries the remote key the store no longer keeps per volume,
|
|
// read from the volume this server holds rather than relayed by a master.
|
|
type remoteVolumeRow struct {
|
|
*storage.VolumeInfo
|
|
RemoteStorageKey string
|
|
}
|
|
|
|
func (vs *VolumeServer) uiStatusHandler(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Server", "SeaweedFS Volume "+version.VERSION)
|
|
infos := make(map[string]interface{})
|
|
infos["Up Time"] = time.Since(startTime).Truncate(time.Second).String()
|
|
var ds []*volume_server_pb.DiskStatus
|
|
for _, loc := range vs.store.Locations {
|
|
if dir, e := filepath.Abs(loc.Directory); e == nil {
|
|
newDiskStatus := stats.NewDiskStatus(dir)
|
|
newDiskStatus.DiskType = loc.DiskType.String()
|
|
ds = append(ds, newDiskStatus)
|
|
}
|
|
}
|
|
volumeInfos := vs.store.VolumeInfos()
|
|
var normalVolumeInfos []*storage.VolumeInfo
|
|
var remoteVolumeInfos []remoteVolumeRow
|
|
for _, vinfo := range volumeInfos {
|
|
if !vinfo.IsRemote() {
|
|
normalVolumeInfos = append(normalVolumeInfos, vinfo)
|
|
continue
|
|
}
|
|
row := remoteVolumeRow{VolumeInfo: vinfo}
|
|
if v := vs.store.GetVolume(vinfo.Id); v != nil {
|
|
_, row.RemoteStorageKey = v.RemoteStorageNameKey()
|
|
}
|
|
remoteVolumeInfos = append(remoteVolumeInfos, row)
|
|
}
|
|
args := struct {
|
|
Version string
|
|
Masters []pb.ServerAddress
|
|
Volumes interface{}
|
|
EcVolumes interface{}
|
|
RemoteVolumes interface{}
|
|
DiskStatuses interface{}
|
|
Stats interface{}
|
|
Counters *stats.ServerStats
|
|
}{
|
|
version.Version(),
|
|
vs.SeedMasterNodes,
|
|
normalVolumeInfos,
|
|
vs.store.EcVolumes(),
|
|
remoteVolumeInfos,
|
|
ds,
|
|
infos,
|
|
serverStats,
|
|
}
|
|
if err := ui.StatusTpl.Execute(w, args); err != nil {
|
|
glog.Errorf("template execution error: %v", err)
|
|
http.Error(w, "Internal server error", http.StatusInternalServerError)
|
|
}
|
|
}
|