Task Management

From Sense/Net Wiki
Jump to: navigation, search
  •  
  •  
  •  
  •  
  • 100%
  • 6.5
  • Enterprise
  • Community
  • Planned

Overview

Task Management
Sense/Net ECMS is a web application, running in the context of one IIS process and designed to serve many users at the same time. There are tasks that are not well-suited for this environment - for example long-running tasks that would keep the web server busy and make the user wait for the response, or resource-consuming jobs that are even able to crash the executing process. For these kinds of scenarios Sense/Net offers the Task Management component that lets you execute background operations in a scalable way.

From version 6.5 Sense/Net ECMS uses a completely standalone task management system. We decoupled the previously integrated task management from the base product to make the feature usable as a service. It is possible to connect to the same task management center from multiple instances of Sense/Net ECMS, or even from 3rd party applications.

If you are looking for the documentation for previous versions, please visit this article.

After you have read this overview and want to deploy the feature, please visit the following article:

Components and glossary

In this section we describe the components of the system that work together when a task gets created and executed.

Task Management components

Task

A task is an atomic, independent job that consumes more resources than a few processor cycles: e.g. a job that loads one or more content and converts them, or generates preview images using an external tool. Compressing multiple documents or decompressing an archive file are also good examples.

These tasks are independent enough that they can be moved to another worker agent, even to a different machine. A task appoints the plug-in (e.g. the preview generator) that should execute it. Tasks also contain all the necessary metadata for these worker agents to start their work - e.g. a document id and the start and end of a page interval that preview images should be generated for.

Task Management application

This is a standalone component, independent from Sense/Net ECMS. It is installed as an IIS web application and is accessed through its REST API. This is a central point that is responsible for managing tasks. Client applications (in our case a Sense/Net ECMS installation) register tasks in this application and get all the feedback about executing tasks from it. The Task Management application has its own database for storing tasks and keeping track of registered client applications.

The Task Management application is not Sense/Net-specific. Any kind of 3rd party application can connect to it and register tasks.

The following sub-components are part of the main task management application.

Task Management service

This is a Windows Service that keeps task agents up and running. The only configuration it needs is the number of agents you want it to keep alive. When you stop this service, it will stop all the running agent processes.

Task Agent

Agents are separate processes (executable files) that will start the actual task tools (e.g. a preview generator exe). One or more agents are hosted on worker nodes (usually virtual machines) and they run constantly. Agent processes are kept alive by a Windows Service (see above). If an agent process crashes, the service will start a new one in place of it. The number of agents per machine is configurable.

Agents are notified by the Task Manager application when a new task comes in (see the communication chapter for more details). Then all available (idle) agents will request a new task for themselves for execution. A task can be assigned (locked) to a single agent only.

When an agent finished a task, it will notify the Task Manager application and request a new task – but only once. If there is no new task to be executed, it will sleep and wait for the push notification from the task manager.

Agents do not know the specifics of tasks, they just start the appropriate task process (e.g. a preview generator), described by the task object.

Task Executor

A Task Executor is a command line tool that actually does the job - e.g. generates preview images. 3rd party developers will create task executors for their custom tasks, for example compressing or decompressing files, or handling any other resource-heavy long-running operation that can be moved outside of the context of the web application.

An executor may connect to Sense/Net ECMS or other 3rd party applications for more information beyond task management. In this case the additional task-specific configuration is the responsibility of the executor itself – and the operator.

Client application

An application that connects to the Task Management application and sends tasks to it. In our case this is a Sense/Net ECMS installation, but can be any kind of 3rd party application that implements the necessary REST API for callback operations. See the following article for details:

Task Monitor

This is a user interface served by the client application. It connects to the Task Management application through Sense/Net ECM using ASP.NET SignalR. See the monitoring section below for details.

Task execution workflow

