Lecture 13b Writing GAT Adaptors - cct.lsu.edu · •GAT engine matches these two preference sets...

12
Writing GAT Adaptors Hartmut Kaiser [email protected] http://www.cct.lsu.edu/~gallen/Teaching

Transcript of Lecture 13b Writing GAT Adaptors - cct.lsu.edu · •GAT engine matches these two preference sets...

Page 1: Lecture 13b Writing GAT Adaptors - cct.lsu.edu · •GAT engine matches these two preference sets to select suitable adaptors •Preferences are a set of key/value pairs decribing

Writing GAT Adaptors

Hartmut [email protected]

http://www.cct.lsu.edu/~gallen/Teaching

Page 2: Lecture 13b Writing GAT Adaptors - cct.lsu.edu · •GAT engine matches these two preference sets to select suitable adaptors •Preferences are a set of key/value pairs decribing

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

Page 3: Lecture 13b Writing GAT Adaptors - cct.lsu.edu · •GAT engine matches these two preference sets to select suitable adaptors •Preferences are a set of key/value pairs decribing

October 17th, 2005 Writing GAT Adaptors 3

What‘s a GAT Adaptor

Page 4: Lecture 13b Writing GAT Adaptors - cct.lsu.edu · •GAT engine matches these two preference sets to select suitable adaptors •Preferences are a set of key/value pairs decribing

October 17th, 2005 Writing GAT Adaptors 4

What‘s a GAT Adaptor• May (has to) implement more then one CPI

(group of related functions):

Page 5: Lecture 13b Writing GAT Adaptors - cct.lsu.edu · •GAT engine matches these two preference sets to select suitable adaptors •Preferences are a set of key/value pairs decribing

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

Page 6: Lecture 13b Writing GAT Adaptors - cct.lsu.edu · •GAT engine matches these two preference sets to select suitable adaptors •Preferences are a set of key/value pairs decribing

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

Page 7: Lecture 13b Writing GAT Adaptors - cct.lsu.edu · •GAT engine matches these two preference sets to select suitable adaptors •Preferences are a set of key/value pairs decribing

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)

Page 8: Lecture 13b Writing GAT Adaptors - cct.lsu.edu · •GAT engine matches these two preference sets to select suitable adaptors •Preferences are a set of key/value pairs decribing

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)

Page 9: Lecture 13b Writing GAT Adaptors - cct.lsu.edu · •GAT engine matches these two preference sets to select suitable adaptors •Preferences are a set of key/value pairs decribing

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

Page 10: Lecture 13b Writing GAT Adaptors - cct.lsu.edu · •GAT engine matches these two preference sets to select suitable adaptors •Preferences are a set of key/value pairs decribing

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

Page 11: Lecture 13b Writing GAT Adaptors - cct.lsu.edu · •GAT engine matches these two preference sets to select suitable adaptors •Preferences are a set of key/value pairs decribing

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

Page 12: Lecture 13b Writing GAT Adaptors - cct.lsu.edu · •GAT engine matches these two preference sets to select suitable adaptors •Preferences are a set of key/value pairs decribing

October 17th, 2005 Writing GAT Adaptors 12

Demo• File Transfer Adaptor

– Local adaptor written in Python