feature/frostfs_system_attribute #10
5 changed files with 71 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -9,7 +9,10 @@ import (
|
|||
)
|
||||
|
||||
// prefix of keys to subnet attributes.
|
||||
const attrSubnetPrefix = "__NEOFS__SUBNET_"
|
||||
const attrSubnetPrefix = "__FROSTFS__SUBNET_"
|
||||
alexvanin
commented
What you think about having What you think about having `// Deprecated: use FrostFS 'attrSubnetPrefixFrostFS'` to such code or is it too early for this?
@fyrchik @dkirillov @carpawell
carpawell
commented
I would just remove that but there are also other thoughts on it. I would just remove that but there are also other thoughts on it.
|
||||
|
||||
// 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.
|
||||
|
@ -142,10 +145,13 @@ func IterateSubnets(node *NodeInfo, f func(refs.SubnetID) error) error {
|
|||
|
||||
// cut subnet ID string
|
||||
idTxt := strings.TrimPrefix(key, attrSubnetPrefix)
|
||||
if len(idTxt) == len(key) {
|
||||
idTxt = strings.TrimPrefix(key, attrSubnetPrefixNeoFS)
|
||||
if len(idTxt) == len(key) {
|
||||
// not a subnet attribute
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// check value
|
||||
val := attrs[i].GetValue()
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue
I am wondering if it is better to use
*NeoFS
for legacy stuff and no suffix for a new one.What do you think?
I suggest keep using a prefix to avoid naming collisions and keep logical separations fro attributes affecting system behavior.
Ah! I get it now. Agree =)
@fyrchik, dont we need any system prefix? it may not have any relations to a product name but be more neutral, e.g.
__SYSTEM__
I like the
__SYSTEM__
idea, but we probably need another round of PRs for that :)