SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Downloaden Sie, um offline zu lesen
GlusterFS APIs
2013-03-08
Bangalore
Libgfapi Basics
 Do some things manually that glusterfs[d] does in
main()
• Create a context
• Load a volfile into that context
• Set up logging, etc.
 Issue individual calls using glfs_xxx
• e.g. glfs_open, glfs_write
Libgfapi CodeExample
glfs_t *fs = NULL;
int ret = 0;
fs = glfs_new ("iops");
if (!fs) {
return 1;
}
ret = glfs_set_volfile_server (fs, "tcp", "localhost",
24007);
ret = glfs_set_logging (fs, "/dev/stderr", 7);
ret = glfs_init (fs);
fd = glfs_creat (fs, filename, O_RDWR, 0644);
Libgfapi inPython
vol = Volume("localhost",volid)
vol.set_logging("/dev/null",7)
vol.mount()
def test_create (vol, mypath, data):
fd = vol.creat(mypath,os.O_WRONLY|os.O_EXCL,0644)
if not fd:
print "creat error"
return False
rc = fd.write(data)
if rc != len(data):
print "wrote %d/%d bytes" % (rc, len(data))
return False
return True
Translator Basics
 Addfunctionalityfromsimplestorage“bricks” touser (at treeroot)
FUSE
DHT
AFR-1
Client-3Client-1
AFR-0
Client-2Client-0
Translator Environment
 All writtenin“PlainOldC” - thankyou, Dennis
 STACK_WINDtocall “down” (towardstorage) at thebeginningof a
request
 STACK_UNWINDtocall “up” (towarduser) at theendof arequest
 General filesystem-relatedfunctions
• get/set context oninodesandfds, dictionaries, …
 Utilityfunctions
• memoryallocation, stringhandling, logging, …
• moreabout thislater
HereBeDragons
 All callsareasynchronous
• ContinuationPassingStyle, node.js, etc.
 Youlosecontrol whenyoucall upor down
 Youregaincontrol viacallback
1267 STACK_WIND (frame, dht_unlink_cbk,
1268 cached_subvol, cached_subvol->fops->unlink,
1269 &local->loc);
1270
1271 return 0;
callback pointer
world might have changed
PrivateContext
 Accessedviaframe->local
 Availabletobothoriginal dispatchfunctionandcallback, soit'svery
handy
 Canbeanystructureyouwant (void*)
 Youareresponsiblefor allocatingit, but freedautomatically(if non-
null) alongwiththeframe
 Trickyobject-lifecyclerulesarearecurringtheme(e.g. sameissues
withdictionaries)
Request Types
 Mostlywhat you'dexpect fromPOSIXor LinuxVFS
• open, close, readv, writev, stat, …
• …but watchout e.g. for separatelookupfunction
 Most operateonfiledescriptorsor inodes
• sometimesboth, e.g. fstat vs. stat
 All haverequest-specificarguments
• paths, modes, flags, data(of course)
• hint: usedefault_xxxasatemplatefor eachxxxyouimplement
Dictionaries
 String-valuedkeyplusarbitraryvalue
 Usedfor translator options, andalsoasargumentsfor some
requests(e.g. getxattr)
 Lotsof functionstoset different kindsof values
• ints, strings(static/dynamic), binaryblobs
 Enumerationviadict_foreach
 Bothdictionaries(dict_t) anddataitems(data_t) haverefcounts
Persistent object context
 Inode(inode_t) andfiledescriptor (fd_t)
 Treat translator askey, arbitraryvalue
