ZOO-Project
Data Structures | Functions | Variables
service_callback.c File Reference
#include <pthread.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include <libxslt/xslt.h>
#include <libxslt/xsltInternals.h>
#include <libxslt/transform.h>
#include <libxslt/xsltutils.h>
#include "service_callback.h"
#include "service_json.h"
#include "sqlapi.h"
#include <ulinet.h>
#include "json_object_iterator.h"

Data Structures

struct  local_params
 Parameter definition to be used for sending parameters to a thread. More...
 
struct  job_handlers_params
 Parameter definition to be used for sending parameters to a thread. More...
 

Functions

bool isProhibited (maps *conf, const char *serviceName)
 Check if a service name is prohibited, meaning that the Kernel doesn't have to invoke the callback for this specific service. More...
 
void * _handleJobStatus (void *args)
 Practically handle the job status, meaning polling for status until the end of process execution. More...
 
bool handleJobStatus (maps *pmsConf, maps *pmsInputs, int iCnt)
 Invoke the handleJobStatus for a given input. More...
 
void cleanupJobStatusThreads (maps **pmsInputs)
 Wait for the threads to end then, clean used memory. More...
 
void * _invokeBasicCallback (void *args)
 Practically invoke the callback, meaning sending the HTTP POST request. More...
 
bool invokeBasicCallback (maps *conf, int state)
 Invoke the callback in case there is a [subscriber] section containing one or more url parameter. More...
 
void cleanupCallbackThreads ()
 Wait for the threads to end then, clean used memory. More...
 

Variables

int iNbJobsHandlers =0
 Number of threads associated with a job handler. More...
 
int iNbJobsHandled =0
 Number of job handled. More...
 
pthread_t * ppJobsHandlers =NULL
 Thread array associated with a job handler. More...
 
int nbThreads =0
 Number of threads. More...
 
int cStep =0
 Current step. More...
 
int maxProgress =0
 Maximum value of PercentCompleted. More...
 
int isOngoing =0
 Is there any ongoing HTTP request. More...
 
pthread_t * myThreads =NULL
 Threads array. More...
 
bool steps [7][2]
 Steps array. More...
 
local_params ** local_arguments
 Arguments array to give to the _invokeCallback thread's function. More...
 
job_handlers_params ** job_handler_arguments
 Arguments array to give to the _handleJobStatus thread's function. More...
 

Data Structure Documentation

◆ local_params

struct local_params

Parameter definition to be used for sending parameters to a thread.

Data Fields
maps * conf the main configuration file
char * local_file
json_object * res the JSON object to post
int state the current state [0,1]
int step the current step [0,6]
char * target_file
map * url the callback url maps

◆ job_handlers_params

struct job_handlers_params

Parameter definition to be used for sending parameters to a thread.

Data Fields
maps * conf the main configuration file
int id the job handler identifier
map * input the input maps

Function Documentation

◆ _handleJobStatus()

void* _handleJobStatus ( void *  args)

Practically handle the job status, meaning polling for status until the end of process execution.

Once status is suceeded, the result is fetched. Depending on the transmission mode, the result is either downloaded or the value si stored in the input map.

Parameters
argsjob_handlers_params containing the variables required

◆ _invokeBasicCallback()

void* _invokeBasicCallback ( void *  args)

Practically invoke the callback, meaning sending the HTTP POST request.

Parameters
argslocal_params containing all the variables required

◆ cleanupCallbackThreads()

void cleanupCallbackThreads ( )

Wait for the threads to end then, clean used memory.

◆ cleanupJobStatusThreads()

void cleanupJobStatusThreads ( maps **  pmsInputs)

Wait for the threads to end then, clean used memory.

◆ handleJobStatus()

bool handleJobStatus ( maps pmsConf,
maps pmsInputs,
int  iCnt 
)

Invoke the handleJobStatus for a given input.

Parameters
pmsConfthe maps containing the main configuration file definitions
pmsInputsthe inputs defined in the request
Returns
bool true in case of success, false in other cases

◆ invokeBasicCallback()

bool invokeBasicCallback ( maps conf,
int  state 
)

Invoke the callback in case there is a [subscriber] section containing one or more url parameter.

Parameters
confthe maps containing the main configuration file definitions
statethe service state SERVICE_SUCCEEDED / STARTED / FAILED
Returns
bool true in case of success, false in other cases

◆ isProhibited()

bool isProhibited ( maps conf,
const char *  serviceName 
)

Check if a service name is prohibited, meaning that the Kernel doesn't have to invoke the callback for this specific service.

Parameters
confthe main configuration file maps
serviceNamethe serviceName
Returns
a bool true if the service is prohibited, false in other case

Variable Documentation

◆ cStep

int cStep =0

Current step.

◆ iNbJobsHandled

int iNbJobsHandled =0

Number of job handled.

◆ iNbJobsHandlers

int iNbJobsHandlers =0

Number of threads associated with a job handler.

◆ isOngoing

int isOngoing =0

Is there any ongoing HTTP request.

◆ job_handler_arguments

job_handlers_params** job_handler_arguments

Arguments array to give to the _handleJobStatus thread's function.

◆ local_arguments

local_params** local_arguments

Arguments array to give to the _invokeCallback thread's function.

◆ maxProgress

int maxProgress =0

Maximum value of PercentCompleted.

◆ myThreads

pthread_t* myThreads =NULL

Threads array.

◆ nbThreads

int nbThreads =0

Number of threads.

◆ ppJobsHandlers

pthread_t* ppJobsHandlers =NULL

Thread array associated with a job handler.

◆ steps

bool steps[7][2]
Initial value:
={
{false,false},
{false,false},
{false,false},
{false,false},
{false,false},
{false,false},
{false,false}
}

Steps array.