use of com.yahoo.config.subscription.CfgConfigPayloadBuilder 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.CfgConfigPayloadBuilder 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;
}
Aggregations