Class ReducedPropagationManager
- java.lang.Object
-
- org.swisspush.gateleen.hook.reducedpropagation.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]
-
-
Field Summary
Fields Modifier and Type Field Description static StringLOCK_REQUESTERstatic StringMANAGER_QUEUE_PREFIXstatic StringPROCESS_EXPIRED_QUEUES_LOCKstatic StringPROCESSOR_ADDRESS
-
Constructor Summary
Constructors Constructor Description ReducedPropagationManager(io.vertx.core.Vertx vertx, ReducedPropagationStorage storage, 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.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.voidstartExpiredQueueProcessing(long intervalMs)Start the periodic check to process expired queues.
-
-
-
Field Detail
-
PROCESS_EXPIRED_QUEUES_LOCK
public static final String PROCESS_EXPIRED_QUEUES_LOCK
- See Also:
- Constant Field Values
-
LOCK_REQUESTER
public static final String LOCK_REQUESTER
- See Also:
- Constant Field Values
-
PROCESSOR_ADDRESS
public static final String PROCESSOR_ADDRESS
- See Also:
- Constant Field Values
-
MANAGER_QUEUE_PREFIX
public static final String MANAGER_QUEUE_PREFIX
- See Also:
- Constant Field Values
-
-
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 requesttargetUri- targetUri of the queued requestqueueHeaders- headers of the queued requestpayload- payload of the queued requestqueue- the queue namepropagationIntervalMs- the propagation interval in milliseconds defining how long to prevent from propagating changes to the resourcedoneHandler- a handler which is called as soon as the request is written into the queue.- Returns:
- a future when the processing is done
-
-