Scheduler Class Reference
Scheduler facade class. More...
Static Public Member Functions |
|
static | create_adapter () |
Create an adfapter for scheduled tasks.
|
|
static | create_task ($params, &$result, $exclusive=false) |
Create a new task for scheduler. |
|
static | get_all () |
Return all Scheduled Actions. |
|
static | get_next_task () |
Return next task to execute. |
|
static | get_reschedule_policies () |
Returns list of all available reschedule
policies. |
|
static | get_statuses () |
get all status of the scheduler |
|
static | remove_tasks ($action, $op=self::REMOVE_EXACT) |
Remove tasks for given action. |
|
static | reschedule (DAOScheduler $task) |
Reschedule the given task. |
|
Public Attributes |
|
const | REMOVE_EXACT = '=' |
const | REMOVE_LIKE = 'LIKE' |
const | RESCHEDULE_24_HOURS = '24HOURS' |
const | RESCHEDULE_DIE_HARD_1 = 'DIEHARD1' |
const | RESCHEDULE_DIE_HARD_2 = 'DIEHARD2' |
const | RESCHEDULE_DIE_HARD_3 = 'DIEHARD3' |
const | RESCHEDULE_RUSHHOUR1 = 'RUSHHOUR1' |
const | RESCHEDULE_RUSHHOUR2 = 'RUSHHOUR2' |
const | RESCHEDULE_RUSHHOUR3 = 'RUSHHOUR3' |
const | RESCHEDULE_TERMINATOR_1 = 'TERMINATOR1' |
const | RESCHEDULE_TERMINATOR_2 = 'TERMINATOR2' |
const | RESCHEDULE_TERMINATOR_3 = 'TERMINATOR3' |
const | STATUS_ACTIVE = 'ACTIVE' |
const | STATUS_DISABLED = 'DISABLED' |
const | STATUS_ERROR = 'ERROR' |
const | STATUS_PROCESSING = 'PROCESSING' |
const | STATUS_RESCHEDULED = 'RESCHEDULED' |
Detailed Description
Scheduler facade class.
Definition at line 6 of file scheduler.facade.php.
Member Function Documentation
static Scheduler::create_adapter | ( | ) | [static] |
Create an adfapter for scheduled tasks.
- Returns:
- DAOScheduler
Definition at line 86 of file scheduler.facade.php.
00086 { 00087 $dao = new DAOScheduler(); 00088 $dao->sort('scheduledate', ISearchAdapter::ASC); 00089 return $dao; 00090 }
static Scheduler::create_task | ( | $ | params, | |
&$ | result, | |||
$ | exclusive = false |
|||
) | [static] |
Create a new task for scheduler.
- Parameters:
-
array $params Task created $result If true prior tasks with same action will get deleted $exclusive DAOUsers $user
- Returns:
- Status
Definition at line 36 of file scheduler.facade.php.
00036 { 00037 $params['exclusive'] = $exclusive; 00038 $params['runs_error'] = 0; 00039 $params['runs_success'] = 0; 00040 $cmd = CommandsFactory::create_command('scheduler', 'create', $params); 00041 $ret = $cmd->execute(); 00042 $result = $cmd->get_result(); 00043 return $ret; 00044 }
static Scheduler::get_all | ( | ) | [static] |
Return all Scheduled Actions.
- Returns:
- Array of DAOScheduler
Definition at line 97 of file scheduler.facade.php.
00097 { 00098 $dao = self::create_adapter(); 00099 return $dao->find_array(); 00100 }
static Scheduler::get_next_task | ( | ) | [static] |
Return next task to execute.
- Returns:
- DAOScheduler
Definition at line 107 of file scheduler.facade.php.
00107 { 00108 DB::start_trans(); 00109 /* @var $dao DAOScheduler */ 00110 $dao = self::create_adapter(); 00111 $dao->add_where('status', DBWhere::OP_IN, array(self::STATUS_ACTIVE, self::STATUS_RESCHEDULED)); 00112 $dao->add_where('scheduledate', '<=', time()); 00113 $dao->limit(0, 1); 00114 $query = $dao->create_select_query(); 00115 $query->set_policy(DBQuerySelect::FOR_UPDATE); 00116 00117 $ret = false; 00118 if ($dao->query($query->get_sql(), DAOScheduler::AUTOFETCH)) { 00119 $dao->status = self::STATUS_PROCESSING; 00120 $dao->update(); 00121 $ret = clone($dao); 00122 } 00123 00124 DB::commit(); 00125 return $ret; 00126 }
static Scheduler::get_reschedule_policies | ( | ) | [static] |
Returns list of all available reschedule policies.
- Returns:
- array
Definition at line 66 of file scheduler.facade.php.
00066 { 00067 return array( 00068 self::RESCHEDULE_TERMINATOR_1 => tr(self::RESCHEDULE_TERMINATOR_1, 'scheduler'), 00069 self::RESCHEDULE_TERMINATOR_2 => tr(self::RESCHEDULE_TERMINATOR_2, 'scheduler'), 00070 self::RESCHEDULE_TERMINATOR_3 => tr(self::RESCHEDULE_TERMINATOR_3, 'scheduler'), 00071 self::RESCHEDULE_DIE_HARD_1 => tr(self::RESCHEDULE_DIE_HARD_1, 'scheduler'), 00072 self::RESCHEDULE_DIE_HARD_2 => tr(self::RESCHEDULE_DIE_HARD_2, 'scheduler'), 00073 self::RESCHEDULE_DIE_HARD_3 => tr(self::RESCHEDULE_DIE_HARD_3, 'scheduler'), 00074 self::RESCHEDULE_24_HOURS => tr(self::RESCHEDULE_24_HOURS, 'scheduler'), 00075 self::RESCHEDULE_RUSHHOUR1 => tr(self::RESCHEDULE_RUSHHOUR1, 'scheduler'), 00076 self::RESCHEDULE_RUSHHOUR2 => tr(self::RESCHEDULE_RUSHHOUR2, 'scheduler'), 00077 self::RESCHEDULE_RUSHHOUR3 => tr(self::RESCHEDULE_RUSHHOUR3, 'scheduler'), 00078 ); 00079 }
static Scheduler::get_statuses | ( | ) | [static] |
get all status of the scheduler
- Returns:
- array
Definition at line 51 of file scheduler.facade.php.
00051 { 00052 return array( 00053 self::STATUS_ACTIVE => tr(self::STATUS_ACTIVE, 'scheduler'), 00054 self::STATUS_PROCESSING => tr(self::STATUS_PROCESSING, 'scheduler'), 00055 self::STATUS_DISABLED => tr(self::STATUS_DISABLED, 'scheduler'), 00056 self::STATUS_ERROR => tr(self::STATUS_ERROR, 'scheduler'), 00057 self::STATUS_RESCHEDULED => tr(self::STATUS_RESCHEDULED, 'scheduler'), 00058 ); 00059 }
static Scheduler::remove_tasks | ( | $ | action, | |
$ | op =
self::REMOVE_EXACT |
|||
) | [static] |
Remove tasks for given action.
- Parameters:
-
string $action string $op
- Returns:
- Status
Definition at line 146 of file scheduler.facade.php.
00146 { 00147 $ret = new Status(); 00148 00149 Load::commands('generics/massdelete'); 00150 $db_op = '='; 00151 switch ($op) { 00152 case self::REMOVE_LIKE: 00153 $action .= '%'; 00154 $db_op = DBWhere::OP_LIKE; 00155 break; 00156 default: 00157 break; 00158 } 00159 $where = new DBWhere(new DAOScheduler(), 'action', $db_op, $action); 00160 $cmd = new MassDeleteCommand('scheduler', array($where)); 00161 $ret->merge($cmd->execute()); 00162 00163 return $ret; 00164 }
static Scheduler::reschedule | ( | DAOScheduler $ | task | ) | [static] |
Reschedule the given task.
- Parameters:
-
DAOScheduler $task
- Returns:
- Status
Definition at line 134 of file scheduler.facade.php.
00134 { 00135 $cmd = CommandsFactory::create_command($task, 'reschedule', false); 00136 return $cmd->execute(); 00137 }
Member Data Documentation
const Scheduler::REMOVE_EXACT = '=' |
Definition at line 25 of file scheduler.facade.php.
const Scheduler::REMOVE_LIKE = 'LIKE' |
Definition at line 24 of file scheduler.facade.php.
const Scheduler::RESCHEDULE_24_HOURS = '24HOURS' |
Definition at line 19 of file scheduler.facade.php.
const Scheduler::RESCHEDULE_DIE_HARD_1 = 'DIEHARD1' |
Definition at line 16 of file scheduler.facade.php.
const Scheduler::RESCHEDULE_DIE_HARD_2 = 'DIEHARD2' |
Definition at line 17 of file scheduler.facade.php.
const Scheduler::RESCHEDULE_DIE_HARD_3 = 'DIEHARD3' |
Definition at line 18 of file scheduler.facade.php.
const Scheduler::RESCHEDULE_RUSHHOUR1 = 'RUSHHOUR1' |
Definition at line 20 of file scheduler.facade.php.
const Scheduler::RESCHEDULE_RUSHHOUR2 = 'RUSHHOUR2' |
Definition at line 21 of file scheduler.facade.php.
const Scheduler::RESCHEDULE_RUSHHOUR3 = 'RUSHHOUR3' |
Definition at line 22 of file scheduler.facade.php.
const Scheduler::RESCHEDULE_TERMINATOR_1 = 'TERMINATOR1' |
Definition at line 13 of file scheduler.facade.php.
const Scheduler::RESCHEDULE_TERMINATOR_2 = 'TERMINATOR2' |
Definition at line 14 of file scheduler.facade.php.
const Scheduler::RESCHEDULE_TERMINATOR_3 = 'TERMINATOR3' |
Definition at line 15 of file scheduler.facade.php.
const Scheduler::STATUS_ACTIVE = 'ACTIVE' |
Definition at line 7 of file scheduler.facade.php.
const Scheduler::STATUS_DISABLED = 'DISABLED' |
Definition at line 9 of file scheduler.facade.php.
const Scheduler::STATUS_ERROR = 'ERROR' |
Definition at line 10 of file scheduler.facade.php.
const Scheduler::STATUS_PROCESSING = 'PROCESSING' |
Definition at line 8 of file scheduler.facade.php.
const Scheduler::STATUS_RESCHEDULED = 'RESCHEDULED' |
Definition at line 11 of file scheduler.facade.php.
The documentation for this class was generated from the following file:
- contributions/scheduler/model/classes/scheduler.facade.php