ApplicationSpecification spec = this.store.getApplication
(new Id.Application(new Id.Account(accountId), applicationId));
applications.add(spec);
}
Iterable<Discoverable> discoverables = this.discoveryServiceClient.discover(Constants.Service.METRICS);
Discoverable discoverable = new TimeLimitEndpointStrategy(new RandomEndpointStrategy(discoverables),
DISCOVERY_TIMEOUT_SECONDS, TimeUnit.SECONDS).pick();
if (discoverable == null) {
LOG.error("Fail to get any metrics endpoint for deleting metrics.");
throw new IOException("Can't find Metrics endpoint");
}
for (MetricsScope scope : MetricsScope.values()) {
for (ApplicationSpecification application : applications) {
String url = String.format("http://%s:%d%s/metrics/%s/apps/%s",
discoverable.getSocketAddress().getHostName(),
discoverable.getSocketAddress().getPort(),
Constants.Gateway.GATEWAY_VERSION,
scope.name().toLowerCase(),
application.getName());
sendMetricsDelete(url);
}
}
if (applicationId == null) {
String url = String.format("http://%s:%d%s/metrics", discoverable.getSocketAddress().getHostName(),
discoverable.getSocketAddress().getPort(), Constants.Gateway.GATEWAY_VERSION);
sendMetricsDelete(url);
}
}