summaryrefslogtreecommitdiffstats
path: root/vespaclient-java
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-04-27 14:30:27 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2023-04-27 14:30:27 +0200
commit8993b9df81bf0acbbe42db002a202f46f019e7e6 (patch)
tree935c4155ced84270600886a2d93b7baef3ee0937 /vespaclient-java
parent8b9222ae58fe933c4cfa93d0f877ae5c4bfe09c1 (diff)
Unify passing of all feed operations through the various feed apis.
Diffstat (limited to 'vespaclient-java')
-rw-r--r--vespaclient-java/src/main/java/com/yahoo/vespa/feed/perf/SimpleFeeder.java39
1 files changed, 17 insertions, 22 deletions
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..e29e32aee92 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;
@@ -196,7 +197,7 @@ public class SimpleFeeder implements ReplyHandler {
} else {
isFirst = false;
}
- writer.write(op.getDocument());
+ writer.write(op.getDocumentPut().getDocument());
}
numReplies.incrementAndGet();
}
@@ -234,13 +235,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();
@@ -292,8 +293,10 @@ public class SimpleFeeder implements ReplyHandler {
}
@Override
- public Document getDocument() {
- return new Document(deserializer);
+ public DocumentPut getDocumentPut() {
+ DocumentPut put = new DocumentPut(new Document(deserializer));
+ put.setCondition(getCondition());
+ return put;
}
}
static class LazyUpdateOperation extends ConditionalFeedOperation {
@@ -305,7 +308,9 @@ public class SimpleFeeder implements ReplyHandler {
@Override
public DocumentUpdate getDocumentUpdate() {
- return new DocumentUpdate(deserializer);
+ DocumentUpdate update = new DocumentUpdate(deserializer);
+ update.setCondition(getCondition());
+ return update;
}
}
@@ -339,7 +344,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 +433,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;
};
}