[#29] Client: Add object placement methods
Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
8637515869
commit
568bdc67e8
25 changed files with 1382 additions and 32 deletions
|
@ -13,7 +13,7 @@ namespace FrostFS.SDK.Client;
|
|||
public static class ObjectTools
|
||||
{
|
||||
public static FrostFsObjectId CalculateObjectId(
|
||||
FrostFsObjectHeader header,
|
||||
FrostFsObjectHeader header,
|
||||
ReadOnlyMemory<byte> payloadHash,
|
||||
FrostFsOwner owner,
|
||||
FrostFsVersion version,
|
||||
|
@ -58,6 +58,7 @@ public static class ObjectTools
|
|||
grpcHeader.PayloadHash = Sha256Checksum(@object.SingleObjectPayload);
|
||||
|
||||
var split = @object.Header.Split;
|
||||
|
||||
if (split != null)
|
||||
{
|
||||
SetSplitValues(grpcHeader, split, ctx.Owner, ctx.Version, ctx.Key);
|
||||
|
@ -80,17 +81,21 @@ public static class ObjectTools
|
|||
}
|
||||
|
||||
internal static void SetSplitValues(
|
||||
Header grpcHeader,
|
||||
Header grpcHeader,
|
||||
FrostFsSplit split,
|
||||
FrostFsOwner owner,
|
||||
FrostFsVersion version,
|
||||
FrostFsOwner owner,
|
||||
FrostFsVersion version,
|
||||
ClientKey key)
|
||||
{
|
||||
if (split == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (key == null)
|
||||
{
|
||||
throw new FrostFsInvalidObjectException(nameof(key));
|
||||
}
|
||||
|
||||
grpcHeader.Split = new Header.Types.Split
|
||||
{
|
||||
|
@ -98,7 +103,9 @@ public static class ObjectTools
|
|||
};
|
||||
|
||||
if (split.Children != null && split.Children.Count != 0)
|
||||
{
|
||||
grpcHeader.Split.Children.AddRange(split.Children.Select(id => id.ToMessage()));
|
||||
}
|
||||
|
||||
if (split.ParentHeader is not null)
|
||||
{
|
||||
|
@ -118,8 +125,8 @@ public static class ObjectTools
|
|||
|
||||
internal static Header CreateHeader(
|
||||
FrostFsObjectHeader header,
|
||||
ReadOnlyMemory<byte> payloadChecksum,
|
||||
FrostFsOwner owner,
|
||||
ReadOnlyMemory<byte> payloadChecksum,
|
||||
FrostFsOwner owner,
|
||||
FrostFsVersion version)
|
||||
{
|
||||
header.OwnerId ??= owner;
|
||||
|
@ -128,7 +135,7 @@ public static class ObjectTools
|
|||
var grpcHeader = header.GetHeader();
|
||||
|
||||
grpcHeader.PayloadHash = ChecksumFromSha256(payloadChecksum);
|
||||
|
||||
|
||||
return grpcHeader;
|
||||
}
|
||||
|
||||
|
@ -149,4 +156,4 @@ public static class ObjectTools
|
|||
Sum = UnsafeByteOperations.UnsafeWrap(dataHash)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue