SlideShare a Scribd company logo
1 of 25
JVM Summit 2012



                                          Batches:
                                     Unifying RPC, WS
                                    and Database access
The University of Texas at Austin




                                                  William R. Cook
                                           University of Texas at Austin
                                                        with
                                      Eli Tilevich, Yang Jiao, Virginia Tech
                                    Ali Ibrahim, Ben Wiedermann, UT Austin
JVM Summit 2012
                                    Typical Approach to Distribution/DB
                                    1. Design a programming language
                                     Finalize specification, then...

                                    2. Implement distribution/queries as library
                                     RPC library, stub generator
                                     SQL library
The University of Texas at Austin




                                     Web Service library, wrapper generator




                                                                                   2
JVM Summit 2012
                                    Typical Approach to Distribution/DB
                                    1. Design a programming language
                                     Finalize specification, then...

                                    2. Implement distribution/queries as library
                                     RPC library, stub generator
                                     SQL library
The University of Texas at Austin




                                     Web Service library, wrapper generator

                                    3. Rejected and ignored by community
                                     CORBA, DCOM, RMI are complete disaster



                                                                                   3
JVM Summit 2012
                                             Using a Mail Service
                                    int limit = 500;
                                    for ( Message m : mailer.Messages )
                                       if ( m.Size > limit ) {
                                         print( m.Subject + “: “ + m.Sender.Name);
                                         m.delete();
The University of Texas at Austin




                                       }




                                                                                     4
JVM Summit 2012
                                             Using a Mail Service
                                    int limit = 500;
                                    for ( Message m : mailer.Messages )
                                       if ( m.Size > limit ) {
                                         print( m.Subject + “: “ + m.Sender.Name);
                                         m.delete();
The University of Texas at Austin




                                       }
                                                       Works great if mailer is  a
                                                   local object, but is terrible if 
                                                          mailer is remote




                                                                                       5
JVM Summit 2012
                                    Goals: Why not Have it All?
                                                                               A Note on 
                                    Low latency           One round trip       Distributed 
                                                                               Computing
                                    Stateless             No Proxies

                                    Platform independent No Serialization

                                    Clean Server APIs     No Data Transfer Object
The University of Texas at Austin




                                                          No Server Facade
                                                          No Superclass/type 
                                                             (e.g. java.rmi.Remote)




                                                                                              6
JVM Summit 2012
                                             Using a Mail Service
                                    int limit = 500;
                                    for ( Message m : mailer.Messages )
                                       if ( m.Size > limit ) {
                                         print( m.Subject + “: “ + m.Sender.Name);
                                         m.delete();                Separate local
The University of Texas at Austin




                                       }                           and remote code!




                                                                                      7
