blob: 68ff6bb0135ea55c8b018c3bc64722ad27c458f0 (
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.subscription.impl;
import java.util.Arrays;
import com.yahoo.config.ConfigInstance;
import com.yahoo.config.subscription.CfgConfigPayloadBuilder;
import com.yahoo.config.subscription.ConfigInterruptedException;
import com.yahoo.config.subscription.ConfigSubscriber;
import com.yahoo.vespa.config.ConfigKey;
import com.yahoo.vespa.config.ConfigPayload;
/**
* Subscription used when config id is raw:...
* <p>
* Config is the actual text given after the config id, with newlines
*
* @author Vegard Havdal
*/
public class RawConfigSubscription<T extends ConfigInstance> extends ConfigSubscription<T> {
final String inputPayload;
String payload;
RawConfigSubscription(ConfigKey<T> key, ConfigSubscriber subscriber, String pl) {
super(key, subscriber);
this.inputPayload = pl;
}
@Override
public boolean nextConfig(long timeout) {
if (checkReloaded()) {
return true;
}
if (payload == null) {
payload = inputPayload;
ConfigPayload configPayload = new CfgConfigPayloadBuilder().deserialize(Arrays.asList(payload.split("\n")));
setConfig(0L, false, configPayload.toInstance(configClass, key.getConfigId()));
return true;
}
try {
Thread.sleep(timeout);
} catch (InterruptedException e) {
throw new ConfigInterruptedException(e);
}
return false;
}
@Override
public boolean subscribe(long timeout) {
return true;
}
}
|