DOC PREVIEW
Duke CPS 296.1 - Lecture

This preview shows page 1-2 out of 5 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

2/9/20101Remote Batch Invocation for Compositional Object ServicesCPS 296.19thFeb 2010Vamsidhar ThummalaContent borrowed from William R CookStandard Approach to Distribution` Step I: Design a language` Clean Interfaces, modules` Step 2: Add library for distribution` Remote procedure calls` Stub that send calls remotely` Distributed objects` C, C++, ML` RMI` CORBA` DCOM` Proxies: pointer to remote object` Create proxies on demand` End Result` Clean, elegant, orthogonal` Is it the case for Persistence too?` Example in later slides` Cons?` PerformanceExample: Music Jukebox in the Cloud` Remote service which can play music on your home speakers` Fine-grained interface` OO designinterface Music {Album[] getAlblums();…..}interface Alblum {String getTitle();void play();int rating();….}Remote Procedure Calls (RPC)int minimumRating = 4;Music musicService = ... ;for (Album album : musicService.getAlbums()) {if (album.rating() > minimumRating) {System.out.println("Played: " +album.rating() + " " +g()album.getTitle());album.play();} else {System.out.println("Skipped: " +album.getTitle());}}RPC behind the scenes Result: Too many RPC callsint minimumRating = 4;Music musicService = ... ;for (Album album : musicService.getAlbums()) {if (album.rating() > minimumRating) {System.out.println("Played: " +album.rating() + " " +g()album.getTitle());album.play();} else {System.out.println("Skipped: " +album.getTitle());}}n: number of albumsworst case: 4n + 1 remote calls2/9/20102Current approaches` Data Transfer Objects and Server Façade` Move data in bulk` Specialize to particular sequence of client calls` Document-oriented Web Services` Stateless servers` TCP-based command line interfaces` POP, IMAP, FTP, HTTP, etc...` End result` Messy, non-compositional, rigid … fastData Transfer Objectclass TitleAndRatingAndCond implements Serializable {public String getTitle() { ... }public int getRating() { ... }public boolean getCond() { ... }pg(){}}Remote Facadeinterface MusicFacade{TitleAndRatingAndCond[]TitleAndRatingAndCond[]playHighRatedAlbums(int minRating);...}Remote Façade and Data Transfer Objectsint minimumRating = 4;MusicFacade musicService = ... ;TitleAndRatingAndCond[] results =musicService.playHighRatedAlbums(minimumRating);for (TitleAndRating result : results) {if (result.getCond()) {(g()){System.out.println("Played: " +result.getRating() + " " +result.getTitle());} else {System.out.println("Skipped: " + album.getTitle());}}What are the problem with DTO and Remote Façade? ` Tight coupling with objects/code` Not service-oriented` Can result in ` under-approximation ` Multiple calls to server Client needs to print title of two different albums` over approximation` Single call to serverRemote Batch Invocation (RBI) - Insight` We have an incorrect assumption:` Distribution can be solved in existing languages without any changes` Goals` Fine-grained interfaces` Execute many remote operations in bulk` Create Facades and Transfer objects automatically2/9/20103Remote Batch Invocation (RBI)int minimumRating = 4;Service service = ... ;batch (Music musicService : service) {for (Album album : musicService.getAlbums())final Artist = musicService.addArtist(“John”);if (album.rating() > minimumRating) {System out println("Played:"+System.out.println( Played: +album.rating() + " " +album.getTitle());album.play();} else {System.out.println("Skipped: " + album.getTitle());}}}Generated Façade by Partitioningint minimumRating = 4;Service service = ... ; Music musicService = ...;for (Album a : musicService.getAlbums())if (a.rating() > minimumRating) {// GET rating, titlealbum.play();} else {}Remote}for (????) {if (???) {System.out.println("Played: " +rating + " " +title);} else {System.out.println("Skipped: " + title);}}LocalGenerated Codeint minimumRating = 4;Service service = ... ; Music musicService = ...;List<TitleAndRatingAndCond> results = new...;for (Album a : musicService.getAlbums())if (a.rating() > minimumRating) {results.add(new TitleAndRatingAndCond(a.rating(), album.getTitle(), true));album.play();} else {results add(newTitleAndRatingAndCond(0 null false);Remoteresults.add(new TitleAndRatingAndCond(0, null, false);}for (TitleAndRatingAndCond result : results) {if (result.getCond()) {System.out.println("Played: " +result.getRating() + " " +result.getTitle());} else {System.out.println("Skipped: " +result.getTitle();}}LocalRemote Batch Invocation` Clean server interface, decoupled clients` Fine-grained interfaces` Automatic bulk data transfer and facades` Only primitive values can be transferred between clients and server` No stubs, No proxies!`One round-trip per lexical batch block`One roundtrip per lexical batch block` Two kinds of exceptions:` Remote exceptions` Does the paper handle them? Not gracefully` Proposed solution: transactional memory on server Does this violate service-oriented (stateless) principle?` Network exceptions (reduced!)What can be executed remotely?` Sequences and Composition` batch (r) { r.foo(); r.foo().bar().getName(); }` Loops and Conditions` batch (music) {for (Album a : music.getAlbums() )if (a.rating() > 5)print( a.getName() + “: ” + a.rating() ); }What cannot be executed remotely?` Constructor calls` Casts` While loops` Assignments`Exceptions`Exceptions` Are these Java compiler specific?` What is the main drawbacks?` Think of SQL` Aggregate over collections cannot be done remotely2/9/20104RBI pros & cons – Memory model` Only transfer primitive values` No proxies (remote pointers)` Server can be stateless, “service oriented”` rbi.Service musicService = new rbi.Service(“MusicCloud”, Music.class);` What about iterative computation?` No distributed garbage collection` Serialization through public interfacesbatch (remote) {RemoteSet r = remote.makeSet();for (int elem : localSet().items() )r.add( elem );....}` Is it legal to set RemoteSet r = localSet?` Use public setters and getters` Need reusable helper functions/coercionsRBI pros & cons – Execution model` Client` Language support` How easy/hard is to add support to “batch” in PL?` final keyword` What about order of execution?` What is the output of the below code?StringBuilder sb = new StringBuilder();sb.append("My Album");batch(Music music : musicService) {m(sb);music.createAlbum("1", sb);}...void m(StringBuilder sb) { sb.append(": Blues"); }RBI pros & cons – Execution model` Client` Language support` How easy/hard is to add support to “batch” in PL?` final keyword` What


View Full Document

Duke CPS 296.1 - Lecture

Documents in this Course
Lecture

Lecture

18 pages

Lecture

Lecture

6 pages

Lecture

Lecture

13 pages

Load more
Download Lecture
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?