Scheduled tasks launch

Scheduled tasks can be launched in different manner, however, whatever the way used, scheduled tasks should be launched with an HPA Agent

Do not instrumentate very short ST with complete profile
HPA Agent can have an overhead of 10 to 20 seconds at startup depending of the classpath length
ST that ran during less than one minute will have a major overhead

Use the basic profile (memory monitoring only) for those ones

Select the monitoring level

Two profiles exist for the scheduled task monitoring:

  • The full monitoring is scheduletasks - usual overhead with full range of metrics and features
  • The basic monitoring is scheduletasks_basic - no overhead on launch time or execution time - only CPU, GC, and memory, infrastructure metrics
    • This profile also integrates the data collection session features

back to top

ST launched by a script

If a shell script is launching the Scheduled task JVM (and not sending an event to trigger the scheduled tasks) The procedure is quite similar to engines:

Identify the script used to launch the component, it can be the default or a custom script

You can use Help > Agent wizard in the portal to help you to define the right values

Add the following lines in the startup scripts:

  • Agent name: ScheduledTask-<uniqueIdentifier>
  • Agent profile: scheduletasks or scheduletask_basic (i.e ScheduledTask- and scheduletasks, see agent name and profile) Use a unique identifier in the agent name that can be chosen from the script context, the external ref for example
# HPA start modification
if [ -r {{hpa_agent_dir}}/hpa_agent_common.sh ]; then
    source {{hpa_agent_dir}}/hpa_agent_common.sh "<Agent name>" "<profile>"
fi
# HPA end modification

The lines must be included:

  • either at the beginning of the default/custom script
  • either in a parent script
  • either before the call to java

back to top

ST launched by Scheduler

Scheduled tasks are also launched by schedule server based on database, in this case, the JVM arguments of the scheduled task are stored in the database

Two options:

Activate the ST auto-monitoring feature

This feature is disabled by default.

This feature add the required parameters on the fly when the Calypso job start only if Scheduler is, itself, already monitored
Unlike the others parts, this extension modifies Calypso execution to add the HPA parameters

Activate the auto-monitoring

Go to Agent Settings

Agent Settings

Select Schedule Server

Schedule server selection

Find the Scheluded tasks auto monitoring flag, easiest way is to use the filter and entering auto

Schedule server selection

Activate the flag.

Schedule server selection

back to top

Configure the auto-monitoring

Each time a scheduled task is launched by the Schedule Server, this feature checks if the external reference of the Scheduled task is listed in the configuration file

The configuration file is checked and reloaded every 2mn if modified

Configuration file is :

{{hpa_agent_dir}}/override_config/automatic_st_monitoring.list

This file is not overwritten when you deploy a new agent

If the file does not exist, use the template:

cp {{hpa_agent_dir}}/default_config/automatic_st_monitoring.list {{hpa_agent_dir}}/automatic_st_monitoring.list

or if the template does not exist, create the file with this content :

// You can comment
// line pattern is <regular expression>;;<profile>
// profile can be : scheduletasks (full monitoring) or scheduletasks_basic (only cpu / memory / gc, no overhead)
EXAMPLE_HPA_MY_EXTERNAL_REF.*;;scheduletasks
// the token HPA_MONITOR_ALL is used as a default value if present
// if not present, default action is to do not add monitoring on ST
HPA_MONITOR_ALL;;scheduletasks_basic

The lines are evaluated in order, add as many lines as needed - evaluation stops when a pattern matches

  • 1st part of the line is a regular expression that must match the external reference of the scheduled task
  • 2nd part is the profile to apply - scheduletasks or scheduletasks_basic

If the constant HPA_MONITOR_ALL is present in the file and the no other lines match previously then this default profile is applied

If the constant is not found, and the external reference did not match any line, there is no monitoring considered

It is recommended to keep HPA_MONITOR_ALL on the last line

back to top

Logs

This feature traces the new parameters added to the scheduled tasks in the Schedule Server agent file, usually

{{hpa_agent_dir}}/wily/logs/IntroscopeAgent-HpaGenericSchedulerServer.log

Add HPA parameters in the JAVA OPTIONS (not recommended)

Using the Calypso GUI or directly in the database, add the Java parameters in the JAVA_OPTIONS argument of the scheduled task (same place as the memory options usually)

When a database is copied to another environment, ST parameters that have been added in this way will have a wrong environment name

Worse ! It could prevent the start of the ST if agent is not present

This solution requires a strong automated deployment system to update all the parameters on each deployment

You can use Help > Agent wizard in the portal to help you to define the right values

back to top

Scheduled tasks metrics

Example of custom snippet

Help > Agent wizard provides by default code snippet to refer the HPA agent in the ST launch scripts

It can be modifiable/customized according to client requirements

Below an example, provided “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED where the choice of ST monitoring type is made depending on the content of a specific text file

# HPA start modification
    ST_NAME=<ST identifier - ext ref or task id>
    AGENT_SCRIPT=<HPA agent dir>/hpa_agent_common.sh
    ST_LIST=<HPA agent dir>/override_config/custom_client_list_ST_monitoring.txt

    # profile chosen depending on the content of the file
    if [[ ! -z "$ST_NAME" ]]; then
        if [ -r ${AGENT_SCRIPT} ]; then
            if [ -f ${ST_LIST} ]; then
                if egrep -qi "^${ST_NAME}$" ${ST_LIST}; then
                    source ${AGENT_SCRIPT} "ScheduledTask-$ST_NAME" "scheduletasks"
                else
                    source ${AGENT_SCRIPT} "ScheduledTask-$ST_NAME" "scheduletasks_basic"
                fi
            fi
        fi
    fi
# HPA end modification

As egrep is used, regular expressions are authorized in <HPA agent dir>/override_config/custom_client_list_ST_monitoring.txt