You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Bertrand Delacretaz (JIRA)" <ji...@apache.org> on 2010/07/27 16:54:16 UTC

[jira] Commented: (SLING-550) Support for background servlets

    [ https://issues.apache.org/jira/browse/SLING-550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12892804#action_12892804 ] 

Bertrand Delacretaz commented on SLING-550:
-------------------------------------------

Revision 979727 provides the following features:

Any servlet executed by Sling can be started in the background by adding the sling:bg=true parameter to the request. The servlet then gets a "fake" request object, some servlets might not like that.

Background servlets are executed by a simple (and limited) thread pool.

Nodes corresponding to jobs are stored under /var/bg/jobs with a sling:bgJobData mixin and the sling/bg/job resource type. The output of a background servlet is stored in a node named "stream", with the sling/bg/stream resource type, under that node.

Default servlets are provided to render the status and stream nodes, when starting a servlet in the background Sling redirects to the status node, using the same extension as the request.

How to test:
Use the engine bundle from the SLING-1603 branch [1].

Install the contrib/extensions/bgservlets bundle.

Start the test servlet in the background using either:
http://localhost:8080/system/bgservlets/test.html?sling:bg=true
http://localhost:8080/system/bgservlets/test.txt?sling:bg=true
http://localhost:8080/system/bgservlets/test.json?sling:bg=true

Sling returns the job status page, with a link to the job stream. Refreshing the job stream URL returns the full stream as it progresses, saved on every flush() of the running servlet's OutputStream.

Jobs are listed at /system/console/bgservlets which allows them to be suspended, resumed and stopped.

TODO:
Use existing thread pool and/or scheduling code from Sling.

Access control: status nodes should be readable by their owner only (+ admin of course).

Replace hardcoded values by configuration properties (see TODO in code).

ExecutionEngine should sort jobs by creation date, descending.

Console should allow for identifying and restarting jobs that were interrupted by a shutdown.

[1] http://svn.apache.org/repos/asf/sling/branches/SLING-1603-engine

> Support for background servlets
> -------------------------------
>
>                 Key: SLING-550
>                 URL: https://issues.apache.org/jira/browse/SLING-550
>             Project: Sling
>          Issue Type: Improvement
>          Components: Extensions
>            Reporter: Bertrand Delacretaz
>            Assignee: Bertrand Delacretaz
>            Priority: Minor
>
> In some cases (like the webloader example), long-running processes need to be started, monitored and stopped.
> The webloader implements this in a naive way, it might be useful to have a more generic facility for this: a service that would:
> 1) Start a script or servlet, probably passing it a fake request object that gives access to parameters and output but is not a real HTTP request
> 2) Display a status page where currently running jobs can be monitored, and stopped if desired
> 3) Collect the output of such jobs in the repository and give access to it via a simple monitoring interface
> The output of long-running jobs could be structured using html conventions (like <div class="status">running step 3 of 12</div>) to create overview displays of all currently running jobs.
> This is just an idea for now, I'm not going to work on this right away, but it's probably good to keep in our wishlist.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.