Search in sources :

Example 56 with DocumentId

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();
}
Also used : DocumentId(com.yahoo.document.DocumentId) ArrayList(java.util.ArrayList) DocumentType(com.yahoo.document.DocumentType) Document(com.yahoo.document.Document) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 57 with DocumentId

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;
}
Also used : RemoveDocumentMessage(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage) RemoveDocumentMessage(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage) DocumentId(com.yahoo.document.DocumentId)

Example 58 with DocumentId

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)));
}
Also used : Entry(com.yahoo.vdslib.Entry) DocumentRemove(com.yahoo.document.DocumentRemove) DocumentId(com.yahoo.document.DocumentId)

Example 59 with DocumentId

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());
}
Also used : GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) DocumentId(com.yahoo.document.DocumentId) Test(org.junit.Test)

Example 60 with DocumentId

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());
}
Also used : DocumentId(com.yahoo.document.DocumentId) Test(org.junit.Test)

Aggregations

DocumentId (com.yahoo.document.DocumentId)61 Test (org.junit.Test)28 DocumentType (com.yahoo.document.DocumentType)20 Document (com.yahoo.document.Document)16 DocumentPut (com.yahoo.document.DocumentPut)12 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)9 BucketId (com.yahoo.document.BucketId)7 DocumentRemove (com.yahoo.document.DocumentRemove)5 DocumentUpdate (com.yahoo.document.DocumentUpdate)5 BucketIdFactory (com.yahoo.document.BucketIdFactory)4 FieldUpdate (com.yahoo.document.update.FieldUpdate)4 DocumentOperation (com.yahoo.document.DocumentOperation)3 FastHit (com.yahoo.prelude.fastsearch.FastHit)3 Hit (com.yahoo.search.result.Hit)3 HashMap (java.util.HashMap)3 TestDocumentProcessor1 (com.yahoo.docproc.DocumentProcessingAbstractTestCase.TestDocumentProcessor1)2 Field (com.yahoo.document.Field)2 GlobalId (com.yahoo.document.GlobalId)2 StructDataType (com.yahoo.document.StructDataType)2 Struct (com.yahoo.document.datatypes.Struct)2