optimizations
This commit is contained in:
parent
1a02ac2ae7
commit
a74981dce8
95 changed files with 391 additions and 448 deletions
|
@ -1,6 +1,4 @@
|
|||
|
||||
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2
|
||||
{
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
using FrostFS.Container;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using FrostFS.Container;
|
||||
using FrostFS.Netmap;
|
||||
using FrostFS.Object;
|
||||
using FrostFS.SDK.ClientV2.Interfaces;
|
||||
using FrostFS.SDK.ClientV2.Parameters;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
using FrostFS.SDK.ModelsV2.Netmap;
|
||||
using FrostFS.Session;
|
||||
|
||||
using Grpc.Core;
|
||||
using Grpc.Core.Interceptors;
|
||||
using Grpc.Net.Client;
|
||||
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Version = FrostFS.SDK.ModelsV2.Version;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class Client : IFrostFSClient
|
|||
key: ecdsaKey,
|
||||
owner: OwnerId.FromKey(ecdsaKey),
|
||||
channel: InitGrpcChannel(settings.Value.Host, channelOptions),
|
||||
version: new Version(2, 13));
|
||||
version: new FrostFsVersion(2, 13));
|
||||
|
||||
ContainerServiceClient = containerService;
|
||||
NetmapServiceClient = netmapService;
|
||||
|
@ -98,7 +98,7 @@ public class Client : IFrostFSClient
|
|||
key: null,
|
||||
owner: null,
|
||||
channel: channel,
|
||||
version: new Version(2, 13));
|
||||
version: new FrostFsVersion(2, 13));
|
||||
|
||||
// TODO: define timeout logic
|
||||
// CheckFrostFsVersionSupport(new Context { Timeout = TimeSpan.FromSeconds(20) });
|
||||
|
@ -119,7 +119,7 @@ public class Client : IFrostFSClient
|
|||
key: ecdsaKey,
|
||||
owner: OwnerId.FromKey(ecdsaKey),
|
||||
channel: channel,
|
||||
version: new Version(2, 13));
|
||||
version: new FrostFsVersion(2, 13));
|
||||
|
||||
// TODO: define timeout logic
|
||||
CheckFrostFsVersionSupport(new Context { Timeout = TimeSpan.FromSeconds(20)});
|
||||
|
@ -135,13 +135,13 @@ public class Client : IFrostFSClient
|
|||
{
|
||||
if (disposing && !isDisposed)
|
||||
{
|
||||
ClientCtx.Dispose();
|
||||
ClientCtx?.Dispose();
|
||||
isDisposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
#region ContainerImplementation
|
||||
public Task<ModelsV2.Container> GetContainerAsync(PrmContainerGet args)
|
||||
public Task<FrostFsContainer> GetContainerAsync(PrmContainerGet args)
|
||||
{
|
||||
var service = GetContainerService(args);
|
||||
return service.GetContainerAsync(args);
|
||||
|
@ -175,7 +175,7 @@ public class Client : IFrostFSClient
|
|||
return service.GetNetmapSnapshotAsync(args);
|
||||
}
|
||||
|
||||
public Task<ModelsV2.Netmap.NodeInfo> GetNodeInfoAsync(PrmNodeInfo? args)
|
||||
public Task<FrostFsNodeInfo> GetNodeInfoAsync(PrmNodeInfo? args)
|
||||
{
|
||||
args ??= new PrmNodeInfo();
|
||||
var service = GetNetmapService(args);
|
||||
|
@ -229,12 +229,12 @@ public class Client : IFrostFSClient
|
|||
#endregion
|
||||
|
||||
#region SessionImplementation
|
||||
public async Task<ModelsV2.SessionToken> CreateSessionAsync(PrmSessionCreate args)
|
||||
public async Task<FrostFsSessionToken> CreateSessionAsync(PrmSessionCreate args)
|
||||
{
|
||||
var session = await CreateSessionInternalAsync(args);
|
||||
var token = session.Serialize();
|
||||
|
||||
return new ModelsV2.SessionToken(token);
|
||||
return new FrostFsSessionToken(token);
|
||||
}
|
||||
|
||||
internal Task<Session.SessionToken> CreateSessionInternalAsync(PrmSessionCreate args)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
using FrostFS.SDK.Cryptography;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
using FrostFS.SDK.Cryptography;
|
||||
|
||||
using Google.Protobuf;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2
|
||||
{
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
using FrostFS.SDK.ModelsV2;
|
||||
using System;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
||||
public class ResponseException(ResponseStatus status) : Exception()
|
||||
public class ResponseException(FrostFsResponseStatus status) : Exception()
|
||||
{
|
||||
public ResponseStatus Status { get; set; } = status;
|
||||
public FrostFsResponseStatus Status { get; set; } = status;
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
|
||||
using Grpc.Core;
|
||||
using Grpc.Core.Interceptors;
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using FrostFS.SDK.ClientV2.Parameters;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
using FrostFS.SDK.ModelsV2.Netmap;
|
||||
namespace FrostFS.SDK.ClientV2.Interfaces;
|
||||
|
||||
public interface IFrostFSClient : IDisposable
|
||||
|
@ -11,17 +10,17 @@ public interface IFrostFSClient : IDisposable
|
|||
#region Network
|
||||
Task<NetmapSnapshot> GetNetmapSnapshotAsync(PrmNetmapSnapshot? args = null);
|
||||
|
||||
Task<NodeInfo> GetNodeInfoAsync(PrmNodeInfo? args = null);
|
||||
Task<FrostFsNodeInfo> GetNodeInfoAsync(PrmNodeInfo? args = null);
|
||||
|
||||
Task<NetworkSettings> GetNetworkSettingsAsync(PrmNetworkSettings? args = null);
|
||||
#endregion
|
||||
|
||||
#region Session
|
||||
Task<SessionToken> CreateSessionAsync(PrmSessionCreate args);
|
||||
Task<FrostFsSessionToken> CreateSessionAsync(PrmSessionCreate args);
|
||||
#endregion
|
||||
|
||||
#region Container
|
||||
Task<ModelsV2.Container> GetContainerAsync(PrmContainerGet args);
|
||||
Task<FrostFsContainer> GetContainerAsync(PrmContainerGet args);
|
||||
|
||||
IAsyncEnumerable<ContainerId> ListContainersAsync(PrmContainerGetAll? args = null);
|
||||
|
||||
|
@ -35,7 +34,7 @@ public interface IFrostFSClient : IDisposable
|
|||
|
||||
Task<FrostFsObject> GetObjectAsync(PrmObjectGet args);
|
||||
|
||||
Task<ObjectId> PutObjectAsync(PrmObjectPut putObjectParameters);
|
||||
Task<ObjectId> PutObjectAsync(PrmObjectPut args);
|
||||
|
||||
Task<ObjectId> PutSingleObjectAsync(PrmSingleObjectPut args);
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
using System;
|
||||
|
||||
using Google.Protobuf;
|
||||
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using FrostFS.SDK.ModelsV2.Enums;
|
||||
|
||||
using Google.Protobuf;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
|
||||
public static class ContainerMapper
|
||||
{
|
||||
public static Container.Container ToMessage(this ModelsV2.Container container)
|
||||
public static Container.Container ToMessage(this FrostFsContainer container)
|
||||
{
|
||||
return new Container.Container
|
||||
{
|
||||
|
@ -20,14 +19,14 @@ public static class ContainerMapper
|
|||
};
|
||||
}
|
||||
|
||||
public static ModelsV2.Container ToModel(this Container.Container container)
|
||||
public static FrostFsContainer ToModel(this Container.Container container)
|
||||
{
|
||||
if (!Enum.IsDefined(typeof(BasicAcl),(int)container.BasicAcl))
|
||||
throw new ArgumentException($"Unknown BasicACL rule. Value: '{container.BasicAcl}'.");
|
||||
|
||||
BasicAcl acl = (BasicAcl)container.BasicAcl;
|
||||
|
||||
return new ModelsV2.Container(acl, container.PlacementPolicy.ToModel())
|
||||
return new FrostFsContainer(acl, container.PlacementPolicy.ToModel())
|
||||
{
|
||||
Nonce = container.Nonce.ToUuid(),
|
||||
Version = container.Version.ToModel()
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
using System;
|
||||
|
||||
using FrostFS.Refs;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
|
||||
using Google.Protobuf;
|
||||
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using System;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using FrostFS.SDK.ModelsV2;
|
||||
using FrostFS.Session;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System.Linq;
|
||||
|
||||
using FrostFS.Netmap;
|
||||
using FrostFS.SDK.ModelsV2.Netmap;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap;
|
||||
|
||||
|
|
|
@ -1,30 +1,29 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
using FrostFS.Netmap;
|
||||
using FrostFS.SDK.ModelsV2.Enums;
|
||||
using NodeInfo = FrostFS.SDK.ModelsV2.Netmap.NodeInfo;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap;
|
||||
|
||||
public static class NodeInfoMapper
|
||||
{
|
||||
public static NodeInfo ToModel(this LocalNodeInfoResponse.Types.Body node)
|
||||
public static FrostFsNodeInfo ToModel(this LocalNodeInfoResponse.Types.Body node)
|
||||
{
|
||||
return node.NodeInfo.ToModel(node.Version);
|
||||
}
|
||||
|
||||
public static NodeInfo ToModel(this FrostFS.Netmap.NodeInfo nodeInfo, Refs.Version version)
|
||||
public static FrostFsNodeInfo ToModel(this NodeInfo nodeInfo, Refs.Version version)
|
||||
{
|
||||
NodeState state = nodeInfo.State switch
|
||||
{
|
||||
FrostFS.Netmap.NodeInfo.Types.State.Unspecified => NodeState.Unspecified,
|
||||
FrostFS.Netmap.NodeInfo.Types.State.Online => NodeState.Online,
|
||||
FrostFS.Netmap.NodeInfo.Types.State.Offline => NodeState.Offline,
|
||||
FrostFS.Netmap.NodeInfo.Types.State.Maintenance => NodeState.Maintenance,
|
||||
NodeInfo.Types.State.Unspecified => NodeState.Unspecified,
|
||||
NodeInfo.Types.State.Online => NodeState.Online,
|
||||
NodeInfo.Types.State.Offline => NodeState.Offline,
|
||||
NodeInfo.Types.State.Maintenance => NodeState.Maintenance,
|
||||
_ => throw new ArgumentException($"Unknown NodeState. Value: '{nodeInfo.State}'.")
|
||||
};
|
||||
|
||||
return new NodeInfo(
|
||||
return new FrostFsNodeInfo(
|
||||
version: version.ToModel(),
|
||||
state: state,
|
||||
addresses: [.. nodeInfo.Addresses],
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
using System.Linq;
|
||||
|
||||
using FrostFS.Netmap;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap;
|
||||
|
||||
public static class PlacementPolicyMapper
|
||||
{
|
||||
public static PlacementPolicy ToMessage(this ModelsV2.Netmap.PlacementPolicy placementPolicy)
|
||||
public static PlacementPolicy ToMessage(this FrostFsPlacementPolicy placementPolicy)
|
||||
{
|
||||
var pp = new PlacementPolicy
|
||||
{
|
||||
|
@ -23,9 +24,9 @@ public static class PlacementPolicyMapper
|
|||
return pp;
|
||||
}
|
||||
|
||||
public static ModelsV2.Netmap.PlacementPolicy ToModel(this PlacementPolicy placementPolicy)
|
||||
public static FrostFsPlacementPolicy ToModel(this PlacementPolicy placementPolicy)
|
||||
{
|
||||
return new ModelsV2.Netmap.PlacementPolicy(
|
||||
return new FrostFsPlacementPolicy(
|
||||
placementPolicy.Unique,
|
||||
placementPolicy.Replicas.Select(replica => replica.ToModel()).ToArray()
|
||||
);
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap;
|
|||
|
||||
public static class ReplicaMapper
|
||||
{
|
||||
public static Replica ToMessage(this ModelsV2.Netmap.Replica replica)
|
||||
public static Replica ToMessage(this FrostFsReplica replica)
|
||||
{
|
||||
return new Replica
|
||||
{
|
||||
|
@ -13,8 +13,8 @@ public static class ReplicaMapper
|
|||
};
|
||||
}
|
||||
|
||||
public static ModelsV2.Netmap.Replica ToModel(this Replica replica)
|
||||
public static FrostFsReplica ToModel(this Replica replica)
|
||||
{
|
||||
return new ModelsV2.Netmap.Replica((int)replica.Count, replica.Selector);
|
||||
return new FrostFsReplica((int)replica.Count, replica.Selector);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,3 @@
|
|||
using FrostFS.SDK.ModelsV2;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
|
||||
internal static class ObjectMapper
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using FrostFS.Object;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
|
||||
using FrostFS.Object;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
using MatchType = FrostFS.Object.MatchType;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
|
||||
|
@ -11,11 +10,11 @@ public static class ObjectFilterMapper
|
|||
{
|
||||
var objMatchTypeName = filter.MatchType switch
|
||||
{
|
||||
ModelsV2.Enums.ObjectMatchType.Unspecified => MatchType.Unspecified,
|
||||
ModelsV2.Enums.ObjectMatchType.Equals => MatchType.StringEqual,
|
||||
ModelsV2.Enums.ObjectMatchType.NotEquals => MatchType.StringNotEqual,
|
||||
ModelsV2.Enums.ObjectMatchType.KeyAbsent => MatchType.NotPresent,
|
||||
ModelsV2.Enums.ObjectMatchType.StartsWith => MatchType.CommonPrefix,
|
||||
FrostFsObjectMatchType.Unspecified => MatchType.Unspecified,
|
||||
FrostFsObjectMatchType.Equals => MatchType.StringEqual,
|
||||
FrostFsObjectMatchType.NotEquals => MatchType.StringNotEqual,
|
||||
FrostFsObjectMatchType.KeyAbsent => MatchType.NotPresent,
|
||||
FrostFsObjectMatchType.StartsWith => MatchType.CommonPrefix,
|
||||
|
||||
_ => throw new ArgumentException($"Unknown MatchType. Value: '{filter.MatchType}'.")
|
||||
};
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
using FrostFS.Object;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
using Google.Protobuf;
|
||||
using ObjectType = FrostFS.Object.ObjectType;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
|
||||
|
@ -14,9 +12,9 @@ public static class ObjectHeaderMapper
|
|||
{
|
||||
var objTypeName = header.ObjectType switch
|
||||
{
|
||||
ModelsV2.Enums.ObjectType.Regular => ObjectType.Regular,
|
||||
ModelsV2.Enums.ObjectType.Lock => ObjectType.Lock,
|
||||
ModelsV2.Enums.ObjectType.Tombstone => ObjectType.Tombstone,
|
||||
FrostFsObjectType.Regular => ObjectType.Regular,
|
||||
FrostFsObjectType.Lock => ObjectType.Lock,
|
||||
FrostFsObjectType.Tombstone => ObjectType.Tombstone,
|
||||
_ => throw new ArgumentException($"Unknown ObjectType. Value: '{header.ObjectType}'.")
|
||||
};
|
||||
|
||||
|
@ -39,7 +37,7 @@ public static class ObjectHeaderMapper
|
|||
{
|
||||
head.Split = new Header.Types.Split
|
||||
{
|
||||
SplitId = split.SplitId != null ? ByteString.CopyFrom(split.SplitId.ToBinary()) : null
|
||||
SplitId = split!.SplitId != null ? split.SplitId.GetMessage() : null
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -50,9 +48,9 @@ public static class ObjectHeaderMapper
|
|||
{
|
||||
var objTypeName = header.ObjectType switch
|
||||
{
|
||||
ObjectType.Regular => ModelsV2.Enums.ObjectType.Regular,
|
||||
ObjectType.Lock => ModelsV2.Enums.ObjectType.Lock,
|
||||
ObjectType.Tombstone => ModelsV2.Enums.ObjectType.Tombstone,
|
||||
ObjectType.Regular => FrostFsObjectType.Regular,
|
||||
ObjectType.Lock => FrostFsObjectType.Lock,
|
||||
ObjectType.Tombstone => FrostFsObjectType.Tombstone,
|
||||
_ => throw new ArgumentException($"Unknown ObjectType. Value: '{header.ObjectType}'.")
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using FrostFS.Refs;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
|
||||
using Google.Protobuf;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
using System;
|
||||
|
||||
using FrostFS.Refs;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
|
||||
using Google.Protobuf;
|
||||
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using System;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
using System;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
|
||||
using Google.Protobuf;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
|
||||
public static class SignatureMapper
|
||||
{
|
||||
public static Refs.Signature ToMessage(this Signature signature)
|
||||
public static Refs.Signature ToMessage(this FrostFsSignature signature)
|
||||
{
|
||||
var scheme = signature.Scheme switch
|
||||
{
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
using System;
|
||||
using FrostFS.SDK.ModelsV2.Enums;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
|
||||
public static class StatusMapper
|
||||
{
|
||||
public static ModelsV2.ResponseStatus ToModel(this Status.Status status)
|
||||
public static FrostFsResponseStatus ToModel(this Status.Status status)
|
||||
{
|
||||
if (status is null)
|
||||
return new ModelsV2.ResponseStatus(StatusCode.Success);
|
||||
return new FrostFsResponseStatus(FrostFsStatusCode.Success);
|
||||
|
||||
var codeName = Enum.GetName(typeof(FrostFsStatusCode), status.Code);
|
||||
|
||||
var codeName = Enum.GetName(typeof(StatusCode), status.Code);
|
||||
|
||||
return codeName is null
|
||||
? throw new ArgumentException($"Unknown StatusCode. Value: '{status.Code}'.")
|
||||
: new ModelsV2.ResponseStatus((StatusCode)Enum.Parse(typeof(StatusCode), codeName), status.Message);
|
||||
: new FrostFsResponseStatus((FrostFsStatusCode)status.Code, status.Message);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
using System.Collections;
|
||||
using System.Threading;
|
||||
using Version = FrostFS.Refs.Version;
|
||||
|
||||
using FrostFS.Refs;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
|
||||
|
@ -10,7 +11,7 @@ public static class VersionMapper
|
|||
private static readonly Hashtable _cacheModels = [];
|
||||
private static SpinLock _spinlock = new();
|
||||
|
||||
public static Version ToMessage(this ModelsV2.Version model)
|
||||
public static Version ToMessage(this FrostFsVersion model)
|
||||
{
|
||||
var key = model.Major << 16 + model.Minor;
|
||||
|
||||
|
@ -31,7 +32,7 @@ public static class VersionMapper
|
|||
}
|
||||
catch (System.ArgumentException)
|
||||
{
|
||||
// ignore attempt to add duplicate error.
|
||||
// ignore attempt to add duplicate
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -43,7 +44,7 @@ public static class VersionMapper
|
|||
return (Version)_cacheMessages[key];
|
||||
}
|
||||
|
||||
public static ModelsV2.Version ToModel(this Version message)
|
||||
public static FrostFsVersion ToModel(this Version message)
|
||||
{
|
||||
var key = (int)message.Major << 16 + (int)message.Minor;
|
||||
|
||||
|
@ -53,14 +54,14 @@ public static class VersionMapper
|
|||
try
|
||||
{
|
||||
_spinlock.Enter(ref lockTaken);
|
||||
var model = new ModelsV2.Version((int)message.Major, (int)message.Minor);
|
||||
var model = new FrostFsVersion((int)message.Major, (int)message.Minor);
|
||||
|
||||
_cacheModels.Add(key, model);
|
||||
return model;
|
||||
}
|
||||
catch (System.ArgumentException)
|
||||
{
|
||||
// ignore attempt to add duplicate error.
|
||||
// ignore attempt to add duplicate
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -69,6 +70,6 @@ public static class VersionMapper
|
|||
}
|
||||
}
|
||||
|
||||
return (ModelsV2.Version)_cacheModels[key];
|
||||
return (FrostFsVersion)_cacheModels[key];
|
||||
}
|
||||
}
|
|
@ -2,9 +2,11 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
|
||||
using FrostFS.SDK.Cryptography;
|
||||
|
||||
using Google.Protobuf;
|
||||
|
||||
using Grpc.Core.Interceptors;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
@ -13,13 +15,13 @@ public class Context()
|
|||
{
|
||||
private List<Interceptor>? interceptors;
|
||||
|
||||
private ByteString publicKeyCache;
|
||||
private ByteString? publicKeyCache;
|
||||
|
||||
public ECDsa Key { get; set; }
|
||||
|
||||
public OwnerId OwnerId { get; set; }
|
||||
|
||||
public ModelsV2.Version Version { get; set; }
|
||||
public FrostFsVersion Version { get; set; }
|
||||
|
||||
public CancellationToken CancellationToken { get; set; } = default;
|
||||
|
||||
|
@ -35,16 +37,13 @@ public class Context()
|
|||
set { this.interceptors = value; }
|
||||
}
|
||||
|
||||
public ByteString PublicKeyCache
|
||||
public ByteString? GetPublicKeyCache()
|
||||
{
|
||||
get
|
||||
if (publicKeyCache == null && Key != null)
|
||||
{
|
||||
if (publicKeyCache == null)
|
||||
{
|
||||
publicKeyCache = ByteString.CopyFrom(Key.PublicKey());
|
||||
}
|
||||
|
||||
return publicKeyCache;
|
||||
publicKeyCache = ByteString.CopyFrom(Key.PublicKey());
|
||||
}
|
||||
|
||||
return publicKeyCache;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using FrostFS.SDK.ModelsV2;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Parameters;
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
using FrostFS.SDK.ModelsV2;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Parameters;
|
||||
|
||||
public interface ISessionToken
|
||||
|
@ -10,5 +8,5 @@ public interface ISessionToken
|
|||
/// member. The session has a limited validity period, and applies to a strictly defined set of operations.
|
||||
/// </summary>
|
||||
/// <value>Instance of the session obtained from the server</value>
|
||||
SessionToken? SessionToken { get; set; }
|
||||
FrostFsSessionToken? SessionToken { get; set; }
|
||||
}
|
|
@ -1,11 +1,8 @@
|
|||
using FrostFS.SDK.ModelsV2;
|
||||
using System.Security.Cryptography;
|
||||
namespace FrostFS.SDK.ClientV2.Parameters;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Parameters;
|
||||
|
||||
public sealed class PrmContainerCreate(ModelsV2.Container container) : PrmBase, ISessionToken
|
||||
public sealed class PrmContainerCreate(FrostFsContainer container) : PrmBase, ISessionToken
|
||||
{
|
||||
public ModelsV2.Container Container { get; set; } = container;
|
||||
public FrostFsContainer Container { get; set; } = container;
|
||||
|
||||
/// <summary>
|
||||
/// Since the container becomes available with some delay, it needs to poll the container status
|
||||
|
@ -16,5 +13,5 @@ public sealed class PrmContainerCreate(ModelsV2.Container container) : PrmBase,
|
|||
/// <summary>
|
||||
/// Blank session token
|
||||
/// </summary>
|
||||
public SessionToken? SessionToken { get; set; }
|
||||
public FrostFsSessionToken? SessionToken { get; set; }
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using FrostFS.SDK.ModelsV2;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Parameters;
|
||||
namespace FrostFS.SDK.ClientV2.Parameters;
|
||||
|
||||
public sealed class PrmContainerDelete(ContainerId containerId) : PrmBase, ISessionToken
|
||||
{
|
||||
|
@ -12,5 +10,5 @@ public sealed class PrmContainerDelete(ContainerId containerId) : PrmBase, ISess
|
|||
/// <value>Rules for polling the result</value>
|
||||
public PrmWait? WaitParams { get; set; }
|
||||
|
||||
public SessionToken? SessionToken { get; set; }
|
||||
public FrostFsSessionToken? SessionToken { get; set; }
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using FrostFS.SDK.ModelsV2;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Parameters;
|
||||
namespace FrostFS.SDK.ClientV2.Parameters;
|
||||
|
||||
public sealed class PrmContainerGet(ContainerId containerId) : PrmBase
|
||||
{
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using FrostFS.SDK.ModelsV2;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Parameters;
|
||||
namespace FrostFS.SDK.ClientV2.Parameters;
|
||||
|
||||
public sealed class PrmObjectDelete(ContainerId containerId, ObjectId objectId) : PrmBase, ISessionToken
|
||||
{
|
||||
|
@ -9,5 +7,5 @@ public sealed class PrmObjectDelete(ContainerId containerId, ObjectId objectId)
|
|||
public ObjectId ObjectId { get; set; } = objectId;
|
||||
|
||||
/// <inheritdoc />
|
||||
public SessionToken? SessionToken { get; set; }
|
||||
public FrostFsSessionToken? SessionToken { get; set; }
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using FrostFS.SDK.ModelsV2;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Parameters;
|
||||
namespace FrostFS.SDK.ClientV2.Parameters;
|
||||
|
||||
public sealed class PrmObjectGet(ContainerId containerId, ObjectId objectId) : PrmBase, ISessionToken
|
||||
{
|
||||
|
@ -9,5 +7,5 @@ public sealed class PrmObjectGet(ContainerId containerId, ObjectId objectId) : P
|
|||
public ObjectId ObjectId { get; set; } = objectId;
|
||||
|
||||
/// <inheritdoc />
|
||||
public SessionToken? SessionToken { get; set; }
|
||||
public FrostFsSessionToken? SessionToken { get; set; }
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using FrostFS.SDK.ModelsV2;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Parameters;
|
||||
namespace FrostFS.SDK.ClientV2.Parameters;
|
||||
|
||||
public sealed class PrmObjectHeadGet(ContainerId containerId, ObjectId objectId) : PrmBase, ISessionToken
|
||||
{
|
||||
|
@ -9,5 +7,5 @@ public sealed class PrmObjectHeadGet(ContainerId containerId, ObjectId objectId)
|
|||
public ObjectId ObjectId { get; set; } = objectId;
|
||||
|
||||
/// <inheritdoc />
|
||||
public SessionToken? SessionToken { get; set; }
|
||||
public FrostFsSessionToken? SessionToken { get; set; }
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.IO;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Parameters;
|
||||
|
||||
|
@ -37,7 +36,7 @@ public sealed class PrmObjectPut : PrmBase, ISessionToken
|
|||
public byte[]? CustomBuffer { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public SessionToken? SessionToken { get; set; }
|
||||
public FrostFsSessionToken? SessionToken { get; set; }
|
||||
|
||||
internal int MaxObjectSizeCache { get; set; }
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using FrostFS.SDK.ModelsV2;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Parameters;
|
||||
|
||||
public sealed class PrmObjectSearch(ContainerId containerId, params IObjectFilter[] filters) : PrmBase, ISessionToken
|
||||
|
@ -17,5 +17,5 @@ public sealed class PrmObjectSearch(ContainerId containerId, params IObjectFilte
|
|||
public IEnumerable<IObjectFilter> Filters { get; set; } = filters;
|
||||
|
||||
/// <inheritdoc />
|
||||
public SessionToken? SessionToken { get; set; }
|
||||
public FrostFsSessionToken? SessionToken { get; set; }
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
using FrostFS.SDK.ModelsV2;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Parameters;
|
||||
namespace FrostFS.SDK.ClientV2.Parameters;
|
||||
|
||||
public sealed class PrmSingleObjectPut(FrostFsObject frostFsObject) : PrmBase, ISessionToken
|
||||
{
|
||||
public FrostFsObject FrostFsObject { get; set; } = frostFsObject;
|
||||
|
||||
/// <inheritdoc />
|
||||
public SessionToken? SessionToken { get; set; }
|
||||
public FrostFsSessionToken? SessionToken { get; set; }
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Parameters;
|
||||
|
||||
public class PrmWait(TimeSpan timeout, TimeSpan pollInterval)
|
||||
|
|
|
@ -7,7 +7,6 @@ using FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap;
|
|||
using FrostFS.Container;
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
using FrostFS.SDK.ClientV2.Parameters;
|
||||
using FrostFS.Refs;
|
||||
using FrostFS.Session;
|
||||
|
@ -23,7 +22,7 @@ internal class ContainerServiceProvider(ContainerService.ContainerServiceClient
|
|||
return await sessions.GetOrCreateSession(args, ctx);
|
||||
}
|
||||
|
||||
internal async Task<ModelsV2.Container> GetContainerAsync(PrmContainerGet args)
|
||||
internal async Task<FrostFsContainer> GetContainerAsync(PrmContainerGet args)
|
||||
{
|
||||
GetRequest request = GetContainerRequest(args.ContainerId.ToMessage(), args.XHeaders, args.Context!);
|
||||
|
||||
|
@ -40,9 +39,9 @@ internal class ContainerServiceProvider(ContainerService.ContainerServiceClient
|
|||
|
||||
var request = new ListRequest
|
||||
{
|
||||
Body = new ListRequest.Types.Body
|
||||
Body = new ()
|
||||
{
|
||||
OwnerId = ctx.OwnerId.ToMessage()
|
||||
OwnerId = ctx.OwnerId.ToMessage()
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -81,9 +80,7 @@ internal class ContainerServiceProvider(ContainerService.ContainerServiceClient
|
|||
null,
|
||||
ContainerSessionContext.Types.Verb.Put,
|
||||
ctx.Key,
|
||||
ctx.PublicKeyCache);
|
||||
|
||||
var v = sessionToken.Body.OwnerId == grpcContainer.OwnerId;
|
||||
ctx.GetPublicKeyCache());
|
||||
|
||||
request.AddMetaHeader(args.XHeaders, sessionToken);
|
||||
|
||||
|
@ -116,7 +113,7 @@ internal class ContainerServiceProvider(ContainerService.ContainerServiceClient
|
|||
request.Body.ContainerId,
|
||||
ContainerSessionContext.Types.Verb.Delete,
|
||||
ctx.Key,
|
||||
ctx.PublicKeyCache);
|
||||
ctx.GetPublicKeyCache());
|
||||
|
||||
request.AddMetaHeader(args.XHeaders, sessionToken);
|
||||
|
||||
|
@ -193,7 +190,7 @@ internal class ContainerServiceProvider(ContainerService.ContainerServiceClient
|
|||
if (DateTime.UtcNow >= deadLine)
|
||||
throw new TimeoutException();
|
||||
|
||||
if (ex.Status.Code != ModelsV2.Enums.StatusCode.ContainerNotFound)
|
||||
if (ex.Status.Code != FrostFsStatusCode.ContainerNotFound)
|
||||
throw;
|
||||
|
||||
if (expect == WaitExpects.Removed)
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using FrostFS.Netmap;
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap;
|
||||
using NodeInfo = FrostFS.SDK.ModelsV2.Netmap.NodeInfo;
|
||||
|
||||
using FrostFS.SDK.ModelsV2.Netmap;
|
||||
using static FrostFS.Netmap.NetworkConfig.Types;
|
||||
using FrostFS.SDK.ClientV2.Parameters;
|
||||
|
||||
using static FrostFS.Netmap.NetworkConfig.Types;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
||||
internal class NetmapServiceProvider : ContextAccessor
|
||||
|
@ -40,7 +39,7 @@ internal class NetmapServiceProvider : ContextAccessor
|
|||
return settings;
|
||||
}
|
||||
|
||||
internal async Task<NodeInfo> GetLocalNodeInfoAsync(PrmNodeInfo args)
|
||||
internal async Task<FrostFsNodeInfo> GetLocalNodeInfoAsync(PrmNodeInfo args)
|
||||
{
|
||||
var ctx = args.Context!;
|
||||
var request = new LocalNodeInfoRequest
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Google.Protobuf;
|
||||
|
||||
using FrostFS.Object;
|
||||
using FrostFS.Refs;
|
||||
using FrostFS.SDK.ClientV2.Extensions;
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
using FrostFS.SDK.ClientV2.Parameters;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using FrostFS.Session;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
using FrostFS.SDK.ClientV2.Extensions;
|
||||
using FrostFS.SDK.ClientV2.Parameters;
|
||||
using System.Buffers;
|
||||
|
||||
using Google.Protobuf;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
||||
|
@ -210,7 +209,7 @@ internal class ObjectServiceProvider(ObjectService.ObjectServiceClient client, C
|
|||
var ctx = args.Context!;
|
||||
|
||||
var tokenRaw = await GetOrCreateSession(args, ctx);
|
||||
var token = new ModelsV2.SessionToken(tokenRaw.Serialize());
|
||||
var token = new FrostFsSessionToken(tokenRaw.Serialize());
|
||||
|
||||
args.SessionToken = token;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
using FrostFS.SDK.ClientV2.Parameters;
|
||||
using FrostFS.Session;
|
||||
|
|
|
@ -4,5 +4,3 @@ internal class ContextAccessor(ClientEnvironment context)
|
|||
{
|
||||
protected ClientEnvironment Context { get; set; } = context;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using FrostFS.SDK.ClientV2.Parameters;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
using FrostFS.SDK.ModelsV2;
|
||||
using Grpc.Net.Client;
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Buffers;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
using Grpc.Net.Client;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
||||
public class ClientEnvironment(Client client, ECDsa? key, OwnerId? owner, GrpcChannel channel, ModelsV2.Version version) : IDisposable
|
||||
public class ClientEnvironment(Client client, ECDsa? key, OwnerId? owner, GrpcChannel channel, FrostFsVersion version) : IDisposable
|
||||
{
|
||||
private ArrayPool<byte> _arrayPool;
|
||||
|
||||
|
@ -14,7 +14,7 @@ public class ClientEnvironment(Client client, ECDsa? key, OwnerId? owner, GrpcCh
|
|||
|
||||
internal GrpcChannel Channel { get; private set; } = channel;
|
||||
|
||||
internal ModelsV2.Version Version { get; } = version;
|
||||
internal FrostFsVersion Version { get; } = version;
|
||||
|
||||
internal NetworkSettings? NetworkSettings { get; set; }
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class ClientEnvironment(Client client, ECDsa? key, OwnerId? owner, GrpcCh
|
|||
{
|
||||
if (disposing)
|
||||
{
|
||||
Channel.Dispose();
|
||||
Channel?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Extensions;
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ using System.Threading.Tasks;
|
|||
using Grpc.Core;
|
||||
|
||||
using FrostFS.Object;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
using System.Threading;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
@ -33,7 +32,7 @@ public class ObjectReader(AsyncServerStreamingCall<GetResponse> call) : IObjectR
|
|||
};
|
||||
}
|
||||
|
||||
public async Task<byte[]?> ReadChunk(CancellationToken cancellationToken = default)
|
||||
public async Task<ReadOnlyMemory<byte>?> ReadChunk(CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (!await Call.ResponseStream.MoveNext(cancellationToken))
|
||||
return null;
|
||||
|
@ -44,14 +43,14 @@ public class ObjectReader(AsyncServerStreamingCall<GetResponse> call) : IObjectR
|
|||
if (response.Body.ObjectPartCase != GetResponse.Types.Body.ObjectPartOneofCase.Chunk)
|
||||
throw new InvalidOperationException("unexpected message type");
|
||||
|
||||
return response.Body.Chunk.ToByteArray();
|
||||
return response.Body.Chunk.Memory;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (!disposed)
|
||||
{
|
||||
Call.Dispose();
|
||||
Call?.Dispose();
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
disposed = true;
|
||||
|
|
|
@ -30,6 +30,6 @@ internal class ObjectStreamer(AsyncClientStreamingCall<PutRequest, PutResponse>
|
|||
|
||||
public void Dispose()
|
||||
{
|
||||
Call.Dispose();
|
||||
Call?.Dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ using FrostFS.Object;
|
|||
using FrostFS.Refs;
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
||||
|
@ -47,18 +46,21 @@ internal class ObjectTools
|
|||
|
||||
obj.Signature = new Refs.Signature
|
||||
{
|
||||
Key = ctx.PublicKeyCache,
|
||||
Key = ctx.GetPublicKeyCache(),
|
||||
Sign = ByteString.CopyFrom(ctx.Key.SignData(obj.ObjectId.ToByteArray())),
|
||||
};
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
internal static void SetSplitValues(Header grpcHeader, ModelsV2.Split split, Context ctx)
|
||||
internal static void SetSplitValues(Header grpcHeader, Split split, Context ctx)
|
||||
{
|
||||
if (split == null)
|
||||
return;
|
||||
|
||||
grpcHeader.Split = new Header.Types.Split
|
||||
{
|
||||
SplitId = split.SplitId != null ? ByteString.CopyFrom(split.SplitId.ToBinary()) : null
|
||||
SplitId = split.SplitId?.GetMessage()
|
||||
};
|
||||
|
||||
if (split.Children != null && split.Children.Count != 0)
|
||||
|
@ -72,7 +74,7 @@ internal class ObjectTools
|
|||
grpcHeader.Split.ParentHeader = grpcParentHeader;
|
||||
grpcHeader.Split.ParentSignature = new Refs.Signature
|
||||
{
|
||||
Key = ctx.PublicKeyCache,
|
||||
Key = ctx.GetPublicKeyCache(),
|
||||
Sign = ByteString.CopyFrom(ctx.Key.SignData(grpcHeader.Split.Parent.ToByteArray())),
|
||||
};
|
||||
|
||||
|
|
|
@ -24,10 +24,8 @@ namespace System
|
|||
public Index(int value, bool fromEnd = false)
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(value), "value must be non-negative");
|
||||
}
|
||||
|
||||
|
||||
if (fromEnd)
|
||||
_value = ~value;
|
||||
else
|
||||
|
@ -52,10 +50,8 @@ namespace System
|
|||
public static Index FromStart(int value)
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(value), "value must be non-negative");
|
||||
}
|
||||
|
||||
|
||||
return new Index(value);
|
||||
}
|
||||
|
||||
|
@ -65,10 +61,8 @@ namespace System
|
|||
public static Index FromEnd(int value)
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(value), "value must be non-negative");
|
||||
}
|
||||
|
||||
|
||||
return new Index(~value);
|
||||
}
|
||||
|
||||
|
@ -77,14 +71,7 @@ namespace System
|
|||
{
|
||||
get
|
||||
{
|
||||
if (_value < 0)
|
||||
{
|
||||
return ~_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
return _value < 0 ? ~_value : _value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,6 +189,7 @@ namespace System
|
|||
{
|
||||
int start;
|
||||
var startIndex = Start;
|
||||
|
||||
if (startIndex.IsFromEnd)
|
||||
start = length - startIndex.Value;
|
||||
else
|
||||
|
@ -209,16 +197,15 @@ namespace System
|
|||
|
||||
int end;
|
||||
var endIndex = End;
|
||||
|
||||
if (endIndex.IsFromEnd)
|
||||
end = length - endIndex.Value;
|
||||
else
|
||||
end = endIndex.Value;
|
||||
|
||||
if ((uint)end > (uint)length || (uint)start > (uint)end)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(length));
|
||||
}
|
||||
|
||||
|
||||
return (start, end - start);
|
||||
}
|
||||
}
|
||||
|
@ -234,10 +221,8 @@ namespace System.Runtime.CompilerServices
|
|||
public static T[] GetSubArray<T>(T[] array, Range range)
|
||||
{
|
||||
if (array == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(array));
|
||||
}
|
||||
|
||||
|
||||
(int offset, int length) = range.GetOffsetAndLength(array.Length);
|
||||
|
||||
if (default(T) != null || typeof(T[]) == array.GetType())
|
||||
|
@ -245,10 +230,8 @@ namespace System.Runtime.CompilerServices
|
|||
// We know the type of the array to be exactly T[].
|
||||
|
||||
if (length == 0)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
var dest = new T[length];
|
||||
Array.Copy(array, offset, dest, 0, length);
|
||||
return dest;
|
||||
|
|
|
@ -5,7 +5,6 @@ using System.Security.Cryptography;
|
|||
using FrostFS.Refs;
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
using FrostFS.SDK.ProtosV2.Interfaces;
|
||||
using FrostFS.Session;
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
using System;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
using FrostFS.Refs;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using FrostFS.SDK.ProtosV2.Interfaces;
|
||||
using FrostFS.Session;
|
||||
|
||||
using Google.Protobuf;
|
||||
|
||||
using Org.BouncyCastle.Asn1.Sec;
|
||||
|
@ -9,11 +14,6 @@ using Org.BouncyCastle.Crypto.Parameters;
|
|||
using Org.BouncyCastle.Crypto.Signers;
|
||||
using Org.BouncyCastle.Math;
|
||||
|
||||
using FrostFS.Refs;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using FrostFS.Session;
|
||||
using FrostFS.SDK.ProtosV2.Interfaces;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
||||
public static class RequestSigner
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Grpc.Core;
|
||||
|
||||
using FrostFS.Object;
|
||||
using FrostFS.Refs;
|
||||
using System.Threading;
|
||||
|
||||
using Grpc.Core;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
||||
|
@ -29,6 +29,6 @@ internal class SearchReader(AsyncServerStreamingCall<SearchResponse> call) : IDi
|
|||
|
||||
public void Dispose()
|
||||
{
|
||||
Call.Dispose();
|
||||
Call?.Dispose();
|
||||
}
|
||||
}
|
|
@ -1,6 +1,12 @@
|
|||
using System;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
using FrostFS.Refs;
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using FrostFS.SDK.ProtosV2.Interfaces;
|
||||
using FrostFS.Session;
|
||||
|
||||
using Google.Protobuf;
|
||||
|
||||
using Org.BouncyCastle.Asn1.Sec;
|
||||
|
@ -9,12 +15,6 @@ using Org.BouncyCastle.Crypto.Parameters;
|
|||
using Org.BouncyCastle.Crypto.Signers;
|
||||
using Org.BouncyCastle.Math;
|
||||
|
||||
using FrostFS.Refs;
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using FrostFS.Session;
|
||||
using FrostFS.SDK.ProtosV2.Interfaces;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
||||
public static class Verifier
|
||||
|
|
|
@ -2,7 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace FrostFS.SDK.ModelsV2;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class ClientSettings
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ public class ClientSettings
|
|||
public virtual void Validate()
|
||||
{
|
||||
var errors = CheckFields();
|
||||
if (errors != null)
|
||||
if (errors != null)
|
||||
ThrowException(errors);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ public class ClientSettings
|
|||
}
|
||||
|
||||
protected static void ThrowException(List<string> errors)
|
||||
{
|
||||
{
|
||||
StringBuilder messages = new();
|
||||
|
||||
foreach (var error in errors)
|
||||
|
@ -48,7 +48,7 @@ public class SingleOwnerClientSettings : ClientSettings
|
|||
{
|
||||
var errors = CheckFields();
|
||||
if (errors != null)
|
||||
ThrowException(errors);
|
||||
ThrowException(errors);
|
||||
}
|
||||
|
||||
protected List<string>? CheckFields()
|
||||
|
@ -59,5 +59,5 @@ public class SingleOwnerClientSettings : ClientSettings
|
|||
(errors ??= []).Add(string.Format(errorTemplate, nameof(Key)));
|
||||
|
||||
return errors;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
using System;
|
||||
using FrostFS.SDK.ModelsV2.Enums;
|
||||
using FrostFS.SDK.ModelsV2.Netmap;
|
||||
|
||||
namespace FrostFS.SDK.ModelsV2;
|
||||
|
||||
public class Container(BasicAcl basicAcl, PlacementPolicy placementPolicy)
|
||||
{
|
||||
public Guid Nonce { get; set; } = Guid.NewGuid();
|
||||
public BasicAcl BasicAcl { get; set; } = basicAcl;
|
||||
public PlacementPolicy PlacementPolicy { get; set; } = placementPolicy;
|
||||
public Version? Version { get; set; }
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
namespace FrostFS.SDK.ModelsV2;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class ContainerId(string id)
|
||||
{
|
||||
|
|
11
src/FrostFS.SDK.ModelsV2/Containers/FrostFsContainer.cs
Normal file
11
src/FrostFS.SDK.ModelsV2/Containers/FrostFsContainer.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class FrostFsContainer(BasicAcl basicAcl, FrostFsPlacementPolicy placementPolicy)
|
||||
{
|
||||
public Guid Nonce { get; set; } = Guid.NewGuid();
|
||||
public BasicAcl BasicAcl { get; set; } = basicAcl;
|
||||
public FrostFsPlacementPolicy PlacementPolicy { get; set; } = placementPolicy;
|
||||
public FrostFsVersion? Version { get; set; }
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
using System.ComponentModel;
|
||||
|
||||
namespace FrostFS.SDK.ModelsV2.Enums;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public enum BasicAcl
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
namespace FrostFS.SDK.ModelsV2.Enums;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public enum ObjectMatchType
|
||||
public enum FrostFsObjectMatchType
|
||||
{
|
||||
Unspecified = 0,
|
||||
Equals = 1,
|
8
src/FrostFS.SDK.ModelsV2/Enums/FrostFsObjectType.cs
Normal file
8
src/FrostFS.SDK.ModelsV2/Enums/FrostFsObjectType.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
namespace FrostFS.SDK;
|
||||
|
||||
public enum FrostFsObjectType
|
||||
{
|
||||
Regular = 0,
|
||||
Tombstone = 1,
|
||||
Lock = 3
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
namespace FrostFS.SDK.ModelsV2.Enums;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public enum StatusCode
|
||||
public enum FrostFsStatusCode
|
||||
{
|
||||
Success = 0,
|
||||
Internal = 1024,
|
|
@ -1,4 +1,4 @@
|
|||
namespace FrostFS.SDK.ModelsV2.Enums;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public enum NodeState
|
||||
{
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
namespace FrostFS.SDK.ModelsV2.Enums;
|
||||
|
||||
public enum ObjectType
|
||||
{
|
||||
Regular = 0,
|
||||
Tombstone = 1,
|
||||
Lock = 3
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
namespace FrostFS.SDK.ModelsV2;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public enum SignatureScheme {
|
||||
public enum SignatureScheme
|
||||
{
|
||||
EcdsaSha512,
|
||||
EcdsaRfc6979Sha256,
|
||||
EcdsaRfc6979Sha256WalletConnect
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
namespace FrostFS.SDK.ModelsV2;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class CallStatistics
|
||||
{
|
||||
{
|
||||
public string? MethodName { get; set; }
|
||||
public long ElapsedMicroSeconds { get; set; }
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using FrostFS.SDK.Cryptography;
|
||||
using System;
|
||||
|
||||
namespace FrostFS.SDK.ModelsV2;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class CheckSum
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace FrostFS.SDK.ModelsV2;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class Constants
|
||||
{
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FrostFS.SDK.ModelsV2.Enums;
|
||||
|
||||
namespace FrostFS.SDK.ModelsV2.Netmap;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class NodeInfo(
|
||||
Version version,
|
||||
public class FrostFsNodeInfo(
|
||||
FrostFsVersion version,
|
||||
NodeState state,
|
||||
IReadOnlyCollection<string> addresses,
|
||||
IReadOnlyDictionary<string, string> attributes,
|
||||
ReadOnlyMemory<byte> publicKey)
|
||||
{
|
||||
public NodeState State { get; private set; } = state;
|
||||
public Version Version { get; private set; } = version;
|
||||
public FrostFsVersion 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;
|
|
@ -1,16 +1,16 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace FrostFS.SDK.ModelsV2.Netmap;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class PlacementPolicy(bool unique, params Replica[] replicas) : IComparable<PlacementPolicy>
|
||||
public class FrostFsPlacementPolicy(bool unique, params FrostFsReplica[] replicas) : IComparable<FrostFsPlacementPolicy>
|
||||
{
|
||||
public Replica[] Replicas { get; private set; } = replicas;
|
||||
public FrostFsReplica[] Replicas { get; private set; } = replicas;
|
||||
public bool Unique { get; private set; } = unique;
|
||||
|
||||
public int CompareTo(PlacementPolicy other)
|
||||
public int CompareTo(FrostFsPlacementPolicy other)
|
||||
{
|
||||
var notEqual = other == null
|
||||
var notEqual = other == null
|
||||
|| Unique != other.Unique
|
||||
|| Replicas.Length != other.Replicas.Length;
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
namespace FrostFS.SDK.ModelsV2.Netmap;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class Replica
|
||||
public class FrostFsReplica
|
||||
{
|
||||
public int Count { get; set; }
|
||||
public string Selector { get; set; }
|
||||
|
||||
public Replica(int count, string? selector = null)
|
||||
public FrostFsReplica(int count, string? selector = null)
|
||||
{
|
||||
selector ??= string.Empty;
|
||||
|
||||
|
||||
Count = count;
|
||||
Selector = selector;
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
namespace FrostFS.SDK.ModelsV2;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class Version(int major, int minor)
|
||||
public class FrostFsVersion(int major, int minor)
|
||||
{
|
||||
public int Major { get; set; } = major;
|
||||
public int Minor { get; set; } = minor;
|
||||
|
||||
public bool IsSupported(Version version)
|
||||
public bool IsSupported(FrostFsVersion version)
|
||||
{
|
||||
return Major == version.Major;
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace FrostFS.SDK.ModelsV2.Netmap;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class NetmapSnapshot(ulong epoch, IReadOnlyList<NodeInfo> nodeInfoCollection)
|
||||
public class NetmapSnapshot(ulong epoch, IReadOnlyList<FrostFsNodeInfo> nodeInfoCollection)
|
||||
{
|
||||
public ulong Epoch { get; private set; } = epoch;
|
||||
|
||||
public IReadOnlyList<NodeInfo> NodeInfoCollection { get; private set; } = nodeInfoCollection;
|
||||
public IReadOnlyList<FrostFsNodeInfo> NodeInfoCollection { get; private set; } = nodeInfoCollection;
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using FrostFS.SDK.ModelsV2.Enums;
|
||||
|
||||
namespace FrostFS.SDK.ModelsV2;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class FrostFsObject
|
||||
{
|
||||
|
@ -11,7 +10,7 @@ public class FrostFsObject
|
|||
/// <param name="header"></param> <summary>
|
||||
public FrostFsObject(ObjectHeader header)
|
||||
{
|
||||
Header = header;
|
||||
Header = header;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -19,17 +18,17 @@ public class FrostFsObject
|
|||
/// </summary>
|
||||
/// <param name="container"></param>
|
||||
/// <param name="objectType"></param>
|
||||
public FrostFsObject(ContainerId container, ObjectType objectType = ObjectType.Regular)
|
||||
public FrostFsObject(ContainerId container, FrostFsObjectType objectType = FrostFsObjectType.Regular)
|
||||
{
|
||||
Header = new ObjectHeader(containerId: container, type: objectType);
|
||||
Header = new ObjectHeader(containerId: container, type: objectType);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Header contains metadata for the object
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public ObjectHeader Header { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The value is calculated internally as a hash of ObjectHeader. Do not use pre-calculated value is the object has been changed.
|
||||
/// </summary>
|
||||
|
@ -50,7 +49,7 @@ public class FrostFsObject
|
|||
/// </summary>
|
||||
/// <value>Reader for received data</value>
|
||||
public IObjectReader? ObjectReader { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Applied only for the last Object in chain in case of manual multipart uploading
|
||||
/// </summary>
|
||||
|
@ -74,11 +73,11 @@ public class LargeObject(ContainerId container) : FrostFsObject(container)
|
|||
|
||||
public class LinkObject : FrostFsObject
|
||||
{
|
||||
public LinkObject(ContainerId containerId, SplitId splitId, ObjectHeader largeObjectHeader) : base (containerId)
|
||||
public LinkObject(ContainerId containerId, SplitId splitId, ObjectHeader largeObjectHeader) : base(containerId)
|
||||
{
|
||||
Header!.Split = new Split(splitId)
|
||||
{
|
||||
ParentHeader = largeObjectHeader
|
||||
ParentHeader = largeObjectHeader
|
||||
};
|
||||
}
|
||||
}
|
|
@ -2,9 +2,9 @@ using System;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FrostFS.SDK.ModelsV2;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public interface IObjectReader : IDisposable
|
||||
{
|
||||
Task<byte[]?> ReadChunk(CancellationToken cancellationToken = default);
|
||||
Task<ReadOnlyMemory<byte>?> ReadChunk(CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace FrostFS.SDK.ModelsV2;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class ObjectAttribute(string key, string value)
|
||||
{
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
using FrostFS.SDK.ModelsV2.Enums;
|
||||
|
||||
namespace FrostFS.SDK.ModelsV2;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public interface IObjectFilter
|
||||
{
|
||||
public ObjectMatchType MatchType { get; set; }
|
||||
public FrostFsObjectMatchType MatchType { get; set; }
|
||||
public string Key { get; set; }
|
||||
|
||||
|
||||
string? GetSerializedValue();
|
||||
}
|
||||
|
||||
public abstract class ObjectFilter<T>(ObjectMatchType matchType, string key, T value) : IObjectFilter
|
||||
public abstract class ObjectFilter<T>(FrostFsObjectMatchType matchType, string key, T value) : IObjectFilter
|
||||
{
|
||||
public ObjectMatchType MatchType { get; set; } = matchType;
|
||||
public FrostFsObjectMatchType MatchType { get; set; } = matchType;
|
||||
public string Key { get; set; } = key;
|
||||
|
||||
public T Value { get; set; } = value;
|
||||
|
@ -29,85 +27,85 @@ public abstract class ObjectFilter<T>(ObjectMatchType matchType, string key, T v
|
|||
/// <param name="matchType">Match type</param>
|
||||
/// <param name="key">Attribute key</param>
|
||||
/// <param name="value">Attribute value</param>
|
||||
public class FilterByAttribute(ObjectMatchType matchType, string key, string value) : ObjectFilter<string>(matchType, key, value) { }
|
||||
public class FilterByAttribute(FrostFsObjectMatchType matchType, string key, string value) : ObjectFilter<string>(matchType, key, value) { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates filter to search by ObjectId
|
||||
/// </summary>
|
||||
/// <param name="matchType">Match type</param>
|
||||
/// <param name="objectId">ObjectId</param>
|
||||
public class FilterByObjectId(ObjectMatchType matchType, ObjectId objectId) : ObjectFilter<ObjectId>(matchType, Constants.FilterHeaderObjectID, objectId) { }
|
||||
public class FilterByObjectId(FrostFsObjectMatchType matchType, ObjectId objectId) : ObjectFilter<ObjectId>(matchType, Constants.FilterHeaderObjectID, objectId) { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates filter to search by OwnerId
|
||||
/// </summary>
|
||||
/// <param name="matchType">Match type</param>
|
||||
/// <param name="ownerId">ObjectId</param>
|
||||
public class FilterByOwnerId(ObjectMatchType matchType, OwnerId ownerId) : ObjectFilter<OwnerId>(matchType, Constants.FilterHeaderOwnerID, ownerId) {}
|
||||
public class FilterByOwnerId(FrostFsObjectMatchType matchType, OwnerId ownerId) : ObjectFilter<OwnerId>(matchType, Constants.FilterHeaderOwnerID, ownerId) { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates filter to search by Version
|
||||
/// </summary>
|
||||
/// <param name="matchType">Match type</param>
|
||||
/// <param name="version">Version</param>
|
||||
public class FilterByVersion(ObjectMatchType matchType, Version version) : ObjectFilter<Version>(matchType, Constants.FilterHeaderVersion, version) {}
|
||||
public class FilterByVersion(FrostFsObjectMatchType matchType, FrostFsVersion version) : ObjectFilter<FrostFsVersion>(matchType, Constants.FilterHeaderVersion, version) { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates filter to search by ContainerId
|
||||
/// </summary>
|
||||
/// <param name="matchType">Match type</param>
|
||||
/// <param name="containerId">ContainerId</param>
|
||||
public class FilterByContainerId(ObjectMatchType matchType, ContainerId containerId) : ObjectFilter<ContainerId>(matchType, Constants.FilterHeaderContainerID, containerId) {}
|
||||
public class FilterByContainerId(FrostFsObjectMatchType matchType, ContainerId containerId) : ObjectFilter<ContainerId>(matchType, Constants.FilterHeaderContainerID, containerId) { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates filter to search by creation Epoch
|
||||
/// </summary>
|
||||
/// <param name="matchType">Match type</param>
|
||||
/// <param name="epoch">Creation Epoch</param>
|
||||
public class FilterByEpoch(ObjectMatchType matchType, ulong epoch) : ObjectFilter<ulong>(matchType, Constants.FilterHeaderCreationEpoch, epoch) {}
|
||||
public class FilterByEpoch(FrostFsObjectMatchType matchType, ulong epoch) : ObjectFilter<ulong>(matchType, Constants.FilterHeaderCreationEpoch, epoch) { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates filter to search by Payload Length
|
||||
/// </summary>
|
||||
/// <param name="matchType">Match type</param>
|
||||
/// <param name="payloadLength">Payload Length</param>
|
||||
public class FilterByPayloadLength(ObjectMatchType matchType, ulong payloadLength) : ObjectFilter<ulong>(matchType, Constants.FilterHeaderPayloadLength, payloadLength) {}
|
||||
public class FilterByPayloadLength(FrostFsObjectMatchType matchType, ulong payloadLength) : ObjectFilter<ulong>(matchType, Constants.FilterHeaderPayloadLength, payloadLength) { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates filter to search by Payload Hash
|
||||
/// </summary>
|
||||
/// <param name="matchType">Match type</param>
|
||||
/// <param name="payloadHash">Payload Hash</param>
|
||||
public class FilterByPayloadHash(ObjectMatchType matchType, CheckSum payloadHash) : ObjectFilter<CheckSum>(matchType, Constants.FilterHeaderPayloadHash, payloadHash) {}
|
||||
public class FilterByPayloadHash(FrostFsObjectMatchType matchType, CheckSum payloadHash) : ObjectFilter<CheckSum>(matchType, Constants.FilterHeaderPayloadHash, payloadHash) { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates filter to search by Parent
|
||||
/// </summary>
|
||||
/// <param name="matchType">Match type</param>
|
||||
/// <param name="parentId">Parent</param>
|
||||
public class FilterByParent(ObjectMatchType matchType, ObjectId parentId) : ObjectFilter<ObjectId>(matchType, Constants.FilterHeaderParent, parentId) {}
|
||||
public class FilterByParent(FrostFsObjectMatchType matchType, ObjectId parentId) : ObjectFilter<ObjectId>(matchType, Constants.FilterHeaderParent, parentId) { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates filter to search by SplitId
|
||||
/// </summary>
|
||||
/// <param name="matchType">Match type</param>
|
||||
/// <param name="splitId">SplitId</param>
|
||||
public class FilterBySplitId(ObjectMatchType matchType, SplitId splitId) : ObjectFilter<SplitId>(matchType, Constants.FilterHeaderSplitID, splitId) {}
|
||||
public class FilterBySplitId(FrostFsObjectMatchType matchType, SplitId splitId) : ObjectFilter<SplitId>(matchType, Constants.FilterHeaderSplitID, splitId) { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates filter to search by Payload Hash
|
||||
/// </summary>
|
||||
/// <param name="matchType">Match type</param>
|
||||
/// <param name="ecParentId">Payload Hash</param>
|
||||
public class FilterByECParent(ObjectMatchType matchType, ObjectId ecParentId) : ObjectFilter<ObjectId>(matchType, Constants.FilterHeaderECParent, ecParentId) {}
|
||||
public class FilterByECParent(FrostFsObjectMatchType matchType, ObjectId ecParentId) : ObjectFilter<ObjectId>(matchType, Constants.FilterHeaderECParent, ecParentId) { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates filter to search Root objects
|
||||
/// </summary>
|
||||
public class FilterByRootObject() : ObjectFilter<string>(ObjectMatchType.Unspecified, Constants.FilterHeaderRoot, string.Empty) {}
|
||||
public class FilterByRootObject() : ObjectFilter<string>(FrostFsObjectMatchType.Unspecified, Constants.FilterHeaderRoot, string.Empty) { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates filter to search objects that are physically stored on the server
|
||||
/// </summary
|
||||
public class FilterByPhysicallyStored() : ObjectFilter<string>(ObjectMatchType.Unspecified, Constants.FilterHeaderPhy, string.Empty) {}
|
||||
public class FilterByPhysicallyStored() : ObjectFilter<string>(FrostFsObjectMatchType.Unspecified, Constants.FilterHeaderPhy, string.Empty) { }
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
using System.Collections.Generic;
|
||||
using FrostFS.SDK.ModelsV2.Enums;
|
||||
|
||||
namespace FrostFS.SDK.ModelsV2;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class ObjectHeader(
|
||||
ContainerId containerId,
|
||||
ObjectType type = ObjectType.Regular,
|
||||
FrostFsObjectType type = FrostFsObjectType.Regular,
|
||||
params ObjectAttribute[] attributes
|
||||
)
|
||||
{
|
||||
|
@ -19,9 +18,9 @@ public class ObjectHeader(
|
|||
|
||||
public byte[]? PayloadCheckSum { get; set; }
|
||||
|
||||
public ObjectType ObjectType { get; set; } = type;
|
||||
public FrostFsObjectType ObjectType { get; set; } = type;
|
||||
|
||||
public Version? Version { get; set; }
|
||||
public FrostFsVersion? Version { get; set; }
|
||||
|
||||
public Split? Split { get; set; }
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
using FrostFS.SDK.Cryptography;
|
||||
|
||||
namespace FrostFS.SDK.ModelsV2;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class ObjectId(string id)
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ public class ObjectId(string id)
|
|||
{
|
||||
if (hash.Length != Constants.Sha256HashLength)
|
||||
throw new FormatException("ObjectID must be a sha256 hash.");
|
||||
|
||||
|
||||
return new ObjectId(Base58.Encode(hash));
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ using System.Security.Cryptography;
|
|||
|
||||
using FrostFS.SDK.Cryptography;
|
||||
|
||||
namespace FrostFS.SDK.ModelsV2;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class OwnerId(string id)
|
||||
{
|
||||
|
|
|
@ -1,30 +1,35 @@
|
|||
using FrostFS.SDK.Cryptography;
|
||||
|
||||
using Google.Protobuf;
|
||||
|
||||
using System;
|
||||
|
||||
namespace FrostFS.SDK.ModelsV2;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class SplitId
|
||||
{
|
||||
private Guid id;
|
||||
private readonly Guid id;
|
||||
|
||||
ByteString? _message;
|
||||
|
||||
public SplitId()
|
||||
{
|
||||
this.id = Guid.NewGuid();
|
||||
id = Guid.NewGuid();
|
||||
}
|
||||
|
||||
public SplitId(Guid guid)
|
||||
{
|
||||
this.id = guid;
|
||||
id = guid;
|
||||
}
|
||||
|
||||
private SplitId(byte[] binary)
|
||||
{
|
||||
this.id = new Guid(binary);
|
||||
id = new Guid(binary);
|
||||
}
|
||||
|
||||
private SplitId(string str)
|
||||
{
|
||||
this.id = new Guid(str);
|
||||
id = new Guid(str);
|
||||
}
|
||||
|
||||
public static SplitId CreateFromBinary(byte[] binaryData)
|
||||
|
@ -35,18 +40,23 @@ public class SplitId
|
|||
public static SplitId CreateFromString(string stringData)
|
||||
{
|
||||
return new SplitId(stringData);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.id.ToString();
|
||||
return id.ToString();
|
||||
}
|
||||
|
||||
public byte[]? ToBinary()
|
||||
{
|
||||
if (this.id == Guid.Empty)
|
||||
if (id == Guid.Empty)
|
||||
return null;
|
||||
|
||||
return this.id.ToBytes();
|
||||
return id.ToBytes();
|
||||
}
|
||||
|
||||
public ByteString? GetMessage()
|
||||
{
|
||||
return _message ??= ByteString.CopyFrom(ToBinary());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace FrostFS.SDK.ModelsV2;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class Split(SplitId splitId)
|
||||
{
|
||||
|
@ -14,8 +13,8 @@ public class Split(SplitId splitId)
|
|||
public ObjectId? Parent { get; set; }
|
||||
|
||||
public ObjectId? Previous { get; set; }
|
||||
|
||||
public Signature? ParentSignature { get; set; }
|
||||
|
||||
public FrostFsSignature? ParentSignature { get; set; }
|
||||
|
||||
public ObjectHeader? ParentHeader { get; set; }
|
||||
|
||||
|
|
14
src/FrostFS.SDK.ModelsV2/Response/FrostFsResponseStatus.cs
Normal file
14
src/FrostFS.SDK.ModelsV2/Response/FrostFsResponseStatus.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
namespace FrostFS.SDK;
|
||||
|
||||
public class FrostFsResponseStatus(FrostFsStatusCode code, string? message = null)
|
||||
{
|
||||
public FrostFsStatusCode Code { get; set; } = code;
|
||||
public string Message { get; set; } = message ?? string.Empty;
|
||||
|
||||
public bool IsSuccess => Code == FrostFsStatusCode.Success;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Response status: {Code}. Message: {Message}.";
|
||||
}
|
||||
}
|
10
src/FrostFS.SDK.ModelsV2/Response/FrostFsSignature.cs
Normal file
10
src/FrostFS.SDK.ModelsV2/Response/FrostFsSignature.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
namespace FrostFS.SDK;
|
||||
|
||||
public class FrostFsSignature
|
||||
{
|
||||
public byte[]? Key { get; set; }
|
||||
|
||||
public byte[]? Sign { get; set; }
|
||||
|
||||
public SignatureScheme Scheme { get; set; }
|
||||
}
|
|
@ -1,15 +1,15 @@
|
|||
namespace FrostFS.SDK.ModelsV2;
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class MetaHeader(Version version, int epoch, int ttl)
|
||||
public class MetaHeader(FrostFsVersion version, int epoch, int ttl)
|
||||
{
|
||||
public Version Version { get; set; } = version;
|
||||
public FrostFsVersion Version { get; set; } = version;
|
||||
public int Epoch { get; set; } = epoch;
|
||||
public int Ttl { get; set; } = ttl;
|
||||
|
||||
public static MetaHeader Default()
|
||||
{
|
||||
return new MetaHeader(
|
||||
new Version(
|
||||
new FrostFsVersion(
|
||||
major: 2,
|
||||
minor: 13
|
||||
),
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
using FrostFS.SDK.ModelsV2.Enums;
|
||||
|
||||
namespace FrostFS.SDK.ModelsV2;
|
||||
|
||||
public class ResponseStatus(StatusCode code, string? message = null)
|
||||
{
|
||||
public StatusCode Code { get; set; } = code;
|
||||
public string Message { get; set; } = message ?? string.Empty;
|
||||
|
||||
public bool IsSuccess => Code == StatusCode.Success;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Response status: {Code}. Message: {Message}.";
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
namespace FrostFS.SDK.ModelsV2;
|
||||
|
||||
public class Signature
|
||||
{
|
||||
public byte[]? Key { get; set; }
|
||||
public byte[]? Sign { get; set; }
|
||||
public SignatureScheme Scheme { get; set; }
|
||||
}
|
6
src/FrostFS.SDK.ModelsV2/Session/FrostFsSessionToken.cs
Normal file
6
src/FrostFS.SDK.ModelsV2/Session/FrostFsSessionToken.cs
Normal file
|
@ -0,0 +1,6 @@
|
|||
namespace FrostFS.SDK;
|
||||
|
||||
public class FrostFsSessionToken(byte[] token)
|
||||
{
|
||||
public byte[] Token { get; private set; } = token;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
namespace FrostFS.SDK.ModelsV2;
|
||||
|
||||
public class SessionToken(byte[] token)
|
||||
{
|
||||
public byte[] Token { get; private set; } = token;
|
||||
}
|
|
@ -1,14 +1,11 @@
|
|||
using FrostFS.SDK.ModelsV2;
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap;
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
using FrostFS.SDK.ClientV2.Interfaces;
|
||||
using FrostFS.SDK.ClientV2.Parameters;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
|
||||
using Microsoft.Extensions.Options;
|
||||
using FrostFS.SDK.ModelsV2.Netmap;
|
||||
using FrostFS.SDK.ModelsV2.Enums;
|
||||
using Google.Protobuf;
|
||||
using FrostFS.SDK.ClientV2.Interfaces;
|
||||
using FrostFS.SDK.ClientV2.Parameters;
|
||||
|
||||
namespace FrostFS.SDK.Tests;
|
||||
|
||||
|
@ -29,8 +26,8 @@ public abstract class ContainerTestsBase
|
|||
|
||||
Mocker = new ContainerMocker(this.key)
|
||||
{
|
||||
PlacementPolicy = new PlacementPolicy(true, new Replica(1)),
|
||||
Version = new ModelsV2.Version(2, 13),
|
||||
PlacementPolicy = new FrostFsPlacementPolicy(true, new FrostFsReplica(1)),
|
||||
Version = new FrostFsVersion(2, 13),
|
||||
ContainerGuid = Guid.NewGuid()
|
||||
};
|
||||
}
|
||||
|
@ -52,7 +49,7 @@ public class ContainerTest : ContainerTestsBase
|
|||
[Fact]
|
||||
public async void CreateContainerTest()
|
||||
{
|
||||
var param = new PrmContainerCreate(new ModelsV2.Container(BasicAcl.PublicRW, Mocker.PlacementPolicy));
|
||||
var param = new PrmContainerCreate(new FrostFsContainer(BasicAcl.PublicRW, Mocker.PlacementPolicy));
|
||||
|
||||
var result = await GetClient().CreateContainerAsync(param);
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ using FrostFS.Session;
|
|||
using Google.Protobuf;
|
||||
using Grpc.Core;
|
||||
using FrostFS.SDK.ClientV2;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap;
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
|
|
|
@ -3,8 +3,6 @@ using FrostFS.Container;
|
|||
using Moq;
|
||||
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using FrostFS.SDK.ModelsV2.Enums;
|
||||
using FrostFS.SDK.ModelsV2.Netmap;
|
||||
using FrostFS.Session;
|
||||
using Google.Protobuf;
|
||||
|
||||
|
@ -19,18 +17,18 @@ public abstract class ServiceBase(string key)
|
|||
{
|
||||
public string StringKey { get; private set; } = key;
|
||||
public ECDsa Key { get; private set; } = key.LoadWif();
|
||||
public ModelsV2.Version Version { get; set; } = DefaultVersion;
|
||||
public FrostFsVersion Version { get; set; } = DefaultVersion;
|
||||
public BasicAcl Acl { get; set; } = DefaultAcl;
|
||||
public PlacementPolicy PlacementPolicy { get; set; } = DefaultPlacementPolicy;
|
||||
public FrostFsPlacementPolicy PlacementPolicy { get; set; } = DefaultPlacementPolicy;
|
||||
|
||||
public static ModelsV2.Version DefaultVersion { get; } = new(2, 13);
|
||||
public static FrostFsVersion DefaultVersion { get; } = new(2, 13);
|
||||
public static BasicAcl DefaultAcl { get; } = BasicAcl.PublicRW;
|
||||
public static PlacementPolicy DefaultPlacementPolicy { get; } = new PlacementPolicy(true, new Replica(1));
|
||||
public static FrostFsPlacementPolicy DefaultPlacementPolicy { get; } = new FrostFsPlacementPolicy(true, new FrostFsReplica(1));
|
||||
|
||||
public Metadata Metadata { get; protected set; }
|
||||
public DateTime? DateTime { get; protected set; }
|
||||
public CancellationToken CancellationToken { get; protected set; }
|
||||
|
||||
public CancellationToken CancellationToken { get; protected set; }
|
||||
public CancellationTokenSource CancellationTokenSource { get; protected set; } = new CancellationTokenSource();
|
||||
|
||||
public static Metadata ResponseMetaData => [];
|
||||
|
|
|
@ -5,7 +5,6 @@ using Moq;
|
|||
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using FrostFS.SDK.ClientV2;
|
||||
using FrostFS.SDK.ModelsV2.Netmap;
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap;
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
using FrostFS.Session;
|
||||
|
|
|
@ -2,7 +2,6 @@ using Google.Protobuf;
|
|||
using Grpc.Core;
|
||||
using Moq;
|
||||
using FrostFS.SDK.ClientV2;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
using FrostFS.Object;
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
using System.Security.Cryptography;
|
||||
|
|
|
@ -3,10 +3,11 @@ using FrostFS.SDK.ClientV2;
|
|||
using FrostFS.SDK.ClientV2.Interfaces;
|
||||
using FrostFS.SDK.ClientV2.Parameters;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
using FrostFS.SDK.ModelsV2.Enums;
|
||||
|
||||
using Google.Protobuf;
|
||||
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace FrostFS.SDK.Tests;
|
||||
|
@ -17,7 +18,7 @@ public abstract class NetworkTestsBase
|
|||
|
||||
protected IOptions<SingleOwnerClientSettings> Settings { get; set; }
|
||||
|
||||
protected ModelsV2.Version Version { get; set; } = new ModelsV2.Version(2, 13);
|
||||
protected FrostFsVersion Version { get; set; } = new FrostFsVersion(2, 13);
|
||||
|
||||
protected ECDsa ECDsaKey { get; set; }
|
||||
protected OwnerId OwnerId { get; set; }
|
||||
|
|
|
@ -4,11 +4,11 @@ using FrostFS.SDK.ClientV2.Interfaces;
|
|||
using FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
using FrostFS.SDK.ClientV2.Parameters;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
using FrostFS.SDK.ModelsV2.Enums;
|
||||
using FrostFS.SDK.ModelsV2.Netmap;
|
||||
|
||||
using Google.Protobuf;
|
||||
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
|
@ -38,16 +38,16 @@ public abstract class ObjectTestsBase
|
|||
|
||||
Mocker = new ObjectMocker(key)
|
||||
{
|
||||
PlacementPolicy = new PlacementPolicy(true, new Replica(1)),
|
||||
Version = new ModelsV2.Version(2, 13),
|
||||
PlacementPolicy = new FrostFsPlacementPolicy(true, new FrostFsReplica(1)),
|
||||
Version = new FrostFsVersion(2, 13),
|
||||
ContainerGuid = Guid.NewGuid()
|
||||
};
|
||||
|
||||
ContainerId = new ContainerId(Base58.Encode(Mocker.ContainerGuid.ToBytes()));
|
||||
|
||||
Mocker.ObjectHeader = new(ContainerId, ModelsV2.Enums.ObjectType.Regular, [new ObjectAttribute("k", "v")])
|
||||
Mocker.ObjectHeader = new(ContainerId, FrostFsObjectType.Regular, [new ObjectAttribute("k", "v")])
|
||||
{
|
||||
Version = new ModelsV2.Version(2, 13),
|
||||
Version = new FrostFsVersion(2, 13),
|
||||
OwnerId = OwnerId.FromKey(ecdsaKey)
|
||||
};
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public class ObjectTest : ObjectTestsBase
|
|||
var ctx = new Context {
|
||||
Key = ecdsaKey,
|
||||
OwnerId = OwnerId.FromKey(ecdsaKey),
|
||||
Version = new ModelsV2.Version(2, 13) };
|
||||
Version = new FrostFsVersion(2, 13) };
|
||||
|
||||
var objectId = client.CalculateObjectId(Mocker.ObjectHeader!, ctx);
|
||||
|
||||
|
@ -256,7 +256,7 @@ public class ObjectTest : ObjectTestsBase
|
|||
|
||||
Assert.Equal(Mocker.HeadResponse!.PayloadLength, response.PayloadLength);
|
||||
|
||||
Assert.Equal(ObjectType.Regular, response.ObjectType);
|
||||
Assert.Equal(FrostFsObjectType.Regular, response.ObjectType);
|
||||
|
||||
Assert.Single(response.Attributes);
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ using FrostFS.SDK.ClientV2.Mappers.GRPC;
|
|||
using FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap;
|
||||
using FrostFS.SDK.ClientV2.Parameters;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
using FrostFS.SDK.ModelsV2.Netmap;
|
||||
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace FrostFS.SDK.Tests;
|
||||
|
@ -35,8 +35,8 @@ public abstract class SessionTestsBase
|
|||
|
||||
Mocker = new SessionMocker(this.key)
|
||||
{
|
||||
PlacementPolicy = new PlacementPolicy(true, new Replica(1)),
|
||||
Version = new ModelsV2.Version(2, 13)
|
||||
PlacementPolicy = new FrostFsPlacementPolicy(true, new FrostFsReplica(1)),
|
||||
Version = new FrostFsVersion(2, 13)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
using System.Security.Cryptography;
|
||||
using FrostFS.SDK.ClientV2;
|
||||
using FrostFS.SDK.ClientV2.Interfaces;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
using FrostFS.SDK.ModelsV2.Enums;
|
||||
using FrostFS.SDK.ModelsV2.Netmap;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
|
||||
using Grpc.Core;
|
||||
|
@ -26,7 +23,7 @@ public abstract class SmokeTestsBase
|
|||
|
||||
protected OwnerId OwnerId { get; }
|
||||
|
||||
protected ModelsV2.Version Version { get; }
|
||||
protected FrostFsVersion Version { get; }
|
||||
|
||||
protected Context Ctx { get; }
|
||||
|
||||
|
@ -34,7 +31,7 @@ public abstract class SmokeTestsBase
|
|||
{
|
||||
Key = key.LoadWif();
|
||||
OwnerId = OwnerId.FromKey(Key);
|
||||
Version = new ModelsV2.Version(2, 13);
|
||||
Version = new FrostFsVersion(2, 13);
|
||||
|
||||
Ctx = new Context { Key = Key, OwnerId = OwnerId, Version = Version };
|
||||
}
|
||||
|
@ -134,7 +131,7 @@ public class SmokeTests : SmokeTestsBase
|
|||
var token = await client.CreateSessionAsync(new PrmSessionCreate(int.MaxValue));
|
||||
|
||||
var createContainerParam = new PrmContainerCreate(
|
||||
new ModelsV2.Container(BasicAcl.PublicRW, new PlacementPolicy(true, new Replica(1))));
|
||||
new FrostFsContainer(BasicAcl.PublicRW, new FrostFsPlacementPolicy(true, new FrostFsReplica(1))));
|
||||
|
||||
createContainerParam.XHeaders.Add("key1", "value1");
|
||||
|
||||
|
@ -146,7 +143,7 @@ public class SmokeTests : SmokeTestsBase
|
|||
{
|
||||
Header = new ObjectHeader(
|
||||
containerId: containerId,
|
||||
type: ModelsV2.Enums.ObjectType.Regular,
|
||||
type: FrostFsObjectType.Regular,
|
||||
new ObjectAttribute("fileName", "test")),
|
||||
Payload = new MemoryStream(bytes),
|
||||
ClientCut = false,
|
||||
|
@ -160,10 +157,10 @@ public class SmokeTests : SmokeTestsBase
|
|||
var downloadedBytes = new byte[@object.Header.PayloadLength];
|
||||
MemoryStream ms = new(downloadedBytes);
|
||||
|
||||
byte[]? chunk = null;
|
||||
ReadOnlyMemory<byte>? chunk = null;
|
||||
while ((chunk = await @object.ObjectReader!.ReadChunk()) != null)
|
||||
{
|
||||
ms.Write(chunk);
|
||||
ms.Write(chunk.Value.Span);
|
||||
}
|
||||
|
||||
Assert.Equal(MD5.HashData(bytes), MD5.HashData(downloadedBytes));
|
||||
|
@ -179,7 +176,7 @@ public class SmokeTests : SmokeTestsBase
|
|||
await Cleanup(client);
|
||||
|
||||
var createContainerParam = new PrmContainerCreate(
|
||||
new ModelsV2.Container(BasicAcl.PublicRW, new PlacementPolicy(true, new Replica(1))))
|
||||
new FrostFsContainer(BasicAcl.PublicRW, new FrostFsPlacementPolicy(true, new FrostFsReplica(1))))
|
||||
{
|
||||
WaitParams = lightWait
|
||||
};
|
||||
|
@ -190,7 +187,7 @@ public class SmokeTests : SmokeTestsBase
|
|||
|
||||
var ParentHeader = new ObjectHeader(
|
||||
containerId: containerId,
|
||||
type: ModelsV2.Enums.ObjectType.Regular)
|
||||
type: FrostFsObjectType.Regular)
|
||||
{
|
||||
PayloadLength = 3
|
||||
};
|
||||
|
@ -199,7 +196,7 @@ public class SmokeTests : SmokeTestsBase
|
|||
{
|
||||
Header = new ObjectHeader(
|
||||
containerId: containerId,
|
||||
type: ModelsV2.Enums.ObjectType.Regular,
|
||||
type: FrostFsObjectType.Regular,
|
||||
new ObjectAttribute("fileName", "test"))
|
||||
{
|
||||
Split = new Split(),
|
||||
|
@ -216,25 +213,25 @@ public class SmokeTests : SmokeTestsBase
|
|||
|
||||
var networkInfo = await client.GetNetmapSnapshotAsync();
|
||||
|
||||
await CheckFilter(client, containerId, new FilterByContainerId(ObjectMatchType.Equals, containerId));
|
||||
await CheckFilter(client, containerId, new FilterByContainerId(FrostFsObjectMatchType.Equals, containerId));
|
||||
|
||||
await CheckFilter(client, containerId, new FilterByOwnerId(ObjectMatchType.Equals, OwnerId.FromKey(ecdsaKey)));
|
||||
await CheckFilter(client, containerId, new FilterByOwnerId(FrostFsObjectMatchType.Equals, OwnerId.FromKey(ecdsaKey)));
|
||||
|
||||
await CheckFilter(client, containerId, new FilterBySplitId(ObjectMatchType.Equals, param.Header.Split.SplitId));
|
||||
await CheckFilter(client, containerId, new FilterBySplitId(FrostFsObjectMatchType.Equals, param.Header.Split.SplitId));
|
||||
|
||||
await CheckFilter(client, containerId, new FilterByAttribute(ObjectMatchType.Equals, "fileName", "test"));
|
||||
await CheckFilter(client, containerId, new FilterByAttribute(FrostFsObjectMatchType.Equals, "fileName", "test"));
|
||||
|
||||
await CheckFilter(client, containerId, new FilterByObjectId(ObjectMatchType.Equals, objectId));
|
||||
await CheckFilter(client, containerId, new FilterByObjectId(FrostFsObjectMatchType.Equals, objectId));
|
||||
|
||||
await CheckFilter(client, containerId, new FilterByVersion(ObjectMatchType.Equals, networkInfo.NodeInfoCollection[0].Version));
|
||||
await CheckFilter(client, containerId, new FilterByVersion(FrostFsObjectMatchType.Equals, networkInfo.NodeInfoCollection[0].Version));
|
||||
|
||||
await CheckFilter(client, containerId, new FilterByEpoch(ObjectMatchType.Equals, networkInfo.Epoch));
|
||||
await CheckFilter(client, containerId, new FilterByEpoch(FrostFsObjectMatchType.Equals, networkInfo.Epoch));
|
||||
|
||||
await CheckFilter(client, containerId, new FilterByPayloadLength(ObjectMatchType.Equals, 3));
|
||||
await CheckFilter(client, containerId, new FilterByPayloadLength(FrostFsObjectMatchType.Equals, 3));
|
||||
|
||||
var checkSum = CheckSum.CreateCheckSum(bytes);
|
||||
|
||||
await CheckFilter(client, containerId, new FilterByPayloadHash(ObjectMatchType.Equals, checkSum));
|
||||
await CheckFilter(client, containerId, new FilterByPayloadHash(FrostFsObjectMatchType.Equals, checkSum));
|
||||
|
||||
await CheckFilter(client, containerId, new FilterByPhysicallyStored());
|
||||
}
|
||||
|
@ -276,7 +273,7 @@ public class SmokeTests : SmokeTestsBase
|
|||
};
|
||||
|
||||
var createContainerParam = new PrmContainerCreate(
|
||||
new ModelsV2.Container(BasicAcl.PublicRW, new PlacementPolicy(true, new Replica(1))))
|
||||
new FrostFsContainer(BasicAcl.PublicRW, new FrostFsPlacementPolicy(true, new FrostFsReplica(1))))
|
||||
{
|
||||
Context = ctx
|
||||
};
|
||||
|
@ -293,7 +290,7 @@ public class SmokeTests : SmokeTestsBase
|
|||
{
|
||||
Header = new ObjectHeader(
|
||||
containerId: containerId,
|
||||
type: ModelsV2.Enums.ObjectType.Regular,
|
||||
type: FrostFsObjectType.Regular,
|
||||
new ObjectAttribute("fileName", "test")),
|
||||
Payload = new MemoryStream(bytes),
|
||||
ClientCut = false,
|
||||
|
@ -305,7 +302,7 @@ public class SmokeTests : SmokeTestsBase
|
|||
|
||||
var objectId = await client.PutObjectAsync(param);
|
||||
|
||||
var filter = new FilterByAttribute(ObjectMatchType.Equals, "fileName", "test");
|
||||
var filter = new FilterByAttribute(FrostFsObjectMatchType.Equals, "fileName", "test");
|
||||
|
||||
bool hasObject = false;
|
||||
await foreach (var objId in client.SearchObjectsAsync(new PrmObjectSearch(containerId) { Filters = [filter] }))
|
||||
|
@ -326,10 +323,10 @@ public class SmokeTests : SmokeTestsBase
|
|||
var downloadedBytes = new byte[@object.Header.PayloadLength];
|
||||
MemoryStream ms = new(downloadedBytes);
|
||||
|
||||
byte[]? chunk = null;
|
||||
ReadOnlyMemory<byte>? chunk = null;
|
||||
while ((chunk = await @object.ObjectReader!.ReadChunk()) != null)
|
||||
{
|
||||
ms.Write(chunk);
|
||||
ms.Write(chunk.Value.Span);
|
||||
}
|
||||
|
||||
Assert.Equal(MD5.HashData(bytes), MD5.HashData(downloadedBytes));
|
||||
|
@ -361,7 +358,7 @@ public class SmokeTests : SmokeTestsBase
|
|||
};
|
||||
|
||||
var createContainerParam = new PrmContainerCreate(
|
||||
new ModelsV2.Container(BasicAcl.PublicRW, new PlacementPolicy(true, new Replica(1))))
|
||||
new FrostFsContainer(BasicAcl.PublicRW, new FrostFsPlacementPolicy(true, new FrostFsReplica(1))))
|
||||
{
|
||||
Context = ctx
|
||||
};
|
||||
|
@ -377,7 +374,7 @@ public class SmokeTests : SmokeTestsBase
|
|||
{
|
||||
Header = new ObjectHeader(
|
||||
containerId: containerId,
|
||||
type: ModelsV2.Enums.ObjectType.Regular,
|
||||
type: FrostFsObjectType.Regular,
|
||||
new ObjectAttribute("fileName", "test")),
|
||||
Payload = new MemoryStream(bytes),
|
||||
ClientCut = false,
|
||||
|
@ -390,7 +387,7 @@ public class SmokeTests : SmokeTestsBase
|
|||
|
||||
var objectId = await client.PutObjectAsync(param);
|
||||
|
||||
var filter = new FilterByAttribute(ObjectMatchType.Equals, "fileName", "test");
|
||||
var filter = new FilterByAttribute(FrostFsObjectMatchType.Equals, "fileName", "test");
|
||||
|
||||
bool hasObject = false;
|
||||
await foreach (var objId in client.SearchObjectsAsync(new PrmObjectSearch(containerId) { Filters = [filter], SessionToken = token }))
|
||||
|
@ -411,10 +408,10 @@ public class SmokeTests : SmokeTestsBase
|
|||
var downloadedBytes = new byte[@object.Header.PayloadLength];
|
||||
MemoryStream ms = new(downloadedBytes);
|
||||
|
||||
byte[]? chunk = null;
|
||||
ReadOnlyMemory<byte>? chunk = null;
|
||||
while ((chunk = await @object.ObjectReader!.ReadChunk()) != null)
|
||||
{
|
||||
ms.Write(chunk);
|
||||
ms.Write(chunk.Value.Span);
|
||||
}
|
||||
|
||||
Assert.Equal(MD5.HashData(bytes), MD5.HashData(downloadedBytes));
|
||||
|
@ -440,7 +437,7 @@ public class SmokeTests : SmokeTestsBase
|
|||
|
||||
await Cleanup(client);
|
||||
|
||||
var createContainerParam = new PrmContainerCreate(new ModelsV2.Container(BasicAcl.PublicRW, new PlacementPolicy(true, new Replica(1))))
|
||||
var createContainerParam = new PrmContainerCreate(new FrostFsContainer(BasicAcl.PublicRW, new FrostFsPlacementPolicy(true, new FrostFsReplica(1))))
|
||||
{
|
||||
WaitParams = lightWait
|
||||
};
|
||||
|
@ -463,7 +460,7 @@ public class SmokeTests : SmokeTestsBase
|
|||
{
|
||||
Header = new ObjectHeader(
|
||||
containerId: containerId,
|
||||
type: ModelsV2.Enums.ObjectType.Regular,
|
||||
type: FrostFsObjectType.Regular,
|
||||
new ObjectAttribute("fileName", "test")),
|
||||
Payload = new MemoryStream(bytes),
|
||||
ClientCut = true
|
||||
|
@ -471,7 +468,7 @@ public class SmokeTests : SmokeTestsBase
|
|||
|
||||
var objectId = await client.PutObjectAsync(param);
|
||||
|
||||
var filter = new FilterByAttribute(ObjectMatchType.Equals, "fileName", "test");
|
||||
var filter = new FilterByAttribute(FrostFsObjectMatchType.Equals, "fileName", "test");
|
||||
|
||||
bool hasObject = false;
|
||||
await foreach (var objId in client.SearchObjectsAsync(new PrmObjectSearch(containerId, filter)))
|
||||
|
@ -492,10 +489,10 @@ public class SmokeTests : SmokeTestsBase
|
|||
var downloadedBytes = new byte[@object.Header.PayloadLength];
|
||||
MemoryStream ms = new(downloadedBytes);
|
||||
|
||||
byte[]? chunk = null;
|
||||
ReadOnlyMemory<byte>? chunk = null;
|
||||
while ((chunk = await @object.ObjectReader!.ReadChunk()) != null)
|
||||
{
|
||||
ms.Write(chunk);
|
||||
ms.Write(chunk.Value.Span);
|
||||
}
|
||||
|
||||
Assert.Equal(MD5.HashData(bytes), MD5.HashData(downloadedBytes));
|
||||
|
|
Loading…
Reference in a new issue