use of org.apache.flink.runtime.rest.messages.EmptyMessageParameters in project flink by apache.
the class RestServerEndpointITCase method setup.
@Before
public void setup() throws Exception {
config.setString(WebOptions.UPLOAD_DIR, temporaryFolder.newFolder().getCanonicalPath());
defaultSSLContext = SSLContext.getDefault();
defaultSSLSocketFactory = HttpsURLConnection.getDefaultSSLSocketFactory();
final SSLContext sslClientContext = SSLUtils.createRestSSLContext(config, true);
if (sslClientContext != null) {
SSLContext.setDefault(sslClientContext);
HttpsURLConnection.setDefaultSSLSocketFactory(sslClientContext.getSocketFactory());
}
RestfulGateway mockRestfulGateway = new TestingRestfulGateway.Builder().build();
final GatewayRetriever<RestfulGateway> mockGatewayRetriever = () -> CompletableFuture.completedFuture(mockRestfulGateway);
testHandler = new TestHandler(mockGatewayRetriever, RpcUtils.INF_TIMEOUT);
TestVersionHandler testVersionHandler = new TestVersionHandler(mockGatewayRetriever, RpcUtils.INF_TIMEOUT);
TestRestHandler<RestfulGateway, EmptyRequestBody, EmptyResponseBody, EmptyMessageParameters> testVersionSelectionHandler1 = new TestRestHandler<>(mockGatewayRetriever, TestVersionSelectionHeaders1.INSTANCE, FutureUtils.completedExceptionally(new RestHandlerException("test failure 1", HttpResponseStatus.OK)));
TestRestHandler<RestfulGateway, EmptyRequestBody, EmptyResponseBody, EmptyMessageParameters> testVersionSelectionHandler2 = new TestRestHandler<>(mockGatewayRetriever, TestVersionSelectionHeaders2.INSTANCE, FutureUtils.completedExceptionally(new RestHandlerException("test failure 2", HttpResponseStatus.ACCEPTED)));
testUploadHandler = new TestUploadHandler(mockGatewayRetriever, RpcUtils.INF_TIMEOUT);
final StaticFileServerHandler<RestfulGateway> staticFileServerHandler = new StaticFileServerHandler<>(mockGatewayRetriever, RpcUtils.INF_TIMEOUT, temporaryFolder.getRoot());
serverEndpoint = TestRestServerEndpoint.builder(config).withHandler(new TestHeaders(), testHandler).withHandler(TestUploadHeaders.INSTANCE, testUploadHandler).withHandler(testVersionHandler).withHandler(testVersionSelectionHandler1).withHandler(testVersionSelectionHandler2).withHandler(WebContentHandlerSpecification.getInstance(), staticFileServerHandler).buildAndStart();
restClient = new TestRestClient(config);
serverAddress = serverEndpoint.getServerAddress();
}
use of org.apache.flink.runtime.rest.messages.EmptyMessageParameters in project flink by apache.
the class AbstractHandlerITCase method testOOMErrorMessageEnrichment.
@Test
public void testOOMErrorMessageEnrichment() throws Exception {
final TestMessageHeaders<EmptyRequestBody, EmptyResponseBody, EmptyMessageParameters> messageHeaders = TestMessageHeaders.emptyBuilder().setTargetRestEndpointURL("/test-handler").build();
final TestRestHandler<RestfulGateway, EmptyRequestBody, EmptyResponseBody, EmptyMessageParameters> testRestHandler = new TestRestHandler<>(mockGatewayRetriever, messageHeaders, FutureUtils.completedExceptionally(new OutOfMemoryError("Metaspace")));
try (final TestRestServerEndpoint server = TestRestServerEndpoint.builder(REST_BASE_CONFIG).withHandler(messageHeaders, testRestHandler).buildAndStart();
final RestClient restClient = createRestClient(server.getServerAddress().getPort())) {
CompletableFuture<EmptyResponseBody> response = restClient.sendRequest(server.getServerAddress().getHostName(), server.getServerAddress().getPort(), messageHeaders, EmptyMessageParameters.getInstance(), EmptyRequestBody.getInstance());
try {
response.get();
fail("An ExecutionException was expected here being caused by the OutOfMemoryError.");
} catch (ExecutionException e) {
assertThat(e.getMessage(), StringContains.containsString("Metaspace. The metaspace out-of-memory error has occurred. "));
}
}
}
Aggregations