|
OverviewThis section discusses client applications that:
With this configuration, JavaSpaces API can still specify object data to read by template or by SQLQuery. However, RegExQuery templates are not supported.
Hibernate CacheLoader/Store DriverThe Hibernate ServiceHibernate is an Object-Relational Mapping (ORM) persistence and query service for the Java language. It is free, open-source software that is distributed under the LGPL. It provides an easy to use framework for mapping an object-oriented domain model to a traditional relational database. Hibernate allows you to express queries in its own portable SQL extension (HQL), as well as in native SQL, or with an object-oriented Criteria and Example API. The Hibernate CacheLoader/Store driver is an implementation of the generic CacheLoader/Store Interface that automatically activates a full Hibernate session to perform read/write functionality to a database. Both JavaSpace API and Map API space read/write operations interface seamlessly with it. Legacy Hibernate InstallationsThe Hibernate CacheLoader/Store driver is especially suited for users with legacy Hibernate installations. It lets you preserve your Hibernate domain classes and HBM mapping configuration file investment while allowing you to take advantage of the SBA data exchange , data caching , data collaboration , messaging , clustering , high-availability, notifications, and SQL query capabilities. Read-Through - Hibernate CacheLoader
The figure above illustrates how a client application reads or takes a single entry from the space that matches a given template or SQL Query where the actual data is loaded from a database. In this case the Hibernate CacheLoader is called. The JavaSpaces API is used as an example.
Write-Through - the Hibernate Cache Store
The figure above illustrates how a client application writes a single Entry object to the space and persists the data in a database. The space writes the Entry data into the database using the Hibernate CacheStore plug-in. The JavaSpace API is used as an example.
Migrating Legacy Hibernate API Applications to JavaSpaces APITo benefit from data caching and other capabilities, it is worthwhile to migrate a legacy application that uses the Hibernate API, to either the GigaSpaces Map API or the JavaSpaces API. In such cases, these applications can benefit from the ability to scale when using the GigaSpaces Data Grid. This is achieved by partitioning the data across different spaces running on different machines, and having the business logic also running with each partition. This allows the space and the business logic to run in same memory address, eliminating remote calls when accessing the data. The following tables show the correspondence between the Hibernate basic API methods to GigaSpaces Map/JavaSpaces API methods. org.hibernate.Session to IJSpace Mapping
org.hibernate.Session to IMap Mapping
Hibernate CacheLoader/Store Usage ConsiderationsDatabase Changes are Not Reflected at the SpaceApplication accessing the database directly performing insert, updates or data removal operations are not propagated to space – the space is unaware of the operations conducted within the database. You may use database triggers or database replication facilities to update the space with such changes.
Hibernate CacheLoader and the Mirror ServiceThe Hibernate CacheStore updates the database with new space objects, updated objects or objects that have been removed before the space provide acknowledge to the client – this means the client operation against the space cannot be completed until the database has been fully updated. This impose serious performance impact when performing space destructive operations (write, take, or update; put or remove with the map API). To minimize the performance impact you can perform all relevant database operations in asynchronous manner without impacting the "run time" space operation. All run time destructive operation are replicated in asynchronous manner to a space that is dedicated to perform the database operations in bulk mode – the mirror space. You can control the replication event execution duration interval and replication batch size via the mirror service settings. To perform data load into the run time space in lazy manner the run time space should be configured to use the Hibernate CacheLoader. This will allow the application to retrieve the required data from the database in case it cannot be found as part of the space. Data from the space can be evicted based on maximum space cached object amount, based on space JVM heap size or based on Entry lease time (this will be supported in future version). The run time space and the Mirror Service sharing the same database server. Data Consistency Across Space and DatabaseWhen the space interacts with the database, the space maintains a consistent view across the space and the database, in case of a database operation failure, i.e., an operation in the space is reverted and the relevant com.j_spaces.core.sadapter.SAException is thrown back into the client, when the HibernateCacheLoader/Store fails to interact with the database. When the HibernateCacheLoader/Store fails to interact with the database, the operation in the space is reverted and the relevant com.j_spaces.core.sadapter.SAException is thrown back into the client. Transaction SupportAll client operations conducted with a transaction are delegated into the database via one database transaction using the HibernateCacheStore.(List<BulkEntry> bulk) implementation when the commit is called. Extending the Hibernate CacheLoader/StoreYou can extend the existing Hibernate CacheLoader/Store and add your own business logic on top of it. Configuration Files and Space Classpath
Space Entry and Hibernate Object MappingWhen using an Entry class with the HibernateClassLoader/Store, the space checks for an Entry fields list, when performing client space operations and when performing data load from the database. Both of these operations must represent the same Entry field list. When loading data from the database, the Entry fields list is determined by the getter and setter methods. When performing space operations, the Entry fields list is determined based on the public fields. A public field for an Entry class that does not have getter or setter methods, is not recognized by Hibernate, so it isn't persistent. This will cause inconsistency when reading back from the database into the space, and an UnusableEntryException will be thrown. In this case you should have the field as private or have a getter or setter for it.
Initial LoadWhen a space running in persistent mode (i.e. using HibernateCacheLoader or HibernateCacheStore implementation) is started, the space trying to load data from its underlying data source. The amount of data to be loaded is 50% of the space cache max size. To disable this initial load phase you should configure the initial_load value to be 0. Space configuration schema tag: <space-config> <engine> <initial_load>0</initial_load> </engine> </space-config> XPATH property: space-config.engine.initial_load=0 The space schema file does not have the above tag by default. You should add it into the correct location. Libraries and their LocationThe following libraries are required when using GigaSpaces Hibernate CacheLoader/Store:
|
Wiki Content Tree
Your Feedback Needed!
We need your help to improve this wiki site. If you have any suggestions or corrections, write to us at techw@gigaspaces.com. Please provide a link to the wiki page you are referring to.


Add Comment