diff options
4 files changed, 28 insertions, 29 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java index 900061949f4..0cc9a804d8c 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java @@ -16,6 +16,7 @@ import com.yahoo.jdisc.Response; import com.yahoo.jdisc.application.BindingMatch; import com.yahoo.jdisc.application.UriPattern; import com.yahoo.slime.Cursor; +import com.yahoo.text.StringUtilities; import com.yahoo.vespa.config.server.ApplicationRepository; import com.yahoo.vespa.config.server.application.ApplicationReindexing; import com.yahoo.vespa.config.server.application.ClusterReindexing; @@ -35,6 +36,8 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; +import java.util.Set; +import java.util.StringJoiner; import java.util.stream.Stream; import static java.util.Map.Entry.comparingByKey; @@ -86,7 +89,7 @@ public class ApplicationHandler extends HttpHandler { if (isReindexingRequest(request)) { applicationRepository.modifyReindexing(applicationId, reindexing -> reindexing.enabled(false)); - return new JSONResponse(Response.Status.OK); + return new JSONResponse(Response.Status.OK) { { object.setString("message", "Reindexing disabled"); } }; } if (applicationRepository.delete(applicationId)) @@ -211,27 +214,21 @@ public class ApplicationHandler extends HttpHandler { } if (isReindexRequest(request)) { - triggerReindexing(request, applicationId); - return new JSONResponse(Response.Status.OK); + String message = triggerReindexing(request, applicationId); + return new JSONResponse(Response.Status.OK) { { object.setString("message", message); } }; } if (isReindexingRequest(request)) { applicationRepository.modifyReindexing(applicationId, reindexing -> reindexing.enabled(true)); - return new JSONResponse(Response.Status.OK); + return new JSONResponse(Response.Status.OK) { { object.setString("message", "Reindexing enabled"); } }; } throw new NotFoundException("Illegal POST request '" + request.getUri() + "'"); } - private void triggerReindexing(HttpRequest request, ApplicationId applicationId) { - List<String> clusters = Optional.ofNullable(request.getProperty("clusterId")).stream() - .flatMap(value -> Stream.of(value.split(","))) - .filter(cluster -> ! cluster.isBlank()) - .collect(toList()); - List<String> types = Optional.ofNullable(request.getProperty("documentType")).stream() - .flatMap(value -> Stream.of(value.split(","))) - .filter(type -> ! type.isBlank()) - .collect(toList()); + private String triggerReindexing(HttpRequest request, ApplicationId applicationId) { + Set<String> clusters = StringUtilities.split(request.getProperty("clusterId")); + Set<String> types = StringUtilities.split(request.getProperty("documentType")); Instant now = applicationRepository.clock().instant(); applicationRepository.modifyReindexing(applicationId, reindexing -> { if (clusters.isEmpty()) @@ -245,6 +242,12 @@ public class ApplicationHandler extends HttpHandler { reindexing = reindexing.withReady(cluster, type, now); return reindexing; }); + return "Reindexing " + + (clusters.isEmpty() ? "" + : (types.isEmpty() ? "" + : "document types " + String.join(", ", types) + " in ") + + "clusters " + String.join(", ", clusters) + " of ") + + "application " + applicationId; } private HttpResponse getReindexingStatus(ApplicationId applicationId) { diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java index f2558fa50b8..a05a4a5559b 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java @@ -79,7 +79,7 @@ public class ApplicationHandlerTest { private final static TenantName mytenantName = TenantName.from("mytenant"); private final static ApplicationId myTenantApplicationId = ApplicationId.from(mytenantName, ApplicationName.defaultName(), InstanceName.defaultName()); - private final static ApplicationId applicationId = ApplicationId.from(TenantName.defaultName(), ApplicationName.defaultName(), InstanceName.defaultName()); + private final static ApplicationId applicationId = ApplicationId.defaultId(); private final static MockTesterClient testerClient = new MockTesterClient(); private static final MockLogRetriever logRetriever = new MockLogRetriever(); private static final Version vespaVersion = Version.fromString("7.8.9"); @@ -219,32 +219,32 @@ public class ApplicationHandlerTest { database.readReindexingStatus(applicationId).orElseThrow()); clock.advance(Duration.ofSeconds(1)); - reindex(applicationId, ""); + reindex(applicationId, "", "{\"message\":\"Reindexing application default.default\"}"); expected = expected.withReady(clock.instant()); assertEquals(expected, database.readReindexingStatus(applicationId).orElseThrow()); clock.advance(Duration.ofSeconds(1)); expected = expected.withReady(clock.instant()); - reindex(applicationId, "?clusterId="); + reindex(applicationId, "?clusterId=", "{\"message\":\"Reindexing application default.default\"}"); assertEquals(expected, database.readReindexingStatus(applicationId).orElseThrow()); clock.advance(Duration.ofSeconds(1)); expected = expected.withReady(clock.instant()); - reindex(applicationId, "?documentType=moo"); + reindex(applicationId, "?documentType=moo", "{\"message\":\"Reindexing application default.default\"}"); assertEquals(expected, database.readReindexingStatus(applicationId).orElseThrow()); clock.advance(Duration.ofSeconds(1)); - reindex(applicationId, "?clusterId=foo,boo"); + reindex(applicationId, "?clusterId=foo,boo", "{\"message\":\"Reindexing clusters foo, boo of application default.default\"}"); expected = expected.withReady("foo", clock.instant()) .withReady("boo", clock.instant()); assertEquals(expected, database.readReindexingStatus(applicationId).orElseThrow()); clock.advance(Duration.ofSeconds(1)); - reindex(applicationId, "?clusterId=foo,boo&documentType=bar,baz"); + reindex(applicationId, "?clusterId=foo,boo&documentType=bar,baz", "{\"message\":\"Reindexing document types bar, baz in clusters foo, boo of application default.default\"}"); expected = expected.withReady("foo", "bar", clock.instant()) .withReady("foo", "baz", clock.instant()) .withReady("boo", "bar", clock.instant()) @@ -252,12 +252,12 @@ public class ApplicationHandlerTest { assertEquals(expected, database.readReindexingStatus(applicationId).orElseThrow()); - reindexing(applicationId, DELETE); + reindexing(applicationId, DELETE, "{\"message\":\"Reindexing disabled\"}"); expected = expected.enabled(false); assertEquals(expected, database.readReindexingStatus(applicationId).orElseThrow()); - reindexing(applicationId, POST); + reindexing(applicationId, POST, "{\"message\":\"Reindexing enabled\"}"); expected = expected.enabled(true); assertEquals(expected, database.readReindexingStatus(applicationId).orElseThrow()); @@ -607,13 +607,9 @@ public class ApplicationHandlerTest { reindexing(application, method, expectedBody, 200); } - private void reindexing(ApplicationId application, Method method) throws IOException { - reindexing(application, method, null); - } - - private void reindex(ApplicationId application, String query) throws IOException { + private void reindex(ApplicationId application, String query, String message) throws IOException { String reindexUrl = toUrlPath(application, Zone.defaultZone(), true) + "/reindex" + query; - assertHttpStatusCodeAndMessage(createApplicationHandler().handle(createTestRequest(reindexUrl, POST)), 200, ""); + assertHttpStatusCodeAndMessage(createApplicationHandler().handle(createTestRequest(reindexUrl, POST)), 200, message); } private void restart(ApplicationId application, Zone zone) throws IOException { diff --git a/fbench/src/fbench/fbench.cpp b/fbench/src/fbench/fbench.cpp index efac34409cc..b2bdc69eca4 100644 --- a/fbench/src/fbench/fbench.cpp +++ b/fbench/src/fbench/fbench.cpp @@ -291,7 +291,7 @@ FBench::Usage() printf(" [-s seconds] [-q queryFilePattern] [-o outputFilePattern]\n"); printf(" [-r restartLimit] [-m maxLineSize] [-k] <hostname> <port>\n\n"); printf(" -H <str> : append extra header to each get request.\n"); - printf(" -A <str> : assign autority. <str> should be hostname:port format. Overrides Host: header sent.\n"); + printf(" -A <str> : assign authority. <str> should be hostname:port format. Overrides Host: header sent.\n"); printf(" -P : use POST for requests instead of GET.\n"); printf(" -a <str> : append string to each query\n"); printf(" -n <num> : run with <num> parallel clients [10]\n"); diff --git a/vespajlib/src/main/java/com/yahoo/concurrent/maintenance/JobMetrics.java b/vespajlib/src/main/java/com/yahoo/concurrent/maintenance/JobMetrics.java index a43e2156025..483057a828d 100644 --- a/vespajlib/src/main/java/com/yahoo/concurrent/maintenance/JobMetrics.java +++ b/vespajlib/src/main/java/com/yahoo/concurrent/maintenance/JobMetrics.java @@ -22,7 +22,7 @@ public class JobMetrics { /** Record a run for given job */ public void recordRunOf(String job) { - incompleteRuns.compute(job, (ignored, run) -> run == null ? 1 : ++run); + incompleteRuns.merge(job, 1L, Long::sum); } /** Record successful run of given job */ |