private void registerPendingPreemption(String host) { writeLock.lock(); try { pendingPreemptions.incrementAndGet(); if (metrics != null) { metrics.incrPendingPreemptionTasksCount(); } MutableInt val = pendingPreemptionsPerHost.get(host); if (val == null) { val = new MutableInt(0); pendingPreemptionsPerHost.put(host, val); } val.increment(); } finally { writeLock.unlock(); } }
protected void processPut(String putArgStr) { MutableInt parsePos = new MutableInt(0); Object key = parseKey(putArgStr, parsePos); putArgStr = putArgStr.substring(parsePos.intValue()); Object value = parseValue(putArgStr, parsePos); client.put(key, value); }
keyToSuccessCount.put(key, new MutableInt(0)); List<Versioned<byte[]>> retrieved = getResult.retrieved.get(key); MutableInt successCount = keyToSuccessCount.get(key); successCount.increment(); int successCount = successCountWrapper.intValue(); if(successCount < storeDef.getPreferredReads()) { List<Node> extraNodes = keyToExtraNodesMap.get(key); successCountWrapper.setValue(successCount); int successCount = mapEntry.getValue().intValue(); if(successCount < storeDef.getRequiredReads()) throw new InsufficientOperationalNodesException(this.storeDef.getRequiredReads()
public MutableInt postIncrement(MutableInt x) { int valueBeforeIncrement = x.intValue(); x.add(1); return new MutableInt(valueBeforeIncrement); }
MutableInt x = new MutableInt(); // x is 0. MutableInt y = new MutableInt(); // y is 0. MutableInt temp = postIncrement(x); // Now x is 1, and temp is 0. y = temp; // y is still 0.
@Test public void functionRunnerShouldWorkIfNotSucceededOnMaxRetryReached() throws Exception { final MutableInt value = new MutableInt(0); new FunctionRunnerWithRetry(MAX_RETRY).execute( () -> { value.increment(); return (Integer) value.getValue() == MAX_RETRY; } ); assertThat(value.getValue()).isEqualTo(MAX_RETRY); }
private static FilterQuery traverseFilterQueryAndPopulateMap(FilterQueryTree tree, Map<Integer, FilterQuery> filterQueryMap, MutableInt currentId) { int currentNodeId = currentId.intValue(); currentId.increment(); final List<Integer> f = new ArrayList<>(); if (null != tree.getChildren()) { for (final FilterQueryTree c : tree.getChildren()) { int childNodeId = currentId.intValue(); currentId.increment(); f.add(childNodeId); final FilterQuery q = traverseFilterQueryAndPopulateMap(c, filterQueryMap, currentId); filterQueryMap.put(childNodeId, q); } } FilterQuery query = new FilterQuery(); query.setColumn(tree.getColumn()); query.setId(currentNodeId); query.setNestedFilterQueryIds(f); query.setOperator(tree.getOperator()); query.setValue(tree.getValue()); return query; }
/** * Decrement a count value for a named key * * @param resourceKey the key to count against * @param allowNegative <tt>true</tt> to allow negative values otherwise zero will be the floor * @return the newly-decremented value (negative, if allowed) */ public static final int decrementCount(Object resourceKey, boolean allowNegative) { MutableInt counter = (MutableInt) AlfrescoTransactionSupport.getResource(resourceKey); if (counter == null) { counter = new MutableInt(0); AlfrescoTransactionSupport.bindResource(resourceKey, counter); } if (counter.intValue() > 0 || allowNegative) { counter.decrement(); } return counter.intValue(); }
/** * Compares this object to the specified object. The result is <code>true</code> if and only if the argument is * not <code>null</code> and is a <code>MutableInt</code> object that contains the same <code>int</code> value * as this object. * * @param obj the object to compare with, null returns false * @return <code>true</code> if the objects are the same; <code>false</code> otherwise. */ public boolean equals(Object obj) { if (obj instanceof MutableInt) { return value == ((MutableInt) obj).intValue(); } return false; }
private Double annotateWithPileup(final AlignmentContext stratifiedContext, final VariantContext vc) { final HashMap<Byte, MutableInt> alleleCounts = new HashMap<>(); for ( final Allele allele : vc.getAlleles() ) alleleCounts.put(allele.getBases()[0], new MutableInt(0)); for ( final byte base : stratifiedContext.getBasePileup().getBases() ) { if ( alleleCounts.containsKey(base) ) alleleCounts.get(base).increment(); } final int refCount = alleleCounts.get(vc.getReference().getBases()[0]).intValue(); final int altCount = alleleCounts.get(vc.getAlternateAllele(0).getBases()[0]).intValue(); return (refCount + altCount == 0) ? null : ((double) refCount) / (refCount + altCount); }
MutableInt s = new MutableInt(0); MutableInt j = s; s.setValue(5); System.out.println(s.intValue()); // 5 System.out.println(j.intValue()); // 5
vcAlleles.stream().forEach(a -> alleleCounts.set(a, new MutableInt(0))); alleleCounts.get(mostLikelyAllele.getMostLikelyAllele()).increment(); vc.getAlleles().stream().forEach(a -> result.set(a, alleleCounts.get(a).toInteger()));
Map map = new HashMap (); final int defaut = 0; final int inc = 1; MutableInt oldValue = new MutableInt (default); while(true) { MutableInt newValue = oldValue; oldValue = map.put (key, newValue); // insert or... if (oldValue != null) { newValue.setValue(oldValue + inc); // ...update oldValue.setValue(default); // reuse } else oldValue = new MutableInt (default); // renew } }
public void addConnection() { numActiveConnections.increment(); }
@Test public void testSetGet() { final MutableInt value = new MutableInt(); public Object answer() throws Throwable { Object[] arguments = getCurrentArguments(); value.setValue((Integer) arguments[0]); return null; public Integer answer() throws Throwable { return value.toInteger();
@Override public void run() { //let the players update smoother int remainingUpdates = getNextUpdates(); for (Map.Entry<Player, MutableInt> entry : queue.entrySet()) { Player player = entry.getKey(); MutableInt remainingTicks = entry.getValue(); if (remainingTicks.intValue() == 0) { if (remainingUpdates != 0) { //Smoother refreshing; limit the updates plugin.getScoreboardManager().onUpdate(player); remainingTicks.setValue(20 * Settings.getInterval()); remainingUpdates--; } } else { remainingTicks.decrement(); } } nextGlobalUpdate--; if (nextGlobalUpdate == 0) { nextGlobalUpdate = 20 * Settings.getInterval(); //update globals plugin.getReplaceManager().updateGlobals(); } }
MutableInt maxActive = new MutableInt(); MutableInt numActive = new MutableInt(); MutableInt maxIdle = new MutableInt(); MutableInt numIdle = new MutableInt(); MutableInt numWaiting = new MutableInt(); poolInfo.setMaxActive(maxActive.toInteger()); poolInfo.setNumActive(numActive.toInteger()); poolInfo.setNumWaiting(numWaiting.toInteger()); poolInfo.setMaxIdle(maxIdle.toInteger()); poolInfo.setNumIdle(numIdle.toInteger()); poolInfo.setPoolName(poolName);