forked from TrueCloudLab/frostfs-node
[#1439] node: Reduce usage of netmapAPI.NodeInfo
Remove outdated code from `netmap` service. Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
8b6ec57c61
commit
e17837b512
2 changed files with 11 additions and 37 deletions
|
@ -1176,17 +1176,15 @@ func initObjectPool(cfg *config.Config) (pool cfgObjectRoutines) {
|
|||
return pool
|
||||
}
|
||||
|
||||
func (c *cfg) LocalNodeInfo() (*netmapV2.NodeInfo, error) {
|
||||
var res netmapV2.NodeInfo
|
||||
|
||||
func (c *cfg) LocalNodeInfo() *netmap.NodeInfo {
|
||||
var res netmap.NodeInfo
|
||||
ni, ok := c.cfgNetmap.state.getNodeInfo()
|
||||
if ok {
|
||||
ni.WriteToV2(&res)
|
||||
res = ni
|
||||
} else {
|
||||
c.cfgNodeInfo.localInfo.WriteToV2(&res)
|
||||
res = c.cfgNodeInfo.localInfo
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
return &res
|
||||
}
|
||||
|
||||
// setContractNodeInfo rewrites local node info from the FrostFS network map.
|
||||
|
|
|
@ -28,7 +28,7 @@ type executorSvc struct {
|
|||
type NodeState interface {
|
||||
// LocalNodeInfo must return current node state
|
||||
// in FrostFS API v2 NodeInfo structure.
|
||||
LocalNodeInfo() (*netmap.NodeInfo, error)
|
||||
LocalNodeInfo() *netmapSDK.NodeInfo
|
||||
|
||||
// ReadCurrentNetMap reads current local network map of the storage node
|
||||
// into the given parameter. Returns any error encountered which prevented
|
||||
|
@ -64,39 +64,15 @@ func NewExecutionService(s NodeState, v versionsdk.Version, netInfo NetworkInfo,
|
|||
|
||||
func (s *executorSvc) LocalNodeInfo(
|
||||
_ context.Context,
|
||||
req *netmap.LocalNodeInfoRequest,
|
||||
_ *netmap.LocalNodeInfoRequest,
|
||||
) (*netmap.LocalNodeInfoResponse, error) {
|
||||
verV2 := req.GetMetaHeader().GetVersion()
|
||||
if verV2 == nil {
|
||||
return nil, errors.New("missing version")
|
||||
}
|
||||
|
||||
var ver versionsdk.Version
|
||||
if err := ver.ReadFromV2(*verV2); err != nil {
|
||||
return nil, fmt.Errorf("can't read version: %w", err)
|
||||
}
|
||||
|
||||
ni, err := s.state.LocalNodeInfo()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if addrNum := ni.NumberOfAddresses(); addrNum > 0 && ver.Minor() <= 7 {
|
||||
ni2 := new(netmap.NodeInfo)
|
||||
ni2.SetPublicKey(ni.GetPublicKey())
|
||||
ni2.SetState(ni.GetState())
|
||||
ni2.SetAttributes(ni.GetAttributes())
|
||||
ni.IterateAddresses(func(s string) bool {
|
||||
ni2.SetAddresses(s)
|
||||
return true
|
||||
})
|
||||
|
||||
ni = ni2
|
||||
}
|
||||
ni := s.state.LocalNodeInfo()
|
||||
var nodeInfo netmap.NodeInfo
|
||||
ni.WriteToV2(&nodeInfo)
|
||||
|
||||
body := new(netmap.LocalNodeInfoResponseBody)
|
||||
body.SetVersion(&s.version)
|
||||
body.SetNodeInfo(ni)
|
||||
body.SetNodeInfo(&nodeInfo)
|
||||
|
||||
resp := new(netmap.LocalNodeInfoResponse)
|
||||
resp.SetBody(body)
|
||||
|
|
Loading…
Reference in a new issue