Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
Server Library

Shared code specific for Servers. More...

Data Structures

struct  JobsManager
 A datatype for monitoring ServiceJobs. More...
 
struct  ExternalServer
 A datatype to allow access to an external Grassroots Server. More...
 
struct  ExternalServerNode
 A datatype for storing ExternalServers in a LinkedList. More...
 
struct  ServersManager
 A datatype for monitoring ExternalServers. More...
 

Typedefs

typedef unsigned char *(* ServiceJobSerialiser) (ServiceJob *job_p, uint32 *length_p)
 A typedef'd function for serialising a ServiceJob into an array of raw bytes. More...
 
typedef ServiceJob *(* ServiceJobDeserialiser) (unsigned char *input_data_p, void *config_p)
 A typedef'd function for deserialising a ServiceJob from an array of raw bytes. More...
 
typedef ExternalServer *(* ExternalServerDeserialiser) (const unsigned char *data_p)
 A function to take a raw binary data representation of a previously stored ExternalServer and recreate it. More...
 
typedef unsigned char *(* ExternalServerSerialiser) (ExternalServer *server_p, uint32 *length_p)
 A function to generate a raw binary data representation of a ExternalServer allowing it to be recreated at a later time. More...
 

Functions

bool InitMongoDB (void)
 When the Grassroots system starts up, iniitialise and global MongoDB resources that it needs. More...
 
void ExitMongoDB (void)
 Free any MongoDB resources that the Grassroots system obtained when it was started. More...
 
bool InitDrmaaEnvironment (void)
 Get any DRMAA environment resources, if required, when starting the Grassroots Server. More...
 
bool ExitDrmaaEnvironment (void)
 Release any DRMAA environment resources, if required, when shutting down the Grassroots Server. More...
 
void ConnectToExternalServers (GrassrootsServer *server_p)
 Connect to any defined separate Grassroots servers. More...
 
GRASSROOTS_SERVICE_MANAGER_LOCAL void DisconnectFromExternalServers (GrassrootsServer *server_p)
 Disconnect to any defined separate Grassroots servers. More...
 
const char * GetServerProviderName (const GrassrootsServer *grassroots_p)
 Get the Provider name for this Grassroots Server. More...
 
const char * GetServerProviderDescription (const GrassrootsServer *grassroots_p)
 Get the Provider description for this Grassroots Server. More...
 
const char * GetServerProviderURI (const GrassrootsServer *grassroots_p)
 Get the Provider URI for this Grassroots Server. More...
 
const json_t * GetProviderAsJSON (const GrassrootsServer *grassroots_p)
 Get the JSON fragment with all of the details of the Provider for this Grassroots Server. More...
 
bool IsServiceEnabled (const GrassrootsServer *grassroots_p, const char *service_name_s)
 Check if a named Service is enabled upon this Grassroots server. More...
 
const char * GetJobLoggingURI (const GrassrootsServer *grassroots_p)
 Get the job logging URI for this Grassroots Server. More...
 
uuid_tGetLocalServerId (struct GrassrootsServer *grassroots_p)
 Get the current Server uuid. More...
 
const char * GetLocalServerIdAsString (struct GrassrootsServer *grassroots_p)
 Get the current Server uuid as a c-style string. More...
 
bool InitInformationSystem (void)
 Initialise the various base components of the Grassroots system. More...
 
bool DestroyInformationSystem (void)
 Perform any pre-termination tasks of the Grassroots system prior to it exiting. More...
 
GrassrootsServerAllocateGrassrootsServer (const char *grassroots_path_s, const char *config_filename_s, const char *service_config_path_s, const char *services_path_s, const char *references_path_s, const char *jobs_managers_path_s, const char *servers_managers_path_s, struct JobsManager *external_jobs_manager_p, MEM_FLAG jobs_manager_flag, struct ServersManager *external_servers_manager_p, MEM_FLAG servers_manager_flag)
 Allocate a GrassrootsServer. More...
 
void FreeGrassrootsServer (GrassrootsServer *server_p)
 Free a GrassrootsServer. More...
 
json_t * ProcessServerJSONMessage (GrassrootsServer *grassroots_p, json_t *json_req_p, User *user_p, const char **error_ss)
 Process a given JSON request and produce the server response. More...
 
json_t * GetInitialisedResponseOnServer (GrassrootsServer *server_p, User *user_p, const json_t *req_p, const char *key_s, json_t *value_p)
 Create a response object with a valid header and a given key and value. More...
 
