use of org.apache.flink.util.FlinkRuntimeException in project flink by apache.
the class XaFacadeImpl method endAndPrepare.
@Override
public void endAndPrepare(Xid xid) {
execute(Command.fromRunnable("end", xid, () -> xaResource.end(xid, XAResource.TMSUCCESS)));
int prepResult = execute(new Command<>("prepare", of(xid), () -> xaResource.prepare(xid)));
if (prepResult == XAResource.XA_RDONLY) {
throw new EmptyXaTransactionException(xid);
} else if (prepResult != XAResource.XA_OK) {
throw new FlinkRuntimeException(formatErrorMessage("prepare", of(xid), empty(), "response: " + prepResult));
}
}
use of org.apache.flink.util.FlinkRuntimeException in project flink by apache.
the class DriverBaseITCase method getSystemOutput.
/**
* Capture the command-line standard output from the driver execution.
*
* @param args driver command-line arguments
* @return standard output from driver execution
* @throws Exception on error
*/
private String getSystemOutput(String[] args) throws Exception {
ByteArrayOutputStream output = new ByteArrayOutputStream();
// Configure object reuse mode
switch(mode) {
case CLUSTER:
case COLLECTION:
args = ArrayUtils.add(args, "--__disable_object_reuse");
break;
case CLUSTER_OBJECT_REUSE:
// object reuse is enabled by default when executing drivers
break;
default:
throw new FlinkRuntimeException("Unknown execution mode " + mode);
}
// Redirect stdout
PrintStream stdout = System.out;
System.setOut(new PrintStream(output));
Runner.main(args);
// Restore stdout
System.setOut(stdout);
return output.toString();
}
use of org.apache.flink.util.FlinkRuntimeException in project flink by apache.
the class DefaultDispatcherGatewayServiceFactory method create.
@Override
public AbstractDispatcherLeaderProcess.DispatcherGatewayService create(DispatcherId fencingToken, Collection<JobGraph> recoveredJobs, Collection<JobResult> recoveredDirtyJobResults, JobGraphWriter jobGraphWriter, JobResultStore jobResultStore) {
final Dispatcher dispatcher;
try {
dispatcher = dispatcherFactory.createDispatcher(rpcService, fencingToken, recoveredJobs, recoveredDirtyJobResults, (dispatcherGateway, scheduledExecutor, errorHandler) -> new NoOpDispatcherBootstrap(), 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);
}
use of org.apache.flink.util.FlinkRuntimeException in project flink by apache.
the class SubtaskGatewayImpl method sendEvent.
@Override
public CompletableFuture<Acknowledge> sendEvent(OperatorEvent evt) {
if (!isReady()) {
throw new FlinkRuntimeException("SubtaskGateway is not ready, task not yet running.");
}
final SerializedValue<OperatorEvent> serializedEvent;
try {
serializedEvent = new SerializedValue<>(evt);
} catch (IOException e) {
// unchecked so that it can bubble up
throw new FlinkRuntimeException("Cannot serialize operator event", e);
}
final Callable<CompletableFuture<Acknowledge>> sendAction = subtaskAccess.createEventSendAction(serializedEvent);
final CompletableFuture<Acknowledge> sendResult = new CompletableFuture<>();
final CompletableFuture<Acknowledge> result = sendResult.whenCompleteAsync((success, failure) -> {
if (failure != null && subtaskAccess.isStillRunning()) {
String msg = String.format(EVENT_LOSS_ERROR_MESSAGE, evt, subtaskAccess.subtaskName());
Runnables.assertNoException(() -> subtaskAccess.triggerTaskFailover(new FlinkException(msg, failure)));
}
}, sendingExecutor);
sendingExecutor.execute(() -> {
sender.sendEvent(sendAction, sendResult);
incompleteFuturesTracker.trackFutureWhileIncomplete(result);
});
return result;
}
use of org.apache.flink.util.FlinkRuntimeException in project flink by apache.
the class JobMasterServiceLeadershipRunnerTest method testJobMasterServiceProcessCreationFailureIsForwardedToResultFuture.
@Test
public void testJobMasterServiceProcessCreationFailureIsForwardedToResultFuture() throws Exception {
final FlinkRuntimeException testException = new FlinkRuntimeException("Test exception");
final JobMasterServiceLeadershipRunner jobManagerRunner = newJobMasterServiceLeadershipRunnerBuilder().setJobMasterServiceProcessFactory(TestingJobMasterServiceProcessFactory.newBuilder().setJobMasterServiceProcessFunction(ignored -> {
throw testException;
}).build()).build();
jobManagerRunner.start();
leaderElectionService.isLeader(UUID.randomUUID());
assertThat(jobManagerRunner.getResultFuture(), FlinkMatchers.futureWillCompleteExceptionally(cause -> ExceptionUtils.findThrowable(cause, testException::equals).isPresent(), Duration.ofMillis(5L), "Result future should be completed exceptionally."));
}
Aggregations