Search in sources :

Example 11 with EmptyRequestBody

use of org.apache.flink.runtime.rest.messages.EmptyRequestBody in project flink by apache.

the class WebSubmissionExtensionTest method uploadJar.

private static String uploadJar(WebSubmissionExtension extension, Path jarFile, DispatcherGateway dispatcherGateway) throws Exception {
    final JarUploadHandler jarUploadHandler = extension.getJarUploadHandler();
    final HandlerRequest<EmptyRequestBody> uploadRequest = HandlerRequest.create(EmptyRequestBody.getInstance(), EmptyMessageParameters.getInstance(), Collections.singletonList(jarFile.toFile()));
    return jarUploadHandler.handleRequest(uploadRequest, dispatcherGateway).get().getFilename();
}
Also used : JarUploadHandler(org.apache.flink.runtime.webmonitor.handlers.JarUploadHandler) EmptyRequestBody(org.apache.flink.runtime.rest.messages.EmptyRequestBody)

Example 12 with EmptyRequestBody

use of org.apache.flink.runtime.rest.messages.EmptyRequestBody in project flink by apache.

the class JarUploadHandlerTest method testFailedUpload.

@Test
public void testFailedUpload() throws Exception {
    final Path uploadedFile = jarDir.resolve("FooBazzleExample.jar");
    final HandlerRequest<EmptyRequestBody> request = createRequest(uploadedFile);
    try {
        jarUploadHandler.handleRequest(request, mockDispatcherGateway).get();
        fail("Expected exception not thrown.");
    } catch (final ExecutionException e) {
        final Throwable throwable = ExceptionUtils.stripCompletionException(e.getCause());
        assertThat(throwable, instanceOf(RestHandlerException.class));
        final RestHandlerException restHandlerException = (RestHandlerException) throwable;
        assertThat(restHandlerException.getMessage(), containsString("Could not move uploaded jar file"));
        assertThat(restHandlerException.getHttpResponseStatus(), equalTo(HttpResponseStatus.INTERNAL_SERVER_ERROR));
    }
}
Also used : Path(java.nio.file.Path) ExecutionException(java.util.concurrent.ExecutionException) EmptyRequestBody(org.apache.flink.runtime.rest.messages.EmptyRequestBody) RestHandlerException(org.apache.flink.runtime.rest.handler.RestHandlerException) Test(org.junit.Test)

Example 13 with EmptyRequestBody

use of org.apache.flink.runtime.rest.messages.EmptyRequestBody in project flink by apache.

the class JarUploadHandlerTest method testUploadJar.

@Test
public void testUploadJar() throws Exception {
    final Path uploadedFile = Files.createFile(jarDir.resolve("FooBazzleExample.jar"));
    final HandlerRequest<EmptyRequestBody> request = createRequest(uploadedFile);
    final JarUploadResponseBody jarUploadResponseBody = jarUploadHandler.handleRequest(request, mockDispatcherGateway).get();
    assertThat(jarUploadResponseBody.getStatus(), equalTo(JarUploadResponseBody.UploadStatus.success));
    final String returnedFileNameWithUUID = jarUploadResponseBody.getFilename();
    assertThat(returnedFileNameWithUUID, containsString("_"));
    final String returnedFileName = returnedFileNameWithUUID.substring(returnedFileNameWithUUID.lastIndexOf("_") + 1);
    assertThat(returnedFileName, equalTo(uploadedFile.getFileName().toString()));
}
Also used : Path(java.nio.file.Path) Matchers.containsString(org.hamcrest.Matchers.containsString) EmptyRequestBody(org.apache.flink.runtime.rest.messages.EmptyRequestBody) Test(org.junit.Test)

Example 14 with EmptyRequestBody

use of org.apache.flink.runtime.rest.messages.EmptyRequestBody in project flink by apache.

the class JobExceptionsHandlerTest method testNoExceptions.

