SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

Summer Training In Dotnet
Summer Training In DotnetSummer Training In Dotnet
Summer Training In DotnetDUCC Systems
 
Chapter 10.slides
Chapter 10.slidesChapter 10.slides
Chapter 10.slideslara_ays
 
OrientDB the graph database
OrientDB the graph databaseOrientDB the graph database
OrientDB the graph databaseArtem Orobets
 
Chapter 3 a
Chapter 3 aChapter 3 a
Chapter 3 alara_ays
 
Java Message Service
Java Message ServiceJava Message Service
Java Message ServiceAMIT YADAV
 
Chapter 2 slides
Chapter 2 slidesChapter 2 slides
Chapter 2 slideslara_ays
 
Chapter 6 slides
Chapter 6 slidesChapter 6 slides
Chapter 6 slideslara_ays
 
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 CookbookKen Lin
 
Stream Processing with DDS and CEP
Stream Processing with  DDS and CEPStream Processing with  DDS and CEP
Stream Processing with DDS and CEPAngelo Corsaro
 
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
 
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.Angelo Corsaro
 
B vb script11
B vb script11B vb script11
B vb script11oakhrd
 
CMIS and Interoperability - AIIM 2009
CMIS and Interoperability - AIIM 2009CMIS and Interoperability - AIIM 2009
CMIS and Interoperability - AIIM 2009johnnewton
 
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
 

La actualidad más candente (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...
 

Destacado

Benefits & Fees for MAREI
Benefits & Fees for MAREIBenefits & Fees for MAREI
Benefits & Fees for MAREIKim at MAREI
 
Conducting Job Interviews
Conducting Job InterviewsConducting Job Interviews
Conducting Job InterviewsPratik Patel
 
The Investment News: February 2013
The Investment News:  February 2013The Investment News:  February 2013
The Investment News: February 2013Kim at MAREI
 
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 2012Will Cook
 
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 Corazonmmunozmun
 
Investment News: September 2014
Investment News:  September 2014Investment News:  September 2014
Investment News: September 2014Kim at MAREI
 
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 2014Kim at MAREI
 
Newsletter september 2012
Newsletter   september 2012Newsletter   september 2012
Newsletter september 2012Kim at MAREI
 
Global HR Practices
Global HR PracticesGlobal HR Practices
Global HR PracticesPratik Patel
 
Introduction to the internet
Introduction to the internetIntroduction to the internet
Introduction to the internetFolasade Adedeji
 
Termo de saneamento unip
Termo de saneamento unipTermo de saneamento unip
Termo de saneamento uniplokorazor
 

Destacado (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 a 2012 07-jvm-summit-batches

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 Clientsgreenwop
 
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 2010Arun Gupta
 
Elegant Systems Integration w/ Apache Camel
Elegant Systems Integration w/ Apache CamelElegant Systems Integration w/ Apache Camel
Elegant Systems Integration w/ Apache CamelPradeep Elankumaran
 
Architectures with Windows Azure
Architectures with Windows AzureArchitectures with Windows Azure
Architectures with Windows AzureDamir Dobric
 
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)Robert Grossman
 
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 Joshua Long
 
Comet with node.js and V8
Comet with node.js and V8Comet with node.js and V8
Comet with node.js and V8amix3k
 
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)Matthias Noback
 
Inside mbga Open Platform API architecture
Inside mbga Open Platform API architectureInside mbga Open Platform API architecture
Inside mbga Open Platform API architectureToru Yamaguchi
 
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 2013Charles Moulliard
 
Scotas - Oracle Open World Sao Pablo
Scotas - Oracle Open World Sao PabloScotas - Oracle Open World Sao Pablo
Scotas - Oracle Open World Sao PabloJulian Arocena
 

Similar a 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
 

Último

4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 

Último (20)

4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 

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