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:io.github.albertopires.mjc.JConsoleM.java

public long getCMSUsageThresholdCount(ServerConfiguration serverConfiguration) throws Exception {
    ObjectName mbeanName = null;//from w w w.j a  va 2 s  .  co  m
    if (serverConfiguration.getJdkVersion().equals(JdkVersion.JDK6)) {
        mbeanName = new ObjectName("java.lang:type=MemoryPool,name=CMS Old Gen");
    } else if (serverConfiguration.getJdkVersion().equals(JdkVersion.JDK8)) {
        mbeanName = new ObjectName("java.lang:type=MemoryPool,name=G1 Old Gen");
    }
    Long ut;
    ut = (Long) mbsc.getAttribute(mbeanName, "UsageThresholdCount");
    return ut.longValue();
}

From source file:com.amazonaws.util.TimingInfo.java

@Deprecated
public final long getStartEpochTimeMilli() {
    Long v = getStartEpochTimeMilliIfKnown();
    return v == null ? UNKNOWN : v.longValue();
}

From source file:at.tugraz.ist.akm.webservice.requestprocessor.interceptor.HttpClientBackLog.java

protected boolean isExpired(int clientHash) {
    Long clientExpirationTimestamp = mClientBacklog.get(clientHash);
    if (null == clientExpirationTimestamp) {
        return true;
    }//from  www.  j  av a2  s .  c o  m
    return ((clientExpirationTimestamp.longValue()) < (System.currentTimeMillis()));
}

From source file:ws.argo.responder.ProbeHandlerThread.java

private boolean isProbeHandled(String probeID) {

    boolean isProbeHandled = false;
    long now = System.currentTimeMillis();

    Long lastTime = handledProbes.get(probeID);

    if (lastTime != null) {
        long delta = now - lastTime.longValue();
        if (delta < probeCacheTimeout) {
            isProbeHandled = true; // yup, I have handled this before. If past
                                   // timeout, then it's like I never saw it before
        }/* w  w w.ja  va2 s .  co m*/
    }

    return isProbeHandled;
}

From source file:cherry.example.web.basic.ex20.BasicEx20ControllerImpl.java

@Override
public ModelAndView execute(BasicEx20Form form, BindingResult binding, Authentication auth, Locale locale,
        SitePreference sitePref, NativeWebRequest request, RedirectAttributes redirAttr) {

    if (hasErrors(form, binding)) {
        return withViewname(viewnameOfStart).build();
    }//  www.j  a va 2  s  .c om

    if (!oneTimeTokenValidator.isValid(request.getNativeRequest(HttpServletRequest.class))) {
        LogicalErrorUtil.rejectOnOneTimeTokenError(binding);
        return withViewname(viewnameOfStart).build();
    }

    Long id = service.create(form);
    checkState(id != null, "failed to create: form=%s", form);

    redirAttr.addFlashAttribute(FLASH_CREATED, Boolean.TRUE);

    return redirect(redirectOnExecute(id.longValue())).build();
}

From source file:com.redhat.rhn.domain.kickstart.KickstartFactory.java

/**
 * Lookup a KickstartData based on a label and orgId
 * @param label to lookup/*from   w  ww  .  j av  a2 s .c om*/
 * @param orgId who owns KickstartData
 * @return KickstartData if found, null if not
 */
public static KickstartData lookupKickstartDataByLabelAndOrgId(String label, Long orgId) {
    if (StringUtils.isBlank(label)) {
        throw new IllegalArgumentException("kickstartLabel cannot be null");
    }
    return (KickstartData) HibernateFactory.getSession().getNamedQuery("KickstartData.findByLabelAndOrg")
            .setString("label", label).setLong("org_id", orgId.longValue()).uniqueResult();
}

From source file:com.ewcms.web.pubsub.MessageSender.java

