Search in sources :

Example 31 with ConfigKeyPath

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

the class TestConfigClientUtils method testGetConfigKeyPath.

@Test
public void testGetConfigKeyPath() throws URISyntaxException {
    String expected = "/datasets/a1/a2";
    URI clientAbsURI = new URI("etl-hdfs://eat1-nertznn01.grid.linkedin.com:9000/user/mitu/HdfsBasedConfigTest/datasets/a1/a2");
    ConfigKeyPath result = ConfigClientUtils.buildConfigKeyPath(clientAbsURI, mockConfigStore);
    Assert.assertEquals(result.toString(), expected);
    URI clientRelativeURI = new URI("etl-hdfs:///datasets/a1/a2");
    result = ConfigClientUtils.buildConfigKeyPath(clientRelativeURI, mockConfigStore);
    Assert.assertEquals(result.toString(), expected);
    clientRelativeURI = new URI("etl-hdfs:/datasets/a1/a2");
    result = ConfigClientUtils.buildConfigKeyPath(clientRelativeURI, mockConfigStore);
    Assert.assertEquals(result.toString(), expected);
    ConfigKeyPath configKey = SingleLinkedListConfigKeyPath.ROOT.createChild("data").createChild("databases").createChild("Identity");
    // client app pass URI without authority
    URI adjusted = ConfigClientUtils.buildUriInClientFormat(configKey, mockConfigStore, false);
    Assert.assertTrue(adjusted.toString().equals("etl-hdfs:/data/databases/Identity"));
    // client app pass URI with authority
    adjusted = ConfigClientUtils.buildUriInClientFormat(configKey, mockConfigStore, true);
    Assert.assertTrue(adjusted.toString().equals("etl-hdfs://eat1-nertznn01.grid.linkedin.com:9000/user/mitu/HdfsBasedConfigTest/data/databases/Identity"));
}
Also used : URI(java.net.URI) SingleLinkedListConfigKeyPath(org.apache.gobblin.config.common.impl.SingleLinkedListConfigKeyPath) ConfigKeyPath(org.apache.gobblin.config.store.api.ConfigKeyPath) Test(org.testng.annotations.Test)

Example 32 with ConfigKeyPath

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

the class ConfigClient method getConfig.

public Config getConfig(URI configKeyUri, Optional<Config> runtimeConfig) throws ConfigStoreFactoryDoesNotExistsException, ConfigStoreCreationException, VersionDoesNotExistException {
    ConfigStoreAccessor accessor = this.getConfigStoreAccessor(configKeyUri);
    ConfigKeyPath configKeypath = ConfigClientUtils.buildConfigKeyPath(configKeyUri, accessor.configStore);
    return accessor.valueInspector.getResolvedConfig(configKeypath, runtimeConfig);
}
Also used : ConfigKeyPath(org.apache.gobblin.config.store.api.ConfigKeyPath)

Example 33 with ConfigKeyPath

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

the class ConfigClient method getImportedBy.

public Collection<URI> getImportedBy(URI configKeyUri, boolean recursive, Optional<Config> runtimeConfig) throws ConfigStoreFactoryDoesNotExistsException, ConfigStoreCreationException, VersionDoesNotExistException {
    ConfigStoreAccessor accessor = this.getConfigStoreAccessor(configKeyUri);
    ConfigKeyPath configKeypath = ConfigClientUtils.buildConfigKeyPath(configKeyUri, accessor.configStore);
    Collection<ConfigKeyPath> result;
    if (!recursive) {
        result = accessor.topologyInspector.getImportedBy(configKeypath, runtimeConfig);
    } else {
        result = accessor.topologyInspector.getImportedByRecursively(configKeypath, runtimeConfig);
    }
    return ConfigClientUtils.buildUriInClientFormat(result, accessor.configStore, configKeyUri.getAuthority() != null);
}
Also used : ConfigKeyPath(org.apache.gobblin.config.store.api.ConfigKeyPath)

Example 34 with ConfigKeyPath

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

the class ConfigStoreBackedValueInspector method getResolvedConfigRecursive.

private Config getResolvedConfigRecursive(ConfigKeyPath configKey, Set<String> alreadyLoadedPaths, Optional<Config> runtimeConfig) {
    if (this.cs instanceof ConfigStoreWithResolution) {
        return ((ConfigStoreWithResolution) this.cs).getResolvedConfig(configKey, this.version);
    }
    if (!alreadyLoadedPaths.add(configKey.getAbsolutePathString())) {
        return ConfigFactory.empty();
    }
    Config initialConfig = this.getOwnConfig(configKey);
    if (configKey.isRootPath()) {
        return initialConfig;
    }
    List<ConfigKeyPath> ownImports = this.topology.getOwnImports(configKey, runtimeConfig);
    // merge with other configs from imports
    if (ownImports != null) {
        for (ConfigKeyPath p : ownImports) {
            initialConfig = initialConfig.withFallback(this.getResolvedConfigRecursive(p, alreadyLoadedPaths, runtimeConfig));
        }
    }
    // merge with configs from parent for Non root
    initialConfig = initialConfig.withFallback(this.getResolvedConfigRecursive(configKey.getParent(), alreadyLoadedPaths, runtimeConfig));
    return initialConfig;
}
Also used : ConfigStoreWithResolution(org.apache.gobblin.config.store.api.ConfigStoreWithResolution) Config(com.typesafe.config.Config) ConfigKeyPath(org.apache.gobblin.config.store.api.ConfigKeyPath)

Example 35 with ConfigKeyPath

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

the class SimpleHdfsConfigStoreTest method testGetChildren.

@Test
public void testGetChildren() throws IOException, URISyntaxException, ConfigStoreCreationException {
    String datasetName = "dataset-test-get-children";
    String childDatasetName = "childDataset";
    Path datasetPath = new Path(CONFIG_DIR_PATH, datasetName);
    try {
        this.fs.mkdirs(new Path(datasetPath, childDatasetName));
        ConfigKeyPath datasetConfigKey = SingleLinkedListConfigKeyPath.ROOT.createChild(datasetName);
        Collection<ConfigKeyPath> children = this._simpleHadoopFilesystemConfigStore.getChildren(datasetConfigKey, VERSION);
        Assert.assertEquals(children.size(), 1);
        Assert.assertEquals(children.iterator().next().getOwnPathName(), childDatasetName);
    } 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) SingleLinkedListConfigKeyPath(org.apache.gobblin.config.common.impl.SingleLinkedListConfigKeyPath) ConfigKeyPath(org.apache.gobblin.config.store.api.ConfigKeyPath) Test(org.testng.annotations.Test)

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