json_t * GetGlobalConfigValue (const GrassrootsServer *grassroots_p, const char *key_s)
 Get a configuration value from the global Grassroots configuration file. More...
 
struct ServersManagerGetServersManager (GrassrootsServer *server_p)
 Get the ServersManager for a given GrassrootsServer. More...
 
json_t * GetGlobalServiceConfig (GrassrootsServer *grassroots_p, const char *const service_name_s, bool *alloc_flag_p)
 Get a configuration value for a named Service. More...
 

Detailed Description

Shared code specific for Servers.

Typedef Documentation

◆ ServiceJobSerialiser

typedef unsigned char*(* ServiceJobSerialiser) (ServiceJob *job_p, uint32 *length_p)

A typedef'd function for serialising a ServiceJob into an array of raw bytes.

Parameters
job_pThe ServiceJob to serialise.
length_pIf the serialisation is successful, the length of the resultant array will be stored here.
Returns
The raw array or NULL upon error.

◆ ServiceJobDeserialiser

typedef ServiceJob*(* ServiceJobDeserialiser) (unsigned char *input_data_p, void *config_p)

A typedef'd function for deserialising a ServiceJob from an array of raw bytes.

Parameters
input_data_pThe array of raw bytes from a previously serialised ServiceJob.
config_pIf the ServiceJobDeserialiser requires some configuration data, it can be passed in here. This can be NULL.
Returns
The ServiceJob or NULL upon error.

◆ ExternalServerDeserialiser

typedef ExternalServer*(* ExternalServerDeserialiser) (const unsigned char *data_p)

A function to take a raw binary data representation of a previously stored ExternalServer and recreate it.

Parameters
data_pThe raw binary data representation of the ExternalServer.
Returns
The newly created ExternalServer or NULL upon error.

◆ ExternalServerSerialiser

typedef unsigned char*(* ExternalServerSerialiser) (ExternalServer *server_p, uint32 *length_p)

A function to generate a raw binary data representation of a ExternalServer allowing it to be recreated at a later time.

Parameters
server_pThe ExternalServer to generate the representation for.
length_pUpon success, the length of the generated binary data stream will be stored here.
Returns
The raw binary data or NULL upon error.

Function Documentation

◆ InitMongoDB()

bool InitMongoDB ( void  )

When the Grassroots system starts up, iniitialise and global MongoDB resources that it needs.

Returns
true if the global MongoDB resources were acquired successfully, false otherwise.

◆ ExitMongoDB()

void ExitMongoDB ( void  )

Free any MongoDB resources that the Grassroots system obtained when it was started.

◆ InitDrmaaEnvironment()

bool InitDrmaaEnvironment ( void  )

Get any DRMAA environment resources, if required, when starting the Grassroots Server.

Returns
true if the DRMAA environment was started up successfully, false otherwise.

◆ ExitDrmaaEnvironment()

bool ExitDrmaaEnvironment ( void  )

Release any DRMAA environment resources, if required, when shutting down the Grassroots Server.

Returns
true if the DRMAA environment was started up successfully, false otherwise.

◆ ConnectToExternalServers()

void ConnectToExternalServers ( GrassrootsServer server_p)

Connect to any defined separate Grassroots servers.

◆ DisconnectFromExternalServers()

GRASSROOTS_SERVICE_MANAGER_LOCAL void DisconnectFromExternalServers ( GrassrootsServer server_p)

Disconnect to any defined separate Grassroots servers.

◆ GetServerProviderName()

const char* GetServerProviderName ( const GrassrootsServer grassroots_p)

Get the Provider name for this Grassroots Server.

Returns
The Provider name.

◆ GetServerProviderDescription()

const char* GetServerProviderDescription ( const GrassrootsServer grassroots_p)

Get the Provider description for this Grassroots Server.

Returns
The Provider description.

◆ GetServerProviderURI()

const char* GetServerProviderURI ( const GrassrootsServer grassroots_p)

Get the Provider URI for this Grassroots Server.

Returns
The Provider URI.

◆ GetProviderAsJSON()

const json_t* GetProviderAsJSON ( const GrassrootsServer grassroots_p)

Get the JSON fragment with all of the details of the Provider for this Grassroots Server.

Returns
A read-only JSON representation of the Provider or NULL upon error.

◆ IsServiceEnabled()

bool IsServiceEnabled ( const GrassrootsServer grassroots_p,
const char *  service_name_s 
)

Check if a named Service is enabled upon this Grassroots server.

Parameters
service_name_sThe name of the Service to check.
Returns
true if the named Service is enabled, false otherwise.

