Java Code Examples for org.apache.commons.configuration.Configuration#subset()
The following examples show how to use
org.apache.commons.configuration.Configuration#subset() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpsSegmentFetcher.java From incubator-pinot with Apache License 2.0 | 6 votes |
@Override protected void doInit(Configuration config) { Configuration sslConfig = config.subset(CommonConstants.PREFIX_OF_SSL_SUBSET); _logger.info("Initializing with the following ssl config:"); Set<String> protectedConfigKeys = ClientSSLContextGenerator.getProtectedConfigKeys(); @SuppressWarnings("unchecked") Iterator<String> iterator = sslConfig.getKeys(); while (iterator.hasNext()) { String configKey = iterator.next(); if (protectedConfigKeys.contains(configKey)) { _logger.info("{}: {}", configKey, "********"); } else { _logger.info("{}: {}", configKey, config.getString(configKey)); } } SSLContext sslContext = new ClientSSLContextGenerator(sslConfig).generate(); _httpClient = new FileUploadDownloadClient(sslContext); }
Example 2
Source File: ConfigurableIngestTopologyTest.java From cognition with Apache License 2.0 | 6 votes |
@Test public void testConfigureSpout( @Injectable TopologyBuilder builder, @Injectable Configuration spout, @Injectable Configuration spoutConf, @Injectable StormParallelismConfig stormParallelismConfig, @Injectable IRichSpout spoutComponent) throws Exception { String spoutType = "spout-class"; new Expectations(topology) {{ spout.getString(TYPE); result = spoutType; spout.subset(CONF); result = spoutConf; topology.getStormParallelismConfig(spoutConf); result = stormParallelismConfig; topology.buildComponent(spoutType, spoutConf); result = spoutComponent; }}; assertThat(topology.configureSpout(builder, spout), is(spoutType)); }
Example 3
Source File: JobHandler.java From proarc with GNU General Public License v3.0 | 6 votes |
public void init(AppConfiguration appConfig) throws SchedulerException { this.appconfig = appConfig; Configuration jobsConfig = appConfig.getJobCofig(); loadDevices(jobsConfig); scheduler.clear(); //job.list for (String jobId : jobsConfig.getStringArray(JOBS_LIST)) { Configuration jobConfig = jobsConfig.subset(jobId); for (ProArcJob job : getJobs()) { //job.name.type if (job.getType().equals(jobConfig.getString(JOB_TYPE))) { job.initJob(scheduler, jobId, jobConfig); } } } }
Example 4
Source File: ArangoDBGraphProvider.java From arangodb-tinkerpop-provider with Apache License 2.0 | 6 votes |
@Override public void clear(Graph graph, Configuration configuration) throws Exception { ArangoDBGraphClient client; if (graph ==null) { Configuration arangoConfig = configuration.subset(ArangoDBGraph.PROPERTY_KEY_PREFIX); Properties arangoProperties = ConfigurationConverter.getProperties(arangoConfig); client = new ArangoDBGraphClient(null, arangoProperties, "tinkerpop", 0, true); client.deleteGraph(arangoConfig.getString(ArangoDBGraph.PROPERTY_KEY_GRAPH_NAME)); } else { ArangoDBGraph agraph = (ArangoDBGraph) graph; client = agraph.getClient(); client.clear(agraph); agraph.close(); } }
Example 5
Source File: Kramerius4ExportOptions.java From proarc with GNU General Public License v3.0 | 6 votes |
public static Kramerius4ExportOptions from(Configuration config) { Kramerius4ExportOptions options = new Kramerius4ExportOptions(); String[] excludeIds = config.getStringArray(PROP_EXCLUDE_DATASTREAM_ID); options.setExcludeDatastreams(new HashSet<String>(Arrays.asList(excludeIds))); Configuration renames = config.subset(PROP_RENAME_PREFIX); HashMap<String, String> dsIdMap = new HashMap<String, String>(); // use RAW if FULL ds is not available dsIdMap.put(BinaryEditor.RAW_ID, "IMG_FULL"); for (Iterator<String> it = renames.getKeys(); it.hasNext();) { String dsId = it.next(); String newDsId = renames.getString(dsId); dsIdMap.put(dsId, newDsId); } options.setDsIdMap(dsIdMap); String policy = config.getString(PROP_POLICY); if (policy != null && !policy.isEmpty()) { options.setPolicy(policy); } return options; }
Example 6
Source File: LocationResolverBolt.java From cognition with Apache License 2.0 | 6 votes |
@Override public void configure(Configuration conf) throws ConfigurationException { _luceneIndexDir = conf.getString(LUCENE_INDEX_DIR); _localIndexDir = conf.getString(LOCAL_INDEX_DIR); _textFields = conf.getList(TEXT_FIELDS); _pipClavinLocationPrefix = conf.getString(PIP_CLAVIN_LOCATION_PREFIX, "pip.clavinLocation_"); _fieldName = conf.getString(FIELD_NAME, FIELD_NAME); _name = conf.getString(NAME, NAME); _admin1Code = conf.getString(ADMIN1CODE, ADMIN1CODE); _admin2Code = conf.getString(ADMIN2CODE, ADMIN2CODE); _countryCode = conf.getString(COUNTRYCODE, COUNTRYCODE); _latitude = conf.getString(LATITUDE, LATITUDE); _longitude = conf.getString(LONGITUDE, LONGITUDE); _confidence = conf.getString(CONFIDENCE, CONFIDENCE); Configuration hadoopConfigSubset = conf.subset(HADOOP_CONFIG); for (Iterator<String> itr = hadoopConfigSubset.getKeys(); itr.hasNext(); ) { String key = itr.next(); String value = hadoopConfigSubset.getString(key); hadoopConfig.put(key, value); } }
Example 7
Source File: ServerSegmentCompletionProtocolHandler.java From incubator-pinot with Apache License 2.0 | 5 votes |
public static void init(Configuration uploaderConfig) { Configuration httpsConfig = uploaderConfig.subset(HTTPS_PROTOCOL); if (httpsConfig.getBoolean(CONFIG_OF_CONTROLLER_HTTPS_ENABLED, false)) { _sslContext = new ClientSSLContextGenerator(httpsConfig.subset(CommonConstants.PREFIX_OF_SSL_SUBSET)).generate(); _controllerHttpsPort = httpsConfig.getInt(CONFIG_OF_CONTROLLER_HTTPS_PORT); } _segmentUploadRequestTimeoutMs = uploaderConfig.getInt(CONFIG_OF_SEGMENT_UPLOAD_REQUEST_TIMEOUT_MS, DEFAULT_SEGMENT_UPLOAD_REQUEST_TIMEOUT_MS); }
Example 8
Source File: ApplicationPropertiesTest.java From incubator-atlas with Apache License 2.0 | 5 votes |
@Test //variable substitutions should work with subset configuration as well public void testSubset() throws Exception { Configuration configuration = ApplicationProperties.get(ApplicationProperties.APPLICATION_PROPERTIES); Configuration subConfiguration = configuration.subset("atlas"); assertEquals(subConfiguration.getString("service"), "atlas"); String data = System.getProperty("user.dir") + "/target/data"; assertEquals(subConfiguration.getString("data"), data); assertEquals(subConfiguration.getString("graph.data"), data + "/graph"); }
Example 9
Source File: ExternalProcess.java From proarc with GNU General Public License v3.0 | 5 votes |
protected Map<String, String> buildEnv(Configuration conf) { Configuration envConfig = conf.subset(PROP_ENVIRONMENT); Map<String, String> env = new HashMap<String, String>(); for (Iterator<String> it = envConfig.getKeys(); it.hasNext();) { String envKey = it.next(); env.put(envKey, envConfig.getString(envKey)); } return env; }
Example 10
Source File: ConfigurableIngestTopology.java From cognition with Apache License 2.0 | 5 votes |
/** * Gets a topology builder and a storm spout configuration. Initializes the spout and sets it with the topology * builder. * * @param builder * @param spout * @return * @throws ConfigurationException */ String configureSpout(TopologyBuilder builder, Configuration spout) throws ConfigurationException { String spoutType = spout.getString(TYPE); Configuration spoutConf = spout.subset(CONF); StormParallelismConfig parallelismConfig = getStormParallelismConfig(spoutConf); IRichSpout spoutComponent = (IRichSpout) buildComponent(spoutType, spoutConf); builder .setSpout(spoutType, spoutComponent, parallelismConfig.getParallelismHint()) .setNumTasks(parallelismConfig.getNumTasks()); return spoutType; }
Example 11
Source File: CsvHdfsBolt.java From cognition with Apache License 2.0 | 5 votes |
void configureHadoop(Configuration conf) throws ConfigurationException { hadoopConfDirectory = conf.getString(HADOOP_CONF_DIRECTORY); Configuration hadoopConfigSubset = conf.subset(HADOOP_CONFIG); for (Iterator itr = hadoopConfigSubset.getKeys(); itr.hasNext(); ) { String key = (String) itr.next(); String value = hadoopConfigSubset.getString(key); _hadoopConfig.put(key, value); } if (isBlank(hadoopConfDirectory) && _hadoopConfig.isEmpty()) { throw new ConfigurationException( String.format("Missing Hadoop configuration. Configure with either %s or %s.", HADOOP_CONFIG, HADOOP_CONF_DIRECTORY)); } }
Example 12
Source File: TitanGraphDatabase.java From graphdb-benchmarks with Apache License 2.0 | 4 votes |
private static final Configuration generateBaseTitanConfiguration(GraphDatabaseType type, File dbPath, boolean batchLoading, BenchmarkConfiguration bench) { if (!GraphDatabaseType.TITAN_FLAVORS.contains(type)) { throw new IllegalArgumentException("must provide a Titan database type but got " + (type == null ? "null" : type.name())); } if (dbPath == null) { throw new IllegalArgumentException("the dbPath must not be null"); } if (!dbPath.exists() || !dbPath.canWrite() || !dbPath.isDirectory()) { throw new IllegalArgumentException("db path must exist as a directory and must be writeable"); } final Configuration conf = new MapConfiguration(new HashMap<String, String>()); final Configuration storage = conf.subset(GraphDatabaseConfiguration.STORAGE_NS.getName()); final Configuration ids = conf.subset(GraphDatabaseConfiguration.IDS_NS.getName()); final Configuration metrics = conf.subset(GraphDatabaseConfiguration.METRICS_NS.getName()); conf.addProperty(GraphDatabaseConfiguration.ALLOW_SETTING_VERTEX_ID.getName(), "true"); // storage NS config. FYI, storage.idauthority-wait-time is 300ms storage.addProperty(GraphDatabaseConfiguration.STORAGE_BACKEND.getName(), type.getBackend()); storage.addProperty(GraphDatabaseConfiguration.STORAGE_DIRECTORY.getName(), dbPath.getAbsolutePath()); storage.addProperty(GraphDatabaseConfiguration.STORAGE_BATCH.getName(), Boolean.toString(batchLoading)); storage.addProperty(GraphDatabaseConfiguration.BUFFER_SIZE.getName(), bench.getTitanBufferSize()); storage.addProperty(GraphDatabaseConfiguration.PAGE_SIZE.getName(), bench.getTitanPageSize()); // ids NS config ids.addProperty(GraphDatabaseConfiguration.IDS_BLOCK_SIZE.getName(), bench.getTitanIdsBlocksize()); // Titan metrics - https://github.com/thinkaurelius/titan/wiki/Titan-Performance-and-Monitoring metrics.addProperty(GraphDatabaseConfiguration.BASIC_METRICS.getName(), "true"); metrics.addProperty("prefix", type.getShortname()); if(bench.publishGraphiteMetrics()) { final Configuration graphite = metrics.subset(BenchmarkConfiguration.GRAPHITE); graphite.addProperty("hostname", bench.getGraphiteHostname()); graphite.addProperty(BenchmarkConfiguration.CSV_INTERVAL, bench.getCsvReportingInterval()); } if(bench.publishCsvMetrics()) { final Configuration csv = metrics.subset(GraphDatabaseConfiguration.METRICS_CSV_NS.getName()); csv.addProperty(GraphDatabaseConfiguration.METRICS_CSV_DIR.getName(), bench.getCsvDir().getAbsolutePath()); csv.addProperty(BenchmarkConfiguration.CSV_INTERVAL, bench.getCsvReportingInterval()); } return conf; }
Example 13
Source File: ApplicationProperties.java From atlas with Apache License 2.0 | 4 votes |
public static Configuration getSubsetConfiguration(Configuration inConf, String prefix) { return inConf.subset(prefix); }
Example 14
Source File: TitanGraphDatabase.java From graphdb-benchmarks with Apache License 2.0 | 4 votes |
private static final TitanGraph buildTitanGraph(GraphDatabaseType type, File dbPath, BenchmarkConfiguration bench, boolean batchLoading) { final Configuration conf = generateBaseTitanConfiguration(type, dbPath, batchLoading, bench); final Configuration storage = conf.subset(GraphDatabaseConfiguration.STORAGE_NS.getName()); if (GraphDatabaseType.TITAN_CASSANDRA == type) { storage.addProperty("hostname", "localhost"); storage.addProperty("transactions", Boolean.toString(batchLoading)); } else if (GraphDatabaseType.TITAN_CASSANDRA_EMBEDDED == type) { // TODO(amcp) - this line seems broken: // throws: Unknown configuration element in namespace // [root.storage]: cassandra-config-dir storage.addProperty("cassandra-config-dir", "configuration/cassandra.yaml"); storage.addProperty("transactions", Boolean.toString(batchLoading)); } else if (GraphDatabaseType.TITAN_DYNAMODB == type) { final Configuration dynamodb = storage.subset("dynamodb"); final Configuration client = dynamodb.subset(Constants.DYNAMODB_CLIENT_NAMESPACE.getName()); final Configuration credentials = client.subset(Constants.DYNAMODB_CLIENT_CREDENTIALS_NAMESPACE.getName()); storage.addProperty("transactions", Boolean.toString(batchLoading)); if (bench.getDynamodbDataModel() == null) { throw new IllegalArgumentException("data model must be set for dynamodb benchmarking"); } if (GraphDatabaseType.TITAN_DYNAMODB == type && bench.getDynamodbEndpoint() != null && !bench.getDynamodbEndpoint().isEmpty()) { client.addProperty(Constants.DYNAMODB_CLIENT_ENDPOINT.getName(), bench.getDynamodbEndpoint()); client.addProperty(Constants.DYNAMODB_CLIENT_MAX_CONN.getName(), bench.getDynamodbWorkerThreads()); } else { throw new IllegalArgumentException("require endpoint"); } if (bench.getDynamodbCredentialsFqClassName() != null && !bench.getDynamodbCredentialsFqClassName().isEmpty()) { credentials.addProperty(Constants.DYNAMODB_CREDENTIALS_CLASS_NAME.getName(), bench.getDynamodbCredentialsFqClassName()); } if (bench.getDynamodbCredentialsCtorArguments() != null) { credentials.addProperty(Constants.DYNAMODB_CREDENTIALS_CONSTRUCTOR_ARGS.getName(), bench.getDynamodbCredentialsCtorArguments()); } dynamodb.addProperty(Constants.DYNAMODB_FORCE_CONSISTENT_READ.getName(), bench.dynamodbConsistentRead()); Configuration executor = client.subset(Constants.DYNAMODB_CLIENT_EXECUTOR_NAMESPACE.getName()); executor.addProperty(Constants.DYNAMODB_CLIENT_EXECUTOR_CORE_POOL_SIZE.getName(), bench.getDynamodbWorkerThreads()); executor.addProperty(Constants.DYNAMODB_CLIENT_EXECUTOR_MAX_POOL_SIZE.getName(), bench.getDynamodbWorkerThreads()); executor.addProperty(Constants.DYNAMODB_CLIENT_EXECUTOR_KEEP_ALIVE.getName(), TimeUnit.MINUTES.toMillis(1)); executor.addProperty(Constants.DYNAMODB_CLIENT_EXECUTOR_QUEUE_MAX_LENGTH.getName(), bench.getTitanBufferSize()); final long writeTps = bench.getDynamodbTps(); final long readTps = Math.max(1, bench.dynamodbConsistentRead() ? writeTps : writeTps / 2); final Configuration stores = dynamodb.subset(Constants.DYNAMODB_STORES_NAMESPACE.getName()); for (String storeName : Constants.REQUIRED_BACKEND_STORES) { final Configuration store = stores.subset(storeName); store.addProperty(Constants.STORES_DATA_MODEL.getName(), bench.getDynamodbDataModel().name()); store.addProperty(Constants.STORES_CAPACITY_READ.getName(), readTps); store.addProperty(Constants.STORES_CAPACITY_WRITE.getName(), writeTps); store.addProperty(Constants.STORES_READ_RATE_LIMIT.getName(), readTps); store.addProperty(Constants.STORES_WRITE_RATE_LIMIT.getName(), writeTps); } } return TitanFactory.open(conf); }
Example 15
Source File: DesaServices.java From proarc with GNU General Public License v3.0 | 4 votes |
private DesaConfiguration readConfiguration(Configuration config, String serviceId) { String servicePrefix = PREFIX_DESA + '.' + serviceId; Configuration serviceConfig = config.subset(servicePrefix); return new DesaConfiguration(serviceId, servicePrefix, serviceConfig); }
Example 16
Source File: GenericExternalProcess.java From proarc with GNU General Public License v3.0 | 4 votes |
/** * Merges result parameters. {@code onExit} and {@code onSkip} are experimental features. * * @param conf * @param inputParameters * @param skippedProcess * @param exitCode * @param log * @return */ public static ProcessResult getResultParameters(Configuration conf, Map<String, String> inputParameters, boolean skippedProcess, int exitCode, String log) { // gets <processorId>.param.* parameters with interpolated values // it allows to share properties among process and read helper values from process declaration (mime, output file, ...) String processorId = conf.getString("id"); Map<String, String> hm = new HashMap<String, String>(inputParameters); addResultParamaters(conf, processorId, hm); ExitStrategy exit = new ExitStrategy(); if (skippedProcess) { Configuration onSkip = conf.subset("onSkip"); addResultParamaters(onSkip, processorId, hm); exit.setSkip(true); exit.setContinueWithProcessIds(Arrays.asList(onSkip.getStringArray("next"))); return new ProcessResult(processorId, hm, exit); } exit.setExitCode(exitCode); String[] onExitIds = conf.getStringArray("onExits"); Configuration onExitConf = conf.subset("onExit"); boolean defaultExit = true; for (String onExitId : onExitIds) { if (isExitId(onExitId, exitCode)) { Configuration onExitIdConf = onExitConf.subset(onExitId); addResultParamaters(onExitIdConf, processorId, hm); exit.setErrorMessage(onExitIdConf.getString("message")); exit.setStop(onExitIdConf.getBoolean("stop", exitCode != 0)); exit.setContinueWithProcessIds(Arrays.asList(onExitIdConf.getStringArray("next"))); defaultExit = false; break; } } if (defaultExit) { exit.setStop(exitCode != 0); exit.setErrorMessage(log); } return new ProcessResult(processorId, hm, exit); }
Example 17
Source File: ApplicationProperties.java From incubator-atlas with Apache License 2.0 | 4 votes |
public static Configuration getSubsetConfiguration(Configuration inConf, String prefix) { return inConf.subset(prefix); }
Example 18
Source File: ArangoDBGraph.java From arangodb-tinkerpop-provider with Apache License 2.0 | 4 votes |
/** * Creates a Graph (simple configuration). * * @param configuration the Apache Commons configuration */ public ArangoDBGraph(Configuration configuration) { logger.info("Creating new ArangoDB Graph from configuration"); Configuration arangoConfig = configuration.subset(PROPERTY_KEY_PREFIX); vertexCollections = arangoConfig.getList(PROPERTY_KEY_VERTICES).stream() .map(String.class::cast) .collect(Collectors.toList()); edgeCollections = arangoConfig.getList(PROPERTY_KEY_EDGES).stream() .map(String.class::cast) .collect(Collectors.toList()); relations = arangoConfig.getList(PROPERTY_KEY_RELATIONS).stream() .map(String.class::cast) .collect(Collectors.toList()); name = arangoConfig.getString(PROPERTY_KEY_GRAPH_NAME); checkValues(arangoConfig.getString(PROPERTY_KEY_DB_NAME), name, vertexCollections, edgeCollections, relations); if (CollectionUtils.isEmpty(vertexCollections)) { schemaless = true; vertexCollections.add(DEFAULT_VERTEX_COLLECTION); } if (CollectionUtils.isEmpty(edgeCollections)) { edgeCollections.add(DEFAULT_EDGE_COLLECTION); } shouldPrefixCollectionNames = arangoConfig.getBoolean(PROPERTY_KEY_SHOULD_PREFIX_COLLECTION_NAMES, true); Properties arangoProperties = ConfigurationConverter.getProperties(arangoConfig); int batchSize = 0; client = new ArangoDBGraphClient(this, arangoProperties, arangoConfig.getString(PROPERTY_KEY_DB_NAME), batchSize, shouldPrefixCollectionNames); ArangoGraph graph = client.getArangoGraph(); GraphCreateOptions options = new GraphCreateOptions(); // FIXME Cant be in orphan collections because it will be deleted with graph? // options.orphanCollections(GRAPH_VARIABLES_COLLECTION); final List<String> prefVCols = vertexCollections.stream().map(this::getPrefixedCollectioName).collect(Collectors.toList()); final List<String> prefECols = edgeCollections.stream().map(this::getPrefixedCollectioName).collect(Collectors.toList()); final List<EdgeDefinition> edgeDefinitions = new ArrayList<>(); if (relations.isEmpty()) { logger.info("No relations, creating default ones."); edgeDefinitions.addAll(ArangoDBUtil.createDefaultEdgeDefinitions(prefVCols, prefECols)); } else { for (String value : relations) { EdgeDefinition ed = ArangoDBUtil.relationPropertyToEdgeDefinition(this, value); edgeDefinitions.add(ed); } } edgeDefinitions.add(ArangoDBUtil.createPropertyEdgeDefinitions(this, prefVCols, prefECols)); if (graph.exists()) { ArangoDBUtil.checkGraphForErrors(prefVCols, prefECols, edgeDefinitions, graph, options); ArangoDBGraphVariables iter = client.getGraphVariables(); if (iter == null) { throw new ArangoDBGraphException("Existing graph does not have a Variables collection"); } } else { graph = client.createGraph(name, edgeDefinitions, options); this.name = graph.name(); ArangoDBGraphVariables variables = new ArangoDBGraphVariables(name, GRAPH_VARIABLES_COLLECTION, this); client.insertGraphVariables(variables); } this.configuration = configuration; }
Example 19
Source File: KafkaNotification.java From atlas with Apache License 2.0 | 4 votes |
void setKafkaJAASProperties(Configuration configuration, Properties kafkaProperties) { LOG.debug("==> KafkaNotification.setKafkaJAASProperties()"); if(kafkaProperties.containsKey(KAFKA_SASL_JAAS_CONFIG_PROPERTY)) { LOG.debug("JAAS config is already set, returning"); return; } Properties jaasConfig = ApplicationProperties.getSubsetAsProperties(configuration, JAAS_CONFIG_PREFIX_PARAM); // JAAS Configuration is present then update set those properties in sasl.jaas.config if(jaasConfig != null && !jaasConfig.isEmpty()) { String jaasClientName = JAAS_DEFAULT_CLIENT_NAME; // Required for backward compatability for Hive CLI if (!isLoginKeytabBased() && isLoginTicketBased()) { LOG.debug("Checking if ticketBased-KafkaClient is set"); // if ticketBased-KafkaClient property is not specified then use the default client name String ticketBasedConfigPrefix = JAAS_CONFIG_PREFIX_PARAM + "." + JAAS_TICKET_BASED_CLIENT_NAME; Configuration ticketBasedConfig = configuration.subset(ticketBasedConfigPrefix); if(ticketBasedConfig != null && !ticketBasedConfig.isEmpty()) { LOG.debug("ticketBased-KafkaClient JAAS configuration is set, using it"); jaasClientName = JAAS_TICKET_BASED_CLIENT_NAME; } else { LOG.info("UserGroupInformation.isLoginTicketBased is true, but no JAAS configuration found for client {}. Will use JAAS configuration of client {}", JAAS_TICKET_BASED_CLIENT_NAME, jaasClientName); } } String keyPrefix = jaasClientName + "."; String keyParam = keyPrefix + JAAS_CONFIG_LOGIN_MODULE_NAME_PARAM; String loginModuleName = jaasConfig.getProperty(keyParam); if (loginModuleName == null) { LOG.error("Unable to add JAAS configuration for client [{}] as it is missing param [{}]. Skipping JAAS config for [{}]", jaasClientName, keyParam, jaasClientName); return; } keyParam = keyPrefix + JAAS_CONFIG_LOGIN_MODULE_CONTROL_FLAG_PARAM; String controlFlag = jaasConfig.getProperty(keyParam); if(StringUtils.isEmpty(controlFlag)) { String validValues = JAAS_VALID_LOGIN_MODULE_CONTROL_FLAG_OPTIONS; controlFlag = JAAS_DEFAULT_LOGIN_MODULE_CONTROL_FLAG; LOG.warn("Unknown JAAS configuration value for ({}) = [{}], valid value are [{}] using the default value, REQUIRED", keyParam, controlFlag, validValues); } String optionPrefix = keyPrefix + JAAS_CONFIG_LOGIN_OPTIONS_PREFIX + "."; String principalOptionKey = optionPrefix + JAAS_PRINCIPAL_PROP; int optionPrefixLen = optionPrefix.length(); StringBuffer optionStringBuffer = new StringBuffer(); for (String key : jaasConfig.stringPropertyNames()) { if (key.startsWith(optionPrefix)) { String optionVal = jaasConfig.getProperty(key); if (optionVal != null) { optionVal = optionVal.trim(); try { if (key.equalsIgnoreCase(principalOptionKey)) { optionVal = org.apache.hadoop.security.SecurityUtil.getServerPrincipal(optionVal, (String) null); } } catch (IOException e) { LOG.warn("Failed to build serverPrincipal. Using provided value:[{}]", optionVal); } optionVal = surroundWithQuotes(optionVal); optionStringBuffer.append(String.format(" %s=%s", key.substring(optionPrefixLen), optionVal)); } } } String newJaasProperty = String.format("%s %s %s ;", loginModuleName.trim(), controlFlag, optionStringBuffer.toString()); kafkaProperties.put(KAFKA_SASL_JAAS_CONFIG_PROPERTY, newJaasProperty); } LOG.debug("<== KafkaNotification.setKafkaJAASProperties()"); }
Example 20
Source File: ApplicationProperties.java From atlas with Apache License 2.0 | 4 votes |
public static Properties getSubsetAsProperties(Configuration inConf, String prefix) { Configuration subset = inConf.subset(prefix); Properties ret = ConfigurationConverter.getProperties(subset); return ret; }