GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

adaptor.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <GATCPI.h>
#include "GATUtil.h"
#include "logical_filestore.h"

Include dependency graph for logicalfile/adaptor.c:

Include dependency graph

Go to the source code of this file.

Defines

#define __countof(x)   (sizeof(x)/sizeof(x[0]))
#define METRIC_FILE_REPLICATED   0

Functions

void logicalfile_adaptor_LogicalFileCPI_Destroy (void *data)
 logicalfile_adaptor_LogicalFileCPI_Destroy Destroy the adaptor-provided data object on GATLogicalFileCPI destruction.

GATResult logicalfile_adaptor_LogicalFileCPI_ServiceActions (void *data, GATLogicalFileCPI_Instance *instance_data, GATTimePeriod_const timeout)
 logicalfile_adaptor_LogicalFileCPI_ServiceActions

GATResult logicalfile_adaptor_LogicalFileCPI_CreateInstance (void *adaptor_data, GATLogicalFileCPI_Instance *data)
 logicalfile_adaptor_LogicalFileCPI_CreateInstance Create a new CPI object instance.

void logicalfile_adaptor_LogicalFileCPI_DestroyInstance (void *adaptor_data, GATLogicalFileCPI_Instance *data)
 logicalfile_adaptor_LogicalFileCPI_DestroyInstance Destroy a CPI object instance.

GATResult logicalfile_adaptor_LogicalFileCPI_CloneInstance (void *adaptor_data, GATLogicalFileCPI_Instance const *data, GATLogicalFileCPI_Instance *new_data)
 logicalfile_adaptor_LogicalFileCPI_CloneInstance Clone a CPI object instance.

GATResult logicalfile_adaptor_LogicalFileCPI_EqualsInstance (void *adaptor_data, GATLogicalFileCPI_Instance const *lhs, GATLogicalFileCPI_Instance const *rhs, GATBool *isequal)
 logicalfile_adaptor_LogicalFileCPI_EqualsInstance Clone a CPI object instance.

GATResult logicalfile_adaptor_LogicalFileCPI_AddFile (void *adaptor_data, GATLogicalFileCPI_Instance *data, GATFile_const target)
 logicalfile_adaptor_LogicalFileCPI_AddFile Add a file to the logical file store.

GATResult logicalfile_adaptor_LogicalFileCPI_RemoveFile (void *adaptor_data, GATLogicalFileCPI_Instance *data, GATFile_const target)
 logicalfile_adaptor_LogicalFileCPI_RemoveFile Remove a file from the logical file store.

GATResult logicalfile_adaptor_LogicalFileCPI_Replicate (void *adaptor_data, GATLogicalFileCPI_Instance const *data, GATLocation_const target)
 logicalfile_adaptor_LogicalFileCPI_Replicate Replicates the logical file store to a file at the given location.

GATResult logicalfile_adaptor_LogicalFileCPI_GetFiles (void *adaptor_data, GATLogicalFileCPI_Instance const *data, GATList_GATFile *target)
 logicalfile_adaptor_LogicalFileCPI_GetFiles Get the list of physical files contained in the given logical file store.

GATResult logicalfile_adaptor_LogicalFileCPI_Remove (void *adaptor_data, GATLogicalFileCPI_Instance const *data)
 static GATResult logicalfile_adaptor_LogicalFileCPI_Remove Remove the logical file store.

GATResult logicalfile_adaptor_LogicalFileCPI_Serialise (void *data, GATLogicalFileCPI_Instance const *instance_data, GATObject stream, GATBool clear_dirty)
 logicalfile_adaptor_LogicalFileCPI_Serialise

GATResult logicalfile_adaptor_LogicalFileCPI_DeSerialise (void *data, GATObject stream, GATLogicalFileCPI_Instance *instance_data)
 logicalfile_adaptor_LogicalFileCPI_DeSerialise

GATResult logicalfile_adaptor_LogicalFileCPI_GetMetrics (void *data, GATLogicalFileCPI_Instance const *instance_data, GATList_GATMetric *metrics)
 logicalfile_adaptor_LogicalFileCPI_GetMetrics

GATResult logicalfile_adaptor_LogicalFileCPI_GetMetricEvent (void *data, GATLogicalFileCPI_Instance const *instance_data, GATMetric metric, GATMetricEvent *event)
 logicalfile_adaptor_LogicalFileCPI_GetMetricEvent

GATResult logicalfile_adaptor_FireReplicatedEvent (GATMonitorable_Impl monitorable, GATObject_const source, char const *name)
 logicalfile_adaptor_FireReplicatedEvent

