class ZendAPI_Queue (View source)

Properties

$_jobqueue_url

Methods

zendapi_queue(string $queue_url)

Constructor for a job queue connection

bool
login(string $password, int $application_id = null)

Open a connection to a job queue

int
addJob(Job $job)

Insert a new job to the queue, the Job is passed by reference because its new job ID and status will be set in the Job object If the returned job id is 0 it means the job could be added to the queue

Job
getJob(int $job_id)

Return a Job object that describing a job in the queue

int
updateJob(Job $job)

Update an existing job in the queue with it's new properties. If job doesn't exists, a new job will be added. Job is passed by reference and it's updated from the queue.

bool
removeJob(int|int[] $job_id)

Remove a job from the queue

bool
suspendJob(int|int[] $job_id)

Suspend a job in the queue (without removing it)

bool
resumeJob(int|int[] $job_id)

Resume a suspended job in the queue

bool
requeueJob(Job $job)

Requeue failed job back to the queue.

array
getStatistics()

returns job statistics

bool
isScriptExists(string $path)

Returns whether a script exists in the document root

bool
isSuspend()

Returns whether the queue is suspended

array
getJobsInQueue(array $filter_options = null, int $max_jobs = -1, bool $with_globals_and_output = false)

Return a list of jobs in the queue according to the options given in the filter_options parameter, doesn't return jobs in "final states" (failed, complete) If application id is set for this queue, only jobs with this application id will be returned

int
getNumOfJobsInQueue(array $filter_options = null)

Return the number of jobs in the queue according to the options given in the filter_options parameter

array
getAllhosts()

Return all the hosts that jobs were submitted from.

array
getAllApplicationIDs()

Return all the application ids exists in queue.

array
getHistoricJobs(int $status, int $start_time, int $end_time, int $index, int $count, int $total)

Return finished jobs (either failed or successed) between time range allowing paging.

bool
suspendQueue()

Suspends queue operation

bool
resumeQueue()

Resumes queue operation

string
getLastError()

Return description of the last error occurred in the queue object. After every method invoked an error string describing the error is store in the queue object.

bool
setMaxHistoryTime()

Sets a new maximum time for keeping historic jobs

Details

ZendAPI_Queue zendapi_queue(string $queue_url)

Constructor for a job queue connection

Parameters

string $queue_url

Full address where the queue is in the form host:port

Return Value

ZendAPI_Queue

bool login(string $password, int $application_id = null)

Open a connection to a job queue

Parameters

string $password

For authentication, password must be specified to connect to a queue

int $application_id

Optional, if set, all subsequent calls to job related methods will use this application id (unless explicitly specified otherwise). I.e. When adding new job, unless this job already set an application id, the job will be assigned the queue application id

Return Value

bool Success

int addJob(Job $job)

Insert a new job to the queue, the Job is passed by reference because its new job ID and status will be set in the Job object If the returned job id is 0 it means the job could be added to the queue

Parameters

Job $job

The Job we want to insert to the queue (by ref.)

Return Value

int

The inserted job id

Job getJob(int $job_id)

Return a Job object that describing a job in the queue

Parameters

int $job_id

The job id

Return Value

Job

Object describing a job in the queue

int updateJob(Job $job)

Update an existing job in the queue with it's new properties. If job doesn't exists, a new job will be added. Job is passed by reference and it's updated from the queue.

Parameters

Job $job

The Job object, the ID of the given job is the id of the job we try to update. If the given Job doesn't have an assigned ID, a new job will be added

Return Value

int

The id of the updated job

bool removeJob(int|int[] $job_id)

Remove a job from the queue

Parameters

int|int[] $job_id

The job id or array of job ids we want to remove from the queue

Return Value

bool Success/Failure

bool suspendJob(int|int[] $job_id)

Suspend a job in the queue (without removing it)

Parameters

int|int[] $job_id

The job id or array of job ids we want to suspend

Return Value

bool Success/Failure

bool resumeJob(int|int[] $job_id)

Resume a suspended job in the queue

Parameters

int|int[] $job_id

The job id or array of job ids we want to resume

Return Value

bool

Success/Failure (if the job wasn't suspended, the function will return false)

bool requeueJob(Job $job)

Requeue failed job back to the queue.

Parameters

Job $job

job object to re-query

Return Value

bool
  • true or false.

array getStatistics()

returns job statistics

Return Value

array

with the following: "total_complete_jobs" "total_incomplete_jobs" "average_time_in_queue" [msec] "average_waiting_time" [sec] "added_jobs_in_window" "activated_jobs_in_window" "completed_jobs_in_window" moving window size can be set through ini file

bool isScriptExists(string $path)

Returns whether a script exists in the document root

Parameters

string $path

relative script path

Return Value

bool
  • TRUE if script exists in the document root FALSE otherwise

bool isSuspend()

Returns whether the queue is suspended

Return Value

bool
  • TRUE if job is suspended FALSE otherwise

array getJobsInQueue(array $filter_options = null, int $max_jobs = -1, bool $with_globals_and_output = false)

Return a list of jobs in the queue according to the options given in the filter_options parameter, doesn't return jobs in "final states" (failed, complete) If application id is set for this queue, only jobs with this application id will be returned

Parameters

array $filter_options

Array of optional filter options to filter the jobs we want to get from the queue. If not set, all jobs will be returned.
Options can be: priority, application_id, name, status, recurring.

int $max_jobs

Maximum jobs to retrieve. Default is -1, getting all jobs available.

bool $with_globals_and_output

Whether gets the global variables dataand job output. Default is false.

Return Value

array

Jobs that satisfies filter_options.

int getNumOfJobsInQueue(array $filter_options = null)

Return the number of jobs in the queue according to the options given in the filter_options parameter

Parameters

array $filter_options

Array of optional filter options to filter the jobs we want to get from the queue. If not set, all jobs will be counted.
Options can be: priority, application_id, host, name, status, recurring.

Return Value

int

Number of jobs that satisfy filter_options.

array getAllhosts()

Return all the hosts that jobs were submitted from.

Return Value

array

array getAllApplicationIDs()

Return all the application ids exists in queue.

Return Value

array

array getHistoricJobs(int $status, int $start_time, int $end_time, int $index, int $count, int $total)

Return finished jobs (either failed or successed) between time range allowing paging.

Jobs are sorted by job id descending.

Parameters

int $status

Filter to jobs by status, 1-success, 0-failed either logical or execution.

int $start_time

UNIX timestamp. Get only jobs finished after $start_time.

int $end_time

UNIX timestamp. Get only jobs finished before $end_time.

int $index

Get jobs starting from the $index-th place.

int $count

Get only $count jobs.

int $total

Pass by reference. Return the total number of jobs statisifed the query criteria.

Return Value

array

of jobs.

bool suspendQueue()

Suspends queue operation

Return Value

bool
  • TRUE if successful FALSE otherwise

bool resumeQueue()

Resumes queue operation

Return Value

bool
  • TRUE if successful FALSE otherwise

string getLastError()

Return description of the last error occurred in the queue object. After every method invoked an error string describing the error is store in the queue object.

Return Value

string

bool setMaxHistoryTime()

Sets a new maximum time for keeping historic jobs

Return Value

bool
  • TRUE if successful FALSE otherwise