Java Code Examples for java.util.concurrent.ConcurrentNavigableMap#floorEntry()

The following examples show how to use java.util.concurrent.ConcurrentNavigableMap#floorEntry() . 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: ConcurrentSkipListSubMapTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * floorEntry returns preceding entry.
 */
public void testFloorEntry() {
    ConcurrentNavigableMap map = map5();
    Map.Entry e1 = map.floorEntry(three);
    assertEquals(three, e1.getKey());

    Map.Entry e2 = map.floorEntry(six);
    assertEquals(five, e2.getKey());

    Map.Entry e3 = map.floorEntry(one);
    assertEquals(one, e3.getKey());

    Map.Entry e4 = map.floorEntry(zero);
    assertNull(e4);
}
 
Example 2
Source File: ConcurrentSkipListSubMapTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * floorEntry returns preceding entry.
 */
public void testDescendingFloorEntry() {
    ConcurrentNavigableMap map = dmap5();
    Map.Entry e1 = map.floorEntry(m3);
    assertEquals(m3, e1.getKey());

    Map.Entry e2 = map.floorEntry(m6);
    assertEquals(m5, e2.getKey());

    Map.Entry e3 = map.floorEntry(m1);
    assertEquals(m1, e3.getKey());

    Map.Entry e4 = map.floorEntry(zero);
    assertNull(e4);
}
 
Example 3
Source File: BTreeMapTest5.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * floorEntry returns preceding entry.
 */
public void testFloorEntry() {
    ConcurrentNavigableMap map = map5();
    Map.Entry e1 = map.floorEntry(three);
    assertEquals(three, e1.getKey());

    Map.Entry e2 = map.floorEntry(six);
    assertEquals(five, e2.getKey());

    Map.Entry e3 = map.floorEntry(one);
    assertEquals(one, e3.getKey());

    Map.Entry e4 = map.floorEntry(zero);
    assertNull(e4);
}
 
Example 4
Source File: ConcurrentSkipListSubMapJUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * floorEntry returns preceding entry.
 */
public void testFloorEntry() {
    ConcurrentNavigableMap map = map5();
    Map.Entry e1 = map.floorEntry(three);
    assertEquals(three, e1.getKey());

    Map.Entry e2 = map.floorEntry(six);
    assertEquals(five, e2.getKey());

    Map.Entry e3 = map.floorEntry(one);
    assertEquals(one, e3.getKey());

    Map.Entry e4 = map.floorEntry(zero);
    assertNull(e4);
}
 
Example 5
Source File: ConcurrentSkipListSubMapJUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * floorEntry returns preceding entry.
 */
public void testDescendingFloorEntry() {
    ConcurrentNavigableMap map = dmap5();
    Map.Entry e1 = map.floorEntry(m3);
    assertEquals(m3, e1.getKey());

    Map.Entry e2 = map.floorEntry(m6);
    assertEquals(m5, e2.getKey());

    Map.Entry e3 = map.floorEntry(m1);
    assertEquals(m1, e3.getKey());

    Map.Entry e4 = map.floorEntry(zero);
    assertNull(e4);
}
 
Example 6
Source File: ConcurrentSkipListSubMapJUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * floorEntry returns preceding entry.
 */
public void testFloorEntry() {
    ConcurrentNavigableMap map = map5();
    Map.Entry e1 = map.floorEntry(three);
    assertEquals(three, e1.getKey());

    Map.Entry e2 = map.floorEntry(six);
    assertEquals(five, e2.getKey());

    Map.Entry e3 = map.floorEntry(one);
    assertEquals(one, e3.getKey());

    Map.Entry e4 = map.floorEntry(zero);
    assertNull(e4);
}
 
Example 7
Source File: ConcurrentSkipListSubMapJUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * floorEntry returns preceding entry.
 */
public void testDescendingFloorEntry() {
    ConcurrentNavigableMap map = dmap5();
    Map.Entry e1 = map.floorEntry(m3);
    assertEquals(m3, e1.getKey());

    Map.Entry e2 = map.floorEntry(m6);
    assertEquals(m5, e2.getKey());

    Map.Entry e3 = map.floorEntry(m1);
    assertEquals(m1, e3.getKey());

    Map.Entry e4 = map.floorEntry(zero);
    assertNull(e4);
}
 
Example 8
Source File: ConcurrentSkipListSubMapTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * floorEntry returns preceding entry.
 */
public void testFloorEntry() {
    ConcurrentNavigableMap map = map5();
    Map.Entry e1 = map.floorEntry(three);
    assertEquals(three, e1.getKey());

    Map.Entry e2 = map.floorEntry(six);
    assertEquals(five, e2.getKey());

    Map.Entry e3 = map.floorEntry(one);
    assertEquals(one, e3.getKey());

    Map.Entry e4 = map.floorEntry(zero);
    assertNull(e4);
}
 
