org.apache.flink.runtime.rest.RestServerEndpoint Java Examples
The following examples show how to use
org.apache.flink.runtime.rest.RestServerEndpoint.
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-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 #2
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 #3
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 #4
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).get(); assertEquals(expectedSavepointDir, savepointPath); } }
Example #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
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 #13
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 #14
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 #15
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 #16
Source File: DocumentingRestEndpoint.java From flink with Apache License 2.0 | 5 votes |
default List<MessageHeaders<?, ?, ?>> getSpecs() { final Comparator<String> comparator = new RestServerEndpoint.RestHandlerUrlComparator.CaseInsensitiveOrderComparator(); return initializeHandlers(CompletableFuture.completedFuture(null)).stream() .map(tuple -> tuple.f0) .filter(spec -> spec instanceof MessageHeaders) .map(spec -> (MessageHeaders<?, ?, ?>) spec) .sorted((spec1, spec2) -> comparator.compare(spec1.getTargetRestEndpointURL(), spec2.getTargetRestEndpointURL())) .collect(Collectors.toList()); }
Example #17
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 #18
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)); }
Example #19
Source File: DocumentingRestEndpoint.java From flink with Apache License 2.0 | 5 votes |
default List<MessageHeaders<?, ?, ?>> getSpecs() { final Comparator<String> comparator = new RestServerEndpoint.RestHandlerUrlComparator.CaseInsensitiveOrderComparator(); return initializeHandlers(CompletableFuture.completedFuture(null)).stream() .map(tuple -> tuple.f0) .filter(spec -> spec instanceof MessageHeaders) .map(spec -> (MessageHeaders<?, ?, ?>) spec) .sorted((spec1, spec2) -> comparator.compare(spec1.getTargetRestEndpointURL(), spec2.getTargetRestEndpointURL())) .collect(Collectors.toList()); }
Example #20
Source File: RestAPIDocGenerator.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
default List<MessageHeaders> getSpecs() { Comparator<String> comparator = new RestServerEndpoint.RestHandlerUrlComparator.CaseInsensitiveOrderComparator(); return initializeHandlers(CompletableFuture.completedFuture(null)).stream() .map(tuple -> tuple.f0) .filter(spec -> spec instanceof MessageHeaders) .map(spec -> (MessageHeaders) spec) .sorted((spec1, spec2) -> comparator.compare(spec1.getTargetRestEndpointURL(), spec2.getTargetRestEndpointURL())) .collect(Collectors.toList()); }
Example #21
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)); }