Skip to content

Commit 1f30224

Browse files
authored
Merge pull request #35902 from vespa-engine/arnej/locale-configserver
Use Text.format in configserver module
2 parents de29f63 + 40285ec commit 1f30224

14 files changed

Lines changed: 42 additions & 29 deletions

configserver/src/main/java/com/yahoo/vespa/config/server/application/ConfigConvergenceChecker.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.apache.hc.core5.reactor.IOReactorConfig;
2525
import org.apache.hc.core5.util.TimeValue;
2626
import org.apache.hc.core5.util.Timeout;
27+
import com.yahoo.text.Text;
2728

2829
import java.io.IOException;
2930
import java.io.UncheckedIOException;
@@ -183,7 +184,7 @@ private Map<ServiceInfo, Long> getServiceGenerations(List<ServiceInfo> services,
183184
log.log(
184185
FINE,
185186
error,
186-
() -> String.format("Failed to retrieve service config generation for '%s': %s", service, error.getMessage()));
187+
() -> Text.format("Failed to retrieve service config generation for '%s': %s", service, error.getMessage()));
187188
temporaryResult.put(service, -1L);
188189
}
189190
return null;

configserver/src/main/java/com/yahoo/vespa/config/server/application/ConfigStateChecker.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.hc.core5.reactor.IOReactorConfig;
2323
import org.apache.hc.core5.util.TimeValue;
2424
import org.apache.hc.core5.util.Timeout;
25+
import com.yahoo.text.Text;
2526

2627
import java.io.IOException;
2728
import java.io.UncheckedIOException;
@@ -103,7 +104,7 @@ private Map<ServiceInfo, ServiceConfigState> getServiceConfigStates(List<Service
103104
log.log(
104105
FINE,
105106
error,
106-
() -> String.format(
107+
() -> Text.format(
107108
"Failed to retrieve service config state for '%s': %s",
108109
service, error.getMessage()));
109110
temporaryResult.put(service, new ServiceConfigState(-1L, Optional.empty()));

configserver/src/main/java/com/yahoo/vespa/config/server/application/DefaultClusterReindexingStatusClient.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.apache.hc.core5.http.HttpStatus;
1818
import org.apache.hc.core5.reactor.IOReactorConfig;
1919
import org.apache.hc.core5.util.Timeout;
20+
import com.yahoo.text.Text;
2021

2122
import java.io.IOException;
2223
import java.net.URI;
@@ -75,7 +76,7 @@ public Map<String, ClusterReindexing> getReindexingStatus(ModelResult applicatio
7576
@Override public void close() { uncheck(() -> httpClient.close()); }
7677

7778
private CompletableFuture<Map<String, ClusterReindexing>> getReindexingStatus(ServiceInfo service) {
78-
URI uri = URI.create(String.format("http://%s:%d/reindexing/v1/status", service.getHostName(), getStatePort(service)));
79+
URI uri = URI.create(Text.format("http://%s:%d/reindexing/v1/status", service.getHostName(), getStatePort(service)));
7980
CompletableFuture<SimpleHttpResponse> responsePromise = new CompletableFuture<>();
8081
httpClient.execute(SimpleRequestBuilder.get(uri).build(), new FutureCallback<>() {
8182
@Override public void completed(SimpleHttpResponse result) { responsePromise.complete(result); }
@@ -86,7 +87,7 @@ private CompletableFuture<Map<String, ClusterReindexing>> getReindexingStatus(Se
8687
if (response != null) {
8788
return uncheck(() -> toClusterReindexing(response));
8889
} else {
89-
throw throwUnchecked(new IOException(String.format("For '%s': %s", uri, error.getMessage()), error));
90+
throw throwUnchecked(new IOException(Text.format("For '%s': %s", uri, error.getMessage()), error));
9091
}
9192
}, executor);
9293
}

configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.yahoo.vespa.flags.PermanentFlags;
3232
import org.apache.curator.framework.CuratorFramework;
3333
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
34+
import com.yahoo.text.Text;
3435

3536
import java.nio.file.Files;
3637
import java.nio.file.Paths;
@@ -374,7 +375,7 @@ private Application getApplication(ApplicationId appId, Optional<Version> vespaV
374375
try {
375376
return applicationMapper.getForVersion(appId, vespaVersion, clock.instant());
376377
} catch (VersionDoesNotExistException ex) {
377-
throw new NotFoundException(String.format("%sNo such application (id %s): %s", TenantRepository.logPre(tenant), appId, ex.getMessage()));
378+
throw new NotFoundException(Text.format("%sNo such application (id %s): %s", TenantRepository.logPre(tenant), appId, ex.getMessage()));
378379
}
379380
}
380381

configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.yahoo.vespa.config.server.tenant.Tenant;
3131
import com.yahoo.yolean.Exceptions;
3232
import com.yahoo.yolean.concurrent.Memoized;
33+
import com.yahoo.text.Text;
3334

3435
import java.time.Clock;
3536
import java.time.Duration;
@@ -181,9 +182,9 @@ private void restartServicesIfNeeded(ApplicationId applicationId) {
181182
long configGeneration = session.getSessionId();
182183
applicationRepository.modifyPendingRestarts(applicationId, pendingRestarts -> pendingRestarts.withRestarts(configGeneration, nodesToRestart));
183184
String hostnames = nodesToRestart.stream().sorted().collect(joining(", "));
184-
deployLogger.log(Level.INFO, String.format("Scheduled service restart of %d nodes: %s",
185+
deployLogger.log(Level.INFO, Text.format("Scheduled service restart of %d nodes: %s",
185186
nodesToRestart.size(), hostnames));
186-
log.info(String.format("%sWill schedule service restart of %d nodes after convergence on generation %d (unless restartOnDeploy enabled): %s",
187+
log.info(Text.format("%sWill schedule service restart of %d nodes after convergence on generation %d (unless restartOnDeploy enabled): %s",
187188
session.logPre(), nodesToRestart.size(), configGeneration, hostnames));
188189
configChangeActions = configChangeActions == null ? null : configChangeActions.withRestartActions(new RestartActions());
189190
}
@@ -200,7 +201,7 @@ private void storeReindexing(ApplicationId applicationId) {
200201

201202
return reindexing;
202203
});
203-
deployLogger.log(Level.INFO, String.format("Scheduled reindexing of %d document types across %d clusters: %s",
204+
deployLogger.log(Level.INFO, Text.format("Scheduled reindexing of %d document types across %d clusters: %s",
204205
entries.size(),
205206
entries.stream().map(Reindexing::clusterId).distinct().count(),
206207
entries.stream().collect(groupingBy(Reindexing::clusterId)).entrySet().stream()
@@ -224,8 +225,7 @@ private void applyDeferredReconfigurationOfClusters() {
224225
"Cannot apply deferred reconfiguration: no model available for session " + session.getSessionId()));
225226
model.markClustersForDeferredReconfiguration(clustersWithDeferredReconfiguration);
226227
clustersWithDeferredReconfiguration.forEach(clusterName ->
227-
deployLogger.log(Level.INFO, "Deferring reconfiguration of cluster '%s' until restart is completed"
228-
.formatted(clusterName)));
228+
deployLogger.log(Level.INFO, Text.format("Deferring reconfiguration of cluster '%s' until restart is completed", clusterName)));
229229
}
230230

231231
/**

configserver/src/main/java/com/yahoo/vespa/config/server/http/SecretStoreValidator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
1616
import org.apache.hc.core5.http.ContentType;
1717
import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
18+
import com.yahoo.text.Text;
1819

1920
import java.io.IOException;
2021
import java.net.URI;
@@ -64,7 +65,7 @@ private HttpResponse postRequest(URI uri, Slime slime) {
6465
return new ProxyResponse(httpClient.execute(postRequest));
6566
} catch (IOException e) {
6667
return HttpErrorResponse.internalServerError(
67-
String.format("Failed to post request to %s: %s", uri, Exceptions.toMessageString(e))
68+
Text.format("Failed to post request to %s: %s", uri, Exceptions.toMessageString(e))
6869
);
6970
}
7071
}

configserver/src/main/java/com/yahoo/vespa/config/server/http/v1/RoutingStatusApiHandler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import com.yahoo.vespa.curator.transaction.CuratorOperations;
1717
import com.yahoo.vespa.curator.transaction.CuratorTransaction;
1818
import com.yahoo.yolean.Exceptions;
19+
import com.yahoo.yolean.Exceptions;
20+
import com.yahoo.text.Text;
1921

2022
import java.time.Clock;
2123
import java.time.Instant;
@@ -112,7 +114,7 @@ private SlimeJsonResponse getDeploymentStatus(RestApi.RequestContext context) {
112114
DeploymentRoutingStatus deploymentRoutingStatus = deploymentStatus(upstreamName);
113115
// If the entire zone is out, we always return OUT regardless of the actual routing status
114116
if (zoneStatus() == RoutingStatus.out) {
115-
String reason = String.format("Rotation is OUT because the zone is OUT (actual deployment status is %s)",
117+
String reason = Text.format("Rotation is OUT because the zone is OUT (actual deployment status is %s)",
116118
deploymentRoutingStatus.status().name().toUpperCase(Locale.ENGLISH));
117119
deploymentRoutingStatus = new DeploymentRoutingStatus(RoutingStatus.out, "operator", reason,
118120
clock.instant());

configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/PendingRestartsMaintainer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static PendingRestarts triggerPendingRestarts(Function<Set<String>, ServiceListR
101101
long lowestGeneration = convergence.currentGeneration;
102102
Set<String> nodesToRestart = restarts.restartsReadyAt(lowestGeneration);
103103
if (nodesToRestart.isEmpty()) {
104-
log.info(String.format("Cannot yet restart nodes of %s, as some services are still on generation %d:\n\t%s",
104+
log.info(Text.format("Cannot yet restart nodes of %s, as some services are still on generation %d:\n\t%s",
105105
id.toFullString(),
106106
lowestGeneration,
107107
convergence.services().stream()
@@ -112,7 +112,7 @@ static PendingRestarts triggerPendingRestarts(Function<Set<String>, ServiceListR
112112
}
113113

114114
restarter.accept(id, nodesToRestart);
115-
log.info(String.format("Scheduled restart of %d nodes after observing generation %d: %s",
115+
log.info(Text.format("Scheduled restart of %d nodes after observing generation %d: %s",
116116
nodesToRestart.size(), lowestGeneration, nodesToRestart.stream().sorted().collect(Collectors.joining(", "))));
117117

118118
return restarts.withoutPreviousGenerations(lowestGeneration);

configserver/src/main/java/com/yahoo/vespa/config/server/metrics/ClusterDeploymentMetricsRetriever.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.apache.hc.core5.http.io.entity.EntityUtils;
1919
import org.apache.hc.core5.util.TimeValue;
2020
import org.apache.hc.core5.util.Timeout;
21+
import com.yahoo.text.Text;
2122

2223
import java.io.IOException;
2324
import java.net.URI;
@@ -91,7 +92,7 @@ public Map<ClusterInfo, DeploymentMetricsAggregator> requestMetricsGroupedByClus
9192
}
9293

9394
log.log(Level.FINE, () ->
94-
String.format("Metric retrieval for %d nodes took %d milliseconds", hosts.size(), System.currentTimeMillis() - startTime)
95+
Text.format("Metric retrieval for %d nodes took %d milliseconds", hosts.size(), System.currentTimeMillis() - startTime)
9596
);
9697

9798
return clusterMetricsMap;

configserver/src/main/java/com/yahoo/vespa/config/server/metrics/ClusterSearchNodeMetricsRetriever.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public Map<String, SearchNodeMetricsAggregator> requestMetricsGroupedByCluster(C
5656
}
5757
5858
log.log(Level.FINE, () ->
59-
String.format("Proton metric retrieval for %d nodes took %d milliseconds", hosts.size(), System.currentTimeMillis() - startTime)
59+
Text.format("Proton metric retrieval for %d nodes took %d milliseconds", hosts.size(), System.currentTimeMillis() - startTime)
6060
);*/
6161

6262
return clusterMetricsMap;

0 commit comments

Comments
 (0)