[#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
012af5cc38
commit
3cd7d23f10
2 changed files with 11 additions and 37 deletions
|
@ -1179,17 +1179,15 @@ func initObjectPool(cfg *config.Config) (pool cfgObjectRoutines) {
|
||||||
return pool
|
return pool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cfg) LocalNodeInfo() (*netmapV2.NodeInfo, error) {
|
func (c *cfg) LocalNodeInfo() *netmap.NodeInfo {
|
||||||
var res netmapV2.NodeInfo
|
var res netmap.NodeInfo
|
||||||
|
|
||||||
ni, ok := c.cfgNetmap.state.getNodeInfo()
|
ni, ok := c.cfgNetmap.state.getNodeInfo()
|
||||||
if ok {
|
if ok {
|
||||||
ni.WriteToV2(&res)
|
res = ni
|
||||||
} else {
|
} else {
|
||||||
c.cfgNodeInfo.localInfo.WriteToV2(&res)
|
res = c.cfgNodeInfo.localInfo
|
||||||
}
|
}
|
||||||
|
return &res
|
||||||
return &res, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// setContractNodeInfo rewrites local node info from the FrostFS network map.
|
// setContractNodeInfo rewrites local node info from the FrostFS network map.
|
||||||
|
|
|
@ -28,7 +28,7 @@ type executorSvc struct {
|
||||||
type NodeState interface {
|
type NodeState interface {
|
||||||
// LocalNodeInfo must return current node state
|
// LocalNodeInfo must return current node state
|
||||||
// in FrostFS API v2 NodeInfo structure.
|
// in FrostFS API v2 NodeInfo structure.
|
||||||
LocalNodeInfo() (*netmap.NodeInfo, error)
|
LocalNodeInfo() *netmapSDK.NodeInfo
|
||||||
|
|
||||||
// ReadCurrentNetMap reads current local network map of the storage node
|
// ReadCurrentNetMap reads current local network map of the storage node
|
||||||
// into the given parameter. Returns any error encountered which prevented
|
// 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(
|
func (s *executorSvc) LocalNodeInfo(
|
||||||
_ context.Context,
|
_ context.Context,
|
||||||
req *netmap.LocalNodeInfoRequest,
|
_ *netmap.LocalNodeInfoRequest,
|
||||||
) (*netmap.LocalNodeInfoResponse, error) {
|
) (*netmap.LocalNodeInfoResponse, error) {
|
||||||
verV2 := req.GetMetaHeader().GetVersion()
|
ni := s.state.LocalNodeInfo()
|
||||||
if verV2 == nil {
|
var nodeInfo netmap.NodeInfo
|
||||||
return nil, errors.New("missing version")
|
ni.WriteToV2(&nodeInfo)
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
body := new(netmap.LocalNodeInfoResponseBody)
|
body := new(netmap.LocalNodeInfoResponseBody)
|
||||||
body.SetVersion(&s.version)
|
body.SetVersion(&s.version)
|
||||||
body.SetNodeInfo(ni)
|
body.SetNodeInfo(&nodeInfo)
|
||||||
|
|
||||||
resp := new(netmap.LocalNodeInfoResponse)
|
resp := new(netmap.LocalNodeInfoResponse)
|
||||||
resp.SetBody(body)
|
resp.SetBody(body)
|
||||||
|
|
Loading…
Reference in a new issue