Search in sources :

Example 1 with ConfigStoreCreationException

use of org.apache.gobblin.config.store.api.ConfigStoreCreationException in project incubator-gobblin by apache.

the class ConfigClientBasedPolicyFactory method createPolicy.

@Override
public ThrottlingPolicy createPolicy(SharedLimiterKey key, SharedResourcesBroker<ThrottlingServerScopes> broker, Config config) {
    try {
        Config resourceConfig = getConfigClient().getConfig(new URI(config.getString(CONFIG_KEY_URI_PREFIX_KEY) + key.getResourceLimitedPath()));
        ThrottlingPolicyFactory.SpecificPolicyFactory factory = ThrottlingPolicyFactory.POLICY_CLASS_RESOLVER.resolveClass(resourceConfig.getString(POLICY_KEY)).newInstance();
        return factory.createPolicy(key, broker, ConfigUtils.getConfigOrEmpty(resourceConfig, THROTTLING_CONFIG_PREFIX));
    } catch (URISyntaxException | ConfigStoreFactoryDoesNotExistsException | ConfigStoreCreationException | ReflectiveOperationException exc) {
        throw new RuntimeException(exc);
    }
}
Also used : ConfigStoreCreationException(org.apache.gobblin.config.store.api.ConfigStoreCreationException) Config(com.typesafe.config.Config) ConfigStoreFactoryDoesNotExistsException(org.apache.gobblin.config.client.api.ConfigStoreFactoryDoesNotExistsException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 2 with ConfigStoreCreationException

use of org.apache.gobblin.config.store.api.ConfigStoreCreationException in project incubator-gobblin by apache.

the class QueryBasedSource method getTableSpecificPropsFromConfigStore.

private static Map<SourceEntity, State> getTableSpecificPropsFromConfigStore(Collection<SourceEntity> tables, State state) {
    ConfigClient client = ConfigClientCache.getClient(VersionStabilityPolicy.STRONG_LOCAL_STABILITY);
    String configStoreUri = state.getProp(ConfigurationKeys.CONFIG_MANAGEMENT_STORE_URI);
    Preconditions.checkNotNull(configStoreUri);
    Map<SourceEntity, State> result = Maps.newHashMap();
    for (SourceEntity table : tables) {
        try {
            result.put(table, ConfigUtils.configToState(client.getConfig(PathUtils.combinePaths(configStoreUri, QUERY_BASED_SOURCE, table.getDatasetName()).toUri())));
        } catch (VersionDoesNotExistException | ConfigStoreFactoryDoesNotExistsException | ConfigStoreCreationException e) {
            throw new RuntimeException("Unable to get table config for " + table, e);
        }
    }
    return result;
}
Also used : ConfigClient(org.apache.gobblin.config.client.ConfigClient) VersionDoesNotExistException(org.apache.gobblin.config.store.api.VersionDoesNotExistException) ConfigStoreCreationException(org.apache.gobblin.config.store.api.ConfigStoreCreationException) WorkUnitState(org.apache.gobblin.configuration.WorkUnitState) State(org.apache.gobblin.configuration.State) WorkingState(org.apache.gobblin.configuration.WorkUnitState.WorkingState) SourceState(org.apache.gobblin.configuration.SourceState) ConfigStoreFactoryDoesNotExistsException(org.apache.gobblin.config.client.api.ConfigStoreFactoryDoesNotExistsException)

Aggregations

ConfigStoreFactoryDoesNotExistsException (org.apache.gobblin.config.client.api.ConfigStoreFactoryDoesNotExistsException)2 ConfigStoreCreationException (org.apache.gobblin.config.store.api.ConfigStoreCreationException)2 Config (com.typesafe.config.Config)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ConfigClient (org.apache.gobblin.config.client.ConfigClient)1 VersionDoesNotExistException (org.apache.gobblin.config.store.api.VersionDoesNotExistException)1 SourceState (org.apache.gobblin.configuration.SourceState)1 State (org.apache.gobblin.configuration.State)1 WorkUnitState (org.apache.gobblin.configuration.WorkUnitState)1 WorkingState (org.apache.gobblin.configuration.WorkUnitState.WorkingState)1