@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 { decodeMsg(msg); } catch (Throwable t) { notifyAllChannelsOfErrorAndClose(t); } }
@Override public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception { writeAndFlushNextMessageIfPossible(ctx.channel()); }
bufferOrEvent.releaseBuffer(); cancelRequestFor(bufferOrEvent.receiverId); decodeBufferOrEvent(inputChannel, bufferOrEvent); notifyAllChannelsOfErrorAndClose(new RemoteTransportException( "Fatal error at remote task manager '" + remoteAddr + "'.", remoteAddr,
@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); }
private void decodeBufferOrEvent(RemoteInputChannel inputChannel, NettyMessage.BufferResponse bufferOrEvent) throws Throwable { checkState(bufferOrEvent.getBuffer() == null || bufferOrEvent.getBuffer() instanceof Buffer, "The data buffer should be an instance of Buffer."); // Early return for empty buffers. if (bufferOrEvent.isBuffer() && bufferOrEvent.dataBufferSize == 0) { inputChannel.onEmptyBuffer(bufferOrEvent.sequenceNumber, bufferOrEvent.backlog); return; } ByteBuf dataBuffer = bufferOrEvent.getBuffer(); if (dataBuffer != null) { checkState(dataBuffer instanceof Buffer, "The data buffer should be an instance of Buffer."); inputChannel.onBuffer((Buffer) dataBuffer, bufferOrEvent.sequenceNumber, bufferOrEvent.backlog); } else if (inputChannel.isReleased()) { cancelRequestFor(bufferOrEvent.receiverId); } else { throw new IllegalStateException("The read buffer is null in credit-based input channel."); } }
creditBasedEnabled ? new CreditBasedPartitionRequestClientHandler() : new PartitionRequestClientHandler(); return new ChannelHandler[] {
@Override public Buffer allocatePooledNetworkBuffer(InputChannelID receiverId, int size) { Buffer buffer = null; RemoteInputChannel inputChannel = partitionRequestClientHandler.getInputChannel(receiverId); if (inputChannel != null) { buffer = inputChannel.requestBuffer(); } return buffer; }
bufferOrEvent.releaseBuffer(); cancelRequestFor(bufferOrEvent.receiverId); decodeBufferOrEvent(inputChannel, bufferOrEvent); notifyAllChannelsOfErrorAndClose(new RemoteTransportException( "Fatal error at remote task manager '" + remoteAddr + "'.", remoteAddr,
@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(bufferOrEvent.receiverId); } else { throw new IllegalStateException("No buffer available in credit-based input channel.");
creditBasedEnabled ? new CreditBasedPartitionRequestClientHandler() : new PartitionRequestClientHandler(); return new ChannelHandler[] {
bufferOrEvent.releaseBuffer(); cancelRequestFor(bufferOrEvent.receiverId); decodeBufferOrEvent(inputChannel, bufferOrEvent); notifyAllChannelsOfErrorAndClose(new RemoteTransportException( "Fatal error at remote task manager '" + remoteAddr + "'.", remoteAddr,
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { try { decodeMsg(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 { final SocketAddress localAddr = ctx.channel().localAddress(); tex = new LocalTransportException( String.format("%s (connection to '%s')", cause.getMessage(), remoteAddr), localAddr, cause); } notifyAllChannelsOfErrorAndClose(tex); } }
@Override public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception { writeAndFlushNextMessageIfPossible(ctx.channel()); }
@Override public void addInputChannel(RemoteInputChannel listener) throws IOException { checkError(); inputChannels.putIfAbsent(listener.getInputChannelId(), listener); }
cancelRequestFor(bufferOrEvent.receiverId); } else { throw new IllegalStateException("No buffer available in credit-based input channel.");
CreditBasedPartitionRequestClientHandler networkClientHandler = new CreditBasedPartitionRequestClientHandler(); NetworkBufferAllocator networkBufferAllocator = new CreditedBasedReceiverSideNetworkBufferAllocator(networkClientHandler); ZeroCopyNettyMessageDecoder zeroCopyMessageDecoder = new ZeroCopyNettyMessageDecoder(networkBufferAllocator);
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { try { decodeMsg(msg); } catch (Throwable t) { notifyAllChannelsOfErrorAndClose(t); } }