Java Code Examples for java.util.concurrent.ConcurrentHashMap#isEmpty()

The following examples show how to use java.util.concurrent.ConcurrentHashMap#isEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetricAssociation.java    From StatsAgg with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    // run the association routine against all metric-groups/metric-suspensions/metric-keys. should only run the pattern matcher against previously unknown metric-keys.
    for (String metricKey : metricKeys__) {
        ConcurrentHashMap<String,String> immediateCleanupMetrics = GlobalVariables.immediateCleanupMetrics;
        if ((immediateCleanupMetrics != null) && !immediateCleanupMetrics.isEmpty() && immediateCleanupMetrics.containsKey(metricKey)) continue;

        associateMetricKeyWithIds(metricKey, allMetricGroupIds__, 
                GlobalVariables.matchingMetricKeysAssociatedWithMetricGroup, GlobalVariables.metricKeysAssociatedWithAnyMetricGroup, 
                GlobalVariables.mergedMatchRegexesByMetricGroupId, GlobalVariables.mergedBlacklistRegexesByMetricGroupId);

        associateMetricKeyWithIds(metricKey, allMetricSuspensionIds__, 
                GlobalVariables.matchingMetricKeysAssociatedWithSuspension, GlobalVariables.metricKeysAssociatedWithAnySuspension, 
                GlobalVariables.mergedMatchRegexesBySuspensionId, GlobalVariables.mergedBlacklistRegexesBySuspensionId);
    }
}
 
Example 2
Source File: JettyRestProcessorAbstractSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @return True if any query cursor is available.
 */
private boolean queryCursorFound() {
    boolean found = false;

    for (int i = 0; i < gridCount(); ++i) {
        Map<GridRestCommand, GridRestCommandHandler> handlers =
            GridTestUtils.getFieldValue(grid(i).context().rest(), "handlers");

        GridRestCommandHandler qryHnd = handlers.get(GridRestCommand.CLOSE_SQL_QUERY);

        ConcurrentHashMap<Long, Iterator> its = GridTestUtils.getFieldValue(qryHnd, "qryCurs");

        found |= !its.isEmpty();
    }

    return found;
}
 
Example 3
Source File: IntegrationTestDDLMasterFailover.java    From hbase with Apache License 2.0 6 votes vote down vote up
protected NamespaceDescriptor selectNamespace(
    ConcurrentHashMap<String, NamespaceDescriptor> namespaceMap) {
  // synchronization to prevent removal from multiple threads
  synchronized (namespaceMap) {
    // randomly select namespace from namespaceMap
    if (namespaceMap.isEmpty()) {
      return null;
    }
    ArrayList<String> namespaceList = new ArrayList<>(namespaceMap.keySet());
    String randomKey = namespaceList.get(RandomUtils.nextInt(0, namespaceList.size()));
    NamespaceDescriptor randomNsd = namespaceMap.get(randomKey);
    // remove from namespaceMap
    namespaceMap.remove(randomKey);
    return randomNsd;
  }
}
 
Example 4
Source File: ConsumerOffsetManager.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
/**
 * 判断offset是否落后很多
 * 
 * @param topic
 * @param table
 * @return
 */
private boolean offsetBehindMuchThanData(final String topic, ConcurrentHashMap<Integer, Long> table) {
    Iterator<Entry<Integer, Long>> it = table.entrySet().iterator();
    boolean result = !table.isEmpty();

    while (it.hasNext() && result) {
        Entry<Integer, Long> next = it.next();
        long minOffsetInStore =
                this.brokerController.getMessageStore().getMinOffsetInQuque(topic, next.getKey());
        long offsetInPersist = next.getValue();
        if (offsetInPersist > minOffsetInStore) {
            result = false;
        }
    }

    return result;
}
 
Example 5
Source File: ConsumerOffsetManager.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
private boolean offsetBehindMuchThanData(final String topic, ConcurrentHashMap<Integer, Long> table) {
    Iterator<Entry<Integer, Long>> it = table.entrySet().iterator();
    boolean result = !table.isEmpty();

    while (it.hasNext() && result) {
        Entry<Integer, Long> next = it.next();
        long minOffsetInStore = this.brokerController.getMessageStore().getMinOffsetInQuque(topic, next.getKey());
        long offsetInPersist = next.getValue();
        if (offsetInPersist > minOffsetInStore) {
            result = false;
        } else {
            result = true;
        }
    }

    return result;
}
 
