Main Page Alphabetical List Compound List File List Compound Members File Members
GATSelf.c File ReferenceMain File for the GATSelf class.
More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include "uuid.h"
#include "sqlite.h"
#include "regex.h"
#include "GATInternal.h"
#include "GATErrors.h"
#include "GATSelf.h"
#include "GATJob.h"
#include "GATRequest.h"
#include "GATContext.h"
#include "GATTable.h"
#include "GATRegistry.h"
#include "GATLoader.h"
#include "GATConfig.h"
#include "GATInterfaceMap.h"
Include dependency graph for GATSelf.c:
Go to the source code of this file.
|
Compounds |
| struct | GATErrorMessageHandlerData |
| struct | GATRequestListenerData |
| struct | contextlist |
| struct | GATSelf_S |
| struct | load_data |
Defines |
| #define | MAX_PATH _POSIX_PATH_MAX |
| #define | PATH_MAX 4096 |
Typedefs |
| typedef GATErrorMessageHandlerData | GATErrorMessageHandlerData |
| typedef GATRequestListenerData | GATRequestListenerData |
Functions |
| | GATOBJECT_DEFINE_VTABLE (GATSelf) |
| | GATLIST_DEFINE_QUALIFIED (static, GATErrorMessageHandlerData, GATList_GATErrorMessageHandlerData, GATType_PlainOldData) GATOBJECT_DEFINE_CONVERTERS(GATSelf) |
| | GATOBJECT_DEFINE_CONVERTERS_QUALIFIED (static, GATList_GATErrorMessageHandlerData, GATType_GATList) |
| GATSelf | GATSelf_Create (GATContext error_context) |
| | GATSelf_Create The GATSelf constructor.
|
| void | GATSelf_Destroy (GATSelf *this) |
| | GATSelf_Destroy The GATSelf destructor.
|
| GATResult | LoadAdaptors (GATContext error_context, GATLoader loader, GATRegistry registry, GATConfig config) |
| | LoadAdaptors Load all adaptors on adaptor path.
|
| GATResult | Load (GATContext error_context, const char *filename, void *data) |
| | Load Loads an single adaptor, as many times as configured.
|
| GATResult | ProcessDir (GATContext error_context, const char *dirname, int(*action)(GATContext, const char *, void *), void *data) |
| | ProcessDir Search a directory for files and invoke an action on each one.
|
| GATResult | ProcessFile (GATContext error_context, const char *filename, int(*action)(GATContext, const char *, void *), void *data) |
| | ProcessFile Search a file for valid filenames and invoke an action on each one.
|
| const char * | MakePath (const char *base, const char *original, char sep, char *pathentry, int pathentry_length) |
| | MakePath Search a delimited string and return full paths.
|
| char * | CanonicaliseName (const char *original) |
| | CanonicaliseName Extract the canonical name of an adaptor from its full path name.
|
| GATResult | GATSelf_GetCPIInstanceData (GATSelf object, void **data) |
| GATResult | GATSelf_Equals (GATSelf_const lhs, GATSelf_const rhs, GATBool *isequal) |
| | GATSelf_Equals Compare two GATSelf objects.
|
| GATResult | GATSelf_Clone (GATSelf_const object, GATSelf *new_object) |
| | GATSelf_Clone Clone the given GATSelf.
|
| GATType | GATSelf_GetType (GATSelf_const object) |
| | GATType GATSelf_GetType(GATSelf_const resource) Return the type of the GATSelf.
|
| GATResult | GATSelf_GetInterface (GATSelf_const object, GATInterface iftype, void const **ifp) |
| | GATResult GATSelf_GetInterface(GATSelf_const file, GATInterface iftype, void const **ifp) Get an interface supported by a GATObject.
|
| GATResult | GATStatus_ErrorMessagesEngine (GATResult err_code, char *buffer, GATuint32 length, GATuint32 *written) |
| GATResult | GATStatus_ErrorMessagesXds (GATResult err_code, char *buffer, GATuint32 length, GATuint32 *written) |
| GATResult | GATStatus_ErrorMessagesUuid (GATResult err_code, char *buffer, GATuint32 length, GATuint32 *written) |
| GATResult | GATStatus_ErrorMessagesRegex (GATResult err_code, char *buffer, GATuint32 length, GATuint32 *written) |
| GATResult | GATStatus_ErrorMessagesSQLite (GATResult err_code, char *buffer, GATuint32 length, GATuint32 *written) |
| GATResult | GATStatus_ErrorMessagesPosix (GATResult err_code, char *buffer, GATuint32 length, GATuint32 *written) |
| GATSelf_const | GATSelf_GetInstance (GATContext context) |
| | GATSelf_GetInstance.
|
| GATResult | GATSelf_AddRequestListener (GATContext context, GATRequestListener listener, void *data, GATRequestType type, GATTable_const parameters, const char *name, GATuint32 *cookie) |
| | GATSelf_AddRequestListener.
|
| GATResult | GATSelf_RemoveRequestListener (GATContext context, GATuint32 cookie) |
| | GATSelf_RemoveRequestListener.
|
| GATResult | GATSelf_GetJob (GATContext context, GATJob *job) |
| | GATSelf_GetJob.
|
| GATSelf | GATSelf_internal_GetInstance (GATContext error_context) |
| | GATSelf_internal_GetInstance Private GATEngine method to get the GATSelf object.
|
| GATRegistry | GATSelf_internal_GetRegistry (GATSelf self) |
| | GATSelf_internal_GetRegistry Gets the GATRegsitry object.
|
| GATResult | GATSelf_internal_AddContext (GATSelf self, GATContext context) |
| | GATSelf_internal_AddContext Private method to add a new GATContext to the GATSelf object.
|
| void | GATSelf_internal_RemoveContext (GATSelf self, GATContext context) |
| | GATSelf_internal_RemoveContext Private method to remove a GATContext from the GATSelf object.
|
| GATResult | GATSelf_internal_GetGATJobId (GATSelf_const self, GATContext context, GATString_const *gatjobid) |
| GATResult | GATSelf_internal_CreateGATJobId (GATSelf_const self, GATContext context, GATString *gatjobid) |
| GATResult | GATSelf_AddErrorMessageHandler (GATuint32 facility, GATErrorMessageHandler handler, GATuint32 *cookie) |
| | GATSelf_AddErrorMessageHandler.
|
| GATResult | GATSelf_RemoveErrorMessageHandler (GATuint32 *cookie) |
| | GATSelf_RemoveErrorMessageHandler.
|
| GATResult | GATSelf_ResolveErrorMessage (GATResult err_code, char *buffer, GATuint32 length, GATuint32 *written) |
| | GATSelf_ResolveErrorMessage.
|
Variables |
| const char * | rcsid = "$Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATSelf.c,v 1.56 2004/05/12 18:56:01 hartmutkaiser Exp $" |
| GATSelf_vtable | GATSelf__vtable |
| GATSelf | thegatself = NULL |
| GATuint32 | cookie_engine = 0 |
| GATuint32 | cookie_xds = 0 |
| GATuint32 | cookie_uuid = 0 |
| GATuint32 | cookie_regex = 0 |
| GATuint32 | cookie_sqlite = 0 |
| GATuint32 | cookie_posix = 0 |
| GATuint32 | request_cookie_jar = 0 |
| GATList_GATErrorMessageHandlerData | error_message_handlers = NULL |
| GATuint32 | error_cookie_jar = 0 |
Detailed Description
Main File for the GATSelf class.
The GATSelf class corresponds to the current GAT job. There is only ever one instance of this class, which is obtained by the GetInstance method. This object can be used to change various properties of this job, such as whether it is checkpointable or not, and what metrics or events it can report. It can also provide the GATJob instance associated with this job, which may then be advertised.
- Date:
-
Tue Sep 2 2003
- Version:
-
- Header:
-
/export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATSelf.c,v 1.56 2004/05/12 18:56:01 hartmutkaiser Exp
Copyright (C) Tom Goodale This file is part of the GAT Engine. Contributed by Tom Goodale <goodale@aei.mpg.de>.
Use, modification and distribution is subject to the Gridlab Software License. (See accompanying file GLlicense.txt or copy at http://www.gridlab.org/GLlicense.txt)
Definition in file GATSelf.c.
Define Documentation
| #define MAX_PATH _POSIX_PATH_MAX
|
|
Typedef Documentation
| typedef struct GATErrorMessageHandlerData GATErrorMessageHandlerData
|
|
| typedef struct GATRequestListenerData GATRequestListenerData
|
|
Function Documentation
| GATOBJECT_DEFINE_VTABLE |
( |
GATSelf |
|
) |
|
|
| GATOBJECT_DEFINE_CONVERTERS_QUALIFIED |
( |
static |
, |
|
|
GATList_GATErrorMessageHandlerData |
, |
|
|
GATType_GATList |
|
|
) |
|
|
|
|
GATSelf_Create The GATSelf constructor.
This is the constuctor for the GATSelf. It should initialise the GATEngine, e.g. load adaptors or at least find them, load configuration files, etc. - Parameters:
-
| error_context |
This is the created context, which potentially triggers the creation of the GATSelf. This context may be used for storing/retrieving the current status only. |
- Returns:
-
A new GATSelf
Definition at line 721 of file GATSelf.c.
References GATSelf_S::config, GATSelf_S::contexts, cookie_engine, cookie_posix, cookie_regex, cookie_sqlite, cookie_uuid, cookie_xds, GATSelf_S::cpi, GATSelf_S::cpilist, GATSelf_S::data, GAT_CREATE_STATUS, GAT_CREATE_STATUS_IF, GAT_CREATE_STATUS_UNCOND, GAT_CURRENT_STATUS, GAT_FACILITY_ENGINE, GAT_FACILITY_ENGINE_REGEX, GAT_FACILITY_ENGINE_UUID, GAT_FACILITY_ENGINE_XDS, GAT_FACILITY_POSIX, GAT_FACILITY_SQLITE, GAT_FAILED, GAT_MEMORYFAILURE, GAT_STORE_STATUS, GAT_SUCCEEDED, GAT_USES_STATUS, GATBool, GATConfig_Create(), GATFalse, GATSelf_S::gatjobid, GATLoader_Create(), GATSelf_S::GATObject__vtable, GATObject_Register_GATSerialisables(), GATRegistry_Create(), GATRegistry_internal_AddGATSelfToCPIList(), GATSelf__vtable, GATSelf_AddErrorMessageHandler(), GATSelf_Destroy(), GATSelf_internal_CreateGATJobId(), GATSelf_internal_GetRegistry(), GATSelfCPI_CreateInstance(), GATStatus_ErrorMessagesEngine(), GATStatus_ErrorMessagesPosix(), GATStatus_ErrorMessagesRegex(), GATStatus_ErrorMessagesSQLite(), GATStatus_ErrorMessagesUuid(), GATStatus_ErrorMessagesXds(), GATString_Create(), GATString_GetBuffer(), GATTrue, GATSelf_S::listeners, LoadAdaptors(), GATSelf_S::loader, and GATSelf_S::registry.
Referenced by GATSelf_internal_GetInstance(). |
| void GATSelf_Destroy |
( |
GATSelf * |
object |
) |
[static] |
|
|
|
GATSelf_Destroy The GATSelf destructor.
This is the destructor for the GATSelf. It should shut-down the GATEngine, e.g. unload adaptors, etc. - Parameters:
-
Definition at line 857 of file GATSelf.c.
References cookie_engine, cookie_posix, cookie_regex, cookie_sqlite, cookie_uuid, cookie_xds, GATSelf_S::cpi, GATConfig_Destroy(), GATLoader_Destroy(), GATObject_Unregister_GATSerialisables(), GATRegistry_Destroy(), GATRegistry_internal_RemoveGATSelfFromCPIList(), GATSelf_internal_GetRegistry(), GATSelf_RemoveErrorMessageHandler(), and GATString_Destroy().
Referenced by GATSelf_Create(), and GATSelf_internal_RemoveContext(). |
|
|
LoadAdaptors Load all adaptors on adaptor path.
This function examines the GAT_ADAPTOR_PATH environment variable and loads all the adaptors it finds. The environment variable is a colon seperated list of files or directories. - Parameters:
-
| loader |
The GATLoader object which loads and track individual adaptors. |
| registry |
The CPI registry |
| config |
The GAT configuration database. |
- Returns:
-
An error code - 0 for success, -1 for failure.
Definition at line 904 of file GATSelf.c.
References buf, load_data::config, GAT_CREATE_STATUS, GAT_CREATE_STATUS_MSG, GAT_FAIL, GAT_FALSE, GAT_MEMORYFAILURE, GAT_RETURN_STATUS, GAT_USES_STATUS, Load(), load_data::loader, MakePath(), PATH_MAX, POSIX_TO_GAT, ProcessDir(), ProcessFile(), and load_data::registry.
Referenced by GATSelf_Create(). |
|
|
Load Loads an single adaptor, as many times as configured.
A callback function invoked by the functions which scan directories or files for adaptors. It takes a full path to an adaptor and then invokes the GATLoader with this adaptor and any associated config database tables. - Parameters:
-
| filename |
The full path to the adaptor. |
| registry |
The CPI registry |
| config |
The GAT configuration database. |
- Returns:
-
The number of adaptors loaded.
Definition at line 1038 of file GATSelf.c.
References CanonicaliseName(), load_data::config, data, filename, GAT_CREATE_STATUS, GAT_CREATE_STATUS_UNCOND, GAT_MEMORYFAILURE, GAT_RETURN_STATUS, GAT_USES_STATUS, GATConfig_AddAdaptorConfig(), GATConfig_GetAdaptorConfigs(), GATConfig_GetSystemConfig(), GATConfigTableList_const, GATLoader_LoadAdaptor(), GATTable_const, GATTable_Create(), load_data::loader, and load_data::registry.
Referenced by LoadAdaptors(). |
|
|
ProcessDir Search a directory for files and invoke an action on each one.
Finds all non-hidden files in a directory and invokes the designated function on them. - Parameters:
-
| dirname |
The full path to a directory. |
| action |
A callback function which does something with this file |
| data |
Data for the callback function. |
- Returns:
-
The number of files found.
Definition at line 1111 of file GATSelf.c.
References buf, data, dirent, dirname, entry, GAT_CREATE_STATUS, GAT_CREATE_STATUS_UNCOND, GAT_MEMORYFAILURE, GAT_RETURN_STATUS, GAT_USES_STATUS, and sep.
Referenced by LoadAdaptors(). |
|
|
ProcessFile Search a file for valid filenames and invoke an action on each one.
Finds all non-empty, non-commented out lines in the file and strips leading and trailing whitespace before converting into a full pathname and passing to a callback function. - Parameters:
-
| filename |
The full path to a file |
| action |
A callback function which does something with a file |
| data |
Data for the callback function. |
- Returns:
-
The number of files found.
Definition at line 1177 of file GATSelf.c.
References data, filename, GAT_CREATE_STATUS, GAT_CREATE_STATUS_MSG, GAT_CURRENT_STATUS, GAT_FILEOPEN_ERROR, GAT_INVALID_PARAMETER, GAT_RETURN_STATUS, GAT_SUCCEEDED, GAT_USES_STATUS, MakePath(), MAX_PATH, and PATH_MAX.
Referenced by LoadAdaptors(). |
| const char * MakePath |
( |
const char * |
base, |
|
|
const char * |
original, |
|
|
char |
sep, |
|
|
char * |
pathentry, |
|
|
int |
pathentry_length |
|
) |
[static] |
|
|
|
MakePath Search a delimited string and return full paths.
Parses a string, splitting it into tokens which it assumes are path-names. It returns the first path-name in the pathentry buffer, after converting it to an absolute path. The return value is a pointer to the next path in the string. - Parameters:
-
| base |
The base for pathames - used if path starts with ./ |
| original |
The search string |
| sep |
The delimiter between different pathnames |
| pathentry |
A buffer to put the new pathname into |
| pathentry_length |
the length of the pathentry buffer |
- Returns:
-
The number of files found.
Definition at line 1294 of file GATSelf.c.
References sep.
Referenced by LoadAdaptors(), and ProcessFile(). |
| char * CanonicaliseName |
( |
const char * |
original |
) |
[static] |
|
|
|
CanonicaliseName Extract the canonical name of an adaptor from its full path name.
We need the name of the adaptor in order to invoke its registration function. CanonicaliseName takes the path to an adaptor and extracts the base filename from it. Additionally, if it is a libtool library, it removes the "lib" prefix which libtool insists on having. - Parameters:
-
| input |
The path to an adaptor file. |
- Returns:
-
A canonoical name for the adaptor.
Definition at line 1430 of file GATSelf.c.
Referenced by AdaptorInstance_Create(), and Load(). |
|
|
GATSelf_Equals Compare two GATSelf objects.
The function GATSelf_Equals compares two objects of the GATSelf type. - Parameters:
-
| lhs |
The first list to compare |
| rhs |
The second list to compare |
| isequal |
The pointer to the GATBool variable, which should receive the result if the comparision |
- Returns:
-
An error code.
Definition at line 290 of file GATSelf.c.
References GAT_NOTIMPL, GAT_UNUSED_PARAMETER, GATBool, and GATSelf_const. |
|
|
GATSelf_Clone Clone the given GATSelf.
The function GATSelf_Clone generates a (deep) copy of the given GATSelf. - Parameters:
-
| description |
The object to clone |
| new_object |
The pointer, through which the result is to be returned. |
- Returns:
-
An error type.
Definition at line 311 of file GATSelf.c.
References GAT_NOTIMPL, GAT_UNUSED_PARAMETER, GATSelf_const, and handle. |
|
|
GATSelf_GetInstance.
This is the method used by any application code to get the GATSelf object. - Parameters:
-
| context |
A GATContext which is used to find the GATSelf object. |
- Returns:
-
The GATSelf object
Definition at line 261 of file GATSelf.c.
References GATContext_internal_GetSelf(), and GATSelf_const. |
|
|
GATSelf_AddRequestListener.
Registers a new callback function and a new type of request which the GATEngine should react to when queried from the outside world. Request names should be unique. - Parameters:
-
| self |
The GATSelf object |
| listener |
The callback function |
| data |
Data object for the callback function |
| type |
The type of the new request |
| name |
The name of the new request |
- Returns:
-
An error code
Definition at line 378 of file GATSelf.c.
References GATRequestListenerData::cookie, GATSelf_S::cpi, data, GATSelf_S::data, GAT_CREATE_STATUS, GAT_CURRENT_STATUS, GAT_FAIL, GAT_FAILED, GAT_INVALID_PARAMETER, GAT_KEY_ALREADY_EXISTS, GAT_MEMORYFAILURE, GAT_RETURN_STATUS, GAT_STATUS_APIENTRY, GAT_SUCCEEDED, GATBool, GATContext_internal_GetSelf(), GATFalse, GATRequest, GATRequest_Equals(), GATRequestListener, GATRequestType, GATSelfCPI_CreateRequestForListener(), GATTable_const, GATuint32, GATSelf_S::listeners, name, GATRequestListenerData::request, and request_cookie_jar.
Referenced by main(). |
|
|
GATSelf_RemoveRequestListener.
Unregisters a request callback function. - Parameters:
-
| this |
The GATSelf object |
| name |
The name of the old request |
- Returns:
-
An error code
Definition at line 466 of file GATSelf.c.
References GATRequestListenerData::cookie, GATSelf_S::cpi, GATSelf_S::data, GAT_CREATE_STATUS, GAT_CURRENT_STATUS, GAT_FAIL, GAT_INVALID_PARAMETER, GAT_KEY_NOT_FOUND, GAT_RETURN_STATUS, GAT_STATUS_APIENTRY, GAT_SUCCEEDED, GATBool, GATContext_internal_GetSelf(), GATFalse, GATSelfCPI_DestroyRequestForListener(), GATTrue, GATuint32, GATSelf_S::listeners, and GATRequestListenerData::request.
Referenced by main(). |
|
|
GATSelf_GetJob.
Each GAT job has an associated GATJob object which can be advertised to allow other GAT applications to manipulate it. - Parameters:
-
| self |
The GATSelf object |
| job |
The pointer to the variable, which receives the created job object. |
- Returns:
-
The associated GATJob.
Definition at line 525 of file GATSelf.c.
References GATSelf_S::cpi, GATSelf_S::data, GAT_CREATE_STATUS, GAT_INVALID_PARAMETER, GAT_NO_REGISTERED_CPI, GAT_RETURN_STATUS, GAT_STATUS_APIENTRY, GATContext_internal_GetSelf(), GATJob, GATJob_internal_SetGATJobId(), GATSelf_S::gatjobid, and GATSelfCPI_GetJob().
Referenced by main(). |
|
|
GATSelf_internal_GetInstance Private GATEngine method to get the GATSelf object.
This is the method used by the constructor of a GATContext to get the GATSelf object. This creates the GATSelf if it has not already been created. - Parameters:
-
| error_context |
This is the created context, which potentially triggers the creation of the GATSelf. This context may be used for storing/retrieving the current status only. |
- Returns:
-
The GATSelf object
Definition at line 563 of file GATSelf.c.
References GATSelf_Create().
Referenced by GATContext_Clone(), and GATContext_Create(). |
|
|
Definition at line 1524 of file GATSelf.c.
References GAT_CREATE_STATUS, GAT_CREATE_STATUS_IF, GAT_MEMORYFAILURE, GAT_RETURN_STATUS, GAT_UNUSED_PARAMETER, GAT_USES_STATUS, GATSelf_const, GATString_Create(), str, and UUID_TO_GAT.
Referenced by GATResourceBroker_SubmitJob(), and GATSelf_Create(). |
|
|
GATSelf_AddErrorMessageHandler.
The GATSelf_AddErrorMessageHandler function registeres the given callback function with the engine. This callback function is used by the engine to get the error message corresponding to a given error code. The callback function is called for error codes belonging to the given facility (the facility code is contained in the error code, namely bits 16...27). - Parameters:
-
| facility |
The facility code, for which this callback function has to be called. |
| callback |
The callback function to call to get the error messages for error codes belon ing to the given facility. |
| cookie |
The pointer to a variable, which receives a unique cookie representing the registered function, which should be used to remove the registration of this function later on. |
- Returns:
-
An error code.
Definition at line 1608 of file GATSelf.c.
References GATErrorMessageHandlerData::cookie, data, error_cookie_jar, error_message_handlers, GATErrorMessageHandlerData::facility, GAT_FAILED, GAT_INVALID_PARAMETER, GAT_MEMORYFAILURE, GAT_SUCCESS, GATErrorMessageHandler, GATResult, GATuint32, and GATErrorMessageHandlerData::handler.
Referenced by GATSelf_Create(). |
|
|
GATSelf_ResolveErrorMessage.
The function GATSelf_ResolveErrorMessage returns an error message associated with the given error code. - Parameters:
-
| err_code |
The error code, for which the system needs to get the error message. |
| buffer |
The buffer, where to return the resulting error message. |
| length |
The size of the given buffer. If this size is insufficient for the error message to return, the error callback function should return the required length in the written output parameter and it should additionally return the GAT_BUFFER_TOO_SMALL return value to the caller. |
| written |
The pointer to a variable, which should receive the real size of the generated error message. |
- Returns:
-
An error code.
Definition at line 1718 of file GATSelf.c.
References data, error_message_handlers, GATErrorMessageHandlerData::facility, GAT_BUFFER_TOO_SMALL, GAT_KEY_NOT_FOUND, GAT_RESULT_FACILITY, GAT_SUCCEEDED, GATResult, GATuint32, and GATErrorMessageHandlerData::handler.
Referenced by advertservice_db_re_match(), and GATStatus_TraceLevel(). |
Variable Documentation
const char* rcsid = "$Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATSelf.c,v 1.56 2004/05/12 18:56:01 hartmutkaiser Exp $" [static]
|
|
| GATSelf_vtable GATSelf__vtable
|
|
|
|
Initial value: {
GATSelf_GetType,
GATSelf_Destroy,
GATSelf_Equals,
GATSelf_Clone,
GATSelf_GetInterface,
GATSelf_GetCPIInstanceData
}
Definition at line 218 of file GATSelf.c.
Referenced by GATSelf_Create(). |
GATList_GATErrorMessageHandlerData error_message_handlers = NULL [static]
|
|
|