Package net.solarnetwork.central.biz.dao
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration of user event statistic count types.Nested classes/interfaces inherited from interface net.solarnetwork.service.PingTest
net.solarnetwork.service.PingTest.Result -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal intThequeueLagAlertThresholdproperty default value.static Comparator<UserEvent> A comparator forUserEventthat sorts by event ID first, then user ID.A function to generate a SolarFlux MQTT topic from a user event.A function to generate a SolarFlux MQTT topic from a user event. -
Constructor Summary
ConstructorsConstructorDescriptionAsyncDaoUserEventAppenderBiz(ExecutorService executorService, UserEventAppenderDao dao) Constructor.AsyncDaoUserEventAppenderBiz(ExecutorService executorService, UserEventAppenderDao dao, BlockingQueue<UserEvent> queue, net.solarnetwork.util.StatTracker stats, net.solarnetwork.util.UuidGenerator uuidGenerator) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionaddEvent(Long userId, LogEventInfo info) Add an event.longintGet the minimum queue lag before the ping test will fail.Get the SolarFlux publisher.net.solarnetwork.service.PingTest.Resultvoidrun()voidvoidvoidsetQueueLagAlertThreshold(int queueLagAlertThreshold) Set the minimum queue lag before the ping test will fail.voidsetSolarFluxPublisher(MqttJsonPublisher<UserEvent> solarFluxPublisher) Set the SolarFlux publisher.
-
Field Details
-
DEFAULT_QUEUE_LAG_ALERT_THRESHOLD
public final int DEFAULT_QUEUE_LAG_ALERT_THRESHOLDThequeueLagAlertThresholdproperty default value.- See Also:
-
EVENT_SORT
A comparator forUserEventthat sorts by event ID first, then user ID. -
SOLARFLUX_TOPIC_FN
A function to generate a SolarFlux MQTT topic from a user event.- Since:
- 1.1
-
SOLARFLUX_TAGGED_TOPIC_FN
A function to generate a SolarFlux MQTT topic from a user event.- Since:
- 1.3
-
-
Constructor Details
-
AsyncDaoUserEventAppenderBiz
Constructor.- Parameters:
executorService- the executor servicedao- 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 servicedao- the DAOqueue- the queuestats- the statsuuidGenerator- the UUID generator to use- Throws:
IllegalArgumentException- if any argument is null
-
-
Method Details
-
addEvent
Description copied from interface:UserEventAppenderBizAdd an event.- Specified by:
addEventin interfaceUserEventAppenderBiz- Parameters:
userId- the user account IDinfo- the event info to add- Returns:
- the generated event
-
run
public void run() -
serviceDidStartup
public void serviceDidStartup()- Specified by:
serviceDidStartupin interfacenet.solarnetwork.service.ServiceLifecycleObserver
-
serviceDidShutdown
public void serviceDidShutdown()- Specified by:
serviceDidShutdownin interfacenet.solarnetwork.service.ServiceLifecycleObserver
-
getPingTestId
- Specified by:
getPingTestIdin interfacenet.solarnetwork.service.PingTest
-
getPingTestName
- Specified by:
getPingTestNamein interfacenet.solarnetwork.service.PingTest
-
getPingTestMaximumExecutionMilliseconds
public long getPingTestMaximumExecutionMilliseconds()- Specified by:
getPingTestMaximumExecutionMillisecondsin interfacenet.solarnetwork.service.PingTest
-
performPingTest
- Specified by:
performPingTestin interfacenet.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
Get the SolarFlux publisher.- Returns:
- the publisher
-
setSolarFluxPublisher
Set the SolarFlux publisher.- Parameters:
solarFluxPublisher- the publisher to set
-