Example 6
Source File: ConsumerOffsetManager.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 6 votes vote down vote up
private boolean offsetBehindMuchThanData(final String topic, ConcurrentHashMap<Integer, Long> table) {
    Iterator<Entry<Integer, Long>> it = table.entrySet().iterator();
    boolean result = !table.isEmpty();

    while (it.hasNext() && result) {
        Entry<Integer, Long> next = it.next();
        long minOffsetInStore = this.brokerController.getMessageStore().getMinOffsetInQuque(topic, next.getKey());
        long offsetInPersist = next.getValue();
        if (offsetInPersist > minOffsetInStore) {
            result = false;
        }
        else {
            result = true;
        }
    }

    return result;
}
 
Example 7
Source File: EventBus.java    From firebase-android-sdk with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized <T> void unsubscribe(Class<T> type, EventHandler<? super T> handler) {
  Preconditions.checkNotNull(type);
  Preconditions.checkNotNull(handler);

  if (!handlerMap.containsKey(type)) {
    return;
  }

  ConcurrentHashMap<EventHandler<Object>, Executor> handlers = handlerMap.get(type);

  @SuppressWarnings("unchecked")
  EventHandler<Object> casted = (EventHandler<Object>) handler;
  handlers.remove(casted);

  if (handlers.isEmpty()) {
    handlerMap.remove(type);
  }
}
 
Example 8
Source File: ProducerManager.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public synchronized void unregisterProducer(final String group, final ClientChannelInfo clientChannelInfo) {
    ConcurrentHashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group);
    if (null != channelTable && !channelTable.isEmpty()) {
        ClientChannelInfo old = channelTable.remove(clientChannelInfo.getChannel());
        clientChannelTable.remove(clientChannelInfo.getClientId());
        if (old != null) {
            log.info("unregister a producer[{}] from groupChannelTable {}", group,
                    clientChannelInfo.toString());
        }

        if (channelTable.isEmpty()) {
            this.groupChannelTable.remove(group);
            log.info("unregister a producer group[{}] from groupChannelTable", group);
        }
    }
}
 
Example 9
Source File: AnnotatedJCacheableService.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
@CacheRemoveAll(afterInvocation = false)
public void earlyRemoveAll() {
	ConcurrentHashMap<?, ?> nativeCache = (ConcurrentHashMap<?, ?>) defaultCache.getNativeCache();
	if (!nativeCache.isEmpty()) {
		throw new AssertionError("Cache was expected to be empty");
	}
}
 
Example 10
Source File: DelayedHashMap.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isEmpty() {
    for (ConcurrentHashMap<K, V> segment : segments) {
        if (!segment.isEmpty()) {
            return false;
        }
    }
    return true;
}
 
Example 11
Source File: ConsumerManager.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public void scanNotActiveChannel() {
    Iterator<Entry<String, ConsumerGroupInfo>> it = this.consumerTable.entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, ConsumerGroupInfo> next = it.next();
        String group = next.getKey();
        ConsumerGroupInfo consumerGroupInfo = next.getValue();
        ConcurrentHashMap<Channel, ClientChannelInfo> channelInfoTable =
            consumerGroupInfo.getChannelInfoTable();

        Iterator<Entry<Channel, ClientChannelInfo>> itChannel = channelInfoTable.entrySet().iterator();
        while (itChannel.hasNext()) {
            Entry<Channel, ClientChannelInfo> nextChannel = itChannel.next();
            ClientChannelInfo clientChannelInfo = nextChannel.getValue();
            long diff = System.currentTimeMillis() - clientChannelInfo.getLastUpdateTimestamp();
            if (diff > CHANNEL_EXPIRED_TIMEOUT) {
                log.warn(
                    "SCAN: remove expired channel from ConsumerManager consumerTable. channel={}, consumerGroup={}",
                    RemotingHelper.parseChannelRemoteAddr(clientChannelInfo.getChannel()), group);
                RemotingUtil.closeChannel(clientChannelInfo.getChannel());
                itChannel.remove();
            }
        }

        if (channelInfoTable.isEmpty()) {
            log.warn(
                "SCAN: remove expired channel from ConsumerManager consumerTable, all clear, consumerGroup={}",
                group);
            it.remove();
        }
    }
}
 
Example 12
Source File: AnnotatedJCacheableService.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
@CacheRemoveAll(afterInvocation = false)
public void earlyRemoveAll() {
	ConcurrentHashMap<?, ?> nativeCache = (ConcurrentHashMap<?, ?>) defaultCache.getNativeCache();
	if (!nativeCache.isEmpty()) {
		throw new AssertionError("Cache was expected to be empty");
	}
}
 
Example 13
Source File: AnnotatedJCacheableService.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
@CacheRemoveAll(afterInvocation = false)
public void earlyRemoveAll() {
	ConcurrentHashMap<?, ?> nativeCache = (ConcurrentHashMap<?, ?>) defaultCache.getNativeCache();
	if (!nativeCache.isEmpty()) {
		throw new AssertionError("Cache was expected to be empty");
	}
}
 
Example 14
Source File: DefaultMessageStore.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public void cleanExpiredConsumerQueue() {
    long minCommitLogOffset = this.commitLog.getMinOffset();

    Iterator<Entry<String, ConcurrentHashMap<Integer, ConsumeQueue>>> it = this.consumeQueueTable.entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, ConcurrentHashMap<Integer, ConsumeQueue>> next = it.next();
        String topic = next.getKey();
        if (!topic.equals(ScheduleMessageService.SCHEDULE_TOPIC)) {
            ConcurrentHashMap<Integer, ConsumeQueue> queueTable = next.getValue();
            Iterator<Entry<Integer, ConsumeQueue>> itQT = queueTable.entrySet().iterator();
            while (itQT.hasNext()) {
                Entry<Integer, ConsumeQueue> nextQT = itQT.next();
                long maxCLOffsetInConsumeQueue = nextQT.getValue().getLastOffset();


                if (maxCLOffsetInConsumeQueue == -1) {
                    log.warn("maybe ConsumeQueue was created just now. topic={} queueId={} maxPhysicOffset={} minLogicOffset={}.", //
                            nextQT.getValue().getTopic(), //
                            nextQT.getValue().getQueueId(), //
                            nextQT.getValue().getMaxPhysicOffset(), //
                            nextQT.getValue().getMinLogicOffset());
                } else if (maxCLOffsetInConsumeQueue < minCommitLogOffset) {
                    log.info(
                            "cleanExpiredConsumerQueue: {} {} consumer queue destroyed, minCommitLogOffset: {} maxCLOffsetInConsumeQueue: {}", //
                            topic, //
                            nextQT.getKey(), //
                            minCommitLogOffset, //
                            maxCLOffsetInConsumeQueue);

                    DefaultMessageStore.this.commitLog.removeQueurFromTopicQueueTable(nextQT.getValue().getTopic(),
                            nextQT.getValue().getQueueId());

                    nextQT.getValue().destroy();
                    itQT.remove();
                }
            }

            if (queueTable.isEmpty()) {
                log.info("cleanExpiredConsumerQueue: {},topic destroyed", topic);
                it.remove();
            }
        }
    }
}
 
Example 15
Source File: MQClientInstance.java    From rocketmq-read with Apache License 2.0 4 votes vote down vote up
/**
 * Remove offline broker
 */
private void cleanOfflineBroker() {
    try {
        if (this.lockNamesrv.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
            try {
                ConcurrentHashMap<String, HashMap<Long, String>> updatedTable = new ConcurrentHashMap<String, HashMap<Long, String>>();

                Iterator<Entry<String, HashMap<Long, String>>> itBrokerTable = this.brokerAddrTable.entrySet().iterator();
                while (itBrokerTable.hasNext()) {
                    Entry<String, HashMap<Long, String>> entry = itBrokerTable.next();
                    String brokerName = entry.getKey();
                    HashMap<Long, String> oneTable = entry.getValue();

                    HashMap<Long, String> cloneAddrTable = new HashMap<Long, String>();
                    cloneAddrTable.putAll(oneTable);

                    Iterator<Entry<Long, String>> it = cloneAddrTable.entrySet().iterator();
                    while (it.hasNext()) {
                        Entry<Long, String> ee = it.next();
                        String addr = ee.getValue();
                        if (!this.isBrokerAddrExistInTopicRouteTable(addr)) {
                            it.remove();
                            log.info("the broker addr[{} {}] is offline, remove it", brokerName, addr);
                        }
                    }

                    if (cloneAddrTable.isEmpty()) {
                        itBrokerTable.remove();
                        log.info("the broker[{}] name's host is offline, remove it", brokerName);
                    } else {
                        updatedTable.put(brokerName, cloneAddrTable);
                    }
                }

                if (!updatedTable.isEmpty()) {
                    this.brokerAddrTable.putAll(updatedTable);
                }
            } finally {
                this.lockNamesrv.unlock();
            }
        }
    } catch (InterruptedException e) {
        log.warn("cleanOfflineBroker Exception", e);
    }
}
 
