use of org.graylog2.shared.system.activities.Activity in project graylog2-server by Graylog2.
the class FixDeflectorByDeleteJob method doExecute.
public void doExecute(IndexSet indexSet) {
if (!indexSet.getConfig().isWritable()) {
LOG.debug("No need to fix deflector for non-writable index set <{}> ({})", indexSet.getConfig().id(), indexSet.getConfig().title());
return;
}
if (indexSet.isUp() || !indices.exists(indexSet.getWriteIndexAlias())) {
LOG.error("There is no index <{}>. No need to run this job. Aborting.", indexSet.getWriteIndexAlias());
return;
}
LOG.info("Attempting to fix deflector with delete strategy.");
// Pause message processing and lock the pause.
boolean wasProcessing = serverStatus.isProcessing();
serverStatus.pauseMessageProcessing();
progress = 10;
bufferSynchronizer.waitForEmptyBuffers();
progress = 25;
// Delete deflector index.
LOG.info("Deleting <{}> index.", indexSet.getWriteIndexAlias());
indices.delete(indexSet.getWriteIndexAlias());
progress = 70;
// Set up deflector.
indexSet.setUp();
progress = 80;
// Start message processing again.
try {
serverStatus.unlockProcessingPause();
if (wasProcessing) {
serverStatus.resumeMessageProcessing();
}
} catch (Exception e) {
// lol checked exceptions
throw new RuntimeException("Could not unlock processing pause.", e);
}
progress = 90;
activityWriter.write(new Activity("Notification condition [" + Notification.Type.DEFLECTOR_EXISTS_AS_INDEX + "] " + "has been fixed.", this.getClass()));
notificationService.fixed(Notification.Type.DEFLECTOR_EXISTS_AS_INDEX);
progress = 100;
LOG.info("Finished.");
}
use of org.graylog2.shared.system.activities.Activity in project graylog2-server by Graylog2.
the class FixDeflectorByMoveJob method doExecute.
public void doExecute(IndexSet indexSet) {
if (!indexSet.getConfig().isWritable()) {
LOG.debug("No need to fix deflector for non-writable index set <{}> ({})", indexSet.getConfig().id(), indexSet.getConfig().title());
return;
}
if (indexSet.isUp() || !indices.exists(indexSet.getWriteIndexAlias())) {
LOG.error("There is no index <{}>. No need to run this job. Aborting.", indexSet.getWriteIndexAlias());
return;
}
LOG.info("Attempting to fix deflector with move strategy.");
boolean wasProcessing = true;
try {
// Pause message processing and lock the pause.
wasProcessing = serverStatus.isProcessing();
serverStatus.pauseMessageProcessing();
progress = 5;
bufferSynchronizer.waitForEmptyBuffers();
progress = 10;
// Copy messages to new index.
String newTarget = null;
try {
newTarget = indexSet.getNewestIndex();
LOG.info("Starting to move <{}> to <{}>.", indexSet.getWriteIndexAlias(), newTarget);
indices.move(indexSet.getWriteIndexAlias(), newTarget);
} catch (Exception e) {
LOG.error("Moving index failed. Rolling back.", e);
if (newTarget != null) {
indices.delete(newTarget);
}
throw new RuntimeException(e);
}
LOG.info("Done moving deflector index.");
progress = 85;
// Delete deflector index.
LOG.info("Deleting <{}> index.", indexSet.getWriteIndexAlias());
indices.delete(indexSet.getWriteIndexAlias());
progress = 90;
// Set up deflector.
indexSet.setUp();
progress = 95;
} finally {
// Start message processing again.
serverStatus.unlockProcessingPause();
if (wasProcessing) {
serverStatus.resumeMessageProcessing();
}
}
progress = 90;
activityWriter.write(new Activity("Notification condition [" + Notification.Type.DEFLECTOR_EXISTS_AS_INDEX + "] " + "has been fixed.", this.getClass()));
notificationService.fixed(Notification.Type.DEFLECTOR_EXISTS_AS_INDEX);
progress = 100;
LOG.info("Finished.");
}
use of org.graylog2.shared.system.activities.Activity in project graylog2-server by Graylog2.
the class OptimizeIndexJob method execute.
@Override
public void execute() {
String msg = "Optimizing index <" + index + ">.";
activityWriter.write(new Activity(msg, OptimizeIndexJob.class));
LOG.info(msg);
indices.optimizeIndex(index, maxNumSegments, indexOptimizationTimeout);
}
use of org.graylog2.shared.system.activities.Activity in project graylog2-server by Graylog2.
the class DashboardWidgetsResource method remove.
@DELETE
@Timed
@ApiOperation(value = "Delete a widget")
@Path("/{widgetId}")
@ApiResponses(value = { @ApiResponse(code = 404, message = "Dashboard not found."), @ApiResponse(code = 404, message = "Widget not found.") })
@Produces(MediaType.APPLICATION_JSON)
@AuditEvent(type = AuditEventTypes.DASHBOARD_WIDGET_DELETE)
public void remove(@ApiParam(name = "dashboardId", required = true) @PathParam("dashboardId") String dashboardId, @ApiParam(name = "widgetId", required = true) @PathParam("widgetId") String widgetId) throws NotFoundException {
checkPermission(RestPermissions.DASHBOARDS_EDIT, dashboardId);
final Dashboard dashboard = dashboardService.load(dashboardId);
final DashboardWidget widget = dashboard.getWidget(widgetId);
dashboardService.removeWidget(dashboard, widget);
this.clusterEventBus.post(WidgetUpdatedEvent.create(widget));
final String msg = "Deleted widget <" + widgetId + "> from dashboard <" + dashboardId + ">. Reason: REST request.";
LOG.info(msg);
activityWriter.write(new Activity(msg, DashboardsResource.class));
}
use of org.graylog2.shared.system.activities.Activity in project graylog2-server by Graylog2.
the class DashboardsResource method delete.
@DELETE
@Timed
@ApiOperation(value = "Delete a dashboard and all its widgets")
@Produces(MediaType.APPLICATION_JSON)
@Path("/{dashboardId}")
@ApiResponses(value = { @ApiResponse(code = 404, message = "Dashboard not found.") })
@AuditEvent(type = AuditEventTypes.DASHBOARD_DELETE)
public void delete(@ApiParam(name = "dashboardId", required = true) @PathParam("dashboardId") String dashboardId) throws NotFoundException {
checkPermission(RestPermissions.DASHBOARDS_EDIT, dashboardId);
final Dashboard dashboard = dashboardService.load(dashboardId);
dashboard.getWidgets().values().forEach((widget) -> this.clusterEventBus.post(WidgetUpdatedEvent.create(widget)));
dashboardService.destroy(dashboard);
final String msg = "Deleted dashboard <" + dashboard.getId() + ">. Reason: REST request.";
LOG.info(msg);
activityWriter.write(new Activity(msg, DashboardsResource.class));
this.serverEventBus.post(DashboardDeletedEvent.create(dashboard.getId()));
}
Aggregations