Search in sources :

Example 36 with ConfigKeyPath

use of org.apache.gobblin.config.store.api.ConfigKeyPath in project incubator-gobblin by apache.

the class SimpleHdfsConfigStoreTest method testGetOwnConfig.

@Test
public void testGetOwnConfig() throws ConfigStoreCreationException, URISyntaxException, IOException {
    String datasetName = "dataset-test-get-own-config";
    Path datasetPath = new Path(CONFIG_DIR_PATH, datasetName);
    try {
        this.fs.mkdirs(datasetPath);
        this.fs.create(new Path(datasetPath, "main.conf")).close();
        ConfigKeyPath datasetConfigKey = SingleLinkedListConfigKeyPath.ROOT.createChild(datasetName);
        Config config = this._simpleHadoopFilesystemConfigStore.getOwnConfig(datasetConfigKey, VERSION);
        Assert.assertTrue(config.isEmpty());
    } finally {
        if (this.fs.exists(datasetPath)) {
            this.fs.delete(datasetPath, true);
        }
    }
}
Also used : SingleLinkedListConfigKeyPath(org.apache.gobblin.config.common.impl.SingleLinkedListConfigKeyPath) Path(org.apache.hadoop.fs.Path) ConfigKeyPath(org.apache.gobblin.config.store.api.ConfigKeyPath) Config(com.typesafe.config.Config) FsDeploymentConfig(org.apache.gobblin.config.store.deploy.FsDeploymentConfig) SingleLinkedListConfigKeyPath(org.apache.gobblin.config.common.impl.SingleLinkedListConfigKeyPath) ConfigKeyPath(org.apache.gobblin.config.store.api.ConfigKeyPath) Test(org.testng.annotations.Test)

Example 37 with ConfigKeyPath

use of org.apache.gobblin.config.store.api.ConfigKeyPath in project incubator-gobblin by apache.

the class InMemoryValueInspector method getResolvedConfigs.

/**
 * {@inheritDoc}.
 *
 * <p>
 *   If present in the cache, return the cached {@link com.typesafe.config.Config} for given input
 *   Otherwise, simply delegate the functionality to the internal {ConfigStoreValueInspector} and store the value into cache
 * </p>
 */
@Override
public Map<ConfigKeyPath, Config> getResolvedConfigs(Collection<ConfigKeyPath> configKeys) {
    Collection<ConfigKeyPath> configKeysNotInCache = new ArrayList<>();
    Map<ConfigKeyPath, Config> result = new HashMap<>();
    for (ConfigKeyPath configKey : configKeys) {
        Config cachedValue = this.recursiveConfigCache.getIfPresent(configKey);
        if (cachedValue == null) {
            configKeysNotInCache.add(configKey);
        } else {
            result.put(configKey, cachedValue);
        }
    }
    // for ConfigKeyPath which are not in cache
    if (configKeysNotInCache.size() > 0) {
        Map<ConfigKeyPath, Config> configsFromFallBack = this.valueFallback.getResolvedConfigs(configKeysNotInCache);
        this.recursiveConfigCache.putAll(configsFromFallBack);
        result.putAll(configsFromFallBack);
    }
    return result;
}
Also used : HashMap(java.util.HashMap) Config(com.typesafe.config.Config) ArrayList(java.util.ArrayList) ConfigKeyPath(org.apache.gobblin.config.store.api.ConfigKeyPath)

Aggregations

ConfigKeyPath (org.apache.gobblin.config.store.api.ConfigKeyPath)37 Test (org.testng.annotations.Test)18 SingleLinkedListConfigKeyPath (org.apache.gobblin.config.common.impl.SingleLinkedListConfigKeyPath)15 ArrayList (java.util.ArrayList)10 Path (org.apache.hadoop.fs.Path)9 ConfigStore (org.apache.gobblin.config.store.api.ConfigStore)8 Config (com.typesafe.config.Config)6 IOException (java.io.IOException)6 InputStream (java.io.InputStream)4 URI (java.net.URI)4 HashMap (java.util.HashMap)4 BufferedWriter (java.io.BufferedWriter)3 OutputStreamWriter (java.io.OutputStreamWriter)3 Path (java.nio.file.Path)3 FileStatus (org.apache.hadoop.fs.FileStatus)3 InputStreamReader (java.io.InputStreamReader)2 HashSet (java.util.HashSet)2 FsDeploymentConfig (org.apache.gobblin.config.store.deploy.FsDeploymentConfig)2 SeekableFSInputStream (org.apache.gobblin.util.io.SeekableFSInputStream)2 ImmutableMultimap (com.google.common.collect.ImmutableMultimap)1