The ZendJobQueue is a PHP class that implements a connection to the Job Queue Daemon
Available since: 5.0
class ZendJobQueue {
/* Constants */
const int TYPE_HTTP;
const int TYPE_HTTP_RELATIVE;
const int TYPE_SHELL;
const int PRIORITY_LOW;
const int PRIORITY_NORMAL;
const int PRIORITY_HIGH;
const int PRIORITY_URGENT;
const int STATUS_PENDING;
const int STATUS_WAITING_PREDECESSOR;
const int STATUS_RUNNING;
const int STATUS_COMPLETED;
const int STATUS_FAILED;
const int STATUS_OK;
const int STATUS_LOGICALLY_FAILED;
const int STATUS_TIMEOUT;
const int STATUS_REMOVED;
const int STATUS_SCHEDULED;
const int STATUS_SUSPENDED;
const int SORT_NONE;
const int SORT_BY_ID;
const int SORT_BY_TYPE;
const int SORT_BY_SCRIPT;
const int SORT_BY_APPLICATION;
const int SORT_BY_NAME;
const int SORT_BY_PRIORITY;
const int SORT_BY_STATUS;
const int SORT_BY_PREDECESSOR;
const int SORT_BY_PERSISTENCE;
const int SORT_BY_CREATION_TIME;
const int SORT_BY_SCHEDULE_TIME;
const int SORT_BY_START_TIME;
const int SORT_BY_END_TIME;
const int SORT_ASC;
const int SORT_DESC;
const int OK;
const int FAILED;
/* Methods */
void __construct ([ string $queue ])
int createHttpJob (string $url, array $vars, mixed $options)
array getJobStatus (int $job_id)
boolean removeJob (int $job_id)
boolean restartJob (int $job_id)
boolean isSuspended (void)
static boolean isJobQueueDaemonRunning (void)
void suspendQueue (void)
void resumeQueue (void)
array getStatistics (void)
array getConfig (void)
boolean reloadConfig (void)
array getJobInfo (int $job_id)
array getDependentJobs (int $job_id)
array getJobsList (array $query, int $total)
array getApplications (void)
array getSchedulingRules (void)
array getSchedulingRule (int $rule_id)
boolean deleteSchedulingRule (int $rule_id)
boolean suspendSchedulingRule (int $rule_id)
boolean resumeSchedulingRule (int $rule_id)
boolean updateSchedulingRule (int $rule_id, string $script, array $vars, array $options)
static array getCurrentJobParams (void)
static void setCurrentJobStatus (int $completion, string $msg)
}
Creates a ZendJobQueue object connected to a Job Queue daemon.
Available since version 5.0
void ZendJobQueue::__construct ([ string $queue ])
Creates a new URL based job to make the Job Queue Daemon call given $script with given $vars
Available since version 5.0
int ZendJobQueue::createHttpJob (string $url, array $vars, mixed $options)
A job identifier which can be used to retrieve the job status
Retrieves status of previously created job identified by $job_id
Available since version 5.0
array ZendJobQueue::getJobStatus (int $job_id)
The array contains status, completion status and output of the job
Removes the job from the queue. Makes all dependent jobs fail. In case the job is in progress it will be finished but dependent jobs won't be started anyway. For non-existing jobs the function just returns false. Finished jobs are simply removed from the database
Available since version 5.0
boolean ZendJobQueue::removeJob (int $job_id)
The job was removed or not removed
Restart a previously executed Job and all its followers.
Available since version 5.0
boolean ZendJobQueue::restartJob (int $job_id)
If the job was restarted or not restarted
Checks if Queue is suspended and returns true or false
Available since version 5.0
boolean ZendJobQueue::isSuspended (void)
A Job Queue status
Checks if the Job Queue Daemon is running
Available since version 5.0
static boolean ZendJobQueue::isJobQueueDaemonRunning (void)
Return true if the Job Queue Deamon is running, otherwise it returns false
Suspends the Job Queue so it will accept new jobs, but won't start them. The jobs which were executed during call to this function will be completed
Available since version 5.0
void ZendJobQueue::suspendQueue (void)
Resumes the Job Queue so it will schedule and start queued jobs.
Available since version 5.0
void ZendJobQueue::resumeQueue (void)
Returns internal daemon statistics such as up-time, number of complete jobs, number of failed jobs, number of waiting jobs, number of currently running jobs, etc
Available since version 5.0
array ZendJobQueue::getStatistics (void)
Associative array
Returns the current value of the configuration option of the Job Queue Daemon
Available since version 5.0
array ZendJobQueue::getConfig (void)
Associative array of configuration variables
Re-reads the configuration file of the Job Queue Daemon and reloads all directives that are reloadable
Available since version 5.0
boolean ZendJobQueue::reloadConfig (void)
If configuration file was loaded successfully or not
Returns an associative array with properties of the job with the given id from the daemon database
Available since version 5.0
array ZendJobQueue::getJobInfo (int $job_id)
array of job details. The following properties are provided (some of them don't have to always be set): "id" - The job identifier "type" - The job type (see TYPE_* constants) "status" - The job status (see STATUS_* constants) "priority" - The job priority (see PRIORITY_* constants) "persistent" - The persistence flag "script" - The URL or SHELL script name "predecessor" - The job predecessor "name" - The job name "vars" - The input variables or arguments "http_headers" - The additional HTTP headers for HTTP jobs "output" - The output of the job "error" - The error output of the job "creation_time" - The time when the job was created "start_time" - The time when the job was started "end_time" - The time when the job was finished "schedule" - The CRON-like schedule command "schedule_time" - The time when the job execution was scheduled "app_id" - The application name
Returns a list of associative arrays with the properties of the jobs which depend on the job with the given identifier
Available since version 5.0
array ZendJobQueue::getDependentJobs (int $job_id)
A list of jobs
Returns a list of associative arrays with properties of jobs which conform to a given query
Available since version 5.0
array ZendJobQueue::getJobsList (array $query, int $total)
A list of jobs with their details
Returns an array of application names known by the daemon
Available since version 5.0
array ZendJobQueue::getApplications (void)
A list of applications
Returns an array of all the registered scheduled rules. Each rule is represented by a nested associative array with the following properties: "id" - The scheduling rule identifier "status" - The rule status (see STATUS_* constants) "type" - The rule type (see TYPE_* constants) "priority" - The priority of the jobs created by this rule "persistent" - The persistence flag of the jobs created by this rule "script" - The URL or script to run "name" - The name of the jobs created by this rule "vars" - The input variables or arguments "http_headers" - The additional HTTP headers "schedule" - The CRON-like schedule command "app_id" - The application name associated with this rule and created jobs "last_run" - The last time the rule was run "next_run" - The next time the rule will run
Available since version 5.0
array ZendJobQueue::getSchedulingRules (void)
A list of scheduling rules
Returns an associative array with the properties of the scheduling rule identified by the given argument. The list of the properties is the same as in getSchedulingRule()
Available since version 5.0
array ZendJobQueue::getSchedulingRule (int $rule_id)
Information about the scheduling rule
Deletes the scheduling rule identified by the given $rule_id and scheduled jobs created by this rule
Available since version 5.0
boolean ZendJobQueue::deleteSchedulingRule (int $rule_id)
If scheduling rule was deleted or not deleted
Suspends the scheduling rule identified by given $rule_id and deletes scheduled jobs created by this rule
Available since version 5.0
boolean ZendJobQueue::suspendSchedulingRule (int $rule_id)
If scheduling rule was suspended or not suspended
Resumes the scheduling rule identified by given $rule_id and creates a corresponding scheduled job
Available since version 5.0
boolean ZendJobQueue::resumeSchedulingRule (int $rule_id)
If the scheduling rule was resumed or not resumed
Updates and reschedules the existing scheduling rule
Available since version 5.0
boolean ZendJobQueue::updateSchedulingRule (int $rule_id, string $script, array $vars, array $options)
If scheduling rule was updated or not updated
Decodes an array of input variables passed to the HTTP job
Available since version 5.0
static array ZendJobQueue::getCurrentJobParams (void)
The job variables
Reports job completion status (OK or FAILED) back to the daemon
Available since version 5.0
static void ZendJobQueue::setCurrentJobStatus (int $completion, string $msg)