Class ReducedPropagationManager


  • public class ReducedPropagationManager
    extends java.lang.Object
    Manager class for the reduced propagation feature. The manager starts timers based on incoming requests. The timers periodically check whether there are expired queues to process.
    Author:
    https://github.com/mcweba [Marc-Andre Weber]
    • Constructor Summary

      Constructors 
      Constructor Description
      ReducedPropagationManager​(io.vertx.core.Vertx vertx, ReducedPropagationStorage storage, org.swisspush.gateleen.queue.queuing.RequestQueue requestQueue, org.swisspush.gateleen.core.lock.Lock lock)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      io.vertx.core.Future<java.lang.Void> processIncomingRequest​(io.vertx.core.http.HttpMethod method, java.lang.String targetUri, io.vertx.core.MultiMap queueHeaders, io.vertx.core.buffer.Buffer payload, java.lang.String queue, long propagationIntervalMs, io.vertx.core.Handler<java.lang.Void> doneHandler)
      The processing of incoming requests contains the following steps: Lock the originally defined queue and enqueue the request Add the queue name to the storage with an expiration value based on the propagationIntervalMs parameter When the queue name is already in the storage, a running timer exists.
      void startExpiredQueueProcessing​(long intervalMs)
      Start the periodic check to process expired queues.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PROCESS_EXPIRED_QUEUES_LOCK

        public static final java.lang.String PROCESS_EXPIRED_QUEUES_LOCK
        See Also:
        Constant Field Values
      • PROCESSOR_ADDRESS

        public static final java.lang.String PROCESSOR_ADDRESS
        See Also:
        Constant Field Values
      • MANAGER_QUEUE_PREFIX

        public static final java.lang.String MANAGER_QUEUE_PREFIX
        See Also:
        Constant Field Values
    • Constructor Detail

      • ReducedPropagationManager

        public ReducedPropagationManager​(io.vertx.core.Vertx vertx,
                                         ReducedPropagationStorage storage,
                                         org.swisspush.gateleen.queue.queuing.RequestQueue requestQueue,
                                         org.swisspush.gateleen.core.lock.Lock lock)
    • Method Detail

      • startExpiredQueueProcessing

        public void startExpiredQueueProcessing​(long intervalMs)
        Start the periodic check to process expired queues.
        Parameters:
        intervalMs - interval in milliseconds
      • processIncomingRequest

        public io.vertx.core.Future<java.lang.Void> processIncomingRequest​(io.vertx.core.http.HttpMethod method,
                                                                           java.lang.String targetUri,
                                                                           io.vertx.core.MultiMap queueHeaders,
                                                                           io.vertx.core.buffer.Buffer payload,
                                                                           java.lang.String queue,
                                                                           long propagationIntervalMs,
                                                                           io.vertx.core.Handler<java.lang.Void> doneHandler)
        The processing of incoming requests contains the following steps:
        • Lock the originally defined queue and enqueue the request
        • Add the queue name to the storage with an expiration value based on the propagationIntervalMs parameter
        • When the queue name is already in the storage, a running timer exists. Nothing more to do
        • When the queue name not exists in the storage, a new timer was started. Enqueue the request without payload into an additional locked 'manager' queue
        Parameters:
        method - http method of the queued request
        targetUri - targetUri of the queued request
        queueHeaders - headers of the queued request
        payload - payload of the queued request
        queue - the queue name
        propagationIntervalMs - the propagation interval in milliseconds defining how long to prevent from propagating changes to the resource
        doneHandler - a handler which is called as soon as the request is written into the queue.
        Returns:
        a future when the processing is done