Class PeriodicWriteWorker
- java.lang.Object
-
- io.openems.backend.metadata.odoo.postgres.PeriodicWriteWorker
-
public class PeriodicWriteWorker extends java.lang.Object
This worker combines writes to lastMessage and lastUpdate fields, to avoid DDOSing Odoo/Postgres by writing too often.
-
-
Constructor Summary
Constructors Constructor Description PeriodicWriteWorker(PostgresHandler parent)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static java.util.Set<java.lang.Integer>
drainToSet(java.util.concurrent.LinkedBlockingQueue<java.lang.Integer> queue)
Moves all entries of aLinkedBlockingQueue
to a Set and clears the queue.void
onLastMessage(MyEdge edge)
Called onEdge.Events#ON_SET_LAST_MESSAGE_TIMESTAMP
event.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 Detail
-
PeriodicWriteWorker
public PeriodicWriteWorker(PostgresHandler parent)
-
-
Method Detail
-
start
public void start()
Starts thePeriodicWriteWorker
.
-
stop
public void stop()
Stops thePeriodicWriteWorker
.
-
onLastMessage
public void onLastMessage(MyEdge edge)
Called onEdge.Events#ON_SET_LAST_MESSAGE_TIMESTAMP
event.- Parameters:
edge
- theMyEdge
.
-
onSetOnline
public void onSetOnline(MyEdge edge, boolean isOnline)
Called onEdge.Events.ON_SET_ONLINE
event.- Parameters:
edge
- theMyEdge
.isOnline
- true if online, false if offline
-
onSetSumState
public void onSetSumState(MyEdge edge, Level sumState)
Called onEdge.Events.ON_SET_SUM_STATE
event.
-
drainToSet
protected static java.util.Set<java.lang.Integer> drainToSet(java.util.concurrent.LinkedBlockingQueue<java.lang.Integer> queue)
Moves all entries of aLinkedBlockingQueue
to a Set and clears the queue. This is thread-safe.- Parameters:
queue
- theLinkedBlockingQueue
- Returns:
- the
Set
-
-