netmap

package
v0.0.0-...-0352b5b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 15 Imported by: 35

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

View Source
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

func IterateNetworkEndpoints(node NodeInfo, f func(string))

IterateNetworkEndpoints is an extra-sugared function over IterateNetworkEndpoints method which allows to unconditionally iterate over all node's network endpoints.

func StringifyPublicKey

func StringifyPublicKey(node NodeInfo) string

StringifyPublicKey returns HEX representation of PublicKey.

Types

type Attribute

type Attribute struct {
	Key   string `yaml:"key"`
	Value string `yaml:"value"`
}

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

Filter contains rules for filtering the node sets.

func (*Filter) Equal

func (x *Filter) Equal(key, value string)

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

func (x *Filter) Like(key, value string)

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

func (x *Filter) LogicalAND(filters ...Filter)

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

func (x *Filter) LogicalOR(filters ...Filter)

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

func (x *Filter) NotEqual(key, value string)

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

func (x *Filter) NumericGE(key string, num int64)

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

func (x *Filter) NumericGT(key string, num int64)

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

func (x *Filter) NumericLE(key string, num int64)

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.

func (*Filter) NumericLT

func (x *Filter) NumericLT(key string, num int64)

NumericLT applies the rule to accept only nodes with the numeric attribute less than given number.

Method SHOULD NOT be called along with other similar methods.

func (*Filter) SetName

func (x *Filter) SetName(name string)

SetName sets name with which the Filter can be referenced or, for inner filters, to which the Filter references. Top-level filters MUST be named. The name MUST NOT be '*'.

Zero Filter is unnamed.

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) Epoch

func (m NetMap) Epoch() uint64

Epoch returns epoch set using SetEpoch.

Zero NetMap has zero revision.

func (NetMap) Nodes

func (m NetMap) Nodes() []NodeInfo

Nodes returns nodes set using SetNodes.

Return value MUST not be mutated, make a copy first.

func (NetMap) PlacementVectors

func (m NetMap) PlacementVectors(vectors [][]NodeInfo, pivot []byte) ([][]NodeInfo, error)

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

func (m *NetMap) ReadFromV2(msg netmap.NetMap) error

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.

func (*NetMap) SetEpoch

func (m *NetMap) SetEpoch(epoch uint64)

SetEpoch specifies revision number of the NetMap.

See also Epoch.

func (*NetMap) SetNodes

func (m *NetMap) SetNodes(nodes []NodeInfo)

SetNodes sets information list about all storage nodes from the FrostFS network.

Argument MUST NOT be mutated, make a copy first.

See also Nodes.

func (NetMap) WriteToV2

func (m NetMap) WriteToV2(msg *netmap.NetMap)

WriteToV2 writes NetMap to the netmap.NetMap message. The message MUST NOT be nil.

See also ReadFromV2.

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

func (x NodeInfo) Attribute(key string) string

Attribute returns value of the node attribute set using SetAttribute by the given key. Returns empty string if attribute is missing.

func (NodeInfo) ExternalAddresses

func (x NodeInfo) ExternalAddresses() []string

ExternalAddresses returns list of multi-addresses to use to connect to this node from outside.

func (NodeInfo) Hash

func (x NodeInfo) Hash() uint64

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 (x NodeInfo) IsMaintenance() bool

IsMaintenance checks if the node is in the "maintenance" state.

Zero NodeInfo has undefined state.

See also SetMaintenance.

Deprecated: use Status instead.

func (NodeInfo) IsOffline deprecated

func (x NodeInfo) IsOffline() bool

IsOffline checks if the node is in the "offline" state.

Zero NodeInfo has undefined state which is not offline (note that it does not mean online).

See also SetOffline.

Deprecated: use Status instead.

func (NodeInfo) IsOnline deprecated

func (x NodeInfo) IsOnline() bool

IsOnline checks if the node is in the "online" state.

Zero NodeInfo has undefined state which is not online (note that it does not mean offline).

See also SetOnline.

Deprecated: use Status instead.

func (NodeInfo) IterateAttributes

func (x NodeInfo) IterateAttributes(f func(key, value string))

IterateAttributes iterates over all node attributes and passes the into f. Handler MUST NOT be nil.

func (NodeInfo) IterateNetworkEndpoints

func (x NodeInfo) IterateNetworkEndpoints(f func(string) bool)

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

func (x NodeInfo) LOCODE() string

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

func (x NodeInfo) Marshal() []byte

Marshal encodes NodeInfo into a binary format of the FrostFS API protocol (Protocol Buffers with direct field order).

See also Unmarshal.

func (NodeInfo) MarshalJSON

func (x NodeInfo) MarshalJSON() ([]byte, error)

