forked from TrueCloudLab/frostfs-sdk-go
[#315] netmap: Add maintenance mode network setting
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
4662d39886
commit
3dad44232e
2 changed files with 39 additions and 2 deletions
|
@ -75,7 +75,8 @@ func (x *NetworkInfo) readFromV2(m netmap.NetworkInfo, checkFieldPresence bool)
|
|||
configMaxObjSize,
|
||||
configWithdrawalFee:
|
||||
_, err = decodeConfigValueUint64(prm.GetValue())
|
||||
case configHomomorphicHashingDisabled:
|
||||
case configHomomorphicHashingDisabled,
|
||||
configMaintenanceModeAllowed:
|
||||
_, err = decodeConfigValueBool(prm.GetValue())
|
||||
}
|
||||
|
||||
|
@ -247,7 +248,8 @@ func (x *NetworkInfo) IterateRawNetworkParameters(f func(name string, value []by
|
|||
configIRCandidateFee,
|
||||
configMaxObjSize,
|
||||
configWithdrawalFee,
|
||||
configHomomorphicHashingDisabled:
|
||||
configHomomorphicHashingDisabled,
|
||||
configMaintenanceModeAllowed:
|
||||
}
|
||||
|
||||
return false
|
||||
|
@ -522,3 +524,20 @@ func (x *NetworkInfo) DisableHomomorphicHashing() {
|
|||
func (x NetworkInfo) HomomorphicHashingDisabled() bool {
|
||||
return x.configBool(configHomomorphicHashingDisabled)
|
||||
}
|
||||
|
||||
const configMaintenanceModeAllowed = "MaintenanceModeAllowed"
|
||||
|
||||
// AllowMaintenanceMode sets the flag allowing nodes to go into maintenance mode.
|
||||
//
|
||||
// See also MaintenanceModeAllowed.
|
||||
func (x *NetworkInfo) AllowMaintenanceMode() {
|
||||
x.setConfigBool(configMaintenanceModeAllowed, true)
|
||||
}
|
||||
|
||||
// MaintenanceModeAllowed returns true iff network config allows
|
||||
// maintenance mode for storage nodes.
|
||||
//
|
||||
// Zero NetworkInfo has disallows maintenance mode.
|
||||
func (x NetworkInfo) MaintenanceModeAllowed() bool {
|
||||
return x.configBool(configMaintenanceModeAllowed)
|
||||
}
|
||||
|
|
|
@ -233,3 +233,21 @@ func TestNetworkInfo_HomomorphicHashingDisabled(t *testing.T) {
|
|||
},
|
||||
)
|
||||
}
|
||||
|
||||
func TestNetworkInfo_MaintenanceModeAllowed(t *testing.T) {
|
||||
testConfigValue(t,
|
||||
func(x NetworkInfo) interface{} { return x.MaintenanceModeAllowed() },
|
||||
func(info *NetworkInfo, val interface{}) {
|
||||
if val.(bool) {
|
||||
info.AllowMaintenanceMode()
|
||||
}
|
||||
},
|
||||
true, true,
|
||||
"MaintenanceModeAllowed", func(val interface{}) []byte {
|
||||
if val.(bool) {
|
||||
return []byte{1}
|
||||
}
|
||||
return []byte{0}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue