3.6.1 User-Defined Conditions
A user-defined condition must implement the UserCondition interface. Two key methods in the interface are check() and getRetryTime(). Both methods take a current time parameter. The current time parameter specifies the logical current time. Its value may be different from the actual system time returned by System.currentTimeMillis() and is used for the 'what if' analysis by the Scheduler. Both routines should use the passed value as the current time.
The getRetryTime() method is called by the Scheduler at start-up to determine the time this condition needs to be checked. The method is also called after a check() call returns false. If a task has more than one condition, the task will be retried at the latest retry time of all the conditions. If the getRetryTime() method returns a -1, the condition is abandoned.
The check() method can be called anytime after the retry time. It should check the condition criteria and return true if all the criteria are satisfied and false otherwise. It is up to the user-defined class to perform any checking in the check() method.
The following example illustrates a user-defined condition that checks the existence of a file.
import inetsoft.sree.schedule.*;
import inetsoft.sree.*;
import java.io.*;
public class FileCondition implements UserCondition
{
public String getLabel() {
return "File Check";
}
public RepletRequest getRepletRequest() {
return this.request;
}
public void setRepletRequest(RepletRequest request)
{
this.request = request;
}
public long getRetryTime(long now) {
// if the file name property is not
defined by user
if(filename == null) {
return –1;
}
return now + 600000; // retry in
10 minutes
}
// check if the file exists
public boolean check(long now) {
return (new File(filename)).exists();
}
String filename = SreeEnv.getProperty("extra.datafile");
RepletRequest request = null;
}
See Also
Scheduler Conditions, in Administration Reference, to set a built-in or custom condition in Enterprise Manager.
| << 3.6 Scheduler API | © 1996-2013 InetSoft Technology Corporation (v11.4) | 3.6.2 User-Defined Actions >> |