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

Library of functions used by the UI to manage jobs. More...

Go to the source code of this file.

Functions

 JobAddUpload ($userId, $groupId, $job_name, $filename, $desc, $UploadMode, $folder_pk, $public_perm=Auth::PERM_NONE, $setGlobal=0)
 Insert a new upload record, and update the foldercontents table. More...
 
 JobQueueAdd ($job_pk, $jq_type, $jq_args, $jq_runonpfile, $Depends, $host=NULL, $jq_cmd_args=NULL)
 Insert a jobqueue + jobdepends records. More...
 
 GetJobList ($status)
 Gets the list of jobqueue records with the requested $status. More...
 
 QueueUploadsOnAgents ($upload_pk_list, $agent_list, $Verbose)
 Schedule agent tasks on upload ids. More...
 
 QueueUploadsOnDelagents ($upload_pk_list)
 Schedule delagent on upload ids. More...
 
 IsAlreadyScheduled ($job_pk, $AgentName, $upload_pk)
 Check if an agent is already scheduled in a job. More...
 
 CommonAgentAdd ($plugin, $job_pk, $upload_pk, &$ErrorMsg, $Dependencies, $jqargs="", $jq_cmd_args=NULL)
 Queue an agent. This is a simple version of AgentAdd() that can be used by multiple plugins that only use upload_pk as jqargs. More...
 
 isAlreadyRunning ($agentName, $upload_pk)
 Check if an agent is already running in a job. More...
 

Detailed Description

Library of functions used by the UI to manage jobs.

Jobs information is stored in the jobs, jobdepends and jobqueue tables.

Terminology:
Scheduled jobs are divided into a specific heirarchy.
Job
This is the Job container and is saved in a database job record.
JobQueue
There may be several tasks to perform for a job. For example, a job may be composed of an unpack task, an adj2nest task, and a nomos task. Each job task is specified in a database jobqueue record.

JobQueue tasks may have dependencies upon the completion of other JobQueue tasks. The jobdepends tables keep those parent child relationships.

Definition in file common-job.php.

Function Documentation

◆ CommonAgentAdd()

CommonAgentAdd (   $plugin,
  $job_pk,
  $upload_pk,
$ErrorMsg,
  $Dependencies,
  $jqargs = "",
  $jq_cmd_args = NULL 
)

Queue an agent. This is a simple version of AgentAdd() that can be used by multiple plugins that only use upload_pk as jqargs.

Before queuing, check if agent needs to be queued. It doesn't need to be queued if:

  • It is already queued
  • It has already been run by the latest agent version
Parameters
Plugin$pluginCaller plugin object
int$job_pk
int$upload_pk
[out]string&$ErrorMsgError message on failure
array$DependenciesArray of named dependencies. Each array element is the plugin name. For example, array(agent_adj2nest, agent_pkgagent). Typically, this will just be array(agent_adj2nest).
string$jqargs(optional) jobqueue.jq_args
Returns
  • jq_pk Successfully queued
  • 0 Not queued, latest version of agent has previously run successfully
  • -1 Not queued, error, error string in $ErrorMsg

Definition at line 433 of file common-job.php.

◆ GetJobList()

GetJobList (   $status)

Gets the list of jobqueue records with the requested $status.

Parameters
string$statusThe status might be:
Started, Completed, Restart, Failed, Paused, etc.
The status 'Started' and 'Restart', you can call them as running status to get all the running job list, you can set the $status as 'tart'
Returns
Job list related to the jobstatus, the result is like: Array(1, 2, 3, .., i), sorted

Definition at line 244 of file common-job.php.

◆ isAlreadyRunning()

isAlreadyRunning (   $agentName,
  $upload_pk 
)

Check if an agent is already running in a job.

This is used to make sure dependencies don't get scheduled multiple times when the latest scan is not finished.

Parameters
string$agentNameThe agent name (from agent.agent_name)
int$upload_pkThe upload id
Returns
int jq_pk of scheduled jobqueue or 0 = not scheduled

Definition at line 498 of file common-job.php.

◆ IsAlreadyScheduled()

IsAlreadyScheduled (   $job_pk,
  $AgentName,
  $upload_pk 
)

Check if an agent is already scheduled in a job.

This is used to make sure dependencies, like unpack don't get scheduled multiple times within a single job.

Parameters
int$job_pkThe job to be checked
string$AgentNameThe agent name (from agent.agent_name)
Returns
jq_pk of scheduled jobqueue or 0 = not scheduled

Definition at line 378 of file common-job.php.

◆ JobAddUpload()

JobAddUpload (   $userId,
  $groupId,
  $job_name,
  $filename,
  $desc,
  $UploadMode,
  $folder_pk,
  $public_perm = Auth::PERM_NONE,
  $setGlobal = 0 
)

Insert a new upload record, and update the foldercontents table.

Parameters
int$userIdUser creating the job
int$groupIdGroup creating the job
string$job_nameJob name
string$filenameFor upload from URL, this is the URL.
For upload from file, this is the filename.
For upload from server, this is the file path.
string$descOptional user file description.
int$UploadMode1<<2=URL, 1<<3=upload from server or file
int$folder_pkThe folder to contain this upload
int$public_permThe public permission on this upload
Returns
upload_pk or null (failure). On failure, error is written to stdout

** Add user permission to perm_upload ****

Definition at line 56 of file common-job.php.

◆ JobQueueAdd()

JobQueueAdd (   $job_pk,
  $jq_type,
  $jq_args,
  $jq_runonpfile,
  $Depends,
  $host = NULL,
  $jq_cmd_args = NULL 
)

Insert a jobqueue + jobdepends records.

Parameters
int$job_pkThe job primary key (returned by JobAddJob)
string$jq_typeName of agent (should match the name in agent.conf
string$jq_argsArguments to pass to the agent in the form of $jq_args="folder_pk='$Folder' name='$Name' description='$Desc' ...";
string$jq_runonpfileColumn name
array$DependsArray of jq_pk's this jobqueue is dependent on.
string$hostHost required for the job
string$jq_cmd_argsCommand line arguments
Returns
New jobqueue key (jobqueue.jq_pk), or null on failure.

Definition at line 157 of file common-job.php.

◆ QueueUploadsOnAgents()

QueueUploadsOnAgents (   $upload_pk_list,
  $agent_list,
  $Verbose 
)

Schedule agent tasks on upload ids.

Parameters
string$upload_pk_listUpload ids, The string can be a comma-separated list of upload ids. Or, use 'ALL' to specify all upload ids.
array$agent_listArray of agent plugin objects to schedule.
bool$VerboseVerbose output, not empty: output, empty: does not output

Definition at line 268 of file common-job.php.

◆ QueueUploadsOnDelagents()

QueueUploadsOnDelagents (   $upload_pk_list)

Schedule delagent on upload ids.

Parameters
string$upload_pk_listUpload ids, The string can be a comma-separated list of upload ids. Or, use 'ALL' to specify all upload ids.

Definition at line 333 of file common-job.php.