use of com.yahoo.document.DocumentId in project vespa by vespa-engine.
the class AbstractDocumentApiTestCase method requireThatAsyncSessionWorks.
@Test
public void requireThatAsyncSessionWorks() throws InterruptedException {
AsyncSession session = access().createAsyncSession(new AsyncParameters());
HashMap<Long, Response> results = new LinkedHashMap<>();
Result result;
DocumentType type = access().getDocumentTypeManager().getDocumentType("music");
Document doc1 = new Document(type, new DocumentId("doc:music:1"));
Document doc2 = new Document(type, new DocumentId("doc:music:2"));
result = session.put(doc1);
assertTrue(result.isSuccess());
results.put(result.getRequestId(), new Response(result.getRequestId()));
result = session.put(doc2);
assertTrue(result.isSuccess());
results.put(result.getRequestId(), new Response(result.getRequestId()));
List<Response> responses = new ArrayList<>();
waitForAcks(session, 2, responses);
result = session.get(new DocumentId("doc:music:1"));
assertTrue(result.isSuccess());
results.put(result.getRequestId(), new DocumentResponse(result.getRequestId(), doc1));
result = session.get(new DocumentId("doc:music:2"));
assertTrue(result.isSuccess());
results.put(result.getRequestId(), new DocumentResponse(result.getRequestId(), doc2));
// These Gets shall observe the ACKed Puts sent for the same document IDs.
waitForAcks(session, 2, responses);
result = session.remove(new DocumentId("doc:music:1"));
assertTrue(result.isSuccess());
results.put(result.getRequestId(), new Response(result.getRequestId()));
waitForAcks(session, 1, responses);
result = session.get(new DocumentId("doc:music:1"));
assertTrue(result.isSuccess());
results.put(result.getRequestId(), new DocumentResponse(result.getRequestId()));
result = session.get(new DocumentId("doc:music:2"));
assertTrue(result.isSuccess());
results.put(result.getRequestId(), new DocumentResponse(result.getRequestId(), doc2));
waitForAcks(session, 2, responses);
result = session.remove(new DocumentId("doc:music:2"));
assertTrue(result.isSuccess());
results.put(result.getRequestId(), new Response(result.getRequestId()));
waitForAcks(session, 1, responses);
result = session.get(new DocumentId("doc:music:1"));
assertTrue(result.isSuccess());
results.put(result.getRequestId(), new DocumentResponse(result.getRequestId()));
result = session.get(new DocumentId("doc:music:2"));
assertTrue(result.isSuccess());
results.put(result.getRequestId(), new DocumentResponse(result.getRequestId()));
waitForAcks(session, 2, responses);
for (Response response : responses) {
assertTrue(response.isSuccess());
assertEquals(results.get(response.getRequestId()), response);
}
session.destroy();
}
use of com.yahoo.document.DocumentId in project vespa by vespa-engine.
the class PolicyFactoryTestCase method createMessage.
// //////////////////////////////////////////////////////////////////////////////
//
// Utilities
//
// //////////////////////////////////////////////////////////////////////////////
private static Message createMessage() {
Message msg = new RemoveDocumentMessage(new DocumentId("doc:scheme:"));
msg.getTrace().setLevel(9);
return msg;
}
use of com.yahoo.document.DocumentId in project vespa by vespa-engine.
the class VisitorDataQueueTest method assertResponseHasSingleRemove.
private static void assertResponseHasSingleRemove(final VisitorResponse response, final String docId) {
assertNonNullDocumentListResponse(response);
final DocumentListVisitorResponse visitorResponse = (DocumentListVisitorResponse) response;
assertThat(visitorResponse.getDocumentList().size(), equalTo(1));
final Entry entry = visitorResponse.getDocumentList().get(0);
assertThat(entry.isRemoveEntry(), is(true));
assertThat(entry.getDocumentOperation(), instanceOf(DocumentRemove.class));
assertThat(entry.getDocumentOperation().getId(), equalTo(new DocumentId(docId)));
}
use of com.yahoo.document.DocumentId in project vespa by vespa-engine.
the class VisitorDataQueueTest method unknown_message_throws_unsupported_operation_exception.
@Test(expected = UnsupportedOperationException.class)
public void unknown_message_throws_unsupported_operation_exception() {
final VisitorDataQueue queue = new VisitorDataQueue();
queue.onMessage(new GetDocumentMessage(new DocumentId("id:foo:testdoc::bar")), createDummyAckToken());
}
use of com.yahoo.document.DocumentId in project vespa by vespa-engine.
the class MessageSequencingTest method get_document_message_is_not_sequenced.
/*
* Sequencing read-only operations artificially limits parallelization of such operations.
* We do not violate linearizability by not sequencing, as it only assumes that a write
* will become visible at some "atomic" point between sending the write and receiving an
* ACK for it. I.e. if we have not received an ACK, we cannot guarantee operation visibility
* either way. Sending off a read just after sending a write inherently does not satisfy
* this requirement for visibility.
*/
@Test
public void get_document_message_is_not_sequenced() {
GetDocumentMessage message = new GetDocumentMessage(new DocumentId("id:foo:bar::baz"));
assertFalse(message.hasSequenceId());
}
Aggregations