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:com.frameworkset.commons.dbcp2.datasources.PerUserPoolDataSource.java

/**
 * Gets the user specific value for//from  w w w.jav  a 2  s  .co  m
 * {@link GenericObjectPool#getSoftMinEvictableIdleTimeMillis()} for the
 * specified user's pool or the default if no user specific value is defined.
 */
public long getPerUserSoftMinEvictableIdleTimeMillis(String key) {
    Long value = null;
    if (perUserSoftMinEvictableIdleTimeMillis != null) {
        value = perUserSoftMinEvictableIdleTimeMillis.get(key);
    }
    if (value == null) {
        return getDefaultSoftMinEvictableIdleTimeMillis();
    }
    return value.longValue();
}

From source file:com.oneops.sensor.Sensor.java

/**
 * Get the open OpsEvent stream by setting proper manifest id.
 * OpenEvents --> Filter(validate manifest Id) --> filter (instance id).
 *
 * @return Observable of OpsEvents./*from w  w  w  . jav  a2s .  co  m*/
 */
private Observable<OpsEvent> getAllOpenEvents() {
    return opsEventDao.getOpenEvents(READ_ROWCOUNT).filter(event -> {
        // Filter the events with proper manifest id.
        Long mId = tsDao.getManifestId(event.getCiId());
        if (mId == null) {
            logger.error("Orphan CI. Can not find manifestId for ciId: " + event.getCiId() + ", name:"
                    + event.getName() + ", state: " + event.getState());
            opsEventDao.removeCi(event.getCiId());
            return false;
        }

        if (mId > 0 && ((mId % this.poolSize) == this.instanceId)) {
            event.setManifestId(mId.longValue());
            return true;
        } else {
            // Dicard messages for other instance ids
            return false;
        }
    });
}

From source file:edu.harvard.iq.dvn.core.index.IndexServiceBean.java

public void updateIndexList(List<Long> studyIds) {
    long ioProblemCount = 0;
    boolean ioProblem = false;
    Indexer indexer = Indexer.getInstance();
    boolean deleteSuccess = true;
    /*//from www. jav a 2 s .c  om
    try {
    indexer.setup();
    } catch (IOException ex) {
    ex.printStackTrace();
    }
     */
    for (Iterator it = studyIds.iterator(); it.hasNext();) {
        Long elem = (Long) it.next();
        try {
            deleteSuccess = true;
            try {
                indexer.deleteDocumentCarefully(elem.longValue());
            } catch (IOException ioe) {
                deleteSuccess = false;
            }
            if (deleteSuccess) {
                try {
                    addDocument(elem.longValue());
                } catch (IOException ex) {
                    ioProblem = true;
                    ioProblemCount++;
                    Logger.getLogger(IndexServiceBean.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        } catch (EJBException e) {
            if (e.getCause() instanceof IllegalArgumentException) {
                System.out.println("Study id " + elem.longValue() + " not found");
                e.printStackTrace();
            } else {
                throw e;
            }
        }
    }
    handleIOProblems(ioProblem, ioProblemCount);

}

From source file:dk.netarkivet.externalsoftware.HeritrixTests.java

/**
 * Test that the launcher actually launches Heritrix and fetches at least 50 objects from different hosts on tv2.dk
 * (sporten.tv2.dk, nyheder.tv2.dk.....) and netarkivet.dk by parsing the hosts-report.txt This number includes the
 * dns-lookups for each host in these domains.
 *//*from   www . j a  va  2 s . c  o  m*/
@Test
public void testLaunchWithMaxObjectsPrDomain() throws IOException {
    validateOrder(TestInfo.ORDER_FILE_MAX_OBJECTS);
    File tempDir = mtf.newTmpDir();
    LuceneUtils.makeDummyIndex(tempDir);
    runHeritrix(TestInfo.ORDER_FILE_MAX_OBJECTS, TestInfo.SEEDS_FILE_MAX_OBJECTS, tempDir);

    HeritrixFiles hFiles = HeritrixFiles.getH1HeritrixFilesWithDefaultJmxFiles(TestInfo.HERITRIX_TEMP_DIR,
            new JobInfoTestImpl(0L, 0L));

    File hostReportFile = new File(TestInfo.HERITRIX_TEMP_DIR, "logs/crawl.log");

    HarvestReportGenerator hrg = new HarvestReportGenerator(hFiles);
    DomainStatsReport dsr = new DomainStatsReport(hrg.getDomainStatsMap(), hrg.getDefaultStopReason());
    HarvestReport hhr = new LegacyHarvestReport(dsr);

    Long tv2_objects = hhr.getObjectCount("tv2.dk");
    Long netarkivet_objects = hhr.getObjectCount("netarkivet.dk");
    // int netarkivetHosts = GetHostsForDomain(hostReportFile, "netarkivet.dk");
    assertTrue("Number of objects from tv2.dk should be at least 50, NOT: " + tv2_objects.longValue()
            + "\nNumbers generated from the following host-report.txt: " + FileUtils.readFile(hostReportFile)
            + "\n", tv2_objects.longValue() >= 50);
    assertTrue("Number of objects from netarkivet.dk should be at least 50, NOT: "
            + netarkivet_objects.longValue() + "\nNumbers generated from the following host-report.txt: "
            + FileUtils.readFile(hostReportFile) + "\n", netarkivet_objects >= 50);
}

From source file:org.squale.squalecommon.enterpriselayer.facade.quality.MeasureFacade.java

/**
 * Creation du Piechart d'une application
 * //ww  w.  j av a2 s .c o  m
 * @param pAuditId id de l'audit
 * @throws JrafEnterpriseException si pb Hibernate
 * @return les donnes ncessaires  la conception du PieChart via une Applet soit : Map dont la cl contient les
 *         projets et la valeur le nombre de lignes du projet
 */
public static Object[] getApplicationPieChart(Long pAuditId) throws JrafEnterpriseException {
    // Rcupration des v(g) et des ev(g)
    Collection measures;
    MeasureDAOImpl measureDAO = MeasureDAOImpl.getInstance();
    MetricDAOImpl metricDAO = MetricDAOImpl.getInstance();
    AuditDisplayConfDAOImpl auditConfDao = AuditDisplayConfDAOImpl.getInstance();
    // Session Hibernate
    ISession session = null;
    Object[] result = new Object[2];

    try {
        // rcupration d'une session
        session = PERSISTENTPROVIDER.getSession();

        ApplicationBO application = (ApplicationBO) ApplicationDAOImpl.getInstance().loadByAuditId(session,
                pAuditId);
        // On retrouve les ids de tous les projets de l'application :
        Set projects = new HashSet();
        Iterator itChildren = application.getChildren().iterator();
        // Pour chaque enfant du projet :
        while (itChildren.hasNext()) {
            // Une application ne contient que des projets
            ProjectBO projectBO = (ProjectBO) itChildren.next();
            // On ajoute le projet seulement si celui-ci a t audit
            // (cas par exemple d'une dsactivation)
            if (projectBO.containsAuditById(pAuditId.longValue())) {
                projects.add(projectBO);
            }
        }

        // rcupration du nombre de ligne de code de chaque projet
        Map volum = new HashMap();
        Map url = new HashMap();
        // volumtrie par grille (ne sert que pour l'export PDF)
        Map volumByGrid = new HashMap();
        Iterator itProjects = projects.iterator();
        int i = 0;
        while (itProjects.hasNext()) {
            int accLines = 0;
            Long nbLignes = new Long(0);
            ProjectBO project = (ProjectBO) itProjects.next();
            Long idProject = new Long(project.getId());
            // Rcupration des mesures correspondant  l'audit et
            // au projet concern  l'aide de la configuration de la volumtrie pour une application
            AuditDisplayConfBO auditConf = (AuditDisplayConfBO) auditConfDao.findConfigurationWhere(session,
                    idProject, pAuditId, DisplayConfConstants.VOLUMETRY_SUBCLASS,
                    DisplayConfConstants.VOLUMETRY_APPLICATION_TYPE);
            if (null != auditConf) {
                VolumetryConfBO volumConf = (VolumetryConfBO) auditConf.getDisplayConf();
                // On ajoute les volumtries trouves en fonction des tres
                for (Iterator it = volumConf.getTres().iterator(); it.hasNext();) {
                    IntegerMetricBO metric = metricDAO.findIntegerMetricWhere(session, idProject.longValue(),
                            pAuditId.longValue(), (String) it.next());
                    if (null != metric) {
                        accLines += ((Integer) metric.getValue()).intValue();
                    }
                }
                nbLignes = new Long(accLines);
                // On ajoute la valeur au nb de ligne pour la grille du projet
                setApplicationVolumetryByGrid(session, idProject, pAuditId, volumByGrid, nbLignes);
            } // si il n'y a pas de configuration, c'est qu'il y a un problme en base

            // Placement du nombre de lignes en regard du nom de projet si le nombre de lignes
            // et > 0
            if (0 < nbLignes.longValue()) {
                volum.put(project.getName(), nbLignes);
                url.put(project.getName(), idProject);
            }

            i++;
        }
        result = new Object[] { volum, url, volumByGrid };
    } catch (Exception e) {
        FacadeHelper.convertException(e, MeasureFacade.class.getName() + ".getMeasures");
    } finally {
        FacadeHelper.closeSession(session, MeasureFacade.class.getName() + ".getMeasures");
    }
    return result;
}

From source file:edu.harvard.iq.dvn.core.index.IndexServiceBean.java

public void createCollectionIndexTimer() {
    for (Iterator it = timerService.getTimers().iterator(); it.hasNext();) {
        Timer timer = (Timer) it.next();
        if (timer.getInfo().equals(COLLECTION_INDEX_TIMER)) {
            logger.info("Cannot create COllectionIndexTimer, timer already exists.");
            logger.info("IndexTimer next timeout is " + timer.getNextTimeout());
            return;
        }/*from w w  w .j  a  v  a 2  s.  co m*/
    }

    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.MINUTE, 5); // First run 5 minutes from now

    Date initialRun = cal.getTime();

    long intervalInMinutes = 60; // default value

    String intervalJVMOption = System.getProperty("dvn.index.collection.reindex.interval");

    if (intervalJVMOption != null) {
        Long intervalValue = null;
        try {
            intervalValue = new Long(intervalJVMOption);
        } catch (Exception ex) {
        }
        if (intervalValue != null && (intervalValue.longValue() > 0L)) {
            intervalInMinutes = intervalValue.longValue();
        }
    }

    long intervalDuration = 1000 * 60 * intervalInMinutes;
    timerService.createTimer(initialRun, intervalDuration, COLLECTION_INDEX_TIMER);
    logger.log(Level.INFO, "Collection index timer set for " + initialRun);

}

From source file:dk.netarkivet.externalsoftware.HeritrixTests.java

/**
 * Test that the Maxbytes feature is handled correctly by the the current harvester. Sets maxbytes limit to 500000
 * bytes.//ww  w  .j a  v  a  2 s  .co  m
 */
@Test
public void testMaxBytes() throws IOException, IOFailure, DocumentException {
    File MaxbytesOrderFile = new File(TestInfo.WORKING_DIR, "maxBytesOrderxml.xml");
    FileUtils.copyFile(TestInfo.DEFAULT_ORDERXML_FILE, MaxbytesOrderFile);
    FileUtils.copyFile(TestInfo.HERITRIX_SETTINGS_SCHEMA_FILE,
            new File(TestInfo.WORKING_DIR, TestInfo.HERITRIX_SETTINGS_SCHEMA_FILE.getName()));
    Document orderDocument = XmlUtils.getXmlDoc(MaxbytesOrderFile);
    // Not sure what the bytelimit should be to be consistent with what we presently expect Heritrix
    // to do
    long byteLimit = 500000;
    String xpath = H1HeritrixTemplate.GROUP_MAX_ALL_KB_XPATH;
    Node groupMaxSuccessKbNode = orderDocument.selectSingleNode(xpath);
    if (groupMaxSuccessKbNode != null) {
        // Divide by 1024 since Heritrix uses KB rather than bytes,
        // and add 1 to avoid to low limit due to rounding.
        groupMaxSuccessKbNode.setText(Long.toString((byteLimit / 1024) + 1));
    } else {
        fail("QuotaEnforcer node not found in order.xml");
    }
    OutputStream os = new FileOutputStream(MaxbytesOrderFile);
    XMLWriter writer = new XMLWriter(os);
    writer.write(orderDocument);

    validateOrder(MaxbytesOrderFile);
    File tempDir = mtf.newTmpDir();
    LuceneUtils.makeDummyIndex(tempDir);
    runHeritrix(MaxbytesOrderFile, TestInfo.SEEDS_DEFAULT, tempDir);
    // File hostReportFile = new File(TestInfo.HERITRIX_TEMP_DIR, "logs/crawl.log");
    HeritrixFiles hFiles = HeritrixFiles.getH1HeritrixFilesWithDefaultJmxFiles(TestInfo.HERITRIX_TEMP_DIR,
            new JobInfoTestImpl(0L, 0L));

    HarvestReportGenerator hrg = new HarvestReportGenerator(hFiles);
    DomainStatsReport dsr = new DomainStatsReport(hrg.getDomainStatsMap(), hrg.getDefaultStopReason());

    AbstractHarvestReport hhr = new LegacyHarvestReport(dsr);
    Long netarkivet_bytes = hhr.getByteCount("netarkivet.dk");
    long lastNetarkivetBytes = getLastFetchedBytesForDomain("netarkivet.dk");
    // System.out.println("last netarkivet bytes: " + lastNetarkivetBytes);
    // System.out.println(FileUtils.readFile(hostReportFile));
    if (!(netarkivet_bytes.longValue() - lastNetarkivetBytes < byteLimit)) {
        fail("byteLimit (" + netarkivet_bytes.longValue() + ") exceeded");
    }
}

From source file:com.cloud.tags.TaggedResourceManagerImpl.java

private Pair<Long, Long> getAccountDomain(long resourceId, ResourceObjectType resourceType) {
    Class<?> clazz = s_typeMap.get(resourceType);

    Object entity = _entityMgr.findById(clazz, resourceId);
    Long accountId = null;// w w w .jav a2 s.  c om
    Long domainId = null;

    // if the resource type is a security group rule, get the accountId and domainId from the security group itself
    if (resourceType == ResourceObjectType.SecurityGroupRule) {
        SecurityGroupRuleVO rule = (SecurityGroupRuleVO) entity;
        Object SecurityGroup = _entityMgr.findById(s_typeMap.get(ResourceObjectType.SecurityGroup),
                rule.getSecurityGroupId());

        accountId = ((SecurityGroupVO) SecurityGroup).getAccountId();
        domainId = ((SecurityGroupVO) SecurityGroup).getDomainId();
    }

    if (entity instanceof OwnedBy) {
        accountId = ((OwnedBy) entity).getAccountId();
    }

    if (entity instanceof PartOf) {
        domainId = ((PartOf) entity).getDomainId();
    }

    if (accountId == null) {
        accountId = Account.ACCOUNT_ID_SYSTEM;
    }

    if ((domainId == null) || ((accountId != null) && (domainId.longValue() == -1))) {
        domainId = _accountDao.getDomainIdForGivenAccountId(accountId);
    }
    return new Pair<Long, Long>(accountId, domainId);
}

From source file:com.globalsight.everest.webapp.pagehandler.tasks.TaskDetailHandler.java

/**
 * This is copied from CostingEngineLocal The logic is not exactly same but
 * quite similar.//www . j av  a  2 s.co m
 */
private Rate getActualRateToBeUsed(Task t, String p_acceptor) {
    Rate useRate = t.getExpenseRate();
    int selectionCriteria = t.getRateSelectionCriteria();
    User user = null;

    if (selectionCriteria == WorkflowConstants.USE_SELECTED_RATE_UNTIL_ACCEPTANCE) {
        // find out who accepted the task
        try {
            String acceptor = t.getAcceptor();
            if (acceptor != null) {
                user = ServerProxy.getUserManager().getUser(acceptor);
            } else {
                if (p_acceptor != null) {
                    user = ServerProxy.getUserManager().getUser(p_acceptor);
                }
            }
        } catch (Exception e) {
            CATEGORY.error("TaskDetailHandler::Problem getting user information ", e);
        }
        try {
            // Now find out what is the default rate for this user.
            if (user != null) {
                // find out user role
                Vector uRoles = new Vector(ServerProxy.getUserManager().getUserRoles(user));
                String activity = t.getTaskName();
                GlobalSightLocale source = t.getSourceLocale();
                GlobalSightLocale target = t.getTargetLocale();

                for (int i = 0; i < uRoles.size(); i++) {
                    Role curRole = (Role) uRoles.get(i);
                    // Get the source and target locale for each role.
                    String sourceLocale = curRole.getSourceLocale();
                    String targetLocale = curRole.getTargetLocale();
                    Activity act = curRole.getActivity();
                    UserRole cRole = (UserRole) uRoles.get(i);

                    if (act.getActivityName().equals(activity) && sourceLocale.equals(source.toString())
                            && targetLocale.equals(target.toString())) {
                        // Found the userRole we are talking about
                        if (cRole != null && cRole.getRate() != null) {
                            Long rate = new Long(cRole.getRate());
                            useRate = getRate(rate.longValue());
                        }
                    }
                }
            }
        } catch (Exception e) {
            CATEGORY.error("TaskDetailHandler::Problem getting user information ", e);
        }
    }
    return useRate;
}

From source file:be.hogent.tarsos.util.histogram.Histogram.java

/**
 * Returns the number of values = v./*from  ww  w .j  av a2  s  .c  o m*/
 * 
 * @param value
 *            the value to lookup.
 * @return the frequency of v.
 */
public final long getCount(final double value) {
    final double key = valueToKey(value);
    long result = 0;
    final Long count = freqTable.get(key);
    if (count != null) {
        result = count.longValue();
    }
    return result;
}