@Test
public void testNoExceptions() throws HandlerRequestException {
    final ExecutionGraphInfo executionGraphInfo = new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().build());
    final HandlerRequest<EmptyRequestBody> request = createRequest(executionGraphInfo.getJobId(), 10);
    final JobExceptionsInfoWithHistory response = testInstance.handleRequest(request, executionGraphInfo);
    assertThat(response.getRootException(), is(nullValue()));
    assertThat(response.getRootTimestamp(), is(nullValue()));
    assertFalse(response.isTruncated());
    assertThat(response.getAllExceptions(), empty());
    assertThat(response.getExceptionHistory().getEntries(), empty());
}
Also used : ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) ArchivedExecutionGraphBuilder(org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder) EmptyRequestBody(org.apache.flink.runtime.rest.messages.EmptyRequestBody) JobExceptionsInfoWithHistory(org.apache.flink.runtime.rest.messages.JobExceptionsInfoWithHistory) Test(org.junit.Test)

Example 15 with EmptyRequestBody

use of org.apache.flink.runtime.rest.messages.EmptyRequestBody in project flink by apache.

the class JobExceptionsHandlerTest method testWithExceptionHistory.

@Test
public void testWithExceptionHistory() throws HandlerRequestException {
    final RootExceptionHistoryEntry rootCause = fromGlobalFailure(new RuntimeException("exception #0"), System.currentTimeMillis());
    final RootExceptionHistoryEntry otherFailure = new RootExceptionHistoryEntry(new RuntimeException("exception #1"), System.currentTimeMillis(), "task name", new LocalTaskManagerLocation(), Collections.emptySet());
    final ExecutionGraphInfo executionGraphInfo = createExecutionGraphInfo(rootCause, otherFailure);
    final HandlerRequest<EmptyRequestBody> request = createRequest(executionGraphInfo.getJobId(), 10);
    final JobExceptionsInfoWithHistory response = testInstance.handleRequest(request, executionGraphInfo);
    assertThat(response.getExceptionHistory().getEntries(), contains(historyContainsGlobalFailure(rootCause.getException(), rootCause.getTimestamp()), historyContainsJobExceptionInfo(otherFailure.getException(), otherFailure.getTimestamp(), otherFailure.getFailingTaskName(), JobExceptionsHandler.toString(otherFailure.getTaskManagerLocation()))));
    assertFalse(response.getExceptionHistory().isTruncated());
}
Also used : RootExceptionHistoryEntry(org.apache.flink.runtime.scheduler.exceptionhistory.RootExceptionHistoryEntry) ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) EmptyRequestBody(org.apache.flink.runtime.rest.messages.EmptyRequestBody) JobExceptionsInfoWithHistory(org.apache.flink.runtime.rest.messages.JobExceptionsInfoWithHistory) Test(org.junit.Test)

Aggregations

EmptyRequestBody (org.apache.flink.runtime.rest.messages.EmptyRequestBody)30 Test (org.junit.Test)23 HashMap (java.util.HashMap)12 List (java.util.List)8 RestHandlerException (org.apache.flink.runtime.rest.handler.RestHandlerException)7 AggregatedMetric (org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetric)7 AggregatedMetricsResponseBody (org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetricsResponseBody)7 RestfulGateway (org.apache.flink.runtime.webmonitor.RestfulGateway)6 JobExceptionsInfoWithHistory (org.apache.flink.runtime.rest.messages.JobExceptionsInfoWithHistory)5 ExecutionGraphInfo (org.apache.flink.runtime.scheduler.ExecutionGraphInfo)5 Map (java.util.Map)4 CompletableFuture (java.util.concurrent.CompletableFuture)4 Nonnull (javax.annotation.Nonnull)4 JobID (org.apache.flink.api.common.JobID)4 Time (org.apache.flink.api.common.time.Time)4 HandlerRequest (org.apache.flink.runtime.rest.handler.HandlerRequest)4 DefaultExecutionGraphCache (org.apache.flink.runtime.rest.handler.legacy.DefaultExecutionGraphCache)4 Path (java.nio.file.Path)3 CompletionException (java.util.concurrent.CompletionException)3 ExecutionException (java.util.concurrent.ExecutionException)3