當前位置: 首頁>>代碼示例>>Java>>正文


Java ConcurrentMap.isEmpty方法代碼示例

本文整理匯總了Java中java.util.concurrent.ConcurrentMap.isEmpty方法的典型用法代碼示例。如果您正苦於以下問題:Java ConcurrentMap.isEmpty方法的具體用法?Java ConcurrentMap.isEmpty怎麽用?Java ConcurrentMap.isEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.concurrent.ConcurrentMap的用法示例。


在下文中一共展示了ConcurrentMap.isEmpty方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: offsetBehindMuchThanData

import java.util.concurrent.ConcurrentMap; //導入方法依賴的package包/類
private boolean offsetBehindMuchThanData(final String topic, ConcurrentMap<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().getMinOffsetInQueue(topic, next.getKey());
        long offsetInPersist = next.getValue();
        result = offsetInPersist <= minOffsetInStore;
    }

    return result;
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:14,代碼來源:ConsumerOffsetManager.java

示例2: scanNotActiveChannel

import java.util.concurrent.ConcurrentMap; //導入方法依賴的package包/類
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();
        ConcurrentMap<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();
        }
    }
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:32,代碼來源:ConsumerManager.java

示例3: getMergedAgents

import java.util.concurrent.ConcurrentMap; //導入方法依賴的package包/類
private static ConcurrentMap<ServerType, List<Class<?>>> getMergedAgents(
        final ServerType category,
        final ConcurrentMap<ServerType, Class<?>> internals
) {
    final ConcurrentMap<ServerType, List<Class<?>>> agents = ZeroAnno.getAgents();
    if (agents.isEmpty()) {
        // Inject ServerType by category input.
        agents.put(category, new ArrayList<>(internals.values()));
    }
    return agents;
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:12,代碼來源:Motor.java

示例4: serviceStop

import java.util.concurrent.ConcurrentMap; //導入方法依賴的package包/類
@Override
protected void serviceStop() throws Exception {
  System.out.println("Called stooppppp");
  super.serviceStop();
  isStopped = true;
  ConcurrentMap<ApplicationId, Application> applications =
      getNMContext().getApplications();
  // ensure that applications are empty
  if(!applications.isEmpty()) {
    assertionFailedInThread.set(true);
  }
  syncBarrier.await(10000, TimeUnit.MILLISECONDS);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:14,代碼來源:TestNodeStatusUpdater.java

示例5: cleanExpiredConsumerQueue

import java.util.concurrent.ConcurrentMap; //導入方法依賴的package包/類
public void cleanExpiredConsumerQueue() {
    // CommitLog的最小Offset
    long minCommitLogOffset = this.commitLog.getMinOffset();

    Iterator<Entry<String, ConcurrentMap<Integer, ConsumeQueue>>> it = this.consumeQueueTable.entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, ConcurrentMap<Integer, ConsumeQueue>> next = it.next();
        String topic = next.getKey();
        if (!topic.equals(ScheduleMessageService.SCHEDULE_TOPIC)) {
            ConcurrentMap<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.removeQueueFromTopicQueueTable(nextQT.getValue().getTopic(),
                        nextQT.getValue().getQueueId());

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

            if (queueTable.isEmpty()) {
                log.info("cleanExpiredConsumerQueue: {},topic destroyed", topic);
                it.remove();
            }
        }
    }
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:46,代碼來源:DefaultMessageStore.java

示例6: setConnection

import java.util.concurrent.ConcurrentMap; //導入方法依賴的package包/類
@Override
public void setConnection(Application application, String sessionId, IKey key, IWebSocketConnection connection)
{
	Args.notNull(application, "application");
	Args.notNull(sessionId, "sessionId");
	Args.notNull(key, "key");

	ConcurrentMap<String, ConcurrentMap<IKey, IWebSocketConnection>> connectionsBySession = application.getMetaData(KEY);
	if (connectionsBySession == null)
	{
		synchronized (KEY)
		{
			connectionsBySession = application.getMetaData(KEY);
			if (connectionsBySession == null)
			{
				connectionsBySession = Generics.newConcurrentHashMap();
				application.setMetaData(KEY, connectionsBySession);
			}
		}
	}

	ConcurrentMap<IKey, IWebSocketConnection> connectionsByPage = connectionsBySession.get(sessionId);
	if (connectionsByPage == null && connection != null)
	{
		connectionsByPage = connectionsBySession.get(sessionId);
		if (connectionsByPage == null)
		{
			connectionsByPage = Generics.newConcurrentHashMap();
			ConcurrentMap<IKey, IWebSocketConnection> old = connectionsBySession.putIfAbsent(sessionId, connectionsByPage);
			if (old != null)
			{
				connectionsByPage = old;
			}
		}
	}

	if (connection != null)
	{
		connectionsByPage.put(key, connection);
	}
	else if (connectionsByPage != null)
	{
		connectionsByPage.remove(key);
		if (connectionsByPage.isEmpty())
		{
			connectionsBySession.remove(sessionId);
		}
	}
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:50,代碼來源:SimpleWebSocketConnectionRegistry.java

示例7: loadJsonInfo

import java.util.concurrent.ConcurrentMap; //導入方法依賴的package包/類
private void loadJsonInfo(ConcurrentMap<String, Set<String>> infoMap, String targetInfo)
    throws IOException, JSONException {
  synchronized (infoMap) {
    if (!infoMap.isEmpty()) {
      return;
    }

    JSONArray buildInfo = new JSONArray(
        "[" + simpleCompsBuildInfo.join(",") + "," +
        extCompsBuildInfo.join(",") + "]");

    for (int i = 0; i < buildInfo.length(); ++i) {
      JSONObject compJson = buildInfo.getJSONObject(i);
      JSONArray infoArray = null;
      String type = compJson.getString("type");
      try {
        infoArray = compJson.getJSONArray(targetInfo);
      } catch (JSONException e) {
        // Older compiled extensions will not have a broadcastReceiver
        // defined. Rather then require them all to be recompiled, we
        // treat the missing attribute as empty.
        if (e.getMessage().contains("broadcastReceiver")) {
          LOG.log(Level.INFO, "Component \"" + type + "\" does not have a broadcast receiver.");
          continue;
        } else {
          throw e;
        }
      }

      if (!simpleCompTypes.contains(type) && !extCompTypes.contains(type)) {
        continue;
      }

      Set<String> infoSet = Sets.newHashSet();
      for (int j = 0; j < infoArray.length(); ++j) {
        String info = infoArray.getString(j);
        infoSet.add(info);
      }

      if (!infoSet.isEmpty()) {
        infoMap.put(type, infoSet);
      }
    }
  }
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:46,代碼來源:Compiler.java


注:本文中的java.util.concurrent.ConcurrentMap.isEmpty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。