org.apache.flink.runtime.rest.messages.job.savepoints.SavepointInfo Java Examples

The following examples show how to use org.apache.flink.runtime.rest.messages.job.savepoints.SavepointInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestClusterClientSavepointTriggerTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testTriggerSavepointDefaultDirectory() throws Exception {
	final TriggerId triggerId = new TriggerId();
	final String expectedReturnedSavepointDir = "hello";

	try (final RestServerEndpoint restServerEndpoint = createRestServerEndpoint(
		request -> {
			assertNull(request.getTargetDirectory());
			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).get();
		assertEquals(expectedReturnedSavepointDir, savepointPath);
	}
}
 
Example #2
Source File: StopWithSavepointHandlersTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testSavepointCompletedSuccessfully() throws Exception {
	final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder()
			.setStopWithSavepointFunction((JobID jobId, String targetDirectory) -> CompletableFuture.completedFuture(COMPLETED_SAVEPOINT_EXTERNAL_POINTER))
			.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));
}
 
Example #3
Source File: RestClusterClientSavepointTriggerTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@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).get();
		assertEquals(expectedSavepointDir, savepointPath);
	}
}
 
Example #4
Source File: RestClusterClientSavepointTriggerTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testTriggerSavepointFailure() throws Exception {
	final TriggerId triggerId = new TriggerId();

	try (final RestServerEndpoint restServerEndpoint = createRestServerEndpoint(
		request -> triggerId,
		trigger -> new SavepointInfo(null, new SerializedThrowable(new RuntimeException("expected"))))) {

		final RestClusterClient<?> restClusterClient = createRestClusterClient(restServerEndpoint.getServerAddress().getPort());

		try {
			restClusterClient.triggerSavepoint(new JobID(), null).get();
		} catch (ExecutionException e) {
			final Throwable cause = e.getCause();
			assertThat(cause, instanceOf(SerializedThrowable.class));
			assertThat(((SerializedThrowable) cause)
				.deserializeError(ClassLoader.getSystemClassLoader())
				.getMessage(), equalTo("expected"));
		}
	}
}
 
Example #5
Source File: RestClusterClientSavepointTriggerTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@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);
		assertEquals(expectedSavepointDir, savepointPath);
	}
}
 
Example #6
Source File: RestClusterClientSavepointTriggerTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@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());
			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).get();
		assertEquals(expectedReturnedSavepointDir, savepointPath);
	}
}
 
Example #7
Source File: RestClusterClientSavepointTriggerTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testTriggerSavepointDefaultDirectory() throws Exception {
	final TriggerId triggerId = new TriggerId();
	final String expectedReturnedSavepointDir = "hello";

	try (final RestServerEndpoint restServerEndpoint = createRestServerEndpoint(
		request -> {
			assertNull(request.getTargetDirectory());
			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).get();
		assertEquals(expectedReturnedSavepointDir, savepointPath);
	}
}
 
Example #8
Source File: StopWithSavepointHandlersTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testSavepointCompletedWithException() throws Exception {
	TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder()
			.setStopWithSavepointFunction((JobID jobId, String directory) -> FutureUtils.completedExceptionally(new RuntimeException("expected")))
			.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));
}
 
Example #9
Source File: StopWithSavepointHandlersTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testSavepointCompletedWithException() throws Exception {
	TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder()
			.setStopWithSavepointFunction((JobID jobId, String directory) -> FutureUtils.completedExceptionally(new RuntimeException("expected")))
			.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));
}
 
Example #10
Source File: StopWithSavepointHandlersTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testSavepointCompletedSuccessfully() throws Exception {
	final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder()
			.setStopWithSavepointFunction((JobID jobId, String targetDirectory) -> CompletableFuture.completedFuture(COMPLETED_SAVEPOINT_EXTERNAL_POINTER))
			.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));
}
 
Example #11
Source File: SavepointHandlersTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testSavepointCompletedWithException() throws Exception {
	TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder()
		.setTriggerSavepointFunction((JobID jobId, String directory) -> FutureUtils.completedExceptionally(new RuntimeException("expected")))
		.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));
}
 
