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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.subscription.impl;
import com.yahoo.config.ConfigInstance;
import com.yahoo.config.subscription.ConfigHandle;
import com.yahoo.config.subscription.ConfigSourceSet;
import com.yahoo.config.subscription.ConfigSubscriber;
import com.yahoo.vespa.config.ConfigKey;
import com.yahoo.vespa.config.RawConfig;
import com.yahoo.vespa.config.TimingValues;
import java.util.List;
import java.util.Map;
/**
* A subscriber that can subscribe without the class. Used by config proxy.
*
* @author Vegard Havdal
*/
public class GenericConfigSubscriber extends ConfigSubscriber {
/**
* Constructs a new subscriber using the given pool of requesters (JRTConfigRequester holds 1 connection which in
* turn is subject to failover across the elements in the source set.)
* The behaviour is undefined if the map key is different from the source set the requester was built with.
* See also {@link JRTConfigRequester#JRTConfigRequester(com.yahoo.vespa.config.ConnectionPool, com.yahoo.vespa.config.TimingValues)}
*
* @param requesters a map from config source set to config requester
*/
public GenericConfigSubscriber(Map<ConfigSourceSet, JRTConfigRequester> requesters) {
this.requesters = requesters;
}
/**
* Subscribes to config without using the class. For internal use in config proxy.
*
* @param key the {@link ConfigKey to subscribe to}
* @param defContent the config definition content for the config to subscribe to
* @param source the config source to use
* @param timingValues {@link TimingValues}
* @return generic handle
*/
public GenericConfigHandle subscribe(ConfigKey<RawConfig> key, List<String> defContent, ConfigSourceSet source, TimingValues timingValues) {
checkStateBeforeSubscribe();
GenericJRTConfigSubscription sub = new GenericJRTConfigSubscription(key, defContent, this, source, timingValues);
GenericConfigHandle handle = new GenericConfigHandle(sub);
subscribeAndHandleErrors(sub, key, handle, timingValues);
return handle;
}
@Override
public <T extends ConfigInstance> ConfigHandle<T> subscribe(Class<T> configClass, String configId) {
throw new UnsupportedOperationException();
}
@Override
public <T extends ConfigInstance> ConfigHandle<T> subscribe(Class<T> configClass, String configId, long timeoutMillis) {
throw new UnsupportedOperationException();
}
@Override
public <T extends ConfigInstance> ConfigHandle<T> subscribe(SingleSubscriber<T> singleSubscriber, Class<T> configClass, String configId) {
throw new UnsupportedOperationException();
}
/**
* Do nothing, since we share requesters
*/
public void closeRequesters() {
}
}
|