use of org.graylog2.rest.models.system.indexer.responses.IndexSummary in project graylog2-server by Graylog2.
the class IndexerOverviewResource method getIndexerOverview.
private IndexerOverview getIndexerOverview(IndexSet indexSet) throws TooManyAliasesException {
final String indexSetId = indexSet.getConfig().id();
final DeflectorSummary deflectorSummary = deflectorResource.deflector(indexSetId);
final List<IndexRangeSummary> indexRanges = indexRangesResource.list().ranges();
final JsonNode indexStats = indices.getIndexStats(indexSet);
final List<String> indexNames = new ArrayList<>();
indexStats.fieldNames().forEachRemaining(indexNames::add);
final Map<String, Boolean> areReopened = indices.areReopened(indexNames);
final Map<String, IndexSummary> indicesSummaries = buildIndexSummaries(deflectorSummary, indexSet, indexRanges, indexStats, areReopened);
return IndexerOverview.create(deflectorSummary, IndexerClusterOverview.create(indexerClusterResource.clusterHealth(), indexerClusterResource.clusterName().name()), MessageCountResponse.create(counts.total(indexSet)), indicesSummaries);
}
use of org.graylog2.rest.models.system.indexer.responses.IndexSummary in project graylog2-server by Graylog2.
the class IndexerOverviewResource method buildIndexSummary.
private IndexSummary buildIndexSummary(Map.Entry<String, JsonNode> indexStats, List<IndexRangeSummary> indexRanges, DeflectorSummary deflectorSummary, Map<String, Boolean> areReopened) {
final String index = indexStats.getKey();
final JsonNode primaries = indexStats.getValue().path("primaries");
final JsonNode docs = primaries.path("docs");
final long count = docs.path("count").asLong();
final long deleted = docs.path("deleted").asLong();
final JsonNode store = primaries.path("store");
final long sizeInBytes = store.path("size_in_bytes").asLong();
final Optional<IndexRangeSummary> range = indexRanges.stream().filter(indexRangeSummary -> indexRangeSummary.indexName().equals(index)).findFirst();
final boolean isDeflector = index.equals(deflectorSummary.currentTarget());
final boolean isReopened = areReopened.get(index);
return IndexSummary.create(IndexSizeSummary.create(count, deleted, sizeInBytes), range.orElse(null), isDeflector, false, isReopened);
}
Aggregations