Class ReducedPropagationManager


  • public class ReducedPropagationManager
    extends 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 Detail

      • ReducedPropagationManager

        public ReducedPropagationManager​(io.vertx.core.Vertx vertx,
                                         ReducedPropagationStorage storage,
                                         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.Promise<Void> processIncomingRequest​(io.vertx.core.http.HttpMethod method,
                                                                  String targetUri,
                                                                  io.vertx.core.MultiMap queueHeaders,
                                                                  io.vertx.core.buffer.Buffer payload,
                                                                  String queue,
                                                                  long propagationIntervalMs,
                                                                  io.vertx.core.Handler<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