MarshalJSON encodes NodeInfo into a JSON format of the FrostFS API protocol (Protocol Buffers JSON).

See also UnmarshalJSON.

func (NodeInfo) NumberOfAttributes

func (x NodeInfo) NumberOfAttributes() int

NumberOfAttributes returns number of attributes announced by the node.

See also SetAttribute.

func (NodeInfo) NumberOfNetworkEndpoints

func (x NodeInfo) NumberOfNetworkEndpoints() int

NumberOfNetworkEndpoints returns number of network endpoints announced by the node.

See also SetNetworkEndpoints.

func (NodeInfo) Price

func (x NodeInfo) Price() uint64

Price returns price set using SetPrice.

Zero NodeInfo has zero price.

func (NodeInfo) PublicKey

func (x NodeInfo) PublicKey() []byte

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

func (x *NodeInfo) ReadFromV2(m netmap.NodeInfo) error

ReadFromV2 reads NodeInfo from the netmap.NodeInfo message. Checks if the message conforms to FrostFS API V2 protocol.

See also WriteToV2.

func (*NodeInfo) SetAttribute

func (x *NodeInfo) SetAttribute(key, value string)

SetAttribute sets value of the node attribute value by the given key. Both key and value MUST NOT be empty.

func (*NodeInfo) SetCapacity

func (x *NodeInfo) SetCapacity(capacity uint64)

SetCapacity sets the storage capacity declared by the node. By default, zero capacity is announced.

func (*NodeInfo) SetContinentName

func (x *NodeInfo) SetContinentName(continent string)

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

func (x *NodeInfo) SetCountryCode(countryCode string)

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

func (x *NodeInfo) SetCountryName(country string)

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

func (x *NodeInfo) SetExternalAddresses(addr ...string)

SetExternalAddresses sets multi-addresses to use to connect to this node from outside.

Panics if addr is an empty list.

func (*NodeInfo) SetLOCODE

func (x *NodeInfo) SetLOCODE(locode string)

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

func (x *NodeInfo) SetLocationName(location string)

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

func (x *NodeInfo) SetNetworkEndpoints(v ...string)

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

func (x *NodeInfo) SetPrice(price uint64)

SetPrice sets the storage cost declared by the node. By default, zero price is announced.

func (*NodeInfo) SetPublicKey

func (x *NodeInfo) SetPublicKey(key []byte)

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

func (x *NodeInfo) SetStatus(state NodeState)

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

func (x *NodeInfo) SetSubdivisionCode(subDiv string)

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

func (x *NodeInfo) SetSubdivisionName(subDiv string)

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

func (x NodeInfo) Status() NodeState

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

func (x *NodeInfo) Unmarshal(data []byte) error

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

func (x *NodeInfo) UnmarshalJSON(data []byte) error

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

func (x *NodeInfo) UnmarshalYAML(unmarshal func(interface{}) error) error

func (NodeInfo) WriteToV2

func (x NodeInfo) WriteToV2(m *netmap.NodeInfo)

WriteToV2 writes NodeInfo to the netmap.NodeInfo message. The message MUST NOT be nil.

See also ReadFromV2.

type NodeState

type NodeState netmap.NodeState

func (*NodeState) FromV2

func (ns *NodeState) FromV2(state netmap.NodeState)

FromV2 reads NodeState to v2.

func (NodeState) IsMaintenance

func (ns NodeState) IsMaintenance() bool

IsMaintenance checks if the current state is "maintenance".

func (NodeState) IsOffline

func (ns NodeState) IsOffline() bool

IsOffline checks if the current state is "offline".

func (NodeState) IsOnline

func (ns NodeState) IsOnline() bool

IsOnline checks if the current state is "online".

func (NodeState) String

func (ns NodeState) String() string

String implements fmt.Stringer.

String is designed to be human-readable, and its format MAY differ between SDK versions.

func (NodeState) ToV2

func (ns NodeState) ToV2() netmap.NodeState

ToV2 converts NodeState to v2.

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

func (s *Selector) SelectByBucketAttribute(bucket string)

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) SetClause

func (s *Selector) SetClause(clause netmap.Clause)

SetClause sets the clause for the Selector.

func (*Selector) SetFilterName

func (s *Selector) SetFilterName(f string)

SetFilterName sets reference to pre-filtering nodes for selection.

Zero Selector has no filtering reference.

See also Filter.SetName.

func (*Selector) SetName

func (s *Selector) SetName(name string)

SetName sets name with which the Selector can be referenced.

Zero Selector is unnamed.

func (*Selector) SetNumberOfNodes

func (s *Selector) SetNumberOfNodes(num uint32)

SetNumberOfNodes sets number of nodes to select from the bucket.

Zero Selector selects nothing.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL