@Test public void pingsAreAcked() { KeepAliveManager manager = newManager(false); long pingContent = ThreadLocalRandom.current().nextLong(); manager.pingReceived(new DefaultHttp2PingFrame(pingContent, false)); Http2PingFrame pingFrame = verifyWrite(instanceOf(Http2PingFrame.class)); assertThat("Unexpected ping ack content.", pingFrame.content(), is(pingContent)); assertThat("Unexpected ping ack content.", pingFrame.ack(), is(true)); }
void pingReceived(final Http2PingFrame pingFrame) { assert channel.eventLoop().inEventLoop(); if (pingFrame.ack()) { long pingAckContent = pingFrame.content(); if (pingAckContent == GRACEFUL_CLOSE_PING_CONTENT) { LOGGER.debug("channel={}, graceful close ping ack received.", channel); cancelIfStateIsAFuture(gracefulCloseState); gracefulCloseWriteSecondGoAway(); } else if (pingAckContent == KEEP_ALIVE_PING_CONTENT) { cancelIfStateIsAFuture(keepAliveState); keepAliveState = null; } } else { channel.writeAndFlush(new DefaultHttp2PingFrame(pingFrame.content(), true)); } }
KeepAliveManager { void pingReceived(final Http2PingFrame pingFrame) { assert channel.eventLoop().inEventLoop(); if (pingFrame.ack()) { long pingAckContent = pingFrame.content(); if (pingAckContent == GRACEFUL_CLOSE_PING_CONTENT) { LOGGER.debug("channel={}, graceful close ping ack received.", channel); cancelIfStateIsAFuture(gracefulCloseState); gracefulCloseWriteSecondGoAway(); } else if (pingAckContent == KEEP_ALIVE_PING_CONTENT) { cancelIfStateIsAFuture(keepAliveState); keepAliveState = null; } } else { channel.writeAndFlush(new DefaultHttp2PingFrame(pingFrame.content(), true)); } } }
KeepAliveManager { void pingReceived(final Http2PingFrame pingFrame) { assert channel.eventLoop().inEventLoop(); if (pingFrame.ack()) { long pingAckContent = pingFrame.content(); if (pingAckContent == GRACEFUL_CLOSE_PING_CONTENT) { LOGGER.debug("channel={}, graceful close ping ack received.", channel); cancelIfStateIsAFuture(gracefulCloseState); gracefulCloseWriteSecondGoAway(); } else if (pingAckContent == KEEP_ALIVE_PING_CONTENT) { cancelIfStateIsAFuture(keepAliveState); keepAliveState = null; } } else { channel.writeAndFlush(new DefaultHttp2PingFrame(pingFrame.content(), true)); } } KeepAliveManager(final Channel channel, @Nullable final KeepAlivePolicy keepAlivePolicy);   KeepAliveManager(final Channel channel, @Nullable final KeepAlivePolicy keepAlivePolicy,
                     final Scheduler scheduler, final IdlenessDetector idlenessDetector); }
KeepAliveManager { void pingReceived(final Http2PingFrame pingFrame) { assert channel.eventLoop().inEventLoop(); if (pingFrame.ack()) { long pingAckContent = pingFrame.content(); if (pingAckContent == GRACEFUL_CLOSE_PING_CONTENT) { LOGGER.debug("channel={}, graceful close ping ack received.", channel); cancelIfStateIsAFuture(gracefulCloseState); gracefulCloseWriteSecondGoAway(); } else if (pingAckContent == KEEP_ALIVE_PING_CONTENT) { cancelIfStateIsAFuture(keepAliveState); keepAliveState = null; } } else { channel.writeAndFlush(new DefaultHttp2PingFrame(pingFrame.content(), true)); } } KeepAliveManager(final Channel channel, @Nullable final KeepAlivePolicy keepAlivePolicy);   KeepAliveManager(final Channel channel, @Nullable final KeepAlivePolicy keepAlivePolicy,
                     final Scheduler scheduler, final IdlenessDetector idlenessDetector);  }
KeepAliveManager { void pingReceived(final Http2PingFrame pingFrame) { assert channel.eventLoop().inEventLoop(); if (pingFrame.ack()) { long pingAckContent = pingFrame.content(); if (pingAckContent == GRACEFUL_CLOSE_PING_CONTENT) { LOGGER.debug("channel={}, graceful close ping ack received.", channel); cancelIfStateIsAFuture(gracefulCloseState); gracefulCloseWriteSecondGoAway(); } else if (pingAckContent == KEEP_ALIVE_PING_CONTENT) { cancelIfStateIsAFuture(keepAliveState); keepAliveState = null; } } else { channel.writeAndFlush(new DefaultHttp2PingFrame(pingFrame.content(), true)); } } KeepAliveManager(final Channel channel, @Nullable final KeepAlivePolicy keepAlivePolicy);   KeepAliveManager(final Channel channel, @Nullable final KeepAlivePolicy keepAlivePolicy,
                     final Scheduler scheduler, final IdlenessDetector idlenessDetector);   }