Search in sources :

Example 6 with IndexStats

use of org.graylog2.rest.models.system.indexer.responses.IndexStats in project graylog2-server by Graylog2.

the class IndicesResource method single.

@GET
@Timed
@Path("/{index}")
@ApiOperation(value = "Get information of an index and its shards.")
@Produces(MediaType.APPLICATION_JSON)
public IndexInfo single(@ApiParam(name = "index") @PathParam("index") String index) {
    checkPermission(RestPermissions.INDICES_READ, index);
    if (!indexSetRegistry.isManagedIndex(index)) {
        final String msg = "Index [" + index + "] doesn't look like an index managed by Graylog.";
        LOG.info(msg);
        throw new NotFoundException(msg);
    }
    final IndexStatistics stats = indices.getIndexStats(index);
    if (stats == null) {
        final String msg = "Index [" + index + "] not found.";
        LOG.error(msg);
        throw new NotFoundException(msg);
    }
    final ImmutableList.Builder<ShardRouting> routing = ImmutableList.builder();
    for (org.elasticsearch.cluster.routing.ShardRouting shardRouting : stats.shardRoutings()) {
        routing.add(shardRouting(shardRouting));
    }
    return IndexInfo.create(indexStats(stats.primaries()), indexStats(stats.total()), routing.build(), indices.isReopened(index));
}
Also used : IndexStatistics(org.graylog2.indexer.indices.IndexStatistics) ImmutableList(com.google.common.collect.ImmutableList) NotFoundException(javax.ws.rs.NotFoundException) ShardRouting(org.graylog2.rest.models.system.indexer.responses.ShardRouting) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

IndexStatistics (org.graylog2.indexer.indices.IndexStatistics)4 Timed (com.codahale.metrics.annotation.Timed)3 ImmutableList (com.google.common.collect.ImmutableList)3 ApiOperation (io.swagger.annotations.ApiOperation)3 GET (javax.ws.rs.GET)3 NotFoundException (javax.ws.rs.NotFoundException)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 ShardRouting (org.graylog2.rest.models.system.indexer.responses.ShardRouting)3 Api (io.swagger.annotations.Api)2 ApiParam (io.swagger.annotations.ApiParam)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 PathParam (javax.ws.rs.PathParam)2 MediaType (javax.ws.rs.core.MediaType)2 RequiresAuthentication (org.apache.shiro.authz.annotation.RequiresAuthentication)2 IndexStats (org.elasticsearch.action.admin.indices.stats.IndexStats)2 IndexSet (org.graylog2.indexer.IndexSet)2