use of org.apache.gobblin.config.store.api.ConfigStoreFactory in project incubator-gobblin by apache.
the class StoreDeployer method deploy.
/**
* Deploy configs in <code>classpathStoreRoot</code> to <code>storeUri</code>
*
* @param storeUri to which confgs are deployed
* @param confgSource The source that provides deployable configs.
* @param version to be used for this deployment
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void deploy(URI storeUri, DeployableConfigSource confgSource, String version) throws Exception {
ServiceLoader<ConfigStoreFactory> loader = ServiceLoader.load(ConfigStoreFactory.class);
for (ConfigStoreFactory storeFactory : loader) {
log.info("Found ConfigStore with scheme : " + storeFactory.getScheme());
if (storeUri.getScheme().equals(storeFactory.getScheme())) {
log.info("Using ConfigStore with scheme : " + storeFactory.getScheme());
ConfigStore configStore = storeFactory.createConfigStore(storeUri);
if (configStore instanceof Deployable<?>) {
((Deployable) configStore).deploy(new FsDeploymentConfig(confgSource, version));
} else {
log.error(String.format("Deployment failed. The store %s does not implement %s", storeFactory.getClass(), Deployable.class.getName()));
}
}
}
}
use of org.apache.gobblin.config.store.api.ConfigStoreFactory in project incubator-gobblin by apache.
the class TestConfigClient method testFromClient.
@Test
private void testFromClient() throws Exception {
ConfigStoreFactoryRegister mockConfigStoreFactoryRegister;
ConfigStoreFactory mockConfigStoreFactory;
URI relativeURI = new URI("etl-hdfs:///data/databases/identity");
URI absoluteURI = new URI("etl-hdfs://eat1-nertznn01.grid.linkedin.com:9000/user/mitu/HdfsBasedConfigTest/data/databases/identity");
when(mockConfigStore.getStoreURI()).thenReturn(new URI("etl-hdfs://eat1-nertznn01.grid.linkedin.com:9000/user/mitu/HdfsBasedConfigTest"));
mockConfigStoreFactory = mock(ConfigStoreFactory.class, Mockito.RETURNS_SMART_NULLS);
when(mockConfigStoreFactory.getScheme()).thenReturn("etl-hdfs");
when(mockConfigStoreFactory.createConfigStore(absoluteURI)).thenReturn(mockConfigStore);
when(mockConfigStoreFactory.createConfigStore(relativeURI)).thenReturn(mockConfigStore);
mockConfigStoreFactoryRegister = mock(ConfigStoreFactoryRegister.class, Mockito.RETURNS_SMART_NULLS);
when(mockConfigStoreFactoryRegister.getConfigStoreFactory("etl-hdfs")).thenReturn(mockConfigStoreFactory);
ConfigClient client = new ConfigClient(VersionStabilityPolicy.STRONG_LOCAL_STABILITY, mockConfigStoreFactoryRegister);
Config resolved = client.getConfig(relativeURI);
checkValuesForIdentity(resolved);
resolved = client.getConfig(absoluteURI);
checkValuesForIdentity(resolved);
// importedBy using relative URI
String[] expectedImportedBy = { "etl-hdfs:/tag/espressoTag", "etl-hdfs:/data/databases/identity" };
URI nertzTagURI = new URI("etl-hdfs:///tag2/nertzTag2");
Collection<URI> importedBy = client.getImportedBy(nertzTagURI, false);
Assert.assertEquals(importedBy.size(), 1);
Assert.assertEquals(importedBy.iterator().next().toString(), expectedImportedBy[0]);
importedBy = client.getImportedBy(nertzTagURI, true);
Assert.assertEquals(importedBy.size(), 2);
for (URI u : importedBy) {
Assert.assertTrue(u.toString().equals(expectedImportedBy[0]) || u.toString().equals(expectedImportedBy[1]));
}
// importedBy using abs URI
String[] expectedImportedBy_abs = { "etl-hdfs://eat1-nertznn01.grid.linkedin.com:9000/user/mitu/HdfsBasedConfigTest/tag/espressoTag", "etl-hdfs://eat1-nertznn01.grid.linkedin.com:9000/user/mitu/HdfsBasedConfigTest/data/databases/identity" };
nertzTagURI = new URI("etl-hdfs://eat1-nertznn01.grid.linkedin.com:9000/user/mitu/HdfsBasedConfigTest/tag2/nertzTag2");
importedBy = client.getImportedBy(nertzTagURI, false);
Assert.assertEquals(importedBy.size(), 1);
Assert.assertEquals(importedBy.iterator().next().toString(), expectedImportedBy_abs[0]);
importedBy = client.getImportedBy(nertzTagURI, true);
Assert.assertEquals(importedBy.size(), 2);
for (URI u : importedBy) {
Assert.assertTrue(u.toString().equals(expectedImportedBy_abs[0]) || u.toString().equals(expectedImportedBy_abs[1]));
}
}
Aggregations