use of org.graylog2.indexer.indices.Indices 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.indexer.indices.Indices in project graylog2-server by Graylog2.
the class IndexRangesResource method rebuildIndexSet.
@POST
@Timed
@Path("/index_set/{indexSetId}/rebuild")
@RequiresPermissions(RestPermissions.INDEXRANGES_REBUILD)
@ApiOperation(value = "Rebuild/sync index range information for the given index set.", notes = "This triggers a systemjob that scans every index in the given index set and stores meta information " + "about what indices contain messages in what timeranges. It atomically overwrites " + "already existing meta information.")
@ApiResponses(value = { @ApiResponse(code = 202, message = "Rebuild/sync systemjob triggered.") })
@Produces(MediaType.APPLICATION_JSON)
@AuditEvent(type = AuditEventTypes.ES_INDEX_RANGE_UPDATE_JOB)
public Response rebuildIndexSet(@ApiParam(name = "indexSetId") @PathParam("indexSetId") @NotBlank final String indexSetId) {
final IndexSet indexSet = indexSetRegistry.get(indexSetId).orElseThrow(() -> new javax.ws.rs.NotFoundException("Index set <" + indexSetId + "> not found!"));
submitIndexRangesJob(Collections.singleton(indexSet));
return Response.accepted().build();
}
use of org.graylog2.indexer.indices.Indices in project graylog2-server by Graylog2.
the class IndicesResource method indexSetClosed.
@GET
@Timed
@Path("/{indexSetId}/closed")
@ApiOperation(value = "Get a list of closed indices that can be reopened.")
@Produces(MediaType.APPLICATION_JSON)
public ClosedIndices indexSetClosed(@ApiParam(name = "indexSetId") @PathParam("indexSetId") String indexSetId) {
final IndexSet indexSet = getIndexSet(indexSetRegistry, indexSetId);
final Set<String> closedIndices = indices.getClosedIndices(indexSet).stream().filter((indexName) -> isPermitted(RestPermissions.INDICES_READ, indexName) && indexSetRegistry.isManagedIndex(indexName)).collect(Collectors.toSet());
return ClosedIndices.create(closedIndices, closedIndices.size());
}
use of org.graylog2.indexer.indices.Indices in project graylog2-server by Graylog2.
the class IndicesResource method indexSetReopened.
@GET
@Timed
@Path("/{indexSetId}/reopened")
@ApiOperation(value = "Get a list of reopened indices, which will not be cleaned by retention cleaning")
@Produces(MediaType.APPLICATION_JSON)
public ClosedIndices indexSetReopened(@ApiParam(name = "indexSetId") @PathParam("indexSetId") String indexSetId) {
final IndexSet indexSet = getIndexSet(indexSetRegistry, indexSetId);
final Set<String> reopenedIndices = indices.getReopenedIndices(indexSet).stream().filter((indexName) -> isPermitted(RestPermissions.INDICES_READ, indexName) && indexSetRegistry.isManagedIndex(indexName)).collect(Collectors.toSet());
return ClosedIndices.create(reopenedIndices, reopenedIndices.size());
}
use of org.graylog2.indexer.indices.Indices in project graylog2-server by Graylog2.
the class Searches method search.
public SearchResult search(SearchesConfig config) {
Set<IndexRange> indices = determineAffectedIndicesWithRanges(config.range(), config.filter());
Set<String> indexNames = Sets.newHashSet();
for (IndexRange index : indices) {
indexNames.add(index.indexName());
}
SearchRequest request = searchRequest(config, indexNames).request();
SearchResponse r = c.search(request).actionGet();
recordEsMetrics(r, config.range());
return new SearchResult(r.getHits(), indices, config.query(), request.source(), r.getTook());
}
Aggregations