use of org.graylog2.indexer.indices.stats.IndexStatistics in project graylog2-server by Graylog2.
the class SizeBasedRotationStrategyTest method testDontRotate.
@Test
public void testDontRotate() throws Exception {
final CommonStats commonStats = new CommonStats();
commonStats.store = new StoreStats(1000, 0);
final IndexStatistics stats = IndexStatistics.create("name", commonStats, commonStats, Collections.<ShardRouting>emptyList());
when(indices.getIndexStats("name")).thenReturn(stats);
when(indexSet.getNewestIndex()).thenReturn("name");
when(indexSet.getConfig()).thenReturn(indexSetConfig);
when(indexSetConfig.rotationStrategy()).thenReturn(SizeBasedRotationStrategyConfig.create(100000L));
final SizeBasedRotationStrategy strategy = new SizeBasedRotationStrategy(indices, nodeId, auditEventSender);
strategy.rotate(indexSet);
verify(indexSet, never()).cycle();
reset(indexSet);
}
use of org.graylog2.indexer.indices.stats.IndexStatistics in project graylog2-server by Graylog2.
the class SizeBasedRotationStrategyTest method testRotate.
@Test
public void testRotate() throws Exception {
final CommonStats commonStats = new CommonStats();
commonStats.store = new StoreStats(1000, 0);
final IndexStatistics stats = IndexStatistics.create("name", commonStats, commonStats, Collections.<ShardRouting>emptyList());
when(indices.getIndexStats("name")).thenReturn(stats);
when(indexSet.getNewestIndex()).thenReturn("name");
when(indexSet.getConfig()).thenReturn(indexSetConfig);
when(indexSetConfig.rotationStrategy()).thenReturn(SizeBasedRotationStrategyConfig.create(100L));
final SizeBasedRotationStrategy strategy = new SizeBasedRotationStrategy(indices, nodeId, auditEventSender);
strategy.rotate(indexSet);
verify(indexSet, times(1)).cycle();
reset(indexSet);
}
use of org.graylog2.indexer.indices.stats.IndexStatistics in project graylog2-server by Graylog2.
the class IndicesAdapterES7 method indicesStats.
@Override
public Set<IndexStatistics> indicesStats(Collection<String> indices) {
final ImmutableSet.Builder<IndexStatistics> result = ImmutableSet.builder();
final JsonNode allWithShardLevel = statsApi.indexStatsWithShardLevel(indices);
final Iterator<Map.Entry<String, JsonNode>> fields = allWithShardLevel.fields();
while (fields.hasNext()) {
final Map.Entry<String, JsonNode> entry = fields.next();
final String index = entry.getKey();
final JsonNode indexStats = entry.getValue();
if (indexStats.isObject()) {
result.add(IndexStatistics.create(index, indexStats));
}
}
return result.build();
}
use of org.graylog2.indexer.indices.stats.IndexStatistics in project graylog2-server by Graylog2.
the class IndicesResource method toIndexInfos.
private Map<String, IndexInfo> toIndexInfos(Collection<IndexStatistics> indexStatistics) {
final Set<String> indexNames = indexStatistics.stream().map(IndexStatistics::index).collect(Collectors.toSet());
final Map<String, Boolean> reopenedStatus = indices.areReopened(indexNames);
final ImmutableMap.Builder<String, IndexInfo> indexInfos = ImmutableMap.builder();
for (IndexStatistics indexStats : indexStatistics) {
final IndexInfo indexInfo = IndexInfo.create(indexStats.primaryShards(), indexStats.allShards(), fillShardRoutings(indexStats.routing()), reopenedStatus.getOrDefault(indexStats.index(), false));
indexInfos.put(indexStats.index(), indexInfo);
}
return indexInfos.build();
}
use of org.graylog2.indexer.indices.stats.IndexStatistics in project graylog2-server by Graylog2.
the class IndexSetsResourceTest method globalStats.
@Test
public void globalStats() throws Exception {
final IndexStatistics indexStatistics = IndexStatistics.create("prefix_0", IndexStats.create(IndexStats.TimeAndTotalStats.create(0L, 0L), IndexStats.TimeAndTotalStats.create(0L, 0L), IndexStats.TimeAndTotalStats.create(0L, 0L), IndexStats.TimeAndTotalStats.create(0L, 0L), IndexStats.TimeAndTotalStats.create(0L, 0L), IndexStats.TimeAndTotalStats.create(0L, 0L), IndexStats.TimeAndTotalStats.create(0L, 0L), 0L, 23L, 2L, IndexStats.DocsStats.create(42L, 0L)), IndexStats.create(IndexStats.TimeAndTotalStats.create(0L, 0L), IndexStats.TimeAndTotalStats.create(0L, 0L), IndexStats.TimeAndTotalStats.create(0L, 0L), IndexStats.TimeAndTotalStats.create(0L, 0L), IndexStats.TimeAndTotalStats.create(0L, 0L), IndexStats.TimeAndTotalStats.create(0L, 0L), IndexStats.TimeAndTotalStats.create(0L, 0L), 0L, 23L, 2L, IndexStats.DocsStats.create(42L, 0L)), Collections.emptyList());
when(indices.getClosedIndices(anyCollection())).thenReturn(Collections.singleton("closed_index_0"));
when(indices.getIndicesStats(anyCollection())).thenReturn(Collections.singleton(indexStatistics));
final IndexSetStats indexSetStats = indexSetsResource.globalStats();
assertThat(indexSetStats).isNotNull();
assertThat(indexSetStats.indices()).isEqualTo(2L);
assertThat(indexSetStats.documents()).isEqualTo(42L);
assertThat(indexSetStats.size()).isEqualTo(23L);
}
Aggregations