FOSSology  4.4.0
Open Source License Compliance by Open Source Software
Fossology\Lib\Agent\Agent Class Reference

Structure of an Agent with all required parameters. More...

Inheritance diagram for Fossology\Lib\Agent\Agent:
Inheritance graph
Collaboration diagram for Fossology\Lib\Agent\Agent:
Collaboration graph

Public Member Functions

 __construct ($agentName, $version, $revision)
 
 scheduler_connect ()
 Connect with scheduler and initialize options. More...
 
 heartbeat ($newProcessed)
 Send hear beat to the scheduler. More...
 
 bail ($exitvalue)
 Bail the agent, print the stack and disconnect from scheduler. More...
 
 scheduler_disconnect ($exitvalue)
 Closes connection from scheduler. More...
 
 scheduler_greet ()
 Greet the scheduler at the beginning of connection. More...
 
 initArsTable ()
 Initialize ARS table.
 
 run_scheduler_event_loop ()
 Runs a loop to read commands from scheduler and process them. More...
 

Static Public Member Functions

static heartbeat_handler ($signo)
 Function to handle hear beats from the agent and send them to the scheduler from STDOUT. More...
 

Protected Member Functions

 processUploadId ($uploadId)
 Given an upload ID, process the items in it. More...
 

Protected Attributes

 $userId
 
 $groupId
 
 $jobId
 
 $agentSpecifOptions = ""
 
 $agentSpecifLongOptions = array()
 
 $args = array()
 
 $dbManager
 
 $agentDao
 
 $container
 
 $schedulerMode
 

Private Member Functions

 scheduler_current ()
 Read the commands from scheduler. More...
 

Private Attributes

 $agentName
 
 $agentVersion
 
 $agentRev
 
 $agentDesc
 
 $agentArs
 
 $agentId
 

Detailed Description

Structure of an Agent with all required parameters.

All PHP language based agents should inherit from this class.

Definition at line 40 of file Agent.php.

Constructor & Destructor Documentation

◆ __construct()

Fossology\Lib\Agent\Agent::__construct (   $agentName,
  $version,
  $revision 
)

Constructor for Agent class

Parameters
string$agentNameName of the agent
string$versionVersion of the agent
string$revisionRevision of the agent

Definition at line 108 of file Agent.php.

Member Function Documentation

◆ bail()

Fossology\Lib\Agent\Agent::bail (   $exitvalue)

Bail the agent, print the stack and disconnect from scheduler.

Parameters
int$exitvalueExit value to sent to scheduler
Exceptions

Definition at line 221 of file Agent.php.

◆ heartbeat()

Fossology\Lib\Agent\Agent::heartbeat (   $newProcessed)

Send hear beat to the scheduler.

If the agent is running in scheduler mode, it will dispatch the heart beat signal for the scheduler. This signal is handled by heartbeat_handler() .

The function set the global processed variable and alive variable.

Parameters
int$newProcessedNumber of items processed since last call.

Definition at line 203 of file Agent.php.

◆ heartbeat_handler()

static Fossology\Lib\Agent\Agent::heartbeat_handler (   $signo)
static

Function to handle hear beats from the agent and send them to the scheduler from STDOUT.

The function reads from global parameters processed and alive to know the state of the agent. processed contains the number of items processed by the agent and alive flag have to be reset to TRUE by the agent to signal its status. The function resets the alive flag to FALSE.

Parameters
int$signoInterrupt signal.

Definition at line 184 of file Agent.php.

◆ processUploadId()

Fossology\Lib\Agent\Agent::processUploadId (   $uploadId)
abstractprotected

◆ run_scheduler_event_loop()

Fossology\Lib\Agent\Agent::run_scheduler_event_loop ( )

Runs a loop to read commands from scheduler and process them.

The function loops till scheduler_current() returns FALSE (end of connection).

The flow of the function:

  1. Send new heat beat to the scheduler.
  2. Extract upload id from the scheduler.
  3. Write the ARS record.
  4. Process the upload using processUploadId().
  5. Write processed ARS record.
  6. Loop back and read for next command from scheduler.

Definition at line 311 of file Agent.php.

