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
ConstructorsConstructorDescriptionEventDefinitionHandler
(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.duplicate
(EventDefinitionDto eventDefinition, Optional<User> user) Duplicates an existing event definition.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.void
updateLastMatched
(List<EventWithContext> eventsList) Update the timestamp of last match based on given list of events (which may include events for multiple event definitions).
-
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
-
duplicate
Duplicates an existing event definition. The new copy will be disabled by default and will have theDefaultEntityScope
. Also the title will be prefixed with the string "COPY-".- Parameters:
eventDefinition
- the event definition to copyuser
- the user who copied this eventDefinition. If empty, no ownership will be registered.- Returns:
- the newly 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
-
updateLastMatched
Update the timestamp of last match based on given list of events (which may include events for multiple event definitions). Does not change the updatedAt timestamp.- Parameters:
eventsList
- list of events that successfully matched
-
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.
-