[#18] Client: Rename parameters #19

Merged
PavelGrossSpb merged 1 commit from PavelGrossSpb/frostfs-sdk-csharp:misc/refactor into master 2024-07-25 10:29:56 +00:00
31 changed files with 200 additions and 142 deletions
Showing only changes of commit 3206abc33e - Show all commits

View file

@ -117,26 +117,26 @@ public class Client : IFrostFSClient
}
#region ContainerImplementation
public Task<ModelsV2.Container> GetContainerAsync(PrmGetContainer args)
public Task<ModelsV2.Container> GetContainerAsync(PrmContainerGet args)
{
var service = GetContainerService(args);
return service.GetContainerAsync(args);
}
public IAsyncEnumerable<ContainerId> ListContainersAsync(PrmListContainer? args = null)
public IAsyncEnumerable<ContainerId> ListContainersAsync(PrmContainerGetAll? args = null)
{
args = args ?? new PrmListContainer();
args = args ?? new PrmContainerGetAll();
var service = GetContainerService(args);
return service.ListContainersAsync(args);
}
public Task<ContainerId> CreateContainerAsync(PrmCreateContainer args)
public Task<ContainerId> CreateContainerAsync(PrmContainerCreate args)
{
var service = GetContainerService(args);
return service.CreateContainerAsync(args);
}
public Task DeleteContainerAsync(PrmDeleteContainer args)
public Task DeleteContainerAsync(PrmContainerDelete args)
{
var service = GetContainerService(args);
return service.DeleteContainerAsync(args);
@ -144,60 +144,60 @@ public class Client : IFrostFSClient
#endregion
#region NetworkImplementation
public Task<NetmapSnapshot> GetNetmapSnapshotAsync(PrmGetNetmapSnapshot? args)
public Task<NetmapSnapshot> GetNetmapSnapshotAsync(PrmNetmapSnapshot? args)
{
args ??= new PrmGetNetmapSnapshot();
args ??= new PrmNetmapSnapshot();
var service = GetNetmapService(args);
return service.GetNetmapSnapshotAsync(args);
}
public Task<ModelsV2.Netmap.NodeInfo> GetNodeInfoAsync(PrmGetNodeInfo? args)
public Task<ModelsV2.Netmap.NodeInfo> GetNodeInfoAsync(PrmNodeInfo? args)
{
args ??= new PrmGetNodeInfo();
args ??= new PrmNodeInfo();
var service = GetNetmapService(args);
return service.GetLocalNodeInfoAsync(args);
}
public Task<NetworkSettings> GetNetworkSettingsAsync(PrmGetNetworkSettings? args)
public Task<NetworkSettings> GetNetworkSettingsAsync(PrmNetworkSettings? args)
{
args ??= new PrmGetNetworkSettings();
args ??= new PrmNetworkSettings();
var service = GetNetmapService(args);
return service.GetNetworkSettingsAsync(args.Context!);
}
#endregion
#region ObjectImplementation
public Task<ObjectHeader> GetObjectHeadAsync(PrmGetObjectHead args)
public Task<ObjectHeader> GetObjectHeadAsync(PrmObjectHeadGet args)
{
var service = GetObjectService(args);
return service.GetObjectHeadAsync(args);
}
public Task<FrostFsObject> GetObjectAsync(PrmGetObject args)
public Task<FrostFsObject> GetObjectAsync(PrmObjectGet args)
{
var service = GetObjectService(args);
return service.GetObjectAsync(args);
}
public Task<ObjectId> PutObjectAsync(PrmPutObject args)
public Task<ObjectId> PutObjectAsync(PrmObjectPut args)
{
var service = GetObjectService(args);
return service.PutObjectAsync(args);
}
public Task<ObjectId> PutSingleObjectAsync(PrmPutSingleObject args)
public Task<ObjectId> PutSingleObjectAsync(PrmSingleObjectPut args)
{
var service = GetObjectService(args);
return service.PutSingleObjectAsync(args);
}
public Task DeleteObjectAsync(PrmDeleteObject args)
public Task DeleteObjectAsync(PrmObjectDelete args)
{
var service = GetObjectService(args);
return service.DeleteObjectAsync(args);
}
public IAsyncEnumerable<ObjectId> SearchObjectsAsync(PrmSearchObject args)
public IAsyncEnumerable<ObjectId> SearchObjectsAsync(PrmObjectSearch args)
{
var service = GetObjectService(args);
return service.SearchObjectsAsync(args);
@ -205,7 +205,7 @@ public class Client : IFrostFSClient
#endregion
#region SessionImplementation
public async Task<ModelsV2.SessionToken> CreateSessionAsync(PrmCreateSession args)
public async Task<ModelsV2.SessionToken> CreateSessionAsync(PrmSessionCreate args)
{
var session = await CreateSessionInternalAsync(args);
var token = session.Serialize();
@ -213,7 +213,7 @@ public class Client : IFrostFSClient
return new ModelsV2.SessionToken(token);
}
internal Task<Session.SessionToken> CreateSessionInternalAsync(PrmCreateSession args)
internal Task<Session.SessionToken> CreateSessionInternalAsync(PrmSessionCreate args)
{
var service = GetSessionService(args);
return service.CreateSessionAsync(args);
@ -229,7 +229,7 @@ public class Client : IFrostFSClient
private async void CheckFrostFsVersionSupport(Context? ctx = default)
{
var args = new PrmGetNodeInfo(ctx);
var args = new PrmNodeInfo(ctx);
var service = GetNetmapService(args);
var localNodeInfo = await service.GetLocalNodeInfoAsync(args);

View file

@ -9,39 +9,39 @@ namespace FrostFS.SDK.ClientV2.Interfaces;
public interface IFrostFSClient : IDisposable
{
#region Network
Task<NetmapSnapshot> GetNetmapSnapshotAsync(PrmGetNetmapSnapshot? args = null);
Task<NetmapSnapshot> GetNetmapSnapshotAsync(PrmNetmapSnapshot? args = null);
Task<NodeInfo> GetNodeInfoAsync(PrmGetNodeInfo? args = null);
Task<NodeInfo> GetNodeInfoAsync(PrmNodeInfo? args = null);
Task<NetworkSettings> GetNetworkSettingsAsync(PrmGetNetworkSettings? args = null);
Task<NetworkSettings> GetNetworkSettingsAsync(PrmNetworkSettings? args = null);
#endregion
#region Session
Task<SessionToken> CreateSessionAsync(PrmCreateSession args);
Task<SessionToken> CreateSessionAsync(PrmSessionCreate args);
#endregion
#region Container
Task<ModelsV2.Container> GetContainerAsync(PrmGetContainer args);
Task<ModelsV2.Container> GetContainerAsync(PrmContainerGet args);
IAsyncEnumerable<ContainerId> ListContainersAsync(PrmListContainer? args = null);
IAsyncEnumerable<ContainerId> ListContainersAsync(PrmContainerGetAll? args = null);
Task<ContainerId> CreateContainerAsync(PrmCreateContainer args);
Task<ContainerId> CreateContainerAsync(PrmContainerCreate args);
Task DeleteContainerAsync(PrmDeleteContainer args);
Task DeleteContainerAsync(PrmContainerDelete args);
#endregion
#region Object
Task<ObjectHeader> GetObjectHeadAsync(PrmGetObjectHead args);
Task<ObjectHeader> GetObjectHeadAsync(PrmObjectHeadGet args);
Task<FrostFsObject> GetObjectAsync(PrmGetObject args);
Task<FrostFsObject> GetObjectAsync(PrmObjectGet args);
Task<ObjectId> PutObjectAsync(PrmPutObject putObjectParameters);
Task<ObjectId> PutObjectAsync(PrmObjectPut putObjectParameters);
Task<ObjectId> PutSingleObjectAsync(PrmPutSingleObject args);
Task<ObjectId> PutSingleObjectAsync(PrmSingleObjectPut args);
Task DeleteObjectAsync(PrmDeleteObject args);
Task DeleteObjectAsync(PrmObjectDelete args);
IAsyncEnumerable<ObjectId> SearchObjectsAsync(PrmSearchObject args);
IAsyncEnumerable<ObjectId> SearchObjectsAsync(PrmObjectSearch args);
#endregion
#region Tools

View file

@ -2,7 +2,7 @@
namespace FrostFS.SDK.ClientV2.Parameters;
public sealed class PrmCreateContainer(ModelsV2.Container container) : IContext
public sealed class PrmContainerCreate(ModelsV2.Container container) : IContext
{
public ModelsV2.Container Container { get; set; } = container;

View file

@ -3,7 +3,7 @@ using FrostFS.SDK.ModelsV2;
namespace FrostFS.SDK.ClientV2.Parameters;
public sealed class PrmDeleteContainer(ContainerId containerId, Context? ctx = null) : IContext
public sealed class PrmContainerDelete(ContainerId containerId, Context? ctx = null) : IContext
{
public ContainerId ContainerId { get; set; } = containerId;

View file

@ -3,7 +3,7 @@ using FrostFS.SDK.ModelsV2;
namespace FrostFS.SDK.ClientV2.Parameters;
public sealed class PrmGetContainer(ContainerId containerId, Context? ctx = null) : IContext
public sealed class PrmContainerGet(ContainerId containerId, Context? ctx = null) : IContext
{
public ContainerId ContainerId { get; set; } = containerId;

View file

@ -2,7 +2,7 @@
namespace FrostFS.SDK.ClientV2.Parameters;
public sealed class PrmListContainer() : IContext
public sealed class PrmContainerGetAll() : IContext
{
public string SessionToken { get; set; } = string.Empty;

View file

@ -2,7 +2,7 @@
namespace FrostFS.SDK.ClientV2.Parameters;
public sealed class PrmGetNetmapSnapshot(Context? context = default) : IContext
public sealed class PrmNetmapSnapshot(Context? context = default) : IContext
{
/// <summary>
/// FrostFS request X-Headers

View file

@ -2,7 +2,7 @@
namespace FrostFS.SDK.ClientV2.Parameters;
public sealed class PrmGetNetworkSettings(Context? context = default) : IContext
public sealed class PrmNetworkSettings(Context? context = default) : IContext
{
/// <summary>
/// FrostFS request X-Headers

View file

@ -2,7 +2,7 @@
namespace FrostFS.SDK.ClientV2.Parameters;
public sealed class PrmGetNodeInfo(Context? context = default) : IContext
public sealed class PrmNodeInfo(Context? context = default) : IContext
{
/// <summary>
/// FrostFS request X-Headers

View file

@ -3,7 +3,7 @@ using FrostFS.SDK.ModelsV2;
namespace FrostFS.SDK.ClientV2.Parameters;
public sealed class PrmDeleteObject(ContainerId containerId, ObjectId objectId) : IContext, ISessionToken
public sealed class PrmObjectDelete(ContainerId containerId, ObjectId objectId) : IContext, ISessionToken
{
public ContainerId ContainerId { get; set; } = containerId;
public ObjectId ObjectId { get; set; } = objectId;

View file

@ -3,7 +3,7 @@ using FrostFS.SDK.ModelsV2;
namespace FrostFS.SDK.ClientV2.Parameters;
public sealed class PrmGetObject(ContainerId containerId, ObjectId objectId) : IContext, ISessionToken
public sealed class PrmObjectGet(ContainerId containerId, ObjectId objectId) : IContext, ISessionToken
{
public ContainerId ContainerId { get; set; } = containerId;
public ObjectId ObjectId { get; set; } = objectId;

View file

@ -3,7 +3,7 @@ using FrostFS.SDK.ModelsV2;
namespace FrostFS.SDK.ClientV2.Parameters;
public sealed class PrmGetObjectHead(ContainerId containerId, ObjectId objectId) : IContext, ISessionToken
public sealed class PrmObjectHeadGet(ContainerId containerId, ObjectId objectId) : IContext, ISessionToken
{
public ContainerId ContainerId { get; set; } = containerId;
public ObjectId ObjectId { get; set; } = objectId;

View file

@ -3,7 +3,7 @@ using System.IO;
using FrostFS.SDK.ModelsV2;
namespace FrostFS.SDK.ClientV2.Parameters;
public sealed class PrmPutObject : IContext, ISessionToken
public sealed class PrmObjectPut : IContext, ISessionToken
{
/// <summary>
/// Need to provide values like <c>ContainerId</c> and <c>ObjectType</c> to create and object.

View file

@ -3,7 +3,7 @@ using System.Collections.Specialized;
using FrostFS.SDK.ModelsV2;
namespace FrostFS.SDK.ClientV2.Parameters;
public sealed class PrmSearchObject(ContainerId containerId, params ObjectFilter[] filters) : IContext, ISessionToken
public sealed class PrmObjectSearch(ContainerId containerId, params ObjectFilter[] filters) : IContext, ISessionToken
{
public ContainerId ContainerId { get; set; } = containerId;

View file

@ -2,7 +2,7 @@
namespace FrostFS.SDK.ClientV2.Parameters;
public sealed class PrmCreateSession(ulong expiration, Context? context = default) : IContext
public sealed class PrmSessionCreate(ulong expiration, Context? context = default) : IContext
{
public ulong Expiration { get; set; } = expiration;

View file

@ -2,7 +2,7 @@
using FrostFS.SDK.ModelsV2;
namespace FrostFS.SDK.ClientV2.Parameters;
public sealed class PrmPutSingleObject(FrostFsObject frostFsObject, Context? context = null) : IContext, ISessionToken
public sealed class PrmSingleObjectPut(FrostFsObject frostFsObject, Context? context = null) : IContext, ISessionToken
{
public FrostFsObject FrostFsObject { get; set; } = frostFsObject;

View file

@ -23,7 +23,7 @@ internal class ContainerServiceProvider : ContextAccessor
containerServiceClient = service;
}
internal async Task<ModelsV2.Container> GetContainerAsync(PrmGetContainer args)
internal async Task<ModelsV2.Container> GetContainerAsync(PrmContainerGet args)
{
GetRequest request = GetContainerRequest(args.ContainerId.ToGrpcMessage(), args.XHeaders);
@ -34,7 +34,7 @@ internal class ContainerServiceProvider : ContextAccessor
return response.Body.Container.ToModel();
}
internal async IAsyncEnumerable<ContainerId> ListContainersAsync(PrmListContainer args)
internal async IAsyncEnumerable<ContainerId> ListContainersAsync(PrmContainerGetAll args)
{
var ctx = args.Context!;
@ -59,7 +59,7 @@ internal class ContainerServiceProvider : ContextAccessor
}
}
internal async Task<ContainerId> CreateContainerAsync(PrmCreateContainer args)
internal async Task<ContainerId> CreateContainerAsync(PrmContainerCreate args)
{
var ctx = args.Context!;
var grpcContainer = args.Container.ToGrpcMessage();
@ -87,7 +87,7 @@ internal class ContainerServiceProvider : ContextAccessor
return new ContainerId(Base58.Encode(response.Body.ContainerId.Value.ToByteArray()));
}
internal async Task DeleteContainerAsync(PrmDeleteContainer args)
internal async Task DeleteContainerAsync(PrmContainerDelete args)
{
var ctx = args.Context!;
var request = new DeleteRequest

View file

@ -40,7 +40,7 @@ internal class NetmapServiceProvider : ContextAccessor
return settings;
}
internal async Task<NodeInfo> GetLocalNodeInfoAsync(PrmGetNodeInfo args)
internal async Task<NodeInfo> GetLocalNodeInfoAsync(PrmNodeInfo args)
{
var ctx = args.Context!;
var request = new LocalNodeInfoRequest
@ -72,7 +72,7 @@ internal class NetmapServiceProvider : ContextAccessor
return response;
}
internal async Task<NetmapSnapshot> GetNetmapSnapshotAsync(PrmGetNetmapSnapshot args)
internal async Task<NetmapSnapshot> GetNetmapSnapshotAsync(PrmNetmapSnapshot args)
{
var ctx = args.Context!;

View file

@ -21,7 +21,7 @@ internal class ObjectServiceProvider(ObjectService.ObjectServiceClient client, C
{
readonly ObjectTools tools = new(ctx);
internal async Task<ObjectHeader> GetObjectHeadAsync(PrmGetObjectHead args)
internal async Task<ObjectHeader> GetObjectHeadAsync(PrmObjectHeadGet args)
{
var ctx = args.Context!;
var request = new HeadRequest
@ -54,7 +54,7 @@ internal class ObjectServiceProvider(ObjectService.ObjectServiceClient client, C
return response.Body.Header.Header.ToModel();
}
internal async Task<FrostFsObject> GetObjectAsync(PrmGetObject args)
internal async Task<FrostFsObject> GetObjectAsync(PrmObjectGet args)
{
var ctx = args.Context!;
@ -84,7 +84,7 @@ internal class ObjectServiceProvider(ObjectService.ObjectServiceClient client, C
return await GetObject(request, ctx);
}
internal async Task DeleteObjectAsync(PrmDeleteObject args)
internal async Task DeleteObjectAsync(PrmObjectDelete args)
{
var ctx = args.Context!;
var request = new DeleteRequest
@ -114,7 +114,7 @@ internal class ObjectServiceProvider(ObjectService.ObjectServiceClient client, C
Verifier.CheckResponse(response);
}
internal async IAsyncEnumerable<ObjectId> SearchObjectsAsync(PrmSearchObject args)
internal async IAsyncEnumerable<ObjectId> SearchObjectsAsync(PrmObjectSearch args)
{
var ctx = args.Context!;
var request = new SearchRequest
@ -148,7 +148,7 @@ internal class ObjectServiceProvider(ObjectService.ObjectServiceClient client, C
}
}
internal Task<ObjectId> PutObjectAsync(PrmPutObject args)
internal Task<ObjectId> PutObjectAsync(PrmObjectPut args)
{
if (args.Header == null)
throw new ArgumentException("Value cannot be null", nameof(args.Header));
@ -162,7 +162,7 @@ internal class ObjectServiceProvider(ObjectService.ObjectServiceClient client, C
return PutStreamObject(args);
}
internal async Task<ObjectId> PutSingleObjectAsync(PrmPutSingleObject args)
internal async Task<ObjectId> PutSingleObjectAsync(PrmSingleObjectPut args)
{
var ctx = args.Context!;
var grpcObject = tools.CreateObject(args.FrostFsObject);
@ -195,7 +195,7 @@ internal class ObjectServiceProvider(ObjectService.ObjectServiceClient client, C
static readonly AsyncLocal<Session.SessionToken> asyncLocalSession = new ();
private async Task<ObjectId> PutClientCutObject(PrmPutObject args)
private async Task<ObjectId> PutClientCutObject(PrmObjectPut args)
{
var ctx = args.Context!;
var tokenRaw = await GetOrCreateSession(args, ctx);
@ -209,7 +209,7 @@ internal class ObjectServiceProvider(ObjectService.ObjectServiceClient client, C
FrostFsObject? currentObject;
var networkSettings = await Context.Client.GetNetworkSettingsAsync(new PrmGetNetworkSettings(ctx));
var networkSettings = await Context.Client.GetNetworkSettingsAsync(new PrmNetworkSettings(ctx));
var objectSize = (int)networkSettings.MaxObjectSize;
@ -247,7 +247,7 @@ internal class ObjectServiceProvider(ObjectService.ObjectServiceClient client, C
if (largeObject.PayloadLength == fullLength)
break;
objectId = await PutSingleObjectAsync(new PrmPutSingleObject(currentObject, ctx) { SessionToken = token });
objectId = await PutSingleObjectAsync(new PrmSingleObjectPut(currentObject, ctx) { SessionToken = token });
sentObjectIds.Add(objectId!);
}
@ -258,7 +258,7 @@ internal class ObjectServiceProvider(ObjectService.ObjectServiceClient client, C
currentObject.SetParent(largeObject);
var putSingleObjectParams = new PrmPutSingleObject(currentObject, ctx) { SessionToken = token };
var putSingleObjectParams = new PrmSingleObjectPut(currentObject, ctx) { SessionToken = token };
objectId = await PutSingleObjectAsync(putSingleObjectParams);
@ -269,17 +269,17 @@ internal class ObjectServiceProvider(ObjectService.ObjectServiceClient client, C
linkObject.Header.Attributes.Clear();
_ = await PutSingleObjectAsync(new PrmPutSingleObject(linkObject, ctx){ SessionToken = token });
_ = await PutSingleObjectAsync(new PrmSingleObjectPut(linkObject, ctx){ SessionToken = token });
return tools.CalculateObjectId(largeObject.Header);
}
currentObject.AddAttributes(args.Header!.Attributes);
return await PutSingleObjectAsync(new PrmPutSingleObject(currentObject, ctx));
return await PutSingleObjectAsync(new PrmSingleObjectPut(currentObject, ctx));
}
private async Task<ObjectId> PutStreamObject(PrmPutObject args)
private async Task<ObjectId> PutStreamObject(PrmObjectPut args)
{
var ctx = args.Context!;
var payload = args.Payload!;
@ -426,7 +426,7 @@ internal class ObjectServiceProvider(ObjectService.ObjectServiceClient client, C
{
if (args.SessionToken is null)
{
return await Context.Client.CreateSessionInternalAsync(new PrmCreateSession(uint.MaxValue, ctx));
return await Context.Client.CreateSessionInternalAsync(new PrmSessionCreate(uint.MaxValue, ctx));
}
return new Session.SessionToken().Deserialize(args.SessionToken.Token);

View file

@ -15,7 +15,7 @@ internal class SessionServiceProvider : ContextAccessor
_sessionServiceClient = sessionServiceClient;
}
internal async Task<SessionToken> CreateSessionAsync(PrmCreateSession args)
internal async Task<SessionToken> CreateSessionAsync(PrmSessionCreate args)
{
var request = new CreateRequest
{

View file

@ -33,6 +33,9 @@ public static class RequestConstructor
ObjectSessionContext.Types.Verb verb,
ECDsa key)
{
if (sessionToken.Body.Object?.Target != null)
return;
ObjectSessionContext.Types.Target target = new() { Container = address.ContainerId };
if (address.ObjectId != null)

View file

@ -21,6 +21,7 @@ public static class Extentions
var sha256 = SHA256.Create();
return sha256.ComputeHash(value);
}
public static ByteString Sha256(this IMessage data)
{
return ByteString.CopyFrom(data.ToByteArray().Sha256());

View file

@ -1,7 +0,0 @@
namespace FrostFS.SDK.ModelsV2;
public class Constants
{
public const int ObjectChunkSize = 3 * (1 << 20);
public const int Sha256HashLength = 32;
}

View file

@ -1,8 +0,0 @@
namespace FrostFS.SDK.ModelsV2;
public class GrpcCallInfo(string methodName, long elapsedMicroSec, bool hasError)
{
public string MethodName { get; set; } = methodName;
public long ElapsedTimeMicroSec { get; set; } = elapsedMicroSec;
public bool HasError { get; } = hasError;
}

View file

@ -0,0 +1,25 @@
using System.Security.Cryptography;
using System.Text;
namespace FrostFS.SDK.ModelsV2;
public class CheckSum
{
public byte[]? Hash { get; set; }
public static byte[] GetHash(byte[] content)
{
var sha256 = SHA256.Create();
return sha256.ComputeHash(content);
}
public static CheckSum CreateCheckSum(byte[] content)
{
return new CheckSum { Hash = GetHash(content) };
}
public override string ToString()
{
return Encoding.UTF8.GetString(Hash);
}
}

View file

@ -0,0 +1,52 @@
namespace FrostFS.SDK.ModelsV2;
public class Constants
{
public const int ObjectChunkSize = 3 * (1 << 20);
public const int Sha256HashLength = 32;
// HeaderPrefix is a prefix of key to object header value or property.
public const string HeaderPrefix = "$Object:";
// FilterHeaderVersion is a filter key to "version" field of the object header.
public const string FilterHeaderVersion = HeaderPrefix + "version";
// FilterHeaderObjectID is a filter key to "object_id" field of the object.
public const string FilterHeaderObjectID = HeaderPrefix + "objectID";
// FilterHeaderContainerID is a filter key to "container_id" field of the object header.
public const string FilterHeaderContainerID = HeaderPrefix + "containerID";
// FilterHeaderOwnerID is a filter key to "owner_id" field of the object header.
public const string FilterHeaderOwnerID = HeaderPrefix + "ownerID";
// FilterHeaderCreationEpoch is a filter key to "creation_epoch" field of the object header.
public const string FilterHeaderCreationEpoch = HeaderPrefix + "creationEpoch";
// FilterHeaderPayloadLength is a filter key to "payload_length" field of the object header.
public const string FilterHeaderPayloadLength = HeaderPrefix + "payloadLength";
// FilterHeaderPayloadHash is a filter key to "payload_hash" field of the object header.
public const string FilterHeaderPayloadHash = HeaderPrefix + "payloadHash";
// FilterHeaderObjectType is a filter key to "object_type" field of the object header.
public const string FilterHeaderObjectType = HeaderPrefix + "objectType";
// FilterHeaderHomomorphicHash is a filter key to "homomorphic_hash" field of the object header.
public const string FilterHeaderHomomorphicHash = HeaderPrefix + "homomorphicHash";
// FilterHeaderParent is a filter key to "split.parent" field of the object header.
public const string FilterHeaderParent = HeaderPrefix + "split.parent";
// FilterHeaderSplitID is a filter key to "split.splitID" field of the object header.
public const string FilterHeaderSplitID = HeaderPrefix + "split.splitID";
// FilterHeaderECParent is a filter key to "ec.parent" field of the object header.
public const string FilterHeaderECParent = HeaderPrefix + "ec.parent";
// FilterPropertyRoot is a filter key to check if regular object is on top of split hierarchy.
public const string FilterHeaderRoot = HeaderPrefix + "ROOT";
// FilterPropertyPhy is a filter key to check if an object physically stored on a node.
public const string FilterHeaderPhy = HeaderPrefix + "PHY";
}

View file

@ -4,25 +4,16 @@ using FrostFS.SDK.ModelsV2.Enums;
namespace FrostFS.SDK.ModelsV2.Netmap;
public class NodeInfo
{
public NodeInfo(
public class NodeInfo(
Version version,
NodeState state,
IReadOnlyCollection<string> addresses,
IReadOnlyDictionary<string, string> attributes,
ReadOnlyMemory<byte> publicKey)
{
Version = version;
State = state;
Addresses = addresses;
Attributes = attributes;
PublicKey = publicKey;
}
public NodeState State { get; private set; }
public Version Version { get; private set; }
public IReadOnlyCollection<string> Addresses { get; private set; }
public IReadOnlyDictionary<string, string> Attributes { get; private set; }
public ReadOnlyMemory<byte> PublicKey { get; private set; }
{
public NodeState State { get; private set; } = state;
public Version Version { get; private set; } = version;
public IReadOnlyCollection<string> Addresses { get; private set; } = addresses;
public IReadOnlyDictionary<string, string> Attributes { get; private set; } = attributes;
public ReadOnlyMemory<byte> PublicKey { get; private set; } = publicKey;
}

View file

@ -52,7 +52,7 @@ public class ContainerTest : ContainerTestsBase
[Fact]
public async void CreateContainerTest()
{
var param = new PrmCreateContainer(new ModelsV2.Container(BasicAcl.PublicRW, Mocker.PlacementPolicy));
var param = new PrmContainerCreate(new ModelsV2.Container(BasicAcl.PublicRW, Mocker.PlacementPolicy));
var result = await GetClient().CreateContainerAsync(param);
@ -68,7 +68,7 @@ public class ContainerTest : ContainerTestsBase
Mocker.Acl = BasicAcl.PublicRO;
var result = await GetClient().GetContainerAsync(new PrmGetContainer(cid));
var result = await GetClient().GetContainerAsync(new PrmContainerGet(cid));
Assert.NotNull(result);
Assert.Equal(Mocker.Acl, result.BasicAcl);
@ -104,7 +104,7 @@ public class ContainerTest : ContainerTestsBase
Mocker.ReturnContainerRemoved = true;
var cid = new ContainerId(Base58.Encode(Mocker.ContainerGuid.ToBytes()));
await GetClient().DeleteContainerAsync(new PrmDeleteContainer(cid));
await GetClient().DeleteContainerAsync(new PrmContainerDelete(cid));
Assert.Single(Mocker.Requests);

View file

@ -77,7 +77,7 @@ public class ObjectTest : ObjectTestsBase
Timeout = TimeSpan.FromSeconds(2)
};
var result = await client.GetObjectAsync(new PrmGetObject(ContainerId, objectId) { Context = context });
var result = await client.GetObjectAsync(new PrmObjectGet(ContainerId, objectId) { Context = context });
Assert.NotNull(result);
@ -98,7 +98,7 @@ public class ObjectTest : ObjectTestsBase
var bytes = new byte[1024];
rnd.NextBytes(bytes);
var param = new PrmPutObject
var param = new PrmObjectPut
{
Header = Mocker.ObjectHeader,
Payload = new MemoryStream(bytes),
@ -133,7 +133,7 @@ public class ObjectTest : ObjectTestsBase
byte[] bytes = File.ReadAllBytes(@".\..\..\..\TestData\cat.jpg");
var fileLength = bytes.Length;
var param = new PrmPutObject
var param = new PrmObjectPut
{
Header = Mocker.ObjectHeader,
Payload = new MemoryStream(bytes),
@ -197,7 +197,7 @@ public class ObjectTest : ObjectTestsBase
{
Mocker.ObjectId = new ObjectID { Value = ByteString.CopyFrom(SHA256.HashData(Encoding.UTF8.GetBytes("test"))) }.ToModel();
await GetClient().DeleteObjectAsync(new PrmDeleteObject(ContainerId, Mocker.ObjectId));
await GetClient().DeleteObjectAsync(new PrmObjectDelete(ContainerId, Mocker.ObjectId));
var request = Mocker.DeleteRequests.FirstOrDefault();
Assert.NotNull(request);
@ -210,7 +210,7 @@ public class ObjectTest : ObjectTestsBase
{
Mocker.ObjectId = new ObjectID { Value = ByteString.CopyFrom(SHA256.HashData(Encoding.UTF8.GetBytes("test"))) }.ToModel();
var response = await GetClient().GetObjectHeadAsync(new PrmGetObjectHead(ContainerId, Mocker.ObjectId));
var response = await GetClient().GetObjectHeadAsync(new PrmObjectHeadGet(ContainerId, Mocker.ObjectId));
var request = Mocker.HeadRequests.FirstOrDefault();
Assert.NotNull(request);

View file

@ -18,9 +18,9 @@ namespace FrostFS.SDK.SmokeTests;
public class SmokeTests
{
private static PrmWait lightWait = new (100, 1);
private static readonly PrmWait lightWait = new (100, 1);
private readonly string key = "KwHDAJ66o8FoLBjVbjP2sWBmgBMGjt7Vv4boA7xQrBoAYBE397Aq";
private readonly string url = "http://172.29.238.97:8080";
private readonly string url = "http://172.23.32.4:8080";
[Fact]
public async void NetworkMapTest()
@ -74,7 +74,7 @@ public class SmokeTests
{
using var client = Client.GetInstance(GetOptions(this.key, this.url));
var token = await client.CreateSessionAsync(new PrmCreateSession(100));
var token = await client.CreateSessionAsync(new PrmSessionCreate(100));
var session = new Session.SessionToken().Deserialize(token.Token);
@ -100,9 +100,9 @@ public class SmokeTests
await Cleanup(client);
var token = await client.CreateSessionAsync(new PrmCreateSession(int.MaxValue));
var token = await client.CreateSessionAsync(new PrmSessionCreate(int.MaxValue));
var createContainerParam = new PrmCreateContainer(
var createContainerParam = new PrmContainerCreate(
new ModelsV2.Container(BasicAcl.PublicRW, new PlacementPolicy(true, new Replica(1))));
createContainerParam.XHeaders.Add("key1", "value1");
@ -111,7 +111,7 @@ public class SmokeTests
var bytes = GetRandomBytes(1024);
var param = new PrmPutObject
var param = new PrmObjectPut
{
Header = new ObjectHeader(
containerId: containerId,
@ -124,7 +124,7 @@ public class SmokeTests
var objectId = await client.PutObjectAsync(param);
var @object = await client.GetObjectAsync(new PrmGetObject(containerId, objectId));
var @object = await client.GetObjectAsync(new PrmObjectGet(containerId, objectId));
var downloadedBytes = new byte[@object.Header.PayloadLength];
MemoryStream ms = new(downloadedBytes);
@ -161,7 +161,7 @@ public class SmokeTests
})
};
var createContainerParam = new PrmCreateContainer(
var createContainerParam = new PrmContainerCreate(
new ModelsV2.Container(BasicAcl.PublicRW, new PlacementPolicy(true, new Replica(1))))
{
Context = ctx
@ -169,13 +169,13 @@ public class SmokeTests
var containerId = await client.CreateContainerAsync(createContainerParam);
var container = await client.GetContainerAsync(new PrmGetContainer(containerId,ctx));
var container = await client.GetContainerAsync(new PrmContainerGet(containerId,ctx));
Assert.NotNull(container);
Assert.True(callbackInvoked);
var bytes = GetRandomBytes(objectSize);
var param = new PrmPutObject
var param = new PrmObjectPut
{
Header = new ObjectHeader(
containerId: containerId,
@ -194,11 +194,11 @@ public class SmokeTests
var filter = new ObjectFilter(ObjectMatchType.Equals, "fileName", "test");
bool hasObject = false;
await foreach (var objId in client.SearchObjectsAsync(new PrmSearchObject(containerId) { Filters = [filter] }))
await foreach (var objId in client.SearchObjectsAsync(new PrmObjectSearch(containerId) { Filters = [filter] }))
{
hasObject = true;
var objHeader = await client.GetObjectHeadAsync(new PrmGetObjectHead(containerId, objectId));
var objHeader = await client.GetObjectHeadAsync(new PrmObjectHeadGet(containerId, objectId));
Assert.Equal((ulong)bytes.Length, objHeader.PayloadLength);
Assert.Single(objHeader.Attributes);
Assert.Equal("fileName", objHeader.Attributes.First().Key);
@ -207,7 +207,7 @@ public class SmokeTests
Assert.True(hasObject);
var @object = await client.GetObjectAsync(new PrmGetObject(containerId, objectId));
var @object = await client.GetObjectAsync(new PrmObjectGet(containerId, objectId));
var downloadedBytes = new byte[@object.Header.PayloadLength];
MemoryStream ms = new(downloadedBytes);
@ -236,7 +236,7 @@ public class SmokeTests
{
using var client = Client.GetInstance(GetOptions(this.key, this.url));
var token = await client.CreateSessionAsync(new PrmCreateSession(int.MaxValue));
var token = await client.CreateSessionAsync(new PrmSessionCreate(int.MaxValue));
await Cleanup(client);
@ -246,7 +246,7 @@ public class SmokeTests
Callback = new((CallStatistics cs) => Assert.True(cs.ElapsedMicroSeconds > 0))
};
var createContainerParam = new PrmCreateContainer(
var createContainerParam = new PrmContainerCreate(
new ModelsV2.Container(BasicAcl.PublicRW, new PlacementPolicy(true, new Replica(1))))
{
Context = ctx
@ -254,12 +254,12 @@ public class SmokeTests
var containerId = await client.CreateContainerAsync(createContainerParam);
var container = await client.GetContainerAsync(new PrmGetContainer(containerId,ctx));
var container = await client.GetContainerAsync(new PrmContainerGet(containerId,ctx));
Assert.NotNull(container);
var bytes = GetRandomBytes(objectSize);
var param = new PrmPutObject
var param = new PrmObjectPut
{
Header = new ObjectHeader(
containerId: containerId,
@ -279,11 +279,11 @@ public class SmokeTests
var filter = new ObjectFilter(ObjectMatchType.Equals, "fileName", "test");
bool hasObject = false;
await foreach (var objId in client.SearchObjectsAsync(new PrmSearchObject(containerId) { Filters = [filter], SessionToken = token }))
await foreach (var objId in client.SearchObjectsAsync(new PrmObjectSearch(containerId) { Filters = [filter], SessionToken = token }))
{
hasObject = true;
var objHeader = await client.GetObjectHeadAsync(new PrmGetObjectHead(containerId, objectId) { SessionToken = token });
var objHeader = await client.GetObjectHeadAsync(new PrmObjectHeadGet(containerId, objectId) { SessionToken = token });
Assert.Equal((ulong)bytes.Length, objHeader.PayloadLength);
Assert.Single(objHeader.Attributes);
Assert.Equal("fileName", objHeader.Attributes.First().Key);
@ -292,7 +292,7 @@ public class SmokeTests
Assert.True(hasObject);
var @object = await client.GetObjectAsync(new PrmGetObject(containerId, objectId) { SessionToken = token });
var @object = await client.GetObjectAsync(new PrmObjectGet(containerId, objectId) { SessionToken = token });
var downloadedBytes = new byte[@object.Header.PayloadLength];
MemoryStream ms = new(downloadedBytes);
@ -325,7 +325,7 @@ public class SmokeTests
await Cleanup(client);
var createContainerParam = new PrmCreateContainer(new ModelsV2.Container(BasicAcl.PublicRW, new PlacementPolicy(true, new Replica(1))))
var createContainerParam = new PrmContainerCreate(new ModelsV2.Container(BasicAcl.PublicRW, new PlacementPolicy(true, new Replica(1))))
{
WaitParams = lightWait
};
@ -338,13 +338,13 @@ public class SmokeTests
Interceptors = new([new MetricsInterceptor()])
};
var container = await client.GetContainerAsync(new PrmGetContainer(containerId, context));
var container = await client.GetContainerAsync(new PrmContainerGet(containerId, context));
Assert.NotNull(container);
byte[] bytes = GetRandomBytes(objectSize);
var param = new PrmPutObject
var param = new PrmObjectPut
{
Header = new ObjectHeader(
containerId: containerId,
@ -359,11 +359,11 @@ public class SmokeTests
var filter = new ObjectFilter(ObjectMatchType.Equals, "fileName", "test");
bool hasObject = false;
await foreach (var objId in client.SearchObjectsAsync(new PrmSearchObject(containerId, filter)))
await foreach (var objId in client.SearchObjectsAsync(new PrmObjectSearch(containerId, filter)))
{
hasObject = true;
var objHeader = await client.GetObjectHeadAsync(new PrmGetObjectHead(containerId, objectId));
var objHeader = await client.GetObjectHeadAsync(new PrmObjectHeadGet(containerId, objectId));
Assert.Equal((ulong)bytes.Length, objHeader.PayloadLength);
Assert.Single(objHeader.Attributes);
Assert.Equal("fileName", objHeader.Attributes.First().Key);
@ -372,7 +372,7 @@ public class SmokeTests
Assert.True(hasObject);
var @object = await client.GetObjectAsync(new PrmGetObject(containerId, objectId));
var @object = await client.GetObjectAsync(new PrmObjectGet(containerId, objectId));
var downloadedBytes = new byte[@object.Header.PayloadLength];
MemoryStream ms = new(downloadedBytes);
@ -425,7 +425,7 @@ public class SmokeTests
{
await foreach (var cid in client.ListContainersAsync())
{
await client.DeleteContainerAsync(new PrmDeleteContainer(cid) { WaitParams = lightWait });
await client.DeleteContainerAsync(new PrmContainerDelete(cid) { WaitParams = lightWait });
}
}
}
@ -457,7 +457,8 @@ public class MetricsInterceptor() : Interceptor
watch.Stop();
var elapsed = watch.ElapsedTicks * 1_000_000/Stopwatch.Frequency;
// Do somethins with call info
// var elapsed = watch.ElapsedTicks * 1_000_000/Stopwatch.Frequency;
return response;
}