public interface BBjAdminTaskGroup extends BBjAdminPropertyWriter
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:
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()
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AUTORUN
Property to indicate if the group should run automatically at BBj Services startup.
|
static int |
DAILY |
static java.lang.String |
END_DATE
End date and time for this group to stop running.
|
static int |
FRIDAY
Flag to include Friday in the repeat days.
|
static int |
HOURLY |
static java.lang.String |
ID
Group unique ID
|
static java.lang.String |
LAST_RUN
Last time the group was run.
|
static java.lang.String |
LAST_STATUS
Message indicating the status of the last time the group was run.
|
static int |
MONDAY
Flag to include Monday in the repeat days.
|
static int |
MONTHLY |
static java.lang.String |
NAME
Name of the task group.
|
static java.lang.String |
NEXT_RUN
Next time the group will run.
|
static int |
NONE |
static java.lang.String |
REPEAT_DAYS
Used in conjunction with the
REPEAT_TYPE of WEEKLY . |
static java.lang.String |
REPEAT_FREQUENCY
Works in conjunction with the repeat type.
|
static java.lang.String |
REPEAT_TYPE
Type of repeat that should occur or NONE if it should only run once.
|
static int |
SATURDAY
Flag to include Saturday in the repeat days.
|
static java.lang.String |
SCHEUDULING_PREFIX
Not a property.
|
static java.lang.String |
START_DATE
Date and time that this group should start.
|
static int |
SUNDAY
Flag to include Sunday in the repeat days.
|
static int |
THURSDAY
Flag to include Thursday in the repeat days.
|
static int |
TUESDAY
Flag to include Tuesday in the repeat days.
|
static int |
WEDNESDAY
Flag to include Wednesday in the repeat days.
|
static int |
WEEKLY |
static int |
YEARLY |
Modifier and Type | Method and Description |
---|---|
void |
commit()
Stores any changes made, to the task definition file.
|
boolean |
executeIfAppropriate()
Call this method to execute the scheduled task and its items if it is the
appropriate time according to its configuration.
|
void |
executeIfAutorun()
Executes the task group only if it is configured as autorun.
|
java.lang.String |
getSchedulingDescription()
Returns a human readable description of the scheduling for this group.
|
BBjAdminList<BBjAdminTask> |
getTasks()
Returns a list of tasks within this group.
|
org.w3c.dom.Element |
getXML(org.w3c.dom.Document p_xmlDoc)
Internal use only.
|
boolean |
isEnabled()
Returns true if the group is currently enabled and scheduled run.
|
BBjAdminTask |
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) |
addType, canAddNewProperties, canClear, clear, clearProperties, clearProperty, getReadOnly, hasChanged, isReadOnly, setBoolean, setDouble, setInt, setList, setLong, setProperties, setString, setValue
checkValueEqual, contains, contains, getBoolean, getDouble, getInt, getList, getLong, getProperties, getString, getType, getTypes, getValue
static final java.lang.String NAME
static final java.lang.String ID
static final java.lang.String SCHEUDULING_PREFIX
static final java.lang.String START_DATE
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())
static final java.lang.String REPEAT_TYPE
static final int NONE
static final int HOURLY
static final int DAILY
static final int WEEKLY
static final int MONTHLY
static final int YEARLY
static final java.lang.String REPEAT_FREQUENCY
static final java.lang.String REPEAT_DAYS
REPEAT_TYPE
of WEEKLY
. 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$)
static final int SUNDAY
REPEAT_DAYS
.static final int MONDAY
REPEAT_DAYS
.static final int TUESDAY
REPEAT_DAYS
.static final int WEDNESDAY
REPEAT_DAYS
.static final int THURSDAY
REPEAT_DAYS
.static final int FRIDAY
REPEAT_DAYS
.static final int SATURDAY
REPEAT_DAYS
.static final java.lang.String AUTORUN
REPEAT_TYPE
, REPEAT_FREQUENCY
, and REPEAT_DAYS
will be
ignored.static final java.lang.String END_DATE
START_DATE
for details regarding
use in a BBj program.static final java.lang.String LAST_RUN
static final java.lang.String NEXT_RUN
static final java.lang.String LAST_STATUS
boolean executeIfAppropriate() throws BBjAdminException
BBjAdminException
BBjAdminList<BBjAdminTask> getTasks()
void setTasks(BBjAdminList<BBjAdminTask> p_tasks)
java.lang.String getSchedulingDescription() throws BBjAdminException
BBjAdminException
BBjAdminTask newTask(BBjAdminTask.TaskType p_type) throws BBjAdminException
getTasks()
.BBjAdminException
org.w3c.dom.Element getXML(org.w3c.dom.Document p_xmlDoc) throws BBjAdminException
p_xmlDoc
- BBjAdminException
void commit() throws BBjAdminException
BBjAdminException
void executeIfAutorun() throws BBjAdminException
BBjAdminException
boolean isEnabled() throws BBjAdminException
BBjAdminException
void setEnabled(boolean p_enabled) throws BBjAdminException
p_enabled
- BBjAdminException