Package com.basis.api.admin
Interface BBjAdminTaskGroup
- All Superinterfaces:
BBjAdminPropertyReader
,BBjAdminPropertyWriter
,Remote
- All Known Implementing Classes:
BBjAdminClientTaskGroup
A task group represents a set of one or more tasks to be executed serially at a specific point in time or when BBjServices is started/restarted. The task group can execute tasks such as BBj programs, system calls, and pause/resume replication jobs. To create/view task groups in the Enterprise Manager, see the Scheduling item under BBjServices.
Task groups are used to schedule autorun jobs as well. Autorun jobs are run one time at the time BBjServices starts. The following example shows how to create an autorun task group:
BBj Sample Code
REM Make sure to inclue the use anytime you will reference constants from a class or interface.
use com.basis.api.admin.BBjAdminTask
use com.basis.api.admin.BBjAdminBBjTask
use com.basis.api.admin.BBjAdminSCALLTask
use com.basis.api.admin.BBjAdminTaskGroup
declare BBjAdminBase api!
declare BBjAdminList programList!
declare BBjAdminTaskGroup taskGroup!
declare BBjAdminTask task!
REM Create the API instance.
api! = BBjAdminFactory.getBBjAdmin("admin", "admin123")
REM Create a new autorun BBjAdminTaskGroup instance.
taskGroup! = api!.newTaskGroup()
taskGroup!.setBoolean(BBjAdminTaskGroup.AUTORUN, 1)
taskGroup!.setString(BBjAdminTaskGroup.NAME, "My Autorun Job")
REM Create a new BBj program task to be run by the job.
task! = taskGroup!.newTask(BBjAdminTask.TaskType.BBJ_PROGRAM)
task!.setString(BBjAdminBBjTask.PROGRAM, "/programs/myprogram.bbj")
REM These are all optional. Just a sample of options.
task!.setString(BBjAdminBBjTask.RUN_AS, "jdoe")
task!.setString(BBjAdminBBjTask.RUN_AS_PASSWORD, "mypassword")
task!.setString(BBjAdminBBjTask.CONFIG, "/programs/config.bbx")
task!.setString(BBjAdminBBjTask.WORKING_DIR, "/programs")
REM Add the new task to the task group.
taskGroup!.getTasks().add(task!)
REM Save the task group configuration.
taskGroup!.commit()
REM ================================================================
REM Create another task group that is scheduled to run every Monday.
REM ================================================================
declare BBjAdminTaskGroup mondayGroup!
mondayGroup! = api!.newTaskGroup()
mondayGroup!.setString(BBjAdminTaskGroup.NAME, "MondayGroup")
REM Create a new task to add to the group. Valid types are BBJ_PROGRAM, SCALL, PAUSE, RESUME
REM PAUSE and RESUME refer to replication jobs. See BBjAdminBBjTask
, BBjAdminSCALLTask
,
REM BBjAdminPauseTask
, and BBjAdminResumeTask
for all the properties available.
task! = mondayGroup!.newTask(BBjAdminTask.TaskType.BBJ_PROGRAM)
task!.setString(BBjAdminBBjTask.PROGRAM, "/path/to/myProgram.bbj")
task!.setString(BBjAdminBBjTask.CONFIG, "myconfig.bbx")
mondayGroup!.getTasks().add(task!)
task! = mondayGroup!.newTask(BBjAdminTask.TaskType.SCALL)
task!.setString(BBjAdminSCALLTask.COMMAND, "mycommand -arg1 -arg2")
mondayGroup!.getTasks().add(task!)
REM Set scheduling settings. See START_DATE
for details on generating start date value.
mondayGroup!.setLong(BBjAdminTaskGroup.START_DATE, new java.util.Date().getTime())
mondayGroup!.setInt(BBjAdminTaskGroup.REPEAT_TYPE, BBjAdminTaskGroup.WEEKLY)
REM REPEAT_FREQUENCY set to 1 for every week. Set to 2 for every other week, and so on.
mondayGroup!.setDouble(BBjAdminTaskGroup.REPEAT_FREQUENCY, 1)
REM Set it to repeat on Mondays. See REPEAT_DAYS
for more info.
mondayGroup!.setInt(BBjAdminTaskGroup.REPEAT_DAYS, BBjAdminTaskGroup.MONDAY)
REM Save the group
mondayGroup!.commit()
REM Get the task queue which contains all the running jobs.
queue! = api!.getTaskQueue()
REM Get list of task groups
groupList! = queue!.getTaskGroups()
REM Get a specific task group by name
someGroup! = queue!.getTaskGroup("MyTaskGroup")
REM Clean up the API resources.
api!.release()
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Property to indicate if the group should run automatically at BBj Services startup.static final int
static final String
End date and time for this group to stop running.static final int
Flag to include Friday in the repeat days.static final int
static final String
Group unique IDstatic final String
Last time the group was run.static final String
Message indicating the status of the last time the group was run.static final int
Flag to include Monday in the repeat days.static final int
static final String
Name of the task group.static final String
Next time the group will run.static final int
static final String
Used in conjunction with theREPEAT_TYPE
ofWEEKLY
.static final String
Works in conjunction with the repeat type.static final String
Type of repeat that should occur or NONE if it should only run once.static final int
Flag to include Saturday in the repeat days.static final String
Not a property.static final String
Date and time that this group should start.static final int
Flag to include Sunday in the repeat days.static final int
Flag to include Thursday in the repeat days.static final int
Flag to include Tuesday in the repeat days.static final int
Flag to include Wednesday in the repeat days.static final int
static final int
-
Method Summary
Modifier and TypeMethodDescriptionvoid
commit()
Stores any changes made, to the task definition file.boolean
Call this method to execute the scheduled task and its items if it is the appropriate time according to its configuration.void
Executes the task group only if it is configured as autorun.Returns a human readable description of the scheduling for this group.getTasks()
Returns a list of tasks within this group.Internal use only.boolean
Returns true if the group is currently enabled and scheduled run.newTask
(BBjAdminTask.TaskType p_type) Creates a new instance of a task but does NOT add it to the list of tasks.void
setEnabled
(boolean p_enabled) Enables or disables the task group.void
setTasks
(BBjAdminList<BBjAdminTask> p_tasks) Methods inherited from interface com.basis.api.admin.BBjAdminPropertyReader
checkValueEqual, contains, contains, getBoolean, getDouble, getInt, getList, getLong, getProperties, getString, getType, getTypes, getValue
Methods inherited from interface com.basis.api.admin.BBjAdminPropertyWriter
addType, canAddNewProperties, canClear, clear, clearProperties, clearProperty, getReadOnly, hasChanged, isReadOnly, setBoolean, setDouble, setInt, setList, setLong, setProperties, setString, setValue
-
Field Details
-
NAME
Name of the task group.- See Also:
-
ID
Group unique ID- See Also:
-
SCHEUDULING_PREFIX
Not a property. Used internally as a constant.- See Also:
-
START_DATE
Date and time that this group should start. This value is the Java date long value which represents the number of milliseconds since the epoch. In BBj you would use code something like the following to calculate your value:use java.util.Calendar
declare Calendar cal!
REM Use date of March 13, 2014 2:00 PM
myYear = 2014
myMonth = 3
myDay = 13
myHour = 14
myMinute = 30
cal! = Calendar.getInstance()
cal!.set(Calendar.YEAR, myYear)
cal!.set(Calendar.MONTH, myMonth - 1); REM Uses 0 based month numbers 0-11
cal!.set(Calendar.DAY_OF_MONTH, myDay)
cal!.set(Calendar.HOUR_OF_DAY, myHour)
cal!.set(Calendar.MINUTE, myMinute)
cal!.set(Calendar.SECOND, 0)
cal!.set(Calendar.MILLISECOND, 0)
taskGroup!.setLong(BBjAdminTaskGroup.START_DATE, cal!.getDate())- See Also:
-
REPEAT_TYPE
Type of repeat that should occur or NONE if it should only run once.- See Also:
-
NONE
static final int NONE- See Also:
-
HOURLY
static final int HOURLY- See Also:
-
DAILY
static final int DAILY- See Also:
-
WEEKLY
static final int WEEKLY- See Also:
-
MONTHLY
static final int MONTHLY- See Also:
-
YEARLY
static final int YEARLY- See Also:
-
REPEAT_FREQUENCY
Works in conjunction with the repeat type. Value of 3 for type WEEKLY would mean Repeat every 3 weeks.- See Also:
-
REPEAT_DAYS
Used in conjunction with theREPEAT_TYPE
ofWEEKLY
. Flag with days OR'd together to specify the list of days for the repeat. In Java you would use something like the following to set it to repeat on Monday and Wednesday:
int daysFlag = BBjAdminTaskGroup.MONDAY | BBjAdminTaskGroup.WEDNESDAY;
For the equivalent in BBj code, use:
LET daysFlag = IOR($02$, $08$)
- See Also:
-
SUNDAY
static final int SUNDAYFlag to include Sunday in the repeat days. SeeREPEAT_DAYS
.- See Also:
-
MONDAY
static final int MONDAYFlag to include Monday in the repeat days. SeeREPEAT_DAYS
.- See Also:
-
TUESDAY
static final int TUESDAYFlag to include Tuesday in the repeat days. SeeREPEAT_DAYS
.- See Also:
-
WEDNESDAY
static final int WEDNESDAYFlag to include Wednesday in the repeat days. SeeREPEAT_DAYS
.- See Also:
-
THURSDAY
static final int THURSDAYFlag to include Thursday in the repeat days. SeeREPEAT_DAYS
.- See Also:
-
FRIDAY
static final int FRIDAYFlag to include Friday in the repeat days. SeeREPEAT_DAYS
.- See Also:
-
SATURDAY
static final int SATURDAYFlag to include Saturday in the repeat days. SeeREPEAT_DAYS
.- See Also:
-
AUTORUN
Property to indicate if the group should run automatically at BBj Services startup. The default is false/0 or don't run automatically at startup. If this property is set to true, then theREPEAT_TYPE
,REPEAT_FREQUENCY
, andREPEAT_DAYS
will be ignored.- See Also:
-
END_DATE
End date and time for this group to stop running. Please seeSTART_DATE
for details regarding use in a BBj program.- See Also:
-
LAST_RUN
Last time the group was run. Value returned is the number of milliseconds since the epoch.- See Also:
-
NEXT_RUN
Next time the group will run. Value returned is the number of milliseconds since the epoch.- See Also:
-
LAST_STATUS
Message indicating the status of the last time the group was run.- See Also:
-
-
Method Details
-
executeIfAppropriate
Call this method to execute the scheduled task and its items if it is the appropriate time according to its configuration. If it was time and it executed it returns true. Otherwise returns false.- Throws:
BBjAdminException
-
getTasks
BBjAdminList<BBjAdminTask> getTasks()Returns a list of tasks within this group. When you execute the group, all of its tasks will be executed in the order they appear in the group.- Returns:
- List of the tasks in this group.
-
setTasks
-
getSchedulingDescription
Returns a human readable description of the scheduling for this group. If it is a date, it will show the date and time. If a day of the week, the name of the day of the week. Etc.....- Returns:
- The description of how this task group is scheduled. Takes all the scheduling criteria and builds a human readable string.
- Throws:
BBjAdminException
-
newTask
Creates a new instance of a task but does NOT add it to the list of tasks. Make sure to add the instance to the list of tasks returned by a call togetTasks()
.- Returns:
- New instance of the specified type. Always use this method to create new task instances, never use the implementation classes of BBjAdminTask.
- Throws:
BBjAdminException
-
getXML
Internal use only.- Parameters:
p_xmlDoc
-- Throws:
BBjAdminException
-
commit
Stores any changes made, to the task definition file.- Throws:
BBjAdminException
-
executeIfAutorun
Executes the task group only if it is configured as autorun.- Throws:
BBjAdminException
-
isEnabled
Returns true if the group is currently enabled and scheduled run.- Returns:
- True if the task group is enabled. False if not.
- Throws:
BBjAdminException
-
setEnabled
Enables or disables the task group. A disabled task group will not run the next time it is scheduled to. NOTE: You must call commit() on the BBjAdminTaskGroup in order for the enabled state to be saved and updated.- Parameters:
p_enabled
-- Throws:
BBjAdminException
-