@Override public boolean remove(DocumentRemove documentRemove, DocumentProtocol.Priority pri) { RemoveDocumentMessage msg = new RemoveDocumentMessage(documentRemove.getId()); msg.setPriority(pri); msg.setCondition(documentRemove.getCondition()); return remove(msg); }
@Override protected boolean doEncode(DocumentMessage obj, DocumentSerializer buf) { RemoveDocumentMessage msg = (RemoveDocumentMessage)obj; msg.getDocumentId().serialize(buf); encodeTasCondition(buf, (TestAndSetMessage) obj); return true; } }
@Override public void onMessage(Message m, AckToken token) { if (m instanceof PutDocumentMessage) { appendSingleOpToPendingList(((PutDocumentMessage)m).getDocumentPut(), token); } else if (m instanceof RemoveDocumentMessage) { appendSingleOpToPendingList(((RemoveDocumentMessage)m).getDocumentRemove(), token); } else { throw new UnsupportedOperationException( String.format("Expected put/remove message, got '%s' of type %s", m.toString(), m.getClass().toString())); } }
@Override public Result remove(DocumentId id, DocumentProtocol.Priority pri) { RemoveDocumentMessage msg = new RemoveDocumentMessage(id); msg.setPriority(pri); return send(msg); }
@Override public boolean remove(DocumentRemove documentRemove) { RemoveDocumentMessage msg = new RemoveDocumentMessage(documentRemove.getId()); msg.setCondition(documentRemove.getCondition()); return remove(msg); }
@Override protected DocumentMessage doDecode(DocumentDeserializer buf) { RemoveDocumentMessage msg = new RemoveDocumentMessage(); decodeInto(msg, buf); return msg; }
public List<Processing> fromMessage(Message message) { List<Processing> processings = new ArrayList<>(); switch (message.getType()) { case DocumentProtocol.MESSAGE_PUTDOCUMENT: { PutDocumentMessage putMessage = (PutDocumentMessage) message; DocumentPut putOperation = new DocumentPut(createPutDocument(putMessage)); putOperation.setCondition(putMessage.getCondition()); processings.add(createProcessing(putOperation, message)); break; } case DocumentProtocol.MESSAGE_UPDATEDOCUMENT: { UpdateDocumentMessage updateMessage = (UpdateDocumentMessage) message; DocumentUpdate updateOperation = updateMessage.getDocumentUpdate(); updateOperation.setCondition(updateMessage.getCondition()); processings.add(createProcessing(updateOperation, message)); break; } case DocumentProtocol.MESSAGE_REMOVEDOCUMENT: { RemoveDocumentMessage removeMessage = (RemoveDocumentMessage) message; DocumentRemove removeOperation = new DocumentRemove(removeMessage.getDocumentId()); removeOperation.setCondition(removeMessage.getCondition()); processings.add(createProcessing(removeOperation, message)); break; } } return processings; }
if (removeMsg.getDocumentId().hasDocType()) { return selector.accepts(removeMsg.getDocumentRemove()) != Result.FALSE; } else { return true;
protected void decodeInto(RemoveDocumentMessage msg, DocumentDeserializer buf) { msg.setDocumentId(new DocumentId(buf)); decodeTasCondition(msg, buf); }
private static DocumentMessage newMessage(DocumentOperation documentOperation) { final TestAndSetMessage message; if (documentOperation instanceof DocumentPut) { message = new PutDocumentMessage(((DocumentPut)documentOperation)); } else if (documentOperation instanceof DocumentUpdate) { message = new UpdateDocumentMessage((DocumentUpdate)documentOperation); } else if (documentOperation instanceof DocumentRemove) { message = new RemoveDocumentMessage(documentOperation.getId()); } else { throw new UnsupportedOperationException(documentOperation.getClass().getName()); } message.setCondition(documentOperation.getCondition()); return message; }
static DocumentOperationMessageV3 newRemoveMessage(VespaXMLFeedReader.Operation op, String operationId) { DocumentRemove remove = new DocumentRemove(op.getRemove()); remove.setCondition(op.getCondition()); Message msg = new RemoveDocumentMessage(remove); String id = (operationId == null) ? remove.getId().toString() : operationId; return new DocumentOperationMessageV3(id, msg); }
@Override public void onMessage(Message m, AckToken token) { if (m instanceof PutDocumentMessage) { PutDocumentMessage pm = (PutDocumentMessage)m; onDocument(pm.getDocumentPut().getDocument(), pm.getTimestamp()); } else if (m instanceof RemoveDocumentMessage) { RemoveDocumentMessage rm = (RemoveDocumentMessage)m; onRemove(rm.getDocumentId()); } else { throw new UnsupportedOperationException("Received unsupported message " + m.toString() + " to dump visitor data handler. This handler only accepts Put and Remove"); } ack(token); }
@SuppressWarnings("deprecation") private BucketId getBucketId(Message msg) { switch (msg.getType()) { case DocumentProtocol.MESSAGE_PUTDOCUMENT: return factory.getBucketId(((PutDocumentMessage)msg).getDocumentPut().getDocument().getId()); case DocumentProtocol.MESSAGE_GETDOCUMENT: return factory.getBucketId(((GetDocumentMessage)msg).getDocumentId()); case DocumentProtocol.MESSAGE_REMOVEDOCUMENT: return factory.getBucketId(((RemoveDocumentMessage)msg).getDocumentId()); case DocumentProtocol.MESSAGE_UPDATEDOCUMENT: return factory.getBucketId(((UpdateDocumentMessage)msg).getDocumentUpdate().getId()); case DocumentProtocol.MESSAGE_GETBUCKETLIST: return ((GetBucketListMessage)msg).getBucketId(); 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(); default: log.log(LogLevel.ERROR, "Message type '" + msg.getType() + "' not supported."); return null; } }
private static Response toError(Reply reply, long reqId) { Message msg = reply.getMessage(); String err = getErrorMessage(reply); switch (msg.getType()) { case DocumentProtocol.MESSAGE_PUTDOCUMENT: return new DocumentResponse(reqId, ((PutDocumentMessage)msg).getDocumentPut().getDocument(), err, false); case DocumentProtocol.MESSAGE_UPDATEDOCUMENT: return new DocumentUpdateResponse(reqId, ((UpdateDocumentMessage)msg).getDocumentUpdate(), err, false); case DocumentProtocol.MESSAGE_REMOVEDOCUMENT: return new DocumentIdResponse(reqId, ((RemoveDocumentMessage)msg).getDocumentId(), err, false); case DocumentProtocol.MESSAGE_GETDOCUMENT: return new DocumentIdResponse(reqId, ((GetDocumentMessage)msg).getDocumentId(), err, false); default: return new Response(reqId, err, false); } }
private static Response toSuccess(Reply reply, long reqId) { switch (reply.getType()) { case DocumentProtocol.REPLY_GETDOCUMENT: GetDocumentReply docReply = ((GetDocumentReply) reply); Document getDoc = docReply.getDocument(); if (getDoc != null) { getDoc.setLastModified(docReply.getLastModified()); } return new DocumentResponse(reqId, getDoc); case DocumentProtocol.REPLY_REMOVEDOCUMENT: return new RemoveResponse(reqId, ((RemoveDocumentReply)reply).wasFound()); case DocumentProtocol.REPLY_UPDATEDOCUMENT: return new UpdateResponse(reqId, ((UpdateDocumentReply)reply).wasFound()); case DocumentProtocol.REPLY_PUTDOCUMENT: break; default: return new Response(reqId); } Message msg = reply.getMessage(); switch (msg.getType()) { case DocumentProtocol.MESSAGE_PUTDOCUMENT: return new DocumentResponse(reqId, ((PutDocumentMessage)msg).getDocumentPut().getDocument()); case DocumentProtocol.MESSAGE_REMOVEDOCUMENT: return new DocumentIdResponse(reqId, ((RemoveDocumentMessage)msg).getDocumentId()); case DocumentProtocol.MESSAGE_UPDATEDOCUMENT: return new DocumentUpdateResponse(reqId, ((UpdateDocumentMessage)msg).getDocumentUpdate()); default: return new Response(reqId); } }