Search in sources :

Example 1 with TaskEventRequest

use of org.apache.flink.runtime.io.network.netty.NettyMessage.TaskEventRequest in project flink by apache.

the class PartitionRequestServerHandler method channelRead0.

@Override
protected void channelRead0(ChannelHandlerContext ctx, NettyMessage msg) throws Exception {
    try {
        Class<?> msgClazz = msg.getClass();
        // ----------------------------------------------------------------
        if (msgClazz == PartitionRequest.class) {
            PartitionRequest request = (PartitionRequest) msg;
            LOG.debug("Read channel on {}: {}.", ctx.channel().localAddress(), request);
            try {
                SequenceNumberingViewReader reader = new SequenceNumberingViewReader(request.receiverId, outboundQueue);
                reader.requestSubpartitionView(partitionProvider, request.partitionId, request.queueIndex, bufferPool);
            } catch (PartitionNotFoundException notFound) {
                respondWithError(ctx, notFound, request.receiverId);
            }
        } else // ----------------------------------------------------------------
        if (msgClazz == TaskEventRequest.class) {
            TaskEventRequest request = (TaskEventRequest) msg;
            if (!taskEventDispatcher.publish(request.partitionId, request.event)) {
                respondWithError(ctx, new IllegalArgumentException("Task event receiver not found."), request.receiverId);
            }
        } else if (msgClazz == CancelPartitionRequest.class) {
            CancelPartitionRequest request = (CancelPartitionRequest) msg;
            outboundQueue.cancel(request.receiverId);
        } else if (msgClazz == CloseRequest.class) {
            outboundQueue.close();
        } else {
            LOG.warn("Received unexpected client request: {}", msg);
        }
    } catch (Throwable t) {
        respondWithError(ctx, t);
    }
}
Also used : PartitionNotFoundException(org.apache.flink.runtime.io.network.partition.PartitionNotFoundException) CancelPartitionRequest(org.apache.flink.runtime.io.network.netty.NettyMessage.CancelPartitionRequest) CancelPartitionRequest(org.apache.flink.runtime.io.network.netty.NettyMessage.CancelPartitionRequest) PartitionRequest(org.apache.flink.runtime.io.network.netty.NettyMessage.PartitionRequest) TaskEventRequest(org.apache.flink.runtime.io.network.netty.NettyMessage.TaskEventRequest) CloseRequest(org.apache.flink.runtime.io.network.netty.NettyMessage.CloseRequest)

Example 2 with TaskEventRequest

use of org.apache.flink.runtime.io.network.netty.NettyMessage.TaskEventRequest 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)

Aggregations

TaskEventRequest (org.apache.flink.runtime.io.network.netty.NettyMessage.TaskEventRequest)2 ChannelFuture (io.netty.channel.ChannelFuture)1 ChannelFutureListener (io.netty.channel.ChannelFutureListener)1 IOException (java.io.IOException)1 CancelPartitionRequest (org.apache.flink.runtime.io.network.netty.NettyMessage.CancelPartitionRequest)1 CloseRequest (org.apache.flink.runtime.io.network.netty.NettyMessage.CloseRequest)1 PartitionRequest (org.apache.flink.runtime.io.network.netty.NettyMessage.PartitionRequest)1 LocalTransportException (org.apache.flink.runtime.io.network.netty.exception.LocalTransportException)1 PartitionNotFoundException (org.apache.flink.runtime.io.network.partition.PartitionNotFoundException)1