Search in sources :

Example 1 with LocalTransportException

use of org.apache.flink.runtime.io.network.netty.exception.LocalTransportException in project flink by apache.

the class PartitionRequestClient method requestSubpartition.

/**
	 * Requests a remote intermediate result partition queue.
	 * <p>
	 * The request goes to the remote producer, for which this partition
	 * request client instance has been created.
	 */
public ChannelFuture requestSubpartition(final ResultPartitionID partitionId, final int subpartitionIndex, final RemoteInputChannel inputChannel, int delayMs) throws IOException {
    checkNotClosed();
    LOG.debug("Requesting subpartition {} of partition {} with {} ms delay.", subpartitionIndex, partitionId, delayMs);
    partitionRequestHandler.addInputChannel(inputChannel);
    final PartitionRequest request = new PartitionRequest(partitionId, subpartitionIndex, inputChannel.getInputChannelId());
    final ChannelFutureListener listener = new ChannelFutureListener() {

        @Override
        public void operationComplete(ChannelFuture future) throws Exception {
            if (!future.isSuccess()) {
                partitionRequestHandler.removeInputChannel(inputChannel);
                inputChannel.onError(new LocalTransportException("Sending the partition request failed.", future.channel().localAddress(), future.cause()));
            }
        }
    };
    if (delayMs == 0) {
        ChannelFuture f = tcpChannel.writeAndFlush(request);
        f.addListener(listener);
        return f;
    } else {
        final ChannelFuture[] f = new ChannelFuture[1];
        tcpChannel.eventLoop().schedule(new Runnable() {

            @Override
            public void run() {
                f[0] = tcpChannel.writeAndFlush(request);
                f[0].addListener(listener);
            }
        }, delayMs, TimeUnit.MILLISECONDS);
        return f[0];
    }
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) PartitionRequest(org.apache.flink.runtime.io.network.netty.NettyMessage.PartitionRequest) LocalTransportException(org.apache.flink.runtime.io.network.netty.exception.LocalTransportException) ChannelFutureListener(io.netty.channel.ChannelFutureListener)

Example 2 with LocalTransportException

use of org.apache.flink.runtime.io.network.netty.exception.LocalTransportException in project flink by apache.

the class PartitionRequestClient method sendTaskEvent.

/**
	 * Sends a task event backwards to an intermediate result partition producer.
	 * <p>
	 * Backwards task events flow between readers and writers and therefore
	 * will only work when both are running at the same time, which is only
	 * guaranteed to be the case when both the respective producer and
	 * consumer task run pipelined.
	 */
public void sendTaskEvent(ResultPartitionID partitionId, TaskEvent event, final RemoteInputChannel inputChannel) throws IOException {
    checkNotClosed();
    tcpChannel.writeAndFlush(new TaskEventRequest(event, partitionId, inputChannel.getInputChannelId())).addListener(new ChannelFutureListener() {

        @Override
        public void operationComplete(ChannelFuture future) throws Exception {
            if (!future.isSuccess()) {
                inputChannel.onError(new LocalTransportException("Sending the task event failed.", future.channel().localAddress(), future.cause()));
            }
        }
    });
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) TaskEventRequest(org.apache.flink.runtime.io.network.netty.NettyMessage.TaskEventRequest) LocalTransportException(org.apache.flink.runtime.io.network.netty.exception.LocalTransportException) ChannelFutureListener(io.netty.channel.ChannelFutureListener) IOException(java.io.IOException) LocalTransportException(org.apache.flink.runtime.io.network.netty.exception.LocalTransportException)

Example 3 with LocalTransportException

use of org.apache.flink.runtime.io.network.netty.exception.LocalTransportException in project flink by apache.

the class PartitionRequestClientHandler method exceptionCaught.

/**
	 * 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);
    }
}
Also used : RemoteTransportException(org.apache.flink.runtime.io.network.netty.exception.RemoteTransportException) LocalTransportException(org.apache.flink.runtime.io.network.netty.exception.LocalTransportException) IOException(java.io.IOException) SocketAddress(java.net.SocketAddress) TransportException(org.apache.flink.runtime.io.network.netty.exception.TransportException) LocalTransportException(org.apache.flink.runtime.io.network.netty.exception.LocalTransportException) RemoteTransportException(org.apache.flink.runtime.io.network.netty.exception.RemoteTransportException)

Aggregations

LocalTransportException (org.apache.flink.runtime.io.network.netty.exception.LocalTransportException)3 ChannelFuture (io.netty.channel.ChannelFuture)2 ChannelFutureListener (io.netty.channel.ChannelFutureListener)2 IOException (java.io.IOException)2 SocketAddress (java.net.SocketAddress)1 PartitionRequest (org.apache.flink.runtime.io.network.netty.NettyMessage.PartitionRequest)1 TaskEventRequest (org.apache.flink.runtime.io.network.netty.NettyMessage.TaskEventRequest)1 RemoteTransportException (org.apache.flink.runtime.io.network.netty.exception.RemoteTransportException)1 TransportException (org.apache.flink.runtime.io.network.netty.exception.TransportException)1