[#311] services/control: Define Netmap structure

Define NodeInfo protobuf type. Define Netmap protobuf type.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-01-14 18:59:39 +03:00 committed by Alex Vanin
parent 62de9f327e
commit 88023f3655
3 changed files with 140 additions and 0 deletions

View file

@ -13,3 +13,66 @@ func (m *Signature) SetSign(v []byte) {
m.Sign = v m.Sign = v
} }
} }
// SetKey sets key of the node attribute.
func (m *NodeInfo_Attribute) SetKey(v string) {
if m != nil {
m.Key = v
}
}
// SetValue sets value of the node attribute.
func (m *NodeInfo_Attribute) SetValue(v string) {
if m != nil {
m.Value = v
}
}
// SetParents sets parent keys.
func (m *NodeInfo_Attribute) SetParents(v []string) {
if m != nil {
m.Parents = v
}
}
// SetPublicKey sets public key of the NeoFS node in a binary format.
func (m *NodeInfo) SetPublicKey(v []byte) {
if m != nil {
m.PublicKey = v
}
}
// SetAddress sets ways to connect to a node.
func (m *NodeInfo) SetAddress(v string) {
if m != nil {
m.Address = v
}
}
// SetAttributes sets attributes of the NeoFS Storage Node.
func (m *NodeInfo) SetAttributes(v []*NodeInfo_Attribute) {
if m != nil {
m.Attributes = v
}
}
// SetState sets state of the NeoFS node.
func (m *NodeInfo) SetState(v HealthStatus) {
if m != nil {
m.State = v
}
}
// SetEpoch sets revision number of the network map.
func (m *Netmap) SetEpoch(v uint64) {
if m != nil {
m.Epoch = v
}
}
// SetNodes sets nodes presented in network.
func (m *Netmap) SetNodes(v []*NodeInfo) {
if m != nil {
m.Nodes = v
}
}

Binary file not shown.

View file

@ -24,3 +24,80 @@ enum HealthStatus {
// Node is offline. // Node is offline.
OFFLINE = 2; OFFLINE = 2;
} }
// NeoFS node description.
message NodeInfo {
// Public key of the NeoFS node in a binary format.
bytes public_key = 1 [json_name = "publicKey"];
// Ways to connect to a node.
string address = 2 [json_name = "address"];
// Administrator-defined Attributes of the NeoFS Storage Node.
//
// `Attribute` is a Key-Value metadata pair. Key name must be a valid UTF-8
// string. Value can't be empty.
//
// Node's attributes are mostly used during Storage Policy evaluation to
// calculate object's placement and find a set of nodes satisfying policy
// requirements. There are some "well-known" node attributes common to all the
// Storage Nodes in the network and used implicitly with default values if not
// explicitly set:
//
// * Capacity \
// Total available disk space in Gigabytes.
// * Price \
// Price in GAS tokens for storing one GB of data during one Epoch. In node
// attributes it's a string presenting floating point number with comma or
// point delimiter for decimal part. In the Network Map it will be saved as
// 64-bit unsigned integer representing number of minimal token fractions.
// * Subnet \
// String ID of Node's storage subnet. There can be only one subnet served
// by the Storage Node.
// * Locode \
// Node's geographic location in
// [UN/LOCODE](https://www.unece.org/cefact/codesfortrade/codes_index.html)
// format approximated to the nearest point defined in standard.
// * Country \
// Country code in
// [ISO 3166-1_alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
// format. Calculated automatically from `Locode` attribute
// * Region \
// Country's administative subdivision where node is located. Calculated
// automatically from `Locode` attribute based on `SubDiv` field. Presented
// in [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) format.
// * City \
// City, town, village or rural area name where node is located written
// without diacritics . Calculated automatically from `Locode` attribute.
//
// For detailed description of each well-known attribute please see the
// corresponding section in NeoFS Technical specification.
message Attribute {
// Key of the node attribute.
string key = 1 [json_name = "key"];
// Value of the node attribute.
string value = 2 [json_name = "value"];
// Parent keys, if any. For example for `City` it could be `Region` and
// `Country`.
repeated string parents = 3 [json_name = "parents"];
}
// Carries list of the NeoFS node attributes in a key-value form. Key name
// must be a node-unique valid UTF-8 string. Value can't be empty. NodeInfo
// structures with duplicated attribute names or attributes with empty values
// will be considered invalid.
repeated Attribute attributes = 3 [json_name = "attributes"];
// Carries state of the NeoFS node.
HealthStatus state = 4 [json_name = "state"];
}
// Network map structure.
message Netmap {
// Network map revision number.
uint64 epoch = 1 [json_name = "epoch"];
// Nodes presented in network.
repeated NodeInfo nodes = 2 [json_name = "nodes"];
}