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"));
}
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);
}
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);
}
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;
}
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);
}
}
}
Aggregations