use of com.yahoo.config.subscription.ConfigInterruptedException in project vespa by vespa-engine.
the class FileConfigSubscription method nextConfig.
@Override
public boolean nextConfig(long timeout) {
if (!file.exists() && !file.isFile())
throw new IllegalArgumentException("Not a file: " + file);
if (checkReloaded()) {
log.log(LogLevel.DEBUG, "User forced config reload at " + System.currentTimeMillis());
// User forced reload
setConfigIfChanged(updateConfig());
ConfigState<T> configState = getConfigState();
log.log(LogLevel.DEBUG, "Config updated at " + System.currentTimeMillis() + ", changed: " + configState.isConfigChanged());
log.log(LogLevel.DEBUG, "Config: " + configState.getConfig().toString());
return true;
}
if (file.lastModified() != ts) {
setConfigIncGen(updateConfig());
return true;
}
try {
Thread.sleep(timeout);
} catch (InterruptedException e) {
throw new ConfigInterruptedException(e);
}
return false;
}
use of com.yahoo.config.subscription.ConfigInterruptedException in project vespa by vespa-engine.
the class JarConfigSubscription method nextConfig.
@Override
public boolean nextConfig(long timeout) {
if (checkReloaded()) {
// Not supporting changing the payload for jar
return true;
}
if (zipEntry == null) {
// First time polled
JarFile jarFile = null;
try {
jarFile = new JarFile(jarName);
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
zipEntry = getEntry(jarFile, path);
if (zipEntry == null)
throw new IllegalArgumentException("Config '" + key.getName() + "' not found in '" + jarName + "!/" + path + "'.");
T config = null;
try {
ConfigPayload payload = new CfgConfigPayloadBuilder().deserialize(Arrays.asList(IOUtils.readAll(new InputStreamReader(jarFile.getInputStream(zipEntry), "UTF-8")).split("\n")));
config = payload.toInstance(configClass, key.getConfigId());
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException(e);
} catch (IOException e) {
throw new ConfigurationRuntimeException(e);
}
setConfig(0L, config);
try {
jarFile.close();
} catch (IOException e) {
throw new ConfigurationRuntimeException(e);
}
return true;
}
// TODO: Should wait and detect changes
try {
Thread.sleep(timeout);
} catch (InterruptedException e) {
throw new ConfigInterruptedException(e);
}
return false;
}
use of com.yahoo.config.subscription.ConfigInterruptedException in project vespa by vespa-engine.
the class RawConfigSubscription method nextConfig.
@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, configPayload.toInstance(configClass, key.getConfigId()));
return true;
}
try {
Thread.sleep(timeout);
} catch (InterruptedException e) {
throw new ConfigInterruptedException(e);
}
return false;
}
use of com.yahoo.config.subscription.ConfigInterruptedException in project vespa by vespa-engine.
the class JRTConfigSubscription method subscribe.
@Override
public boolean subscribe(long timeout) {
lastOK = System.currentTimeMillis();
requester = getRequester();
requester.request(this);
JRTClientConfigRequest req = reqQueue.peek();
while (req == null && (System.currentTimeMillis() - lastOK <= timeout)) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
throw new ConfigInterruptedException(e);
}
req = reqQueue.peek();
}
return req != null;
}
Aggregations