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; }
public Object evaluate(Context context) { return distribution.getColumn(factory.getBucketId(context.getDocumentOperation().getId())); }
@Override public void read(Operation operation) throws Exception { DocumentOperation documentOperation = reader.next(); if (documentOperation == null) { stream.close(); operation.setInvalid(); return; } if (documentOperation instanceof DocumentUpdate) { operation.setDocumentUpdate((DocumentUpdate) documentOperation); } else if (documentOperation instanceof DocumentRemove) { operation.setRemove(documentOperation.getId()); } else if (documentOperation instanceof DocumentPut) { operation.setDocument(((DocumentPut) documentOperation).getDocument()); } else { throw new IllegalStateException("Got unknown class from JSON reader: " + documentOperation.getClass().getName()); } operation.setCondition(documentOperation.getCondition()); }
public Object evaluate(Context context) { DocumentId id = context.getDocumentOperation().getId(); if (id == null) { throw new IllegalStateException("Document has no identifier.");