[#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. // bootstrapOnline calls cfg.bootstrapWithState with "online" state.
func bootstrapOnline(c *cfg) error { 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: // bootstrap calls bootstrapWithState with:
@ -1193,7 +1195,9 @@ func (c *cfg) bootstrap() error {
st := c.cfgNetmap.state.controlNetmapStatus() st := c.cfgNetmap.state.controlNetmapStatus()
if st == control.NetmapStatus_MAINTENANCE { if st == control.NetmapStatus_MAINTENANCE {
c.log.Info(logs.FrostFSNodeBootstrappingWithTheMaintenanceState) 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, c.log.Info(logs.FrostFSNodeBootstrappingWithOnlineState,

View file

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

View file

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