/** * Check whether there are any batches which haven't been drained */ public boolean hasUndrained() { for (Map.Entry<TopicPartition, Deque<ProducerBatch>> entry : this.batches.entrySet()) { Deque<ProducerBatch> deque = entry.getValue(); synchronized (deque) { if (!deque.isEmpty()) return true; } } return false; }
public static ConcurrentMap<String, TopicConfig> cloneTopicConfigTable( ConcurrentMap<String, TopicConfig> topicConfigConcurrentMap) { ConcurrentHashMap<String, TopicConfig> result = new ConcurrentHashMap<String, TopicConfig>(); if (topicConfigConcurrentMap != null) { for (Map.Entry<String, TopicConfig> entry : topicConfigConcurrentMap.entrySet()) { result.put(entry.getKey(), entry.getValue()); } } return result; } }
private Map<String, Long> getCurrentValues() { final ImmutableMap.Builder<String, Long> builder = ImmutableMap.builder(); for (Map.Entry<String, AtomicLong> entry : counters.entrySet()) { builder.put(entry.getKey(), entry.getValue().get()); } for (Map.Entry<String, AtomicLong> entry : meters.entrySet()) { builder.put(entry.getKey(), entry.getValue().get()); } return builder.build(); } };
private void checkSelf() { this.commitLog.checkSelf(); Iterator<Entry<String, ConcurrentMap<Integer, ConsumeQueue>>> it = this.consumeQueueTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, ConcurrentMap<Integer, ConsumeQueue>> next = it.next(); Iterator<Entry<Integer, ConsumeQueue>> itNext = next.getValue().entrySet().iterator(); while (itNext.hasNext()) { Entry<Integer, ConsumeQueue> cq = itNext.next(); cq.getValue().checkSelf(); } } }
private void runTimelineCallbacks(final Function<TimelineCallback, CallbackAction> function) { for (Map.Entry<TimelineCallback, Executor> entry : timelineCallbacks.entrySet()) { entry.getValue().execute( () -> { if (CallbackAction.UNREGISTER == function.apply(entry.getKey())) { timelineCallbacks.remove(entry.getKey()); } } ); } }