Search in sources :

Example 16 with ComponentId

use of com.yahoo.component.ComponentId in project vespa by vespa-engine.

the class ClusteredConnectionTestCase method testClusteringWithPing.

public void testClusteringWithPing() {
    Connection connection0 = new Connection("0");
    Connection connection1 = new Connection("1");
    Connection connection2 = new Connection("2");
    List<Connection> connections = new ArrayList<>();
    connections.add(connection0);
    connections.add(connection1);
    connections.add(connection2);
    MyBackend myBackend = new MyBackend(new ComponentId("test"), connections);
    Result r;
    // Note that we cannot make any successful queries here or we have to wait 10 seconds for
    // the traffic monitor to agree that these nodes are really not responding
    connection2.setInService(false);
    connection1.setInService(false);
    connection0.setInService(false);
    forcePing(myBackend);
    r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
    assertEquals("No backends in service. Try later", r.hits().getError().getMessage());
    connection2.setInService(true);
    connection1.setInService(true);
    connection0.setInService(true);
    forcePing(myBackend);
    r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
    assertNull(r.hits().getError());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) ArrayList(java.util.ArrayList) ComponentId(com.yahoo.component.ComponentId) Result(com.yahoo.search.Result)

Example 17 with ComponentId

use of com.yahoo.component.ComponentId in project vespa by vespa-engine.

the class VespaFeedHandlerTestCase method setup.

public void setup(com.yahoo.messagebus.Error e, LoadTypeConfig loadTypeCfg, boolean autoReply, DummySessionFactory.ReplyFactory autoReplyFactory) throws Exception {
    DocumentTypeManager docMan = new DocumentTypeManager();
    DocumentTypeManagerConfigurer.configure(docMan, "file:" + xmlFilesPath + "documentmanager.cfg");
    if (autoReply) {
        if (autoReplyFactory != null) {
            factory = DummySessionFactory.createWithAutoReplyFactory(autoReplyFactory);
        } else {
            factory = DummySessionFactory.createWithErrorAutoReply(e);
        }
    } else {
        factory = DummySessionFactory.createDefault();
    }
    context = new FeedContext(new MessagePropertyProcessor(new FeederConfig(new FeederConfig.Builder()), loadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric());
    Executor threadPool = Executors.newCachedThreadPool();
    feedHandler = new VespaFeedHandler(context, threadPool);
    removeHandler = new VespaFeedHandlerRemove(context, threadPool);
    statusHandler = new VespaFeedHandlerStatus(context, false, false, threadPool);
    removeLocationHandler = new VespaFeedHandlerRemoveLocation(context, threadPool);
    CallStack dpCallstack = new CallStack("bar");
    dpCallstack.addLast(new TestDocProc());
    dpCallstack.addLast(new TestLaterDocProc());
    DocprocService myservice = new DocprocService("bar");
    myservice.setCallStack(dpCallstack);
    myservice.setInService(true);
    ComponentRegistry<DocprocService> registry = new ComponentRegistry<DocprocService>();
    registry.register(new ComponentId(myservice.getName()), myservice);
    DocumentProcessingHandler handler = new DocumentProcessingHandler(registry, new ComponentRegistry<>(), new ComponentRegistry<>(), new DocumentProcessingHandlerParameters());
    Container container = Container.get();
    ComponentRegistry<RequestHandler> requestHandlerComponentRegistry = new ComponentRegistry<>();
    requestHandlerComponentRegistry.register(new ComponentId(DocumentProcessingHandler.class.getName()), handler);
    container.setRequestHandlerRegistry(requestHandlerComponentRegistry);
}
Also used : ClusterList(com.yahoo.vespaclient.ClusterList) CallStack(com.yahoo.docproc.CallStack) FeederConfig(com.yahoo.vespaclient.config.FeederConfig) Container(com.yahoo.container.Container) Executor(java.util.concurrent.Executor) DocumentProcessingHandler(com.yahoo.docproc.jdisc.DocumentProcessingHandler) MessagePropertyProcessor(com.yahoo.feedapi.MessagePropertyProcessor) RequestHandler(com.yahoo.jdisc.handler.RequestHandler) ComponentRegistry(com.yahoo.component.provider.ComponentRegistry) FeedContext(com.yahoo.feedapi.FeedContext) ComponentId(com.yahoo.component.ComponentId) DocumentProcessingHandlerParameters(com.yahoo.docproc.jdisc.DocumentProcessingHandlerParameters)

Example 18 with ComponentId

use of com.yahoo.component.ComponentId in project vespa by vespa-engine.

the class QueryProfileXMLReader method createQueryProfiles.

public List<Element> createQueryProfiles(List<NamedReader> queryProfileReaders, QueryProfileRegistry registry) {
    List<Element> queryProfileElements = new ArrayList<>(queryProfileReaders.size());
    for (NamedReader reader : queryProfileReaders) {
        Element root = XML.getDocument(reader).getDocumentElement();
        if (!root.getNodeName().equals("query-profile")) {
            throw new IllegalArgumentException("Root tag in '" + reader.getName() + "' must be 'query-profile', not '" + root.getNodeName() + "'");
        }
        String idString = root.getAttribute("id");
        if (idString == null || idString.equals(""))
            throw new IllegalArgumentException("Query profile '" + reader.getName() + "' has no 'id' attribute in the root element");
        ComponentId id = new ComponentId(idString);
        validateFileNameToId(reader.getName(), id, "query profile");
        QueryProfile queryProfile = new QueryProfile(id);
        String typeId = root.getAttribute("type");
        if (typeId != null && !typeId.equals("")) {
            QueryProfileType type = registry.getType(typeId);
            if (type == null)
                throw new IllegalArgumentException("Query profile '" + reader.getName() + "': Type id '" + typeId + "' can not be resolved");
            queryProfile.setType(type);
        }
        Element dimensions = XML.getChild(root, "dimensions");
        if (dimensions != null)
            queryProfile.setDimensions(toArray(XML.getValue(dimensions)));
        registry.register(queryProfile);
        queryProfileElements.add(root);
    }
    return queryProfileElements;
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) NamedReader(com.yahoo.io.reader.NamedReader) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType) ComponentId(com.yahoo.component.ComponentId)