@Override
protected String constructOutput() {

    StringBuilder builder = new StringBuilder();

    builder.append(" <script type=\"text/javascript\">\n");

    Long count = messageFac.findUnReadMessageCountByUserName(userName);
    if (isFirst || unReadCount.longValue() != count.longValue()) {
        unReadCount = count;//from w w  w . j a  v  a2  s . c om
        builder.append("      parent._home.getUnReadMessage(" + count.longValue() + ",true);\n");
    } else {
        builder.append("      parent._home.getUnReadMessage(0,false);\n");
    }

    List<Memoranda> popMessages = notesFac.getMemorandaFireTime(userName, clientTime);
    if (isFirst || popMessages.size() != popCount) {
        popCount = popMessages.size();
        builder.append("      parent._home.getPopMessage('{\"pops\":").append(JSONUtil.toJSON(popMessages))
                .append("}', true);\n");
    } else {
        builder.append("      parent._home.getPopMessage('', false);\n");
    }

    List<MsgSend> noticeMessages = messageFac.findMsgSendByNotice(10);
    if (isFirst || noticeMessages.size() != noticeCount) {
        noticeCount = noticeMessages.size();
        builder.append("      parent._home.getNoticeMessage('{\"notices\":")
                .append(JSONUtil.toJSON(noticeMessages)).append("}', true);\n");
    } else {
        builder.append("      parent._home.getNoticeMessage('', false);\n");
    }

    List<MsgSend> subMessages = messageFac.findMsgSendBySubscription(10);
    if (isFirst || subMessages.size() != subCount) {
        subCount = subMessages.size();
        builder.append("      parent._home.getSubscription('{\"subs\":").append(JSONUtil.toJSON(subMessages))
                .append("}', true);\n");
    } else {
        builder.append("      parent._home.getSubscription('', false);\n");
    }

    Map<Channel, Long> map = documentFac.findBeApprovalArticleMain(userName);
    builder.append("      parent._home.getBeApproval('{\"beapprovals\":[");
    StringBuilder temp = new StringBuilder();
    boolean isRead = false;

    Set<Channel> channels = map.keySet();
    if (channels.size() > 0) {
        int channelCount = channels.size();
        int tempCount = beApprovals.size();
        if (channelCount != tempCount) {
            isRead = true;
        }
        int idx = 0;
        for (Channel channel : channels) {
            if (!isRead && (beApprovals.get(channel).longValue() != map.get(channel).longValue())) {
                isRead = true;
            }
            temp.append("{");
            temp.append("\"channelId\":").append(channel.getId());
            temp.append(",\"channelName\":\"").append(channel.getName()).append("\"");
            temp.append(",\"articleCount\":").append(map.get(channel));
            temp.append("}");
            if (channelCount - 1 > idx) {
                temp.append(",");
            }
            beApprovals.put(channel, map.get(channel));
        }
    } else {
        beApprovals.clear();
    }
    if (isFirst)
        isRead = true;
    if (!isRead)
        temp.setLength(0);
    builder.append(temp.toString() + "]}', " + isRead + ");\n");

    builder.append(" </script>");

    if (isFirst)
        isFirst = false;

    return builder.toString();

}

From source file:com.redhat.rhn.frontend.action.systems.sdc.SystemOverviewAction.java

/**
 * @return true if the server was unlocked, false otherwise
 *///from   w w  w .j  ava  2  s.  com
protected boolean processLock(User user, Server s, RequestContext rctx) {
    Long lockValue = rctx.getParamAsLong("lock");
    LocalizationService ls = LocalizationService.getInstance();

    if (lockValue != null) {

        if (lockValue.longValue() == 1) {
            if (s.getLock() == null) {
                SystemManager.lockServer(user, s, ls.getMessage("sdc.details.overview.lock.reason"));

                createSuccessMessage(rctx.getRequest(), "sdc.details.overview.locked.alert", s.getName());
            }
        } else if (lockValue.longValue() == 0) {
            if (s.getLock() != null) {

                SystemManager.unlockServer(user, s);
                createSuccessMessage(rctx.getRequest(), "sdc.details.overview.unlocked.alert", s.getName());

                return true;
            }
        }
    }

    return false;
}

From source file:com.eurelis.opencms.admin.systeminformation.CmsCPUThreadsClassesOverviewDialog.java

public static double getCPUUsage(HttpSession session) {

    OperatingSystemMXBean operatingSystemMXBean = (OperatingSystemMXBean) ManagementFactory
            .getOperatingSystemMXBean();
    RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
    int availableProcessors = operatingSystemMXBean.getAvailableProcessors();
    Long prevUpTime = (Long) session.getAttribute(PARAM_TIMESTAMP);
    Long prevProcessCpuTime = (Long) session.getAttribute(PARAM_PROCESS_CPU_TIME);
    double cpuUsage;
    operatingSystemMXBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
    long upTime = runtimeMXBean.getUptime();
    long processCpuTime = operatingSystemMXBean.getProcessCpuTime();
    if (prevProcessCpuTime != null || prevUpTime != null) {
        long elapsedCpu = processCpuTime - prevProcessCpuTime.longValue();
        long elapsedTime = upTime - prevUpTime.longValue();

        cpuUsage = Math.min(99F, elapsedCpu / (elapsedTime * 10000F * availableProcessors));
    } else {/*  w w  w  . ja  v a2  s  . com*/
        cpuUsage = 0;
    }
    session.setAttribute(PARAM_PROCESS_CPU_TIME, processCpuTime);
    session.setAttribute(PARAM_TIMESTAMP, upTime);
    return cpuUsage;

}

From source file:com.redhat.rhn.domain.kickstart.KickstartFactory.java

/**
 * Lookup a KickstartData based on a case insensitive label and orgId
 * This is needed due to the cobbler converts the kickstart profiles to lowecase
 * @param label to lookup//ww  w  . j  ava2 s .c o m
 * @param orgId who owns KickstartData
 * @return KickstartData if found, null if not
 */
public static KickstartData lookupKickstartDataByCILabelAndOrgId(String label, Long orgId) {
    if (StringUtils.isBlank(label)) {
        throw new IllegalArgumentException("kickstartLabel cannot be null");
    }
    return (KickstartData) HibernateFactory.getSession().getNamedQuery("KickstartData.findByCILabelAndOrg")
            .setString("label", label).setLong("org_id", orgId.longValue()).uniqueResult();
}