SlideShare a Scribd company logo
Scale Java Persistence API Applications with OpenJPA Slice  Pinaki Poddar [email_address]
Agenda ,[object Object],[object Object],[object Object],[object Object],Source: If applicable, describe source origin
What is Slice? ,[object Object],Java Persistence API Specification [Section 3.1] says:   “ A persistence unit defines the set of all classes that are related    or grouped by the application, and which must be colocated in their    mapping to a  single  database.” Slice changes that…  single  to  multiple
Horizontal Partitioning ,[object Object],[object Object],[object Object],[object Object],[object Object]
Horizontal Partitioning in realistic setup ,[object Object],[object Object],[object Object],[object Object]
History of Slice ,[object Object],[object Object],[object Object]
OpenJPA  ,[object Object],[object Object]
Architectural tiers of a typical JPA-based application User Application OpenJPA Standard JPA API JDBC API 400 million records
Architectural tiers of a Slice-based application User Application OpenJPA Standard JPA API JDBC API Slice OpenJPA is a plugabble platform User-defined Data Distribution Policy 4x100 million records
Separate Persistence Unit configured to partitioned databases  C A [1] D A Unit A C A [2] C B [1] D B Unit B C B [2] C C [1] D C Unit C C C [2]
Same persistence unit switches contexts to partitioned databases C A [1] D A Persistence Unit C A [2] C C [2] C C [1] C B [2] C B [1] D B D C
Same persistence unit connected to partitioned databases C[1] D A Persistence Unit C[2] D B D C
Features of Slice Slice-based User Application OpenJPA Standard JPA API JDBC API Slice No changes to Application code User-defined Data Distribution Policy Flexible per-Slice Configuration Parallel Query Execution Heterogeneous Databases Master-based Sequence Targeted  Query No changes to Domain Model User-defined Query Target Policy No changes to Database Schema 4x100 millon records
Agenda ,[object Object],[object Object],[object Object],[object Object],Source: If applicable, describe source origin
Using Slice ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Policy based configuration ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Data Distribution Policy determines where new records are stored ,[object Object],[object Object]
How to distribute data across slices? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],@Entity public class   Person  { private   String  name; private   int  age; @OneToOne  (cascade=ALL) private   Address  address; } @Entity public class   Address  { private   String  city; } User   Application Domain Classes Data Distribution Policy
Distribution Policy decides target slice for each instance public interface   DistributionPolicy  {  /**  * Decide the name of the slice where the given persistent  * instance would be stored.  *  *  @param  pc The newly persistent or to-be-merged object.  *  @param  slices name of the configured slices.  *  @param  context persistence context managing the given instance.  *  *  @return  identifier of the slice. This name must match one of the  * configured slice names.  *  @see   DistributedConfiguration#getSliceNames()   */  String   distribute ( Object  pc,  List<String>  slices,  Object  context);  }  Slice runtime will call this method while persisting or merging a  root  instance. The instance and its   persistent   closure   will be stored in the returned slice.
Details on Distribution Policy  a b em.persist(a); //  or em.merge(a); persistence context MyPolicy.distribute(a,…) { return  “One” ; } One One < property   name=&quot; openjpa.slice.DistributionPolicy &quot;  value=“ acme.org.MyPolicy &quot;/> Slice attaches moniker to  managed  instance as it enters a persistence context Slice runtime calls User Application CascadeType.PERSIST CascadeType.MERGE c One
Slice enforces Collocation Constraint on persistent closure ,[object Object],[object Object],[object Object],[object Object],[object Object]
An example domain model
Instances that violate persistent closure must be replicated Stock CSCO Ask-152 Bid-153 Trader-1 Trader-2 Trade-15 Stock GS Ask-210 Bid-211 Trader-7 Trader-1 Trade-21 slice.One slice.Two Trader-1   will violate collocation constraint and must be replicated across all slices. Data partitioned by Stock sectors
Replicate  master/shared data  across slices ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],< property   name=“ openjpa.slice.ReplicatedTypes ” value=“ domain.Trader ”/> Data Replication Policy
Replication Policy public   interface   ReplicationPolicy  {  /**  * Decide the name of the slices where the given persistent  * instance would be replicated.  *  *  @param  pc The newly persistent or to-be-merged object.  *  @param  slices name of the configured slices.  *  @param  context persistence context managing the given instance.  *  *  @return  identifier(s) of the slice. Each name must match one of the  * configured slice names.  *  @see   DistributedConfiguration#getSliceNames()   */  String[]   replicate ( Object  pc,  List<String>  slices,  Object  context);  }  Slice runtime will call this method while persisting any replicated instance.
Distributed Query ,[object Object],[object Object],[object Object],[object Object]
Query Target Policy decides target slice for each query public interface   QueryTargetPolicy  {  /**  * Decide the name of the slice(s) where the given query  * will be executed.  *  *  @param  query The query string to be executed.  *  @param  params the bound parameters of the query.  *  @param  language the language of the query *  @param  slices name of the configured slices *  @param  context persistence context executing the query.  *  *  @return  identifier of the target slices. Null value implies * all configured slices.  */  String[]   getTargets ( String  query,  Map  params,  String  language,  List<String>  slices,  Object  context);  }  Slice runtime will call this method for every query. Default policy targets all available slices.
Intrusive way to control target slices for a query EntityManager  em = …; String   jpql = &quot; SELECT p FROM Person p where p.name=:name ”; TypedQuery <Person>   query1 = em.createQuery(jpql, Person. class ); // Set a single slice as query target query1.setHint( SlicePersistence.HINT_TARGET , “ One &quot;); List < Person >  result1 = query1.setParameter(“ name ”, “ XYZ ”) .getResultList(); TypedQuery <Person> query2 = em.createQuery(jpql , Person. class ); // Set multiple slices as query targets query2.setHint( SlicePersistence.HINT_TARGET ,  Arrays.asList( new   String []{“ One “,” Two ”}); List < Person >  result2 = query2.setParameter(“ name ”, “ ABC ”) .getResultList();
Distributed Query results are appended ,[object Object],slice1 slice3 slice2 String  jpql = “ select e from Employee e where e.age > 30 ”; List < Employee >  result = em.createQuery(jpql, Employee. class ).getResultList(); 2001 29 BILL 2005 37 LEUNG 2008 22 ROB JOIN_YEAR AGE NAME 1987 41 JOSE 1999 35 SHIVA 2002 31 HARI JOIN_YEAR AGE NAME 1975 43 SANDRA 2007 24 MARY 2001 35 JOHN JOIN_YEAR AGE NAME 2007 24 MARY 2008 22 ROB 2001 29 BILL 2008 22 ROB 2001 29 BILL 2007 24 MARY
Distributed Query results are sorted in-memory ,[object Object],slice1 slice3 slice2 String  jpql = “ select e from Employee e where e.age < 30 order by e.name ”; List < Employee >  result = em.createQuery(jpql, Emloyee. class ).getResultList(); 2001 29 BILL 2005 37 LEUNG 2008 22 ROB JOIN_YEAR AGE NAME 1987 41 JOSE 1999 35 SHIVA 2002 31 HARI JOIN_YEAR AGE NAME 1975 43 SANDRA 2007 24 MARY 2001 35 JOHN JOIN_YEAR AGE NAME 2007 24 MARY 2008 22 ROB 2001 29 BILL 2007 22 ROB 2007 24 MARY 2001 29 BILL
Distributed Top-N Query ,[object Object],slice1 slice3 slice2 String  jpql = “ select e from Employee e order by e.age ”; List < Employee >  result = em.createQuery(jpql, Emloyee. class ) .getMaxResult(2).getResultList(); 2001 29 BILL 2005 37 LEUNG 2008 22 ROB JOIN_YEAR AGE NAME 1987 41 JOSE 1999 35 SHIVA 2002 31 HARI JOIN_YEAR AGE NAME 1975 43 SANDRA 2007 24 MARY 2001 35 JOHN JOIN_YEAR AGE NAME 2001 29 BILL 2008 22 ROB 2001 35 JOHN 2007 24 MARY 1999 35 SHIVA 2002 31 HARI 2007 24 MARY 2008 22 ROB
Distributed Top-N Query ,[object Object],slice1 slice3 slice2 List  result = em.createQuery(“ select e from Employee e ”) .setMaxResult(2).getResultList(); 2001 29 BILL 2005 37 LEUNG 2008 22 ROB JOIN_YEAR AGE NAME 1987 41 JOSE 1999 35 SHIVA 2002 31 HARI JOIN_YEAR AGE NAME 1975 43 SANDRA 2007 24 MARY 2001 35 JOHN JOIN_YEAR AGE NAME 2001 29 BILL 2008 22 ROB 2001 35 JOHN 2007 24 MARY 1999 35 SHIVA 2002 31 HARI 2007 24 MARY 2008 22 ROB
Targeted Query ,[object Object],slice1 slice3 slice2 List   result   =   em.createQuery (“ SELECT e FROM Employee e WHERE e.age > 34 ”) . setHint (“ openjpa.slice.Targets ”, “ slice1,slice3 ”) . getResultList (); 2001 29 BILL 2005 37 LEUNG 2008 22 ROB JOIN_YEAR AGE NAME 1987 41 JOSE 1999 35 SHIVA 2002 31 HARI JOIN_YEAR AGE NAME 1975 43 SANDRA 2007 24 MARY 2001 35 JOHN JOIN_YEAR AGE NAME 2001 35 JOHN 1975 43 SANDRA 1999 35 SHIVA 1987 41 JOSE 1999 35 SHIVA 1987 41 JOSE 2001 35 JOHN 1975 43 SANDRA
Aggregate Query ,[object Object],slice1 slice3 slice2 Number   sum = em.createQuery (“ select sum(e.age) from Employee e where e.age > 30 ”,  Number.class ).getSingleResult(); 2001 29 BILL 2005 37 LEUNG 2008 22 ROB JOIN_YEAR AGE NAME 1987 41 JOSE 1999 35 SHIVA 2002 31 HARI JOIN_YEAR AGE NAME 1975 43 SANDRA 2007 24 MARY 2001 35 JOHN JOIN_YEAR AGE NAME 78 37 107 222 78 37 107
Distributed Aggregate Query Limitations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Aggregate Query ,[object Object],slice1 slice3 slice2 Number   sum = em.createQuery (“ select avg(e.age) from Employee e ”,  Number.class ) .getSingleResult(); 34.0 + 30.0 32.0 = ] + 32.0 [ / 3 Wrong! 2001 29 BILL 2005 38 LEUNG 2008 23 ROB JOIN_YEAR AGE NAME 1999 35 SHIVA 2002 31 HARI JOIN_YEAR AGE NAME 1975 43 SANDRA 2007 24 MARY 2001 35 JOHN JOIN_YEAR AGE NAME 34.0 30.0 32.0
Query for Replicated Entities ,[object Object],Number   sum = ( Number )em.createQuery(“ SELECT COUNT(c) FROM Coutry c ”)  .getSingleResult(); slice1 slice3 slice2 3 3 1200M INDIA 82M GERMANY 300M US POPULATION CODE 1200M INDIA 82M GERMANY 300M US POPULATION CODE 1200M INDIA 82M GERMANY 300M US POPULATION CODE
META-INF/persistence.xml configures a persistence unit  <? xml  version=&quot; 1.0 &quot; encoding=&quot; UTF-8 &quot;?> < persistence   xmlns=&quot; http://java.sun.com/xml/ns/persistence &quot;  xmlns:xsi=&quot; http://www.w3.org/2001/XMLSchema-instance &quot; version=&quot; 1.0 &quot;  xsi:schemaLocation=&quot; http://java.sun.com/xml/ns/persistence   http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd &quot;> < persistence-unit   name=&quot; test “  transaction=“ RESOURCE_LOCAL ”> < provider > org.apache.openjpa.persistence.PersistenceProviderImpl </ provider > < class > domain.EntityA </ class > < class > domain.EntityB </ class > < properties > < property   name=&quot; openjpa.ConnectionDriverName &quot;  value=&quot; com.mysql.jdbc.Driver &quot;/> < property   name=&quot; openjpa.ConnectionURL &quot;  value=&quot; jdbc:mysql://localhost/test &quot;/> < property   name=&quot; openjpa.jdbc.SynchronizeMappings &quot; value=&quot; buildSchema &quot;/> < property   name=&quot; openjpa.Log &quot;  value=&quot; SQL=TRACE &quot;/> </ properties > </ persistence-unit > List of known Persistent types Vendor-specific  configuration Governed by  XML Schema JPA Provider is pluggable Identified by Unit Name
Activate Slice through configuration ,[object Object],[object Object],[object Object]
Each slice is referred by a moniker ,[object Object],[object Object],[object Object]
Identify a Master slice ,[object Object],[object Object],[object Object]
[object Object],[object Object],Specify physical slice connection details ,[object Object],[object Object],[object Object],Moniker for a slice
Slices can share common properties ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ignoring unavailable slices  ,[object Object],[object Object],[object Object]
Configuration Rules  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Configuration Rules (continued)  ,[object Object],[object Object],[object Object]
A complete example of Slice Configuration  < properties > < property   name=&quot; openjpa.BrokerFactory &quot;  value=“ slice &quot;/> < property   name=“ openjpa.slice.Names ”  value=“ One,Two,Three ”/> < property   name=“ openjpa.slice.Master ”  value=“ One ”/> < property   name=&quot; openjpa.ConnectionDriverName &quot;  value=&quot; com.mysql.jdbc.Driver &quot;/> < property   name=&quot; openjpa.slice.One.ConnectionURL &quot;  value=&quot; jdbc:mysql://mac1:3456/slice1 &quot;/> < property   name=“ openjpa.slice.Two.ConnectionURL ”  value=“ jdbc:mysql://mac2:5634/slice2 ”/> < property   name=“ openjpa.slice.Three.ConnectionDriverName ” value=“ com.ibm.db2.jcc.DB2Driver ”/> < property   name=“ openjpa.slice.Three.ConnectionURL ” value=“ jdbc:db2 :// mac3:50000/slice3 ”/> < property   name=&quot; openjpa.slice.DistributionPolicy &quot;  value=“ acme.org.MyDistroPolicy &quot;/> < property   name=&quot; openjpa.jdbc.SynchronizeMappings &quot; value=&quot; buildSchema &quot;/> </ properties > </ persistence-unit > META-INF/persistence.xml Activate Slice Declare slices Configure each slice Configure common behavior Define Data Distribution Policy
Updates ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Database and Transaction ,[object Object],[object Object],[object Object]
Agenda ,[object Object],[object Object],[object Object],[object Object],Source: If applicable, describe source origin
Core Architectural constructs of OpenJPA EntityManager Factory BrokerFactory EntityManager Broker StoreManager JDBCStore Manager JDBC API OpenJPA Configuration creates creates delegates delegates configured by facade kernel storage POJO + State manager
Slice extends OpenJPA by Distributed Template EntityManager Factory BrokerFactory EntityManager Broker DistributedStoreManager JDBCStore Manager JDBC API JDBCStore Manager JDBCStore Manager Distributed Configuration applies Distributed Template Pattern Not aware of partitioned Databases applies Distributed Template Pattern OpenJPA Configuration OpenJPA Configuration OpenJPA Configuration + Slice Moniker facade kernel storage POJO + State manager
Distributed Template Design Pattern public class   DistributedTemplate < T >  implements   T ,  Iterable < T > { protected   List < T >  _delegates  =  new   ArrayList < T >(); public   void  add(T t) { _delegates .add(t); } public   Iterator < T > iterator() { return   _delegates .iterator(); }  // execution requires operation-specific merge semantics public boolean   execute(String arg0) { boolean   ret =   true ; for   (T t   :  this )   ret = t.execute(arg0)   &   ret;   // merge execution result return   ret; } } ,[object Object]
Slice applies Distributed Template Design Pattern on OpenJPA/JDBC  ,[object Object],[object Object],[object Object]
Agenda ,[object Object],[object Object],[object Object],[object Object]
OpenTrader : OpenJPA/Slice and GWT
An example data distribution policy /** * This distribution policy determines the sector of the stock and * picks the slice at ordinal index of the enumerated Sector. */ public   class  SectorDistributionPolicy  implements  DistributionPolicy { public   String  distribute( Object  pc,  List < String > slices,  Object  context) { Stock  stock =  null ; if  (pc  instanceof   Tradable ) { stock = (( Tradable )pc).getStock(); }  else if  (pc  instanceof  Stock ) { stock = ( Stock )pc; }  else if  (pc  instanceof   Trade ) { stock = (( Trade )pc).getStock(); }  else  { throw new  IllegalArgumentException(“ No policy for  “ + pc); } return  stock !=  null  ? slices.get(stock.getSector().ordinal())  :  null ; } }
An example query target policy public   static   final  String  MATCH_BID   = &quot; select   new  Match(a,b)  from  Ask a, Bid b  &quot;  + &quot; where  b = :bid  and  a.stock.symbol = b.stock.symbol  &quot;  + &quot; and  a.price <= b.price  and  a.volume >= b.volume  &quot;  + &quot; and   NOT (a.seller = b.buyer)  “ + “ and  a.trade  is NULL   and  b.trade  is NULL &quot;; public   class  SectorBasedQueryTargetPolicy  implements  QueryTargetPolicy { public   String []  getTargets( String  query,  Map < Object ,  Object >  params, String  language,  List < String >  slices,  Object  context) {  Stock stock =  null ; if  (TradingService. MATCH_BID .equals(query)) { stock = ((Tradable)params.get(&quot; bid &quot;)).getStock(); return   new  String[]{slices.get(stock.getSector().ordinal())}; } return   null ; } }
Future Work ,[object Object],[object Object],[object Object]
Future Work ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
References ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Thank You!

More Related Content

What's hot

Backendless apps
Backendless appsBackendless apps
Backendless apps
Matteo Bonifazi
 
Java Persistence API
Java Persistence APIJava Persistence API
Java Persistence API
Carol McDonald
 
Oleksandr Valetskyy - DI vs. IoC
Oleksandr Valetskyy - DI vs. IoCOleksandr Valetskyy - DI vs. IoC
Oleksandr Valetskyy - DI vs. IoC
Oleksandr Valetskyy
 
Map-Reduce and Apache Hadoop
Map-Reduce and Apache HadoopMap-Reduce and Apache Hadoop
Map-Reduce and Apache Hadoop
Svetlin Nakov
 
JAXP
JAXPJAXP
Jdbc oracle
Jdbc oracleJdbc oracle
Jdbc oracle
yazidds2
 
Dom
DomDom
Indexing and Query Optimizer (Aaron Staple)
Indexing and Query Optimizer (Aaron Staple)Indexing and Query Optimizer (Aaron Staple)
Indexing and Query Optimizer (Aaron Staple)MongoSF
 
.Net Framework 2 fundamentals
.Net Framework 2 fundamentals.Net Framework 2 fundamentals
.Net Framework 2 fundamentals
Harshana Weerasinghe
 
Ajax chap 5
Ajax chap 5Ajax chap 5
Ajax chap 5
Mukesh Tekwani
 
Intake 38 10
Intake 38 10Intake 38 10
Intake 38 10
Mahmoud Ouf
 
XML & XPath Injections
XML & XPath InjectionsXML & XPath Injections
XML & XPath Injections
AMol NAik
 
Ajax chap 4
Ajax chap 4Ajax chap 4
Ajax chap 4
Mukesh Tekwani
 
The Tools for Data Migration Between Oracle , MySQL and Flat Text File.
The Tools for Data Migration Between Oracle , MySQL and Flat Text File.The Tools for Data Migration Between Oracle , MySQL and Flat Text File.
The Tools for Data Migration Between Oracle , MySQL and Flat Text File.
anysql
 
Ejb3 Dan Hinojosa
Ejb3 Dan HinojosaEjb3 Dan Hinojosa
Ejb3 Dan Hinojosa
Dan Hinojosa
 
JDBC
JDBCJDBC
JDBC
Sunil OS
 

What's hot (19)

Backendless apps
Backendless appsBackendless apps
Backendless apps
 
Java Persistence API
Java Persistence APIJava Persistence API
Java Persistence API
 
Oleksandr Valetskyy - DI vs. IoC
Oleksandr Valetskyy - DI vs. IoCOleksandr Valetskyy - DI vs. IoC
Oleksandr Valetskyy - DI vs. IoC
 
Map-Reduce and Apache Hadoop
Map-Reduce and Apache HadoopMap-Reduce and Apache Hadoop
Map-Reduce and Apache Hadoop
 
JAXP
JAXPJAXP
JAXP
 
Jdbc oracle
Jdbc oracleJdbc oracle
Jdbc oracle
 
Dom
DomDom
Dom
 
Indexing and Query Optimizer (Aaron Staple)
Indexing and Query Optimizer (Aaron Staple)Indexing and Query Optimizer (Aaron Staple)
Indexing and Query Optimizer (Aaron Staple)
 
.Net Framework 2 fundamentals
.Net Framework 2 fundamentals.Net Framework 2 fundamentals
.Net Framework 2 fundamentals
 
Ajax chap 5
Ajax chap 5Ajax chap 5
Ajax chap 5
 
Intake 38 10
Intake 38 10Intake 38 10
Intake 38 10
 
บทที่4
บทที่4บทที่4
บทที่4
 
XML & XPath Injections
XML & XPath InjectionsXML & XPath Injections
XML & XPath Injections
 
Ajax chap 4
Ajax chap 4Ajax chap 4
Ajax chap 4
 
The Tools for Data Migration Between Oracle , MySQL and Flat Text File.
The Tools for Data Migration Between Oracle , MySQL and Flat Text File.The Tools for Data Migration Between Oracle , MySQL and Flat Text File.
The Tools for Data Migration Between Oracle , MySQL and Flat Text File.
 
Ejb3 Dan Hinojosa
Ejb3 Dan HinojosaEjb3 Dan Hinojosa
Ejb3 Dan Hinojosa
 
JDBC
JDBCJDBC
JDBC
 
Lecture17
Lecture17Lecture17
Lecture17
 
B13 Investigating oracle by Julian Dyke
B13 Investigating oracle by Julian DykeB13 Investigating oracle by Julian Dyke
B13 Investigating oracle by Julian Dyke
 

Similar to Slice for Distributed Persistence (JavaOne 2010)

Slice: OpenJPA for Distributed Persistence
Slice: OpenJPA for Distributed PersistenceSlice: OpenJPA for Distributed Persistence
Slice: OpenJPA for Distributed Persistence
Pinaki Poddar
 
ORM JPA
ORM JPAORM JPA
Java Web Programming on Google Cloud Platform [2/3] : Datastore
Java Web Programming on Google Cloud Platform [2/3] : DatastoreJava Web Programming on Google Cloud Platform [2/3] : Datastore
Java Web Programming on Google Cloud Platform [2/3] : Datastore
IMC Institute
 
Introduction to Datastore
Introduction to DatastoreIntroduction to Datastore
Introduction to Datastore
Software Park Thailand
 
Accelerated data access
Accelerated data accessAccelerated data access
Accelerated data access
gordonyorke
 
App Grid Dev With Coherence
App Grid Dev With CoherenceApp Grid Dev With Coherence
App Grid Dev With Coherence
James Bayer
 
App Grid Dev With Coherence
App Grid Dev With CoherenceApp Grid Dev With Coherence
App Grid Dev With CoherenceJames Bayer
 
Application Grid Dev with Coherence
Application Grid Dev with CoherenceApplication Grid Dev with Coherence
Application Grid Dev with Coherence
James Bayer
 
QTP Automation Testing Tutorial 7
QTP Automation Testing Tutorial 7QTP Automation Testing Tutorial 7
QTP Automation Testing Tutorial 7
Akash Tyagi
 
Technical Overview of Apache Drill by Jacques Nadeau
Technical Overview of Apache Drill by Jacques NadeauTechnical Overview of Apache Drill by Jacques Nadeau
Technical Overview of Apache Drill by Jacques Nadeau
MapR Technologies
 
Introducing Struts 2
Introducing Struts 2Introducing Struts 2
Introducing Struts 2
wiradikusuma
 
A SERIAL COMPUTING MODEL OF AGENT ENABLED MINING OF GLOBALLY STRONG ASSOCIATI...
A SERIAL COMPUTING MODEL OF AGENT ENABLED MINING OF GLOBALLY STRONG ASSOCIATI...A SERIAL COMPUTING MODEL OF AGENT ENABLED MINING OF GLOBALLY STRONG ASSOCIATI...
A SERIAL COMPUTING MODEL OF AGENT ENABLED MINING OF GLOBALLY STRONG ASSOCIATI...
ijcsa
 
Tamir Dresher - DotNet 7 What's new.pptx
Tamir Dresher - DotNet 7 What's new.pptxTamir Dresher - DotNet 7 What's new.pptx
Tamir Dresher - DotNet 7 What's new.pptx
Tamir Dresher
 
WSO2 Product Release Webinar: WSO2 Complex Event Processor 4.0
WSO2 Product Release Webinar: WSO2 Complex Event Processor 4.0WSO2 Product Release Webinar: WSO2 Complex Event Processor 4.0
WSO2 Product Release Webinar: WSO2 Complex Event Processor 4.0
WSO2
 
NET Systems Programming Learned the Hard Way.pptx
NET Systems Programming Learned the Hard Way.pptxNET Systems Programming Learned the Hard Way.pptx
NET Systems Programming Learned the Hard Way.pptx
petabridge
 
Java
JavaJava
Data access
Data accessData access
Data access
Joshua Yoon
 
Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)
David McCarter
 
Storage Plug-ins
Storage Plug-ins Storage Plug-ins
Storage Plug-ins buildacloud
 

Similar to Slice for Distributed Persistence (JavaOne 2010) (20)

Slice: OpenJPA for Distributed Persistence
Slice: OpenJPA for Distributed PersistenceSlice: OpenJPA for Distributed Persistence
Slice: OpenJPA for Distributed Persistence
 
ORM JPA
ORM JPAORM JPA
ORM JPA
 
Java Web Programming on Google Cloud Platform [2/3] : Datastore
Java Web Programming on Google Cloud Platform [2/3] : DatastoreJava Web Programming on Google Cloud Platform [2/3] : Datastore
Java Web Programming on Google Cloud Platform [2/3] : Datastore
 
Introduction to Datastore
Introduction to DatastoreIntroduction to Datastore
Introduction to Datastore
 
Accelerated data access
Accelerated data accessAccelerated data access
Accelerated data access
 
App Grid Dev With Coherence
App Grid Dev With CoherenceApp Grid Dev With Coherence
App Grid Dev With Coherence
 
App Grid Dev With Coherence
App Grid Dev With CoherenceApp Grid Dev With Coherence
App Grid Dev With Coherence
 
Application Grid Dev with Coherence
Application Grid Dev with CoherenceApplication Grid Dev with Coherence
Application Grid Dev with Coherence
 
QTP Automation Testing Tutorial 7
QTP Automation Testing Tutorial 7QTP Automation Testing Tutorial 7
QTP Automation Testing Tutorial 7
 
Technical Overview of Apache Drill by Jacques Nadeau
Technical Overview of Apache Drill by Jacques NadeauTechnical Overview of Apache Drill by Jacques Nadeau
Technical Overview of Apache Drill by Jacques Nadeau
 
Introducing Struts 2
Introducing Struts 2Introducing Struts 2
Introducing Struts 2
 
A SERIAL COMPUTING MODEL OF AGENT ENABLED MINING OF GLOBALLY STRONG ASSOCIATI...
A SERIAL COMPUTING MODEL OF AGENT ENABLED MINING OF GLOBALLY STRONG ASSOCIATI...A SERIAL COMPUTING MODEL OF AGENT ENABLED MINING OF GLOBALLY STRONG ASSOCIATI...
A SERIAL COMPUTING MODEL OF AGENT ENABLED MINING OF GLOBALLY STRONG ASSOCIATI...
 
Tamir Dresher - DotNet 7 What's new.pptx
Tamir Dresher - DotNet 7 What's new.pptxTamir Dresher - DotNet 7 What's new.pptx
Tamir Dresher - DotNet 7 What's new.pptx
 
WSO2 Product Release Webinar: WSO2 Complex Event Processor 4.0
WSO2 Product Release Webinar: WSO2 Complex Event Processor 4.0WSO2 Product Release Webinar: WSO2 Complex Event Processor 4.0
WSO2 Product Release Webinar: WSO2 Complex Event Processor 4.0
 
Application Hosting
Application HostingApplication Hosting
Application Hosting
 
NET Systems Programming Learned the Hard Way.pptx
NET Systems Programming Learned the Hard Way.pptxNET Systems Programming Learned the Hard Way.pptx
NET Systems Programming Learned the Hard Way.pptx
 
Java
JavaJava
Java
 
Data access
Data accessData access
Data access
 
Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)
 
Storage Plug-ins
Storage Plug-ins Storage Plug-ins
Storage Plug-ins
 

Recently uploaded

Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 

Recently uploaded (20)

Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 

Slice for Distributed Persistence (JavaOne 2010)

  • 1. Scale Java Persistence API Applications with OpenJPA Slice Pinaki Poddar [email_address]
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8. Architectural tiers of a typical JPA-based application User Application OpenJPA Standard JPA API JDBC API 400 million records
  • 9. Architectural tiers of a Slice-based application User Application OpenJPA Standard JPA API JDBC API Slice OpenJPA is a plugabble platform User-defined Data Distribution Policy 4x100 million records
  • 10. Separate Persistence Unit configured to partitioned databases C A [1] D A Unit A C A [2] C B [1] D B Unit B C B [2] C C [1] D C Unit C C C [2]
  • 11. Same persistence unit switches contexts to partitioned databases C A [1] D A Persistence Unit C A [2] C C [2] C C [1] C B [2] C B [1] D B D C
  • 12. Same persistence unit connected to partitioned databases C[1] D A Persistence Unit C[2] D B D C
  • 13. Features of Slice Slice-based User Application OpenJPA Standard JPA API JDBC API Slice No changes to Application code User-defined Data Distribution Policy Flexible per-Slice Configuration Parallel Query Execution Heterogeneous Databases Master-based Sequence Targeted Query No changes to Domain Model User-defined Query Target Policy No changes to Database Schema 4x100 millon records
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19. Distribution Policy decides target slice for each instance public interface DistributionPolicy { /** * Decide the name of the slice where the given persistent * instance would be stored. * * @param pc The newly persistent or to-be-merged object. * @param slices name of the configured slices. * @param context persistence context managing the given instance. * * @return identifier of the slice. This name must match one of the * configured slice names. * @see DistributedConfiguration#getSliceNames() */ String distribute ( Object pc, List<String> slices, Object context); } Slice runtime will call this method while persisting or merging a root instance. The instance and its persistent closure will be stored in the returned slice.
  • 20. Details on Distribution Policy a b em.persist(a); // or em.merge(a); persistence context MyPolicy.distribute(a,…) { return “One” ; } One One < property name=&quot; openjpa.slice.DistributionPolicy &quot; value=“ acme.org.MyPolicy &quot;/> Slice attaches moniker to managed instance as it enters a persistence context Slice runtime calls User Application CascadeType.PERSIST CascadeType.MERGE c One
  • 21.
  • 23. Instances that violate persistent closure must be replicated Stock CSCO Ask-152 Bid-153 Trader-1 Trader-2 Trade-15 Stock GS Ask-210 Bid-211 Trader-7 Trader-1 Trade-21 slice.One slice.Two Trader-1 will violate collocation constraint and must be replicated across all slices. Data partitioned by Stock sectors
  • 24.
  • 25. Replication Policy public interface ReplicationPolicy { /** * Decide the name of the slices where the given persistent * instance would be replicated. * * @param pc The newly persistent or to-be-merged object. * @param slices name of the configured slices. * @param context persistence context managing the given instance. * * @return identifier(s) of the slice. Each name must match one of the * configured slice names. * @see DistributedConfiguration#getSliceNames() */ String[] replicate ( Object pc, List<String> slices, Object context); } Slice runtime will call this method while persisting any replicated instance.
  • 26.
  • 27. Query Target Policy decides target slice for each query public interface QueryTargetPolicy { /** * Decide the name of the slice(s) where the given query * will be executed. * * @param query The query string to be executed. * @param params the bound parameters of the query. * @param language the language of the query * @param slices name of the configured slices * @param context persistence context executing the query. * * @return identifier of the target slices. Null value implies * all configured slices. */ String[] getTargets ( String query, Map params, String language, List<String> slices, Object context); } Slice runtime will call this method for every query. Default policy targets all available slices.
  • 28. Intrusive way to control target slices for a query EntityManager em = …; String jpql = &quot; SELECT p FROM Person p where p.name=:name ”; TypedQuery <Person> query1 = em.createQuery(jpql, Person. class ); // Set a single slice as query target query1.setHint( SlicePersistence.HINT_TARGET , “ One &quot;); List < Person > result1 = query1.setParameter(“ name ”, “ XYZ ”) .getResultList(); TypedQuery <Person> query2 = em.createQuery(jpql , Person. class ); // Set multiple slices as query targets query2.setHint( SlicePersistence.HINT_TARGET , Arrays.asList( new String []{“ One “,” Two ”}); List < Person > result2 = query2.setParameter(“ name ”, “ ABC ”) .getResultList();
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38. META-INF/persistence.xml configures a persistence unit <? xml version=&quot; 1.0 &quot; encoding=&quot; UTF-8 &quot;?> < persistence xmlns=&quot; http://java.sun.com/xml/ns/persistence &quot; xmlns:xsi=&quot; http://www.w3.org/2001/XMLSchema-instance &quot; version=&quot; 1.0 &quot; xsi:schemaLocation=&quot; http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd &quot;> < persistence-unit name=&quot; test “ transaction=“ RESOURCE_LOCAL ”> < provider > org.apache.openjpa.persistence.PersistenceProviderImpl </ provider > < class > domain.EntityA </ class > < class > domain.EntityB </ class > < properties > < property name=&quot; openjpa.ConnectionDriverName &quot; value=&quot; com.mysql.jdbc.Driver &quot;/> < property name=&quot; openjpa.ConnectionURL &quot; value=&quot; jdbc:mysql://localhost/test &quot;/> < property name=&quot; openjpa.jdbc.SynchronizeMappings &quot; value=&quot; buildSchema &quot;/> < property name=&quot; openjpa.Log &quot; value=&quot; SQL=TRACE &quot;/> </ properties > </ persistence-unit > List of known Persistent types Vendor-specific configuration Governed by XML Schema JPA Provider is pluggable Identified by Unit Name
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47. A complete example of Slice Configuration < properties > < property name=&quot; openjpa.BrokerFactory &quot; value=“ slice &quot;/> < property name=“ openjpa.slice.Names ” value=“ One,Two,Three ”/> < property name=“ openjpa.slice.Master ” value=“ One ”/> < property name=&quot; openjpa.ConnectionDriverName &quot; value=&quot; com.mysql.jdbc.Driver &quot;/> < property name=&quot; openjpa.slice.One.ConnectionURL &quot; value=&quot; jdbc:mysql://mac1:3456/slice1 &quot;/> < property name=“ openjpa.slice.Two.ConnectionURL ” value=“ jdbc:mysql://mac2:5634/slice2 ”/> < property name=“ openjpa.slice.Three.ConnectionDriverName ” value=“ com.ibm.db2.jcc.DB2Driver ”/> < property name=“ openjpa.slice.Three.ConnectionURL ” value=“ jdbc:db2 :// mac3:50000/slice3 ”/> < property name=&quot; openjpa.slice.DistributionPolicy &quot; value=“ acme.org.MyDistroPolicy &quot;/> < property name=&quot; openjpa.jdbc.SynchronizeMappings &quot; value=&quot; buildSchema &quot;/> </ properties > </ persistence-unit > META-INF/persistence.xml Activate Slice Declare slices Configure each slice Configure common behavior Define Data Distribution Policy
  • 48.
  • 49.
  • 50.
  • 51. Core Architectural constructs of OpenJPA EntityManager Factory BrokerFactory EntityManager Broker StoreManager JDBCStore Manager JDBC API OpenJPA Configuration creates creates delegates delegates configured by facade kernel storage POJO + State manager
  • 52. Slice extends OpenJPA by Distributed Template EntityManager Factory BrokerFactory EntityManager Broker DistributedStoreManager JDBCStore Manager JDBC API JDBCStore Manager JDBCStore Manager Distributed Configuration applies Distributed Template Pattern Not aware of partitioned Databases applies Distributed Template Pattern OpenJPA Configuration OpenJPA Configuration OpenJPA Configuration + Slice Moniker facade kernel storage POJO + State manager
  • 53.
  • 54.
  • 55.
  • 57. An example data distribution policy /** * This distribution policy determines the sector of the stock and * picks the slice at ordinal index of the enumerated Sector. */ public class SectorDistributionPolicy implements DistributionPolicy { public String distribute( Object pc, List < String > slices, Object context) { Stock stock = null ; if (pc instanceof Tradable ) { stock = (( Tradable )pc).getStock(); } else if (pc instanceof Stock ) { stock = ( Stock )pc; } else if (pc instanceof Trade ) { stock = (( Trade )pc).getStock(); } else { throw new IllegalArgumentException(“ No policy for “ + pc); } return stock != null ? slices.get(stock.getSector().ordinal()) : null ; } }
  • 58. An example query target policy public static final String MATCH_BID = &quot; select new Match(a,b) from Ask a, Bid b &quot; + &quot; where b = :bid and a.stock.symbol = b.stock.symbol &quot; + &quot; and a.price <= b.price and a.volume >= b.volume &quot; + &quot; and NOT (a.seller = b.buyer) “ + “ and a.trade is NULL and b.trade is NULL &quot;; public class SectorBasedQueryTargetPolicy implements QueryTargetPolicy { public String [] getTargets( String query, Map < Object , Object > params, String language, List < String > slices, Object context) { Stock stock = null ; if (TradingService. MATCH_BID .equals(query)) { stock = ((Tradable)params.get(&quot; bid &quot;)).getStock(); return new String[]{slices.get(stock.getSector().ordinal())}; } return null ; } }
  • 59.
  • 60.
  • 61.