Configuration
Getting Started
- In Visual Studio, Create a new
Class Library
project. - Add a reference to
GigaSpaces.Core.dll
from the product'sbin
folder. - Add an xml file called
pu This is the unit of packaging and deployment in the GigaSpaces Data Grid, and is essentially the main GigaSpaces service. The Processing Unit (PU) itself is typically deployed onto the Service Grid. When a Processing Unit is deployed, a Processing Unit instance is the actual runtime entity..config
to the project. - Right-click
pu.config
, select Properties, and modify the Copy to Output Directory to Copy Always (or Copy If Newer). - Copy the following configuration into
pu.config
:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="ProcessingUnit" type="GigaSpaces.XAP GigaSpaces eXtreme Application Platform.
Provides a powerful solution for data processing, launching, and running digital services.Configuration.ProcessingUnitConfigurationSection, GigaSpaces.Core"/>
</configSections>
<ProcessingUnit>
<!-- Processing unit configuration goes here -->
</ProcessingUnit>
</configuration>
Upgrading from older versions The Processing Unit configuration scheme has been simplified in version 10.0, and the previous scheme is still supported for backwards compatibility but is deprecated. If you're upgrading from older versions it is recommended to update your PU configuration accordingly.
Embedded Spaces
The Processing Unit can be configured to create an embedded Space 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., which will be created when the PU is deployed and destroyed when the PU is undeployed:
<ProcessingUnit>
<EmbeddedSpaces>
<add Name="MySpace"/>
</EmbeddedSpaces>
</ProcessingUnit>
Cluster Mode
When creating an embedded Space, the default proxy is created in direct mode, meaning it targets only the collocated cluster member. To target the entire cluster, set the Mode
tag to Clustered:
<ProcessingUnit>
<EmbeddedSpaces>
<add Name="MySpace" Mode="Clustered"/>
</EmbeddedSpaces>
</ProcessingUnit>
Cluster aware
When a Processing Unit is deployed, the configured embedded Spaces are created using the injected cluster information. To force an embedded Space to ignore that cluster info, use the ClusterInfoAware
tag:
<ProcessingUnit>
<EmbeddedSpaces>
<add Name="MySpace" ClusterInfoAware="false"/>
</EmbeddedSpaces>
</ProcessingUnit>
Space Properties
When creating a Space you can override Space properties values using the Properties
tag:
<ProcessingUnit>
<EmbeddedSpaces>
<add Name="MySpace">
<Properties>
<add Name="space-config.engine.cache_policy" Value="0"/>
<add Name="space-config.engine.cache_size" Value="100"/>
</Properties>
</add>
</EmbeddedSpaces>
</ProcessingUnit>
Space Proxies
The Processing Unit can be configured to connect to a remote Space (hosted by another Processing Unit, for example):
<ProcessingUnit>
<SpaceProxies>
<add Name="MySpace"/>
</SpaceProxies>
</ProcessingUnit>
Event Listeners
An event listener container is one of the most commonly used GigaSpaces components as part of a Processing Unit. Similarly to the other components, such event containers can be automatically detected, created and managed by the container -
it will automatically detect classes decorated with EventDriven
attributes (PollingEventDriven
or NotifyEventDriven
) and create corresponding event containers for them.
See Polling Container Component and Notify Container Component for more information regarding event listener containers.
[PollingEventDriven(Name="MyEventListener")]
public class MyEventListener
{
[..]
}
An event listener container needs a Space proxy that will listen for events. If there's a single Space proxy configured it will be selected automatically, otherwise event container should be configured with the relevant Space name:
<ProcessingUnit>
<EmbeddedSpaces>
<add Name="Foo"/>
</EmbeddedSpaces>
<SpaceProxies>
<add Name="Bar"/>
</SpaceProxies>
<EventContainers>
<add Name="MyEventListener" SpaceProxyName="Foo"/>
</EventContainers>
</ProcessingUnit>
Security
To access a secured Space the Credentials
tag is used:
<ProcessingUnit>
<EmbeddedSpaces>
<add Name="EmbeddedSpace">
<Credentials Username="user" Password="pwd"/>
</add>
</EmbeddedSpaces>
<SpacesProxy>
<add Name="RemoteSpace">
<Credentials Username="user2" Password="pwd2"/>
</add>
</SpacesProxy>
</ProcessingUnit>
Assembly Scanning
By default, all the assemblies packaged with the Processing Unit will be scanned to automatically create Processing Unit components, event listener containers and remoting services. In some scenarios you may want to change this. For example:
- The application uses many 3rd party assemblies, and scanning all of them slows down the deployment.
- One of the assemblies contains troublesome code and you want to exclude it.
- You're sharing code between multiple Processing Units and want to control which component is loaded in which Processing Unit.
You can use the ScanAssemblies
tag to specify a list of assemblies to be scanned (wildcards may be used). In addition, you may specify a namespace prefix to which indicates only classes with that prefix will be scanned. For example:
<ProcessingUnit>
<ScanAssemblies>
<!-- Scan all assemblies starting with 'Foo.Bar.' -->
<add AssemblyName="Foo.Bar.*.dll" />
<!-- Scan all assemblies starting with 'MyCompany.' for classes starting with 'MyCompany.MyProject.' -->
<add AssemblyName="MyCompany.*.dll", NameSpace="MyCompany.MyProject."/>
</ScanAssemblies>
</ProcessingUnit>
It is also possible to completely disable assembly scanning:
<ProcessingUnit>
<ScanAssemblies Disabled="true"/>
</ProcessingUnit>
Finally, it is possible to configure the Processing Unit to scan for certain type of classes (components, event listeners and remoting). For example, to scan for event containers only:
<ProcessingUnit ScanRemotingServices="false" ScanBasicComponents="false" ScanEventContainers="true">
<!-- Can be used in combination with ScanAssemblies -->
</ProcessingUnit>