use of com.yahoo.config.subscription.DirSource in project vespa by vespa-engine.
the class FileConfigSubscriptionTest method require_that_dir_config_id_reference_is_not_changed.
@Test
public void require_that_dir_config_id_reference_is_not_changed() {
final String cfgDir = "src/test/resources/configs/foo";
final String cfgId = "dir:" + cfgDir;
final ConfigKey<TestReferenceConfig> key = new ConfigKey<>(TestReferenceConfig.class, cfgId);
ConfigSubscriber subscriber = new ConfigSubscriber();
ConfigSubscription<TestReferenceConfig> sub = ConfigSubscription.get(key, subscriber, new DirSource(new File(cfgDir)), new TimingValues());
assertTrue(sub.nextConfig(1000));
assertThat(sub.getConfigState().getConfig().configId(), is(cfgId));
}
use of com.yahoo.config.subscription.DirSource in project vespa by vespa-engine.
the class ConfigSubscription method getDirFileSub.
private static <T extends ConfigInstance> ConfigSubscription<T> getDirFileSub(ConfigKey<T> key, ConfigSubscriber subscriber, ConfigSource source) {
String dir = key.getConfigId().replace("dir:", "");
if (source instanceof DirSource) {
dir = ((DirSource) source).getDir().toString();
}
if (!dir.endsWith(File.separator))
dir = dir + File.separator;
String name = getConfigFilenameNoVersion(key);
File file = new File(dir + name);
if (!file.exists()) {
throw new IllegalArgumentException("Could not find a config file for '" + key.getName() + "' in '" + dir + "'");
}
return new FileConfigSubscription<>(key, subscriber, file);
}
Aggregations