◆ GetJobLoggingURI()

const char* GetJobLoggingURI ( const GrassrootsServer grassroots_p)

Get the job logging URI for this Grassroots Server.

Returns
The job logging URI.

◆ GetLocalServerId()

uuid_t* GetLocalServerId ( struct GrassrootsServer grassroots_p)

Get the current Server uuid.

Returns
The pointer to the uuid.

◆ GetLocalServerIdAsString()

const char* GetLocalServerIdAsString ( struct GrassrootsServer grassroots_p)

Get the current Server uuid as a c-style string.

Returns
The c-style string of the uuid.

◆ InitInformationSystem()

bool InitInformationSystem ( void  )

Initialise the various base components of the Grassroots system.

Returns
true if the system was successfully initialised, false otherwise.

◆ DestroyInformationSystem()

bool DestroyInformationSystem ( void  )

Perform any pre-termination tasks of the Grassroots system prior to it exiting.

Returns
true if the tasks were successfully completed, false otherwise.

◆ AllocateGrassrootsServer()

GrassrootsServer * AllocateGrassrootsServer ( const char *  grassroots_path_s,
const char *  config_filename_s,
const char *  service_config_path_s,
const char *  services_path_s,
const char *  references_path_s,
const char *  jobs_managers_path_s,
const char *  servers_managers_path_s,
struct JobsManager external_jobs_manager_p,
MEM_FLAG  jobs_manager_flag,
struct ServersManager external_servers_manager_p,
MEM_FLAG  servers_manager_flag 
)

Allocate a GrassrootsServer.

Returns
The newly-created GrassrootsServer or NULL upon error.

◆ FreeGrassrootsServer()

void FreeGrassrootsServer ( GrassrootsServer server_p)

Free a GrassrootsServer.

Parameters
server_pThe GrassrootsServer to free.

◆ ProcessServerJSONMessage()

json_t * ProcessServerJSONMessage ( GrassrootsServer grassroots_p,
json_t *  json_req_p,
User user_p,
const char **  error_ss 
)

Process a given JSON request and produce the server response.

Parameters
server_pThe GrassrootsServer that will process the request.
req_pThe incoming JSON request.
user_pThe user accessing Grassroots. This can be NULL for a public or non-logged in user.
error_ssA pointer to a variable where any error messages can be stored.
Returns
The response from the server or NULL upon error.

◆ GetInitialisedResponseOnServer()

json_t * GetInitialisedResponseOnServer ( GrassrootsServer server_p,
User user_p,
const json_t *  req_p,
const char *  key_s,
json_t *  value_p 
)

Create a response object with a valid header and a given key and value.

Parameters
server_pThe GrassrootsServer that will process the request.
req_pIf this object is not NULL and contains a "verbose" key set to true, then the request will be added to a "request" key within the "header" section of this response. This is to allow the tracking of requests to responses if needed.
key_sThe key to use to add the associated value to the generated response.
value_pThe value to add to the generated response.
Returns
The response or NULL upon error.
See also
GetInitialisedMessage

◆ GetGlobalConfigValue()

json_t * GetGlobalConfigValue ( const GrassrootsServer grassroots_p,
const char *  key_s 
)

Get a configuration value from the global Grassroots configuration file.

Parameters
key_sThe key to get the associated value for.
Returns
The JSON fragment containing the configuration data or NULL if it could not be found.

◆ GetServersManager()

struct ServersManager * GetServersManager ( GrassrootsServer server_p)

Get the ServersManager for a given GrassrootsServer.

Parameters
server_pThe GrassrootsServer to get the ServersManager from.
Returns
The ServersManager.

◆ GetGlobalServiceConfig()

json_t * GetGlobalServiceConfig ( GrassrootsServer grassroots_p,
const char *const  service_name_s,
bool *  alloc_flag_p 
)

Get a configuration value for a named Service.

The system will initially check the "config/<service_name>" folder within the Grassroots directory e.g. "config/BlastN Service" for the Service called "BlastN Service". If this file exists it will be loaded and produce the configuration value. If it does not exist or cannot be loaded then, the system will attempt to use an object specified at "services.<service_name>" in the global configuration file instead.

Parameters
service_name_sThe name of the Service to get the configuration data for.
alloc_flag_pIf the returned JSON fragment has been newly-allocated then the value that this points to will be set to true to indicate that the returned value will need to have json_decref called upon it to avoid a memory leak.
Returns
The JSON fragment containing the configuration data or NULL if it could not be loaded.