List of usage examples for java.util List contains
boolean contains(Object o);
From source file:MailHandlerDemo.java
/** * Runs the demo.//ww w.j a v a2s .c o m * * @param args the command line arguments * @throws IOException if there is a problem. */ public static void main(String[] args) throws IOException { List<String> l = Arrays.asList(args); if (l.contains("/?") || l.contains("-?") || l.contains("-help")) { LOGGER.info("Usage: java MailHandlerDemo " + "[[-all] | [-body] | [-custom] | [-debug] | [-low] " + "| [-simple] | [-pushlevel] | [-pushfilter] " + "| [-pushnormal] | [-pushonly]] " + "\n\n" + "-all\t\t: Execute all demos.\n" + "-body\t\t: An email with all records and only a body.\n" + "-custom\t\t: An email with attachments and dynamic names.\n" + "-debug\t\t: Output basic debug information about the JVM " + "and log configuration.\n" + "-low\t\t: Generates multiple emails due to low capacity." + "\n" + "-simple\t\t: An email with all records with body and " + "an attachment.\n" + "-pushlevel\t: Generates high priority emails when the" + " push level is triggered and normal priority when " + "flushed.\n" + "-pushFilter\t: Generates high priority emails when the " + "push level and the push filter is triggered and normal " + "priority emails when flushed.\n" + "-pushnormal\t: Generates multiple emails when the " + "MemoryHandler push level is triggered. All generated " + "email are sent as normal priority.\n" + "-pushonly\t: Generates multiple emails when the " + "MemoryHandler push level is triggered. Generates high " + "priority emails when the push level is triggered and " + "normal priority when flushed.\n"); } else { final boolean debug = init(l); //may create log messages. try { LOGGER.log(Level.FINEST, "This is the finest part of the demo.", new MessagingException("Fake JavaMail issue.")); LOGGER.log(Level.FINER, "This is the finer part of the demo.", new NullPointerException("Fake bug.")); LOGGER.log(Level.FINE, "This is the fine part of the demo."); LOGGER.log(Level.CONFIG, "Logging config file is {0}.", getConfigLocation()); LOGGER.log(Level.INFO, "Your temp directory is {0}, " + "please wait...", getTempDir()); try { //Waste some time for the custom formatter. Thread.sleep(3L * 1000L); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } LOGGER.log(Level.WARNING, "This is a warning.", new FileNotFoundException("Fake file chooser issue.")); LOGGER.log(Level.SEVERE, "The end of the demo.", new IOException("Fake access denied issue.")); } finally { closeHandlers(); } //Force parse errors. This does have side effects. if (debug && getConfigLocation() != null) { LogManager.getLogManager().readConfiguration(); } } }
From source file:com.rabbitmq.examples.PerfTest.java
public static void main(String[] args) { Options options = getOptions();/*from w ww . j a v a 2 s . co m*/ CommandLineParser parser = new GnuParser(); try { CommandLine cmd = parser.parse(options, args); if (cmd.hasOption('?')) { usage(options); System.exit(0); } String exchangeType = strArg(cmd, 't', "direct"); String exchangeName = strArg(cmd, 'e', exchangeType); String queueName = strArg(cmd, 'u', ""); String routingKey = strArg(cmd, 'k', null); boolean randomRoutingKey = cmd.hasOption('K'); int samplingInterval = intArg(cmd, 'i', 1); float producerRateLimit = floatArg(cmd, 'r', 0.0f); float consumerRateLimit = floatArg(cmd, 'R', 0.0f); int producerCount = intArg(cmd, 'x', 1); int consumerCount = intArg(cmd, 'y', 1); int producerTxSize = intArg(cmd, 'm', 0); int consumerTxSize = intArg(cmd, 'n', 0); long confirm = intArg(cmd, 'c', -1); boolean autoAck = cmd.hasOption('a'); int multiAckEvery = intArg(cmd, 'A', 0); int channelPrefetch = intArg(cmd, 'Q', 0); int consumerPrefetch = intArg(cmd, 'q', 0); int minMsgSize = intArg(cmd, 's', 0); int timeLimit = intArg(cmd, 'z', 0); int producerMsgCount = intArg(cmd, 'C', 0); int consumerMsgCount = intArg(cmd, 'D', 0); List<?> flags = lstArg(cmd, 'f'); int frameMax = intArg(cmd, 'M', 0); int heartbeat = intArg(cmd, 'b', 0); boolean predeclared = cmd.hasOption('p'); String uri = strArg(cmd, 'h', "amqp://localhost"); //setup PrintlnStats stats = new PrintlnStats(1000L * samplingInterval, producerCount > 0, consumerCount > 0, (flags.contains("mandatory") || flags.contains("immediate")), confirm != -1); ConnectionFactory factory = new ConnectionFactory(); factory.setShutdownTimeout(0); // So we still shut down even with slow consumers factory.setUri(uri); factory.setRequestedFrameMax(frameMax); factory.setRequestedHeartbeat(heartbeat); MulticastParams p = new MulticastParams(); p.setAutoAck(autoAck); p.setAutoDelete(true); p.setConfirm(confirm); p.setConsumerCount(consumerCount); p.setConsumerMsgCount(consumerMsgCount); p.setConsumerRateLimit(consumerRateLimit); p.setConsumerTxSize(consumerTxSize); p.setExchangeName(exchangeName); p.setExchangeType(exchangeType); p.setFlags(flags); p.setMultiAckEvery(multiAckEvery); p.setMinMsgSize(minMsgSize); p.setPredeclared(predeclared); p.setConsumerPrefetch(consumerPrefetch); p.setChannelPrefetch(channelPrefetch); p.setProducerCount(producerCount); p.setProducerMsgCount(producerMsgCount); p.setProducerTxSize(producerTxSize); p.setQueueName(queueName); p.setRoutingKey(routingKey); p.setRandomRoutingKey(randomRoutingKey); p.setProducerRateLimit(producerRateLimit); p.setTimeLimit(timeLimit); MulticastSet set = new MulticastSet(stats, factory, p); set.run(true); stats.printFinal(); } catch (ParseException exp) { System.err.println("Parsing failed. Reason: " + exp.getMessage()); usage(options); } catch (Exception e) { System.err.println("Main thread caught exception: " + e); e.printStackTrace(); System.exit(1); } }
From source file:com.rabbitmq.perf.PerfTest.java
public static void main(String[] args) { Options options = getOptions();//from w w w . j a v a 2s . c om CommandLineParser parser = new GnuParser(); try { CommandLine cmd = parser.parse(options, args); if (cmd.hasOption('?')) { usage(options); System.exit(0); } String testID = new SimpleDateFormat("HHmmss-SSS").format(Calendar.getInstance().getTime()); testID = strArg(cmd, 'd', "test-" + testID); String exchangeType = strArg(cmd, 't', "direct"); String exchangeName = strArg(cmd, 'e', exchangeType); String queueNames = strArg(cmd, 'u', ""); String routingKey = strArg(cmd, 'k', null); boolean randomRoutingKey = cmd.hasOption('K'); int samplingInterval = intArg(cmd, 'i', 1); float producerRateLimit = floatArg(cmd, 'r', 0.0f); float consumerRateLimit = floatArg(cmd, 'R', 0.0f); int producerCount = intArg(cmd, 'x', 1); int consumerCount = intArg(cmd, 'y', 1); int producerTxSize = intArg(cmd, 'm', 0); int consumerTxSize = intArg(cmd, 'n', 0); long confirm = intArg(cmd, 'c', -1); boolean autoAck = cmd.hasOption('a'); int multiAckEvery = intArg(cmd, 'A', 0); int channelPrefetch = intArg(cmd, 'Q', 0); int consumerPrefetch = intArg(cmd, 'q', 0); int minMsgSize = intArg(cmd, 's', 0); int timeLimit = intArg(cmd, 'z', 0); int producerMsgCount = intArg(cmd, 'C', 0); int consumerMsgCount = intArg(cmd, 'D', 0); List<?> flags = lstArg(cmd, 'f'); int frameMax = intArg(cmd, 'M', 0); int heartbeat = intArg(cmd, 'b', 0); boolean predeclared = cmd.hasOption('p'); String uri = strArg(cmd, 'h', "amqp://localhost"); //setup PrintlnStats stats = new PrintlnStats(testID, 1000L * samplingInterval, producerCount > 0, consumerCount > 0, (flags.contains("mandatory") || flags.contains("immediate")), confirm != -1); ConnectionFactory factory = new ConnectionFactory(); factory.setShutdownTimeout(0); // So we still shut down even with slow consumers factory.setUri(uri); factory.setRequestedFrameMax(frameMax); factory.setRequestedHeartbeat(heartbeat); MulticastParams p = new MulticastParams(); p.setAutoAck(autoAck); p.setAutoDelete(true); p.setConfirm(confirm); p.setConsumerCount(consumerCount); p.setConsumerMsgCount(consumerMsgCount); p.setConsumerRateLimit(consumerRateLimit); p.setConsumerTxSize(consumerTxSize); p.setExchangeName(exchangeName); p.setExchangeType(exchangeType); p.setFlags(flags); p.setMultiAckEvery(multiAckEvery); p.setMinMsgSize(minMsgSize); p.setPredeclared(predeclared); p.setConsumerPrefetch(consumerPrefetch); p.setChannelPrefetch(channelPrefetch); p.setProducerCount(producerCount); p.setProducerMsgCount(producerMsgCount); p.setProducerTxSize(producerTxSize); p.setQueueNames(Arrays.asList(queueNames.split(","))); p.setRoutingKey(routingKey); p.setRandomRoutingKey(randomRoutingKey); p.setProducerRateLimit(producerRateLimit); p.setTimeLimit(timeLimit); MulticastSet set = new MulticastSet(stats, factory, p, testID); set.run(true); stats.printFinal(); } catch (ParseException exp) { System.err.println("Parsing failed. Reason: " + exp.getMessage()); usage(options); } catch (Exception e) { System.err.println("Main thread caught exception: " + e); e.printStackTrace(); System.exit(1); } }
From source file:com.asakusafw.generator.HadoopBulkLoaderDDLGenerator.java
/** * HadoopBulkLoader?????//from w w w .j a v a2 s . com * * @param args * ?? * @throws Exception * ?????? */ public static void main(String[] args) throws Exception { String outputTablesString = findVariable(ENV_BULKLOADER_TABLES, true); List<String> outputTableList = null; if (outputTablesString != null && !OUTPUT_TABLES_PROPERTY.equals(outputTablesString)) { String[] outputTables = outputTablesString.trim().split("\\s+"); outputTableList = Arrays.asList(outputTables); } String ddlTemplate; InputStream in = HadoopBulkLoaderDDLGenerator.class.getResourceAsStream(TEMPLATE_DDL_FILENAME); try { ddlTemplate = IOUtils.toString(in); } finally { in.close(); } StringBuilder sb = new StringBuilder(); for (String tableName : args) { if (outputTableList == null || outputTableList.contains(tableName)) { String tableddl = ddlTemplate.replaceAll(TABLENAME_REPLACE_STRING, tableName); sb.append(tableddl); } } String outputFilePath = findVariable(ENV_BULKLOADER_GENDDL, true); if (outputFilePath == null) { throw new RuntimeException( "ASAKUSA_BULKLOADER_TABLES???????"); } FileUtils.write(new File(outputFilePath), sb); }
From source file:de.tudarmstadt.ukp.experiments.dip.wp1.documents.Step6HITPreparator.java
public static void main(String[] args) throws Exception { // input dir - list of xml query containers // step5-linguistic-annotation/ System.err.println("Starting step 6 HIT Preparation"); File inputDir = new File(args[0]); // output dir File outputDir = new File(args[1]); if (outputDir.exists()) { outputDir.delete();/*from w ww. j av a 2 s . c o m*/ } outputDir.mkdir(); List<String> queries = new ArrayList<>(); // iterate over query containers int countClueWeb = 0; int countSentence = 0; for (File f : FileUtils.listFiles(inputDir, new String[] { "xml" }, false)) { QueryResultContainer queryResultContainer = QueryResultContainer .fromXML(FileUtils.readFileToString(f, "utf-8")); if (queries.contains(f.getName()) || queries.size() == 0) { // groups contain only non-empty documents Map<Integer, List<QueryResultContainer.SingleRankedResult>> groups = new HashMap<>(); // split to groups according to number of sentences for (QueryResultContainer.SingleRankedResult rankedResult : queryResultContainer.rankedResults) { if (rankedResult.originalXmi != null) { byte[] bytes = new BASE64Decoder() .decodeBuffer(new ByteArrayInputStream(rankedResult.originalXmi.getBytes())); JCas jCas = JCasFactory.createJCas(); XmiCasDeserializer.deserialize(new ByteArrayInputStream(bytes), jCas.getCas()); Collection<Sentence> sentences = JCasUtil.select(jCas, Sentence.class); int groupId = sentences.size() / 40; if (rankedResult.originalXmi == null) { System.err.println("Empty document: " + rankedResult.clueWebID); } else { if (!groups.containsKey(groupId)) { groups.put(groupId, new ArrayList<>()); } } //handle it groups.get(groupId).add(rankedResult); countClueWeb++; } } for (Map.Entry<Integer, List<QueryResultContainer.SingleRankedResult>> entry : groups.entrySet()) { Integer groupId = entry.getKey(); List<QueryResultContainer.SingleRankedResult> rankedResults = entry.getValue(); // make sure the results are sorted // DEBUG // for (QueryResultContainer.SingleRankedResult r : rankedResults) { // System.out.print(r.rank + "\t"); // } Collections.sort(rankedResults, (o1, o2) -> o1.rank.compareTo(o2.rank)); // iterate over results for one query and group for (int i = 0; i < rankedResults.size() && i < TOP_RESULTS_PER_GROUP; i++) { QueryResultContainer.SingleRankedResult rankedResult = rankedResults.get(i); QueryResultContainer.SingleRankedResult r = rankedResults.get(i); int rank = r.rank; MustacheFactory mf = new DefaultMustacheFactory(); Mustache mustache = mf.compile("template/template.html"); String queryId = queryResultContainer.qID; String query = queryResultContainer.query; // make the first letter uppercase query = query.substring(0, 1).toUpperCase() + query.substring(1); List<String> relevantInformationExamples = queryResultContainer.relevantInformationExamples; List<String> irrelevantInformationExamples = queryResultContainer.irrelevantInformationExamples; byte[] bytes = new BASE64Decoder() .decodeBuffer(new ByteArrayInputStream(rankedResult.originalXmi.getBytes())); JCas jCas = JCasFactory.createJCas(); XmiCasDeserializer.deserialize(new ByteArrayInputStream(bytes), jCas.getCas()); List<generators.Sentence> sentences = new ArrayList<>(); List<Integer> paragraphs = new ArrayList<>(); paragraphs.add(0); for (WebParagraph webParagraph : JCasUtil.select(jCas, WebParagraph.class)) { for (Sentence s : JCasUtil.selectCovered(Sentence.class, webParagraph)) { String sentenceBegin = String.valueOf(s.getBegin()); generators.Sentence sentence = new generators.Sentence(s.getCoveredText(), sentenceBegin); sentences.add(sentence); countSentence++; } int SentenceID = paragraphs.get(paragraphs.size() - 1); if (sentences.size() > 120) while (SentenceID < sentences.size()) { if (!paragraphs.contains(SentenceID)) paragraphs.add(SentenceID); SentenceID = SentenceID + 120; } paragraphs.add(sentences.size()); } System.err.println("Output dir: " + outputDir); int startID = 0; int endID; for (int j = 0; j < paragraphs.size(); j++) { endID = paragraphs.get(j); int sentLength = endID - startID; if (sentLength > 120 || j == paragraphs.size() - 1) { if (sentLength > 120) { endID = paragraphs.get(j - 1); j--; } sentLength = endID - startID; if (sentLength <= 40) groupId = 40; else if (sentLength <= 80 && sentLength > 40) groupId = 80; else if (sentLength > 80) groupId = 120; File folder = new File(outputDir + "/" + groupId); if (!folder.exists()) { System.err.println("creating directory: " + outputDir + "/" + groupId); boolean result = false; try { folder.mkdir(); result = true; } catch (SecurityException se) { //handle it } if (result) { System.out.println("DIR created"); } } String newHtmlFile = folder.getAbsolutePath() + "/" + f.getName() + "_" + rankedResult.clueWebID + "_" + sentLength + ".html"; System.err.println("Printing a file: " + newHtmlFile); File newHTML = new File(newHtmlFile); int t = 0; while (newHTML.exists()) { newHTML = new File(folder.getAbsolutePath() + "/" + f.getName() + "_" + rankedResult.clueWebID + "_" + sentLength + "." + t + ".html"); t++; } mustache.execute(new PrintWriter(new FileWriter(newHTML)), new generators(query, relevantInformationExamples, irrelevantInformationExamples, sentences.subList(startID, endID), queryId, rank)) .flush(); startID = endID; } } } } } } System.out.println("Printed " + countClueWeb + " documents with " + countSentence + " sentences"); }
From source file:gov.nih.nci.ncicb.tcga.dcc.qclive.standalone.ArchiveCopyStandalone.java
/** * Copy archives to the public location, making the necessary database and filesystem changes. * <p/>/* ww w .j a v a 2s .com*/ * Right now the only archive type that is supported is "bcr", meaning here all available protected 'bio' archives. * * @param args the archive type to copy to the public location */ public static void main(final String[] args) { if (args.length == 0 || !hasValidArgs(args)) { System.out.println(USAGE); System.exit(-1); } else { final long startTime = System.currentTimeMillis(); final ApplicationContext appContext = new ClassPathXmlApplicationContext(APP_CONTEXT_FILE_NAME); final ArchiveCopyStandalone archiveCopyStandalone = (ArchiveCopyStandalone) appContext .getBean("archiveCopyStandalone"); archiveCopyStandalone.getLogger() .addDestination(new Log4JLoggerDestination(archiveCopyStandalone.getClass().toString())); try { final List<String> argList = Arrays.asList(args); long noOfFilesCopied = 0; if (argList.contains(DRY_RUN_ARG)) { archiveCopyStandalone.getLogger().log(Level.INFO, "This is a DRY RUN, no actual file system and Database change will be made."); archiveCopyStandalone.setDryRun(true); } if (argList.contains(BCR_ARG)) { noOfFilesCopied = archiveCopyStandalone.copyBCRArchivesFromProtectedToPublic(); } if (argList.contains(MAF_ARG)) { noOfFilesCopied = archiveCopyStandalone.copyMafArchivesFromProtectedToPublic(); } archiveCopyStandalone.getLogger().log(Level.INFO, "Total archives copied : " + noOfFilesCopied + ". Total execution time: " + ((System.currentTimeMillis() - startTime) / 1000) + " secs."); } catch (Exception e) { archiveCopyStandalone.getLogger().log(Level.ERROR, e.getMessage()); e.printStackTrace(); } } }
From source file:mujava.cli.genmutes.java
public static void main(String[] args) throws Exception { // System.out.println("test"); genmutesCom jct = new genmutesCom(); String[] argv = { "-all", "-debug", "Flower" }; // development use, when release, // comment out this line JCommander jCommander = new JCommander(jct, args); // check session name if (jct.getParameters().size() > 1) { Util.Error("Has more parameters than needed."); return;//from w w w . jav a 2 s . c o m } // set session name String sessionName = jct.getParameters().get(0); muJavaHomePath = Util.loadConfig(); // check if debug mode if (jct.isDebug()) { Util.debug = true; } // get all existing session name File folder = new File(muJavaHomePath); // check if the config file has defined the correct folder if (!folder.isDirectory()) { Util.Error("ERROR: cannot locate the folder specified in mujava.config"); return; } File[] listOfFiles = folder.listFiles(); // null checking // check the specified folder has files or not if (listOfFiles == null) { Util.Error("ERROR: no files in the muJava home folder: " + muJavaHomePath); return; } List<String> fileNameList = new ArrayList<>(); for (File file : listOfFiles) { fileNameList.add(file.getName()); } // check if session is already created. if (!fileNameList.contains(sessionName)) { Util.Error("Session does not exist."); return; } // get all files in the session String[] file_list = new String[1]; // if(jct.getD()) // { File sessionFolder = new File(muJavaHomePath + "/" + sessionName + "/src"); File[] listOfFilesInSession = sessionFolder.listFiles(); file_list = new String[listOfFilesInSession.length]; for (int i = 0; i < listOfFilesInSession.length; i++) { file_list[i] = listOfFilesInSession[i].getName(); } // get all mutation operators selected HashMap<String, List<String>> ops = new HashMap<String, List<String>>(); // used // for // add // random // percentage // and // maximum String[] paras = new String[] { "1", "0" }; if (jct.getAll()) // all is selected, add all operators { // if all is selected, all mutation operators are added ops.put("AORB", new ArrayList<String>(Arrays.asList(paras))); ops.put("AORS", new ArrayList<String>(Arrays.asList(paras))); ops.put("AOIU", new ArrayList<String>(Arrays.asList(paras))); ops.put("AOIS", new ArrayList<String>(Arrays.asList(paras))); ops.put("AODU", new ArrayList<String>(Arrays.asList(paras))); ops.put("AODS", new ArrayList<String>(Arrays.asList(paras))); ops.put("ROR", new ArrayList<String>(Arrays.asList(paras))); ops.put("COR", new ArrayList<String>(Arrays.asList(paras))); ops.put("COD", new ArrayList<String>(Arrays.asList(paras))); ops.put("COI", new ArrayList<String>(Arrays.asList(paras))); ops.put("SOR", new ArrayList<String>(Arrays.asList(paras))); ops.put("LOR", new ArrayList<String>(Arrays.asList(paras))); ops.put("LOI", new ArrayList<String>(Arrays.asList(paras))); ops.put("LOD", new ArrayList<String>(Arrays.asList(paras))); ops.put("ASRS", new ArrayList<String>(Arrays.asList(paras))); ops.put("SDL", new ArrayList<String>(Arrays.asList(paras))); ops.put("ODL", new ArrayList<String>(Arrays.asList(paras))); ops.put("VDL", new ArrayList<String>(Arrays.asList(paras))); ops.put("CDL", new ArrayList<String>(Arrays.asList(paras))); // ops.put("SDL", jct.getAll()); } else { // if not all, add selected ops to the list if (jct.getAORB()) { ops.put("AORB", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getAORS()) { ops.put("AORS", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getAOIU()) { ops.put("AOIU", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getAOIS()) { ops.put("AOIS", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getAODU()) { ops.put("AODU", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getAODS()) { ops.put("AODS", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getROR()) { ops.put("ROR", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getCOR()) { ops.put("COR", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getCOD()) { ops.put("COD", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getCOI()) { ops.put("COI", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getSOR()) { ops.put("SOR", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getLOR()) { ops.put("LOR", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getLOI()) { ops.put("LOI", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getLOD()) { ops.put("LOD", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getASRS()) { ops.put("ASRS", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getSDL()) { ops.put("SDL", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getVDL()) { ops.put("VDL", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getODL()) { ops.put("ODL", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getCDL()) { ops.put("CDL", new ArrayList<String>(Arrays.asList(paras))); } } // add default option "all" if (ops.size() == 0) { ops.put("AORB", new ArrayList<String>(Arrays.asList(paras))); ops.put("AORS", new ArrayList<String>(Arrays.asList(paras))); ops.put("AOIU", new ArrayList<String>(Arrays.asList(paras))); ops.put("AOIS", new ArrayList<String>(Arrays.asList(paras))); ops.put("AODU", new ArrayList<String>(Arrays.asList(paras))); ops.put("AODS", new ArrayList<String>(Arrays.asList(paras))); ops.put("ROR", new ArrayList<String>(Arrays.asList(paras))); ops.put("COR", new ArrayList<String>(Arrays.asList(paras))); ops.put("COD", new ArrayList<String>(Arrays.asList(paras))); ops.put("COI", new ArrayList<String>(Arrays.asList(paras))); ops.put("SOR", new ArrayList<String>(Arrays.asList(paras))); ops.put("LOR", new ArrayList<String>(Arrays.asList(paras))); ops.put("LOI", new ArrayList<String>(Arrays.asList(paras))); ops.put("LOD", new ArrayList<String>(Arrays.asList(paras))); ops.put("ASRS", new ArrayList<String>(Arrays.asList(paras))); ops.put("SDL", new ArrayList<String>(Arrays.asList(paras))); ops.put("ODL", new ArrayList<String>(Arrays.asList(paras))); ops.put("VDL", new ArrayList<String>(Arrays.asList(paras))); ops.put("CDL", new ArrayList<String>(Arrays.asList(paras))); } // String[] tradional_ops = ops.toArray(new String[0]); // set system setJMutationStructureAndSession(sessionName); // MutationSystem.setJMutationStructureAndSession(sessionName); MutationSystem.recordInheritanceRelation(); // generate mutants generateMutants(file_list, ops); //System.exit(0); }
From source file:at.ac.tuwien.inso.subcat.miner.MinerRunner.java
public static void main(String[] args) { Options options = new Options(); options.addOption("h", "help", false, "Show this options"); options.addOption("m", "miner-help", false, "Show miner specific options"); options.addOption("d", "db", true, "The database to process (required)"); options.addOption("p", "project", true, "The project ID to process"); options.addOption("P", "list-projects", false, "List all registered projects"); options.addOption("v", "verbose", false, "Show details"); options.addOption(null, "bug-repo", true, "Bug Repository URL"); options.addOption(null, "bug-product", true, "Bug Product Name"); options.addOption(null, "bug-tracker", true, "Bug Tracker name (e.g. bugzilla)"); options.addOption(null, "bug-account", true, "Bug account name"); options.addOption(null, "bug-passwd", true, "Bug account password"); options.addOption(null, "bug-enable-untrusted", false, "Accept untrusted certificates"); options.addOption(null, "bug-threads", true, "Thread count used in bug miners"); options.addOption(null, "bug-cooldown-time", true, "Bug cooldown time"); options.addOption(null, "bug-miner-option", true, "Bug miner specific option. Format: <option-name>:value"); options.addOption(null, "bug-update", false, "Mine all changes since the last run"); options.getOption("bug-miner-option").setArgs(Option.UNLIMITED_VALUES); options.addOption(null, "src-path", true, "Local source repository path"); options.addOption(null, "src-remote", true, "Remote address"); options.addOption(null, "src-passwd", true, "Source repository account password"); options.addOption(null, "src-account", true, "Source repository account name"); options.addOption(null, "src-miner-option", true, "Source miner specific option. Format: <option-name>:value"); options.getOption("src-miner-option").setArgs(Option.UNLIMITED_VALUES); final Reporter reporter = new Reporter(true); reporter.startTimer();/* w w w . j av a 2 s . co m*/ boolean printTraces = false; Settings settings = new Settings(); ModelPool pool = null; CommandLineParser parser = new PosixParser(); try { CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("postprocessor", options); return; } if (cmd.hasOption("miner-help")) { init(); for (MetaData meta : registeredMiner) { System.out.println(meta.name()); for (Entry<String, ParamType> opt : meta.getSpecificParams().entrySet()) { System.out.println(" - " + opt.getKey() + " (" + opt.getValue() + ")"); } } return; } if (cmd.hasOption("db") == false) { reporter.error("miner", "Option --db is required"); reporter.printSummary(); return; } printTraces = cmd.hasOption("verbose"); pool = new ModelPool(cmd.getOptionValue("db"), 2); if (cmd.hasOption("list-projects")) { Model model = pool.getModel(); for (Project proj : model.getProjects()) { System.out.println(" " + proj.getId() + ": " + proj.getDate()); } model.close(); return; } Project project; Model model = pool.getModel(); boolean hasSrcInfos = false; boolean hasBugInfos = false; if (cmd.hasOption("project")) { try { int projId = Integer.parseInt(cmd.getOptionValue("project")); project = model.getProject(projId); } catch (NumberFormatException e) { reporter.error("post-processor", "Invalid project ID"); reporter.printSummary(); return; } if (project == null) { reporter.error("post-processor", "Invalid project ID"); reporter.printSummary(); return; } List<String> flags = model.getFlags(project); hasBugInfos = flags.contains(Model.FLAG_BUG_INFO); hasSrcInfos = flags.contains(Model.FLAG_SRC_INFO); } else { project = model.addProject(new Date(), null, settings.bugTrackerName, settings.bugRepository, settings.bugProductName, null); } model.close(); // // Source Repository Mining: // settings.srcLocalPath = cmd.getOptionValue("src-path"); settings.srcRemote = cmd.getOptionValue("src-remote"); settings.srcRemotePw = cmd.getOptionValue("src-passwd"); settings.srcRemoteUser = cmd.getOptionValue("src-account"); if (settings.srcRemotePw == null || settings.srcRemoteUser == null) { if (settings.srcRemotePw != null) { reporter.error("miner", "--src-passwd should only be used in combination with --src-account"); reporter.printSummary(); return; } else if (settings.srcRemoteUser != null) { reporter.error("miner", "--src-account should only be used in combination with --src-passwd"); reporter.printSummary(); return; } } if (settings.srcRemoteUser != null && settings.srcRemote == null) { reporter.error("miner", "--src-account should only be used in combination with --src-remote"); reporter.printSummary(); return; } if (settings.srcLocalPath != null && hasSrcInfos) { reporter.error("miner", "Source repository updates are not supported yet."); reporter.printSummary(true); return; } // // Bug Repository Mining: // settings.bugRepository = cmd.getOptionValue("bug-repo"); settings.bugProductName = cmd.getOptionValue("bug-product"); settings.bugTrackerName = cmd.getOptionValue("bug-tracker"); settings.bugEnableUntrustedCertificates = cmd.hasOption("bug-enable-untrusted"); settings.bugLoginUser = cmd.getOptionValue("bug-account"); settings.bugLoginPw = cmd.getOptionValue("bug-passwd"); settings.bugUpdate = cmd.hasOption("bug-update"); boolean includeBugs = false; if (settings.bugUpdate) { if (project.getBugTracker() == null || project.getDomain() == null) { reporter.error("miner", "flag --bug-update is requires previously mined bugs. Use --bug-repository, --bug-product and --bug-tracker."); reporter.printSummary(true); return; } if (settings.bugTrackerName != null) { reporter.warning("miner", "flag --bug-tracker without effect"); } if (settings.bugProductName != null) { reporter.warning("miner", "flag --bug-product without effect"); } if (settings.bugRepository != null) { reporter.warning("miner", "flag --bug-repository without effect"); } settings.bugTrackerName = project.getBugTracker(); settings.bugProductName = project.getProduct(); settings.bugRepository = project.getDomain(); includeBugs = true; } else if (settings.bugRepository != null && settings.bugProductName != null && settings.bugTrackerName != null) { if (hasBugInfos == false) { // The user is trying to append bug tracker information to a existing project. } else if (!settings.bugTrackerName.equalsIgnoreCase(project.getBugTracker()) || !settings.bugProductName.equalsIgnoreCase(project.getProduct()) || !settings.bugRepository.equalsIgnoreCase(project.getDomain())) { reporter.error("miner", "There are already previously mined bugs for this project. Use --bug-update to update the database."); reporter.printSummary(true); return; } if (settings.bugRepository == null) { reporter.error("miner", "flag --bug-repository is required"); reporter.printSummary(true); return; } if (settings.bugProductName == null) { reporter.error("miner", "flag --bug-product is required"); reporter.printSummary(true); return; } includeBugs = true; } if (includeBugs) { if (settings.bugLoginPw == null || settings.bugLoginUser == null) { if (settings.bugLoginPw != null) { reporter.error("miner", "--bug-passwd should only be used in combination with --bug-account"); reporter.printSummary(); return; } else if (settings.bugLoginUser != null) { reporter.error("miner", "--bug-account should only be used in combination with --bug-passwd"); reporter.printSummary(); return; } } if (cmd.hasOption("bug-threads")) { try { settings.bugThreads = Integer.parseInt(cmd.getOptionValue("bug-threads")); } catch (Exception e) { reporter.error("miner", "--bug-threads: Invalid parameter type"); reporter.printSummary(); return; } } if (cmd.hasOption("bug-cooldown-time")) { try { settings.bugCooldownTime = Integer.parseInt(cmd.getOptionValue("bug-cooldown-time")); } catch (Exception e) { reporter.error("miner", "--bug-cooldown-time: Invalid parameter type"); reporter.printSummary(); return; } } if (cmd.hasOption("bug-miner-option")) { for (String str : cmd.getOptionValues("bug-miner-option")) { addSpecificParameter(settings.bugSpecificParams, str); } } if (cmd.hasOption("src-miner-option")) { for (String str : cmd.getOptionValues("src-miner-option")) { addSpecificParameter(settings.srcSpecificParams, str); } } } else { if (settings.bugLoginPw != null) { reporter.error("miner", "--bug-passwd should only be used in combination with --bug-account"); reporter.printSummary(); return; } if (settings.bugLoginUser != null) { reporter.error("miner", "--bug-account should only be used in combination with --bug-account"); reporter.printSummary(); return; } if (settings.bugRepository != null) { reporter.error("miner", "--bug-repo should only be used in combination with --bug-product and --bug-tracker"); reporter.printSummary(); return; } if (settings.bugProductName != null) { reporter.error("miner", "--bug-product should only be used in combination with --bug-repo and --bug-tracker"); reporter.printSummary(); return; } if (settings.bugTrackerName != null) { reporter.error("miner", "--bug-tracker should only be used in combination with --bug-repo and --bug-product"); reporter.printSummary(); return; } if (settings.bugEnableUntrustedCertificates) { reporter.error("miner", "--bug-enable-untrusted should only be used in combination with --bug-repo, --bug-tracker and --bug-product"); reporter.printSummary(); return; } if (settings.bugUpdate) { reporter.error("miner", "--bug-update should only be used in combination with --bug-repo, --bug-tracker and --bug-product"); reporter.printSummary(); return; } if (cmd.hasOption("bug-threads")) { reporter.error("miner", "--bug-threads should only be used in combination with --bug-repo, --bug-tracker and --bug-product"); reporter.printSummary(); return; } if (cmd.hasOption("bug-cooldown-time")) { reporter.error("miner", "--bug-cooldown-time should only be used in combination with --bug-repo, --bug-tracker and --bug-product"); reporter.printSummary(); return; } if (cmd.hasOption("bug-miner-option")) { reporter.error("miner", "--bug-miner-option should only be used in combination with --bug-repo, --bug-tracker and --bug-product"); reporter.printSummary(); return; } } // // Run: // MinerRunner runner = new MinerRunner(pool, project, settings, reporter); if (cmd.hasOption("verbose")) { runner.addListener(new MinerListener() { private Map<Miner, Integer> totals = new HashMap<Miner, Integer>(); @Override public void start(Miner miner) { } @Override public void end(Miner miner) { } @Override public void stop(Miner miner) { } @Override public void tasksTotal(Miner miner, int count) { totals.put(miner, count); } @Override public void tasksProcessed(Miner miner, int processed) { Integer total = totals.get(miner); reporter.note(miner.getName(), "status: " + processed + "/" + ((total == null) ? "0" : total)); } }); } runner.run(); } catch (ParameterException e) { reporter.error(e.getMiner().getName(), e.getMessage()); } catch (ParseException e) { reporter.error("miner", "Parsing failed: " + e.getMessage()); if (printTraces == true) { e.printStackTrace(); } } catch (ClassNotFoundException e) { reporter.error("miner", "Failed to create a database connection: " + e.getMessage()); if (printTraces == true) { e.printStackTrace(); } } catch (SQLException e) { reporter.error("miner", "Failed to create a database connection: " + e.getMessage()); if (printTraces == true) { e.printStackTrace(); } } catch (MinerException e) { reporter.error("miner", "Mining Error: " + e.getMessage()); if (printTraces == true) { e.printStackTrace(); } } finally { if (pool != null) { pool.close(); } } reporter.printSummary(true); }
From source file:hydrograph.server.execution.tracking.client.main.HydrographMain.java
/** * The main method./*from w w w . j a v a 2 s.c o m*/ * * @param args * the arguments * @throws Exception * the exception */ public static void main(String[] args) throws Exception { HydrographMain hydrographMain = new HydrographMain(); final Timer timer = new Timer(); final CountDownLatch latch = new CountDownLatch(1); try { Session session = null; boolean isExecutionTracking = false; String[] argsList = args; List<String> argumentList = new ArrayList<String>(Arrays.asList(args)); final String jobId = hydrographMain.getJobId(argumentList); getLogLevel(argumentList).ifPresent(x -> { if (!x.equalsIgnoreCase(String.valueOf(logger.getLevel()))) { setLoglevel(x); } else { Optional.empty(); } }); logger.info("Argument List: " + argumentList.toString()); String trackingClientSocketPort = hydrographMain.getTrackingClientSocketPort(argumentList); if (argumentList.contains(Constants.IS_TRACKING_ENABLE)) { int index = argumentList.indexOf(Constants.IS_TRACKING_ENABLE); isExecutionTracking = Boolean.valueOf(argsList[index + 1]); argumentList = removeItemFromIndex(index, argumentList); } if (argumentList.contains(Constants.TRACKING_CLIENT_SOCKET_PORT)) { int index = argumentList.indexOf(Constants.TRACKING_CLIENT_SOCKET_PORT); argumentList = removeItemFromIndex(index, argumentList); } argsList = argumentList.toArray(new String[argumentList.size()]); logger.debug("Execution tracking enabled - " + isExecutionTracking); logger.info("Tracking Client Port: " + trackingClientSocketPort); /** * Start new thread to run job */ final HydrographService execution = new HydrographService(); FutureTask task = hydrographMain.executeGraph(latch, jobId, argsList, execution, isExecutionTracking); hydrographMain.executorService = Executors.newSingleThreadExecutor(); hydrographMain.executorService.submit(task); if (isExecutionTracking) { //If tracking is enabled, start to post execution tracking status. final HydrographEngineCommunicatorSocket socket = new HydrographEngineCommunicatorSocket(execution); session = hydrographMain.connectToServer(socket, jobId, trackingClientSocketPort); hydrographMain.sendExecutionTrackingStatus(latch, session, jobId, timer, execution, socket); } //waiting for execute graph thread task.get(); } catch (Exception exp) { logger.info("Getting exception from HydrographMain"); throw new RuntimeException(exp); } finally { //cleanup threads --> executor thread and timer thread logger.info("HydrographMain releasing resources"); if (!hydrographMain.executorService.isShutdown() && !hydrographMain.executorService.isTerminated()) { hydrographMain.executorService.shutdown(); } timer.cancel(); } }
From source file:com.dhenton9000.screenshots.ScreenShotLauncher.java
/** * main launching method that takes command line arguments * * @param args/*from w ww. jav a 2 s . com*/ */ public static void main(String[] args) { final String[] actions = { ACTIONS.source.toString(), ACTIONS.target.toString(), ACTIONS.compare.toString() }; final List actionArray = Arrays.asList(actions); Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("action").hasArg().isRequired().withArgName("action").create()); HelpFormatter formatter = new HelpFormatter(); String header = "Process screenshots\n" + "--action=source create source screenshots\n" + "--action=target create the screenshots for comparison\n" + "--action=compare compare the images\n" + "%s\n\n"; String action = null; try { // parse the command line arguments CommandLineParser parser = new PosixParser(); CommandLine line = parser.parse(options, args); // validate that action option has been set if (line.hasOption("action")) { action = line.getOptionValue("action"); LOG.debug("action '" + action + "'"); if (!actionArray.contains(action)) { formatter.printHelp(ScreenShotLauncher.class.getName(), String.format(header, String.format("action option '%s' is invalid", action)), options, "\n\n", true); System.exit(1); } } else { formatter.printHelp(ScreenShotLauncher.class.getName(), String.format(header, "not found"), options, "\n\n", false); System.exit(1); } } catch (ParseException exp) { formatter.printHelp(ScreenShotLauncher.class.getName(), String.format(header, "problem " + exp.getMessage()), options, "\n\n", false); System.exit(1); } ACTIONS actionEnum = ACTIONS.valueOf(action); ScreenShotLauncher launcher = new ScreenShotLauncher(); try { launcher.handleRequest(actionEnum); } catch (Exception ex) { LOG.error(ex.getMessage(), ex); } }