Tasks

Task basically specifies WHAT to do at trigger time. There are several tasks implemented for schedule and for graph event listener as follows:

We expect, that some more task implementation will be needed, i.e. task type "Execution of java code", etc.

Task - Execution of Graph

Table 5.4. Attributes of "Graph execution" task

Task type"execute graph"
SandboxThis select box contains sandboxes which are readable for logger user. Select sandbox which contains graph to execute.
GraphThis select box is filled by all graphs accessible in selected sandbox.
ParametersKey-value pairs which are passed to the executed graph as parameters. Besides, if this task is triggered by "graph event", you can specify parameters from the graph which is "graph event" source. These parameters are passed to executed graph. i.e. event source graph has these parameters: paramName2 with value "val2", paramName3 with value "val3", paramNameX. Task "graph execution" has "Parameters" attribute set like this:
			 paramName1=paramValue1
			 paramName2=
			 paramName3
			 paramName4
		 
So executed graph gets these parameters and values: paramName1 with value "paramValue1" (specified by task) paramName2 with value "" (empty string specified by task overrides event source parameters) paramName3 with value "val3" (value is taken from event source graph) These parameters aren't passed: paramName4 isn't passed, since it does not have any value in event source graph. paramNameX isn't passed, since it is not specified among the parameters to pass in the task

Event parameters like "event_run_result", "event_run_id" etc. are passed to the graph without limitations.


Web GUI - Graph execution task

Figure 5.6. Web GUI - Graph execution task


Task - Kill Graph

This task, when activated kills/aborts specified graph, if it is currently running.

Table 5.5. Attributes of "Kill graph" task

Task type"kill graph"
Kill source of eventIf this switch is on, task will kill graph which is source of the event, which activated this task. Attributes Sandbox and graph are ignored.
SandboxSelect sandbox which contains graph to kill. This attribute takes place only when "Kill source of event" switch is off.
GraphThis select box is filled by all graphs accessible in selected sandbox. All instances of selected graph, whose are currently running will be killed. This attribute takes place only when "Kill source of event" switch is off.

Web GUI - "Kill graph"

Figure 5.7. Web GUI - "Kill graph"


Task - Execution of Shell Command

Table 5.6. Attributes of "Shell command" task

Task type"shell command"
Command lineCommand line for execution of external process.
Working directoryWorking directory for process. If not set, working directory of application server process is used.
TimeoutTimeout in milliseconds. After period of time specified by this number, external process is terminated and all results are logged.

Web GUI - shell command

Figure 5.8. Web GUI - shell command


Task - Send Email

This task is very useful, but for now only as response for graph events. This feature is very powerful for monitoring. (see Chapter 6, Graph Event Listeners for description of this task type).

Note: It seems useless to send emails periodically, but it may send current server status or daily summary. These features will be implemented in further versions.

Task - Execute Groovy Code

This type of task allows execute code written in script language Groovy. It is possible to use some variables. Only parameter of this task is source code of written in Groovy.

Table 5.7. List of variables available in Groovy code

variableclassdescriptionavailability
eventcom.cloveretl.server.events.AbstractServerEvent every time
taskcom.cloveretl.server.persistent.Task every time
nowjava.util.Datecurrent timeevery time
parametersjava.util.PropertiesProperties of taskevery time
usercom.cloveretl.server.persistent.UserSame as event.getUser()every time
runcom.cloveretl.server.persistent.RunRecord When the event is instance of GraphServerEvent
trackingcom.cloveretl.server.persistent.TrackingGraphsame as run.getTrackingGraph()When the event is instance of GraphServerEvent
sandboxcom.cloveretl.server.persistent.Sandboxsame as run.getSandbox()When the event is instance of GraphServerEvent
schedulecom.cloveretl.server.persistent.Schedulesame as ((ScheduleServerEvent)event).getSchedule()When the event is instance of ScheduleServerEvent
servletContextjavax.servlet.ServletContext every time
cloverConfigurationcom.cloveretl.server.spring.CloverConfigurationConfiguration values for CloverETL Serverevery time
serverFacadecom.cloveretl.server.facade.api.ServerFacadeReference to the facade interface. Useful for calling CloverETL Server core.

WAR file contains JavaDoc of facade API and it is accessible on URL: http://host:port/clover/javadoc/index.html

every time
sessionTokenStringValid session token of the user who owns the event. It is useful for authorisation to the facade interface.every time

Variables run, tracking and sandbox are available only if event is instance of GraphServerEvent class. Variable schedule is available only for ScheduleServerEvent as event variable class.

Example of use Groovy script

This example shows script which writes text file describing finished graph. It shows use of 'run' variable.

import com.cloveretl.server.persistent.RunRecord;
String dir = "/tmp/";
RunRecord rr = (RunRecord)run;	

String fileName = "report"+rr.getId()+"_finished.txt";

FileWriter fw = new FileWriter(new File(dir+fileName));
fw.write("Run ID       :"+rr.getId()+"\n");
fw.write("Graph ID     :"+rr.getGraphId()+"\n");
fw.write("Sandbox      :"+rr.getSandbox().getName()+"\n");
fw.write("\n");
fw.write("Start time   :"+rr.getStartTime()+"\n");
fw.write("Stop time    :"+rr.getStopTime()+"\n");
fw.write("Duration     :"+rr.getDurationString()+"\n");
fw.write("Final status :"+rr.getFinalStatus()+"\n");
fw.close();

Task - Archive Records

As name suggests, this task can archive (or delete) obsolete records from DB.

Table 5.8. Attributes of "archive records" task

Task type"archivator"
Older thenTime period (in minutes) - it specifies which records are evaluated as obsolete. Records older then the specified interval are stored in archives.
Archivator typeThere are two possible values: "archive" or "delete". Delete removes records without any possibility of UNDO operation. Archive removes records from DB, but creates ZIP package with CSV files containing deleted data.
Output path for archivesThis attribute makes sense only for "archive" type.
Include executions history 
Run record with statusIf status is selected, only run records with specified status will be archived. It is useful i.e. If you want to delete records for successfully finished graphs, but you are interested in failed graphs.
Include tasks historyIf checked, archivator will include run records. Log files of graph runs are included as well.
Task typesIf this task type is selected, only logs for selected task type are archived.
Task result maskMask applied to task log result attribute. Only records whose result meets this mask are archived. Specify string without any wildcards. Each task log which contains specified string in the "result" attribute will be deleted/archived. Case sensitivity depends on database collation.
Include debug filesIf checked, archivator removes all graph debug files older then given timestamp defined in "Older than" attribute.
Include dictionary filesIf checked, archivator removes all dictionary temporary files older then given timestamp defined in "Older than" attribute.

Web GUI - archive records

Figure 5.9. Web GUI - archive records