use of org.graylog2.shared.inputs.NoSuchInputTypeException in project graylog2-server by Graylog2.
the class BundleImporter method createInputs.
private void createInputs(final String bundleId, final Set<Input> inputs, final String userName) throws org.graylog2.plugin.inputs.Extractor.ReservedFieldException, org.graylog2.ConfigurationException, NoSuchInputTypeException, ValidationException, ExtractorFactory.NoSuchExtractorException, NotFoundException, ConfigurationException {
for (final Input input : inputs) {
final MessageInput messageInput = createMessageInput(bundleId, input, userName);
createdInputs.put(messageInput.getId(), messageInput);
// Launch input. (this will run async and clean up itself in case of an error.)
inputLauncher.launch(messageInput);
}
}
use of org.graylog2.shared.inputs.NoSuchInputTypeException in project graylog2-server by Graylog2.
the class BundleImporter method createMessageInput.
private MessageInput createMessageInput(final String bundleId, final Input inputDescription, final String userName) throws NoSuchInputTypeException, ConfigurationException, ValidationException, NotFoundException, org.graylog2.ConfigurationException, ExtractorFactory.NoSuchExtractorException, org.graylog2.plugin.inputs.Extractor.ReservedFieldException {
final Configuration inputConfig = new Configuration(inputDescription.getConfiguration());
final DateTime createdAt = Tools.nowUTC();
final MessageInput messageInput = messageInputFactory.create(inputDescription.getType(), inputConfig);
messageInput.setTitle(inputDescription.getTitle());
messageInput.setGlobal(inputDescription.isGlobal());
messageInput.setCreatorUserId(userName);
messageInput.setCreatedAt(createdAt);
messageInput.setContentPack(bundleId);
messageInput.checkConfiguration();
// Don't run if exclusive and another instance is already running.
if (messageInput.isExclusive() && inputRegistry.hasTypeRunning(messageInput.getClass())) {
LOG.error("Input type <{}> of input <{}> is exclusive and already has input running.", messageInput.getClass(), messageInput.getTitle());
}
final String id = inputDescription.getId();
final org.graylog2.inputs.Input mongoInput;
if (id == null) {
mongoInput = inputService.create(buildMongoDbInput(inputDescription, userName, createdAt, bundleId));
} else {
mongoInput = inputService.create(id, buildMongoDbInput(inputDescription, userName, createdAt, bundleId));
}
// Persist input.
final String persistId = inputService.save(mongoInput);
messageInput.setPersistId(persistId);
messageInput.initialize();
addStaticFields(messageInput, inputDescription.getStaticFields());
addExtractors(messageInput, inputDescription.getExtractors(), userName);
return messageInput;
}
use of org.graylog2.shared.inputs.NoSuchInputTypeException in project graylog2-server by Graylog2.
the class InputFacade method createMessageInput.
private MessageInput createMessageInput(final String title, final String type, final boolean global, final Map<String, Object> configuration, final String username) throws NoSuchInputTypeException, ConfigurationException, ValidationException {
final Configuration inputConfig = new Configuration(configuration);
final DateTime createdAt = Tools.nowUTC();
final MessageInput messageInput = messageInputFactory.create(type, inputConfig);
messageInput.setTitle(title);
messageInput.setGlobal(global);
messageInput.setCreatorUserId(username);
messageInput.setCreatedAt(createdAt);
messageInput.checkConfiguration();
// Don't run if exclusive and another instance is already running.
if (messageInput.isExclusive() && inputRegistry.hasTypeRunning(messageInput.getClass())) {
LOG.error("Input type <{}> of input <{}> is exclusive and already has input running.", messageInput.getClass(), messageInput.getTitle());
}
final Input mongoInput = inputService.create(buildMongoDbInput(title, type, global, configuration, username, createdAt));
// Persist input
final String persistId = inputService.save(mongoInput);
messageInput.setPersistId(persistId);
messageInput.initialize();
return messageInput;
}
use of org.graylog2.shared.inputs.NoSuchInputTypeException in project graylog2-server by Graylog2.
the class InputsResource method update.
@PUT
@Timed
@Path("/{inputId}")
@ApiOperation(value = "Update input on this node", response = InputCreated.class)
@ApiResponses(value = { @ApiResponse(code = 404, message = "No such input on this node."), @ApiResponse(code = 400, message = "Missing or invalid input configuration.") })
@AuditEvent(type = AuditEventTypes.MESSAGE_INPUT_UPDATE)
public Response update(@ApiParam(name = "JSON body", required = true) @Valid @NotNull InputCreateRequest lr, @ApiParam(name = "inputId", required = true) @PathParam("inputId") String inputId) throws org.graylog2.database.NotFoundException, NoSuchInputTypeException, ConfigurationException, ValidationException {
checkPermission(RestPermissions.INPUTS_EDIT, inputId);
final Input input = inputService.find(inputId);
final Map<String, Object> mergedInput = input.getFields();
final MessageInput messageInput = messageInputFactory.create(lr, getCurrentUser().getName(), lr.node());
messageInput.checkConfiguration();
mergedInput.putAll(messageInput.asMap());
final Input newInput = inputService.create(input.getId(), mergedInput);
inputService.update(newInput);
final URI inputUri = getUriBuilderToSelf().path(InputsResource.class).path("{inputId}").build(input.getId());
return Response.created(inputUri).entity(InputCreated.create(input.getId())).build();
}
use of org.graylog2.shared.inputs.NoSuchInputTypeException in project graylog2-server by Graylog2.
the class PersistedInputsImpl method iterator.
@Override
public Iterator<MessageInput> iterator() {
List<MessageInput> result = Lists.newArrayList();
for (Input io : inputService.allOfThisNode(serverStatus.getNodeId().toString())) {
try {
final MessageInput input = inputService.getMessageInput(io);
result.add(input);
} catch (NoSuchInputTypeException e) {
LOG.warn("Cannot instantiate persisted input. No such type [{}].", io.getType());
} catch (Throwable e) {
LOG.warn("Cannot instantiate persisted input. Exception caught: ", e);
}
}
return result.iterator();
}
Aggregations