Class EventDefinitionHandler

java.lang.Object
org.graylog.events.processor.EventDefinitionHandler

public class EventDefinitionHandler extends Object
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 Details

  • Method Details

    • create

      public EventDefinitionDto create(EventDefinitionDto unsavedEventDefinition, Optional<User> user)
      Creates a new event definition and a corresponding scheduler job definition and trigger.
      Parameters:
      unsavedEventDefinition - the event definition to save
      user - the user who created this eventDefinition. If empty, no ownership will be registered.
      Returns:
      the created event definition
    • duplicate

      public EventDefinitionDto duplicate(EventDefinitionDto eventDefinition, Optional<User> user)
      Duplicates an existing event definition. The new copy will be disabled by default and will have the DefaultEntityScope. Also the title will be prefixed with the string "COPY-".
      Parameters:
      eventDefinition - the event definition to copy
      user - 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 the create(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

      public EventDefinitionDto update(EventDefinitionDto updatedEventDefinition, boolean schedule)
      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

      public 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). Does not change the updatedAt timestamp.
      Parameters:
      eventsList - list of events that successfully matched
    • delete

      public boolean delete(String eventDefinitionId)
      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

      public boolean deleteImmutable(String eventDefinitionId)
      Deletes an existing immutable event definition and its corresponding scheduler job definition and trigger. Do not call this method for API requests. Only call from EventDefinitionFacade.
      Parameters:
      eventDefinitionId - the event definition to delete
      Returns:
      true if the event definition got deleted, false otherwise
    • schedule

      public void schedule(String eventDefinitionId)
      Creates a job definition and a trigger to schedule the given event definition.
      Parameters:
      eventDefinitionId - the event definition to schedule
    • unschedule

      public void unschedule(String eventDefinitionId)
      Removes job definition and trigger for the given event definition to disable it.
      Parameters:
      eventDefinitionId - the event definition to unschedule
    • deleteNotificationJobTriggers

      public void deleteNotificationJobTriggers(String eventDefinitionId)
      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.