use of org.apache.flink.runtime.rest.RestServerEndpoint in project flink by apache.
the class RestClusterClientSavepointTriggerTest method testTriggerSavepointRetry.
@Test
public void testTriggerSavepointRetry() throws Exception {
final TriggerId triggerId = new TriggerId();
final String expectedSavepointDir = "hello";
final AtomicBoolean failRequest = new AtomicBoolean(true);
try (final RestServerEndpoint restServerEndpoint = createRestServerEndpoint(request -> triggerId, trigger -> {
if (failRequest.compareAndSet(true, false)) {
throw new RestHandlerException("expected", HttpResponseStatus.SERVICE_UNAVAILABLE);
} else {
return new SavepointInfo(expectedSavepointDir, null);
}
})) {
final RestClusterClient<?> restClusterClient = createRestClusterClient(restServerEndpoint.getServerAddress().getPort());
final String savepointPath = restClusterClient.triggerSavepoint(new JobID(), null, SavepointFormatType.CANONICAL).get();
assertEquals(expectedSavepointDir, savepointPath);
}
}
use of org.apache.flink.runtime.rest.RestServerEndpoint in project flink by apache.
the class RestClusterClientSavepointTriggerTest method testTriggerSavepointDefaultDirectory.
@Test
public void testTriggerSavepointDefaultDirectory() throws Exception {
final TriggerId triggerId = new TriggerId();
final String expectedReturnedSavepointDir = "hello";
try (final RestServerEndpoint restServerEndpoint = createRestServerEndpoint(request -> {
assertThat(request.getTargetDirectory().isPresent(), is(false));
assertFalse(request.isCancelJob());
return triggerId;
}, trigger -> {
assertEquals(triggerId, trigger);
return new SavepointInfo(expectedReturnedSavepointDir, null);
})) {
final RestClusterClient<?> restClusterClient = createRestClusterClient(restServerEndpoint.getServerAddress().getPort());
final String savepointPath = restClusterClient.triggerSavepoint(new JobID(), null, SavepointFormatType.CANONICAL).get();
assertEquals(expectedReturnedSavepointDir, savepointPath);
}
}
use of org.apache.flink.runtime.rest.RestServerEndpoint 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);
}
}
use of org.apache.flink.runtime.rest.RestServerEndpoint 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);
}
}
Aggregations