@Override public Element take(String queueName, String consumerId) { return queueMap.getUnchecked(queueName).take(consumerId); }
private GroupElement getNextElement() { while (currentBatch.hasNext()) { Map.Entry<String, TrackingQueue> currentQueueEntry = currentBatch.next(); TrackingQueue queue = currentQueueEntry.getValue(); String queueName = currentQueueEntry.getKey(); Element element = queue.take(consumerId); if (element != null) { return new GroupElement(queueName, element); } } return null; }
@Override public Element take(String consumerId) { return getQueue().take(consumerId); }
@Override public void run() { while (true) { Element element = balanceQueue.take(id); if (element == null) { return; } try { tenantProvisionerService.rebalanceTenantWorkers(element.getValue()); balanceQueue.recordProgress(id, element.getId(), TrackingQueue.ConsumingStatus.FINISHED_SUCCESSFULLY, "balanced"); } catch (CapacityException e) { LOG.error("Not enough capacity trying to balance workers for tenant {}", element.getValue(), e); // a failed status puts the element back in the queue, we don't want to consume this element again. // when another provisioner comes online, workers will get rebalanced once again. balanceQueue.recordProgress(id, element.getId(), TrackingQueue.ConsumingStatus.FINISHED_SUCCESSFULLY, "not enough capacity"); } catch (IOException e) { LOG.error("Exception trying to balance workers for tenant {}", element.getValue(), e); balanceQueue.recordProgress(id, element.getId(), TrackingQueue.ConsumingStatus.FINISHED_SUCCESSFULLY, "failed"); } } } }
while (true) { cycle++; Element element = queue.take(consumerName); System.out.println("took: " + (element == null ? "null" : element.getId())); if (element == null) {