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


Java ConcurrentSkipListMap類代碼示例

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


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

示例1: testsForConcurrentSkipListMapNatural

import java.util.concurrent.ConcurrentSkipListMap; //導入依賴的package包/類
public Test testsForConcurrentSkipListMapNatural() {
  return NavigableMapTestSuiteBuilder.using(
          new TestStringSortedMapGenerator() {
            @Override
            protected SortedMap<String, String> create(Entry<String, String>[] entries) {
              return populate(new ConcurrentSkipListMap<String, String>(), entries);
            }
          })
      .named("ConcurrentSkipListMap, natural")
      .withFeatures(
          MapFeature.GENERAL_PURPOSE,
          CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
          CollectionFeature.KNOWN_ORDER,
          CollectionFeature.SERIALIZABLE,
          CollectionSize.ANY)
      .suppressing(suppressForConcurrentSkipListMap())
      .createTestSuite();
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:19,代碼來源:TestsForMapsInJavaUtil.java

示例2: MetricSampleAggregator

import java.util.concurrent.ConcurrentSkipListMap; //導入依賴的package包/類
/**
 * Construct the metric sample aggregator.
 *
 * @param config   The load monitor configurations.
 * @param metadata The metadata of the cluster.
 */
public MetricSampleAggregator(KafkaCruiseControlConfig config,
                              Metadata metadata,
                              MetricCompletenessChecker metricCompletenessChecker) {
  _windowedAggregatedPartitionMetrics = new ConcurrentSkipListMap<>(Comparator.reverseOrder());
  // We keep twice as many the snapshot windows.
  _numSnapshots = config.getInt(KafkaCruiseControlConfig.NUM_LOAD_SNAPSHOTS_CONFIG);
  _numSnapshotsToKeep = _numSnapshots * 2;
  _snapshotWindowMs = config.getLong(KafkaCruiseControlConfig.LOAD_SNAPSHOT_WINDOW_MS_CONFIG);
  _minSamplesPerSnapshot = config.getInt(KafkaCruiseControlConfig.MIN_SAMPLES_PER_LOAD_SNAPSHOT_CONFIG);
  _activeSnapshotWindow = -1L;
  _snapshotCollectionInProgress = new AtomicInteger(0);
  _metadata = metadata;
  _metricCompletenessChecker = metricCompletenessChecker;
  _cachedAggregationResult = null;
  _cachedAggregationResultWindow = -1L;
  _aggregationResultGeneration = new AtomicLong(0);
  _latestBrokerMetrics = new ConcurrentHashMap<>();
  _identityPartitionMap = new ConcurrentHashMap<>();
}
 
開發者ID:linkedin,項目名稱:cruise-control,代碼行數:26,代碼來源:MetricSampleAggregator.java

示例3: makeMeta

import java.util.concurrent.ConcurrentSkipListMap; //導入依賴的package包/類
/**
 * Create up a map that is keyed by meta row name and whose value is the HRegionInfo and
 * ServerName to return for this row.
 * @return Map with faked hbase:meta content in it.
 */
static SortedMap<byte [], Pair<HRegionInfo, ServerName>> makeMeta(final byte [] tableName,
    final int regionCount, final long namespaceSpan, final int serverCount) {
  // I need a comparator for meta rows so we sort properly.
  SortedMap<byte [], Pair<HRegionInfo, ServerName>> meta =
    new ConcurrentSkipListMap<byte[], Pair<HRegionInfo,ServerName>>(new MetaRowsComparator());
  HRegionInfo [] hris = makeHRegionInfos(tableName, regionCount, namespaceSpan);
  ServerName [] serverNames = makeServerNames(serverCount);
  int per = regionCount / serverCount;
  int count = 0;
  for (HRegionInfo hri: hris) {
    Pair<HRegionInfo, ServerName> p =
      new Pair<HRegionInfo, ServerName>(hri, serverNames[count++ / per]);
    meta.put(hri.getRegionName(), p);
  }
  return meta;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:22,代碼來源:TestClientNoCluster.java

示例4: validateFTableRegionMap

import java.util.concurrent.ConcurrentSkipListMap; //導入依賴的package包/類
public void validateFTableRegionMap(final String tableName) {
  MCache mCache = MCacheFactory.getAnyInstance();
  FTable ftable = mCache.getFTable(tableName);
  // check the region map and internal map
  RegionMap regionMap =
      ((LocalRegion) ((ProxyFTableRegion) ftable).getTableRegion()).getRegionMap();
  assertNotNull(regionMap);
  assertTrue(regionMap instanceof RowTupleLRURegionMap);
  Set<BucketRegion> allLocalBucketRegions =
      ((PartitionedRegion) ((ProxyFTableRegion) ftable).getTableRegion()).getDataStore()
          .getAllLocalBucketRegions();
  allLocalBucketRegions.forEach((BR) -> {
    assertTrue(BR.entries instanceof RowTupleLRURegionMap);
    assertTrue(BR.entries.getInternalMap() instanceof RowTupleConcurrentSkipListMap);
    assertTrue(((RowTupleConcurrentSkipListMap) BR.entries.getInternalMap())
        .getInternalMap() instanceof ConcurrentSkipListMap);
  });
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:19,代碼來源:AmpoolRegionMapFactoryDUnitTest.java

示例5: initScheduler

import java.util.concurrent.ConcurrentSkipListMap; //導入依賴的package包/類
private synchronized void initScheduler(Configuration conf) {
  validateConf(conf);
  //Use ConcurrentSkipListMap because applications need to be ordered
  this.applications =
      new ConcurrentSkipListMap<ApplicationId, SchedulerApplication<FiCaSchedulerApp>>();
  this.minimumAllocation =
      Resources.createResource(conf.getInt(
          YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB,
          YarnConfiguration.DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_MB));
  initMaximumResourceCapability(
      Resources.createResource(conf.getInt(
          YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
          YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB),
        conf.getInt(
          YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
          YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES),
        conf.getInt(
          YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_GCORES,
          YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_GCORES)));
  this.usePortForNodeName = conf.getBoolean(
      YarnConfiguration.RM_SCHEDULER_INCLUDE_PORT_IN_NODE_NAME,
      YarnConfiguration.DEFAULT_RM_SCHEDULER_USE_PORT_FOR_NODE_NAME);
  this.metrics = QueueMetrics.forQueue(DEFAULT_QUEUE_NAME, null, false,
      conf);
  this.activeUsersManager = new ActiveUsersManager(metrics);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:27,代碼來源:FifoScheduler.java

示例6: setCases

import java.util.concurrent.ConcurrentSkipListMap; //導入依賴的package包/類
@DataProvider(name="setProvider", parallel=true)
public static Iterator<Object[]> setCases() {
    final List<Object[]> cases = new LinkedList<>();
    cases.add(new Object[] { new HashSet<>() });
    cases.add(new Object[] { new LinkedHashSet<>() });
    cases.add(new Object[] { new TreeSet<>() });
    cases.add(new Object[] { new java.util.concurrent.ConcurrentSkipListSet<>() });
    cases.add(new Object[] { new java.util.concurrent.CopyOnWriteArraySet<>() });

    cases.add(new Object[] { new ExtendsAbstractSet<>() });

    cases.add(new Object[] { Collections.newSetFromMap(new HashMap<>()) });
    cases.add(new Object[] { Collections.newSetFromMap(new LinkedHashMap<>()) });
    cases.add(new Object[] { Collections.newSetFromMap(new TreeMap<>()) });
    cases.add(new Object[] { Collections.newSetFromMap(new ConcurrentHashMap<>()) });
    cases.add(new Object[] { Collections.newSetFromMap(new ConcurrentSkipListMap<>()) });

    cases.add(new Object[] { new HashSet<Integer>(){{add(42);}} });
    cases.add(new Object[] { new ExtendsAbstractSet<Integer>(){{add(42);}} });
    cases.add(new Object[] { new LinkedHashSet<Integer>(){{add(42);}} });
    cases.add(new Object[] { new TreeSet<Integer>(){{add(42);}} });
    return cases.iterator();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:24,代碼來源:CollectionDefaults.java

示例7: testSimpleGroupBy

import java.util.concurrent.ConcurrentSkipListMap; //導入依賴的package包/類
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class)
public void testSimpleGroupBy(String name, TestData.OfRef<Integer> data) throws ReflectiveOperationException {
    Function<Integer, Integer> classifier = i -> i % 3;

    // Single-level groupBy
    exerciseMapTabulation(data, groupingBy(classifier),
                          new GroupedMapAssertion<>(classifier, HashMap.class,
                                                    new ListAssertion<>()));
    exerciseMapTabulation(data, groupingByConcurrent(classifier),
                          new GroupedMapAssertion<>(classifier, ConcurrentHashMap.class,
                                                    new ListAssertion<>()));

    // With explicit constructors
    exerciseMapTabulation(data,
                          groupingBy(classifier, TreeMap::new, toCollection(HashSet::new)),
                          new GroupedMapAssertion<>(classifier, TreeMap.class,
                                                    new CollectionAssertion<Integer>(HashSet.class, false)));
    exerciseMapTabulation(data,
                          groupingByConcurrent(classifier, ConcurrentSkipListMap::new,
                                               toCollection(HashSet::new)),
                          new GroupedMapAssertion<>(classifier, ConcurrentSkipListMap.class,
                                                    new CollectionAssertion<Integer>(HashSet.class, false)));
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:24,代碼來源:TabulatorsTest.java

示例8: realMain

import java.util.concurrent.ConcurrentSkipListMap; //導入依賴的package包/類
private static void realMain(String[] args) throws Throwable {
    Map<Integer, Long>[] maps = (Map<Integer, Long>[]) new Map[]{
                new HashMap<>(),
                new Hashtable<>(),
                new IdentityHashMap<>(),
                new LinkedHashMap<>(),
                new TreeMap<>(),
                new WeakHashMap<>(),
                new ConcurrentHashMap<>(),
                new ConcurrentSkipListMap<>()
            };

    // for each map type.
    for (Map<Integer, Long> map : maps) {
         try {
            testMap(map);
         } catch(Exception all) {
            unexpected("Failed for " + map.getClass().getName(), all);
         }
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:22,代碼來源:ToArray.java

示例9: goodChoicesFor

import java.util.concurrent.ConcurrentSkipListMap; //導入依賴的package包/類
private Collection<Choice> goodChoicesFor(Board board, Goal goal) {
  return board
      .availableChoices()
      .sorted(goal.choiceComparator())
      .reduce(
          new ConcurrentSkipListMap<Double, Choice>(goal.comparator()),
          (diffMap, choice) -> {
            diffMap.put(board.boardScore() - board.choose(choice).boardScore(), choice);
            return diffMap;
          },
          (m1, m2) -> m1)
      .values()
      .stream()
      .limit(3)
      .collect(toImmutableList());
}
 
開發者ID:sudhirj,項目名稱:switchboard,代碼行數:17,代碼來源:UnreasonablyOptimisticPlayer.java

示例10: maps

import java.util.concurrent.ConcurrentSkipListMap; //導入依賴的package包/類
@Test
public void maps() {
    test(new TreeMap<>(), NonComparable::new,
         (m, e) -> {
             assertEquals(m.size(), 0);
             assertTrue(e instanceof ClassCastException);
         });
    test(new TreeMap<>(), AComparable::new,
         (m, e) -> {
             assertEquals(m.size(), 1);
             assertTrue(e == null);
         });

    test(new ConcurrentSkipListMap<>(), NonComparable::new,
         (s, e) -> {
             assertEquals(s.size(), 0);
             assertTrue(e instanceof ClassCastException);
         });
    test(new ConcurrentSkipListMap<>(), AComparable::new,
         (s, e) -> {
             assertEquals(s.size(), 1);
             assertTrue(e == null);
         });
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:AddNonComparable.java

示例11: testRecursiveSubMaps

import java.util.concurrent.ConcurrentSkipListMap; //導入依賴的package包/類
/**
 * Submaps of submaps subdivide correctly
 */
public void testRecursiveSubMaps() throws Exception {
    int mapSize = expensiveTests ? 1000 : 100;
    Class cl = ConcurrentSkipListMap.class;
    NavigableMap<Integer, Integer> map = newMap(cl);
    bs = new BitSet(mapSize);

    populate(map, mapSize);
    check(map,                 0, mapSize - 1, true);
    check(map.descendingMap(), 0, mapSize - 1, false);

    mutateMap(map, 0, mapSize - 1);
    check(map,                 0, mapSize - 1, true);
    check(map.descendingMap(), 0, mapSize - 1, false);

    bashSubMap(map.subMap(0, true, mapSize, false),
               0, mapSize - 1, true);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:ConcurrentSkipListMapTest.java

示例12: testKeySetOrder

import java.util.concurrent.ConcurrentSkipListMap; //導入依賴的package包/類
/**
 * keySet is ordered
 */
public void testKeySetOrder() {
    ConcurrentSkipListMap map = map5();
    Set s = map.keySet();
    Iterator i = s.iterator();
    Integer last = (Integer)i.next();
    assertEquals(last, one);
    int count = 1;
    while (i.hasNext()) {
        Integer k = (Integer)i.next();
        assertTrue(last.compareTo(k) < 0);
        last = k;
        ++count;
    }
    assertEquals(5, count);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:ConcurrentSkipListMapTest.java

示例13: testKeySetDescendingIteratorOrder

import java.util.concurrent.ConcurrentSkipListMap; //導入依賴的package包/類
/**
 * descending iterator of key set is inverse ordered
 */
public void testKeySetDescendingIteratorOrder() {
    ConcurrentSkipListMap map = map5();
    NavigableSet s = map.navigableKeySet();
    Iterator i = s.descendingIterator();
    Integer last = (Integer)i.next();
    assertEquals(last, five);
    int count = 1;
    while (i.hasNext()) {
        Integer k = (Integer)i.next();
        assertTrue(last.compareTo(k) > 0);
        last = k;
        ++count;
    }
    assertEquals(5, count);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:ConcurrentSkipListMapTest.java

示例14: testDescendingKeySetOrder

import java.util.concurrent.ConcurrentSkipListMap; //導入依賴的package包/類
/**
 * descendingKeySet is ordered
 */
public void testDescendingKeySetOrder() {
    ConcurrentSkipListMap map = map5();
    Set s = map.descendingKeySet();
    Iterator i = s.iterator();
    Integer last = (Integer)i.next();
    assertEquals(last, five);
    int count = 1;
    while (i.hasNext()) {
        Integer k = (Integer)i.next();
        assertTrue(last.compareTo(k) > 0);
        last = k;
        ++count;
    }
    assertEquals(5, count);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:ConcurrentSkipListMapTest.java

示例15: testEntrySet

import java.util.concurrent.ConcurrentSkipListMap; //導入依賴的package包/類
/**
 * entrySet contains all pairs
 */
public void testEntrySet() {
    ConcurrentSkipListMap map = map5();
    Set s = map.entrySet();
    assertEquals(5, s.size());
    Iterator it = s.iterator();
    while (it.hasNext()) {
        Map.Entry e = (Map.Entry) it.next();
        assertTrue(
                   (e.getKey().equals(one) && e.getValue().equals("A")) ||
                   (e.getKey().equals(two) && e.getValue().equals("B")) ||
                   (e.getKey().equals(three) && e.getValue().equals("C")) ||
                   (e.getKey().equals(four) && e.getValue().equals("D")) ||
                   (e.getKey().equals(five) && e.getValue().equals("E")));
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:ConcurrentSkipListMapTest.java


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