[#32] Code review fix
All checks were successful
DCO / DCO (pull_request) Successful in 28s
Verify code phase / Verify code (pull_request) Successful in 1m24s

Signed-off-by: Ori Bruk <o.bruk@yadro.com>
This commit is contained in:
Ori Bruk 2025-01-17 16:27:41 +03:00
parent 05f7dc6603
commit a56a66bead
2 changed files with 20 additions and 18 deletions

View file

@ -1,16 +1,23 @@
package info.frostfs.sdk.enums;
public enum HealthyStatus {
// status UNHEALTHY_ON_DIAL is set when dialing to the endpoint is failed,
// so there is no connection to the endpoint, and pool should not close it
// before re-establishing connection once again.
UNHEALTHY_ON_DIAL,
// status HEALTHY is set when connection is ready to be used by the pool.
HEALTHY(1),
// status UNHEALTHY_ON_REQUEST is set when communication after dialing to the
// endpoint is failed due to immediate or accumulated errors, connection is
// available and pool should close it before re-establishing connection once again.
UNHEALTHY_ON_REQUEST,
UNHEALTHY_ON_REQUEST(2),
// status HEALTHY is set when connection is ready to be used by the pool.
HEALTHY
// status UNHEALTHY_ON_DIAL is set when dialing to the endpoint is failed,
// so there is no connection to the endpoint, and pool should not close it
// before re-establishing connection once again.
UNHEALTHY_ON_DIAL(3),
;
public final int value;
HealthyStatus(int value) {
this.value = value;
}
}

View file

@ -1,5 +1,6 @@
package info.frostfs.sdk.pool;
import info.frostfs.sdk.enums.HealthyStatus;
import info.frostfs.sdk.enums.MethodIndex;
import info.frostfs.sdk.utils.FrostFSMessages;
import lombok.Getter;
@ -26,7 +27,7 @@ public class ClientStatusMonitor implements ClientStatus {
public ClientStatusMonitor(Logger logger, String address) {
this.logger = logger;
this.healthy.set(HealthyStatus.HEALTHY.ordinal());
this.healthy.set(HealthyStatus.HEALTHY.value);
this.address = address;
this.methods = Arrays.stream(MethodIndex.values())
@ -36,12 +37,12 @@ public class ClientStatusMonitor implements ClientStatus {
@Override
public boolean isHealthy() {
return healthy.get() == HealthyStatus.HEALTHY.ordinal();
return healthy.get() == HealthyStatus.HEALTHY.value;
}
@Override
public boolean isDialed() {
return healthy.get() != HealthyStatus.UNHEALTHY_ON_DIAL.ordinal();
return healthy.get() != HealthyStatus.UNHEALTHY_ON_DIAL.value;
}
public void setHealthy() {
@ -50,11 +51,11 @@ public class ClientStatusMonitor implements ClientStatus {
@Override
public void setUnhealthy() {
healthy.set(HealthyStatus.UNHEALTHY_ON_REQUEST.ordinal());
healthy.set(HealthyStatus.UNHEALTHY_ON_REQUEST.value);
}
public void setUnhealthyOnDial() {
healthy.set(HealthyStatus.UNHEALTHY_ON_DIAL.ordinal());
healthy.set(HealthyStatus.UNHEALTHY_ON_DIAL.value);
}
public void incErrorRate() {
@ -109,11 +110,5 @@ public class ClientStatusMonitor implements ClientStatus {
return result;
}
private enum HealthyStatus {
HEALTHY,
UNHEALTHY_ON_REQUEST,
UNHEALTHY_ON_DIAL
}
}