blob: 596375ea93aa890f3ba598fa4db7f8b8cf385c39 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container.xml;
import com.yahoo.container.bundle.BundleInstantiationSpecification;
import com.yahoo.container.handler.threadpool.ContainerThreadpoolConfig;
import com.yahoo.vespa.model.container.ApplicationContainerCluster;
import com.yahoo.vespa.model.container.ContainerThreadpool;
import com.yahoo.vespa.model.container.component.BindingPattern;
import com.yahoo.vespa.model.container.component.SystemBindingPattern;
import com.yahoo.vespa.model.container.component.chain.ProcessingHandler;
import com.yahoo.vespa.model.container.search.searchchain.SearchChains;
import java.util.List;
import java.util.Optional;
import java.util.OptionalInt;
import static com.yahoo.container.bundle.BundleInstantiationSpecification.fromSearchAndDocproc;
/**
* Component definition for {@link com.yahoo.search.handler.SearchHandler}
*
* @author bjorncs
*/
class SearchHandler extends ProcessingHandler<SearchChains> {
static final String HANDLER_CLASS = com.yahoo.search.handler.SearchHandler.class.getName();
static final String EXECUTION_FACTORY_CLASS = com.yahoo.search.searchchain.ExecutionFactory.class.getName();
static final BundleInstantiationSpecification HANDLER_SPEC = fromSearchAndDocproc(HANDLER_CLASS);
static final BindingPattern DEFAULT_BINDING = bindingPattern(Optional.empty());
SearchHandler(ApplicationContainerCluster cluster,
List<BindingPattern> bindings,
ContainerThreadpool.UserOptions threadpoolOptions) {
super(cluster.getSearchChains(), HANDLER_SPEC, new Threadpool(threadpoolOptions));
bindings.forEach(this::addServerBindings);
}
static BindingPattern bindingPattern(Optional<String> port) {
String path = "/search/*";
return port
.filter(s -> !s.isBlank())
.map(s -> SystemBindingPattern.fromHttpPortAndPath(s, path))
.orElseGet(() -> SystemBindingPattern.fromHttpPath(path));
}
private static class Threadpool extends ContainerThreadpool {
Threadpool(UserOptions options) {
super("search-handler", options);
}
@Override
public void setDefaultConfigValues(ContainerThreadpoolConfig.Builder builder) {
builder.maxThreadExecutionTimeSeconds(190)
.keepAliveTime(5.0)
.maxThreads(-2)
.minThreads(-2)
.queueSize(-40);
}
}
}
|