本文整理汇总了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);
}
}
}
示例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();
}
示例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();
}
示例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.");
}
}
示例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();
}
示例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);
}
示例7: testInstanceOfCancelTaskException
import org.apache.flink.runtime.execution.CancelTaskException; //导入依赖的package包/类
@Test
public void testInstanceOfCancelTaskException() throws Exception {
assertTrue(CancelTaskException.class.isAssignableFrom(ProducerFailedException.class));
}
示例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;
}