Search in sources :

Example 6 with AsyncExecution

use of com.yahoo.search.searchchain.AsyncExecution in project vespa by vespa-engine.

the class AsyncExecutionTestCase method testAsyncExecutionTimeout.

@SuppressWarnings("deprecation")
public void testAsyncExecutionTimeout() {
    Chain<Searcher> chain = new Chain<>(new Searcher() {

        @Override
        public Result search(Query query, Execution execution) {
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return new Result(query);
        }
    });
    Execution execution = new Execution(chain, Execution.Context.createContextStub());
    AsyncExecution async = new AsyncExecution(execution);
    FutureResult future = async.searchAndFill(new Query());
    future.get(1, TimeUnit.MILLISECONDS);
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) AsyncExecution(com.yahoo.search.searchchain.AsyncExecution) Query(com.yahoo.search.Query) FutureResult(com.yahoo.search.searchchain.FutureResult) AsyncExecution(com.yahoo.search.searchchain.AsyncExecution) Searcher(com.yahoo.search.Searcher) FutureResult(com.yahoo.search.searchchain.FutureResult) Result(com.yahoo.search.Result)

Aggregations

Query (com.yahoo.search.Query)6 Result (com.yahoo.search.Result)6 AsyncExecution (com.yahoo.search.searchchain.AsyncExecution)6 FutureResult (com.yahoo.search.searchchain.FutureResult)6 Searcher (com.yahoo.search.Searcher)5 Chain (com.yahoo.component.chain.Chain)4 Execution (com.yahoo.search.searchchain.Execution)3 ArrayList (java.util.ArrayList)3 ComponentId (com.yahoo.component.ComponentId)2 Pair (com.yahoo.collections.Pair)1 CopyOnWriteHashMap (com.yahoo.concurrent.CopyOnWriteHashMap)1 Hit (com.yahoo.search.result.Hit)1 ForkingSearcher (com.yahoo.search.searchchain.ForkingSearcher)1 IdentityHashMap (java.util.IdentityHashMap)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1