Introduced JsonRpcUpstreamException - we shouldn't log errors marked with this type of exception - it is errors from the nodes
This commit is contained in:
@@ -27,6 +27,7 @@ import io.emeraldpay.dshackle.upstream.Upstream
|
|||||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcException
|
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcException
|
||||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||||
|
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcUpstreamException
|
||||||
import io.emeraldpay.dshackle.upstream.signature.ResponseSigner
|
import io.emeraldpay.dshackle.upstream.signature.ResponseSigner
|
||||||
import io.emeraldpay.etherjar.rpc.RpcException
|
import io.emeraldpay.etherjar.rpc.RpcException
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
@@ -167,7 +168,13 @@ class QuorumRpcReader(
|
|||||||
private fun <T> withErrorResume(api: Upstream, key: JsonRpcRequest): Function<Mono<T>, Mono<T>> {
|
private fun <T> withErrorResume(api: Upstream, key: JsonRpcRequest): Function<Mono<T>, Mono<T>> {
|
||||||
return Function { src ->
|
return Function { src ->
|
||||||
src.onErrorResume { err ->
|
src.onErrorResume { err ->
|
||||||
log.debug("Error during call upstream ${api.getId()} with method ${key.method}", err)
|
val msgError = "Error during call upstream ${api.getId()} with method ${key.method}"
|
||||||
|
if (err is JsonRpcUpstreamException) {
|
||||||
|
log.debug(msgError, err)
|
||||||
|
} else {
|
||||||
|
log.warn(msgError, err)
|
||||||
|
}
|
||||||
|
|
||||||
// when the call failed with an error we want to notify the quorum because
|
// when the call failed with an error we want to notify the quorum because
|
||||||
// it may use the error message or other details
|
// it may use the error message or other details
|
||||||
//
|
//
|
||||||
@@ -175,7 +182,13 @@ class QuorumRpcReader(
|
|||||||
quorum.record(cleanErr, null, api,)
|
quorum.record(cleanErr, null, api,)
|
||||||
// if it's failed after that, then we don't need more calls, stop api source
|
// if it's failed after that, then we don't need more calls, stop api source
|
||||||
if (quorum.isFailed()) {
|
if (quorum.isFailed()) {
|
||||||
log.debug("Quorum is failed, stop api source. Upstream ${api.getId()}, method ${key.method}")
|
val msgQuorumFailed = "Quorum is failed, stop api source. Upstream ${api.getId()}, method ${key.method}"
|
||||||
|
if (cleanErr is JsonRpcUpstreamException) {
|
||||||
|
log.debug(msgQuorumFailed)
|
||||||
|
} else {
|
||||||
|
log.warn(msgQuorumFailed)
|
||||||
|
}
|
||||||
|
|
||||||
apiControl.resolve()
|
apiControl.resolve()
|
||||||
} else {
|
} else {
|
||||||
log.debug("Received an error, trying to request next upstream")
|
log.debug("Received an error, trying to request next upstream")
|
||||||
@@ -194,7 +207,7 @@ class QuorumRpcReader(
|
|||||||
log.debug("Quorum is failed. Method ${key.method}, message ${err.message}")
|
log.debug("Quorum is failed. Method ${key.method}, message ${err.message}")
|
||||||
Mono.error(err)
|
Mono.error(err)
|
||||||
} else {
|
} else {
|
||||||
log.debug("Did not get any result from upstream. Method [${key.method}] using [$q]")
|
log.warn("Did not get any result from upstream. Method [${key.method}] using [$q]")
|
||||||
noResponse(key.method, q)
|
noResponse(key.method, q)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ data class JsonRpcError(val code: Int, val message: String, val details: Any?) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun asException(id: JsonRpcResponse.Id?): JsonRpcException {
|
fun asException(id: JsonRpcResponse.Id?): JsonRpcException {
|
||||||
return JsonRpcException(id ?: JsonRpcResponse.NumberId(-1), this, null, false)
|
return JsonRpcUpstreamException(id ?: JsonRpcResponse.NumberId(-1), this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun asException(id: JsonRpcResponse.Id?, upstreamId: String?): JsonRpcException {
|
fun asException(id: JsonRpcResponse.Id?, upstreamId: String?): JsonRpcException {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ package io.emeraldpay.dshackle.upstream.rpcclient
|
|||||||
|
|
||||||
import io.emeraldpay.etherjar.rpc.RpcException
|
import io.emeraldpay.etherjar.rpc.RpcException
|
||||||
|
|
||||||
class JsonRpcException(
|
open class JsonRpcException(
|
||||||
val id: JsonRpcResponse.Id,
|
val id: JsonRpcResponse.Id,
|
||||||
val error: JsonRpcError,
|
val error: JsonRpcError,
|
||||||
val upstreamId: String? = null,
|
val upstreamId: String? = null,
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ class JsonRpcHttpClient(
|
|||||||
return Function { resp ->
|
return Function { resp ->
|
||||||
resp.flatMap {
|
resp.flatMap {
|
||||||
if (it.hasError()) {
|
if (it.hasError()) {
|
||||||
Mono.error(JsonRpcException(it.id, it.error!!, null, false))
|
Mono.error(JsonRpcUpstreamException(it.id, it.error!!))
|
||||||
} else {
|
} else {
|
||||||
Mono.just(it)
|
Mono.just(it)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package io.emeraldpay.dshackle.upstream.rpcclient
|
||||||
|
|
||||||
|
class JsonRpcUpstreamException(
|
||||||
|
id: JsonRpcResponse.Id,
|
||||||
|
error: JsonRpcError
|
||||||
|
) : JsonRpcException(id, error, null, false)
|
||||||
Reference in New Issue
Block a user