FOSSology
4.4.0
Open Source License Compliance by Open Source Software
|
Header file with agent related operations. More...
#include <host.h>
#include <job.h>
#include <scheduler.h>
#include <sys/types.h>
#include <gio/gio.h>
#include <glib.h>
Go to the source code of this file.
Classes | |
struct | meta_agent_t |
struct | agent_t |
Macros | |
#define | MAX_CMD 1023 |
the size of the agent's command buffer (arbitrary) | |
#define | MAX_NAME 255 |
the size of the agent's name buffer (arbitrary) | |
#define | MAX_ARGS 32 |
the size of the argument buffer (arbitrary) | |
#define | DEFAULT_RET -1 |
default return code (arbitrary) | |
#define | LOCAL_HOST "localhost" |
#define | SAG_NOKILL (1 << 0) |
This agent should not be killed when updating the agent. | |
#define | SAG_EXCLUSIVE (1 << 1) |
This agent must not run at the same time as any other agent. | |
#define | SAG_NOEMAIL (1 << 2) |
This agent should not send notification emails. | |
#define | SAG_LOCAL (1 << 3) |
This agent should only run on localhost. | |
#define | AGENT_STATUS_TYPES(apply) |
#define | SELECT_ENUM(passed) AG_##passed, |
Typedefs | |
typedef int | agent_pk |
Enumerations | |
enum | agent_status { AGENT_STATUS_TYPES =(SELECT_ENUM) } |
Functions | |
meta_agent_t * | meta_agent_init (char *name, char *cmd, int max, int spc) |
Creates a new meta agent. More... | |
void | meta_agent_destroy (meta_agent_t *meta_agent) |
agent_t * | agent_init (scheduler_t *scheduler, host_t *host, job_t *owner) |
Allocate and spawn a new agent. More... | |
void | agent_destroy (agent_t *agent) |
Frees the memory associated with an agent. More... | |
void | agent_death_event (scheduler_t *scheduler, pid_t *pids) |
void | agent_create_event (scheduler_t *scheduler, agent_t *agent) |
Event created when a new agent has been created. More... | |
void | agent_ready_event (scheduler_t *scheduler, agent_t *agent) |
Event created when an agent is ready for more data. More... | |
void | agent_update_event (scheduler_t *scheduler, void *unused) |
void | agent_fail_event (scheduler_t *scheduler, agent_t *agent) |
Fails an agent. More... | |
void | list_agents_event (scheduler_t *scheduler, GOutputStream *ostr) |
Receive agent on interface. More... | |
void | agent_transition (agent_t *agent, agent_status new_status) |
void | agent_pause (agent_t *agent) |
void | agent_unpause (agent_t *agent) |
void | agent_print_status (agent_t *agent, GOutputStream *ostr) |
Prints the status of the agent to the output stream provided. More... | |
void | agent_kill (agent_t *agent) |
Unclean kill of an agent. More... | |
int | aprintf (agent_t *agent, const char *fmt,...) |
ssize_t | agent_write (agent_t *agent, const void *buf, int count) |
void | test_agents (scheduler_t *scheduler) |
Calls the agent test function for every type of agent. More... | |
int | add_meta_agent (GTree *meta_agents, char *name, char *cmd, int max, int spc) |
void | kill_agents (scheduler_t *scheduler) |
Call the agent_kill function for every agent within the system. More... | |
int | is_meta_special (meta_agent_t *ma, int special_type) |
tests if a particular meta agent has a specific special flag set More... | |
int | is_agent_special (agent_t *agent, int special_type) |
tests if a particular agent has a specific special flag set More... | |
void | meta_agent_increase_count (meta_agent_t *) |
void | meta_agent_decrease_count (meta_agent_t *) |
Variables | |
const char * | agent_status_strings [] |
Header file with agent related operations.
Definition in file agent.h.
#define AGENT_STATUS_TYPES | ( | apply | ) |
Implementation of x macros used for the creation of the agent status enum. This is used so that if a new agent status is needed, it can be added here and all relevant declarations can be changed.
If you are unfamiliar with X macros, this is a very simply implementation of them and I suggest you look them up online.
#define SELECT_ENUM | ( | passed | ) | AG_##passed, |
int add_meta_agent | ( | GTree * | meta_agents, |
char * | name, | ||
char * | cmd, | ||
int | max, | ||
int | spc | ||
) |
Creates a new meta agent and adds it to the list of meta agents. This will parse the shell command that will start the agent process.
meta_agents | GTree of meta agents available for the scheduler |
name | the name of the meta agent (e.g. "nomos", "copyright", etc...) |
cmd | the shell command used to the run the agent |
max | the max number of this type of agent that can run concurrently |
spc | anything special about the agent type |
void agent_create_event | ( | scheduler_t * | scheduler, |
agent_t * | agent | ||
) |
Event created when a new agent has been created.
This means that the agent has been allocated internally and the fork() call has successfully executed. The agent has not yet communicated with the scheduler when this event is created.
scheduler | the scheduler reference to which agent has to attach |
agent | the agent that has been created. |
void agent_death_event | ( | scheduler_t * | scheduler, |
pid_t * | pid | ||
) |
Event created when a SIGCHLD is received for an agent. If one SIGCHILD is received for several process deaths, there will be seperate events for each pid.
scheduler | the scheduler reference to which process was attached to |
pid | the pid of the process that died |
void agent_destroy | ( | agent_t * | agent | ) |
Frees the memory associated with an agent.
This include:
agent | the agent to destroy |
void agent_fail_event | ( | scheduler_t * | scheduler, |
agent_t * | agent | ||
) |
Fails an agent.
This will move the agent status to AG_FAILED and send a SIGKILL to the relevant agent. It will also update the agents status within the job that owns it and close the associated communication thread.
scheduler | the scheduler to which agent is attached |
agent | the agent that is failing. |
agent_t* agent_init | ( | scheduler_t * | scheduler, |
host_t * | host, | ||
job_t * | job | ||
) |
Allocate and spawn a new agent.
The agent that is spawned will be of the same type as the meta_agent that is passed to this function and the agent will run on the host that is passed.
scheduler | the scheduler this agent is being created under |
host | the machine to start the agent on |
job | the job that this agent belongs to |
void agent_kill | ( | agent_t * | agent | ) |
void agent_pause | ( | agent_t * | agent | ) |
void agent_print_status | ( | agent_t * | agent, |
GOutputStream * | ostr | ||
) |
void agent_ready_event | ( | scheduler_t * | scheduler, |
agent_t * | agent | ||
) |
Event created when an agent is ready for more data.
This will event will be created when an agent first communicates with the scheduler, so this will handle changing its status to AG_RUNNING. This will also be created every time an agent finishes a block of data.
scheduler | the scheduler reference to which agent is attached |
agent | the agent that is ready |
void agent_transition | ( | agent_t * | agent, |
agent_status | new_status | ||
) |
Changes the status of the agent internal to the scheduler. This function is used to transition between agent states instead of a raw set of the status so that correct printing of the verbose message is guaranteed
agent | the agent to change the status for |
new_status | the new status of the agentchar* sysconfdir = NULL; // system configuration directory (SYSCONFDIR) |
void agent_unpause | ( | agent_t * | agent | ) |
void agent_update_event | ( | scheduler_t * | scheduler, |
void * | unused | ||
) |
Event created when the scheduler receives a SIGALRM. This will loop over every agent and call the update function on it. This will kill any agents that are hung without heart beat or any agents that have stopped updating the number of item processed.
scheduler | the scheduler reference to inform |
unused | needed since this an event, but should be NULL |
ssize_t agent_write | ( | agent_t * | agent, |
const void * | buf, | ||
int | count | ||
) |
Write information to the communication thread for the agent. This is used when the scheduler needs to wake up or kill the thread used to talk to the agent. When using this function, one should always print "@@@..." where ... is the message that is actually getting sent.
agent | the agent to send the information to |
buf | the actual data |
count | the number of bytes to write to the agent |
int aprintf | ( | agent_t * | agent, |
const char * | fmt, | ||
... | |||
) |
Acts as a standard printf, but prints the agents instead of stdout. This is the main function used by the scheduler when communicating with the agents.
agent | the agent to send the formated data to |
fmt | the formating string for the data |
int is_agent_special | ( | agent_t * | agent, |
int | special_type | ||
) |
int is_meta_special | ( | meta_agent_t * | ma, |
int | special_type | ||
) |
void kill_agents | ( | scheduler_t * | scheduler | ) |
void list_agents_event | ( | scheduler_t * | scheduler, |
GOutputStream * | ostr | ||
) |
Receive agent on interface.
Calls agent_list() and print evert agent attached to the scheduler.
scheduler | the scheduler to which agent is attached |
ostr | Stream to write info to |
void meta_agent_decrease_count | ( | meta_agent_t * | ma | ) |
void meta_agent_destroy | ( | meta_agent_t * | ma | ) |
void meta_agent_increase_count | ( | meta_agent_t * | ma | ) |
meta_agent_t* meta_agent_init | ( | char * | name, |
char * | cmd, | ||
int | max, | ||
int | spc | ||
) |
Creates a new meta agent.
This will take and parse the information necessary for the creation of a new agent instance. The name of the agent, the cmd for starting the agent, the number of these agents that can run simutaniously, and any special conditions for this agent. This function is where the cmd will get parsed to be passed as command line args to the new agent.
name | the name of the agent (i.e. nomos, buckets, etc...) |
cmd | the command for starting the agent in a shell |
max | the number of these that can concurrently, -1 for no limit |
spc | any special conditions associated with the agent |
void test_agents | ( | scheduler_t * | scheduler | ) |