public Config getConfig(String configKeyStr, Optional<Config> runtimeConfig) throws ConfigStoreFactoryDoesNotExistsException, ConfigStoreCreationException, VersionDoesNotExistException, URISyntaxException { return this.getConfig(new URI(configKeyStr), runtimeConfig); }
/** * Convenient method to get resolved {@link Config} based on String input. */ public Config getConfig(String configKeyStr) throws ConfigStoreFactoryDoesNotExistsException, ConfigStoreCreationException, VersionDoesNotExistException, URISyntaxException { return getConfig(configKeyStr, Optional.<Config>absent()); }
/** * Wrapper to convert Checked Exception to Unchecked Exception * Easy to use in lambda expressions */ public static Config getConfig(ConfigClient client, URI u, Optional<Config> runtimeConfig) { try { return client.getConfig(u, runtimeConfig); } catch (ConfigStoreFactoryDoesNotExistsException | ConfigStoreCreationException e) { throw new Error(e); } }
/** * Get the resolved {@link Config} based on the input URI. * * @param configKeyUri - The URI for the configuration key. There are two types of URI: * * 1. URI missing authority and configuration store root , for example "etl-hdfs:///datasets/a1/a2". It will get * the configuration based on the default {@link ConfigStore} in etl-hdfs {@link ConfigStoreFactory} * 2. Complete URI: for example "etl-hdfs://eat1-nertznn01.grid.linkedin.com:9000/user/mitu/HdfsBasedConfigTest/" * * @return the resolved {@link Config} based on the input URI. * * @throws ConfigStoreFactoryDoesNotExistsException: if missing scheme name or the scheme name is invalid * @throws ConfigStoreCreationException: Specified {@link ConfigStoreFactory} can not create required {@link ConfigStore} * @throws VersionDoesNotExistException: Required version does not exist anymore ( may get deleted by retention job ) */ public Config getConfig(URI configKeyUri) throws ConfigStoreFactoryDoesNotExistsException, ConfigStoreCreationException, VersionDoesNotExistException { return getConfig(configKeyUri, Optional.<Config>absent()); }
@Override public Void call() throws Exception { // Process each {@link Config}, find dataset and add those into the datasets Config c = confClient.getConfig(u); Dataset datasetForConfig = new ConfigurableCleanableDataset(fileSystem, p, new Path(c.getString(DATASET_PATH)), c, log); datasets.add(datasetForConfig); return null; } };
@Override public ConfigurableCleanableDataset<FileSystemDatasetVersion> datasetAtPath(Path path) throws IOException { try { return new ConfigurableCleanableDataset<>(this.fs, this.props, path, this.client .getConfig(this.props.getProperty(ConfigurationKeys.CONFIG_MANAGEMENT_STORE_URI) + path.toString()), LoggerFactory.getLogger(ConfigurableCleanableDataset.class)); } catch (VersionDoesNotExistException | ConfigStoreFactoryDoesNotExistsException | ConfigStoreCreationException | URISyntaxException e) { throw new IllegalArgumentException(e); } } }
@Override public Void call() throws Exception { // Process each {@link Config}, find dataset and add those into the datasets Config c = confClient.getConfig(u); List<Dataset> datasetForConfig = new ConfigBasedMultiDatasets(c, p, blacklistPatterns).getConfigBasedDatasetList(); datasets.addAll(datasetForConfig); return null; } };
@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); } }
datasetConfig = this.configClient.getConfig( this.configStoreUri.get() + Path.SEPARATOR + this.configStoreDatasetUriBuilder.apply(table), runtimeConfig); } else { datasetConfig = this.configClient.getConfig( this.configStoreUri.get() + Path.SEPARATOR + this.configStoreDatasetUriBuilder.apply(table));
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; }
when(client.getConfig(any(String.class))).thenReturn(testConfig); Properties jobProps = new Properties(); jobProps.setProperty(CleanableDatasetBase.SKIP_TRASH_KEY, Boolean.toString(true));
Config datasetClassConfig = client.getConfig(importedBy);
@Override public void run(String[] args) throws Exception { CliObjectFactory<Command> factory = new ConstructorAndPublicMethodsCliObjectFactory<>(Command.class); Command command = factory.buildObject(args, 1, true, args[0]); ConfigClient configClient = ConfigClient.createConfigClient(VersionStabilityPolicy.READ_FRESHEST); if (command.resolvedConfig) { Config resolvedConfig = configClient.getConfig(command.uri); System.out.println(resolvedConfig.root().render(ConfigRenderOptions.defaults())); } }
/** * Wrapper to convert Checked Exception to Unchecked Exception * Easy to use in lambda expressions */ public static Config getConfig(ConfigClient client, URI u, Optional<Config> runtimeConfig) { try { return client.getConfig(u, runtimeConfig); } catch (ConfigStoreFactoryDoesNotExistsException | ConfigStoreCreationException e) { throw new Error(e); } }
/** * Convenient method to get resolved {@link Config} based on String input. */ public Config getConfig(String configKeyStr) throws ConfigStoreFactoryDoesNotExistsException, ConfigStoreCreationException, VersionDoesNotExistException, URISyntaxException { return getConfig(configKeyStr, Optional.<Config>absent()); }
public Config getConfig(String configKeyStr, Optional<Config> runtimeConfig) throws ConfigStoreFactoryDoesNotExistsException, ConfigStoreCreationException, VersionDoesNotExistException, URISyntaxException { return this.getConfig(new URI(configKeyStr), runtimeConfig); }
@Override public ConfigurableCleanableDataset<FileSystemDatasetVersion> datasetAtPath(Path path) throws IOException { try { return new ConfigurableCleanableDataset<>(this.fs, this.props, path, this.client .getConfig(this.props.getProperty(ConfigurationKeys.CONFIG_MANAGEMENT_STORE_URI) + path.toString()), LoggerFactory.getLogger(ConfigurableCleanableDataset.class)); } catch (VersionDoesNotExistException | ConfigStoreFactoryDoesNotExistsException | ConfigStoreCreationException | URISyntaxException e) { throw new IllegalArgumentException(e); } } }
@Override public Void call() throws Exception { // Process each {@link Config}, find dataset and add those into the datasets Config c = confClient.getConfig(u); Dataset datasetForConfig = new ConfigurableCleanableDataset(fileSystem, p, new Path(c.getString(DATASET_PATH)), c, log); datasets.add(datasetForConfig); return null; } };
@Override public Void call() throws Exception { // Process each {@link Config}, find dataset and add those into the datasets Config c = confClient.getConfig(u); List<Dataset> datasetForConfig = new ConfigBasedMultiDatasets(c, p, blacklistPatterns).getConfigBasedDatasetList(); datasets.addAll(datasetForConfig); return null; } };