com.dynatrace.diagnostics.pdk
Interface Task

All Superinterfaces:
Plugin

public interface Task
extends Plugin

The interface for Task Plugins.

Task Plugins are the simplest type of Plugins. They utilizes the TaskEnvironment which contains the Plugin configuration only.


Method Summary
 Status execute(TaskEnvironment env)
          Executes the Task Plugin.
 Status setup(TaskEnvironment env)
          Initializes the Plugin.
 void teardown(TaskEnvironment env)
          Shuts the Plugin down and frees resources.
 

Method Detail

setup

Status setup(TaskEnvironment env)
             throws java.lang.Exception
Initializes the Plugin. This method is called in the following cases:

If the returned status is null or the status code is a non-success code then teardown(TaskEnvironment) will be called next.

Resources like sockets or files can be opened in this method.

Parameters:
env - the configured TaskEnvironment for this Plugin
Returns:
a Status object that describes the result of the method call
Throws:
java.lang.Exception
See Also:
teardown(TaskEnvironment)

execute

Status execute(TaskEnvironment env)
               throws java.lang.Exception
Executes the Task Plugin.

This method is called at the scheduled intervals. If the Plugin execution takes longer than the schedule interval, subsequent calls to execute(TaskEnvironment) will be skipped until this method returns. After the execution duration exceeds the schedule timeout, PluginEnvironment.isStopped() will return true. In this case execution should be stopped as soon as possible. If the Plugin ignores PluginEnvironment.isStopped() or fails to stop execution in a reasonable timeframe, the execution thread will be stopped ungracefully which might lead to resource leaks!

Parameters:
env - a TaskEnvironment object that contains the Plugin configuration
Returns:
a Status object that describes the result of the method call
Throws:
java.lang.Exception

teardown

void teardown(TaskEnvironment env)
              throws java.lang.Exception
Shuts the Plugin down and frees resources. This method is called in the following cases:

The Plugin methods setup, execute and teardown are called on different threads, but they are called sequentially. This means that the execution of these methods does not overlap, they are executed one after the other.

Examples:

Failed means that either an unhandled exception is thrown or the status returned by the method contains a non-success code.

All by the Plugin allocated resources should be freed in this method. Examples are opened sockets or files.

Throws:
java.lang.Exception
See Also:
setup(TaskEnvironment)


Copyright © 2004-2012 dynaTrace software GmbH