Lecture 13b Writing GAT Adaptors - cct.lsu.edu · •GAT engine matches these two preference sets...
Transcript of Lecture 13b Writing GAT Adaptors - cct.lsu.edu · •GAT engine matches these two preference sets...
October 17th, 2005 Writing GAT Adaptors 2
What‘s a GAT Adaptor• Piece of glue code connecting the GAT CPI
with the concrete service API to use• CPI: capability provider interface
– Interface between the GAT and the adaptors• Service API
– Client side interface of a service (OS service,webservice, client library etc.)
• Maps the single CPI functions to thecorresponding service API functions
October 17th, 2005 Writing GAT Adaptors 3
What‘s a GAT Adaptor
October 17th, 2005 Writing GAT Adaptors 4
What‘s a GAT Adaptor• May (has to) implement more then one CPI
(group of related functions):
October 17th, 2005 Writing GAT Adaptors 5
What‘s a GAT Adaptor• Every of the CPI functions correspond to one of the GAT API
functions, i.e.
• Engine dispatches the API call to a suitable adaptor (calls theCPI function implemented in the adaptor)
• But not all of the CPI functions have to be implemented, runtimeprovides the missing functions (C++ and Python)
• Runtime returns GAT_NOTIMPL for these (C++ and Python)
<-><->
GAT.Adaptors.FileCPI.CopyGAT.File.CopyCPIAPI
October 17th, 2005 Writing GAT Adaptors 6
File Transfer Adaptor• File transfer CPI
– CPI data• Context this object was created with• Location of this file
– CPI functions:• Copy(Location dest, CopyMode mode)
– Copy the file to the specified destination• Move(Location dest, MoveMode mode)
– Move the file to the specified destination• Delete()
– Delete the file• GetLength()
– Return the current size of the file• IsReadable()
– Return, whether the file is readable• IsWritable()
– Return, whether the file is readable• LastWriteTime()
– Return the time of the last write access
October 17th, 2005 Writing GAT Adaptors 7
File Transfer AdaptorApplication
import GAT
file = GAT.File("file://tmp/t")
file.Copy("file://tmp/t2", Overwrite)
file = GAT.File("file://tmp/t2")
file.Move("file://tmp/t3", FailIfThere)
Adaptor
import shutilimport GATimport GAT.Adaptors
class filecpi(GAT.Adaptors.FileCPI): Copy(self, dest, mode): shutil.copyfile(self.location, dest)
class filecpi: Move(self, dest, mode) shutil.move(self.location, dest)
October 17th, 2005 Writing GAT Adaptors 8
Service Discovery Adaptor• ServiceResourceBroker CPI
– CPI data• Context this object was created with
– CPI functions• FindResources(ServiceDescription)
– Return a list of suitable resources
• Reource CPI (ServiceResource)– CPI data
• Context this object was created with• Resource Description
– CPI functions• GetResourceDescription
– Return the resource description of this resource• (GetReservation)
– Does not apply here (is for HardwareResources only)
October 17th, 2005 Writing GAT Adaptors 9
Adaptor Selection• GAT engine narrows down the list of available
adaptors using supplied/default preferences• GAT engine goes through the remaining list
and tries to instantiate the objectimplementing the CPI
• The first adaptor found to return successgets associated with the GAT API object
• GAT.File <-> GAT.Adaptors.FileCPI
October 17th, 2005 Writing GAT Adaptors 10
Preference Matching• Adaptor registers its preferences (capabilities)
during adaptor loading• Application may specify its preferences
(requirements) during object construction
• GAT engine matches these two preference sets toselect suitable adaptors
• Preferences are a set of key/value pairs decribing aCPI implementation provided by a certain adaptor
• Look at the adaptor_instances example whichprints the registered adaptor preferences
October 17th, 2005 Writing GAT Adaptors 11
CPI Instantiation• GAT engine tries to instantiate the object which
implements the CPI• C++/Python: first the function IsApplicable is
called to decide, whether this object will be able tosupport the request
• CPI object is instantiated only, when IsApplicablereturns True
• Drawback: adaptors are ‚bound‘ to the API object atobject creation time and it‘s not possible to changethe adaptor during the object lifetime (early binding)
• SAGA will support late binding
October 17th, 2005 Writing GAT Adaptors 12
Demo• File Transfer Adaptor
– Local adaptor written in Python