Search in sources :

Example 46 with ComponentId

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

the class ApplicationStatusHandlerTest method chains_are_rendered.

@Test
public void chains_are_rendered() throws Exception {
    ChainRegistry<Processor> chains = new ChainRegistry<>();
    Chain<Processor> chain = new Chain<Processor>("myChain", new VoidProcessor(new ComponentId("voidProcessor")));
    chains.register(new ComponentId("myChain"), chain);
    String json = ApplicationStatusHandler.StatusResponse.renderChains(chains).toString();
    assertThat(json, containsString("myChain"));
    assertThat(json, containsString("voidProcessor"));
}
Also used : Chain(com.yahoo.component.chain.Chain) Processor(com.yahoo.processing.Processor) ChainRegistry(com.yahoo.processing.execution.chain.ChainRegistry) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ComponentId(com.yahoo.component.ComponentId) Test(org.junit.Test)

Example 47 with ComponentId

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

the class ComponentRegistryTestCase method testInnerComponentNotMixedWithTopLevelComponent.

@Test
public void testInnerComponentNotMixedWithTopLevelComponent() {
    assertNull(registry.getComponent(componentName));
    TestComponent topLevel = new TestComponent(new ComponentId(componentName));
    registry.register(topLevel.getId(), topLevel);
    assertEquals(topLevel, registry.getComponent(componentName));
    assertEquals(component1, registry.getComponent(specInNamespace(namespace1)));
    assertEquals(component1, registry.getComponent(idInNamespace(namespace1)));
}
Also used : ComponentId(com.yahoo.component.ComponentId) Test(org.junit.Test)

Example 48 with ComponentId

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

the class FederationSearcher method createFederationQuery.

private Query createFederationQuery(Query query, Query outgoing, Window window, long timeout, Target target) {
    ComponentId chainId = target.getChain().getId();
    String sourceName = chainId.getName();
    outgoing.properties().set(SOURCENAME, sourceName);
    String providerName = chainId.getName();
    if (chainId.getNamespace() != null)
        providerName = chainId.getNamespace().getName();
    outgoing.properties().set(PROVIDERNAME, providerName);
    outgoing.setTimeout(timeout);
    switch(propagateSourceProperties) {
        case ALL:
            propagatePerSourceQueryProperties(query, outgoing, window, sourceName, providerName, QueryProperties.PER_SOURCE_QUERY_PROPERTIES);
            break;
        case OFFSET_HITS:
            propagatePerSourceQueryProperties(query, outgoing, window, sourceName, providerName, new CompoundName[] { Query.OFFSET, Query.HITS });
            break;
    }
    // TODO: FederationTarget
    // TODO: only for target produced by this, not others
    target.modifyTargetQuery(outgoing);
    return outgoing;
}
Also used : ComponentId(com.yahoo.component.ComponentId)

Example 49 with ComponentId

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

the class FederationSearcher method mergeResult.

private void mergeResult(Query query, Target target, Result mergedResults, Result result) {
    target.modifyTargetResult(result);
    ComponentId searchChainId = target.getId();
    Chain<Searcher> searchChain = target.getChain();
    mergedResults.mergeWith(result);
    HitGroup group = result.hits();
    group.setId("source:" + searchChainId.getName());
    group.setSearcherSpecificMetaData(this, searchChain);
    // Set hit groups as non-meta as a default
    group.setMeta(false);
    // Set hit group as auxiliary so that it doesn't contribute to count
    group.setAuxiliary(true);
    group.setSource(searchChainId.getName());
    group.setQuery(result.getQuery());
    for (Iterator<Hit> it = group.unorderedDeepIterator(); it.hasNext(); ) {
        Hit hit = it.next();
        hit.setSearcherSpecificMetaData(this, searchChain);
        hit.setSource(searchChainId.stringValue());
        // See HTTPBackendSearcher, where this hit is created
        if (hit.isMeta() && hit.types().contains("logging")) {
            // Augment this hit with count fields
            hit.setField(LOG_COUNT_PREFIX + "deep", result.getDeepHitCount());
            hit.setField(LOG_COUNT_PREFIX + "total", result.getTotalHitCount());
            int offset = result.getQuery().getOffset();
            hit.setField(LOG_COUNT_PREFIX + "first", offset + 1);
            hit.setField(LOG_COUNT_PREFIX + "last", result.getConcreteHitCount() + offset);
        }
    }
    if (query.getTraceLevel() >= 4)
        query.trace("Got " + group.getConcreteSize() + " hits from " + group.getId(), false, 4);
    mergedResults.hits().add(group);
}
Also used : Hit(com.yahoo.search.result.Hit) Searcher(com.yahoo.search.Searcher) ForkingSearcher(com.yahoo.search.searchchain.ForkingSearcher) ComponentId(com.yahoo.component.ComponentId) HitGroup(com.yahoo.search.result.HitGroup)

Example 50 with ComponentId

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

the class RendererRegistry method addTemplateSet.

@SuppressWarnings({ "deprecation", "unchecked" })
private ComponentId addTemplateSet(UserTemplate<?> templateSet) {
    Renderer renderer = new SearchRendererAdaptor(templateSet);
    ComponentId rendererId = new ComponentId(templateSet.getName());
    renderer.initId(rendererId);
    register(rendererId, renderer);
    return rendererId;
}
Also used : SearchRendererAdaptor(com.yahoo.prelude.templates.SearchRendererAdaptor) Renderer(com.yahoo.processing.rendering.Renderer) ComponentId(com.yahoo.component.ComponentId)

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