Skip to content

Commit

Permalink
Merge pull request #26504 from vespa-engine/hmusum/rename-proton-metr…
Browse files Browse the repository at this point in the history
…ics-to-searchnode-metrics-2

More proton metrics -> searchnode metrics
  • Loading branch information
Harald Musum authored Mar 20, 2023
2 parents 30dcb2d + da63d5b commit f54343d
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ private List<ApplicationId> activeApplications(TenantName tenantName) {

// ---------------- SearchNode Metrics ------------------------------------------------------------------------

public SearchNodeMetricsResponse getProtonMetrics(ApplicationId applicationId) {
public SearchNodeMetricsResponse getSearchNodeMetrics(ApplicationId applicationId) {
Application application = getApplication(applicationId);
SearchNodeMetricsRetriever searchNodeMetricsRetriever = new SearchNodeMetricsRetriever();
return searchNodeMetricsRetriever.getMetrics(application);
Expand Down Expand Up @@ -992,7 +992,7 @@ public ConfigserverConfig configserverConfig() {

public ApplicationId getApplicationIdForHostname(String hostname) {
Optional<ApplicationId> applicationId = tenantRepository.getAllTenantNames().stream()
.map(tenantName -> tenantRepository.getTenant(tenantName).getApplicationRepo().getApplicationIdForHostName(hostname))
.map(tenantName -> tenantRepository.getTenant(tenantName).getApplicationRepo().resolveApplicationId(hostname))
.filter(Objects::nonNull)
.findFirst();
return applicationId.orElse(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,6 @@ public void verifyHosts(ApplicationId applicationId, Collection<String> newHosts
hostRegistry.verifyHosts(applicationId, newHosts);
}

// TODO: Duplicate of resolveApplicationId() above
public ApplicationId getApplicationIdForHostName(String hostname) {
return hostRegistry.getApplicationId(hostname);
}

public TenantFileSystemDirs getTenantFileSystemDirs() { return tenantFileSystemDirs; }

public CompletionWaiter createRemoveApplicationWaiter(ApplicationId applicationId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ public HttpResponse handleGET(HttpRequest request) {
if (path.matches("/application/v2/tenant/{tenant}/application/{application}/environment/{ignore}/region/{ignore}/instance/{instance}/filedistributionstatus")) return filedistributionStatus(applicationId(path), request);
if (path.matches("/application/v2/tenant/{tenant}/application/{application}/environment/{ignore}/region/{ignore}/instance/{instance}/logs")) return logs(applicationId(path), request);
if (path.matches("/application/v2/tenant/{tenant}/application/{application}/environment/{ignore}/region/{ignore}/instance/{instance}/metrics/deployment")) return deploymentMetrics(applicationId(path));
if (path.matches("/application/v2/tenant/{tenant}/application/{application}/environment/{ignore}/region/{ignore}/instance/{instance}/metrics/proton")) return protonMetrics(applicationId(path));
// TODO: Remove when all usage has migrated to .../metrics/searchnode
if (path.matches("/application/v2/tenant/{tenant}/application/{application}/environment/{ignore}/region/{ignore}/instance/{instance}/metrics/proton")) return searchNodeMetrics(applicationId(path));
if (path.matches("/application/v2/tenant/{tenant}/application/{application}/environment/{ignore}/region/{ignore}/instance/{instance}/metrics/searchnode")) return searchNodeMetrics(applicationId(path));
if (path.matches("/application/v2/tenant/{tenant}/application/{application}/environment/{ignore}/region/{ignore}/instance/{instance}/reindexing")) return getReindexingStatus(applicationId(path));
if (path.matches("/application/v2/tenant/{tenant}/application/{application}/environment/{ignore}/region/{ignore}/instance/{instance}/service/{service}/{hostname}/status/{*}")) return serviceStatusPage(applicationId(path), path.get("service"), path.get("hostname"), path.getRest(), request);
if (path.matches("/application/v2/tenant/{tenant}/application/{application}/environment/{ignore}/region/{ignore}/instance/{instance}/service/{service}/{hostname}/state/v1/{*}")) return serviceStateV1(applicationId(path), path.get("service"), path.get("hostname"), path.getRest(), request);
Expand Down Expand Up @@ -200,8 +202,8 @@ private HttpResponse logs(ApplicationId applicationId, HttpRequest request) {
return applicationRepository.getLogs(applicationId, hostname, apiParams);
}

private HttpResponse protonMetrics(ApplicationId applicationId) {
return applicationRepository.getProtonMetrics(applicationId);
private HttpResponse searchNodeMetrics(ApplicationId applicationId) {
return applicationRepository.getSearchNodeMetrics(applicationId);
}

private HttpResponse deploymentMetrics(ApplicationId applicationId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
*/
public class SearchNodeMetricsResponse extends SlimeJsonResponse {

public SearchNodeMetricsResponse(ApplicationId applicationId, Map<String, SearchNodeMetricsAggregator> aggregatedProtonMetrics) {
public SearchNodeMetricsResponse(ApplicationId applicationId, Map<String, SearchNodeMetricsAggregator> aggregatedMetrics) {
Cursor application = slime.setObject();
application.setString("applicationId", applicationId.serializedForm());

Cursor clusters = application.setArray("clusters");

for (var entry : aggregatedProtonMetrics.entrySet()) {
for (var entry : aggregatedMetrics.entrySet()) {
Cursor cluster = clusters.addObject();
cluster.setString("clusterId", entry.getKey());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;

public class ClusterProtonMetricsRetriever {
public class ClusterSearchNodeMetricsRetriever {

private static final Logger log = Logger.getLogger(ClusterProtonMetricsRetriever.class.getName());
private static final Logger log = Logger.getLogger(ClusterSearchNodeMetricsRetriever.class.getName());

private static final CloseableHttpClient httpClient = VespaHttpClientBuilder
.custom()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

public class SearchNodeMetricsRetriever {

private final ClusterProtonMetricsRetriever metricsRetriever;
private final ClusterSearchNodeMetricsRetriever metricsRetriever;

public SearchNodeMetricsRetriever() {
this( new ClusterProtonMetricsRetriever());
this( new ClusterSearchNodeMetricsRetriever());
}

public SearchNodeMetricsRetriever(ClusterProtonMetricsRetriever metricsRetriever) {
public SearchNodeMetricsRetriever(ClusterSearchNodeMetricsRetriever metricsRetriever) {
this.metricsRetriever = metricsRetriever;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void testMetricAggregation() throws IOException {

String expectedClusterNameContent = "content/content/0/0";
String expectedClusterNameMusic = "content/music/0/0";
Map<String, SearchNodeMetricsAggregator> aggregatorMap = new ClusterProtonMetricsRetriever().requestMetricsGroupedByCluster(hosts);
Map<String, SearchNodeMetricsAggregator> aggregatorMap = new ClusterSearchNodeMetricsRetriever().requestMetricsGroupedByCluster(hosts);

compareAggregators(
new SearchNodeMetricsAggregator()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class SearchNodeMetricsRetrieverTest {
@Test
public void getMetrics() {
SearchNodeMetricsRetrieverTest.MockModel mockModel = new MockModel(mockHosts());
SearchNodeMetricsRetrieverTest.MockProtonMetricsRetriever mockMetricsRetriever = new MockProtonMetricsRetriever();
MockSearchNodeMetricsRetriever mockMetricsRetriever = new MockSearchNodeMetricsRetriever();
Application application = new Application(mockModel, null, 0,
null, null, ApplicationId.fromSerializedForm("tenant:app:instance"));

Expand All @@ -53,7 +53,7 @@ private Collection<HostInfo> mockHosts() {
return List.of(hostInfo1, hostInfo2, hostInfo3);
}

static class MockProtonMetricsRetriever extends ClusterProtonMetricsRetriever {
static class MockSearchNodeMetricsRetriever extends ClusterSearchNodeMetricsRetriever {

Collection<URI> hosts = new ArrayList<>();

Expand Down

0 comments on commit f54343d

Please sign in to comment.