Commit 7b624aa4 authored by Georg Mittendorfer's avatar Georg Mittendorfer

Set low timeout for pow node health check.

parent 02dcd259
......@@ -281,7 +281,7 @@ public class IriNode implements Node {
return (powEnabled && powAvailable) || !(command instanceof AttachToTangle);
}
private String getHealthCheckErrorMessage(Throwable t) {
String getHealthCheckErrorMessage(Throwable t) {
if (t instanceof Exception) {
return t instanceof TimeoutException ? "Timeout" : t.getMessage(); // timeout exception is too verbose
} else {
......
......@@ -55,10 +55,12 @@ public class PowNode extends IriNode implements Node {
return POW_TIMEOUT;
}
@SuppressWarnings("unused") // false inspection warning in intellij
@Override
public Mono<NodeInfo> queryNodeHealth() {
logger.debug("Query node health for node [{}]", name);
return nodeClient.exchange(this, new AttachToTangle())
.timeout(Duration.ofSeconds(3)) // maximum timeout for health check
.doOnNext(response -> {
if (response.getStatusCode().isError() && response.getStatusCode() != HttpStatus.BAD_REQUEST) { // HTTP 400 is OK
this.updateWithHealthCheckError(String.format("Response status [%s] with body [%s].", response.getStatusCode(), response.getBody()));
......@@ -69,7 +71,7 @@ public class PowNode extends IriNode implements Node {
.transform(CircuitBreakerOperator.of(circuitBreaker)) // might throw => therefore before onErrorResume
// attachToTangle might throw. resume with empty mono otherwise error gets replayed.
.onErrorResume(t -> {
Mono.just(updateWithHealthCheckError(t.getMessage()));
Mono.just(updateWithHealthCheckError(getHealthCheckErrorMessage(t)));
return Mono.empty();
})
// return dummy node info as an result
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment