Search in sources :

Example 6 with LoadType

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

the class VdsVisitorTestCase method verifyVisitorParameters.

private void verifyVisitorParameters(VisitorParameters params, QueryArguments qa, String searchCluster, Route route) {
    // Verify parameters based on properties
    if (qa.userId != null) {
        assertEquals("id.user==" + qa.userId, params.getDocumentSelection());
    } else if (qa.groupName != null) {
        assertEquals("id.group==\"" + qa.groupName + "\"", params.getDocumentSelection());
    } else if (qa.selection != null) {
        assertEquals(qa.selection, params.getDocumentSelection());
    } else {
        assertEquals("", params.getDocumentSelection());
    }
    assertEquals(qa.headersOnly, params.getVisitHeadersOnly());
    assertEquals(qa.from, params.getFromTimestamp());
    assertEquals(qa.to, params.getToTimestamp());
    if (qa.loadTypeName != null && loadTypeSet.getNameMap().get(qa.loadTypeName) != null) {
        LoadType expectedLoadType = loadTypeSet.getNameMap().get(qa.loadTypeName);
        assertEquals(expectedLoadType, params.getLoadType());
        if (qa.priority != null) {
            assertEquals(qa.priority, params.getPriority());
        } else {
            assertEquals(expectedLoadType.getPriority(), params.getPriority());
        }
    } else {
        assertEquals(LoadType.DEFAULT, params.getLoadType());
        if (qa.priority != null) {
            assertEquals(qa.priority, params.getPriority());
        } else {
            assertEquals(DocumentProtocol.Priority.VERY_HIGH, params.getPriority());
        }
    }
    if (qa.ordering != null) {
        assertEquals(VdsVisitor.getOrdering(qa.ordering), params.getVisitorOrdering());
        assertEquals(qa.offset + qa.hits, params.getMaxFirstPassHits());
        if (qa.maxBucketsPerVisitor != 0) {
            assertEquals(qa.maxBucketsPerVisitor, params.getMaxBucketsPerVisitor());
        } else {
            assertEquals(1, params.getMaxBucketsPerVisitor());
        }
        assertEquals(true, params.getDynamicallyIncreaseMaxBucketsPerVisitor());
    } else {
        assertEquals(0, params.getVisitorOrdering());
        assertEquals(-1, params.getMaxFirstPassHits());
        if (qa.maxBucketsPerVisitor != 0) {
            assertEquals(qa.maxBucketsPerVisitor, params.getMaxBucketsPerVisitor());
        } else {
            assertEquals(Integer.MAX_VALUE, params.getMaxBucketsPerVisitor());
        }
        assertEquals(false, params.getDynamicallyIncreaseMaxBucketsPerVisitor());
    }
    // Verify parameters based only on query
    assertEquals(qa.timeout * 1000, params.getTimeoutMs());
    assertEquals(qa.timeout * 1000, params.getSessionTimeoutMs());
    assertEquals("searchvisitor", params.getVisitorLibrary());
    assertEquals(Integer.MAX_VALUE, params.getMaxPending());
    assertEquals(qa.traceLevel, params.getTraceLevel());
    // Verify library parameters
    // System.err.println("query="+new String(params.getLibraryParameters().get("query")));
    // TODO: Check contents
    assertNotNull(params.getLibraryParameters().get("query"));
    // System.err.println("query="+new String(params.getLibraryParameters().get("querystackcount")));
    // TODO: Check contents
    assertNotNull(params.getLibraryParameters().get("querystackcount"));
    assertEquals(searchCluster, new String(params.getLibraryParameters().get("searchcluster")));
    if (qa.summary != null) {
        assertEquals(qa.summary, new String(params.getLibraryParameters().get("summaryclass")));
    } else {
        assertEquals("default", new String(params.getLibraryParameters().get("summaryclass")));
    }
    assertEquals(Integer.toString(qa.offset + qa.hits), new String(params.getLibraryParameters().get("summarycount")));
    if (qa.profile != null) {
        assertEquals(qa.profile, new String(params.getLibraryParameters().get("rankprofile")));
    } else {
        assertEquals("default", new String(params.getLibraryParameters().get("rankprofile")));
    }
    // System.err.println("queryflags="+new String(params.getLibraryParameters().get("queryflags")));
    // TODO: Check contents
    assertNotNull(params.getLibraryParameters().get("queryflags"));
    if (qa.location != null) {
        assertEquals(qa.location, new String(params.getLibraryParameters().get("location")));
    } else {
        assertNull(params.getLibraryParameters().get("location"));
    }
    if (qa.rankProperties != null) {
        // System.err.println("rankProperties="+new String(params.getLibraryParameters().get("rankproperties")));
        // TODO: Check contents
        assertNotNull(params.getLibraryParameters().get("rankproperties"));
    } else {
        assertNull(params.getLibraryParameters().get("rankproperties"));
    }
    if (qa.defineGrouping) {
        // System.err.println("aggregation="+new String(params.getLibraryParameters().get("aggregation")));
        // TODO: Check contents
        assertNotNull(params.getLibraryParameters().get("aggregation"));
    } else {
        assertNull(params.getLibraryParameters().get("aggregation"));
    }
    if (qa.sortSpec != null) {
        assertEquals(qa.sortSpec, new String(params.getLibraryParameters().get("sort")));
    } else {
        assertNull(params.getLibraryParameters().get("sort"));
    }
    assertEquals(route, params.getRoute());
}
Also used : Utf8String(com.yahoo.text.Utf8String) LoadType(com.yahoo.documentapi.messagebus.loadtypes.LoadType)

Example 7 with LoadType

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

the class MessagePropertyProcessor method buildPropertySetter.

public PropertySetter buildPropertySetter(HttpRequest request) {
    String routeParam = null;
    double timeoutParam = -1;
    String priorityParam = null;
    String abortOnDocErrorParam = null;
    String abortOnFeedErrorParam = null;
    String loadTypeStr = null;
    String traceStr = null;
    String createIfNonExistentParam = null;
    Double totalTimeoutParam = null;
    if (request != null) {
        routeParam = request.getProperty("route");
        String timeoutStr = request.getProperty("timeout");
        if (timeoutStr != null) {
            timeoutParam = Double.parseDouble(timeoutStr);
        }
        timeoutStr = request.getProperty("totaltimeout");
        if (timeoutStr != null) {
            totalTimeoutParam = Double.parseDouble(timeoutStr);
        }
        priorityParam = request.getProperty("priority");
        traceStr = request.getProperty("tracelevel");
        abortOnDocErrorParam = request.getProperty("abortondocumenterror");
        abortOnFeedErrorParam = request.getProperty("abortonfeederror");
        loadTypeStr = request.getProperty("loadtype");
        createIfNonExistentParam = request.getProperty("createifnonexistent");
    }
    Route route = (routeParam != null ? Route.parse(routeParam) : null);
    long timeout;
    boolean retry;
    boolean abortOnDocumentError;
    boolean abortOnFeedError;
    boolean createIfNonExistent;
    synchronized (this) {
        if (route == null) {
            route = defaultRoute;
        }
        timeout = (timeoutParam < 0 ? defaultTimeoutMillis : (long) (timeoutParam * 1000));
        retry = retryEnabled;
        abortOnDocumentError = (abortOnDocErrorParam == null ? defaultAbortOnDocumentError : (!"false".equals(abortOnDocErrorParam)));
        abortOnFeedError = (abortOnFeedErrorParam == null ? defaultAbortOnSendError : (!"false".equals(abortOnFeedErrorParam)));
        createIfNonExistent = (createIfNonExistentParam == null ? defaultCreateIfNonExistent : ("true".equals(createIfNonExistentParam)));
    }
    long totalTimeout = (totalTimeoutParam == null) ? timeout : (long) (totalTimeoutParam * 1000);
    DocumentProtocol.Priority priority = null;
    if (priorityParam != null) {
        priority = DocumentProtocol.getPriorityByName(priorityParam);
    }
    LoadType loadType = null;
    if (loadTypes != null && loadTypeStr != null) {
        loadType = loadTypes.getNameMap().get(loadTypeStr);
    }
    if (loadType == null) {
        loadType = LoadType.DEFAULT;
    }
    return new PropertySetter(route, timeout, totalTimeout, priority, loadType, retry, abortOnDocumentError, abortOnFeedError, createIfNonExistent, traceStr != null ? Integer.parseInt(traceStr) : 0);
}
Also used : LoadType(com.yahoo.documentapi.messagebus.loadtypes.LoadType) Route(com.yahoo.messagebus.routing.Route) DocumentProtocol(com.yahoo.documentapi.messagebus.protocol.DocumentProtocol)

Example 8 with LoadType

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

the class DocumentRetriever method retrieveDocuments.

public void retrieveDocuments() throws DocumentRetrieverException {
    boolean first = true;
    String route = params.cluster.isEmpty() ? params.route : resolveClusterRoute(params.cluster);
    LoadType loadType = params.loadTypeName.isEmpty() ? null : resolveLoadType(params.loadTypeName);
    MessageBusParams messageBusParams = createMessageBusParams(params.configId, params.timeout, route);
    documentAccess = documentAccessFactory.createDocumentAccess(messageBusParams);
    session = documentAccess.createSyncSession(new SyncParameters.Builder().build());
    int trace = params.traceLevel;
    if (trace > 0) {
        session.setTraceLevel(trace);
    }
    Iterator<String> iter = params.documentIds;
    if (params.jsonOutput && !params.printIdsOnly) {
        System.out.println('[');
    }
    while (iter.hasNext()) {
        if (params.jsonOutput && !params.printIdsOnly) {
            if (!first) {
                System.out.println(',');
            } else {
                first = false;
            }
        }
        String docid = iter.next();
        Message msg = createDocumentRequest(docid, loadType);
        Reply reply = session.syncSend(msg);
        printReply(reply);
    }
    if (params.jsonOutput && !params.printIdsOnly) {
        System.out.println(']');
    }
}
Also used : SyncParameters(com.yahoo.documentapi.SyncParameters) Message(com.yahoo.messagebus.Message) GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) Reply(com.yahoo.messagebus.Reply) GetDocumentReply(com.yahoo.documentapi.messagebus.protocol.GetDocumentReply) MessageBusParams(com.yahoo.documentapi.messagebus.MessageBusParams) LoadType(com.yahoo.documentapi.messagebus.loadtypes.LoadType)

Aggregations

LoadType (com.yahoo.documentapi.messagebus.loadtypes.LoadType)8 Test (org.junit.Test)3 GetDocumentMessage (com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage)2 SyncParameters (com.yahoo.documentapi.SyncParameters)1 MessageBusParams (com.yahoo.documentapi.messagebus.MessageBusParams)1 MessageBusVisitorSession (com.yahoo.documentapi.messagebus.MessageBusVisitorSession)1 LoadTypeSet (com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet)1 DocumentProtocol (com.yahoo.documentapi.messagebus.protocol.DocumentProtocol)1 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)1 GrowableByteBuffer (com.yahoo.io.GrowableByteBuffer)1 Message (com.yahoo.messagebus.Message)1 Reply (com.yahoo.messagebus.Reply)1 Route (com.yahoo.messagebus.routing.Route)1 Grouping (com.yahoo.searchlib.aggregation.Grouping)1 Utf8String (com.yahoo.text.Utf8String)1 LoadTypeConfig (com.yahoo.vespa.config.content.LoadTypeConfig)1 BufferSerializer (com.yahoo.vespa.objects.BufferSerializer)1 ClusterList (com.yahoo.vespaclient.ClusterList)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1