Java Code Examples for java.util.concurrent.ConcurrentSkipListSet#add()
The following examples show how to use
java.util.concurrent.ConcurrentSkipListSet#add() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BuildJobSubmitter.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
void addToJobTrackList(SegmentJobBuildInfo segmentBuildJob) { ConcurrentSkipListSet<SegmentJobBuildInfo> buildInfos = segmentBuildJobCheckList.get(segmentBuildJob.cubeName); if (buildInfos == null) { buildInfos = new ConcurrentSkipListSet<>(); ConcurrentSkipListSet<SegmentJobBuildInfo> previousValue = segmentBuildJobCheckList .putIfAbsent(segmentBuildJob.cubeName, buildInfos); if (previousValue != null) { buildInfos = previousValue; } } logger.trace("Add job {} of segment [{} - {}] to track.", segmentBuildJob.jobID, segmentBuildJob.cubeName, segmentBuildJob.segmentName); boolean addSucceed = buildInfos.add(segmentBuildJob); if (!addSucceed) { logger.debug("Add {} failed because we have a duplicated one.", segmentBuildJob); buildInfos.remove(segmentBuildJob); buildInfos.add(segmentBuildJob); } }
Example 2
Source File: SkipListMemIndex.java From sasi with Apache License 2.0 | 6 votes |
@Override public void add(ByteBuffer value, ByteBuffer key) { final DecoratedKey dk = StorageService.getPartitioner().decorateKey(key); ConcurrentSkipListSet<DecoratedKey> keys = index.get(value); if (keys == null) { ConcurrentSkipListSet<DecoratedKey> newKeys = new ConcurrentSkipListSet<>(DecoratedKey.comparator); keys = index.putIfAbsent(value, newKeys); if (keys == null) keys = newKeys; } keys.add(dk); }
Example 3
Source File: ConcurrentSkipListSetTest.java From j2objc with Apache License 2.0 | 6 votes |
/** * iterator.remove removes current element */ public void testIteratorRemove() { final ConcurrentSkipListSet q = new ConcurrentSkipListSet(); q.add(new Integer(2)); q.add(new Integer(1)); q.add(new Integer(3)); Iterator it = q.iterator(); it.next(); it.remove(); it = q.iterator(); assertEquals(it.next(), new Integer(2)); assertEquals(it.next(), new Integer(3)); assertFalse(it.hasNext()); }
Example 4
Source File: InMemoryBucketStore.java From pravega with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<Void> addStreamToBucketStore(ServiceType serviceType, String scope, String stream, Executor executor) { int bucketCount = bucketCountMap.get(serviceType); int bucket = BucketStore.getBucket(scope, stream, bucketCount); String bucketName = getBucketName(serviceType, bucket); ConcurrentSkipListSet<String> set = bucketedStreams.compute(bucketName, (x, y) -> { if (y == null) { return new ConcurrentSkipListSet<>(); } else { return y; } }); String scopedStreamName = BucketStore.getScopedStreamName(scope, stream); set.add(scopedStreamName); listeners.computeIfPresent(bucketName, (b, listener) -> { listener.notify(scope, stream, true); return listener; }); return CompletableFuture.completedFuture(null); }
Example 5
Source File: BuildJobSubmitter.java From kylin with Apache License 2.0 | 6 votes |
void addToJobTrackList(SegmentJobBuildInfo segmentBuildJob) { ConcurrentSkipListSet<SegmentJobBuildInfo> buildInfos = segmentBuildJobCheckList.get(segmentBuildJob.cubeName); if (buildInfos == null) { buildInfos = new ConcurrentSkipListSet<>(); ConcurrentSkipListSet<SegmentJobBuildInfo> previousValue = segmentBuildJobCheckList .putIfAbsent(segmentBuildJob.cubeName, buildInfos); if (previousValue != null) { buildInfos = previousValue; } } logger.trace("Add job {} of segment [{} - {}] to track.", segmentBuildJob.jobID, segmentBuildJob.cubeName, segmentBuildJob.segmentName); boolean addSucceed = buildInfos.add(segmentBuildJob); if (!addSucceed) { logger.debug("Add {} failed because we have a duplicated one.", segmentBuildJob); buildInfos.remove(segmentBuildJob); buildInfos.add(segmentBuildJob); } }
Example 6
Source File: ConcurrentSkipListSetTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * Returns a new set of first 5 ints. */ private ConcurrentSkipListSet set5() { ConcurrentSkipListSet q = new ConcurrentSkipListSet(); assertTrue(q.isEmpty()); q.add(one); q.add(two); q.add(three); q.add(four); q.add(five); assertEquals(5, q.size()); return q; }
Example 7
Source File: ConcurrentSkipListSetTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * clear removes all elements */ public void testClear() { ConcurrentSkipListSet q = populatedSet(SIZE); q.clear(); assertTrue(q.isEmpty()); assertEquals(0, q.size()); q.add(new Integer(1)); assertFalse(q.isEmpty()); q.clear(); assertTrue(q.isEmpty()); }
Example 8
Source File: ConcurrentSkipListSetTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * Add of non-Comparable throws CCE */ public void testAddNonComparable() { ConcurrentSkipListSet q = new ConcurrentSkipListSet(); try { q.add(new Object()); q.add(new Object()); shouldThrow(); } catch (ClassCastException success) {} }
Example 9
Source File: ConcurrentSkipListSetTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * size changes when elements added and removed */ public void testSize() { ConcurrentSkipListSet q = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(SIZE - i, q.size()); q.pollFirst(); } for (int i = 0; i < SIZE; ++i) { assertEquals(i, q.size()); q.add(new Integer(i)); } }
Example 10
Source File: ConcurrentSkipListSetTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * add(null) throws NPE */ public void testAddNull() { ConcurrentSkipListSet q = new ConcurrentSkipListSet(); try { q.add(null); shouldThrow(); } catch (NullPointerException success) {} }
Example 11
Source File: ConcurrentSkipListSetTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * add(null) throws NPE */ public void testAddNull() { ConcurrentSkipListSet q = new ConcurrentSkipListSet(); try { q.add(null); shouldThrow(); } catch (NullPointerException success) {} }
Example 12
Source File: ConcurrentSkipListSetTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * clear removes all elements */ public void testClear() { ConcurrentSkipListSet q = populatedSet(SIZE); q.clear(); assertTrue(q.isEmpty()); assertEquals(0, q.size()); q.add(new Integer(1)); assertFalse(q.isEmpty()); q.clear(); assertTrue(q.isEmpty()); }
Example 13
Source File: ConcurrentSkipListSetTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * containsAll(c) is true when c contains a subset of elements */ public void testContainsAll() { ConcurrentSkipListSet q = populatedSet(SIZE); ConcurrentSkipListSet p = new ConcurrentSkipListSet(); for (int i = 0; i < SIZE; ++i) { assertTrue(q.containsAll(p)); assertFalse(p.containsAll(q)); p.add(new Integer(i)); } assertTrue(p.containsAll(q)); }
Example 14
Source File: ConcurrentSkipListSubSetTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Returns a new set of first 5 ints. */ private NavigableSet set5() { ConcurrentSkipListSet q = new ConcurrentSkipListSet(); assertTrue(q.isEmpty()); q.add(one); q.add(two); q.add(three); q.add(four); q.add(five); q.add(zero); q.add(seven); NavigableSet s = q.subSet(one, true, seven, false); assertEquals(5, s.size()); return s; }
Example 15
Source File: ConcurrentSkipListSetTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * isEmpty is true before add, false after */ public void testEmpty() { ConcurrentSkipListSet q = new ConcurrentSkipListSet(); assertTrue(q.isEmpty()); q.add(new Integer(1)); assertFalse(q.isEmpty()); q.add(new Integer(2)); q.pollFirst(); q.pollFirst(); assertTrue(q.isEmpty()); }
Example 16
Source File: ConstantContainer.java From FuzzDroid with Apache License 2.0 | 5 votes |
public void insertTmpValue(String className, Object value) { ConcurrentSkipListSet<Object> constantSet = null; if (tmpSetMap.containsKey(className)) { constantSet = tmpSetMap.get(className); } else { constantSet = new ConcurrentSkipListSet<Object>(); tmpSetMap.put(className, constantSet); } constantSet.add(value); allValuesSet.add(value); isEmpty = false; }
Example 17
Source File: Coordinator.java From kylin with Apache License 2.0 | 5 votes |
public void addSegmentBuildJob(SegmentJobBuildInfo segmentBuildJob) { ConcurrentSkipListSet<SegmentJobBuildInfo> buildInfos = segmentBuildJobMap.get(segmentBuildJob.cubeName); if (buildInfos == null) { buildInfos = new ConcurrentSkipListSet<>(); ConcurrentSkipListSet<SegmentJobBuildInfo> previousValue = segmentBuildJobMap .putIfAbsent(segmentBuildJob.cubeName, buildInfos); if (previousValue != null) { buildInfos = previousValue; } } buildInfos.add(segmentBuildJob); }
Example 18
Source File: ConcurrentSkipListSubSetTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * Returns a new set of first 5 ints. */ private NavigableSet set5() { ConcurrentSkipListSet q = new ConcurrentSkipListSet(); assertTrue(q.isEmpty()); q.add(one); q.add(two); q.add(three); q.add(four); q.add(five); q.add(zero); q.add(seven); NavigableSet s = q.subSet(one, true, seven, false); assertEquals(5, s.size()); return s; }
Example 19
Source File: SortedListForAsyncQueueJUnitTest.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
public void testIfTheKeyToSeqNumIsKeptSortedWithoutConflation() throws Exception { byte[] k1 = new byte[] { 1}; byte[] k2 = new byte[] { 2}; byte[] k3 = new byte[] { 3}; byte[] k4 = new byte[] { 4}; KeyToSeqNumObject keyToSeq1 = new KeyToSeqNumObject(k1, new Long(2)); KeyToSeqNumObject keyToSeq2 = new KeyToSeqNumObject(k1, new Long(5)); KeyToSeqNumObject keyToSeq3 = new KeyToSeqNumObject(k1, new Long(8)); KeyToSeqNumObject keyToSeq4 = new KeyToSeqNumObject(k2, new Long(3)); KeyToSeqNumObject keyToSeq5 = new KeyToSeqNumObject(k2, new Long(7)); ConcurrentSkipListSet<KeyToSeqNumObject> list = new ConcurrentSkipListSet<HDFSBucketRegionQueue.KeyToSeqNumObject>(); list.add(keyToSeq4); list.add(keyToSeq3); list.add(keyToSeq5); list.add(keyToSeq1); list.add(keyToSeq2); list.add(keyToSeq5); KeyToSeqNumObject k = list.pollFirst(); this.c.getLoggerI18n().fine(" KeyToSeqNumObject byte: " + k.getRegionkey()[0] + " seq num: " + k.getSeqNum()); assertTrue ("Order of elements in Concurrent list is not correct ", k.equals(keyToSeq3)); list.remove(k); k = list.pollFirst(); this.c.getLoggerI18n().fine(" KeyToSeqNumObject byte: " + k.getRegionkey()[0] + " seq num: " + k.getSeqNum()); assertTrue ("Order of elements in Concurrent list is not correct ", k.equals(keyToSeq2)); list.remove(k); k = list.pollFirst(); this.c.getLoggerI18n().fine(" KeyToSeqNumObject byte: " + k.getRegionkey()[0] + " seq num: " + k.getSeqNum()); assertTrue ("Order of elements in Concurrent list is not correct ", k.equals(keyToSeq1)); list.remove(k); list.add(keyToSeq4); list.add(keyToSeq3); list.add(keyToSeq5); list.add(keyToSeq1); k = list.pollFirst(); this.c.getLoggerI18n().fine(" KeyToSeqNumObject byte: " + k.getRegionkey()[0] + " seq num: " + k.getSeqNum()); assertTrue ("Order of elements in Concurrent list is not correct ", k.equals(keyToSeq3)); list.remove(k); k = list.pollFirst(); this.c.getLoggerI18n().fine(" KeyToSeqNumObject byte: " + k.getRegionkey()[0] + " seq num: " + k.getSeqNum()); assertTrue ("Order of elements in Concurrent list is not correct ", k.equals(keyToSeq1)); list.remove(k); k = list.pollFirst(); this.c.getLoggerI18n().fine(" KeyToSeqNumObject byte: " + k.getRegionkey()[0] + " seq num: " + k.getSeqNum()); assertTrue ("Order of elements in Concurrent list is not correct ", k.equals(keyToSeq5)); list.remove(k); k = list.pollFirst(); this.c.getLoggerI18n().fine(" KeyToSeqNumObject byte: " + k.getRegionkey()[0] + " seq num: " + k.getSeqNum()); assertTrue ("Order of elements in Concurrent list is not correct ", k.equals(keyToSeq4)); list.remove(k); }
Example 20
Source File: SortedListForAsyncQueueJUnitTest.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
public void testIfTheKeyToSeqNumIsKeptSortedWithoutConflation() throws Exception { byte[] k1 = new byte[] { 1}; byte[] k2 = new byte[] { 2}; byte[] k3 = new byte[] { 3}; byte[] k4 = new byte[] { 4}; KeyToSeqNumObject keyToSeq1 = new KeyToSeqNumObject(k1, new Long(2)); KeyToSeqNumObject keyToSeq2 = new KeyToSeqNumObject(k1, new Long(5)); KeyToSeqNumObject keyToSeq3 = new KeyToSeqNumObject(k1, new Long(8)); KeyToSeqNumObject keyToSeq4 = new KeyToSeqNumObject(k2, new Long(3)); KeyToSeqNumObject keyToSeq5 = new KeyToSeqNumObject(k2, new Long(7)); ConcurrentSkipListSet<KeyToSeqNumObject> list = new ConcurrentSkipListSet<HDFSBucketRegionQueue.KeyToSeqNumObject>(); list.add(keyToSeq4); list.add(keyToSeq3); list.add(keyToSeq5); list.add(keyToSeq1); list.add(keyToSeq2); list.add(keyToSeq5); KeyToSeqNumObject k = list.pollFirst(); this.c.getLoggerI18n().fine(" KeyToSeqNumObject byte: " + k.getRegionkey()[0] + " seq num: " + k.getSeqNum()); assertTrue ("Order of elements in Concurrent list is not correct ", k.equals(keyToSeq3)); list.remove(k); k = list.pollFirst(); this.c.getLoggerI18n().fine(" KeyToSeqNumObject byte: " + k.getRegionkey()[0] + " seq num: " + k.getSeqNum()); assertTrue ("Order of elements in Concurrent list is not correct ", k.equals(keyToSeq2)); list.remove(k); k = list.pollFirst(); this.c.getLoggerI18n().fine(" KeyToSeqNumObject byte: " + k.getRegionkey()[0] + " seq num: " + k.getSeqNum()); assertTrue ("Order of elements in Concurrent list is not correct ", k.equals(keyToSeq1)); list.remove(k); list.add(keyToSeq4); list.add(keyToSeq3); list.add(keyToSeq5); list.add(keyToSeq1); k = list.pollFirst(); this.c.getLoggerI18n().fine(" KeyToSeqNumObject byte: " + k.getRegionkey()[0] + " seq num: " + k.getSeqNum()); assertTrue ("Order of elements in Concurrent list is not correct ", k.equals(keyToSeq3)); list.remove(k); k = list.pollFirst(); this.c.getLoggerI18n().fine(" KeyToSeqNumObject byte: " + k.getRegionkey()[0] + " seq num: " + k.getSeqNum()); assertTrue ("Order of elements in Concurrent list is not correct ", k.equals(keyToSeq1)); list.remove(k); k = list.pollFirst(); this.c.getLoggerI18n().fine(" KeyToSeqNumObject byte: " + k.getRegionkey()[0] + " seq num: " + k.getSeqNum()); assertTrue ("Order of elements in Concurrent list is not correct ", k.equals(keyToSeq5)); list.remove(k); k = list.pollFirst(); this.c.getLoggerI18n().fine(" KeyToSeqNumObject byte: " + k.getRegionkey()[0] + " seq num: " + k.getSeqNum()); assertTrue ("Order of elements in Concurrent list is not correct ", k.equals(keyToSeq4)); list.remove(k); }