List of usage examples for java.lang Integer parseInt
public static int parseInt(String s) throws NumberFormatException
From source file:Server.java
/** * A main() method for running the server as a standalone program. The * command-line arguments to the program should be pairs of servicenames and * port numbers. For each pair, the program will dynamically load the named * Service class, instantiate it, and tell the server to provide that * Service on the specified port. The special -control argument should be * followed by a password and port, and will start special server control * service running on the specified port, protected by the specified * password./*from w w w . j a v a 2s.c o m*/ */ public static void main(String[] args) { try { if (args.length < 2) // Check number of arguments throw new IllegalArgumentException("Must specify a service"); // Create a Server object that uses standard out as its log and // has a limit of ten concurrent connections at once. Server s = new Server(System.out, 10); // Parse the argument list int i = 0; while (i < args.length) { if (args[i].equals("-control")) { // Handle the -control arg i++; String password = args[i++]; int port = Integer.parseInt(args[i++]); // add control service s.addService(new Control(s, password), port); } else { // Otherwise start a named service on the specified port. // Dynamically load and instantiate a Service class String serviceName = args[i++]; Class serviceClass = Class.forName(serviceName); Service service = (Service) serviceClass.newInstance(); int port = Integer.parseInt(args[i++]); s.addService(service, port); } } } catch (Exception e) { // Display a message if anything goes wrong System.err.println("Server: " + e); System.err.println( "Usage: java Server " + "[-control <password> <port>] " + "[<servicename> <port> ... ]"); System.exit(1); } }
From source file:eu.roschi.obdkinesis.HttpReferrerCounterApplication.java
/** * Start the Kinesis Client application. * /* w w w . ja va 2 s. c o m*/ * @param args Expecting 4 arguments: Application name to use for the Kinesis Client Application, Stream name to * read from, DynamoDB table name to persist counts into, and the AWS region in which these resources * exist or should be created. */ public static void main(String[] args) throws UnknownHostException { if (args.length != 2) { System.err.println("Using default values"); COMPUTE_RANGE_FOR_COUNTS_IN_MILLIS = 30000; COMPUTE_INTERVAL_IN_MILLIS = 2000; } else { COMPUTE_RANGE_FOR_COUNTS_IN_MILLIS = Integer.parseInt(args[0]); COMPUTE_INTERVAL_IN_MILLIS = Integer.parseInt(args[1]); System.err.println( "Using values " + Integer.parseInt(args[0]) + " width " + Integer.parseInt(args[1]) + " rate"); } String applicationName = "obd_kinesis"; String streamName = "obd_input_stream"; String countsTableName = "obd_kinesis_count"; Region region = SampleUtils.parseRegion("us-west-2"); AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain(); ClientConfiguration clientConfig = SampleUtils.configureUserAgentForSample(new ClientConfiguration()); AmazonKinesis kinesis = new AmazonKinesisClient(credentialsProvider, clientConfig); kinesis.setRegion(region); AmazonDynamoDB dynamoDB = new AmazonDynamoDBClient(credentialsProvider, clientConfig); dynamoDB.setRegion(region); // Creates a stream to write to, if it doesn't exist StreamUtils streamUtils = new StreamUtils(kinesis); streamUtils.createStreamIfNotExists(streamName, 2); LOG.info(String.format("%s stream is ready for use", streamName)); DynamoDBUtils dynamoDBUtils = new DynamoDBUtils(dynamoDB); dynamoDBUtils.createCountTableIfNotExists(countsTableName); LOG.info(String.format("%s DynamoDB table is ready for use", countsTableName)); String workerId = String.valueOf(UUID.randomUUID()); LOG.info(String.format("Using working id: %s", workerId)); KinesisClientLibConfiguration kclConfig = new KinesisClientLibConfiguration(applicationName, streamName, credentialsProvider, workerId); kclConfig.withCommonClientConfig(clientConfig); kclConfig.withRegionName(region.getName()); kclConfig.withInitialPositionInStream(InitialPositionInStream.LATEST); // Persist counts to DynamoDB DynamoDBCountPersister persister = new DynamoDBCountPersister( dynamoDBUtils.createMapperForTable(countsTableName)); IRecordProcessorFactory recordProcessor = new CountingRecordProcessorFactory<HttpReferrerPair>( HttpReferrerPair.class, persister, COMPUTE_RANGE_FOR_COUNTS_IN_MILLIS, COMPUTE_INTERVAL_IN_MILLIS); Worker worker = new Worker(recordProcessor, kclConfig); int exitCode = 0; try { worker.run(); } catch (Throwable t) { LOG.error("Caught throwable while processing data.", t); exitCode = 1; } System.exit(exitCode); }
From source file:net.swigg.talo.TaloCacheBootstrap.java
public static void main(String[] args) throws ConfigurationException, ParseException { Options options = new Options(); options.addOption("help", false, "help"); options.addOption("listenHost", true, "interface to listen on"); options.addOption("listenPort", true, "port to listen on"); options.addOption("targetPrefix", true, "where to proxy to"); CommandLineParser parser = new BasicParser(); CommandLine command = parser.parse(options, args); if (command.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("talocache", options); return;//w w w . j a v a2 s . c o m } BootstrapConfig config = new BootstrapConfig(); config.listenHost = command.getOptionValue("listenHost", config.listenHost); config.listenPort = Integer.parseInt(command.getOptionValue("listenPort", config.listenPort.toString())); config.targetPrefix = command.getOptionValue("targetPrefix", config.targetPrefix); TaloCacheBootstrap taloCache = new TaloCacheBootstrap(config); taloCache.start(); }
From source file:com.edduarte.argus.Main.java
public static void main(String[] args) { installUncaughtExceptionHandler();// w w w .j a v a 2s . co m CommandLineParser parser = new GnuParser(); Options options = new Options(); options.addOption("t", "threads", true, "Number of threads to be used " + "for computation and indexing processes. Defaults to the number " + "of available cores."); options.addOption("p", "port", true, "Core server port. Defaults to 9000."); options.addOption("dbh", "db-host", true, "Database host. Defaults to localhost."); options.addOption("dbp", "db-port", true, "Database port. Defaults to 27017."); options.addOption("case", "preserve-case", false, "Keyword matching with case sensitivity."); options.addOption("stop", "stopwords", false, "Keyword matching with stopword filtering."); options.addOption("stem", "stemming", false, "Keyword matching with stemming (lexical variants)."); options.addOption("h", "help", false, "Shows this help prompt."); CommandLine commandLine; try { // Parse the program arguments commandLine = parser.parse(options, args); } catch (ParseException ex) { logger.error("There was a problem processing the input arguments. " + "Write -h or --help to show the list of available commands."); logger.error(ex.getMessage(), ex); return; } if (commandLine.hasOption('h')) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar argus-core.jar", options); return; } int maxThreads = Runtime.getRuntime().availableProcessors() - 1; maxThreads = maxThreads > 0 ? maxThreads : 1; if (commandLine.hasOption('t')) { String threadsText = commandLine.getOptionValue('t'); maxThreads = Integer.parseInt(threadsText); if (maxThreads <= 0 || maxThreads > 32) { logger.error("Invalid number of threads. Must be a number between 1 and 32."); return; } } int port = 9000; if (commandLine.hasOption('p')) { String portString = commandLine.getOptionValue('p'); port = Integer.parseInt(portString); } String dbHost = "localhost"; if (commandLine.hasOption("dbh")) { dbHost = commandLine.getOptionValue("dbh"); } int dbPort = 27017; if (commandLine.hasOption("dbp")) { String portString = commandLine.getOptionValue("dbp"); dbPort = Integer.parseInt(portString); } boolean isIgnoringCase = true; if (commandLine.hasOption("case")) { isIgnoringCase = false; } boolean isStoppingEnabled = false; if (commandLine.hasOption("stop")) { isStoppingEnabled = true; } boolean isStemmingEnabled = false; if (commandLine.hasOption("stem")) { isStemmingEnabled = true; } try { Context context = Context.getInstance(); context.setIgnoreCase(isIgnoringCase); context.setStopwordsEnabled(isStoppingEnabled); context.setStemmingEnabled(isStemmingEnabled); context.start(port, maxThreads, dbHost, dbPort); } catch (Exception ex) { ex.printStackTrace(); logger.info("Shutting down the server..."); System.exit(1); } }
From source file:friendsandfollowers.DBFollowersIDs.java
public static void main(String[] args) throws ClassNotFoundException, SQLException, JSONException, FileNotFoundException, UnsupportedEncodingException { // Check arguments that passed in if ((args == null) || (args.length == 0)) { System.err.println("2 Parameters are required plus one optional " + "parameter to launch a Job."); System.err.println("First: String 'OUTPUT: /output/path/'"); System.err.println("Second: (int) Number of ids to fetch. " + "Provide number which increment by 5000 " + "(5000, 10000, 15000 etc) " + "or -1 to fetch all ids."); System.err.println("Third (optional): 'screen_name / user_id_str'"); System.err.println("If 3rd argument not provided then provide" + " Twitter users through database."); System.exit(-1);/*from w w w .j av a 2 s .c o m*/ } MysqlDB DB = new MysqlDB(); AppOAuth AppOAuths = new AppOAuth(); Misc helpers = new Misc(); String endpoint = "/followers/ids"; String OutputDirPath = null; try { OutputDirPath = StringEscapeUtils.escapeJava(args[0]); } catch (Exception e) { System.err.println("Argument" + args[0] + " must be an String."); System.exit(-1); } int IDS_TO_FETCH_INT = -1; try { IDS_TO_FETCH_INT = Integer.parseInt(args[1]); } catch (NumberFormatException e) { System.err.println("Argument" + args[1] + " must be an integer."); System.exit(-1); } int IDS_TO_FETCH = 0; if (IDS_TO_FETCH_INT > 5000) { float IDS_TO_FETCH_F = (float) IDS_TO_FETCH_INT / 5000; IDS_TO_FETCH = (int) Math.ceil(IDS_TO_FETCH_F); } else if ((IDS_TO_FETCH_INT <= 5000) && (IDS_TO_FETCH_INT > 0)) { IDS_TO_FETCH = 1; } String targetedUser = ""; if (args.length == 3) { try { targetedUser = StringEscapeUtils.escapeJava(args[2]); } catch (Exception e) { System.err.println("Argument" + args[2] + " must be an String."); System.exit(-1); } } try { TwitterFactory tf = AppOAuths.loadOAuthUser(endpoint); Twitter twitter = tf.getInstance(); int RemainingCalls = AppOAuths.RemainingCalls; int RemainingCallsCounter = 0; System.out.println("First Time Remianing Calls: " + RemainingCalls); String Screen_name = AppOAuths.screen_name; System.out.println("First Time Loaded OAuth Screen_name: " + Screen_name); IDs ids; System.out.println("Listing followers ids."); // if targetedUser not provided by argument, then look into database. if (StringUtils.isEmpty(targetedUser)) { String selectQuery = "SELECT * FROM `followers_parent` WHERE " + "`targeteduser` != '' AND " + "`nextcursor` != '0' AND " + "`nextcursor` != '2'"; ResultSet results = DB.selectQ(selectQuery); int numRows = DB.numRows(results); if (numRows < 1) { System.err.println("No User in database to get followersIDS"); System.exit(-1); } OUTERMOST: while (results.next()) { int followers_parent_id = results.getInt("id"); targetedUser = results.getString("targeteduser"); long cursor = results.getLong("nextcursor"); System.out.println("Targeted User: " + targetedUser); int idsLoopCounter = 0; int totalIDs = 0; // put idsJSON in a file PrintWriter writer = new PrintWriter(OutputDirPath + "/" + targetedUser, "UTF-8"); // call different functions for screen_name and id_str Boolean chckedNumaric = helpers.isNumeric(targetedUser); do { ids = null; try { if (chckedNumaric) { long LongValueTargetedUser = Long.valueOf(targetedUser).longValue(); ids = twitter.getFollowersIDs(LongValueTargetedUser, cursor); } else { ids = twitter.getFollowersIDs(targetedUser, cursor); } } catch (TwitterException te) { // do not throw if user has protected tweets, // or if they deleted their account if (te.getStatusCode() == HttpResponseCode.UNAUTHORIZED || te.getStatusCode() == HttpResponseCode.NOT_FOUND) { System.out.println(targetedUser + " is protected or account is deleted"); } else { System.out.println("Followers Get Exception: " + te.getMessage()); } // If rate limit reached then switch Auth user RemainingCallsCounter++; if (RemainingCallsCounter >= RemainingCalls) { // load auth user tf = AppOAuths.loadOAuthUser(endpoint); twitter = tf.getInstance(); System.out.println( "New User Loaded OAuth" + " Screen_name: " + AppOAuths.screen_name); RemainingCalls = AppOAuths.RemainingCalls; RemainingCallsCounter = 0; System.out.println("New Remianing Calls: " + RemainingCalls); } // update cursor in "followers_parent" String fieldValues = "`nextcursor` = 2"; String where = "id = " + followers_parent_id; DB.Update("`followers_parent`", fieldValues, where); // If error then switch to next user continue OUTERMOST; } if (ids.getIDs().length > 0) { idsLoopCounter++; totalIDs += ids.getIDs().length; System.out.println(idsLoopCounter + ": IDS length: " + ids.getIDs().length); JSONObject responseDetailsJson = new JSONObject(); JSONArray jsonArray = new JSONArray(); for (long id : ids.getIDs()) { jsonArray.put(id); } Object idsJSON = responseDetailsJson.put("ids", jsonArray); writer.println(idsJSON); } // If rate limit reached then switch Auth user RemainingCallsCounter++; if (RemainingCallsCounter >= RemainingCalls) { // load auth user tf = AppOAuths.loadOAuthUser(endpoint); twitter = tf.getInstance(); System.out.println("New User Loaded OAuth " + "Screen_name: " + AppOAuths.screen_name); RemainingCalls = AppOAuths.RemainingCalls; RemainingCallsCounter = 0; System.out.println("New Remianing Calls: " + RemainingCalls); } if (IDS_TO_FETCH_INT != -1) { if (idsLoopCounter == IDS_TO_FETCH) { break; } } } while ((cursor = ids.getNextCursor()) != 0); writer.close(); System.out.println("Total ids dumped of " + targetedUser + " are: " + totalIDs); System.out.println(); // update cursor in "followers_parent" String fieldValues = "`nextcursor` = " + cursor; String where = "id = " + followers_parent_id; DB.Update("`followers_parent`", fieldValues, where); } // loop through every result found in db } else { // Second Argument Set, so we are here. System.out.println("screen_name / user_id_str passed by argument"); int idsLoopCounter = 0; int totalIDs = 0; // put idsJSON in a file PrintWriter writer = new PrintWriter( OutputDirPath + "/" + targetedUser + "_ids_" + helpers.getUnixTimeStamp(), "UTF-8"); // call different functions for screen_name and id_str Boolean chckedNumaric = helpers.isNumeric(targetedUser); long cursor = -1; do { ids = null; try { if (chckedNumaric) { long LongValueTargetedUser = Long.valueOf(targetedUser).longValue(); ids = twitter.getFollowersIDs(LongValueTargetedUser, cursor); } else { ids = twitter.getFollowersIDs(targetedUser, cursor); } } catch (TwitterException te) { // do not throw if user has protected tweets, or if they deleted their account if (te.getStatusCode() == HttpResponseCode.UNAUTHORIZED || te.getStatusCode() == HttpResponseCode.NOT_FOUND) { System.out.println(targetedUser + " is protected or account is deleted"); } else { System.out.println("Followers Get Exception: " + te.getMessage()); } System.exit(-1); } if (ids.getIDs().length > 0) { idsLoopCounter++; totalIDs += ids.getIDs().length; System.out.println(idsLoopCounter + ": IDS length: " + ids.getIDs().length); JSONObject responseDetailsJson = new JSONObject(); JSONArray jsonArray = new JSONArray(); for (long id : ids.getIDs()) { jsonArray.put(id); } Object idsJSON = responseDetailsJson.put("ids", jsonArray); writer.println(idsJSON); } // If rate limit reach then switch Auth user RemainingCallsCounter++; if (RemainingCallsCounter >= RemainingCalls) { // load auth user tf = AppOAuths.loadOAuthUser(endpoint); twitter = tf.getInstance(); System.out.println("New User Loaded OAuth Screen_name: " + AppOAuths.screen_name); RemainingCalls = AppOAuths.RemainingCalls; RemainingCallsCounter = 0; System.out.println("New Remianing Calls: " + RemainingCalls); } if (IDS_TO_FETCH_INT != -1) { if (idsLoopCounter == IDS_TO_FETCH) { break; } } } while ((cursor = ids.getNextCursor()) != 0); writer.close(); System.out.println("Total ids dumped of " + targetedUser + " are: " + totalIDs); System.out.println(); } } catch (TwitterException te) { // te.printStackTrace(); System.err.println("Failed to get followers' ids: " + te.getMessage()); System.exit(-1); } System.out.println("!!!! DONE !!!!"); }
From source file:dhtaccess.benchmark.ThroughputMeasure.java
public static void main(String[] args) { boolean details = false; int repeats = DEFAULT_REPEATS; int queryFreq = DEFAULT_QUERIES_PER_SEC; boolean doPut = true; // parse options Options options = new Options(); options.addOption("h", "help", false, "print help"); options.addOption("d", "details", false, "requests secret hash and TTL"); options.addOption("r", "repeats", true, "number of requests"); options.addOption("f", "freq", true, "number of queries per second"); options.addOption("n", "no-put", false, "does not put"); CommandLineParser parser = new PosixParser(); CommandLine cmd = null;/*from w w w.j a va 2 s . co m*/ try { cmd = parser.parse(options, args); } catch (ParseException e) { System.out.println("There is an invalid option."); e.printStackTrace(); System.exit(1); } String optVal; if (cmd.hasOption('h')) { usage(COMMAND); System.exit(1); } if (cmd.hasOption('d')) { details = true; } optVal = cmd.getOptionValue('r'); if (optVal != null) { repeats = Integer.parseInt(optVal); } optVal = cmd.getOptionValue('f'); if (optVal != null) { queryFreq = Integer.parseInt(optVal); } if (cmd.hasOption('n')) { doPut = false; } args = cmd.getArgs(); // parse arguments if (args.length < 1) { usage(COMMAND); System.exit(1); } (new ThroughputMeasure()).start(details, repeats, queryFreq, doPut, args); }
From source file:ee.ria.xroad.opmonitordaemon.OperationalDataRecordsGenerator.java
/** * Main function.//from w w w .j a v a 2 s . c om * @param args args * @throws Exception if something goes wrong. */ public static void main(String args[]) throws Exception { CommandLine cmd = parseCommandLine(args); if (cmd.hasOption("help")) { usage(); System.exit(0); } long startTimestamp = cmd.getOptionValue("timestamp") != null ? Long.parseLong(cmd.getOptionValue("timestamp")) : DEFAULT_FIRST_TIMESTAMP; int batchSize = cmd.getOptionValue("batch-size") != null ? Integer.parseInt(cmd.getOptionValue("batch-size")) : DEFAULT_BATCH_SIZE; int batchCount = cmd.getOptionValue("batch-count") != null ? Integer.parseInt(cmd.getOptionValue("batch-count")) : DEFAULT_BATCH_COUNT; String longString = cmd.getOptionValue("long-string-length") != null ? getDummyStr(Integer.parseInt(cmd.getOptionValue("long-string-length"))) : getDummyStr(DEFAULT_LONG_STRING_LENGTH); String shortString = cmd.getOptionValue("short-string-length") != null ? getDummyStr(Integer.parseInt(cmd.getOptionValue("short-string-length"))) : getDummyStr(DEFAULT_SHORT_LONG_STRING_LENGTH); log.info("first timestamp: {}, batch-size: {}, batch-count: {}", startTimestamp, batchSize, batchCount); for (int i = 0; i < batchCount; ++i) { storeRecords(batchSize, startTimestamp++, longString, shortString); } log.info("{} records generated", batchCount * batchSize); }
From source file:com.edduarte.vokter.Main.java
public static void main(String[] args) { installUncaughtExceptionHandler();/* w w w .j ava 2s . c o m*/ CommandLineParser parser = new GnuParser(); Options options = new Options(); options.addOption("t", "threads", true, "Number of threads to be used " + "for computation and indexing processes. Defaults to the number " + "of available cores."); options.addOption("p", "port", true, "Core server port. Defaults to 9000."); options.addOption("dbh", "db-host", true, "Database host. Defaults to localhost."); options.addOption("dbp", "db-port", true, "Database port. Defaults to 27017."); options.addOption("case", "preserve-case", false, "Keyword matching with case sensitivity."); options.addOption("stop", "stopwords", false, "Keyword matching with stopword filtering."); options.addOption("stem", "stemming", false, "Keyword matching with stemming (lexical variants)."); options.addOption("h", "help", false, "Shows this help prompt."); CommandLine commandLine; try { // Parse the program arguments commandLine = parser.parse(options, args); } catch (ParseException ex) { logger.error("There was a problem processing the input arguments. " + "Write -h or --help to show the list of available commands."); logger.error(ex.getMessage(), ex); return; } if (commandLine.hasOption('h')) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar vokter-core.jar", options); return; } int maxThreads = Runtime.getRuntime().availableProcessors() - 1; maxThreads = maxThreads > 0 ? maxThreads : 1; if (commandLine.hasOption('t')) { String threadsText = commandLine.getOptionValue('t'); maxThreads = Integer.parseInt(threadsText); if (maxThreads <= 0 || maxThreads > 32) { logger.error("Invalid number of threads. Must be a number between 1 and 32."); return; } } int port = 9000; if (commandLine.hasOption('p')) { String portString = commandLine.getOptionValue('p'); port = Integer.parseInt(portString); } String dbHost = "localhost"; if (commandLine.hasOption("dbh")) { dbHost = commandLine.getOptionValue("dbh"); } int dbPort = 27017; if (commandLine.hasOption("dbp")) { String portString = commandLine.getOptionValue("dbp"); dbPort = Integer.parseInt(portString); } boolean isIgnoringCase = true; if (commandLine.hasOption("case")) { isIgnoringCase = false; } boolean isStoppingEnabled = false; if (commandLine.hasOption("stop")) { isStoppingEnabled = true; } boolean isStemmingEnabled = false; if (commandLine.hasOption("stem")) { isStemmingEnabled = true; } try { Context context = Context.getInstance(); context.setIgnoreCase(isIgnoringCase); context.setStopwordsEnabled(isStoppingEnabled); context.setStemmingEnabled(isStemmingEnabled); context.start(port, maxThreads, dbHost, dbPort); } catch (Exception ex) { ex.printStackTrace(); logger.info("Shutting down the server..."); System.exit(1); } }
From source file:SparkStreaming.java
public static void main(String[] args) throws Exception { JSONObject jo = new JSONObject(); SparkConf sparkConf = new SparkConf().setAppName("mytestapp").setMaster("local[2]"); JavaStreamingContext jssc = new JavaStreamingContext(sparkConf, new Duration(2000)); int numThreads = Integer.parseInt("2"); Map<String, Integer> topicMap = new HashMap<>(); String[] topics = "testdemo".split(","); for (String topic : topics) { topicMap.put(topic, numThreads); }/*from w ww . java 2 s .c om*/ JavaPairReceiverInputDStream<String, String> messages = KafkaUtils.createStream(jssc, "localhost:2181", "testdemo", topicMap); JavaDStream<String> lines = messages.map(new Function<Tuple2<String, String>, String>() { @Override public String call(Tuple2<String, String> tuple2) { return tuple2._2(); } }); JavaDStream<String> words = lines.flatMap(new FlatMapFunction<String, String>() { @Override public Iterable<String> call(String x) throws IOException { String temperature = x.substring(x.indexOf(":") + 1); /* System.out.println("Temperature from spark++++++++++ "+temperature); URL url = new URL("http://localhost:8080/apachetest/Test?var1="+temperature); URLConnection conn = url.openConnection(); conn.setDoOutput(true);*/ final ThermometerDemo2 demo = new ThermometerDemo2("Thermometer Demo 2", temperature); demo.pack(); demo.setVisible(true); return Arrays.asList(x.split(" ")); } }); JavaPairDStream<String, Integer> wordCounts = words.mapToPair(new PairFunction<String, String, Integer>() { @Override public Tuple2<String, Integer> call(String s) { return new Tuple2<>(s, 1); } }).reduceByKey(new Function2<Integer, Integer, Integer>() { @Override public Integer call(Integer i1, Integer i2) { return i1 + i2; } }); wordCounts.print(); jssc.start(); jssc.awaitTermination(); }
From source file:com.aerospike.examples.BatchUpdateTTL.java
public static void main(String[] args) throws AerospikeException { try {//w w w. j a va 2 s. c o m Options options = new Options(); options.addOption("h", "host", true, "Server hostname (default: 127.0.0.1)"); options.addOption("p", "port", true, "Server port (default: 3000)"); options.addOption("n", "namespace", true, "Namespace (default: test)"); options.addOption("s", "set", true, "Set (default: demo)"); options.addOption("u", "usage", false, "Print usage."); CommandLineParser parser = new PosixParser(); CommandLine cl = parser.parse(options, args, false); String host = cl.getOptionValue("h", "127.0.0.1"); String portString = cl.getOptionValue("p", "3000"); int port = Integer.parseInt(portString); String namespace = cl.getOptionValue("n", "test"); String set = cl.getOptionValue("s", "demo"); log.debug("Host: " + host); log.debug("Port: " + port); log.debug("Namespace: " + namespace); log.debug("Set: " + set); @SuppressWarnings("unchecked") List<String> cmds = cl.getArgList(); if (cmds.size() == 0 && cl.hasOption("u")) { logUsage(options); return; } BatchUpdateTTL as = new BatchUpdateTTL(host, port, namespace, set); as.work(); } catch (Exception e) { log.error("Critical error", e); } }