use of org.apache.flink.util.FlinkRuntimeException in project flink by apache.
the class AbstractFileSource method createEnumerator.
@Override
public SplitEnumerator<SplitT, PendingSplitsCheckpoint<SplitT>> createEnumerator(SplitEnumeratorContext<SplitT> enumContext) {
final FileEnumerator enumerator = enumeratorFactory.create();
// read the initial set of splits (which is also the total set of splits for bounded
// sources)
final Collection<FileSourceSplit> splits;
try {
// TODO - in the next cleanup pass, we should try to remove the need to "wrap unchecked"
// here
splits = enumerator.enumerateSplits(inputPaths, enumContext.currentParallelism());
} catch (IOException e) {
throw new FlinkRuntimeException("Could not enumerate file splits", e);
}
return createSplitEnumerator(enumContext, enumerator, splits, null);
}
use of org.apache.flink.util.FlinkRuntimeException in project flink by apache.
the class FutureUtilsTest method testStopAtNonRetryableException.
/**
* Test that {@link FutureUtils#retry} should stop at non-retryable exception.
*/
@Test
public void testStopAtNonRetryableException() {
final int retries = 10;
final int notRetry = 3;
final AtomicInteger atomicInteger = new AtomicInteger(0);
final FlinkRuntimeException nonRetryableException = new FlinkRuntimeException("Non-retryable exception");
CompletableFuture<Boolean> retryFuture = FutureUtils.retry(() -> CompletableFuture.supplyAsync(() -> {
if (atomicInteger.incrementAndGet() == notRetry) {
// throw non-retryable exception
throw new CompletionException(nonRetryableException);
} else {
throw new CompletionException(new FlinkException("Test exception"));
}
}, TestingUtils.defaultExecutor()), retries, throwable -> ExceptionUtils.findThrowable(throwable, FlinkException.class).isPresent(), TestingUtils.defaultExecutor());
try {
retryFuture.get();
fail("Exception should be thrown.");
} catch (Exception ex) {
assertThat(ex, FlinkMatchers.containsCause(nonRetryableException));
}
assertThat(atomicInteger.get(), is(notRetry));
}
use of org.apache.flink.util.FlinkRuntimeException in project flink by apache.
the class JobDispatcherLeaderProcessFactoryFactory method createFactory.
@Override
public JobDispatcherLeaderProcessFactory createFactory(JobPersistenceComponentFactory jobPersistenceComponentFactory, Executor ioExecutor, RpcService rpcService, PartialDispatcherServices partialDispatcherServices, FatalErrorHandler fatalErrorHandler) {
final JobGraph jobGraph;
try {
jobGraph = Preconditions.checkNotNull(jobGraphRetriever.retrieveJobGraph(partialDispatcherServices.getConfiguration()));
} catch (FlinkException e) {
throw new FlinkRuntimeException("Could not retrieve the JobGraph.", e);
}
final JobResultStore jobResultStore = jobPersistenceComponentFactory.createJobResultStore();
final Collection<JobResult> recoveredDirtyJobResults = getDirtyJobResults(jobResultStore);
final Optional<JobResult> maybeRecoveredDirtyJobResult = extractDirtyJobResult(recoveredDirtyJobResults, jobGraph);
final Optional<JobGraph> maybeJobGraph = getJobGraphBasedOnDirtyJobResults(jobGraph, recoveredDirtyJobResults);
final DefaultDispatcherGatewayServiceFactory defaultDispatcherServiceFactory = new DefaultDispatcherGatewayServiceFactory(JobDispatcherFactory.INSTANCE, rpcService, partialDispatcherServices);
return new JobDispatcherLeaderProcessFactory(defaultDispatcherServiceFactory, maybeJobGraph.orElse(null), maybeRecoveredDirtyJobResult.orElse(null), jobResultStore, fatalErrorHandler);
}
use of org.apache.flink.util.FlinkRuntimeException in project flink by apache.
the class NFA method findFinalStateAfterProceed.
private State<T> findFinalStateAfterProceed(ConditionContext context, State<T> state, T event) {
final Stack<State<T>> statesToCheck = new Stack<>();
statesToCheck.push(state);
try {
while (!statesToCheck.isEmpty()) {
final State<T> currentState = statesToCheck.pop();
for (StateTransition<T> transition : currentState.getStateTransitions()) {
if (transition.getAction() == StateTransitionAction.PROCEED && checkFilterCondition(context, transition.getCondition(), event)) {
if (transition.getTargetState().isFinal()) {
return transition.getTargetState();
} else {
statesToCheck.push(transition.getTargetState());
}
}
}
}
} catch (Exception e) {
throw new FlinkRuntimeException("Failure happened in filter function.", e);
}
return null;
}
use of org.apache.flink.util.FlinkRuntimeException in project flink by apache.
the class ApplicationDispatcherGatewayServiceFactory method create.
@Override
public AbstractDispatcherLeaderProcess.DispatcherGatewayService create(DispatcherId fencingToken, Collection<JobGraph> recoveredJobs, Collection<JobResult> recoveredDirtyJobResults, JobGraphWriter jobGraphWriter, JobResultStore jobResultStore) {
final List<JobID> recoveredJobIds = getRecoveredJobIds(recoveredJobs);
final Dispatcher dispatcher;
try {
dispatcher = dispatcherFactory.createDispatcher(rpcService, fencingToken, recoveredJobs, recoveredDirtyJobResults, (dispatcherGateway, scheduledExecutor, errorHandler) -> new ApplicationDispatcherBootstrap(application, recoveredJobIds, configuration, dispatcherGateway, scheduledExecutor, errorHandler), PartialDispatcherServicesWithJobPersistenceComponents.from(partialDispatcherServices, jobGraphWriter, jobResultStore));
} catch (Exception e) {
throw new FlinkRuntimeException("Could not create the Dispatcher rpc endpoint.", e);
}
dispatcher.start();
return DefaultDispatcherGatewayService.from(dispatcher);
}
Aggregations