Example 9
Source File: ConcurrentSkipListSubMapTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * floorEntry returns preceding entry.
 */
public void testDescendingFloorEntry() {
    ConcurrentNavigableMap map = dmap5();
    Map.Entry e1 = map.floorEntry(m3);
    assertEquals(m3, e1.getKey());

    Map.Entry e2 = map.floorEntry(m6);
    assertEquals(m5, e2.getKey());

    Map.Entry e3 = map.floorEntry(m1);
    assertEquals(m1, e3.getKey());

    Map.Entry e4 = map.floorEntry(zero);
    assertNull(e4);
}
 
Example 10
Source File: BlobStoreStats.java    From ambry with Apache License 2.0 4 votes vote down vote up
@Override
public void run() {
  try {
    if (cancelled) {
      return;
    }
    logger.trace("IndexScanner triggered for store {}", storeId);
    recentEntryQueueEnabled = false;
    startTimeInMs = time.milliseconds();
    newScanResults = new ScanResults(startTimeInMs, logSegmentForecastOffsetMs, bucketCount, bucketSpanTimeInMs);
    scanLock.lock();
    try {
      isScanning = true;
    } finally {
      scanLock.unlock();
    }
    Offset firstCheckpoint = index.getCurrentEndOffset();
    logger.trace("First checkpoint by IndexScanner {} for store {}", firstCheckpoint, storeId);
    ConcurrentNavigableMap<Offset, IndexSegment> indexSegments = index.getIndexSegments();
    Map<StoreKey, Long> deletedKeys = new HashMap<>();
    // process the active index segment based on the firstCheckpoint in case index segment rolled over after the
    // checkpoint is taken
    if (!cancelled && indexSegments.size() > 0) {
      Map.Entry<Offset, IndexSegment> activeIndexSegmentEntry = indexSegments.floorEntry(firstCheckpoint);
      long indexSegmentStartProcessTime = time.milliseconds();
      logger.trace("Processing index entries in active segment {} before first checkpoint for store {}",
          activeIndexSegmentEntry.getValue().getFile().getName(), storeId);
      List<IndexEntry> activeIndexEntries =
          getIndexEntriesBeforeOffset(activeIndexSegmentEntry.getValue(), firstCheckpoint);
      processIndexSegmentEntriesBackward(activeIndexSegmentEntry.getValue(), activeIndexEntries, deletedKeys);
      metrics.statsBucketingScanTimePerIndexSegmentMs.update(time.milliseconds() - indexSegmentStartProcessTime,
          TimeUnit.MILLISECONDS);
      if (!cancelled && indexSegments.size() > 1) {
        ConcurrentNavigableMap<Offset, IndexSegment> sealedIndexSegments =
            indexSegments.subMap(index.getStartOffset(), activeIndexSegmentEntry.getKey());
        logger.trace("Sealed index segments count {} for store {}", sealedIndexSegments.size(), storeId);
        int segmentCount = 0;
        for (IndexSegment indexSegment : sealedIndexSegments.descendingMap().values()) {
          if (cancelled) {
            return;
          }
          indexSegmentStartProcessTime = time.milliseconds();
          List<IndexEntry> indexEntries = getIndexEntries(indexSegment);
          processIndexSegmentEntriesBackward(indexSegment, indexEntries, deletedKeys);
          metrics.statsBucketingScanTimePerIndexSegmentMs.update(time.milliseconds() - indexSegmentStartProcessTime,
              TimeUnit.MILLISECONDS);
          segmentCount++;
          if (segmentCount == 1 || segmentCount % 10 == 0) {
            logger.info("IndexScanner: Completed scanning of sealed segment {} for store {}",
                indexSegment.getFile().getName(), storeId);
          }
        }
      }
    } else {
      newScanResults.updateLogSegmentBaseBucket(index.getStartOffset().getName(), 0L);
    }
    recentEntryQueueEnabled = true;
    Offset secondCheckpoint = index.getCurrentEndOffset();
    logger.trace("Second checkpoint by IndexScanner {} for store {}", secondCheckpoint, storeId);
    if (secondCheckpoint.compareTo(firstCheckpoint) > 0) {
      forwardScan(firstCheckpoint, secondCheckpoint);
    }
    newScanResults.scannedEndOffset = secondCheckpoint;
    scanResults.set(newScanResults);
  } catch (Exception e) {
    logger.error("Exception thrown while scanning index for bucketing stats in store {}", storeId, e);
    metrics.blobStoreStatsIndexScannerErrorCount.inc();
  } finally {
    scanLock.lock();
    try {
      isScanning = false;
      waitCondition.signalAll();
    } finally {
      scanLock.unlock();
    }
    metrics.statsBucketingScanTotalTimeMs.update(time.milliseconds() - startTimeInMs, TimeUnit.MILLISECONDS);
  }
}