當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。