• settingvaluealsotriggersforget/releasecallbackwhentheobject itself is
destroyed
inode_ctx_put (inode, xlator, value)
inode_ctx_get (inode, xlator, &value)
inode_ctx_del (inode, xlator, &value)
fd_ctx_set (fd, xlator, value)
fd_ctx_get (fd, xlator, &value)
fd_ctx_del (fd, xlator, &value)
Translator CodeExample
int32_t
negative_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
dict_t *xdata)
{
...
gf_log(this->name,GF_LOG_DEBUG,"%s/%s => MISS",
uuid_utoa(loc->gfid), loc->name);
gp = GF_CALLOC(1,sizeof(ghost_t),gf_negative_mt_ghost);
if (gp) {
uuid_copy(gp->gfid,loc->pargfid);
gp->name = gf_strdup(loc->name);
}
STACK_WIND_COOKIE (frame, negative_lookup_cbk, gp,
FIRST_CHILD(this),
FIRST_CHILD(this)->fops->lookup,
loc, xdata);
return 0;
}
Glupy
Normal xlator
Glupy “shim”
User's code
gluster.py
Normal xlator
GlupyCodeExample
def create_fop (self, frame, this, loc, flags, mode,
umask, fd, xdata):
pargfid = uuid2str(loc.contents.pargfid)
print "create FOP: %s:%s" % (pargfid,
loc.contents.name)
key = dl.get_id(frame)
self.requests[key] = (pargfid, loc.contents.name[:])
dl.wind_create(frame,POINTER(xlator_t)(),
loc,flags,mode,umask,fd,xdata)
return 0

Weitere ähnliche Inhalte

Was ist angesagt?

Clojure and Modularity
Clojure and ModularityClojure and Modularity
Clojure and Modularity
elliando dias
 
Streams in node js
Streams in node jsStreams in node js
Streams in node js
Kushal Likhi
 

Was ist angesagt? (20)

I Believe I Can See the Future
I Believe I Can See the FutureI Believe I Can See the Future
I Believe I Can See the Future
 
Intro to Apache Storm
Intro to Apache StormIntro to Apache Storm
Intro to Apache Storm
 
Linker Wisdom
Linker WisdomLinker Wisdom
Linker Wisdom
 
Calling python from r
Calling python from rCalling python from r
Calling python from r
 
Scheming Defaults
Scheming DefaultsScheming Defaults
Scheming Defaults
 
"Metrics: Where and How", Vsevolod Polyakov
"Metrics: Where and How", Vsevolod Polyakov"Metrics: Where and How", Vsevolod Polyakov
"Metrics: Where and How", Vsevolod Polyakov
 
Clojure and Modularity
Clojure and ModularityClojure and Modularity
Clojure and Modularity
 
Data File Handiling File POINTERS IN C++
Data File Handiling File POINTERS IN C++Data File Handiling File POINTERS IN C++
Data File Handiling File POINTERS IN C++
 
Inheritance
InheritanceInheritance
Inheritance
 
Python 4-迴圈-for
Python 4-迴圈-forPython 4-迴圈-for
Python 4-迴圈-for
 
Namespace1
Namespace1Namespace1
Namespace1
 
Full Stack Clojure
Full Stack ClojureFull Stack Clojure
Full Stack Clojure
 
[214] Ai Serving Platform: 하루 수 억 건의 인퍼런스를 처리하기 위한 고군분투기
[214] Ai Serving Platform: 하루 수 억 건의 인퍼런스를 처리하기 위한 고군분투기[214] Ai Serving Platform: 하루 수 억 건의 인퍼런스를 처리하기 위한 고군분투기
[214] Ai Serving Platform: 하루 수 억 건의 인퍼런스를 처리하기 위한 고군분투기
 
Python lec4
Python lec4Python lec4
Python lec4
 
Learning a node stream
Learning a node streamLearning a node stream
Learning a node stream
 
Streams in node js
Streams in node jsStreams in node js
Streams in node js
 
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect ToolboxWebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
 
Managing console i/o operation,working with files
Managing console i/o operation,working with filesManaging console i/o operation,working with files
Managing console i/o operation,working with files
 
Python lec5
Python lec5Python lec5
Python lec5
 
OSTEP Chapter2 Introduction
OSTEP Chapter2 IntroductionOSTEP Chapter2 Introduction
OSTEP Chapter2 Introduction
 

Ähnlich wie Gsummit apis-2012

Rust All Hands Winter 2011
Rust All Hands Winter 2011Rust All Hands Winter 2011
Rust All Hands Winter 2011
Patrick Walton
 

Ähnlich wie Gsummit apis-2012 (20)

Gsummit apis-2013
Gsummit apis-2013Gsummit apis-2013
Gsummit apis-2013
 