In the following example we go through the steps of the first built-in use case for the Task Management framework: generating preview images for an uploaded document.

  1. A user uploads a document.
  2. Sense/Net ECMS saves and indexes the document.
  3. Users can now access (download) the document.
  4. Sense/Net ECMS registers a task for generating preview images through the Task Management API.
  5. The Task Management application notifies all agents that there is a new task.
  6. Idle agents compete for the new task (through the task management application).
  7. The Task Management application locks a task in the task database.
  8. Only one agent wins the task.
  9. The Task Management application returns the task to the caller agent.
  10. The winner agent starts the appropriate executor tool (in this case the preview generator) that will start working: downloads the document through the portal's REST API.
  11. The executor uploads the generated images (previews + thumbnails) to the Content Repository, than exits.
  12. The agent rounds off the finished task and requests a new one.
  13. The Task Management application finalizes the task in the database and sends a callback request to the client application. Finally it provides a new task for the agent (if there is any).

Registering the client application

Client applications must register and identify themselves before sending tasks to the Task Management application. Sense/Net ECMS already does this for you, but 3rd party application developers will need to take care of it themselves. It is a simple REST API call that can be made at the start of the application. See the details in the following article:

Finalizing tasks

When a task is finished, the Task Management application calls the provided finalize url for the task. In the handler of that url the client application will be able to execute custom logic depending on the outcome of the task.

Communication

The components above need to communicate with each other. For example the Task Management app has to notify the agents when a new task comes in (note that this is a push model) and sometimes the agents need to notify the Task Management app or ask for information. The general communication is performed using the ASP.NET SignalR technology. It allows a two-way communication and has a robust, fail-safe architecture that ensures that the system functions stably.

Simple requests, like registering a task are done using a REST API. This part of the Task Management application was built using ASP.NET Web API.

Sense/Net does not know anything about the agents connected to the system – this is maintained by the task management center using SignalR. Connection/disconnection events are raised automatically. Other health information (processor/memory load) is sent by the agents (see the monitoring section below).

All other communication related to specific tasks (e.g. downloading a document or getting information from the Sense/Net ECMS Content Repository) will be performed by the task executor tools.

Authentication

Coming soon.

Task priority

When there are many tasks to be executed at the same time (e.g. there are plenty of new documents to create preview images for), there should be a way to have more important tasks than others.

The Task Management API provides a way for setting task priority without knowing much about the logic behind the task. Developers may choose from the following task priority levels:

  • Immediately
  • Important
  • Normal
  • Unimportant

See the details in the article for developers.

Task error and timeout

If an error occurs during task execution related to the task itself, it is the responsibility of the executor to handle the case with the appropriate business logic: for example if the document could not be downloaded, the preview generator will set the preview status of the document to Error and will close the task gracefully.

It is possible that the task executor itself crashes during execution. In this case the agent sends all the available information to the Task Management server and closes the task itself. The error message will be forwarded to the client application during the finalizer callback.

See the details in the article for developers.

It is also possible that the executor process hangs. For this case there is a timeout interval we wait for a task to raise some life sign or finish - after that we close the process and release the task so that it could be claimed by another agent.

It is the responsibility of the developer of the task executor tool to raise a status message regularly so that the agent knows that the task is still running correctly and it should not close it forcefully.

Monitoring

(from version 6.4 patch 2)

If you are using the Enterprise Edition, you get a page accessible from the Root console (click on the Root node in Content Explorer) where you can monitor the Task Management system's status. On the Task Monitor page you'll see the list of agent machines and all the connected agents. The page updates periodically with real-time information about the status of the individual agents and currently executing tasks.

The page displays the CPU usage and the available memory (RAM) on each agent machine. You can also get a more detailed log if you click on the individual agents.

Machine details on Task Monitoring UI

This Ui also displays a grid, where tasks are listed. Detailed information on the state of task is available by clicking ont he ’+’ mark at the beginning of each row.

Show detailed state of task in the grid

Filtering and sorting by displayed metadata is also possible in the grid by drag&drop metadata title to the grouping-header of the grid.

Filtering by metadata displayed in the grid

This monitoring page is part of the Sense/Net ECMS application. If you are connecting to the Task Management system from a custom 3rd party application, you may also create your own monitoring page using our API.

Configuration and maintenance

About configuring the different components see the following article:

Built-in tasks

Currently the following Sense/Net features use the Task Management component:

Related links

References