Example usage for java.lang Long MAX_VALUE

List of usage examples for java.lang Long MAX_VALUE

Introduction

In this page you can find the example usage for java.lang Long MAX_VALUE.

Prototype

long MAX_VALUE

To view the source code for java.lang Long MAX_VALUE.

Click Source Link

Document

A constant holding the maximum value a long can have, 263-1.

Usage

From source file:PrintfStuff.java

public static void main(String[] args) throws IOException {
    char three[] = { 't', 'h', 'r', 'e', 'e' };
    System.out.printf("%b %n %c %n %s %n %s %n %d %n" + "%d %n %g %n %g %n %s %n", !false, '3',
            new String(three), "Three", 3, Long.MAX_VALUE, Math.PI, Double.MAX_VALUE, new Object());
}

From source file:com.alibaba.simpleimage.PressureTester.java

public static void main(String[] args) throws Exception {
    int threads = 1;
    long tasks = Long.MAX_VALUE;
    String rootDir = "";

    if (args.length >= 1) {
        rootDir = args[0];// w ww  . j  a  v  a 2  s.  c om
    }

    if (args.length >= 2) {
        threads = Integer.parseInt(args[1]);
    }

    if (args.length >= 3) {
        tasks = Long.parseLong(args[2]);
    }

    if ("null".equalsIgnoreCase(rootDir)) {
        rootDir = null;
    }
    System.out.println("task begin");
    new PressureTester(threads, tasks, rootDir).run();
    System.out.println("task end");
}

From source file:MaxVariablesDemo.java

public static void main(String args[]) {

    // integers/* w w w.  j a  v  a 2s. com*/
    byte largestByte = Byte.MAX_VALUE;
    short largestShort = Short.MAX_VALUE;
    int largestInteger = Integer.MAX_VALUE;
    long largestLong = Long.MAX_VALUE;

    /* real numbers*/
    float largestFloat = Float.MAX_VALUE;
    double largestDouble = Double.MAX_VALUE;

    // other primitive types
    char aChar = 'S';
    boolean aBoolean = true;

    // display them all
    System.out.println("The largest byte value is " + largestByte);
    System.out.println("The largest short value is " + largestShort);
    System.out.println("The largest integer value is " + largestInteger);
    System.out.println("The largest long value is " + largestLong);

    System.out.println("The largest float value is " + largestFloat);
    System.out.println("The largest double value is " + largestDouble);

    if (Character.isUpperCase(aChar)) {
        System.out.println("The character " + aChar + " is upper case.");
    } else {
        System.out.println("The character " + aChar + " is lower case.");
    }
    System.out.println("The value of aBoolean is " + aBoolean);
}

From source file:com.linkedin.pinotdruidbenchmark.PinotThroughput.java

