Shutdown Implementation

Document created by resplin Employee on Jun 6, 2015
Version 1Show Document
  • View in full screen mode

Obsolete Pages{{Obsolete}}

The official documentation is at: http://docs.alfresco.com



The following describs the Alfresco shutdown process.


Normal Shutdown


Upon receiving a shutdown event Alfresco begins its shutdown process.


  • Some current units of work will continue to execute until completion.  
  • If units of work are long running or require the use of services which are no longer available they will be aborted.
  • Database connections, ftp handles, cifs handles etc are released.

AbstractLifecycleBean


The org.alfresco.util.AbstractLifecycleBean is a base class for beans managed by the spring framework.



    /**
     * Callback for initialising Component on first startup of Alfresco Server
     *
     * @param event
     */
    protected abstract void onBootstrap(ApplicationEvent event);
   
    /**
     * Callback for terminating Component on shutdown of Alfresco Server
     *
     * @param event
     */
    protected abstract void onShutdown(ApplicationEvent event);  

The onShutdown event handler can not assume that any resources are available,
in particular transactions.


VmShutdownListener



* A class that keeps track of the VM shutdown status.  It can be
* used by threads as a singleton to check if the
* VM shutdown status has been activated.



The VM shutdown listeners are listening for termination of the Java VM.

Some notes about vm listeners.   


  • The vm will only start shutting down after the last non-deamon thread has exited.
  • A Vm shutdown hook can not call System.exit()  (Which will cause a hang.)

Shutdown Clean


This would prevent new units of work from starting but allow current work to complete. Alfresco does not implement this at the moment, although it is being considered.

The features would include.


  • There needs to be a new shutdown framework.
  • There may still need to be some sort of cut off for long running transactions, but the action taken should be configurable rather than prescribed.
  • Services are terminated in an orderly pre-defined order - which is not the same as the order that they were created by Spring (at minimum there needs to be support of reverse order)
  • The action framework should check that shutdown is not in progress before starting new actions.
  • The timer framework should check that shutdown is not in progress before starting new actions.
  • All long running services need to to be observing the shutdown service to handle shutdown correctly.
  • All user interfaces need to be shutdown.
  • The logging service needs to remain active until very late in the shutdown process (At the moment it terminates too early.)

Shutdown Backstop


The shutdown backstop is a spring bean that prevents an Alfresco server from failing to shut down.   Depending upon the work in progress Alfresco may occasionally take too long to shut down (for example if it is waiting upon a remote resource.)   The backstop gives Alfresco a reasonable time to shutdown normally and then if Alfresco is still running writes some diagnostic information and ends Alfresco immediatley.


Configuration of Shutdown Backstop


The Shutdown Backstop Bean is a special bean which is used to terminate Alfresco if its
normal shutdown does not complete in a reasonable time.

Spring definition.



    <bean id='shutdownBackstop' class='org.alfresco.repo.shutdown.ShutdownBackstop'>
       <property name='timeout'>
          <value>${shutdown.backstop.timeout}</value>
       </property>
       <property name='enabled'>
          <value>${shutdown.backstop.enabled}</value>
       </property>
    </bean>

The following settings in repository.properties configure the shutdown backstop.  


shutdown.backstop.timeout : How long should shutdown wait to complete normally before taking stronger action and calling System.exit() in ms. 10,000 is 10 seconds
shutdown.backstop.enabled : Is the backstop enabled (true) or not (false).   If not enabled then the backstop will never take action.

Labs 3D
3.0.1

Attachments

    Outcomes