Example 19 with ComponentId

use of com.yahoo.component.ComponentId in project vespa by vespa-engine.

the class ClusterSearcherTestCase method createSearcher.

private static ClusterSearcher createSearcher(Double maxQueryTimeout, Double maxQueryCacheTimeout) {
    ComponentId id = new ComponentId("test-id");
    QrSearchersConfig qrsCfg = new QrSearchersConfig(new QrSearchersConfig.Builder().searchcluster(new QrSearchersConfig.Searchcluster.Builder().name("test-cluster")));
    ClusterConfig.Builder clusterCfgBld = new ClusterConfig.Builder().clusterName("test-cluster");
    if (maxQueryTimeout != null) {
        clusterCfgBld.maxQueryTimeout(maxQueryTimeout);
    }
    if (maxQueryCacheTimeout != null) {
        clusterCfgBld.maxQueryCacheTimeout(maxQueryCacheTimeout);
    }
    ClusterConfig clusterCfg = new ClusterConfig(clusterCfgBld);
    DocumentdbInfoConfig documentDbCfg = new DocumentdbInfoConfig(new DocumentdbInfoConfig.Builder().documentdb(new DocumentdbInfoConfig.Documentdb.Builder().name("type1")));
    LegacyEmulationConfig emulationCfg = new LegacyEmulationConfig(new LegacyEmulationConfig.Builder());
    QrMonitorConfig monitorCfg = new QrMonitorConfig(new QrMonitorConfig.Builder());
    Statistics statistics = Statistics.nullImplementation;
    Fs4Config fs4Cfg = new Fs4Config(new Fs4Config.Builder());
    FS4ResourcePool fs4ResourcePool = new FS4ResourcePool(fs4Cfg);
    ClusterSearcher searcher = new ClusterSearcher(id, qrsCfg, clusterCfg, documentDbCfg, emulationCfg, monitorCfg, new DispatchConfig(new DispatchConfig.Builder()), createClusterInfoConfig(), statistics, fs4ResourcePool, new VipStatus());
    return searcher;
}
Also used : DispatchConfig(com.yahoo.vespa.config.search.DispatchConfig) QrSearchersConfig(com.yahoo.container.QrSearchersConfig) VipStatus(com.yahoo.container.handler.VipStatus) Fs4Config(com.yahoo.container.search.Fs4Config) Statistics(com.yahoo.statistics.Statistics) FS4ResourcePool(com.yahoo.prelude.fastsearch.FS4ResourcePool) DocumentdbInfoConfig(com.yahoo.prelude.fastsearch.DocumentdbInfoConfig) LegacyEmulationConfig(com.yahoo.container.search.LegacyEmulationConfig) ComponentId(com.yahoo.component.ComponentId) ClusterConfig(com.yahoo.search.config.ClusterConfig)

Example 20 with ComponentId

use of com.yahoo.component.ComponentId in project vespa by vespa-engine.

the class QueryProfileConfigurer method createFromConfig.

public static QueryProfileRegistry createFromConfig(QueryProfilesConfig config) {
    QueryProfileRegistry registry = new QueryProfileRegistry();
    // Pass 1: Create all profiles and profile types
    for (QueryProfilesConfig.Queryprofiletype profileTypeConfig : config.queryprofiletype()) {
        createProfileType(profileTypeConfig, registry.getTypeRegistry());
    }
    for (QueryProfilesConfig.Queryprofile profileConfig : config.queryprofile()) {
        createProfile(profileConfig, registry);
    }
    // Pass 2: Resolve references and add content
    for (QueryProfilesConfig.Queryprofiletype profileTypeConfig : config.queryprofiletype()) {
        fillProfileType(profileTypeConfig, registry.getTypeRegistry());
    }
    // To ensure topological sorting, using DPS. This will _NOT_ detect cycles (but it will not fail if they
    // exist either)
    Set<ComponentId> filled = new HashSet<>();
    for (QueryProfilesConfig.Queryprofile profileConfig : config.queryprofile()) {
        fillProfile(profileConfig, config, registry, filled);
    }
    registry.freeze();
    return registry;
}
Also used : QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) ComponentId(com.yahoo.component.ComponentId) HashSet(java.util.HashSet)

Aggregations

ComponentId (com.yahoo.component.ComponentId)68 Test (org.junit.Test)25 Result (com.yahoo.search.Result)14 Query (com.yahoo.search.Query)13 Execution (com.yahoo.search.searchchain.Execution)13 ArrayList (java.util.ArrayList)10 Chain (com.yahoo.component.chain.Chain)8 Searcher (com.yahoo.search.Searcher)8 ComponentRegistry (com.yahoo.component.provider.ComponentRegistry)7 QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)7 FederationSearcher (com.yahoo.search.federation.FederationSearcher)6 Hit (com.yahoo.search.result.Hit)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)4 ChainsConfig (com.yahoo.container.core.ChainsConfig)4 FilterChainRepository (com.yahoo.container.http.filter.FilterChainRepository)4 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)4 QueryProfileTypeRegistry (com.yahoo.search.query.profile.types.QueryProfileTypeRegistry)4 Component (com.yahoo.vespa.model.container.component.Component)4 HashMap (java.util.HashMap)4