Search in sources :

Example 1 with RpcTimeoutException

use of tech.pegasys.teku.networking.eth2.rpc.core.RpcTimeouts.RpcTimeoutException in project teku by ConsenSys.

the class Eth2OutgoingRequestHandler method ensureReadCompleteArrivesInTime.

private void ensureReadCompleteArrivesInTime(final RpcStream stream) {
    final Duration timeout = RpcTimeouts.RESP_TIMEOUT;
    timeoutRunner.getDelayedFuture(timeout).thenAccept((__) -> {
        if (!(state.get() == READ_COMPLETE || state.get() == CLOSED)) {
            abortRequest(stream, new RpcTimeoutException("Timed out waiting for read channel close", timeout));
        }
    }).reportExceptions();
}
Also used : INITIAL(tech.pegasys.teku.networking.eth2.rpc.core.Eth2OutgoingRequestHandler.State.INITIAL) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SafeFuture(tech.pegasys.teku.infrastructure.async.SafeFuture) RpcRequest(tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.RpcRequest) Bytes(org.apache.tuweni.bytes.Bytes) AtomicReference(java.util.concurrent.atomic.AtomicReference) ByteBuf(io.netty.buffer.ByteBuf) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Duration(java.time.Duration) SszData(tech.pegasys.teku.infrastructure.ssz.SszData) RpcStream(tech.pegasys.teku.networking.p2p.rpc.RpcStream) ABORTED(tech.pegasys.teku.networking.eth2.rpc.core.Eth2OutgoingRequestHandler.State.ABORTED) AsyncRunner(tech.pegasys.teku.infrastructure.async.AsyncRunner) Collection(java.util.Collection) DATA_COMPLETED(tech.pegasys.teku.networking.eth2.rpc.core.Eth2OutgoingRequestHandler.State.DATA_COMPLETED) RpcRequestHandler(tech.pegasys.teku.networking.p2p.rpc.RpcRequestHandler) List(java.util.List) Logger(org.apache.logging.log4j.Logger) RpcTimeoutException(tech.pegasys.teku.networking.eth2.rpc.core.RpcTimeouts.RpcTimeoutException) CLOSED(tech.pegasys.teku.networking.eth2.rpc.core.Eth2OutgoingRequestHandler.State.CLOSED) READ_COMPLETE(tech.pegasys.teku.networking.eth2.rpc.core.Eth2OutgoingRequestHandler.State.READ_COMPLETE) VisibleForTesting(com.google.common.annotations.VisibleForTesting) LogManager(org.apache.logging.log4j.LogManager) EXPECT_DATA(tech.pegasys.teku.networking.eth2.rpc.core.Eth2OutgoingRequestHandler.State.EXPECT_DATA) NodeId(tech.pegasys.teku.networking.p2p.peer.NodeId) ExtraDataAppendedException(tech.pegasys.teku.networking.eth2.rpc.core.RpcException.ExtraDataAppendedException) Duration(java.time.Duration) RpcTimeoutException(tech.pegasys.teku.networking.eth2.rpc.core.RpcTimeouts.RpcTimeoutException)

Example 2 with RpcTimeoutException

use of tech.pegasys.teku.networking.eth2.rpc.core.RpcTimeouts.RpcTimeoutException in project teku by ConsenSys.

the class Eth2OutgoingRequestHandler method ensureNextResponseArrivesInTime.

private void ensureNextResponseArrivesInTime(final RpcStream stream, final int previousResponseCount, final AtomicInteger currentResponseCount) {
    final Duration timeout = RpcTimeouts.RESP_TIMEOUT;
    timeoutRunner.getDelayedFuture(timeout).thenAccept((__) -> {
        if (previousResponseCount == currentResponseCount.get()) {
            abortRequest(stream, new RpcTimeoutException("Timed out waiting for response chunk " + previousResponseCount, timeout));
        }
    }).reportExceptions();
}
Also used : INITIAL(tech.pegasys.teku.networking.eth2.rpc.core.Eth2OutgoingRequestHandler.State.INITIAL) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SafeFuture(tech.pegasys.teku.infrastructure.async.SafeFuture) RpcRequest(tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.RpcRequest) Bytes(org.apache.tuweni.bytes.Bytes) AtomicReference(java.util.concurrent.atomic.AtomicReference) ByteBuf(io.netty.buffer.ByteBuf) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Duration(java.time.Duration) SszData(tech.pegasys.teku.infrastructure.ssz.SszData) RpcStream(tech.pegasys.teku.networking.p2p.rpc.RpcStream) ABORTED(tech.pegasys.teku.networking.eth2.rpc.core.Eth2OutgoingRequestHandler.State.ABORTED) AsyncRunner(tech.pegasys.teku.infrastructure.async.AsyncRunner) Collection(java.util.Collection) DATA_COMPLETED(tech.pegasys.teku.networking.eth2.rpc.core.Eth2OutgoingRequestHandler.State.DATA_COMPLETED) RpcRequestHandler(tech.pegasys.teku.networking.p2p.rpc.RpcRequestHandler) List(java.util.List) Logger(org.apache.logging.log4j.Logger) RpcTimeoutException(tech.pegasys.teku.networking.eth2.rpc.core.RpcTimeouts.RpcTimeoutException) CLOSED(tech.pegasys.teku.networking.eth2.rpc.core.Eth2OutgoingRequestHandler.State.CLOSED) READ_COMPLETE(tech.pegasys.teku.networking.eth2.rpc.core.Eth2OutgoingRequestHandler.State.READ_COMPLETE) VisibleForTesting(com.google.common.annotations.VisibleForTesting) LogManager(org.apache.logging.log4j.LogManager) EXPECT_DATA(tech.pegasys.teku.networking.eth2.rpc.core.Eth2OutgoingRequestHandler.State.EXPECT_DATA) NodeId(tech.pegasys.teku.networking.p2p.peer.NodeId) ExtraDataAppendedException(tech.pegasys.teku.networking.eth2.rpc.core.RpcException.ExtraDataAppendedException) Duration(java.time.Duration) RpcTimeoutException(tech.pegasys.teku.networking.eth2.rpc.core.RpcTimeouts.RpcTimeoutException)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 ByteBuf (io.netty.buffer.ByteBuf)2 Duration (java.time.Duration)2 Collection (java.util.Collection)2 List (java.util.List)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 LogManager (org.apache.logging.log4j.LogManager)2 Logger (org.apache.logging.log4j.Logger)2 Bytes (org.apache.tuweni.bytes.Bytes)2 AsyncRunner (tech.pegasys.teku.infrastructure.async.AsyncRunner)2 SafeFuture (tech.pegasys.teku.infrastructure.async.SafeFuture)2 SszData (tech.pegasys.teku.infrastructure.ssz.SszData)2 ABORTED (tech.pegasys.teku.networking.eth2.rpc.core.Eth2OutgoingRequestHandler.State.ABORTED)2 CLOSED (tech.pegasys.teku.networking.eth2.rpc.core.Eth2OutgoingRequestHandler.State.CLOSED)2 DATA_COMPLETED (tech.pegasys.teku.networking.eth2.rpc.core.Eth2OutgoingRequestHandler.State.DATA_COMPLETED)2 EXPECT_DATA (tech.pegasys.teku.networking.eth2.rpc.core.Eth2OutgoingRequestHandler.State.EXPECT_DATA)2 INITIAL (tech.pegasys.teku.networking.eth2.rpc.core.Eth2OutgoingRequestHandler.State.INITIAL)2 READ_COMPLETE (tech.pegasys.teku.networking.eth2.rpc.core.Eth2OutgoingRequestHandler.State.READ_COMPLETE)2