List of usage examples for java.lang Long longValue
@HotSpotIntrinsicCandidate public long longValue()
From source file:org.duniter.core.client.service.bma.TransactionRemoteServiceImpl.java
public long getCreditOrZero(String currencyId, String pubKey) { Long credit = getCredit(currencyId, pubKey); if (credit == null) { return 0; }//from w w w . j av a 2 s . c o m return credit.longValue(); }
From source file:gridool.db.partitioning.phihash.monetdb.MonetDBCsvLoadTask.java
@Override protected void postShuffle(int numShuffled) { super.postShuffle(numShuffled); assert (csvFileName != null); String connectUrl = jobConf.getConnectUrl(); String tableName = jobConf.getTableName(); String createTableDDL = jobConf.getCreateTableDDL(); String copyIntoQuery = GridDbUtils.generateCopyIntoQuery(tableName, jobConf); String alterTableDDL = jobConf.getAlterTableDDL(); MonetDBCsvLoadOperation ops = new MonetDBCsvLoadOperation(connectUrl, tableName, csvFileName, createTableDDL, copyIntoQuery, alterTableDDL); ops.setAuth(jobConf.getUserName(), jobConf.getPassword()); final Pair<MonetDBCsvLoadOperation, Map<GridNode, MutableLong>> pair = new Pair<MonetDBCsvLoadOperation, Map<GridNode, MutableLong>>( ops, assignMap);/*from w w w .j av a 2 s . co m*/ final StopWatch sw = new StopWatch(); final GridJobFuture<Long> future = kernel.execute(MonetDBInvokeCsvLoadJob.class, pair); final Long numInserted; try { numInserted = future.get(); } catch (InterruptedException ie) { LOG.error(ie.getMessage(), ie); throw new IllegalStateException(ie); } catch (ExecutionException ee) { LOG.error(ee.getMessage(), ee); throw new IllegalStateException(ee); } assert (numInserted != null); if (LOG.isInfoEnabled()) { LOG.info("Processed/Inserted " + numShuffled + '/' + numInserted.longValue() + " records into '" + tableName + "' table in " + sw.toString()); } }
From source file:com.globalsight.everest.permission.Permission.java
/** Returns the mapped integer value to the given permission. */ static int getBitValueForPermission(String p_perm) throws PermissionException { Long id = (Long) s_idMap.get(p_perm); if (id == null) { throw new PermissionException("Permission '" + p_perm + "' does not exist."); }//from w w w .ja va2s .c o m // possible impedance mismatch... return (int) id.longValue(); }
From source file:it.doqui.index.ecmengine.business.personalization.multirepository.node.index.IndexTransactionTracker.java
/** * Checks that each of the transactions is present in the index. As soon as one is found that * isn't, all the following transactions will be reindexed. After the reindexing, the sequence * of transaction IDs will be examined for any voids. These will be recorded. * * @param txns transactions ordered by time ascending * @return returns the// ww w .j av a 2 s . c o m */ private void reindexTransactions(List<Transaction> txns) { if (txns.isEmpty()) { return; } Set<Long> processedTxnIds = new HashSet<Long>(13); Map<Long, TxnRecord> curVoids = voidsMap.get(RepositoryManager.getCurrentRepository()); // Map is mutable boolean forceReindex = false; long minNewTxnId = Long.MAX_VALUE; long maxNewTxnId = Long.MIN_VALUE; long maxNewTxnCommitTime = System.currentTimeMillis(); for (Transaction txn : txns) { Long txnId = txn.getId(); long txnIdLong = txnId.longValue(); if (txnIdLong < minNewTxnId) { minNewTxnId = txnIdLong; } if (txnIdLong > maxNewTxnId) { maxNewTxnId = txnIdLong; maxNewTxnCommitTime = txn.getCommitTimeMs(); } // Keep track of it for void checking processedTxnIds.add(txnId); // Remove this entry from the void list - it is not void curVoids.remove(txnId); // Reindex the transaction if we are forcing it or if it isn't in the index already if (forceReindex || isTxnIdPresentInIndex(txnId) == InIndex.NO) { // Any indexing means that all the next transactions have to be indexed forceReindex = true; try { if (logger.isDebugEnabled()) { logger.debug("Reindexing transaction: " + txn); } // We try the reindex, but for the sake of continuity, have to let it run on reindexTransaction(txnId); } catch (Throwable e) { logger.warn("\n" + "Reindex of transaction failed: \n" + " Transaction ID: " + txnId + "\n" + " Error: " + e.getMessage(), e); } } else { if (logger.isDebugEnabled()) { logger.debug("Reindex skipping transaction: " + txn); } } } // We have to search for voids now. Don't start at the min transaction, // but start at the least of the lastMaxTxnId and minNewTxnId long voidCheckStartTxnId = (lastMaxTxnId < minNewTxnId ? lastMaxTxnId : minNewTxnId) + 1; long voidCheckEndTxnId = maxNewTxnId; // Check for voids in new transactions for (long i = voidCheckStartTxnId; i <= voidCheckEndTxnId; i++) { Long txnId = Long.valueOf(i); if (processedTxnIds.contains(txnId)) { // It is there continue; } // First make sure that it is a real void. Sometimes, transactions are in the table but don't // fall within the commit time window that we queried. If they're in the DB AND in the index, // then they're not really voids and don't need further checks. If they're missing from either, // then they're voids and must be processed. Transaction voidTxn = nodeDaoService.getTxnById(txnId); if (voidTxn != null && isTxnIdPresentInIndex(txnId) != InIndex.NO) { // It is a real transaction (not a void) and is already in the index, so just ignore it. continue; } // Calculate an age for the void. We can't use the current time as that will mean we keep all // discovered voids, even if they are very old. Rather, we use the commit time of the last transaction // in the set as it represents the query time for this iteration. TxnRecord voidRecord = new TxnRecord(); voidRecord.txnCommitTime = maxNewTxnCommitTime; curVoids.put(txnId, voidRecord); if (logger.isDebugEnabled()) { logger.debug("Void detected: " + txnId); } } // Having searched for the nodes, we've recorded all the voids. So move the lastMaxTxnId up. lastMaxTxnId = voidCheckEndTxnId; }
From source file:com.spotify.asyncdatastoreclient.Datastore.java
private void refreshAccessToken() { final Credential credential = config.getCredential(); final Long expiresIn = credential.getExpiresInSeconds(); // trigger refresh if token is about to expire if (credential.getAccessToken() == null || expiresIn != null && expiresIn.longValue() <= 60) { try {//from www . j a va 2 s .c om credential.refreshToken(); final String accessToken = credential.getAccessToken(); if (accessToken != null) { this.accessToken = accessToken; } } catch (final IOException e) { log.error("Storage exception", Throwables.getRootCause(e)); } } }
From source file:at.salzburgresearch.kmt.zkconfig.ZookeeperConfigurationTest.java
@Test public void testLong() throws Exception { Configuration config = new ZookeeperConfiguration(zkConnection, 5000, "/test"); final String key = UUID.randomUUID().toString(); final Random random = new Random(); final long val1 = random.nextLong(); final Long val2 = random.nextLong(); assertThat(config.getProperty(key), nullValue()); config.setProperty(key, val1); assertEquals(val1, config.getLong(key)); assertEquals(Long.valueOf(val1), config.getLong(key, val2)); config.setProperty(key, val2); assertEquals(val2.longValue(), config.getLong(key)); assertEquals(val2, config.getLong(key, Long.valueOf(val1))); }
From source file:org.elasticsoftware.elasterix.server.actors.User.java
private final boolean authenticate(ActorRef dialog, SipRequestMessage request, State state) { if (log.isDebugEnabled()) { log.debug(String.format("onReceive. Authenticating %s[%s]", request.getMethod(), state.getUsername())); }//from w ww .jav a 2s .c o m switch (request.getSipMethod()) { case REGISTER: // check if authentication is present... String authorization = request.getHeader(SipHeader.AUTHORIZATION); if (!StringUtils.hasLength(authorization)) { if (log.isDebugEnabled()) log.debug("authenticate. No authorization set"); return false; } Map<String, String> map = request.tokenize(SipHeader.AUTHORIZATION); // check username String val = map.get("username"); if (!state.getUsername().equalsIgnoreCase(val)) { if (log.isDebugEnabled()) log.debug(String.format("authenticate. Provided username[%s] " + "!= given username[%s]", val, state.getUsername())); return false; } // check nonce val = map.get("nonce"); if (!state.getNonce().equalsIgnoreCase(val)) { if (log.isDebugEnabled()) log.debug(String.format("authenticate. Provided nonce[%s] " + "!= given nonce[%s]", val, state.getNonce())); return false; } // check hash val = map.get("response"); String secretHash = generateHash(state, map); if (!secretHash.equals(val)) { if (log.isDebugEnabled()) log.debug(String.format("authenticate. Provided hash[%s] " + "!= given hash[%s]", val, secretHash)); return false; } return true; case INVITE: // check if we have a UAC registered for user Long expires = state.getUserAgentClient(request.getSipUser(SipHeader.CONTACT)); if (expires == null || expires.longValue() < System.currentTimeMillis()) { return false; } else { return true; } } return false; }
From source file:br.com.nordestefomento.jrimum.utilix.Field.java
@SuppressWarnings("unchecked") private void readDecimalField(String valueAsString) { DecimalFormat decimalFormat = (DecimalFormat) format; try {/* ww w . ja va 2 s.c o m*/ Long parsedValue = (Long) format.parseObject(valueAsString); BigDecimal decimalValue = new BigDecimal(parsedValue.longValue()); decimalValue = decimalValue.movePointLeft(decimalFormat.getMaximumFractionDigits()); value = (G) decimalValue; } catch (ParseException e) { getGenericReadError(e, valueAsString); } }
From source file:com.github.gerbsen.math.Frequency.java
/** * Returns the number of values = v.//from ww w.ja v a2s . c om * Returns 0 if the value is not comparable. * * @param v the value to lookup. * @return the frequency of v. */ public long getCount(Comparable<?> v) { if (v instanceof Integer) { return getCount(((Integer) v).longValue()); } long result = 0; try { Long count = freqTable.get(v); if (count != null) { result = count.longValue(); } } catch (ClassCastException ex) { // ignore and return 0 -- ClassCastException will be thrown if value is not comparable } return result; }
From source file:com.draagon.meta.manager.xml.ObjectManagerXML.java
protected String getNextFieldId(ObjectConnection c, MetaObject mc, MetaField f) throws MetaException { long id = 0;//from w w w . j ava 2 s .c o m List<Object> list = getObjectsFromTable(c, mc); for (Object o : list) { Long l = f.getLong(o); if (l == null) l = new Long(1); if (l.longValue() > id) id = l.longValue(); } return "" + (id + 1); }