public Map<E, ValuesAndExtrapolations> peekCurrentWindow() {
    // prevent window rolling.
    _windowRollingLock.lock();
    try {
      Map<E, ValuesAndExtrapolations> result = new HashMap<>();
      _rawMetrics.forEach((entity, rawMetric) -> {
        ValuesAndExtrapolations vae = rawMetric.peekCurrentWindow(_currentWindowIndex, _metricDef);
        SortedSet<Long> currentWindows = new TreeSet<>(Collections.singleton(_currentWindowIndex));
        vae.setWindows(toWindows(currentWindows));
        result.put(entity, vae);
      });
      return result;
    } finally {
      _windowRollingLock.unlock();
    }
  }
@Test
  public void testPeekCurrentWindow() {
    MetricSampleAggregator<String, IntegerEntity> aggregator =
        new MetricSampleAggregator<>(NUM_WINDOWS, WINDOW_MS, MIN_SAMPLES_PER_WINDOW,
                                     0, _metricDef);
    // Add samples to three entities.
    // Entity1 has 2 windows with insufficient data.
    // Entity2 has 2 windows with sufficient data.
    // Entity3 has 1 window with sufficient data, i.e. the active window does not have data.
    populateSampleAggregator(2, 1, aggregator, ENTITY1);
    populateSampleAggregator(2, MIN_SAMPLES_PER_WINDOW, aggregator, ENTITY2);
    CruiseControlUnitTestUtils.populateSampleAggregator(1, MIN_SAMPLES_PER_WINDOW,
                                                        aggregator, ENTITY3, 0, WINDOW_MS,
                                                        _metricDef);
    Map<IntegerEntity, ValuesAndExtrapolations> currentWindowMetrics = aggregator.peekCurrentWindow();
    assertEquals(FORCED_INSUFFICIENT, currentWindowMetrics.get(ENTITY1).extrapolations().get(0));
    assertTrue(currentWindowMetrics.get(ENTITY2).extrapolations().isEmpty());
    assertEquals(NO_VALID_EXTRAPOLATION, currentWindowMetrics.get(ENTITY3).extrapolations().get(0));
  }