Example usage for java.lang Long longValue

List of usage examples for java.lang Long longValue

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public long longValue() 

Source Link

Document

Returns the value of this Long as a long value.

Usage

From source file:tachyon.master.EditLogOperationTest.java

@Test
public void createDependencyTest() throws IOException {
    EditLogOperation editLogOperation = OBJECT_MAPPER.readValue(CREATE_DEPENDENCY_TYPE.getBytes(),
            EditLogOperation.class);

    // get all parameters for "CREATE_DEPENDENCY"
    List<Integer> parents = editLogOperation.get("parents", new TypeReference<List<Integer>>() {
    });/*from  w ww.  j av  a2s.  c om*/
    Assert.assertEquals(3, parents.size());

    List<Integer> children = editLogOperation.get("children", new TypeReference<List<Integer>>() {
    });
    Assert.assertEquals(4, children.size());

    String commandPrefix = editLogOperation.getString("commandPrefix");
    Assert.assertEquals("fake command", commandPrefix);

    List<ByteBuffer> data = editLogOperation.getByteBufferList("data");
    Assert.assertEquals(1, data.size());
    String decodedBase64 = new String(data.get(0).array(), "UTF-8");
    Assert.assertEquals(new String(Base64.decodeBase64("AAAAAAAAAAAAAA==")), decodedBase64);

    String comment = editLogOperation.getString("comment");
    Assert.assertEquals("Comment Test", comment);

    String framework = editLogOperation.getString("framework");
    Assert.assertEquals("Tachyon Examples", framework);

    String frameworkVersion = editLogOperation.getString("frameworkVersion");
    Assert.assertEquals("0.3", frameworkVersion);

    DependencyType dependencyType = editLogOperation.get("dependencyType", DependencyType.class);
    Assert.assertEquals(DependencyType.Narrow, dependencyType);

    Integer depId = editLogOperation.getInt("dependencyId");
    Assert.assertEquals(1, depId.intValue());

    Long creationTimeMs = editLogOperation.getLong("creationTimeMs");
    Assert.assertEquals(1409349750338L, creationTimeMs.longValue());
}

From source file:com.hpcloud.mon.app.command.CreateMetricCommand.java

@JsonProperty
public void setTimestamp(Long timestamp) {
    this.timestamp = timestamp == null || timestamp.longValue() == 0L ? System.currentTimeMillis() / 1000L
            : timestamp.longValue();/*from  www .ja  va 2  s .  c  om*/
}

From source file:com.anite.antelope.zebra.om.TurbineAntelopeProcessInstanceTest.java

public void testGetProcessInstanceId() {
    Long processInstanceID = this.processInstance.getProcessInstanceId();
    assertTrue(processInstanceID.longValue() > 0);
}

From source file:com.microsoft.tfs.core.httpclient.util.IdleConnectionHandler.java

/**
 * Closes connections that have been idle for at least the given amount of
 * time.//from   w w w  . j  a v a2  s.c  om
 *
 * @param idleTime
 *        the minimum idle time, in milliseconds, for connections to be
 *        closed
 */
public void closeIdleConnections(final long idleTime) {

    // the latest time for which connections will be closed
    final long idleTimeout = System.currentTimeMillis() - idleTime;

    if (log.isDebugEnabled()) {
        log.debug("Checking for connections, idleTimeout: " + idleTimeout);
    }

    final Iterator connectionIter = connectionToAdded.keySet().iterator();

    while (connectionIter.hasNext()) {
        final HttpConnection conn = (HttpConnection) connectionIter.next();
        final Long connectionTime = (Long) connectionToAdded.get(conn);
        if (connectionTime.longValue() <= idleTimeout) {
            if (log.isDebugEnabled()) {
                log.debug("Closing connection " + conn.getID() + ", connection time: " + connectionTime);
            }
            connectionIter.remove();
            conn.close();
        }
    }
}

From source file:de.hybris.platform.acceleratorservices.config.impl.AbstractConfigLookup.java

@Override
public long getLong(final String key, final long defaultValue) {
    final String property = getProperty(key);
    if (property != null && !property.isEmpty()) {
        try {/* w w  w .j a v  a 2 s  . c  o m*/
            final Long longValue = Long.valueOf(property);
            if (longValue != null) {
                return longValue.longValue();
            }
        } catch (final NumberFormatException ex) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Failed to parse long property value for key [" + key + "] value was [" + property
                        + "]", ex);
            }
        }
    }
    return defaultValue;
}

From source file:org.flite.cach3.test.l2.CombinedLevelsTest.java

