diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2018-09-25 13:52:38 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@broadpark.no> | 2018-09-25 13:52:38 +0200 |
commit | 923399a03316b8cc7acf5ffdf99426edf667ac6c (patch) | |
tree | b62969dfb67045386e6a9561cebc87394995237c /documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol | |
parent | 5cddfbae790d23b5a98506a31bd43f197658486b (diff) |
Remove BatchDocumentUpdateMessage and BatchDocumentUpdateReply from
java portion of documentapi.
Diffstat (limited to 'documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol')
6 files changed, 0 insertions, 307 deletions
diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/BatchDocumentUpdateMessage.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/BatchDocumentUpdateMessage.java deleted file mode 100644 index d8288a94ab6..00000000000 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/BatchDocumentUpdateMessage.java +++ /dev/null @@ -1,184 +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.documentapi.messagebus.protocol; - -import com.yahoo.document.BucketId; -import com.yahoo.document.BucketIdFactory; -import com.yahoo.document.DocumentId; -import com.yahoo.document.DocumentUpdate; -import com.yahoo.document.idstring.GroupDocIdString; -import com.yahoo.document.idstring.IdString; -import com.yahoo.document.idstring.UserDocIdString; -import com.yahoo.document.serialization.DocumentDeserializer; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Simon Thoresen Hult - */ -public class BatchDocumentUpdateMessage extends DocumentMessage { - - private DocumentDeserializer buffer = null; - private List<DocumentUpdate> updates = new ArrayList<DocumentUpdate>(); - private LazyDecoder decoder = null; - private String group = null; - private Long userId = null; - private BucketId bucketId = null; - - public String getGroup() { - return group; - } - - public Long getUserId() { - return userId; - } - - /** - * Constructs a new message for deserialization. - */ - BatchDocumentUpdateMessage() { - // 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. - */ - public BatchDocumentUpdateMessage(long userId, LazyDecoder decoder, DocumentDeserializer buffer) { - this.userId = userId; - this.decoder = decoder; - this.buffer = buffer; - setBucketId(new UserDocIdString("foo", userId, "bar")); - } - - /** - * 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. - */ - public BatchDocumentUpdateMessage(String group, LazyDecoder decoder, DocumentDeserializer buffer) { - this.group = group; - this.decoder = decoder; - this.buffer = buffer; - setBucketId(new GroupDocIdString("foo", group, "bar")); - } - - /** - * Constructs a batch document update message, to contain updates for documents for the given user. - */ - public BatchDocumentUpdateMessage(long userId) { - super(); - this.userId = userId; - setBucketId(new UserDocIdString("foo", userId, "bar")); - } - - /** - * Constructs a batch document update message, to contain updates for documents for the given user. - */ - public BatchDocumentUpdateMessage(String group) { - super(); - this.group = group; - setBucketId(new GroupDocIdString("foo", group, "bar")); - } - - void setBucketId(IdString id) { - BucketIdFactory factory = new BucketIdFactory(); - bucketId = factory.getBucketId(new DocumentId(id)); - } - - BucketId getBucketId() { - return bucketId; - } - - /** - * This method will make sure that any serialized content is deserialized into proper message content on first - * entry. Any subsequent entry into this function will do nothing. - */ - private void deserialize() { - if (decoder != null && buffer != null) { - decoder.decode(this, buffer); - decoder = null; - buffer = null; - } - } - - /** - * Returns the list of document updates to perform. - * - * @return The updates. - */ - public List<DocumentUpdate> getUpdates() { - deserialize(); - return updates; - } - - /** - * Adds a document update to perform. - * - * @param upd The document update to set. - */ - public void addUpdate(DocumentUpdate upd) { - buffer = null; - decoder = null; - - verifyUpdate(upd); - updates.add(upd); - } - - /** - * Returns the raw serialized buffer. This buffer is stored as the message is received from accross the network, and - * deserialized from as soon as a member is requested. This method will return null if the buffer has been decoded. - * - * @return The buffer containing the serialized data for this message, or null. - */ - ByteBuffer getSerializedBuffer() { - return buffer != null ? buffer.getBuf().getByteBuffer() : null; - } - - @Override - public DocumentReply createReply() { - return new BatchDocumentUpdateReply(); - } - - @Override - public int getType() { - return DocumentProtocol.MESSAGE_BATCHDOCUMENTUPDATE; - } - - void verifyUpdate(DocumentUpdate update) { - if (update == null) { - throw new IllegalArgumentException("Document update can not be null."); - } - - IdString idString = update.getId().getScheme(); - - if (group != null) { - String idGroup; - - if (idString.hasGroup()) { - idGroup = idString.getGroup(); - } else { - throw new IllegalArgumentException("Batch update message can only contain groupdoc or orderdoc items"); - } - - if (!group.equals(idGroup)) { - throw new IllegalArgumentException("Batch update message can not contain messages from group " + idGroup + " only group " + group); - } - } else { - long foundUserId = 0; - - if (idString.hasNumber()) { - foundUserId = idString.getNumber(); - } else { - throw new IllegalArgumentException("Batch update message can only contain userdoc or orderdoc items"); - } - - if (userId != foundUserId) { - throw new IllegalArgumentException("Batch update message can not contain messages from user " + foundUserId + " only user " + userId); - } - } - } - -} diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/BatchDocumentUpdateReply.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/BatchDocumentUpdateReply.java deleted file mode 100755 index 3e6e3a3429d..00000000000 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/BatchDocumentUpdateReply.java +++ /dev/null @@ -1,29 +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.documentapi.messagebus.protocol; - -import java.util.ArrayList; - -public class BatchDocumentUpdateReply extends WriteDocumentReply { - - private ArrayList<Boolean> documentsNotFound = new ArrayList<Boolean>(); - - /** - * Constructs a new reply with no content. - */ - public BatchDocumentUpdateReply() { - super(DocumentProtocol.REPLY_BATCHDOCUMENTUPDATE); - } - - /** - * If all documents to update are found, this vector will be empty. If - * one or more documents are not found, this vector will have the size of - * the initial number of updates, with entries set to true where the - * corresponding update was not found. - * - * @return Vector containing indices of not found documents, or empty - * if all documents were found - */ - public ArrayList<Boolean> getDocumentsNotFound() { - return documentsNotFound; - } -} diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/DocumentProtocol.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/DocumentProtocol.java index b765b928869..6983eb4fbd9 100755 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/DocumentProtocol.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/DocumentProtocol.java @@ -66,7 +66,6 @@ public class DocumentProtocol implements Protocol { public static final int MESSAGE_EMPTYBUCKETS = DOCUMENT_MESSAGE + 23; public static final int MESSAGE_REMOVELOCATION = DOCUMENT_MESSAGE + 24; public static final int MESSAGE_QUERYRESULT = DOCUMENT_MESSAGE + 25; - public static final int MESSAGE_BATCHDOCUMENTUPDATE = DOCUMENT_MESSAGE + 26; /** * All reply types that are implemented by this protocol. @@ -89,7 +88,6 @@ public class DocumentProtocol implements Protocol { public static final int REPLY_EMPTYBUCKETS = DOCUMENT_REPLY + 23; public static final int REPLY_REMOVELOCATION = DOCUMENT_REPLY + 24; public static final int REPLY_QUERYRESULT = DOCUMENT_REPLY + 25; - public static final int REPLY_BATCHDOCUMENTUPDATE = DOCUMENT_REPLY + 26; public static final int REPLY_WRONGDISTRIBUTION = DOCUMENT_REPLY + 1000; public static final int REPLY_DOCUMENTIGNORED = DOCUMENT_REPLY + 1001; @@ -314,7 +312,6 @@ public class DocumentProtocol implements Protocol { List<VersionSpecification> from6 = Collections.singletonList(version6); // TODO decide minor version... // 5.0 serialization (keep alphabetized please) - putRoutableFactory(MESSAGE_BATCHDOCUMENTUPDATE, new RoutableFactories50.BatchDocumentUpdateMessageFactory(), from50); putRoutableFactory(MESSAGE_CREATEVISITOR, new RoutableFactories50.CreateVisitorMessageFactory(), from50); putRoutableFactory(MESSAGE_DESTROYVISITOR, new RoutableFactories50.DestroyVisitorMessageFactory(), from50); putRoutableFactory(MESSAGE_DOCUMENTLIST, new RoutableFactories50.DocumentListMessageFactory(), from50); @@ -332,7 +329,6 @@ public class DocumentProtocol implements Protocol { putRoutableFactory(MESSAGE_STATBUCKET, new RoutableFactories50.StatBucketMessageFactory(), from50); putRoutableFactory(MESSAGE_UPDATEDOCUMENT, new RoutableFactories50.UpdateDocumentMessageFactory(), from50); putRoutableFactory(MESSAGE_VISITORINFO, new RoutableFactories50.VisitorInfoMessageFactory(), from50); - putRoutableFactory(REPLY_BATCHDOCUMENTUPDATE, new RoutableFactories50.BatchDocumentUpdateReplyFactory(), from50); putRoutableFactory(REPLY_CREATEVISITOR, new RoutableFactories50.CreateVisitorReplyFactory(), from50); putRoutableFactory(REPLY_DESTROYVISITOR, new RoutableFactories50.DestroyVisitorReplyFactory(), from50); putRoutableFactory(REPLY_DOCUMENTLIST, new RoutableFactories50.DocumentListReplyFactory(), from50); diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/DocumentRouteSelectorPolicy.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/DocumentRouteSelectorPolicy.java index e48026ae7d7..dbf4a6cc593 100755 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/DocumentRouteSelectorPolicy.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/DocumentRouteSelectorPolicy.java @@ -154,15 +154,6 @@ public class DocumentRouteSelectorPolicy } } - case DocumentProtocol.MESSAGE_BATCHDOCUMENTUPDATE: - BatchDocumentUpdateMessage bdu = (BatchDocumentUpdateMessage)msg; - for (int i = 0; i < bdu.getUpdates().size(); i++) { - if (selector.accepts(bdu.getUpdates().get(i)) == Result.FALSE) { - return false; - } - } - return true; - default: return true; } diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories50.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories50.java index dfc87b77474..c7c1121ae68 100755 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories50.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories50.java @@ -583,86 +583,6 @@ public abstract class RoutableFactories50 { } } - public static class BatchDocumentUpdateMessageFactory extends DocumentMessageFactory { - - private final LazyDecoder decoder = new LazyDecoder() { - - public void decode(Routable obj, DocumentDeserializer buf) { - BatchDocumentUpdateMessage msg = (BatchDocumentUpdateMessage)obj; - int size = buf.getInt(null); - for (int i = 0; i < size; i++) { - msg.addUpdate(new DocumentUpdate(buf)); - } - } - }; - - @Override - protected DocumentMessage doDecode(DocumentDeserializer buf) { - long userId = buf.getLong(null); - String group = decodeString(buf); - - if (group.length() > 0) { - return new BatchDocumentUpdateMessage(group, decoder, buf); - } else { - return new BatchDocumentUpdateMessage(userId, decoder, buf); - } - } - - @Override - protected boolean doEncode(DocumentMessage obj, DocumentSerializer buf) { - BatchDocumentUpdateMessage msg = (BatchDocumentUpdateMessage)obj; - - if (msg.getSerializedBuffer() != null) { - buf.put(null, msg.getSerializedBuffer()); - } else { - if (msg.getUserId() != null) { - buf.putLong(null, msg.getUserId()); - } else { - buf.putLong(null, 0); - } - - if (msg.getGroup() != null) { - encodeString(msg.getGroup(), buf); - } else { - encodeString("", buf); - } - - buf.putInt(null, msg.getUpdates().size()); - for (int i = 0; i < msg.getUpdates().size(); i++) { - msg.getUpdates().get(i).serialize(buf); - } - } - - return true; - } - } - - public static class BatchDocumentUpdateReplyFactory extends DocumentReplyFactory { - - @Override - protected DocumentReply doDecode(DocumentDeserializer buf) { - BatchDocumentUpdateReply rep = new BatchDocumentUpdateReply(); - rep.setHighestModificationTimestamp(buf.getLong(null)); - int size = buf.getInt(null); - rep.getDocumentsNotFound().ensureCapacity(size); - for (int i = 0; i < size; ++i) { - rep.getDocumentsNotFound().add(buf.getByte(null) == 1); - } - return rep; - } - - @Override - protected boolean doEncode(DocumentReply obj, DocumentSerializer buf) { - BatchDocumentUpdateReply rep = (BatchDocumentUpdateReply)obj; - buf.putLong(null, rep.getHighestModificationTimestamp()); - buf.putInt(null, rep.getDocumentsNotFound().size()); - for (int i = 0; i < rep.getDocumentsNotFound().size(); ++i) { - buf.putByte(null, (byte)(rep.getDocumentsNotFound().get(i) ? 1 : 0)); - } - return true; - } - } - public static class PutDocumentMessageFactory extends DocumentMessageFactory { protected void decodeInto(PutDocumentMessage msg, DocumentDeserializer buf) { msg.setDocumentPut(new DocumentPut(Document.createDocument(buf))); diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/StoragePolicy.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/StoragePolicy.java index 6a8c00cc1b1..22f7a491056 100644 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/StoragePolicy.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/StoragePolicy.java @@ -252,7 +252,6 @@ public class StoragePolicy extends ExternalSlobrokPolicy { case DocumentProtocol.MESSAGE_STATBUCKET: return ((StatBucketMessage)msg).getBucketId(); case DocumentProtocol.MESSAGE_CREATEVISITOR: return ((CreateVisitorMessage)msg).getBuckets().get(0); case DocumentProtocol.MESSAGE_REMOVELOCATION: return ((RemoveLocationMessage)msg).getBucketId(); - case DocumentProtocol.MESSAGE_BATCHDOCUMENTUPDATE: return ((BatchDocumentUpdateMessage)msg).getBucketId(); default: log.log(LogLevel.ERROR, "Message type '" + msg.getType() + "' not supported."); return null; |