use of com.yahoo.documentapi.messagebus.loadtypes.LoadType in project vespa by vespa-engine.
the class VespaFeedHandlerTestCase method testLoadTypes.
@Test
public void testLoadTypes() throws Exception {
List<LoadTypeConfig.Type.Builder> typeBuilder = new ArrayList<>();
typeBuilder.add(new LoadTypeConfig.Type.Builder().id(1234).name("foo").priority("VERY_LOW"));
typeBuilder.add(new LoadTypeConfig.Type.Builder().id(4567).name("bar").priority("NORMAL_3"));
setup(null, new LoadTypeConfig(new LoadTypeConfig.Builder().type(typeBuilder)), true, null);
{
Result res = testRequest(HttpRequest.createTestRequest("remove?id=doc:test:removeme&loadtype=foo", com.yahoo.jdisc.http.HttpRequest.Method.PUT));
assertEquals(1, res.messages.size());
Message m = res.messages.get(0);
assertEquals(DocumentProtocol.MESSAGE_REMOVEDOCUMENT, m.getType());
DocumentId d = ((RemoveDocumentMessage) m).getDocumentId();
assertEquals("doc:test:removeme", d.toString());
assertEquals(new LoadType(1234, "foo", DocumentProtocol.Priority.VERY_LOW), ((DocumentMessage) m).getLoadType());
assertEquals(DocumentProtocol.Priority.VERY_LOW, ((DocumentMessage) m).getPriority());
}
}
use of com.yahoo.documentapi.messagebus.loadtypes.LoadType in project vespa by vespa-engine.
the class DocumentMessage method swapState.
@Override
public void swapState(Routable rhs) {
super.swapState(rhs);
if (rhs instanceof DocumentMessage) {
DocumentMessage msg = (DocumentMessage) rhs;
DocumentProtocol.Priority pri = this.priority;
this.priority = msg.priority;
msg.priority = pri;
LoadType lt = this.loadType;
this.loadType = msg.loadType;
msg.loadType = lt;
}
}
use of com.yahoo.documentapi.messagebus.loadtypes.LoadType in project vespa by vespa-engine.
the class DocumentRetrieverTest method testSendSingleMessage.
@Test
public void testSendSingleMessage() throws DocumentRetrieverException {
ClientParameters params = createParameters().setDocumentIds(asIterator(DOC_ID_1)).setPriority(DocumentProtocol.Priority.HIGH_1).setNoRetry(true).setLoadTypeName("loadtype").build();
when(mockedSession.syncSend(any())).thenReturn(createDocumentReply(DOC_ID_1));
LoadTypeSet loadTypeSet = new LoadTypeSet();
loadTypeSet.addLoadType(1, "loadtype", DocumentProtocol.Priority.HIGH_1);
DocumentRetriever documentRetriever = new DocumentRetriever(new ClusterList(), mockedFactory, loadTypeSet, params);
documentRetriever.retrieveDocuments();
verify(mockedSession, times(1)).syncSend(argThat(new ArgumentMatcher<GetDocumentMessage>() {
@Override
public boolean matches(Object o) {
GetDocumentMessage msg = (GetDocumentMessage) o;
return msg.getPriority().equals(DocumentProtocol.Priority.HIGH_1) && !msg.getRetryEnabled() && msg.getLoadType().equals(new LoadType(1, "loadtype", DocumentProtocol.Priority.HIGH_1));
}
}));
assertContainsDocument(DOC_ID_1);
}
use of com.yahoo.documentapi.messagebus.loadtypes.LoadType 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.loadtypes.LoadType in project vespa by vespa-engine.
the class VdsVisitor method setVisitorParameters.
private void setVisitorParameters(String searchCluster, Route route) {
if (query.properties().getString(streamingUserid) != null) {
params.setDocumentSelection("id.user==" + query.properties().getString(streamingUserid));
} else if (query.properties().getString(streamingGroupname) != null) {
params.setDocumentSelection("id.group==\"" + query.properties().getString(streamingGroupname) + "\"");
} else if (query.properties().getString(streamingSelection) != null) {
params.setDocumentSelection(query.properties().getString(streamingSelection));
}
// Per bucket visitor timeout
params.setTimeoutMs(query.getTimeout());
params.setSessionTimeoutMs(query.getTimeout());
params.setVisitorLibrary("searchvisitor");
params.setLocalDataHandler(this);
params.setVisitHeadersOnly(query.properties().getBoolean(streamingHeadersonly));
if (query.properties().getDouble(streamingFromtimestamp) != null) {
params.setFromTimestamp(query.properties().getDouble(streamingFromtimestamp).longValue());
}
if (query.properties().getDouble(streamingTotimestamp) != null) {
params.setToTimestamp(query.properties().getDouble(streamingTotimestamp).longValue());
}
params.visitInconsistentBuckets(true);
params.setPriority(DocumentProtocol.Priority.VERY_HIGH);
if (query.properties().getString(streamingLoadtype) != null) {
LoadType loadType = visitorSessionFactory.getLoadTypeSet().getNameMap().get(query.properties().getString(streamingLoadtype));
if (loadType != null) {
params.setLoadType(loadType);
params.setPriority(loadType.getPriority());
}
}
if (query.properties().getString(streamingPriority) != null) {
params.setPriority(DocumentProtocol.getPriorityByName(query.properties().getString(streamingPriority)));
}
params.setMaxPending(Integer.MAX_VALUE);
params.setMaxBucketsPerVisitor(Integer.MAX_VALUE);
params.setTraceLevel(inferSessionTraceLevel(query));
String ordering = query.properties().getString(streamingOrdering);
if (ordering != null) {
params.setVisitorOrdering(getOrdering(ordering));
params.setMaxFirstPassHits(query.getOffset() + query.getHits());
params.setMaxBucketsPerVisitor(1);
params.setDynamicallyIncreaseMaxBucketsPerVisitor(true);
}
String maxbuckets = query.properties().getString(streamingMaxbucketspervisitor);
if (maxbuckets != null) {
params.setMaxBucketsPerVisitor(Integer.parseInt(maxbuckets));
}
EncodedData ed = new EncodedData();
encodeQueryData(query, 0, ed);
params.setLibraryParameter("query", ed.getEncodedData());
params.setLibraryParameter("querystackcount", String.valueOf(ed.getReturned()));
params.setLibraryParameter("searchcluster", searchCluster.getBytes());
if (query.getPresentation().getSummary() != null) {
params.setLibraryParameter("summaryclass", query.getPresentation().getSummary());
} else {
params.setLibraryParameter("summaryclass", "default");
}
params.setLibraryParameter("summarycount", String.valueOf(query.getOffset() + query.getHits()));
params.setLibraryParameter("rankprofile", query.getRanking().getProfile());
params.setLibraryParameter("allowslimedocsums", "true");
params.setLibraryParameter("queryflags", String.valueOf(getQueryFlags(query)));
ByteBuffer buf = ByteBuffer.allocate(1024);
if (query.getRanking().getLocation() != null) {
buf.clear();
query.getRanking().getLocation().encode(buf);
buf.flip();
byte[] af = new byte[buf.remaining()];
buf.get(af);
params.setLibraryParameter("location", af);
}
if (query.hasEncodableProperties()) {
encodeQueryData(query, 1, ed);
params.setLibraryParameter("rankproperties", ed.getEncodedData());
}
List<Grouping> groupingList = GroupingExecutor.getGroupingList(query);
if (groupingList.size() > 0) {
BufferSerializer gbuf = new BufferSerializer(new GrowableByteBuffer());
gbuf.putInt(null, groupingList.size());
for (Grouping g : groupingList) {
g.serialize(gbuf);
}
gbuf.flip();
byte[] blob = gbuf.getBytes(null, gbuf.getBuf().limit());
params.setLibraryParameter("aggregation", blob);
}
if (query.getRanking().getSorting() != null) {
encodeQueryData(query, 3, ed);
params.setLibraryParameter("sort", ed.getEncodedData());
}
params.setRoute(route);
}
Aggregations