Class PersistentEJBTimerService
java.lang.Object
com.sun.ejb.containers.EJBTimerService
org.glassfish.ejb.persistent.timer.PersistentEJBTimerService
public class PersistentEJBTimerService
extends com.sun.ejb.containers.EJBTimerService
Persistent support part of the EJBTimerService
- Author:
- Marina Vatkina
-
Nested Class Summary
Nested classes/interfaces inherited from class com.sun.ejb.containers.EJBTimerService
com.sun.ejb.containers.EJBTimerService.TimerCache -
Field Summary
Fields inherited from class com.sun.ejb.containers.EJBTimerService
ejbContainerUtil, isDas, ownerIdOfThisServer_, STATE_ACTIVE, STATE_CANCELLED, timerCache_, totalTimedObjectsInitialized_ -
Method Summary
Modifier and TypeMethodDescriptionprotected void_createTimer(com.sun.ejb.containers.TimerPrimaryKey timerId, long containerId, long applicationId, Object timedObjectPrimaryKey, String server_name, Date initialExpiration, long intervalDuration, com.sun.ejb.containers.EJBTimerSchedule schedule, jakarta.ejb.TimerConfig timerConfig) Create persistent timer.protected void_destroyTimers(long id, boolean all) protected voidcancelTimer(com.sun.ejb.containers.TimerPrimaryKey timerId) protected voidcancelTimersByKey(long containerId, Object primaryKey) voidcreateSchedules(long containerId, long applicationId, Map<com.sun.enterprise.deployment.MethodDescriptor, List<com.sun.enterprise.deployment.ScheduledTimerDescriptor>> methodDescriptorSchedules, String server_name) Create automatic timers defined by the @Schedule annotation on the EJB bean during deployment to a cluster or the first create-application-ref call after deployment to DAS only.voidcreateSchedulesOnServer(org.glassfish.ejb.deployment.descriptor.EjbDescriptor ejbDescriptor, String server_name) Called in a clustered environment to eagerly create automatic persistent timers on the specific server instance.protected voidexpungeTimer(com.sun.ejb.containers.TimerPrimaryKey timerId, boolean removeTimerBean) protected SerializablegetInfo(com.sun.ejb.containers.TimerPrimaryKey timerId) protected DategetNextTimeout(com.sun.ejb.containers.TimerPrimaryKey timerId) protected Collection<com.sun.ejb.containers.TimerPrimaryKey>getTimerIds(long containerId, Object timedObjectPrimaryKey) Use database query to retrieve persistrent timer ids of all active timers.protected Collection<com.sun.ejb.containers.TimerPrimaryKey>getTimerIds(Collection<Long> containerIds) Return the Ids of active timers owned by EJBs.protected com.sun.ejb.containers.EJBTimerSchedulegetTimerSchedule(com.sun.ejb.containers.TimerPrimaryKey timerId) protected booleanisCancelledByAnotherInstance(com.sun.ejb.containers.RuntimeTimerState timerState) Check if another server instance cancelled this timer.booleanprotected booleanisPersistent(com.sun.ejb.containers.TimerPrimaryKey timerId) protected booleanisValidTimerForThisServer(com.sun.ejb.containers.TimerPrimaryKey timerId, com.sun.ejb.containers.RuntimeTimerState timerState) Persistent timers can be cancelled from another server instanceString[]listTimers(String[] serverIds) Provide a count of timers owned by each serverintmigrateTimers(String fromOwnerId) Take ownership of another server's timers.recoverAndCreateSchedules(long containerId, long applicationId, Map<Method, List<com.sun.enterprise.deployment.ScheduledTimerDescriptor>> schedules, boolean deploy) Recover pre-existing timers associated with the Container identified by the containerId, and create automatic timers defined by the @Schedule annotation on the EJB bean.protected booleanredeliverTimeout(com.sun.ejb.containers.RuntimeTimerState timerState) protected voidresetEJBTimers(String target) protected voidresetLastExpiration(com.sun.ejb.containers.TimerPrimaryKey timerId, com.sun.ejb.containers.RuntimeTimerState timerState) Update database for a persistent timerprotected booleanprotected voidstopTimers(long containerId) protected booleantimerExists(com.sun.ejb.containers.TimerPrimaryKey timerId) Methods inherited from class com.sun.ejb.containers.EJBTimerService
_getNextTimeout, addTimerSynchronization, addTimerSynchronization, addToSchedules, calcNextFixedRateExpiration, calcNextFixedRateExpiration, cancelNonPersistentTimer, cancelTimerSynchronization, createEJBException, createSchedules, destroyAllTimers, destroyTimers, getContainer, getEJBTimerService, getEJBTimerService, getEJBTimerService, getMaxRedeliveries, getNextScheduledTimeout, getNonPersistentActiveTimerIdsByThisServer, getNonPersistentTimer, getOwnerIdOfThisServer, getTimerClassLoader, getTimerState, getValidEJBTimerService, isEJBTimerServiceLoaded, onShutdown, scheduleTask, setEJBTimerService, stopTimers, timerStateToString
-
Method Details
-
listTimers
Provide a count of timers owned by each server- Overrides:
listTimersin classcom.sun.ejb.containers.EJBTimerService
-
migrateTimers
Take ownership of another server's timers.- Overrides:
migrateTimersin classcom.sun.ejb.containers.EJBTimerService
-
isPersistent
public boolean isPersistent()- Overrides:
isPersistentin classcom.sun.ejb.containers.EJBTimerService
-
cancelTimersByKey
- Overrides:
cancelTimersByKeyin classcom.sun.ejb.containers.EJBTimerService
-
stopTimers
protected void stopTimers(long containerId) - Overrides:
stopTimersin classcom.sun.ejb.containers.EJBTimerService
-
_destroyTimers
protected void _destroyTimers(long id, boolean all) - Overrides:
_destroyTimersin classcom.sun.ejb.containers.EJBTimerService
-
_createTimer
protected void _createTimer(com.sun.ejb.containers.TimerPrimaryKey timerId, long containerId, long applicationId, Object timedObjectPrimaryKey, String server_name, Date initialExpiration, long intervalDuration, com.sun.ejb.containers.EJBTimerSchedule schedule, jakarta.ejb.TimerConfig timerConfig) throws Exception Create persistent timer.- Overrides:
_createTimerin classcom.sun.ejb.containers.EJBTimerService- Throws:
Exception
-
recoverAndCreateSchedules
protected Map<com.sun.ejb.containers.TimerPrimaryKey,Method> recoverAndCreateSchedules(long containerId, long applicationId, Map<Method, List<com.sun.enterprise.deployment.ScheduledTimerDescriptor>> schedules, boolean deploy) Recover pre-existing timers associated with the Container identified by the containerId, and create automatic timers defined by the @Schedule annotation on the EJB bean. If it is called from deploy on a non-clustered instance, both persistent and non-persistent timers will be created. Otherwise only non-persistent timers are created by this method.- Overrides:
recoverAndCreateSchedulesin classcom.sun.ejb.containers.EJBTimerService- Returns:
- a Map of both, restored and created timers, where the key is TimerPrimaryKey and the value is the Method to be executed by the container when the timer with this PK times out.
-
createSchedulesOnServer
public void createSchedulesOnServer(org.glassfish.ejb.deployment.descriptor.EjbDescriptor ejbDescriptor, String server_name) Called in a clustered environment to eagerly create automatic persistent timers on the specific server instance.- Overrides:
createSchedulesOnServerin classcom.sun.ejb.containers.EJBTimerService
-
createSchedules
public void createSchedules(long containerId, long applicationId, Map<com.sun.enterprise.deployment.MethodDescriptor, List<com.sun.enterprise.deployment.ScheduledTimerDescriptor>> methodDescriptorSchedules, String server_name) Create automatic timers defined by the @Schedule annotation on the EJB bean during deployment to a cluster or the first create-application-ref call after deployment to DAS only. Only persistent schedule based timers for the containerId that has no timers associated with it, will be created. And no timers will be scheduled.- Overrides:
createSchedulesin classcom.sun.ejb.containers.EJBTimerService
-
getTimerIds
protected Collection<com.sun.ejb.containers.TimerPrimaryKey> getTimerIds(long containerId, Object timedObjectPrimaryKey) Use database query to retrieve persistrent timer ids of all active timers. Results must be transactionally consistent. E.g., a client calling getTimerIds within a transaction where a timer has been created but not committed "sees" the timer but a client in a different transaction doesn't. Called by EJBTimerServiceWrapper when caller calls getTimers.- Overrides:
getTimerIdsin classcom.sun.ejb.containers.EJBTimerService- Parameters:
timedObjectPrimaryKey- can be null if not entity bean- Returns:
- Collection of Timer Ids.
-
getTimerIds
protected Collection<com.sun.ejb.containers.TimerPrimaryKey> getTimerIds(Collection<Long> containerIds) Return the Ids of active timers owned by EJBs. Primary key of entity bean is unnecessary because all of the active timers are expected- Overrides:
getTimerIdsin classcom.sun.ejb.containers.EJBTimerService- Returns:
- Collection of Timer Ids.
-
cancelTimer
protected void cancelTimer(com.sun.ejb.containers.TimerPrimaryKey timerId) throws jakarta.ejb.FinderException, Exception - Overrides:
cancelTimerin classcom.sun.ejb.containers.EJBTimerService- Throws:
jakarta.ejb.FinderExceptionException
-
getNextTimeout
protected Date getNextTimeout(com.sun.ejb.containers.TimerPrimaryKey timerId) throws jakarta.ejb.FinderException - Overrides:
getNextTimeoutin classcom.sun.ejb.containers.EJBTimerService- Throws:
jakarta.ejb.FinderException
-
getInfo
protected Serializable getInfo(com.sun.ejb.containers.TimerPrimaryKey timerId) throws jakarta.ejb.FinderException - Overrides:
getInfoin classcom.sun.ejb.containers.EJBTimerService- Throws:
jakarta.ejb.FinderException
-
isPersistent
protected boolean isPersistent(com.sun.ejb.containers.TimerPrimaryKey timerId) throws jakarta.ejb.FinderException - Overrides:
isPersistentin classcom.sun.ejb.containers.EJBTimerService- Throws:
jakarta.ejb.FinderException
-
timerExists
protected boolean timerExists(com.sun.ejb.containers.TimerPrimaryKey timerId) - Overrides:
timerExistsin classcom.sun.ejb.containers.EJBTimerService
-
getTimerSchedule
protected com.sun.ejb.containers.EJBTimerSchedule getTimerSchedule(com.sun.ejb.containers.TimerPrimaryKey timerId) throws jakarta.ejb.FinderException - Overrides:
getTimerSchedulein classcom.sun.ejb.containers.EJBTimerService- Throws:
jakarta.ejb.FinderException
-
isCancelledByAnotherInstance
protected boolean isCancelledByAnotherInstance(com.sun.ejb.containers.RuntimeTimerState timerState) Check if another server instance cancelled this timer.- Overrides:
isCancelledByAnotherInstancein classcom.sun.ejb.containers.EJBTimerService
-
redeliverTimeout
protected boolean redeliverTimeout(com.sun.ejb.containers.RuntimeTimerState timerState) - Overrides:
redeliverTimeoutin classcom.sun.ejb.containers.EJBTimerService
-
isValidTimerForThisServer
protected boolean isValidTimerForThisServer(com.sun.ejb.containers.TimerPrimaryKey timerId, com.sun.ejb.containers.RuntimeTimerState timerState) Persistent timers can be cancelled from another server instance- Overrides:
isValidTimerForThisServerin classcom.sun.ejb.containers.EJBTimerService
-
resetLastExpiration
protected void resetLastExpiration(com.sun.ejb.containers.TimerPrimaryKey timerId, com.sun.ejb.containers.RuntimeTimerState timerState) Update database for a persistent timer- Overrides:
resetLastExpirationin classcom.sun.ejb.containers.EJBTimerService
-
expungeTimer
protected void expungeTimer(com.sun.ejb.containers.TimerPrimaryKey timerId, boolean removeTimerBean) - Overrides:
expungeTimerin classcom.sun.ejb.containers.EJBTimerService
-
stopOnFailure
protected boolean stopOnFailure()- Overrides:
stopOnFailurein classcom.sun.ejb.containers.EJBTimerService
-
resetEJBTimers
- Overrides:
resetEJBTimersin classcom.sun.ejb.containers.EJBTimerService
-