Search in sources :

Example 76 with Chain

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

the class RateLimitingSearcherTestCase method testRateLimiting.

@Test
public void testRateLimiting() {
    RateLimitingConfig.Builder rateLimitingConfig = new RateLimitingConfig.Builder();
    rateLimitingConfig.maxAvailableCapacity(4);
    rateLimitingConfig.capacityIncrement(2);
    rateLimitingConfig.recheckForCapacityProbability(1.0);
    ClusterInfoConfig.Builder clusterInfoConfig = new ClusterInfoConfig.Builder();
    clusterInfoConfig.clusterId("testCluster");
    clusterInfoConfig.nodeCount(4);
    ManualClock clock = new ManualClock();
    MetricReceiver.MockReceiver metric = new MetricReceiver.MockReceiver();
    Chain<Searcher> chain = new Chain<Searcher>("test", new RateLimitingSearcher(new RateLimitingConfig(rateLimitingConfig), new ClusterInfoConfig(clusterInfoConfig), metric, clock), new CostSettingSearcher());
    assertEquals("'rate' request are available initially", 2, tryRequests(chain, "id1"));
    assertTrue("However, don't reject if we dryRun", executeWasAllowed(chain, "id1", true));
    // causes 2 new requests to become available
    clock.advance(Duration.ofMillis(1500));
    assertEquals("'rate' new requests became available", 2, tryRequests(chain, "id1"));
    assertEquals("Another id", 2, tryRequests(chain, "id2"));
    clock.advance(Duration.ofMillis(1000000));
    assertEquals("'maxAvailableCapacity' request became available", 4, tryRequests(chain, "id2"));
    assertFalse("If quota is set to 0, all requests are rejected, even initially", executeWasAllowed(chain, "id3", 0));
    clock.advance(Duration.ofMillis(1000000));
    assertTrue("A single query which costs more than capacity is allowed as cost is calculated after allowing it", executeWasAllowed(chain, "id1", 8, 8, false));
    assertFalse("capacity is -4: disallowing", executeWasAllowed(chain, "id1"));
    clock.advance(Duration.ofMillis(1000));
    assertFalse("capacity is -2: disallowing", executeWasAllowed(chain, "id1"));
    clock.advance(Duration.ofMillis(1000));
    assertFalse("capacity is 0: disallowing", executeWasAllowed(chain, "id1"));
    clock.advance(Duration.ofMillis(1000));
    assertTrue(executeWasAllowed(chain, "id1"));
    // check metrics
    Map<Point, UntypedMetric> map = metric.getSnapshot().getMapForMetric("requestsOverQuota");
    assertEquals(requestsToTry - 2 + 1 + requestsToTry - 2 + 3, map.get(metric.point("id", "id1")).getCount());
    assertEquals(requestsToTry - 2 + requestsToTry - 4, map.get(metric.point("id", "id2")).getCount());
}
Also used : Chain(com.yahoo.component.chain.Chain) MetricReceiver(com.yahoo.metrics.simple.MetricReceiver) RateLimitingSearcher(com.yahoo.search.searchers.RateLimitingSearcher) Searcher(com.yahoo.search.Searcher) Point(com.yahoo.metrics.simple.Point) RateLimitingConfig(com.yahoo.search.config.RateLimitingConfig) RateLimitingSearcher(com.yahoo.search.searchers.RateLimitingSearcher) UntypedMetric(com.yahoo.metrics.simple.UntypedMetric) ManualClock(com.yahoo.test.ManualClock) ClusterInfoConfig(com.yahoo.cloud.config.ClusterInfoConfig) Test(org.junit.Test)

Example 77 with Chain

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

the class ElapsedTimeTestCase method testBasicBreakdownWithFillFullyWiredIn.

public void testBasicBreakdownWithFillFullyWiredIn() {
    Chain<? extends Searcher> chain = new Chain<>(new UselessSearcher("first"), new UselessSearcher("second"), new AlmostUselessSearcher("third"));
    Execution exec = new Execution(chain, Execution.Context.createContextStub());
    exec.timer().injectTimeSource(new CreativeTimeSource(SEARCH_AND_FILL_TIMESEQUENCE));
    exec.context().setDetailedDiagnostics(true);
    Result result = exec.search(new Query());
    exec.fill(result);
    SearcherTimer[] searchers = exec.timer().searcherTracking();
    checkTiming(searchers);
    checkFillTiming(searchers);
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) SearcherTimer(com.yahoo.search.statistics.TimeTracker.SearcherTimer) Result(com.yahoo.search.Result)

Example 78 with Chain

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

the class ElapsedTimeTestCase method testBasicBreakdownFullyWiredInFirstSearcherNotFirstInChain.

public void testBasicBreakdownFullyWiredInFirstSearcherNotFirstInChain() {
    Chain<? extends Searcher> chain = new Chain<>(new TestingSearcher(), new UselessSearcher("first"), new UselessSearcher("second"), new UselessSearcher("third"));
    Execution exec = new Execution(chain, Execution.Context.createContextStub());
    exec.search(new Query());
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query)

Example 79 with Chain

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

the class QueryTestCase method testNoQueryString.

@Test
public void testNoQueryString() throws IOException {
    Query q = new Query(httpEncode("?tracelevel=1"));
    Chain<Searcher> chain = new Chain<>(new RandomSearcher());
    new Execution(chain, Execution.Context.createContextStub()).search(q);
    assertNotNull(q.getModel().getQueryString());
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) Test(org.junit.Test)

Example 80 with Chain

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

the class RangeQueryOptimizerTestCase method assertOptimized.

private Query assertOptimized(String explanation, String expected, Query query) {
    Chain<Searcher> chain = new Chain<>("test", new RangeQueryOptimizer());
    new Execution(chain, Execution.Context.createContextStub(indexFacts)).search(query);
    assertEquals(explanation, expected, query.getModel().getQueryTree().getRoot().toString());
    return query;
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) RangeQueryOptimizer(com.yahoo.search.querytransform.RangeQueryOptimizer) Searcher(com.yahoo.search.Searcher)

Aggregations

Chain (com.yahoo.component.chain.Chain)92 Execution (com.yahoo.search.searchchain.Execution)59 Searcher (com.yahoo.search.Searcher)57 Test (org.junit.Test)56 Result (com.yahoo.search.Result)48 Query (com.yahoo.search.Query)47 FeedContext (com.yahoo.feedapi.FeedContext)21 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)21 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)21 ClusterList (com.yahoo.vespaclient.ClusterList)21 Processor (com.yahoo.processing.Processor)17 Request (com.yahoo.processing.Request)10 Response (com.yahoo.processing.Response)10 ComponentId (com.yahoo.component.ComponentId)8 FederationSearcher (com.yahoo.search.federation.FederationSearcher)8 ArrayList (java.util.ArrayList)8 GetDocumentMessage (com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage)7 Message (com.yahoo.messagebus.Message)7 Hit (com.yahoo.search.result.Hit)7 AsyncExecution (com.yahoo.search.searchchain.AsyncExecution)6