public void inheritQueueContents(final FlowFileQueueContents queueContents) { writeLock.lock(); try { putAll(queueContents.getActiveFlowFiles()); swapLocations.addAll(queueContents.getSwapLocations()); incrementSwapQueueSize(queueContents.getSwapSize().getObjectCount(), queueContents.getSwapSize().getByteCount(), queueContents.getSwapLocations().size()); } finally { writeLock.unlock("inheritQueueContents"); } }
@Override public void rebalance(final FlowFileQueueContents queueContents) { if (queueContents.getActiveFlowFiles().isEmpty() && queueContents.getSwapLocations().isEmpty()) { return; } queue.inheritQueueContents(queueContents); rebalanceFromQueue(); }
} while (!updated); return new FlowFileQueueContents(activeRecords, updatedSwapLocations, swapSize); } finally { writeLock.unlock("packageForRebalance(SwappablePriorityQueue)");
@Override public void putAll(final Function<String, FlowFileQueueContents> queueContentsFunction, final FlowFilePartitioner partitionerUsed) { partitionReadLock.lock(); try { if (isRebalanceOnFailure(partitionerUsed)) { final FlowFileQueueContents contents = queueContentsFunction.apply(rebalancingPartition.getSwapPartitionName()); rebalancingPartition.rebalance(contents); logger.debug("Transferring all {} FlowFiles and {} Swap Files queued for node {} to Rebalancing Partition", contents.getActiveFlowFiles().size(), contents.getSwapLocations().size(), nodeId); } else { logger.debug("Will not transfer FlowFiles queued for node {} to Rebalancing Partition because Partitioner {} indicates that the FlowFiles should stay where they are", nodeId, partitioner); } } finally { partitionReadLock.unlock(); } }
final FlowFileQueueContents queueContents = new FlowFileQueueContents(Collections.emptyList(), Collections.singletonList(updatedSwapLocation), swapSummary.getQueueSize()); rebalancingPartition.rebalance(queueContents);