Class SwitchingEmitter

java.lang.Object
org.apache.druid.java.util.emitter.core.SwitchingEmitter
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable, Emitter

public class SwitchingEmitter extends Object implements Emitter
An emitter than that offers the ability to direct an event to multiple emitters based on the event's feed.
  • Constructor Details

    • SwitchingEmitter

      public SwitchingEmitter(Map<String,List<Emitter>> feedToEmitters, Emitter[] defaultEmitter)
      Constructor for the SwitchingEmitter
      Parameters:
      feedToEmitters - Map of feed to a list of emitters that correspond to each feed,
      defaultEmitter - A list of emitters to use if there isn't a match of feed to an emitter
  • Method Details

    • start

      public void start()
      Start the emitter. This will start all the emitters the SwitchingEmitter uses.
      Specified by:
      start in interface Emitter
    • emit

      public void emit(Event event)
      Emit an event. This method must not throw exceptions or block. The emitters that this uses must also not throw exceptions or block.

      This emitter will direct events based on feed to a list of emitters specified. If there is no match the event will use a list of default emitters instead.

      Emitters that this emitter uses that receive too many events and internal queues fill up, should drop events rather than blocking or consuming excessive memory.

      If an emitter that this emitter uses receives input it considers to be invalid, or has an internal problem, it should deal with that by logging a warning rather than throwing an exception. Emitters that log warnings should consider throttling warnings to avoid excessive logs, since a busy Druid cluster can emit a high volume of events.

      Specified by:
      emit in interface Emitter
      Parameters:
      event - The event that will be emitted.
    • flush

      public void flush() throws IOException
      Triggers this emitter to tell all emitters that this uses to flush.
      Specified by:
      flush in interface Emitter
      Specified by:
      flush in interface Flushable
      Throws:
      IOException
    • close

      public void close() throws IOException
      Closes all emitters that the SwitchingEmitter uses
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface Emitter
      Throws:
      IOException