Example usage for java.lang Integer MAX_VALUE

List of usage examples for java.lang Integer MAX_VALUE

Introduction

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

Prototype

int MAX_VALUE

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

Click Source Link

Document

A constant holding the maximum value an int can have, 231-1.

Usage

From source file:com.alibaba.dubbo.examples.merge.MergeConsumer2.java

public static void main(String[] args) throws Exception {
    String config = MergeConsumer2.class.getPackage().getName().replace('.', '/') + "/merge-consumer2.xml";
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config);
    context.start();//www  .j a  v a 2  s  . c  o  m
    MergeService mergeService = (MergeService) context.getBean("mergeService");
    for (int i = 0; i < Integer.MAX_VALUE; i++) {
        try {
            List<String> result = mergeService.mergeResult();
            System.out.println("(" + i + ") " + result);
            Thread.sleep(1000);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:com.alibaba.cobar.manager.test.ConnectionTest.java

/**
 * @param args/*from   w w w  .java  2s.c om*/
 */
public static void main(String[] args) {
    try {
        BasicDataSource ds = new BasicDataSource();
        ds.setUsername("test");
        ds.setPassword("");
        ds.setUrl("jdbc:mysql://10.20.153.178:9066/");
        ds.setDriverClassName("com.mysql.jdbc.Driver");
        ds.setMaxActive(-1);
        ds.setMinIdle(0);
        ds.setTimeBetweenEvictionRunsMillis(600000);
        ds.setNumTestsPerEvictionRun(Integer.MAX_VALUE);
        ds.setMinEvictableIdleTimeMillis(GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
        Connection conn = ds.getConnection();

        Statement stm = conn.createStatement();
        stm.execute("show @@version");

        ResultSet rst = stm.getResultSet();
        rst.next();
        String version = rst.getString("VERSION");

        System.out.println(version);

    } catch (Exception exception) {
        System.out.println("10.20.153.178:9066   " + exception.getMessage() + exception);
    }
}

From source file:com.alacoder.lion.rpc.springsupport.DemoRpcClient.java

@SuppressWarnings({ "resource", "unused" })
public static void main(String[] args) throws InterruptedException {

    ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            new String[] { "classpath*:lion_demo_server.xml" });
    System.out.println("server start...");

    ApplicationContext ctx = new ClassPathXmlApplicationContext(
            new String[] { "classpath:lion_demo_client.xml" });

    DemoService service = (DemoService) ctx.getBean("lionDemoReferer");
    for (int i = 0; i < Integer.MAX_VALUE; i++) {
        System.out.println(service.hello("lion " + i));
        Thread.sleep(1000);/*  ww  w  .ja v a 2s. com*/
    }
    System.out.println("lion demo is finish.");
    System.exit(0);
}

From source file:MaxVariablesDemo.java

public static void main(String args[]) {

    //integers/*from w  w w .ja v a2  s  . c o m*/
    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 uppercase.");
    } else {
        System.out.println("The character " + aChar + " is lowercase.");
    }
    System.out.println("The value of aBoolean is " + aBoolean + ".");
}

From source file:MaxVariablesDemo.java

public static void main(String args[]) {

    // integers/*from  w  w w  .j  a  v  a  2  s  .  c o  m*/
    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:Search.java

public static void main(String[] args) throws IOException {

    Path searchFile = Paths.get("Demo.jpg");
    Search walk = new Search(searchFile);
    EnumSet<FileVisitOption> opts = EnumSet.of(FileVisitOption.FOLLOW_LINKS);

    Iterable<Path> dirs = FileSystems.getDefault().getRootDirectories();
    for (Path root : dirs) {
        if (!walk.found) {
            Files.walkFileTree(root, opts, Integer.MAX_VALUE, walk);
        }//from   w  ww .  j a v  a 2 s  . c  o  m
    }

    if (!walk.found) {
        System.out.println("The file " + searchFile + " was not found!");
    }
}

From source file:edu.msu.cme.rdp.probematch.cli.PrimerMatch.java

public static void main(String[] args) throws Exception {

    PrintStream out = new PrintStream(System.out);
    int maxDist = Integer.MAX_VALUE;

    try {//from  w w w  .  ja  v a  2s. c o  m
        CommandLine line = new PosixParser().parse(options, args);
        if (line.hasOption("outFile")) {
            out = new PrintStream(new File(line.getOptionValue("outFile")));
        }
        if (line.hasOption("maxDist")) {
            maxDist = Integer.valueOf(line.getOptionValue("maxDist"));
        }
        args = line.getArgs();

        if (args.length != 2) {
            throw new Exception("Unexpected number of command line arguments");
        }
    } catch (Exception e) {
        System.err.println("Error: " + e.getMessage());
        new HelpFormatter().printHelp("PrimerMatch <primer_list | primer_file> <seq_file>", options);
        return;
    }

    List<PatternBitMask64> primers = new ArrayList();
    if (new File(args[0]).exists()) {
        File primerFile = new File(args[0]);
        SequenceFormat seqformat = SeqUtils.guessFileFormat(primerFile);

        if (seqformat.equals(SequenceFormat.FASTA)) {
            SequenceReader reader = new SequenceReader(primerFile);
            Sequence seq;

            while ((seq = reader.readNextSequence()) != null) {
                primers.add(new PatternBitMask64(seq.getSeqString(), true, seq.getSeqName()));
            }
            reader.close();
        } else {
            BufferedReader reader = new BufferedReader(new FileReader(args[0]));
            String line;

            while ((line = reader.readLine()) != null) {
                line = line.trim();
                if (!line.equals("")) {
                    primers.add(new PatternBitMask64(line, true));
                }
            }
            reader.close();
        }
    } else {
        for (String primer : args[0].split(",")) {
            primers.add(new PatternBitMask64(primer, true));
        }
    }

    SeqReader seqReader = new SequenceReader(new File(args[1]));
    Sequence seq;
    String primerRegion;

    out.println("#seqname\tdesc\tprimer_index\tprimer_name\tposition\tmismatches\tseq_primer_region");
    while ((seq = seqReader.readNextSequence()) != null) {
        for (int index = 0; index < primers.size(); index++) {
            PatternBitMask64 primer = primers.get(index);
            BitVector64Result results = BitVector64.process(seq.getSeqString().toCharArray(), primer, maxDist);

            for (BitVector64Match result : results.getResults()) {
                primerRegion = seq.getSeqString().substring(
                        Math.max(0, result.getPosition() - primer.getPatternLength()), result.getPosition());

                if (result.getPosition() < primer.getPatternLength()) {
                    for (int pad = result.getPosition(); pad < primer.getPatternLength(); pad++) {
                        primerRegion = "x" + primerRegion;
                    }
                }

                out.println(seq.getSeqName() + "\t" + seq.getDesc() + "\t" + (index + 1) + "\t"
                        + primer.getPrimerName() + "\t" + result.getPosition() + "\t" + result.getScore() + "\t"
                        + primerRegion);
            }
        }
    }
    out.close();
    seqReader.close();
}

From source file:edu.cmu.lti.oaqa.knn4qa.apps.QueryGenNMSLIB.java

public static void main(String[] args) {
    Options options = new Options();

    options.addOption(CommonParams.QUERY_FILE_PARAM, null, true, CommonParams.QUERY_FILE_DESC);
    options.addOption(CommonParams.MEMINDEX_PARAM, null, true, CommonParams.MEMINDEX_DESC);
    options.addOption(CommonParams.KNN_QUERIES_PARAM, null, true, CommonParams.KNN_QUERIES_DESC);
    options.addOption(CommonParams.NMSLIB_FIELDS_PARAM, null, true, CommonParams.NMSLIB_FIELDS_DESC);
    options.addOption(CommonParams.MAX_NUM_QUERY_PARAM, null, true, CommonParams.MAX_NUM_QUERY_DESC);
    options.addOption(CommonParams.SEL_PROB_PARAM, null, true, CommonParams.SEL_PROB_DESC);

    CommandLineParser parser = new org.apache.commons.cli.GnuParser();

    BufferedWriter knnQueries = null;

    int maxNumQuery = Integer.MAX_VALUE;

    Float selProb = null;//from   w  ww . j a v a  2s  .c om

    try {
        CommandLine cmd = parser.parse(options, args);
        String queryFile = null;

        if (cmd.hasOption(CommonParams.QUERY_FILE_PARAM)) {
            queryFile = cmd.getOptionValue(CommonParams.QUERY_FILE_PARAM);
        } else {
            Usage("Specify 'query file'", options);
        }

        String knnQueriesFile = cmd.getOptionValue(CommonParams.KNN_QUERIES_PARAM);

        if (null == knnQueriesFile)
            Usage("Specify '" + CommonParams.KNN_QUERIES_DESC + "'", options);

        String tmpn = cmd.getOptionValue(CommonParams.MAX_NUM_QUERY_PARAM);
        if (tmpn != null) {
            try {
                maxNumQuery = Integer.parseInt(tmpn);
            } catch (NumberFormatException e) {
                Usage("Maximum number of queries isn't integer: '" + tmpn + "'", options);
            }
        }

        String tmps = cmd.getOptionValue(CommonParams.NMSLIB_FIELDS_PARAM);
        if (null == tmps)
            Usage("Specify '" + CommonParams.NMSLIB_FIELDS_DESC + "'", options);
        String nmslibFieldList[] = tmps.split(",");

        knnQueries = new BufferedWriter(new FileWriter(knnQueriesFile));
        knnQueries.write("isQueryFile=1");
        knnQueries.newLine();
        knnQueries.newLine();

        String memIndexPref = cmd.getOptionValue(CommonParams.MEMINDEX_PARAM);

        if (null == memIndexPref) {
            Usage("Specify '" + CommonParams.MEMINDEX_DESC + "'", options);
        }

        String tmpf = cmd.getOptionValue(CommonParams.SEL_PROB_PARAM);

        if (tmpf != null) {
            try {
                selProb = Float.parseFloat(tmpf);
            } catch (NumberFormatException e) {
                Usage("A selection probability isn't a number in the range (0,1)'" + tmpf + "'", options);
            }
            if (selProb < Float.MIN_NORMAL || selProb + Float.MIN_NORMAL >= 1)
                Usage("A selection probability isn't a number in the range (0,1)'" + tmpf + "'", options);
        }

        BufferedReader inpText = new BufferedReader(
                new InputStreamReader(CompressUtils.createInputStream(queryFile)));

        String docText = XmlHelper.readNextXMLIndexEntry(inpText);

        NmslibQueryGenerator queryGen = new NmslibQueryGenerator(nmslibFieldList, memIndexPref);

        Random rnd = new Random();

        for (int docNum = 1; docNum <= maxNumQuery
                && docText != null; ++docNum, docText = XmlHelper.readNextXMLIndexEntry(inpText)) {
            if (selProb != null) {
                if (rnd.nextFloat() > selProb)
                    continue;
            }

            Map<String, String> docFields = null;

            try {
                docFields = XmlHelper.parseXMLIndexEntry(docText);

                String queryObjStr = queryGen.getStrObjForKNNService(docFields);

                knnQueries.append(queryObjStr);
                knnQueries.newLine();
            } catch (SAXException e) {
                System.err.println("Parsing error, offending DOC:" + NL + docText + " doc # " + docNum);
                throw new Exception("Parsing error.");
            }
        }

        knnQueries.close();
    } catch (ParseException e) {
        Usage("Cannot parse arguments", options);
        if (null != knnQueries)
            try {
                knnQueries.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }
    } catch (Exception e) {
        System.err.println("Terminating due to an exception: " + e);
        try {
            if (knnQueries != null)
                knnQueries.close();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        System.exit(1);
    }

    System.out.println("Terminated successfully!");
}

From source file:backup.store.ExternalExtendedBlockSort.java

public static void main(String[] args) throws Exception {
    Configuration conf = new Configuration();
    Path dir = new Path("file:///home/apm/Development/git-projects/hdfs-backup/hdfs-backup-core/tmp");
    dir.getFileSystem(conf).delete(dir, true);
    long start = System.nanoTime();
    try (ExternalExtendedBlockSort<LongWritable> sort = new ExternalExtendedBlockSort<>(conf, dir,
            LongWritable.class)) {
        Random random = new Random();
        for (int bp = 0; bp < 1; bp++) {
            String bpid = UUID.randomUUID().toString();
            for (int i = 0; i < 10000000; i++) {
                // for (int i = 0; i < 10; i++) {
                long genstamp = random.nextInt(20000);
                long blockId = random.nextLong();
                ExtendedBlock extendedBlock = new ExtendedBlock(bpid, blockId,
                        random.nextInt(Integer.MAX_VALUE), genstamp);
                sort.add(extendedBlock, new LongWritable(blockId));
            }/*from  w w  w  . j  av  a  2  s  . com*/
        }
        System.out.println("finished");
        sort.finished();
        System.out.println("interate");
        for (String blockPoolId : sort.getBlockPoolIds()) {
            ExtendedBlockEnum<LongWritable> blockEnum = sort.getBlockEnum(blockPoolId);
            ExtendedBlock block;
            long l = 0;
            while ((block = blockEnum.next()) != null) {
                // System.out.println(block);
                long blockId = block.getBlockId();
                l += blockId;
                LongWritable currentValue = blockEnum.currentValue();
                if (currentValue.get() != blockId) {
                    System.err.println("Error " + blockId);
                }
            }
            System.out.println(l);
        }
    }
    long end = System.nanoTime();
    System.out.println("Time [" + (end - start) / 1000000.0 + " ms]");
}

From source file:edu.cmu.lti.oaqa.knn4qa.apps.FilterVocabulary.java

public static void main(String[] args) {
    String optKeys[] = { IN_VOC_FILE_PARAM, OUT_VOC_FILE_PARAM, CommonParams.MEM_FWD_INDEX_PARAM,
            CommonParams.MAX_WORD_QTY_PARAM };
    String optDescs[] = { IN_VOC_FILE_DESC, OUT_VOC_FILE_DESC, CommonParams.MEM_FWD_INDEX_DESC,
            CommonParams.MAX_WORD_QTY_DESC };
    boolean hasArg[] = { true, true, true, true };

    ParamHelper mParamHelper = null;//from  w ww.j  a  v a2s  . c om

    try {

        mParamHelper = new ParamHelper(args, optKeys, optDescs, hasArg);

        CommandLine cmd = mParamHelper.getCommandLine();

        String outputFile = cmd.getOptionValue(OUT_VOC_FILE_PARAM);
        if (null == outputFile) {
            UsageSpecify(OUT_VOC_FILE_DESC, mParamHelper.getOptions());
        }

        String inputFile = cmd.getOptionValue(IN_VOC_FILE_PARAM);
        if (null == inputFile) {
            UsageSpecify(IN_VOC_FILE_DESC, mParamHelper.getOptions());
        }

        int maxWordQty = Integer.MAX_VALUE;

        String tmpi = cmd.getOptionValue(CommonParams.MAX_WORD_QTY_PARAM);

        if (null != tmpi) {
            maxWordQty = Integer.parseInt(tmpi);
        }

        String memFwdIndxName = cmd.getOptionValue(CommonParams.MEM_FWD_INDEX_PARAM);
        if (null == memFwdIndxName) {
            UsageSpecify(CommonParams.MEM_FWD_INDEX_DESC, mParamHelper.getOptions());
        }

        VocabularyFilterAndRecoder filter = new FrequentIndexWordFilterAndRecoder(memFwdIndxName, maxWordQty);

        BufferedReader finp = new BufferedReader(
                new InputStreamReader(CompressUtils.createInputStream(inputFile)));
        BufferedWriter fout = new BufferedWriter(
                new OutputStreamWriter(CompressUtils.createOutputStream(outputFile)));
        try {

            String line;

            int wordQty = 0;
            long addedQty = 0;
            long totalQty = 0;

            for (totalQty = 0; (line = finp.readLine()) != null;) {
                ++totalQty;
                // Skip empty lines
                line = line.trim();
                if (line.isEmpty())
                    continue;

                GizaVocRec rec = new GizaVocRec(line);

                if (filter.checkWord(rec.mWord)) {
                    rec.save(fout);
                    addedQty++;
                }

                if (totalQty % REPORT_INTERVAL_QTY == 0)
                    System.out.println(String.format(
                            "Processed %d lines (%d source word entries) from '%s', added %d lines", totalQty,
                            wordQty, inputFile, addedQty));
            }

        } finally {
            finp.close();
            fout.close();
        }
    } catch (ParseException e) {
        Usage("Cannot parse arguments", mParamHelper != null ? mParamHelper.getOptions() : null);
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
        System.err.println("Terminating due to an exception: " + e);
        System.exit(1);
    }
}