|
Search CCF4XAP
Browse CCF4XAP
|
Summary: Cloud Data Persistency
OverviewWhen running your application on the cloud you may store your application data within the IMDG and also persist it into a Database for long term storage. One your data is stored within the database it can be used for recoverability after a complete shutdown, complex reporting or Data-Mining. The application may store all its data within the IMDG (run in ALL_IN_CACHE Cache policy) or evict some of it, while all the data stored within the database. You may evict data from the IMDG by running in LRU Cache policy mode or have a limited lease for the object when writing it into the IMDG. Persistency on the cloud supported via the following:
Operations within the IMDG are persistent in synchronous manner into a mySQL database running on the cloud.
Operations within the IMDG are persistent in Asynchronous manner via the Mirror Service that is storing the data into a mySQL database running on the cloud. In both cases the mySQL database configured to use EBS. You may configure MySQL connection information and relevant EBS volume-id. How Persistency on the Cloud Works?When a database machine is started on the cloud the following happens:
When the IMDG configured to use External Data Source the following happens:
How to enable Persistency on the Cloud?To enable persistency you should go through the following:
The machine host name running the database server will be injected during the deployment time via the deployment process. To allow the deployment process to inject the database machine host name you should use the $mirror-url as part of the database connection URL. This would be used as part of the space processing unit pu.xml and the mirror pu.xml. Cloud Application Deployment File Settings | Database Initialization Script | Database Creation Commands | Database Configuration file | Mirror Override File | Mirror PU | IMDG PU General Settings | Mirror and IMDG PU External Data Source Settings
Cloud Application Deployment File SettingsTo enable the Persistency, the Cloud application deployment file should include the following settings:
Database Initialization ScriptThe Database Initialization file mirror-init-file.sh calls the database tables creation commands. It should have the following commands: The mirror-init-file.sh #!/bin/bash /etc/init.d/mysql restart # Creating database mysql < /home/gsadmin/createDB.sql /etc/init.d/mysql restart Database Creation CommandsThis Command script used to create database schema tables (i.e. createDB.sql). GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost' IDENTIFIED BY 'password'; These should be called by the Mirror init script. Database Configuration fileThe database configuration file includes the specific settings you would like the database server to use when started. MySQL Database configuration file [mysqld] innodb_file_per_table datadir = /vol/lib/mysql log_bin = /vol/log/mysql/mysql-bin.log max_binlog_size = 1000M log_slow_queries = /vol/log/mysql/mysql-slow.log long_query_time = 10 lower_case_table_names=1 Mirror Override FileThe Mirror Override File used by the GSC running on the database machine. This override file marks this GSC with the special property that instructs the GSM to provision the Mirror Service into a specific machine and not arbitrary GSC. The mirror-override.xml <overrides>
<Component Name="org.jini.rio.qos">
<Parameter Name="addPlatformCapabilities">
<![CDATA[
new org.jini.rio.qos.capability.PlatformCapability[] {
new org.jini.rio.qos.capability.software.SoftwareSupport(
new Object[]{"Name", "Mirror"})
}
]]>
</Parameter>
</Component>
</overrides>
The "Name" property with the above specifies the "Mirror". This matches the Mirror PU SoftwareSupport sla used with the Mirror PU. Mirror PUThe pu.xml used to deploy the Mirror Service should include the following sla that instruct the GSM to provision the Mirror into the GSC that is using the above override: The Mirror pu.xml <beans <os-sla:sla number-of-instances="1"> <os-sla:requirements> <os-sla:system name="SoftwareSupport"> <os-sla:attributes> <entry key="Name" value="Mirror" /> </os-sla:attributes> </os-sla:system> </os-sla:requirements> </os-sla:sla> <os-core:space id="space" url="/./mirror-service" schema="mirror" external-data-source="hibernateDataSource"/> </beans> IMDG PU General SettingsThe IMDG should specify the EDS settings. These should be:
The IMDG PU General Settings should include the following: IMDG pu.xml <beans <os-core:space id="space" url="/./space" schema="persistent" mirror="true" external-data-source="hibernateDataSource"> <os-core:properties> <props> <!-- Use ALL IN CACHE - Read Only from the database--> <prop key="space-config.engine.cache_policy">1</prop> <prop key="space-config.external-data-source.usage">read-only</prop> <prop key="cluster-config.cache-loader.external-data-source">true</prop> <prop key="cluster-config.cache-loader.central-data-source">true</prop> </props> </os-core:properties> </os-core:space> </beans>
Mirror and IMDG PU External Data Source SettingsThe Mirror and the IMDG (Space) PU configuration file (pu.xml) should use the following variables as part of the Database connections settings: These variable values will be injected during the deployment time. See below example how these variables should be used as part of the Mirror and the IMDG pu.xml: pu.xml with Database connection settings <beans>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${data-source-driver}"/>
<property name="url" value="${data-source-url}"/>
<property name="username" value="${data-source-username}"/>
<property name="password" value="${data-source-password}"/>
<property name="maxActive" value="100"/>
<property name="initialSize" value="10"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="annotatedClasses">
<list>
<value>com.example.Class1</value>
<value>com.example.Class2</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
<prop key="hibernate.cache.use_second_level_cache">false</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<bean id="hibernateDataSource" class="org.openspaces.persistency.hibernate.StatelessHibernateExternalDataSource">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
</beans>
Snapshoting
The above is relevant for the database machine profile allowing the database server to have its files recovered prior having the database processes been started. The database machine supports two initialization options:
When to Snapshot your data?
In the future we will provide enhanced snapshot management that will handle snapshot in automatic manner. See more about Amazon EBS Volumes and Snapshots. Required librariesMake sure the PU running the IMDG (Space) and the PU running Mirror would have the following as part of their shared-lib folder:
ExampleIMDG with Synchronous-Persistency TopologyHere are examples files you may use to deploy IMDG with Synchronous-Persistency Topology:
This example will deploy IMDG PU and a Feeder PU on the cloud. The Feeder will be writing data into the IMDG. The objects stored within the IMDG will be persistent in Synchronous manner into a MySQL Database running on the cloud. IMDG with Asynchronous-Persistency TopologyHere are examples files you may use to deploy IMDG with Asynchronous-Persistency Topology:
This example will deploy IMDG PU , Mirror PU and a Feeder PU on the cloud. The Feeder will be writing data into the IMDG. The objects stored within the IMDG will be persistent in Asynchronous-Synchronous manner via the Mirror into a MySQL Database running on the cloud. |
Cloud Data Persistency
(None)



Add Comment