aboutsummaryrefslogtreecommitdiffstats
path: root/vespaclient-container-plugin
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-05-28 11:06:40 +0200
committerJon Bratseth <bratseth@oath.com>2018-05-28 11:06:40 +0200
commit919d746ba513859cad11839b553ac6bb691a370d (patch)
treef455d364b16bd866f869d01171900475ad38a82a /vespaclient-container-plugin
parentda778405d6e8888f0f90444dc4a3610c5bf9f1bc (diff)
parente7203cce8fa1092c501784cd50d3e559ff2f0020 (diff)
Merge with master
Diffstat (limited to 'vespaclient-container-plugin')
-rwxr-xr-xvespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentFieldTemplate.java13
-rwxr-xr-xvespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentXMLTemplate.java13
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java19
-rwxr-xr-xvespaclient-container-plugin/src/test/java/com/yahoo/storage/searcher/GetSearcherTestCase.java6
4 files changed, 25 insertions, 26 deletions
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentFieldTemplate.java b/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentFieldTemplate.java
index 7a59be49458..4390f70cac0 100755
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentFieldTemplate.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentFieldTemplate.java
@@ -7,7 +7,6 @@ import com.yahoo.document.Field;
import com.yahoo.document.datatypes.FieldValue;
import com.yahoo.document.datatypes.Raw;
import com.yahoo.io.ByteWriter;
-import com.yahoo.prelude.templates.Context;
import com.yahoo.text.XML;
import java.io.IOException;
@@ -38,7 +37,7 @@ public class DocumentFieldTemplate extends com.yahoo.prelude.templates.UserTempl
}
@Override
- public void error(Context context, Writer writer) throws IOException {
+ public void error(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
// Error shouldn't be handled by this template, but rather
// delegated to the searcher
}
@@ -55,7 +54,7 @@ public class DocumentFieldTemplate extends com.yahoo.prelude.templates.UserTempl
}
@Override
- public void header(Context context, Writer writer) throws IOException {
+ public void header(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
if (wrapXml) {
// XML wrapping should only be used for default field rendering
writer.write("<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>\n");
@@ -64,14 +63,14 @@ public class DocumentFieldTemplate extends com.yahoo.prelude.templates.UserTempl
}
@Override
- public void footer(Context context, Writer writer) throws IOException {
+ public void footer(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
if (wrapXml) {
writer.write("</result>\n");
}
}
@Override
- public void hit(Context context, Writer writer) throws IOException {
+ public void hit(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
DocumentHit hit = (DocumentHit)context.get("hit");
Document doc = hit.getDocument();
// Assume field existence has been checked before we ever get here.
@@ -88,11 +87,11 @@ public class DocumentFieldTemplate extends com.yahoo.prelude.templates.UserTempl
}
@Override
- public void hitFooter(Context context, Writer writer) throws IOException {
+ public void hitFooter(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
}
@Override
- public void noHits(Context context, Writer writer) throws IOException {
+ public void noHits(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
}
}
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentXMLTemplate.java b/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentXMLTemplate.java
index 25ee0ff5d03..b16f39800ef 100755
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentXMLTemplate.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentXMLTemplate.java
@@ -6,7 +6,6 @@ import com.yahoo.search.Result;
import com.yahoo.search.result.ErrorHit;
import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.result.HitGroup;
-import com.yahoo.prelude.templates.Context;
import com.yahoo.search.result.Hit;
import com.yahoo.text.XML;
@@ -55,7 +54,7 @@ public class DocumentXMLTemplate extends com.yahoo.prelude.templates.UserTemplat
}
@Override
- public void error(Context context, Writer writer) throws IOException {
+ public void error(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
writer.write("<errors>\n");
// If the error contains no error hits, use a single error with the main
// code and description. Otherwise, use the error hits explicitly
@@ -72,7 +71,7 @@ public class DocumentXMLTemplate extends com.yahoo.prelude.templates.UserTemplat
}
@Override
- public void header(Context context, Writer writer) throws IOException {
+ public void header(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
writer.write("<result>\n");
HitGroup rootGroup = ((Result) context.get("result")).hits();
@@ -82,12 +81,12 @@ public class DocumentXMLTemplate extends com.yahoo.prelude.templates.UserTemplat
}
@Override
- public void footer(Context context, Writer writer) throws IOException {
+ public void footer(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
writer.write("</result>\n");
}
@Override
- public void hit(Context context, Writer writer) throws IOException {
+ public void hit(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
Hit hit = (Hit)context.get("hit");
if (hit instanceof DocumentHit) {
DocumentHit docHit = (DocumentHit) hit;
@@ -110,11 +109,11 @@ public class DocumentXMLTemplate extends com.yahoo.prelude.templates.UserTemplat
}
@Override
- public void hitFooter(Context context, Writer writer) throws IOException {
+ public void hitFooter(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
}
@Override
- public void noHits(Context context, Writer writer) throws IOException {
+ public void noHits(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException {
}
}
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java
index cd491073a1c..5f49dd5ddf8 100644
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java
@@ -181,9 +181,10 @@ class ClientFeederV3 {
if (! operationId.isPresent()) {
return Optional.empty();
}
- DocumentOperationMessageV3 msg;
+
+ DocumentOperationMessageV3 message;
try {
- msg = getNextMessage(operationId.get(), requestInputStream, settings);
+ message = getNextMessage(operationId.get(), requestInputStream, settings);
} catch (Exception e) {
if (log.isLoggable(LogLevel.DEBUG)) {
log.log(LogLevel.DEBUG, Exceptions.toMessageString(e), e);
@@ -193,8 +194,9 @@ class ClientFeederV3 {
continue;
}
- setRoute(msg, settings);
- return Optional.of(msg);
+ if (message != null)
+ setRoute(message, settings);
+ return Optional.ofNullable(message);
}
}
@@ -271,6 +273,7 @@ class ClientFeederV3 {
}
// protected for mocking
+ /** Returns the next message in the stream, or null if none */
protected DocumentOperationMessageV3 getNextMessage(
String operationId, InputStream requestInputStream, FeederSettings settings) throws Exception {
VespaXMLFeedReader.Operation operation = streamReaderV3.getNextOperation(requestInputStream, settings);
@@ -283,14 +286,14 @@ class ClientFeederV3 {
null);
}
- DocumentOperationMessageV3 msg = DocumentOperationMessageV3.create(operation, operationId, metric);
- if (msg == null) {
+ DocumentOperationMessageV3 message = DocumentOperationMessageV3.create(operation, operationId, metric);
+ if (message == null) {
// typical end of feed
return null;
}
metric.add(MetricNames.NUM_OPERATIONS, 1, null /*metricContext*/);
- log(LogLevel.DEBUG, "Successfully deserialized document id: ", msg.getOperationId());
- return msg;
+ log(LogLevel.DEBUG, "Successfully deserialized document id: ", message.getOperationId());
+ return message;
}
private void setMessageParameters(DocumentOperationMessageV3 msg, FeederSettings settings) {
diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/storage/searcher/GetSearcherTestCase.java b/vespaclient-container-plugin/src/test/java/com/yahoo/storage/searcher/GetSearcherTestCase.java
index 2424ce596a3..9d6c8c2feac 100755
--- a/vespaclient-container-plugin/src/test/java/com/yahoo/storage/searcher/GetSearcherTestCase.java
+++ b/vespaclient-container-plugin/src/test/java/com/yahoo/storage/searcher/GetSearcherTestCase.java
@@ -17,11 +17,9 @@ import com.yahoo.feedapi.FeedContext;
import com.yahoo.feedapi.MessagePropertyProcessor;
import com.yahoo.messagebus.Message;
import com.yahoo.messagebus.routing.Route;
-import com.yahoo.prelude.templates.SearchRendererAdaptor;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
-import com.yahoo.search.rendering.RendererRegistry;
import com.yahoo.search.result.Hit;
import com.yahoo.search.result.HitGroup;
import com.yahoo.search.searchchain.Execution;
@@ -740,7 +738,7 @@ public class GetSearcherTestCase {
assertEquals("application/octet-stream", result.getTemplating().getTemplates().getMimeType());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
- SearchRendererAdaptor.callRender(stream, result);
+ com.yahoo.prelude.templates.SearchRendererAdaptor.callRender(stream, result);
stream.flush();
byte[] resultBytes = stream.toByteArray();
@@ -769,7 +767,7 @@ public class GetSearcherTestCase {
assertEquals("text/fancy", result.getTemplating().getTemplates().getMimeType());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
- SearchRendererAdaptor.callRender(stream, result);
+ com.yahoo.prelude.templates.SearchRendererAdaptor.callRender(stream, result);
stream.flush();
byte[] resultBytes = stream.toByteArray();