Class 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 Detail

      • PeriodicWriteWorker

        public PeriodicWriteWorker​(PostgresHandler parent)
    • Method Detail

      • onLastMessage

        public void onLastMessage​(MyEdge edge)
        Called on Edge.Events#ON_SET_LAST_MESSAGE_TIMESTAMP event.
        Parameters:
        edge - the MyEdge.
      • onSetOnline

        public void onSetOnline​(MyEdge edge,
                                boolean isOnline)
        Called on Edge.Events.ON_SET_ONLINE event.
        Parameters:
        edge - the MyEdge.
        isOnline - true if online, false if offline
      • drainToSet

        protected static java.util.Set<java.lang.Integer> drainToSet​(java.util.concurrent.LinkedBlockingQueue<java.lang.Integer> queue)
        Moves all entries of a LinkedBlockingQueue to a Set and clears the queue. This is thread-safe.
        Parameters:
        queue - the LinkedBlockingQueue
        Returns:
        the Set