List of usage examples for java.util Arrays asList
@SafeVarargs @SuppressWarnings("varargs") public static <T> List<T> asList(T... a)
From source file:com.thoughtworks.go.helpers.LocalhostWithLargeDataSets.java
public static void main(String[] args) throws Exception { DataUtils.cloneCCHome();//from w ww . j a va2 s. c o m int port = PORT; String sourceConfigFilePath = "test/data/4stages5builds-cruise-config.xml"; int numberOfPipelines = 5000; LocalhostWithLargeDataSets localhostWithLargeDataSets = new LocalhostWithLargeDataSets(port, sourceConfigFilePath, Arrays.asList(PIPELINE_NAME), Arrays.asList("stage1", "stage2", "stage3", "stage4"), Arrays.asList("build1", "build2", "build3", "build4", "build5")); prepareSampleDataFromZipFile(); mainAction(localhostWithLargeDataSets, numberOfPipelines); }
From source file:com.tbodt.trp.TheRapidPermuter.java
/** * Main method for The Rapid Permuter.//w w w .j a v a 2 s . c o m * * @param args * @throws IOException */ public static void main(String[] args) throws IOException { CommandProcessor.processCommand("\"\": remove(\"\") in([words])").ifPresent(x -> x.forEach(y -> { })); // to load all the classes we need try { cmd = new BasicParser().parse(options, args); } catch (ParseException ex) { System.err.println(ex.getMessage()); return; } if (Arrays.asList(cmd.getOptions()).contains(help)) { // another way commons cli is severely broken new HelpFormatter().printHelp("trp", options); return; } if (cmd.hasOption('c')) doCommand(cmd.getOptionValue('c')); else { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); System.out.print("trp> "); String input; while ((input = in.readLine()) != null) { if (input.equals("exit")) return; // exit doCommand(input); System.out.print("trp> "); } } }
From source file:com.talkdesk.geo.PhoneNumberGeoMap.java
/** * @param args//from w w w . j ava 2 s . c om * @throws IOException * @throws SQLException * @throws ClassNotFoundException * @throws GeoResolverException */ public static void main(String[] args) throws GeoResolverException { // create Options object DBConnector connector = new DBConnector(); GeoCodeResolver resolver = new GeoCodeResolver(connector.getDefaultDBconnection()); ArrayList list = new ArrayList(Arrays.asList(args)); Hashtable<String, Double> infoTable = new Hashtable<String, Double>(); if (list.contains("--populate-data")) { GeoCodeRepositoryBuilder repositoryBuilder = new GeoCodeRepositoryBuilder(); if (list.contains("--country")) repositoryBuilder.populateCountryData(); else if (list.contains("--geo")) repositoryBuilder.populateGeoData(); else { repositoryBuilder.populateCountryData(); repositoryBuilder.populateGeoData(); } } else if (list.contains("--same-country-only")) { list.remove("--same-country-only"); infoTable = resolver.buildInfoTable(list, true); } else { infoTable = resolver.buildInfoTable(list, false); } String phoneNumber = resolver.getClosestNumber(infoTable); if (phoneNumber != null) { System.out.println("-----------------------"); System.out.println(phoneNumber); Locale locale = new Locale("en", phoneNumber.split(":")[0]); System.out.println(locale.getDisplayCountry()); } else { System.out.println("-----------------------"); System.out.println("No Result ..!!!"); } }
From source file:de.javagl.jgltf.browser.MenuNodesCreator.java
/** * For internal purposes only//from ww w . j a va2s . c o m * * @param args Not used * @throws IOException If an IO error occurs */ public static void main(String[] args) throws IOException { MenuNode samplesNode = new MenuNode(); samplesNode.label = "Samples"; samplesNode.children = new ArrayList<MenuNode>(); samplesNode.children.add(createKhronosNode10()); samplesNode.children.add(createTutorialNode()); write(Arrays.asList(samplesNode), System.out); }
From source file:cz.incad.kramerius.imaging.lp.DeleteGeneratedDeepZoomCache.java
public static void main(String[] args) throws IOException, ProcessSubtreeException { System.out.println("Delete deepZoomCache :" + Arrays.asList(args)); if (args.length == 1) { Injector injector = Guice.createInjector(new GenerateDeepZoomCacheModule(), new Fedora3Module()); FedoraAccess fa = injector.getInstance(Key.get(FedoraAccess.class, Names.named("securedFedoraAccess"))); DiscStrucutreForStore discStruct = injector.getInstance(DiscStrucutreForStore.class); deleteCacheForPID(args[0], fa, discStruct); boolean spawnFlag = Boolean.getBoolean(GenerateDeepZoomFlag.class.getName()); if (spawnFlag) { String[] processArgs = { GenerateDeepZoomFlag.Action.DELETE.name(), args[0] }; ProcessUtils.startProcess("generateDeepZoomFlag", processArgs); }/* w w w . ja v a2 s. c om*/ } }
From source file:com.adobe.aem.demomachine.Checksums.java
public static void main(String[] args) { String rootFolder = null;//from ww w . ja v a 2 s. co m // Command line options for this tool Options options = new Options(); options.addOption("f", true, "Demo Machine root folder"); CommandLineParser parser = new BasicParser(); try { CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("f")) { rootFolder = cmd.getOptionValue("f"); } } catch (Exception e) { System.exit(-1); } Properties md5properties = new Properties(); List<String[]> listPaths = Arrays.asList(AemDemoConstants.demoPaths); for (String[] path : listPaths) { if (path.length == 5) { logger.debug(path[1]); File pathFolder = new File(rootFolder + (path[1].length() > 0 ? (File.separator + path[1]) : "")); if (pathFolder.exists()) { String md5 = AemDemoUtils.calcMD5HashForDir(pathFolder, Boolean.parseBoolean(path[3]), false); logger.debug("MD5 is: " + md5); md5properties.setProperty("demo.path." + path[0], path[1]); md5properties.setProperty("demo.md5." + path[0], md5); } else { logger.error("Folder cannot be found"); } } } File md5 = new File(rootFolder + File.separator + "conf" + File.separator + "checksums.properties"); try { @SuppressWarnings("serial") Properties tmpProperties = new Properties() { @Override public synchronized Enumeration<Object> keys() { return Collections.enumeration(new TreeSet<Object>(super.keySet())); } }; tmpProperties.putAll(md5properties); tmpProperties.store(new FileOutputStream(md5), null); } catch (Exception e) { logger.error(e.getMessage()); } System.out.println("MD5 checkums generated"); }
From source file:com.yahoo.labs.samoa.topology.impl.StormTopologySubmitter.java
public static void main(String[] args) throws IOException { Properties props = StormSamoaUtils.getProperties(); String uploadedJarLocation = props.getProperty(StormJarSubmitter.UPLOADED_JAR_LOCATION_KEY); if (uploadedJarLocation == null) { logger.error("Invalid properties file. It must have key {}", StormJarSubmitter.UPLOADED_JAR_LOCATION_KEY); return;/* w w w. ja va 2 s .c o m*/ } List<String> tmpArgs = new ArrayList<String>(Arrays.asList(args)); int numWorkers = StormSamoaUtils.numWorkers(tmpArgs); args = tmpArgs.toArray(new String[0]); StormTopology stormTopo = StormSamoaUtils.argsToTopology(args); Config conf = new Config(); conf.putAll(Utils.readStormConfig()); conf.putAll(Utils.readCommandLineOpts()); conf.setDebug(false); conf.setNumWorkers(numWorkers); String profilerOption = props.getProperty(StormTopologySubmitter.YJP_OPTIONS_KEY); if (profilerOption != null) { String topoWorkerChildOpts = (String) conf.get(Config.TOPOLOGY_WORKER_CHILDOPTS); StringBuilder optionBuilder = new StringBuilder(); if (topoWorkerChildOpts != null) { optionBuilder.append(topoWorkerChildOpts); optionBuilder.append(' '); } optionBuilder.append(profilerOption); conf.put(Config.TOPOLOGY_WORKER_CHILDOPTS, optionBuilder.toString()); } Map<String, Object> myConfigMap = new HashMap<String, Object>(conf); StringWriter out = new StringWriter(); try { JSONValue.writeJSONString(myConfigMap, out); } catch (IOException e) { System.out.println("Error in writing JSONString"); e.printStackTrace(); return; } Config config = new Config(); config.putAll(Utils.readStormConfig()); String nimbusHost = (String) config.get(Config.NIMBUS_HOST); NimbusClient nc = new NimbusClient(nimbusHost); String topologyName = stormTopo.getTopologyName(); try { System.out.println("Submitting topology with name: " + topologyName); nc.getClient().submitTopology(topologyName, uploadedJarLocation, out.toString(), stormTopo.getStormBuilder().createTopology()); System.out.println(topologyName + " is successfully submitted"); } catch (AlreadyAliveException aae) { System.out.println("Fail to submit " + topologyName + "\nError message: " + aae.get_msg()); } catch (InvalidTopologyException ite) { System.out.println("Invalid topology for " + topologyName); ite.printStackTrace(); } catch (TException te) { System.out.println("Texception for " + topologyName); te.printStackTrace(); } }
From source file:com.ok2c.lightmtp.examples.LocalMailClientTransportExample.java
public static void main(final String[] args) throws Exception { String text1 = "From: root\r\n" + "To: testuser1\r\n" + "Subject: test message 1\r\n" + "\r\n" + "This is a short test message 1\r\n"; String text2 = "From: root\r\n" + "To: testuser1, testuser2\r\n" + "Subject: test message 2\r\n" + "\r\n" + "This is a short test message 2\r\n"; String text3 = "From: root\r\n" + "To: testuser1, testuser2, testuser3\r\n" + "Subject: test message 3\r\n" + "\r\n" + "This is a short test message 3\r\n"; DeliveryRequest request1 = new BasicDeliveryRequest("root", Arrays.asList("testuser1"), new ByteArraySource(text1.getBytes("US-ASCII"))); DeliveryRequest request2 = new BasicDeliveryRequest("root", Arrays.asList("testuser1", "testuser2"), new ByteArraySource(text2.getBytes("US-ASCII"))); DeliveryRequest request3 = new BasicDeliveryRequest("root", Arrays.asList("testuser1", "testuser2", "testuser3"), new ByteArraySource(text3.getBytes("US-ASCII"))); Queue<DeliveryRequest> queue = new ConcurrentLinkedQueue<DeliveryRequest>(); queue.add(request1);/* w ww . j a v a 2s . c o m*/ queue.add(request2); queue.add(request3); CountDownLatch messageCount = new CountDownLatch(queue.size()); IOReactorConfig config = IOReactorConfig.custom().setIoThreadCount(1).build(); MailClientTransport mua = new LocalMailClientTransport(config); mua.start(new MyDeliveryRequestHandler(messageCount)); SessionEndpoint endpoint = new SessionEndpoint(new InetSocketAddress("localhost", 2525)); SessionRequest sessionRequest = mua.connect(endpoint, queue, null); sessionRequest.waitFor(); IOSession iosession = sessionRequest.getSession(); if (iosession != null) { messageCount.await(); } else { IOException ex = sessionRequest.getException(); if (ex != null) { System.out.println("Connection failed: " + ex.getMessage()); } } System.out.println("Shutting down I/O reactor"); try { mua.shutdown(); } catch (IOException ex) { mua.forceShutdown(); } System.out.println("Done"); }
From source file:com.cloud.test.utils.SubmitCert.java
public static void main(String[] args) { // Parameters List<String> argsList = Arrays.asList(args); Iterator<String> iter = argsList.iterator(); while (iter.hasNext()) { String arg = iter.next(); if (arg.equals("-c")) { certFileName = iter.next();//from w w w . ja v a2 s. c om } if (arg.equals("-s")) { secretKey = iter.next(); } if (arg.equals("-a")) { apiKey = iter.next(); } if (arg.equals("-action")) { url = "Action=" + iter.next(); } } Properties prop = new Properties(); try { prop.load(new FileInputStream("conf/tool.properties")); } catch (IOException ex) { s_logger.error("Error reading from conf/tool.properties", ex); System.exit(2); } host = prop.getProperty("host"); port = prop.getProperty("port"); if (url.equals("Action=SetCertificate") && certFileName == null) { s_logger.error("Please set path to certificate (including file name) with -c option"); System.exit(1); } if (secretKey == null) { s_logger.error("Please set secretkey with -s option"); System.exit(1); } if (apiKey == null) { s_logger.error("Please set apikey with -a option"); System.exit(1); } if (host == null) { s_logger.error("Please set host in tool.properties file"); System.exit(1); } if (port == null) { s_logger.error("Please set port in tool.properties file"); System.exit(1); } TreeMap<String, String> param = new TreeMap<String, String>(); String req = "GET\n" + host + ":" + prop.getProperty("port") + "\n/" + prop.getProperty("accesspoint") + "\n"; String temp = ""; if (certFileName != null) { cert = readCert(certFileName); param.put("cert", cert); } param.put("AWSAccessKeyId", apiKey); param.put("Expires", prop.getProperty("expires")); param.put("SignatureMethod", prop.getProperty("signaturemethod")); param.put("SignatureVersion", "2"); param.put("Version", prop.getProperty("version")); StringTokenizer str1 = new StringTokenizer(url, "&"); while (str1.hasMoreTokens()) { String newEl = str1.nextToken(); StringTokenizer str2 = new StringTokenizer(newEl, "="); String name = str2.nextToken(); String value = str2.nextToken(); param.put(name, value); } //sort url hash map by key Set c = param.entrySet(); Iterator it = c.iterator(); while (it.hasNext()) { Map.Entry me = (Map.Entry) it.next(); String key = (String) me.getKey(); String value = (String) me.getValue(); try { temp = temp + key + "=" + URLEncoder.encode(value, "UTF-8") + "&"; } catch (Exception ex) { s_logger.error("Unable to set parameter " + value + " for the command " + param.get("command"), ex); } } temp = temp.substring(0, temp.length() - 1); String requestToSign = req + temp; String signature = UtilsForTest.signRequest(requestToSign, secretKey); String encodedSignature = ""; try { encodedSignature = URLEncoder.encode(signature, "UTF-8"); } catch (Exception ex) { ex.printStackTrace(); } String url = "http://" + host + ":" + prop.getProperty("port") + "/" + prop.getProperty("accesspoint") + "?" + temp + "&Signature=" + encodedSignature; s_logger.info("Sending request with url: " + url + "\n"); sendRequest(url); }
From source file:gr.cslab.Metric_test.java
public static void main(String[] args) throws InterruptedException { readArgs(Arrays.asList(args)); loadHostFile();//ww w .j a va 2 s. co m JSONArray inJson = file2Json(metricsFile); loadJsonMetrics(inJson); if (hostsFile != null) { //TODO: read hosts file } connectToHosts(); //if the list arg was given, only list the available names and exit if (list) { list(); System.exit(0); } for (;;) { reportAll(); Thread.sleep(interval * 1000); } }