The road so far….

July 1, 2010

Gigaspace Concepts: Space, Miror Space and Persistance

Filed under: java — Tags: — Rahul Sharma @ 8:38 pm

I have been using GigaSpace for some amount of time now and I must admit the product seems to 99% there but for the rest you have to scratch your own itch. It offers quite a lot but also lacks some basic stuff like testing support.

Since there is no inherent testing support in the package so we tried to make a sort of solution by making the Space up in the test case, running it and then getting the data out in the test case.  While doing so we initially though we would require three things “the space”,  a “mirror space” which is proxy to the space and a “persistence” where the data can be pulled for assertion.

But actually we ended up using “space” and “persistence” only. The three things viz space, mirror space , persistence are independent concepts and can be coupled with one another independently of the third or with third depending on the scenario. So here I will try to take a  shot at explaining the three.

The Space

The space is some kind of a bus or repository running in some GigaSpace container where every data object that arrives in the system is written/updated and is consequently picked up for processing by some unit. It can be created within the so-called “Processing Unit” in such a case it is called “The Embedded space”” or it can be created separately from the container as “Enterprise Data Grid“. In any case of space creation there are a couple of attributes that can be specified, using the GigaSpace UI or java code, that can cause a space to behave differently e.g. persistence, partitioned attributes etc.

As a practice we should try to create a partitioned space. This would allow us to scale the application as the load varies. Just enabling the support for the same is good enough, we may or may not use it in our various environments. But If you do not enable the support for the same then enabling it at the end would make your life quite difficult. Enabling it is just a matter of putting a routing info in your data objects .

Mirror Space

The mirror space is a copy of your application space,”The Space”. You can define a mirror space and then connect it to you application space. Every event that happens on the application space gets replicated  asynchronously to the mirror space as well. Since it is a copy of your space you can work with it as you like. Operations like saving it to the database for audit purpose or logging it can be executed in bulk on this data. These operations do not affect the processing of your application space data in any manner.


Persistence is a behaviour of a space, be it of any kind embedded space, enterprise data grid or mirror space.  It can be defined using the ExternalDataSource and connected to the space. It will gets synchronously called when ever there is some event on the  associated space. It can be used to persist data, log data etc.

Now when we implemented tests for our application running on GigaSpace we defined an embedded space and then attached a persistance  to it. The persistance logged all the required events  synchronously  and then they were recorded in a pojo that was then compared with the expected one to verify the result.

If the goal is to persist in the database then as prescribed we should employ all the three things. The mirror space will replicate all the events asynchronously and then they will be saved to the database using the persistence. This helps to improve the efficiency as if the persistence is attached to the application space it will affect the performance of the application, since db writes are quite slow. Basically, persistance can be used to do an audit of the running space but that will do things synchronously and mirror space is employed to do things asynchronously.


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: