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:com.joyent.manta.client.crypto.AesCtrCipherDetails.java

@Override
public long plaintextSize(final long ciphertextSize) {
    Validate.inclusiveBetween(0L, Long.MAX_VALUE, ciphertextSize);
    return ciphertextSize - getAuthenticationTagOrHmacLengthInBytes();
}

From source file:cpcc.core.services.UniqueLongIdGenerator.java

/**
 * {@inheritDoc}/*from  w w  w .  j av a2s.c o m*/
 */
@Override
public Serializable generate(SessionImplementor session, Object obj) throws HibernateException {
    final Serializable id = session.getEntityPersister(entityName, obj).getIdentifier(obj, session);
    return id != null ? id : RandomUtils.nextLong(0, Long.MAX_VALUE);
}

From source file:au.id.wolfe.fxassetman.server.dao.AssetDaoTest.java

@Test(expected = NoResultException.class)
public void testFindByIdNoResultExceptionExpected() {
    assetDao.findById(Long.MAX_VALUE);
}

From source file:co.cask.cdap.data2.increment.hbase94.IncrementSummingScanner.java

IncrementSummingScanner(HRegion region, int batchSize, InternalScanner baseScanner) {
    this(region, batchSize, baseScanner, Long.MAX_VALUE);
}

From source file:com.ict.dtube.tools.command.message.QueryMsgByKeySubCommand.java

void queryByKey(final DefaultMQAdminExt admin, final String topic, final String key)
        throws MQClientException, InterruptedException {
    admin.start();//from  ww w.j ava 2s  .c  o m

    QueryResult queryResult = admin.queryMessage(topic, key, 32, 0, Long.MAX_VALUE);
    System.out.printf("%-50s %-4s  %s\n", //
            "#Message ID", //
            "#QID", //
            "#Offset");
    for (MessageExt msg : queryResult.getMessageList()) {
        System.out.printf("%-50s %-4d %d\n", msg.getMsgId(), msg.getQueueId(), msg.getQueueOffset());
    }
}

From source file:com.iciql.test.IciqlSuite.java

/**
 * Main entry point for the test suite. Executing this method will run the
 * test suite on all registered databases.
 * //from  w  w w.j av a2s.c  om
 * @param args
 * @throws Exception
 */
