Search in sources :

Example 1 with DeflectorSummary

use of org.graylog2.rest.models.system.deflector.responses.DeflectorSummary 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 Map<String, IndexStats> allDocCounts = indices.getAllDocCounts(indexSet).entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
    final Map<String, Boolean> areReopened = indices.areReopened(allDocCounts.keySet());
    final Map<String, IndexSummary> indicesSummaries = allDocCounts.values().stream().parallel().collect(Collectors.toMap(IndexStats::getIndex, (indexStats) -> IndexSummary.create(IndexSizeSummary.create(indexStats.getPrimaries().getDocs().getCount(), indexStats.getPrimaries().getDocs().getDeleted(), indexStats.getPrimaries().getStore().sizeInBytes()), indexRanges.stream().filter((indexRangeSummary) -> indexRangeSummary.indexName().equals(indexStats.getIndex())).findFirst().orElse(null), deflectorSummary.currentTarget() != null && deflectorSummary.currentTarget().equals(indexStats.getIndex()), false, areReopened.get(indexStats.getIndex()))));
    indices.getClosedIndices(indexSet).forEach(indexName -> indicesSummaries.put(indexName, IndexSummary.create(null, indexRanges.stream().filter((indexRangeSummary) -> indexRangeSummary.indexName().equals(indexName)).findFirst().orElse(null), deflectorSummary.currentTarget() != null && deflectorSummary.currentTarget().equals(indexName), true, false)));
    return IndexerOverview.create(deflectorSummary, IndexerClusterOverview.create(indexerClusterResource.clusterHealth(), indexerClusterResource.clusterName().name()), countResource.total(indexSetId), indicesSummaries);
}
Also used : DeflectorSummary(org.graylog2.rest.models.system.deflector.responses.DeflectorSummary) 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) IndexStats(org.elasticsearch.action.admin.indices.stats.IndexStats) 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) IndexSummary(org.graylog2.rest.models.system.indexer.responses.IndexSummary) 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) RestResource(org.graylog2.shared.rest.resources.RestResource) Collectors(java.util.stream.Collectors) 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) IndexRangesResource(org.graylog2.rest.resources.system.IndexRangesResource) RequiresAuthentication(org.apache.shiro.authz.annotation.RequiresAuthentication) TooManyAliasesException(org.graylog2.indexer.indices.TooManyAliasesException) CountResource(org.graylog2.rest.resources.count.CountResource) IndexRangeSummary(org.graylog2.rest.models.system.indexer.responses.IndexRangeSummary) IndexStats(org.elasticsearch.action.admin.indices.stats.IndexStats) Map(java.util.Map) IndexSummary(org.graylog2.rest.models.system.indexer.responses.IndexSummary)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)1 Api (io.swagger.annotations.Api)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiParam (io.swagger.annotations.ApiParam)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)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 ServiceUnavailableException (javax.ws.rs.ServiceUnavailableException)1 MediaType (javax.ws.rs.core.MediaType)1 RequiresAuthentication (org.apache.shiro.authz.annotation.RequiresAuthentication)1 IndexStats (org.elasticsearch.action.admin.indices.stats.IndexStats)1 IndexSet (org.graylog2.indexer.IndexSet)1 IndexSetRegistry (org.graylog2.indexer.IndexSetRegistry)1 Cluster (org.graylog2.indexer.cluster.Cluster)1