@Override public ChannelHandler[] getClientChannelHandlers() { return new ChannelHandler[] { messageEncoder, createFrameLengthDecoder(), messageDecoder, new PartitionRequestClientHandler()}; } }
public void close(RemoteInputChannel inputChannel) throws IOException { partitionRequestHandler.removeInputChannel(inputChannel); if (closeReferenceCounter.decrement()) { // Close the TCP connection. Send a close request msg to ensure // that outstanding backwards task events are not discarded. tcpChannel.writeAndFlush(new NettyMessage.CloseRequest()) .addListener(ChannelFutureListener.CLOSE_ON_FAILURE); // Make sure to remove the client from the factory clientFactory.destroyPartitionRequestClient(connectionId, this); } else { partitionRequestHandler.cancelRequestFor(inputChannel.getInputChannelId()); } }
@Override public void addInputChannel(RemoteInputChannel listener) throws IOException { checkError(); inputChannels.putIfAbsent(listener.getInputChannelId(), listener); }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { try { if (!bufferListener.hasStagedBufferOrEvent() && stagedMessages.isEmpty()) { decodeMsg(msg, false); } else { stagedMessages.add(msg); } } catch (Throwable t) { notifyAllChannelsOfErrorAndClose(t); } }
bufferOrEvent.releaseBuffer(); cancelRequestFor(bufferOrEvent.receiverId); return decodeBufferOrEvent(inputChannel, bufferOrEvent, isStagedBuffer); notifyAllChannelsOfErrorAndClose(new RemoteTransportException( "Fatal error at remote task manager '" + remoteAddr + "'.", remoteAddr, error.cause));
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { // Unexpected close. In normal operation, the client closes the connection after all input // channels have been removed. This indicates a problem with the remote task manager. if (!inputChannels.isEmpty()) { final SocketAddress remoteAddr = ctx.channel().remoteAddress(); notifyAllChannelsOfErrorAndClose(new RemoteTransportException( "Connection unexpectedly closed by remote task manager '" + remoteAddr + "'. " + "This might indicate that the remote task manager was lost.", remoteAddr)); } super.channelInactive(ctx); }
cancelRequestFor(stagedBufferResponse.receiverId);
subpartitionIndex, partitionId, delayMs); partitionRequestHandler.addInputChannel(inputChannel);
bufferOrEvent.releaseBuffer(); cancelRequestFor(bufferOrEvent.receiverId); return decodeBufferOrEvent(inputChannel, bufferOrEvent, isStagedBuffer); notifyAllChannelsOfErrorAndClose(new RemoteTransportException( "Fatal error at remote task manager '" + remoteAddr + "'.", remoteAddr, error.cause));
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { try { if (!bufferListener.hasStagedBufferOrEvent() && stagedMessages.isEmpty()) { decodeMsg(msg, false); } else { stagedMessages.add(msg); } } catch (Throwable t) { notifyAllChannelsOfErrorAndClose(t); } }
/** * Called on exceptions in the client handler pipeline. * * <p> Remote exceptions are received as regular payload. */ @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { if (cause instanceof TransportException) { notifyAllChannelsOfErrorAndClose(cause); } else { final SocketAddress remoteAddr = ctx.channel().remoteAddress(); final TransportException tex; // Improve on the connection reset by peer error message if (cause instanceof IOException && cause.getMessage().equals("Connection reset by peer")) { tex = new RemoteTransportException( "Lost connection to task manager '" + remoteAddr + "'. This indicates " + "that the remote task manager was lost.", remoteAddr, cause); } else { tex = new LocalTransportException(cause.getMessage(), ctx.channel().localAddress(), cause); } notifyAllChannelsOfErrorAndClose(tex); } }
cancelRequestFor(stagedBufferResponse.receiverId);
bufferOrEvent.releaseBuffer(); cancelRequestFor(bufferOrEvent.receiverId); return decodeBufferOrEvent(inputChannel, bufferOrEvent, isStagedBuffer); notifyAllChannelsOfErrorAndClose(new RemoteTransportException( "Fatal error at remote task manager '" + remoteAddr + "'.", remoteAddr, error.cause));
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { try { if (!bufferListener.hasStagedBufferOrEvent() && stagedMessages.isEmpty()) { decodeMsg(msg, false); } else { stagedMessages.add(msg); } } catch (Throwable t) { notifyAllChannelsOfErrorAndClose(t); } }
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { // Unexpected close. In normal operation, the client closes the connection after all input // channels have been removed. This indicates a problem with the remote task manager. if (!inputChannels.isEmpty()) { final SocketAddress remoteAddr = ctx.channel().remoteAddress(); notifyAllChannelsOfErrorAndClose(new RemoteTransportException( "Connection unexpectedly closed by remote task manager '" + remoteAddr + "'. " + "This might indicate that the remote task manager was lost.", remoteAddr)); } super.channelInactive(ctx); }
cancelRequestFor(stagedBufferResponse.receiverId);
@Override public void addInputChannel(RemoteInputChannel listener) throws IOException { checkError(); inputChannels.putIfAbsent(listener.getInputChannelId(), listener); }
NetworkClientHandler networkClientHandler = creditBasedEnabled ? new CreditBasedPartitionRequestClientHandler() : new PartitionRequestClientHandler(); return new ChannelHandler[] { messageEncoder,
bufferOrEvent.releaseBuffer(); cancelRequestFor(bufferOrEvent.receiverId); return decodeBufferOrEvent(inputChannel, bufferOrEvent, isStagedBuffer); notifyAllChannelsOfErrorAndClose(new RemoteTransportException( "Fatal error at remote task manager '" + remoteAddr + "'.", remoteAddr, error.cause));
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { try { if (!bufferListener.hasStagedBufferOrEvent() && stagedMessages.isEmpty()) { decodeMsg(msg, false); } else { stagedMessages.add(msg); } } catch (Throwable t) { notifyAllChannelsOfErrorAndClose(t); } }