Class 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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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)
      Create persistent timer.
      protected void _destroyTimers​(long id, boolean all)  
      protected void cancelTimer​(com.sun.ejb.containers.TimerPrimaryKey timerId)  
      protected void cancelTimersByKey​(long containerId, Object primaryKey)  
      void createSchedules​(long containerId, long applicationId, Map<com.sun.enterprise.deployment.MethodDescriptor,​List<org.glassfish.ejb.deployment.descriptor.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.
      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.
      protected void expungeTimer​(com.sun.ejb.containers.TimerPrimaryKey timerId, boolean removeTimerBean)  
      protected Serializable getInfo​(com.sun.ejb.containers.TimerPrimaryKey timerId)  
      protected Date getNextTimeout​(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.EJBTimerSchedule getTimerSchedule​(com.sun.ejb.containers.TimerPrimaryKey timerId)  
      protected boolean isCancelledByAnotherInstance​(com.sun.ejb.containers.RuntimeTimerState timerState)
      Check if another server instance cancelled this timer.
      boolean isPersistent()  
      protected boolean isPersistent​(com.sun.ejb.containers.TimerPrimaryKey timerId)  
      protected boolean isValidTimerForThisServer​(com.sun.ejb.containers.TimerPrimaryKey timerId, com.sun.ejb.containers.RuntimeTimerState timerState)
      Persistent timers can be cancelled from another server instance
      String[] listTimers​(String[] serverIds)
      Provide a count of timers owned by each server
      int migrateTimers​(String fromOwnerId)
      Take ownership of another server's timers.
      protected Map<com.sun.ejb.containers.TimerPrimaryKey,​Method> recoverAndCreateSchedules​(long containerId, long applicationId, Map<Method,​List<org.glassfish.ejb.deployment.descriptor.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 boolean redeliverTimeout​(com.sun.ejb.containers.RuntimeTimerState timerState)  
      protected void resetEJBTimers​(String target)  
      protected void resetLastExpiration​(com.sun.ejb.containers.TimerPrimaryKey timerId, com.sun.ejb.containers.RuntimeTimerState timerState)
      Update database for a persistent timer
      protected boolean stopOnFailure()  
      protected void stopTimers​(long containerId)  
      protected boolean timerExists​(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 Detail

      • listTimers

        public String[] listTimers​(String[] serverIds)
        Provide a count of timers owned by each server
        Overrides:
        listTimers in class com.sun.ejb.containers.EJBTimerService
      • migrateTimers

        public int migrateTimers​(String fromOwnerId)
        Take ownership of another server's timers.
        Overrides:
        migrateTimers in class com.sun.ejb.containers.EJBTimerService
      • isPersistent

        public boolean isPersistent()
        Overrides:
        isPersistent in class com.sun.ejb.containers.EJBTimerService
      • cancelTimersByKey

        protected void cancelTimersByKey​(long containerId,
                                         Object primaryKey)
        Overrides:
        cancelTimersByKey in class com.sun.ejb.containers.EJBTimerService
      • stopTimers

        protected void stopTimers​(long containerId)
        Overrides:
        stopTimers in class com.sun.ejb.containers.EJBTimerService
      • _destroyTimers

        protected void _destroyTimers​(long id,
                                      boolean all)
        Overrides:
        _destroyTimers in class com.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:
        _createTimer in class com.sun.ejb.containers.EJBTimerService
        Throws:
        Exception
      • recoverAndCreateSchedules

        protected Map<com.sun.ejb.containers.TimerPrimaryKey,​Method> recoverAndCreateSchedules​(long containerId,
                                                                                                     long applicationId,
                                                                                                     Map<Method,​List<org.glassfish.ejb.deployment.descriptor.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:
        recoverAndCreateSchedules in class com.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:
        createSchedulesOnServer in class com.sun.ejb.containers.EJBTimerService
      • createSchedules

        public void createSchedules​(long containerId,
                                    long applicationId,
                                    Map<com.sun.enterprise.deployment.MethodDescriptor,​List<org.glassfish.ejb.deployment.descriptor.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:
        createSchedules in class com.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:
        getTimerIds in class com.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:
        getTimerIds in class com.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:
        cancelTimer in class com.sun.ejb.containers.EJBTimerService
        Throws:
        jakarta.ejb.FinderException
        Exception
      • getNextTimeout

        protected Date getNextTimeout​(com.sun.ejb.containers.TimerPrimaryKey timerId)
                               throws jakarta.ejb.FinderException
        Overrides:
        getNextTimeout in class com.sun.ejb.containers.EJBTimerService
        Throws:
        jakarta.ejb.FinderException
      • getInfo

        protected Serializable getInfo​(com.sun.ejb.containers.TimerPrimaryKey timerId)
                                throws jakarta.ejb.FinderException
        Overrides:
        getInfo in class com.sun.ejb.containers.EJBTimerService
        Throws:
        jakarta.ejb.FinderException
      • isPersistent

        protected boolean isPersistent​(com.sun.ejb.containers.TimerPrimaryKey timerId)
                                throws jakarta.ejb.FinderException
        Overrides:
        isPersistent in class com.sun.ejb.containers.EJBTimerService
        Throws:
        jakarta.ejb.FinderException
      • timerExists

        protected boolean timerExists​(com.sun.ejb.containers.TimerPrimaryKey timerId)
        Overrides:
        timerExists in class com.sun.ejb.containers.EJBTimerService
      • getTimerSchedule

        protected com.sun.ejb.containers.EJBTimerSchedule getTimerSchedule​(com.sun.ejb.containers.TimerPrimaryKey timerId)
                                                                    throws jakarta.ejb.FinderException
        Overrides:
        getTimerSchedule in class com.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:
        isCancelledByAnotherInstance in class com.sun.ejb.containers.EJBTimerService
      • redeliverTimeout

        protected boolean redeliverTimeout​(com.sun.ejb.containers.RuntimeTimerState timerState)
        Overrides:
        redeliverTimeout in class com.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:
        isValidTimerForThisServer in class com.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:
        resetLastExpiration in class com.sun.ejb.containers.EJBTimerService
      • expungeTimer

        protected void expungeTimer​(com.sun.ejb.containers.TimerPrimaryKey timerId,
                                    boolean removeTimerBean)
        Overrides:
        expungeTimer in class com.sun.ejb.containers.EJBTimerService
      • stopOnFailure

        protected boolean stopOnFailure()
        Overrides:
        stopOnFailure in class com.sun.ejb.containers.EJBTimerService
      • resetEJBTimers

        protected void resetEJBTimers​(String target)
        Overrides:
        resetEJBTimers in class com.sun.ejb.containers.EJBTimerService