java.util.concurrent.ConcurrentNavigableMap Java Examples
The following examples show how to use
java.util.concurrent.ConcurrentNavigableMap.
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: AdapterImplementations.java From sling-org-apache-sling-models-impl with Apache License 2.0 | 6 votes |
/** * @param adapterType the type to check * @return {@code true} in case the given type is a model (may be with a different adapter class) */ @SuppressWarnings("unchecked") public <ModelType> boolean isModelClass(Class<ModelType> adapterType) { String key = adapterType.getName(); // lookup in cache for models without adapter classes ModelClass<ModelType> modelClass = (ModelClass<ModelType>)modelClasses.get(key); if (modelClass!=null) { return true; } // not found? look in cache with adapter classes ConcurrentNavigableMap<String,ModelClass<?>> implementations = adapterImplementations.get(key); if (implementations==null || implementations.isEmpty()) { return false; } return true; }
Example #2
Source File: ConcurrentSkipListSubMapTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void testSubMapContents2() { ConcurrentNavigableMap map = map5(); SortedMap sm = map.subMap(two, three); assertEquals(1, sm.size()); assertEquals(two, sm.firstKey()); assertEquals(two, sm.lastKey()); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertFalse(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); Iterator i = sm.keySet().iterator(); Object k; k = (Integer)(i.next()); assertEquals(two, k); assertFalse(i.hasNext()); Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(two)); assertEquals(4, map.size()); assertEquals(0, sm.size()); assertTrue(sm.isEmpty()); assertSame(sm.remove(three), null); assertEquals(4, map.size()); }
Example #3
Source File: DeltaStoreBasedWaveletState.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
private static void readDeltasInRange(WaveletDeltaRecordReader reader, ConcurrentNavigableMap<HashedVersion, WaveletDeltaRecord> cachedDeltas, HashedVersion startVersion, HashedVersion endVersion, Receiver<WaveletDeltaRecord> receiver) throws IOException { WaveletDeltaRecord delta = getDelta(reader, cachedDeltas, startVersion); Preconditions.checkArgument(delta != null && delta.getAppliedAtVersion().equals(startVersion), "invalid start version"); for (;;) { if (!receiver.put(delta)) { return; } if (delta.getResultingVersion().getVersion() >= endVersion.getVersion()) { break; } delta = getDelta(reader, cachedDeltas, delta.getResultingVersion()); if (delta == null) { break; } } Preconditions.checkArgument(delta != null && delta.getResultingVersion().equals(endVersion), "invalid end version"); }
Example #4
Source File: ConcurrentSkipListSubMapJUnitTest.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public void testSubMapContents2() { ConcurrentNavigableMap map = map5(); SortedMap sm = map.subMap(two, three); assertEquals(1, sm.size()); assertEquals(two, sm.firstKey()); assertEquals(two, sm.lastKey()); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertFalse(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); Iterator i = sm.keySet().iterator(); Object k; k = (Integer)(i.next()); assertEquals(two, k); assertFalse(i.hasNext()); Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(two)); assertEquals(4, map.size()); assertEquals(0, sm.size()); assertTrue(sm.isEmpty()); assertSame(sm.remove(three), null); assertEquals(4, map.size()); }
Example #5
Source File: ConcurrentSkipListSubMapTest.java From j2objc with Apache License 2.0 | 6 votes |
/** * pollFirstEntry returns entries in order */ public void testDescendingPollFirstEntry() { ConcurrentNavigableMap map = dmap5(); Map.Entry e = map.pollFirstEntry(); assertEquals(m1, e.getKey()); assertEquals("A", e.getValue()); e = map.pollFirstEntry(); assertEquals(m2, e.getKey()); map.put(m1, "A"); e = map.pollFirstEntry(); assertEquals(m1, e.getKey()); assertEquals("A", e.getValue()); e = map.pollFirstEntry(); assertEquals(m3, e.getKey()); map.remove(m4); e = map.pollFirstEntry(); assertEquals(m5, e.getKey()); try { e.setValue("A"); shouldThrow(); } catch (UnsupportedOperationException success) {} e = map.pollFirstEntry(); assertNull(e); }
Example #6
Source File: ConcurrentSkipListSubMapJUnitTest.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public void testSubMapContents2() { ConcurrentNavigableMap map = map5(); SortedMap sm = map.subMap(two, three); assertEquals(1, sm.size()); assertEquals(two, sm.firstKey()); assertEquals(two, sm.lastKey()); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertFalse(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); Iterator i = sm.keySet().iterator(); Object k; k = (Integer)(i.next()); assertEquals(two, k); assertFalse(i.hasNext()); Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(two)); assertEquals(4, map.size()); assertEquals(0, sm.size()); assertTrue(sm.isEmpty()); assertSame(sm.remove(three), null); assertEquals(4, map.size()); }
Example #7
Source File: ConcurrentSkipListSubMapTest.java From j2objc with Apache License 2.0 | 6 votes |
/** * pollLastEntry returns entries in order */ public void testDescendingPollLastEntry() { ConcurrentNavigableMap map = dmap5(); Map.Entry e = map.pollLastEntry(); assertEquals(m5, e.getKey()); assertEquals("E", e.getValue()); e = map.pollLastEntry(); assertEquals(m4, e.getKey()); map.put(m5, "E"); e = map.pollLastEntry(); assertEquals(m5, e.getKey()); assertEquals("E", e.getValue()); e = map.pollLastEntry(); assertEquals(m3, e.getKey()); map.remove(m2); e = map.pollLastEntry(); assertEquals(m1, e.getKey()); try { e.setValue("E"); shouldThrow(); } catch (UnsupportedOperationException success) {} e = map.pollLastEntry(); assertNull(e); }
Example #8
Source File: Log.java From ambry with Apache License 2.0 | 6 votes |
/** * Sets the active segment in the log. * </p> * Frees all segments that follow the active segment. Therefore, this should be * used only after the active segment is conclusively determined. * @param name the name of the log segment that is to be marked active. * @throws IllegalArgumentException if there no segment with name {@code name}. * @throws StoreException if there is any store exception while freeing segments. */ void setActiveSegment(String name) throws StoreException { if (!segmentsByName.containsKey(name)) { throw new IllegalArgumentException("There is no log segment with name: " + name); } ConcurrentNavigableMap<String, LogSegment> extraSegments = segmentsByName.tailMap(name, false); Iterator<Map.Entry<String, LogSegment>> iterator = extraSegments.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<String, LogSegment> entry = iterator.next(); logger.info("Freeing extra segment with name [{}] ", entry.getValue().getName()); free(entry.getValue(), false); remainingUnallocatedSegments.getAndIncrement(); iterator.remove(); } logger.info("Setting active segment to [{}]", name); LogSegment newActiveSegment = segmentsByName.get(name); if (newActiveSegment != activeSegment) { // If activeSegment needs to be changed, then drop buffer for old activeSegment and init buffer for new activeSegment. activeSegment.dropBufferForAppend(); activeSegment = newActiveSegment; activeSegment.initBufferForAppend(); } }
Example #9
Source File: ConcurrentSkipListSubMapJUnitTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * higherEntry returns next entry. */ public void testHigherEntry() { ConcurrentNavigableMap map = map5(); Map.Entry e1 = map.higherEntry(three); assertEquals(four, e1.getKey()); Map.Entry e2 = map.higherEntry(zero); assertEquals(one, e2.getKey()); Map.Entry e3 = map.higherEntry(five); assertNull(e3); Map.Entry e4 = map.higherEntry(six); assertNull(e4); }
Example #10
Source File: ConcurrentSkipListSubMapJUnitTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * replace(null, x) throws NPE */ public void testReplace_NullPointerException() { try { ConcurrentNavigableMap c = map5(); c.replace(null, "whatever"); shouldThrow(); } catch (NullPointerException success) {} }
Example #11
Source File: ConcurrentSkipListSubMapTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * replace(null, x) throws NPE */ public void testReplace_NullPointerException() { try { ConcurrentNavigableMap c = map5(); c.replace(null, "whatever"); shouldThrow(); } catch (NullPointerException success) {} }
Example #12
Source File: ConcurrentSkipListSubMapTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * descendingkeySet.toArray returns contains all keys */ public void testDescendingKeySetToArray() { ConcurrentNavigableMap map = map5(); Set s = map.descendingKeySet(); Object[] ar = s.toArray(); assertEquals(5, ar.length); assertTrue(s.containsAll(Arrays.asList(ar))); ar[0] = m10; assertFalse(s.containsAll(Arrays.asList(ar))); }
Example #13
Source File: ConcurrentSkipListSubMapTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * keySet.toArray returns contains all keys */ public void testKeySetToArray() { ConcurrentNavigableMap map = map5(); Set s = map.keySet(); Object[] ar = s.toArray(); assertTrue(s.containsAll(Arrays.asList(ar))); assertEquals(5, ar.length); ar[0] = m10; assertFalse(s.containsAll(Arrays.asList(ar))); }
Example #14
Source File: ConcurrentSkipListSubMapTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Maps with same contents are equal */ public void testEquals() { ConcurrentNavigableMap map1 = map5(); ConcurrentNavigableMap map2 = map5(); assertEquals(map1, map2); assertEquals(map2, map1); map1.clear(); assertFalse(map1.equals(map2)); assertFalse(map2.equals(map1)); }
Example #15
Source File: ConcurrentSkipListSubMapTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * isEmpty is true of empty map and false for non-empty */ public void testIsEmpty() { ConcurrentNavigableMap empty = map0(); ConcurrentNavigableMap map = map5(); assertTrue(empty.isEmpty()); assertFalse(map.isEmpty()); }
Example #16
Source File: ConcurrentSkipListSubMapTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * remove(key,value) removes only if pair present */ public void testDescendingRemove2() { ConcurrentNavigableMap map = dmap5(); assertTrue(map.containsKey(m5)); assertEquals("E", map.get(m5)); map.remove(m5, "E"); assertEquals(4, map.size()); assertFalse(map.containsKey(m5)); map.remove(m4, "A"); assertEquals(4, map.size()); assertTrue(map.containsKey(m4)); }
Example #17
Source File: ConcurrentSkipListSubMapTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * keySet.toArray returns contains all keys */ public void testKeySetToArray() { ConcurrentNavigableMap map = map5(); Set s = map.keySet(); Object[] ar = s.toArray(); assertTrue(s.containsAll(Arrays.asList(ar))); assertEquals(5, ar.length); ar[0] = m10; assertFalse(s.containsAll(Arrays.asList(ar))); }
Example #18
Source File: ConcurrentSkipListSubMapTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * subMap returns map with keys in requested range */ public void testDescendingSubMapContents() { ConcurrentNavigableMap map = dmap5(); SortedMap sm = map.subMap(m2, m4); assertEquals(m2, sm.firstKey()); assertEquals(m3, sm.lastKey()); assertEquals(2, sm.size()); assertFalse(sm.containsKey(m1)); assertTrue(sm.containsKey(m2)); assertTrue(sm.containsKey(m3)); assertFalse(sm.containsKey(m4)); assertFalse(sm.containsKey(m5)); Iterator i = sm.keySet().iterator(); Object k; k = (Integer)(i.next()); assertEquals(m2, k); k = (Integer)(i.next()); assertEquals(m3, k); assertFalse(i.hasNext()); Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(m2)); assertEquals(4, map.size()); assertEquals(1, sm.size()); assertEquals(m3, sm.firstKey()); assertEquals(m3, sm.lastKey()); assertEquals("C", sm.remove(m3)); assertTrue(sm.isEmpty()); assertEquals(3, map.size()); }
Example #19
Source File: ConcurrentSkipListSubMapTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * ceilingEntry returns next entry. */ public void testCeilingEntry() { ConcurrentNavigableMap map = map5(); Map.Entry e1 = map.ceilingEntry(three); assertEquals(three, e1.getKey()); Map.Entry e2 = map.ceilingEntry(zero); assertEquals(one, e2.getKey()); Map.Entry e3 = map.ceilingEntry(five); assertEquals(five, e3.getKey()); Map.Entry e4 = map.ceilingEntry(six); assertNull(e4); }
Example #20
Source File: ConcurrentSkipListSubMapTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * higherEntry returns next entry. */ public void testDescendingHigherEntry() { ConcurrentNavigableMap map = dmap5(); Map.Entry e1 = map.higherEntry(m3); assertEquals(m4, e1.getKey()); Map.Entry e2 = map.higherEntry(zero); assertEquals(m1, e2.getKey()); Map.Entry e3 = map.higherEntry(m5); assertNull(e3); Map.Entry e4 = map.higherEntry(m6); assertNull(e4); }
Example #21
Source File: BTreeMapTest5.java From scava with Eclipse Public License 2.0 | 5 votes |
/** * Values.toArray contains all values */ public void testValuesToArray() { ConcurrentNavigableMap map = map5(); Collection v = map.values(); Object[] ar = v.toArray(); ArrayList s = new ArrayList(Arrays.asList(ar)); assertEquals(5, ar.length); assertTrue(s.contains("A")); assertTrue(s.contains("B")); assertTrue(s.contains("C")); assertTrue(s.contains("D")); assertTrue(s.contains("E")); }
Example #22
Source File: ConcurrentSkipListSubMapTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * put(null,x) throws NPE */ public void testPut1_NullPointerException() { try { ConcurrentNavigableMap c = map5(); c.put(null, "whatever"); shouldThrow(); } catch (NullPointerException success) {} }
Example #23
Source File: ConcurrentSkipListSubMapTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * get(null) of nonempty map throws NPE */ public void testGet_NullPointerException() { try { ConcurrentNavigableMap c = map5(); c.get(null); shouldThrow(); } catch (NullPointerException success) {} }
Example #24
Source File: ConcurrentSkipListSubMapJUnitTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * descendingkeySet.toArray returns contains all keys */ public void testDescendingKeySetToArray() { ConcurrentNavigableMap map = map5(); Set s = map.descendingKeySet(); Object[] ar = s.toArray(); assertEquals(5, ar.length); assertTrue(s.containsAll(Arrays.asList(ar))); ar[0] = m10; assertFalse(s.containsAll(Arrays.asList(ar))); }
Example #25
Source File: ConcurrentSkipListSubMapJUnitTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * keySet returns a Set containing all the keys */ public void testDescendingKeySet() { ConcurrentNavigableMap map = dmap5(); Set s = map.keySet(); assertEquals(5, s.size()); assertTrue(s.contains(m1)); assertTrue(s.contains(m2)); assertTrue(s.contains(m3)); assertTrue(s.contains(m4)); assertTrue(s.contains(m5)); }
Example #26
Source File: ConcurrentSkipListSubMapJUnitTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * replace(null, x, y) throws NPE */ public void testDescendingReplaceValue_NullPointerException() { try { ConcurrentNavigableMap c = dmap5(); c.replace(null, m1, "whatever"); shouldThrow(); } catch (NullPointerException success) {} }
Example #27
Source File: ConcurrentSkipListSubMapJUnitTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * keySet is ordered */ public void testDescendingKeySetOrder() { ConcurrentNavigableMap map = dmap5(); Set s = map.keySet(); Iterator i = s.iterator(); Integer last = (Integer)i.next(); assertEquals(last, m1); while (i.hasNext()) { Integer k = (Integer)i.next(); assertTrue(last.compareTo(k) > 0); last = k; } }
Example #28
Source File: ConcurrentSkipListSubMapJUnitTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Maps with same contents are equal */ public void testEquals() { ConcurrentNavigableMap map1 = map5(); ConcurrentNavigableMap map2 = map5(); assertEquals(map1, map2); assertEquals(map2, map1); map1.clear(); assertFalse(map1.equals(map2)); assertFalse(map2.equals(map1)); }
Example #29
Source File: ConcurrentSkipListSubMapJUnitTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * size returns the correct values */ public void testSize() { ConcurrentNavigableMap map = map5(); ConcurrentNavigableMap empty = map0(); assertEquals(0, empty.size()); assertEquals(5, map.size()); }
Example #30
Source File: ConcurrentSkipListSubMapTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * Returns a new map from Integers -5 to -1 to Strings "A"-"E". */ private static ConcurrentNavigableMap dmap5() { ConcurrentSkipListMap map = new ConcurrentSkipListMap(); assertTrue(map.isEmpty()); map.put(m1, "A"); map.put(m5, "E"); map.put(m3, "C"); map.put(m2, "B"); map.put(m4, "D"); assertFalse(map.isEmpty()); assertEquals(5, map.size()); return map.descendingMap(); }