@Override public boolean equals(final Object obj) { if (obj == this) { return true; } if (obj == null) { return false; } if (!(obj instanceof QueueSize)) { return false; } final QueueSize other = (QueueSize) obj; return getObjectCount() == other.getObjectCount() && getByteCount() == other.getByteCount(); } }
/** * Returns a new QueueSize that is the sum of this QueueSize and the provided QueueSize * * @param other the other QueueSize to add to this QueueSize * @return a new QueueSize that is the sum of this QueueSize and the provided QueueSize */ public QueueSize add(final QueueSize other) { if (other == null) { return new QueueSize(objectCount, totalSizeBytes); } return new QueueSize(objectCount + other.getObjectCount(), totalSizeBytes + other.getByteCount()); }
private void adjustSize(final int countToAdd, final long bytesToAdd) { boolean updated = false; while (!updated) { final QueueSize queueSize = this.totalSize.get(); final QueueSize updatedSize = queueSize.add(countToAdd, bytesToAdd); updated = totalSize.compareAndSet(queueSize, updatedSize); } }
@Override public boolean isActivelyLoadBalancing() { final QueueSize size = size(); if (size.getObjectCount() == 0) { return false; } final int localObjectCount = localPartition.size().getObjectCount(); return (size.getObjectCount() > localObjectCount); }
QueueSize totalQueueSize = new QueueSize(0, 0L); final List<ResourceClaim> resourceClaims = new ArrayList<>(); totalQueueSize = totalQueueSize.add(summaryQueueSize); adjustSize(totalQueueSize.getObjectCount(), totalQueueSize.getByteCount());
public QueueSize toQueueSize() { return new QueueSize(activeQueueCount + swappedCount + unacknowledgedCount, activeQueueBytes + swappedBytes + unacknowledgedBytes); }
incrementActiveQueueSize(-droppedSize.getObjectCount(), -droppedSize.getByteCount()); dropRequest.setCurrentSize(size()); dropRequest.setDroppedSize(dropRequest.getDroppedSize().add(droppedSize)); requestIdentifier, swapQueue.size(), swapSize.getObjectCount(), swapSize.getByteCount()); if (dropRequest.getState() == DropFlowFileState.CANCELED) { logger.info("Cancel requested for DropFlowFileRequest {}", requestIdentifier); dropRequest.setDroppedSize(dropRequest.getDroppedSize().add(droppedSize)); swapMode = false; incrementSwapQueueSize(-droppedSize.getObjectCount(), -droppedSize.getByteCount(), 0); logger.debug("For DropFlowFileRequest {}, dropped {} from Swap Queue", requestIdentifier, droppedSize); dropRequest.setDroppedSize(dropRequest.getDroppedSize().add(droppedSize)); incrementSwapQueueSize(-droppedSize.getObjectCount(), -droppedSize.getByteCount(), -1); dropRequest.getDroppedSize().getObjectCount(), dropRequest.getDroppedSize().getByteCount(), getQueueIdentifier(), requestor); dropRequest.setState(DropFlowFileState.COMPLETE); } catch (final Exception e) {
@Override public boolean isEmpty() { return size().getObjectCount() == 0; }
public QueueSize activeQueueSize() { return new QueueSize(activeQueueCount, activeQueueBytes); }
private QueueSizeDTO createQueueSizeDTO(final QueueSize queueSize) { final QueueSizeDTO dto = new QueueSizeDTO(); dto.setByteCount(queueSize.getByteCount()); dto.setObjectCount(queueSize.getObjectCount()); return dto; }
public QueueSize getTotalFlowFileCount(final ProcessGroup group) { int count = 0; long contentSize = 0L; for (final Connection connection : group.getConnections()) { final QueueSize size = connection.getFlowFileQueue().size(); count += size.getObjectCount(); contentSize += size.getByteCount(); } for (final ProcessGroup childGroup : group.getProcessGroups()) { final QueueSize size = getTotalFlowFileCount(childGroup); count += size.getObjectCount(); contentSize += size.getByteCount(); } return new QueueSize(count, contentSize); }
public boolean isEmpty() { return size().getObjectCount() == 0; } }
public QueueSize swapQueueSize() { return new QueueSize(swappedCount, swappedBytes); }
private RemoteQueuePartitionDTO createRemoteQueuePartitionDto(final RemoteQueuePartitionDiagnostics queueDiagnostics) { final RemoteQueuePartitionDTO dto = new RemoteQueuePartitionDTO(); dto.setNodeIdentifier(queueDiagnostics.getNodeIdentifier()); final QueueSize activeSize = queueDiagnostics.getActiveQueueSize(); dto.setActiveQueueByteCount(activeSize.getByteCount()); dto.setActiveQueueFlowFileCount(activeSize.getObjectCount()); final QueueSize inFlightSize = queueDiagnostics.getUnacknowledgedQueueSize(); dto.setInFlightByteCount(inFlightSize.getByteCount()); dto.setInFlightFlowFileCount(inFlightSize.getObjectCount()); final QueueSize swapSize = queueDiagnostics.getSwapQueueSize(); dto.setSwapByteCount(swapSize.getByteCount()); dto.setSwapFlowFileCount(swapSize.getObjectCount()); dto.setSwapFiles(queueDiagnostics.getSwapFileCount()); dto.setTotalByteCount(activeSize.getByteCount() + inFlightSize.getByteCount() + swapSize.getByteCount()); dto.setTotalFlowFileCount(activeSize.getObjectCount() + inFlightSize.getObjectCount() + swapSize.getObjectCount()); return dto; }
@Override public QueueSize getQueueSize() { verifyTaskActive(); int flowFileCount = 0; long byteCount = 0L; for (final Connection conn : context.getPollableConnections()) { final QueueSize queueSize = conn.getFlowFileQueue().size(); flowFileCount += queueSize.getObjectCount(); byteCount += queueSize.getByteCount(); } return new QueueSize(flowFileCount, byteCount); }
private int getWorkCount(final Connectable connectable) { int sum = 0; for (final Connection connection : connectable.getIncomingConnections()) { sum += connection.getFlowFileQueue().size().getObjectCount(); } return sum; }
public QueueSize add(final int count, final long bytes) { return new QueueSize(objectCount + count, totalSizeBytes + bytes); }
@Override public Object getFieldValue(final String fieldName) { switch (fieldName) { case SwapSchema.MAX_RECORD_ID: return swapSummary.getMaxFlowFileId(); case SwapSchema.FLOWFILE_COUNT: return swapSummary.getQueueSize().getObjectCount(); case SwapSchema.FLOWFILE_SIZE: return swapSummary.getQueueSize().getByteCount(); case SwapSchema.QUEUE_IDENTIFIER: return queueIdentifier; case SwapSchema.RESOURCE_CLAIMS: return claimCounts; } return null; }
swapFlowFileCount += queueSize.getObjectCount(); swapByteCount += queueSize.getByteCount(); resourceClaims.addAll(summary.getResourceClaims()); } catch (final IOException ioe) { return new StandardSwapSummary(new QueueSize(swapFlowFileCount, swapByteCount), maxId, resourceClaims);
dropRequest.setCurrentSize(originalSize); dropRequest.setOriginalSize(originalSize); if (originalSize.getObjectCount() == 0) { dropRequest.setDroppedSize(originalSize); dropRequest.setState(DropFlowFileState.COMPLETE);