Class AsyncDaoUserEventAppenderBiz

java.lang.Object
net.solarnetwork.central.biz.dao.AsyncDaoUserEventAppenderBiz
All Implemented Interfaces:
Runnable, UserEventAppenderBiz, net.solarnetwork.service.PingTest, net.solarnetwork.service.ServiceLifecycleObserver

public class AsyncDaoUserEventAppenderBiz extends Object implements UserEventAppenderBiz, net.solarnetwork.service.PingTest, net.solarnetwork.service.ServiceLifecycleObserver, Runnable
Asynchronous UserEventAppenderBiz.
  • Field Details

    • DEFAULT_QUEUE_LAG_ALERT_THRESHOLD

      public final int DEFAULT_QUEUE_LAG_ALERT_THRESHOLD
      The queueLagAlertThreshold property default value.
      See Also:
    • EVENT_SORT

      public static Comparator<UserEvent> EVENT_SORT
      A comparator for UserEvent that sorts by event ID first, then user ID.
    • SOLARFLUX_TOPIC_FN

      public static Function<UserEvent,String> SOLARFLUX_TOPIC_FN
      A function to generate a SolarFlux MQTT topic from a user event.
      Since:
      1.1
    • SOLARFLUX_TAGGED_TOPIC_FN

      public static Function<UserEvent,String> SOLARFLUX_TAGGED_TOPIC_FN
      A function to generate a SolarFlux MQTT topic from a user event.
      Since:
      1.3
  • Constructor Details

    • AsyncDaoUserEventAppenderBiz

      public AsyncDaoUserEventAppenderBiz(ExecutorService executorService, UserEventAppenderDao dao)
      Constructor.
      Parameters:
      executorService - the executor service
      dao - the DAO
    • AsyncDaoUserEventAppenderBiz

      public AsyncDaoUserEventAppenderBiz(ExecutorService executorService, UserEventAppenderDao dao, BlockingQueue<UserEvent> queue, net.solarnetwork.util.StatTracker stats, net.solarnetwork.util.UuidGenerator uuidGenerator)
      Constructor.
      Parameters:
      executorService - the executor service
      dao - the DAO
      queue - the queue
      stats - the stats
      uuidGenerator - the UUID generator to use
      Throws:
      IllegalArgumentException - if any argument is null
  • Method Details

    • addEvent

      public UserEvent addEvent(Long userId, LogEventInfo info)
      Description copied from interface: UserEventAppenderBiz
      Add an event.
      Specified by:
      addEvent in interface UserEventAppenderBiz
      Parameters:
      userId - the user account ID
      info - the event info to add
      Returns:
      the generated event
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • serviceDidStartup

      public void serviceDidStartup()
      Specified by:
      serviceDidStartup in interface net.solarnetwork.service.ServiceLifecycleObserver
    • serviceDidShutdown

      public void serviceDidShutdown()
      Specified by:
      serviceDidShutdown in interface net.solarnetwork.service.ServiceLifecycleObserver
    • getPingTestId

      public String getPingTestId()
      Specified by:
      getPingTestId in interface net.solarnetwork.service.PingTest
    • getPingTestName

      public String getPingTestName()
      Specified by:
      getPingTestName in interface net.solarnetwork.service.PingTest
    • getPingTestMaximumExecutionMilliseconds

      public long getPingTestMaximumExecutionMilliseconds()
      Specified by:
      getPingTestMaximumExecutionMilliseconds in interface net.solarnetwork.service.PingTest
    • performPingTest

      public net.solarnetwork.service.PingTest.Result performPingTest() throws Exception
      Specified by:
      performPingTest in interface net.solarnetwork.service.PingTest
      Throws:
      Exception
    • getQueueLagAlertThreshold

      public int getQueueLagAlertThreshold()
      Get the minimum queue lag before the ping test will fail.
      Returns:
      the threshold; defaults to DEFAULT_QUEUE_LAG_ALERT_THRESHOLD
    • setQueueLagAlertThreshold

      public void setQueueLagAlertThreshold(int queueLagAlertThreshold)
      Set the minimum queue lag before the ping test will fail.
      Parameters:
      queueLagAlertThreshold - the threshold to set
    • getSolarFluxPublisher

      public MqttJsonPublisher<UserEvent> getSolarFluxPublisher()
      Get the SolarFlux publisher.
      Returns:
      the publisher
    • setSolarFluxPublisher

      public void setSolarFluxPublisher(MqttJsonPublisher<UserEvent> solarFluxPublisher)
      Set the SolarFlux publisher.
      Parameters:
      solarFluxPublisher - the publisher to set