Search in sources :

Example 6 with IndexRangeSummary

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);
}
Also used : IndexerOverview(org.graylog2.rest.models.system.indexer.responses.IndexerOverview) PathParam(javax.ws.rs.PathParam) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) DeflectorSummary(org.graylog2.rest.models.system.deflector.responses.DeflectorSummary) IndexRangeSummary(org.graylog2.rest.models.system.indexer.responses.IndexRangeSummary) Path(javax.ws.rs.Path) ApiParam(io.swagger.annotations.ApiParam) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ApiOperation(io.swagger.annotations.ApiOperation) MediaType(javax.ws.rs.core.MediaType) Indices(org.graylog2.indexer.indices.Indices) Map(java.util.Map) MessageCountResponse(org.graylog2.rest.models.count.responses.MessageCountResponse) IndexSummary(org.graylog2.rest.models.system.indexer.responses.IndexSummary) JsonNode(com.fasterxml.jackson.databind.JsonNode) Api(io.swagger.annotations.Api) IndexSet(org.graylog2.indexer.IndexSet) IndexSetRegistry(org.graylog2.indexer.IndexSetRegistry) DeflectorResource(org.graylog2.rest.resources.system.DeflectorResource) Cluster(org.graylog2.indexer.cluster.Cluster) Iterator(java.util.Iterator) ImmutableMap(com.google.common.collect.ImmutableMap) RestResource(org.graylog2.shared.rest.resources.RestResource) NotFoundException(javax.ws.rs.NotFoundException) Timed(com.codahale.metrics.annotation.Timed) ServiceUnavailableException(javax.ws.rs.ServiceUnavailableException) List(java.util.List) IndexSizeSummary(org.graylog2.rest.models.system.indexer.responses.IndexSizeSummary) IndexerClusterOverview(org.graylog2.rest.models.system.indexer.responses.IndexerClusterOverview) Counts(org.graylog2.indexer.counts.Counts) Optional(java.util.Optional) IndexRangesResource(org.graylog2.rest.resources.system.IndexRangesResource) RequiresAuthentication(org.apache.shiro.authz.annotation.RequiresAuthentication) TooManyAliasesException(org.graylog2.indexer.indices.TooManyAliasesException) IndexRangeSummary(org.graylog2.rest.models.system.indexer.responses.IndexRangeSummary) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 7 with IndexRangeSummary

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);
}
Also used : IndexRange(org.graylog2.indexer.ranges.IndexRange) IndexRangeSummary(org.graylog2.rest.models.system.indexer.responses.IndexRangeSummary) Produces(javax.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

IndexRangeSummary (org.graylog2.rest.models.system.indexer.responses.IndexRangeSummary)6 Timed (com.codahale.metrics.annotation.Timed)3 ApiOperation (io.swagger.annotations.ApiOperation)3 GET (javax.ws.rs.GET)3 Produces (javax.ws.rs.Produces)3 ResultMessageSummary (org.graylog2.rest.models.messages.responses.ResultMessageSummary)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ArrayList (java.util.ArrayList)2 Path (javax.ws.rs.Path)2 IndexRange (org.graylog2.indexer.ranges.IndexRange)2 DeflectorSummary (org.graylog2.rest.models.system.deflector.responses.DeflectorSummary)2 IndexSummary (org.graylog2.rest.models.system.indexer.responses.IndexSummary)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Range (com.google.common.collect.Range)1 Api (io.swagger.annotations.Api)1 ApiParam (io.swagger.annotations.ApiParam)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1