@SuppressWarnings("InfiniteLoopStatement")
public static void main(String[] args) throws Exception {
    if (args.length != 3 && args.length != 4) {
        System.err.println(// ww w . j  a v a 2  s .  c o m
                "3 or 4 arguments required: QUERY_DIR, RESOURCE_URL, NUM_CLIENTS, TEST_TIME (seconds).");
        return;
    }

    File queryDir = new File(args[0]);
    String resourceUrl = args[1];
    final int numClients = Integer.parseInt(args[2]);
    final long endTime;
    if (args.length == 3) {
        endTime = Long.MAX_VALUE;
    } else {
        endTime = System.currentTimeMillis() + Integer.parseInt(args[3]) * MILLIS_PER_SECOND;
    }

    File[] queryFiles = queryDir.listFiles();
    assert queryFiles != null;
    Arrays.sort(queryFiles);

    final int numQueries = queryFiles.length;
    final HttpPost[] httpPosts = new HttpPost[numQueries];
    for (int i = 0; i < numQueries; i++) {
        HttpPost httpPost = new HttpPost(resourceUrl);
        String query = new BufferedReader(new FileReader(queryFiles[i])).readLine();
        httpPost.setEntity(new StringEntity("{\"pql\":\"" + query + "\"}"));
        httpPosts[i] = httpPost;
    }

    final AtomicInteger counter = new AtomicInteger(0);
    final AtomicLong totalResponseTime = new AtomicLong(0L);
    final ExecutorService executorService = Executors.newFixedThreadPool(numClients);

    for (int i = 0; i < numClients; i++) {
        executorService.submit(new Runnable() {
            @Override
            public void run() {
                try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
                    while (System.currentTimeMillis() < endTime) {
                        long startTime = System.currentTimeMillis();
                        CloseableHttpResponse httpResponse = httpClient
                                .execute(httpPosts[RANDOM.nextInt(numQueries)]);
                        httpResponse.close();
                        long responseTime = System.currentTimeMillis() - startTime;
                        counter.getAndIncrement();
                        totalResponseTime.getAndAdd(responseTime);
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
    }
    executorService.shutdown();

    long startTime = System.currentTimeMillis();
    while (System.currentTimeMillis() < endTime) {
        Thread.sleep(REPORT_INTERVAL_MILLIS);
        double timePassedSeconds = ((double) (System.currentTimeMillis() - startTime)) / MILLIS_PER_SECOND;
        int count = counter.get();
        double avgResponseTime = ((double) totalResponseTime.get()) / count;
        System.out.println("Time Passed: " + timePassedSeconds + "s, Query Executed: " + count + ", QPS: "
                + count / timePassedSeconds + ", Avg Response Time: " + avgResponseTime + "ms");
    }
}

From source file:com.linkedin.pinotdruidbenchmark.DruidThroughput.java

@SuppressWarnings("InfiniteLoopStatement")
public static void main(String[] args) throws Exception {
    if (args.length != 3 && args.length != 4) {
        System.err.println(//w  w w. j a va  2 s.  c  o  m
                "3 or 4 arguments required: QUERY_DIR, RESOURCE_URL, NUM_CLIENTS, TEST_TIME (seconds).");
        return;
    }

    File queryDir = new File(args[0]);
    String resourceUrl = args[1];
    final int numClients = Integer.parseInt(args[2]);
    final long endTime;
    if (args.length == 3) {
        endTime = Long.MAX_VALUE;
    } else {
        endTime = System.currentTimeMillis() + Integer.parseInt(args[3]) * MILLIS_PER_SECOND;
    }

    File[] queryFiles = queryDir.listFiles();
    assert queryFiles != null;
    Arrays.sort(queryFiles);

    final int numQueries = queryFiles.length;
    final HttpPost[] httpPosts = new HttpPost[numQueries];
    for (int i = 0; i < numQueries; i++) {
        HttpPost httpPost = new HttpPost(resourceUrl);
        httpPost.addHeader("content-type", "application/json");
        StringBuilder stringBuilder = new StringBuilder();
        try (BufferedReader bufferedReader = new BufferedReader(new FileReader(queryFiles[i]))) {
            int length;
            while ((length = bufferedReader.read(CHAR_BUFFER)) > 0) {
                stringBuilder.append(new String(CHAR_BUFFER, 0, length));
            }
        }
        String query = stringBuilder.toString();
        httpPost.setEntity(new StringEntity(query));
        httpPosts[i] = httpPost;
    }

    final AtomicInteger counter = new AtomicInteger(0);
    final AtomicLong totalResponseTime = new AtomicLong(0L);
    final ExecutorService executorService = Executors.newFixedThreadPool(numClients);

    for (int i = 0; i < numClients; i++) {
        executorService.submit(new Runnable() {
            @Override
            public void run() {
                try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
                    while (System.currentTimeMillis() < endTime) {
                        long startTime = System.currentTimeMillis();
                        CloseableHttpResponse httpResponse = httpClient
                                .execute(httpPosts[RANDOM.nextInt(numQueries)]);
                        httpResponse.close();
                        long responseTime = System.currentTimeMillis() - startTime;
                        counter.getAndIncrement();
                        totalResponseTime.getAndAdd(responseTime);
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
    }
    executorService.shutdown();

    long startTime = System.currentTimeMillis();
    while (System.currentTimeMillis() < endTime) {
        Thread.sleep(REPORT_INTERVAL_MILLIS);
        double timePassedSeconds = ((double) (System.currentTimeMillis() - startTime)) / MILLIS_PER_SECOND;
        int count = counter.get();
        double avgResponseTime = ((double) totalResponseTime.get()) / count;
        System.out.println("Time Passed: " + timePassedSeconds + "s, Query Executed: " + count + ", QPS: "
                + count / timePassedSeconds + ", Avg Response Time: " + avgResponseTime + "ms");
    }
}

From source file:co.paralleluniverse.galaxy.Server.java

/**
 * Runs the Galaxy server./*from   www .j  av a 2  s.  c  o m*/
 * If command line arguments are given, the first {@code args[0]} is the path xml (spring) configuration file
 * and the second (if it exists) is the path to a properties file (referenced in the config-file).
 * @param args the command line arguments
 */
public static void main(String[] args) throws Exception {
    final String configFile = args.length > 0 ? args[0] : null;
    final String propertiesFile = args.length > 1 ? args[1] : null;
    start(configFile, propertiesFile);
    Thread.sleep(Long.MAX_VALUE);
}

From source file:com.coherentlogic.treasurydirect.client.applications.MainApplication.java

public static void main(String[] unused) throws InterruptedException {

    try {//from   ww w.  j  a  va 2  s .  co m

        SpringApplicationBuilder builder = new SpringApplicationBuilder(MainApplication.class);

        builder.web(false).headless(false).registerShutdownHook(true).run(unused);

    } catch (Throwable thrown) {
        log.error("ExampleApplication.main caught an exception.", thrown);
    }

    Thread.sleep(Long.MAX_VALUE);

    System.exit(-9999);
}

From source file:com.github.rinde.rinsim.examples.demo.factory.FactoryExample.java

/**
 * Starts the example./*from  www  .j a  va  2s .  c o  m*/
 * @param args One optional argument specifying the simulation end time is
 *          supported.
 */
public static void main(@Nullable String[] args) {
    final long endTime = args != null && args.length >= 1 ? Long.parseLong(args[0]) : Long.MAX_VALUE;

    final Display d = new Display();
    @Nullable
    Monitor sec = null;
    for (final Monitor m : d.getMonitors()) {
        if (d.getPrimaryMonitor() != m) {
            sec = m;
            break;
        }
    }
    run(endTime, d, sec, null);
}

From source file:com.pinterest.secor.main.LogFileVerifierMain.java

public static void main(String[] args) {
    try {/*  ww w  . ja v a  2s.co  m*/
        CommandLine commandLine = parseArgs(args);
        SecorConfig config = SecorConfig.load();
        FileUtil.configure(config);
        LogFileVerifier verifier = new LogFileVerifier(config, commandLine.getOptionValue("topic"));
        long startOffset = -2;
        long endOffset = Long.MAX_VALUE;
        if (commandLine.hasOption("start_offset")) {
            startOffset = Long.parseLong(commandLine.getOptionValue("start_offset"));
            if (commandLine.hasOption("end_offset")) {
                endOffset = Long.parseLong(commandLine.getOptionValue("end_offset"));
            }
        }
        int numMessages = -1;
        if (commandLine.hasOption("messages")) {
            numMessages = ((Number) commandLine.getParsedOptionValue("messages")).intValue();
        }
        verifier.verifyCounts(startOffset, endOffset, numMessages);
        if (commandLine.hasOption("sequence_offsets")) {
            verifier.verifySequences(startOffset, endOffset);
        }
        System.out.println("verification succeeded");
    } catch (Throwable t) {
        LOG.error("Log file verifier failed", t);
        System.exit(1);
    }
}

From source file:ch.algotrader.event.TopicEventDumper.java

public static void main(String... args) throws Exception {

    SingleConnectionFactory jmsActiveMQFactory = new SingleConnectionFactory(
            new ActiveMQConnectionFactory("tcp://localhost:61616"));
    jmsActiveMQFactory.afterPropertiesSet();
    jmsActiveMQFactory.resetConnection();

    ActiveMQTopic topic = new ActiveMQTopic(">");

    DefaultMessageListenerContainer messageListenerContainer = new DefaultMessageListenerContainer();
    messageListenerContainer.setDestination(topic);
    messageListenerContainer.setConnectionFactory(jmsActiveMQFactory);
    messageListenerContainer.setSubscriptionShared(false);
    messageListenerContainer.setCacheLevel(DefaultMessageListenerContainer.CACHE_CONSUMER);

    messageListenerContainer.setMessageListener((MessageListener) message -> {
        try {/* ww  w.  j  a  v  a  2 s .co m*/
            Destination destination = message.getJMSDestination();
            if (message instanceof TextMessage) {
                TextMessage textMessage = (TextMessage) message;
                System.out.println(destination + " -> " + textMessage.getText());
            } else if (message instanceof BytesMessage) {
                BytesMessage bytesMessage = (BytesMessage) message;
                byte[] bytes = new byte[(int) bytesMessage.getBodyLength()];
                bytesMessage.readBytes(bytes);
                System.out.println(destination + " -> " + new String(bytes, Charsets.UTF_8));
            }
        } catch (JMSException ex) {
            throw new UnrecoverableCoreException(ex);
        }
    });

    messageListenerContainer.initialize();
    messageListenerContainer.start();

    System.out.println("Dumping messages from all topics");

    Runtime.getRuntime().addShutdownHook(new Thread(messageListenerContainer::stop));

    Thread.sleep(Long.MAX_VALUE);
}