Search in sources :

Example 1 with AsynchronousJobOperationKey

use of org.apache.flink.runtime.rest.handler.job.AsynchronousJobOperationKey in project flink by apache.

the class SavepointHandlersTest method testProvidedTriggerId.

@Test
public void testProvidedTriggerId() throws Exception {
    final OperationResult<String> successfulResult = OperationResult.success(COMPLETED_SAVEPOINT_EXTERNAL_POINTER);
    AtomicReference<AsynchronousJobOperationKey> keyReference = new AtomicReference<>();
    final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder().setTriggerSavepointFunction(setReferenceToOperationKey(keyReference)).setGetSavepointStatusFunction(getResultIfKeyMatches(successfulResult, keyReference)).build();
    final TriggerId providedTriggerId = new TriggerId();
    final TriggerId returnedTriggerId = savepointTriggerHandler.handleRequest(triggerSavepointRequest(DEFAULT_REQUESTED_SAVEPOINT_TARGET_DIRECTORY, SavepointFormatType.CANONICAL, providedTriggerId), testingRestfulGateway).get().getTriggerId();
    assertEquals(providedTriggerId, returnedTriggerId);
    AsynchronousOperationResult<SavepointInfo> savepointResponseBody;
    savepointResponseBody = savepointStatusHandler.handleRequest(savepointStatusRequest(providedTriggerId), 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 2 with AsynchronousJobOperationKey

use of org.apache.flink.runtime.rest.handler.job.AsynchronousJobOperationKey in project flink by apache.

the class SavepointHandlersTest method testSavepointCompletedSuccessfully.

@Test
public void testSavepointCompletedSuccessfully() throws Exception {
    final OperationResult<String> successfulResult = OperationResult.success(COMPLETED_SAVEPOINT_EXTERNAL_POINTER);
    final AtomicReference<AsynchronousJobOperationKey> keyReference = new AtomicReference<>();
    final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder().setTriggerSavepointFunction(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 3 with AsynchronousJobOperationKey

use of org.apache.flink.runtime.rest.handler.job.AsynchronousJobOperationKey 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 4 with AsynchronousJobOperationKey

use of org.apache.flink.runtime.rest.handler.job.AsynchronousJobOperationKey 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 5 with AsynchronousJobOperationKey

use of org.apache.flink.runtime.rest.handler.job.AsynchronousJobOperationKey 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

AsynchronousJobOperationKey (org.apache.flink.runtime.rest.handler.job.AsynchronousJobOperationKey)10 TestingRestfulGateway (org.apache.flink.runtime.webmonitor.TestingRestfulGateway)10 Test (org.junit.Test)10 AtomicReference (java.util.concurrent.atomic.AtomicReference)6 TriggerId (org.apache.flink.runtime.rest.messages.TriggerId)6 SavepointInfo (org.apache.flink.runtime.rest.messages.job.savepoints.SavepointInfo)6 SavepointFormatType (org.apache.flink.core.execution.SavepointFormatType)4 CompletableFuture (java.util.concurrent.CompletableFuture)2 RestHandlerException (org.apache.flink.runtime.rest.handler.RestHandlerException)2