Skip to content

Commit

Permalink
object: Separate op for node-to-node replication
Browse files Browse the repository at this point in the history
Previously, object replication between container nodes was performed via
`ObjectService.Put` RPC. This approach had a number of problems:
 - system operations inside the container were mixed with user requests
 - it was not possible to send an object in one message

To improve this, a separate `Replicate` RPC is added. It's intended for
usage by nodes of the containers only to comply with their storage
policies. Within a request, any object is packaged into one message.
Only the object itself is signed, which simplifies and speeds up the
formation and processing of the request.

Signed-off-by: Leonard Lyubich <[email protected]>
  • Loading branch information
cthulhu-rider committed Jan 15, 2024
1 parent 1424834 commit bd1ffaf
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
41 changes: 41 additions & 0 deletions object/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ option csharp_namespace = "Neo.FileStorage.API.Object";
import "object/types.proto";
import "refs/types.proto";
import "session/types.proto";
import "status/types.proto";

// `ObjectService` provides API for manipulating objects. Object operations do
// not affect the sidechain and are only served by nodes in p2p style.
Expand Down Expand Up @@ -218,6 +219,12 @@ service ObjectService {
// - **TOKEN_EXPIRED** (4097, SECTION_SESSION): \
// provided session token has expired.
rpc GetRangeHash(GetRangeHashRequest) returns (GetRangeHashResponse);

// Save replica of the object on the NeoFS storage node. Both client and
// server must authenticate NeoFS storage nodes matching storage policy of
// the container referenced by the replicated object. Thus, this operation is
// purely system: regular users should not pay attention to it but use Put.
rpc Replicate(ReplicateRequest) returns (ReplicateResponse);
}

// GET object request
Expand Down Expand Up @@ -688,3 +695,37 @@ message GetRangeHashResponse {
// transmission.
neo.fs.v2.session.ResponseVerificationHeader verify_header = 3;
}

// Replicate RPC request
message ReplicateRequest {
// Object to be replicated.
neo.fs.v2.object.Object object = 1;

// Signature of all other request fields serialized in Protocol Buffers v3
// format in ascending order of fields.
neo.fs.v2.refs.Signature signature = 2;
}

// Replicate RPC response
message ReplicateResponse {
// Operation status codes.
enum Code {
// Object has been replicated successfully.
OK = 0;
// Internal server error described in the text message.
INTERNAL = 1;
// Request message format violation.
BAD_REQUEST = 2;
// Request signature is missing or incorrect.
UNAUTHORIZED = 3;
// The client does not authenticate any NeoFS storage node matching storage
// policy of the container referenced by the replicated object.
FORBIDDEN = 4;
// The server is not a NeoFS storage node matching storage policy of the
// container referenced by the replicated object.
PRECONDITION_FAILED = 5;
}

// Operation execution status with one of the enumerated codes.
neo.fs.v2.status.Status status = 1;
}
52 changes: 52 additions & 0 deletions proto-docs/object.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
- [PutResponse](#neo.fs.v2.object.PutResponse)
- [PutResponse.Body](#neo.fs.v2.object.PutResponse.Body)
- [Range](#neo.fs.v2.object.Range)
- [ReplicateRequest](#neo.fs.v2.object.ReplicateRequest)
- [ReplicateResponse](#neo.fs.v2.object.ReplicateResponse)
- [SearchRequest](#neo.fs.v2.object.SearchRequest)
- [SearchRequest.Body](#neo.fs.v2.object.SearchRequest.Body)
- [SearchRequest.Body.Filter](#neo.fs.v2.object.SearchRequest.Body.Filter)
Expand Down Expand Up @@ -80,6 +82,7 @@ rpc Head(HeadRequest) returns (HeadResponse);
rpc Search(SearchRequest) returns (stream SearchResponse);
rpc GetRange(GetRangeRequest) returns (stream GetRangeResponse);
rpc GetRangeHash(GetRangeHashRequest) returns (GetRangeHashResponse);
rpc Replicate(ReplicateRequest) returns (ReplicateResponse);
```

Expand Down Expand Up @@ -318,6 +321,16 @@ Statuses:
| Name | Input | Output |
| ---- | ----- | ------ |
| GetRangeHash | [GetRangeHashRequest](#neo.fs.v2.object.GetRangeHashRequest) | [GetRangeHashResponse](#neo.fs.v2.object.GetRangeHashResponse) |
#### Method Replicate

Save replica of the object on the NeoFS storage node. Both client and
server must authenticate NeoFS storage nodes matching storage policy of
the container referenced by the replicated object. Thus, this operation is
purely system: regular users should not pay attention to it but use Put.

| Name | Input | Output |
| ---- | ----- | ------ |
| Replicate | [ReplicateRequest](#neo.fs.v2.object.ReplicateRequest) | [ReplicateResponse](#neo.fs.v2.object.ReplicateResponse) |
<!-- end services -->


Expand Down Expand Up @@ -687,6 +700,29 @@ Object payload range. Ranges of zero length SHOULD be considered as invalid.
| length | [uint64](#uint64) | | Length in bytes of the object payload range |


<a name="neo.fs.v2.object.ReplicateRequest"></a>

### Message ReplicateRequest
Replicate RPC request


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| object | [Object](#neo.fs.v2.object.Object) | | Object to be replicated. |
| signature | [neo.fs.v2.refs.Signature](#neo.fs.v2.refs.Signature) | | Signature of all other request fields serialized in Protocol Buffers v3 format in ascending order of fields. |


<a name="neo.fs.v2.object.ReplicateResponse"></a>

### Message ReplicateResponse
Replicate RPC response


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| status | [neo.fs.v2.status.Status](#neo.fs.v2.status.Status) | | Operation execution status with one of the enumerated codes. |


<a name="neo.fs.v2.object.SearchRequest"></a>

### Message SearchRequest
Expand Down Expand Up @@ -804,6 +840,22 @@ Object Search response body

<!-- end messages -->


<a name="neo.fs.v2.object.ReplicateResponse.Code"></a>

### ReplicateResponse.Code
Operation status codes.

| Name | Number | Description |
| ---- | ------ | ----------- |
| OK | 0 | Object has been replicated successfully. |
| INTERNAL | 1 | Internal server error described in the text message. |
| BAD_REQUEST | 2 | Request message format violation. |
| UNAUTHORIZED | 3 | Request signature is missing or incorrect. |
| FORBIDDEN | 4 | The client does not authenticate any NeoFS storage node matching storage policy of the container referenced by the replicated object. |
| PRECONDITION_FAILED | 5 | The server is not a NeoFS storage node matching storage policy of the container referenced by the replicated object. |


<!-- end enums -->


Expand Down

0 comments on commit bd1ffaf

Please sign in to comment.