private void incrementUnacknowledgedQueueSize(final int count, final long bytes) { boolean updated = false; while (!updated) { final FlowFileQueueSize original = size.get(); final FlowFileQueueSize newSize = new FlowFileQueueSize(original.getActiveCount(), original.getActiveBytes(), original.getSwappedCount(), original.getSwappedBytes(), original.getSwapFileCount(), original.getUnacknowledgedCount() + count, original.getUnacknowledgedBytes() + bytes); updated = updateSize(original, newSize); if (updated) { logIfNegative(original, newSize, "Unacknowledged"); } } }
private void logIfNegative(final FlowFileQueueSize original, final FlowFileQueueSize newSize, final String counterName) { if (newSize.getActiveBytes() < 0 || newSize.getActiveCount() < 0 || newSize.getSwappedBytes() < 0 || newSize.getSwappedCount() < 0 || newSize.getUnacknowledgedBytes() < 0 || newSize.getUnacknowledgedCount() < 0) { logger.error("Updated Size of Queue " + counterName + " from " + original + " to " + newSize, new RuntimeException("Cannot create negative queue size")); } }
private int getFlowFileCount() { final FlowFileQueueSize size = getFlowFileQueueSize(); return size.getActiveCount() + size.getSwappedCount() + size.getUnacknowledgedCount(); }
do { final FlowFileQueueSize currentSize = getFlowFileQueueSize(); swapSize = new QueueSize(currentSize.getSwappedCount() - swapQueueCount, currentSize.getSwappedBytes() - swapQueueBytes); final FlowFileQueueSize updatedSize = new FlowFileQueueSize(0, 0, 0, 0, 0, currentSize.getUnacknowledgedCount(), currentSize.getUnacknowledgedBytes()); updated = updateSize(currentSize, updatedSize); } while (!updated);
@Override public boolean isActiveQueueEmpty() { final FlowFileQueueSize queueSize = queue.getFlowFileQueueSize(); return queueSize.getActiveCount() == 0 && queueSize.getSwappedCount() == 0; }
@Override public QueueSize getActiveQueueSize() { return new QueueSize(queueSize.getActiveCount(), queueSize.getActiveBytes()); }
@Override public QueueSize getSwapQueueSize() { return new QueueSize(queueSize.getSwappedCount(), queueSize.getSwappedBytes()); }
@Override public QueueSize getUnacknowledgedQueueSize() { return new QueueSize(queueSize.getUnacknowledgedCount(), queueSize.getUnacknowledgedCount()); }
@Override public int getSwapFileCount() { return queueSize.getSwapFileCount(); } }
@Override public boolean isEmpty() { return queue.getFlowFileQueueSize().isEmpty(); }
if (size.getSwappedCount() == 0 && swapQueue.isEmpty()) { return; if (size.getSwappedCount() > swapQueue.size()) { if (size.getSwappedCount() == 0) { swapMode = false;
dropRequest.setDroppedSize(dropRequest.getDroppedSize().add(droppedSize)); final QueueSize swapSize = getFlowFileQueueSize().swapQueueSize(); logger.debug("For DropFlowFileRequest {}, Swap Queue has {} elements, Swapped Record Count = {}, Swapped Content Size = {}", requestIdentifier, swapQueue.size(), swapSize.getObjectCount(), swapSize.getByteCount());
final long addedSwapBytes = updatedSwapQueueBytes - originalSwapQueueBytes; final FlowFileQueueSize newSize = new FlowFileQueueSize(activeQueue.size(), activeQueueBytes, originalSize.getSwappedCount() + addedSwapRecords + flowFilesSwappedOut, originalSize.getSwappedBytes() + addedSwapBytes + bytesSwappedOut, originalSize.getSwapFileCount() + numSwapFiles, originalSize.getUnacknowledgedCount(), originalSize.getUnacknowledgedBytes()); updated = updateSize(originalSize, newSize);
public boolean isActiveQueueEmpty() { final FlowFileQueueSize queueSize = getFlowFileQueueSize(); return queueSize.getActiveCount() == 0 && queueSize.getSwappedCount() == 0; }
@Override public QueueSize getActiveQueueSize() { return new QueueSize(queueSize.getActiveCount(), queueSize.getActiveBytes()); }
@Override public QueueSize getSwapQueueSize() { return new QueueSize(queueSize.getSwappedCount(), queueSize.getSwappedBytes()); }
@Override public QueueSize getUnacknowledgedQueueSize() { return new QueueSize(queueSize.getUnacknowledgedCount(), queueSize.getUnacknowledgedCount()); }
@Override public int getSwapFileCount() { return queueSize.getSwapFileCount(); }
public boolean isEmpty() { return getFlowFileQueueSize().isEmpty(); }
protected void incrementActiveQueueSize(final int count, final long bytes) { boolean updated = false; while (!updated) { final FlowFileQueueSize original = size.get(); final FlowFileQueueSize newSize = new FlowFileQueueSize( original.getActiveCount() + count, original.getActiveBytes() + bytes, original.getSwappedCount(), original.getSwappedBytes(), original.getSwapFileCount(), original.getUnacknowledgedCount(), original.getUnacknowledgedBytes()); updated = updateSize(original, newSize); if (updated) { logIfNegative(original, newSize, "active"); } } }