use of org.apache.flink.runtime.rest.RestClient in project flink by apache.
the class MetricsAvailabilityITCase method testReporter.
@Test
public void testReporter() throws Exception {
try (ClusterController ignored = dist.startCluster(1)) {
final RestClient restClient = new RestClient(new Configuration(), scheduledExecutorService);
checkJobManagerMetricAvailability(restClient);
final Collection<ResourceID> taskManagerIds = getTaskManagerIds(restClient);
for (final ResourceID taskManagerId : taskManagerIds) {
checkTaskManagerMetricAvailability(restClient, taskManagerId);
}
}
}
use of org.apache.flink.runtime.rest.RestClient in project flink by apache.
the class AbstractHandlerITCase method createRestClient.
private RestClient createRestClient(int serverPort) throws ConfigurationException {
Configuration config = new Configuration(REST_BASE_CONFIG);
config.setInteger(RestOptions.PORT, serverPort);
return new RestClient(config, Executors.directExecutor());
}
use of org.apache.flink.runtime.rest.RestClient in project flink by apache.
the class LocalStandaloneFlinkResource method startCluster.
@Override
public ClusterController startCluster(int numTaskManagers) throws IOException {
distribution.setTaskExecutorHosts(Collections.nCopies(numTaskManagers, "localhost"));
distribution.startFlinkCluster();
try (final RestClient restClient = new RestClient(new Configuration(), Executors.directExecutor())) {
for (int retryAttempt = 0; retryAttempt < 30; retryAttempt++) {
final CompletableFuture<TaskManagersInfo> localhost = restClient.sendRequest("localhost", 8081, TaskManagersHeaders.getInstance(), EmptyMessageParameters.getInstance(), EmptyRequestBody.getInstance());
try {
final TaskManagersInfo taskManagersInfo = localhost.get(1, TimeUnit.SECONDS);
final int numRunningTaskManagers = taskManagersInfo.getTaskManagerInfos().size();
if (numRunningTaskManagers == numTaskManagers) {
return new StandaloneClusterController(distribution);
} else {
LOG.info("Waiting for task managers to come up. {}/{} are currently running.", numRunningTaskManagers, numTaskManagers);
}
} catch (InterruptedException e) {
LOG.info("Waiting for dispatcher REST endpoint to come up...");
Thread.currentThread().interrupt();
} catch (TimeoutException | ExecutionException e) {
// ExecutionExceptions may occur if leader election is still going on
LOG.info("Waiting for dispatcher REST endpoint to come up...");
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
} catch (ConfigurationException e) {
throw new RuntimeException("Could not create RestClient.", e);
} catch (Exception e) {
throw new RuntimeException(e);
}
throw new RuntimeException("Cluster did not start in expected time-frame.");
}
use of org.apache.flink.runtime.rest.RestClient in project flink by apache.
the class RestClusterClientSavepointTriggerTest method createRestClusterClient.
private RestClusterClient<StandaloneClusterId> createRestClusterClient(final int port) throws Exception {
final Configuration clientConfig = new Configuration(REST_CONFIG);
clientConfig.setInteger(RestOptions.PORT, port);
return new RestClusterClient<>(clientConfig, new RestClient(REST_CONFIG, executor), StandaloneClusterId.getInstance(), (attempt) -> 0);
}
use of org.apache.flink.runtime.rest.RestClient 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