the following viewgraphs about ridl from: d: a framework for distributed programming
DESCRIPTION
The following viewgraphs about RIDL from: D: A Framework for Distributed Programming. Cristina Videira Lopes. Implementation of the functional specs. public class Shape { protected double x_= 0.0, y_= 0.0; protected double width_=0.0, height_=0.0; double get_x() { return x_(); } - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/1.jpg)
The following viewgraphs about RIDL from:
D: A Framework for Distributed Programming
Cristina Videira Lopes
![Page 2: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/2.jpg)
public class Shape { protected double x_= 0.0, y_= 0.0; protected double width_=0.0, height_=0.0;
double get_x() { return x_(); } void set_x(int x) { x_ = x; } double get_y() { return y_(); } void set_y(int y) { y_ = y; } double get_width(){ return width_(); } void set_width(int w) { width_ = w; } double get_height(){ return height_(); } void set_height(int h) { height_ = h; } void adjustLocation() { x_ = longCalculation1(); y_ = longCalculation2(); } void adjustDimensions() { width_ = longCalculation3(); height_ = longCalculation4(); }
}
Nice functionalencapsulation
Implementation of thefunctional specs
Make itdistributed…
m
eth
ods
state
![Page 3: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/3.jpg)
public class Shape implements ShapeI { protected AdjustableLocation loc; protected AdjustableDimension dim; public Shape() { loc = new AdjustableLocation(0, 0); dim = new AdjustableDimension(0, 0); } double get_x() throws RemoteException { return loc.x(); } void set_x(int x) throws RemoteException { loc.set_x(); } double get_y() throws RemoteException { return loc.y(); } void set_y(int y) throws RemoteException { loc.set_y(); } double get_width() throws RemoteException { return dim.width(); } void set_width(int w) throws RemoteException { dim.set_w(); } double get_height() throws RemoteException { return dim.height(); } void set_height(int h) throws RemoteException { dim.set_h(); } void adjustLocation() throws RemoteException { loc.adjust(); } void adjustDimensions() throws RemoteException { dim.adjust(); }
}
interface ShapeI extends Remote { double get_x() throws RemoteException ; void set_x(int x) throws RemoteException ; double get_y() throws RemoteException ; void set_y(int y) throws RemoteException ; double get_width() throws RemoteException ; void set_width(int w) throws RemoteException ; double get_height() throws RemoteException ; void set_height(int h) throws RemoteException ; void adjustLocation() throws RemoteException ; void adjustDimensions() throws RemoteException ;
}class AdjustableLocation { protected double x_, y_; public AdjustableLocation(double x, double y) { x_ = x; y_ = y; } synchronized double get_x() { return x_; } synchronized void set_x(int x) {x_ = x;} synchronized double get_y() { return y_; } synchronized void set_y(int y) {y_ = y;} synchronized void adjust() { x_ = longCalculation1(); y_ = longCalculation2(); }
}class AdjustableDimension { protected double width_=0.0, height_=0.0; public AdjustableDimension(double h, double w) { height_ = h; width_ = w; } synchronized double get_width() { return width_; } synchronized void set_w(int w) {width_ = w;} synchronized double get_height() { return height_; } synchronized void set_h(int h) {height_ = h;} synchronized void adjust() { width_ = longCalculation3(); height_ = longCalculation4(); }
}
![Page 4: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/4.jpg)
public class Shape implements ShapeI { protected AdjustableLocation loc; protected AdjustableDimension dim; public Shape() { loc = new AdjustableLocation(0, 0); dim = new AdjustableDimension(0, 0); } double get_x() throws RemoteException { return loc.x(); } void set_x(int x) throws RemoteException { loc.set_x(); } double get_y() throws RemoteException { return loc.y(); } void set_y(int y) throws RemoteException { loc.set_y(); } double get_width() throws RemoteException { return dim.width(); } void set_width(int w) throws RemoteException { dim.set_w(); } double get_height() throws RemoteException { return dim.height(); } void set_height(int h) throws RemoteException { dim.set_h(); } void adjustLocation() throws RemoteException { loc.adjust(); } void adjustDimensions() throws RemoteException { dim.adjust(); }
}
interface ShapeI extends Remote { double get_x() throws RemoteException ; void set_x(int x) throws RemoteException ; double get_y() throws RemoteException ; void set_y(int y) throws RemoteException ; double get_width() throws RemoteException ; void set_width(int w) throws RemoteException ; double get_height() throws RemoteException ; void set_height(int h) throws RemoteException ; void adjustLocation() throws RemoteException ; void adjustDimensions() throws RemoteException ;
}class AdjustableLocation { protected double x_, y_; public AdjustableLocation(double x, double y) { x_ = x; y_ = y; } synchronized double get_x() { return x_; } synchronized void set_x(int x) {x_ = x;} synchronized double get_y() { return y_; } synchronized void set_y(int y) {y_ = y;} synchronized void adjust() { x_ = longCalculation1(); y_ = longCalculation2(); }
}class AdjustableDimension { protected double width_=0.0, height_=0.0; public AdjustableDimension(double h, double w) { height_ = h; width_ = w; } synchronized double get_width() { return width_; } synchronized void set_w(int w) {width_ = w;} synchronized double get_height() { return height_; } synchronized void set_h(int h) {height_ = h;} synchronized void adjust() { width_ = longCalculation3(); height_ = longCalculation4(); }
}
![Page 5: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/5.jpg)
public class Shape implements ShapeI { protected AdjustableLocation loc; protected AdjustableDimension dim; public Shape() { loc = new AdjustableLocation(0, 0); dim = new AdjustableDimension(0, 0); } double get_x() throws RemoteException { return loc.x(); } void set_x(int x) throws RemoteException { loc.set_x(); } double get_y() throws RemoteException { return loc.y(); } void set_y(int y) throws RemoteException { loc.set_y(); } double get_width() throws RemoteException { return dim.width(); } void set_width(int w) throws RemoteException { dim.set_w(); } double get_height() throws RemoteException { return dim.height(); } void set_height(int h) throws RemoteException { dim.set_h(); } void adjustLocation() throws RemoteException { loc.adjust(); } void adjustDimensions() throws RemoteException { dim.adjust(); }
}
interface ShapeI extends Remote { double get_x() throws RemoteException ; void set_x(int x) throws RemoteException ; double get_y() throws RemoteException ; void set_y(int y) throws RemoteException ; double get_width() throws RemoteException ; void set_width(int w) throws RemoteException ; double get_height() throws RemoteException ; void set_height(int h) throws RemoteException ; void adjustLocation() throws RemoteException ; void adjustDimensions() throws RemoteException ;
}class AdjustableLocation { protected double x_, y_; public AdjustableLocation(double x, double y) { x_ = x; y_ = y; } synchronized double get_x() { return x_; } synchronized void set_x(int x) {x_ = x;} synchronized double get_y() { return y_; } synchronized void set_y(int y) {y_ = y;} synchronized void adjust() { x_ = longCalculation1(); y_ = longCalculation2(); }
}class AdjustableDimension { protected double width_=0.0, height_=0.0; public AdjustableDimension(double h, double w) { height_ = h; width_ = w; } synchronized double get_width() { return width_; } synchronized void set_w(int w) {width_ = w;} synchronized double get_height() { return height_; } synchronized void set_h(int h) {height_ = h;} synchronized void adjust() { width_ = longCalculation3(); height_ = longCalculation4(); }
}
thread synchronizationremote interaction
![Page 6: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/6.jpg)
The source of tangling
Alignment with classeswould be nice, but...
![Page 7: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/7.jpg)
The source of tangling
...issues cross-cutclasses
![Page 8: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/8.jpg)
During implementationseparate issues
are mixed together
During maintenance individualissues need to be
factored out of the tangled code
![Page 9: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/9.jpg)
D
Write this
public class Shape { protected double x_= 0.0, y_= 0.0; protected double width_=0.0, height_=0.0;
double get_x() { return x_(); } void set_x(int x) { x_ = x; } double get_y() { return y_(); } void set_y(int y) { y_ = y; } double get_width(){ return width_(); } void set_width(int w) { width_ = w; } double get_height(){ return height_(); } void set_height(int h) { height_ = h; } void adjustLocation() { x_ = longCalculation1(); y_ = longCalculation2(); } void adjustDimensions() { width_ = longCalculation3(); height_ = longCalculation4(); }}
coordinator Shape { selfex adjustLocation, adjustDimensions; mutex {adjustLocation, get_x, set_x, get_y, set_y}; mutex {adjustDimensions, get_width, get_height, set_width, set_height};}
portal Shape { double get_x() {} ; void set_x(int x) {}; double get_y() {}; void set_y(int y) {}; double get_width() {}; void set_width(int w) {}; double get_height() {}; void set_height(int h) {}; void adjustLocation() {}; void adjustDimensions() {};}
Instead of writing this
public class Shape implements ShapeI { protected AdjustableLocation loc; protected AdjustableDimension dim; public Shape() { loc = new AdjustableLocation(0, 0); dim = new AdjustableDimension(0, 0); } double get_x() throws RemoteException { return loc.x(); } void set_x(int x) throws RemoteException { loc.set_x(); } double get_y() throws RemoteException { return loc.y(); } void set_y(int y) throws RemoteException { loc.set_y(); } double get_width() throws RemoteException { return dim.width(); } void set_width(int w) throws RemoteException { dim.set_w(); } double get_height() throws RemoteException { return dim.height(); } void set_height(int h) throws RemoteException { dim.set_h(); } void adjustLocation() throws RemoteException { loc.adjust(); } void adjustDimensions() throws RemoteException { dim.adjust(); }}
class AdjustableLocation { protected double x_, y_; public AdjustableLocation(double x, double y) { x_ = x; y_ = y; } synchronized double get_x() { return x_; } synchronized void set_x(int x) {x_ = x;} synchronized double get_y() { return y_; } synchronized void set_y(int y) {y_ = y;} synchronized void adjust() { x_ = longCalculation1(); y_ = longCalculation2(); }}class AdjustableDimension { protected double width_=0.0, height_=0.0; public AdjustableDimension(double h, double w) { height_ = h; width_ = w; } synchronized double get_width() { return width_; } synchronized void set_w(int w) {width_ = w;} synchronized double get_height() { return height_; } synchronized void set_h(int h) {height_ = h;} synchronized void adjust() { width_ = longCalculation3(); height_ = longCalculation4(); }}
interface ShapeI extends Remote { double get_x() throws RemoteException ; void set_x(int x) throws RemoteException ; double get_y() throws RemoteException ; void set_y(int y) throws RemoteException ; double get_width() throws RemoteException ; void set_width(int w) throws RemoteException ; double get_height() throws RemoteException ; void set_height(int h) throws RemoteException ; void adjustLocation() throws RemoteException ; void adjustDimensions() throws RemoteException ;}
![Page 10: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/10.jpg)
Thesis• distribution concerns can be untangled from
functionality code by providing new composition mechanisms:– given by new and separate languages– smoothly integrated with OOPL– very low cost
• distributed programs are easier to write and understand
![Page 11: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/11.jpg)
Presentation
DFormal
semantics
Implementation
Programanalysis
Desig
n
Usa
bilit
y stu
dies
D
![Page 12: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/12.jpg)
Outline
• Overview
• D: Design
• D: Implementation
• Validation Results
• Conclusion
D
Implementation
Programanalysis
Des
ign
Usa
bilit
y stu
dies
D
![Page 13: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/13.jpg)
What is D• COOL: language for programming thread
synchronization
• RIDL: language for programming remote interaction and data transfers
• Cooperating with OOPL
OOPL
COOL RIDL
![Page 14: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/14.jpg)
Goals of D
• To decrease code tangling by dividing programs both in – units of functionality (components)– units of control over concurrency and
distribution (aspects)– (can’t do this well with OO…)
![Page 15: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/15.jpg)
Programming in D
classes
Cool aspect (already covered)
Ridl aspect
![Page 16: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/16.jpg)
RIDL• provides means for dealing with data
transfers between different execution spaces
op
Execution space 1
ot
Execution space 2
ot.m(op)?
Portals
![Page 17: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/17.jpg)
RIDL
• Identifies “good” abstractions for controlling remote interactions of OO programs– remote method calls– different parameter passing semantics– selective object copying– ...
Sources:Study of many distributed programs
![Page 18: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/18.jpg)
RIDL Book Locator / Printerclass Book { protected String title, author; protected int isbn; protected OCRImage firstpage; protected Postscript ps;}
class BookLocator { private Book books[]; private Location locations[]; public void register(Book b, Location l){ // Verify and add book b to database } public Location locate (String title) { Location loc; // Locate book and get its location return loc; }}
class Printer { public void print(Book b) { // Print the book }}
coordinator BookLocator { selfex register; mutex {register, locate};}
portal BookLocator { void register (Book book, Location l); Location locate (String title) default: Book: copy{Book only title, author, isbn;}}
portal Printer { void print(Book book) { book: copy { Book only title, ps; } }}
class Location { private String building;}
![Page 19: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/19.jpg)
Parameter Passing Modes
portal ANode { ANode get_right() { return: gref; }; void set_right(Anode r) { r: copy; };}
![Page 20: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/20.jpg)
Selective Marshaling
portal Printer { void print(Book book) { book: copy { Book only title, ps; } }}
class Book { protected String title, author; protected int isbn; protected OCRImage firstpage; protected Postscript ps;}
![Page 21: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/21.jpg)
Selective Marshaling
portal Library { BookCopy getBook(User u, String title) { return: copy {BookCopy bypass borrower, Book bypass copies;} u: copy {User bypass books;} } Book findBook(String title) { return: copy {Book bypass copies, ps;} }}
Library
User Book
BookCopy
booksusers
theBookborrower
* *
* *copiesbooks
![Page 22: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/22.jpg)
Programming with RIDL
object
portal
m(){…}
Protocol object/portal:
1
1: remote method invocation2: request presented to the portal
2
33: parameters extracted according to transfer specifications
4: request proceeds to the object4
5 5: method execution6: return is presented to portal
6
7
7: return value processed according to transfer specification
8
8: method returns; return value sent
![Page 23: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/23.jpg)
RIDL View of Classes• Stronger and more global visibility:
– portal can access:• all methods of its class, independent of access
control; all non-private methods of superclasses
• all variables of classes of parameters and of any objects that they contain
• Limited actions:– only read variables, not modify them– only define remote methods, not invoke them
![Page 24: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/24.jpg)
D Design Points
• provider defines synchronization
• smallest unit of synchronization is the method
• coordination contained within one coordinator
• association between coordinator and object is static
• provider defines remote interaction
• smallest unit of remote interaction is the method
• remote interaction contained within one portal
• association between portal and object is static
COOL RIDL
![Page 25: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/25.jpg)
D Design Principles
• Separation of concerns
• Enforcement of the separation
• Add-on integration with existing languages
![Page 26: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/26.jpg)
Demeter/Java with COOL and RIDL
• The two aspect languages of D
• Java as the component language– no overloading (constructors ok)– no synchronized qualifier/statement– no wait/notify methods– no “Remote” or “Serializable” interfaces
control of effort
semanticstrengthening
![Page 27: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/27.jpg)
Summary
• D is two languages, add-ons to an OOPL: – COOL for matters of thread synchronization– RIDL for matters of remote interaction
![Page 28: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/28.jpg)
Outline
• Overview
• D: Design
• D: Implementation
• Validation Results
• Conclusion
D
Implementation
Programanalysis
Des
ign
Usa
bilit
y stu
dies
D
![Page 29: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/29.jpg)
The Aspect Weaver
AspectWeaver
Tool that automates program transformations
![Page 30: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/30.jpg)
Target Architectures(the output code)
• Translation of aspect modules +Woven code in the classes +library
• Simplicity over optimization
• In a real tool: re-design these architectures!(must optimize)
![Page 31: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/31.jpg)
Programming with COOL
object
coordinator
m() {…}1
2
3
4
5
6
7
8
Semantics
object
coordinatorobject
m() {…}1
2 4
5
6
3
8
Implementation
3 7
Implementing COOL
![Page 32: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/32.jpg)
Programming with RIDL
Semantics
object
portal
m(){…}
1
2
3
4
5
6
7
8
Implementing RIDL
object
portalobject
m() {…}
1
2 4
5
68
3
Implementation
7
object’sproxy
portal’sproxy
![Page 33: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/33.jpg)
RIDL Protocol
aObj’
aObj
the “real” objectthe object’s proxy
aObjPP
Space 1(client of aObj)
Space 2
aObjP
the portal objectthe portal proxy
Traversals Traversals
RM I
RM I
R I D L
R I D L
APPLICATION LAYER
virtual referencereal reference
![Page 34: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/34.jpg)
Outline
• Overview
• D: Design
• D: Implementation
• Validation Results
• Conclusion
D
Implementation
Programanalysis
Des
ign
Usa
bilit
y stu
dies
D
![Page 35: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/35.jpg)
Thesis• distribution concerns can be untangled from
functionality code by providing new composition mechanisms:– given by new and separate languages– smoothly integrated with OOPL– very low cost
• distributed programs are easier to write and understand
![Page 36: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/36.jpg)
Results for DJ (Crista’s implementation of D)
• Case-studies– empirical study
– benefits of the design
• Performance– cost of implementation (target architectures)
• Alpha-usage– human understanding
– acceptance
![Page 37: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/37.jpg)
Case-Studies• 10 small applications
– two implementations: DJ and plain Java
• analysis: identification of aspect code– synchronized qualifier/statement– wait/notify– variables used for synchronization state– Remote interface / RemoteException– splitting parts design– ...
![Page 38: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/38.jpg)
Bounded Buffer
Case-studies
public class BoundedBuffer { private Object array[]; private int putPtr = 0, takePtr = 0; private int usedSlots=0;
public void put(Object o) { array[putPtr] = o; putPtr = (putPtr + 1) % array.length; usedSlots++; }
public Object take() { Object old = array[takePtr]; array[takePtr] = null; takePtr = (takePtr + 1) % array.length; usedSlots--; return old; }}
coordinator BoundedBuffer { selfex put, take; mutex {put, take}; cond full = false, empty = true; put: requires !full; on_exit { empty = false; if (usedSlots == array.length) full = true; } take: requires !empty; on_exit { full = false; if (usedSlots == 0) empty = true; }}
public class BoundedBuffer { private Object[] array; private int putPtr = 0, takePtr = 0; private int usedSlots = 0;
public synchronized void put(Object o) { while (usedSlots == array.length) { try { wait(); } catch (InterruptedException e) {}; } array[putPtr] = o; putPtr = (putPtr + 1) % array.length; } if (usedSlots++ == 0) notifyAll(); }
public synchronized Object take() { while (usedSlots == 0) { try { wait(); } catch (InterruptedException e) {}; } Object old = array[takePtr]; array[takePtr] = null; takePtr = (takePtr+1) % array.length; } if (usedSlots-- == array.length) notifyAll(); return old; }}
DJ Java
![Page 39: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/39.jpg)
LOCLines of Code
0 100 200 300 400 500
Bounded Buffer
Philosophers
Shape
Matrix Multiplication
Graph Traversal
Assembly Line
Locator/Printer
Text Editor
Document Service
Message Queue
LOC
Other
DJ
Case-studies
![Page 40: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/40.jpg)
Aspectual Bloat
aspectual bloat =LOC in Java - LOC in JCore
LOC in Cool+Ridl
Measures how poorly Java, without D, captures the aspect programs
Case-studies
![Page 41: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/41.jpg)
Aspectual BloatAspectual Bloat
0 1 2 3 4 5 6 7 8 9 10 11
Bounded Buffer
Philosophers
Shape
Graph Traversal
Assembly Line
Locator/Printer
Text Editor
Doc Service
Message Queue
Bloat
Other
Case-studies
![Page 42: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/42.jpg)
Tangling Ratio
tangling =
# of transition points
between aspect code and functionality code
LOC
Measures intermingling, dispersion
Case-studies
![Page 43: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/43.jpg)
Tangling RatioTangling (%)
0 10 20 30 40 50 60 70 80
Bounded Buffer
Philosophers
Shape
Matrix Multiplication
Graph Traversal
Assembly Line
Locator/Printer
Text Editor
Doc Service
Message Queue
Other
DJ
Case-studies
![Page 44: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/44.jpg)
Observations
• D effectivelly separates aspect code from classes and localizes it in coordinators and portals.
• Aspect programs in D, in many cases, are shorter; never more lengthy.
• DJ versions, in many cases, are smaller; never bigger.
![Page 45: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/45.jpg)
PerformanceCOOL
DJ Java
1000 method invocations per thread
Single thread callinga selfex method:
Single thread callinga synchronized method: 28ms 7ms
Two threads calling thesame selfex method:
Two threads callingthe same synchronized method:
90ms 30ms
Two threads calling 2methods with requires, on_exit:
Two threads, calling 2 methods with wait, notification:
13s 12s
![Page 46: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/46.jpg)
Performance
DJ Java
1000 method invocationsRIDL
no parameters: no parameters:10s 10s
one gref parameter: one parameter of type Remote:24s 24s
one copy parameter(object with 4 Integer fields):
one parameter Serializable(object with 4 Integer fields):
26s 30s
copying directive thatselects 3 out of 4 Integerfields of a parameter:
parameter with 3 Integer fields that is partially copied from an object of another class:35s 28s
![Page 47: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/47.jpg)
Observations
• DJ’s performance is within Java’s performance
![Page 48: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/48.jpg)
Alpha-Usage• Four programmers wrote two medium-size
applications: space war, distributed library
• Learning, designing, programming:2 months
• A different AW implemented at PARC by Mendhekar, Loingtier, Lamping, Kiczales• Experiment conducted by Murphy
![Page 49: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/49.jpg)
Applications
• Distributed Space War– 1500 LOC, 19 classes, 2 coordinators, 4 portals
• Distributed Library– 1200 LOC, 13 classes, 3 coordinators, 4 portals
![Page 50: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/50.jpg)
Observations
• Users found COOL and RIDL easy to use
• No difficulty in understanding effect of aspect code on components
• Aspect languages eased burden of programming some distribution issues (E.g. using RMI)
• Cannot expect aspect modules to capture intent
![Page 51: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/51.jpg)
Outline
• Overview
• D: Design
• D: Implementation
• Validation Results
• Conclusion
![Page 52: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/52.jpg)
Contributions• Support for programming thread synchronization
and remote data transfers separately from the implementation of the components
• Enforcement of separation
• Systematic and simple division of labor
• Basis for better documentation
• Implementation: DJ
![Page 53: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/53.jpg)
Directions in Language Design
• Methodological study of code tangling
• New kinds of interfaces between modules not of the type client/provider, but useful for structuring programs
• Add-on aspect languages; no modifications or extensions to component language
![Page 54: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/54.jpg)
Future Work• Improve/extend existing languages
– replication– timeouts– relation between aspect modules– add more imperative features?– error handling
• New aspects, new aspect languages
![Page 55: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/55.jpg)
EOP
![Page 56: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/56.jpg)
Outline
• Overview
• Code Tangling / Aspect Identification
• D: Design
• D: Implementation
• Validation Results
• Conclusion
• Demo
![Page 57: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/57.jpg)
public class Shape implements ShapeI { protected AdjustableLocation loc; protected AdjustableDimension dim; public Shape() { loc = new AdjustableLocation(0, 0); dim = new AdjustableDimension(0, 0); } double get_x() throws RemoteException { return loc.x(); } void set_x(int x) throws RemoteException { loc.set_x(); } double get_y() throws RemoteException { return loc.y(); } void set_y(int y) throws RemoteException { loc.set_y(); } double get_width() throws RemoteException { return dim.width(); } void set_width(int w) throws RemoteException { dim.set_w(); } double get_height() throws RemoteException { return dim.height(); } void set_height(int h) throws RemoteException { dim.set_h(); } void adjustLocation() throws RemoteException { loc.adjust(); } void adjustDimensions() throws RemoteException { dim.adjust(); }}
class AdjustableLocation { protected double x_, y_; public AdjustableLocation(double x, double y) { x_ = x; y_ = y; } synchronized double get_x() { return x_; } synchronized void set_x(int x) {x_ = x;} synchronized double get_y() { return y_; } synchronized void set_y(int y) {y_ = y;} synchronized void adjust() { x_ = longCalculation1(); y_ = longCalculation2(); }}class AdjustableDimension { protected double width_=0.0, height_=0.0; public AdjustableDimension(double h, double w) { height_ = h; width_ = w; } synchronized double get_width() { return width_; } synchronized void set_w(int w) {width_ = w;} synchronized double get_height() { return height_; } synchronized void set_h(int h) {height_ = h;} synchronized void adjust() { width_ = longCalculation3(); height_ = longCalculation4(); }}
interface ShapeI extends Remote { double get_x() throws RemoteException ; void set_x(int x) throws RemoteException ; double get_y() throws RemoteException ; void set_y(int y) throws RemoteException ; double get_width() throws RemoteException ; void set_width(int w) throws RemoteException ; double get_height() throws RemoteException ; void set_height(int h) throws RemoteException ; void adjustLocation() throws RemoteException ; void adjustDimensions() throws RemoteException ;}
Questions:
What exactly are these?
Why are they here?
How can we remove them?Make them more localized?
![Page 58: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/58.jpg)
Book locator service specifications:
• register book b in location l• unregister book b• locate book given title• concurrent accesses• network service
How programs become tangled:an example
![Page 59: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/59.jpg)
How programs become tangled:an example
Implementing the functionality:
public class BookLocator { private Book books[]; private Location locations[]; private int nbooks = 0; // the constructor public BookLocator (int dbsize) { books = new Book[dbsize]; locations = new Location[dbsize]; } public void register (Book b, Location l) throws LocatorFull { if (nbooks > books.length) throw new LocatorFull(); else { // Just put it at the end books[nbooks] = b; locations[nbooks++] = l; } } public void unregister (Book b) { // find the book and take it out of books[] --nbooks; } public Location locate (String title) throws BookNotFound { Book abook = books[0]; int i = 0; boolean found = false; while (i < nbooks && found == false) { if (abook.get_title().compareTo(str) == 0 ) found = true; else abook = books[++i]; } if (found == false) throw new BookNotFound (str); return locations[i]; }}
public class Book { public String title, author; public int isbn; Project owner; Postscript ps;
public Book (String t, String a, int n) { title = t; author = a; isbn = n; } // other methods...}
public class Location { public int building, room; public Location (int bn, int rn) { building = bn; room = rn; } // other methods...}
![Page 60: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/60.jpg)
How programs become tangled:an example
Book locator service implementation:
• register book b in location l• unregister book b• locate book given title• concurrent accesses• network service
![Page 61: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/61.jpg)
How programs become tangled:an example
Synchronizing concurrent accesses:
public class BookLocator { private Book books[]; private Location locations[]; private int nbooks = 0; // the constructor public BookLocator (int dbsize) { books = new Book[dbsize]; locations = new Location[dbsize]; } public void register (Book b, Location l) throws LocatorFull { if (nbooks > books.length) throw new LocatorFull(); else { // Just put it at the end books[nbooks] = b; locations[nbooks++] = l; } } public void unregister (Book b) { // find the book and take it out of books[] --nbooks; } public Location locate (String title) throws BookNotFound { Book abook = books[0]; int i = 0; boolean found = false; while (i < nbooks && found == false) { if (abook.get_title().compareTo(str) == 0 ) found = true; else abook = books[++i]; } if (found == false) throw new BookNotFound (str); return locations[i]; }}
register, unregister (writers): disable all
locate (reader): disable register, unregister
![Page 62: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/62.jpg)
public class BookLocator { private Book books[]; private Location locations[]; private int nbooks = 0;
protected int activeReaders = 0, activeWriters = 0; // the constructor public BookLocator (int dbsize) { books = new Book[dbsize]; locations = new Location[dbsize]; }
public void register (Book b, Location l) throws LocatorFull { synchronized (this) { while (activeReaders > 0 || activeWriters > 0) try { wait(); } catch (InterruptedException e) {} ++activeWriters; } if (nbooks > books.length) throw new LocatorFull(); else { // Just put it at the end books[nbooks] = b; locations[nbooks++] = l; }
synchronized (this) {--activeWriters; notifyAll();} } // similar for unregister public Location locate (String title) throws BookNotFound { Location l; synchronized (this) { while (activeWriters > 0) try { wait(); } catch (InterruptedException e) {} ++activeReaders; } Book abook = books[0]; int i = 0; boolean found = false; while (i < nbooks && found == false) { if (abook.get_title().compareTo(str) == 0 ) found = true; else abook = books[++i]; } if (found == false) {
synchronized (this) {--activeReaders; notifyAll();} throw new BookNotFound (str);}
l = locations[i]; synchronized (this) {--activeReaders; notifyAll();} return l; }}
How programs become tangled:an example
Synchronizing concurrent accesses:
![Page 63: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/63.jpg)
How programs become tangled:an example
Book locator service implementation:
• register book b in location l• unregister book b• locate book given title• concurrent accesses• network service
![Page 64: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/64.jpg)
How programs become tangled:an example
Providing fornetwork access and remote data transfers:
public interface Locator extends Remote { void register(String title, int isbn, Location l) throws RemoteException; void unregister(String t) throws RemoteException; Location locate(String title) throws RemoteException;}
public class BookLocator implements Locator extends UnicastRemoteObject{ private Book books[]; private Location locations[]; private int nbooks = 0;
protected int activeReaders = 0, activeWriters = 0; public BookLocator (int dbsize) { books = new Book[dbsize]; locations = new Location[dbsize]; }
public void register(String title, int isbn, Location l) throws LocatorFull, RemoteException { synchronized (this) { while (activeReaders > 0 || activeWriters > 0) try { wait(); } catch (InterruptedException e) {} ++activeWriters; } if (nbooks > books.length) throw new LocatorFull(); else { // Just put it at the end books[nbooks] = b; locations[nbooks++] = l; }
synchronized (this) {--activeWriters; notifyAll();} } public void unregister(String title) throws RemoteException { /* … */ } public Location locate (String title) throws BookNotFound, RemoteException { /* … */ }}
![Page 65: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/65.jpg)
Two Issues
• Synchronization of threads
• Remote access and data transfers
![Page 66: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/66.jpg)
The source of tangling
We would likealignment with classes
![Page 67: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/67.jpg)
The source of tangling:cross-cutting issues
![Page 68: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/68.jpg)
Code tangling is bad
• Harms program structure
• Distracts from main functionality
• Hard to program, error-prone
• Code difficult to understand, maintain
![Page 69: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/69.jpg)
Ways to decrease the tangling
• Style guidelines
• Coding rules
• Design patterns
• Better programming languages
![Page 70: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/70.jpg)
orthogonal approach seems to be promisingsome languages have tried this approach beforeD builds on top of all that previous work
Ways to decrease the tangling:better programming languages
![Page 71: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/71.jpg)
COOL Assembly Line
CandyMaker
CandyMaker
Packer Finalizer
LaberMaker
DJcandy
newCandynewPack
newLabelDJcandy
newCandyPack
processPack glueLabelToPack
![Page 72: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/72.jpg)
COOL Assembly Linecoordinator Packer, Finalizer { selfex Packer.newCandy; cond packDone = false, packFull = false; cond gotPack = false, gotLabel = false;
Packer.newPack: on_exit{packDone = true;} Packer.newCandy: requires !packFull && packDone; on_exit { if (nCandy == nCandyPerPack) packFull = true; } Packer.processPack: requires packFull; Finalizer.newPack: requires !gotPack; on_exit { gotPack = true; packFull = false; packDone = false; } Finalizer.newLabel: requires !gotLabel; on_exit { gotLabel = true; } Finalizer.glueLabelToPack: requires gotPack && gotLabel; Finalizer.newCandyPack: on_exit { gotPack = false; gotLabel = false; }}
![Page 73: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/73.jpg)
COOL Syntaxcooldef : [ perclass | perobject ] coord class_list { autoex method_list; mutex{method_list}; * type var [ = value]; * cond [ perobject | perclass ] condvar = true | false ; * met hod_list: requires ( boolean_expr ) [orwait t] on_entry { cool_stmt *} * on_exit { cool_stmt *} };cool_stmt : condvar = true | false ; | var = value; |
if (boolean_expr) cool_ stmt [else cool_ stmt ]
![Page 74: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/74.jpg)
RIDL Document ServiceDocService
userslogsdocs
addDocument(doc)addUser(name, passwd)search(title, user) returns a documentgetLogs(user) returns the user’s logs
Log
dateuserdoc
User
uidnamepasswdlogs
Document
titleauthorsummarylogs
*
*
*
*
![Page 75: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/75.jpg)
RIDL Document ServiceDocService
userslogsdocs
addDocument(doc)addUser(name, passwd)search(title, user) returns a documentgetLogs(user) returns the user’s logs
Log
dateuserdoc
User
uidnamepasswdlogs
Document
titleauthorsummarylogs
*
*
*
*
![Page 76: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/76.jpg)
RIDL Document ServiceDocService
userslogsdocs
addDocument(doc)addUser(name, passwd)search(title, user) returns a documentgetLogs(user) returns the user’s logs
Log
dateuserdoc
User
uidnamepasswdlogs
Document
titleauthorsummarylogs
*
*
*
*
![Page 77: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/77.jpg)
RIDL Document Serviceportal DocService { boolean addDocument(Document doc); Integer addUser(String name Integer passwd); Document search(String title, Integer uid, Interger passwd){ return: copy { Document bypass logs; } }; DVector getUserLogs(Integer uid, Integer passwd){ return: copy { Document bypass logs; User bypass logs, passwd; } };}
![Page 78: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/78.jpg)
COOL Design
• provider (i.e. the class) defines the synchronization (monitor approach)
• smallest unit of synchronization is the method• no middle ground between one instance and all
instances of classes• coordination is contained within one coordinator• association between an object and its coordinator
is static
![Page 79: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/79.jpg)
RIDL Design• provider (i.e. the class) defines the remote
interaction• smallest unit for remote interaction is the method• parameter passing semantics …• remote interaction is contained within one portal• association between an object and its portal is
static• no multi-class portals
![Page 80: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/80.jpg)
Implementing RIDL
Semantics
object
portal
m(){…}
1
2
3
4
5
6
7
8
Implementation
object
portalobject
m() {…}
1
2 4
5
68
37
object’sproxy
portal’sproxy
![Page 81: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/81.jpg)
RIDLportal BookLocator { void register (Book book, Location l); Location locate (String title) default: Book: copy{Book only title, author, isbn;}}
class BookLocator { private Book books[]; private Location locations[]; public void register(Book b, Location l){ // Verify and add book b to database } public Location locate (String title) { Location loc; // Locate book and get its location return loc; }}
![Page 82: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/82.jpg)
RIDL Protocol
aObj’
aObj
the “real” objectthe object’s proxy
aObjPP
Space 1(client of aObj)
Space 2
aObjPthe portal object
the portal proxy
Traversals Traversals
RM I
RM I
R I D L
R I D L
APPLICATION LAYER
virtual referencereal reference
![Page 83: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/83.jpg)
D’s Remote Objectsclass BookLocator { BookLocatorP _p; // portal object BookLocatorPP _pp = null; // portal proxy BookLocator(BookLocatorPP proxy) { _pp = proxy; } BookLocator(...) { _p = new BookLocatorP(this);}
protected void _d_register(Book b, Location l) { original implementation of f }
void register(BookLocator b, Location l) { if (_pp != null) // this is a proxy _pp.register(b, l); else // this is a real object _d_register(b, l); } // similar for locate}
![Page 84: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/84.jpg)
D’s Remote Objectsclass BookLocator { BookLocatorP _p; // portal object BookLocatorPP _pp = null; // portal proxy BookLocator(BookLocatorPP proxy) { _pp = proxy; } BookLocator(...) { _p = new BookLocatorP(this);}
protected void _d_register(Book b, Location l) { original implementation of f }
void register(BookLocator b, Location l) { if (_pp != null) // this is a proxy _pp.register(b, l); else // this is a real object _d_register(b, l); } // similar for locate}
![Page 85: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/85.jpg)
D’s Remote Objectsclass BookLocator { BookLocatorP _p; // portal object BookLocatorPP _pp = null; // portal proxy BookLocator(BookLocatorPP proxy) { _pp = proxy; } BookLocator(...) { _p = new BookLocatorP(this);}
protected void _d_register(Book b, Location l) { original implementation of f }
void register(BookLocator b, Location l) { if (_pp != null) // this is a proxy _pp.register(b, l); else // this is a real object _d_register(b, l); } // similar for locate}
![Page 86: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/86.jpg)
RIDL Protocol
aObj’
aObj
the “real” objectthe object’s proxy
aObjPP
Space 1(client of aObj)
Space 2
aObjPthe portal object
the portal proxy
Traversals Traversals
RM I
RM I
R I D L
R I D L
APPLICATION LAYER
virtual referencereal reference
![Page 87: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/87.jpg)
Portal objectsclass BookLocatorPP { BookLocatorPRI rself; BookLocatorPP(BookLocatorPRI o){ rself = o; } void register(Book b, Location l) { Dargument a1, a2; a1 = new Dargument(b, BookLocatorTraversals.t1); a2 = new Dargument(l, null); rself.register(a1, a2); // redirect } // similar for locate}
class BookLocatorP implements BookLocatorPRI { BookLocator myself; BookLocatorP(BookLocator o) { myself = o; } void register(Dargument a1, Dargument a2) { myself.register(a1.obj, a2.obj); }}
![Page 88: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/88.jpg)
Portal objectsclass BookLocatorPP { BookLocatorPRI rself; BookLocatorPP(BookLocatorPRI o){ rself = o; } void register(Book b, Location l) { Dargument a1, a2; a1 = new Dargument(b, BookLocatorTraversals.t1); a2 = new Dargument(l, null); rself.register(a1, a2); // redirect } // similar for locate}
class BookLocatorP implements BookLocatorPRI { BookLocator myself; BookLocatorP(BookLocator o) { myself = o; } void register(Dargument a1, Dargument a2) { myself.register(a1.obj, a2.obj); }}
![Page 89: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/89.jpg)
Portal objectsclass BookLocatorPP { BookLocatorPRI rself; BookLocatorPP(BookLocatorPRI o){ rself = o; } void register(Book b, Location l) { Dargument a1, a2; a1 = new Dargument(b, BookLocatorTraversals.t1); a2 = new Dargument(l, null); rself.register(a1, a2); // redirect } // similar for locate}
class BookLocatorP implements BookLocatorPRI { BookLocator myself; BookLocatorP(BookLocator o) { myself = o; } void register(Dargument a1, Dargument a2) { myself.register(a1.obj, a2.obj); }}
![Page 90: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/90.jpg)
RIDL Protocol
aObj’
aObj
the “real” objectthe object’s proxy
aObjPP
Space 1(client of aObj)
Space 2
aObjPthe portal object
the portal proxy
Traversals Traversals
RM I
RM I
R I D L
R I D L
APPLICATION LAYER
virtual referencereal reference
![Page 91: The following viewgraphs about RIDL from: D: A Framework for Distributed Programming](https://reader036.vdocuments.net/reader036/viewer/2022062519/568150cf550346895dbef3b8/html5/thumbnails/91.jpg)
Traversal objectsclass BookLocatorTraversals { public static Traversal t1; static boolean once = false; public static synchronized void init() { IncompleteClass c; if (once) return; t1 = new Traversal("t1", "BookLocatorTraversals"); c = new IncompleteClass("Book"); c.bypass("firstPage"); c.bypass("ps"); t1.incompleteClass(c); }}
portal BookLocator { void register (Book book, Location l); Location locate (String title) default: Book: copy{Book only title, author, isbn;}}