org.apache.commons.configuration.ConfigurationConverter Java Examples
The following examples show how to use
org.apache.commons.configuration.ConfigurationConverter.
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: AtlasPamAuthenticationProvider.java From incubator-atlas with Apache License 2.0 | 6 votes |
private void setPamProperties() { try { this.groupsFromUGI = ApplicationProperties.get().getBoolean("atlas.authentication.method.pam.ugi-groups", true); Properties properties = ConfigurationConverter.getProperties(ApplicationProperties.get() .subset("atlas.authentication.method.pam")); for (String key : properties.stringPropertyNames()) { String value = properties.getProperty(key); options.put(key, value); } if (!options.containsKey("service")) { options.put("service", "atlas-login"); } } catch (Exception e) { LOG.error("Exception while setLdapProperties", e); } }
Example #2
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 #3
Source File: BaseTestCase.java From arangodb-tinkerpop-provider with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { // host name and port see: arangodb.properties PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.setProperty("arangodb.hosts", "127.0.0.1:8529"); configuration.setProperty("arangodb.user", "gremlin"); configuration.setProperty("arangodb.password", "gremlin"); Properties arangoProperties = ConfigurationConverter.getProperties(configuration); client = new ArangoDBGraphClient(null, arangoProperties, "tinkerpop", 30000, true); client.deleteGraph(graphName); client.deleteCollection(vertices); client.deleteCollection(edges); }
Example #4
Source File: SchedulerDaemon.java From incubator-gobblin with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { if (args.length < 1 || args.length > 2) { System.err.println( "Usage: SchedulerDaemon <default configuration properties file> [custom configuration properties file]"); System.exit(1); } // Load default framework configuration properties Properties defaultProperties = ConfigurationConverter.getProperties(new PropertiesConfiguration(args[0])); // Load custom framework configuration properties (if any) Properties customProperties = new Properties(); if (args.length == 2) { customProperties.putAll(ConfigurationConverter.getProperties(new PropertiesConfiguration(args[1]))); } log.debug("Scheduler Daemon::main starting with defaultProperties: {}, customProperties: {}", defaultProperties, customProperties); // Start the scheduler daemon new SchedulerDaemon(defaultProperties, customProperties).start(); }
Example #5
Source File: PullFileLoader.java From incubator-gobblin with Apache License 2.0 | 6 votes |
/** * Load a {@link Properties} compatible path using fallback as fallback. * @return The {@link Config} in path with fallback as fallback. * @throws IOException */ private Config loadJavaPropsWithFallback(Path propertiesPath, Config fallback) throws IOException { PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(); try (InputStreamReader inputStreamReader = new InputStreamReader(this.fs.open(propertiesPath), Charsets.UTF_8)) { propertiesConfiguration.setDelimiterParsingDisabled(ConfigUtils.getBoolean(fallback, PROPERTY_DELIMITER_PARSING_ENABLED_KEY, DEFAULT_PROPERTY_DELIMITER_PARSING_ENABLED_KEY)); propertiesConfiguration.load(inputStreamReader); Config configFromProps = ConfigUtils.propertiesToConfig(ConfigurationConverter.getProperties(propertiesConfiguration)); return ConfigFactory.parseMap(ImmutableMap.of(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY, PathUtils.getPathWithoutSchemeAndAuthority(propertiesPath).toString())) .withFallback(configFromProps) .withFallback(fallback); } catch (ConfigurationException ce) { throw new IOException(ce); } }
Example #6
Source File: DaoSpringModuleConfig.java From herd with Apache License 2.0 | 6 votes |
/** * The database supplied property sources placeholder configurer that allows access to externalized properties from a database. This method also adds a new * property source that contains the database properties to the environment. * * @return the property sources placeholder configurer. */ @Bean public static PropertySourcesPlaceholderConfigurer databasePropertySourcesPlaceholderConfigurer() { // Get the configurable environment and add a new property source to it that contains the database properties. // That way, the properties can be accessed via the environment or via an injected @Value annotation. // We are adding this property source last so other property sources (e.g. system properties, environment variables) can be used // to override the database properties. Environment environment = ApplicationContextHolder.getApplicationContext().getEnvironment(); if (environment instanceof ConfigurableEnvironment) { ConfigurableEnvironment configurableEnvironment = (ConfigurableEnvironment) environment; ReloadablePropertySource reloadablePropertySource = new ReloadablePropertySource(ReloadablePropertySource.class.getName(), ConfigurationConverter.getProperties(getPropertyDatabaseConfiguration()), getPropertyDatabaseConfiguration()); configurableEnvironment.getPropertySources().addLast(reloadablePropertySource); } return new PropertySourcesPlaceholderConfigurer(); }
Example #7
Source File: AtlasPamAuthenticationProvider.java From atlas with Apache License 2.0 | 6 votes |
private void setPamProperties() { try { this.groupsFromUGI = ApplicationProperties.get().getBoolean("atlas.authentication.method.pam.ugi-groups", true); Properties properties = ConfigurationConverter.getProperties(ApplicationProperties.get() .subset("atlas.authentication.method.pam")); for (String key : properties.stringPropertyNames()) { String value = properties.getProperty(key); options.put(key, value); } if (!options.containsKey("service")) { options.put("service", "atlas-login"); } if(LOG.isDebugEnabled()) { LOG.debug("AtlasPAMAuthenticationProvider{groupsFromUGI= "+ groupsFromUGI +'\'' + ", options=" + options + '}'); } } catch (Exception e) { LOG.error("Exception while setLdapProperties", e); } }
Example #8
Source File: KafkaNotification.java From incubator-atlas with Apache License 2.0 | 5 votes |
/** * Construct a KafkaNotification. * * @param applicationProperties the application properties used to configure Kafka * * @throws AtlasException if the notification interface can not be created */ @Inject public KafkaNotification(Configuration applicationProperties) throws AtlasException { super(applicationProperties); Configuration subsetConfiguration = ApplicationProperties.getSubsetConfiguration(applicationProperties, PROPERTY_PREFIX); properties = ConfigurationConverter.getProperties(subsetConfiguration); //override to store offset in kafka //todo do we need ability to replay? //Override default configs properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer"); properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer"); properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer"); properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer"); properties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"); pollTimeOutMs = subsetConfiguration.getLong("poll.timeout.ms", 1000); boolean oldApiCommitEnbleFlag = subsetConfiguration.getBoolean("auto.commit.enable",false); //set old autocommit value if new autoCommit property is not set. properties.put("enable.auto.commit", subsetConfiguration.getBoolean("enable.auto.commit", oldApiCommitEnbleFlag)); properties.put("session.timeout.ms", subsetConfiguration.getString("session.timeout.ms", "30000")); }
Example #9
Source File: AtlasLdapAuthenticationProvider.java From atlas with Apache License 2.0 | 5 votes |
private void setLdapProperties() { try { Configuration configuration = ApplicationProperties.get(); Properties properties = ConfigurationConverter.getProperties(configuration.subset("atlas.authentication.method.ldap")); ldapURL = properties.getProperty("url"); ldapUserDNPattern = properties.getProperty("userDNpattern"); ldapGroupSearchBase = properties.getProperty("groupSearchBase"); ldapGroupSearchFilter = properties.getProperty("groupSearchFilter"); ldapGroupRoleAttribute = properties.getProperty("groupRoleAttribute"); ldapBindDN = properties.getProperty("bind.dn"); ldapBindPassword = properties.getProperty("bind.password"); ldapDefaultRole = properties.getProperty("default.role"); ldapUserSearchFilter = properties.getProperty("user.searchfilter"); ldapReferral = properties.getProperty("referral"); ldapBase = properties.getProperty("base.dn"); groupsFromUGI = configuration.getBoolean("atlas.authentication.method.ldap.ugi-groups", true); if(LOG.isDebugEnabled()) { LOG.debug("AtlasLdapAuthenticationProvider{" + "ldapURL='" + ldapURL + '\'' + ", ldapUserDNPattern='" + ldapUserDNPattern + '\'' + ", ldapGroupSearchBase='" + ldapGroupSearchBase + '\'' + ", ldapGroupSearchFilter='" + ldapGroupSearchFilter + '\'' + ", ldapGroupRoleAttribute='" + ldapGroupRoleAttribute + '\'' + ", ldapBindDN='" + ldapBindDN + '\'' + ", ldapDefaultRole='" + ldapDefaultRole + '\'' + ", ldapUserSearchFilter='" + ldapUserSearchFilter + '\'' + ", ldapReferral='" + ldapReferral + '\'' + ", ldapBase='" + ldapBase + '\'' + ", groupsFromUGI=" + groupsFromUGI + '}'); } } catch (Exception e) { LOG.error("Exception while setLdapProperties", e); } }
Example #10
Source File: ClientTest.java From arangodb-tinkerpop-provider with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { configuration = new PropertiesConfiguration(); configuration.setProperty(ArangoDBGraph.PROPERTY_KEY_PREFIX + "." + ArangoDBGraph.PROPERTY_KEY_DB_NAME, "tinkerpop"); configuration.setProperty(ArangoDBGraph.PROPERTY_KEY_PREFIX + "." + ArangoDBGraph.PROPERTY_KEY_GRAPH_NAME, "standard"); configuration.setProperty(ArangoDBGraph.PROPERTY_KEY_PREFIX + "." + "arangodb.hosts", "127.0.0.1:8529"); configuration.setProperty(ArangoDBGraph.PROPERTY_KEY_PREFIX + "." + "arangodb.user", "gremlin"); configuration.setProperty(ArangoDBGraph.PROPERTY_KEY_PREFIX + "." + "arangodb.password", "gremlin"); configuration.setProperty(ArangoDBGraph.PROPERTY_KEY_PREFIX + "." + ArangoDBGraph.PROPERTY_KEY_SHOULD_PREFIX_COLLECTION_NAMES, shouldPrefixCollectionWithGraphName); Properties arangoProperties = ConfigurationConverter.getProperties(configuration); ArangoDBGraph g = new ArangoDBGraph(configuration); System.out.println(g.features()); // client = new ArangoDBGraphClient(g, arangoProperties, "tinkerpop", 30000); }
Example #11
Source File: AstyanaxDaoSchemaProvider.java From staash with Apache License 2.0 | 5 votes |
@Override public synchronized void createSchema() { final Properties props = ConfigurationConverter.getProperties(configuration.subset(String.format(CONFIG_PREFIX_FORMAT, schemaName.toLowerCase()))); try { props.setProperty("name", props.getProperty("keyspace")); LOG.info("Creating schema: " + schemaName + " " + props); this.keyspace.createKeyspace(props); } catch (ConnectionException e) { LOG.error("Failed to create schema '{}' with properties '{}'", new Object[]{schemaName, props.toString(), e}); throw new RuntimeException("Failed to create keyspace " + keyspace.getKeyspaceName(), e); } }
Example #12
Source File: PinotInstanceStatus.java From incubator-pinot with Apache License 2.0 | 5 votes |
public PinotInstanceStatus(ServiceRole serviceRole, String instanceId, Configuration config, ServiceStatus.Status serviceStatus, String statusDescription) { _serviceRole = serviceRole; _instanceId = instanceId; _config = ConfigurationConverter.getMap(config); _serviceStatus = serviceStatus; _statusDescription = statusDescription; }
Example #13
Source File: AtlasAuthenticationFilter.java From atlas with Apache License 2.0 | 5 votes |
private org.apache.hadoop.conf.Configuration getProxyuserConfiguration() { org.apache.hadoop.conf.Configuration ret = new org.apache.hadoop.conf.Configuration(false); if(configuration!=null) { Properties props = ConfigurationConverter.getProperties(configuration.subset(CONF_PROXYUSER_PREFIX)); for (String key : props.stringPropertyNames()) { ret.set(CONF_PROXYUSER_PREFIX + "." + key, props.getProperty(key)); } } return ret; }
Example #14
Source File: InMemoryJAASConfiguration.java From atlas with Apache License 2.0 | 5 votes |
public static void init(org.apache.commons.configuration.Configuration atlasConfiguration) throws AtlasException { LOG.debug("==> InMemoryJAASConfiguration.init()"); if (atlasConfiguration != null && !atlasConfiguration.isEmpty()) { Properties properties = ConfigurationConverter.getProperties(atlasConfiguration); init(properties); } else { throw new AtlasException("Failed to load JAAS application properties: configuration NULL or empty!"); } LOG.debug("<== InMemoryJAASConfiguration.init()"); }
Example #15
Source File: JobConfigurationUtils.java From incubator-gobblin with Apache License 2.0 | 5 votes |
/** * Load the properties from the specified file into a {@link Properties} object. * * @param fileName the name of the file to load properties from * @param conf configuration object to determine the file system to be used * @return a new {@link Properties} instance */ public static Properties fileToProperties(String fileName, Configuration conf) throws IOException, ConfigurationException { PropertiesConfiguration propsConfig = new PropertiesConfiguration(); Path filePath = new Path(fileName); URI fileURI = filePath.toUri(); if (fileURI.getScheme() == null && fileURI.getAuthority() == null) { propsConfig.load(FileSystem.getLocal(conf).open(filePath)); } else { propsConfig.load(filePath.getFileSystem(conf).open(filePath)); } return ConfigurationConverter.getProperties(propsConfig); }
Example #16
Source File: EmbeddedKafkaServer.java From atlas with Apache License 2.0 | 5 votes |
@Inject public EmbeddedKafkaServer(Configuration applicationProperties) throws AtlasException { Configuration kafkaConf = ApplicationProperties.getSubsetConfiguration(applicationProperties, PROPERTY_PREFIX); this.isEmbedded = applicationProperties.getBoolean(PROPERTY_EMBEDDED, false); this.properties = ConfigurationConverter.getProperties(kafkaConf); }
Example #17
Source File: InMemoryJAASConfiguration.java From incubator-atlas with Apache License 2.0 | 5 votes |
public static void init(org.apache.commons.configuration.Configuration atlasConfiguration) throws AtlasException { LOG.debug("==> InMemoryJAASConfiguration.init()"); if (atlasConfiguration != null && !atlasConfiguration.isEmpty()) { Properties properties = ConfigurationConverter.getProperties(atlasConfiguration); init(properties); } else { throw new AtlasException("Failed to load JAAS application properties: configuration NULL or empty!"); } LOG.debug("<== InMemoryJAASConfiguration.init()"); }
Example #18
Source File: AtlasADAuthenticationProvider.java From atlas with Apache License 2.0 | 5 votes |
private void setADProperties() { try { Configuration configuration = ApplicationProperties.get(); Properties properties = ConfigurationConverter.getProperties(configuration.subset("atlas.authentication.method.ldap.ad")); this.adDomain = properties.getProperty("domain"); this.adURL = properties.getProperty("url"); this.adBindDN = properties.getProperty("bind.dn"); this.adBindPassword = properties.getProperty("bind.password"); this.adUserSearchFilter = properties.getProperty("user.searchfilter"); if (adUserSearchFilter==null || adUserSearchFilter.trim().isEmpty()) { adUserSearchFilter="(sAMAccountName={0})"; } this.adBase = properties.getProperty("base.dn"); this.adReferral = properties.getProperty("referral"); this.adDefaultRole = properties.getProperty("default.role"); this.groupsFromUGI = configuration.getBoolean("atlas.authentication.method.ldap.ugi-groups", true); if(LOG.isDebugEnabled()) { LOG.debug("AtlasADAuthenticationProvider{" + "adURL='" + adURL + '\'' + ", adDomain='" + adDomain + '\'' + ", adBindDN='" + adBindDN + '\'' + ", adUserSearchFilter='" + adUserSearchFilter + '\'' + ", adBase='" + adBase + '\'' + ", adReferral='" + adReferral + '\'' + ", adDefaultRole='" + adDefaultRole + '\'' + ", groupsFromUGI=" + groupsFromUGI + '}'); } } catch (Exception e) { LOG.error("Exception while setADProperties", e); } }
Example #19
Source File: AtlasLdapAuthenticationProvider.java From incubator-atlas with Apache License 2.0 | 5 votes |
private void setLdapProperties() { try { Configuration configuration = ApplicationProperties.get(); Properties properties = ConfigurationConverter.getProperties(configuration.subset("atlas.authentication.method.ldap")); ldapURL = properties.getProperty("url"); ldapUserDNPattern = properties.getProperty("userDNpattern"); ldapGroupSearchBase = properties.getProperty("groupSearchBase"); ldapGroupSearchFilter = properties.getProperty("groupSearchFilter"); ldapGroupRoleAttribute = properties.getProperty("groupRoleAttribute"); ldapBindDN = properties.getProperty("bind.dn"); ldapBindPassword = properties.getProperty("bind.password"); ldapDefaultRole = properties.getProperty("default.role"); ldapUserSearchFilter = properties.getProperty("user.searchfilter"); ldapReferral = properties.getProperty("referral"); ldapBase = properties.getProperty("base.dn"); groupsFromUGI = configuration.getBoolean("atlas.authentication.method.ldap.ugi-groups", true); if(LOG.isDebugEnabled()) { LOG.debug("AtlasLdapAuthenticationProvider{" + "ldapURL='" + ldapURL + '\'' + ", ldapUserDNPattern='" + ldapUserDNPattern + '\'' + ", ldapGroupSearchBase='" + ldapGroupSearchBase + '\'' + ", ldapGroupSearchFilter='" + ldapGroupSearchFilter + '\'' + ", ldapGroupRoleAttribute='" + ldapGroupRoleAttribute + '\'' + ", ldapBindDN='" + ldapBindDN + '\'' + ", ldapDefaultRole='" + ldapDefaultRole + '\'' + ", ldapUserSearchFilter='" + ldapUserSearchFilter + '\'' + ", ldapReferral='" + ldapReferral + '\'' + ", ldapBase='" + ldapBase + '\'' + ", groupsFromUGI=" + groupsFromUGI + '}'); } } catch (Exception e) { LOG.error("Exception while setLdapProperties", e); } }
Example #20
Source File: AtlasADAuthenticationProvider.java From incubator-atlas with Apache License 2.0 | 5 votes |
private void setADProperties() { try { Configuration configuration = ApplicationProperties.get(); Properties properties = ConfigurationConverter.getProperties(configuration.subset("atlas.authentication.method.ldap.ad")); this.adDomain = properties.getProperty("domain"); this.adURL = properties.getProperty("url"); this.adBindDN = properties.getProperty("bind.dn"); this.adBindPassword = properties.getProperty("bind.password"); this.adUserSearchFilter = properties.getProperty("user.searchfilter"); this.adBase = properties.getProperty("base.dn"); this.adReferral = properties.getProperty("referral"); this.adDefaultRole = properties.getProperty("default.role"); this.groupsFromUGI = configuration.getBoolean("atlas.authentication.method.ldap.ugi-groups", true); if(LOG.isDebugEnabled()) { LOG.debug("AtlasADAuthenticationProvider{" + "adURL='" + adURL + '\'' + ", adDomain='" + adDomain + '\'' + ", adBindDN='" + adBindDN + '\'' + ", adUserSearchFilter='" + adUserSearchFilter + '\'' + ", adBase='" + adBase + '\'' + ", adReferral='" + adReferral + '\'' + ", adDefaultRole='" + adDefaultRole + '\'' + ", groupsFromUGI=" + groupsFromUGI + '}'); } } catch (Exception e) { LOG.error("Exception while setADProperties", e); } }
Example #21
Source File: QAFInetrceptableDataProvider.java From qaf with MIT License | 5 votes |
private static String getConfigParameters(String key){ if(getBundle().containsKey(key) || !getBundle().subset(key).isEmpty()){ org.apache.commons.configuration.Configuration config = getBundle().subset(key); if(config.isEmpty()){ return getBundle().getString(key); } return new JSONObject(ConfigurationConverter.getMap(config)).toString(); } return ""; }
Example #22
Source File: AtlasAuthenticationFilter.java From incubator-atlas with Apache License 2.0 | 4 votes |
/** * Initialize the filter. * * @param filterConfig filter configuration. * @throws ServletException thrown if the filter could not be initialized. */ @Override public void init(FilterConfig filterConfig) throws ServletException { LOG.info("AtlasAuthenticationFilter initialization started"); final FilterConfig globalConf = filterConfig; final Map<String, String> params = new HashMap<>(); try { configuration = ApplicationProperties.get(); } catch (Exception e) { throw new ServletException(e); } if (configuration != null) { headerProperties = ConfigurationConverter.getProperties(configuration.subset("atlas.headers")); } FilterConfig filterConfig1 = new FilterConfig() { @Override public ServletContext getServletContext() { if (globalConf != null) { return globalConf.getServletContext(); } else { return nullContext; } } @SuppressWarnings("unchecked") @Override public Enumeration<String> getInitParameterNames() { return new IteratorEnumeration(params.keySet().iterator()); } @Override public String getInitParameter(String param) { return params.get(param); } @Override public String getFilterName() { return "AtlasAuthenticationFilter"; } }; super.init(filterConfig1); optionsServlet = new HttpServlet() { }; optionsServlet.init(); }
Example #23
Source File: CommonsConfigurationFactoryBean.java From telekom-workflow-engine with MIT License | 4 votes |
/** * @see org.springframework.beans.factory.FactoryBean#getObject() */ public java.util.Properties getObject() throws Exception { return (configuration != null) ? ConfigurationConverter.getProperties(configuration) : null; }
Example #24
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; }
Example #25
Source File: ReloadablePropertySource.java From herd with Apache License 2.0 | 4 votes |
/** * Refreshes the properties from the configuration if it's time to. */ @SuppressWarnings({"unchecked", "rawtypes"}) protected void refreshPropertiesIfNeeded() { // Ensure we update the properties in a synchronized fashion to avoid possibly corrupting the properties. synchronized (this) { // See if it's time to refresh the properties (i.e. the elapsed time is greater than the configured refresh interval). LOGGER.debug("Checking if properties need to be refreshed. currentTime={} lastRefreshTime={} millisecondsSinceLastPropertiesRefresh={}", System.currentTimeMillis(), lastRefreshTime, System.currentTimeMillis() - lastRefreshTime); if (System.currentTimeMillis() - lastRefreshTime >= refreshIntervalMillis) { // Enough time has passed so refresh the properties. LOGGER.debug("Refreshing properties..."); // Get the latest properties from the configuration. Properties properties = ConfigurationConverter.getProperties(configuration); if (lastConfigurationErrorEvent != null) { LOGGER.error("An error occurred while retrieving configurations. Previous values are retained. See cause for details.", lastConfigurationErrorEvent.getCause()); lastConfigurationErrorEvent = null; } else { // Log the properties we just retrieved from the configuration. if (LOGGER.isDebugEnabled()) { LOGGER.debug("New properties just retrieved."); for (Map.Entry<Object, Object> entry : properties.entrySet()) { LOGGER.debug("{}=\"{}\"", entry.getKey(), entry.getValue()); } } // Update our property sources properties with the ones just read by clearing and adding in the new ones since the "source" is final. this.source.clear(); this.source.putAll((Map) properties); // Log the properties we have in our property source. if (LOGGER.isDebugEnabled()) { LOGGER.debug("Updated reloadable properties."); for (Object key : source.keySet()) { LOGGER.debug("{}=\"{}\"", key, properties.get(key)); } } } // Update the last refresh time and refresh interval. updateLastRefreshTime(); updateRefreshInterval(); LOGGER.debug("The properties have been refreshed from the configuration."); } } }
Example #26
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 #27
Source File: QAFTestNGListener2.java From qaf with MIT License | 4 votes |
@SuppressWarnings("unchecked") private void deployResult(ITestResult tr) { try { if (ResultUpdator.getResultUpdatorsCnt()>0 && (tr.getMethod() instanceof TestNGScenario) && ((tr.getStatus() == ITestResult.FAILURE) || (tr.getStatus() == ITestResult.SUCCESS || tr.getStatus() == ITestResult.SKIP))) { TestCaseRunResult.Status status = tr.getStatus() == ITestResult.SUCCESS ? TestCaseRunResult.Status.PASS : tr.getStatus() == ITestResult.FAILURE ? TestCaseRunResult.Status.FAIL : TestCaseRunResult.Status.SKIPPED; TestNGScenario scenario = (TestNGScenario) tr.getMethod(); Map<String, Object> params = new HashMap<String, Object>(scenario.getMetaData()); params.put("duration", tr.getEndMillis() - tr.getStartMillis()); Map<String, Object> executionInfo = new HashMap<String, Object>(); executionInfo.put("testName", tr.getTestContext().getCurrentXmlTest().getName()); executionInfo.put("suiteName", tr.getTestContext().getSuite().getName()); Map<String, Object> runPrams = new HashMap<String, Object>( tr.getTestContext().getCurrentXmlTest().getAllParameters()); runPrams.putAll(ConfigurationConverter.getMap(getBundle().subset("env"))); executionInfo.put("env", runPrams); int retryCount = getBundle().getInt(RetryAnalyzer.RETRY_INVOCATION_COUNT, 0); boolean willRetry = getBundle().getBoolean(RetryAnalyzer.WILL_RETRY, false); getBundle().clearProperty(RetryAnalyzer.WILL_RETRY); if(retryCount>0) { executionInfo.put("retryCount", retryCount); } TestCaseRunResult testCaseRunResult = new TestCaseRunResult(status, scenario.getMetaData(), tr.getParameters(), executionInfo, scenario.getSteps(), tr.getStartMillis(),willRetry,scenario.isTest() ); testCaseRunResult.setClassName(scenario.getClassOrFileName()); if (scenario.getGroups() != null && scenario.getGroups().length > 0) { testCaseRunResult.getMetaData().put("groups", scenario.getGroups()); } testCaseRunResult.getMetaData().put("description",scenario.getDescription()); testCaseRunResult.setThrowable(tr.getThrowable()); ResultUpdator.updateResult(testCaseRunResult); } } catch (Exception e) { logger.warn("Unable to deploy result", e); } }
Example #28
Source File: KafkaNotification.java From atlas with Apache License 2.0 | 4 votes |
/** * Construct a KafkaNotification. * * @param applicationProperties the application properties used to configure Kafka * * @throws AtlasException if the notification interface can not be created */ @Inject public KafkaNotification(Configuration applicationProperties) throws AtlasException { super(applicationProperties); LOG.info("==> KafkaNotification()"); Configuration kafkaConf = ApplicationProperties.getSubsetConfiguration(applicationProperties, PROPERTY_PREFIX); properties = ConfigurationConverter.getProperties(kafkaConf); pollTimeOutMs = kafkaConf.getLong("poll.timeout.ms", 1000); consumerClosedErrorMsg = kafkaConf.getString("error.message.consumer_closed", DEFAULT_CONSUMER_CLOSED_ERROR_MESSAGE); //Override default configs properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer"); properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer"); properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer"); properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer"); properties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"); boolean oldApiCommitEnableFlag = kafkaConf.getBoolean("auto.commit.enable", false); //set old autocommit value if new autoCommit property is not set. properties.put("enable.auto.commit", kafkaConf.getBoolean("enable.auto.commit", oldApiCommitEnableFlag)); properties.put("session.timeout.ms", kafkaConf.getString("session.timeout.ms", "30000")); if(applicationProperties.getBoolean(TLS_ENABLED, false)) { try { properties.put("ssl.truststore.password", getPassword(applicationProperties, TRUSTSTORE_PASSWORD_KEY)); } catch (Exception e) { LOG.error("Exception while getpassword truststore.password ", e); } } // if no value is specified for max.poll.records, set to 1 properties.put("max.poll.records", kafkaConf.getInt("max.poll.records", 1)); setKafkaJAASProperties(applicationProperties, properties); LOG.info("<== KafkaNotification()"); }