Search in sources :

Example 1 with IndexSummary

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);
}
Also used : DeflectorSummary(org.graylog2.rest.models.system.deflector.responses.DeflectorSummary) IndexRangeSummary(org.graylog2.rest.models.system.indexer.responses.IndexRangeSummary) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) IndexSummary(org.graylog2.rest.models.system.indexer.responses.IndexSummary)

Example 2 with IndexSummary

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);
}
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)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ArrayList (java.util.ArrayList)2 DeflectorSummary (org.graylog2.rest.models.system.deflector.responses.DeflectorSummary)2 IndexRangeSummary (org.graylog2.rest.models.system.indexer.responses.IndexRangeSummary)2 IndexSummary (org.graylog2.rest.models.system.indexer.responses.IndexSummary)2 Timed (com.codahale.metrics.annotation.Timed)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Api (io.swagger.annotations.Api)1 ApiOperation (io.swagger.annotations.ApiOperation)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 Inject (javax.inject.Inject)1 GET (javax.ws.rs.GET)1 NotFoundException (javax.ws.rs.NotFoundException)1 Path (javax.ws.rs.Path)1 PathParam (javax.ws.rs.PathParam)1 Produces (javax.ws.rs.Produces)1