use of org.apache.gobblin.config.store.api.ConfigStore in project incubator-gobblin by apache.
the class TestCircularDependency method testSelfIndirectlyImportDescendant.
@Test
public void testSelfIndirectlyImportDescendant() {
ConfigKeyPath tag = SingleLinkedListConfigKeyPath.ROOT.createChild("tag");
ConfigKeyPath highPriorityTag = tag.createChild("highPriorityTag");
ConfigKeyPath nertzHighPriorityTag = highPriorityTag.createChild("nertzHighPriorityTag");
ConfigKeyPath tag2 = SingleLinkedListConfigKeyPath.ROOT.createChild("tag2");
ConfigStore mockConfigStore = mock(ConfigStore.class, Mockito.RETURNS_SMART_NULLS);
when(mockConfigStore.getCurrentVersion()).thenReturn(version);
addConfigStoreChildren(mockConfigStore, version, SingleLinkedListConfigKeyPath.ROOT, tag, tag2);
addConfigStoreChildren(mockConfigStore, version, tag, highPriorityTag);
addConfigStoreChildren(mockConfigStore, version, highPriorityTag, nertzHighPriorityTag);
// self import descendant
// formed the loop /tag -> /tag2 -> /tag/highPriorityTag/nertzHighPriorityTag -> /tag/highPriorityTag -> /tag
addConfigStoreImports(mockConfigStore, version, tag, tag2);
addConfigStoreImports(mockConfigStore, version, tag2, nertzHighPriorityTag);
ConfigStoreBackedTopology csTopology = new ConfigStoreBackedTopology(mockConfigStore, this.version);
InMemoryTopology inMemory = new InMemoryTopology(csTopology);
try {
inMemory.getImportsRecursively(tag);
Assert.fail("Did not catch expected CircularDependencyException");
} catch (CircularDependencyException e) {
Assert.assertTrue(e.getMessage().indexOf("/tag/highPriorityTag/nertzHighPriorityTag") > 0 && e.getMessage().indexOf("/tag/highPriorityTag ") > 0 && e.getMessage().indexOf("/tag ") > 0 && e.getMessage().indexOf("/tag2 ") > 0);
}
}
use of org.apache.gobblin.config.store.api.ConfigStore in project incubator-gobblin by apache.
the class TestCircularDependency method testSelfImportChild.
@Test
public void testSelfImportChild() {
ConfigKeyPath tag = SingleLinkedListConfigKeyPath.ROOT.createChild("tag");
ConfigKeyPath highPriorityTag = tag.createChild("highPriorityTag");
ConfigStore mockConfigStore = mock(ConfigStore.class, Mockito.RETURNS_SMART_NULLS);
when(mockConfigStore.getCurrentVersion()).thenReturn(version);
addConfigStoreChildren(mockConfigStore, version, SingleLinkedListConfigKeyPath.ROOT, tag);
addConfigStoreChildren(mockConfigStore, version, tag, highPriorityTag);
// parent import direct child
addConfigStoreImports(mockConfigStore, version, tag, highPriorityTag);
ConfigStoreBackedTopology csTopology = new ConfigStoreBackedTopology(mockConfigStore, this.version);
InMemoryTopology inMemory = new InMemoryTopology(csTopology);
try {
inMemory.getImportsRecursively(tag);
Assert.fail("Did not catch expected CircularDependencyException");
} catch (CircularDependencyException e) {
Assert.assertTrue(e.getMessage().indexOf("/tag/highPriorityTag") > 0 && e.getMessage().indexOf("/tag ") > 0);
}
}
use of org.apache.gobblin.config.store.api.ConfigStore in project incubator-gobblin by apache.
the class TestCircularDependency method testNoCircular.
@Test
public void testNoCircular() {
ConfigKeyPath tag = SingleLinkedListConfigKeyPath.ROOT.createChild("tag");
ConfigKeyPath highPriorityTag = tag.createChild("highPriorityTag");
ConfigKeyPath nertzHighPriorityTag = highPriorityTag.createChild("nertzHighPriorityTag");
ConfigKeyPath tag2 = SingleLinkedListConfigKeyPath.ROOT.createChild("tag2");
ConfigStore mockConfigStore = mock(ConfigStore.class, Mockito.RETURNS_SMART_NULLS);
when(mockConfigStore.getCurrentVersion()).thenReturn(version);
addConfigStoreChildren(mockConfigStore, version, SingleLinkedListConfigKeyPath.ROOT, tag, tag2);
addConfigStoreChildren(mockConfigStore, version, tag, highPriorityTag);
addConfigStoreChildren(mockConfigStore, version, highPriorityTag, nertzHighPriorityTag);
// mock up imports, point to same node but without circular
addConfigStoreImports(mockConfigStore, version, nertzHighPriorityTag, tag2);
addConfigStoreImports(mockConfigStore, version, tag2, tag);
ConfigStoreBackedTopology csTopology = new ConfigStoreBackedTopology(mockConfigStore, this.version);
InMemoryTopology inMemory = new InMemoryTopology(csTopology);
List<ConfigKeyPath> result = inMemory.getImportsRecursively(nertzHighPriorityTag);
Assert.assertEquals(result.size(), 4);
Iterator<ConfigKeyPath> it = result.iterator();
Assert.assertEquals(it.next(), tag2);
Assert.assertEquals(it.next(), tag);
Assert.assertTrue(it.next().isRootPath());
Assert.assertEquals(it.next(), highPriorityTag);
}
use of org.apache.gobblin.config.store.api.ConfigStore in project incubator-gobblin by apache.
the class TestCircularDependency method testSelfImportSelf.
@Test
public void testSelfImportSelf() {
ConfigKeyPath tag = SingleLinkedListConfigKeyPath.ROOT.createChild("tag");
ConfigStore mockConfigStore = mock(ConfigStore.class, Mockito.RETURNS_SMART_NULLS);
when(mockConfigStore.getCurrentVersion()).thenReturn(version);
addConfigStoreChildren(mockConfigStore, version, SingleLinkedListConfigKeyPath.ROOT, tag);
// self import self
addConfigStoreImports(mockConfigStore, version, tag, tag);
ConfigStoreBackedTopology csTopology = new ConfigStoreBackedTopology(mockConfigStore, this.version);
InMemoryTopology inMemory = new InMemoryTopology(csTopology);
try {
inMemory.getImportsRecursively(tag);
Assert.fail("Did not catch expected CircularDependencyException");
} catch (CircularDependencyException e) {
Assert.assertTrue(e.getMessage().indexOf("/tag") > 0);
}
}
use of org.apache.gobblin.config.store.api.ConfigStore 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()));
}
}
}
}
Aggregations