forked from TrueCloudLab/frostfs-node
[#315] cmd/node: Implement node status updating in application
Call Netmap contract on SetNetmapStatus rpc of Control service (AddPeer method if new status is ONLINE, UpdatePeerState method otherwise). Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
619f8826e1
commit
fa0ea35f83
2 changed files with 18 additions and 0 deletions
|
@ -43,6 +43,7 @@ func initControlService(c *cfg) {
|
||||||
controlSvc.WithAuthorizedKeys(keys),
|
controlSvc.WithAuthorizedKeys(keys),
|
||||||
controlSvc.WithHealthChecker(c),
|
controlSvc.WithHealthChecker(c),
|
||||||
controlSvc.WithNetMapSource(c.cfgNetmap.wrapper),
|
controlSvc.WithNetMapSource(c.cfgNetmap.wrapper),
|
||||||
|
controlSvc.WithNodeState(c),
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -178,3 +178,20 @@ func goOffline(c *cfg) {
|
||||||
c.log.Info("request to go offline successfully sent")
|
c.log.Info("request to go offline successfully sent")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *cfg) SetNetmapStatus(st control.NetmapStatus) error {
|
||||||
|
if st == control.NetmapStatus_ONLINE {
|
||||||
|
return c.cfgNetmap.wrapper.AddPeer(c.cfgNodeInfo.info)
|
||||||
|
}
|
||||||
|
|
||||||
|
var apiState netmap.NodeState
|
||||||
|
|
||||||
|
if st == control.NetmapStatus_OFFLINE {
|
||||||
|
apiState = netmap.NodeStateOffline
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.cfgNetmap.wrapper.UpdatePeerState(
|
||||||
|
crypto.MarshalPublicKey(&c.key.PublicKey),
|
||||||
|
apiState,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue