Search in sources :

Example 1 with READ_COMPLETE

use of tech.pegasys.teku.networking.eth2.rpc.core.Eth2OutgoingRequestHandler.State.READ_COMPLETE 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)

Aggregations

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