Search in sources :

Example 1 with FederationOptions

use of com.yahoo.search.searchchain.model.federation.FederationOptions in project vespa by vespa-engine.

the class DomSearchChainsBuilderTest method checkSourceFederationOptions.

@Test
public void checkSourceFederationOptions() {
    FederationOptions options = getSource().federationOptions();
    // inherited
    assertEquals(true, options.getOptional());
    assertEquals(12, options.getTimeoutInMilliseconds());
}
Also used : FederationOptions(com.yahoo.search.searchchain.model.federation.FederationOptions) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 2 with FederationOptions

use of com.yahoo.search.searchchain.model.federation.FederationOptions in project vespa by vespa-engine.

the class FederationSearcherTest method require_that_calling_a_single_slow_source_with_long_timeout_does_not_delay_federation.

@Test
public void require_that_calling_a_single_slow_source_with_long_timeout_does_not_delay_federation() {
    FederationTester tester = new FederationTester();
    tester.addSearchChain("chain1", new FederationOptions().setUseByDefault(true).setRequestTimeoutInMilliseconds(3600 * 1000), new BlockingSearcher());
    Query query = new Query();
    // make the test run faster
    query.setTimeout(50);
    Result result = tester.search(query);
    assertThat(getNonErrorHits(result).size(), is(0));
    assertNotNull(result.hits().getError());
}
Also used : FederationOptions(com.yahoo.search.searchchain.model.federation.FederationOptions) Query(com.yahoo.search.Query) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 3 with FederationOptions

use of com.yahoo.search.searchchain.model.federation.FederationOptions in project vespa by vespa-engine.

the class FutureDataTestCase method testAsyncFederation.

@Test
public void testAsyncFederation() throws InterruptedException, ExecutionException, TimeoutException {
    // Setup environment
    AsyncProviderSearcher asyncProviderSearcher = new AsyncProviderSearcher();
    Searcher syncProviderSearcher = new SyncProviderSearcher();
    Chain<Searcher> asyncSource = new Chain<Searcher>(new ComponentId("async"), asyncProviderSearcher);
    Chain<Searcher> syncSource = new Chain<>(new ComponentId("sync"), syncProviderSearcher);
    SearchChainResolver searchChainResolver = new SearchChainResolver.Builder().addSearchChain(new ComponentId("sync"), new FederationOptions().setUseByDefault(true)).addSearchChain(new ComponentId("async"), new FederationOptions().setUseByDefault(true)).build();
    Chain<Searcher> main = new Chain<Searcher>(new FederationSearcher(new ComponentId("federator"), searchChainResolver));
    SearchChainRegistry searchChainRegistry = new SearchChainRegistry();
    searchChainRegistry.register(main);
    searchChainRegistry.register(syncSource);
    searchChainRegistry.register(asyncSource);
    Result result = new Execution(main, Execution.Context.createContextStub(searchChainRegistry, null)).search(new Query());
    assertNotNull(result);
    HitGroup syncGroup = (HitGroup) result.hits().get("source:sync");
    assertNotNull(syncGroup);
    HitGroup asyncGroup = (HitGroup) result.hits().get("source:async");
    assertNotNull(asyncGroup);
    assertEquals("Got all sync data", 3, syncGroup.size());
    assertEquals("sync:0", syncGroup.get(0).getId().toString());
    assertEquals("sync:1", syncGroup.get(1).getId().toString());
    assertEquals("sync:2", syncGroup.get(2).getId().toString());
    assertTrue(asyncGroup.incoming() == asyncProviderSearcher.incomingData);
    assertEquals("Got no async data yet", 0, asyncGroup.size());
    asyncProviderSearcher.simulateOneHitIOComplete(new Hit("async:0"));
    assertEquals("Got no async data yet, as we haven't completed the incoming buffer and there is no data listener", 0, asyncGroup.size());
    asyncProviderSearcher.simulateOneHitIOComplete(new Hit("async:1"));
    asyncProviderSearcher.simulateAllHitsIOComplete();
    assertEquals("Got no async data yet, as we haven't pulled it", 0, asyncGroup.size());
    asyncGroup.complete().get();
    assertEquals("Completed, so we have the data", 2, asyncGroup.size());
    assertEquals("async:0", asyncGroup.get(0).getId().toString());
    assertEquals("async:1", asyncGroup.get(1).getId().toString());
}
Also used : Chain(com.yahoo.component.chain.Chain) FederationSearcher(com.yahoo.search.federation.FederationSearcher) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) FederationSearcher(com.yahoo.search.federation.FederationSearcher) SearchChainResolver(com.yahoo.search.federation.sourceref.SearchChainResolver) Result(com.yahoo.search.Result) FederationOptions(com.yahoo.search.searchchain.model.federation.FederationOptions) Hit(com.yahoo.search.result.Hit) Execution(com.yahoo.search.searchchain.Execution) SearchChainRegistry(com.yahoo.search.searchchain.SearchChainRegistry) ComponentId(com.yahoo.component.ComponentId) HitGroup(com.yahoo.search.result.HitGroup) Test(org.junit.Test)