GATResult logicalfile_adaptor_register (GATContext error_context, GATRegistry registry, GATTable_const system_config, GATTable_const instance_config, void *token)
 logicalfile_adaptor_register Registers all CPIs this adaptor provides.


Variables

const char * rcsid = "$Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/adaptors/logicalfile/adaptor.c,v 1.20 2004/04/22 10:25:05 hartmutkaiser Exp $"
GATStaticMetric metric_data []


Define Documentation

#define __countof      (sizeof(x)/sizeof(x[0]))
 

Definition at line 37 of file logicalfile/adaptor.c.

#define METRIC_FILE_REPLICATED   0
 

Definition at line 134 of file logicalfile/adaptor.c.

Referenced by logicalfile_adaptor_FireReplicatedEvent().


Function Documentation

void logicalfile_adaptor_LogicalFileCPI_Destroy void *    data [static]
 

logicalfile_adaptor_LogicalFileCPI_Destroy Destroy the adaptor-provided data object on GATLogicalFileCPI destruction.

When the GATLogicalFileCPI object created in this adaptor's _register function is destroyed, this function is invoked to allow the adaptor to cleanup.

Parameters:
data  Adaptor-provided data object.

Definition at line 249 of file logicalfile/adaptor.c.

References data.

Referenced by logicalfile_adaptor_register().

GATResult logicalfile_adaptor_LogicalFileCPI_ServiceActions void *    data,
GATLogicalFileCPI_Instance   instance_data,
GATTimePeriod_const    timeout
[static]
 

logicalfile_adaptor_LogicalFileCPI_ServiceActions

The function logicalfile_adaptor_LogicalFileCPI_ServiceActions is called, whenever the client calls GATContext_ServiceActions. This function is called for every created object. This function should be used to update all instance specific data, which may have been changed asynchronously or to fire pending events.

Parameters:
data  Adaptor-provided data object.
instance_data  The instance data of this CPI object
timeout  This may be a 0 timeout to indicate no timeout at all, or a specific time length.
Returns:
An error code.

Definition at line 270 of file logicalfile/adaptor.c.

References data, GAT_NOTIMPL, and GATTimePeriod_const.

Referenced by logicalfile_adaptor_register().

GATResult logicalfile_adaptor_LogicalFileCPI_CreateInstance void *    adaptor_data,
GATLogicalFileCPI_Instance   data
 

logicalfile_adaptor_LogicalFileCPI_CreateInstance Create a new CPI object instance.

Adaptor implementation of create instance capability.

Parameters:
adaptor_data  Adaptor-provided data object.
data  The pointer to the data structure containing at least the constructor provided data items and a member instance_data, which may be used by the adaptor to store CPI instance specific data.
Returns:
An error code.

Definition at line 288 of file logicalfile/adaptor.c.

References data, GAT_INVALID_PARAMETER, GAT_SUCCESS, GATResult, and GATLogicalFileCPI_Instance::instance_data.

Referenced by logicalfile_adaptor_register().

void logicalfile_adaptor_LogicalFileCPI_DestroyInstance void *    adaptor_data,
GATLogicalFileCPI_Instance   data
 

logicalfile_adaptor_LogicalFileCPI_DestroyInstance Destroy a CPI object instance.

Adaptor implementation of destroy instance capability.

Parameters:
data  Adaptor-provided data object.
instance_data  The instance data of the CPI object to destroy.

Definition at line 309 of file logicalfile/adaptor.c.

References assert, data, and GATLogicalFileCPI_Instance::instance_data.

Referenced by logicalfile_adaptor_register().

GATResult logicalfile_adaptor_LogicalFileCPI_CloneInstance void *    adaptor_data,
GATLogicalFileCPI_Instance const *    instance_data,
GATLogicalFileCPI_Instance   new_instance_data
 

logicalfile_adaptor_LogicalFileCPI_CloneInstance Clone a CPI object instance.

Adaptor implementation of the clone instance capability.

Parameters:
data  Adaptor-provided data object.
instance_data  The instance data of this CPI object
new_instance_data  The pointer to the variable, where the instance data of the cloned CPI object is to be returned to.
Returns:
An error code.

Definition at line 328 of file logicalfile/adaptor.c.

References assert, GAT_SUCCESS, and GATLogicalFileCPI_Instance::instance_data.

Referenced by logicalfile_adaptor_register().

GATResult logicalfile_adaptor_LogicalFileCPI_EqualsInstance void *    data,
GATLogicalFileCPI_Instance const *    lhs,
GATLogicalFileCPI_Instance const *    rhs,
GATBool   isequal
 

logicalfile_adaptor_LogicalFileCPI_EqualsInstance Clone a CPI object instance.

