Search in sources :

Example 1 with InMemoryTopology

use of org.apache.gobblin.config.common.impl.InMemoryTopology in project incubator-gobblin by apache.

the class ConfigClient method createNewConfigStoreAccessor.

private ConfigStoreAccessor createNewConfigStoreAccessor(URI configKeyURI) throws ConfigStoreFactoryDoesNotExistsException, ConfigStoreCreationException, VersionDoesNotExistException {
    LOG.info("Create new config store accessor for URI " + configKeyURI);
    ConfigStoreAccessor result;
    ConfigStoreFactory<ConfigStore> csFactory = this.getConfigStoreFactory(configKeyURI);
    ConfigStore cs = csFactory.createConfigStore(configKeyURI);
    if (!isConfigStoreWithStableVersion(cs)) {
        if (this.policy == VersionStabilityPolicy.CROSS_JVM_STABILITY) {
            throw new RuntimeException(String.format("with policy set to %s, can not connect to unstable config store %s", VersionStabilityPolicy.CROSS_JVM_STABILITY, cs.getStoreURI()));
        }
    }
    String currentVersion = cs.getCurrentVersion();
    LOG.info("Current config store version number: " + currentVersion);
    // topology related
    ConfigStoreBackedTopology csTopology = new ConfigStoreBackedTopology(cs, currentVersion);
    InMemoryTopology inMemoryTopology = new InMemoryTopology(csTopology);
    // value related
    ConfigStoreBackedValueInspector rawValueInspector = new ConfigStoreBackedValueInspector(cs, currentVersion, inMemoryTopology);
    InMemoryValueInspector inMemoryValueInspector;
    // ConfigStoreWithStableVersioning always create Soft reference cache
    if (isConfigStoreWithStableVersion(cs) || this.policy == VersionStabilityPolicy.WEAK_LOCAL_STABILITY) {
        inMemoryValueInspector = new InMemoryValueInspector(rawValueInspector, false);
        result = new ConfigStoreAccessor(cs, inMemoryValueInspector, inMemoryTopology);
    } else // Non ConfigStoreWithStableVersioning but require STRONG_LOCAL_STABILITY, use Strong reference cache
    if (this.policy == VersionStabilityPolicy.STRONG_LOCAL_STABILITY) {
        inMemoryValueInspector = new InMemoryValueInspector(rawValueInspector, true);
        result = new ConfigStoreAccessor(cs, inMemoryValueInspector, inMemoryTopology);
    } else // Require No cache
    {
        result = new ConfigStoreAccessor(cs, rawValueInspector, inMemoryTopology);
    }
    return result;
}
Also used : InMemoryTopology(org.apache.gobblin.config.common.impl.InMemoryTopology) ConfigStoreBackedValueInspector(org.apache.gobblin.config.common.impl.ConfigStoreBackedValueInspector) ConfigStore(org.apache.gobblin.config.store.api.ConfigStore) ConfigStoreBackedTopology(org.apache.gobblin.config.common.impl.ConfigStoreBackedTopology) InMemoryValueInspector(org.apache.gobblin.config.common.impl.InMemoryValueInspector)

Aggregations

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 ConfigStore (org.apache.gobblin.config.store.api.ConfigStore)1