List of usage examples for java.lang System getProperty
public static String getProperty(String key)
From source file:eu.optimis.elasticityengine.EETester.java
public static void main(String[] args) throws IOException, InterruptedException { if (args.length != 1) { printUsage();/*ww w .jav a 2 s. c om*/ System.exit(-1); } Logger log = Logger.getLogger(ElasticityEngineImpl.class); System.out.println("Testing Elasticity Engine"); System.out.println("One instance per 100 users expected, starting at 1"); ElasticityEngine eEngine = new ElasticityEngineImpl(); String manifest = Util.getManifest(args[0]); String serviceID = "EETester"; // TODO parse somehow? String sp = "SP_Add"; boolean LowRiskMode; ElasticityCallback callback = new CallbackPrinter(); if ("true".equals(System.getProperty("lowrisk"))) { System.out.println("USING Low Risk Mode"); LowRiskMode = true; } else { System.out.println("USING Low cost Mode"); LowRiskMode = false; } eEngine.startElasticity(serviceID, manifest, LowRiskMode, sp); //Call a test-specific method which only returns when we got the -2 recommendation, and the test should then be done. ((CallbackPrinter) callback).awaitLoad(1); System.out.println("\nTest done, exiting"); Thread.sleep(500); }
From source file:com.ibm.jaql.MiniCluster.java
/** * @param args//from w w w . j a va2s .c om */ public static void main(String[] args) throws IOException { String clusterHome = System.getProperty("hadoop.minicluster.dir"); if (clusterHome == null) { clusterHome = "./minicluster"; System.setProperty("hadoop.minicluster.dir", clusterHome); } LOG.info("hadoop.minicluster.dir=" + clusterHome); File clusterFile = new File(clusterHome); if (!clusterFile.exists()) { clusterFile.mkdirs(); } if (!clusterFile.isDirectory()) { throw new IOException("minicluster home directory must be a directory: " + clusterHome); } if (!clusterFile.canRead() || !clusterFile.canWrite()) { throw new IOException("minicluster home directory must be readable and writable: " + clusterHome); } String logDir = System.getProperty("hadoop.log.dir"); if (logDir == null) { logDir = clusterHome + File.separator + "logs"; System.setProperty("hadoop.log.dir", logDir); } File logFile = new File(logDir); if (!logFile.exists()) { logFile.mkdirs(); } String confDir = System.getProperty("hadoop.conf.override"); if (confDir == null) { confDir = clusterHome + File.separator + "conf"; System.setProperty("hadoop.conf.override", confDir); } File confFile = new File(confDir); if (!confFile.exists()) { confFile.mkdirs(); } System.out.println("starting minicluster in " + clusterHome); MiniCluster mc = new MiniCluster(args); // To find the ports in the // hdfs: search for: Web-server up at: localhost:#### // mapred: search for: mapred.JobTracker: JobTracker webserver: #### Configuration conf = mc.getConf(); System.out.println("fs.default.name: " + conf.get("fs.default.name")); System.out.println("dfs.http.address: " + conf.get("dfs.http.address")); System.out.println("mapred.job.tracker.http.address: " + conf.get("mapred.job.tracker.http.address")); boolean waitForInterrupt; try { System.out.println("press enter to end minicluster (or eof to run forever)..."); waitForInterrupt = System.in.read() < 0; // wait for any input or eof } catch (Exception e) { // something odd happened. Just shutdown. LOG.error("error reading from stdin", e); waitForInterrupt = false; } // eof means that we will wait for a kill signal while (waitForInterrupt) { System.out.println("minicluster is running until interrupted..."); try { Thread.sleep(60 * 60 * 1000); } catch (InterruptedException e) { waitForInterrupt = false; } } System.out.println("shutting down minicluster..."); try { mc.tearDown(); } catch (Exception e) { LOG.error("error while shutting down minicluster", e); } }
From source file:edu.umn.msi.tropix.proteomics.tools.DTAToMzXML.java
public static void main(final String[] args) throws Exception { if (args.length < 1) { usage();//ww w .ja va2s . c om System.exit(0); } Collection<File> files = null; if (args[0].equals("-files")) { if (args.length < 2) { out.println("No files specified."); usage(); exit(-1); } else { files = new ArrayList<File>(args.length - 1); for (int i = 1; i < args.length; i++) { files.add(new File(args[i])); } } } else if (args[0].equals("-directory")) { File directory; if (args.length < 2) { directory = new File(System.getProperty("user.dir")); } else { directory = new File(args[2]); } files = FileUtilsFactory.getInstance().listFiles(directory, new String[] { "dta" }, false); } else { usage(); exit(-1); } final InMemoryDTAListImpl dtaList = new InMemoryDTAListImpl(); File firstFile = null; if (files.size() == 0) { out.println("No files found."); exit(-1); } else { firstFile = files.iterator().next(); } for (final File file : files) { dtaList.add(FileUtils.readFileToByteArray(file), file.getName()); } final DTAToMzXMLConverter dtaToMzXMLConverter = new DTAToMzXMLConverterImpl(); final MzXML mzxml = dtaToMzXMLConverter.dtaToMzXML(dtaList, null); final String mzxmlName = firstFile.getName().substring(0, firstFile.getName().indexOf(".")) + ".mzXML"; new MzXMLUtility().serialize(mzxml, mzxmlName); }
From source file:com.datatorrent.stram.StreamingAppMaster.java
/** * @param args/* w w w . ja va 2s. c o m*/ * Command line args * @throws Throwable */ public static void main(final String[] args) throws Throwable { StdOutErrLog.tieSystemOutAndErrToLog(); LOG.info("Master starting with classpath: {}", System.getProperty("java.class.path")); LOG.info("version: {}", VersionInfo.APEX_VERSION.getBuildVersion()); StringWriter sw = new StringWriter(); for (Map.Entry<String, String> e : System.getenv().entrySet()) { sw.append("\n").append(e.getKey()).append("=").append(e.getValue()); } LOG.info("appmaster env:" + sw.toString()); Options opts = new Options(); opts.addOption("app_attempt_id", true, "App Attempt ID. Not to be used unless for testing purposes"); opts.addOption("help", false, "Print usage"); CommandLine cliParser = new GnuParser().parse(opts, args); // option "help" overrides and cancels any run if (cliParser.hasOption("help")) { new HelpFormatter().printHelp("ApplicationMaster", opts); return; } Map<String, String> envs = System.getenv(); ApplicationAttemptId appAttemptID = Records.newRecord(ApplicationAttemptId.class); if (!envs.containsKey(Environment.CONTAINER_ID.name())) { if (cliParser.hasOption("app_attempt_id")) { String appIdStr = cliParser.getOptionValue("app_attempt_id", ""); appAttemptID = ConverterUtils.toApplicationAttemptId(appIdStr); } else { throw new IllegalArgumentException("Application Attempt Id not set in the environment"); } } else { ContainerId containerId = ConverterUtils.toContainerId(envs.get(Environment.CONTAINER_ID.name())); appAttemptID = containerId.getApplicationAttemptId(); } boolean result = false; StreamingAppMasterService appMaster = null; try { appMaster = new StreamingAppMasterService(appAttemptID); LOG.info("Initializing Application Master."); Configuration conf = new YarnConfiguration(); appMaster.init(conf); appMaster.start(); result = appMaster.run(); } catch (Throwable t) { LOG.error("Exiting Application Master", t); System.exit(1); } finally { if (appMaster != null) { appMaster.stop(); } } if (result) { LOG.info("Application Master completed."); System.exit(0); } else { LOG.info("Application Master failed."); System.exit(2); } }
From source file:com.almende.eve.deploy.Boot.java
/** * The default agent booter. It takes an EVE yaml file and creates all * agents mentioned in the "agents" section. * //from ww w . j a v a 2s. co m * @param args * Single argument: args[0] -> Eve yaml */ public static void main(final String[] args) { if (args.length == 0) { LOG.warning("Missing argument pointing to yaml file:"); LOG.warning("Usage: java -jar <jarfile> eve.yaml"); return; } final ClassLoader cl = new ClassLoader() { @Override protected Class<?> findClass(final String name) throws ClassNotFoundException { Class<?> result = null; try { result = super.findClass(name); } catch (ClassNotFoundException cne) { } if (result == null) { FileInputStream fi = null; try { String path = name.replace('.', '/'); fi = new FileInputStream(System.getProperty("user.dir") + "/" + path + ".class"); byte[] classBytes = new byte[fi.available()]; fi.read(classBytes); fi.close(); return defineClass(name, classBytes, 0, classBytes.length); } catch (Exception e) { LOG.log(Level.WARNING, "Failed to load class:", e); } } if (result == null) { throw new ClassNotFoundException(name); } return result; } }; String configFileName = args[0]; try { InputStream is = new FileInputStream(new File(configFileName)); boot(is, cl); } catch (FileNotFoundException e) { LOG.log(Level.WARNING, "Couldn't find configfile:" + configFileName, e); return; } }
From source file:com.kolich.aws.S3Test.java
public static void main(String[] args) { final String key = System.getProperty(AWS_ACCESS_KEY_PROPERTY); final String secret = System.getProperty(AWS_SECRET_PROPERTY); if (key == null || secret == null) { throw new IllegalArgumentException("You are missing the " + "-Daws.key and -Daws.secret required VM " + "properties on your command line."); }/*from ww w . ja v a2 s.c o m*/ final HttpClient client = KolichHttpClientFactory.getNewInstanceNoProxySelector(); final S3Client s3 = new KolichS3Client(client, key, secret); final Option<HttpFailure> bucket = s3.createBucket("foobar.kolich.local"); if (bucket.isNone()) { System.out.println("created successfully."); } else { System.err.println(bucket.get().getStatusCode()); } final Either<HttpFailure, List<Bucket>> list = s3.listBuckets(); if (list.success()) { for (final Bucket b : list.right()) { System.out.println("Bucket: " + b.getName()); } } else { System.err.println("Failed to list buckets!"); } final Either<HttpFailure, PutObjectResult> put = s3.putObject("foobar.kolich.local", getBytesUtf8("zomg it works!"), "test", "foo", "bar/kewl", "test.txt"); if (put.success()) { System.out.println("Put object worked!!"); } final boolean exists = s3.objectExists("foobar.kolich.local", "test", "foo", "bar/kewl", "test.txt"); if (exists) { System.out.println("Object confirmed exists!"); } final boolean exists2 = s3.objectExists("foobar.kolich.local", "bogus"); if (!exists2) { System.out.println("Bogus object confirmed missing."); } final Either<HttpFailure, ObjectListing> objList = s3.listObjects("foobar.kolich.local"); if (objList.success()) { for (final S3ObjectSummary o : objList.right().getObjectSummaries()) { System.out.println("Object: " + o.getKey()); } } final Option<HttpFailure> delete = s3.deleteObject("foobar.kolich.local", "test", "foo", "bar/kewl", "test.txt"); if (delete.isNone()) { System.out.println("Delete object worked too!"); } else { System.out.println("Delete object failed: " + delete.get().getStatusCode()); } /* try { final File f = new File("/home/mkolich/Desktop/foobar.pdf"); final Either<HttpFailure,PutObjectResult> putLarge = s3.putObject("foobar.kolich.local", ContentType.APPLICATION_OCTET_STREAM, new FileInputStream(f), f.length(), f.getName()); if(putLarge.success()) { System.out.println("Large upload worked!"); } } catch (Exception e) { System.err.println("Large upload failed."); } */ final Option<HttpFailure> deleteBucket = s3.deleteBucket("foobar.kolich.local"); if (deleteBucket.isNone()) { System.out.println("deleted bucket!"); } else { System.err.println("Failed to delete bucket: " + deleteBucket.get().getStatusCode()); } }
From source file:com.liferay.alloy.tools.xmlbuilder.XMLBuilder.java
public static void main(String[] args) throws Exception { String componentsJSON = System.getProperty("xmlbuilder.components.json"); String componentsXML = System.getProperty("tagbuilder.components.xml"); String componentExcluded = System.getProperty("xmlbuilder.components.excluded"); new XMLBuilder(componentsJSON, componentsXML, componentExcluded); }
From source file:com.precioustech.fxtrading.oanda.restapi.marketdata.historic.HistoricMarketDataOnDemandDemo.java
public static void main(String[] args) throws Exception { usage(args);/* w w w . java 2 s . c o m*/ final String url = args[0]; final String accessToken = args[1]; HistoricMarketDataProvider<String> historicMarketDataProvider = new OandaHistoricMarketDataProvider(url, accessToken); Scanner scanner = new Scanner(System.in); scanner.useDelimiter(System.getProperty("line.separator")); System.out.print("Instrument" + TradingConstants.COLON); String ccyPair = scanner.next(); TradeableInstrument<String> instrument = new TradeableInstrument<>(ccyPair.toUpperCase()); System.out.print( "Granularity" + ArrayUtils.toString(CandleStickGranularity.values()) + TradingConstants.COLON); CandleStickGranularity granularity = CandleStickGranularity.valueOf(scanner.next().toUpperCase()); System.out.print("Time Range Candles(t) or Last N Candles(n)?:"); String choice = scanner.next(); List<CandleStick<String>> candles = null; if ("t".equalsIgnoreCase(choice)) { System.out.print("Start Time(" + datefmtLabel + ")" + TradingConstants.COLON); String startStr = scanner.next(); Date startDt = sdf.parse(startStr); System.out.print(" End Time(" + datefmtLabel + ")" + TradingConstants.COLON); String endStr = scanner.next(); Date endDt = sdf.parse(endStr); candles = historicMarketDataProvider.getCandleSticks(instrument, granularity, new DateTime(startDt.getTime()), new DateTime(endDt.getTime())); } else { System.out.print("Last how many candles?" + TradingConstants.COLON); int n = scanner.nextInt(); candles = historicMarketDataProvider.getCandleSticks(instrument, granularity, n); } System.out.println(center("Time", timeColLen) + center("Open", priceColLen) + center("Close", priceColLen) + center("High", priceColLen) + center("Low", priceColLen)); System.out.println(repeat("=", timeColLen + priceColLen * 4)); for (CandleStick<String> candle : candles) { System.out.println(center(sdf.format(candle.getEventDate().toDate()), timeColLen) + formatPrice(candle.getOpenPrice()) + formatPrice(candle.getClosePrice()) + formatPrice(candle.getHighPrice()) + formatPrice(candle.getLowPrice())); } scanner.close(); }
From source file:com.leshazlewood.scms.cli.Main.java
public static void main(String[] args) throws Exception { CommandLineParser parser = new PosixParser(); Options options = new Options(); options.addOption(CONFIG).addOption(DEBUG).addOption(HELP).addOption(VERSION); boolean debug = false; File sourceDir = toFile(System.getProperty("user.dir")); File configFile = null;//from ww w . j a v a2 s . c om File destDir = null; try { CommandLine line = parser.parse(options, args); if (line.hasOption(VERSION.getOpt())) { printVersionAndExit(); } if (line.hasOption(HELP.getOpt())) { printHelpAndExit(options, null, debug, 0); } if (line.hasOption(DEBUG.getOpt())) { debug = true; } if (line.hasOption(CONFIG.getOpt())) { String configFilePath = line.getOptionValue(CONFIG.getOpt()); configFile = toFile(configFilePath); } String[] remainingArgs = line.getArgs(); if (remainingArgs == null) { printHelpAndExit(options, null, debug, -1); } assert remainingArgs != null; if (remainingArgs.length == 1) { String workingDirPath = System.getProperty("user.dir"); sourceDir = toFile(workingDirPath); destDir = toFile(remainingArgs[0]); } else if (remainingArgs.length == 2) { sourceDir = toFile(remainingArgs[0]); destDir = toFile((remainingArgs[1])); } else { printHelpAndExit(options, null, debug, -1); } assert sourceDir != null; assert destDir != null; if (configFile == null) { configFile = new File(sourceDir, DEFAULT_CONFIG_FILE_NAME); } if (configFile.exists()) { if (configFile.isDirectory()) { throw new IllegalArgumentException( "Expected configuration file " + configFile + " is a directory, not a file."); } } else { String msg = "Configuration file not found. Create a default " + DEFAULT_CONFIG_FILE_NAME + " file in your source directory or specify the " + CONFIG + " option to provide the file location."; throw new IllegalStateException(msg); } SiteExporter siteExporter = new SiteExporter(); siteExporter.setSourceDir(sourceDir); siteExporter.setDestDir(destDir); siteExporter.setConfigFile(configFile); siteExporter.init(); siteExporter.execute(); } catch (IllegalArgumentException iae) { exit(iae, debug); } catch (IllegalStateException ise) { exit(ise, debug); } catch (Exception e) { printHelpAndExit(options, e, debug, -1); } }
From source file:demo.wssec.client.Client.java
public static void main(String args[]) throws Exception { if (args.length == 0) { System.out.println("please specify wsdl"); System.exit(1);//ww w. j a v a2s . com } URL wsdlURL; File wsdlFile = new File(args[0]); if (wsdlFile.exists()) { wsdlURL = wsdlFile.toURI().toURL(); } else { wsdlURL = new URL(args[0]); } SpringBusFactory bf = new SpringBusFactory(); URL busFile = new ClassPathResource("wssec-client.xml").getURL(); Bus bus = bf.createBus(busFile.toString()); SpringBusFactory.setDefaultBus(bus); SpringBusFactory.setThreadDefaultBus(bus); Service service = Service.create(wsdlURL, SERVICE_NAME); Greeter port = service.getPort(PORT_NAME, Greeter.class); System.out.println("Invoking greetMe..."); try { String resp = port.greetMe(System.getProperty("user.name")); System.out.println("Server responded with: " + resp); System.out.println(); } catch (Exception e) { System.out.println("Invocation failed with the following: " + e.getCause()); System.out.println(); } System.exit(0); }