Example 16
Source File: MQClientInstance.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
/**
     * Remove offline broker
     */
//
    private void cleanOfflineBroker() {
        try {
            if (this.lockNamesrv.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS))
                try {
                    ConcurrentHashMap<String, HashMap<Long, String>> updatedTable = new ConcurrentHashMap<String, HashMap<Long, String>>();

//                    遍历broker
                    Iterator<Entry<String, HashMap<Long, String>>> itBrokerTable = this.brokerAddrTable.entrySet().iterator();
                    while (itBrokerTable.hasNext()) {
                        Entry<String, HashMap<Long, String>> entry = itBrokerTable.next();
                        String brokerName = entry.getKey();
                        HashMap<Long, String> oneTable = entry.getValue();

                        HashMap<Long, String> cloneAddrTable = new HashMap<Long, String>();
                        cloneAddrTable.putAll(oneTable);

                        Iterator<Entry<Long, String>> it = cloneAddrTable.entrySet().iterator();
                        while (it.hasNext()) {
                            Entry<Long, String> ee = it.next();
                            String addr = ee.getValue();
//                            broker信息是否存在topic路由表=》
                            if (!this.isBrokerAddrExistInTopicRouteTable(addr)) {
                                it.remove();
                                log.info("the broker addr[{} {}] is offline, remove it", brokerName, addr);
                            }
                        }

//                        如果不存在删除
                        if (cloneAddrTable.isEmpty()) {
                            itBrokerTable.remove();
                            log.info("the broker[{}] name's host is offline, remove it", brokerName);
                        } else {
                            updatedTable.put(brokerName, cloneAddrTable);
                        }
                    }

                    if (!updatedTable.isEmpty()) {
                        this.brokerAddrTable.putAll(updatedTable);
                    }
                } finally {
                    this.lockNamesrv.unlock();
                }
        } catch (InterruptedException e) {
            log.warn("cleanOfflineBroker Exception", e);
        }
    }
 
Example 17
Source File: DefaultMessageStore.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public void cleanExpiredConsumerQueue() {
    // CommitLog的最小Offset
    long minCommitLogOffset = this.commitLog.getMinOffset();

    Iterator<Entry<String, ConcurrentHashMap<Integer, ConsumeQueue>>> it =
            this.consumeQueueTable.entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, ConcurrentHashMap<Integer, ConsumeQueue>> next = it.next();
        String topic = next.getKey();
        if (!topic.equals(ScheduleMessageService.SCHEDULE_TOPIC)) {
            ConcurrentHashMap<Integer, ConsumeQueue> queueTable = next.getValue();
            Iterator<Entry<Integer, ConsumeQueue>> itQT = queueTable.entrySet().iterator();
            while (itQT.hasNext()) {
                Entry<Integer, ConsumeQueue> nextQT = itQT.next();
                long maxCLOffsetInConsumeQueue = nextQT.getValue().getLastOffset();

                // maxCLOffsetInConsumeQueue==-1有可能正好是索引文件刚好创建的那一时刻,此时不清除数据
                if (maxCLOffsetInConsumeQueue == -1) {
                    log.warn(
                        "maybe ConsumeQueue was created just now. topic={} queueId={} maxPhysicOffset={} minLogicOffset={}.", //
                        nextQT.getValue().getTopic(), //
                        nextQT.getValue().getQueueId(), //
                        nextQT.getValue().getMaxPhysicOffset(), //
                        nextQT.getValue().getMinLogicOffset());
                }
                else if (maxCLOffsetInConsumeQueue < minCommitLogOffset) {
                    log.info(
                        "cleanExpiredConsumerQueue: {} {} consumer queue destroyed, minCommitLogOffset: {} maxCLOffsetInConsumeQueue: {}", //
                        topic, //
                        nextQT.getKey(), //
                        minCommitLogOffset, //
                        maxCLOffsetInConsumeQueue);

                    DefaultMessageStore.this.commitLog.removeQueurFromTopicQueueTable(
                        nextQT.getValue().getTopic(), nextQT.getValue().getQueueId());

                    nextQT.getValue().destroy();
                    itQT.remove();
                }
            }

            if (queueTable.isEmpty()) {
                log.info("cleanExpiredConsumerQueue: {},topic destroyed", topic);
                it.remove();
            }
        }
    }
}
 
Example 18
Source File: AbstractJCacheAnnotationTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
protected boolean isEmpty(Cache cache) {
	ConcurrentHashMap<?, ?> nativeCache = (ConcurrentHashMap<?, ?>) cache.getNativeCache();
	return nativeCache.isEmpty();
}
 
Example 19
Source File: MetricAssociation.java    From StatsAgg with Apache License 2.0 4 votes vote down vote up
public static Long associateMetricKeysWithMetricGroups_OutputBlacklistMetricGroup(String threadId, List<String> metricKeys) {
    
    if (metricKeys == null) {
        return new Long(0);
    }

    boolean restartRoutineRequred = true;
    long numNewKeysProcessed = 0;
    
    while (restartRoutineRequred) {
        // don't run this loop a second time unless this variable is changed below
        restartRoutineRequred = false;
        
        String matchRegex_BeforeMatching = null, matchRegex_AfterMatching = null, blacklistRegex_BeforeMatching = null, blacklistRegex_AfterMatching = null;
        MetricAssociationPattern metricAssociationPattern_Match_BeforeMatching = null, metricAssociationPattern_Blacklist_BeforeMatching = null;
        MetricAssociationPattern metricAssociationPattern_Match_AfterMatching = null, metricAssociationPattern_Blacklist_AfterMatching = null;
        
        //  get the metric-group id of the output blacklist (if one exists)
        OutputBlacklist outputBlacklist_BeforeMatching = OutputBlacklistDao.getSingleOutputBlacklistRow();
        Integer outputBlacklist_BeforeMatching_MetricGroupId = null;
        if ((outputBlacklist_BeforeMatching != null) && (outputBlacklist_BeforeMatching.getMetricGroupId() != null)) outputBlacklist_BeforeMatching_MetricGroupId = outputBlacklist_BeforeMatching.getMetricGroupId();
        
        // if a output blacklist metric group exists, associate metrics-keys with it
        if (outputBlacklist_BeforeMatching_MetricGroupId != null) {
            // update the output blacklist regex
            List<Integer> outputBlacklistMetricGroupId_List = new ArrayList<>();
            outputBlacklistMetricGroupId_List.add(outputBlacklist_BeforeMatching_MetricGroupId);
            updateMergedRegexesForMetricGroups(outputBlacklistMetricGroupId_List);

            // used in checking if the output-blacklist was altered while this routine was running
            matchRegex_BeforeMatching = GlobalVariables.mergedMatchRegexesByMetricGroupId.get(outputBlacklist_BeforeMatching_MetricGroupId);
            if (matchRegex_BeforeMatching != null) metricAssociationPattern_Match_BeforeMatching = regexPatterns_.get(matchRegex_BeforeMatching);
            blacklistRegex_BeforeMatching = GlobalVariables.mergedBlacklistRegexesByMetricGroupId.get(outputBlacklist_BeforeMatching_MetricGroupId);
            if (blacklistRegex_BeforeMatching != null) metricAssociationPattern_Blacklist_BeforeMatching = regexPatterns_.get(blacklistRegex_BeforeMatching);

            // associate metrics-keys with the output blacklist
            for (String metricKey : metricKeys) {
                ConcurrentHashMap<String,String> immediateCleanupMetrics = GlobalVariables.immediateCleanupMetrics;
                if ((immediateCleanupMetrics != null) && !immediateCleanupMetrics.isEmpty() && immediateCleanupMetrics.containsKey(metricKey)) continue;

                if (!GlobalVariables.metricKeysAssociatedWithOutputBlacklistMetricGroup.containsKey(metricKey)) {
                    Boolean didMatch = associateMetricKeyWithId(metricKey, outputBlacklist_BeforeMatching_MetricGroupId, 
                            GlobalVariables.matchingMetricKeysAssociatedWithOutputBlacklistMetricGroup, 
                            GlobalVariables.mergedMatchRegexesByMetricGroupId, 
                            GlobalVariables.mergedBlacklistRegexesByMetricGroupId);

                    if (didMatch != null) {
                        GlobalVariables.metricKeysAssociatedWithOutputBlacklistMetricGroup.put(metricKey, didMatch);
                        numNewKeysProcessed++;
                    }
                }
            }
            
            // used in checking if the output-blacklist was altered while this routine was running
            OutputBlacklist outputBlacklist_AfterMatching = OutputBlacklistDao.getSingleOutputBlacklistRow();
            Integer outputBlacklist_AfterMatching_MetricGroupId = null;
            if ((outputBlacklist_AfterMatching != null) && outputBlacklist_AfterMatching.getMetricGroupId() != null) outputBlacklist_AfterMatching_MetricGroupId = outputBlacklist_BeforeMatching_MetricGroupId;
            if (outputBlacklist_AfterMatching_MetricGroupId != null) matchRegex_AfterMatching = GlobalVariables.mergedMatchRegexesByMetricGroupId.get(outputBlacklist_AfterMatching_MetricGroupId);
            if (matchRegex_AfterMatching != null) metricAssociationPattern_Match_AfterMatching = regexPatterns_.get(matchRegex_AfterMatching);
            if (outputBlacklist_AfterMatching_MetricGroupId != null) blacklistRegex_AfterMatching = GlobalVariables.mergedBlacklistRegexesByMetricGroupId.get(outputBlacklist_AfterMatching_MetricGroupId);
            if (blacklistRegex_AfterMatching != null) metricAssociationPattern_Blacklist_AfterMatching = regexPatterns_.get(blacklistRegex_AfterMatching);
            
            // check if the output-blacklist was altered while this routine was running. if it was, then re-run this routine
            if (((metricAssociationPattern_Match_BeforeMatching != null) && (metricAssociationPattern_Blacklist_BeforeMatching != null) &&
                    (metricAssociationPattern_Match_AfterMatching != null) && (metricAssociationPattern_Blacklist_AfterMatching != null)) && 
                    ((outputBlacklist_BeforeMatching_MetricGroupId != null) && (outputBlacklist_AfterMatching_MetricGroupId != null) && 
                    (outputBlacklist_BeforeMatching_MetricGroupId.intValue() == outputBlacklist_AfterMatching_MetricGroupId.intValue())) &&
                    ((metricAssociationPattern_Match_BeforeMatching.getTimestamp() != metricAssociationPattern_Match_AfterMatching.getTimestamp()) || 
                    (metricAssociationPattern_Blacklist_BeforeMatching.getTimestamp() != metricAssociationPattern_Blacklist_AfterMatching.getTimestamp()))) {
                logger.info("ThreadId=" + threadId + ", Routine=MetricAssociation_OutputBlacklist_MetricSet, Message=\"Detected output-blacklist metric-group change. Restarting association routine.\"");
                restartRoutineRequred = true;
                numNewKeysProcessed = 0;
            }
        }
    }

    return numNewKeysProcessed;
}
 
