Search in sources :

Example 6 with SavepointInfo

use of org.apache.flink.runtime.rest.messages.job.savepoints.SavepointInfo in project flink by apache.

the class SavepointHandlersTest method testSavepointCompletedWithException.

@Test
public void testSavepointCompletedWithException() throws Exception {
    final OperationResult<String> failedResult = OperationResult.failure(new RuntimeException("expected"));
    final AtomicReference<AsynchronousJobOperationKey> keyReference = new AtomicReference<>();
    TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder().setTriggerSavepointFunction(setReferenceToOperationKey(keyReference)).setGetSavepointStatusFunction(getResultIfKeyMatches(failedResult, keyReference)).build();
    final TriggerId triggerId = savepointTriggerHandler.handleRequest(triggerSavepointRequest(), testingRestfulGateway).get().getTriggerId();
    final AsynchronousOperationResult<SavepointInfo> savepointResponseBody = savepointStatusHandler.handleRequest(savepointStatusRequest(triggerId), testingRestfulGateway).get();
    assertThat(savepointResponseBody.queueStatus().getId(), equalTo(QueueStatus.Id.COMPLETED));
    assertThat(savepointResponseBody.resource(), notNullValue());
    assertThat(savepointResponseBody.resource().getFailureCause(), notNullValue());
    final Throwable savepointError = savepointResponseBody.resource().getFailureCause().deserializeError(ClassLoader.getSystemClassLoader());
    assertThat(savepointError.getMessage(), equalTo("expected"));
    assertThat(savepointError, instanceOf(RuntimeException.class));
}
Also used : TriggerId(org.apache.flink.runtime.rest.messages.TriggerId) AsynchronousJobOperationKey(org.apache.flink.runtime.rest.handler.job.AsynchronousJobOperationKey) AtomicReference(java.util.concurrent.atomic.AtomicReference) SavepointInfo(org.apache.flink.runtime.rest.messages.job.savepoints.SavepointInfo) TestingRestfulGateway(org.apache.flink.runtime.webmonitor.TestingRestfulGateway) Test(org.junit.Test)

Example 7 with SavepointInfo

use of org.apache.flink.runtime.rest.messages.job.savepoints.SavepointInfo in project flink by apache.

the class StopWithSavepointHandlersTest method testSavepointCompletedSuccessfully.

@Test
public void testSavepointCompletedSuccessfully() throws Exception {
    final OperationResult<String> successfulResult = OperationResult.success(COMPLETED_SAVEPOINT_EXTERNAL_POINTER);
    AtomicReference<AsynchronousJobOperationKey> keyReference = new AtomicReference<>();
    final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder().setStopWithSavepointFunction(setReferenceToOperationKey(keyReference)).setGetSavepointStatusFunction(getResultIfKeyMatches(successfulResult, keyReference)).build();
    final TriggerId triggerId = savepointTriggerHandler.handleRequest(triggerSavepointRequest(), testingRestfulGateway).get().getTriggerId();
    AsynchronousOperationResult<SavepointInfo> savepointResponseBody;
    savepointResponseBody = savepointStatusHandler.handleRequest(savepointStatusRequest(triggerId), testingRestfulGateway).get();
    assertThat(savepointResponseBody.queueStatus().getId(), equalTo(QueueStatus.Id.COMPLETED));
    assertThat(savepointResponseBody.resource(), notNullValue());
    assertThat(savepointResponseBody.resource().getLocation(), equalTo(COMPLETED_SAVEPOINT_EXTERNAL_POINTER));
}
Also used : TriggerId(org.apache.flink.runtime.rest.messages.TriggerId) AsynchronousJobOperationKey(org.apache.flink.runtime.rest.handler.job.AsynchronousJobOperationKey) AtomicReference(java.util.concurrent.atomic.AtomicReference) SavepointInfo(org.apache.flink.runtime.rest.messages.job.savepoints.SavepointInfo) TestingRestfulGateway(org.apache.flink.runtime.webmonitor.TestingRestfulGateway) Test(org.junit.Test)

Example 8 with SavepointInfo

use of org.apache.flink.runtime.rest.messages.job.savepoints.SavepointInfo in project flink by apache.

the class RestClusterClientSavepointTriggerTest method testTriggerSavepointTargetDirectory.

@Test
public void testTriggerSavepointTargetDirectory() throws Exception {
    final TriggerId triggerId = new TriggerId();
    final String expectedSubmittedSavepointDir = "world";
    final String expectedReturnedSavepointDir = "hello";
    try (final RestServerEndpoint restServerEndpoint = createRestServerEndpoint(triggerRequestBody -> {
        assertEquals(expectedSubmittedSavepointDir, triggerRequestBody.getTargetDirectory().get());
        assertFalse(triggerRequestBody.isCancelJob());
        return triggerId;
    }, statusRequestTriggerId -> {
        assertEquals(triggerId, statusRequestTriggerId);
        return new SavepointInfo(expectedReturnedSavepointDir, null);
    })) {
        final RestClusterClient<?> restClusterClient = createRestClusterClient(restServerEndpoint.getServerAddress().getPort());
        final String savepointPath = restClusterClient.triggerSavepoint(new JobID(), expectedSubmittedSavepointDir, SavepointFormatType.CANONICAL).get();
        assertEquals(expectedReturnedSavepointDir, savepointPath);
    }
}
Also used : TriggerId(org.apache.flink.runtime.rest.messages.TriggerId) TestRestServerEndpoint(org.apache.flink.runtime.rest.util.TestRestServerEndpoint) RestServerEndpoint(org.apache.flink.runtime.rest.RestServerEndpoint) SavepointInfo(org.apache.flink.runtime.rest.messages.job.savepoints.SavepointInfo) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 9 with SavepointInfo

