[#25] Client: Implement Patch and Range methods
Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
bff8d67867
commit
003b7fdfdd
51 changed files with 1338 additions and 137 deletions
47
src/FrostFS.SDK.ClientV2/Pool/InnerPool.cs
Normal file
47
src/FrostFS.SDK.ClientV2/Pool/InnerPool.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
using FrostFS.SDK.ClientV2;
|
||||
|
||||
internal sealed class InnerPool
|
||||
{
|
||||
private readonly object _lock = new();
|
||||
|
||||
internal InnerPool(Sampler sampler, ClientWrapper[] clients)
|
||||
{
|
||||
Clients = clients;
|
||||
Sampler = sampler;
|
||||
}
|
||||
|
||||
internal Sampler Sampler { get; set; }
|
||||
|
||||
internal ClientWrapper[] Clients { get; }
|
||||
|
||||
internal ClientWrapper? Connection()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (Clients.Length == 1)
|
||||
{
|
||||
var client = Clients[0];
|
||||
if (client.IsHealthy())
|
||||
{
|
||||
return client;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var attempts = 3 * Clients.Length;
|
||||
|
||||
for (int i = 0; i < attempts; i++)
|
||||
{
|
||||
int index = Sampler.Next();
|
||||
|
||||
if (Clients[index].IsHealthy())
|
||||
{
|
||||
return Clients[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue