当前位置: 首页>>代码示例>>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;未经允许,请勿转载。