public static void main(String... args) throws Exception {
    Params params = new Params();
    JCommander jc = new JCommander(params);
    try {
        jc.parse(args);
    } catch (ParameterException t) {
        usage(jc, t);
    }

    // Replace System.out with a file
    if (!StringUtils.isNullOrEmpty(params.dbPerformanceFile)) {
        out = new PrintStream(params.dbPerformanceFile);
        System.setErr(out);
    }

    deleteRecursively(new File("testdbs"));

    // Start the HSQL and H2 servers in-process
    org.hsqldb.Server hsql = startHSQL();
    org.h2.tools.Server h2 = startH2();

    // Statement logging
    final FileWriter statementWriter;
    if (StringUtils.isNullOrEmpty(params.sqlStatementsFile)) {
        statementWriter = null;
    } else {
        statementWriter = new FileWriter(params.sqlStatementsFile);
    }
    IciqlListener statementListener = new IciqlListener() {
        @Override
        public void logIciql(StatementType type, String statement) {
            if (statementWriter == null) {
                return;
            }
            try {
                statementWriter.append(statement);
                statementWriter.append('\n');
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    };
    IciqlLogger.registerListener(statementListener);

    SuiteClasses suiteClasses = IciqlSuite.class.getAnnotation(SuiteClasses.class);
    long quickestDatabase = Long.MAX_VALUE;
    String dividerMajor = buildDivider('*', 79);
    String dividerMinor = buildDivider('-', 79);

    // Header
    out.println(dividerMajor);
    out.println(MessageFormat.format("{0} {1} ({2}) testing {3} database configurations", Constants.NAME,
            Constants.VERSION, Constants.VERSION_DATE, TEST_DBS.length));
    out.println(dividerMajor);
    out.println();

    showProperty("java.vendor");
    showProperty("java.runtime.version");
    showProperty("java.vm.name");
    showProperty("os.name");
    showProperty("os.version");
    showProperty("os.arch");
    showProperty("available processors", "" + Runtime.getRuntime().availableProcessors());
    showProperty("available memory", MessageFormat.format("{0,number,0.0} GB",
            ((double) Runtime.getRuntime().maxMemory()) / (1024 * 1024)));
    out.println();

    // Test a database
    long lastCount = 0;
    for (TestDb testDb : TEST_DBS) {
        out.println(dividerMinor);
        out.println("Testing " + testDb.describeDatabase());
        out.println("        " + testDb.url);
        out.println(dividerMinor);

        // inject a database section delimiter in the statement log
        if (statementWriter != null) {
            statementWriter.append("\n\n");
            statementWriter.append("# ").append(dividerMinor).append('\n');
            statementWriter.append("# ").append("Testing " + testDb.describeDatabase()).append('\n');
            statementWriter.append("# ").append(dividerMinor).append('\n');
            statementWriter.append("\n\n");
        }

        if (testDb.getVersion().equals("OFFLINE")) {
            // Database not available
            out.println("Skipping.  Could not find " + testDb.url);
            out.println();
        } else {
            // Setup system properties
            System.setProperty("iciql.url", testDb.url);
            System.setProperty("iciql.user", testDb.username);
            System.setProperty("iciql.password", testDb.password);

            // Test database
            Result result = JUnitCore.runClasses(suiteClasses.value());

            // Report results
            testDb.runtime = result.getRunTime();
            if (testDb.runtime < quickestDatabase) {
                quickestDatabase = testDb.runtime;
            }
            testDb.statements = IciqlLogger.getTotalCount() - lastCount;
            // reset total count for next database
            lastCount = IciqlLogger.getTotalCount();

            out.println(MessageFormat.format(
                    "{0} tests ({1} failures, {2} ignores)  {3} statements in {4,number,0.000} secs",
                    result.getRunCount(), result.getFailureCount(), result.getIgnoreCount(), testDb.statements,
                    result.getRunTime() / 1000f));

            if (result.getFailureCount() == 0) {
                out.println();
                out.println("  100% successful test suite run.");
                out.println();
            } else {
                for (Failure failure : result.getFailures()) {
                    out.println(MessageFormat.format("\n  + {0}\n    {1}", failure.getTestHeader(),
                            failure.getMessage()));
                }
                out.println();
            }
        }
    }

    // Display runtime results sorted by performance leader
    out.println();
    out.println(dividerMajor);
    out.println(MessageFormat.format("{0} {1} ({2}) test suite performance results", Constants.NAME,
            Constants.VERSION, Constants.VERSION_DATE));
    out.println(dividerMajor);
    List<TestDb> dbs = Arrays.asList(TEST_DBS);
    Collections.sort(dbs);

    out.println(MessageFormat.format("{0} {1} {2} {3} {4}", StringUtils.pad("Name", 11, " ", true),
            StringUtils.pad("Type", 5, " ", true), StringUtils.pad("Version", 23, " ", true),
            StringUtils.pad("Stats/Sec", 10, " ", true), "Runtime"));
    out.println(dividerMinor);
    for (TestDb testDb : dbs) {
        DecimalFormat df = new DecimalFormat("0.0");
        out.println(MessageFormat.format("{0} {1} {2}   {3} {4} {5}s  ({6,number,0.0}x)",
                StringUtils.pad(testDb.name, 11, " ", true), testDb.isEmbedded ? "E" : "T",
                testDb.isMemory ? "M" : "F", StringUtils.pad(testDb.getVersion(), 21, " ", true),
                StringUtils.pad("" + testDb.getStatementRate(), 10, " ", false),
                StringUtils.pad(df.format(testDb.getRuntime()), 8, " ", false),
                ((double) testDb.runtime) / quickestDatabase));
    }
    out.println(dividerMinor);
    out.println("  E = embedded connection");
    out.println("  T = tcp/ip connection");
    out.println("  M = memory database");
    out.println("  F = file/persistent database");

    // cleanup
    for (PoolableConnectionFactory factory : connectionFactories.values()) {
        factory.getPool().close();
    }
    IciqlLogger.unregisterListener(statementListener);
    out.close();
    System.setErr(ERR);
    if (statementWriter != null) {
        statementWriter.close();
    }
    hsql.stop();
    h2.stop();
    System.exit(0);
}

From source file:info.archinnov.achilles.test.integration.tests.SliceQueryDeleteIT.java

@Test
public void should_delete_with_partition_keys() throws Exception {
    long pk1 = RandomUtils.nextLong(0, Long.MAX_VALUE);
    long pk2 = RandomUtils.nextLong(0, Long.MAX_VALUE);

    insertClusteredValues(pk1, 1, "name1", 1);
    insertClusteredValues(pk2, 1, "name21", 1);
    insertClusteredValues(pk2, 1, "name22", 1);

    manager.sliceQuery(ClusteredEntity.class).forDelete().withPartitionComponents(pk1).delete();

    List<ClusteredEntity> entities = manager.sliceQuery(ClusteredEntity.class).forSelect()
            .withPartitionComponentsIN(pk1, pk2).get(100);

    assertThat(entities).hasSize(2);/* w ww . j a  v  a2 s  .c  o  m*/

    Collections.sort(entities, new ClusteredEntity.ClusteredEntityComparator());

    assertThat(entities.get(0).getId().getCount()).isEqualTo(1);
    assertThat(entities.get(0).getId().getName()).isEqualTo("name21");
    assertThat(entities.get(0).getValue()).isEqualTo("value11");

    assertThat(entities.get(1).getId().getCount()).isEqualTo(1);
    assertThat(entities.get(1).getId().getName()).isEqualTo("name22");
    assertThat(entities.get(1).getValue()).isEqualTo("value11");
}

From source file:com.twitter.hraven.datasource.HdfsStatsService.java

/**
 * returns the inverted timestamp for a given timestamp
 * @param now/*  w ww  . j  a  va2s . c  om*/
 * @return
 */
public static long getEncodedRunId(long now) {
    // get top of the hour
    long lastHour = now - (now % 3600);
    // return inverted timestamp
    return (Long.MAX_VALUE - lastHour);
}

From source file:com.parse.ParseQueryStateTest.java

@Test
public void testDefaults() {
    ParseQuery.State.Builder<ParseObject> builder = new ParseQuery.State.Builder<>("TestObject");
    ParseQuery.State<ParseObject> state = builder.build();

    assertEquals("TestObject", state.className());
    assertTrue(state.constraints().isEmpty());
    assertTrue(state.includes().isEmpty());
    assertNull(state.selectedKeys());//from  w  w w .  j a va  2  s .c  om
    assertEquals(-1, state.limit());
    assertEquals(0, state.skip());
    assertTrue(state.order().isEmpty());
    assertTrue(state.extraOptions().isEmpty());

    assertFalse(state.isTracingEnabled());

    assertEquals(ParseQuery.CachePolicy.IGNORE_CACHE, state.cachePolicy());
    assertEquals(Long.MAX_VALUE, state.maxCacheAge());

    assertFalse(state.isFromLocalDatastore());
    assertNull(state.pinName());
    assertFalse(state.ignoreACLs());
}

From source file:com.twinsoft.convertigo.beans.statements.CookiesAddStatement.java

protected void addCookie(HttpState httpState, String cook) {
    String name = "";
    String domain = "";
    String path = "";
    String value = "";
    boolean secure = false;
    Date expires = new Date(Long.MAX_VALUE);

    String[] fields = cook.split(";");
    for (int i = 0; i < fields.length; i++) {
        String[] half = fields[i].trim().split("=");
        if (half.length == 2) {
            if (fields[i].startsWith("$")) {
                if (half[0].equals("$Domain"))
                    domain = half[1];/*w  ww  . ja v a 2  s.co m*/
                else if (half[0].equals("$Path"))
                    path = half[1];
                else if (half[0].equals("$Secure"))
                    secure = Boolean.getBoolean(half[1]);
                else if (half[0].equals("$Date"))
                    try {
                        expires = DateFormat.getDateTimeInstance().parse(half[1]);
                    } catch (ParseException e) {
                    }
            } else {
                name = half[0];
                value = half[1];
            }
        }
    }

    Cookie cookie = null;
    try {
        cookie = new Cookie(domain, name, value, path, expires, secure);
        if (cookie != null)
            httpState.addCookie(cookie);
    } catch (Exception e) {
        Engine.logBeans.debug("(CookiesAdd) failed to parse those cookies : " + cook);
    }
}