XAP

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 SpaceClosed Where GigaSpaces data is stored. It is the logical cache that holds data objects in memory and might also hold them in layered in tiering. Data is hosted from multiple SoRs, consolidated as a unified data model. Bean and optional parameters.

Embedded Space

Example:

<os-core:embedded-space id="space" space-name="gsSpace" 
   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 Service
lookup-locators String Instructs the started space to locate the Jini Lookup Service on specific host name and port No Lookup Service
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: default, mirror, persistent default 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 External Data Source is supported for Space Documents No Space Document
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 API for LRUClosed Last Recently Used. This is a common caching strategy. It defines the policy to evict elements from the cache to make room for new elements when the cache is full, meaning it discards the least recently used items first. cache policy mode Custom eviction policy
blob-store-data-policy Configuration and Deployment with RocksDB MemoryXtend
attribute-store Configure a persistent SSD RocksDB add-on with an attribute store MemoryXtend
leader-selection
space-sql-function Register user defined SQL functions SQL Functions
query-extension-provider
space-filter Space operation interceptors Space Filters
annotation-adapter-filter Delegate Space Filters using annotations Space Filters
method-adapter-filter Delegate Space Filters with explicit method listings Space Filters
filter-provider
replication-filter-provider
space-replication-filter Filter replication data between sites Multi Site WAN Replication
security Accessing a secured space with username and password Secured Space
properties

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

The 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();

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, FIFOClosed FIFO is an acronym for first in, first out, a method for organizing the manipulation of a data structure where the oldest entry, or "head" of the queue, is processed first., 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"/>

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"/>

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

GigaSpaces 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.

GigaSpaces 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