Skip to content
GigaSpaces Logo GigaSpaces Logo
  • Products
    • InsightEdge Portfolio
      • Smart Cache
      • Smart ODS
      • Smart Augmented Transactions
    • GigaSpaces Cloud
  • Roles
    • Architects
    • CXOs
    • Product Teams
  • Solutions
    • Industry Solutions
      • Financial Services
      • Insurance
      • Retail and eCommerce
      • Telecommunications
      • Transportations
    • Technical Solutions
      • Operational BI
      • Mainframe & AS/400 Modernization
      • In Memory Data Grid
      • Transactional and Analytical Processing (HTAP)
      • Hybrid Cloud Data Fabric
      • Multi-Tiered Storage
      • Kubernetes Deployment
      • Streaming Analytics for Stateful Apps
  • Customers
  • Company
    • About GigaSpaces
    • Customers
    • Partners
    • Support & Services
      • University
      • Services
      • Support
    • News
    • Contact Us
    • Careers
  • Resources
    • Webinars
    • Blog
    • Demos
    • Solution Briefs & Whitepapers
    • Case Studies
    • Benchmarks
    • ROI Calculators
    • Analyst Reports
    • eBooks
    • Technical Documentation
  • Contact Us
  • Try Free

Integrating GigaSpaces Persistency Service into Existing Tier-Based System

Subscribe to our blog!

Subscribe for Updates
Close
Back

Integrating GigaSpaces Persistency Service into Existing Tier-Based System

Mickey Ohayon April 23, 2008
5 minutes read

A common issue I’m facing recently is how to integrate existing tier-based applications with GigaSpaces persistency service, AKA persistency as a service (Paas) or mirror . The motivation is often a result of the acknowledgment that a standard tier based application fails to scale when facing the database throughput limitation.

Software Caching technologies (overlooking their complexity and maintenance they add to the stack) are useful for read operations. You’ll find out quite fast that operations as insert or update under a transaction require synchronous disk write operations, which are expensive both in performance and cost perspectives. Storage devices (NAS/DAS) together with database clustering software are becoming major investments for large-scale applications.

GigaSpaces XAP/EDG provides both caching and persistency services based on its memory virtualization capability. GigaSpaces XAP/EDG simply utilize the available machine’s memory on the cloud (grid computing). Using the space as a fast clustered in-memory entity, the transactions are replicated into a minimum of two separate physical machines. The persistency service is an asynchronous (thus out of the latency path) service that stores the data into the disk using the CacheStore interface.

Now comes our out of the box Hibernate CacheStore implementation, where once the mirror service is configured to use Hibernate, it will store the data asynchronously based on the hibernate mapping files (*.hbm.xml) that contain the object-relational mapping metadata.

The nice thing about using Hibernate and GigaSpaces is that the combination of the two provides a non-intrusive way to keep your programming model and services as POJOs (plain old java objects) that are abstracted from the caching or disk implementation. This is done by either using annotations or external XML descriptor files.

So after reviewing the theory, I thought you might be interested in a practical example, showing how to integrate GigaSpaces mirror service into an existing tier-based application; see below.
Example: Integrating GigaSpaces Mirror Service into an Existing Tier Based Application

The Hibernate mapping implementation is encapsulated in GigaSpaces mirror service, meaning this can be a non-intrusive procedure in existing projects. Using hibernate-tools you can auto-generate your Pojo sources and hbm files using existing database tables just by configuring the database connection.

There are 2 options of using hibernate tools:

  1. Using a simple ant + hibernate tools jar file.
  2. Using an up to date eclipse plug-in; more details.

This example uses option one, which requires the download of the workshop toolset; download.

Note: this is an old implementation of hibernate tools, but a very lightweight version, which I find sometimes to be more efficient as appose to play with eclipse plug-ins that might end up with eclipse malfunctioning.

