List of usage examples for java.lang Long MAX_VALUE
long MAX_VALUE
To view the source code for java.lang Long MAX_VALUE.
Click Source Link
From source file:com.foudroyantfactotum.mod.fousarchive.utility.midi.FileSupporter.java
public static void main(String[] args) throws InterruptedException, IOException { for (int i = 0; i < noOfWorkers; ++i) pool.submit(new ConMidiDetailsPuller()); final File sourceDir = new File(source); final File outputDir = new File(output); Logger.info(UserLogger.GENERAL, "source directory: " + sourceDir.getAbsolutePath()); Logger.info(UserLogger.GENERAL, "output directory: " + outputDir.getAbsolutePath()); Logger.info(UserLogger.GENERAL, "processing midi files using " + noOfWorkers + " cores"); FileUtils.deleteDirectory(outputDir); FileUtils.touch(new File(outputDir + "/master.json.gz")); for (File sfile : sourceDir.listFiles()) { recFile(sfile, files);//w w w. j a v a 2 s. c o m } for (int i = 0; i < noOfWorkers; ++i) files.put(TERMINATOR); pool.shutdown(); pool.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);//just get all the work done first. try (final OutputStream fstream = new FileOutputStream(outputDir + "/master.json.gz")) { try (final GZIPOutputStream gzstream = new GZIPOutputStream(fstream)) { final OutputStreamWriter osw = new OutputStreamWriter(gzstream); osw.write(JSON.toJson(processedMidiFiles)); osw.flush(); } } catch (IOException e) { Logger.info(UserLogger.GENERAL, e.toString()); } Logger.info(UserLogger.GENERAL, "Processed " + processedMidiFiles.size() + " midi files out of " + fileCount + " files. " + (fileCount - processedMidiFiles.size()) + " removed"); }
From source file:com.github.rinde.rinsim.examples.core.taxi.TaxiExample.java
/** * Starts the {@link TaxiExample}.//from w w w . j a v a 2s. c om * @param args The first option may optionally indicate the end time of the * simulation. */ public static void main(@Nullable String[] args) { final long endTime = args != null && args.length >= 1 ? Long.parseLong(args[0]) : Long.MAX_VALUE; final String graphFile = args != null && args.length >= 2 ? args[1] : MAP_FILE; run(false, endTime, graphFile, null /* new Display() */, null, null); }
From source file:kymr.github.io.training.scheduler.SchedulerEx1.java
public static void main(String[] args) { Publisher<Integer> pub = sub -> { sub.onSubscribe(new Subscription() { @Override//from w w w . j a v a2s . c o m public void request(long n) { log.debug("request()"); sub.onNext(1); sub.onNext(2); sub.onNext(3); sub.onNext(4); sub.onNext(5); sub.onComplete(); } @Override public void cancel() { } }); }; Publisher<Integer> subOnPub = sub -> { ExecutorService es = Executors.newSingleThreadExecutor(new CustomizableThreadFactory() { @Override public String getThreadNamePrefix() { return "subOn-"; } }); pub.subscribe(new Subscriber<Integer>() { @Override public void onSubscribe(Subscription s) { es.execute(() -> sub.onSubscribe(s)); } @Override public void onNext(Integer integer) { sub.onNext(integer); } @Override public void onError(Throwable t) { sub.onError(t); es.shutdown(); } @Override public void onComplete() { sub.onComplete(); es.shutdown(); } }); }; /*Publisher<Integer> subOnPub = sub -> { ExecutorService es = Executors.newSingleThreadExecutor(new CustomizableThreadFactory() { @Override public String getThreadNamePrefix() { return "subOn-"; } }); es.execute(() -> pub.subscribe(sub)); }; */ Publisher<Integer> pubOnPub = sub -> { subOnPub.subscribe(new Subscriber<Integer>() { ExecutorService es = Executors.newSingleThreadExecutor(new CustomizableThreadFactory() { @Override public String getThreadNamePrefix() { return "pubOn-"; } }); @Override public void onSubscribe(Subscription s) { sub.onSubscribe(s); } @Override public void onNext(Integer integer) { es.execute(() -> sub.onNext(integer)); } @Override public void onError(Throwable t) { es.execute(() -> sub.onError(t)); es.shutdown(); } @Override public void onComplete() { es.execute(() -> sub.onComplete()); es.shutdown(); } }); }; pubOnPub.subscribe(new Subscriber<Integer>() { @Override public void onSubscribe(Subscription s) { log.debug("onSubscribe"); s.request(Long.MAX_VALUE); } @Override public void onNext(Integer integer) { log.debug("onNext : {}", integer); } @Override public void onError(Throwable t) { log.debug("onError : {}", t); } @Override public void onComplete() { log.debug("onComplete"); } }); log.debug("exit"); }
From source file:edu.mit.fss.tutorial.part4.ElementGUI.java
/** * The main method.//from w ww . j av a 2 s . c o m * * @param args the arguments * @throws RTIexception the RTI exception */ public static void main(String[] args) throws RTIexception { // Configure the logger and set it to display info messages. BasicConfigurator.configure(); logger.setLevel(Level.INFO); // Use an input dialog to request the element's name. String name = null; while (name == null || name.isEmpty()) { name = JOptionPane.showInputDialog("Enter element name:"); } // Create a MobileElement object instance. The "final" keyword allows // it to be referenced in the GUI thread below. final MobileElement element = new MobileElement(name, new Vector3D(0, 0, 0)); // Create an OnlineTutorialFederate object instance. The "final" // keyword allows it to be referenced in the GUI thread below. final OnlineTutorialFederate fed = new OnlineTutorialFederate(element); // Create the graphical user interface using the Event Dispatch Thread. try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { // Create a new ControlPanel object instance. ControlPanel controlPanel = new ControlPanel(); // Bind it to the element above. controlPanel.setBoundElement(element); // Add the control panel as an object change listener. fed.addObjectChangeListener(controlPanel); // Create a new frame to display the panel. Add the panel // as the content, pack it, and make it visible. JFrame frame = new JFrame(); frame.setContentPane(controlPanel); frame.pack(); frame.setVisible(true); // Add a new WindowAdapter object instance to exit the // federate when the window is closing. frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { fed.exit(); } }); } }); } catch (InvocationTargetException | InterruptedException e) { logger.error(e); } // Execute the federate. fed.execute(0, Long.MAX_VALUE, 1000); }
From source file:fr.tpt.s3.mcdag.scheduling.Main.java
public static void main(String[] args) throws IOException, InterruptedException { /* Command line options */ Options options = new Options(); Option input = new Option("i", "input", true, "MC-DAG XML Models"); input.setRequired(true);//from www . jav a 2s. co m input.setArgs(Option.UNLIMITED_VALUES); // Sets maximum number of threads to be launched options.addOption(input); Option outSched = new Option("os", "out-scheduler", false, "Write the scheduling tables into a file."); outSched.setRequired(false); options.addOption(outSched); Option outPrism = new Option("op", "out-prism", false, "Write PRISM model into a file."); outPrism.setRequired(false); options.addOption(outPrism); Option jobs = new Option("j", "jobs", true, "Number of threads to be launched."); jobs.setRequired(false); options.addOption(jobs); Option debugOpt = new Option("d", "debug", false, "Enabling debug."); debugOpt.setRequired(false); options.addOption(debugOpt); Option preemptOpt = new Option("p", "preempt", false, "Count for preemptions."); preemptOpt.setRequired(false); options.addOption(preemptOpt); CommandLineParser parser = new DefaultParser(); HelpFormatter formatter = new HelpFormatter(); CommandLine cmd; try { cmd = parser.parse(options, args); } catch (ParseException e) { System.err.println(e.getMessage()); formatter.printHelp("MC-DAG framework", options); System.exit(1); return; } String inputFilePath[] = cmd.getOptionValues("input"); boolean bOutSched = cmd.hasOption("out-scheduler"); boolean bOutPrism = cmd.hasOption("out-prism"); boolean debug = cmd.hasOption("debug"); boolean preempt = cmd.hasOption("preempt"); boolean levels = cmd.hasOption("n-levels"); int nbFiles = inputFilePath.length; int nbJobs = 1; if (cmd.hasOption("jobs")) nbJobs = Integer.parseInt(cmd.getOptionValue("jobs")); if (debug) System.out.println("[DEBUG] Launching " + inputFilePath.length + " thread(s)."); int i_files = 0; ExecutorService executor = Executors.newFixedThreadPool(nbJobs); /* Launch threads to solve allocation */ while (i_files != nbFiles) { SchedulingThread ft = new SchedulingThread(inputFilePath[i_files], bOutSched, bOutPrism, debug, preempt); ft.setLevels(levels); executor.execute(ft); i_files++; } executor.shutdown(); executor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); System.out.println("[FRAMEWORK Main] DONE"); }
From source file:eu.interedition.collatex.http.Server.java
public static void main(String... args) { try {/* w ww . j a va 2 s .c om*/ final CommandLine commandLine = new GnuParser().parse(OPTIONS, args); if (commandLine.hasOption("h")) { new HelpFormatter().printHelp("collatex-server [<options> ...]\n", OPTIONS); return; } final Collator collator = new Collator(Integer.parseInt(commandLine.getOptionValue("mpc", "2")), Integer.parseInt(commandLine.getOptionValue("mcs", "0")), commandLine.getOptionValue("dot", null)); final String staticPath = System.getProperty("collatex.static.path", ""); final HttpHandler httpHandler = staticPath.isEmpty() ? new CLStaticHttpHandler(Server.class.getClassLoader(), "/static/") { @Override protected void onMissingResource(Request request, Response response) throws Exception { collator.service(request, response); } } : new StaticHttpHandler(staticPath.replaceAll("/+$", "") + "/") { @Override protected void onMissingResource(Request request, Response response) throws Exception { collator.service(request, response); } }; final NetworkListener httpListener = new NetworkListener("http", "0.0.0.0", Integer.parseInt(commandLine.getOptionValue("p", "7369"))); final CompressionConfig compressionConfig = httpListener.getCompressionConfig(); compressionConfig.setCompressionMode(CompressionConfig.CompressionMode.ON); compressionConfig.setCompressionMinSize(860); // http://webmasters.stackexchange.com/questions/31750/what-is-recommended-minimum-object-size-for-gzip-performance-benefits compressionConfig.setCompressableMimeTypes("application/javascript", "application/json", "application/xml", "text/css", "text/html", "text/javascript", "text/plain", "text/xml"); final HttpServer httpServer = new HttpServer(); httpServer.addListener(httpListener); httpServer.getServerConfiguration().addHttpHandler(httpHandler, commandLine.getOptionValue("cp", "").replaceAll("/+$", "") + "/*"); Runtime.getRuntime().addShutdownHook(new Thread(() -> { if (LOG.isLoggable(Level.INFO)) { LOG.info("Stopping HTTP server"); } httpServer.shutdown(); })); httpServer.start(); Thread.sleep(Long.MAX_VALUE); } catch (Throwable t) { LOG.log(Level.SEVERE, "Error while parsing command line", t); System.exit(1); } }
From source file:com.omertron.slackbot.SlackBot.java
public static void main(String[] args) throws Exception { LOG.info("Starting {} v{} ...", Constants.BOT_NAME, Constants.BOT_VERSION); // Load the properties PropertiesUtil.setPropertiesStreamName(DEFAULT_PROPERTIES_FILE); LOG.info("Starting session..."); SlackSession session;//from ww w .ja va2s .c o m String proxyURL = PropertiesUtil.getProperty(Constants.PROXY_HOST); if (StringUtils.isNotBlank(proxyURL)) { int proxyPort = Integer.parseInt(PropertiesUtil.getProperty(Constants.PROXY_PORT, "80")); session = SlackSessionFactory.getSlackSessionBuilder(Constants.BOT_TOKEN) .withProxy(Proxy.Type.HTTP, proxyURL, proxyPort).build(); } else { session = SlackSessionFactory .createWebSocketSlackSession(PropertiesUtil.getProperty(Constants.BOT_TOKEN)); } session.connect(); // Populate the BOT admins populateBotAdmins(session); // Notify BOT admins notifyStartup(session); // Add the listeners to the session addListeners(session); LOG.info("Session connected: {}", session.isConnected()); LOG.info("\tConnected to {} ({})", session.getTeam().getName(), session.getTeam().getId()); LOG.info("\tFound {} channels and {} users", session.getChannels().size(), session.getUsers().size()); outputBotAdminsMessage(); LOG.info("Starting the Task Executor"); executor = new BotTaskExecutor(session); LOG.info("Checking for users welcomed list"); BotWelcome.readFile(); LOG.info("Checking for stats file"); BotStatistics.readFile(); LOG.info("Stats read:\n{}", BotStatistics.generateStatistics(false, true)); Thread.sleep(Long.MAX_VALUE); }
From source file:io.covert.binary.analysis.ExecutorThread.java
public static void main(String[] args) throws Exception { HashMap<String, Object> substitutionMap = new HashMap<String, Object>(); substitutionMap.put("file", "/home/jtrost/workspace/hadoop-binary-analysis/pom.xml"); ExecutorThread e = new ExecutorThread("sha1sum", new String[] { "${file}" }, substitutionMap, new int[] { 0, 1 }, Long.MAX_VALUE, new File("/tmp")); e.start();// w ww . j a v a 2 s. c o m e.join(); System.out.println("exitCode = " + e.getExitCode()); System.out.println("exitCode = " + e.getExecuteException()); if (e.isProcessStarted() && !e.isProcessDestroyed()) { System.out.println("stdout: " + new String(e.getStdOut().toByteArray())); System.out.println("stderr: " + new String(e.getStdErr().toByteArray())); } else if (e.isProcessStarted()) { System.out.println("Process was launched, but process destroyed"); } else { System.out.println("Process not launched"); } }
From source file:com.tamingtext.tagging.LuceneTagExtractor.java
public static void main(String[] args) throws IOException { DefaultOptionBuilder obuilder = new DefaultOptionBuilder(); ArgumentBuilder abuilder = new ArgumentBuilder(); GroupBuilder gbuilder = new GroupBuilder(); Option inputOpt = obuilder.withLongName("dir").withRequired(true) .withArgument(abuilder.withName("dir").withMinimum(1).withMaximum(1).create()) .withDescription("The Lucene directory").withShortName("d").create(); Option outputOpt = obuilder.withLongName("output").withRequired(false) .withArgument(abuilder.withName("output").withMinimum(1).withMaximum(1).create()) .withDescription("The output directory").withShortName("o").create(); Option maxOpt = obuilder.withLongName("max").withRequired(false) .withArgument(abuilder.withName("max").withMinimum(1).withMaximum(1).create()) .withDescription(/*from ww w . j a va2 s .c om*/ "The maximum number of vectors to output. If not specified, then it will loop over all docs") .withShortName("m").create(); Option fieldOpt = obuilder.withLongName("field").withRequired(true) .withArgument(abuilder.withName("field").withMinimum(1).withMaximum(1).create()) .withDescription("The field in the index").withShortName("f").create(); Option helpOpt = obuilder.withLongName("help").withDescription("Print out help").withShortName("h") .create(); Group group = gbuilder.withName("Options").withOption(inputOpt).withOption(outputOpt).withOption(maxOpt) .withOption(fieldOpt).create(); try { Parser parser = new Parser(); parser.setGroup(group); CommandLine cmdLine = parser.parse(args); if (cmdLine.hasOption(helpOpt)) { CommandLineUtil.printHelp(group); return; } File file = new File(cmdLine.getValue(inputOpt).toString()); if (!file.isDirectory()) { throw new IllegalArgumentException(file + " does not exist or is not a directory"); } long maxDocs = Long.MAX_VALUE; if (cmdLine.hasOption(maxOpt)) { maxDocs = Long.parseLong(cmdLine.getValue(maxOpt).toString()); } if (maxDocs < 0) { throw new IllegalArgumentException("maxDocs must be >= 0"); } String field = cmdLine.getValue(fieldOpt).toString(); PrintWriter out = null; if (cmdLine.hasOption(outputOpt)) { out = new PrintWriter(new FileWriter(cmdLine.getValue(outputOpt).toString())); } else { out = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8")); } File output = new File("/home/drew/taming-text/delicious/training"); output.mkdirs(); emitTextForTags(file, output); IOUtils.close(Collections.singleton(out)); } catch (OptionException e) { log.error("Exception", e); CommandLineUtil.printHelp(group); } }
From source file:com.tamingtext.tagging.LuceneCategoryExtractor.java
public static void main(String[] args) throws IOException { DefaultOptionBuilder obuilder = new DefaultOptionBuilder(); ArgumentBuilder abuilder = new ArgumentBuilder(); GroupBuilder gbuilder = new GroupBuilder(); Option inputOpt = obuilder.withLongName("dir").withRequired(true) .withArgument(abuilder.withName("dir").withMinimum(1).withMaximum(1).create()) .withDescription("The Lucene directory").withShortName("d").create(); Option outputOpt = obuilder.withLongName("output").withRequired(false) .withArgument(abuilder.withName("output").withMinimum(1).withMaximum(1).create()) .withDescription("The output directory").withShortName("o").create(); Option maxOpt = obuilder.withLongName("max").withRequired(false) .withArgument(abuilder.withName("max").withMinimum(1).withMaximum(1).create()) .withDescription(/*from www .j av a 2 s.c o m*/ "The maximum number of documents to analyze. If not specified, then it will loop over all docs") .withShortName("m").create(); Option fieldOpt = obuilder.withLongName("field").withRequired(true) .withArgument(abuilder.withName("field").withMinimum(1).withMaximum(1).create()) .withDescription("The field in the index").withShortName("f").create(); Option helpOpt = obuilder.withLongName("help").withDescription("Print out help").withShortName("h") .create(); Group group = gbuilder.withName("Options").withOption(inputOpt).withOption(outputOpt).withOption(maxOpt) .withOption(fieldOpt).create(); try { Parser parser = new Parser(); parser.setGroup(group); CommandLine cmdLine = parser.parse(args); if (cmdLine.hasOption(helpOpt)) { CommandLineUtil.printHelp(group); return; } File inputDir = new File(cmdLine.getValue(inputOpt).toString()); if (!inputDir.isDirectory()) { throw new IllegalArgumentException(inputDir + " does not exist or is not a directory"); } long maxDocs = Long.MAX_VALUE; if (cmdLine.hasOption(maxOpt)) { maxDocs = Long.parseLong(cmdLine.getValue(maxOpt).toString()); } if (maxDocs < 0) { throw new IllegalArgumentException("maxDocs must be >= 0"); } String field = cmdLine.getValue(fieldOpt).toString(); PrintWriter out = null; if (cmdLine.hasOption(outputOpt)) { out = new PrintWriter(new FileWriter(cmdLine.getValue(outputOpt).toString())); } else { out = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8")); } dumpDocumentFields(inputDir, field, maxDocs, out); IOUtils.close(Collections.singleton(out)); } catch (OptionException e) { log.error("Exception", e); CommandLineUtil.printHelp(group); } }