use of org.graylog2.rest.models.system.indexer.responses.IndexRangeSummary 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);
}
use of org.graylog2.rest.models.system.indexer.responses.IndexRangeSummary in project graylog2-server by Graylog2.
the class IndexRangesResource method list.
@GET
@Timed
@ApiOperation(value = "Get a list of all index ranges")
@Produces(MediaType.APPLICATION_JSON)
public IndexRangesResponse list() {
final SortedSet<IndexRange> all = indexRangeService.findAll();
final List<IndexRangeSummary> ranges = Lists.newArrayListWithCapacity(all.size());
for (IndexRange range : all) {
if (!isPermitted(RestPermissions.INDEXRANGES_READ, range.indexName())) {
continue;
}
final IndexRangeSummary indexRange = IndexRangeSummary.create(range.indexName(), range.begin(), range.end(), range.calculatedAt(), range.calculationDuration());
ranges.add(indexRange);
}
return IndexRangesResponse.create(ranges.size(), ranges);
}
Aggregations