List of usage examples for org.apache.commons.configuration PropertiesConfiguration PropertiesConfiguration
public PropertiesConfiguration(URL url) throws ConfigurationException
From source file:com.linkedin.pinot.broker.broker.BrokerServerBuilderTest.java
public static void main(String[] args) throws Exception { PropertiesConfiguration config = new PropertiesConfiguration( new File(BrokerServerBuilderTest.class.getClassLoader().getResource("broker.properties").toURI())); final BrokerServerBuilder bld = new BrokerServerBuilder(config, null, null, null); bld.buildNetwork();/* w w w. j av a 2 s . co m*/ bld.buildHTTP(); bld.start(); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { try { bld.stop(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while (true) { String command = br.readLine(); if (command.equals("exit")) { bld.stop(); } } }
From source file:com.discursive.jccook.configuration.TypedConfigurationExample.java
public static void main(String[] args) throws Exception { Configuration config = new PropertiesConfiguration("test.properties"); System.out.println("Speed: " + config.getFloat("speed")); System.out.println("Names: " + config.getList("names")); System.out.println("Correct: " + config.getBoolean("correct")); }
From source file:fr.jetoile.hadoopunit.HadoopStandaloneBootstrap.java
public static void main(String[] args) throws BootstrapException { try {//from w ww. j a va 2s . c o m configuration = new PropertiesConfiguration("hadoop.properties"); } catch (ConfigurationException e) { throw new BootstrapException("bad config", e); } HadoopBootstrap bootstrap = HadoopBootstrap.INSTANCE; bootstrap.componentsToStart = bootstrap.componentsToStart.stream() .filter(c -> configuration.containsKey(c.getName().toLowerCase()) && configuration.getBoolean(c.getName().toLowerCase())) .collect(Collectors.toList()); bootstrap.componentsToStop = bootstrap.componentsToStop.stream() .filter(c -> configuration.containsKey(c.getName().toLowerCase()) && configuration.getBoolean(c.getName().toLowerCase())) .collect(Collectors.toList()); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { LOGGER.info("All services are going to be stopped"); bootstrap.stopAll(); } }); bootstrap.startAll(); }
From source file:it.polimi.tower4clouds.data_analyzer.DAServer.java
public static void main(String[] args) { PropertiesConfiguration releaseProperties = null; try {//from www . ja v a 2 s . c o m releaseProperties = new PropertiesConfiguration("release.properties"); } catch (org.apache.commons.configuration.ConfigurationException e) { logger.error("Internal error", e); System.exit(1); } APP_NAME = releaseProperties.getString("application.name"); APP_FILE_NAME = releaseProperties.getString("dist.file.name"); APP_VERSION = releaseProperties.getString("release.version"); try { DAConfig config = new DAConfig(args, APP_FILE_NAME); if (config.isHelp()) { System.out.println(config.usage); } else if (config.isVersion()) { System.out.println("Version: " + APP_VERSION); } else { String[] rspArgs = new String[1]; rspArgs[0] = "da.properties"; System.setProperty(InputDataUnmarshaller.INPUT_DATA_UNMARSHALLER_IMPL_PROPERTY_NAME, DAInputDataUnmarshaller.class.getName()); System.setProperty(OutputDataMarshaller.OUTPUT_DATA_MARSHALLER_IMPL_PROPERTY_NAME, DAOutputDataMarshaller.class.getName()); System.setProperty("log4j.configuration", "log4j.properties"); // System.setProperty("rsp_server.static_resources.path", // config.getKBFolder()); NOT USED BY RSP!!! System.setProperty("csparql_server.port", Integer.toString(config.getPort())); logger.info("{} {}", APP_NAME, APP_VERSION); rsp_services_csparql_server.main(rspArgs); } } catch (ConfigurationException e) { logger.error("Configuration problem: " + e.getMessage()); logger.error("Run \"" + APP_FILE_NAME + " -help\" for help"); System.exit(1); } catch (Exception e) { logger.error("Unknown error", e); } }
From source file:com.pinterest.terrapin.client.ClientTool.java
public static void main(String[] args) throws Exception { PropertiesConfiguration config = new PropertiesConfiguration(System.getProperty("terrapin.config")); TerrapinClient client = new TerrapinClient(config, 9090, 1000, 5000); String key = args[1];//from ww w. ja v a 2 s. co m TerrapinSingleResponse response = client.getOne(args[0], // fileset ByteBuffer.wrap(key.getBytes())).get(); if (response.isSetErrorCode()) { System.out.println("Got error " + response.getErrorCode().toString()); } else if (response.isSetValue()) { System.out.println("Got value."); System.out.println(new String(response.getValue())); } else { System.out.println("Key " + key + " not found."); } System.exit(0); }
From source file:com.comcast.viper.flume2storm.example.ExampleTopology.java
public static void main(String[] args) throws F2SConfigurationException, ConfigurationException, AlreadyAliveException, InvalidTopologyException { Configuration configuration = new PropertiesConfiguration("properties"); ExampleStringEmitter emitter = new ExampleStringEmitter(); FlumeSpout<KryoNetConnectionParameters, KryoNetServiceProvider> spout = new FlumeSpout<KryoNetConnectionParameters, KryoNetServiceProvider>( emitter, configuration);/*from w ww. ja v a2 s. c o m*/ TopologyBuilder builder = new TopologyBuilder(); builder.setSpout("spout", spout); LoggerBolt bolt = new LoggerBolt(); builder.setBolt("bolt", bolt).shuffleGrouping("spout"); Config stormConf = new Config(); stormConf.setDebug(true); stormConf.setNumWorkers(3); StormSubmitter.submitTopology("ExampleTopology", stormConf, builder.createTopology()); }
From source file:ch.cyclops.gatekeeper.Main.java
public static void main(String[] args) throws Exception { CompositeConfiguration config = new CompositeConfiguration(); config.addConfiguration(new SystemConfiguration()); if (args.length > 0) config.addConfiguration(new PropertiesConfiguration(args[args.length - 1])); //setting up the logging framework now Logger.getRootLogger().getLoggerRepository().resetConfiguration(); ConsoleAppender console = new ConsoleAppender(); //create appender //configure the appender String PATTERN = "%d [%p|%C{1}|%M|%L] %m%n"; console.setLayout(new PatternLayout(PATTERN)); String logConsoleLevel = config.getProperty("log.level.console").toString(); switch (logConsoleLevel) { case ("INFO"): console.setThreshold(Level.INFO); break;/*from ww w .ja v a2s . co m*/ case ("DEBUG"): console.setThreshold(Level.DEBUG); break; case ("WARN"): console.setThreshold(Level.WARN); break; case ("ERROR"): console.setThreshold(Level.ERROR); break; case ("FATAL"): console.setThreshold(Level.FATAL); break; case ("OFF"): console.setThreshold(Level.OFF); break; default: console.setThreshold(Level.ALL); } console.activateOptions(); //add appender to any Logger (here is root) Logger.getRootLogger().addAppender(console); String logFileLevel = config.getProperty("log.level.file").toString(); String logFile = config.getProperty("log.file").toString(); if (logFile != null && logFile.length() > 0) { FileAppender fa = new FileAppender(); fa.setName("FileLogger"); fa.setFile(logFile); fa.setLayout(new PatternLayout("%d %-5p [%c{1}] %m%n")); switch (logFileLevel) { case ("INFO"): fa.setThreshold(Level.INFO); break; case ("DEBUG"): fa.setThreshold(Level.DEBUG); break; case ("WARN"): fa.setThreshold(Level.WARN); break; case ("ERROR"): fa.setThreshold(Level.ERROR); break; case ("FATAL"): fa.setThreshold(Level.FATAL); break; case ("OFF"): fa.setThreshold(Level.OFF); break; default: fa.setThreshold(Level.ALL); } fa.setAppend(true); fa.activateOptions(); //add appender to any Logger (here is root) Logger.getRootLogger().addAppender(fa); } //now logger configuration is done, we can start using it. Logger mainLogger = Logger.getLogger("gatekeeper-driver.Main"); mainLogger.debug("Driver loaded properly"); if (args.length > 0) { GKDriver gkDriver = new GKDriver(args[args.length - 1], 1, "Eq7K8h9gpg"); System.out.println("testing if admin: " + gkDriver.isAdmin(1, 0)); ArrayList<String> uList = gkDriver.getUserList(0); //the argument is the starting count of number of allowed //internal attempts. if (uList != null) { mainLogger.info("Received user list from Gatekeeper! Count: " + uList.size()); for (int i = 0; i < uList.size(); i++) mainLogger.info(uList.get(i)); } boolean authResponse = gkDriver.simpleAuthentication(1, "Eq7K8h9gpg"); if (authResponse) mainLogger.info("Authentication attempt was successful."); else mainLogger.warn("Authentication attempt failed!"); String sName = "myservice-" + System.currentTimeMillis(); HashMap<String, String> newService = gkDriver.registerService(sName, "this is my new cool service", 0); String sKey = ""; if (newService != null) { mainLogger.info("Service registration was successful! Got:" + newService.get("uri") + ", Key=" + newService.get("key")); sKey = newService.get("key"); } else { mainLogger.warn("Service registration failed!"); } int newUserId = gkDriver.registerUser("user-" + System.currentTimeMillis(), "pass1234", false, sName, 0); if (newUserId != -1) mainLogger.info("User registration was successful. Received new id: " + newUserId); else mainLogger.warn("User registration failed!"); String token = gkDriver.generateToken(newUserId, "pass1234"); boolean isValidToken = gkDriver.validateToken(token, newUserId); if (isValidToken) mainLogger.info("The token: " + token + " is successfully validated for user-id: " + newUserId); else mainLogger.warn("Token validation was unsuccessful! Token: " + token + ", user-id: " + newUserId); ArrayList<String> sList = gkDriver.getServiceList(0); //the argument is the starting count of number of allowed //internal attempts. if (sList != null) { mainLogger.info("Received service list from Gatekeeper! Count: " + sList.size()); for (int i = 0; i < sList.size(); i++) mainLogger.info(sList.get(i)); } isValidToken = gkDriver.validateToken(token, sKey); if (isValidToken) mainLogger.info("The token: " + token + " is successfully validated for user-id: " + newUserId + " against s-key:" + sKey); else mainLogger.warn("Token validation was unsuccessful! Token: " + token + ", user-id: " + newUserId + ", s-key: " + sKey); boolean deleteResult = gkDriver.deleteUser(newUserId, 0); if (deleteResult) mainLogger.info("User with id: " + newUserId + " was deleted successfully."); else mainLogger.warn("User with id: " + newUserId + " could not be deleted successfully!"); } }
From source file:fr.dudie.acrachilisync.AcraChiliSync.java
/** * @param args/*from w ww. j a va 2 s .com*/ * @throws RedmineException * @throws NotFoundException * @throws AuthenticationException * @throws ServiceException * @throws IOException * @throws ParseException * @throws ConfigurationException */ public static void main(final String[] args) throws IOException, ServiceException, AuthenticationException, NotFoundException, RedmineException, ParseException, ConfigurationException { final PropertiesConfiguration conf = new PropertiesConfiguration("acrachilisync.properties"); final AcraToChiliprojectSyncer syncer = new AcraToChiliprojectSyncer(conf); syncer.startSynchronization(); }
From source file:com.jff.searchapicluster.server.mina.Server.java
public static void main(String[] args) throws Throwable { org.apache.commons.configuration.Configuration config = new PropertiesConfiguration("settings.txt"); int serverPort = config.getInt("listenPort"); NioSocketAcceptor acceptor = new NioSocketAcceptor(); acceptor.getFilterChain().addLast("com/jff/searchapicluster/core/mina/codec", new ProtocolCodecFilter(new ObjectSerializationCodecFactory())); acceptor.getFilterChain().addLast("logger", new LoggingFilter()); acceptor.setHandler(new ServerSessionHandler()); acceptor.bind(new InetSocketAddress(serverPort)); System.out.println("Listening on port " + serverPort); System.out.println("Please enter filename"); // open up standard input BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while (true) { String filepath = br.readLine(); filepath = "/Users/admin/repos/study_repos/kurs_sp/search_api_cluster/SearchApiClusterServer/task.json"; File file = new File(filepath); Logger.d(LOG_TAG, file.getAbsolutePath()); if (file.exists() && file.isFile()) { Gson gson = new Gson(); SearchTask taskMessage = gson.fromJson(new FileReader(file), SearchTask.class); ServerManager serverManager = ServerManager.getInstance(); Logger.d(LOG_TAG, taskMessage.toString()); serverManager.startProcessTask(taskMessage); } else {/*from w w w . j a va2s.co m*/ Logger.d(LOG_TAG, filepath + "not found"); } } }
From source file:it.polimi.tower4clouds.manager.server.MMServer.java
public static void main(String[] args) { PropertiesConfiguration releaseProperties = null; try {//from ww w . j a va2 s. c o m releaseProperties = new PropertiesConfiguration("release.properties"); } catch (org.apache.commons.configuration.ConfigurationException e) { logger.error("Internal error", e); System.exit(1); } APP_NAME = releaseProperties.getString("application.name"); APP_FILE_NAME = releaseProperties.getString("dist.file.name"); APP_VERSION = releaseProperties.getString("release.version"); try { ManagerConfig.init(args, APP_FILE_NAME); if (ManagerConfig.getInstance().isHelp()) { logger.info(ManagerConfig.usage); } else if (ManagerConfig.getInstance().isVersion()) { logger.info("Version: {}", APP_VERSION); } else { logger.info("{} {}", APP_NAME, APP_VERSION); logger.info("Current configuration:\n{}", ManagerConfig.getInstance().toString()); MonitoringManager manager = new MonitoringManager(ManagerConfig.getInstance()); System.setProperty("org.restlet.engine.loggerFacadeClass", "org.restlet.ext.slf4j.Slf4jLoggerFacade"); Component component = new Component(); Server server = new Server(Protocol.HTTP, ManagerConfig.getInstance().getMmPort()); Context context = new Context(); context.getParameters().add("maxThreads", "500"); // context.getParameters().add("maxTotalConnections", "500"); context.getParameters().add("maxQueued", "5000"); server.setContext(context); component.getServers().add(server); component.getClients().add(Protocol.CLAP); component.getDefaultHost().attach("", new MMServer(manager)); logger.info( "Starting Monitoring Manager server on port " + ManagerConfig.getInstance().getMmPort()); component.start(); } } catch (ConfigurationException e) { logger.error("Configuration problem: " + e.getMessage()); logger.error("Run \"" + APP_FILE_NAME + " --help\" for help"); System.exit(1); } catch (HttpException | IOException | ServerErrorException e) { logger.error("Connection problem: {}", e.getMessage()); System.exit(1); } catch (Exception e) { logger.error("Unknown error", e); System.exit(1); } }