Package org.graylog.events.processor
Class EventDefinitionHandler
java.lang.Object
org.graylog.events.processor.EventDefinitionHandler
Handles event definitions and creates scheduler job definitions and job triggers.
Caveat: These handlers modify different database documents without using any transactions. That means we can
run into concurrency issues and partial operations.
TODO: Make use of transactions once our database library supports it
-
Constructor Summary
ConstructorDescriptionEventDefinitionHandler
(DBEventDefinitionService eventDefinitionService, DBJobDefinitionService jobDefinitionService, DBJobTriggerService jobTriggerService, JobSchedulerClock clock) -
Method Summary
Modifier and TypeMethodDescriptioncreate
(EventDefinitionDto unsavedEventDefinition, Optional<User> user) Creates a new event definition and a corresponding scheduler job definition and trigger.createWithoutSchedule
(EventDefinitionDto unsavedEventDefinition, Optional<User> user) Creates a new event definition without scheduling it.boolean
Deletes an existing event definition and its corresponding scheduler job definition and trigger.boolean
deleteImmutable
(String eventDefinitionId) Deletes an existing immutable event definition and its corresponding scheduler job definition and trigger.void
deleteNotificationJobTriggers
(String eventDefinitionId) Deletes notification triggers for this event.void
Creates a job definition and a trigger to schedule the given event definition.void
unschedule
(String eventDefinitionId) Removes job definition and trigger for the given event definition to disable it.update
(EventDefinitionDto updatedEventDefinition, boolean schedule) Updates an existing event definition and its corresponding scheduler job definition and trigger.
-
Constructor Details
-
EventDefinitionHandler
@Inject public EventDefinitionHandler(DBEventDefinitionService eventDefinitionService, DBJobDefinitionService jobDefinitionService, DBJobTriggerService jobTriggerService, JobSchedulerClock clock)
-
-
Method Details
-
create
Creates a new event definition and a corresponding scheduler job definition and trigger.- Parameters:
unsavedEventDefinition
- the event definition to saveuser
- the user who created this eventDefinition. If empty, no ownership will be registered.- Returns:
- the created event definition
-
createWithoutSchedule
public EventDefinitionDto createWithoutSchedule(EventDefinitionDto unsavedEventDefinition, Optional<User> user) Creates a new event definition without scheduling it. Normally thecreate(EventDefinitionDto, Optional<User>)
method should be used to ensure proper scheduling of the event definition. In some cases new event definitions must be created without a schedule, though. (e.g. content packs)- Parameters:
unsavedEventDefinition
- the event definition to save- Returns:
- the created event definition
-
update
Updates an existing event definition and its corresponding scheduler job definition and trigger.- Parameters:
updatedEventDefinition
- the event definition to update- Returns:
- the updated event definition
-
delete
Deletes an existing event definition and its corresponding scheduler job definition and trigger.- Parameters:
eventDefinitionId
- the event definition to delete- Returns:
- true if the event definition got deleted, false otherwise
-
deleteImmutable
Deletes an existing immutable event definition and its corresponding scheduler job definition and trigger. Do not call this method for API requests. Only call fromEventDefinitionFacade
.- Parameters:
eventDefinitionId
- the event definition to delete- Returns:
- true if the event definition got deleted, false otherwise
-
schedule
Creates a job definition and a trigger to schedule the given event definition.- Parameters:
eventDefinitionId
- the event definition to schedule
-
unschedule
Removes job definition and trigger for the given event definition to disable it.- Parameters:
eventDefinitionId
- the event definition to unschedule
-
deleteNotificationJobTriggers
Deletes notification triggers for this event.This mostly serves as a safety net, when a misconfiguration has lead to a high number of outstanding notifications.
Processing these notifications would unnecessarily block the job scheduler and in some cases consume a lot of resources.
-