[#1382] node: Replace deprecated methods

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2024-09-18 12:27:10 +03:00
parent a603d14d08
commit ac1eee091d
3 changed files with 25 additions and 17 deletions

View file

@ -1182,7 +1182,9 @@ func (c *cfg) bootstrapWithState(stateSetter func(*netmap.NodeInfo)) error {
// bootstrapOnline calls cfg.bootstrapWithState with "online" state.
func bootstrapOnline(c *cfg) error {
return c.bootstrapWithState((*netmap.NodeInfo).SetOnline)
return c.bootstrapWithState(func(ni *netmap.NodeInfo) {
ni.SetStatus(netmap.Online)
})
}
// bootstrap calls bootstrapWithState with:
@ -1193,7 +1195,9 @@ func (c *cfg) bootstrap() error {
st := c.cfgNetmap.state.controlNetmapStatus()
if st == control.NetmapStatus_MAINTENANCE {
c.log.Info(logs.FrostFSNodeBootstrappingWithTheMaintenanceState)
return c.bootstrapWithState((*netmap.NodeInfo).SetMaintenance)
return c.bootstrapWithState(func(ni *netmap.NodeInfo) {
ni.SetStatus(netmap.Maintenance)
})
}
c.log.Info(logs.FrostFSNodeBootstrappingWithOnlineState,

View file

@ -61,13 +61,15 @@ func (s *networkState) setNodeInfo(ni *netmapSDK.NodeInfo) {
if ni != nil {
s.nodeInfo.Store(*ni)
switch {
case ni.IsOnline():
switch ni.Status() {
case netmapSDK.Online:
ctrlNetSt = control.NetmapStatus_ONLINE
case ni.IsOffline():
case netmapSDK.Offline:
ctrlNetSt = control.NetmapStatus_OFFLINE
case ni.IsMaintenance():
case netmapSDK.Maintenance:
ctrlNetSt = control.NetmapStatus_MAINTENANCE
case netmapSDK.UnspecifiedState:
ctrlNetSt = control.NetmapStatus_STATUS_UNDEFINED
}
} else {
ctrlNetSt = control.NetmapStatus_OFFLINE
@ -78,7 +80,7 @@ func (s *networkState) setNodeInfo(ni *netmapSDK.NodeInfo) {
// nil ni means that the node is not included
// in the netmap
niOld.SetOffline()
niOld.SetStatus(netmapSDK.Offline)
s.nodeInfo.Store(niOld)
}
@ -139,7 +141,7 @@ func initNetmapService(ctx context.Context, c *cfg) {
network.WriteToNodeInfo(c.localAddr, &c.cfgNodeInfo.localInfo)
c.cfgNodeInfo.localInfo.SetPublicKey(c.key.PublicKey().Bytes())
parseAttributes(c)
c.cfgNodeInfo.localInfo.SetOffline()
c.cfgNodeInfo.localInfo.SetStatus(netmapSDK.Offline)
if c.cfgMorph.client == nil {
initMorphComponents(ctx, c)
@ -252,7 +254,7 @@ func initNetmapState(c *cfg) {
zap.String("state", stateWord),
)
if ni != nil && ni.IsMaintenance() {
if ni != nil && ni.Status().IsMaintenance() {
c.isMaintenance.Store(true)
}
@ -263,13 +265,15 @@ func initNetmapState(c *cfg) {
func nodeState(ni *netmapSDK.NodeInfo) string {
if ni != nil {
switch {
case ni.IsOnline():
switch ni.Status() {
case netmapSDK.Online:
return "online"
case ni.IsOffline():
case netmapSDK.Offline:
return "offline"
case ni.IsMaintenance():
case netmapSDK.Maintenance:
return "maintenance"
case netmapSDK.UnspecifiedState:
return "undefined"
}
}
return "undefined"

View file

@ -14,14 +14,14 @@ func PrettyPrintNodeInfo(cmd *cobra.Command, node netmap.NodeInfo,
) {
var strState string
switch {
switch node.Status() {
default:
strState = "STATE_UNSUPPORTED"
case node.IsOnline():
case netmap.Online:
strState = "ONLINE"
case node.IsOffline():
case netmap.Offline:
strState = "OFFLINE"
case node.IsMaintenance():
case netmap.Maintenance:
strState = "MAINTENANCE"
}