use of org.apache.flink.runtime.rest.handler.job.AsynchronousJobOperationKey in project flink by apache.
the class StopWithSavepointHandlersTest method testTriggerSavepointNoDirectory.
@Test
public void testTriggerSavepointNoDirectory() throws Exception {
TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder().setStopWithSavepointFunction((AsynchronousJobOperationKey operationKey, String directory, SavepointFormatType formatType) -> CompletableFuture.completedFuture(Acknowledge.get())).build();
try {
savepointTriggerHandler.handleRequest(triggerSavepointRequestWithDefaultDirectory(), testingRestfulGateway).get();
fail("Expected exception not thrown.");
} catch (RestHandlerException rhe) {
assertThat(rhe.getMessage(), equalTo("Config key [state.savepoints.dir] is not set. " + "Property [targetDirectory] must be provided."));
assertThat(rhe.getHttpResponseStatus(), equalTo(HttpResponseStatus.BAD_REQUEST));
}
}
use of org.apache.flink.runtime.rest.handler.job.AsynchronousJobOperationKey in project flink by apache.
the class StopWithSavepointHandlersTest 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().setStopWithSavepointFunction(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));
}
use of org.apache.flink.runtime.rest.handler.job.AsynchronousJobOperationKey in project flink by apache.
the class StopWithSavepointHandlersTest method testTriggerSavepointWithDefaultDirectory.
@Test
public void testTriggerSavepointWithDefaultDirectory() throws Exception {
final CompletableFuture<String> targetDirectoryFuture = new CompletableFuture<>();
final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder().setStopWithSavepointFunction((AsynchronousJobOperationKey operationKey, String targetDirectory, SavepointFormatType formatType) -> {
targetDirectoryFuture.complete(targetDirectory);
return CompletableFuture.completedFuture(Acknowledge.get());
}).build();
final String defaultSavepointDir = "/other/dir";
final SavepointHandlers savepointHandlers = new SavepointHandlers(defaultSavepointDir);
final SavepointHandlers.StopWithSavepointHandler savepointTriggerHandler = savepointHandlers.new StopWithSavepointHandler(leaderRetriever, TIMEOUT, Collections.emptyMap());
savepointTriggerHandler.handleRequest(triggerSavepointRequestWithDefaultDirectory(), testingRestfulGateway).get();
assertThat(targetDirectoryFuture.get(), equalTo(defaultSavepointDir));
}
use of org.apache.flink.runtime.rest.handler.job.AsynchronousJobOperationKey in project flink by apache.
the class SavepointHandlersTest method testTriggerSavepointNoDirectory.
@Test
public void testTriggerSavepointNoDirectory() throws Exception {
TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder().setTriggerSavepointFunction((AsynchronousJobOperationKey operationKey, String directory, SavepointFormatType formatType) -> CompletableFuture.completedFuture(Acknowledge.get())).build();
try {
savepointTriggerHandler.handleRequest(triggerSavepointRequestWithDefaultDirectory(), testingRestfulGateway).get();
fail("Expected exception not thrown.");
} catch (RestHandlerException rhe) {
assertThat(rhe.getMessage(), equalTo("Config key [state.savepoints.dir] is not set. " + "Property [target-directory] must be provided."));
assertThat(rhe.getHttpResponseStatus(), equalTo(HttpResponseStatus.BAD_REQUEST));
}
}
use of org.apache.flink.runtime.rest.handler.job.AsynchronousJobOperationKey in project flink by apache.
the class SavepointHandlersTest method testTriggerSavepointWithDefaultDirectory.
@Test
public void testTriggerSavepointWithDefaultDirectory() throws Exception {
final CompletableFuture<String> targetDirectoryFuture = new CompletableFuture<>();
final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder().setTriggerSavepointFunction((AsynchronousJobOperationKey operationKey, String targetDirectory, SavepointFormatType formatType) -> {
targetDirectoryFuture.complete(targetDirectory);
return CompletableFuture.completedFuture(Acknowledge.get());
}).build();
final String defaultSavepointDir = "/other/dir";
final SavepointHandlers savepointHandlers = new SavepointHandlers(defaultSavepointDir);
final SavepointHandlers.SavepointTriggerHandler savepointTriggerHandler = savepointHandlers.new SavepointTriggerHandler(leaderRetriever, TIMEOUT, Collections.emptyMap());
savepointTriggerHandler.handleRequest(triggerSavepointRequestWithDefaultDirectory(), testingRestfulGateway).get();
assertThat(targetDirectoryFuture.get(), equalTo(defaultSavepointDir));
}
Aggregations