Example #12
Source File: SavepointHandlersTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testSavepointCompletedSuccessfully() throws Exception {
	final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder()
		.setTriggerSavepointFunction((JobID jobId, String targetDirectory) -> CompletableFuture.completedFuture(COMPLETED_SAVEPOINT_EXTERNAL_POINTER))
		.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));
}
 
Example #13
Source File: SavepointHandlersTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testSavepointCompletedWithException() throws Exception {
	TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder()
		.setTriggerSavepointFunction((JobID jobId, String directory) -> FutureUtils.completedExceptionally(new RuntimeException("expected")))
		.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));
}
 
Example #14
Source File: RestClusterClientSavepointTriggerTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@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());
			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).get();
		assertEquals(expectedReturnedSavepointDir, savepointPath);
	}
}
 
Example #15
Source File: RestClusterClientSavepointTriggerTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@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).get();
		assertEquals(expectedSavepointDir, savepointPath);
	}
}
 
Example #16
Source File: RestClusterClientSavepointTriggerTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testTriggerSavepointFailure() throws Exception {
	final TriggerId triggerId = new TriggerId();

	try (final RestServerEndpoint restServerEndpoint = createRestServerEndpoint(
		request -> triggerId,
		trigger -> new SavepointInfo(null, new SerializedThrowable(new RuntimeException("expected"))))) {

		final RestClusterClient<?> restClusterClient = createRestClusterClient(restServerEndpoint.getServerAddress().getPort());

		try {
			restClusterClient.triggerSavepoint(new JobID(), null).get();
		} catch (ExecutionException e) {
			final Throwable cause = e.getCause();
			assertThat(cause, instanceOf(SerializedThrowable.class));
			assertThat(((SerializedThrowable) cause)
				.deserializeError(ClassLoader.getSystemClassLoader())
				.getMessage(), equalTo("expected"));
		}
	}
}
 
Example #17
Source File: RestClusterClientSavepointTriggerTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@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).get();
		assertEquals(expectedSavepointDir, savepointPath);
	}
}
 
Example #18
Source File: RestClusterClientSavepointTriggerTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testTriggerSavepointFailure() throws Exception {
	final TriggerId triggerId = new TriggerId();

	try (final RestServerEndpoint restServerEndpoint = createRestServerEndpoint(
		request -> triggerId,
		trigger -> new SavepointInfo(null, new SerializedThrowable(new RuntimeException("expected"))))) {

		final RestClusterClient<?> restClusterClient = createRestClusterClient(restServerEndpoint.getServerAddress().getPort());

		try {
			restClusterClient.triggerSavepoint(new JobID(), null).get();
		} catch (ExecutionException e) {
			final Throwable cause = e.getCause();
			assertThat(cause, instanceOf(SerializedThrowable.class));
			assertThat(((SerializedThrowable) cause)
				.deserializeError(ClassLoader.getSystemClassLoader())
				.getMessage(), equalTo("expected"));
		}
	}
}
 
Example #19
Source File: RestClusterClientSavepointTriggerTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@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);
		assertEquals(expectedSavepointDir, savepointPath);
	}
}
 
Example #20
Source File: RestClusterClientSavepointTriggerTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@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());
			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).get();
		assertEquals(expectedReturnedSavepointDir, savepointPath);
	}
}
 
Example #21
Source File: RestClusterClientSavepointTriggerTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testTriggerSavepointDefaultDirectory() throws Exception {
	final TriggerId triggerId = new TriggerId();
	final String expectedReturnedSavepointDir = "hello";

	try (final RestServerEndpoint restServerEndpoint = createRestServerEndpoint(
		request -> {
			assertNull(request.getTargetDirectory());
			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).get();
		assertEquals(expectedReturnedSavepointDir, savepointPath);
	}
}
 
Example #22
Source File: RestClusterClientSavepointTriggerTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@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).get();
		assertEquals(expectedSavepointDir, savepointPath);
	}
}
 
