List of usage examples for java.lang String valueOf
public static String valueOf(double d)
From source file:com.alibaba.rocketmq.example.benchmark.Producer.java
public static void main(String[] args) throws MQClientException, UnsupportedEncodingException { Options options = ServerUtil.buildCommandlineOptions(new Options()); CommandLine commandLine = ServerUtil.parseCmdLine("producer", args, buildCommandlineOptions(options), new PosixParser()); if (null == commandLine) { System.exit(-1);//from ww w. j av a 2 s .c o m } final int threadCount = commandLine.hasOption('t') ? Integer.parseInt(commandLine.getOptionValue('t')) : 64; final int messageSize = commandLine.hasOption('s') ? Integer.parseInt(commandLine.getOptionValue('s')) : 128; final boolean keyEnable = commandLine.hasOption('k') ? Boolean.parseBoolean(commandLine.getOptionValue('k')) : false; System.out.printf("threadCount %d messageSize %d keyEnable %s%n", threadCount, messageSize, keyEnable); final Logger log = ClientLogger.getLog(); final Message msg = buildMessage(messageSize); final ExecutorService sendThreadPool = Executors.newFixedThreadPool(threadCount); final StatsBenchmarkProducer statsBenchmark = new StatsBenchmarkProducer(); final Timer timer = new Timer("BenchmarkTimerThread", true); final LinkedList<Long[]> snapshotList = new LinkedList<Long[]>(); timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { snapshotList.addLast(statsBenchmark.createSnapshot()); if (snapshotList.size() > 10) { snapshotList.removeFirst(); } } }, 1000, 1000); timer.scheduleAtFixedRate(new TimerTask() { private void printStats() { if (snapshotList.size() >= 10) { Long[] begin = snapshotList.getFirst(); Long[] end = snapshotList.getLast(); final long sendTps = (long) (((end[3] - begin[3]) / (double) (end[0] - begin[0])) * 1000L); final double averageRT = ((end[5] - begin[5]) / (double) (end[3] - begin[3])); System.out.printf( "Send TPS: %d Max RT: %d Average RT: %7.3f Send Failed: %d Response Failed: %d%n"// , sendTps// , statsBenchmark.getSendMessageMaxRT().get()// , averageRT// , end[2]// , end[4]// ); } } @Override public void run() { try { this.printStats(); } catch (Exception e) { e.printStackTrace(); } } }, 10000, 10000); final DefaultMQProducer producer = new DefaultMQProducer("benchmark_producer"); producer.setInstanceName(Long.toString(System.currentTimeMillis())); if (commandLine.hasOption('n')) { String ns = commandLine.getOptionValue('n'); producer.setNamesrvAddr(ns); } producer.setCompressMsgBodyOverHowmuch(Integer.MAX_VALUE); producer.start(); for (int i = 0; i < threadCount; i++) { sendThreadPool.execute(new Runnable() { @Override public void run() { while (true) { try { final long beginTimestamp = System.currentTimeMillis(); if (keyEnable) { msg.setKeys(String.valueOf(beginTimestamp / 1000)); } producer.send(msg); statsBenchmark.getSendRequestSuccessCount().incrementAndGet(); statsBenchmark.getReceiveResponseSuccessCount().incrementAndGet(); final long currentRT = System.currentTimeMillis() - beginTimestamp; statsBenchmark.getSendMessageSuccessTimeTotal().addAndGet(currentRT); long prevMaxRT = statsBenchmark.getSendMessageMaxRT().get(); while (currentRT > prevMaxRT) { boolean updated = statsBenchmark.getSendMessageMaxRT().compareAndSet(prevMaxRT, currentRT); if (updated) break; prevMaxRT = statsBenchmark.getSendMessageMaxRT().get(); } } catch (RemotingException e) { statsBenchmark.getSendRequestFailedCount().incrementAndGet(); log.error("[BENCHMARK_PRODUCER] Send Exception", e); try { Thread.sleep(3000); } catch (InterruptedException e1) { } } catch (InterruptedException e) { statsBenchmark.getSendRequestFailedCount().incrementAndGet(); try { Thread.sleep(3000); } catch (InterruptedException e1) { } } catch (MQClientException e) { statsBenchmark.getSendRequestFailedCount().incrementAndGet(); log.error("[BENCHMARK_PRODUCER] Send Exception", e); } catch (MQBrokerException e) { statsBenchmark.getReceiveResponseFailedCount().incrementAndGet(); log.error("[BENCHMARK_PRODUCER] Send Exception", e); try { Thread.sleep(3000); } catch (InterruptedException e1) { } } } } }); } }
From source file:com.damon.rocketmq.example.benchmark.Producer.java
public static void main(String[] args) throws MQClientException, UnsupportedEncodingException { Options options = ServerUtil.buildCommandlineOptions(new Options()); CommandLine commandLine = ServerUtil.parseCmdLine("benchmarkProducer", args, buildCommandlineOptions(options), new PosixParser()); if (null == commandLine) { System.exit(-1);/*ww w . j ava2 s .com*/ } final String topic = commandLine.hasOption('t') ? commandLine.getOptionValue('t').trim() : "BenchmarkTest"; final int threadCount = commandLine.hasOption('w') ? Integer.parseInt(commandLine.getOptionValue('w')) : 64; final int messageSize = commandLine.hasOption('s') ? Integer.parseInt(commandLine.getOptionValue('s')) : 128; final boolean keyEnable = commandLine.hasOption('k') && Boolean.parseBoolean(commandLine.getOptionValue('k')); System.out.printf("topic %s threadCount %d messageSize %d keyEnable %s%n", topic, threadCount, messageSize, keyEnable); final Logger log = ClientLogger.getLog(); final Message msg = buildMessage(messageSize, topic); final ExecutorService sendThreadPool = Executors.newFixedThreadPool(threadCount); final StatsBenchmarkProducer statsBenchmark = new StatsBenchmarkProducer(); final Timer timer = new Timer("BenchmarkTimerThread", true); final LinkedList<Long[]> snapshotList = new LinkedList<Long[]>(); timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { snapshotList.addLast(statsBenchmark.createSnapshot()); if (snapshotList.size() > 10) { snapshotList.removeFirst(); } } }, 1000, 1000); timer.scheduleAtFixedRate(new TimerTask() { private void printStats() { if (snapshotList.size() >= 10) { Long[] begin = snapshotList.getFirst(); Long[] end = snapshotList.getLast(); final long sendTps = (long) (((end[3] - begin[3]) / (double) (end[0] - begin[0])) * 1000L); final double averageRT = (end[5] - begin[5]) / (double) (end[3] - begin[3]); System.out.printf( "Send TPS: %d Max RT: %d Average RT: %7.3f Send Failed: %d Response Failed: %d%n", sendTps, statsBenchmark.getSendMessageMaxRT().get(), averageRT, end[2], end[4]); } } @Override public void run() { try { this.printStats(); } catch (Exception e) { e.printStackTrace(); } } }, 10000, 10000); final DefaultMQProducer producer = new DefaultMQProducer("benchmark_producer"); producer.setInstanceName(Long.toString(System.currentTimeMillis())); if (commandLine.hasOption('n')) { String ns = commandLine.getOptionValue('n'); producer.setNamesrvAddr(ns); } producer.setCompressMsgBodyOverHowmuch(Integer.MAX_VALUE); producer.start(); for (int i = 0; i < threadCount; i++) { sendThreadPool.execute(new Runnable() { @Override public void run() { while (true) { try { final long beginTimestamp = System.currentTimeMillis(); if (keyEnable) { msg.setKeys(String.valueOf(beginTimestamp / 1000)); } producer.send(msg); statsBenchmark.getSendRequestSuccessCount().incrementAndGet(); statsBenchmark.getReceiveResponseSuccessCount().incrementAndGet(); final long currentRT = System.currentTimeMillis() - beginTimestamp; statsBenchmark.getSendMessageSuccessTimeTotal().addAndGet(currentRT); long prevMaxRT = statsBenchmark.getSendMessageMaxRT().get(); while (currentRT > prevMaxRT) { boolean updated = statsBenchmark.getSendMessageMaxRT().compareAndSet(prevMaxRT, currentRT); if (updated) break; prevMaxRT = statsBenchmark.getSendMessageMaxRT().get(); } } catch (RemotingException e) { statsBenchmark.getSendRequestFailedCount().incrementAndGet(); log.error("[BENCHMARK_PRODUCER] Send Exception", e); try { Thread.sleep(3000); } catch (InterruptedException ignored) { } } catch (InterruptedException e) { statsBenchmark.getSendRequestFailedCount().incrementAndGet(); try { Thread.sleep(3000); } catch (InterruptedException e1) { } } catch (MQClientException e) { statsBenchmark.getSendRequestFailedCount().incrementAndGet(); log.error("[BENCHMARK_PRODUCER] Send Exception", e); } catch (MQBrokerException e) { statsBenchmark.getReceiveResponseFailedCount().incrementAndGet(); log.error("[BENCHMARK_PRODUCER] Send Exception", e); try { Thread.sleep(3000); } catch (InterruptedException ignored) { } } } } }); } }
From source file:com.sshtools.j2ssh.agent.SshAgentSocketListener.java
/** * The main entry point for the application. This method currently accepts * the -start parameter which will look for the sshtools.agent system * property. To configure the agent and to get a valid location call with * -configure, set the system sshtools.home system property and start. * * @param args the programs arguments//from ww w .j a va2 s . c o m */ public static void main(String[] args) { if (args.length > 0) { if (args[0].equals("-start")) { Thread thread = new Thread(new Runnable() { public void run() { try { SshAgentSocketListener agent = new SshAgentSocketListener( System.getProperty("sshtools.agent"), new KeyStore()); agent.start(); } catch (Exception ex) { ex.printStackTrace(); } } }); thread.start(); } if (args[0].equals("-configure")) { System.out.println("SET SSHTOOLS_AGENT=localhost:" + String.valueOf(configureNewLocation())); } } }
From source file:com.mockey.runner.JettyRunner.java
public static void main(String[] args) throws Exception { if (args == null) args = new String[0]; // Initialize the argument parser SimpleJSAP jsap = new SimpleJSAP("java -jar Mockey.jar", "Starts a Jetty server running Mockey"); jsap.registerParameter(new FlaggedOption(ARG_PORT, JSAP.INTEGER_PARSER, "8080", JSAP.NOT_REQUIRED, 'p', ARG_PORT, "port to run Jetty on")); jsap.registerParameter(new FlaggedOption(BSC.FILE, JSAP.STRING_PARSER, MockeyXmlFileManager.MOCK_SERVICE_DEFINITION, JSAP.NOT_REQUIRED, 'f', BSC.FILE, "Relative path to a mockey-definitions file to initialize Mockey, relative to where you're starting Mockey")); jsap.registerParameter(new FlaggedOption(BSC.URL, JSAP.STRING_PARSER, "", JSAP.NOT_REQUIRED, 'u', BSC.URL, "URL to a mockey-definitions file to initialize Mockey")); jsap.registerParameter(new FlaggedOption(BSC.TRANSIENT, JSAP.BOOLEAN_PARSER, "true", JSAP.NOT_REQUIRED, 't', BSC.TRANSIENT, "Read only mode if set to true, no updates are made to the file system.")); jsap.registerParameter(new FlaggedOption(BSC.FILTERTAG, JSAP.STRING_PARSER, "", JSAP.NOT_REQUIRED, 'F', BSC.FILTERTAG,/* ww w. j a v a 2s. c o m*/ "Filter tag for services and scenarios, useful for 'only use information with this tag'. ")); jsap.registerParameter( new Switch(ARG_QUIET, 'q', "quiet", "Runs in quiet mode and does not loads the browser")); jsap.registerParameter(new FlaggedOption(BSC.HEADLESS, JSAP.BOOLEAN_PARSER, "false", JSAP.NOT_REQUIRED, 'H', BSC.HEADLESS, "Headless flag. Default is 'false'. Set to 'true' if you do not want Mockey to spawn a browser thread upon startup.")); // parse the command line options JSAPResult config = jsap.parse(args); // Bail out if they asked for the --help if (jsap.messagePrinted()) { System.exit(1); } // Construct the new arguments for jetty-runner int port = config.getInt(ARG_PORT); boolean transientState = true; // We can add more things to the quite mode. For now we are just not launching browser boolean isQuiteMode = false; try { transientState = config.getBoolean(BSC.TRANSIENT); isQuiteMode = config.getBoolean(ARG_QUIET); } catch (Exception e) { // } // Initialize Log4J file roller appender. StartUpServlet.getDebugFile(); InputStream log4jInputStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream("WEB-INF/log4j.properties"); Properties log4JProperties = new Properties(); log4JProperties.load(log4jInputStream); PropertyConfigurator.configure(log4JProperties); Server server = new Server(port); WebAppContext webapp = new WebAppContext(); webapp.setContextPath("/"); webapp.setConfigurations(new Configuration[] { new PreCompiledJspConfiguration() }); ClassPathResourceHandler resourceHandler = new ClassPathResourceHandler(); resourceHandler.setContextPath("/"); ContextHandlerCollection contexts = new ContextHandlerCollection(); contexts.addHandler(resourceHandler); contexts.addHandler(webapp); server.setHandler(contexts); server.start(); // Construct the arguments for Mockey String file = String.valueOf(config.getString(BSC.FILE)); String url = String.valueOf(config.getString(BSC.URL)); String filterTag = config.getString(BSC.FILTERTAG); String fTagParam = ""; boolean headless = config.getBoolean(BSC.HEADLESS); if (filterTag != null) { fTagParam = "&" + BSC.FILTERTAG + "=" + URLEncoder.encode(filterTag, "UTF-8"); } // Startup displays a big message and URL redirects after x seconds. // Snazzy. String initUrl = HOMEURL; // BUT...if a file is defined, (which it *should*), // then let's initialize with it instead. if (url != null && url.trim().length() > 0) { URLEncoder.encode(initUrl, "UTF-8"); initUrl = HOMEURL + "?" + BSC.ACTION + "=" + BSC.INIT + "&" + BSC.TRANSIENT + "=" + transientState + "&" + BSC.URL + "=" + URLEncoder.encode(url, "UTF-8") + fTagParam; } else if (file != null && file.trim().length() > 0) { URLEncoder.encode(initUrl, "UTF-8"); initUrl = HOMEURL + "?" + BSC.ACTION + "=" + BSC.INIT + "&" + BSC.TRANSIENT + "=" + transientState + "&" + BSC.FILE + "=" + URLEncoder.encode(file, "UTF-8") + fTagParam; } else { initUrl = HOMEURL + "?" + BSC.ACTION + "=" + BSC.INIT + "&" + BSC.TRANSIENT + "=" + transientState + "&" + BSC.FILE + "=" + URLEncoder.encode(MockeyXmlFileManager.MOCK_SERVICE_DEFINITION, "UTF-8") + fTagParam; } if (!(headless || isQuiteMode)) { new Thread(new BrowserThread("http://127.0.0.1", String.valueOf(port), initUrl, 0)).start(); server.join(); } else { initializeMockey(new URL("http://127.0.0.1" + ":" + String.valueOf(port) + initUrl)); } }
From source file:com.mvdb.etl.actions.ModifyCustomerData.java
public static void main(String[] args) { ActionUtils.assertEnvironmentSetupOk(); ActionUtils.assertFileExists("~/.mvdb", "~/.mvdb missing. Existing."); ActionUtils.assertFileExists("~/.mvdb/status.InitCustomerData.complete", "300init-customer-data.sh not executed yet. Exiting"); //This check is not required as data can be modified any number of times //ActionUtils.assertFileDoesNotExist("~/.mvdb/status.ModifyCustomerData.complete", "ModifyCustomerData already done. Start with 100init.sh if required. Exiting"); ActionUtils.setUpInitFileProperty(); ActionUtils.createMarkerFile("~/.mvdb/status.ModifyCustomerData.start", true); String customerName = null;/* w w w . j ava 2 s. c o m*/ //Date startDate = null; //Date endDate = null; final CommandLineParser cmdLinePosixParser = new PosixParser(); final Options posixOptions = constructPosixOptions(); CommandLine commandLine; try { commandLine = cmdLinePosixParser.parse(posixOptions, args); // if (commandLine.hasOption("startDate")) // { // String startDateStr = commandLine.getOptionValue("startDate"); // startDate = ActionUtils.getDate(startDateStr); // } // if (commandLine.hasOption("endDate")) // { // String endDateStr = commandLine.getOptionValue("endDate"); // endDate = ActionUtils.getDate(endDateStr); // } if (commandLine.hasOption("customerName")) { customerName = commandLine.getOptionValue("customerName"); } } catch (ParseException parseException) // checked exception { System.err.println( "Encountered exception while parsing using PosixParser:\n" + parseException.getMessage()); } if (customerName == null) { System.err.println("customerName has not been specified. Aborting..."); System.exit(1); } // if (startDate == null) // { // System.err.println("startDate has not been specified with the correct format YYYYMMddHHmmss. Aborting..."); // System.exit(1); // } // // if (endDate == null) // { // System.err.println("endDate has not been specified with the correct format YYYYMMddHHmmss. Aborting..."); // System.exit(1); // } // // if (endDate.after(startDate) == false) // { // System.err.println("endDate must be after startDate. Aborting..."); // System.exit(1); // } ApplicationContext context = Top.getContext(); final OrderDAO orderDAO = (OrderDAO) context.getBean("orderDAO"); long maxId = orderDAO.findMaxId(); long totalOrders = orderDAO.findTotalOrders(); long modifyCount = (long) (totalOrders * 0.1); String lastUsedEndTimeStr = ActionUtils.getConfigurationValue(customerName, ConfigurationKeys.LAST_USED_END_TIME); long lastUsedEndTime = Long.parseLong(lastUsedEndTimeStr); Date startDate1 = new Date(); startDate1.setTime(lastUsedEndTime + 1000 * 60 * 60 * 24 * 1); Date endDate1 = new Date(startDate1.getTime() + 1000 * 60 * 60 * 24 * 1); for (int i = 0; i < modifyCount; i++) { Date updateDate = RandomUtil.getRandomDateInRange(startDate1, endDate1); long orderId = (long) Math.floor((Math.random() * maxId)) + 1L; logger.info("Modify Id " + orderId + " in orders"); Order theOrder = orderDAO.findByOrderId(orderId); // System.out.println("theOrder : " + theOrder); theOrder.setNote(RandomUtil.getRandomString(4)); theOrder.setUpdateTime(updateDate); theOrder.setSaleCode(RandomUtil.getRandomInt()); orderDAO.update(theOrder); // System.out.println("theOrder Modified: " + theOrder); } ActionUtils.setConfigurationValue(customerName, ConfigurationKeys.LAST_USED_END_TIME, String.valueOf(endDate1.getTime())); logger.info("Modified " + modifyCount + " orders"); ActionUtils.createMarkerFile("~/.mvdb/status.ModifyCustomerData.complete", true); }
From source file:net.myrrix.online.eval.AUCEvaluator.java
public static void main(String[] args) throws Exception { EvaluationResult result = new AUCEvaluator().evaluate(new File(args[0])); log.info(String.valueOf(result)); }
From source file:net.myrrix.online.eval.ReconstructionEvaluator.java
public static void main(String[] args) throws Exception { EvaluationResult result = new ReconstructionEvaluator().evaluate(new File(args[0])); log.info(String.valueOf(result)); }
From source file:org.datagator.tools.importer.Main.java
public static void main(String[] args) throws IOException { int columnHeaders = 0; // cli input int rowHeaders = 0; // cli input try {/*from w ww. ja va2s. c o m*/ CommandLine cmds = parser.parse(opts, args); if (cmds.hasOption("filter")) { throw new UnsupportedOperationException("Not supported yet."); } if (cmds.hasOption("layout")) { String[] layout = cmds.getOptionValues("layout"); if ((layout == null) || (layout.length != 2)) { throw new IllegalArgumentException("Bad layout."); } try { columnHeaders = Integer.valueOf(layout[0]); rowHeaders = Integer.valueOf(layout[1]); if ((columnHeaders < 0) || (rowHeaders < 0)) { throw new IllegalArgumentException("Bad layout."); } } catch (NumberFormatException ex) { throw new IllegalArgumentException(ex); } } if (cmds.hasOption("help")) { help.printHelp("importer", opts, true); System.exit(EX_OK); } // positional arguments, i.e., input file name(s) args = cmds.getArgs(); } catch (ParseException ex) { throw new IllegalArgumentException(ex); } catch (IllegalArgumentException ex) { help.printHelp("importer", opts, true); throw ex; } JsonGenerator jg = json.createGenerator(System.out, JsonEncoding.UTF8); jg.setPrettyPrinter(new StandardPrinter()); final Extractor extractor; if (args.length == 1) { extractor = new FileExtractor(new File(args[0])); } else if (args.length > 1) { throw new UnsupportedOperationException("Not supported yet."); } else { throw new IllegalArgumentException("Missing input."); } int columnsCount = -1; int matrixCount = 0; ArrayDeque<String> stack = new ArrayDeque<String>(); AtomType token = extractor.nextAtom(); while (token != null) { switch (token) { case FLOAT: case INTEGER: case STRING: case NULL: jg.writeObject(extractor.getCurrentAtomData()); break; case START_RECORD: jg.writeStartArray(); break; case END_RECORD: int _numFields = (Integer) extractor.getCurrentAtomData(); if (columnsCount < 0) { columnsCount = _numFields; } else if (columnsCount != _numFields) { throw new RuntimeException(String.format("row %s has different length than previous rows", String.valueOf(_numFields - 1))); } jg.writeEndArray(); break; case START_GROUP: stack.push(String.valueOf(extractor.getCurrentAtomData())); jg.writeStartObject(); jg.writeStringField("kind", "datagator#Matrix"); jg.writeNumberField("columnHeaders", columnHeaders); jg.writeNumberField("rowHeaders", rowHeaders); jg.writeFieldName("rows"); jg.writeStartArray(); break; case END_GROUP: int rowsCount = (Integer) extractor.getCurrentAtomData(); if (rowsCount == 0) { jg.writeStartArray(); jg.writeEndArray(); rowsCount = 1; columnsCount = 0; } jg.writeEndArray(); jg.writeNumberField("rowsCount", rowsCount); jg.writeNumberField("columnsCount", columnsCount); jg.writeEndObject(); matrixCount += 1; stack.pop(); break; default: break; } token = extractor.nextAtom(); } jg.close(); System.exit(EX_OK); }
From source file:edu.indiana.d2i.sloan.internal.CreateVMSimulator.java
public static void main(String[] args) { CreateVMSimulator simulator = new CreateVMSimulator(); CommandLineParser parser = new PosixParser(); try {/* w w w .ja va2 s . c o m*/ CommandLine line = simulator.parseCommandLine(parser, args); String imagePath = line.getOptionValue(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.IMAGE_PATH)); int vcpu = Integer.parseInt(line.getOptionValue(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.VCPU))); int mem = Integer.parseInt(line.getOptionValue(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.MEM))); if (!HypervisorCmdSimulator.resourceExist(imagePath)) { logger.error(String.format("Cannot find requested image: %s", imagePath)); System.exit(ERROR_CODE.get(ERROR_STATE.IMAGE_NOT_EXIST)); } if (!hasEnoughCPUs(vcpu)) { logger.error(String.format("Don't have enough cpus, requested %d", vcpu)); System.exit(ERROR_CODE.get(ERROR_STATE.NOT_ENOUGH_CPU)); } if (!hasEnoughMem(mem)) { logger.error(String.format("Don't have enough memory, requested %d", mem)); System.exit(ERROR_CODE.get(ERROR_STATE.NOT_ENOUGH_MEM)); } String wdir = line.getOptionValue(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.WORKING_DIR)); if (HypervisorCmdSimulator.resourceExist(wdir)) { logger.error(String.format("Working directory %s already exists ", wdir)); System.exit(ERROR_CODE.get(ERROR_STATE.VM_ALREADY_EXIST)); } // copy VM image to working directory File imageFile = new File(imagePath); FileUtils.copyFile(imageFile, new File(HypervisorCmdSimulator.cleanPath(wdir) + imageFile.getName())); // write state as property file so that we can query later Properties prop = new Properties(); prop.put(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.IMAGE_PATH), imagePath); prop.put(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.VCPU), String.valueOf(vcpu)); prop.put(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.MEM), String.valueOf(mem)); prop.put(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.WORKING_DIR), wdir); prop.put(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.VNC_PORT), line.getOptionValue(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.VNC_PORT))); prop.put(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.SSH_PORT), line.getOptionValue(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.SSH_PORT))); prop.put(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.LOGIN_USERNAME), line.getOptionValue(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.LOGIN_USERNAME))); prop.put(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.LOGIN_PASSWD), line.getOptionValue(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.LOGIN_PASSWD))); // write VM state as shutdown prop.put(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.VM_STATE), VMState.SHUTDOWN.toString()); // write VM mode as undefined prop.put(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.VM_MODE), VMMode.NOT_DEFINED.toString()); prop.store( new FileOutputStream(new File( HypervisorCmdSimulator.cleanPath(wdir) + HypervisorCmdSimulator.VM_INFO_FILE_NAME)), ""); // do other related settings try { Thread.sleep(1000); } catch (InterruptedException e) { logger.error(e.getMessage()); } // success System.exit(0); } catch (ParseException e) { logger.error(String.format("Cannot parse input arguments: %s%n, expected:%n%s", StringUtils.join(args, " "), simulator.getUsage(100, "", 5, 5, ""))); System.exit(ERROR_CODE.get(ERROR_STATE.INVALID_INPUT_ARGS)); } catch (IOException e) { logger.error(e.getMessage(), e); System.exit(ERROR_CODE.get(ERROR_STATE.IO_ERR)); } }
From source file:net.myrrix.online.eval.PrecisionRecallEvaluator.java
public static void main(String[] args) throws Exception { EvaluationResult result = new PrecisionRecallEvaluator().evaluate(new File(args[0])); log.info(String.valueOf(result)); }