Search in sources :

Example 26 with ConfigDefinitionKey

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;
}
Also used : Tuple2(com.yahoo.collections.Tuple2) ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey)

Example 27 with ConfigDefinitionKey

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])));
    }
}
Also used : ConfigDefinition(com.yahoo.vespa.config.buildergen.ConfigDefinition) ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey)

Example 28 with ConfigDefinitionKey

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;
}
Also used : ServerCache(com.yahoo.vespa.config.server.ServerCache) ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey)

Aggregations

ConfigDefinitionKey (com.yahoo.vespa.config.ConfigDefinitionKey)28 Test (org.junit.Test)15 File (java.io.File)7 UnparsedConfigDefinition (com.yahoo.config.application.api.UnparsedConfigDefinition)6 UserConfigRepo (com.yahoo.config.model.producer.UserConfigRepo)5 ConfigDefinition (com.yahoo.vespa.config.ConfigDefinition)5 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)4 JarFile (java.util.jar.JarFile)4 Element (org.w3c.dom.Element)4 DefParser (com.yahoo.config.codegen.DefParser)3 ConfigPayloadBuilder (com.yahoo.vespa.config.ConfigPayloadBuilder)3 ConfigDefinition (com.yahoo.vespa.config.buildergen.ConfigDefinition)3 LinkedHashMap (java.util.LinkedHashMap)3 ConfigInstance (com.yahoo.config.ConfigInstance)2 ApplicationFile (com.yahoo.config.application.api.ApplicationFile)2 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)2 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)2 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)2 GenericConfig (com.yahoo.vespa.config.GenericConfig)2 VespaModel (com.yahoo.vespa.model.VespaModel)2