Search in sources :

Example 1 with MessageBusVisitorSession

use of com.yahoo.documentapi.messagebus.MessageBusVisitorSession in project vespa by vespa-engine.

the class MessageBusVisitorSessionTestCase method testCreateDefaultVisitorControlHandlerIfNoneGiven.

@Test
public void testCreateDefaultVisitorControlHandlerIfNoneGiven() {
    MockSender sender = new MockSender();
    MockReceiver receiver = new MockReceiver();
    MockAsyncTaskExecutor executor = new MockAsyncTaskExecutor();
    VisitorParameters params = createVisitorParameters("");
    MessageBusVisitorSession visitorSession = createVisitorSession(sender, receiver, executor, params);
    assertNotNull(params.getControlHandler());
}
Also used : MessageBusVisitorSession(com.yahoo.documentapi.messagebus.MessageBusVisitorSession) Test(org.junit.Test)

Example 2 with MessageBusVisitorSession

use of com.yahoo.documentapi.messagebus.MessageBusVisitorSession in project vespa by vespa-engine.

the class MessageBusVisitorSessionTestCase method testVisitAll.

@Test
public void testVisitAll() {
    MockSender sender = new MockSender();
    MockReceiver receiver = new MockReceiver();
    sender.setMaxPending(1000);
    MockAsyncTaskExecutor executor = new MockAsyncTaskExecutor();
    VisitorParameters params = createVisitorParameters("");
    MessageBusVisitorSession visitorSession = createVisitorSession(sender, receiver, executor, params);
    visitorSession.start();
    executor.expectAndProcessTasks(1);
    assertEquals(2, sender.getMessageCount());
    assertEquals("CreateVisitorMessage(buckets=[\n" + "BucketId(0x0400000000000000)\n" + "BucketId(0x0000000000000000)\n" + "]\n)", replyToCreateVisitor(sender, ProgressToken.FINISHED_BUCKET));
    executor.expectAndProcessTasks(1);
    // No new visitors yet.
    executor.expectNoTasks();
    assertEquals("CreateVisitorMessage(buckets=[\n" + "BucketId(0x0400000000000001)\n" + "BucketId(0x0000000000000000)\n" + "]\n)", replyToCreateVisitor(sender, new BucketId(8, 1 | (1 << 8))));
    executor.expectAndProcessTasks(1);
    // Send new visitor for bucket 1
    executor.expectAndProcessTasks(1);
    assertEquals("CreateVisitorMessage(buckets=[\n" + "BucketId(0x0400000000000001)\n" + "BucketId(0x2000000000000001)\n" + "]\n)", replyToCreateVisitor(sender, ProgressToken.FINISHED_BUCKET));
    // Reply task
    executor.expectAndProcessTasks(1);
    // Visiting complete
    executor.expectNoTasks();
    assertTrue(visitorSession.isDone());
}
Also used : MessageBusVisitorSession(com.yahoo.documentapi.messagebus.MessageBusVisitorSession) BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Example 3 with MessageBusVisitorSession

use of com.yahoo.documentapi.messagebus.MessageBusVisitorSession in project vespa by vespa-engine.

the class MessageBusVisitorSessionTestCase method testMessageParameters.

