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());
}
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());
}
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());
}
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());
}
}
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());
}
Aggregations