當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。