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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.searchchain.model.federation;
import com.yahoo.container.bundle.BundleInstantiationSpecification;
import net.jcip.annotations.Immutable;
import com.yahoo.search.federation.http.HTTPProviderSearcher;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Specifies how a http provider is to be set up.
*
* @author Tony Vaagenes
* @deprecated
*/
@Immutable
@Deprecated // OK
// TODO: Remove on Vespa 7
public class HttpProviderSpec {
public enum Type {
vespa(com.yahoo.search.federation.vespa.VespaSearcher.class);
Type(Class<? extends HTTPProviderSearcher> searcherClass) {
className = searcherClass.getName();
}
final String className;
}
// The default connection parameter values come from the config definition
public static class ConnectionParameters {
public final Double readTimeout;
public final Double connectionTimeout;
public final Double connectionPoolTimeout;
public final Integer retries;
public ConnectionParameters(Double readTimeout, Double connectionTimeout,
Double connectionPoolTimeout, Integer retries) {
this.readTimeout = readTimeout;
this.connectionTimeout = connectionTimeout;
this.connectionPoolTimeout = connectionPoolTimeout;
this.retries = retries;
}
}
public static class Node {
public final String host;
public final int port;
public Node(String host, int port) {
this.host = host;
this.port = port;
}
@Override
public String toString() {
return "Node{" +
"host='" + host + '\'' +
", port=" + port +
'}';
}
}
public final ConnectionParameters connectionParameters;
public final Integer cacheSizeMB;
public final String path;
public final List<Node> nodes;
public final String ycaApplicationId;
public final Integer ycaCertificateTtl;
public final Integer ycaRetryWait;
public final Node ycaProxy;
public static BundleInstantiationSpecification toBundleInstantiationSpecification(Type type) {
return BundleInstantiationSpecification.getInternalSearcherSpecificationFromStrings(type.className, null);
}
public static boolean includesType(String typeString) {
for (Type type : Type.values()) {
if (type.name().equals(typeString)) {
return true;
}
}
return false;
}
public HttpProviderSpec(Double cacheWeight,
String path,
List<Node> nodes,
String ycaApplicationId,
Integer ycaCertificateTtl,
Integer ycaRetryWait,
Node ycaProxy,
Integer cacheSizeMB,
ConnectionParameters connectionParameters) {
this.path = path;
this.nodes = unmodifiable(nodes);
this.ycaApplicationId = ycaApplicationId;
this.ycaProxy = ycaProxy;
this.ycaCertificateTtl = ycaCertificateTtl;
this.ycaRetryWait = ycaRetryWait;
this.cacheSizeMB = cacheSizeMB;
this.connectionParameters = connectionParameters;
}
private List<HttpProviderSpec.Node> unmodifiable(List<HttpProviderSpec.Node> nodes) {
return nodes == null ?
Collections.emptyList() :
Collections.unmodifiableList(new ArrayList<>(nodes));
}
}
|