forked from TrueCloudLab/frostfs-node
[#493] node: Abolish re-bootstrap configurations
From now non-relay node always sends re-bootstrap transaction every 2 epochs starting from the boot-up epoch. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
7a64a70b12
commit
f90fc86ec8
2 changed files with 17 additions and 22 deletions
|
@ -96,9 +96,7 @@ const (
|
||||||
|
|
||||||
cfgReplicatorPutTimeout = "replicator.put_timeout"
|
cfgReplicatorPutTimeout = "replicator.put_timeout"
|
||||||
|
|
||||||
cfgReBootstrapRelay = "bootstrap.relay_only"
|
cfgReBootstrapRelay = "bootstrap.relay_only"
|
||||||
cfgReBootstrapEnabled = "bootstrap.periodic.enabled"
|
|
||||||
cfgReBootstrapInterval = "bootstrap.periodic.interval"
|
|
||||||
|
|
||||||
cfgObjectPutPoolSize = "pool.object.put.size"
|
cfgObjectPutPoolSize = "pool.object.put.size"
|
||||||
cfgObjectGetPoolSize = "pool.object.get.size"
|
cfgObjectGetPoolSize = "pool.object.get.size"
|
||||||
|
@ -250,7 +248,7 @@ type cfgNetmap struct {
|
||||||
|
|
||||||
reBootstrapEnabled bool
|
reBootstrapEnabled bool
|
||||||
reBoostrapTurnedOff *atomic.Bool // managed by control service in runtime
|
reBoostrapTurnedOff *atomic.Bool // managed by control service in runtime
|
||||||
reBootstrapInterval uint64 // in epochs
|
startEpoch uint64 // epoch number when application is started
|
||||||
}
|
}
|
||||||
|
|
||||||
type BootstrapType uint32
|
type BootstrapType uint32
|
||||||
|
@ -377,8 +375,7 @@ func initCfg(path string) *cfg {
|
||||||
scriptHash: u160Netmap,
|
scriptHash: u160Netmap,
|
||||||
state: state,
|
state: state,
|
||||||
workerPool: netmapWorkerPool,
|
workerPool: netmapWorkerPool,
|
||||||
reBootstrapInterval: viperCfg.GetUint64(cfgReBootstrapInterval),
|
reBootstrapEnabled: !relayOnly,
|
||||||
reBootstrapEnabled: !relayOnly && viperCfg.GetBool(cfgReBootstrapEnabled),
|
|
||||||
reBoostrapTurnedOff: atomic.NewBool(relayOnly),
|
reBoostrapTurnedOff: atomic.NewBool(relayOnly),
|
||||||
},
|
},
|
||||||
cfgNodeInfo: cfgNodeInfo{
|
cfgNodeInfo: cfgNodeInfo{
|
||||||
|
@ -459,9 +456,6 @@ func defaultConfiguration(v *viper.Viper) {
|
||||||
|
|
||||||
v.SetDefault(cfgReplicatorPutTimeout, 5*time.Second)
|
v.SetDefault(cfgReplicatorPutTimeout, 5*time.Second)
|
||||||
|
|
||||||
v.SetDefault(cfgReBootstrapEnabled, false) // in epochs
|
|
||||||
v.SetDefault(cfgReBootstrapInterval, 2) // in epochs
|
|
||||||
|
|
||||||
v.SetDefault(cfgObjectGetPoolSize, 10)
|
v.SetDefault(cfgObjectGetPoolSize, 10)
|
||||||
v.SetDefault(cfgObjectHeadPoolSize, 10)
|
v.SetDefault(cfgObjectHeadPoolSize, 10)
|
||||||
v.SetDefault(cfgObjectPutPoolSize, 10)
|
v.SetDefault(cfgObjectPutPoolSize, 10)
|
||||||
|
|
|
@ -73,22 +73,22 @@ func initNetmapService(c *cfg) {
|
||||||
c.cfgNetmap.state.setCurrentEpoch(ev.(netmapEvent.NewEpoch).EpochNumber())
|
c.cfgNetmap.state.setCurrentEpoch(ev.(netmapEvent.NewEpoch).EpochNumber())
|
||||||
})
|
})
|
||||||
|
|
||||||
if c.cfgNetmap.reBootstrapEnabled {
|
addNewEpochAsyncNotificationHandler(c, func(ev event.Event) {
|
||||||
addNewEpochAsyncNotificationHandler(c, func(ev event.Event) {
|
if c.cfgNetmap.reBoostrapTurnedOff.Load() { // fixes #470
|
||||||
if c.cfgNetmap.reBoostrapTurnedOff.Load() { // fixes #470
|
return
|
||||||
return
|
}
|
||||||
}
|
|
||||||
|
|
||||||
n := ev.(netmapEvent.NewEpoch).EpochNumber()
|
n := ev.(netmapEvent.NewEpoch).EpochNumber()
|
||||||
|
|
||||||
if n%c.cfgNetmap.reBootstrapInterval == 0 {
|
const reBootstrapInterval = 2
|
||||||
err := c.cfgNetmap.wrapper.AddPeer(c.toOnlineLocalNodeInfo())
|
|
||||||
if err != nil {
|
if (n-c.cfgNetmap.startEpoch)%reBootstrapInterval == 0 {
|
||||||
c.log.Warn("can't send re-bootstrap tx", zap.Error(err))
|
err := c.cfgNetmap.wrapper.AddPeer(c.toOnlineLocalNodeInfo())
|
||||||
}
|
if err != nil {
|
||||||
|
c.log.Warn("can't send re-bootstrap tx", zap.Error(err))
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
addNewEpochAsyncNotificationHandler(c, func(ev event.Event) {
|
addNewEpochAsyncNotificationHandler(c, func(ev event.Event) {
|
||||||
e := ev.(netmapEvent.NewEpoch).EpochNumber()
|
e := ev.(netmapEvent.NewEpoch).EpochNumber()
|
||||||
|
@ -149,6 +149,7 @@ func initState(c *cfg) {
|
||||||
)
|
)
|
||||||
|
|
||||||
c.cfgNetmap.state.setCurrentEpoch(epoch)
|
c.cfgNetmap.state.setCurrentEpoch(epoch)
|
||||||
|
c.cfgNetmap.startEpoch = epoch
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cfg) netmapLocalNodeState(epoch uint64) (*netmapSDK.NodeInfo, error) {
|
func (c *cfg) netmapLocalNodeState(epoch uint64) (*netmapSDK.NodeInfo, error) {
|
||||||
|
|
Loading…
Reference in a new issue