Example 4 with FederationOptions

use of com.yahoo.search.searchchain.model.federation.FederationOptions in project vespa by vespa-engine.

the class DomProviderBuilder method buildChain.

@Override
protected Provider buildChain(AbstractConfigProducer ancestor, Element providerElement, ChainSpecification specWithoutInnerComponents) {
    ProviderReader providerReader = new ProviderReader(providerElement);
    if (providerReader.certificateApplicationId == null && providerReader.certificateProxy != null) {
        throw new IllegalArgumentException("Provider '" + specWithoutInnerComponents.componentId + "' must have a certificate application ID, since a certificate store proxy is given");
    }
    FederationOptions federationOptions = readFederationOptions(providerElement);
    Provider provider = buildProvider(specWithoutInnerComponents, providerReader, federationOptions);
    Collection<Source> sources = buildSources(ancestor, providerElement);
    addSources(provider, sources);
    return provider;
}
Also used : FederationOptions(com.yahoo.search.searchchain.model.federation.FederationOptions) Source(com.yahoo.vespa.model.container.search.searchchain.Source) LocalProvider(com.yahoo.vespa.model.container.search.searchchain.LocalProvider) HttpProvider(com.yahoo.vespa.model.container.search.searchchain.HttpProvider) Provider(com.yahoo.vespa.model.container.search.searchchain.Provider)

Example 5 with FederationOptions

use of com.yahoo.search.searchchain.model.federation.FederationOptions in project vespa by vespa-engine.

the class DomSearchChainsBuilderTest method checkProviderFederationOptions.

@Test
public void checkProviderFederationOptions() {
    FederationOptions options = getProvider().federationOptions();
    assertEquals(true, options.getOptional());
    assertEquals(2300, options.getTimeoutInMilliseconds());
}
Also used : FederationOptions(com.yahoo.search.searchchain.model.federation.FederationOptions) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Aggregations

FederationOptions (com.yahoo.search.searchchain.model.federation.FederationOptions)7 Test (org.junit.Test)4 ComponentId (com.yahoo.component.ComponentId)2 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)2 Query (com.yahoo.search.Query)2 Result (com.yahoo.search.Result)2 FederationSearcher (com.yahoo.search.federation.FederationSearcher)2 SearchChainResolver (com.yahoo.search.federation.sourceref.SearchChainResolver)2 ComponentSpecification (com.yahoo.component.ComponentSpecification)1 Chain (com.yahoo.component.chain.Chain)1 Searcher (com.yahoo.search.Searcher)1 Hit (com.yahoo.search.result.Hit)1 HitGroup (com.yahoo.search.result.HitGroup)1 Execution (com.yahoo.search.searchchain.Execution)1 SearchChainRegistry (com.yahoo.search.searchchain.SearchChainRegistry)1 TargetSpec (com.yahoo.search.searchchain.model.federation.FederationSearcherModel.TargetSpec)1 HttpProvider (com.yahoo.vespa.model.container.search.searchchain.HttpProvider)1 LocalProvider (com.yahoo.vespa.model.container.search.searchchain.LocalProvider)1 Provider (com.yahoo.vespa.model.container.search.searchchain.Provider)1 Source (com.yahoo.vespa.model.container.search.searchchain.Source)1