@Test
public void test() throws Exception {
    final TestSvc test = (TestSvc) context.getBean("testSvc");
    final String key = RandomStringUtils.randomAlphanumeric(12);

    final long start = System.currentTimeMillis();

    final Long initial = test.getCombinedData(key);
    final long initialValue = initial.longValue();
    assertEquals(4, initial.toString().length());

    // For the first little bit, make sure that both levels of caching are returning the same info.
    while (System.currentTimeMillis() - start < 1500) {
        //            System.out.println("1 - 2nd: " + test.getCombinedData(key).longValue());
        //            System.out.println("1 - 1st: " + test.getL1Data(key).longValue());
        assertEquals(initialValue, test.getCombinedData(key).longValue());
        assertEquals(initialValue, test.getL1Data(key).longValue());

        Thread.sleep(200);//  w w  w  .  j  ava 2  s. co  m
    }

    // Now force an update to the Level 1 cache, but don't have it get in the L2 cache
    final Long update = test.updateL1Data(key);
    final long updateValue = update.longValue();
    assertEquals(6, update.toString().length());

    // Make sure the values continue to diverge while the L2 cache window is still open (< 4.75sec)
    while (System.currentTimeMillis() - start < 4750) {
        //            System.out.println("2 - 2nd: " + test.getCombinedData(key).longValue());
        //            System.out.println("2 - 1st: " + test.getL1Data(key).longValue());
        assertEquals(initialValue, test.getCombinedData(key).longValue());
        assertEquals(updateValue, test.getL1Data(key).longValue());

        Thread.sleep(500);
    }

    // Wait until the L2 cache timeout of 5sec is good and expired, now try again.
    Thread.sleep(1000);

    // We expect the L2 cache to fall through to the V1 cache, which still has a good value.
    final long lastValue = test.getCombinedData(key).longValue();
    assertEquals(updateValue, lastValue);

    //        System.out.println("3 - 2nd: " + test.getCombinedData(key).longValue());
    //        System.out.println("3 - 1st: " + test.getL1Data(key).longValue());

}

From source file:com.benfante.minimark.ajax.QuestionFillingABo.java

@RemoteMethod
public void updateTimeLeft() {
    final WebContext wctx = WebContextFactory.get();
    AssessmentFilling filling = retrieveFilling(wctx);
    Long duration = filling.getAssessment().getDuration();
    if (duration != null && duration.longValue() != 0) {
        long timeLeft = duration;
        long timePassed = 0;
        final Date startDate = filling.getStartDate();
        if (startDate != null) {
            timePassed = ((new Date().getTime()) - startDate.getTime()) / 60000;
            timeLeft = Math.max(0, duration - timePassed);
            final long exposedTimeLeft = timeLeft;
            ScriptSession session = wctx.getScriptSession();
            Browser.withSession(session.getId(), new Runnable() {

                public void run() {
                    Util.setValue("timeLeft", exposedTimeLeft + "m");
                }//  w  w  w .  java2s  .co  m
            });

        }
    }
}

From source file:com.taobao.ad.jpa.test.LogsTest.java

@Test
public void testGetCountByTypeAndTime() {
    Long v = logsBO.getCountByTypeAndTime(901L, new Date(), new Date());
    Assert.assertNotNull(v);// w w w.  j a  v  a  2s  .com
    Assert.assertEquals(0L, v.longValue());
}

From source file:net.cloudkit.enterprises.infrastructure.commons.ExecuteTimeInterceptor.java

@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
        ModelAndView modelAndView) {//w  w w.ja  v  a 2  s  . c om
    Long startTime = (Long) request.getAttribute(EXECUTE_TIME_ATTRIBUTE_NAME);
    Object localObject;
    if (startTime == null) {
        localObject = request.getAttribute(START_TIME);
        Long endTime = Long.valueOf(System.currentTimeMillis());
        startTime = Long.valueOf(endTime.longValue() - ((Long) localObject).longValue());
        request.setAttribute(START_TIME, localObject);
    }
    if (modelAndView != null) {
        localObject = modelAndView.getViewName();
        if (!StringUtils.startsWith((String) localObject, redirect)) {
            modelAndView.addObject(EXECUTE_TIME_ATTRIBUTE_NAME, startTime);
        }
    }
    if (logger.isDebugEnabled()) {
        logger.debug("[" + handler + "] executeTime: " + startTime + "ms");
    }
}

From source file:gridool.deployment.PeerClassLoader.java

@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
    final Class<?> onetimeClass = findLoadedClass(name);
    if (onetimeClass != null) {
        return onetimeClass;
    }//from   w  ww .  j  a  va  2 s. com
    final Long prevTimestamp = parentLdr.getTimestamp(name);
    if (prevTimestamp != null && prevTimestamp.longValue() < timestamp) {//newer version of class is found
        if (LOG.isInfoEnabled()) {
            LOG.info("Reloading a class '" + name + "' of timestamp '" + prevTimestamp
                    + "' with one of timestamp '" + timestamp);
        }
        return findClass(name);
    }
    Class<?> c;
    try {
        c = parentLdr.loadClass(name);
    } catch (ClassNotFoundException e) {
        // If still not found, then invoke findClass in order
        // to find the class.
        c = findClass(name);
    }
    return c;
}