org.apache.flink.runtime.rest.messages.TriggerId Java Examples
The following examples show how to use
org.apache.flink.runtime.rest.messages.TriggerId.
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: SavepointHandlersTest.java From flink with Apache License 2.0 | 6 votes |
@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 #2
Source File: RestClusterClientSavepointTriggerTest.java From flink with Apache License 2.0 | 6 votes |
@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 #3
Source File: AbstractAsynchronousOperationHandlersTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that an querying an unknown trigger id will return an exceptionally completed * future. */ @Test public void testUnknownTriggerId() throws Exception { final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder().build(); try { testingStatusHandler.handleRequest( statusOperationRequest(new TriggerId()), testingRestfulGateway).get(); fail("This should have failed with a RestHandlerException."); } catch (ExecutionException ee) { final Optional<RestHandlerException> optionalRestHandlerException = ExceptionUtils.findThrowable(ee, RestHandlerException.class); assertThat(optionalRestHandlerException.isPresent(), is(true)); final RestHandlerException restHandlerException = optionalRestHandlerException.get(); assertThat(restHandlerException.getMessage(), containsString("Operation not found")); assertThat(restHandlerException.getHttpResponseStatus(), is(HttpResponseStatus.NOT_FOUND)); } }
Example #4
Source File: SavepointHandlersTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@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 #5
Source File: RestClusterClientSavepointTriggerTest.java From flink with Apache License 2.0 | 6 votes |
@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 #6
Source File: SavepointHandlersTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@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 #7
Source File: AbstractAsynchronousOperationHandlersTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that the future returned by {@link AbstractAsynchronousOperationHandlers.StatusHandler#closeAsync()} * completes when the result of the asynchronous operation is served. */ @Test public void testCloseShouldFinishOnFirstServedResult() throws Exception { final CompletableFuture<String> savepointFuture = new CompletableFuture<>(); final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder() .setTriggerSavepointFunction((JobID jobId, String directory) -> savepointFuture) .build(); final TriggerId triggerId = testingTriggerHandler.handleRequest( triggerOperationRequest(), testingRestfulGateway).get().getTriggerId(); final CompletableFuture<Void> closeFuture = testingStatusHandler.closeAsync(); testingStatusHandler.handleRequest(statusOperationRequest(triggerId), testingRestfulGateway).get(); assertThat(closeFuture.isDone(), is(false)); savepointFuture.complete("foobar"); testingStatusHandler.handleRequest(statusOperationRequest(triggerId), testingRestfulGateway).get(); assertThat(closeFuture.isDone(), is(true)); }
Example #8
Source File: AbstractAsynchronousOperationHandlersTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests the triggering and exceptional completion of an asynchronous operation. */ @Test public void testOperationFailure() throws Exception { final FlinkException testException = new FlinkException("Test exception"); final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder() .setTriggerSavepointFunction((JobID jobId, String directory) -> FutureUtils.completedExceptionally(testException)) .build(); // trigger the operation final TriggerId triggerId = testingTriggerHandler.handleRequest( triggerOperationRequest(), testingRestfulGateway).get().getTriggerId(); AsynchronousOperationResult<OperationResult> operationResult = testingStatusHandler.handleRequest( statusOperationRequest(triggerId), testingRestfulGateway).get(); assertThat(operationResult.queueStatus().getId(), is(QueueStatus.completed().getId())); final OperationResult resource = operationResult.resource(); assertThat(resource.throwable, is(testException)); }
Example #9
Source File: AbstractAsynchronousOperationHandlersTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Tests the triggering and exceptional completion of an asynchronous operation. */ @Test public void testOperationFailure() throws Exception { final FlinkException testException = new FlinkException("Test exception"); final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder() .setTriggerSavepointFunction((JobID jobId, String directory) -> FutureUtils.completedExceptionally(testException)) .build(); // trigger the operation final TriggerId triggerId = testingTriggerHandler.handleRequest( triggerOperationRequest(), testingRestfulGateway).get().getTriggerId(); AsynchronousOperationResult<OperationResult> operationResult = testingStatusHandler.handleRequest( statusOperationRequest(triggerId), testingRestfulGateway).get(); assertThat(operationResult.queueStatus().getId(), is(QueueStatus.completed().getId())); final OperationResult resource = operationResult.resource(); assertThat(resource.throwable, is(testException)); }
Example #10
Source File: AbstractAsynchronousOperationHandlersTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Tests that an querying an unknown trigger id will return an exceptionally completed * future. */ @Test public void testUnknownTriggerId() throws Exception { final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder().build(); try { testingStatusHandler.handleRequest( statusOperationRequest(new TriggerId()), testingRestfulGateway).get(); fail("This should have failed with a RestHandlerException."); } catch (ExecutionException ee) { final Optional<RestHandlerException> optionalRestHandlerException = ExceptionUtils.findThrowable(ee, RestHandlerException.class); assertThat(optionalRestHandlerException.isPresent(), is(true)); final RestHandlerException restHandlerException = optionalRestHandlerException.get(); assertThat(restHandlerException.getMessage(), containsString("Operation not found")); assertThat(restHandlerException.getHttpResponseStatus(), is(HttpResponseStatus.NOT_FOUND)); } }
Example #11
Source File: AbstractAsynchronousOperationHandlersTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Tests that the future returned by {@link AbstractAsynchronousOperationHandlers.StatusHandler#closeAsync()} * completes when the result of the asynchronous operation is served. */ @Test public void testCloseShouldFinishOnFirstServedResult() throws Exception { final CompletableFuture<String> savepointFuture = new CompletableFuture<>(); final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder() .setTriggerSavepointFunction((JobID jobId, String directory) -> savepointFuture) .build(); final TriggerId triggerId = testingTriggerHandler.handleRequest( triggerOperationRequest(), testingRestfulGateway).get().getTriggerId(); final CompletableFuture<Void> closeFuture = testingStatusHandler.closeAsync(); testingStatusHandler.handleRequest(statusOperationRequest(triggerId), testingRestfulGateway).get(); assertThat(closeFuture.isDone(), is(false)); savepointFuture.complete("foobar"); testingStatusHandler.handleRequest(statusOperationRequest(triggerId), testingRestfulGateway).get(); assertThat(closeFuture.isDone(), is(true)); }
Example #12
Source File: RestClusterClient.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private CompletableFuture<String> triggerSavepoint( final JobID jobId, final @Nullable String savepointDirectory, final boolean cancelJob) { final SavepointTriggerHeaders savepointTriggerHeaders = SavepointTriggerHeaders.getInstance(); final SavepointTriggerMessageParameters savepointTriggerMessageParameters = savepointTriggerHeaders.getUnresolvedMessageParameters(); savepointTriggerMessageParameters.jobID.resolve(jobId); final CompletableFuture<TriggerResponse> responseFuture = sendRequest( savepointTriggerHeaders, savepointTriggerMessageParameters, new SavepointTriggerRequestBody(savepointDirectory, cancelJob)); return responseFuture.thenCompose(savepointTriggerResponseBody -> { final TriggerId savepointTriggerId = savepointTriggerResponseBody.getTriggerId(); return pollSavepointAsync(jobId, savepointTriggerId); }).thenApply(savepointInfo -> { if (savepointInfo.getFailureCause() != null) { throw new CompletionException(savepointInfo.getFailureCause()); } return savepointInfo.getLocation(); }); }
Example #13
Source File: RestClusterClientSavepointTriggerTest.java From flink with Apache License 2.0 | 6 votes |
@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 #14
Source File: RestClusterClientSavepointTriggerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@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 |
@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 #16
Source File: SavepointHandlersTest.java From flink with Apache License 2.0 | 6 votes |
@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 #17
Source File: StopWithSavepointHandlersTest.java From flink with Apache License 2.0 | 6 votes |
@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 #18
Source File: StopWithSavepointHandlersTest.java From flink with Apache License 2.0 | 6 votes |
@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 #19
Source File: RestClusterClientTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override protected CompletableFuture<AsynchronousOperationResult<AsynchronousOperationInfo>> handleRequest(@Nonnull HandlerRequest<EmptyRequestBody, SavepointDisposalStatusMessageParameters> request, @Nonnull DispatcherGateway gateway) throws RestHandlerException { final TriggerId actualTriggerId = request.getPathParameter(TriggerIdPathParameter.class); if (actualTriggerId.equals(triggerId)) { final OptionalFailure<AsynchronousOperationInfo> nextResponse = responses.poll(); if (nextResponse != null) { if (nextResponse.isFailure()) { throw new RestHandlerException("Failure", HttpResponseStatus.BAD_REQUEST, nextResponse.getFailureCause()); } else { return CompletableFuture.completedFuture(AsynchronousOperationResult.completed(nextResponse.getUnchecked())); } } else { throw new AssertionError(); } } else { throw new AssertionError(); } }
Example #20
Source File: RestClusterClientSavepointTriggerTest.java From flink with Apache License 2.0 | 6 votes |
@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 #21
Source File: RestClusterClientTest.java From flink with Apache License 2.0 | 6 votes |
@Override protected CompletableFuture<AsynchronousOperationResult<AsynchronousOperationInfo>> handleRequest(@Nonnull HandlerRequest<EmptyRequestBody, SavepointDisposalStatusMessageParameters> request, @Nonnull DispatcherGateway gateway) throws RestHandlerException { final TriggerId actualTriggerId = request.getPathParameter(TriggerIdPathParameter.class); if (actualTriggerId.equals(triggerId)) { final OptionalFailure<AsynchronousOperationInfo> nextResponse = responses.poll(); if (nextResponse != null) { if (nextResponse.isFailure()) { throw new RestHandlerException("Failure", HttpResponseStatus.BAD_REQUEST, nextResponse.getFailureCause()); } else { return CompletableFuture.completedFuture(AsynchronousOperationResult.completed(nextResponse.getUnchecked())); } } else { throw new AssertionError(); } } else { throw new AssertionError(); } }
Example #22
Source File: RestClusterClientSavepointTriggerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@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: RestClusterClientSavepointTriggerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@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 #24
Source File: RestClusterClientSavepointTriggerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@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 #25
Source File: RestClusterClientSavepointTriggerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@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 #26
Source File: RestClusterClient.java From flink with Apache License 2.0 | 5 votes |
@Override public CompletableFuture<Acknowledge> disposeSavepoint(String savepointPath) { final SavepointDisposalRequest savepointDisposalRequest = new SavepointDisposalRequest(savepointPath); final CompletableFuture<TriggerResponse> savepointDisposalTriggerFuture = sendRequest( SavepointDisposalTriggerHeaders.getInstance(), savepointDisposalRequest); final CompletableFuture<AsynchronousOperationInfo> savepointDisposalFuture = savepointDisposalTriggerFuture.thenCompose( (TriggerResponse triggerResponse) -> { final TriggerId triggerId = triggerResponse.getTriggerId(); final SavepointDisposalStatusHeaders savepointDisposalStatusHeaders = SavepointDisposalStatusHeaders.getInstance(); final SavepointDisposalStatusMessageParameters savepointDisposalStatusMessageParameters = savepointDisposalStatusHeaders.getUnresolvedMessageParameters(); savepointDisposalStatusMessageParameters.triggerIdPathParameter.resolve(triggerId); return pollResourceAsync( () -> sendRequest( savepointDisposalStatusHeaders, savepointDisposalStatusMessageParameters)); }); return savepointDisposalFuture.thenApply( (AsynchronousOperationInfo asynchronousOperationInfo) -> { if (asynchronousOperationInfo.getFailureCause() == null) { return Acknowledge.get(); } else { throw new CompletionException(asynchronousOperationInfo.getFailureCause()); } }); }
Example #27
Source File: RestClusterClient.java From flink with Apache License 2.0 | 5 votes |
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 #28
Source File: SavepointHandlersTest.java From flink with Apache License 2.0 | 5 votes |
private static HandlerRequest<EmptyRequestBody, SavepointStatusMessageParameters> savepointStatusRequest( final TriggerId triggerId) throws HandlerRequestException { final Map<String, String> pathParameters = new HashMap<>(); pathParameters.put(JobIDPathParameter.KEY, JOB_ID.toString()); pathParameters.put(TriggerIdPathParameter.KEY, triggerId.toString()); return new HandlerRequest<>( EmptyRequestBody.getInstance(), new SavepointStatusMessageParameters(), pathParameters, Collections.emptyMap()); }
Example #29
Source File: RestClusterClientSavepointTriggerTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
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 #30
Source File: RestClusterClientSavepointTriggerTest.java From flink with Apache License 2.0 | 5 votes |
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)); }