Script of Scripts Polyglot Notebook and Workflow System
Script of ScriptsPolyglot Notebook and Workflow SystemScript of ScriptsPolyglot Notebook and Workflow System
Script of Scripts Polyglot Notebook and Workflow System
 
Lcna tutorial-2012
Lcna tutorial-2012Lcna tutorial-2012
Lcna tutorial-2012
 
Lcna 2012-tutorial
Lcna 2012-tutorialLcna 2012-tutorial
Lcna 2012-tutorial
 
An Introduction to User Space Filesystem Development
An Introduction to User Space Filesystem DevelopmentAn Introduction to User Space Filesystem Development
An Introduction to User Space Filesystem Development
 
Leveraging Hadoop in your PostgreSQL Environment
Leveraging Hadoop in your PostgreSQL EnvironmentLeveraging Hadoop in your PostgreSQL Environment
Leveraging Hadoop in your PostgreSQL Environment
 
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
 
Fuse'ing python for rapid development of storage efficient FS
Fuse'ing python for rapid development of storage efficient FSFuse'ing python for rapid development of storage efficient FS
Fuse'ing python for rapid development of storage efficient FS
 
Node.js - A practical introduction (v2)
Node.js  - A practical introduction (v2)Node.js  - A practical introduction (v2)
Node.js - A practical introduction (v2)
 
Node intro
Node introNode intro
Node intro
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
 
Part 03 File System Implementation in Linux
Part 03 File System Implementation in LinuxPart 03 File System Implementation in Linux
Part 03 File System Implementation in Linux
 
Rust All Hands Winter 2011
Rust All Hands Winter 2011Rust All Hands Winter 2011
Rust All Hands Winter 2011
 
Advfs system calls & kernel interfaces
Advfs system calls & kernel interfacesAdvfs system calls & kernel interfaces
Advfs system calls & kernel interfaces
 
Developing apps and_integrating_with_gluster_fs_-_libgfapi
Developing apps and_integrating_with_gluster_fs_-_libgfapiDeveloping apps and_integrating_with_gluster_fs_-_libgfapi
Developing apps and_integrating_with_gluster_fs_-_libgfapi
 
Getting started with Clojure
Getting started with ClojureGetting started with Clojure
Getting started with Clojure
 
Exploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernelExploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernel
 
Python for Linux System Administration
Python for Linux System AdministrationPython for Linux System Administration
Python for Linux System Administration
 
The Future of Apache Storm
The Future of Apache StormThe Future of Apache Storm
The Future of Apache Storm
 
Char Drivers And Debugging Techniques
Char Drivers And Debugging TechniquesChar Drivers And Debugging Techniques
Char Drivers And Debugging Techniques
 

Mehr von Gluster.org

nfusr: a new userspace NFS client based on libnfs - Shreyas Siravara
nfusr: a new userspace NFS client based on libnfs - Shreyas Siravaranfusr: a new userspace NFS client based on libnfs - Shreyas Siravara
nfusr: a new userspace NFS client based on libnfs - Shreyas Siravara
Gluster.org
 
Facebook’s upstream approach to GlusterFS - David Hasson
Facebook’s upstream approach to GlusterFS  - David HassonFacebook’s upstream approach to GlusterFS  - David Hasson
Facebook’s upstream approach to GlusterFS - David Hasson
Gluster.org
 

Mehr von Gluster.org (20)

Automating Gluster @ Facebook - Shreyas Siravara
Automating Gluster @ Facebook - Shreyas SiravaraAutomating Gluster @ Facebook - Shreyas Siravara
Automating Gluster @ Facebook - Shreyas Siravara
 
nfusr: a new userspace NFS client based on libnfs - Shreyas Siravara
nfusr: a new userspace NFS client based on libnfs - Shreyas Siravaranfusr: a new userspace NFS client based on libnfs - Shreyas Siravara
nfusr: a new userspace NFS client based on libnfs - Shreyas Siravara
 
Facebook’s upstream approach to GlusterFS - David Hasson
Facebook’s upstream approach to GlusterFS  - David HassonFacebook’s upstream approach to GlusterFS  - David Hasson
Facebook’s upstream approach to GlusterFS - David Hasson
 
