List of usage examples for java.lang Integer longValue
public long longValue()
From source file:org.apache.ignite.yardstick.cache.load.IgniteCacheRandomOperationBenchmark.java
/** * @param map Parameters map.// w ww .j a v a2s .c o m */ private void updateStat(Map<Object, Object> map) { for (Operation op : Operation.values()) for (String cacheName : ignite().cacheNames()) { String opCacheKey = op + "_" + cacheName; Integer val = (Integer) map.get(opCacheKey); if (val != null) { operationStatistics.get(opCacheKey).addAndGet(val.longValue()); map.put(opCacheKey, 0); } } }
From source file:com.redhat.rhn.frontend.xmlrpc.org.OrgHandler.java
/** * Set organization wide crash file size limit. * * @param loggedInUser The current user/* www . j av a2 s . c o m*/ * @param orgId Organization ID to set the limit for. * @param limit The limit to set. * @return 1 on success. * * @xmlrpc.doc Set the organization wide crash file size limit. The limit value * must be non-negative, zero means no limit. * * @xmlrpc.param #param("string", "sessionKey") * @xmlrpc.param #param("int", "orgId") * @xmlrpc.param #param_desc("int", "limit", "The limit to set (non-negative value).") * @xmlrpc.returntype #return_int_success() */ public int setCrashFileSizeLimit(User loggedInUser, Integer orgId, Integer limit) { ensureUserRole(loggedInUser, RoleFactory.SAT_ADMIN); Org org = verifyOrgExists(orgId); if (limit < 0) { throw new InvalidParameterException("Limit value must be non-negative."); } org.getOrgConfig().setCrashFileSizelimit(new Long(limit.longValue())); return 1; }
From source file:org.sakaiproject.evaluation.logic.EvalEmailsLogicImpl.java
/** * INTERNAL METHOD<br/>/*ww w.j a va2 s.com*/ * @param waitInterval */ protected void takeShortBreak(Integer waitInterval) { if (waitInterval.longValue() > 0L) { if (LOG.isDebugEnabled()) { LOG.debug("Starting wait interval during email processing (in seconds): " + waitInterval); } try { Thread.sleep(waitInterval.longValue() * 1000L); } catch (InterruptedException e) { LOG.warn("InterruptedException while waiting during email processing: " + e); } } }
From source file:org.opendaylight.genius.itm.impl.ItmUtils.java
public static Interface buildHwTunnelInterface(String tunnelIfName, String desc, boolean enabled, String topoId, String nodeId, Class<? extends TunnelTypeBase> tunType, IpAddress srcIp, IpAddress destIp, IpAddress gwIp, Boolean monitorEnabled, Class<? extends TunnelMonitoringTypeBase> monitorProtocol, Integer monitorInterval) { InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(tunnelIfName)) .setName(tunnelIfName).setDescription(desc).setEnabled(enabled).setType(Tunnel.class); List<NodeIdentifier> nodeIds = new ArrayList<>(); NodeIdentifier hwNode = new NodeIdentifierBuilder().setKey(new NodeIdentifierKey(topoId)) .setTopologyId(topoId).setNodeId(nodeId).build(); nodeIds.add(hwNode);/*w w w.j a va 2 s. c om*/ ParentRefs parent = new ParentRefsBuilder().setNodeIdentifier(nodeIds).build(); builder.addAugmentation(ParentRefs.class, parent); Long monitoringInterval = (long) ITMConstants.DEFAULT_MONITOR_INTERVAL; Boolean monitoringEnabled = true; Class<? extends TunnelMonitoringTypeBase> monitoringProtocol = ITMConstants.DEFAULT_MONITOR_PROTOCOL; if (monitoringInterval != null) { monitoringInterval = monitorInterval.longValue(); } if (monitorEnabled != null) { monitoringEnabled = monitorEnabled; } if (monitorProtocol != null) { monitoringProtocol = monitorProtocol; } IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(destIp).setTunnelGateway(gwIp) .setTunnelSource(srcIp).setMonitorEnabled(monitoringEnabled).setMonitorProtocol(monitorProtocol) .setMonitorInterval(100L).setTunnelInterfaceType(tunType).setInternal(false).build(); builder.addAugmentation(IfTunnel.class, tunnel); LOG.trace("iftunnel {} built from hwvtep {} ", tunnel, nodeId); return builder.build(); }
From source file:org.opendaylight.genius.itm.impl.ItmUtils.java
public static Interface buildTunnelInterface(BigInteger dpn, String ifName, String desc, boolean enabled, Class<? extends TunnelTypeBase> tunType, IpAddress localIp, IpAddress remoteIp, IpAddress gatewayIp, Integer vlanId, boolean internal, Boolean monitorEnabled, Class<? extends TunnelMonitoringTypeBase> monitorProtocol, Integer monitorInterval, boolean useOfTunnel, String parentIfaceName) { InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(ifName)).setName(ifName) .setDescription(desc).setEnabled(enabled).setType(Tunnel.class); ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(dpn) .setParentInterface(parentIfaceName).build(); builder.addAugmentation(ParentRefs.class, parentRefs); Long monitoringInterval = null; if (vlanId > 0) { IfL2vlan l2vlan = new IfL2vlanBuilder().setVlanId(new VlanId(vlanId)).build(); builder.addAugmentation(IfL2vlan.class, l2vlan); }/*from w w w.j a v a 2 s.c o m*/ LOG.debug("buildTunnelInterface: monitorProtocol = {} and monitorInterval = {}", monitorProtocol.getName(), monitorInterval); if (monitorInterval != null) { monitoringInterval = monitorInterval.longValue(); } IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(remoteIp).setTunnelGateway(gatewayIp) .setTunnelSource(localIp).setTunnelInterfaceType(tunType).setInternal(internal) .setMonitorEnabled(monitorEnabled).setMonitorProtocol(monitorProtocol) .setMonitorInterval(monitoringInterval).setTunnelRemoteIpFlow(useOfTunnel).build(); builder.addAugmentation(IfTunnel.class, tunnel); return builder.build(); }
From source file:com.jkoolcloud.jesl.simulator.TNT4JSimulatorParserHandler.java
private Property processPropertyValue(String name, String type, String value, String valType) throws SAXParseException { Object propValue = value;/*from w w w . java 2 s .c o m*/ if ("INTEGER".equalsIgnoreCase(type)) { Integer num = Integer.parseInt(generateFromRange(type, value)); propValue = (int) TNT4JSimulator.varyValue(num.intValue()); } else if ("LONG".equalsIgnoreCase(type)) { Long num = Long.parseLong(generateFromRange(type, value)); propValue = (long) TNT4JSimulator.varyValue(num.longValue()); } else if ("DECIMAL".equalsIgnoreCase(type)) { Double num = Double.parseDouble(generateFromRange(type, value)); propValue = TNT4JSimulator.varyValue(num.doubleValue()); } else if ("BOOLEAN".equalsIgnoreCase(type)) { if (StringUtils.isEmpty(valType)) valType = "boolean"; propValue = Boolean.parseBoolean(value); } else if ("TIMESTAMP".equalsIgnoreCase(type)) { try { try { propValue = new UsecTimestamp((long) TNT4JSimulator.varyValue(Long.parseLong(value))); } catch (NumberFormatException e) { propValue = new UsecTimestamp(value, "yyyy-MM-dd HH:mm:ss.SSSSSS", (String) null); } } catch (Exception e) { throw new SAXParseException("Failed parsing timestamp", saxLocator, e); } if (StringUtils.isEmpty(valType)) valType = ValueTypes.VALUE_TYPE_TIMESTAMP; } else if ("STRING".equalsIgnoreCase(type)) { propValue = value.toString(); } else if (!StringUtils.isEmpty(type)) { throw new SAXParseException("<" + SIM_XML_PROP + ">: invalid type: " + type, saxLocator); } return new Property(name, propValue, valType); }
From source file:org.mifos.accounts.struts.action.EditStatusAction.java
@TransactionDemarcate(validateAndResetToken = true) @CloseSession//from w ww . jav a2s .c o m public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception { UserContext userContext = getUserContext(request); EditStatusActionForm editStatusActionForm = (EditStatusActionForm) form; Integer accountId = Integer.valueOf(editStatusActionForm.getAccountId()); AccountBO accountBO = new AccountBusinessService().getAccount(accountId); Short flagId = null; Short newStatusId = null; String updateComment = editStatusActionForm.getNotes(); if (StringUtils.isNotBlank(editStatusActionForm.getFlagId())) { flagId = getShortValue(editStatusActionForm.getFlagId()); } if (StringUtils.isNotBlank(editStatusActionForm.getNewStatusId())) { newStatusId = getShortValue(editStatusActionForm.getNewStatusId()); } checkPermission(accountBO, getUserContext(request), newStatusId, flagId); if (accountBO.isLoanAccount()) { initializeLoanQuestionnaire(accountBO.getGlobalAccountNum(), newStatusId != null ? newStatusId.toString() : null); loanQuestionnaire.saveResponses(request, editStatusActionForm, accountId); //GLIM List<LoanBO> individualLoans = this.loanDao.findIndividualLoans(accountId); List<AccountUpdateStatus> updateStatus = new ArrayList<AccountUpdateStatus>(individualLoans.size() + 1); updateStatus.add(new AccountUpdateStatus(accountId.longValue(), newStatusId, flagId, updateComment)); for (LoanBO individual : individualLoans) { updateStatus.add(new AccountUpdateStatus(individual.getAccountId().longValue(), newStatusId, flagId, updateComment)); } this.loanAccountServiceFacade.updateSeveralLoanAccountStatuses(updateStatus, editStatusActionForm.getTransactionDateValue(userContext.getPreferredLocale())); return mapping.findForward(ActionForwards.loan_detail_page.toString()); } if (accountBO.isSavingsAccount()) { AccountUpdateStatus updateStatus = new AccountUpdateStatus(accountId.longValue(), newStatusId, flagId, updateComment); this.savingsServiceFacade.updateSavingsAccountStatus(updateStatus); return mapping.findForward(ActionForwards.savings_details_page.toString()); } // nothing but loan of savings account should be detected. customer account status change goes through separate action. return null; }
From source file:com.redhat.rhn.frontend.xmlrpc.errata.ErrataHandler.java
/** * creates an errata/*from ww w. j a v a2 s . c o m*/ * @param loggedInUser The current user * @param errataInfo map containing the following values: * String "synopsis" short synopsis of the errata * String "advisory_name" advisory name of the errata * Integer "advisory_release" release number of the errata * String "advisory_type" the type of advisory for the errata (Must be one of the * following: "Security Advisory", "Product Enhancement Advisory", or * "Bug Fix Advisory" * String "product" the product the errata affects * String "errataFrom" the author of the errata * String "topic" the topic of the errata * String "description" the description of the errata * String "solution" the solution of the errata * String "references" references of the errata to be created * String "notes" notes on the errata * @param bugs a List of maps consisting of 'id' Integers and 'summary' strings * @param keywords a List of keywords for the errata * @param packageIds a List of package Id packageId Integers * @param publish should the errata be published * @param channelLabels an array of channel labels to publish to if the errata is to * be published * @throws InvalidChannelRoleException if the user perms are incorrect * @return The errata created (whether published or unpublished) * * @xmlrpc.doc Create a custom errata. If "publish" is set to true, * the errata will be published as well * @xmlrpc.param #session_key() * @xmlrpc.param * #struct("errata info") * #prop("string", "synopsis") * #prop("string", "advisory_name") * #prop("int", "advisory_release") * #prop_desc("string", "advisory_type", "Type of advisory (one of the * following: 'Security Advisory', 'Product Enhancement Advisory', * or 'Bug Fix Advisory'") * #prop("string", "product") * #prop("string", "errataFrom") * #prop("string", "topic") * #prop("string", "description") * #prop("string", "references") * #prop("string", "notes") * #prop("string", "solution") * #struct_end() * @xmlrpc.param * #array() * #struct("bug") * #prop_desc("int", "id", "Bug Id") * #prop("string", "summary") * #prop("string", "url") * #struct_end() * #array_end() * @xmlrpc.param #array_single("string", "keyword - List of keywords to associate * with the errata.") * @xmlrpc.param #array_single("int", "packageId") * @xmlrpc.param #param_desc("boolean", "publish", "Should the errata be published.") * @xmlrpc.param * #array_single("string", "channelLabel - list of channels the errata should be * published too, ignored if publish is set to false") * @xmlrpc.returntype * $ErrataSerializer */ public Errata create(User loggedInUser, Map<String, String> errataInfo, List<Map<String, Object>> bugs, List<String> keywords, List<Integer> packageIds, boolean publish, List<String> channelLabels) throws InvalidChannelRoleException { // confirm that the user only provided valid keys in the map Set<String> validKeys = new HashSet<String>(); validKeys.add("synopsis"); validKeys.add("advisory_name"); validKeys.add("advisory_release"); validKeys.add("advisory_type"); validKeys.add("product"); validKeys.add("errataFrom"); validKeys.add("topic"); validKeys.add("description"); validKeys.add("references"); validKeys.add("notes"); validKeys.add("solution"); validateMap(validKeys, errataInfo); validKeys.clear(); validKeys.add("id"); validKeys.add("summary"); validKeys.add("url"); for (Map<String, Object> bugMap : bugs) { validateMap(validKeys, bugMap); } //Don't want them to publish an errata without any channels, //so check first before creating anything List<Channel> channels = null; if (publish) { channels = verifyChannelList(channelLabels, loggedInUser); } String synopsis = (String) getRequiredAttribute(errataInfo, "synopsis"); String advisoryName = (String) getRequiredAttribute(errataInfo, "advisory_name"); Integer advisoryRelease = (Integer) getRequiredAttribute(errataInfo, "advisory_release"); if (advisoryRelease.longValue() > ErrataManager.MAX_ADVISORY_RELEASE) { throw new InvalidAdvisoryReleaseException(advisoryRelease.longValue()); } String advisoryType = (String) getRequiredAttribute(errataInfo, "advisory_type"); String product = (String) getRequiredAttribute(errataInfo, "product"); String errataFrom = errataInfo.get("errataFrom"); String topic = (String) getRequiredAttribute(errataInfo, "topic"); String description = (String) getRequiredAttribute(errataInfo, "description"); String solution = (String) getRequiredAttribute(errataInfo, "solution"); String references = errataInfo.get("references"); String notes = errataInfo.get("notes"); Errata newErrata = ErrataManager.lookupByAdvisory(advisoryName); if (newErrata != null) { throw new DuplicateErrataException(advisoryName); } newErrata = ErrataManager.createNewErrata(); newErrata.setOrg(loggedInUser.getOrg()); //all required newErrata.setSynopsis(synopsis); newErrata.setAdvisory(advisoryName + "-" + advisoryRelease.toString()); newErrata.setAdvisoryName(advisoryName); newErrata.setAdvisoryRel(new Long(advisoryRelease.longValue())); if (advisoryType.equals("Security Advisory") || advisoryType.equals("Product Enhancement Advisory") || advisoryType.equals("Bug Fix Advisory")) { newErrata.setAdvisoryType(advisoryType); } else { throw new InvalidAdvisoryTypeException(advisoryType); } newErrata.setProduct(product); newErrata.setTopic(topic); newErrata.setDescription(description); newErrata.setSolution(solution); newErrata.setIssueDate(new Date()); newErrata.setUpdateDate(new Date()); //not required newErrata.setErrataFrom(errataFrom); newErrata.setRefersTo(references); newErrata.setNotes(notes); for (Iterator<Map<String, Object>> itr = bugs.iterator(); itr.hasNext();) { Map<String, Object> bugMap = itr.next(); String url = null; if (bugMap.containsKey("url")) { url = (String) bugMap.get("url"); } Bug bug = ErrataFactory.createPublishedBug(new Long(((Integer) bugMap.get("id")).longValue()), (String) bugMap.get("summary"), url); newErrata.addBug(bug); } for (Iterator<String> itr = keywords.iterator(); itr.hasNext();) { String keyword = itr.next(); newErrata.addKeyword(keyword); } newErrata.setPackages(new HashSet()); for (Iterator<Integer> itr = packageIds.iterator(); itr.hasNext();) { Integer pid = itr.next(); Package pack = PackageFactory.lookupByIdAndOrg(new Long(pid.longValue()), loggedInUser.getOrg()); if (pack != null) { newErrata.addPackage(pack); } else { throw new InvalidPackageException(pid.toString()); } } ErrataFactory.save(newErrata); //if true, channels will not be null, but will be a List of channel objects if (publish) { return publish(newErrata, channels, loggedInUser, false); } return newErrata; }
From source file:org.apache.storm.daemon.supervisor.SyncProcessEvent.java
protected Map<String, Integer> startNewWorkers(Map<Integer, String> newWorkerIds, Map<Integer, LocalAssignment> reassignExecutors) throws IOException { Map<String, Integer> newValidWorkerIds = new HashMap<>(); Map conf = supervisorData.getConf(); String supervisorId = supervisorData.getSupervisorId(); String clusterMode = ConfigUtils.clusterMode(conf); for (Map.Entry<Integer, LocalAssignment> entry : reassignExecutors.entrySet()) { Integer port = entry.getKey(); LocalAssignment assignment = entry.getValue(); String workerId = newWorkerIds.get(port); String stormId = assignment.get_topology_id(); WorkerResources resources = assignment.get_resources(); // This condition checks for required files exist before launching the worker if (SupervisorUtils.doRequiredTopoFilesExist(conf, stormId)) { String pidsPath = ConfigUtils.workerPidsRoot(conf, workerId); String hbPath = ConfigUtils.workerHeartbeatsRoot(conf, workerId); LOG.info("Launching worker with assignment {} for this supervisor {} on port {} with id {}", assignment, supervisorData.getSupervisorId(), port, workerId); FileUtils.forceMkdir(new File(pidsPath)); FileUtils.forceMkdir(new File(ConfigUtils.workerTmpRoot(conf, workerId))); FileUtils.forceMkdir(new File(hbPath)); if (clusterMode.endsWith("distributed")) { launchDistributedWorker(supervisorData.getWorkerManager(), conf, supervisorId, supervisorData.getAssignmentId(), stormId, port.longValue(), workerId, resources, supervisorData.getDeadWorkers()); } else if (clusterMode.endsWith("local")) { launchLocalWorker(supervisorData, stormId, port.longValue(), workerId, resources); }/*from ww w .j a v a 2s . c om*/ newValidWorkerIds.put(workerId, port); } else { LOG.info( "Missing topology storm code, so can't launch worker with assignment {} for this supervisor {} on port {} with id {}", assignment, supervisorData.getSupervisorId(), port, workerId); } } return newValidWorkerIds; }