Adaptor implementation of the clone instance capability.

Parameters:
data  Adaptor-provided data object.
lhs  The instance data of the left CPI object.
lhs  The instance data of the right CPI object.
isequal  The pointer to the variable, where the result is to be returned to.
Returns:
An error code.

Definition at line 351 of file logicalfile/adaptor.c.

References data, GAT_INVALID_HANDLE, GAT_SUCCESS, GATBool, GATResult, and GATTrue.

Referenced by logicalfile_adaptor_register().

GATResult logicalfile_adaptor_LogicalFileCPI_AddFile void *    adaptor_data,
GATLogicalFileCPI_Instance   data,
GATFile_const    target
[static]
 

logicalfile_adaptor_LogicalFileCPI_AddFile Add a file to the logical file store.

Adaptor implementation of logical file add capability.

Parameters:
data  Adaptor-provided data object.
context  a GATContext
target  File to add to the logical file collection.
Returns:
An error code.

Definition at line 376 of file logicalfile/adaptor.c.

References GATLogicalFileCPI_Instance::context, data, GAT_FAIL, GATFile_const, GATLocation_ToString(), GATResult, GATLogicalFileCPI_Instance::location, logical_filestore_addfile(), logical_filestore_create(), logical_filestore_destroy(), GATLogicalFileCPI_Instance::mode, and name.

Referenced by logicalfile_adaptor_register().

GATResult logicalfile_adaptor_LogicalFileCPI_RemoveFile void *    adaptor_data,
GATLogicalFileCPI_Instance   data,
GATFile_const    target
[static]
 

logicalfile_adaptor_LogicalFileCPI_RemoveFile Remove a file from the logical file store.

Adaptor implementation of logical file remove capability.

Parameters:
data  Adaptor-provided data object.
instance_data  The instance data of this CPI object
target  File to remove from the collection.
Returns:
An error code.

Definition at line 404 of file logicalfile/adaptor.c.

References GATLogicalFileCPI_Instance::context, data, GAT_FAIL, GATFile_const, GATLocation_ToString(), GATResult, GATLogicalFileCPI_Instance::location, logical_filestore_create(), logical_filestore_destroy(), logical_filestore_removefile(), GATLogicalFileCPI_Instance::mode, and name.

Referenced by logicalfile_adaptor_register().

GATResult logicalfile_adaptor_LogicalFileCPI_Replicate void *    adaptor_data,
GATLogicalFileCPI_Instance const *    data,
GATLocation_const    target
[static]
 

logicalfile_adaptor_LogicalFileCPI_Replicate Replicates the logical file store to a file at the given location.

Adaptor implementation of logical file replicate capability.

Parameters:
data  Adaptor-provided data object.
instance_data  The instance data of this CPI object
target  Location of the file, where the logical file store is to be replicated to.
Returns:
An error code.

Definition at line 460 of file logicalfile/adaptor.c.

References GATLogicalFileCPI_Instance::context, data, GAT_FAIL, GAT_SUCCESS, GATLocation_const, GATLocation_ToString(), GATResult, GATLogicalFileCPI_Instance::location, logical_filestore_create(), logical_filestore_destroy(), logical_filestore_replicate(), logicalfile_adaptor_FireReplicatedEvent(), GATLogicalFileCPI_Instance::mode, GATLogicalFileCPI_Instance::monitorable, name, and GATLogicalFileCPI_Instance::source.

Referenced by logicalfile_adaptor_register().

GATResult logicalfile_adaptor_LogicalFileCPI_GetFiles void *    adaptor_data,
GATLogicalFileCPI_Instance const *    data,
GATList_GATFile *    target
[static]
 

logicalfile_adaptor_LogicalFileCPI_GetFiles Get the list of physical files contained in the given logical file store.

Adaptor implementation of logical file get files capability.

Parameters:
data  Adaptor-provided data object.
instance_data  The instance data of this CPI object
target  A pointer to the location, where the returned list of files is to be placed to.
Returns:
An error code.

Definition at line 498 of file logicalfile/adaptor.c.

References GATLogicalFileCPI_Instance::context, data, GAT_CREATE_STATUS, GAT_INVALID_PARAMETER, GAT_MEMORYFAILURE, GAT_RETURN_STATUS, GAT_USES_STATUS, GATLocation_ToString(), GATLogicalFileCPI_Instance::location, logical_filestore_create(), logical_filestore_destroy(), logical_filestore_getfiles(), GATLogicalFileCPI_Instance::mode, and name.

Referenced by logicalfile_adaptor_register().

