Documentation ¶
Overview ¶
Package netmap provides functionality for working with information about the FrostFS network, primarily a layer of storage nodes.
The package concentrates all the characteristics of FrostFS networks.
NetMap represents FrostFS network map - one of the main technologies used to store data in the system. It is composed of information about all storage nodes (NodeInfo type) in a particular network. NetMap methods allow you to impose container storage policies (PlacementPolicy type) on a fixed composition of nodes for selecting nodes corresponding to the placement rules chosen by the container creator.
NetworkInfo type is dedicated to descriptive characterization of network state and settings.
Instances can be also used to process FrostFS API V2 protocol messages (see neo.fs.v2.netmap package in https://git.frostfs.info/TrueCloudLab/frostfs-api).
On client side:
import "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/netmap" var msg netmap.NodeInfo info.WriteToV2(&msg) // send msg
On server side:
// recv msg var info NodeInfo err := info.ReadFromV2(msg) // ... // process info
Using package types in an application is recommended to potentially work with different protocol versions with which these types are compatible.
Index ¶
- Constants
- func IterateNetworkEndpoints(node NodeInfo, f func(string))
- func StringifyPublicKey(node NodeInfo) string
- type Attribute
- type Filter
- func (x *Filter) Equal(key, value string)
- func (x *Filter) Like(key, value string)
- func (x *Filter) LogicalAND(filters ...Filter)
- func (x *Filter) LogicalOR(filters ...Filter)
- func (x *Filter) NotEqual(key, value string)
- func (x *Filter) NumericGE(key string, num int64)
- func (x *Filter) NumericGT(key string, num int64)
- func (x *Filter) NumericLE(key string, num int64)
- func (x *Filter) NumericLT(key string, num int64)
- func (x *Filter) SetName(name string)
- type NetMap
- func (m NetMap) ContainerNodes(p PlacementPolicy, pivot []byte) ([][]NodeInfo, error)
- func (m NetMap) Epoch() uint64
- func (m NetMap) Nodes() []NodeInfo
- func (m NetMap) PlacementVectors(vectors [][]NodeInfo, pivot []byte) ([][]NodeInfo, error)
- func (m *NetMap) ReadFromV2(msg netmap.NetMap) error
- func (m NetMap) SelectFilterNodes(expr *SelectFilterExpr) ([][]NodeInfo, error)
- func (m *NetMap) SetEpoch(epoch uint64)
- func (m *NetMap) SetNodes(nodes []NodeInfo)
- func (m NetMap) WriteToV2(msg *netmap.NetMap)
- type NetworkInfo
- func (x *NetworkInfo) AllowMaintenanceMode()
- func (x NetworkInfo) AuditFee() uint64
- func (x NetworkInfo) ContainerFee() uint64
- func (x NetworkInfo) CurrentEpoch() uint64
- func (x *NetworkInfo) DisableHomomorphicHashing()
- func (x NetworkInfo) EpochDuration() uint64
- func (x NetworkInfo) HomomorphicHashingDisabled() bool
- func (x NetworkInfo) IRCandidateFee() uint64
- func (x *NetworkInfo) IterateRawNetworkParameters(f func(name string, value []byte))
- func (x NetworkInfo) MagicNumber() uint64
- func (x NetworkInfo) MaintenanceModeAllowed() bool
- func (x NetworkInfo) MaxECDataCount() uint64
- func (x NetworkInfo) MaxECParityCount() uint64
- func (x NetworkInfo) MaxObjectSize() uint64
- func (x NetworkInfo) MsPerBlock() int64
- func (x NetworkInfo) NamedContainerFee() uint64
- func (x *NetworkInfo) RawNetworkParameter(name string) []byte
- func (x *NetworkInfo) ReadFromV2(m netmap.NetworkInfo) error
- func (x *NetworkInfo) SetAuditFee(fee uint64)
- func (x *NetworkInfo) SetContainerFee(fee uint64)
- func (x *NetworkInfo) SetCurrentEpoch(epoch uint64)
- func (x *NetworkInfo) SetEpochDuration(blocks uint64)
- func (x *NetworkInfo) SetIRCandidateFee(fee uint64)
- func (x *NetworkInfo) SetMagicNumber(epoch uint64)
- func (x *NetworkInfo) SetMaxECDataCount(dataCount uint64)
- func (x *NetworkInfo) SetMaxECParityCount(parityCount uint64)
- func (x *NetworkInfo) SetMaxObjectSize(sz uint64)
- func (x *NetworkInfo) SetMsPerBlock(v int64)
- func (x *NetworkInfo) SetNamedContainerFee(fee uint64)
- func (x *NetworkInfo) SetRawNetworkParameter(name string, value []byte)
- func (x *NetworkInfo) SetStoragePrice(price uint64)
- func (x *NetworkInfo) SetWithdrawalFee(sz uint64)
- func (x NetworkInfo) StoragePrice() uint64
- func (x NetworkInfo) WithdrawalFee() uint64
- func (x NetworkInfo) WriteToV2(m *netmap.NetworkInfo)
- type NodeInfo
- func (x NodeInfo) Attribute(key string) string
- func (x NodeInfo) ExternalAddresses() []string
- func (x NodeInfo) Hash() uint64
- func (x NodeInfo) IsMaintenance() booldeprecated
- func (x NodeInfo) IsOffline() booldeprecated
- func (x NodeInfo) IsOnline() booldeprecated
- func (x NodeInfo) IterateAttributes(f func(key, value string))
- func (x NodeInfo) IterateNetworkEndpoints(f func(string) bool)
- func (x NodeInfo) LOCODE() string
- func (x NodeInfo) Marshal() []byte
- func (x NodeInfo) MarshalJSON() ([]byte, error)
- func (x NodeInfo) NumberOfAttributes() int
- func (x NodeInfo) NumberOfNetworkEndpoints() int
- func (x NodeInfo) Price() uint64
- func (x NodeInfo) PublicKey() []byte
- func (x *NodeInfo) ReadFromV2(m netmap.NodeInfo) error
- func (x *NodeInfo) SetAttribute(key, value string)
- func (x *NodeInfo) SetCapacity(capacity uint64)
- func (x *NodeInfo) SetContinentName(continent string)
- func (x *NodeInfo) SetCountryCode(countryCode string)
- func (x *NodeInfo) SetCountryName(country string)
- func (x *NodeInfo) SetExternalAddresses(addr ...string)
- func (x *NodeInfo) SetLOCODE(locode string)
- func (x *NodeInfo) SetLocationName(location string)
- func (x *NodeInfo) SetMaintenance()deprecated
- func (x *NodeInfo) SetNetworkEndpoints(v ...string)
- func (x *NodeInfo) SetOffline()deprecated
- func (x *NodeInfo) SetOnline()deprecated
- func (x *NodeInfo) SetPrice(price uint64)
- func (x *NodeInfo) SetPublicKey(key []byte)
- func (x *NodeInfo) SetStatus(state NodeState)
- func (x *NodeInfo) SetSubdivisionCode(subDiv string)
- func (x *NodeInfo) SetSubdivisionName(subDiv string)
- func (x *NodeInfo) SortAttributes()
- func (x NodeInfo) Status() NodeState
- func (x *NodeInfo) Unmarshal(data []byte) error
- func (x *NodeInfo) UnmarshalJSON(data []byte) error
- func (x *NodeInfo) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (x NodeInfo) WriteToV2(m *netmap.NodeInfo)
- type NodeState
- type PlacementPolicy
- func (p *PlacementPolicy) AddFilters(fs ...Filter)
- func (p *PlacementPolicy) AddReplicas(rs ...ReplicaDescriptor)
- func (p *PlacementPolicy) AddSelectors(ss ...Selector)
- func (p *PlacementPolicy) DecodeString(s string) error
- func (p PlacementPolicy) Marshal() []byte
- func (p PlacementPolicy) MarshalJSON() ([]byte, error)
- func (p PlacementPolicy) NumberOfReplicas() int
- func (p *PlacementPolicy) ReadFromV2(m netmap.PlacementPolicy) error
- func (p PlacementPolicy) ReplicaDescriptor(i int) ReplicaDescriptor
- func (p PlacementPolicy) ReplicaNumberByIndex(i int) uint32deprecated
- func (p *PlacementPolicy) SetContainerBackupFactor(f uint32)
- func (p *PlacementPolicy) SetUnique(b bool)
- func (p *PlacementPolicy) Unmarshal(data []byte) error
- func (p *PlacementPolicy) UnmarshalJSON(data []byte) error
- func (p *PlacementPolicy) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (p PlacementPolicy) WriteStringTo(w io.StringWriter) (err error)
- func (p PlacementPolicy) WriteToV2(m *netmap.PlacementPolicy)
- type ReplicaDescriptor
- func (r ReplicaDescriptor) GetECDataCount() uint32
- func (r ReplicaDescriptor) GetECParityCount() uint32
- func (r ReplicaDescriptor) NumberOfObjects() uint32
- func (r *ReplicaDescriptor) SetECDataCount(v uint32)
- func (r *ReplicaDescriptor) SetECParityCount(v uint32)
- func (r *ReplicaDescriptor) SetNumberOfObjects(c uint32)
- func (r *ReplicaDescriptor) SetSelectorName(s string)
- func (r ReplicaDescriptor) TotalECPartCount() uint32
- type SelectFilterExpr
- type Selector
- func (s *Selector) SelectByBucketAttribute(bucket string)
- func (s *Selector) SelectDistinct()
- func (s *Selector) SelectSame()
- func (s *Selector) SetClause(clause netmap.Clause)
- func (s *Selector) SetFilterName(f string)
- func (s *Selector) SetName(name string)
- func (s *Selector) SetNumberOfNodes(num uint32)
Constants ¶
const ( UnspecifiedState = NodeState(netmap.UnspecifiedState) Online = NodeState(netmap.Online) Offline = NodeState(netmap.Offline) Maintenance = NodeState(netmap.Maintenance) )
Variables ¶
This section is empty.
Functions ¶
func IterateNetworkEndpoints ¶
IterateNetworkEndpoints is an extra-sugared function over IterateNetworkEndpoints method which allows to unconditionally iterate over all node's network endpoints.
func StringifyPublicKey ¶
StringifyPublicKey returns HEX representation of PublicKey.
Types ¶
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter contains rules for filtering the node sets.
func (*Filter) Equal ¶
Equal applies the rule to accept only nodes with the same attribute value.
Method SHOULD NOT be called along with other similar methods.
func (*Filter) Like ¶
Like applies the rule to accept only nodes with attribute like value.
Method SHOULD NOT be called along with other similar methods.
func (*Filter) LogicalAND ¶
LogicalAND applies the rule to accept only nodes which satisfy all the given filters.
Method SHOULD NOT be called along with other similar methods.
func (*Filter) LogicalOR ¶
LogicalOR applies the rule to accept only nodes which satisfy at least one of the given filters.
Method SHOULD NOT be called along with other similar methods.
func (*Filter) NotEqual ¶
NotEqual applies the rule to accept only nodes with the distinct attribute value.
Method SHOULD NOT be called along with other similar methods.
func (*Filter) NumericGE ¶
NumericGE applies the rule to accept only nodes with the numeric attribute greater than or equal to given number.
Method SHOULD NOT be called along with other similar methods.
func (*Filter) NumericGT ¶
NumericGT applies the rule to accept only nodes with the numeric attribute greater than given number.
Method SHOULD NOT be called along with other similar methods.
func (*Filter) NumericLE ¶
NumericLE applies the rule to accept only nodes with the numeric attribute less than or equal to given number.
Method SHOULD NOT be called along with other similar methods.
type NetMap ¶
type NetMap struct {
// contains filtered or unexported fields
}
NetMap represents FrostFS network map. It includes information about all storage nodes registered in FrostFS the network.
NetMap is mutually compatible with git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/netmap.NetMap message. See ReadFromV2 / WriteToV2 methods.
Instances can be created using built-in var declaration.
func (NetMap) ContainerNodes ¶
func (m NetMap) ContainerNodes(p PlacementPolicy, pivot []byte) ([][]NodeInfo, error)
ContainerNodes returns two-dimensional list of nodes as a result of applying given PlacementPolicy to the NetMap. Each line of the list corresponds to a replica descriptor. Line order corresponds to order of ReplicaDescriptor list in the policy. Nodes are pre-filtered according to the Filter list from the policy, and then selected by Selector list. Result is deterministic for the fixed NetMap and parameters.
Result can be used in PlacementVectors.
func (NetMap) Nodes ¶
Nodes returns nodes set using SetNodes.
Return value MUST not be mutated, make a copy first.
func (NetMap) PlacementVectors ¶
PlacementVectors sorts container nodes returned by ContainerNodes method and returns placement vectors for the entity identified by the given pivot. For example, in order to build node list to store the object, binary-encoded object identifier can be used as pivot. Result is deterministic for the fixed NetMap and parameters.
func (*NetMap) ReadFromV2 ¶
ReadFromV2 reads NetMap from the netmap.NetMap message. Checks if the message conforms to FrostFS API V2 protocol.
See also WriteToV2.
func (NetMap) SelectFilterNodes ¶
func (m NetMap) SelectFilterNodes(expr *SelectFilterExpr) ([][]NodeInfo, error)
SelectFilterNodes returns a two-dimensional list of nodes as a result of applying the given SelectFilterExpr to the NetMap. If the SelectFilterExpr contains only filters, the result contains a single row with the result of the last filter application. If the SelectFilterExpr contains only selectors, the result contains the selection rows of the last select application.
type NetworkInfo ¶
type NetworkInfo struct {
// contains filtered or unexported fields
}
NetworkInfo groups information about the FrostFS network state. Mainly used to describe the current state of the network.
NetworkInfo is mutually compatible with git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/netmap.NetworkInfo message. See ReadFromV2 / WriteToV2 methods.
Instances can be created using built-in var declaration.
func (*NetworkInfo) AllowMaintenanceMode ¶
func (x *NetworkInfo) AllowMaintenanceMode()
AllowMaintenanceMode sets the flag allowing nodes to go into maintenance mode.
See also MaintenanceModeAllowed.
func (NetworkInfo) AuditFee ¶
func (x NetworkInfo) AuditFee() uint64
AuditFee returns audit fee set using SetAuditFee.
Zero NetworkInfo has zero audit fee.
func (NetworkInfo) ContainerFee ¶
func (x NetworkInfo) ContainerFee() uint64
ContainerFee returns container fee set using SetContainerFee.
Zero NetworkInfo has zero container fee.
func (NetworkInfo) CurrentEpoch ¶
func (x NetworkInfo) CurrentEpoch() uint64
CurrentEpoch returns epoch set using SetCurrentEpoch.
Zero NetworkInfo has zero current epoch.
func (*NetworkInfo) DisableHomomorphicHashing ¶
func (x *NetworkInfo) DisableHomomorphicHashing()
DisableHomomorphicHashing sets flag requiring to disable homomorphic hashing of the containers in the network.
See also HomomorphicHashingDisabled.
func (NetworkInfo) EpochDuration ¶
func (x NetworkInfo) EpochDuration() uint64
EpochDuration returns epoch duration set using SetEpochDuration.
Zero NetworkInfo has zero iteration number.
func (NetworkInfo) HomomorphicHashingDisabled ¶
func (x NetworkInfo) HomomorphicHashingDisabled() bool
HomomorphicHashingDisabled returns the state of the homomorphic hashing network setting.
Zero NetworkInfo has enabled homomorphic hashing.
func (NetworkInfo) IRCandidateFee ¶
func (x NetworkInfo) IRCandidateFee() uint64
IRCandidateFee returns IR entrance fee set using SetIRCandidateFee.
Zero NetworkInfo has zero fee.
func (*NetworkInfo) IterateRawNetworkParameters ¶
func (x *NetworkInfo) IterateRawNetworkParameters(f func(name string, value []byte))
IterateRawNetworkParameters iterates over all raw networks parameters set using SetRawNetworkParameter and passes them into f.
Handler MUST NOT be nil. Handler MUST NOT mutate value parameter.
Zero NetworkInfo has no network parameters.
func (NetworkInfo) MagicNumber ¶
func (x NetworkInfo) MagicNumber() uint64
MagicNumber returns magic number set using SetMagicNumber.
Zero NetworkInfo has zero magic.
func (NetworkInfo) MaintenanceModeAllowed ¶
func (x NetworkInfo) MaintenanceModeAllowed() bool
MaintenanceModeAllowed returns true iff network config allows maintenance mode for storage nodes.
Zero NetworkInfo has disallows maintenance mode.
func (NetworkInfo) MaxECDataCount ¶
func (x NetworkInfo) MaxECDataCount() uint64
MaxECDataCount returns maximum number of data shards for erasure codes.
func (NetworkInfo) MaxECParityCount ¶
func (x NetworkInfo) MaxECParityCount() uint64
MaxECParityCount returns maximum number of parity shards for erasure codes.
func (NetworkInfo) MaxObjectSize ¶
func (x NetworkInfo) MaxObjectSize() uint64
MaxObjectSize returns maximum object size set using SetMaxObjectSize.
Zero NetworkInfo has zero maximum size.
func (NetworkInfo) MsPerBlock ¶
func (x NetworkInfo) MsPerBlock() int64
MsPerBlock returns network parameter set using SetMsPerBlock.
func (NetworkInfo) NamedContainerFee ¶
func (x NetworkInfo) NamedContainerFee() uint64
NamedContainerFee returns container fee set using SetNamedContainerFee.
Zero NetworkInfo has zero container fee.
func (*NetworkInfo) RawNetworkParameter ¶
func (x *NetworkInfo) RawNetworkParameter(name string) []byte
RawNetworkParameter reads raw network parameter set using SetRawNetworkParameter by its name. Returns nil if value is missing.
Return value MUST NOT be mutated, make a copy first.
Zero NetworkInfo has no network parameters.
func (*NetworkInfo) ReadFromV2 ¶
func (x *NetworkInfo) ReadFromV2(m netmap.NetworkInfo) error
ReadFromV2 reads NetworkInfo from the netmap.NetworkInfo message. Checks if the message conforms to FrostFS API V2 protocol.
See also WriteToV2.
func (*NetworkInfo) SetAuditFee ¶
func (x *NetworkInfo) SetAuditFee(fee uint64)
SetAuditFee sets the configuration value of the audit fee for the Inner Ring.
See also AuditFee.
func (*NetworkInfo) SetContainerFee ¶
func (x *NetworkInfo) SetContainerFee(fee uint64)
SetContainerFee sets fee for the container creation that creator pays to each Alphabet node.
See also ContainerFee.
func (*NetworkInfo) SetCurrentEpoch ¶
func (x *NetworkInfo) SetCurrentEpoch(epoch uint64)
SetCurrentEpoch sets current epoch of the FrostFS network.
func (*NetworkInfo) SetEpochDuration ¶
func (x *NetworkInfo) SetEpochDuration(blocks uint64)
SetEpochDuration sets FrostFS epoch duration measured in number of blocks of the FrostFS Sidechain.
See also EpochDuration.
func (*NetworkInfo) SetIRCandidateFee ¶
func (x *NetworkInfo) SetIRCandidateFee(fee uint64)
SetIRCandidateFee sets fee for Inner Ring entrance paid by a new member.
See also IRCandidateFee.
func (*NetworkInfo) SetMagicNumber ¶
func (x *NetworkInfo) SetMagicNumber(epoch uint64)
SetMagicNumber sets magic number of the FrostFS Sidechain.
See also MagicNumber.
func (*NetworkInfo) SetMaxECDataCount ¶
func (x *NetworkInfo) SetMaxECDataCount(dataCount uint64)
SetMaxECDataCount sets maximum number of data shards for erasure codes.
Zero means no restrictions.
func (*NetworkInfo) SetMaxECParityCount ¶
func (x *NetworkInfo) SetMaxECParityCount(parityCount uint64)
SetMaxECParityCount sets maximum number of parity shards for erasure codes.
Zero means no restrictions.
func (*NetworkInfo) SetMaxObjectSize ¶
func (x *NetworkInfo) SetMaxObjectSize(sz uint64)
SetMaxObjectSize sets maximum size of the object stored locally on the storage nodes (physical objects). Binary representation of any physically stored object MUST NOT overflow the limit.
See also MaxObjectSize.
func (*NetworkInfo) SetMsPerBlock ¶
func (x *NetworkInfo) SetMsPerBlock(v int64)
SetMsPerBlock sets MillisecondsPerBlock network parameter of the FrostFS Sidechain.
See also MsPerBlock.
func (*NetworkInfo) SetNamedContainerFee ¶
func (x *NetworkInfo) SetNamedContainerFee(fee uint64)
SetNamedContainerFee sets fee for creation of the named container creation that creator pays to each Alphabet node.
See also NamedContainerFee.
func (*NetworkInfo) SetRawNetworkParameter ¶
func (x *NetworkInfo) SetRawNetworkParameter(name string, value []byte)
SetRawNetworkParameter sets named FrostFS network parameter whose value is transmitted but not interpreted by the FrostFS API protocol.
Argument MUST NOT be mutated, make a copy first.
See also RawNetworkParameter, IterateRawNetworkParameters.
func (*NetworkInfo) SetStoragePrice ¶
func (x *NetworkInfo) SetStoragePrice(price uint64)
SetStoragePrice sets the price per gigabyte of data storage that data owners pay to storage nodes.
See also StoragePrice.
func (*NetworkInfo) SetWithdrawalFee ¶
func (x *NetworkInfo) SetWithdrawalFee(sz uint64)
SetWithdrawalFee sets fee for withdrawals from the FrostFS accounts that account owners pay to each Alphabet node.
See also WithdrawalFee.
func (NetworkInfo) StoragePrice ¶
func (x NetworkInfo) StoragePrice() uint64
StoragePrice returns storage price set using SetStoragePrice.
Zero NetworkInfo has zero storage price.
func (NetworkInfo) WithdrawalFee ¶
func (x NetworkInfo) WithdrawalFee() uint64
WithdrawalFee returns withdrawal fee set using SetWithdrawalFee.
Zero NetworkInfo has zero fee.
func (NetworkInfo) WriteToV2 ¶
func (x NetworkInfo) WriteToV2(m *netmap.NetworkInfo)
WriteToV2 writes NetworkInfo to the netmap.NetworkInfo message. The message MUST NOT be nil.
See also ReadFromV2.
type NodeInfo ¶
type NodeInfo struct {
// contains filtered or unexported fields
}
NodeInfo groups information about FrostFS storage node which is reflected in the FrostFS network map. Storage nodes advertise this information when registering with the FrostFS network. After successful registration, information about the nodes is available to all network participants to work with the network map (mainly to comply with container storage policies).
NodeInfo is mutually compatible with git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/netmap.NodeInfo message. See ReadFromV2 / WriteToV2 methods.
Instances can be created using built-in var declaration.
func (NodeInfo) Attribute ¶
Attribute returns value of the node attribute set using SetAttribute by the given key. Returns empty string if attribute is missing.
func (NodeInfo) ExternalAddresses ¶
ExternalAddresses returns list of multi-addresses to use to connect to this node from outside.
func (NodeInfo) Hash ¶
Hash implements hrw.Hasher interface.
Hash is needed to support weighted HRW therefore sort function sorts nodes based on their public key. Hash isn't expected to be used directly.
func (NodeInfo) IsMaintenance
deprecated
func (NodeInfo) IterateAttributes ¶
IterateAttributes iterates over all node attributes and passes the into f. Handler MUST NOT be nil.
func (NodeInfo) IterateNetworkEndpoints ¶
IterateNetworkEndpoints iterates over network endpoints announced by the node and pass them into f. Breaks iteration on f's true return. Handler MUST NOT be nil.
Zero NodeInfo contains no endpoints which is incorrect according to FrostFS system requirements.
See also SetNetworkEndpoints.
func (NodeInfo) LOCODE ¶
LOCODE returns node's location code set using SetLOCODE.
Zero NodeInfo has empty location code which is invalid according to FrostFS API system requirement.
func (NodeInfo) Marshal ¶
Marshal encodes NodeInfo into a binary format of the FrostFS API protocol (Protocol Buffers with direct field order).
See also Unmarshal.
func (NodeInfo) MarshalJSON ¶
MarshalJSON encodes NodeInfo into a JSON format of the FrostFS API protocol (Protocol Buffers JSON).
See also UnmarshalJSON.
func (NodeInfo) NumberOfAttributes ¶
NumberOfAttributes returns number of attributes announced by the node.
See also SetAttribute.
func (NodeInfo) NumberOfNetworkEndpoints ¶
NumberOfNetworkEndpoints returns number of network endpoints announced by the node.
See also SetNetworkEndpoints.
func (NodeInfo) PublicKey ¶
PublicKey returns value set using SetPublicKey.
Zero NodeInfo has no public key, which is incorrect according to FrostFS system requirements.
Return value MUST not be mutated, make a copy first.
func (*NodeInfo) ReadFromV2 ¶
ReadFromV2 reads NodeInfo from the netmap.NodeInfo message. Checks if the message conforms to FrostFS API V2 protocol.
See also WriteToV2.
func (*NodeInfo) SetAttribute ¶
SetAttribute sets value of the node attribute value by the given key. Both key and value MUST NOT be empty.
func (*NodeInfo) SetCapacity ¶
SetCapacity sets the storage capacity declared by the node. By default, zero capacity is announced.
func (*NodeInfo) SetContinentName ¶
SetContinentName sets name of the storage node's continent from Seven-Continent model.
SetContinentName is intended only for processing the network registration request by the Inner Ring. Other parties SHOULD NOT use it.
func (*NodeInfo) SetCountryCode ¶
SetCountryCode sets code of the country in ISO 3166-1_alpha-2 to which storage node belongs (or the closest one).
SetCountryCode is intended only for processing the network registration request by the Inner Ring. Other parties SHOULD NOT use it.
func (*NodeInfo) SetCountryName ¶
SetCountryName sets short name of the country in ISO-3166 format to which storage node belongs (or the closest one).
SetCountryName is intended only for processing the network registration request by the Inner Ring. Other parties SHOULD NOT use it.
func (*NodeInfo) SetExternalAddresses ¶
SetExternalAddresses sets multi-addresses to use to connect to this node from outside.
Panics if addr is an empty list.
func (*NodeInfo) SetLOCODE ¶
SetLOCODE specifies node's geographic location in UN/LOCODE format. Each storage node MUST declare it for entrance to the FrostFS network. Node MAY declare the code of the nearest location as needed, for example, when it is impossible to unambiguously attribute the node to any location from UN/LOCODE database.
See also LOCODE.
func (*NodeInfo) SetLocationName ¶
SetLocationName sets storage node's location name from "NameWoDiacritics" column in the UN/LOCODE record corresponding to the specified LOCODE.
SetLocationName is intended only for processing the network registration request by the Inner Ring. Other parties SHOULD NOT use it.
func (*NodeInfo) SetMaintenance
deprecated
func (x *NodeInfo) SetMaintenance()
SetMaintenance sets the state of the node to "maintenance". When a node updates information about itself in the network map, this state declares temporal unavailability for a node.
See also IsMaintenance.
Deprecated: use SetStatus instead.
func (*NodeInfo) SetNetworkEndpoints ¶
SetNetworkEndpoints sets list to the announced node's network endpoints. Node MUSt have at least one announced endpoint. List MUST be unique. Endpoints are used for communication with the storage node within FrostFS network. It is expected that node serves storage node services on these endpoints (it also adds a wait on their network availability).
Argument MUST NOT be mutated, make a copy first.
See also IterateNetworkEndpoints.
func (*NodeInfo) SetOffline
deprecated
func (x *NodeInfo) SetOffline()
SetOffline sets the state of the node to "offline". When a node updates information about itself in the network map, this action is interpreted as an intention to leave the network.
See also IsOffline.
Deprecated: use SetStatus instead.
func (*NodeInfo) SetOnline
deprecated
func (x *NodeInfo) SetOnline()
SetOnline sets the state of the node to "online". When a node updates information about itself in the network map, this action is interpreted as an intention to enter the network.
See also IsOnline.
Deprecated: use SetStatus instead.
func (*NodeInfo) SetPrice ¶
SetPrice sets the storage cost declared by the node. By default, zero price is announced.
func (*NodeInfo) SetPublicKey ¶
SetPublicKey sets binary-encoded public key bound to the node. The key authenticates the storage node, so it MUST be unique within the network.
Argument MUST NOT be mutated, make a copy first.
See also PublicKey.
func (*NodeInfo) SetStatus ¶
SetState updates the state of the node in the network map.
The state determines the node's current status within the network:
- "online": Indicates the node intends to enter the network.
- "offline": Indicates the node intends to leave the network.
- "maintenance": Indicates the node is temporarily unavailable.
See also Status.
func (*NodeInfo) SetSubdivisionCode ¶
SetSubdivisionCode sets storage node's subdivision code from "SubDiv" column in the UN/LOCODE record corresponding to the specified LOCODE.
SetSubdivisionCode is intended only for processing the network registration request by the Inner Ring. Other parties SHOULD NOT use it.
func (*NodeInfo) SetSubdivisionName ¶
SetSubdivisionName sets storage node's subdivision name in ISO 3166-2 format.
SetSubdivisionName is intended only for processing the network registration request by the Inner Ring. Other parties SHOULD NOT use it.
func (*NodeInfo) SortAttributes ¶
func (x *NodeInfo) SortAttributes()
SortAttributes sorts node attributes set using SetAttribute lexicographically. The method is only needed to make NodeInfo consistent, e.g. for signing.
func (NodeInfo) Status ¶
Status returns the current state of the node in the network map.
Zero NodeInfo has an undefined state, neither online nor offline.
func (*NodeInfo) Unmarshal ¶
Unmarshal decodes FrostFS API protocol binary format into the NodeInfo (Protocol Buffers with direct field order). Returns an error describing a format violation.
See also Marshal.
func (*NodeInfo) UnmarshalJSON ¶
UnmarshalJSON decodes FrostFS API protocol JSON format into the NodeInfo (Protocol Buffers JSON). Returns an error describing a format violation.
See also MarshalJSON.
func (*NodeInfo) UnmarshalYAML ¶
type NodeState ¶
func (NodeState) IsMaintenance ¶
IsMaintenance checks if the current state is "maintenance".
type PlacementPolicy ¶
type PlacementPolicy struct {
// contains filtered or unexported fields
}
PlacementPolicy declares policy to store objects in the FrostFS container. Within itself, PlacementPolicy represents a set of rules to select a subset of nodes from FrostFS network map - node-candidates for object storage.
PlacementPolicy is mutually compatible with git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/netmap.PlacementPolicy message. See ReadFromV2 / WriteToV2 methods.
Instances can be created using built-in var declaration.
func (*PlacementPolicy) AddFilters ¶
func (p *PlacementPolicy) AddFilters(fs ...Filter)
AddFilters adds a Filter bunch that will be applied when selecting nodes.
Zero PlacementPolicy has no filters.
func (*PlacementPolicy) AddReplicas ¶
func (p *PlacementPolicy) AddReplicas(rs ...ReplicaDescriptor)
AddReplicas adds a bunch object replica's characteristics.
See also IterateReplicas.
func (*PlacementPolicy) AddSelectors ¶
func (p *PlacementPolicy) AddSelectors(ss ...Selector)
AddSelectors adds a Selector bunch to form the subset of the nodes to store container objects.
Zero PlacementPolicy does not declare selectors.
func (*PlacementPolicy) DecodeString ¶
func (p *PlacementPolicy) DecodeString(s string) error
DecodeString decodes PlacementPolicy from the string composed using WriteStringTo. Returns error if s is malformed.
func (PlacementPolicy) Marshal ¶
func (p PlacementPolicy) Marshal() []byte
Marshal encodes PlacementPolicy into a binary format of the FrostFS API protocol (Protocol Buffers with direct field order).
See also Unmarshal.
func (PlacementPolicy) MarshalJSON ¶
func (p PlacementPolicy) MarshalJSON() ([]byte, error)
MarshalJSON encodes PlacementPolicy into a JSON format of the FrostFS API protocol (Protocol Buffers JSON).
See also UnmarshalJSON.
func (PlacementPolicy) NumberOfReplicas ¶
func (p PlacementPolicy) NumberOfReplicas() int
NumberOfReplicas returns number of replica descriptors set using AddReplicas.
Zero PlacementPolicy has no replicas which is incorrect according to the FrostFS API protocol.
func (*PlacementPolicy) ReadFromV2 ¶
func (p *PlacementPolicy) ReadFromV2(m netmap.PlacementPolicy) error
ReadFromV2 reads PlacementPolicy from the netmap.PlacementPolicy message. Checks if the message conforms to FrostFS API V2 protocol.
See also WriteToV2.
func (PlacementPolicy) ReplicaDescriptor ¶
func (p PlacementPolicy) ReplicaDescriptor(i int) ReplicaDescriptor
ReplicaDescriptor returns i-th replica descriptor. Index MUST be in range [0; NumberOfReplicas()).
func (PlacementPolicy) ReplicaNumberByIndex
deprecated
func (p PlacementPolicy) ReplicaNumberByIndex(i int) uint32
ReplicaNumberByIndex returns number of object replicas from the i-th replica descriptor. Index MUST be in range [0; NumberOfReplicas()).
Zero PlacementPolicy has no replicas.
Deprecated: Use PlacementPolicy.ReplicaDescriptor(int).NumberOfObjects() instead.
func (*PlacementPolicy) SetContainerBackupFactor ¶
func (p *PlacementPolicy) SetContainerBackupFactor(f uint32)
SetContainerBackupFactor sets container backup factor: it controls how deep FrostFS will search for nodes alternatives to include into container's nodes subset.
Zero PlacementPolicy has zero container backup factor.
func (*PlacementPolicy) SetUnique ¶
func (p *PlacementPolicy) SetUnique(b bool)
SetUnique sets the unique flag: it controls whether the selected replica buckets are disjoint or not.
Zero PlacementPolicy has false unique flag.
func (*PlacementPolicy) Unmarshal ¶
func (p *PlacementPolicy) Unmarshal(data []byte) error
Unmarshal decodes FrostFS API protocol binary format into the PlacementPolicy (Protocol Buffers with direct field order). Returns an error describing a format violation.
See also Marshal.
func (*PlacementPolicy) UnmarshalJSON ¶
func (p *PlacementPolicy) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes FrostFS API protocol JSON format into the PlacementPolicy (Protocol Buffers JSON). Returns an error describing a format violation.
See also MarshalJSON.
func (*PlacementPolicy) UnmarshalYAML ¶
func (p *PlacementPolicy) UnmarshalYAML(unmarshal func(interface{}) error) error
func (PlacementPolicy) WriteStringTo ¶
func (p PlacementPolicy) WriteStringTo(w io.StringWriter) (err error)
WriteStringTo encodes PlacementPolicy into human-readably query and writes the result into w. Returns w's errors directly.
See also DecodeString. nolint: funlen
func (PlacementPolicy) WriteToV2 ¶
func (p PlacementPolicy) WriteToV2(m *netmap.PlacementPolicy)
WriteToV2 writes PlacementPolicy to the session.Token message. The message must not be nil.
See also ReadFromV2.
type ReplicaDescriptor ¶
type ReplicaDescriptor struct {
// contains filtered or unexported fields
}
ReplicaDescriptor replica descriptor characterizes replicas of objects from the subset selected by a particular Selector.
func (ReplicaDescriptor) GetECDataCount ¶
func (r ReplicaDescriptor) GetECDataCount() uint32
func (ReplicaDescriptor) GetECParityCount ¶
func (r ReplicaDescriptor) GetECParityCount() uint32
func (ReplicaDescriptor) NumberOfObjects ¶
func (r ReplicaDescriptor) NumberOfObjects() uint32
NumberOfObjects returns number set using SetNumberOfObjects.
Zero ReplicaDescriptor has zero number of objects.
func (*ReplicaDescriptor) SetECDataCount ¶
func (r *ReplicaDescriptor) SetECDataCount(v uint32)
func (*ReplicaDescriptor) SetECParityCount ¶
func (r *ReplicaDescriptor) SetECParityCount(v uint32)
func (*ReplicaDescriptor) SetNumberOfObjects ¶
func (r *ReplicaDescriptor) SetNumberOfObjects(c uint32)
SetNumberOfObjects sets number of object replicas.
func (*ReplicaDescriptor) SetSelectorName ¶
func (r *ReplicaDescriptor) SetSelectorName(s string)
SetSelectorName sets name of the related Selector.
Zero ReplicaDescriptor references to the root bucket's selector: it contains all possible nodes to store the object.
func (ReplicaDescriptor) TotalECPartCount ¶
func (r ReplicaDescriptor) TotalECPartCount() uint32
TotalECPartCount returns total sum of ECDataCount and ECParityCount.
type SelectFilterExpr ¶
type SelectFilterExpr struct {
// contains filtered or unexported fields
}
SelectFilterExpr is an expression containing only selectors and filters. It's useful to evaluate their effect before being used in a policy.
func DecodeSelectFilterString ¶
func DecodeSelectFilterString(s string) (*SelectFilterExpr, error)
DecodeString decodes a string into a SelectFilterExpr. Returns an error if s is malformed.
type Selector ¶
type Selector struct {
// contains filtered or unexported fields
}
Selector describes the bucket selection operator: choose a number of nodes from the bucket taking the nearest nodes to the related container by hash distance.
func (*Selector) SelectByBucketAttribute ¶
SelectByBucketAttribute sets attribute of the bucket to select nodes from.
Zero Selector has empty attribute.
func (*Selector) SelectDistinct ¶
func (s *Selector) SelectDistinct()
SelectDistinct makes selection algorithm to select only nodes having the different values of the bucket attribute.
Zero Selector doesn't specify selection modifier so nodes are selected randomly.
See also SelectByBucketAttribute.
func (*Selector) SelectSame ¶
func (s *Selector) SelectSame()
SelectSame makes selection algorithm to select only nodes having the same values of the bucket attribute.
Zero Selector doesn't specify selection modifier so nodes are selected randomly.
See also SelectByBucketAttribute.
func (*Selector) SetFilterName ¶
SetFilterName sets reference to pre-filtering nodes for selection.
Zero Selector has no filtering reference.
See also Filter.SetName.
func (*Selector) SetName ¶
SetName sets name with which the Selector can be referenced.
Zero Selector is unnamed.
func (*Selector) SetNumberOfNodes ¶
SetNumberOfNodes sets number of nodes to select from the bucket.
Zero Selector selects nothing.