use of org.apache.flink.runtime.rest.messages.job.savepoints.SavepointInfo in project flink by apache.

the class RestClusterClientSavepointTriggerTest method testTriggerSavepointCancelJob.

@Test
public void testTriggerSavepointCancelJob() throws Exception {
    final TriggerId triggerId = new TriggerId();
    final String expectedSavepointDir = "hello";
    try (final RestServerEndpoint restServerEndpoint = createRestServerEndpoint(request -> {
        assertTrue(request.isCancelJob());
        return triggerId;
    }, trigger -> {
        assertEquals(triggerId, trigger);
        return new SavepointInfo(expectedSavepointDir, null);
    })) {
        final RestClusterClient<?> restClusterClient = createRestClusterClient(restServerEndpoint.getServerAddress().getPort());
        final String savepointPath = restClusterClient.cancelWithSavepoint(new JobID(), null, SavepointFormatType.CANONICAL).get();
        assertEquals(expectedSavepointDir, savepointPath);
    }
}
Also used : TriggerId(org.apache.flink.runtime.rest.messages.TriggerId) TestRestServerEndpoint(org.apache.flink.runtime.rest.util.TestRestServerEndpoint) RestServerEndpoint(org.apache.flink.runtime.rest.RestServerEndpoint) SavepointInfo(org.apache.flink.runtime.rest.messages.job.savepoints.SavepointInfo) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 10 with SavepointInfo

use of org.apache.flink.runtime.rest.messages.job.savepoints.SavepointInfo in project flink by apache.

the class StopWithSavepointHandlersTest method testSavepointCompletedWithException.

@Test
public void testSavepointCompletedWithException() throws Exception {
    AtomicReference<AsynchronousJobOperationKey> keyReference = new AtomicReference<>();
    final OperationResult<String> failedResult = OperationResult.failure(new RuntimeException("expected"));
    TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder().setStopWithSavepointFunction(setReferenceToOperationKey(keyReference)).setGetSavepointStatusFunction(getResultIfKeyMatches(failedResult, keyReference)).build();
    final TriggerId triggerId = savepointTriggerHandler.handleRequest(triggerSavepointRequest(), testingRestfulGateway).get().getTriggerId();
    final AsynchronousOperationResult<SavepointInfo> savepointResponseBody = savepointStatusHandler.handleRequest(savepointStatusRequest(triggerId), testingRestfulGateway).get();
    assertThat(savepointResponseBody.queueStatus().getId(), equalTo(QueueStatus.Id.COMPLETED));
    assertThat(savepointResponseBody.resource(), notNullValue());
    assertThat(savepointResponseBody.resource().getFailureCause(), notNullValue());
    final Throwable savepointError = savepointResponseBody.resource().getFailureCause().deserializeError(ClassLoader.getSystemClassLoader());
    assertThat(savepointError.getMessage(), equalTo("expected"));
    assertThat(savepointError, instanceOf(RuntimeException.class));
}
Also used : TriggerId(org.apache.flink.runtime.rest.messages.TriggerId) AsynchronousJobOperationKey(org.apache.flink.runtime.rest.handler.job.AsynchronousJobOperationKey) AtomicReference(java.util.concurrent.atomic.AtomicReference) SavepointInfo(org.apache.flink.runtime.rest.messages.job.savepoints.SavepointInfo) TestingRestfulGateway(org.apache.flink.runtime.webmonitor.TestingRestfulGateway) Test(org.junit.Test)

Aggregations

TriggerId (org.apache.flink.runtime.rest.messages.TriggerId)13 SavepointInfo (org.apache.flink.runtime.rest.messages.job.savepoints.SavepointInfo)13 Test (org.junit.Test)11 AtomicReference (java.util.concurrent.atomic.AtomicReference)7 JobID (org.apache.flink.api.common.JobID)7 AsynchronousJobOperationKey (org.apache.flink.runtime.rest.handler.job.AsynchronousJobOperationKey)7 TestingRestfulGateway (org.apache.flink.runtime.webmonitor.TestingRestfulGateway)7 RestServerEndpoint (org.apache.flink.runtime.rest.RestServerEndpoint)4 TestRestServerEndpoint (org.apache.flink.runtime.rest.util.TestRestServerEndpoint)4 Collections (java.util.Collections)3 Map (java.util.Map)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 Nullable (javax.annotation.Nullable)3 Time (org.apache.flink.api.common.time.Time)3 IOException (java.io.IOException)2 ObjectOutputStream (java.io.ObjectOutputStream)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 Files (java.nio.file.Files)2