Search in sources :

Example 6 with ConfigStore

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);
    }
}
Also used : ConfigStore(org.apache.gobblin.config.store.api.ConfigStore) ConfigKeyPath(org.apache.gobblin.config.store.api.ConfigKeyPath) Test(org.testng.annotations.Test)

Example 7 with ConfigStore

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);
    }
}
Also used : ConfigStore(org.apache.gobblin.config.store.api.ConfigStore) ConfigKeyPath(org.apache.gobblin.config.store.api.ConfigKeyPath) Test(org.testng.annotations.Test)

Example 8 with ConfigStore

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);
}
Also used : ConfigStore(org.apache.gobblin.config.store.api.ConfigStore) ConfigKeyPath(org.apache.gobblin.config.store.api.ConfigKeyPath) Test(org.testng.annotations.Test)

Example 9 with ConfigStore

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);
    }
}
Also used : ConfigStore(org.apache.gobblin.config.store.api.ConfigStore) ConfigKeyPath(org.apache.gobblin.config.store.api.ConfigKeyPath) Test(org.testng.annotations.Test)

Example 10 with ConfigStore

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()));
            }
        }
    }
}
Also used : ConfigStore(org.apache.gobblin.config.store.api.ConfigStore) ConfigStoreFactory(org.apache.gobblin.config.store.api.ConfigStoreFactory)

Aggregations

ConfigStore (org.apache.gobblin.config.store.api.ConfigStore)11 ConfigKeyPath (org.apache.gobblin.config.store.api.ConfigKeyPath)8 Test (org.testng.annotations.Test)8 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ConfigStoreBackedTopology (org.apache.gobblin.config.common.impl.ConfigStoreBackedTopology)1 ConfigStoreBackedValueInspector (org.apache.gobblin.config.common.impl.ConfigStoreBackedValueInspector)1 InMemoryTopology (org.apache.gobblin.config.common.impl.InMemoryTopology)1 InMemoryValueInspector (org.apache.gobblin.config.common.impl.InMemoryValueInspector)1 ConfigStoreFactory (org.apache.gobblin.config.store.api.ConfigStoreFactory)1