Example #23
Source File: SavepointHandlersTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testSavepointCompletedWithException() throws Exception {
	TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder()
		.setTriggerSavepointFunction((JobID jobId, String directory) -> FutureUtils.completedExceptionally(new RuntimeException("expected")))
		.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));
}
 
Example #24
Source File: SavepointHandlersTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testSavepointCompletedSuccessfully() throws Exception {
	final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder()
		.setTriggerSavepointFunction((JobID jobId, String targetDirectory) -> CompletableFuture.completedFuture(COMPLETED_SAVEPOINT_EXTERNAL_POINTER))
		.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));
}
 
Example #25
Source File: SavepointHandlersTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testSavepointCompletedSuccessfully() throws Exception {
	final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder()
		.setTriggerSavepointFunction((JobID jobId, String targetDirectory) -> CompletableFuture.completedFuture(COMPLETED_SAVEPOINT_EXTERNAL_POINTER))
		.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));
}
 
Example #26
Source File: RestClusterClient.java    From flink with Apache License 2.0 5 votes vote down vote up
private CompletableFuture<SavepointInfo> pollSavepointAsync(
		final JobID jobId,
		final TriggerId triggerID) {
	return pollResourceAsync(() -> {
		final SavepointStatusHeaders savepointStatusHeaders = SavepointStatusHeaders.getInstance();
		final SavepointStatusMessageParameters savepointStatusMessageParameters =
			savepointStatusHeaders.getUnresolvedMessageParameters();
		savepointStatusMessageParameters.jobIdPathParameter.resolve(jobId);
		savepointStatusMessageParameters.triggerIdPathParameter.resolve(triggerID);
		return sendRequest(
			savepointStatusHeaders,
			savepointStatusMessageParameters);
	});
}
 
Example #27
Source File: RestClusterClientSavepointTriggerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected CompletableFuture<AsynchronousOperationResult<SavepointInfo>> handleRequest(
		@Nonnull HandlerRequest<EmptyRequestBody, SavepointStatusMessageParameters> request,
		@Nonnull DispatcherGateway gateway) throws RestHandlerException {

	final TriggerId triggerId = request.getPathParameter(TriggerIdPathParameter.class);
	return CompletableFuture.completedFuture(AsynchronousOperationResult.completed(savepointHandlerLogic.apply(triggerId)));
}
 
Example #28
Source File: RestClusterClientSavepointTriggerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static RestServerEndpoint createRestServerEndpoint(
		final FunctionWithException<SavepointTriggerRequestBody, TriggerId, RestHandlerException> triggerHandlerLogic,
		final FunctionWithException<TriggerId, SavepointInfo, RestHandlerException> savepointHandlerLogic) throws Exception {
	return TestRestServerEndpoint.createAndStartRestServerEndpoint(
		restServerEndpointConfiguration,
		new TestSavepointTriggerHandler(triggerHandlerLogic),
		new TestSavepointHandler(savepointHandlerLogic));
}
 
Example #29
Source File: RestClusterClientSavepointTriggerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected CompletableFuture<AsynchronousOperationResult<SavepointInfo>> handleRequest(
		@Nonnull HandlerRequest<EmptyRequestBody, SavepointStatusMessageParameters> request,
		@Nonnull DispatcherGateway gateway) throws RestHandlerException {

	final TriggerId triggerId = request.getPathParameter(TriggerIdPathParameter.class);
	return CompletableFuture.completedFuture(AsynchronousOperationResult.completed(savepointHandlerLogic.apply(triggerId)));
}
 
Example #30
Source File: RestClusterClientSavepointTriggerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static RestServerEndpoint createRestServerEndpoint(
		final FunctionWithException<SavepointTriggerRequestBody, TriggerId, RestHandlerException> triggerHandlerLogic,
		final FunctionWithException<TriggerId, SavepointInfo, RestHandlerException> savepointHandlerLogic) throws Exception {
	return TestRestServerEndpoint.createAndStartRestServerEndpoint(
		restServerEndpointConfiguration,
		new TestSavepointTriggerHandler(triggerHandlerLogic),
		new TestSavepointHandler(savepointHandlerLogic));
}