Class ARequestQueue
- java.lang.Object
-
- com.netscape.cmscore.request.ARequestQueue
-
- All Implemented Interfaces:
IRequestQueue
- Direct Known Subclasses:
RequestQueue
public abstract class ARequestQueue extends java.lang.Object implements IRequestQueue
The ARequestQueue class is an abstract class that implements most portions of the IRequestQueue interface. This includes the state engine as defined for processing IRequest objects.!Put state machine description here!
This class defines several abstract protected functions that need to be defined by the concrete implementation. In particular, this class does not implement the operations for storing requests persistantly.
This class also provides several accessor functions for setting fields in the IRequest object. These functions are provided as an aid to saving and restoring the state in the database.
This class also implements the locking operations specified by the IRequestQueue interface.
- Version:
- $Revision$ $Date$
- Author:
- thayes
-
-
Field Summary
Fields Modifier and Type Field Description static org.slf4j.Loggerloggerstatic java.lang.StringREQUEST_VERSIONglobal request version for tracking request changes.
-
Constructor Summary
Constructors Modifier Constructor Description protectedARequestQueue(IPolicy policy, IService service, INotify notify, INotify pendingNotify)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidaddRequest(IRequest request)Add the request to the store.voidapproveRequest(IRequest r)Implements IRequestQueue.approveRequestvoidcancelRequest(IRequest r)Implments IRequestQueue.cancelRequestIRequestcloneAndMarkPending(IRequest r)Implements IRequestQueue.cloneAndMarkPendingIRequestcloneRequest(IRequest r)Implements IRequestQueue.cloneRequestprotected IRequestcreateRequest(RequestId id, java.lang.String requestType)protected access for creating a new Request objectIRequestfindRequest(RequestId id)Implements IRequestQueue.findRequestINotifygetPendingNotify()Retrieves the notifier for pending request.protected abstract java.util.Enumeration<RequestId>getRawList()Get complete list of RequestId values found i this queue.IRequestSchedulergetRequestScheduler()Gets request scheduler.protected java.lang.StringgetUserIdentity()get the identity of the current userIRequestListlistRequests()Implements IRequestQueue.listRequestsIRequestListlistRequestsByStatus(RequestStatus s)Implements IRequestQueue.listRequestsByStatusprotected voidlogChange(IRequest request)log a change in the request statusvoidmarkAsServiced(IRequest r)caller must lock request and release requestvoidmarkRequestPending(IRequest r)Implements IRequestQueue.markRequestPendingprotected abstract voidmodifyRequest(IRequest request)Modify the request in the store.protected abstract RequestIdnewEphemeralRequestId()Create a new synchronous request IDIRequestnewRequest(java.lang.String requestType)Creates a new request object.IRequestnewRequest(java.lang.String requestType, boolean ephemeral)Implements IRequestQueue.newRequestprotected abstract RequestIdnewRequestId()Create a new (unique) RequestId.voidprocessRequest(IRequest r)Implements IRequestQueue.processRequestprotected abstract IRequestreadRequest(RequestId id)Read a request from the persistant store.voidrecover()New non-blocking recover method.voidrecoverWillBlock()recover from a crash.voidrejectRequest(IRequest r)Implements IRequestQueue.rejectRequestvoidreleaseRequest(IRequest request)Implements IRequestQueue.releaseRequestprotected voidsetCreationTime(IRequest request, java.util.Date date)protected access for setting the creation time of a request.protected voidsetModificationTime(IRequest request, java.util.Date date)protected access for setting the modification time of a request.voidsetRequestScheduler(IRequestScheduler scheduler)Sets request scheduler.protected voidsetRequestStatus(IRequest request, RequestStatus status)protected access for setting the current state of a request.voidupdateRequest(IRequest r)Updates the request in the permanent data store.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.netscape.certsrv.request.IRequestQueue
findRequestBySourceId, findRequestsBySourceId, getLastRequestIdInRange, getPagedRequests, getPagedRequestsByFilter, getPagedRequestsByFilter, getPagedRequestsByFilter, getPublishingStatus, getRequestRepository, listRequestsByFilter, listRequestsByFilter, listRequestsByFilter, removeAllObjects, resetSerialNumber, setPublishingStatus
-
-
-
-
Field Detail
-
logger
public static org.slf4j.Logger logger
-
REQUEST_VERSION
public static final java.lang.String REQUEST_VERSION
global request version for tracking request changes.- See Also:
- Constant Field Values
-
-
Method Detail
-
newRequestId
protected abstract RequestId newRequestId() throws EBaseException
Create a new (unique) RequestId. (abstract)This method must be implemented by the specialized class to generate a new id from data in the persistant store. This id is used to create a new request object.
- Returns:
- a new RequestId object.
- Throws:
EBaseException- indicates that creation of the new id could not be completed.- See Also:
RequestId
-
newEphemeralRequestId
protected abstract RequestId newEphemeralRequestId()
Create a new synchronous request ID
-
readRequest
protected abstract IRequest readRequest(RequestId id)
Read a request from the persistant store. (abstract)This function is called to create the in-memory version of a request object.
The implementation of this object can use the createRequest member function to create a new instance of an IRequest, and use the setRequestStatus, setCreationTime and setModificationTime functions to set those values.
- Parameters:
id- the id of the request to read.- Returns:
- a new IRequest object. null is returned if the object cannot be located.
- Throws:
EBaseException- TODO: this is not implemented yet- See Also:
createRequest(com.netscape.certsrv.request.RequestId, java.lang.String),setRequestStatus(com.netscape.certsrv.request.IRequest, com.netscape.certsrv.request.RequestStatus),setModificationTime(com.netscape.certsrv.request.IRequest, java.util.Date),setCreationTime(com.netscape.certsrv.request.IRequest, java.util.Date)
-
addRequest
protected abstract void addRequest(IRequest request) throws EBaseException
Add the request to the store. (abstract)This function is called when a new request immediately after creating a new request.
- Parameters:
request- the request to add.- Throws:
EBaseException- TODO: this is not implemented yet
-
modifyRequest
protected abstract void modifyRequest(IRequest request)
Modify the request in the store. (abstract)Update the persistant copy of this request with the current values in the object.
Currently there are no hints for what has changed, so the entire request should be updated.
- Parameters:
request-- Throws:
EBaseException- TODO: this is not implemented yet
-
getRawList
protected abstract java.util.Enumeration<RequestId> getRawList()
Get complete list of RequestId values found i this queue.This method can form the basis for creating other types of search/list operations (although there are probably more efficient ways of doing this. ARequestQueue implements default versions of some of the searching by using this method as a basis.
TODO: return IRequestList -or- just use listRequests as the basic engine.
- Returns:
- an Enumeration that generates RequestId objects.
-
setRequestStatus
protected final void setRequestStatus(IRequest request, RequestStatus status)
protected access for setting the current state of a request.- Parameters:
request- The request to be modified.status- The new value for the request status.
-
setModificationTime
protected final void setModificationTime(IRequest request, java.util.Date date)
protected access for setting the modification time of a request.- Parameters:
request- The request to be modified.date- The new value for the time.
-
setCreationTime
protected final void setCreationTime(IRequest request, java.util.Date date)
protected access for setting the creation time of a request.- Parameters:
request- The request to be modified.date- The new value for the time.
-
createRequest
protected final IRequest createRequest(RequestId id, java.lang.String requestType)
protected access for creating a new Request object- Parameters:
id- The identifier for the new request- Returns:
- A new request object. The caller should fill in other data values from the datastore.
-
newRequest
public IRequest newRequest(java.lang.String requestType) throws EBaseException
Description copied from interface:IRequestQueueCreates a new request object. A request id is assigned to it - see IRequest.getRequestId, and the status is set to RequestStatus.BEGINThe request is LOCKED. The caller MUST release the request object by calling releaseRequest().
TODO: provide other required values (such as type and sourceId)
- Specified by:
newRequestin interfaceIRequestQueue- Parameters:
requestType- request type- Returns:
- new request
- Throws:
EBaseException- failed to create new request
-
newRequest
public IRequest newRequest(java.lang.String requestType, boolean ephemeral) throws EBaseException
Implements IRequestQueue.newRequest- Specified by:
newRequestin interfaceIRequestQueue- Parameters:
requestType- - request typeephemeral- - is the request ephemeral?- Returns:
- new request
- Throws:
EBaseException- failed to create new request- See Also:
IRequestQueue.newRequest(java.lang.String, boolean)
-
cloneRequest
public IRequest cloneRequest(IRequest r) throws EBaseException
Implements IRequestQueue.cloneRequest- Specified by:
cloneRequestin interfaceIRequestQueue- Parameters:
r- request to be cloned- Returns:
- cloned request
- Throws:
EBaseException- failed to clone request- See Also:
IRequestQueue.cloneRequest(com.netscape.certsrv.request.IRequest)
-
findRequest
public IRequest findRequest(RequestId id) throws EBaseException
Implements IRequestQueue.findRequest- Specified by:
findRequestin interfaceIRequestQueue- Parameters:
id- request id- Returns:
- found request
- Throws:
EBaseException- failed to access request queue- See Also:
IRequestQueue.findRequest(com.netscape.certsrv.request.RequestId)
-
setRequestScheduler
public void setRequestScheduler(IRequestScheduler scheduler)
Description copied from interface:IRequestQueueSets request scheduler.- Specified by:
setRequestSchedulerin interfaceIRequestQueue- Parameters:
scheduler- request scheduler
-
getRequestScheduler
public IRequestScheduler getRequestScheduler()
Description copied from interface:IRequestQueueGets request scheduler.- Specified by:
getRequestSchedulerin interfaceIRequestQueue- Returns:
- request scheduler
-
processRequest
public final void processRequest(IRequest r) throws EBaseException
Implements IRequestQueue.processRequest- Specified by:
processRequestin interfaceIRequestQueue- Parameters:
r- request to be processed- Throws:
EBaseException- failed to process request- See Also:
IRequestQueue.processRequest(com.netscape.certsrv.request.IRequest)
-
markRequestPending
public final void markRequestPending(IRequest r) throws EBaseException
Implements IRequestQueue.markRequestPending- Specified by:
markRequestPendingin interfaceIRequestQueue- Parameters:
r- the request to mark PENDING- Throws:
EBaseException- failed to mark request as pending- See Also:
IRequestQueue.markRequestPending(com.netscape.certsrv.request.IRequest)
-
cloneAndMarkPending
public IRequest cloneAndMarkPending(IRequest r) throws EBaseException
Implements IRequestQueue.cloneAndMarkPending- Specified by:
cloneAndMarkPendingin interfaceIRequestQueue- Parameters:
r- request to be cloned- Returns:
- cloned request mark PENDING
- Throws:
EBaseException- failed to clone or mark request- See Also:
IRequestQueue.cloneAndMarkPending(com.netscape.certsrv.request.IRequest)
-
approveRequest
public final void approveRequest(IRequest r) throws EBaseException
Implements IRequestQueue.approveRequest- Specified by:
approveRequestin interfaceIRequestQueue- Parameters:
r- the request that is being approved- Throws:
EBaseException- failed to approve request- See Also:
IRequestQueue.approveRequest(com.netscape.certsrv.request.IRequest)
-
rejectRequest
public final void rejectRequest(IRequest r) throws EBaseException
Implements IRequestQueue.rejectRequest- Specified by:
rejectRequestin interfaceIRequestQueue- Parameters:
r- the request that is being rejected- Throws:
EBaseException- failed to reject request- See Also:
IRequestQueue.rejectRequest(com.netscape.certsrv.request.IRequest)
-
cancelRequest
public final void cancelRequest(IRequest r) throws EBaseException
Implments IRequestQueue.cancelRequest- Specified by:
cancelRequestin interfaceIRequestQueue- Parameters:
r- the request that is being canceled- Throws:
EBaseException- failed to cancel request- See Also:
IRequestQueue.cancelRequest(com.netscape.certsrv.request.IRequest)
-
markAsServiced
public final void markAsServiced(IRequest r)
caller must lock request and release request- Specified by:
markAsServicedin interfaceIRequestQueue- Parameters:
r- request
-
listRequests
public IRequestList listRequests()
Implements IRequestQueue.listRequestsShould be overridden by the specialized class if a more efficient method is available for implementing this operation.
- Specified by:
listRequestsin interfaceIRequestQueue- Returns:
- request list
- See Also:
IRequestQueue.listRequests()
-
listRequestsByStatus
public IRequestList listRequestsByStatus(RequestStatus s)
Implements IRequestQueue.listRequestsByStatusShould be overridden by the specialized class if a more efficient method is available for implementing this operation.
- Specified by:
listRequestsByStatusin interfaceIRequestQueue- Parameters:
s- request status- Returns:
- request list
- See Also:
IRequestQueue.listRequestsByStatus(com.netscape.certsrv.request.RequestStatus)
-
releaseRequest
public final void releaseRequest(IRequest request)
Implements IRequestQueue.releaseRequest- Specified by:
releaseRequestin interfaceIRequestQueue- Parameters:
request- request- See Also:
IRequestQueue.releaseRequest(com.netscape.certsrv.request.IRequest)
-
updateRequest
public void updateRequest(IRequest r)
Description copied from interface:IRequestQueueUpdates the request in the permanent data store.This call can be made after changing a value like source id or owner, to force the new value to be written.
The request must be locked to make this call.
- Specified by:
updateRequestin interfaceIRequestQueue- Parameters:
r- the request that is being updated
-
logChange
protected void logChange(IRequest request)
log a change in the request status
-
getUserIdentity
protected java.lang.String getUserIdentity()
get the identity of the current user
-
recover
public void recover()
New non-blocking recover method.- Specified by:
recoverin interfaceIRequestQueue
-
recoverWillBlock
public void recoverWillBlock()
recover from a crash. Resends all requests that are in the APPROVED state.
-
getPendingNotify
public INotify getPendingNotify()
Description copied from interface:IRequestQueueRetrieves the notifier for pending request.- Specified by:
getPendingNotifyin interfaceIRequestQueue- Returns:
- notifier for pending request
-
-