FOSSology  4.4.0
Open Source License Compliance by Open Source Software
common-scheduler.php File Reference

Core functions for communicating with the scheduler (v2) More...

Go to the source code of this file.

Functions

 fo_scheduler_connect ($IPaddr='', $Port='', &$ErrorMsg="")
 Connect to the scheduler. More...
 
 fo_scheduler_read ($SchedObj, $MaxSize=2048)
 Read the scheduler socket. More...
 
 fo_scheduler_write ($SchedObj, $msg)
 Write to the scheduler socket. More...
 
 fo_scheduler_close ($SchedObj)
 Close the scheduler connection (socket). More...
 
 fo_communicate_with_scheduler ($input, &$output, &$error_msg)
 Communicate with scheduler, send commands to the scheduler, then get the output. More...
 
 GetRunnableJobList ()
 Get runnable job list, the process is below: More...
 

Detailed Description

Core functions for communicating with the scheduler (v2)

Version
2

Definition in file common-scheduler.php.

Function Documentation

◆ fo_communicate_with_scheduler()

fo_communicate_with_scheduler (   $input,
$output,
$error_msg 
)

Communicate with scheduler, send commands to the scheduler, then get the output.

Parameters
string$input

The command that you want to send to the scheduler.

Now the commands include:

  • stop
  • pause <job_id>
  • agents
  • reload
  • status
  • status <job_id>
  • restart <job_id>
  • verbose <level>
  • verbose <job_id> <level>
  • database
  • priority <job_id> <level>
[out]string&$outputSave the output from the scheduler, when received, that means this communication with the scheduler is over
[out]string&$error_msgSave the error message
Returns
True on success, false on failure

Definition at line 120 of file common-scheduler.php.

◆ fo_scheduler_close()

fo_scheduler_close (   $SchedObj)

Close the scheduler connection (socket).

Parameters
resource$SchedObjScheduler object (currently the socket)
Returns
void

Definition at line 90 of file common-scheduler.php.

◆ fo_scheduler_connect()

fo_scheduler_connect (   $IPaddr = '',
  $Port = '',
$ErrorMsg = "" 
)

Connect to the scheduler.

The scheduler IP address and port are read from fossology.conf. But they may be overridden with the optional parameters.

Parameters
string$IPaddrOptional IP address, default is 127.0.0.1
int$PortOptional port, default is 5555
[out]string&$ErrorMsgThe error message is stored
Returns
Scheduler object or false if failure to connect.
Note
Currently returned object is the socket used to communicate with the scheduler. However, it is highly discouraged to use it directly instead of through the functions in this file in case we need to keep track of other data associated with a connection.

Definition at line 31 of file common-scheduler.php.

◆ fo_scheduler_read()

fo_scheduler_read (   $SchedObj,
  $MaxSize = 2048 
)

Read the scheduler socket.

Parameters
resource$SchedObjScheduler object (currently the socket)
int$MaxSizeOptional max read size, default is 2048
Returns
Message from scheduler

Definition at line 62 of file common-scheduler.php.

◆ fo_scheduler_write()

fo_scheduler_write (   $SchedObj,
  $msg 
)

Write to the scheduler socket.

Parameters
resource$SchedObjScheduler object (currently the socket)
string$msgMessage to write to scheduler
Returns
Number of bytes successfully written or false on failure. The error code can be retrieved with socket_last_error() and passed to socket_strerror() for a text explanation.

Definition at line 78 of file common-scheduler.php.

◆ GetRunnableJobList()

GetRunnableJobList ( )

Get runnable job list, the process is below:

  1. Send command 'status'to scheduler
  2. The scheduler return status of all scheduled jobs
  3. Retrieve the job list
  4. Return the job list
Returns
An array, the runnable job list the array is like: Array(1, 2, 3, .., i), sorted, if no jobs, return nothing

Definition at line 171 of file common-scheduler.php.