JVM Summit 2012                                                             for (m : ROOT.Messages) {
                                                                             if (m.Size > In(“A”)) {
                                                             Run remote        OUT(“B”, m.Subject); 
                                                             script first      OUT(“C”, m.Sender.Name);
                                                                               m.delete();
                                    int limit = 500;                         }
                                    Remote<Mailer> connection = ....;
                                                                                     B           C
                                    batch (Mailer mailer : connection) {       RE: testing Will Cook
                                      for ( Message m : mailer.Messages ) JVM Summit Dan Smith
The University of Texas at Austin




                                                                               ...         ...
                                        if ( m.Size > limit ) {
                                          print( m.Subject + “: “ + m.Sender.Name);
                                          m.delete();
                                              Remote<Mailer> connection = ....;
                                        }     Forest in = new Forest(“A”, limit);
                                              Forest mailer = connection.execute(script, in);
                                    }         for (m : mailer.getIteration(“m”))
                                                     print(m.getStr(“B”) + “: ” + m.getStr(“C”) );

                                                                                                          8
JVM Summit 2012
                                                   Batch Pattern
                                    Execution model: Batch Command Pattern
                                    1. Client sends script to the server
                                        (Creates Remote Façade on the fly)
                                    2. Server executes the script
                                    3. Server returns results in bulk (name, size)
The University of Texas at Austin




                                        (Creates Data Transfer Objects on the fly)
                                    4. Client runs the local code (print statements)




                                                                                       9
JVM Summit 2012
                                              Batch Script to SQL
                                           for (m : ROOT.Messages) {
                                            if (m.Size > In(“A”)) {
                                              out(“B”, m.Subject);
                                              out(“C”, m.Sender.Name);
                                              m.delete();
                                            }
The University of Texas at Austin




                                    SELECT m.Subject as B, u.Name as C
                                    FROM Message m INER JOIN User u
                                        ON m.Sender = User.ID
                                    WHERE m.Size > ?           Always constant 
                                    DELETE FROM Message       number of queries
                                     WHERE m.Size > ? 




                                                                                  10
JVM Summit 2012
                                                      Batch Script
                                                  (Subset of JavaScript)
                                    s ::= <literal>           variables, constants
                                       | e.x                     fields
                                        | e.m(e, ..., e)             method call
                                        | e=e                        assignment
                                        | e ⊕ e | !e | e ? e : e     primitive operators
The University of Texas at Austin




                                      |    if (e) { e } [else { e }] conditionals
                                      |    for (x in e) { e }         loops
                                      |    var x = e; e               binding
                                     |     OUTPUT(label, e)              outputs
                                     |    INPUT(label)                inputs
                                      |    function(x) { e }       functions
                                                                                           11
                                    ⊕=    + - * / % < <= == => > && || ;
JVM Summit 2012
                                                 Batch Providers

                                                               Execution:


                                    Forwarder:
                                                                    Execute
                                                                       A
                                        TCP       TCP
The University of Texas at Austin




                                        Send     Receive
                                         A         B
                                                           ?
                                                           B
                                                                      SQL
                                                                      Gen     DB
                                                                       A




                                                                                   12
JVM Summit 2012
                                                          Batch Providers

                                                                        Execution:     568 LOC in Java


                                    Forwarder:
                                                                             Execute
                                                                                A
                                        TCP                TCP
The University of Texas at Austin




                                        Send              Receive
                                         A                  B
                                                                    ?
                                                                    B
                                       XML, JSON, ...                          SQL
                                       (no fetish about                        Gen        DB
                                          transport)                            A




                                                                                                         13
JVM Summit 2012
                                    Combining Batch Providers
                                       Traditional RPC:


                                                     TCP               TCP
                                                     Send            Receive
                                                   (Python)           (Java)
                                                                              Execute
                                                                               (Java)
                                    Database Connection:
The University of Texas at Austin




                                            TCP                 TCP
                                            Send              Receive
                                            (JS)               (Java)
                                                                      SQL
                                                                      Gen               DB
                                                                     (Java)




                                                                                             14
JVM Summit 2012
                                                      The Hard Part
                                    Add Batch Statement to your favorite language
                                    JavaScript, Python, ML, F#, Scala, etc
                                         (More difficult in dynamic languages)

                                         Batch (x) {...}     LangToScript           Script + Other
The University of Texas at Austin




                                                                                                    Partition(x)
                                    I = Local1                                             Remote Local2
                                                              ScriptToLang Local1
                                    O = Execute(Remote, I)                                 (no other)
                                    Local2(O)


                                                           This is the part that 
                                                           needs to be written


                                                                                                                   15
JVM Summit 2012
                                                  Batch Summary
                                    Client
                                    Batch statement: compiles to Local/Remote/Local
                                    Works in any language (e.g. Java, Python, JavaScript)
                                        Completely cross-language and cross-platform

                                    Server
The University of Texas at Austin




                                    Small engine to execute scripts
                                        Call only public methods/fields (safe as RPC)
                                        Stateless, no remote pointers (aka proxies)

                                    Communication
                                    Forests (trees) of primitive values (no serialization)
                                        Efficient and portable                               16
JVM Summit 2012
                                          Batch = One Round Trip
                                    Clean, simple performance model
                                    Some batches would require more round trips
                                    batch (..) {
                                      if (AskUser(“Delete ” + msg.Subject + “?”)
The University of Texas at Austin




                                          msg.delete();
                                    }

                                    Pattern of execution
                                    OK:    Local → Remote → Local
                                    Error: Remote → Local → Remote

                                    Can't just mark everything as a batch!
                                                                                   17
JVM Summit 2012
                                    What about Object Serialization?
                                    Batch only transfers primitive values, not objects
                                    But they work with any object, not just remotable ones

                                    Send a local set to the server?
                                    java.util.Set<String> local = … ;
The University of Texas at Austin




                                    batch ( mail : server ) {
                                       mail.sendMessage( local, subject, body);
                                       // compiler error sending local to remote method
                                    }




                                                                                             18
JVM Summit 2012
                                    Serialization by Public Interfaces
                                    java.util.Set<String> local = … ;
                                    batch ( mail : server ) {
                                       service.Set recipients = mail.makeSet();
                                       for (String addr : local )
                                         recipients.add( addr );
The University of Texas at Austin




                                       mail.sendMessage( recipients, subject, body);
                                    }

                                    Sends list of addresses with the batch
                                    Constructors set on server and populates it
                                    Works between different languages

                                                                                       19
JVM Summit 2012
                                           Interprocedural Batches
                                    Reusable serialization function
                                    @Batch
                                    service.Set send(Mail server, local.Set<String> local) {
                                      service.Set remote = server.makeSet();
                                      for (String addr : local )
The University of Texas at Austin




                                         remote.add( addr );
                                      return remote;
                                    }

                                    Main program
                                    batch ( mail : server ) {
                                      remote.Set recipients = send( localNames );
                                                                                               20
JVM Summit 2012
                                                     Exceptions
                                    Server Exceptions
                                    Terminate the batch
                                    Return exception in forest
                                    Exception is raised in client at same point as on server

                                    Client Exceptions
The University of Texas at Austin




                                    Be careful!
                                    Batch has already been fully processed on server
                                    Client may terminate without handling all results locally



                                                                                                21
JVM Summit 2012
                                     Transactions and Partial Failure
                                    Batches are not necessarily transactional
                                    But they do facilitate transactions
                                    Server can execute transactionally


                                    Batches reduce the chances for partial failure
The University of Texas at Austin




                                    Fewer round trips
                                    Server operations are sent in groups




                                                                                     22
JVM Summit 2012
                                       Order of Execution Preserved
                                    All local and remote code runs in correct order
                                     batch ( remote : service ) {
                                       print( remote.updateA( local.getA() )); // getA, print
                                       print( remote.updateB( local.getB() )); // getB, print
                                     }
The University of Texas at Austin




                                    Partitions to:
                                     input.put(“X”, local.getA() ); // getA
                                     input.put(“Y”, local.getB() ); // getB
                                     .... execute updates on server
                                     print( result.get(“A) );       // print
                                     print( result.get(“B”) );      // print
                                                                                                23
JVM Summit 2012
                                                   Lambdas
                                    for (InfoSchema db : connection)
                                      for (Group<Category, Product> g :
                                             db.Products.groupBy(Product.byCategory))
                                        print("Category={0}t ProductCount={1}",
                                               g.Key.CategoryName,
                                               g.Items.count());


                                    Fun<Product, Category> byCategory =
The University of Texas at Austin




                                     new Fun<Product, Category>() {
                                       public Category apply(Product p) {
                                          return p.Category;
                                       }
                                    };




                                                                                        24
JVM Summit 2012
                                                 Available Now...
                                    Batch Java
                                    100% compatible with Java 1.7 (OpenJDK)
                                    Transport: XML, JSON, easy to add more
                                    Available now (alpha)

                                    Batch statement as “for”
The University of Texas at Austin




                                    for (RootInterface r : serviceConenction) { ... }

                                    Full SQL generation and ORM
                                    Select/Insert/Delete/Update, aggregate, group, sorting



                                                                                             25

More Related Content

What's hot

Summer Training In Dotnet
Summer Training In DotnetSummer Training In Dotnet
Summer Training In Dotnet
DUCC Systems
 
Chapter 10.slides
Chapter 10.slidesChapter 10.slides
Chapter 10.slides
lara_ays
 
OrientDB the graph database
OrientDB the graph databaseOrientDB the graph database
OrientDB the graph database
Artem Orobets
 
Chapter 3 a
Chapter 3 aChapter 3 a
Chapter 3 a
lara_ays
 
Chapter 2 slides
Chapter 2 slidesChapter 2 slides
Chapter 2 slides
lara_ays
 
Chapter 6 slides
Chapter 6 slidesChapter 6 slides
Chapter 6 slides
lara_ays
 
Slash n: Tech Talk Track 2 – Distributed Transactions in SOA - Yogi Kulkarni,...
Slash n: Tech Talk Track 2 – Distributed Transactions in SOA - Yogi Kulkarni,...Slash n: Tech Talk Track 2 – Distributed Transactions in SOA - Yogi Kulkarni,...
Slash n: Tech Talk Track 2 – Distributed Transactions in SOA - Yogi Kulkarni,...
slashn
 
Self Repairing Tree Topology Enabling Content Based Routing In Local Area Ne...
Self Repairing Tree Topology Enabling  Content Based Routing In Local Area Ne...Self Repairing Tree Topology Enabling  Content Based Routing In Local Area Ne...
Self Repairing Tree Topology Enabling Content Based Routing In Local Area Ne...
ncct
 

What's hot (16)

Summer Training In Dotnet
Summer Training In DotnetSummer Training In Dotnet
Summer Training In Dotnet
 
Chapter 10.slides
Chapter 10.slidesChapter 10.slides
Chapter 10.slides
 
OrientDB the graph database
OrientDB the graph databaseOrientDB the graph database
OrientDB the graph database
 
Chapter 3 a
Chapter 3 aChapter 3 a
Chapter 3 a
 
Java Message Service
Java Message ServiceJava Message Service
Java Message Service
 
Threads 2x[1]
Threads 2x[1]Threads 2x[1]
Threads 2x[1]
 
Chapter 2 slides
Chapter 2 slidesChapter 2 slides
Chapter 2 slides
 
Chapter 6 slides
Chapter 6 slidesChapter 6 slides
Chapter 6 slides
 
Collaborative Cuisine's 1 Hour JNDI Cookbook
Collaborative Cuisine's 1 Hour JNDI CookbookCollaborative Cuisine's 1 Hour JNDI Cookbook
Collaborative Cuisine's 1 Hour JNDI Cookbook
 
Simple insites into JVM
Simple insites into JVMSimple insites into JVM
Simple insites into JVM
 
Stream Processing with DDS and CEP
Stream Processing with  DDS and CEPStream Processing with  DDS and CEP
Stream Processing with DDS and CEP
 
Slash n: Tech Talk Track 2 – Distributed Transactions in SOA - Yogi Kulkarni,...
Slash n: Tech Talk Track 2 – Distributed Transactions in SOA - Yogi Kulkarni,...Slash n: Tech Talk Track 2 – Distributed Transactions in SOA - Yogi Kulkarni,...
Slash n: Tech Talk Track 2 – Distributed Transactions in SOA - Yogi Kulkarni,...
 
Getting Started with OpenSplice DDS Community Ed.
Getting Started with OpenSplice DDS Community Ed.Getting Started with OpenSplice DDS Community Ed.
Getting Started with OpenSplice DDS Community Ed.
 
B vb script11
B vb script11B vb script11
B vb script11
 
CMIS and Interoperability - AIIM 2009
CMIS and Interoperability - AIIM 2009CMIS and Interoperability - AIIM 2009
CMIS and Interoperability - AIIM 2009
 
Self Repairing Tree Topology Enabling Content Based Routing In Local Area Ne...
Self Repairing Tree Topology Enabling  Content Based Routing In Local Area Ne...Self Repairing Tree Topology Enabling  Content Based Routing In Local Area Ne...
Self Repairing Tree Topology Enabling Content Based Routing In Local Area Ne...
 

Viewers also liked

Newsletter september 2012
Newsletter   september 2012Newsletter   september 2012
Newsletter september 2012
Kim at MAREI
 
Termo de saneamento unip
Termo de saneamento unipTermo de saneamento unip
Termo de saneamento unip
lokorazor
 

Viewers also liked (14)

Benefits & Fees for MAREI
Benefits & Fees for MAREIBenefits & Fees for MAREI
Benefits & Fees for MAREI
 
ARTICULO
ARTICULOARTICULO
ARTICULO
 
Conducting Job Interviews
Conducting Job InterviewsConducting Job Interviews
Conducting Job Interviews
 
The Investment News: February 2013
The Investment News:  February 2013The Investment News:  February 2013
The Investment News: February 2013
 
Enso presented at Microsoft Research/CSW summer 2012
Enso presented at Microsoft Research/CSW summer 2012Enso presented at Microsoft Research/CSW summer 2012
Enso presented at Microsoft Research/CSW summer 2012
 
Mascotas en adopcion Fundación Patitas de Corazon
Mascotas en adopcion Fundación Patitas de CorazonMascotas en adopcion Fundación Patitas de Corazon
Mascotas en adopcion Fundación Patitas de Corazon
 
Investment News: September 2014
Investment News:  September 2014Investment News:  September 2014
Investment News: September 2014
 
The Real Estate Investment News, Spring 2014
The Real Estate Investment News, Spring 2014The Real Estate Investment News, Spring 2014
The Real Estate Investment News, Spring 2014
 
Newsletter september 2012
Newsletter   september 2012Newsletter   september 2012
Newsletter september 2012
 
HR Optimization
HR OptimizationHR Optimization
HR Optimization
 
Global HR Practices
Global HR PracticesGlobal HR Practices
Global HR Practices
 
Introduction to the internet
Introduction to the internetIntroduction to the internet
Introduction to the internet
 
Termo de saneamento unip
Termo de saneamento unipTermo de saneamento unip
Termo de saneamento unip
 
Química cerebral
Química cerebralQuímica cerebral
Química cerebral
 

Similar to 2012 07-jvm-summit-batches

Inside mbga Open Platform API architecture
Inside mbga Open Platform API architectureInside mbga Open Platform API architecture
Inside mbga Open Platform API architecture
Toru Yamaguchi
 
Scotas - Oracle Open World Sao Pablo
Scotas - Oracle Open World Sao PabloScotas - Oracle Open World Sao Pablo
Scotas - Oracle Open World Sao Pablo
Julian Arocena
 

Similar to 2012 07-jvm-summit-batches (20)

Unifying Remote Data, Remote Procedure, and Service Clients
Unifying Remote Data, Remote Procedure, and Service ClientsUnifying Remote Data, Remote Procedure, and Service Clients
Unifying Remote Data, Remote Procedure, and Service Clients
 
Jms
JmsJms
Jms
 
Jms intro
Jms introJms intro
Jms intro
 
Powering the Next Generation Services with Java Platform - Spark IT 2010
Powering the Next Generation Services with Java Platform - Spark IT 2010Powering the Next Generation Services with Java Platform - Spark IT 2010
Powering the Next Generation Services with Java Platform - Spark IT 2010
 
Jms
JmsJms
Jms
 
Elegant Systems Integration w/ Apache Camel
Elegant Systems Integration w/ Apache CamelElegant Systems Integration w/ Apache Camel
Elegant Systems Integration w/ Apache Camel
 
Architectures with Windows Azure
Architectures with Windows AzureArchitectures with Windows Azure
Architectures with Windows Azure
 
Exchange 2013 ABC's: Architecture, Best Practices and Client Access
Exchange 2013 ABC's: Architecture, Best Practices and Client AccessExchange 2013 ABC's: Architecture, Best Practices and Client Access
Exchange 2013 ABC's: Architecture, Best Practices and Client Access
 
Processing Big Data (Chapter 3, SC 11 Tutorial)
Processing Big Data (Chapter 3, SC 11 Tutorial)Processing Big Data (Chapter 3, SC 11 Tutorial)
Processing Big Data (Chapter 3, SC 11 Tutorial)
 
Nio
NioNio
Nio
 
Offline Html5 3days
Offline Html5 3daysOffline Html5 3days
Offline Html5 3days
 
Meteor
MeteorMeteor
Meteor
 
Messaging in Java
Messaging in JavaMessaging in Java
Messaging in Java
 
A Walking Tour of (almost) all of Springdom
A Walking Tour of (almost) all of Springdom A Walking Tour of (almost) all of Springdom
A Walking Tour of (almost) all of Springdom
 
Comet with node.js and V8
Comet with node.js and V8Comet with node.js and V8
Comet with node.js and V8
 
Hexagonal architecture - message-oriented software design (PHP Barcelona 2015)
Hexagonal architecture - message-oriented software design (PHP Barcelona 2015)Hexagonal architecture - message-oriented software design (PHP Barcelona 2015)
Hexagonal architecture - message-oriented software design (PHP Barcelona 2015)
 
Azure and cloud design patterns
Azure and cloud design patternsAzure and cloud design patterns
Azure and cloud design patterns
 
Inside mbga Open Platform API architecture
Inside mbga Open Platform API architectureInside mbga Open Platform API architecture
Inside mbga Open Platform API architecture
 
Make easier Integration of your services with Fuse Solutions - RedHat 2013
Make easier Integration of your services with Fuse Solutions - RedHat 2013Make easier Integration of your services with Fuse Solutions - RedHat 2013
Make easier Integration of your services with Fuse Solutions - RedHat 2013
 
Scotas - Oracle Open World Sao Pablo
Scotas - Oracle Open World Sao PabloScotas - Oracle Open World Sao Pablo
Scotas - Oracle Open World Sao Pablo
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 

2012 07-jvm-summit-batches

  • 1. JVM Summit 2012 Batches: Unifying RPC, WS and Database access The University of Texas at Austin William R. Cook University of Texas at Austin with Eli Tilevich, Yang Jiao, Virginia Tech Ali Ibrahim, Ben Wiedermann, UT Austin
  • 2. JVM Summit 2012 Typical Approach to Distribution/DB 1. Design a programming language Finalize specification, then... 2. Implement distribution/queries as library RPC library, stub generator SQL library The University of Texas at Austin Web Service library, wrapper generator 2
  • 3. JVM Summit 2012 Typical Approach to Distribution/DB 1. Design a programming language Finalize specification, then... 2. Implement distribution/queries as library RPC library, stub generator SQL library The University of Texas at Austin Web Service library, wrapper generator 3. Rejected and ignored by community CORBA, DCOM, RMI are complete disaster 3
  • 4. JVM Summit 2012 Using a Mail Service int limit = 500; for ( Message m : mailer.Messages ) if ( m.Size > limit ) { print( m.Subject + “: “ + m.Sender.Name); m.delete(); The University of Texas at Austin } 4
  • 5. JVM Summit 2012 Using a Mail Service int limit = 500; for ( Message m : mailer.Messages ) if ( m.Size > limit ) { print( m.Subject + “: “ + m.Sender.Name); m.delete(); The University of Texas at Austin } Works great if mailer is  a local object, but is terrible if  mailer is remote 5
  • 6. JVM Summit 2012 Goals: Why not Have it All? A Note on  Low latency One round trip Distributed  Computing Stateless No Proxies Platform independent No Serialization Clean Server APIs No Data Transfer Object The University of Texas at Austin No Server Facade No Superclass/type     (e.g. java.rmi.Remote) 6
  • 7. JVM Summit 2012 Using a Mail Service int limit = 500; for ( Message m : mailer.Messages ) if ( m.Size > limit ) { print( m.Subject + “: “ + m.Sender.Name); m.delete(); Separate local The University of Texas at Austin } and remote code! 7
  • 8. JVM Summit 2012 for (m : ROOT.Messages) {               if (m.Size > In(“A”)) {                      Run remote OUT(“B”, m.Subject);                   script first OUT(“C”, m.Sender.Name); m.delete(); int limit = 500; } Remote<Mailer> connection = ....; B C batch (Mailer mailer : connection) { RE: testing Will Cook for ( Message m : mailer.Messages ) JVM Summit Dan Smith The University of Texas at Austin ... ... if ( m.Size > limit ) { print( m.Subject + “: “ + m.Sender.Name); m.delete(); Remote<Mailer> connection = ....; } Forest in = new Forest(“A”, limit); Forest mailer = connection.execute(script, in); } for (m : mailer.getIteration(“m”)) print(m.getStr(“B”) + “: ” + m.getStr(“C”) ); 8
  • 9. JVM Summit 2012 Batch Pattern Execution model: Batch Command Pattern 1. Client sends script to the server (Creates Remote Façade on the fly) 2. Server executes the script 3. Server returns results in bulk (name, size) The University of Texas at Austin (Creates Data Transfer Objects on the fly) 4. Client runs the local code (print statements) 9
  • 10. JVM Summit 2012 Batch Script to SQL for (m : ROOT.Messages) { if (m.Size > In(“A”)) { out(“B”, m.Subject); out(“C”, m.Sender.Name); m.delete(); } The University of Texas at Austin SELECT m.Subject as B, u.Name as C FROM Message m INER JOIN User u     ON m.Sender = User.ID WHERE m.Size > ? Always constant  DELETE FROM Message number of queries WHERE m.Size > ?  10
  • 11. JVM Summit 2012 Batch Script (Subset of JavaScript) s ::= <literal> variables, constants | e.x fields | e.m(e, ..., e) method call | e=e assignment | e ⊕ e | !e | e ? e : e primitive operators The University of Texas at Austin | if (e) { e } [else { e }] conditionals | for (x in e) { e } loops | var x = e; e binding | OUTPUT(label, e) outputs | INPUT(label) inputs | function(x) { e } functions 11 ⊕= + - * / % < <= == => > && || ;
  • 12. JVM Summit 2012 Batch Providers Execution: Forwarder: Execute A TCP TCP The University of Texas at Austin Send Receive A B ? B SQL Gen DB A 12
  • 13. JVM Summit 2012 Batch Providers Execution: 568 LOC in Java Forwarder: Execute A TCP TCP The University of Texas at Austin Send Receive A B ? B XML, JSON, ... SQL (no fetish about Gen DB transport) A 13
  • 14. JVM Summit 2012 Combining Batch Providers Traditional RPC: TCP TCP Send Receive (Python) (Java) Execute (Java) Database Connection: The University of Texas at Austin TCP TCP Send Receive (JS) (Java) SQL Gen DB (Java) 14
  • 15. JVM Summit 2012 The Hard Part Add Batch Statement to your favorite language JavaScript, Python, ML, F#, Scala, etc (More difficult in dynamic languages) Batch (x) {...} LangToScript Script + Other The University of Texas at Austin                       Partition(x) I = Local1 Remote Local2 ScriptToLang Local1 O = Execute(Remote, I) (no other) Local2(O) This is the part that  needs to be written 15
  • 16. JVM Summit 2012 Batch Summary Client Batch statement: compiles to Local/Remote/Local Works in any language (e.g. Java, Python, JavaScript) Completely cross-language and cross-platform Server The University of Texas at Austin Small engine to execute scripts Call only public methods/fields (safe as RPC) Stateless, no remote pointers (aka proxies) Communication Forests (trees) of primitive values (no serialization) Efficient and portable 16
  • 17. JVM Summit 2012 Batch = One Round Trip Clean, simple performance model Some batches would require more round trips batch (..) { if (AskUser(“Delete ” + msg.Subject + “?”) The University of Texas at Austin msg.delete(); } Pattern of execution OK: Local → Remote → Local Error: Remote → Local → Remote Can't just mark everything as a batch! 17
  • 18. JVM Summit 2012 What about Object Serialization? Batch only transfers primitive values, not objects But they work with any object, not just remotable ones Send a local set to the server? java.util.Set<String> local = … ; The University of Texas at Austin batch ( mail : server ) { mail.sendMessage( local, subject, body); // compiler error sending local to remote method } 18
  • 19. JVM Summit 2012 Serialization by Public Interfaces java.util.Set<String> local = … ; batch ( mail : server ) { service.Set recipients = mail.makeSet(); for (String addr : local ) recipients.add( addr ); The University of Texas at Austin mail.sendMessage( recipients, subject, body); } Sends list of addresses with the batch Constructors set on server and populates it Works between different languages 19
  • 20. JVM Summit 2012 Interprocedural Batches Reusable serialization function @Batch service.Set send(Mail server, local.Set<String> local) { service.Set remote = server.makeSet(); for (String addr : local ) The University of Texas at Austin remote.add( addr ); return remote; } Main program batch ( mail : server ) { remote.Set recipients = send( localNames ); 20
  • 21. JVM Summit 2012 Exceptions Server Exceptions Terminate the batch Return exception in forest Exception is raised in client at same point as on server Client Exceptions The University of Texas at Austin Be careful! Batch has already been fully processed on server Client may terminate without handling all results locally 21
  • 22. JVM Summit 2012 Transactions and Partial Failure Batches are not necessarily transactional But they do facilitate transactions Server can execute transactionally Batches reduce the chances for partial failure The University of Texas at Austin Fewer round trips Server operations are sent in groups 22
  • 23. JVM Summit 2012 Order of Execution Preserved All local and remote code runs in correct order batch ( remote : service ) { print( remote.updateA( local.getA() )); // getA, print print( remote.updateB( local.getB() )); // getB, print } The University of Texas at Austin Partitions to: input.put(“X”, local.getA() ); // getA input.put(“Y”, local.getB() ); // getB .... execute updates on server print( result.get(“A) ); // print print( result.get(“B”) ); // print 23
  • 24. JVM Summit 2012 Lambdas for (InfoSchema db : connection) for (Group<Category, Product> g : db.Products.groupBy(Product.byCategory)) print("Category={0}t ProductCount={1}", g.Key.CategoryName, g.Items.count()); Fun<Product, Category> byCategory = The University of Texas at Austin new Fun<Product, Category>() { public Category apply(Product p) { return p.Category; } }; 24
  • 25. JVM Summit 2012 Available Now... Batch Java 100% compatible with Java 1.7 (OpenJDK) Transport: XML, JSON, easy to add more Available now (alpha) Batch statement as “for” The University of Texas at Austin for (RootInterface r : serviceConenction) { ... } Full SQL generation and ORM Select/Insert/Delete/Update, aggregate, group, sorting 25