本文整理汇总了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();
}
示例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<>();
}
示例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;
}
示例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);
});
}
示例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);
}
示例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();
}
示例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)));
}
示例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);
}
}
}
示例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());
}
示例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);
});
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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")));
}
}