private synchronized TrackingQueue getQueue() { if (queue == null) { queue = new ElementsTrackingQueue(new ZKElementsTracking(zkClient, zkQueuePath)); } return queue; }
/** * Returns a live iterator that cycles through queues in the group in a round-robin fashion, returning an element from * the first queue that has one available. If all queues are cycled through once without an element, null is returned. * * @param consumerId Id of the consumer taking the element. * @return An element from a queue in the group, or null if none exists. */ @Override public Iterator<GroupElement> takeIterator(String consumerId) { return new GroupElementIterator(consumerId); }
@Override public TrackingQueue load(String queueName) throws Exception { return new LazyZKTrackingQueue(zkClient, getZKPathForQueue(queueName)); } });
protected ElementsTrackingQueue getQueue() { queue = new ElementsTrackingQueue(new InMemoryElementsTracking()); return queue; } }
@Override public synchronized boolean addToQueue(Element element) { return notStarted.add(new PrioritizedElement(element, getCurrentHighestPriority())); }
@Override public int size() { return getQueue().size(); } }
@Override public boolean removeAll() { return elementsTracking.removeAll(); }
@Override public int size() { return elementsTracking.size(); }
@Override public GroupElement next() { if (hasNext()) { foundElement = false; return nextElement; } throw new NoSuchElementException(); }
@Override public boolean toHighestPriority(String elementId) { Preconditions.checkArgument(elementId != null, "id of the element to promote to highest priority should not be null"); return elementsTracking.toHighestPriority(elementId); }
@Override public boolean remove(String elementId) { Preconditions.checkArgument(elementId != null, "id of the element to remove should not be null"); return elementsTracking.remove(elementId); }
@Override public Element take(String consumerId) { Preconditions.checkArgument(consumerId != null, "id of the consumer that takes element should not be null"); return elementsTracking.startConsuming(consumerId); }
@Override public Iterator<QueuedElement> getQueued() { return elementsTracking.getQueued().iterator(); }
@Override public Iterator<QueuedElement> getBeingConsumed() { return elementsTracking.getBeingConsumed().iterator(); }
@Override QueueGroup getQueueGroup(QueueType type) { return zkQueueGroupService.getQueueGroup(type); }
@Override protected ElementsTrackingQueue getQueue() throws Exception { String queueName = "/tracking-queue"; System.out.println("queue name: " + queueName); queue = new ElementsTrackingQueue(new ZKElementsTracking(zkClient, queueName)); return queue; } }
@Override public boolean toHighestPriority(String elementId) { return getQueue().toHighestPriority(elementId); }
@Before public void beforeCliTest() throws Exception { queueName = "/tracking-queue"; queue = new ElementsTrackingQueue(new ZKElementsTracking(zkClient, queueName)); }
@Override public Iterator<QueuedElement> getBeingConsumed() { return getQueue().getBeingConsumed(); }
@Override public TrackingQueue.PossessionState recordProgress(String consumerId, String elementId, TrackingQueue.ConsumingStatus status, String result) { return getQueue().recordProgress(consumerId, elementId, status, result); }