diff --git a/client/src/main/java/info/frostfs/sdk/enums/HealthyStatus.java b/client/src/main/java/info/frostfs/sdk/enums/HealthyStatus.java index 04915c6..f88a8db 100644 --- a/client/src/main/java/info/frostfs/sdk/enums/HealthyStatus.java +++ b/client/src/main/java/info/frostfs/sdk/enums/HealthyStatus.java @@ -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; + } } diff --git a/client/src/main/java/info/frostfs/sdk/pool/ClientStatusMonitor.java b/client/src/main/java/info/frostfs/sdk/pool/ClientStatusMonitor.java index c755a58..0770482 100644 --- a/client/src/main/java/info/frostfs/sdk/pool/ClientStatusMonitor.java +++ b/client/src/main/java/info/frostfs/sdk/pool/ClientStatusMonitor.java @@ -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 - } }