Example 20
Source File: DefaultMessageStore.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 4 votes vote down vote up
public void cleanExpiredConsumerQueue() {
    long minCommitLogOffset = this.commitLog.getMinOffset();

    Iterator<Entry<String, ConcurrentHashMap<Integer, ConsumeQueue>>> it = this.consumeQueueTable.entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, ConcurrentHashMap<Integer, ConsumeQueue>> next = it.next();
        String topic = next.getKey();
        if (!topic.equals(ScheduleMessageService.SCHEDULE_TOPIC)) {
            ConcurrentHashMap<Integer, ConsumeQueue> queueTable = next.getValue();
            Iterator<Entry<Integer, ConsumeQueue>> itQT = queueTable.entrySet().iterator();
            while (itQT.hasNext()) {
                Entry<Integer, ConsumeQueue> nextQT = itQT.next();
                long maxCLOffsetInConsumeQueue = nextQT.getValue().getLastOffset();

                if (maxCLOffsetInConsumeQueue == -1) {
                    log.warn("maybe ConsumeQueue was created just now. topic={} queueId={} maxPhysicOffset={} minLogicOffset={}.",//
                        nextQT.getValue().getTopic(),//
                        nextQT.getValue().getQueueId(),//
                        nextQT.getValue().getMaxPhysicOffset(),//
                        nextQT.getValue().getMinLogicOffset());
                }
                else if (maxCLOffsetInConsumeQueue < minCommitLogOffset) {
                    log.info(
                        "cleanExpiredConsumerQueue: {} {} consumer queue destroyed, minCommitLogOffset: {} maxCLOffsetInConsumeQueue: {}",//
                        topic,//
                        nextQT.getKey(),//
                        minCommitLogOffset,//
                        maxCLOffsetInConsumeQueue);

                    DefaultMessageStore.this.commitLog.removeQueurFromTopicQueueTable(nextQT.getValue().getTopic(), nextQT.getValue()
                        .getQueueId());

                    nextQT.getValue().destroy();
                    itQT.remove();
                }
            }

            if (queueTable.isEmpty()) {
                log.info("cleanExpiredConsumerQueue: {},topic destroyed", topic);
                it.remove();
            }
        }
    }
}