[#10] Add __FROSTFS__ system attributes

Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
pull/10/head
Denis Kirillov 2023-03-06 15:24:58 +03:00
parent c46cd37f71
commit cd2e46a17c
5 changed files with 71 additions and 14 deletions

View File

@ -1,7 +1,7 @@
package container
// SysAttributePrefix is a prefix of key to system attribute.
const SysAttributePrefix = "__NEOFS__"
const SysAttributePrefix = "__FROSTFS__"
const (
// SysAttributeSubnet is a string ID of container's storage subnet.
@ -17,6 +17,23 @@ const (
SysAttributeHomomorphicHashing = SysAttributePrefix + "DISABLE_HOMOMORPHIC_HASHING"
)
// SysAttributePrefixNeoFS is a prefix of key to system attribute.
const SysAttributePrefixNeoFS = "__NEOFS__"
const (
// SysAttributeSubnetNeoFS is a string ID of container's storage subnet.
SysAttributeSubnetNeoFS = SysAttributePrefixNeoFS + "SUBNET"
// SysAttributeNameNeoFS is a string of human-friendly container name registered as the domain in NNS contract.
SysAttributeNameNeoFS = SysAttributePrefixNeoFS + "NAME"
// SysAttributeZoneNeoFS is a string of zone for container name.
SysAttributeZoneNeoFS = SysAttributePrefixNeoFS + "ZONE"
// SysAttributeHomomorphicHashingNeoFS is a container's homomorphic hashing state.
SysAttributeHomomorphicHashingNeoFS = SysAttributePrefixNeoFS + "DISABLE_HOMOMORPHIC_HASHING"
)
// SysAttributeZoneDefault is a default value for SysAttributeZone attribute.
const SysAttributeZoneDefault = "container"
@ -33,7 +50,7 @@ const disabledHomomorphicHashingValue = "true"
// See also SetHomomorphicHashingState.
func (c Container) HomomorphicHashingState() bool {
for i := range c.attr {
if c.attr[i].GetKey() == SysAttributeHomomorphicHashing {
if c.attr[i].GetKey() == SysAttributeHomomorphicHashing || c.attr[i].GetKey() == SysAttributeHomomorphicHashingNeoFS {
return c.attr[i].GetValue() != disabledHomomorphicHashingValue
}
}
@ -50,7 +67,7 @@ func (c Container) HomomorphicHashingState() bool {
// See also HomomorphicHashingState.
func (c *Container) SetHomomorphicHashingState(enable bool) {
for i := range c.attr {
if c.attr[i].GetKey() == SysAttributeHomomorphicHashing {
if c.attr[i].GetKey() == SysAttributeHomomorphicHashing || c.attr[i].GetKey() == SysAttributeHomomorphicHashingNeoFS {
if enable {
// approach without allocation/waste
// coping works since the attributes

View File

@ -9,7 +9,10 @@ import (
)
// prefix of keys to subnet attributes.
const attrSubnetPrefix = "__NEOFS__SUBNET_"
const attrSubnetPrefix = "__FROSTFS__SUBNET_"
// prefix of keys to subnet attributes.
const attrSubnetPrefixNeoFS = "__NEOFS__SUBNET_"
const (
// subnet attribute's value denoting subnet entry
@ -62,7 +65,7 @@ func subnetAttributeKey(id *refs.SubnetID) string {
// - disables non-zero subnet;
// - enables zero subnet.
//
// Attribute key is calculated from ID using format `__NEOFS__SUBNET_%s`.
// Attribute key is calculated from ID using format `__FROSTFS__SUBNET_%s`.
// Attribute Value is:
// - `True` if node enters the subnet;
// - `False`, otherwise.
@ -143,8 +146,11 @@ func IterateSubnets(node *NodeInfo, f func(refs.SubnetID) error) error {
// cut subnet ID string
idTxt := strings.TrimPrefix(key, attrSubnetPrefix)
if len(idTxt) == len(key) {
// not a subnet attribute
continue
idTxt = strings.TrimPrefix(key, attrSubnetPrefixNeoFS)
if len(idTxt) == len(key) {
// not a subnet attribute
continue
}
}
// check value

View File

@ -11,7 +11,7 @@ import (
)
func subnetAttrKey(val string) string {
return "__NEOFS__SUBNET_" + val
return "__FROSTFS__SUBNET_" + val
}
func assertSubnetAttrKey(t *testing.T, attr *netmap.Attribute, num uint32) {

View File

@ -7,7 +7,7 @@ import (
)
// SysAttributePrefix is a prefix of key to system attribute.
const SysAttributePrefix = "__NEOFS__"
const SysAttributePrefix = "__FROSTFS__"
const (
// SysAttributeUploadID marks smaller parts of a split bigger object.
@ -25,6 +25,25 @@ const (
SysAttributeTickTopic = SysAttributePrefix + "TICK_TOPIC"
)
// SysAttributePrefixNeoFS is a prefix of key to system attribute.
const SysAttributePrefixNeoFS = "__NEOFS__"
const (
// SysAttributeUploadIDNeoFS marks smaller parts of a split bigger object.
SysAttributeUploadIDNeoFS = SysAttributePrefixNeoFS + "UPLOAD_ID"
// SysAttributeExpEpochNeoFS tells GC to delete object after that epoch.
SysAttributeExpEpochNeoFS = SysAttributePrefixNeoFS + "EXPIRATION_EPOCH"
// SysAttributeTickEpochNeoFS defines what epoch must produce object
// notification.
SysAttributeTickEpochNeoFS = SysAttributePrefixNeoFS + "TICK_EPOCH"
// SysAttributeTickTopicNeoFS defines what topic object notification
// must be sent to.
SysAttributeTickTopicNeoFS = SysAttributePrefixNeoFS + "TICK_TOPIC"
)
// NotificationInfo groups information about object notification
// that can be written to object.
//
@ -81,10 +100,10 @@ func WriteNotificationInfo(o *Object, ni NotificationInfo) {
for i := range attrs {
switch attrs[i].GetKey() {
case SysAttributeTickEpoch:
case SysAttributeTickEpoch, SysAttributeTickEpochNeoFS:
attrs[i].SetValue(epoch)
changedEpoch = true
case SysAttributeTickTopic:
case SysAttributeTickTopic, SysAttributeTickTopicNeoFS:
changedTopic = true
if topic == "" {
@ -141,7 +160,7 @@ func GetNotificationInfo(o *Object) (*NotificationInfo, error) {
for _, attr := range o.GetHeader().GetAttributes() {
switch key := attr.GetKey(); key {
case SysAttributeTickEpoch:
case SysAttributeTickEpoch, SysAttributeTickEpochNeoFS:
epoch, err := strconv.ParseUint(attr.GetValue(), 10, 64)
if err != nil {
return nil, fmt.Errorf("could not parse epoch: %w", err)
@ -150,7 +169,7 @@ func GetNotificationInfo(o *Object) (*NotificationInfo, error) {
ni.SetEpoch(epoch)
foundEpoch = true
case SysAttributeTickTopic:
case SysAttributeTickTopic, SysAttributeTickTopicNeoFS:
ni.SetTopic(attr.GetValue())
}
}

View File

@ -1,7 +1,7 @@
package session
// ReservedXHeaderPrefix is a prefix of keys to "well-known" X-headers.
const ReservedXHeaderPrefix = "__NEOFS__"
const ReservedXHeaderPrefix = "__FROSTFS__"
const (
// XHeaderNetmapEpoch is a key to the reserved X-header that specifies netmap epoch
@ -14,3 +14,18 @@ const (
// set, the current epoch only will be used.
XHeaderNetmapLookupDepth = ReservedXHeaderPrefix + "NETMAP_LOOKUP_DEPTH"
)
// ReservedXHeaderPrefixNeoFS is a prefix of keys to "well-known" X-headers.
const ReservedXHeaderPrefixNeoFS = "__NEOFS__"
const (
// XHeaderNetmapEpochNeoFS is a key to the reserved X-header that specifies netmap epoch
// to use for object placement calculation. If set to '0' or not set, the current
// epoch only will be used.
XHeaderNetmapEpochNeoFS = ReservedXHeaderPrefixNeoFS + "NETMAP_EPOCH"
// XHeaderNetmapLookupDepthNeoFS is a key to the reserved X-header that limits
// how many past epochs back the node will can lookup. If set to '0' or not
// set, the current epoch only will be used.
XHeaderNetmapLookupDepthNeoFS = ReservedXHeaderPrefixNeoFS + "NETMAP_LOOKUP_DEPTH"
)