GATResult logicalfile_adaptor_LogicalFileCPI_Remove void *    adaptor_data,
GATLogicalFileCPI_Instance const *    data
[static]
 

static GATResult logicalfile_adaptor_LogicalFileCPI_Remove Remove the logical file store.

Adaptor implementation of logical file store remove capability.

Parameters:
data  Adaptor-provided data object.
instance_data  The instance data of this CPI object
Returns:
An error code.

Definition at line 431 of file logicalfile/adaptor.c.

References GATLogicalFileCPI_Instance::context, data, GAT_FAIL, GATLocation_ToString(), GATResult, GATLogicalFileCPI_Instance::location, logical_filestore_create(), logical_filestore_destroy(), logical_filestore_remove(), GATLogicalFileCPI_Instance::mode, and name.

Referenced by logicalfile_adaptor_register().

GATResult logicalfile_adaptor_LogicalFileCPI_Serialise void *    data,
GATLogicalFileCPI_Instance const *    instance_data,
GATObject    stream,
GATBool    clear_dirty
[static]
 

logicalfile_adaptor_LogicalFileCPI_Serialise

The function logicalfile_adaptor_LogicalFileCPI_Serialise is called by the GAT engine, whenever the client requested a Serialise operation on the corresponding GATLogicalFile object. The function should serialise into the given stream all the instance specific data of the object.

Parameters:
data  Adaptor-provided data object.
instance_data  The instance data of this CPI object.
stream  The GATSTream object to use for serialisation of the instance data.
clear_dirty  This flag defines, whether the dirty flag of saved dependent objects is to be cleared.
Returns:
An error code

Definition at line 546 of file logicalfile/adaptor.c.

References data, GAT_SUCCESS, GATBool, and GATResult.

Referenced by logicalfile_adaptor_register().

GATResult logicalfile_adaptor_LogicalFileCPI_DeSerialise void *    data,
GATObject    stream,
GATLogicalFileCPI_Instance   instance_data
[static]
 

logicalfile_adaptor_LogicalFileCPI_DeSerialise

The function logicalfile_adaptor_LogicalFileCPI_DeSerialise is called by the GATEngine, whenever the client requested a DeSerialise operation for a GATLogicalFile object. The function should deserialise all the instance specific data of the object from the given stream.

Parameters:
data  Adaptor-provided data object.
stream  The GATSTream object to use for de-serialisation of the instance data.
instance_data  The instance data of this CPI object.
Returns:
An error code

Definition at line 570 of file logicalfile/adaptor.c.

References data, GAT_SUCCESS, GATResult, and GATLogicalFileCPI_Instance::instance_data.

Referenced by logicalfile_adaptor_register().

GATResult logicalfile_adaptor_LogicalFileCPI_GetMetrics void *    data,
GATLogicalFileCPI_Instance const *    instance_data,
GATList_GATMetric *    metrics
[static]
 

logicalfile_adaptor_LogicalFileCPI_GetMetrics

The function logicalfile_adaptor_LogicalFileCPI_GetMetrics should return a list of GATMetric objects supported by this adaptor. I.e. the adaptor is capable to fire GATMetricEvents for the returned metrics. This list should include all the supported metrics, event like and continuous ones.

Parameters:
data  Adaptor-provided data object.
instance_data  Instance data for the CPI provider object.
metrics  The pointer to the variable, which receives the returned list of metrics.
Returns:
An error code.

Definition at line 600 of file logicalfile/adaptor.c.

References __countof, data, and GATMetric_CreateListOfMetrics().

Referenced by logicalfile_adaptor_register().

GATResult logicalfile_adaptor_LogicalFileCPI_GetMetricEvent void *    data,
GATLogicalFileCPI_Instance const *    instance_data,
GATMetric    metric,
GATMetricEvent   event
[static]
 

logicalfile_adaptor_LogicalFileCPI_GetMetricEvent

The function logicalfile_adaptor_LogicalFileCPI_GetMetricEvent should return the GATMetricEvent associated with the given continuous metric. This function gets called for continuous metrics only, since returning the metric event object to the caller is th only way for the client to get access to it.

Parameters:
data  Adaptor-provided data object.
instance_data  Instance data for the CPI provider object.
metric  The metric instance describing the metric event to return. This metric should be equivalent to one of the metrics returned by our own GetMetrics CPI function (see above). If this is another (not known to us metric), an error should be returned.
event  The pointer to the variable, which receives the metric event to return.
Returns:
An error code.

Definition at line 627 of file logicalfile/adaptor.c.

References data, GAT_SUCCESS, GATMetric, and GATResult.

Referenced by logicalfile_adaptor_register().

