[#24] Client: Implement pool part2
All checks were successful
DCO / DCO (pull_request) Successful in 46s
All checks were successful
DCO / DCO (pull_request) Successful in 46s
Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
c9a75ea025
commit
ee20798379
63 changed files with 801 additions and 526 deletions
|
@ -27,8 +27,7 @@ public class ClientStatusMonitor : IClientStatus
|
|||
MethodIndex.methodSessionCreate,
|
||||
MethodIndex.methodAPEManagerAddChain,
|
||||
MethodIndex.methodAPEManagerRemoveChain,
|
||||
MethodIndex.methodAPEManagerListChains,
|
||||
MethodIndex.methodLast
|
||||
MethodIndex.methodAPEManagerListChains
|
||||
];
|
||||
|
||||
public static string GetMethodName(MethodIndex index)
|
||||
|
@ -53,7 +52,7 @@ public class ClientStatusMonitor : IClientStatus
|
|||
MethodIndex.methodAPEManagerAddChain => "APEManagerAddChain",
|
||||
MethodIndex.methodAPEManagerRemoveChain => "APEManagerRemoveChain",
|
||||
MethodIndex.methodAPEManagerListChains => "APEManagerListChains",
|
||||
_ => throw new NotImplementedException(),
|
||||
_ => throw new ArgumentException("Unknown method", nameof(index)),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -62,13 +61,12 @@ public class ClientStatusMonitor : IClientStatus
|
|||
private readonly ILogger? logger;
|
||||
private int healthy;
|
||||
|
||||
public ClientStatusMonitor(ILogger? logger, string address, uint errorThreshold)
|
||||
public ClientStatusMonitor(ILogger? logger, string address)
|
||||
{
|
||||
this.logger = logger;
|
||||
healthy = (int)HealthyStatus.Healthy;
|
||||
Address = address;
|
||||
ErrorThreshold = errorThreshold;
|
||||
|
||||
Address = address;
|
||||
Methods = new MethodStatus[MethodIndexes.Length];
|
||||
|
||||
for (int i = 0; i < MethodIndexes.Length; i++)
|
||||
|
@ -79,7 +77,7 @@ public class ClientStatusMonitor : IClientStatus
|
|||
|
||||
public string Address { get; }
|
||||
|
||||
internal uint ErrorThreshold { get; }
|
||||
internal uint ErrorThreshold { get; set; }
|
||||
|
||||
public uint CurrentErrorCount { get; set; }
|
||||
|
||||
|
@ -89,7 +87,8 @@ public class ClientStatusMonitor : IClientStatus
|
|||
|
||||
public bool IsHealthy()
|
||||
{
|
||||
return Interlocked.CompareExchange(ref healthy, -1, -1) == (int)HealthyStatus.Healthy;
|
||||
var res = Interlocked.CompareExchange(ref healthy, -1, -1) == (int)HealthyStatus.Healthy;
|
||||
return res;
|
||||
}
|
||||
|
||||
public bool IsDialed()
|
||||
|
@ -124,14 +123,13 @@ public class ClientStatusMonitor : IClientStatus
|
|||
if (thresholdReached)
|
||||
{
|
||||
SetUnhealthy();
|
||||
|
||||
CurrentErrorCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (thresholdReached)
|
||||
if (thresholdReached && logger != null)
|
||||
{
|
||||
logger?.Log(LogLevel.Warning, "Error threshold reached. Address {Address}, threshold {Threshold}", Address, ErrorThreshold);
|
||||
FrostFsMessages.ErrorЕhresholdReached(logger, Address, ErrorThreshold);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue