/** * Sets the member's logical timestamp. * * @param timestamp the member's logical timestamp */ void setTimestamp(long timestamp) { this.timestamp.accumulateAndGet(timestamp, Math::max); }
private void updateIfMaxValue(AtomicLong atomicLong, long timestamp){ atomicLong.accumulateAndGet(timestamp, (currentValue, newValue) -> newValue > currentValue ? newValue : currentValue); } }
private void updatePeakMemoryReservations() { long userMemory = operatorMemoryContext.getUserMemory(); long systemMemory = operatorMemoryContext.getSystemMemory(); long totalMemory = userMemory + systemMemory; peakUserMemoryReservation.accumulateAndGet(userMemory, Math::max); peakSystemMemoryReservation.accumulateAndGet(systemMemory, Math::max); peakTotalMemoryReservation.accumulateAndGet(totalMemory, Math::max); }
public void updateMemoryUsage(long deltaUserMemoryInBytes, long deltaTotalMemoryInBytes, long taskTotalMemoryInBytes) { currentUserMemory.addAndGet(deltaUserMemoryInBytes); currentTotalMemory.addAndGet(deltaTotalMemoryInBytes); peakUserMemory.updateAndGet(currentPeakValue -> Math.max(currentUserMemory.get(), currentPeakValue)); peakTotalMemory.updateAndGet(currentPeakValue -> Math.max(currentTotalMemory.get(), currentPeakValue)); peakTaskTotalMemory.accumulateAndGet(taskTotalMemoryInBytes, Math::max); }
@Override public void updateBytes(long bytes) { if (bytes >= 0) { reservedBytes.addAndGet(bytes); driverContext.reserveSpill(bytes); spilledBytes.addAndGet(bytes); } else { reservedBytes.accumulateAndGet(-bytes, this::decrementSpilledReservation); driverContext.freeSpill(-bytes); } }
private void updateMemoryUsage() { long pageSinkMemoryUsage = pageSink.getSystemMemoryUsage(); pageSinkMemoryContext.setBytes(pageSinkMemoryUsage); pageSinkPeakMemoryUsage.accumulateAndGet(pageSinkMemoryUsage, Math::max); }
public synchronized void updateMemoryUsage(long bytesAdded) { Optional<LocalMemoryContext> systemMemoryContext = getSystemMemoryContext(); // If closed is true, that means the task is completed. In that state, // the output buffers already ignore the newly added pages, and therefore // we can also safely ignore any calls after OutputBufferMemoryManager is closed. // If the systemMemoryContext doesn't exist, the task is probably already // aborted, so we can just return (see the comment in getSystemMemoryContext()). if (closed || !systemMemoryContext.isPresent()) { return; } long currentBufferedBytes = bufferedBytes.addAndGet(bytesAdded); peakMemoryUsage.accumulateAndGet(currentBufferedBytes, Math::max); this.blockedOnMemory = systemMemoryContext.get().setBytes(currentBufferedBytes); if (!isBufferFull() && !isBlockedOnMemory() && !bufferBlockedFuture.isDone()) { // Complete future in a new thread to avoid making a callback on the caller thread. // This make is easier for callers to use this class since they can update the memory // usage while holding locks. SettableFuture<?> future = this.bufferBlockedFuture; notificationExecutor.execute(() -> future.set(null)); return; } this.blockedOnMemory.addListener(this::onMemoryAvailable, notificationExecutor); }
longestSchedulingTime.accumulateAndGet(elapsed, Math::max); schedulingDuration.update(elapsed, TimeUnit.NANOSECONDS); LOG.debug("Scheduling took {} ms for {} topologies", elapsed, topologies.getTopologies().size());
public void request(long n) { if(!sub.isOpen) return; if (processAll) return; if(n==Long.MAX_VALUE){ processAll =true; requested.set(Long.MAX_VALUE); } requested.accumulateAndGet(n,(a,b)->{ long sum = a+b; return sum <0L ? Long.MAX_VALUE : sum; }); handleMainPublisher(); }
reqs = requested.accumulateAndGet(delivered, (a, b) -> a - b); if (reqs == 0) return;
public void emitted(long n) { if (processAll) { return; } if (wip.compareAndSet(0, 1)) { requested.accumulateAndGet(n,(a,b)->a-b); if (decrementAndCheckActive()) { addMissingRequests(); } }else { produced.accumulateAndGet(n, (a, b) -> a + b); if (incrementAndCheckInactive()) { addMissingRequests(); } } }
public void emitted(long n) { if (processAll) { return; } if (wip.compareAndSet(0, 1)) { requested.accumulateAndGet(n,(a,b)->a-b); if (decrementAndCheckActive()) { addMissingRequests(); } }else { produced.accumulateAndGet(n, (a, b) -> a + b); if (incrementAndCheckInactive()) { addMissingRequests(); } } }
requested.accumulateAndGet(n,(a,b)->a+b); queued.accumulateAndGet(n,(a,b)->a+b);
reqs = requested.accumulateAndGet(delivered, (a, b) -> a - b); if(reqs==0) return;
reqs = requested.accumulateAndGet(delivered, (a, b) -> a - b); if(reqs==0) { if(!isOpen)
reqs = requested.accumulateAndGet(delivered, (a, b) -> a - b); if(reqs==0) return;
return; requested.accumulateAndGet(n,(a,b)->a+b); queued.accumulateAndGet(n,(a,b)->a+b);
reqs = requested.accumulateAndGet(delivered, (a, b) -> a - b); if(reqs==0) { if(!isOpen)
reqs = requested.accumulateAndGet(delivered, (a, b) -> a - b); if(reqs==0) return;
/** * Consistent results here mean that: * (1) all calls to backupAndInvalidate() return the same value V, and * (2) this value V is the maximum of all successfully stored timestamp bounds. */ @Test public void invalidationDuringTimestampIssuanceYieldsConsistentResults() { Set<Long> backedUpValues = Sets.newConcurrentHashSet(); AtomicLong maxSuccessfulBound = new AtomicLong(CassandraTimestampUtils.INITIAL_VALUE); CassandraTestTools.executeInParallelOnExecutorService(() -> { CassandraTimestampStoreInvalidator storeInvalidator = CassandraTimestampStoreInvalidator.create(kv); try { if (ThreadLocalRandom.current().nextBoolean()) { backedUpValues.add(storeInvalidator.backupAndInvalidate()); } else { maxSuccessfulBound.accumulateAndGet(getBoundAfterTakingOutOneMillionTimestamps(), Math::max); } } catch (IllegalArgumentException | IllegalStateException | MultipleRunningTimestampServiceError error) { // Can arise if trying to manipulate the timestamp bound during/after an invalidation. This is fine. } }); if (!backedUpValues.isEmpty()) { invalidator.revalidateFromBackup(); assertThat(Iterables.getOnlyElement(backedUpValues)).isEqualTo(maxSuccessfulBound.get()); assertWeCanReadTimestamp(maxSuccessfulBound.get()); } // 2^-32 chance that nothing got backed up; accept in this case. }