use of com.yahoo.vespa.config.ConfigDefinitionKey in project vespa by vespa-engine.
the class LoadTester method readDefs.
private Map<ConfigDefinitionKey, Tuple2<String, String[]>> readDefs(String defPath) throws IOException {
Map<ConfigDefinitionKey, Tuple2<String, String[]>> ret = new HashMap<>();
if (defPath == null)
return ret;
File defDir = new File(defPath);
if (!defDir.isDirectory()) {
System.out.println("# Given def file dir is not a directory: " + defDir.getPath() + " , will not send def contents in requests.");
return ret;
}
final File[] files = defDir.listFiles();
if (files == null) {
System.out.println("# Given def file dir has no files: " + defDir.getPath() + " , will not send def contents in requests.");
return ret;
}
for (File f : files) {
String name = f.getName();
if (!name.endsWith(".def"))
continue;
String[] splitted = name.split("\\.");
if (splitted.length < 2)
continue;
String nam = splitted[splitted.length - 2];
String contents = IOUtils.readFile(f);
ConfigDefinitionKey key = ConfigUtils.createConfigDefinitionKeyFromDefContent(nam, Utf8.toBytes(contents));
ret.put(key, new Tuple2<>(ConfigUtils.getDefMd5(Arrays.asList(contents.split("\n"))), contents.split("\n")));
}
System.out.println("# Read " + ret.size() + " def files from " + defDir.getPath());
return ret;
}
use of com.yahoo.vespa.config.ConfigDefinitionKey in project vespa by vespa-engine.
the class ServerCacheLoader method loadConfigDefinitionsFromPath.
/**
* Loads config definitions from a specified path into server cache and returns it.
*
* @param appPath the path to load config definitions from
*/
private void loadConfigDefinitionsFromPath(ServerCache cache, String appPath) {
if (!configCurator.exists(appPath))
return;
for (String nodeName : configCurator.getChildren(appPath)) {
String payload = configCurator.getData(appPath, nodeName);
ConfigDefinitionKey dKey = ConfigUtils.createConfigDefinitionKeyFromZKString(nodeName);
cache.addDef(dKey, new ConfigDefinition(dKey.getName(), Splitter.on("\n").splitToList(payload).toArray(new String[0])));
}
}
use of com.yahoo.vespa.config.ConfigDefinitionKey in project vespa by vespa-engine.
the class ApplicationTest method createCacheAndAddContent.
private static ServerCache createCacheAndAddContent() {
ServerCache cache = new ServerCache();
final ConfigDefinitionKey key = new ConfigDefinitionKey(SimpletypesConfig.CONFIG_DEF_NAME, SimpletypesConfig.CONFIG_DEF_NAMESPACE);
com.yahoo.vespa.config.buildergen.ConfigDefinition def = getDef(key, SimpletypesConfig.CONFIG_DEF_SCHEMA);
// TODO Why do we have to use empty def md5 here?
cache.addDef(key, def);
final ConfigDefinitionKey key2 = new ConfigDefinitionKey(SlobroksConfig.CONFIG_DEF_NAME, SlobroksConfig.CONFIG_DEF_NAMESPACE);
com.yahoo.vespa.config.buildergen.ConfigDefinition def2 = getDef(key2, SlobroksConfig.CONFIG_DEF_SCHEMA);
cache.addDef(key2, def2);
final ConfigDefinitionKey key3 = new ConfigDefinitionKey(LogdConfig.CONFIG_DEF_NAME, LogdConfig.CONFIG_DEF_NAMESPACE);
com.yahoo.vespa.config.buildergen.ConfigDefinition def3 = getDef(key3, LogdConfig.CONFIG_DEF_SCHEMA);
cache.addDef(key3, def3);
return cache;
}
Aggregations