Install & config:

  • Unzip the workshop_tools tar.gz file into a working directory
  • Make sure ant is installed (http://ant.apache.org/)
  • Configure the build.xml to match your JDBC and package settings

Adding a usage target to the build.xml will give you a nice default option menu:
<target name=”usage”>
        <echo message=””/>
        <echo message=”Integrating GigaSpaces build script”/>
        <echo message=”—————————————–“/>
        <echo message=””/>
        <echo message=”Among the available targets are:”/>
        <echo message=””/>
        <echo message=”clean  –> Delete all generated demo files.”/>
        <echo message=”bottomup.middlegen –> Run Middlegen and generate Hibernate mapping files.”/>
        <echo message=”bottomup.hbm2java  –> Generate .java from .hbm files.”/>
        <echo message=”gui.hibernate  –> Run hibern8ide for ad-hoc queries.”/>
        <echo message=””/>
    </target>
Remember to point usage target as default target:
<project name=”workshop-toolset” default=”usage” >
Running ant should produce the following:
step1x.jpg
Step one:
Doing some “reverse engineering” by creating hibernate mapping files (hbm.xml) files out of existing database tables

  • Configure the target using your JDBC properties (set the package to your preference)
  • Execute Ant bottomup.middlegen command

Update the build.xml jdbc configuration:
<target
        name=”bottomup.middlegen”
        description=”Run Middlegen and generate Hibernate mapping files.”>
        <middlegen
            appname=”Toolset”
            prefsdir=”${basedir}”
            gui=”true”
            databaseurl=”jdbc:mysql://localhost:3306/test”
            driver=”com.mysql.jdbc.Driver”
            username=”root”
            password=”1234″>
            <hibernate
                destination=”${gensrc.dir}”
                package=”org.hibernate.workshop.toolset”/>
        </middlegen>
    </target>
Running: ant bottomup.middlegen
Step 2
Select the tables you wish to generate object from and click Generate
Step 3
Note: since this is an old hibernate tools version, you’ll need to update the DOCTYPE header to:
<!DOCTYPE hibernate-mapping PUBLIC “-//Hibernate/Hibernate Mapping DTD 3.0//EN”
“http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd”>
Step two:
Create the POJOs out of the created hibernate mapping files (see: Step one)

  • Using Ant bottomup.hbm2java command
  • Create GigaSpaces mapping files (gs.xml); see instructions
  • Or use GigaSpaces annotations; see instructions

Step three:
Enabling the mirror service; see details and instructions.
Optional:
Using the hibernate gui to validate the hibernate.config.xml and query the DB:
>ant gui.hibernate:
Step 4
Step 5
If you’re interested in some further reading, here is a useful link for Hibernate ORM users.
I’d be happy to hear your thoughts, or try it out and let me know how it worked for you!
Mickey.

CATEGORIES

  • Application Architecture
  • Application Performance
  • Caching
  • Data Grid
  • Development
  • GigaSpaces
  • Hibernate
  • J2EE
  • Java
  • JavaSpaces
  • sba
  • SOA
  • space-based architecture
Mickey Ohayon

All Posts (2)

YOU MAY ALSO LIKE

October 29, 2008

Need scalability? Don’t forget pricing
5 minutes read

March 10, 2010

New Service Grid Admin API…
1 minutes read

June 26, 2012

Elephants and Eyeballs: Real-Time Big…
9 minutes read
  • Copied to clipboard

PRODUCTS, SOLUTIONS & ROLES

  • Products
  • InsightEdge Portfolio
    • Smart Cache
    • Smart ODS
    • Smart Augmented Transactions
    • Compare InsightEdge Products
  • GigaSpaces Cloud
  • Roles
  • Architects
  • CXOs
  • Product Teams
  • Solutions
  • Industry
    • Financial Services
    • Insurance
    • Retail and eCommerce
    • Telecommunications
    • Transportation
  • Technical
    • Operational BI
    • Mainframe & AS/400 Modernization
    • In Memory Data Grid
    • HTAP
    • Hybrid Cloud Data Fabric
    • Multi-Tiered Storage
    • Kubernetes Deployment
    • Streaming Analytics for Stateful Apps

RESOURCES

  • Resource Hub
  • Webinars
  • Blogs
  • Demos
  • Solution Briefs & Whitepapers
  • Case Studies
  • Benchmarks
  • ROI Calculators
  • Analyst Reports
  • eBooks
  • Technical Documentation
  • Featured Case Studies
  • Mainframe Offload with Groupe PSA
  • Digital Transformation with Avanza Bank
  • High Peak Handling with PriceRunner
  • Optimizing Business Communications with Avaya

COMPANY

  • About
  • Customers
  • Management
  • Board Members
  • Investors
  • News
  • Events
  • Careers
  • Contact Us
  • Book A Demo
  • Try GigaSpaces For Free
  • Partners
  • OEM Partners
  • System Integrators
  • Value Added Resellers
  • Technology Partners
  • Support & Services
  • University
  • Services
  • Support
Copyright © GigaSpaces 2021 All rights reserved | Privacy Policy
LinkedInTwitterFacebookYouTube

Contact Us