List of usage examples for java.util List size
int size();
From source file:com.joyent.manta.cli.MantaCLI.java
public static void main(final String[] args) { final CommandLine application = new CommandLine(new MantaCLI()); application.registerConverter(Path.class, Paths::get); List<CommandLine> parsedCommands = null; try {//from ww w. j ava 2 s . c o m parsedCommands = application.parse(args); } catch (CommandLine.ParameterException ex) { System.err.println(ex.getMessage()); CommandLine.usage(new MantaCLI(), System.err); return; } MantaCLI cli = (MantaCLI) parsedCommands.get(0).getCommand(); if (cli.isHelpRequested) { application.usage(System.out); return; } if (cli.isVersionRequested) { System.out.println("java-manta-client: " + MantaVersion.VERSION); return; } if (parsedCommands.size() == 1) { // no subcmd given application.usage(System.err); return; } CommandLine deepest = parsedCommands.get(parsedCommands.size() - 1); MantaSubCommand subcommand = (MantaSubCommand) deepest.getCommand(); if (subcommand.isHelpRequested) { CommandLine.usage(deepest.getCommand(), System.err); return; } if (subcommand.logLevel != null) { Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); root.setLevel(Level.valueOf(subcommand.logLevel.toString())); } subcommand.run(); }
From source file:com.aerospike.load.AerospikeLoad.java
public static void main(String[] args) throws IOException { Thread statPrinter = new Thread(new PrintStat(counters)); try {/*ww w . j a v a 2s . c o m*/ log.info("Aerospike loader started"); Options options = new Options(); options.addOption("h", "host", true, "Server hostname (default: localhost)"); options.addOption("p", "port", true, "Server port (default: 3000)"); options.addOption("n", "namespace", true, "Namespace (default: test)"); options.addOption("s", "set", true, "Set name. (default: null)"); options.addOption("c", "config", true, "Column definition file name"); options.addOption("wt", "write-threads", true, "Number of writer threads (default: Number of cores * 5)"); options.addOption("rt", "read-threads", true, "Number of reader threads (default: Number of cores * 1)"); options.addOption("l", "rw-throttle", true, "Throttling of reader to writer(default: 10k) "); options.addOption("tt", "transaction-timeout", true, "write transaction timeout in miliseconds(default: No timeout)"); options.addOption("et", "expiration-time", true, "Expiration time of records in seconds (default: never expire)"); options.addOption("T", "timezone", true, "Timezone of source where data dump is taken (default: local timezone)"); options.addOption("ec", "abort-error-count", true, "Error count to abort (default: 0)"); options.addOption("wa", "write-action", true, "Write action if key already exists (default: update)"); options.addOption("v", "verbose", false, "Logging all"); options.addOption("u", "usage", false, "Print usage."); CommandLineParser parser = new PosixParser(); CommandLine cl = parser.parse(options, args, false); if (args.length == 0 || cl.hasOption("u")) { logUsage(options); return; } if (cl.hasOption("l")) { rwThrottle = Integer.parseInt(cl.getOptionValue("l")); } else { rwThrottle = Constants.READLOAD; } // Get all command line options params = Utils.parseParameters(cl); //Get client instance AerospikeClient client = new AerospikeClient(params.host, params.port); if (!client.isConnected()) { log.error("Client is not able to connect:" + params.host + ":" + params.port); return; } if (params.verbose) { log.setLevel(Level.DEBUG); } // Get available processors to calculate default number of threads int cpus = Runtime.getRuntime().availableProcessors(); nWriterThreads = cpus * scaleFactor; nReaderThreads = cpus; // Get writer thread count if (cl.hasOption("wt")) { nWriterThreads = Integer.parseInt(cl.getOptionValue("wt")); nWriterThreads = (nWriterThreads > 0 ? (nWriterThreads > Constants.MAX_THREADS ? Constants.MAX_THREADS : nWriterThreads) : 1); log.debug("Using writer Threads: " + nWriterThreads); } writerPool = Executors.newFixedThreadPool(nWriterThreads); // Get reader thread count if (cl.hasOption("rt")) { nReaderThreads = Integer.parseInt(cl.getOptionValue("rt")); nReaderThreads = (nReaderThreads > 0 ? (nReaderThreads > Constants.MAX_THREADS ? Constants.MAX_THREADS : nReaderThreads) : 1); log.debug("Using reader Threads: " + nReaderThreads); } String columnDefinitionFileName = cl.getOptionValue("c", null); log.debug("Column definition files/directory: " + columnDefinitionFileName); if (columnDefinitionFileName == null) { log.error("Column definition files/directory not specified. use -c <file name>"); return; } File columnDefinitionFile = new File(columnDefinitionFileName); if (!columnDefinitionFile.exists()) { log.error("Column definition files/directory does not exist: " + Utils.getFileName(columnDefinitionFileName)); return; } // Get data file list String[] files = cl.getArgs(); if (files.length == 0) { log.error("No data file Specified: add <file/dir name> to end of the command "); return; } List<String> allFileNames = new ArrayList<String>(); allFileNames = Utils.getFileNames(files); if (allFileNames.size() == 0) { log.error("Given datafiles/directory does not exist"); return; } for (int i = 0; i < allFileNames.size(); i++) { log.debug("File names:" + Utils.getFileName(allFileNames.get(i))); File file = new File(allFileNames.get(i)); counters.write.recordTotal = counters.write.recordTotal + file.length(); } //remove column definition file from list allFileNames.remove(columnDefinitionFileName); log.info("Number of data files:" + allFileNames.size()); /** * Process column definition file to get meta data and bin mapping. */ metadataColumnDefs = new ArrayList<ColumnDefinition>(); binColumnDefs = new ArrayList<ColumnDefinition>(); metadataConfigs = new HashMap<String, String>(); if (Parser.processJSONColumnDefinitions(columnDefinitionFile, metadataConfigs, metadataColumnDefs, binColumnDefs, params)) { log.info("Config file processed."); } else { throw new Exception("Config file parsing Error"); } // Add metadata of config to parameters String metadata; if ((metadata = metadataConfigs.get(Constants.INPUT_TYPE)) != null) { params.fileType = metadata; if (params.fileType.equals(Constants.CSV_FILE)) { // Version check metadata = metadataConfigs.get(Constants.VERSION); String[] vNumber = metadata.split("\\."); int v1 = Integer.parseInt(vNumber[0]); int v2 = Integer.parseInt(vNumber[1]); if ((v1 <= Constants.MajorV) && (v2 <= Constants.MinorV)) { log.debug("Config version used:" + metadata); } else throw new Exception("\"" + Constants.VERSION + ":" + metadata + "\" is not Supported"); // Set delimiter if ((metadata = metadataConfigs.get(Constants.DELIMITER)) != null && metadata.length() == 1) { params.delimiter = metadata.charAt(0); } else { log.warn("\"" + Constants.DELIMITER + ":" + metadata + "\" is not properly specified in config file. Default is ','"); } if ((metadata = metadataConfigs.get(Constants.IGNORE_FIRST_LINE)) != null) { params.ignoreFirstLine = metadata.equals("true"); } else { log.warn("\"" + Constants.IGNORE_FIRST_LINE + ":" + metadata + "\" is not properly specified in config file. Default is false"); } if ((metadata = metadataConfigs.get(Constants.COLUMNS)) != null) { counters.write.colTotal = Integer.parseInt(metadata); } else { throw new Exception("\"" + Constants.COLUMNS + ":" + metadata + "\" is not properly specified in config file"); } } else { throw new Exception("\"" + params.fileType + "\" is not supported in config file"); } } else { throw new Exception("\"" + Constants.INPUT_TYPE + "\" is not specified in config file"); } // add config input to column definitions if (params.fileType.equals(Constants.CSV_FILE)) { List<String> binName = null; if (params.ignoreFirstLine) { String line; BufferedReader br = new BufferedReader( new InputStreamReader(new FileInputStream(allFileNames.get(0)), "UTF8")); if ((line = br.readLine()) != null) { binName = Parser.getCSVRawColumns(line, params.delimiter); br.close(); if (binName.size() != counters.write.colTotal) { throw new Exception("Number of column in config file and datafile are mismatch." + " Datafile: " + Utils.getFileName(allFileNames.get(0)) + " Configfile: " + Utils.getFileName(columnDefinitionFileName)); } } } //update columndefs for metadata for (int i = 0; i < metadataColumnDefs.size(); i++) { if (metadataColumnDefs.get(i).staticValue) { } else { if (metadataColumnDefs.get(i).binValuePos < 0) { if (metadataColumnDefs.get(i).columnName == null) { if (metadataColumnDefs.get(i).jsonPath == null) { log.error("dynamic metadata having improper info" + metadataColumnDefs.toString()); //TODO } else { //TODO check for json_path } } else { if (params.ignoreFirstLine) { if (binName.indexOf(metadataColumnDefs.get(i).binValueHeader) != -1) { metadataColumnDefs.get(i).binValuePos = binName .indexOf(metadataColumnDefs.get(i).binValueHeader); } else { throw new Exception("binName missing in data file:" + metadataColumnDefs.get(i).binValueHeader); } } } } else { if (params.ignoreFirstLine) metadataColumnDefs.get(i).binValueHeader = binName .get(metadataColumnDefs.get(i).binValuePos); } } if ((!metadataColumnDefs.get(i).staticValue) && (metadataColumnDefs.get(i).binValuePos < 0)) { throw new Exception("Information for bin mapping is missing in config file:" + metadataColumnDefs.get(i)); } if (metadataColumnDefs.get(i).srcType == null) { throw new Exception( "Source data type is not properly mentioned:" + metadataColumnDefs.get(i)); } if (metadataColumnDefs.get(i).binNameHeader == Constants.SET && !metadataColumnDefs.get(i).srcType.equals(SrcColumnType.STRING)) { throw new Exception("Set name should be string type:" + metadataColumnDefs.get(i)); } if (metadataColumnDefs.get(i).binNameHeader.equalsIgnoreCase(Constants.SET) && params.set != null) { throw new Exception( "Set name is given both in config file and commandline. Provide only once."); } } //update columndefs for bins for (int i = 0; i < binColumnDefs.size(); i++) { if (binColumnDefs.get(i).staticName) { } else { if (binColumnDefs.get(i).binNamePos < 0) { if (binColumnDefs.get(i).columnName == null) { if (binColumnDefs.get(i).jsonPath == null) { log.error("dynamic bin having improper info"); //TODO } else { //TODO check for json_path } } else { if (params.ignoreFirstLine) { if (binName.indexOf(binColumnDefs.get(i).binNameHeader) != -1) { binColumnDefs.get(i).binNamePos = binName .indexOf(binColumnDefs.get(i).binNameHeader); } else { throw new Exception("binName missing in data file:" + binColumnDefs.get(i).binNameHeader); } } } } else { if (params.ignoreFirstLine) binColumnDefs.get(i).binNameHeader = binName.get(binColumnDefs.get(i).binNamePos); } } if (binColumnDefs.get(i).staticValue) { } else { if (binColumnDefs.get(i).binValuePos < 0) { if (binColumnDefs.get(i).columnName == null) { if (binColumnDefs.get(i).jsonPath == null) { log.error("dynamic bin having improper info"); //TODO } else { //TODO check for json_path } } else { if (params.ignoreFirstLine) { if (binName.contains(binColumnDefs.get(i).binValueHeader)) { binColumnDefs.get(i).binValuePos = binName .indexOf(binColumnDefs.get(i).binValueHeader); } else if (!binColumnDefs.get(i).binValueHeader.toLowerCase() .equals(Constants.SYSTEM_TIME)) { throw new Exception("Wrong column name mentioned in config file:" + binColumnDefs.get(i).binValueHeader); } } } } else { if (params.ignoreFirstLine) binColumnDefs.get(i).binValueHeader = binName.get(binColumnDefs.get(i).binValuePos); } //check for missing entries in config file if (binColumnDefs.get(i).binValuePos < 0 && binColumnDefs.get(i).binValueHeader == null) { throw new Exception("Information missing(Value header or bin mapping) in config file:" + binColumnDefs.get(i)); } //check for proper data type in config file. if (binColumnDefs.get(i).srcType == null) { throw new Exception( "Source data type is not properly mentioned:" + binColumnDefs.get(i)); } //check for valid destination type if ((binColumnDefs.get(i).srcType.equals(SrcColumnType.TIMESTAMP) || binColumnDefs.get(i).srcType.equals(SrcColumnType.BLOB)) && binColumnDefs.get(i).dstType == null) { throw new Exception("Destination type is not mentioned: " + binColumnDefs.get(i)); } //check for encoding if (binColumnDefs.get(i).dstType != null && binColumnDefs.get(i).encoding == null) { throw new Exception( "Encoding is not given for src-dst type conversion:" + binColumnDefs.get(i)); } //check for valid encoding if (binColumnDefs.get(i).srcType.equals(SrcColumnType.BLOB) && !binColumnDefs.get(i).encoding.equals(Constants.HEX_ENCODING)) { throw new Exception("Wrong encoding for blob data:" + binColumnDefs.get(i)); } } //Check static bin name mapped to dynamic bin value if ((binColumnDefs.get(i).binNamePos == binColumnDefs.get(i).binValuePos) && (binColumnDefs.get(i).binNamePos != -1)) { throw new Exception("Static bin name mapped to dynamic bin value:" + binColumnDefs.get(i)); } //check for missing entries in config file if (binColumnDefs.get(i).binNameHeader == null && binColumnDefs.get(i).binNameHeader.length() > Constants.BIN_NAME_LENGTH) { throw new Exception("Information missing binName or large binName in config file:" + binColumnDefs.get(i)); } } } log.info(params.toString()); log.debug("MetadataConfig:" + metadataColumnDefs); log.debug("BinColumnDefs:" + binColumnDefs); // Start PrintStat thread statPrinter.start(); // Reader pool size ExecutorService readerPool = Executors.newFixedThreadPool( nReaderThreads > allFileNames.size() ? allFileNames.size() : nReaderThreads); log.info("Reader pool size : " + nReaderThreads); // Submit all tasks to writer threadpool. for (String aFile : allFileNames) { log.debug("Submitting task for: " + aFile); readerPool.submit(new AerospikeLoad(aFile, client, params)); } // Wait for reader pool to complete readerPool.shutdown(); log.info("Shutdown down reader thread pool"); while (!readerPool.isTerminated()) ; //readerPool.awaitTermination(20, TimeUnit.MINUTES); log.info("Reader thread pool terminated"); // Wait for writer pool to complete after getting all tasks from reader pool writerPool.shutdown(); log.info("Shutdown down writer thread pool"); while (!writerPool.isTerminated()) ; log.info("Writer thread pool terminated"); // Print final statistic of aerospike-loader. log.info("Final Statistics of importer: (Succesfull Writes = " + counters.write.writeCount.get() + ", " + "Errors=" + (counters.write.writeErrors.get() + counters.write.readErrors.get() + counters.write.processingErrors.get()) + "(" + (counters.write.writeErrors.get()) + "-Write," + counters.write.readErrors.get() + "-Read," + counters.write.processingErrors.get() + "-Processing)"); } catch (Exception e) { log.error(e); if (log.isDebugEnabled()) { e.printStackTrace(); } } finally { // Stop statistic printer thread. statPrinter.interrupt(); log.info("Aerospike loader completed"); } }
From source file:com.johnson.grab.browser.HttpClientUtil.java
public static void main(String[] args) throws IOException, CrawlException { // final String url = "http://192.168.24.248:8080/HbaseDb/youku/"; // String url = "http://business.sohu.com/20131021/n388557348.shtml?pvid=tc_business&a=&b=%E6%A5%BC%E5%B8%82%E6%B3%A1%E6%B2%AB%E7%A0%B4%E7%81%AD%E5%B0%86%E5%9C%A82015%E5%B9%B4%E5%BA%95%E4%B9%8B%E5%89%8D"; final String url = "http://www.sohu.com"; final int threadNum = 20; final int loop = 100; Thread[] threads = new Thread[threadNum]; final List<Integer> times = new ArrayList<Integer>(); final long s = System.currentTimeMillis(); for (int i = 0; i < threads.length; i++) { threads[i] = new Thread() { public void run() { for (int i = 0; i < loop; i++) { try { getContent(url); } catch (CrawlException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (Throwable t) { t.printStackTrace(); }//from w w w . j a v a 2 s.co m long e = System.currentTimeMillis(); times.add((int) (e - s)); } } }; threads[i].start(); } while (times.size() < threadNum * loop) { int current = times.size(); System.out.println("total: " + threadNum * loop + ", current: " + current + ", left: " + (threadNum * loop - current)); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } long e = System.currentTimeMillis(); int totalTime = 0; for (Integer time : times) { totalTime += time; } System.out.println("------------------------------------------------------"); System.out.println("thread num: " + threadNum + ", loop: " + loop); System.out.println("totalTime: " + totalTime + ", averTime: " + totalTime / (threadNum * loop)); System.out.println("finalTime: " + (e - s) + ", throughput: " + (e - s) / (threadNum * loop)); }
From source file:net.dontdrinkandroot.lastfm.api.CheckImplementationStatus.java
public static void main(final String[] args) throws DocumentException, IOException { CheckImplementationStatus.xmlReader = new Parser(); CheckImplementationStatus.saxReader = new SAXReader(CheckImplementationStatus.xmlReader); final String packagePrefix = "net.dontdrinkandroot.lastfm.api.model."; final Map<String, Map<String, URL>> packages = CheckImplementationStatus.parseOverview(); final StringBuffer html = new StringBuffer(); html.append("<html>\n"); html.append("<head>\n"); html.append("<title>Implementation Status</title>\n"); html.append("</head>\n"); html.append("<body>\n"); html.append("<h1>Implementation Status</h1>\n"); final StringBuffer wiki = new StringBuffer(); int numImplemented = 0; int numTested = 0; int numMethods = 0; final List<String> packageList = new ArrayList<String>(packages.keySet()); Collections.sort(packageList); for (final String pkg : packageList) { System.out.println("Parsing " + pkg); html.append("<h2>" + pkg + "</h2>\n"); wiki.append("\n===== " + pkg + " =====\n\n"); Class<?> modelClass = null; final String className = packagePrefix + pkg; try {/* w ww . j av a 2s .com*/ modelClass = Class.forName(className); System.out.println("\tClass " + modelClass.getName() + " exists"); } catch (final ClassNotFoundException e) { // e.printStackTrace(); System.out.println("\t" + className + ": DOES NOT exist"); } Class<?> testClass = null; final String testClassName = packagePrefix + pkg + "Test"; try { testClass = Class.forName(testClassName); System.out.println("\tTestClass " + testClass.getName() + " exists"); } catch (final ClassNotFoundException e) { // e.printStackTrace(); System.out.println("\t" + testClassName + ": TestClass for DOES NOT exist"); } final List<String> methods = new ArrayList<String>(packages.get(pkg).keySet()); Collections.sort(methods); final Method[] classMethods = modelClass.getMethods(); final Method[] testMethods = testClass.getMethods(); html.append("<table>\n"); html.append("<tr><th>Method</th><th>Implemented</th><th>Tested</th></tr>\n"); wiki.append("^ Method ^ Implemented ^ Tested ^\n"); numMethods += methods.size(); for (final String method : methods) { System.out.println("\t\t parsing " + method); html.append("<tr>\n"); html.append("<td>" + method + "</td>\n"); wiki.append("| " + method + " "); boolean classMethodFound = false; for (final Method classMethod : classMethods) { if (classMethod.getName().equals(method)) { classMethodFound = true; break; } } if (classMethodFound) { System.out.println("\t\t\tMethod " + method + " found"); html.append("<td style=\"background-color: green\">true</td>\n"); wiki.append("| yes "); numImplemented++; } else { System.out.println("\t\t\t" + method + " NOT found"); html.append("<td style=\"background-color: red\">false</td>\n"); wiki.append("| **no** "); } boolean testMethodFound = false; final String testMethodName = "test" + StringUtils.capitalize(method); for (final Method testMethod : testMethods) { if (testMethod.getName().equals(testMethodName)) { testMethodFound = true; break; } } if (testMethodFound) { System.out.println("\t\t\tTestMethod " + method + " found"); html.append("<td style=\"background-color: green\">true</td>\n"); wiki.append("| yes |\n"); numTested++; } else { System.out.println("\t\t\t" + testMethodName + " NOT found"); html.append("<td style=\"background-color: red\">false</td>\n"); wiki.append("| **no** |\n"); } html.append("</tr>\n"); } html.append("</table>\n"); // for (String methodName : methods) { // URL url = pkg.getValue().get(methodName); // System.out.println("PARSING: " + pkg.getKey() + "." + methodName + ": " + url); // String html = loadIntoString(url); // String description = null; // Matcher descMatcher = descriptionPattern.matcher(html); // if (descMatcher.find()) { // description = descMatcher.group(1).trim(); // } // boolean post = false; // Matcher postMatcher = postPattern.matcher(html); // if (postMatcher.find()) { // post = true; // } // Matcher paramsMatcher = paramsPattern.matcher(html); // List<String[]> params = new ArrayList<String[]>(); // boolean authenticated = false; // if (paramsMatcher.find()) { // String paramsString = paramsMatcher.group(1); // Matcher paramMatcher = paramPattern.matcher(paramsString); // while (paramMatcher.find()) { // String[] param = new String[3]; // param[0] = paramMatcher.group(1); // param[1] = paramMatcher.group(3); // param[2] = paramMatcher.group(5); // // System.out.println(paramMatcher.group(1) + "|" + paramMatcher.group(3) + "|" + // paramMatcher.group(5)); // if (param[0].equals("")) { // /* DO NOTHING */ // } else if (param[0].equals("api_key")) { // /* DO NOTHING */ // } else if (param[0].equals("api_sig")) { // authenticated = true; // } else { // params.add(param); // } // } // } // } // count++; // } html.append("<hr />"); html.append("<p>" + numImplemented + "/" + numMethods + " implemented (" + numImplemented * 100 / numMethods + "%)</p>"); html.append("<p>" + numTested + "/" + numMethods + " tested (" + numTested * 100 / numMethods + "%)</p>"); html.append("</body>\n"); html.append("</html>\n"); FileOutputStream out = new FileOutputStream(new File(FileUtils.getTempDirectory(), "apistatus.html")); IOUtils.write(html, out); IOUtils.closeQuietly(out); out = new FileOutputStream(new File(FileUtils.getTempDirectory(), "apistatus.wiki.txt")); IOUtils.write(wiki, out); IOUtils.closeQuietly(out); }
From source file:com.china317.gmmp.gmmp_report_analysis.App.java
public static void main(String[] args) { log.info("[App main started]"); String yyyyMMdd = "20150218"; String beginTime = "20150211"; // if (args != null && args.length > 0) { // yyyyMMdd = args[0];\ // beginTime = args[0]; // }//from w ww . j av a 2 s . c om log.info("[Spring init begin-------------]"); // ApplicationContext context = new ClassPathXmlApplicationContext(new // String[]{"applicationContext.xml"}); //ApplicationContext context = new FileSystemXmlApplicationContext( // "//home/gmmp/lybc_reAnalySis/bin/applicationcontext.xml"); ApplicationContext context = new FileSystemXmlApplicationContext( "//home/gmmp/repAnalysis4/bin/applicationcontext.xml"); /* * ApplicationContext context = new FileSystemXmlApplicationContext( * "//home/gmmp/banche_reAnalysis/bin/applicationcontext.xml"); */ log.info("[Spring init end-------------]"); log.info("AreaAddProcessor areaList init begin"); AreaAddProcessor.init(context); PolyUtilityE2.getRules(); List<Rule> list_rules = AreaAddProcessor.getRuleList(); log.info("AreaAddProcessor areaList init end:" + list_rules.size() + "[PolyUtilityE2 rules:]" + PolyUtilityE2.getMapSize()); for (int i = 0; i < dates.length; i++) { yyyyMMdd = dates[i]; LineDenoterCache.getInstance().init(yyyyMMdd); log.info("LineDenoterCache size:" + LineDenoterCache.getInstance().getSize()); try { // analysisBanche(yyyyMMdd, context); // analysisBaoChe(yyyyMMdd, context); analysisDgm(yyyyMMdd, context); } catch (Exception e) { log.error(e); } log.info("ONE DAY ANALYSIS ENDED:" + yyyyMMdd); /* * log.info("[Result:]"); log.info("ptm: offline:" + * PtmAnalysisImp.getInstance().getOfflineRecordsSize() + * "::: overspeed:" + * PtmAnalysisImp.getInstance().getOverSpeedRecordsSize()); * * log.info("lybc: offline:" + * BaocheAnalysisImp.getInstance().getOfflineRecordsSize() + * "::: overspeed:" + * BaocheAnalysisImp.getInstance().getOverSpeedRecordsSize()); * * log.info("dgm: fobbided:" + * DgmAnalysisImp.getInstance().getFobbidedSize() + * " ::: overspeed:" + * DgmAnalysisImp.getInstance().getOverSpeedRecordsSize() + * " ::: getIllegalParking:" + * DgmAnalysisImp.getInstance().getIllegalParking().size() + * " ::: getExitMap:" + * DgmAnalysisImp.getInstance().getExitMap().size() + * " ::: getFatigue:" + * DgmAnalysisImp.getInstance().getFatigueSize() + "::: offline:" + * DgmAnalysisImp.getInstance().getOfflineRecordsSize()); */ } log.info("[App ended]"); }
From source file:ch.sdi.core.impl.ftp.FTPClientExample.java
public static void main(String[] aArgs) throws UnknownHostException { List<String> args = new ArrayList<String>(Arrays.asList(aArgs)); args.add("-s"); // store file on sesrver args.add("-b"); // binary transfer mode args.add("-#"); args.add("192.168.99.1"); args.add("heri"); // user args.add("heri"); // pw args.add("/var/www/log4j2.xml"); URL url = ClassLoader.getSystemResource("sdimain_test.properties"); // URL url = ClassLoader.getSystemResource( "log4j2.xml" ); args.add(url.getFile());//from w ww . j av a 2 s. co m FTPClientExample example = new FTPClientExample(); try { example.init(args.toArray(new String[args.size()])); example.run(); } catch (Throwable t) { myLog.error("Exception caught", t); myLog.info(USAGE); System.exit(1); } }
From source file:edu.stanford.epad.common.pixelmed.TIFFMasksToDSOConverter.java
/** * @param args/* ww w .j ava2 s .c om*/ */ public static void main(String[] args) { if (args.length < 3) { System.out.println( "\n\nInvalid arguments.\n\nUsage: java -classpath epad-ws-1.1-jar-with-dependencies.jar edu.stanford.epad.common.pixelmed.TIFFMasksToDSOConverter tiffFolder dicomFolder outputDSO.dcm"); return; } String maskFilesDirectory = args[0]; String dicomFilesDirectory = args[1]; String outputFileName = args[2]; //String maskFilesDirectory = "/Stanford/rlabs/data/tiffmasks"; //String dicomFilesDirectory = "/Stanford/rlabs/data/dicoms"; //String outputFileName = "/Stanford/rlabs/data/output/dso.dcm"; List<String> dicomFilePaths = listFilesInAlphabeticOrder(dicomFilesDirectory); for (int i = 0; i < dicomFilePaths.size(); i++) { if (!dicomFilePaths.get(i).toLowerCase().endsWith(".dcm")) { System.out.println("Removing DICOM file " + dicomFilePaths.get(i)); dicomFilePaths.remove(i); i--; } } if (dicomFilePaths.size() == 0) { System.out.println("No DICOM files found"); return; } List<String> maskFilePaths = listFilesInAlphabeticOrder(maskFilesDirectory); for (int i = 0; i < maskFilePaths.size(); i++) { if (!maskFilePaths.get(i).toLowerCase().endsWith(".tif") && !maskFilePaths.get(i).toLowerCase().endsWith(".tiff")) { System.out.println("Removing tif file " + maskFilePaths.get(i)); maskFilePaths.remove(i); i--; } } // Flip them because the code expects that List<String> reverseMaskFilePaths = new ArrayList<String>(); for (int i = maskFilePaths.size(); i > 0; i--) { reverseMaskFilePaths.add(maskFilePaths.get(i - 1)); } if (maskFilePaths.size() == 0) { System.out.println("No Tif Mask files found"); return; } if (dicomFilePaths.size() > maskFilePaths.size()) dicomFilePaths = dicomFilePaths.subList(0, reverseMaskFilePaths.size()); else if (reverseMaskFilePaths.size() > dicomFilePaths.size()) reverseMaskFilePaths = reverseMaskFilePaths.subList(0, dicomFilePaths.size()); try { TIFFMasksToDSOConverter converter = new TIFFMasksToDSOConverter(); String[] uids = null; if (args.length > 3) uids = converter.generateDSO(reverseMaskFilePaths, dicomFilePaths, outputFileName, args[3]); else uids = converter.generateDSO(reverseMaskFilePaths, dicomFilePaths, outputFileName); System.out .println("DICOM Segmentation Object created. SeriesUID:" + uids[0] + " InstanceUID:" + uids[1]); } catch (Exception e) { System.err.println(e); e.printStackTrace(System.err); System.exit(0); } }
From source file:com.github.vatbub.awsvpnlauncher.Main.java
public static void main(String[] args) { Common.getInstance().setAppName("awsVpnLauncher"); FOKLogger.enableLoggingOfUncaughtExceptions(); prefs = new Preferences(Main.class.getName()); // enable the shutdown hook Runtime.getRuntime().addShutdownHook(new Thread(() -> { if (session != null) { if (session.isConnected()) { session.disconnect();/*from w ww. j av a2s . c om*/ } } })); UpdateChecker.completeUpdate(args, (oldVersion, oldFile) -> { if (oldVersion != null) { FOKLogger.info(Main.class.getName(), "Successfully upgraded " + Common.getInstance().getAppName() + " from v" + oldVersion.toString() + " to v" + Common.getInstance().getAppVersion()); } }); List<String> argsAsList = new ArrayList<>(Arrays.asList(args)); for (String arg : args) { if (arg.toLowerCase().matches("mockappversion=.*")) { // Set the mock version String version = arg.substring(arg.toLowerCase().indexOf('=') + 1); Common.getInstance().setMockAppVersion(version); argsAsList.remove(arg); } else if (arg.toLowerCase().matches("mockbuildnumber=.*")) { // Set the mock build number String buildnumber = arg.substring(arg.toLowerCase().indexOf('=') + 1); Common.getInstance().setMockBuildNumber(buildnumber); argsAsList.remove(arg); } else if (arg.toLowerCase().matches("mockpackaging=.*")) { // Set the mock packaging String packaging = arg.substring(arg.toLowerCase().indexOf('=') + 1); Common.getInstance().setMockPackaging(packaging); argsAsList.remove(arg); } } args = argsAsList.toArray(new String[0]); try { mvnRepoConfig = new Config( new URL("https://www.dropbox.com/s/vnhs4nax2lczccf/mavenRepoConfig.properties?dl=1"), Main.class.getResource("mvnRepoFallbackConfig.properties"), true, "mvnRepoCachedConfig", true); projectConfig = new Config( new URL("https://www.dropbox.com/s/d36hwrrufoxfmm7/projectConfig.properties?dl=1"), Main.class.getResource("projectFallbackConfig.properties"), true, "projectCachedConfig", true); } catch (IOException e) { FOKLogger.log(Main.class.getName(), Level.SEVERE, "Could not load the remote config", e); } try { installUpdates(args); } catch (Exception e) { FOKLogger.log(Main.class.getName(), Level.SEVERE, "Could not install updates", e); } if (args.length == 0) { // not enough arguments printHelpMessage(); throw new NotEnoughArgumentsException(); } switch (args[0].toLowerCase()) { case "setup": setup(); break; case "launch": initAWSConnection(); launch(); break; case "terminate": initAWSConnection(); terminate(); break; case "config": // require a second arg if (args.length == 2) { // not enough arguments printHelpMessage(); throw new NotEnoughArgumentsException(); } config(Property.valueOf(args[1]), args[2]); break; case "getconfig": // require a second arg if (args.length == 1) { // not enough arguments printHelpMessage(); throw new NotEnoughArgumentsException(); } getConfig(Property.valueOf(args[1])); break; case "printconfig": printConfig(); break; case "deleteconfig": // require a second arg if (args.length == 1) { // not enough arguments printHelpMessage(); throw new NotEnoughArgumentsException(); } deleteConfig(Property.valueOf(args[1])); break; case "ssh": String sshInstanceId; if (args.length == 2) { // a instanceID is specified sshInstanceId = args[1]; } else { String instanceIdsPrefValue = prefs.getPreference("instanceIDs", ""); if (instanceIdsPrefValue.equals("")) { throw new NotEnoughArgumentsException( "No instanceId was specified to connect to and no instanceId was saved in the preference file. Please either start another instance using the launch command or specify the instance id of the instance to connect to as a additional parameter."); } List<String> instanceIds = Arrays.asList(instanceIdsPrefValue.split(";")); if (instanceIds.size() == 1) { // exactly one instance found sshInstanceId = instanceIds.get(0); } else { FOKLogger.severe(Main.class.getName(), "Multiple instance ids found:"); for (String instanceId : instanceIds) { FOKLogger.severe(Main.class.getName(), instanceId); } throw new NotEnoughArgumentsException( "Multiple instance ids were found in the preference file. Please specify the instance id of the instance to connect to as a additional parameter."); } } initAWSConnection(); ssh(sshInstanceId); break; default: printHelpMessage(); } }
From source file:com.fluidops.iwb.tools.RepositoryTool.java
public static void main(String[] args) throws IOException { // Configure logging Log4JHandler.initLogging();/*from w w w .jav a2 s.c om*/ Config.getConfigWithOverride(); try { CommandLineParser parser = new BasicParser(); Options options = buildOptions(); // parse the command line arguments CommandLine line = parser.parse(options, args); // print the help if (line.getOptions().length == 0 || line.hasOption("help")) { printHelp(options); return; } @SuppressWarnings("unchecked") List<String> lArgs = line.getArgList(); File source = null, target = null; if (lArgs.size() == 0) { source = IWBFileUtil.getFileInDataFolder(Config.getConfig().getRepositoryName()); target = source; } else if (lArgs.size() == 1) { source = new File(lArgs.get(0)); target = source; } else if (lArgs.size() == 2) { source = new File(lArgs.get(0)); target = new File(lArgs.get(1)); } else { System.out.println("Unrecognized arguments."); printHelp(options); System.exit(1); } // handle different options boolean checkGhosts = line.hasOption("g"); String indices = line.hasOption("i") ? line.getOptionValue("i") : getDefaultNativeStoreIndices(); if (line.hasOption("a")) { analyze(source, checkGhosts, indices); System.exit(0); } if (line.hasOption("f")) { analyzeAndFix(source, target, checkGhosts, indices); System.exit(0); } if (line.hasOption("c")) { cleanupRepository(source, target, indices); System.exit(0); } if (line.hasOption("u")) { copyUserData(source, target, indices); System.exit(0); } } catch (Exception exp) { System.out.println("Unexpected error: " + exp.getMessage()); System.exit(1); } }
From source file:edu.harvard.med.iccbl.dev.HibernateConsole.java
public static void main(String[] args) { BufferedReader br = null;//from w w w . jav a 2 s . co m try { CommandLineApplication app = new CommandLineApplication(args); app.processOptions(true, false); br = new BufferedReader(new InputStreamReader(System.in)); EntityManagerFactory emf = (EntityManagerFactory) app.getSpringBean("entityManagerFactory"); EntityManager em = emf.createEntityManager(); do { System.out.println("Enter HQL query (blank to quit): "); String input = br.readLine(); if (input.length() == 0) { System.out.println("Goodbye!"); System.exit(0); } try { List list = ((Session) em.getDelegate()).createQuery(input).list(); // note: this uses the Hibernate Session object, to allow HQL (and JPQL) // List list = em.createQuery(input).getResultList(); // note: this JPA method supports JPQL System.out.println("Result:"); for (Iterator iter = list.iterator(); iter.hasNext();) { Object item = iter.next(); // format output from multi-item selects ("select a, b, c, ... from ...") if (item instanceof Object[]) { List<Object> fields = Arrays.asList((Object[]) item); System.out.println(StringUtils.makeListString(fields, ", ")); } // format output from single-item selected ("select a from ..." or "from ...") else { System.out.println("[" + item.getClass().getName() + "]: " + item); } } System.out.println("(" + list.size() + " rows)\n"); } catch (Exception e) { System.out.println("Hibernate Error: " + e.getMessage()); log.error("Hibernate error", e); } System.out.println(); } while (true); } catch (Exception e) { System.err.println("Fatal Error: " + e.getMessage()); e.printStackTrace(); } finally { IOUtils.closeQuietly(br); } }