How to use WebSphere eXtreme Scale in front of a database
<div xmlns="http://www.w3.org/1999/xhtml"><span style="font-family: Times; font-size: medium; line-height: normal; "><p style="padding-top: 7px; padding-right: 7px; padding-bottom: 7px; padding-left: 7px; background-color: #ffffff; font: normal normal normal 13px/1.22 arial, helvetica, clean, sans-serif; font-family: 'Trebuchet MS', Verdana, sans-serif; font-size: small; "><p>This is a very common scenario. The customer wants a Map to reflect entries in a database table. They want:</p>
<p></p>
<ol>
<li>To preload database records in to the grid map</li>
<li>Lazy fetch anything not preloaded in to the grid map</li>
<li>Write any changes to entries in the map back to the database</li>
</ol>
<p>The <a href="http://github.com/bnewport/Samples/tree/master/sample-jpa-preload/" style="color: blue !important; text-decoration: underline !important; cursor: text !important; ">sample on github</a> shows how to do this. This sample uses the wxsutils library on github also. This contains code for several patterns and makes using WXS easier. The main things used by this sample are the bulk load primitives in the wxsutils library.</p>
<p>The sample as is works on the command line and uses a mysql database. OpenJPA 1.2 is used as an object relational mapper which means you can substitute DB2 or Oracle pretty easily. There is no mysql specific code in the main sample. I do register the mysql driver in the code.</p>
<p>The main package includes the <a href="http://github.com/bnewport/Samples/blob/master/sample-jpa-preload/src/main/resources/objectgrid.xml" style="color: blue !important; text-decoration: underline !important; cursor: text !important; ">objectgrid.xml</a> and <a href="http://github.com/bnewport/Samples/blob/master/sample-jpa-preload/src/main/resources/deployment.xml" style="color: blue !important; text-decoration: underline !important; cursor: text !important; ">deployment.xml</a> files showing how to make the grid with one Map (Customer) with an attached Loader. The Loader uses the builtin JPALoader. This Loader converts Map.get and map.update/delete methods to SQL commands to the database. The META-INF folder has the <a href="http://github.com/bnewport/Samples/blob/master/sample-jpa-preload/src/main/resources/META-INF/persistence.xml" style="color: blue !important; text-decoration: underline !important; cursor: text !important; ">persistence.xml</a> file which points at the database to use with the program.</p>
<p>The test package contains code to <a href="http://github.com/bnewport/Samples/blob/master/sample-jpa-preload/src/test/java/com/devwebsphere/TestPreloadDatabaseFromFile.java" style="color: blue !important; text-decoration: underline !important; cursor: text !important; ">create a database table and fill it with records</a> for the test. There is another test case that shows <a href="http://github.com/bnewport/Samples/blob/master/sample-jpa-preload/src/test/java/com/devwebsphere/TestSimplePreloadGridFromDatabase.java" style="color: blue !important; text-decoration: underline !important; cursor: text !important; ">how to preload</a> the database table in to a Map efficiently (using WXSUtils WXSMap.insertAll). The final test case just shows us looking up records in WXS.</p>
<p>For very large record sets then it may be necessary to fetch the records in a parallel fashion for highest speed but for reasonable numbers of records (I tested with 300k records on my laptop), the approach in this simple sample should suffice.</p>
<br></p></span></div>
About Billy Newport
Billy is a Distinguished Engineer at IBM. He's been at IBM since 2001. Billy was the lead on the WorkManager/ Scheduler APIs which were later standardized by IBM and BEA and are now the subject of JSR 236 and JSR 237. Billy lead the design of the WebSphere 6.0 non blocking IO framework (channel framework) and the WebSphere 6.0 high availability/clustering (HAManager). Billy currently works on WebSphere XD and ObjectGrid. He's also the lead persistence architect and runtime availability/scaling architect for the base application server.
Before IBM, Billy worked as an independant consultant at investment banks, telcos, publishing companies and travel reservation companies. He wrote video games in C and assembler on the ZX Spectrum, Atari ST and Commodore Amiga as a teenager. He started programming on an Apple IIe when he was eleven, his first programming language was 6502 assembler.
Billys current interests are lightweight non invasive middleware, complex event processing systems and grid based OLTP frameworks.
NFJS, the Magazine
July Issue Now Available- Enterprise Security with Identity Access Management
by Rohit Bhardwaj - The Secret to Building Highly Available Systems
by Mark Richards - Polyglot OSGi, Part 2
by Matt Stine - On Writing a Groovy DSL
by Raju Gandhi