Class PeriodicWriteWorker
java.lang.Object
io.openems.backend.metadata.odoo.postgres.PeriodicWriteWorker
This worker combines writes to lastMessage and lastUpdate fields, to avoid
DDOSing Odoo/Postgres by writing too often.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondrainToSet
(LinkedBlockingQueue<Integer> queue) Moves all entries of aLinkedBlockingQueue
to a Set and clears the queue.void
onLastMessage
(MyEdge edge) Called oninvalid reference
Edge.Events#ON_SET_LAST_MESSAGE_TIMESTAMP
void
onSetOnline
(MyEdge edge, boolean isOnline) Called onEdge.Events.ON_SET_ONLINE
event.void
onSetSumState
(MyEdge edge, Level sumState) Called onEdge.Events.ON_SET_SUM_STATE
event.void
start()
Starts thePeriodicWriteWorker
.void
stop()
Stops thePeriodicWriteWorker
.
-
Constructor Details
-
PeriodicWriteWorker
-
-
Method Details
-
start
public void start()Starts thePeriodicWriteWorker
. -
stop
public void stop()Stops thePeriodicWriteWorker
. -
onLastMessage
Called oninvalid reference
Edge.Events#ON_SET_LAST_MESSAGE_TIMESTAMP
- Parameters:
edge
- theMyEdge
.
-
onSetOnline
Called onEdge.Events.ON_SET_ONLINE
event.- Parameters:
edge
- theMyEdge
.isOnline
- true if online, false if offline
-
onSetSumState
Called onEdge.Events.ON_SET_SUM_STATE
event. -
drainToSet
Moves all entries of aLinkedBlockingQueue
to a Set and clears the queue. This is thread-safe.- Parameters:
queue
- theLinkedBlockingQueue
- Returns:
- the
Set
-