use of org.graylog2.indexer.cluster.Node in project graylog2-server by Graylog2.
the class OutputResource method get.
@GET
@Path("/{outputId}")
@Timed
@ApiOperation(value = "Get specific output")
@Produces(MediaType.APPLICATION_JSON)
@ApiResponses(value = { @ApiResponse(code = 404, message = "No such output on this node.") })
public OutputSummary get(@ApiParam(name = "outputId", value = "The id of the output we want.", required = true) @PathParam("outputId") String outputId) throws NotFoundException {
checkPermission(RestPermissions.OUTPUTS_READ, outputId);
final Output output = outputService.load(outputId);
return OutputSummary.create(output.getId(), output.getTitle(), output.getType(), output.getCreatorUserId(), new DateTime(output.getCreatedAt()), output.getConfiguration(), output.getContentPack());
}
use of org.graylog2.indexer.cluster.Node in project graylog2-server by Graylog2.
the class OutputResource method update.
@PUT
@Path("/{outputId}")
@Timed
@ApiOperation(value = "Update output")
@Produces(MediaType.APPLICATION_JSON)
@ApiResponses(value = { @ApiResponse(code = 404, message = "No such output on this node.") })
@AuditEvent(type = AuditEventTypes.MESSAGE_OUTPUT_UPDATE)
public Output update(@ApiParam(name = "outputId", value = "The id of the output that should be deleted", required = true) @PathParam("outputId") String outputId, @ApiParam(name = "JSON body", required = true) Map<String, Object> deltas) throws ValidationException, NotFoundException {
checkPermission(RestPermissions.OUTPUTS_EDIT, outputId);
final Output oldOutput = outputService.load(outputId);
final AvailableOutputSummary outputSummary = messageOutputFactory.getAvailableOutputs().get(oldOutput.getType());
if (outputSummary == null) {
throw new ValidationException("type", "Invalid output type");
}
deltas.remove("streams");
if (deltas.containsKey("configuration")) {
@SuppressWarnings("unchecked") final Map<String, Object> configuration = (Map<String, Object>) deltas.get("configuration");
deltas.put("configuration", ConfigurationMapConverter.convertValues(configuration, outputSummary.requestedConfiguration()));
}
final Output output = this.outputService.update(outputId, deltas);
this.outputRegistry.removeOutput(oldOutput);
return output;
}
use of org.graylog2.indexer.cluster.Node in project graylog2-server by Graylog2.
the class InputLauncher method launchAllPersisted.
public void launchAllPersisted() {
for (MessageInput input : persistedInputs) {
if (leaderStatusInhibitsLaunch(input)) {
LOG.info("Not launching 'onlyOnePerCluster' input [{}/{}/{}] because this node is not the leader.", input.getName(), input.getTitle(), input.getId());
continue;
}
if (shouldStartAutomatically(input)) {
LOG.info("Launching input [{}/{}/{}] - desired state is {}", input.getName(), input.getTitle(), input.getId(), input.getDesiredState());
input.initialize();
launch(input);
} else {
LOG.info("Not auto-starting input [{}/{}/{}] - desired state is {}", input.getName(), input.getTitle(), input.getId(), input.getDesiredState());
}
}
}
use of org.graylog2.indexer.cluster.Node in project graylog2-server by Graylog2.
the class GracefulShutdown method doRun.
private void doRun(boolean exit) {
LOG.info("Graceful shutdown initiated.");
// Trigger a lifecycle change. Some services are listening for those and will halt operation accordingly.
serverStatus.shutdown();
// Give possible load balancers time to recognize state change. State is DEAD because of HALTING.
LOG.info("Node status: [{}]. Waiting <{}sec> for possible load balancers to recognize state change.", serverStatus.getLifecycle(), configuration.getLoadBalancerRecognitionPeriodSeconds());
Uninterruptibles.sleepUninterruptibly(configuration.getLoadBalancerRecognitionPeriodSeconds(), TimeUnit.SECONDS);
activityWriter.write(new Activity("Graceful shutdown initiated.", GracefulShutdown.class));
/*
* Wait a second to give for example the calling REST call some time to respond
* to the client. Using a latch or something here might be a bit over-engineered.
*/
Uninterruptibles.sleepUninterruptibly(SLEEP_SECS, TimeUnit.SECONDS);
// Stop REST API service to avoid changes from outside.
jerseyService.stopAsync();
// stop all inputs so no new messages can come in
inputSetupService.stopAsync();
jerseyService.awaitTerminated();
inputSetupService.awaitTerminated();
// Try to flush all remaining messages from the system
bufferSynchronizerService.stopAsync().awaitTerminated();
// Stop all services that registered with the shutdown service (e.g. plugins)
// This must run after the BufferSynchronizerService shutdown to make sure the buffers are empty.
gracefulShutdownService.stopAsync();
// stop all maintenance tasks
periodicalsService.stopAsync().awaitTerminated();
// Wait until the shutdown service is done
gracefulShutdownService.awaitTerminated();
auditEventSender.success(AuditActor.system(serverStatus.getNodeId()), NODE_SHUTDOWN_COMPLETE);
// Shut down hard with no shutdown hooks running.
LOG.info("Goodbye.");
if (exit) {
System.exit(0);
}
}
use of org.graylog2.indexer.cluster.Node in project graylog2-server by Graylog2.
the class IndicesIT method setUp.
@BeforeEach
public void setUp() {
// noinspection UnstableApiUsage
eventBus = new EventBus("indices-test");
final Node node = new Node(createNodeAdapter());
final IndexMappingFactory indexMappingFactory = new IndexMappingFactory(node, ImmutableMap.of(MessageIndexTemplateProvider.MESSAGE_TEMPLATE_TYPE, new MessageIndexTemplateProvider()));
indices = new Indices(indexMappingFactory, mock(NodeId.class), new NullAuditEventSender(), eventBus, indicesAdapter());
}
Aggregations