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.
Table 5.4. Attributes of "Graph execution" task
| Task type | "execute graph" |
| Sandbox | This select box contains sandboxes which are readable for logger user. Select sandbox which contains graph to execute. |
| Graph | This select box is filled by all graphs accessible in selected sandbox. |
| Parameters | Key-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 paramName4So 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. |
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 event | If this switch is on, task will kill graph which is source of the event, which activated this task. Attributes Sandbox and graph are ignored. |
| Sandbox | Select sandbox which contains graph to kill. This attribute takes place only when "Kill source of event" switch is off. |
| Graph | This 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. |
Table 5.6. Attributes of "Shell command" task
| Task type | "shell command" |
| Command line | Command line for execution of external process. |
| Working directory | Working directory for process. If not set, working directory of application server process is used. |
| Timeout | Timeout in milliseconds. After period of time specified by this number, external process is terminated and all results are logged. |
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.
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
| variable | class | description | availability |
|---|---|---|---|
| event | com.cloveretl.server.events.AbstractServerEvent | every time | |
| task | com.cloveretl.server.persistent.Task | every time | |
| now | java.util.Date | current time | every time |
| parameters | java.util.Properties | Properties of task | every time |
| user | com.cloveretl.server.persistent.User | Same as event.getUser() | every time |
| run | com.cloveretl.server.persistent.RunRecord | When the event is instance of GraphServerEvent | |
| tracking | com.cloveretl.server.persistent.TrackingGraph | same as run.getTrackingGraph() | When the event is instance of GraphServerEvent |
| sandbox | com.cloveretl.server.persistent.Sandbox | same as run.getSandbox() | When the event is instance of GraphServerEvent |
| schedule | com.cloveretl.server.persistent.Schedule | same as ((ScheduleServerEvent)event).getSchedule() | When the event is instance of ScheduleServerEvent |
| servletContext | javax.servlet.ServletContext | every time | |
| cloverConfiguration | com.cloveretl.server.spring.CloverConfiguration | Configuration values for CloverETL Server | every time |
| serverFacade | com.cloveretl.server.facade.api.ServerFacade | Reference 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 |
| sessionToken | String | Valid 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.
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();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 then | Time period (in minutes) - it specifies which records are evaluated as obsolete. Records older then the specified interval are stored in archives. |
| Archivator type | There 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 archives | This attribute makes sense only for "archive" type. |
| Include executions history | |
| Run record with status | If 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 history | If checked, archivator will include run records. Log files of graph runs are included as well. |
| Task types | If this task type is selected, only logs for selected task type are archived. |
| Task result mask | Mask 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 files | If checked, archivator removes all graph debug files older then given timestamp defined in "Older than" attribute. |
| Include dictionary files | If checked, archivator removes all dictionary temporary files older then given timestamp defined in "Older than" attribute. |