List of usage examples for org.apache.commons.configuration Configuration subset
Configuration subset(String prefix);
From source file:com.linkedin.pinot.common.segment.fetcher.SegmentFetcherFactory.java
public static void initSegmentFetcherFactory(Configuration pinotHelixProperties) { Configuration segmentFetcherFactoryConfig = pinotHelixProperties .subset(CommonConstants.Server.PREFIX_OF_CONFIG_OF_SEGMENT_FETCHER_FACTORY); Iterator segmentFetcherFactoryConfigIterator = segmentFetcherFactoryConfig.getKeys(); while (segmentFetcherFactoryConfigIterator.hasNext()) { Object configKeyObject = segmentFetcherFactoryConfigIterator.next(); try {/*from ww w . j a v a 2 s.c om*/ String segmentFetcherConfigKey = configKeyObject.toString(); String protocol = segmentFetcherConfigKey.split(".", 2)[0]; if (!SegmentFetcherFactory.containsProtocol(protocol)) { SegmentFetcherFactory .initSegmentFetcher(new ConfigurationMap(segmentFetcherFactoryConfig.subset(protocol))); } } catch (Exception e) { LOGGER.error("Got exception to process the key: " + configKeyObject); } } }
From source file:com.linkedin.pinot.minion.executor.BaseSegmentConversionExecutor.java
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();/*from ww w .j a va2 s.co m*/ } }
From source file:com.gs.obevo.db.apps.reveng.DbMergeInfo.java
public static MutableCollection<DbMergeInfo> parseFromProperties(Configuration config) { Set<String> dbs = new HashSet<String>(config.getList("instances")); MutableList<DbMergeInfo> dbMergeInfos = Lists.mutable.empty(); for (String db : dbs) { Configuration subset = config.subset(db); if (subset.containsKey("inputDir")) { File inputDir = new File(subset.getString("inputDir")); DbMergeInfo mergeInfo = new DbMergeInfo(db, inputDir); if (subset.containsKey("driverClassName")) { mergeInfo.setDriverClassName(subset.getString("driverClassName")); mergeInfo.setUrl(subset.getString("url")); mergeInfo.setUsername(subset.getString("username")); mergeInfo.setPassword(subset.getString("password")); mergeInfo.setPhysicalSchema(subset.getString("physicalSchema")); }//from ww w.ja v a 2 s.c om dbMergeInfos.add(mergeInfo); } } return dbMergeInfos; }
From source file:cn.quickj.Setting.java
private static void createPlugin(Configuration config, String pluginClazz, int i) throws ClassNotFoundException, InstantiationException, IllegalAccessException { Configuration c = config.subset("plugins.plugin(" + i + ")"); Class<?> clazz = Class.forName(pluginClazz); Plugin plugin = (Plugin) clazz.newInstance(); plugin.init(c);/*from w w w. j a va 2s . c o m*/ log.info("?" + plugin.getName() + " id:" + plugin.getId()); plugins.add(plugin); }
From source file:com.knowbout.epg.EPG.java
private static void test(Configuration config) throws IOException { HibernateUtil.openSession();/*from ww w . ja v a2 s. c om*/ Configuration provider = config.subset("provider"); File destinationFolder = new File(provider.getString("destinationFolder")); Configuration files = config.subset("files"); File schedules = new File(destinationFolder, files.getString("schedules")); //Test loading GZIPInputStream uis = new GZIPInputStream(new FileInputStream(schedules)); ScheduleParser SkedParser = new ScheduleParser(); SkedParser.parseSchedule(uis, config); try { EPGProviderService service = new EPGProviderService(); Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, 20); //Test date now. ScheduledProgram sp = service.getScheduledProgramByNetworkCallSign("P-C", "NBC", new Date()); System.err.println("IS SP NULL: " + (sp == null)); if (sp != null) { System.err.println("\tSP: " + sp.getProgramTitle() + " " + sp.getProgramId()); } sp = service.getScheduledProgramByNetworkCallSign("SDTW-C", "NBC", new Date()); System.err.println("SDTW- IS SP NULL: " + (sp == null)); if (sp != null) { System.err.println("\tSP: " + sp.getProgramTitle() + " " + sp.getProgramId()); } // System.err.println("SP is :" +sp.getProgramTitle()); // try { // List<ScheduledProgram> skedProgs = service.getScheduleForShow("P-DC", "Survivorman", new Date(), cal.getTime(), 1); // for (ScheduledProgram prog: skedProgs) { // System.err.println(" limit 1 SHOW: " + prog.getProgramId()+ " " + prog.getEpisodeTitle() + " starts at " + prog.getStartTime() + " " + prog.getNetwork().getStationCallSign()); // } //// sp = service.getScheduledProgram("CA04542:DEFAULT", "41", new Date()); //// System.err.println("SP is :" +sp.getProgramTitle()); // skedProgs = service.getScheduleForShow("P-DC", "Survivorman", new Date(), cal.getTime(), 0); // for (ScheduledProgram prog: skedProgs) { // System.err.println("NO LIMIT SHOW: " + prog.getProgramId()+ " " + prog.getEpisodeTitle() + "(" + prog.getScheduleId()+")"+ " starts at " + prog.getStartTime()+ " " + prog.getNetwork().getStationCallSign()); // } // sp = service.getScheduledProgram("CA04542:DEFAULT", "7", new Date()); // System.err.println("SP is :" +sp.getProgramTitle()); // ScheduledProgram next = service.getNextShowing("CA04542:DEFAULT", "EP6856270007"); // if (next != null) { // System.err.println("Next - " + next.getEpisodeTitle() + " starts at " + next.getStartTime()); // } else { // System.err.println("Unable to find next showing"); // } // ScheduledProgram last = service.getLastShowing("CA04542:DEFAULT", "EP6856270007"); // if (last != null) { // System.err.println("Last - " + last.getEpisodeTitle() + " starts at " + last.getStartTime()); // } else { // System.err.println("Unable to find last showing"); // } // // } finally { HibernateUtil.closeSession(); } if (true) { System.exit(-1); } }
From source file:cz.cas.lib.proarc.common.export.Kramerius4ExportOptions.java
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();/*from w w w . ja v a2 s . com*/ 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; }
From source file:com.cisco.oss.foundation.message.RabbitMQMessagingFactory.java
static void connect() { try {/*from ww w . j a v a2 s . c o m*/ ConnectionFactory connectionFactory = new ConnectionFactory(); connectionFactory.setAutomaticRecoveryEnabled(true); connectionFactory.setTopologyRecoveryEnabled(true); Configuration configuration = ConfigurationFactory.getConfiguration(); Configuration subsetBase = configuration.subset("service.rabbitmq"); Configuration subsetSecurity = subsetBase.subset("security"); int requestHeartbeat = subsetBase.getInt("requestHeartbeat", 10); connectionFactory.setRequestedHeartbeat(requestHeartbeat); String userName = subsetSecurity.getString("userName"); String password = subsetSecurity.getString("password"); boolean isEnabled = subsetSecurity.getBoolean("isEnabled"); final Map<String, Map<String, String>> serverConnections = ConfigUtil .parseComplexArrayStructure("service.rabbitmq.connections"); final ArrayList<String> serverConnectionKeys = Lists.newArrayList(serverConnections.keySet()); Collections.sort(serverConnectionKeys); if (isEnabled) { connectionFactory.setUsername(userName); connectionFactory.setPassword(password); } List<Address> addresses = new ArrayList<>(5); for (String serverConnectionKey : serverConnectionKeys) { Map<String, String> serverConnection = serverConnections.get(serverConnectionKey); String host = serverConnection.get("host"); int port = Integer.parseInt(serverConnection.get("port")); addresses.add(new Address(host, port)); // connectionFactory.setHost(host); // connectionFactory.setPort(Integer.parseInt(port)); } Address[] addrs = new Address[0]; connection = connectionFactory.newConnection(addresses.toArray(addrs)); connection.addBlockedListener(new BlockedListener() { public void handleBlocked(String reason) throws IOException { LOGGER.error("RabbitMQ connection is now blocked. Port: {}, Reason: {}", connection.getPort(), reason); IS_BLOCKED.set(true); } public void handleUnblocked() throws IOException { LOGGER.info("RabbitMQ connection is now un-blocked. Port: {}", connection.getPort()); IS_BLOCKED.set(false); } }); connection.addShutdownListener(new ShutdownListener() { @Override public void shutdownCompleted(ShutdownSignalException cause) { LOGGER.error("Connection shutdown detected. Reason: {}", cause.toString(), cause); } }); IS_CONNECTED.set(true); INIT_LATCH.countDown(); } catch (Exception e) { LOGGER.error("can't create RabbitMQ Connection: {}", e, e); // triggerReconnectThread(); throw new QueueException(e); } }
From source file:com.syncleus.grail.graph.titangraph.TitanGods.java
public static TitanGraph create(final String directory) { BaseConfiguration config = new BaseConfiguration(); Configuration storage = config.subset(GraphDatabaseConfiguration.STORAGE_NAMESPACE); // configuring local backend storage.setProperty(GraphDatabaseConfiguration.STORAGE_BACKEND_KEY, "local"); storage.setProperty(GraphDatabaseConfiguration.STORAGE_DIRECTORY_KEY, directory); // configuring elastic search index Configuration index = storage.subset(GraphDatabaseConfiguration.INDEX_NAMESPACE).subset(INDEX_NAME); index.setProperty(INDEX_BACKEND_KEY, "elasticsearch"); index.setProperty("local-mode", true); index.setProperty("client-only", false); index.setProperty(STORAGE_DIRECTORY_KEY, directory + File.separator + "es"); TitanGraph graph = TitanFactory.open(config); if (!graph.getVertices().iterator().hasNext()) TitanGods.load(graph);// w w w . ja va 2 s . c o m return graph; }
From source file:com.rapid7.diskstorage.dynamodb.TestGraphUtil.java
public static Configuration addElasticSearchConfig(Configuration config) { File tempSearchIndexDirectory; try {/* w w w . ja v a 2 s.c o m*/ tempSearchIndexDirectory = Files.createTempDirectory(null /*prefix*/).toFile(); } catch (IOException e) { throw new IllegalStateException("unable to create search index temp dir", e); } final Configuration search = config.subset("index").subset("search"); search.setProperty("backend", "elasticsearch"); search.setProperty("directory", tempSearchIndexDirectory.getAbsolutePath()); final Configuration es = search.subset("elasticsearch"); es.setProperty("client-only", "false"); es.setProperty("local-mode", "true"); return config; }
From source file:com.cisco.oss.foundation.message.HornetQMessagingFactory.java
/** * build once the hornetq service locator. * this is where we read the ost port list from configuration *///from w ww . ja v a2 s . com private static void init() { try { cleanup(); // nettyFactory = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(NettyConnectorFactory.class.getName())).createSessionFactory(); Configuration configuration = ConfigurationFactory.getConfiguration(); Configuration subset = configuration.subset("service.hornetq.connections"); final Map<String, Map<String, String>> serverConnections = ConfigUtil .parseComplexArrayStructure("service.hornetq.connections"); boolean isVersionPrinted = false; if (serverConnections != null && !serverConnections.isEmpty()) { if (isActiveActiveMode(subset)) { final ArrayList<String> serverConnectionKeys = Lists.newArrayList(serverConnections.keySet()); Collections.sort(serverConnectionKeys); for (String serverConnectionKey : serverConnectionKeys) { String host1Param = "service.hornetq.connections." + serverConnectionKey + ".instance1.host"; String port1Param = "service.hornetq.connections." + serverConnectionKey + ".instance1.port"; String jmxPort1Param = "service.hornetq.connections." + serverConnectionKey + ".instance1.jmxPort"; String host2Param = "service.hornetq.connections." + serverConnectionKey + ".instance2.host"; String port2Param = "service.hornetq.connections." + serverConnectionKey + ".instance2.port"; String host1 = configuration.getString(host1Param, null); String port1 = configuration.getString(port1Param, null); String host2 = configuration.getString(host2Param, null); String port2 = configuration.getString(port2Param, null); if (StringUtils.isAnyBlank(host1Param, host2Param, port1Param, port2Param)) { throw new IllegalArgumentException( "each HornetQ active active pair must contain all these suffixed {instance1.host, instance1.port, instance2.host, instance2.port} - but some are missing"); } if (!isVersionPrinted) { printHQVersion(host1, configuration.getString(jmxPort1Param, "3900")); } transportConfigurationsArray = new TransportConfiguration[2]; List<TransportConfiguration> transportConfigurations = new ArrayList<TransportConfiguration>(); Map<String, Object> map1 = new HashMap<String, Object>(); map1.put("host", host1); map1.put("port", port1); transportConfigurations .add(new TransportConfiguration(NettyConnectorFactory.class.getName(), map1)); Map<String, Object> map2 = new HashMap<String, Object>(); map2.put("host", host2); map2.put("port", port2); transportConfigurations .add(new TransportConfiguration(NettyConnectorFactory.class.getName(), map2)); transportConfigurations.toArray(transportConfigurationsArray); connect(); } } else { final ArrayList<String> serverConnectionKeys = Lists.newArrayList(serverConnections.keySet()); Collections.sort(serverConnectionKeys); printHQVersion(serverConnections, serverConnectionKeys); transportConfigurationsArray = new TransportConfiguration[serverConnectionKeys.size()]; List<TransportConfiguration> transportConfigurations = new ArrayList<TransportConfiguration>(); for (String serverConnectionKey : serverConnectionKeys) { Map<String, String> serverConnection = serverConnections.get(serverConnectionKey); Map<String, Object> map = new HashMap<String, Object>(); map.put("host", serverConnection.get("host")); map.put("port", serverConnection.get("port")); transportConfigurations .add(new TransportConfiguration(NettyConnectorFactory.class.getName(), map)); } transportConfigurations.toArray(transportConfigurationsArray); connect(); } } else { throw new IllegalArgumentException( "'service.hornetq.connections' must contain at least on host/port pair."); } setupConsumers(); } catch (Exception e) { LOGGER.error("can't create hornetq service locator: {}", e, e); throw new QueueException(e); } }