summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHÃ¥vard Pettersen <3535158+havardpe@users.noreply.github.com>2023-04-27 15:15:50 +0200
committerGitHub <noreply@github.com>2023-04-27 15:15:50 +0200
commit8cf2f720a10e3d06c69fd43a6fdfab1a59274036 (patch)
treeb1a570a4a8567193a25d2a692af5b89d38f088f6
parent265decd47197566d4b1b1c4d017e9686125607be (diff)
parent10c64dec098e1b5109eb07c0c43a879b8cc38c0b (diff)
Merge pull request #26891 from vespa-engine/balder/unify-feed-operations
Unify passing of all feed operations through the various feed apis.
-rw-r--r--document/src/main/java/com/yahoo/document/json/JsonFeedReader.java6
-rw-r--r--document/src/main/java/com/yahoo/vespaxmlparser/ConditionalFeedOperation.java24
-rw-r--r--document/src/main/java/com/yahoo/vespaxmlparser/DocumentFeedOperation.java20
-rw-r--r--document/src/main/java/com/yahoo/vespaxmlparser/DocumentUpdateFeedOperation.java10
-rw-r--r--document/src/main/java/com/yahoo/vespaxmlparser/FeedOperation.java12
-rw-r--r--document/src/main/java/com/yahoo/vespaxmlparser/RemoveFeedOperation.java22
-rw-r--r--document/src/main/java/com/yahoo/vespaxmlparser/VespaXMLFeedReader.java14
-rw-r--r--document/src/test/java/com/yahoo/vespaxmlparser/PositionParserTestCase.java2
-rw-r--r--document/src/test/java/com/yahoo/vespaxmlparser/UriParserTestCase.java2
-rw-r--r--document/src/test/java/com/yahoo/vespaxmlparser/VespaXMLReaderTestCase.java22
-rwxr-xr-xdocumentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/UpdateDocumentMessage.java7
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/DocumentOperationMessageV3.java33
-rw-r--r--vespaclient-container-plugin/src/test/java/com/yahoo/vespaxmlparser/MockReader.java21
-rwxr-xr-xvespaclient-core/src/main/java/com/yahoo/feedapi/SimpleFeedAccess.java10
-rwxr-xr-xvespaclient-core/src/main/java/com/yahoo/feedapi/SingleSender.java33
-rwxr-xr-xvespaclient-core/src/main/java/com/yahoo/feedapi/VespaFeedSender.java6
-rw-r--r--vespaclient-core/src/main/java/com/yahoo/feedhandler/ThreadedFeedAccess.java27
-rw-r--r--vespaclient-java/src/main/java/com/yahoo/vespa/feed/perf/SimpleFeeder.java60
18 files changed, 132 insertions, 199 deletions
diff --git a/document/src/main/java/com/yahoo/document/json/JsonFeedReader.java b/document/src/main/java/com/yahoo/document/json/JsonFeedReader.java
index 4618a516f66..6a75e35ebe5 100644
--- a/document/src/main/java/com/yahoo/document/json/JsonFeedReader.java
+++ b/document/src/main/java/com/yahoo/document/json/JsonFeedReader.java
@@ -45,11 +45,11 @@ public class JsonFeedReader implements FeedReader {
}
if (documentOperation instanceof DocumentUpdate) {
- return new DocumentUpdateFeedOperation((DocumentUpdate) documentOperation, documentOperation.getCondition());
+ return new DocumentUpdateFeedOperation((DocumentUpdate) documentOperation);
} else if (documentOperation instanceof DocumentRemove) {
- return new RemoveFeedOperation(documentOperation.getId(), documentOperation.getCondition());
+ return new RemoveFeedOperation((DocumentRemove)documentOperation);
} else if (documentOperation instanceof DocumentPut) {
- return new DocumentFeedOperation(((DocumentPut) documentOperation).getDocument(), documentOperation.getCondition());
+ return new DocumentFeedOperation((DocumentPut) documentOperation);
} else {
throw new IllegalArgumentException("Got unknown class from JSON reader: " + documentOperation.getClass().getName());
}
diff --git a/document/src/main/java/com/yahoo/vespaxmlparser/ConditionalFeedOperation.java b/document/src/main/java/com/yahoo/vespaxmlparser/ConditionalFeedOperation.java
deleted file mode 100644
index 2f63bad714c..00000000000
--- a/document/src/main/java/com/yahoo/vespaxmlparser/ConditionalFeedOperation.java
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespaxmlparser;
-
-import com.yahoo.document.TestAndSetCondition;
-
-public class ConditionalFeedOperation extends FeedOperation {
-
- private final TestAndSetCondition condition;
-
- protected ConditionalFeedOperation(Type type) {
- super(type);
- this.condition = TestAndSetCondition.NOT_PRESENT_CONDITION;
- }
- protected ConditionalFeedOperation(Type type, TestAndSetCondition condition) {
- super(type);
- this.condition = condition;
- }
-
- @Override
- public TestAndSetCondition getCondition() {
- return condition;
- }
-
-}
diff --git a/document/src/main/java/com/yahoo/vespaxmlparser/DocumentFeedOperation.java b/document/src/main/java/com/yahoo/vespaxmlparser/DocumentFeedOperation.java
index 5edb066ddaf..f76cad08e50 100644
--- a/document/src/main/java/com/yahoo/vespaxmlparser/DocumentFeedOperation.java
+++ b/document/src/main/java/com/yahoo/vespaxmlparser/DocumentFeedOperation.java
@@ -1,26 +1,26 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespaxmlparser;
-import com.yahoo.document.Document;
+import com.yahoo.document.DocumentPut;
import com.yahoo.document.TestAndSetCondition;
-public class DocumentFeedOperation extends ConditionalFeedOperation {
+public class DocumentFeedOperation extends FeedOperation {
- private final Document document;
+ private final DocumentPut put;
- public DocumentFeedOperation(Document document) {
+ public DocumentFeedOperation(DocumentPut put) {
super(Type.DOCUMENT);
- this.document = document;
+ this.put = put;
}
- public DocumentFeedOperation(Document document, TestAndSetCondition condition) {
- super(Type.DOCUMENT, condition);
- this.document = document;
+ @Override
+ public DocumentPut getDocumentPut() {
+ return put;
}
@Override
- public Document getDocument() {
- return document;
+ public TestAndSetCondition getCondition() {
+ return put.getCondition();
}
}
diff --git a/document/src/main/java/com/yahoo/vespaxmlparser/DocumentUpdateFeedOperation.java b/document/src/main/java/com/yahoo/vespaxmlparser/DocumentUpdateFeedOperation.java
index 59611a7d083..cddf0557bcc 100644
--- a/document/src/main/java/com/yahoo/vespaxmlparser/DocumentUpdateFeedOperation.java
+++ b/document/src/main/java/com/yahoo/vespaxmlparser/DocumentUpdateFeedOperation.java
@@ -4,19 +4,19 @@ package com.yahoo.vespaxmlparser;
import com.yahoo.document.DocumentUpdate;
import com.yahoo.document.TestAndSetCondition;
-public class DocumentUpdateFeedOperation extends ConditionalFeedOperation {
+public class DocumentUpdateFeedOperation extends FeedOperation {
private final DocumentUpdate update;
public DocumentUpdateFeedOperation(DocumentUpdate update) {
super(Type.UPDATE);
this.update = update;
}
- public DocumentUpdateFeedOperation(DocumentUpdate update, TestAndSetCondition condition) {
- super(Type.UPDATE, condition);
- this.update = update;
- }
@Override
public DocumentUpdate getDocumentUpdate() {
return update;
}
+ @Override
+ public TestAndSetCondition getCondition() {
+ return update.getCondition();
+ }
}
diff --git a/document/src/main/java/com/yahoo/vespaxmlparser/FeedOperation.java b/document/src/main/java/com/yahoo/vespaxmlparser/FeedOperation.java
index 69d851b09bc..a77e752f79b 100644
--- a/document/src/main/java/com/yahoo/vespaxmlparser/FeedOperation.java
+++ b/document/src/main/java/com/yahoo/vespaxmlparser/FeedOperation.java
@@ -1,8 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespaxmlparser;
-import com.yahoo.document.Document;
-import com.yahoo.document.DocumentId;
+import com.yahoo.document.DocumentRemove;
+import com.yahoo.document.DocumentPut;
import com.yahoo.document.DocumentUpdate;
import com.yahoo.document.TestAndSetCondition;
@@ -21,9 +21,9 @@ public class FeedOperation {
this.type = type;
}
- public Document getDocument() { return null; }
+ public DocumentPut getDocumentPut() { return null; }
public DocumentUpdate getDocumentUpdate() { return null; }
- public DocumentId getRemove() { return null; }
+ public DocumentRemove getDocumentRemove() { return null; }
public TestAndSetCondition getCondition() {
return TestAndSetCondition.NOT_PRESENT_CONDITION;
@@ -32,8 +32,8 @@ public class FeedOperation {
public String toString() {
return "Operation{" +
"type=" + getType() +
- ", doc=" + getDocument() +
- ", remove=" + getRemove() +
+ ", doc=" + getDocumentPut() +
+ ", remove=" + getDocumentRemove() +
", docUpdate=" + getDocumentUpdate() +
" testandset=" + getCondition() +
'}';
diff --git a/document/src/main/java/com/yahoo/vespaxmlparser/RemoveFeedOperation.java b/document/src/main/java/com/yahoo/vespaxmlparser/RemoveFeedOperation.java
index 86bd4632905..82455ea165a 100644
--- a/document/src/main/java/com/yahoo/vespaxmlparser/RemoveFeedOperation.java
+++ b/document/src/main/java/com/yahoo/vespaxmlparser/RemoveFeedOperation.java
@@ -1,22 +1,22 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespaxmlparser;
-import com.yahoo.document.DocumentId;
+import com.yahoo.document.DocumentRemove;
import com.yahoo.document.TestAndSetCondition;
-public class RemoveFeedOperation extends ConditionalFeedOperation {
- private final DocumentId documentId;
- public RemoveFeedOperation(DocumentId documentId) {
+public class RemoveFeedOperation extends FeedOperation {
+ private final DocumentRemove remove;
+ public RemoveFeedOperation(DocumentRemove remove) {
super(Type.REMOVE);
- this.documentId = documentId;
- }
- public RemoveFeedOperation(DocumentId documentId, TestAndSetCondition condition) {
- super(Type.REMOVE, condition);
- this.documentId = documentId;
+ this.remove = remove;
}
@Override
- public DocumentId getRemove() {
- return documentId;
+ public DocumentRemove getDocumentRemove() {
+ return remove;
+ }
+ @Override
+ public TestAndSetCondition getCondition() {
+ return remove.getCondition();
}
}
diff --git a/document/src/main/java/com/yahoo/vespaxmlparser/VespaXMLFeedReader.java b/document/src/main/java/com/yahoo/vespaxmlparser/VespaXMLFeedReader.java
index 361665a2ef1..85123de349a 100644
--- a/document/src/main/java/com/yahoo/vespaxmlparser/VespaXMLFeedReader.java
+++ b/document/src/main/java/com/yahoo/vespaxmlparser/VespaXMLFeedReader.java
@@ -3,6 +3,8 @@ package com.yahoo.vespaxmlparser;
import com.yahoo.document.Document;
import com.yahoo.document.DocumentId;
+import com.yahoo.document.DocumentPut;
+import com.yahoo.document.DocumentRemove;
import com.yahoo.document.DocumentTypeManager;
import com.yahoo.document.DocumentUpdate;
import com.yahoo.document.TestAndSetCondition;
@@ -99,12 +101,14 @@ public class VespaXMLFeedReader extends VespaXMLReader implements FeedReader {
if ("document".equals(startTag)) {
VespaXMLDocumentReader documentReader = new VespaXMLDocumentReader(reader, docTypeManager);
- Document document = new Document(documentReader);
- return new DocumentFeedOperation(document, TestAndSetCondition.fromConditionString(documentReader.getCondition()));
+ DocumentPut put = new DocumentPut(new Document(documentReader));
+ put.setCondition(TestAndSetCondition.fromConditionString(documentReader.getCondition()));
+ return new DocumentFeedOperation(put);
} else if ("update".equals(startTag)) {
VespaXMLUpdateReader updateReader = new VespaXMLUpdateReader(reader, docTypeManager);
DocumentUpdate update = new DocumentUpdate(updateReader);
- return new DocumentUpdateFeedOperation(update, TestAndSetCondition.fromConditionString(updateReader.getCondition()));
+ update.setCondition(TestAndSetCondition.fromConditionString(updateReader.getCondition()));
+ return new DocumentUpdateFeedOperation(update);
} else if ("remove".equals(startTag)) {
DocumentId documentId = null;
@@ -121,7 +125,9 @@ public class VespaXMLFeedReader extends VespaXMLReader implements FeedReader {
if (documentId == null) {
throw newDeserializeException("Missing \"documentid\" attribute for remove operation");
}
- return new RemoveFeedOperation(documentId, TestAndSetCondition.fromConditionString(condition));
+ DocumentRemove remove = new DocumentRemove(documentId);
+ remove.setCondition(TestAndSetCondition.fromConditionString(condition));
+ return new RemoveFeedOperation(remove);
} else {
throw newDeserializeException("Element \"" + startTag + "\" not allowed in this context");
}
diff --git a/document/src/test/java/com/yahoo/vespaxmlparser/PositionParserTestCase.java b/document/src/test/java/com/yahoo/vespaxmlparser/PositionParserTestCase.java
index e2070edd397..a8ee7685790 100644
--- a/document/src/test/java/com/yahoo/vespaxmlparser/PositionParserTestCase.java
+++ b/document/src/test/java/com/yahoo/vespaxmlparser/PositionParserTestCase.java
@@ -41,7 +41,7 @@ public class PositionParserTestCase {
private static void assertDocument(Struct expected, FeedOperation operation) {
assertNotNull(operation);
assertEquals(FeedOperation.Type.DOCUMENT, operation.getType());
- Document doc = operation.getDocument();
+ Document doc = operation.getDocumentPut().getDocument();
assertNotNull(doc);
assertEquals(expected, doc.getFieldValue("my_pos"));
}
diff --git a/document/src/test/java/com/yahoo/vespaxmlparser/UriParserTestCase.java b/document/src/test/java/com/yahoo/vespaxmlparser/UriParserTestCase.java
index 3eb05e6871b..87797e3f4bd 100644
--- a/document/src/test/java/com/yahoo/vespaxmlparser/UriParserTestCase.java
+++ b/document/src/test/java/com/yahoo/vespaxmlparser/UriParserTestCase.java
@@ -64,7 +64,7 @@ public class UriParserTestCase {
FeedOperation op = it.next();
assertNotNull(op);
assertEquals(FeedOperation.Type.DOCUMENT, op.getType());
- Document doc = op.getDocument();
+ Document doc = op.getDocumentPut().getDocument();
assertNotNull(doc);
return doc;
}
diff --git a/document/src/test/java/com/yahoo/vespaxmlparser/VespaXMLReaderTestCase.java b/document/src/test/java/com/yahoo/vespaxmlparser/VespaXMLReaderTestCase.java
index b2fa7014480..20be6109076 100644
--- a/document/src/test/java/com/yahoo/vespaxmlparser/VespaXMLReaderTestCase.java
+++ b/document/src/test/java/com/yahoo/vespaxmlparser/VespaXMLReaderTestCase.java
@@ -68,7 +68,7 @@ public class VespaXMLReaderTestCase {
FeedOperation op = parser.read();
assertTrue(FeedOperation.Type.INVALID != op.getType());
- Document doc = op.getDocument();
+ Document doc = op.getDocumentPut().getDocument();
assertEquals(new StringFieldValue("testUrl"), doc.getFieldValue("url"));
assertEquals(new StringFieldValue("testTitle"), doc.getFieldValue("title"));
assertEquals(new IntegerFieldValue(1), doc.getFieldValue("last_downloaded"));
@@ -339,7 +339,7 @@ public class VespaXMLReaderTestCase {
// empty string
FeedOperation op = parser.read();
- assertEquals("id:ns:news::http://news6b", op.getDocument().getId().toString());
+ assertEquals("id:ns:news::http://news6b", op.getDocumentPut().getDocument().getId().toString());
// int array with text
try {
@@ -398,7 +398,7 @@ public class VespaXMLReaderTestCase {
}
op = parser.read();
- assertEquals("id:ns:news::http://news6j", op.getDocument().getId().toString());
+ assertEquals("id:ns:news::http://news6j", op.getDocumentPut().getDocument().getId().toString());
op = parser.read();
assertEquals(FeedOperation.Type.INVALID, op.getType());
@@ -515,13 +515,13 @@ public class VespaXMLReaderTestCase {
FeedOperation op = parser.read();
assertEquals(FeedOperation.Type.REMOVE, op.getType());
- assertEquals("id:ns:news::http://news9a", op.getRemove().toString());
+ assertEquals("id:ns:news::http://news9a", op.getDocumentRemove().getId().toString());
}
{
FeedOperation op = parser.read();
assertEquals(FeedOperation.Type.REMOVE, op.getType());
- assertEquals("id:ns:news::http://news9b", op.getRemove().toString());
+ assertEquals("id:ns:news::http://news9b", op.getDocumentRemove().getId().toString());
}
{
// Remove without documentid. Not supported.
@@ -539,7 +539,7 @@ public class VespaXMLReaderTestCase {
VespaXMLFeedReader parser = new VespaXMLFeedReader("src/test/vespaxmlparser/test10.xml", manager);
{
FeedOperation op = parser.read();
- Document doc = op.getDocument();
+ Document doc = op.getDocumentPut().getDocument();
assertEquals(new StringFieldValue("testUrl"), doc.getFieldValue("url"));
assertEquals(new StringFieldValue("testTitle"), doc.getFieldValue("title"));
@@ -576,7 +576,7 @@ public class VespaXMLReaderTestCase {
}
{
FeedOperation op = parser.read();
- Document doc = op.getDocument();
+ Document doc = op.getDocumentPut().getDocument();
assertNotNull(doc);
assertEquals(new StringFieldValue("testUrl2"), doc.getFieldValue("url"));
}
@@ -649,7 +649,7 @@ public class VespaXMLReaderTestCase {
}
{
FeedOperation op = parser.read();
- assertEquals("id:ns:news::http://news10e", op.getRemove().toString());
+ assertEquals("id:ns:news::http://news10e", op.getDocumentRemove().getId().toString());
}
{
// Illegal remove without documentid attribute
@@ -792,11 +792,11 @@ public class VespaXMLReaderTestCase {
System.err.println(op);
assertEquals(FeedOperation.Type.DOCUMENT, op.getType());
- assertNull(op.getRemove());
+ assertNull(op.getDocumentRemove());
assertNull(op.getDocumentUpdate());
- assertNotNull(op.getDocument());
+ assertNotNull(op.getDocumentPut().getDocument());
- Document doc = op.getDocument();
+ Document doc = op.getDocumentPut().getDocument();
assertEquals("outerdoc", doc.getDataType().getName());
assertEquals("id:outer:outerdoc::this:is:outer:doc", doc.getId().toString());
diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/UpdateDocumentMessage.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/UpdateDocumentMessage.java
index 214fe1637cd..d3af2cfa64d 100755
--- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/UpdateDocumentMessage.java
+++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/UpdateDocumentMessage.java
@@ -20,13 +20,6 @@ public class UpdateDocumentMessage extends TestAndSetMessage {
private LazyDecoder decoder = null;
/**
- * Constructs a new message for deserialization.
- */
- UpdateDocumentMessage() {
- // empty
- }
-
- /**
* Constructs a new message from a byte buffer.
* @param decoder The decoder to use for deserialization.
* @param buffer A byte buffer that contains a serialized message.
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/DocumentOperationMessageV3.java b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/DocumentOperationMessageV3.java
index a12fe4efa8b..6613f1a5538 100644
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/DocumentOperationMessageV3.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/DocumentOperationMessageV3.java
@@ -1,9 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.http.server;
-import com.yahoo.document.DocumentPut;
-import com.yahoo.document.DocumentRemove;
-import com.yahoo.document.DocumentUpdate;
import com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage;
import com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage;
import com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage;
@@ -35,46 +32,44 @@ class DocumentOperationMessageV3 {
}
private static DocumentOperationMessageV3 newUpdateMessage(FeedOperation op, String operationId) {
- DocumentUpdate update = op.getDocumentUpdate();
- update.setCondition(op.getCondition());
- Message msg = new UpdateDocumentMessage(update);
+ var msg = new UpdateDocumentMessage(op.getDocumentUpdate());
- String id = (operationId == null) ? update.getId().toString() : operationId;
+ String id = (operationId == null) ? msg.getDocumentUpdate().getId().toString() : operationId;
return new DocumentOperationMessageV3(id, msg);
}
static DocumentOperationMessageV3 newRemoveMessage(FeedOperation op, String operationId) {
- DocumentRemove remove = new DocumentRemove(op.getRemove());
- remove.setCondition(op.getCondition());
- Message msg = new RemoveDocumentMessage(remove);
+ var msg = new RemoveDocumentMessage(op.getDocumentRemove());
- String id = (operationId == null) ? remove.getId().toString() : operationId;
+ String id = (operationId == null) ? msg.getDocumentId().toString() : operationId;
return new DocumentOperationMessageV3(id, msg);
}
private static DocumentOperationMessageV3 newPutMessage(FeedOperation op, String operationId) {
- DocumentPut put = new DocumentPut(op.getDocument());
- put.setCondition(op.getCondition());
- Message msg = new PutDocumentMessage(put);
+ var msg = new PutDocumentMessage(op.getDocumentPut());
- String id = (operationId == null) ? put.getId().toString() : operationId;
+ String id = (operationId == null) ? msg.getDocumentPut().getId().toString() : operationId;
return new DocumentOperationMessageV3(id, msg);
}
static DocumentOperationMessageV3 create(FeedOperation operation, String operationId, Metric metric) {
switch (operation.getType()) {
- case DOCUMENT:
+ case DOCUMENT -> {
metric.add(MetricNames.NUM_PUTS, 1, null);
return newPutMessage(operation, operationId);
- case REMOVE:
+ }
+ case REMOVE -> {
metric.add(MetricNames.NUM_REMOVES, 1, null);
return newRemoveMessage(operation, operationId);
- case UPDATE:
+ }
+ case UPDATE -> {
metric.add(MetricNames.NUM_UPDATES, 1, null);
return newUpdateMessage(operation, operationId);
- default:
+ }
+ default -> {
// typical end of feed
return null;
+ }
}
}
diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/vespaxmlparser/MockReader.java b/vespaclient-container-plugin/src/test/java/com/yahoo/vespaxmlparser/MockReader.java
index c751849b84e..c6f48b6ae47 100644
--- a/vespaclient-container-plugin/src/test/java/com/yahoo/vespaxmlparser/MockReader.java
+++ b/vespaclient-container-plugin/src/test/java/com/yahoo/vespaxmlparser/MockReader.java
@@ -3,6 +3,8 @@ package com.yahoo.vespaxmlparser;
import com.yahoo.document.Document;
import com.yahoo.document.DocumentId;
+import com.yahoo.document.DocumentPut;
+import com.yahoo.document.DocumentRemove;
import com.yahoo.document.DocumentType;
import com.yahoo.document.DocumentUpdate;
import com.yahoo.vespa.http.server.MetaStream;
@@ -52,18 +54,13 @@ public class MockReader implements FeedReader {
byte whatToDo = stream.getNextOperation();
DocumentId id = new DocumentId("id:banana:banana::doc1");
DocumentType docType = new DocumentType("banana");
- switch (whatToDo) {
- case 0:
- return FeedOperation.INVALID;
- case 1:
- return new DocumentFeedOperation(new Document(docType, id));
- case 2:
- return new RemoveFeedOperation(id);
- case 3:
- return new DocumentUpdateFeedOperation(new DocumentUpdate(docType, id));
- default:
- throw new RuntimeException("boom");
- }
+ return switch (whatToDo) {
+ case 0 -> FeedOperation.INVALID;
+ case 1 -> new DocumentFeedOperation(new DocumentPut(new Document(docType, id)));
+ case 2 -> new RemoveFeedOperation(new DocumentRemove(id));
+ case 3 -> new DocumentUpdateFeedOperation(new DocumentUpdate(docType, id));
+ default -> throw new RuntimeException("boom");
+ };
}
}
diff --git a/vespaclient-core/src/main/java/com/yahoo/feedapi/SimpleFeedAccess.java b/vespaclient-core/src/main/java/com/yahoo/feedapi/SimpleFeedAccess.java
index ba267fe2fef..ea45979ee84 100755
--- a/vespaclient-core/src/main/java/com/yahoo/feedapi/SimpleFeedAccess.java
+++ b/vespaclient-core/src/main/java/com/yahoo/feedapi/SimpleFeedAccess.java
@@ -1,19 +1,17 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.feedapi;
-import com.yahoo.document.Document;
import com.yahoo.document.DocumentId;
+import com.yahoo.document.DocumentPut;
+import com.yahoo.document.DocumentRemove;
import com.yahoo.document.DocumentUpdate;
import com.yahoo.document.TestAndSetCondition;
public interface SimpleFeedAccess {
- void put(Document doc);
- void remove(DocumentId docId);
+ void put(DocumentPut doc);
+ void remove(DocumentRemove remove);
void update(DocumentUpdate update);
- void put(Document doc, TestAndSetCondition condition);
- void remove(DocumentId docId, TestAndSetCondition condition);
- void update(DocumentUpdate update, TestAndSetCondition condition);
boolean isAborted();
void close();
}
diff --git a/vespaclient-core/src/main/java/com/yahoo/feedapi/SingleSender.java b/vespaclient-core/src/main/java/com/yahoo/feedapi/SingleSender.java
index 6adc8a2299a..896812b58e7 100755
--- a/vespaclient-core/src/main/java/com/yahoo/feedapi/SingleSender.java
+++ b/vespaclient-core/src/main/java/com/yahoo/feedapi/SingleSender.java
@@ -1,11 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.feedapi;
-import com.yahoo.document.Document;
-import com.yahoo.document.DocumentId;
import com.yahoo.document.DocumentPut;
+import com.yahoo.document.DocumentRemove;
import com.yahoo.document.DocumentUpdate;
-import com.yahoo.document.TestAndSetCondition;
import com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage;
import com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage;
import com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage;
@@ -26,13 +24,13 @@ public class SingleSender implements SimpleFeedAccess {
}
@Override
- public void put(Document doc) {
- send(new PutDocumentMessage(new DocumentPut(doc)));
+ public void put(DocumentPut put) {
+ send(new PutDocumentMessage(put));
}
@Override
- public void remove(DocumentId docId) {
- send(new RemoveDocumentMessage(docId));
+ public void remove(DocumentRemove remove) {
+ send(new RemoveDocumentMessage(remove));
}
@Override
@@ -41,27 +39,6 @@ public class SingleSender implements SimpleFeedAccess {
}
@Override
- public void put(Document doc, TestAndSetCondition condition) {
- PutDocumentMessage message = new PutDocumentMessage(new DocumentPut(doc));
- message.setCondition(condition);
- send(message);
- }
-
- @Override
- public void remove(DocumentId docId, TestAndSetCondition condition) {
- RemoveDocumentMessage message = new RemoveDocumentMessage(docId);
- message.setCondition(condition);
- send(message);
- }
-
- @Override
- public void update(DocumentUpdate update, TestAndSetCondition condition) {
- UpdateDocumentMessage message = new UpdateDocumentMessage(update);
- message.setCondition(condition);
- send(message);
- }
-
- @Override
public boolean isAborted() {
return owner.isAborted();
}
diff --git a/vespaclient-core/src/main/java/com/yahoo/feedapi/VespaFeedSender.java b/vespaclient-core/src/main/java/com/yahoo/feedapi/VespaFeedSender.java
index 5453f5301ff..9a5735f273c 100755
--- a/vespaclient-core/src/main/java/com/yahoo/feedapi/VespaFeedSender.java
+++ b/vespaclient-core/src/main/java/com/yahoo/feedapi/VespaFeedSender.java
@@ -21,13 +21,13 @@ public class VespaFeedSender {
public void sendOperation(FeedOperation op) {
switch (op.getType()) {
case DOCUMENT:
- sender.put(op.getDocument(), op.getCondition());
+ sender.put(op.getDocumentPut());
break;
case REMOVE:
- sender.remove(op.getRemove(), op.getCondition());
+ sender.remove(op.getDocumentRemove());
break;
case UPDATE:
- sender.update(op.getDocumentUpdate(), op.getCondition());
+ sender.update(op.getDocumentUpdate());
break;
}
}
diff --git a/vespaclient-core/src/main/java/com/yahoo/feedhandler/ThreadedFeedAccess.java b/vespaclient-core/src/main/java/com/yahoo/feedhandler/ThreadedFeedAccess.java
index b5a507e894f..215ea6b9917 100644
--- a/vespaclient-core/src/main/java/com/yahoo/feedhandler/ThreadedFeedAccess.java
+++ b/vespaclient-core/src/main/java/com/yahoo/feedhandler/ThreadedFeedAccess.java
@@ -2,10 +2,9 @@
package com.yahoo.feedhandler;
import com.yahoo.concurrent.ThreadFactoryFactory;
-import com.yahoo.document.Document;
-import com.yahoo.document.DocumentId;
+import com.yahoo.document.DocumentPut;
+import com.yahoo.document.DocumentRemove;
import com.yahoo.document.DocumentUpdate;
-import com.yahoo.document.TestAndSetCondition;
import com.yahoo.feedapi.SimpleFeedAccess;
import java.util.concurrent.Executor;
@@ -40,14 +39,15 @@ final class ThreadedFeedAccess implements SimpleFeedAccess {
};
}
}
+
@Override
- public void put(Document doc) {
+ public void put(DocumentPut doc) {
executor.execute(() -> simpleFeedAccess.put(doc));
}
@Override
- public void remove(DocumentId docId) {
- executor.execute(() -> simpleFeedAccess.remove(docId));
+ public void remove(DocumentRemove remove) {
+ executor.execute(() -> simpleFeedAccess.remove(remove));
}
@Override
@@ -56,21 +56,6 @@ final class ThreadedFeedAccess implements SimpleFeedAccess {
}
@Override
- public void put(Document doc, TestAndSetCondition condition) {
- executor.execute(() -> simpleFeedAccess.put(doc, condition));
- }
-
- @Override
- public void remove(DocumentId docId, TestAndSetCondition condition) {
- executor.execute(() -> simpleFeedAccess.remove(docId, condition));
- }
-
- @Override
- public void update(DocumentUpdate update, TestAndSetCondition condition) {
- executor.execute(() -> simpleFeedAccess.update(update, condition));
- }
-
- @Override
public boolean isAborted() {
return simpleFeedAccess.isAborted();
}
diff --git a/vespaclient-java/src/main/java/com/yahoo/vespa/feed/perf/SimpleFeeder.java b/vespaclient-java/src/main/java/com/yahoo/vespa/feed/perf/SimpleFeeder.java
index 189ac69ea91..c4dfe6b26f1 100644
--- a/vespaclient-java/src/main/java/com/yahoo/vespa/feed/perf/SimpleFeeder.java
+++ b/vespaclient-java/src/main/java/com/yahoo/vespa/feed/perf/SimpleFeeder.java
@@ -6,6 +6,7 @@ import com.yahoo.config.subscription.ConfigSubscriber;
import com.yahoo.document.Document;
import com.yahoo.document.DocumentId;
import com.yahoo.document.DocumentPut;
+import com.yahoo.document.DocumentRemove;
import com.yahoo.document.DocumentTypeManager;
import com.yahoo.document.DocumentTypeManagerConfigurer;
import com.yahoo.document.DocumentUpdate;
@@ -34,7 +35,6 @@ import com.yahoo.messagebus.SourceSessionParams;
import com.yahoo.messagebus.StaticThrottlePolicy;
import com.yahoo.messagebus.network.rpc.RPCNetworkParams;
import com.yahoo.messagebus.routing.Route;
-import com.yahoo.vespaxmlparser.ConditionalFeedOperation;
import com.yahoo.vespaxmlparser.FeedReader;
import com.yahoo.vespaxmlparser.FeedOperation;
import com.yahoo.vespaxmlparser.RemoveFeedOperation;
@@ -196,7 +196,7 @@ public class SimpleFeeder implements ReplyHandler {
} else {
isFirst = false;
}
- writer.write(op.getDocument());
+ writer.write(op.getDocumentPut().getDocument());
}
numReplies.incrementAndGet();
}
@@ -234,13 +234,13 @@ public class SimpleFeeder implements ReplyHandler {
DocumentSerializer writer = DocumentSerializerFactory.createHead(buffer);
int type = NONE;
if (op.getType() == FeedOperation.Type.DOCUMENT) {
- writer.write(op.getDocument());
+ writer.write(op.getDocumentPut().getDocument());
type = DOCUMENT;
} else if (op.getType() == FeedOperation.Type.UPDATE) {
writer.write(op.getDocumentUpdate());
type = UPDATE;
} else if (op.getType() == FeedOperation.Type.REMOVE) {
- writer.write(op.getRemove());
+ writer.write(op.getDocumentRemove().getId());
type = REMOVE;
}
int sz = buffer.position();
@@ -284,28 +284,44 @@ public class SimpleFeeder implements ReplyHandler {
}
}
- static class LazyDocumentOperation extends ConditionalFeedOperation {
+ static class LazyDocumentOperation extends FeedOperation {
private final DocumentDeserializer deserializer;
+ private final TestAndSetCondition condition;
LazyDocumentOperation(DocumentDeserializer deserializer, TestAndSetCondition condition) {
- super(Type.DOCUMENT, condition);
+ super(Type.DOCUMENT);
this.deserializer = deserializer;
+ this.condition = condition;
}
@Override
- public Document getDocument() {
- return new Document(deserializer);
+ public DocumentPut getDocumentPut() {
+ DocumentPut put = new DocumentPut(new Document(deserializer));
+ put.setCondition(condition);
+ return put;
+ }
+ @Override
+ public TestAndSetCondition getCondition() {
+ return condition;
}
}
- static class LazyUpdateOperation extends ConditionalFeedOperation {
+ static class LazyUpdateOperation extends FeedOperation {
private final DocumentDeserializer deserializer;
+ private final TestAndSetCondition condition;
LazyUpdateOperation(DocumentDeserializer deserializer, TestAndSetCondition condition) {
- super(Type.UPDATE, condition);
+ super(Type.UPDATE);
this.deserializer = deserializer;
+ this.condition = condition;
}
@Override
public DocumentUpdate getDocumentUpdate() {
- return new DocumentUpdate(deserializer);
+ DocumentUpdate update = new DocumentUpdate(deserializer);
+ update.setCondition(condition);
+ return update;
+ }
+ @Override
+ public TestAndSetCondition getCondition() {
+ return condition;
}
}
@@ -339,7 +355,9 @@ public class SimpleFeeder implements ReplyHandler {
} else if (type == UPDATE) {
return new LazyUpdateOperation(deser, testAndSetCondition);
} else if (type == REMOVE) {
- return new RemoveFeedOperation(new DocumentId(deser), testAndSetCondition);
+ var remove = new DocumentRemove(new DocumentId(deser));
+ remove.setCondition(testAndSetCondition);
+ return new RemoveFeedOperation(remove);
} else {
throw new IllegalArgumentException("Unknown operation " + type);
}
@@ -426,21 +444,9 @@ public class SimpleFeeder implements ReplyHandler {
private static Message newMessage(FeedOperation op) {
return switch (op.getType()) {
- case DOCUMENT -> {
- PutDocumentMessage message = new PutDocumentMessage(new DocumentPut(op.getDocument()));
- message.setCondition(op.getCondition());
- yield message;
- }
- case REMOVE -> {
- RemoveDocumentMessage message = new RemoveDocumentMessage(op.getRemove());
- message.setCondition(op.getCondition());
- yield message;
- }
- case UPDATE -> {
- UpdateDocumentMessage message = new UpdateDocumentMessage(op.getDocumentUpdate());
- message.setCondition(op.getCondition());
- yield message;
- }
+ case DOCUMENT -> new PutDocumentMessage(op.getDocumentPut());
+ case REMOVE -> new RemoveDocumentMessage(op.getDocumentRemove());
+ case UPDATE -> new UpdateDocumentMessage(op.getDocumentUpdate());
default -> null;
};
}