Throttling Traffic at Facebook Scale
Throttling Traffic at Facebook ScaleThrottling Traffic at Facebook Scale
Throttling Traffic at Facebook Scale
 
GlusterFS w/ Tiered XFS
GlusterFS w/ Tiered XFS  GlusterFS w/ Tiered XFS
GlusterFS w/ Tiered XFS
 
Gluster Metrics: why they are crucial for running stable deployments of all s...
Gluster Metrics: why they are crucial for running stable deployments of all s...Gluster Metrics: why they are crucial for running stable deployments of all s...
Gluster Metrics: why they are crucial for running stable deployments of all s...
 
Up and Running with Glusto & Glusto-Tests in 5 Minutes (or less)
Up and Running with Glusto & Glusto-Tests in 5 Minutes (or less)Up and Running with Glusto & Glusto-Tests in 5 Minutes (or less)
Up and Running with Glusto & Glusto-Tests in 5 Minutes (or less)
 
Data Reduction for Gluster with VDO
Data Reduction for Gluster with VDOData Reduction for Gluster with VDO
Data Reduction for Gluster with VDO
 
Releases: What are contributors responsible for
Releases: What are contributors responsible forReleases: What are contributors responsible for
Releases: What are contributors responsible for
 
RIO Distribution: Reconstructing the onion - Shyamsundar Ranganathan
RIO Distribution: Reconstructing the onion - Shyamsundar RanganathanRIO Distribution: Reconstructing the onion - Shyamsundar Ranganathan
RIO Distribution: Reconstructing the onion - Shyamsundar Ranganathan
 
Gluster and Kubernetes
Gluster and KubernetesGluster and Kubernetes
Gluster and Kubernetes
 
Native Clients, more the merrier with GFProxy!
Native Clients, more the merrier with GFProxy!Native Clients, more the merrier with GFProxy!
Native Clients, more the merrier with GFProxy!
 
Gluster: a SWOT Analysis
Gluster: a SWOT Analysis Gluster: a SWOT Analysis
Gluster: a SWOT Analysis
 
GlusterD-2.0: What's Happening? - Kaushal Madappa
GlusterD-2.0: What's Happening? - Kaushal MadappaGlusterD-2.0: What's Happening? - Kaushal Madappa
GlusterD-2.0: What's Happening? - Kaushal Madappa
 
Scalability and Performance of CNS 3.6
Scalability and Performance of CNS 3.6Scalability and Performance of CNS 3.6
Scalability and Performance of CNS 3.6
 
What Makes Us Fail
What Makes Us FailWhat Makes Us Fail
What Makes Us Fail
 
Gluster as Native Storage for Containers - past, present and future
Gluster as Native Storage for Containers - past, present and futureGluster as Native Storage for Containers - past, present and future
Gluster as Native Storage for Containers - past, present and future
 
Heketi Functionality into Glusterd2
Heketi Functionality into Glusterd2Heketi Functionality into Glusterd2
Heketi Functionality into Glusterd2
 
Hands On Gluster with Jeff Darcy
Hands On Gluster with Jeff DarcyHands On Gluster with Jeff Darcy
Hands On Gluster with Jeff Darcy
 
Architecture of the High Availability Solution for Ganesha and Samba with Kal...
Architecture of the High Availability Solution for Ganesha and Samba with Kal...Architecture of the High Availability Solution for Ganesha and Samba with Kal...
Architecture of the High Availability Solution for Ganesha and Samba with Kal...
 

Kürzlich hochgeladen

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 

