mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
feat(master): support report whether enable bcache for client. #22845037
Signed-off-by: Victor1319 <zengxuewei@oppo.com>
This commit is contained in:
parent
a5be7f5c7b
commit
fa2e7a4cdf
@ -34,6 +34,7 @@ import (
|
||||
"github.com/cubefs/cubefs/proto"
|
||||
"github.com/cubefs/cubefs/sdk/data/blobstore"
|
||||
"github.com/cubefs/cubefs/sdk/data/stream"
|
||||
"github.com/cubefs/cubefs/sdk/master"
|
||||
"github.com/cubefs/cubefs/sdk/meta"
|
||||
"github.com/cubefs/cubefs/util"
|
||||
"github.com/cubefs/cubefs/util/auditlog"
|
||||
@ -131,6 +132,8 @@ func NewSuper(opt *proto.MountOptions) (s *Super, err error) {
|
||||
return nil, errors.Trace(err, "NewMetaWrapper failed!"+err.Error())
|
||||
}
|
||||
|
||||
master.BcacheOnlyForNotSSD = opt.EnableBcache && opt.BcacheOnlyForNotSSD
|
||||
|
||||
s.SetTransaction(opt.EnableTransaction, opt.TxTimeout, opt.TxConflictRetryNum, opt.TxConflictRetryInterval)
|
||||
s.mw.EnableQuota = opt.EnableQuota
|
||||
|
||||
|
||||
@ -5635,14 +5635,16 @@ func (m *Server) getVolStatInfo(w http.ResponseWriter, r *http.Request) {
|
||||
clientVer := r.FormValue(proto.ClientVerKey)
|
||||
hostName := r.FormValue(proto.HostKey)
|
||||
role := r.FormValue(proto.RoleKey)
|
||||
log.LogInfof("getVolStatInfo: get client ver info %s, ip %s, host %s, vol %s, role %s", clientVer, remoteIp, hostName, name, role)
|
||||
enableBcache := r.FormValue(proto.BcacheOnlyForNotSSDKey)
|
||||
log.LogInfof("getVolStatInfo: get client ver info %s, ip %s, host %s, vol %s, role %s, enableBcache %s",
|
||||
clientVer, remoteIp, hostName, name, role, enableBcache)
|
||||
|
||||
if vol, err = m.cluster.getVol(name); err != nil {
|
||||
sendErrReply(w, r, newErrHTTPReply(proto.ErrVolNotExists))
|
||||
return
|
||||
}
|
||||
|
||||
m.cliMgr.PutItem(remoteIp, hostName, name, clientVer, role)
|
||||
m.cliMgr.PutItem(remoteIp, hostName, name, clientVer, role, enableBcache)
|
||||
|
||||
if proto.IsCold(vol.VolType) && ver != proto.LFClient {
|
||||
sendErrReply(w, r, &proto.HTTPReply{Code: proto.ErrCodeParamError, Msg: "ec-vol is supported by LF client only"})
|
||||
|
||||
@ -30,7 +30,7 @@ func newClientMgr() *ClientMgr {
|
||||
return mgr
|
||||
}
|
||||
|
||||
func (cm *ClientMgr) PutItem(ip, host, vol, version, role string) {
|
||||
func (cm *ClientMgr) PutItem(ip, host, vol, version, role, enableBcache string) {
|
||||
cm.Lock()
|
||||
defer cm.Unlock()
|
||||
|
||||
@ -46,7 +46,13 @@ func (cm *ClientMgr) PutItem(ip, host, vol, version, role string) {
|
||||
role = defaultRole
|
||||
}
|
||||
|
||||
key := fmt.Sprintf("_%s_%s_%s_%s_%s", vol, version, role, ip, host)
|
||||
if enableBcache == "1" {
|
||||
enableBcache = "true"
|
||||
} else {
|
||||
enableBcache = "false"
|
||||
}
|
||||
|
||||
key := fmt.Sprintf("_%s_%s_%s_%s_%s_enableBcache-%s", vol, version, role, ip, host, enableBcache)
|
||||
|
||||
if len(cm.clients) > maxClientCnt {
|
||||
log.LogWarnf("PutItem: too many record in cluster, ignore, key %s", key)
|
||||
|
||||
@ -390,6 +390,7 @@ const (
|
||||
HostKey = "host"
|
||||
ClientVerKey = "clientVer"
|
||||
RoleKey = "role"
|
||||
BcacheOnlyForNotSSDKey = "enableBcacheNotSSD"
|
||||
)
|
||||
|
||||
// const TimeFormat = "2006-01-02 15:04:05"
|
||||
|
||||
@ -23,6 +23,8 @@ import (
|
||||
"github.com/cubefs/cubefs/util/iputil"
|
||||
)
|
||||
|
||||
var BcacheOnlyForNotSSD bool
|
||||
|
||||
type Decoder func([]byte) ([]byte, error)
|
||||
|
||||
func (d Decoder) Decode(raw []byte) ([]byte, error) {
|
||||
@ -90,6 +92,7 @@ func (api *ClientAPI) GetVolumeStat(volName string) (info *proto.VolStatInfo, er
|
||||
anyParam{proto.ClientVerKey, proto.Version},
|
||||
anyParam{proto.HostKey, iputil.HostName},
|
||||
anyParam{proto.RoleKey, proto.Role},
|
||||
anyParam{proto.BcacheOnlyForNotSSDKey, BcacheOnlyForNotSSD},
|
||||
))
|
||||
return
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user