use of org.graylog2.indexer.IndexSetRegistry in project graylog2-server by Graylog2.
the class IndexRotationThreadTest method testDoNotPerformRotationIfClusterIsDown.
@Test
public void testDoNotPerformRotationIfClusterIsDown() throws NoTargetIndexException {
final Provider<RotationStrategy> provider = spy(new RotationStrategyProvider());
when(cluster.isConnected()).thenReturn(false);
final IndexRotationThread rotationThread = new IndexRotationThread(notificationService, indices, indexSetRegistry, cluster, new NullActivityWriter(), nodeId, ImmutableMap.<String, Provider<RotationStrategy>>builder().put("strategy", provider).build());
rotationThread.doRun();
verify(indexSet, never()).cycle();
verify(provider, never()).get();
}
use of org.graylog2.indexer.IndexSetRegistry in project graylog2-server by Graylog2.
the class IndexRotationThreadTest method testPerformRotation.
@Test
public void testPerformRotation() throws NoTargetIndexException {
final Provider<RotationStrategy> provider = new RotationStrategyProvider() {
@Override
public void doRotate(IndexSet indexSet) {
indexSet.cycle();
}
};
final IndexRotationThread rotationThread = new IndexRotationThread(notificationService, indices, indexSetRegistry, cluster, new NullActivityWriter(), nodeId, ImmutableMap.<String, Provider<RotationStrategy>>builder().put("strategy", provider).build());
when(indexSetConfig.rotationStrategyClass()).thenReturn("strategy");
rotationThread.checkForRotation(indexSet);
verify(indexSet, times(1)).cycle();
}
use of org.graylog2.indexer.IndexSetRegistry in project graylog2-server by Graylog2.
the class IndexSetsResource method delete.
@DELETE
@Path("{id}")
@Timed
@ApiOperation(value = "Delete index set")
@AuditEvent(type = AuditEventTypes.INDEX_SET_DELETE)
@ApiResponses(value = { @ApiResponse(code = 403, message = "Unauthorized"), @ApiResponse(code = 404, message = "Index set not found") })
public void delete(@ApiParam(name = "id", required = true) @PathParam("id") String id, @ApiParam(name = "delete_indices") @QueryParam("delete_indices") @DefaultValue("true") boolean deleteIndices) {
checkPermission(RestPermissions.INDEXSETS_DELETE, id);
final IndexSet indexSet = getIndexSet(indexSetRegistry, id);
final IndexSet defaultIndexSet = indexSetRegistry.getDefault();
if (indexSet.equals(defaultIndexSet)) {
throw new BadRequestException("Default index set <" + indexSet.getConfig().id() + "> cannot be deleted!");
}
if (indexSetService.delete(id) == 0) {
throw new NotFoundException("Couldn't delete index set with ID <" + id + ">");
} else {
if (deleteIndices) {
try {
systemJobManager.submit(indexSetCleanupJobFactory.create(indexSet));
} catch (SystemJobConcurrencyException e) {
LOG.error("Error running system job", e);
}
}
}
}
use of org.graylog2.indexer.IndexSetRegistry in project graylog2-server by Graylog2.
the class IndicesResource method indexSetOpen.
@GET
@Path("/{indexSetId}/open")
@Timed
@ApiOperation(value = "Get information of all open indices managed by Graylog and their shards.")
@RequiresPermissions(RestPermissions.INDICES_READ)
@Produces(MediaType.APPLICATION_JSON)
public OpenIndicesInfo indexSetOpen(@ApiParam(name = "indexSetId") @PathParam("indexSetId") String indexSetId) {
final IndexSet indexSet = getIndexSet(indexSetRegistry, indexSetId);
final Set<IndexStatistics> indicesInfos = indices.getIndicesStats(indexSet).stream().filter(indexStats -> isPermitted(RestPermissions.INDICES_READ, indexStats.index())).collect(Collectors.toSet());
return getOpenIndicesInfo(indicesInfos);
}
Aggregations