The SpaceRetry plugin for OpenSpaces

The spaceRetry project is a plugin for GigaSpaces OpenSpaces.

Features:

  • Lazy-load: we can instantiate the PU also if the proxy can’t connect to the space
  • Connection is made when we invoke a method on the IJSpace Proxy (like a write)

Synopsis:

We have developed this plugin in order to fix two problems with the space components of OpenSpaces.
1) The Space component of OpenSpaces allows you to create an IJSpace.
If we want to create a Remote Space with an url like jini://*/*/space the remote site has to be deployed first. If not, the deployment of the PU will failed with a org.openspaces.core.space.CannotFindSpaceException (ATTENTION: Failed to find space with url …).

2) The second problem is about automatic proxy renewal.
If the proxy loose his connection there is no mechanism to try to rebind the connection when a method of IJSpace is invoked.

Now, let’s dive into the configuration of this component.

Configuration

In order to have the <fc-os:spaceretry> namespace add

xmlns:fc-os="http://opensource.fastconnect.org/schema/spaceretry"

Then add the schema location

http://opensource.fastconnect.org/schema/spaceretry http://opensource.fastconnect.org/schema/space/fcspace.xsd

Finally, to use the fcSpaceRetry proxy, you have to wrap the <os-core:space /> with the <fc:spaceretry/> tag.

<fc-os:spaceretry id="myspace" max-retry-init="1" max-retry-invoke="1" wait-time="5000">
<os-core:space id="ijspace" url="jini://*/*/mySpace" />
</fc-os:spaceretry>

Parameters:

  • max-retry-init: the number of tests for connexion during the initialization of the proxy
  • max-retry-invoke: the number of tests for connexion when a method of IJSpace is invoke
  • wait-time: the wait time between both tests of connexion (in millisecond)

Use the <os-core:space> like you have the used to do.

If you use Maven, you have also add a dependency to space-retry in your POM.xml

<dependencies>
<dependency>
<groupId>fr.fastconnect.openspaces</groupId>
<artifactId>space-retry</artifactId>
<version>0.7</version>
</dependency>
</dependencies>

Technical Information

The spaceRetry plugin extends the UrlSpaceFactoryBean and overloads the doCreateSpace method to create a new instance of IJSpaceProxy (dynamic proxy of IJSpace).

Algorithm :

We try n times to create an IJSpace with the SpaceFinder.find(spaceURL). When the max-retry-init is reached, we create a proxy of the IJSpace but not initialised.

When a method of the IJSpace is invoked and if the connection is not established the IJSpaceProxy try n times to make the connection.
When the max-retry-invoke is reached, the IJSpaceProxy throw a RuntimeException.

Compatibility

The spaceRetry plugin is compatible with all components of the IJSpace (core, events or remoting components). Just use the id of the spaceRetry bean to have all benefits of the plugin.
Example :

<fc:spaceretry id="myspace" max-retry-init="2" max-retry-invoke="5" wait-time="5000">
<os-core:space id="dontuseit" url="/./mySpace" />
</fc:spaceretry>
<os-core:giga-space id="gigaSpace" space="myspace"/>

More information on https://opensource.fastconnect.org/redmine/projects/show/extended-space-bean