当前位置: 首页>>代码示例>>Java>>正文


Java ConcurrentMap.containsKey方法代码示例

本文整理汇总了Java中java.util.concurrent.ConcurrentMap.containsKey方法的典型用法代码示例。如果您正苦于以下问题:Java ConcurrentMap.containsKey方法的具体用法?Java ConcurrentMap.containsKey怎么用?Java ConcurrentMap.containsKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.ConcurrentMap的用法示例。


在下文中一共展示了ConcurrentMap.containsKey方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: openConnection

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
@Override public void openConnection(ConnectionHandle ch,
    Map<String, String> info) {
  Properties fullInfo = new Properties();
  fullInfo.putAll(this.info);
  if (info != null) {
    fullInfo.putAll(info);
  }

  final ConcurrentMap<String, Connection> cacheAsMap = connectionCache.asMap();
  if (cacheAsMap.containsKey(ch.id)) {
    throw new RuntimeException("Connection already exists: " + ch.id);
  }
  // Avoid global synchronization of connection opening
  try {
    Connection conn = createConnection(url, fullInfo);
    Connection loadedConn = cacheAsMap.putIfAbsent(ch.id, conn);
    // Race condition: someone beat us to storing the connection in the cache.
    if (loadedConn != null) {
      conn.close();
      throw new RuntimeException("Connection already exists: " + ch.id);
    }
  } catch (SQLException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:26,代码来源:JdbcMeta.java

示例2: addZKClient

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
/**
 * @param group
 * @param name
 * @param zkClient
 */
private static void addZKClient(String group, String name,
                                ZKClient zkClient) {
    group = group == null ? DEFAULT : group;
    logger.info("Add zkclient to zk groups ,gourp is %s, zk name %s", group, name);
    ConcurrentMap<String, ZKClient> groups = zkGroups.get(group);
    if (groups == null) {
        groups = new ConcurrentHashMap<String, ZKClient>();
    }
    if (groups.containsKey(name)) {
        logger.warn(
                "zk pools have contains the zk name...override the old and close it....");
        close(name);
    }
    groups.put(name, zkClient);
    zkGroups.put(group, groups);
}
 
开发者ID:ShawnShoper,项目名称:x-job,代码行数:22,代码来源:ZKPool.java

示例3: assembleFeatures

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
@Override
protected void assembleFeatures(final ConcurrentMap<String, ConcurrentMap<String, List<Gene>>> mRnaStuffMap,
                                Gene gene, final ConcurrentMap<String, ConcurrentMap<String, Gene>> mRnaMap,
                                Double scaleFactor, List<Gene> passedGenes) {
    final ConcurrentMap<String, Gene> mrnas = mRnaMap.remove(gene.getGroupId());

    if (mrnas != null && scaleFactor > LARGE_SCALE_FACTOR_LIMIT) {
        for (Map.Entry<String, Gene> mrnaEntry : mrnas.entrySet()) {
            if (mRnaStuffMap.containsKey(gene.getGroupId())
                    && mRnaStuffMap.get(gene.getGroupId()).containsKey(mrnaEntry.getKey())) {
                List<Gene> mRnaStuff = mRnaStuffMap.get(gene.getGroupId()).remove(mrnaEntry.getKey());

                removeIfEmpty(mRnaStuffMap, gene.getGroupId());
                mrnaEntry.getValue().setItems(mRnaStuff);
                setExonsCountAndLength(mrnaEntry.getValue(), mRnaStuff);
            }
        }

        gene.setItems(new ArrayList<>(mrnas.values()));
    }

    if (passesScaleFactor(gene, scaleFactor)) {
        passedGenes.add(gene);
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:26,代码来源:GtfReader.java

示例4: queryTopicConsumeByWho

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public HashSet<String> queryTopicConsumeByWho(final String topic) {
    HashSet<String> groups = new HashSet<>();
    Iterator<Entry<String, ConsumerGroupInfo>> it = this.consumerTable.entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, ConsumerGroupInfo> entry = it.next();
        ConcurrentMap<String, SubscriptionData> subscriptionTable =
            entry.getValue().getSubscriptionTable();
        if (subscriptionTable.containsKey(topic)) {
            groups.add(entry.getKey());
        }
    }
    return groups;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:14,代码来源:ConsumerManager.java

示例5: group

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
/**
 * Group function
 *
 * @param object
 * @param keyFn
 * @param valueFn
 * @param <K>
 * @param <V>
 * @param <E>
 * @return
 */
static <K, V, E> ConcurrentMap<K, List<V>> group(
        final Collection<E> object,
        final Function<E, K> keyFn,
        final Function<E, V> valueFn
) {
    final ConcurrentMap<K, List<V>> ret = new ConcurrentHashMap<>();
    if (0 < object.size()) {
        for (final E item : object) {
            if (null != item) {
                final K key = keyFn.apply(item);
                if (null != key) {
                    // Extract List
                    List<V> reference = null;
                    if (ret.containsKey(key)) {
                        reference = ret.get(key);
                    }
                    // Double check
                    if (null == reference) {
                        reference = new ArrayList<>();
                    }
                    final V value = valueFn.apply(item);
                    if (null != value) {
                        reference.add(value);
                    }
                    // Replace finally
                    ret.put(key, reference);
                }
            }
        }
    }
    return ret;
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:44,代码来源:Pond.java

示例6: collapseFeatures

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
@Override
protected void collapseFeatures(final ConcurrentMap<String, ConcurrentMap<String, List<Gene>>> mRnaStuffMap,
                                Gene gene, final ConcurrentMap<String, ConcurrentMap<String, Gene>> mRnaMap,
                                Double scaleFactor, List<Gene> passedGenes) {
    ConcurrentMap<String, Gene> mrnas = mRnaMap.remove(gene.getGffId());

    if (mrnas != null && scaleFactor > LARGE_SCALE_FACTOR_LIMIT) {
        IntervalTreeMap<Gene> stuffIntervalMap = new IntervalTreeMap<>();
        Gene canonicalTranscript = createCanonicalTranscript(gene);

        for (Map.Entry<String, Gene> mrnaEntry : mrnas.entrySet()) {
            Gene transcript = mrnaEntry.getValue();
            setCanonicalTranscriptIndexes(canonicalTranscript, transcript);

            if (mRnaStuffMap.containsKey(transcript.getGffId()) &&
                    mRnaStuffMap.get(transcript.getGffId()).containsKey(transcript.getGffId())) {

                List<Gene> mRnaStuff = mRnaStuffMap.get(transcript.getGffId()).remove(transcript.getGffId());
                removeIfEmpty(mRnaStuffMap, transcript.getGffId());

                groupMrnaStuff(mRnaStuff, stuffIntervalMap);
            }
        }

        canonicalTranscript.setItems(new ArrayList<>(stuffIntervalMap.values()));
        gene.setItems(Collections.singletonList(canonicalTranscript));

        if (gene.getExonsCount() == null) {
            calculateExonsCountAndLength(gene, canonicalTranscript.getItems());
        }
    }

    if (passesScaleFactor(gene, scaleFactor)) {
        passedGenes.add(gene);
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:37,代码来源:GffReader.java

示例7: assembleFeatures

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
@Override
protected void assembleFeatures(final ConcurrentMap<String, ConcurrentMap<String, List<Gene>>> mRnaStuffMap,
                                Gene gene, final ConcurrentMap<String, ConcurrentMap<String, Gene>> mRnaMap,
                                Double scaleFactor, List<Gene> passedGenes) {
    ConcurrentMap<String, Gene> mrnas = mRnaMap.remove(gene.getGffId());

    if (mrnas != null && scaleFactor > LARGE_SCALE_FACTOR_LIMIT) {
        for (Map.Entry<String, Gene> mrnaEntry : mrnas.entrySet()) {
            if (mRnaStuffMap.containsKey(mrnaEntry.getValue().getGffId())
                    && mRnaStuffMap.get(mrnaEntry.getValue().getGffId())
                        .containsKey(mrnaEntry.getValue().getGffId())) {
                List<Gene> mRnaStuff = mRnaStuffMap.get(mrnaEntry.getValue().getGffId()).remove(
                        mrnaEntry.getValue().getGffId());
                removeIfEmpty(mRnaStuffMap, mrnaEntry.getValue().getGffId());
                mrnaEntry.getValue().setItems(mRnaStuff);

                setExonsCountAndLength(mrnaEntry.getValue(), mRnaStuff);
            }
        }

        gene.setItems(new ArrayList<>(mrnas.values()));
    }

    if (passesScaleFactor(gene, scaleFactor)) {
        passedGenes.add(gene);
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:28,代码来源:GffReader.java

示例8: collapseFeatures

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
@Override
protected void collapseFeatures(final ConcurrentMap<String, ConcurrentMap<String, List<Gene>>> mRnaStuffMap,
                                Gene gene, final ConcurrentMap<String, ConcurrentMap<String, Gene>> mRnaMap,
                                Double scaleFactor, List<Gene> passedGenes) {
    final ConcurrentMap<String, Gene> mrnas = mRnaMap.remove(gene.getGroupId());

    if (mrnas != null && scaleFactor > LARGE_SCALE_FACTOR_LIMIT) {
        IntervalTreeMap<Gene> stuffIntervalMap = new IntervalTreeMap<>();
        Gene canonicalTranscript = createCanonicalTranscript(gene);

        for (Map.Entry<String, Gene> mrnaEntry : mrnas.entrySet()) {
            setCanonicalTranscriptIndexes(canonicalTranscript, mrnaEntry.getValue());

            if (mRnaStuffMap.containsKey(gene.getGroupId())
                    && mRnaStuffMap.get(gene.getGroupId()).containsKey(mrnaEntry.getKey())) {
                List<Gene> mRnaStuff = mRnaStuffMap.get(gene.getGroupId()).remove(mrnaEntry.getKey());
                removeIfEmpty(mRnaStuffMap, gene.getGroupId());

                groupMrnaStuff(mRnaStuff, stuffIntervalMap);
            }
        }

        canonicalTranscript.setItems(new ArrayList<>(stuffIntervalMap.values()));
        gene.setItems(Collections.singletonList(canonicalTranscript));

        if (gene.getExonsCount() == null) {
            calculateExonsCountAndLength(gene, canonicalTranscript.getItems());
        }
    }

    if (passesScaleFactor(gene, scaleFactor)) {
        passedGenes.add(gene);
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:35,代码来源:GtfReader.java

示例9: updateServerStats

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public void updateServerStats(ServerName serverName, byte[] regionName,
                              Object r) {
  if (!(r instanceof Result)) {
    return;
  }
  Result result = (Result) r;
  ClientProtos.RegionLoadStats stats = result.getStats();
  if(stats == null){
    return;
  }
  String name = serverName.getServerName() + "," + Bytes.toStringBinary(regionName);
  ConcurrentMap<byte[], RegionStats> rsStats = null;
  if (serverStats.containsKey(serverName)) {
    rsStats = serverStats.get(serverName);
  } else {
    rsStats = serverStats.putIfAbsent(serverName,
        new ConcurrentSkipListMap<byte[], RegionStats>(Bytes.BYTES_COMPARATOR));
    if (rsStats == null) {
      rsStats = serverStats.get(serverName);
    }
  }
  RegionStats regionStats = null;
  if (rsStats.containsKey(regionName)) {
    regionStats = rsStats.get(regionName);
  } else {
    regionStats = rsStats.putIfAbsent(regionName, new RegionStats(this.registry, name));
    if (regionStats == null) {
      regionStats = rsStats.get(regionName);
    }
  }
  regionStats.update(stats);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:33,代码来源:MetricsConnection.java

示例10: containsKey

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public boolean containsKey(K1 k1, K2 k2) {
	ConcurrentMap<K2, V> m = this.map.get(k1);
	return m == null ? false : m.containsKey(k2);
}
 
开发者ID:nextopcn,项目名称:xcalendar,代码行数:5,代码来源:ConcurrentMultiKeyMap.java

示例11: lazyInitStep

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
/**
 * Lazily initializes the internal data structure for tracking the specified
 * phase and step.  Returns either the newly initialized data structure or the
 * existing one.  Initialization is atomic, so there is no risk of lost updates
 * even if multiple threads attempt to initialize the same step simultaneously.
 * 
 * @param phase Phase to initialize
 * @param step Step to initialize
 * @return StepTracking newly initialized, or existing if found
 */
private StepTracking lazyInitStep(Phase phase, Step step) {
  ConcurrentMap<Step, StepTracking> steps = phases.get(phase).steps;
  if (!steps.containsKey(step)) {
    steps.putIfAbsent(step, new StepTracking());
  }
  return steps.get(step);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:StartupProgress.java


注:本文中的java.util.concurrent.ConcurrentMap.containsKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。