Gsummit apis-2012

  • 2. Libgfapi Basics  Do some things manually that glusterfs[d] does in main() • Create a context • Load a volfile into that context • Set up logging, etc.  Issue individual calls using glfs_xxx • e.g. glfs_open, glfs_write
  • 3. Libgfapi CodeExample glfs_t *fs = NULL; int ret = 0; fs = glfs_new ("iops"); if (!fs) { return 1; } ret = glfs_set_volfile_server (fs, "tcp", "localhost", 24007); ret = glfs_set_logging (fs, "/dev/stderr", 7); ret = glfs_init (fs); fd = glfs_creat (fs, filename, O_RDWR, 0644);
  • 4. Libgfapi inPython vol = Volume("localhost",volid) vol.set_logging("/dev/null",7) vol.mount() def test_create (vol, mypath, data): fd = vol.creat(mypath,os.O_WRONLY|os.O_EXCL,0644) if not fd: print "creat error" return False rc = fd.write(data) if rc != len(data): print "wrote %d/%d bytes" % (rc, len(data)) return False return True
  • 5. Translator Basics  Addfunctionalityfromsimplestorage“bricks” touser (at treeroot) FUSE DHT AFR-1 Client-3Client-1 AFR-0 Client-2Client-0
  • 6. Translator Environment  All writtenin“PlainOldC” - thankyou, Dennis  STACK_WINDtocall “down” (towardstorage) at thebeginningof a request  STACK_UNWINDtocall “up” (towarduser) at theendof arequest  General filesystem-relatedfunctions • get/set context oninodesandfds, dictionaries, …  Utilityfunctions • memoryallocation, stringhandling, logging, … • moreabout thislater
  • 7. HereBeDragons  All callsareasynchronous • ContinuationPassingStyle, node.js, etc.  Youlosecontrol whenyoucall upor down  Youregaincontrol viacallback 1267 STACK_WIND (frame, dht_unlink_cbk, 1268 cached_subvol, cached_subvol->fops->unlink, 1269 &local->loc); 1270 1271 return 0; callback pointer world might have changed
  • 8. PrivateContext  Accessedviaframe->local  Availabletobothoriginal dispatchfunctionandcallback, soit'svery handy  Canbeanystructureyouwant (void*)  Youareresponsiblefor allocatingit, but freedautomatically(if non- null) alongwiththeframe  Trickyobject-lifecyclerulesarearecurringtheme(e.g. sameissues withdictionaries)
  • 9. Request Types  Mostlywhat you'dexpect fromPOSIXor LinuxVFS • open, close, readv, writev, stat, … • …but watchout e.g. for separatelookupfunction  Most operateonfiledescriptorsor inodes • sometimesboth, e.g. fstat vs. stat  All haverequest-specificarguments • paths, modes, flags, data(of course) • hint: usedefault_xxxasatemplatefor eachxxxyouimplement
  • 10. Dictionaries  String-valuedkeyplusarbitraryvalue  Usedfor translator options, andalsoasargumentsfor some requests(e.g. getxattr)  Lotsof functionstoset different kindsof values • ints, strings(static/dynamic), binaryblobs  Enumerationviadict_foreach  Bothdictionaries(dict_t) anddataitems(data_t) haverefcounts
  • 11. Persistent object context  Inode(inode_t) andfiledescriptor (fd_t)  Treat translator askey, arbitraryvalue • settingvaluealsotriggersforget/releasecallbackwhentheobject itself is destroyed inode_ctx_put (inode, xlator, value) inode_ctx_get (inode, xlator, &value) inode_ctx_del (inode, xlator, &value) fd_ctx_set (fd, xlator, value) fd_ctx_get (fd, xlator, &value) fd_ctx_del (fd, xlator, &value)
  • 12. Translator CodeExample int32_t negative_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) { ... gf_log(this->name,GF_LOG_DEBUG,"%s/%s => MISS", uuid_utoa(loc->gfid), loc->name); gp = GF_CALLOC(1,sizeof(ghost_t),gf_negative_mt_ghost); if (gp) { uuid_copy(gp->gfid,loc->pargfid); gp->name = gf_strdup(loc->name); } STACK_WIND_COOKIE (frame, negative_lookup_cbk, gp, FIRST_CHILD(this), FIRST_CHILD(this)->fops->lookup, loc, xdata); return 0; }
  • 13. Glupy Normal xlator Glupy “shim” User's code gluster.py Normal xlator
  • 14. GlupyCodeExample def create_fop (self, frame, this, loc, flags, mode, umask, fd, xdata): pargfid = uuid2str(loc.contents.pargfid) print "create FOP: %s:%s" % (pargfid, loc.contents.name) key = dl.get_id(frame) self.requests[key] = (pargfid, loc.contents.name[:]) dl.wind_create(frame,POINTER(xlator_t)(), loc,flags,mode,umask,fd,xdata) return 0