use of org.graylog2.rest.models.system.indexer.responses.ShardRouting in project graylog2-server by Graylog2.
the class SizeBasedRotationStrategyTest method testDontRotate.
@Test
public void testDontRotate() throws Exception {
final CommonStats commonStats = new CommonStats();
commonStats.store = new StoreStats(1000, 0);
final IndexStatistics stats = IndexStatistics.create("name", commonStats, commonStats, Collections.<ShardRouting>emptyList());
when(indices.getIndexStats("name")).thenReturn(stats);
when(indexSet.getNewestIndex()).thenReturn("name");
when(indexSet.getConfig()).thenReturn(indexSetConfig);
when(indexSetConfig.rotationStrategy()).thenReturn(SizeBasedRotationStrategyConfig.create(100000L));
final SizeBasedRotationStrategy strategy = new SizeBasedRotationStrategy(indices, nodeId, auditEventSender);
strategy.rotate(indexSet);
verify(indexSet, never()).cycle();
reset(indexSet);
}
use of org.graylog2.rest.models.system.indexer.responses.ShardRouting in project graylog2-server by Graylog2.
the class SizeBasedRotationStrategyTest method testRotate.
@Test
public void testRotate() throws Exception {
final CommonStats commonStats = new CommonStats();
commonStats.store = new StoreStats(1000, 0);
final IndexStatistics stats = IndexStatistics.create("name", commonStats, commonStats, Collections.<ShardRouting>emptyList());
when(indices.getIndexStats("name")).thenReturn(stats);
when(indexSet.getNewestIndex()).thenReturn("name");
when(indexSet.getConfig()).thenReturn(indexSetConfig);
when(indexSetConfig.rotationStrategy()).thenReturn(SizeBasedRotationStrategyConfig.create(100L));
final SizeBasedRotationStrategy strategy = new SizeBasedRotationStrategy(indices, nodeId, auditEventSender);
strategy.rotate(indexSet);
verify(indexSet, times(1)).cycle();
reset(indexSet);
}
use of org.graylog2.rest.models.system.indexer.responses.ShardRouting in project graylog2-server by Graylog2.
the class IndicesResource method getOpenIndicesInfo.
private OpenIndicesInfo getOpenIndicesInfo(Set<IndexStatistics> indicesStats) {
final Map<String, IndexInfo> indexInfos = new HashMap<>();
final Map<String, Boolean> areReopened = indices.areReopened(indicesStats.stream().map(IndexStatistics::indexName).collect(Collectors.toSet()));
for (IndexStatistics indexStatistics : indicesStats) {
final ImmutableList.Builder<ShardRouting> routing = ImmutableList.builder();
for (org.elasticsearch.cluster.routing.ShardRouting shardRouting : indexStatistics.shardRoutings()) {
routing.add(shardRouting(shardRouting));
}
final IndexInfo indexInfo = IndexInfo.create(indexStats(indexStatistics.primaries()), indexStats(indexStatistics.total()), routing.build(), areReopened.get(indexStatistics.indexName()));
indexInfos.put(indexStatistics.indexName(), indexInfo);
}
return OpenIndicesInfo.create(indexInfos);
}
use of org.graylog2.rest.models.system.indexer.responses.ShardRouting 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