Class DefaultEventProcessor

  • All Implemented Interfaces:
    EventProcessor, java.io.Closeable, java.lang.AutoCloseable

    public final class DefaultEventProcessor
    extends java.lang.Object
    implements java.io.Closeable, EventProcessor
    The internal component that processes and delivers analytics events.

    This component is not visible to application code; the SDKs may choose to expose an interface for customizing event behavior, but if so, their default implementations of the interface will delegate to this component rather than this component implementing the interface itself. This allows us to make changes as needed to the internal interface and event parameters without disrupting application code, and also to provide internal features that may not be relevant to some SDKs. The current implementation is really three components. DefaultEventProcessor is a simple facade that accepts event parameters (from SDK activity that might be happening on many threads) and pushes the events onto a queue. The queue is consumed by a single-threaded task run by EventDispatcher, which performs any necessary processing such as incrementing summary counters. When events are ready to deliver, it uses an implementation of EventSender (normally DefaultEventSender) to deliver the JSON data.

    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultEventProcessor​(EventsConfiguration eventsConfig, java.util.concurrent.ScheduledExecutorService sharedExecutor, int threadPriority, com.launchdarkly.logging.LDLogger logger)
      Creates an instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      void flushAsync()
      Schedules an asynchronous flush.
      void flushBlocking()
      Flushes and blocks until the flush is done.
      void sendEvent​(Event e)
      Enqueues an event.
      void setInBackground​(boolean inBackground)
      Tells the event processor whether we should be in background mode.
      void setOffline​(boolean offline)
      Tells the event processor whether we should be in background mode.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultEventProcessor

        public DefaultEventProcessor​(EventsConfiguration eventsConfig,
                                     java.util.concurrent.ScheduledExecutorService sharedExecutor,
                                     int threadPriority,
                                     com.launchdarkly.logging.LDLogger logger)
        Creates an instance.
        Parameters:
        eventsConfig - the events configuration
        sharedExecutor - used for scheduling repeating tasks
        threadPriority - worker thread priority
        logger - the logger
    • Method Detail

      • setInBackground

        public void setInBackground​(boolean inBackground)
        Description copied from interface: EventProcessor
        Tells the event processor whether we should be in background mode. This is only applicable in the client-side (Android) SDK. In background mode, events mostly work the same but we do not send any periodic diagnostic events.
        Specified by:
        setInBackground in interface EventProcessor
        Parameters:
        inBackground - true if we should be in background mode
      • setOffline

        public void setOffline​(boolean offline)
        Description copied from interface: EventProcessor
        Tells the event processor whether we should be in background mode. This is only applicable in the client-side (Android) SDK; in the server-side Java SDK, offline mode does not change dynamically and so we don't even bother to create an event processor if we're offline. In offline mode, events are enqueued but never flushed, and diagnostic events are not sent.
        Specified by:
        setOffline in interface EventProcessor
        Parameters:
        offline - true if we should be in offline mode
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException