use of org.graylog2.indexer.searches.IndexRangeStats in project graylog2-server by Graylog2.
the class IndicesTest method testTimestampStatsOfIndexWithEmptyIndex.
@Test
@UsingDataSet(locations = "IndicesTest-EmptyIndex.json", loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void testTimestampStatsOfIndexWithEmptyIndex() throws Exception {
IndexRangeStats stats = indices.indexRangeStatsOfIndex(INDEX_NAME);
assertThat(stats.min()).isEqualTo(new DateTime(0L, DateTimeZone.UTC));
assertThat(stats.max()).isEqualTo(new DateTime(0L, DateTimeZone.UTC));
}
use of org.graylog2.indexer.searches.IndexRangeStats in project graylog2-server by Graylog2.
the class IndicesTest method testTimestampStatsOfIndex.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void testTimestampStatsOfIndex() throws Exception {
IndexRangeStats stats = indices.indexRangeStatsOfIndex(INDEX_NAME);
assertThat(stats.min()).isEqualTo(new DateTime(2015, 1, 1, 1, 0, DateTimeZone.UTC));
assertThat(stats.max()).isEqualTo(new DateTime(2015, 1, 1, 5, 0, DateTimeZone.UTC));
}
use of org.graylog2.indexer.searches.IndexRangeStats in project graylog2-server by Graylog2.
the class IndicesIT method indexRangeStatsOfIndexReturnsMinMaxTimestampsForGivenIndex.
@ContainerMatrixTest
public void indexRangeStatsOfIndexReturnsMinMaxTimestampsForGivenIndex() {
importFixture("org/graylog2/indexer/indices/IndicesIT.json");
IndexRangeStats stats = indices.indexRangeStatsOfIndex(INDEX_NAME);
assertThat(stats.min()).isEqualTo(new DateTime(2015, 1, 1, 1, 0, DateTimeZone.UTC));
assertThat(stats.max()).isEqualTo(new DateTime(2015, 1, 1, 5, 0, DateTimeZone.UTC));
}
use of org.graylog2.indexer.searches.IndexRangeStats in project graylog2-server by Graylog2.
the class IndicesIT method indexRangeStatsWorksForEmptyIndex.
@ContainerMatrixTest
public void indexRangeStatsWorksForEmptyIndex() {
final String indexName = createRandomIndex("indices_it_");
IndexRangeStats stats = indices.indexRangeStatsOfIndex(indexName);
assertThat(stats.min()).isEqualTo(new DateTime(0L, DateTimeZone.UTC));
assertThat(stats.max()).isEqualTo(new DateTime(0L, DateTimeZone.UTC));
}
use of org.graylog2.indexer.searches.IndexRangeStats in project graylog2-server by Graylog2.
the class MongoIndexRangeService method calculateRange.
@Override
public IndexRange calculateRange(String index) {
checkIfHealthy(indices.waitForRecovery(index), (status) -> new RuntimeException("Unable to calculate range for index <" + index + ">, index is unhealthy: " + status));
final DateTime now = DateTime.now(DateTimeZone.UTC);
final Stopwatch sw = Stopwatch.createStarted();
final IndexRangeStats stats = indices.indexRangeStatsOfIndex(index);
final int duration = Ints.saturatedCast(sw.stop().elapsed(TimeUnit.MILLISECONDS));
LOG.info("Calculated range of [{}] in [{}ms].", index, duration);
return MongoIndexRange.create(index, stats.min(), stats.max(), now, duration, stats.streamIds());
}
Aggregations