Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question

Mirror not loading data into space

Using this:

and this:

as guides, I was able to get a mirror service setup and working in a very simple scenario... or so I thought. I can create domain objects that are successfully mirrored to a database, however when I shut everything down and restart the mirror, the data is not being loaded back into the space and therefore not accessible to the client application that uses the space.

Here is my current setup

Mirror Configuration
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost:3306/guildman"/>
        <property name="username" value="root"/>
        <property name="password" value=""/>

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="mappingLocations">
        <property name="hibernateProperties">
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
                <prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
                <prop key="hibernate.cache.usesecondlevel_cache">false</prop>
                <prop key="hibernate.cache.usequerycache">false</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>

<bean id="hibernateDataSource" class="com.gigaspaces.datasource.hibernate.HibernateDataSource">
        <property name="sessionFactory" ref="sessionFactory"/>

<os-core:space id="space" url="/./mirror-service" schema="mirror" external-data-source="hibernateDataSource"/>

Space Configuration
<os-sla:sla cluster-schema="partitioned-sync2backup" number-of-instances="1" number-of-backups="1" max-instances-per-vm="1"/>

<os-core:space id="space" url="/./primaryDataSpace" mirror="true" />

I certainly have a lot more to learn, but it was my understanding that the primaryDataSpace would automatically be populated with the data via the mirror. Is this incorrect? Is there a step I'm missing that explicitly tells the primaryDataSpace to use the mirror to load the data?


This thread was imported from the previous forum.
For your reference, the original is available here

asked 2008-04-30 23:59:04 -0500

mwelch gravatar image

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

Hi Matt,

The Mirror service is storing data from the spaces into the database (or other persisteny mechanism). The direction is one way from the space towards the storage (through the Mirror service).

In order to load data you'll need to make sure the PUs which include the spaces have an External Data Soruce configured.

Please take a look at the Reading from the Mirror Data Source section in http://www.gigaspaces.com/wiki/display/GS6/OpenSpacesPersistencyScenarios-Mirror


answered 2008-05-01 01:28:58 -0500

nirpaz gravatar image
edit flag offensive delete link more


Ok, I'm confused. Looking at that example it would seem to indicate that I need to have two separate spaces for my data? One that I use just for persisting the data to the database via mirror and the other that is used for reading the data from database? That can't be right. I must be misunderstanding something as that would seem to contradict Mirror diagrams I've seen.

The link you provided has this as the space configuration for reading from an external data source:

<os-core:space id="space" url="/./mySpace" schema="persistent" external-data-source="hibernateDataSource"> <os-core:properties> <props> <prop key="space-config.engine.cache_policy">1</prop>
<prop key="space-config.external-data-source.usage">read-only</prop> <prop key="-Dcom.gs.cluster.cache-loader.external-data-source">true</prop> <prop key="-Dcom.gs.cluster.cache-loader.central-data-source">true</prop> </props> </os-core:properties> </os-core:space>

Is it possible to change that first line of this configuration to be: <os-core:space id="space" url="/./mySpace" schema="persistent" external-data-source="hibernateDataSource" mirror="true">

That, at least, would mean I only one space would be needed for reading and writing to the datasource, which is what the Mirror diagrams would seem to indicate is possible: http://www.gigaspaces.com/wiki/displa...


Edited by: Matthew Welch on May 1, 2008 11:58 AM

mwelch gravatar imagemwelch ( 2008-05-01 10:55:29 -0500 )edit

Lets make an order here: The Mirror is not a real space. It looks like a space , configured like a space, smells like a space , but it is not a real space. It does not store the incoming data replicated from the primary space. It is not even triggers its statistics filter , it simply push it out. It acts as a dispatcher. That?s it.

When you want to have a full cycle of pushing data out via the mirror and later loading it back to the space once started you need to have the following: - Mirror configured to use ExternalDataSource implementation. - Your Spaces to be configured to use ExternalDataSource implementation + run in "Mirror" mode to allow them to replicate their operations to the Mirror. These will call their ExternalDataSource.initialLoad method when started to load relevant data from the database. Loaded data as a result of the ExternalDataSource.initialLoad call would NOT be replicated to the Mirror ? so you would not have cyclic loop/resonance affect here.

You can use the same ExternalDataSource implementation for both the Mirror and the Spaces or different ones.

Please note you can use enhanced Hibernate Data Source implementation from here: ftp://ftp.gigaspaces.com/enhanced_HibernateDataSource/ user/pass: public/public


shay hassidim gravatar imageshay hassidim ( 2008-05-01 13:30:12 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2008-04-30 23:59:04 -0500

Seen: 96 times

Last updated: May 01 '08