use of com.datastax.oss.driver.api.core.connection.HeartbeatException in project java-driver by datastax.
the class InFlightHandler method write.
@Override
public void write(ChannelHandlerContext ctx, Object in, ChannelPromise promise) throws Exception {
if (in == DriverChannel.GRACEFUL_CLOSE_MESSAGE) {
LOG.debug("[{}] Received graceful close request", logPrefix);
startGracefulShutdown(ctx);
} else if (in == DriverChannel.FORCEFUL_CLOSE_MESSAGE) {
LOG.debug("[{}] Received forceful close request, aborting pending queries", logPrefix);
abortAllInFlight(new ClosedConnectionException("Channel was force-closed"));
ctx.channel().close();
} else if (in instanceof HeartbeatException) {
abortAllInFlight(new ClosedConnectionException("Heartbeat query failed", ((HeartbeatException) in)));
ctx.close();
} else if (in instanceof RequestMessage) {
write(ctx, (RequestMessage) in, promise);
} else if (in instanceof ResponseCallback) {
cancel(ctx, (ResponseCallback) in, promise);
} else {
promise.setFailure(new IllegalArgumentException("Unsupported message type " + in.getClass().getName()));
}
}
Aggregations