@Test
public void testMessageParameters() {
    MockSender sender = new MockSender();
    MockReceiver receiver = new MockReceiver();
    MockAsyncTaskExecutor executor = new MockAsyncTaskExecutor();
    // Test all parameters that can be forwarded except bucketsToVisit,
    // which is already explicitly tested in testSendSingleCreateVisitor().
    VisitorParameters params = new VisitorParameters("");
    params.setDocumentSelection("id.user=5678");
    params.setFromTimestamp(9001);
    params.setToTimestamp(10001);
    params.setVisitorLibrary("CoolVisitor");
    params.setLibraryParameter("groovy", "dudes");
    params.setLibraryParameter("ninja", "turtles");
    params.setMaxBucketsPerVisitor(55);
    params.setPriority(DocumentProtocol.Priority.HIGHEST);
    params.setRoute("extraterrestrial/highway");
    params.setTimeoutMs(1337);
    params.setMaxPending(111);
    params.setFieldSet("[header]");
    params.setVisitorOrdering(123);
    params.setLoadType(new LoadType(3, "samnmax", DocumentProtocol.Priority.HIGH_3));
    params.setVisitRemoves(true);
    params.setVisitInconsistentBuckets(true);
    params.setTraceLevel(9);
    MessageBusVisitorSession visitorSession = createVisitorSession(sender, receiver, executor, params);
    visitorSession.start();
    // Process initial task which sends a single CreateVisitor.
    executor.expectAndProcessTasks(1);
    CreateVisitorMessage msg = (CreateVisitorMessage) sender.getAndRemoveMessage(0);
    assertEquals("CreateVisitorMessage(buckets=[\n" + "BucketId(0x800000000000162e)\n" + "BucketId(0x0000000000000000)\n" + "]\n" + "selection='id.user=5678'\n" + "time remaining=1337\n" + "from timestamp=9001\n" + "to timestamp=10001\n" + "max pending=111\n" + "fieldset=[header]\n" + "visit inconsistent=true\n" + "visit removes=true\n" + "parameters=[\n" + "groovy -> dudes\n" + "ninja -> turtles\n" + "]\n" + "route=extraterrestrial/highway\n" + "ordering=123\n" + "max buckets per visitor=55\n" + "load type=samnmax\n" + "priority=HIGHEST\n" + "visitor library=CoolVisitor\n" + "trace level=9\n" + ")", createVisitorToString(msg));
    assertFalse(msg.getRetryEnabled());
}
Also used : MessageBusVisitorSession(com.yahoo.documentapi.messagebus.MessageBusVisitorSession) LoadType(com.yahoo.documentapi.messagebus.loadtypes.LoadType) Test(org.junit.Test)

Example 4 with MessageBusVisitorSession

use of com.yahoo.documentapi.messagebus.MessageBusVisitorSession in project vespa by vespa-engine.

the class MessageBusVisitorSessionTestCase method testNoLocalDataHandlerGetNext.

@Test
public void testNoLocalDataHandlerGetNext() throws Exception {
    MockSender sender = new MockSender();
    MockReceiver receiver = new MockReceiver();
    MockAsyncTaskExecutor executor = new MockAsyncTaskExecutor();
    VisitorParameters params = createVisitorParameters("");
    params.setRemoteDataHandler("the/moon");
    MessageBusVisitorSession visitorSession = createVisitorSession(sender, receiver, executor, params);
    visitorSession.start();
    executor.expectAndProcessTasks(1);
    try {
        assertNotNull(visitorSession.getNext());
        fail("No exception thrown on getNext()");
    } catch (IllegalStateException e) {
        assertEquals("Data has been routed to external source for this visitor", e.getMessage());
    }
    try {
        assertNotNull(visitorSession.getNext(1234));
        fail("No exception thrown on getNext(int)");
    } catch (IllegalStateException e) {
        assertEquals("Data has been routed to external source for this visitor", e.getMessage());
    }
}
Also used : MessageBusVisitorSession(com.yahoo.documentapi.messagebus.MessageBusVisitorSession) Test(org.junit.Test)

Example 5 with MessageBusVisitorSession

use of com.yahoo.documentapi.messagebus.MessageBusVisitorSession in project vespa by vespa-engine.

the class MessageBusVisitorSessionTestCase method doTestSingleBucketVisit.

private void doTestSingleBucketVisit(VisitorParameters params, String expectedMessage) {
    MockSender sender = new MockSender();
    MockReceiver receiver = new MockReceiver();
    MockAsyncTaskExecutor executor = new MockAsyncTaskExecutor();
    MessageBusVisitorSession visitorSession = createVisitorSession(sender, receiver, executor, params);
    visitorSession.start();
    // Process initial task which sends a single CreateVisitor.
    executor.expectAndProcessTasks(1);
    assertEquals(expectedMessage, replyToCreateVisitor(sender, ProgressToken.FINISHED_BUCKET));
    assertFalse(visitorSession.isDone());
    // Single task for handling CreateVisitorReply.
    executor.expectAndProcessTasks(1);
    executor.expectNoTasks();
    assertTrue(visitorSession.isDone());
}
Also used : MessageBusVisitorSession(com.yahoo.documentapi.messagebus.MessageBusVisitorSession)

Aggregations

MessageBusVisitorSession (com.yahoo.documentapi.messagebus.MessageBusVisitorSession)10 Test (org.junit.Test)9 ParseException (com.yahoo.document.select.parser.ParseException)2 CyclicBarrier (java.util.concurrent.CyclicBarrier)2 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)2 BucketId (com.yahoo.document.BucketId)1 LoadType (com.yahoo.documentapi.messagebus.loadtypes.LoadType)1 Error (com.yahoo.messagebus.Error)1