use of org.apache.flink.util.SerializedThrowable in project flink by apache.
the class CheckpointResourcesCleanupRunnerTest method testResultFutureWithErrorAfterStart.
private static void testResultFutureWithErrorAfterStart(ThrowingConsumer<CheckpointResourcesCleanupRunner, ? extends Exception> preCheckLifecycleHandling) throws Exception {
final SerializedThrowable expectedError = new SerializedThrowable(new Exception("Expected exception"));
final CompletableFuture<JobManagerRunnerResult> actualResult = getResultFutureFromTestInstance(createJobResultWithFailure(expectedError), preCheckLifecycleHandling);
assertThat(actualResult).isCompletedWithValueMatching(jobManagerRunnerResult -> Objects.requireNonNull(jobManagerRunnerResult.getExecutionGraphInfo().getArchivedExecutionGraph().getFailureInfo()).getException().equals(expectedError), "JobManagerRunner should have failed with expected error");
}
use of org.apache.flink.util.SerializedThrowable in project flink by apache.
the class CheckpointResourcesCleanupRunnerTest method testResultFutureWithErrorBeforeStart.
@Test
public void testResultFutureWithErrorBeforeStart() throws Exception {
final CompletableFuture<JobManagerRunnerResult> resultFuture = getResultFutureFromTestInstance(createJobResultWithFailure(new SerializedThrowable(new Exception("Expected exception"))), BEFORE_START);
assertThat(resultFuture).isNotCompleted();
}
use of org.apache.flink.util.SerializedThrowable in project flink by apache.
the class SerializedThrowableDeserializer method deserialize.
@Override
public SerializedThrowable deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
final JsonNode root = p.readValueAsTree();
final byte[] serializedException = root.get(FIELD_NAME_SERIALIZED_THROWABLE).binaryValue();
try {
return InstantiationUtil.deserializeObject(serializedException, ClassLoader.getSystemClassLoader());
} catch (ClassNotFoundException e) {
throw new IOException("Failed to deserialize " + SerializedThrowable.class.getCanonicalName(), e);
}
}
use of org.apache.flink.util.SerializedThrowable in project flink by apache.
the class RestClusterClientTest method testDisposeSavepoint.
@Test
public void testDisposeSavepoint() throws Exception {
final String savepointPath = "foobar";
final String exceptionMessage = "Test exception.";
final FlinkException testException = new FlinkException(exceptionMessage);
final TestSavepointDisposalHandlers testSavepointDisposalHandlers = new TestSavepointDisposalHandlers(savepointPath);
final TestSavepointDisposalHandlers.TestSavepointDisposalTriggerHandler testSavepointDisposalTriggerHandler = testSavepointDisposalHandlers.new TestSavepointDisposalTriggerHandler();
final TestSavepointDisposalHandlers.TestSavepointDisposalStatusHandler testSavepointDisposalStatusHandler = testSavepointDisposalHandlers.new TestSavepointDisposalStatusHandler(OptionalFailure.of(AsynchronousOperationInfo.complete()), OptionalFailure.of(AsynchronousOperationInfo.completeExceptional(new SerializedThrowable(testException))), OptionalFailure.ofFailure(testException));
try (TestRestServerEndpoint restServerEndpoint = createRestServerEndpoint(testSavepointDisposalStatusHandler, testSavepointDisposalTriggerHandler)) {
RestClusterClient<?> restClusterClient = createRestClusterClient(restServerEndpoint.getServerAddress().getPort());
try {
{
final CompletableFuture<Acknowledge> disposeSavepointFuture = restClusterClient.disposeSavepoint(savepointPath);
assertThat(disposeSavepointFuture.get(), is(Acknowledge.get()));
}
{
final CompletableFuture<Acknowledge> disposeSavepointFuture = restClusterClient.disposeSavepoint(savepointPath);
try {
disposeSavepointFuture.get();
fail("Expected an exception");
} catch (ExecutionException ee) {
assertThat(ExceptionUtils.findThrowableWithMessage(ee, exceptionMessage).isPresent(), is(true));
}
}
{
try {
restClusterClient.disposeSavepoint(savepointPath).get();
fail("Expected an exception.");
} catch (ExecutionException ee) {
assertThat(ExceptionUtils.findThrowable(ee, RestClientException.class).isPresent(), is(true));
}
}
} finally {
restClusterClient.close();
}
}
}
use of org.apache.flink.util.SerializedThrowable in project flink by apache.
the class WritableSavepointITCase method validateModification.
private void validateModification(StateBackend backend, String savepointPath) throws Exception {
StreamExecutionEnvironment sEnv = StreamExecutionEnvironment.getExecutionEnvironment();
sEnv.setStateBackend(backend);
DataStream<Account> stream = sEnv.fromCollection(accounts).keyBy(acc -> acc.id).flatMap(new UpdateAndGetAccount()).uid(ACCOUNT_UID);
CompletableFuture<Collection<Account>> results = collector.collect(stream);
stream.map(acc -> acc.id).map(new StatefulOperator()).uid(MODIFY_UID).addSink(new DiscardingSink<>());
JobGraph jobGraph = sEnv.getStreamGraph().getJobGraph();
jobGraph.setSavepointRestoreSettings(SavepointRestoreSettings.forPath(savepointPath, false));
ClusterClient<?> client = MINI_CLUSTER_RESOURCE.getClusterClient();
Optional<SerializedThrowable> serializedThrowable = client.submitJob(jobGraph).thenCompose(client::requestJobResult).get().getSerializedThrowable();
Assert.assertFalse(serializedThrowable.isPresent());
Assert.assertEquals("Unexpected output", 3, results.get().size());
}
Aggregations