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