FOSSology  3.2.0rc1
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 51 of file Agent.php.

Constructor & Destructor Documentation

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 119 of file Agent.php.

Member Function Documentation

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 232 of file Agent.php.

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 214 of file Agent.php.

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 195 of file Agent.php.

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

Given an upload ID, process the items in it.

This function is implemented by agent and should call heartbeat() at regular intervals.

Parameters
int$uploadIdUpload to be processed by the agent.
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 321 of file Agent.php.

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 150 of file Agent.php.

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 294 of file Agent.php.

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 247 of file Agent.php.

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 260 of file Agent.php.

Member Data Documentation

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

Agent ARS table name

Definition at line 67 of file Agent.php.

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

Agent DAO object

Definition at line 103 of file Agent.php.

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

Agent description (displayed in UI)

Definition at line 64 of file Agent.php.

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

Agent ID (from DB)

Definition at line 70 of file Agent.php.

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

Name of the agent

Definition at line 55 of file Agent.php.

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

Agent revision

Definition at line 61 of file Agent.php.

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

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

Definition at line 91 of file Agent.php.

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

Agent specific CLI options (used for communication with scheduler)

Definition at line 86 of file Agent.php.

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

Version of the agent

Definition at line 58 of file Agent.php.

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

Arguments value (from CLI) map for current agent

Definition at line 95 of file Agent.php.

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

Symfony DI container

Definition at line 107 of file Agent.php.

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

DB manager used by agent

Definition at line 99 of file Agent.php.

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

Current group ID

Definition at line 77 of file Agent.php.

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

Job ID for the agent to work on

Definition at line 80 of file Agent.php.

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

Running in scheduler mode or standalone

Definition at line 111 of file Agent.php.

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

Current user ID

Definition at line 74 of file Agent.php.


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