diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-04-27 14:30:27 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-04-27 14:30:27 +0200 |
commit | 8993b9df81bf0acbbe42db002a202f46f019e7e6 (patch) | |
tree | 935c4155ced84270600886a2d93b7baef3ee0937 /vespaclient-core | |
parent | 8b9222ae58fe933c4cfa93d0f877ae5c4bfe09c1 (diff) |
Unify passing of all feed operations through the various feed apis.
Diffstat (limited to 'vespaclient-core')
4 files changed, 18 insertions, 58 deletions
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(); } |