summaryrefslogtreecommitdiffstats
path: root/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler
diff options
context:
space:
mode:
Diffstat (limited to 'vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler')
-rwxr-xr-xvespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/StatusResponse.java65
-rwxr-xr-xvespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerCompatibility.java41
-rwxr-xr-xvespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerGet.java34
-rwxr-xr-xvespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerRemove.java91
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerRemoveLocation.java91
-rwxr-xr-xvespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerStatus.java89
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerVisit.java36
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/package-info.java3
8 files changed, 0 insertions, 450 deletions
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/StatusResponse.java b/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/StatusResponse.java
deleted file mode 100755
index 365f605688c..00000000000
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/StatusResponse.java
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.feedhandler;
-
-import com.yahoo.container.jdisc.HttpResponse;
-import com.yahoo.metrics.MetricManager;
-import com.yahoo.metrics.MetricSnapshot;
-import com.yahoo.text.Utf8String;
-import com.yahoo.text.XMLWriter;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-
-/**
- * @deprecated Legacy API. Will be removed in Vespa 7
- */
-// TODO: Remove on Vespa 7
-@Deprecated // OK
-public class StatusResponse extends HttpResponse {
-
- MetricManager manager;
- int verbosity;
- int snapshotTime;
-
- StatusResponse(MetricManager manager, int verbosity, int snapshotTime) {
- super(com.yahoo.jdisc.http.HttpResponse.Status.OK);
- this.manager = manager;
- this.snapshotTime = snapshotTime;
- this.verbosity = verbosity;
- }
-
- @Override
- public void render(OutputStream stream) throws IOException {
- XMLWriter writer = new XMLWriter(new OutputStreamWriter(stream));
- writer.openTag("status");
- if (verbosity >= 2) {
- writer.attribute(new Utf8String("description"), "Metrics since start");
- }
-
- if (snapshotTime == 0) {
- MetricSnapshot snapshot = (new MetricSnapshot(
- "Total metrics from start until current time", 0,
- manager.getActiveMetrics().getMetrics(), false));
- manager.getTotalMetricSnapshot().addToSnapshot(snapshot, (int)(System.currentTimeMillis() / 1000), false);
- snapshot.printXml(manager, "", verbosity, writer);
- } else {
- try {
- manager.getMetricSnapshotSet(snapshotTime).getSnapshot().printXml(manager, "", verbosity, writer);
- } catch (Exception e) {
- writer.openTag("error");
- writer.attribute(new Utf8String("details"), "No metric snapshot with period " + snapshotTime +
- " was found. Legal snapshot periods are: " + manager.getSnapshotPeriods());
- writer.closeTag();
- }
- }
- writer.closeTag();
- writer.flush();
- }
-
- @Override
- public java.lang.String getContentType() {
- return "application/xml";
- }
-
-}
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerCompatibility.java b/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerCompatibility.java
deleted file mode 100755
index 8fe721899f9..00000000000
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerCompatibility.java
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.feedhandler;
-
-import java.util.concurrent.Executor;
-import javax.inject.Inject;
-
-import com.yahoo.jdisc.Metric;
-import com.yahoo.container.jdisc.HttpRequest;
-import com.yahoo.container.jdisc.HttpResponse;
-import com.yahoo.container.jdisc.ThreadedHttpRequestHandler;
-
-/**
- * @deprecated Legacy API. Will be removed in Vespa 7
- */
-// TODO: Remove on Vespa 7
-@Deprecated // OK
-public class VespaFeedHandlerCompatibility extends ThreadedHttpRequestHandler {
-
- private final VespaFeedHandlerGet getHandler;
- private final VespaFeedHandler feedHandler;
-
- @Inject
- public VespaFeedHandlerCompatibility(Executor executor, Metric metric, VespaFeedHandlerGet getHandler,
- VespaFeedHandler feedHandler) {
- super(executor, metric);
- this.getHandler = getHandler;
- this.feedHandler = feedHandler;
- }
-
- @Override
- public HttpResponse handle(HttpRequest request) {
- boolean hasType = request.hasProperty("type");
- // If we have an ID and no document type, redirect to Get
- if (request.hasProperty("id") && !hasType) {
- return getHandler.handle(request);
- } else {
- return feedHandler.handle(request);
- }
- }
-
-}
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerGet.java b/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerGet.java
deleted file mode 100755
index ab8728e017b..00000000000
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerGet.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.feedhandler;
-
-import java.util.Collections;
-import java.util.concurrent.Executor;
-import javax.inject.Inject;
-
-import com.yahoo.jdisc.Metric;
-import com.yahoo.container.jdisc.HttpRequest;
-import com.yahoo.container.jdisc.HttpResponse;
-import com.yahoo.container.jdisc.ThreadedHttpRequestHandler;
-import com.yahoo.search.handler.SearchHandler;
-
-/**
- * @deprecated Legacy API. Will be removed in Vespa 7
- */
-// TODO: Remove on Vespa 7
-@Deprecated // OK
-public class VespaFeedHandlerGet extends ThreadedHttpRequestHandler {
-
- private final SearchHandler searchHandler;
-
- @Inject
- public VespaFeedHandlerGet(SearchHandler searchHandler, Executor executor, Metric metric) {
- super(executor, metric, true);
- this.searchHandler = searchHandler;
- }
-
- @Override
- public HttpResponse handle(HttpRequest request) {
- return searchHandler.handle(new HttpRequest(request.getJDiscRequest(), request.getData(), Collections.singletonMap("searchChain", "vespaget")));
- }
-
-}
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerRemove.java b/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerRemove.java
deleted file mode 100755
index 9baad1a605d..00000000000
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerRemove.java
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.feedhandler;
-
-import com.google.inject.Inject;
-import com.yahoo.clientmetrics.RouteMetricSet;
-import com.yahoo.cloud.config.ClusterListConfig;
-import com.yahoo.cloud.config.SlobroksConfig;
-import com.yahoo.container.jdisc.HttpRequest;
-import com.yahoo.container.jdisc.HttpResponse;
-import com.yahoo.container.protect.Error;
-import com.yahoo.document.DocumentId;
-import com.yahoo.document.config.DocumentmanagerConfig;
-import com.yahoo.feedapi.FeedContext;
-import com.yahoo.feedapi.MessagePropertyProcessor;
-import com.yahoo.feedapi.SingleSender;
-import com.yahoo.jdisc.Metric;
-import com.yahoo.vespa.config.content.LoadTypeConfig;
-import com.yahoo.vespaclient.config.FeederConfig;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.util.concurrent.Executor;
-
-/**
- * @deprecated Legacy API. Will be removed in Vespa 7
- */
-// TODO: Remove on Vespa 7
-@Deprecated // OK
-public class VespaFeedHandlerRemove extends VespaFeedHandlerBase {
-
- @Inject
- public VespaFeedHandlerRemove(FeederConfig feederConfig,
- LoadTypeConfig loadTypeConfig,
- DocumentmanagerConfig documentmanagerConfig,
- SlobroksConfig slobroksConfig,
- ClusterListConfig clusterListConfig,
- Executor executor,
- Metric metric) throws Exception {
- super(feederConfig, loadTypeConfig, documentmanagerConfig, slobroksConfig, clusterListConfig, executor, metric);
- }
-
- VespaFeedHandlerRemove(FeedContext context, Executor executor) throws Exception {
- super(context, executor);
- }
-
- @Override
- public HttpResponse handle(HttpRequest request) {
- if (request.getProperty("status") != null) {
- return new MetricResponse(context.getMetrics().getMetricSet());
- }
-
- MessagePropertyProcessor.PropertySetter properties = getPropertyProcessor().buildPropertySetter(request);
- String route = properties.getRoute().toString();
- FeedResponse response = new FeedResponse(new RouteMetricSet(route, null));
- SingleSender sender = new SingleSender(response, getSharedSender(route));
- sender.addMessageProcessor(properties);
-
- response.setAbortOnFeedError(properties.getAbortOnFeedError());
-
- if (request.hasProperty("id")) {
- sender.remove(new DocumentId(request.getProperty("id")));
- } else if (request.hasProperty("id[0]")) {
- int index = 0;
- while (request.hasProperty("id[" + index + "]")) {
- sender.remove(new DocumentId(request.getProperty("id[" + index + "]")));
- ++index;
- }
- }
-
- if (request.getData() != null) {
- try {
- String line;
- BufferedReader reader = new BufferedReader(
- new InputStreamReader(getRequestInputStream(request), "UTF-8"));
- while ((line = reader.readLine()) != null) {
- sender.remove(new DocumentId(line));
- }
- } catch (Exception e) {
- response.addError(e.getClass() + ": " + e.getCause());
- }
- }
-
- sender.done();
- long millis = getTimeoutMillis(request);
- boolean completed = sender.waitForPending(millis);
- if ( ! completed)
- response.addError(Error.TIMEOUT, "Timed out after "+millis+" ms waiting for responses");
- return response;
- }
-
-}
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerRemoveLocation.java b/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerRemoveLocation.java
deleted file mode 100644
index 0ca77decf22..00000000000
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerRemoveLocation.java
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.feedhandler;
-
-import com.google.inject.Inject;
-import com.yahoo.clientmetrics.RouteMetricSet;
-import com.yahoo.cloud.config.ClusterListConfig;
-import com.yahoo.cloud.config.SlobroksConfig;
-import com.yahoo.container.jdisc.HttpRequest;
-import com.yahoo.container.jdisc.HttpResponse;
-import com.yahoo.container.protect.Error;
-import com.yahoo.document.config.DocumentmanagerConfig;
-import com.yahoo.documentapi.messagebus.protocol.RemoveLocationMessage;
-import com.yahoo.feedapi.FeedContext;
-import com.yahoo.feedapi.MessagePropertyProcessor;
-import com.yahoo.feedapi.SingleSender;
-import com.yahoo.jdisc.Metric;
-import com.yahoo.messagebus.routing.Route;
-import com.yahoo.vespa.config.content.LoadTypeConfig;
-import com.yahoo.vespaclient.config.FeederConfig;
-
-import java.util.concurrent.Executor;
-
-/**
- * @deprecated Legacy API. Will be removed in Vespa 7
- */
-// TODO: Remove on Vespa 7
-@Deprecated // OK
-public class VespaFeedHandlerRemoveLocation extends VespaFeedHandlerBase {
-
- @Inject
- public VespaFeedHandlerRemoveLocation(FeederConfig feederConfig,
- LoadTypeConfig loadTypeConfig,
- DocumentmanagerConfig documentmanagerConfig,
- SlobroksConfig slobroksConfig,
- ClusterListConfig clusterListConfig,
- Executor executor, Metric metric) throws Exception {
- super(feederConfig, loadTypeConfig, documentmanagerConfig, slobroksConfig, clusterListConfig, executor, metric);
- }
-
- VespaFeedHandlerRemoveLocation(FeedContext context, Executor executor) throws Exception {
- super(context, executor);
- }
-
- @Override
- public HttpResponse handle(HttpRequest request) {
- MessagePropertyProcessor.PropertySetter properties = getPropertyProcessor().buildPropertySetter(request);
- FeedResponse response;
-
- if (request.getProperty("route") == null) {
- if (context.getClusterList().getStorageClusters().size() == 0) {
- return new FeedResponse(null).addError("No storage clusters configured and no alternate route specified.");
- } else if (context.getClusterList().getStorageClusters().size() > 1) {
- return new FeedResponse(null).addError("More than one storage cluster configured and no route specified.");
- } else {
- properties.setRoute(Route.parse(context.getClusterList().getStorageClusters().get(0).getName()));
- }
- }
-
- response = new FeedResponse(new RouteMetricSet(properties.getRoute().toString(), null));
-
- SingleSender sender = new SingleSender(response, getSharedSender(properties.getRoute().toString()));
- sender.addMessageProcessor(properties);
-
- String user = request.getProperty("user");
- String group = request.getProperty("group");
- String selection = request.getProperty("selection");
-
- boolean oneFound = (user != null) ^ (group != null) ^ (selection != null);
-
- if (!oneFound) {
- response.addError("Exactly one of \"user\", \"group\" or \"selection\" must be specified for removelocation");
- return response;
- }
-
- if (user != null) {
- selection = "id.user=" + user;
- }
- if (group != null) {
- selection = "id.group=\"" + group + "\"";
- }
-
- sender.send(new RemoveLocationMessage(selection));
- sender.done();
- long millis = getTimeoutMillis(request);
- boolean completed = sender.waitForPending(millis);
- if ( ! completed)
- response.addError(Error.TIMEOUT, "Timed out after "+millis+" ms waiting for responses");
- return response;
- }
-
-}
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerStatus.java b/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerStatus.java
deleted file mode 100755
index ac16159a9bb..00000000000
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerStatus.java
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.feedhandler;
-
-import java.util.concurrent.Executor;
-
-import com.yahoo.cloud.config.ClusterListConfig;
-import com.yahoo.cloud.config.SlobroksConfig;
-import com.yahoo.container.jdisc.HttpRequest;
-import com.yahoo.container.jdisc.HttpResponse;
-import com.yahoo.container.jdisc.ThreadedHttpRequestHandler;
-import com.yahoo.document.config.DocumentmanagerConfig;
-import com.yahoo.jdisc.Metric;
-import com.yahoo.vespa.config.content.LoadTypeConfig;
-import com.yahoo.feedapi.FeedContext;
-import com.yahoo.metrics.MetricManager;
-import com.yahoo.metrics.MetricSet;
-import com.yahoo.vespaclient.config.FeederConfig;
-
-/**
- * @deprecated Legacy API. Will be removed in Vespa 7
- */
-// TODO: Remove on Vespa 7
-@Deprecated // OK
-public class VespaFeedHandlerStatus extends ThreadedHttpRequestHandler {
-
- private MetricManager manager;
-
- public VespaFeedHandlerStatus(FeederConfig feederConfig,
- LoadTypeConfig loadTypeConfig,
- DocumentmanagerConfig documentmanagerConfig,
- SlobroksConfig slobroksConfig,
- ClusterListConfig clusterListConfig,
- Executor executor,
- Metric metric) {
- this(FeedContext.getInstance(feederConfig, loadTypeConfig,
- documentmanagerConfig, slobroksConfig,
- clusterListConfig, metric),
- true, true, executor);
- }
-
- VespaFeedHandlerStatus(FeedContext context, boolean doLog, boolean makeSnapshots, Executor executor) {
- super(executor);
- manager = new MetricManager();
- final MetricSet metricSet = context.getMetrics().getMetricSet();
- metricSet.unregister();
- manager.registerMetric(metricSet);
- if (doLog) {
- manager.addMetricToConsumer("log", "routes.total.putdocument.count");
- manager.addMetricToConsumer("log", "routes.total.removedocument.count");
- manager.addMetricToConsumer("log", "routes.total.updatedocument.count");
- manager.addMetricToConsumer("log", "routes.total.getdocument.count");
-
- manager.addMetricToConsumer("log", "routes.total.putdocument.errors.total");
- manager.addMetricToConsumer("log", "routes.total.removedocument.errors.total");
- manager.addMetricToConsumer("log", "routes.total.updatedocument.errors.total");
- manager.addMetricToConsumer("log", "routes.total.getdocument.errors.total");
-
- manager.addMetricToConsumer("log", "routes.total.putdocument.latency");
- manager.addMetricToConsumer("log", "routes.total.removedocument.latency");
- manager.addMetricToConsumer("log", "routes.total.updatedocument.latency");
- manager.addMetricToConsumer("log", "routes.total.getdocument.latency");
- }
-
- if (doLog || makeSnapshots) {
- new Thread(manager).start();
- }
- }
-
- @Override
- public HttpResponse handle(HttpRequest request) {
- try {
- return new StatusResponse(manager, asInt(request.getProperty("verbosity"), 0), asInt(request.getProperty("snapshotperiod"), 0));
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- private int asInt(String value, int defaultValue) {
- if (value == null) return defaultValue;
- return Integer.parseInt(value);
- }
-
- @Override
- public void destroy() {
- manager.stop();
- }
-
-}
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerVisit.java b/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerVisit.java
deleted file mode 100644
index b73ea455c32..00000000000
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerVisit.java
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.feedhandler;
-
-import java.util.Collections;
-import java.util.concurrent.Executor;
-import javax.inject.Inject;
-
-import com.yahoo.jdisc.Metric;
-import com.yahoo.container.jdisc.HttpRequest;
-import com.yahoo.container.jdisc.HttpResponse;
-import com.yahoo.container.jdisc.ThreadedHttpRequestHandler;
-import com.yahoo.search.handler.SearchHandler;
-
-/**
- * @author thomasg
- *
- * @deprecated Legacy API. Will be removed in Vespa 7
- */
-// TODO: Remove on Vespa 7
-@Deprecated // OK
-public class VespaFeedHandlerVisit extends ThreadedHttpRequestHandler {
-
- private final SearchHandler searchHandler;
-
- @Inject
- public VespaFeedHandlerVisit(SearchHandler searchHandler, Executor executor, Metric metric) {
- super(executor, metric, true);
- this.searchHandler = searchHandler;
- }
-
- @Override
- public HttpResponse handle(HttpRequest request) {
- return searchHandler.handle(new HttpRequest(request.getJDiscRequest(), request.getData(), Collections.singletonMap("searchChain", "vespavisit")));
- }
-
-}
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/package-info.java b/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/package-info.java
deleted file mode 100644
index 857e7127b6f..00000000000
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/package-info.java
+++ /dev/null
@@ -1,3 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-// TODO: This implements the old, deprecated document http API. Remove this package on Vespa 7.
-package com.yahoo.feedhandler;