This page describes an older version of the product. The latest stable version is 16.4.

The Space Bean


When a client connects to a space, a proxy is created that holds a connection to the space. All client interaction is performed through this proxy. The proxy provides a simpler space API using the GigaSpace interface. It can be created with a Space Bean and optional parameters.

Embedded Space

Example:

<os-core:embedded-space id="space" space-name="xapSpace" 
   versioned="true" lookup-groups="uat" lookup-locators="someHost:4174" />

Here are the available parameters for an embedded space:

Name Type Description Default Required See Also
id String Used to create the GigaSpace Bean Yes GigaSpace Bean
space-name String The space name to use Yes
lookup-groups String The Jini Lookup Service group to find the space using multicast No
lookup-locators String Instructs the started space to locate the Jini Lookup Service on specific host name and port No
lookup-timeout Number Lookup timeout in milli seconds 5000ms No
versioned Boolean When false, optimistic lock is disabled. In a local cache and views the default is true, otherwise the default value is false. False No Annotation
Optimistic Locking
schema String Schema options: mirror, persistent No
mirrored Boolean Asynchronous Persistency - Write Behind False No Mirror Service
register-for-space-mode-notifications Boolean Register for Space mode notifications False No Space Notifications
external-data-source Reference No
space-data-source Reference Data Source for the Space No Space Persistency
space-sync-endpoint Reference Space Synchronization Endpoint No Asynchronous Persistence
enable-member-alive-indicator No
gateway-targets String Multi Site WAN Replication No Multi Site WAN Replication

Bean Properties

Property Description See Also
all-in-cache-policy
lru-cache-policy
custom-cache-policy Custom eviction policy
blob-store-data-policy MemoryXtend
attribute-store
leader-selection
properties
space-filter Space Filters
space-sql-function SQL Functions
annotation-adapter-filter Space Filters
method-adapter-filter Space Filters
filter-provider
query-extension-provider
replication-filter-provider
space-replication-filter Multi Site WAN Replication
security Accessing a secured space with username and password Secured Space

Remote Space

Example:

<os-core:space-proxy id="space" space-name="remoteSpace"
    lookup-groups="uat" lookup-locators="someHost:4174"/>

Here are the available parameters for a remote space:

Name Type Description Default Required See Also
id String Used to create the GigaSpace Bean Yes GigaSpace Bean
space-name String The space name to connect to the remote space Yes
instance-id Number The id of the space instance within a cluster to connect to No
lookup-groups String The Jini Lookup Service group to find the space using multicast No
lookup-locators String Instructs the started space to locate the Jini Lookup Service on specific host name and port No
lookup-timeout MSeconds Lookup timeout in milli seconds 5000ms No
versioned Boolean When false, optimistic lock is disabled. In a local cache and views the default is true, otherwise the default value is false. False No Annotation
Optimistic Locking

Properties

Property Description See Also
security Accessing a secured space with username and password Secured Space
properties

GigaSpace Bean

The GigaSpace Spring Bean provides a simple way to configure a proxy to be injected into the relevant Bean.

Here is an example on how to create the proxy:

<os-core:embedded-space id="space" space-name="space" />
</os-core:giga-space id="mySpace" space="space" />
<os-core:embedded-space id="space" space-name="space">
<bean id="mySpace" class="org.openspaces.core.space.EmbeddedSpaceFactoryBean">
    <property name="name" value="space" />
</bean>

   // Create the Space Bean
   EmbeddedSpaceConfigurer spaceConfigurer = new EmbeddedSpaceConfigurer("mySpace");

   // Create the Proxy
   GigaSpace gigaSpace = new GigaSpaceConfigurer(spaceConfigurer).gigaSpace();

   // shutting down -- closing the Space
   spaceConfigurer.destroy();
Note

The application is always injected with os-core:giga-space bean that wraps always a os-core:space.

Properties

The GigaSpace Bean can have the following elements:

Element Description Required Default Value
space This can be an embedded space , remote space , local view or local cache. YES
clustered Boolean. Cluster flag. Controlling if this GigaSpace will work with a clustered view of the space or directly with a cluster member. By default if this flag is not set it will be set automatically by this factory. It will be set to true if the space is an embedded one AND the space is not a local cache proxy. It will be set to false otherwise (i.e. the space is not an embedded space OR the space is a local cache proxy) NO true for remote proxy , false for embedded proxy
default-read-timeout Numerical Value. Sets the default read timeout for read(Object) and readIfExists(Object) operations. NO 0 (NO_WAIT). TimeUnit:millsec
default-take-timeout Numerical Value. Sets the default take timeout for take(Object) and takeIfExists(Object) operations. NO 0 (NO_WAIT). TimeUnit:millsec
default-write-lease Numerical Value. Sets the default space object lease (TTL) for write(Object) operation. NO FOREVER. TimeUnit:millsec
default-isolation Options: DEFAULT , READ_UNCOMMITTED, READ_COMMITTED , REPEATABLE_READ NO DEFAULT
tx-manager Set the transaction manager to enable transactional operations. Can be null if transactional support is not required or the default space is used as a transactional context. NO
write-modifier Defines a single default write modifier for the space proxy. Options: NONE, WRITE_ONLY, UPDATE_ONLY, UPDATE_OR_WRITE, RETURN_PREV_ON_UPDATE, ONE_WAY, MEMORY_ONLY_SEARCH, PARTIAL_UPDATE NO UPDATE_OR_WRITE
read-modifier The modifier constant name as defined in ReadModifiers. Options:NONE, REPEATABLE_READ, READ_COMMITTED, DIRTY_READ, EXCLUSIVE_READ_LOCK, IGNORE_PARTIAL_FAILURE, FIFO, FIFO_GROUPING_POLL, MEMORY_ONLY_SEARCH NO READ_COMMITTED
take-modifier Defines a single default take modifier for the space proxy. Options:NONE, EVICT_ONLY, IGNORE_PARTIAL_FAILURE, FIFO, FIFO_GROUPING_POLL, MEMORY_ONLY_SEARCH NO NONE
change-modifier Defines a single default change modifier for the space proxy. Options:NONE, ONE_WAY, MEMORY_ONLY_SEARCH, RETURN_DETAILED_RESULTS NO NONE
clear-modifier Defines a single default count modifier for the space proxy. Options:NONE, EVICT_ONLY, MEMORY_ONLY_SEARCH NO NONE
count-modifier Defines a single default count modifier for the space proxy. Options:NONE, REPEATABLE_READ, READ_COMMITTED, DIRTY_READ, EXCLUSIVE_READ_LOCK, MEMORY_ONLY_SEARCH NO NONE

Here is an example of the GigaSpace Bean:

 <os-core:space id="mySpace" name="space"/>

 <os-core:giga-space id="gigaSpaceClustered" space="mySpace" clustered="true"
     default-read-timeout="10000"
     default-take-timeout="10000"
     default-write-lease="100000">
     <os-core:read-modifier value="FIFO"/>
     <os-core:change-modifier value="RETURN_DETAILED_RESULTS"/>
     <os-core:clear-modifier value="EVICT_ONLY"/>
     <os-core:count-modifier value="READ_COMMITTED"/>
     <os-core:take-modifier value="FIFO"/>

     <!-- to add more than one modifier, simply include all desired modifiers -->
     <os-core:write-modifier value="PARTIAL_UPDATE"/>
     <os-core:write-modifier value="UPDATE_ONLY"/>
    </os-core:giga-space>
<bean id="gigaSpace" class="org.openspaces.core.GigaSpaceFactoryBean">
     <property name="space" ref="space" />
     <property name="clustered" value="true" />
     <property name="defaultReadTimeout" value="10000" />
     <property name="defaultTakeTimeout" value="100000" />
     <property name="defaultWriteLease" value="100000" />
     <property name="defaultWriteModifiers">
     <array>
     <bean id="updateOnly"
     class="org.openspaces.core.config.modifiers.WriteModifierFactoryBean">
     <property name="modifierName" value="UPDATE_ONLY" />
     </bean>
     <bean id="partialUpdate"
     class="org.openspaces.core.config.modifiers.WriteModifierFactoryBean">
     <property name="modifierName" value="PARTIAL_UPDATE" />
     </bean>
     </array>
     </property>
</bean>

Examples

Here are some examples on how to configure the Space Bean and the proxy:

Declaring a remote space with a transaction manager:

<tx:annotation-driven transaction-manager="transactionManager"/>

<os-core:space-proxy id="space" space-name="space" />
<os-core:giga-space id="gigaSpace" space="space" tx-manager="transactionManager"/>

Declaring a remote space with a transaction manager and creating an embedded space:

<os-core:space-proxy id="spaceRemote" space-name="space" />
<os-core:giga-space id="gigaSpaceRemote" space=" spaceRemote"  tx-manager="transactionManager1"/>

<os-core:space id="spaceEmbed" name="space" />
<os-core:giga-space id="gigaSpaceEmbed" space="spaceEmbed"  tx-manager="transactionManager2"/>

Declaring a remote space creating a local view:

<os-core:space-proxy id="spaceRemote" space-name="space" />
<os-core:local-view id="localViewSpace" space="spaceRemote">
    <os-core:view-query class="com.example.Message1" where="processed = true"/>
</os-core:local-view>
<os-core:giga-space id="gigaSpaceLocalView" space="localViewSpace"/>
See also:

Local View

Declaring a remote space with a local view , a regular remote space (without a view) and an embedded space:

<os-core:space-proxy id="spaceRemote" space-name="space" />
    <os-core:local-view id="localViewSpace" space="spaceRemote">
    <os-core:view-query class="com.example.Message1" where="processed = true"/>
</os-core:local-view>

<os-core:giga-space id="gigaSpaceLocalView" space="localViewSpace"/>
<os-core:giga-space id="gigaSpaceRemote" space="spaceRemote"  tx-manager="transactionManager1"/>

<os-core:space id="spaceEmbed" name="space" />
<os-core:giga-space id="gigaSpaceEmbed" space="spaceEmbed"  tx-manager="transactionManager2"/>
Note

The application is always injected with os-core:giga-space bean that wraps always a os-core:space.

Default Operation Modifiers

You may configure default modifiers for the different operations in the GigaSpace interface. The default modifiers can be configured in the following manner:

<os-core:embedded-space id="space" space-name="space" />
<os-core:giga-space id="gigaSpace" space="space">
  <os-core:read-modifier value="FIFO"/>
  <os-core:change-modifier value="RETURN_DETAILED_RESULTS"/>
  <os-core:clear-modifier value="EVICT_ONLY"/>
  <os-core:count-modifier value="READ_COMMITTED"/>
  <os-core:take-modifier value="FIFO"/>

  <!-- to add more than one modifier, simply include all desired modifiers -->
  <os-core:write-modifier value="PARTIAL_UPDATE"/>
  <os-core:write-modifier value="UPDATE_ONLY"/>
</<os-core:giga-space>
<bean id="space" class="org.openspaces.core.space.EmbeddedSpaceFactoryBean">
  <property name="name" value="space" />
</bean>

<bean id="gigaSpace" class="org.openspaces.core.GigaSpaceFactoryBean">
  <property name="space" ref="space" />
  <property name="defaultWriteModifiers">
    <array>
      <bean id="updateOnly"
        class="org.openspaces.core.config.modifiers.WriteModifierFactoryBean">
        <property name="modifierName" value="UPDATE_ONLY" />
      </bean>
      <bean id="partialUpdate"
        class="org.openspaces.core.config.modifiers.WriteModifierFactoryBean">
        <property name="modifierName" value="PARTIAL_UPDATE" />
      </bean>
    </array>
  </property>
</bean>
  EmbeddedSpaceConfigurer spaceConfigurer = new EmbeddedSpaceConfigurer("space");

  GigaSpace gigaSpace = new GigaSpaceConfigurer(spaceConfigurer)
  .defaultWriteModifiers(WriteModifiers.PARTIAL_UPDATE.add(WriteModifiers.UPDATE_ONLY))
  .defaultReadModifiers(ReadModifiers.FIFO)
  .defaultChangeModifiers(ChangeModifiers.RETURN_DETAILED_RESULTS)
  .defaultClearModifiers(ClearModifiers.EVICT_ONLY)
  .defaultCountModifiers(CountModifiers.READ_COMMITTED)
  .defaultTakeModifiers(TakeModifiers.FIFO)
  .gigaSpace();

Any operation on the configured proxy will be treated as if the default modifiers were explicitly passed. If a certain operation requires passing an explicit modifier and also wishes to merge the existing default modifiers, the following pattern should be used:

GigaSpace gigaSpace = ...
gigaSpace.write(someObject, gigaSpace.getDefaultWriteModifiers().add(WriteModifiers.WRITE_ONLY));

For further details on each of the available modifiers see:

Exception Hierarchy

XAP is built on top of the Spring consistent exception hierarchy by translating all of the different JavaSpaces exceptions and GigaSpaces exceptions into runtime exceptions, consistent with the Spring exception hierarchy. All the different exceptions exist in the org.openspaces.core package.

XAP provides a pluggable exception translator using the following interface:

public interface ExceptionTranslator {

    DataAccessException translate(Throwable e);
}

A default implementation of the exception translator is automatically used, which translates most of the relevant exceptions into either Spring data access exceptions, or concrete OpenSpaces runtime exceptions (in the org.openspaces.core package).

Exception handling for Batch Operations

Batch operations many throw the following Exceptions. Make sure you catch these and act appropriately:

Basic Guidelines

  • The variable represents a remote or embedded space proxy (for a single space or clustered) and should be constructed only once throughout the lifetime of the application process.
  • You should treat the variable as a singleton to be shared across multiple different threads within your application.
  • The interface is thread safe and there is no need to create a GigaSpace variable per application thread.
  • In case the space has been fully terminated (no backup or primary instances running any more) the client space proxy will try to reconnect to the space up to a predefined timeout based on the Proxy Connectivity settings. If it fails to reconnect, an error will be displayed.
  • Within a single Processing Unit (or Spring application context), several GigaSpace instances can be defined, each with different characteristics, all will be interacting with the same remote space.