GATResult logicalfile_adaptor_FireReplicatedEvent GATMonitorable_Impl    monitorable,
GATObject_const    source,
char const *    name
[static]
 

logicalfile_adaptor_FireReplicatedEvent

The function logicalfile_adaptor_FireReplicatedEvent fires a 'file replicated' event to all registered metric listeners.

Definition at line 643 of file logicalfile/adaptor.c.

References GAT_INVALID_PARAMETER, GAT_MEMORYFAILURE, GAT_SUCCESS, GATMetric, GATMetric_CreateMetric(), GATMetric_Destroy(), GATMetricEvent_Create_EventLike(), GATMetricEvent_Destroy(), GATMonitorable_Impl_FireEvent(), GATObject_const, GATResult, GATuint32, METRIC_FILE_REPLICATED, and name.

Referenced by logicalfile_adaptor_LogicalFileCPI_Replicate().

GATResult logicalfile_adaptor_register GATContext    error_context,
GATRegistry    registry,
GATTable_const    system_config,
GATTable_const    instance_config,
void *    token
 

logicalfile_adaptor_register Registers all CPIs this adaptor provides.

This function is invoked by the loader in the GATEngine when an instance of this adaptor is loaded. Each instance has its own private configuration table.

For every CPI provided the adapter has to hand all the corresponding function pointers to the engine to allow to be called back under certain circumstances. Additionally the adaptor may allocate some private data for every loaded instance. This data is handed back to the adaptor as the first parameter to each of the subsequently called functions.

Parameters:
registry  The registry the adaptor should register its CPIs with.
system_config  The system configuration table.
instance_config  The configuration table for this instance.
token  An arbitrary token used by the loader to identify this adaptor instance
Returns:
An error code.

Definition at line 160 of file logicalfile/adaptor.c.

References GATLogicalFileCPI_Data::add, GATLogicalFileCPI_Data::clone_instance, cpi, GATLogicalFileCPI_Data::create_instance, GATLogicalFileCPI_Data::data, GATLogicalFileCPI_Data::deserialise, GATLogicalFileCPI_Data::destroy, GATLogicalFileCPI_Data::destroy_instance, GATLogicalFileCPI_Data::equals_instance, GAT_MEMORYFAILURE, GAT_SUCCESS, GAT_UNKNOWN_VERSION, GATLogicalFileCPI_Create(), GATLogicalFileCPI_Destroy(), GATLOGICALFILECPI_VERSION, GATPreferences_Add(), GATPreferences_Create(), GATPreferences_Destroy(), GATResult, GATTable_const, GATVERSION_ISCOMPATIBLE, GATLogicalFileCPI_Data::get_metric_event, GATLogicalFileCPI_Data::get_metrics, GATLogicalFileCPI_Data::getfiles, logicalfile_adaptor_LogicalFileCPI_AddFile(), logicalfile_adaptor_LogicalFileCPI_CloneInstance(), logicalfile_adaptor_LogicalFileCPI_CreateInstance(), logicalfile_adaptor_LogicalFileCPI_DeSerialise(), logicalfile_adaptor_LogicalFileCPI_Destroy(), logicalfile_adaptor_LogicalFileCPI_DestroyInstance(), logicalfile_adaptor_LogicalFileCPI_EqualsInstance(), logicalfile_adaptor_LogicalFileCPI_GetFiles(), logicalfile_adaptor_LogicalFileCPI_GetMetricEvent(), logicalfile_adaptor_LogicalFileCPI_GetMetrics(), logicalfile_adaptor_LogicalFileCPI_Remove(), logicalfile_adaptor_LogicalFileCPI_RemoveFile(), logicalfile_adaptor_LogicalFileCPI_Replicate(), logicalfile_adaptor_LogicalFileCPI_Serialise(), logicalfile_adaptor_LogicalFileCPI_ServiceActions(), GATLogicalFileCPI_Data::remove, GATLogicalFileCPI_Data::removefile, GATLogicalFileCPI_Data::replicate, GATLogicalFileCPI_Data::serialise, GATLogicalFileCPI_Data::service_actions, and token.


Variable Documentation

const char* rcsid = "$Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/adaptors/logicalfile/adaptor.c,v 1.20 2004/04/22 10:25:05 hartmutkaiser Exp $" [static]
 

Definition at line 20 of file logicalfile/adaptor.c.

GATStaticMetric metric_data[] [static]
 

Initial value:

 {
  
  { 
    "logicalfile.file_replicated",  
    GATMeasurementType_EventLike,   
    GATType_String,                 
    "",                             
    0,                              
    0                               
  },
}

Definition at line 121 of file logicalfile/adaptor.c.