当前位置: 首页>>代码示例>>Java>>正文


Java CancelTaskException类代码示例

本文整理汇总了Java中org.apache.flink.runtime.execution.CancelTaskException的典型用法代码示例。如果您正苦于以下问题:Java CancelTaskException类的具体用法?Java CancelTaskException怎么用?Java CancelTaskException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CancelTaskException类属于org.apache.flink.runtime.execution包,在下文中一共展示了CancelTaskException类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkError

import org.apache.flink.runtime.execution.CancelTaskException; //导入依赖的package包/类
/**
 * Checks for an error and rethrows it if one was reported.
 */
protected void checkError() throws IOException {
	final Throwable t = cause.get();

	if (t != null) {
		if (t instanceof CancelTaskException) {
			throw (CancelTaskException) t;
		}
		if (t instanceof IOException) {
			throw (IOException) t;
		}
		else {
			throw new IOException(t);
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:19,代码来源:InputChannel.java

示例2: testProducerFailedException

import org.apache.flink.runtime.execution.CancelTaskException; //导入依赖的package包/类
@Test(expected = CancelTaskException.class)
public void testProducerFailedException() throws Exception {

	ConnectionManager connManager = mock(ConnectionManager.class);
	when(connManager.createPartitionRequestClient(any(ConnectionID.class)))
			.thenReturn(mock(PartitionRequestClient.class));

	final RemoteInputChannel ch = new RemoteInputChannel(
			mock(SingleInputGate.class),
			0,
			new ResultPartitionID(),
			mock(ConnectionID.class),
			connManager,
			UnregisteredMetricGroups.createUnregisteredTaskMetricGroup().getIOMetricGroup());

	ch.onError(new ProducerFailedException(new RuntimeException("Expected test exception.")));

	ch.requestSubpartition(0);

	// Should throw an instance of CancelTaskException.
	ch.getNextBuffer();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:RemoteInputChannelTest.java

示例3: testProducerFailedException

import org.apache.flink.runtime.execution.CancelTaskException; //导入依赖的package包/类
@Test(expected = CancelTaskException.class)
public void testProducerFailedException() throws Exception {
	ResultSubpartitionView view = mock(ResultSubpartitionView.class);
	when(view.isReleased()).thenReturn(true);
	when(view.getFailureCause()).thenReturn(new Exception("Expected test exception"));

	ResultPartitionManager partitionManager = mock(ResultPartitionManager.class);
	when(partitionManager
			.createSubpartitionView(any(ResultPartitionID.class), anyInt(), any(BufferAvailabilityListener.class)))
			.thenReturn(view);

	SingleInputGate inputGate = mock(SingleInputGate.class);
	BufferProvider bufferProvider = mock(BufferProvider.class);
	when(inputGate.getBufferProvider()).thenReturn(bufferProvider);

	LocalInputChannel ch = createLocalInputChannel(
			inputGate, partitionManager, new Tuple2<>(0, 0));

	ch.requestSubpartition(0);

	// Should throw an instance of CancelTaskException.
	ch.getNextBuffer();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:24,代码来源:LocalInputChannelTest.java

示例4: getNextBuffer

import org.apache.flink.runtime.execution.CancelTaskException; //导入依赖的package包/类
@Override
BufferAndAvailability getNextBuffer() throws IOException, InterruptedException {
	checkError();

	ResultSubpartitionView subpartitionView = this.subpartitionView;
	if (subpartitionView == null) {
		// this can happen if the request for the partition was triggered asynchronously
		// by the time trigger
		// would be good to avoid that, by guaranteeing that the requestPartition() and
		// getNextBuffer() always come from the same thread
		// we could do that by letting the timer insert a special "requesting channel" into the input gate's queue
		subpartitionView = checkAndWaitForSubpartitionView();
	}

	BufferAndBacklog next = subpartitionView.getNextBuffer();

	if (next == null) {
		if (subpartitionView.isReleased()) {
			throw new CancelTaskException("Consumed partition " + subpartitionView + " has been released.");
		} else {
			// This means there is a bug in the buffer availability
			// notifications.
			throw new IllegalStateException("Consumed partition has no buffers available. " +
				"Number of received buffer notifications is " + numBuffersAvailable + ".");
		}
	}

	long remaining = numBuffersAvailable.decrementAndGet();

	if (remaining >= 0) {
		numBytesIn.inc(next.buffer().getSizeUnsafe());
		return new BufferAndAvailability(next.buffer(), remaining > 0, next.buffersInBacklog());
	} else if (subpartitionView.isReleased()) {
		throw new ProducerFailedException(subpartitionView.getFailureCause());
	} else {
		throw new IllegalStateException("No buffer available and producer partition not released.");
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:39,代码来源:LocalInputChannel.java

示例5: invoke

import org.apache.flink.runtime.execution.CancelTaskException; //导入依赖的package包/类
@Override
public void invoke() throws Exception {
	awaitLatch.trigger();

	try {
		triggerLatch.await();
	}
	catch (Throwable ignored) {}
	
	throw new CancelTaskException();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:12,代码来源:TaskTest.java

示例6: testProducerFailedException

import org.apache.flink.runtime.execution.CancelTaskException; //导入依赖的package包/类
@Test
public void testProducerFailedException() throws Exception {
	PartitionRequestQueue queue = new PartitionRequestQueue();

	ResultPartitionProvider partitionProvider = mock(ResultPartitionProvider.class);
	ResultPartitionID rpid = new ResultPartitionID();

	ResultSubpartitionView view = mock(ResultSubpartitionView.class);
	when(view.isReleased()).thenReturn(true);
	when(view.getFailureCause()).thenReturn(new RuntimeException("Expected test exception"));

	when(partitionProvider.createSubpartitionView(
		eq(rpid),
		eq(0),
		any(BufferAvailabilityListener.class))).thenReturn(view);

	EmbeddedChannel ch = new EmbeddedChannel(queue);

	SequenceNumberingViewReader seqView = new SequenceNumberingViewReader(new InputChannelID(), queue);
	seqView.requestSubpartitionView(partitionProvider, rpid, 0);

	// Enqueue the erroneous view
	queue.notifyReaderNonEmpty(seqView);
	ch.runPendingTasks();

	// Read the enqueued msg
	Object msg = ch.readOutbound();

	assertEquals(msg.getClass(), NettyMessage.ErrorResponse.class);

	NettyMessage.ErrorResponse err = (NettyMessage.ErrorResponse) msg;
	assertTrue(err.cause instanceof CancelTaskException);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:34,代码来源:PartitionRequestQueueTest.java

示例7: testInstanceOfCancelTaskException

import org.apache.flink.runtime.execution.CancelTaskException; //导入依赖的package包/类
@Test
public void testInstanceOfCancelTaskException() throws Exception {
	assertTrue(CancelTaskException.class.isAssignableFrom(ProducerFailedException.class));
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:5,代码来源:ProducerFailedExceptionTest.java

示例8: getReceiverList

import org.apache.flink.runtime.execution.CancelTaskException; //导入依赖的package包/类
/**
 * Returns the list of receivers for transfer envelopes produced by the channel with the given source channel ID.
 *
 * @param jobID
 *        the ID of the job the given channel ID belongs to
 * @param sourceChannelID
 *        the source channel ID for which the receiver list shall be retrieved
 * @return the list of receivers or <code>null</code> if the receiver could not be determined
 * @throws IOException
 */
private EnvelopeReceiverList getReceiverList(JobID jobID, ChannelID sourceChannelID, boolean reportException) throws IOException {
	EnvelopeReceiverList receiverList = this.receiverCache.get(sourceChannelID);

	if (receiverList != null) {
		return receiverList;
	}

	while (true) {
		ConnectionInfoLookupResponse lookupResponse;
		synchronized (this.channelLookupService) {
			lookupResponse = this.channelLookupService.lookupConnectionInfo(this.connectionInfo, jobID, sourceChannelID);
		}

		if (lookupResponse.receiverReady()) {
			receiverList = new EnvelopeReceiverList(lookupResponse);
			break;
		}
		else if (lookupResponse.receiverNotReady()) {
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				if (reportException) {
					throw new IOException("Lookup was interrupted.");
				} else {
					return null;
				}
			}
		}
		else if (lookupResponse.isJobAborting()) {
			if (reportException) {
				throw new CancelTaskException();
			} else {
				return null;
			}
		}
		else if (lookupResponse.receiverNotFound()) {
			if (reportException) {
				throw new IOException("Could not find the receiver for Job " + jobID + ", channel with source id " + sourceChannelID);
			} else {
				return null;
			}
		}
		else {
			throw new IllegalStateException("Unrecognized response to channel lookup.");
		}
	}

	this.receiverCache.put(sourceChannelID, receiverList);

	if (LOG.isDebugEnabled()) {
		LOG.debug(String.format("Receiver for %s: %s [%s])",
				sourceChannelID,
				receiverList.hasLocalReceiver() ? receiverList.getLocalReceiver() : receiverList.getRemoteReceiver(),
				receiverList.hasLocalReceiver() ? "local" : "remote"));
	}

	return receiverList;
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:69,代码来源:ChannelManager.java


注:本文中的org.apache.flink.runtime.execution.CancelTaskException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。