parent
05f7dc6603
commit
a56a66bead
2 changed files with 20 additions and 18 deletions
|
@ -1,16 +1,23 @@
|
||||||
package info.frostfs.sdk.enums;
|
package info.frostfs.sdk.enums;
|
||||||
|
|
||||||
public enum HealthyStatus {
|
public enum HealthyStatus {
|
||||||
// status UNHEALTHY_ON_DIAL is set when dialing to the endpoint is failed,
|
// status HEALTHY is set when connection is ready to be used by the pool.
|
||||||
// so there is no connection to the endpoint, and pool should not close it
|
HEALTHY(1),
|
||||||
// before re-establishing connection once again.
|
|
||||||
UNHEALTHY_ON_DIAL,
|
|
||||||
|
|
||||||
// status UNHEALTHY_ON_REQUEST is set when communication after dialing to the
|
// status UNHEALTHY_ON_REQUEST is set when communication after dialing to the
|
||||||
// endpoint is failed due to immediate or accumulated errors, connection is
|
// endpoint is failed due to immediate or accumulated errors, connection is
|
||||||
// available and pool should close it before re-establishing connection once again.
|
// 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.
|
// status UNHEALTHY_ON_DIAL is set when dialing to the endpoint is failed,
|
||||||
HEALTHY
|
// 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.frostfs.sdk.pool;
|
package info.frostfs.sdk.pool;
|
||||||
|
|
||||||
|
import info.frostfs.sdk.enums.HealthyStatus;
|
||||||
import info.frostfs.sdk.enums.MethodIndex;
|
import info.frostfs.sdk.enums.MethodIndex;
|
||||||
import info.frostfs.sdk.utils.FrostFSMessages;
|
import info.frostfs.sdk.utils.FrostFSMessages;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
@ -26,7 +27,7 @@ public class ClientStatusMonitor implements ClientStatus {
|
||||||
|
|
||||||
public ClientStatusMonitor(Logger logger, String address) {
|
public ClientStatusMonitor(Logger logger, String address) {
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.healthy.set(HealthyStatus.HEALTHY.ordinal());
|
this.healthy.set(HealthyStatus.HEALTHY.value);
|
||||||
|
|
||||||
this.address = address;
|
this.address = address;
|
||||||
this.methods = Arrays.stream(MethodIndex.values())
|
this.methods = Arrays.stream(MethodIndex.values())
|
||||||
|
@ -36,12 +37,12 @@ public class ClientStatusMonitor implements ClientStatus {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isHealthy() {
|
public boolean isHealthy() {
|
||||||
return healthy.get() == HealthyStatus.HEALTHY.ordinal();
|
return healthy.get() == HealthyStatus.HEALTHY.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDialed() {
|
public boolean isDialed() {
|
||||||
return healthy.get() != HealthyStatus.UNHEALTHY_ON_DIAL.ordinal();
|
return healthy.get() != HealthyStatus.UNHEALTHY_ON_DIAL.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHealthy() {
|
public void setHealthy() {
|
||||||
|
@ -50,11 +51,11 @@ public class ClientStatusMonitor implements ClientStatus {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUnhealthy() {
|
public void setUnhealthy() {
|
||||||
healthy.set(HealthyStatus.UNHEALTHY_ON_REQUEST.ordinal());
|
healthy.set(HealthyStatus.UNHEALTHY_ON_REQUEST.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUnhealthyOnDial() {
|
public void setUnhealthyOnDial() {
|
||||||
healthy.set(HealthyStatus.UNHEALTHY_ON_DIAL.ordinal());
|
healthy.set(HealthyStatus.UNHEALTHY_ON_DIAL.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void incErrorRate() {
|
public void incErrorRate() {
|
||||||
|
@ -109,11 +110,5 @@ public class ClientStatusMonitor implements ClientStatus {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum HealthyStatus {
|
|
||||||
HEALTHY,
|
|
||||||
UNHEALTHY_ON_REQUEST,
|
|
||||||
UNHEALTHY_ON_DIAL
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue