Package org.camunda.bpm.engine.rest.impl
Class FetchAndLockHandlerImpl
- java.lang.Object
-
- org.camunda.bpm.engine.rest.impl.FetchAndLockHandlerImpl
-
- All Implemented Interfaces:
java.lang.Runnable,FetchAndLockHandler
public class FetchAndLockHandlerImpl extends java.lang.Object implements java.lang.Runnable, FetchAndLockHandler
- Author:
- Tassilo Weidner
-
-
Field Summary
Fields Modifier and Type Field Description protected SingleConsumerConditionconditionprotected java.lang.ThreadhandlerThreadprotected booleanisRunningprotected booleanisUniqueWorkerRequestprotected static longMAX_BACK_OFF_TIMEprotected static longMAX_REQUEST_TIMEOUTprotected java.util.List<FetchAndLockRequest>newRequestsprotected static longPENDING_REQUEST_FETCH_INTERVALprotected java.util.List<FetchAndLockRequest>pendingRequestsprotected java.util.concurrent.BlockingQueue<FetchAndLockRequest>queueprotected static java.lang.StringUNIQUE_WORKER_REQUEST_PARAM_NAME
-
Constructor Summary
Constructors Constructor Description FetchAndLockHandlerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidacquire()voidaddPendingRequest(FetchExternalTasksExtendedDto dto, javax.ws.rs.container.AsyncResponse asyncResponse, ProcessEngine processEngine)Invoked if a fetch and lock request has been sent by the clientprotected voidaddRequest(FetchAndLockRequest request)voidcontextInitialized(javax.servlet.ServletContextEvent servletContextEvent)Invoked on initialization of the servlet contextprotected voiderrorTooManyRequests(javax.ws.rs.container.AsyncResponse asyncResponse)protected java.util.List<LockedExternalTaskDto>executeFetchAndLock(FetchExternalTasksExtendedDto fetchingDto, ProcessEngine processEngine)java.util.List<FetchAndLockRequest>getPendingRequests()protected ProcessEnginegetProcessEngine(FetchAndLockRequest request)protected booleanisExpired(FetchAndLockRequest request)protected voidparseUniqueWorkerRequestParam(java.lang.String uniqueWorkerRequestParam)protected voidrejectPendingRequests()protected voidremoveDuplicates()voidrun()voidshutdown()Receives a notification that the engine rest web application is about to be shut downvoidstart()Receives a notification that the engine rest web application initialization has been startedprotected voidsuspend(long millis)protected voidsuspendAcquisition(long millis)protected FetchAndLockResulttryFetchAndLock(FetchAndLockRequest request)
-
-
-
Field Detail
-
UNIQUE_WORKER_REQUEST_PARAM_NAME
protected static final java.lang.String UNIQUE_WORKER_REQUEST_PARAM_NAME
- See Also:
- Constant Field Values
-
PENDING_REQUEST_FETCH_INTERVAL
protected static final long PENDING_REQUEST_FETCH_INTERVAL
- See Also:
- Constant Field Values
-
MAX_BACK_OFF_TIME
protected static final long MAX_BACK_OFF_TIME
- See Also:
- Constant Field Values
-
MAX_REQUEST_TIMEOUT
protected static final long MAX_REQUEST_TIMEOUT
- See Also:
- Constant Field Values
-
condition
protected SingleConsumerCondition condition
-
queue
protected java.util.concurrent.BlockingQueue<FetchAndLockRequest> queue
-
pendingRequests
protected java.util.List<FetchAndLockRequest> pendingRequests
-
newRequests
protected java.util.List<FetchAndLockRequest> newRequests
-
handlerThread
protected java.lang.Thread handlerThread
-
isRunning
protected volatile boolean isRunning
-
isUniqueWorkerRequest
protected boolean isUniqueWorkerRequest
-
-
Method Detail
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
acquire
protected void acquire()
-
removeDuplicates
protected void removeDuplicates()
-
start
public void start()
Description copied from interface:FetchAndLockHandlerReceives a notification that the engine rest web application initialization has been started- Specified by:
startin interfaceFetchAndLockHandler
-
shutdown
public void shutdown()
Description copied from interface:FetchAndLockHandlerReceives a notification that the engine rest web application is about to be shut down- Specified by:
shutdownin interfaceFetchAndLockHandler
-
suspend
protected void suspend(long millis)
-
suspendAcquisition
protected void suspendAcquisition(long millis)
-
addRequest
protected void addRequest(FetchAndLockRequest request)
-
tryFetchAndLock
protected FetchAndLockResult tryFetchAndLock(FetchAndLockRequest request)
-
executeFetchAndLock
protected java.util.List<LockedExternalTaskDto> executeFetchAndLock(FetchExternalTasksExtendedDto fetchingDto, ProcessEngine processEngine)
-
errorTooManyRequests
protected void errorTooManyRequests(javax.ws.rs.container.AsyncResponse asyncResponse)
-
rejectPendingRequests
protected void rejectPendingRequests()
-
getProcessEngine
protected ProcessEngine getProcessEngine(FetchAndLockRequest request)
-
isExpired
protected boolean isExpired(FetchAndLockRequest request)
-
addPendingRequest
public void addPendingRequest(FetchExternalTasksExtendedDto dto, javax.ws.rs.container.AsyncResponse asyncResponse, ProcessEngine processEngine)
Description copied from interface:FetchAndLockHandlerInvoked if a fetch and lock request has been sent by the client- Specified by:
addPendingRequestin interfaceFetchAndLockHandler- Parameters:
dto- which is supposed to hold the payloadasyncResponse- provides means for asynchronous server side response processingprocessEngine- provides the process engine context of the respective request
-
contextInitialized
public void contextInitialized(javax.servlet.ServletContextEvent servletContextEvent)
Description copied from interface:FetchAndLockHandlerInvoked on initialization of the servlet context- Specified by:
contextInitializedin interfaceFetchAndLockHandler- Parameters:
servletContextEvent- provides the servlet context
-
parseUniqueWorkerRequestParam
protected void parseUniqueWorkerRequestParam(java.lang.String uniqueWorkerRequestParam)
-
getPendingRequests
public java.util.List<FetchAndLockRequest> getPendingRequests()
-
-