◆ scheduler_connect()

Fossology\Lib\Agent\Agent::scheduler_connect ( )

Connect with scheduler and initialize options.

This function reads arguments passed from the CLI to the agent and initialize parameters according to them. It also greets the scheduler and setup signal alarms to keep connection active.

See also
scheduler_greet()

Definition at line 139 of file Agent.php.

◆ scheduler_current()

Fossology\Lib\Agent\Agent::scheduler_current ( )
private

Read the commands from scheduler.

Read the commands sent from scheduler (from STDIN). The function returns FALSE if the connection is closed by the scheduler (received CLOSE or END) otherwise the command received.

Returns
boolean|string Command from scheduler (FALSE if CLOSE or END is received).

Definition at line 284 of file Agent.php.

◆ scheduler_disconnect()

Fossology\Lib\Agent\Agent::scheduler_disconnect (   $exitvalue)

Closes connection from scheduler.

The function sends a BYE <exit-value> to the scheduler to close the connection along with final heart beat only if the agent is running in scheduler mode.

Parameters
int$exitvalueExit value to sent to scheduler

Definition at line 236 of file Agent.php.

◆ scheduler_greet()

Fossology\Lib\Agent\Agent::scheduler_greet ( )

Greet the scheduler at the beginning of connection.

The function sends the agent version and an OK message through STDOUT.

Definition at line 249 of file Agent.php.

Member Data Documentation

◆ $agentArs

string Fossology\Lib\Agent\Agent::$agentArs
private

Agent ARS table name

Definition at line 56 of file Agent.php.

◆ $agentDao

AgentDao Fossology\Lib\Agent\Agent::$agentDao
protected

Agent DAO object

Definition at line 92 of file Agent.php.

◆ $agentDesc

string Fossology\Lib\Agent\Agent::$agentDesc
private

Agent description (displayed in UI)

Definition at line 53 of file Agent.php.

◆ $agentId

int Fossology\Lib\Agent\Agent::$agentId
private

Agent ID (from DB)

Definition at line 59 of file Agent.php.

◆ $agentName

string Fossology\Lib\Agent\Agent::$agentName
private

Name of the agent

Definition at line 44 of file Agent.php.

◆ $agentRev

string Fossology\Lib\Agent\Agent::$agentRev
private

Agent revision

Definition at line 50 of file Agent.php.

◆ $agentSpecifLongOptions

array Fossology\Lib\Agent\Agent::$agentSpecifLongOptions = array()
protected

Agent specific CLI long options (used for communication with scheduler)

Definition at line 80 of file Agent.php.

◆ $agentSpecifOptions

string Fossology\Lib\Agent\Agent::$agentSpecifOptions = ""
protected

Agent specific CLI options (used for communication with scheduler)

Definition at line 75 of file Agent.php.

◆ $agentVersion

string Fossology\Lib\Agent\Agent::$agentVersion
private

Version of the agent

Definition at line 47 of file Agent.php.

◆ $args

array Fossology\Lib\Agent\Agent::$args = array()
protected

Arguments value (from CLI) map for current agent

Definition at line 84 of file Agent.php.

◆ $container

ContainerBuilder Fossology\Lib\Agent\Agent::$container
protected

Symfony DI container

Definition at line 96 of file Agent.php.

◆ $dbManager

DbManager Fossology\Lib\Agent\Agent::$dbManager
protected

DB manager used by agent

Definition at line 88 of file Agent.php.

◆ $groupId

int Fossology\Lib\Agent\Agent::$groupId
protected

Current group ID

Definition at line 66 of file Agent.php.

◆ $jobId

int Fossology\Lib\Agent\Agent::$jobId
protected

Job ID for the agent to work on

Definition at line 69 of file Agent.php.

◆ $schedulerMode

bool Fossology\Lib\Agent\Agent::$schedulerMode
protected

Running in scheduler mode or standalone

Definition at line 100 of file Agent.php.

◆ $userId

int Fossology\Lib\Agent\Agent::$userId
protected

Current user ID

Definition at line 63 of file Agent.php.


The documentation for this class was generated from the following file: