Summary: Using the GigaSpaces External Data Source interface with the .NET API.
OverviewGigaSpaces External Data Source interface is the key middleware connection link for loading and storing data to and from persistent data sources. .NET persistency is a GigaSpaces implementation on top of Java SQLDataProvider and BulkPersister interfaces.
.NET Specific SettingsCreating a Space with ExternalDataSourceYou can either use GigaSpaces NHibernate implementation, or create a custom implementation:
GigaSpaces NHibernate SQL Data Source Implementation
The following code demonstrates how to start an embedded space with GigaSpaces NHibernate SqlDataSource implementation as its External Data Source. //Create a new space configuration object that is used to start a space SpaceConfig spaceConfig = new SpaceConfig(); //Start a new ExternalDataSource config object spaceConfig.ExternalDataSourceConfig = new ExternalDataSourceConfig(); //Start a new instance of NHibernateExternalDataSource and attach it to the config spaceConfig.ExternalDataSourceConfig.Instance = new NHibernateExternalDataSource(); //Create custom properties that are required to build NHibernate session factory spaceConfig.ExternalDataSourceConfig.CustomProperties = new Dictionary<string, string>(); //Point to NHibernate session factory config file spaceConfig.ExternalDataSourceConfig.CustomProperties.Add(NHibernateExternalDataSource.NHibernateConfigProperty, "[NHibernate config file]"); //Optional - points to a directory that contains the NHibernate mapping files (hbm) spaceConfig.ExternalDataSourceConfig.CustomProperties.Add(NHibernateExternalDataSource.NHibernateHbmDirectory, "[NHibernate hbm files location]"); //Starts the space with the External Data Source ISpaceProxy persistentSpace = SpaceProxyProviderFactory.Instance.FindSpace("/./mySpace", spaceConfig);
Custom SQL Data Source Implementation A custom .NET SqlDataSource implementation can be used as well. The following code demonstrates how to start an embedded space with a custom .NET SqlDataSource implementation as its External Data Source. //Create a new space configuration object that is used to start a space SpaceConfig spaceConfig = new SpaceConfig(); //Start a new ExternalDataSource config object spaceConfig.ExternalDataSourceConfig = new ExternalDataSourceConfig(); //Start a new instance of the custom implementation and attach it to the config spaceConfig.ExternalDataSourceConfig.Instance = new *CustomImplementation*(); //if custom properties should be passed to the Init method put them here, otherwise there's no need to create a dictionary of custom properties spaceConfig.ExternalDataSourceConfig.CustomProperties = new Dictionary<string, string>(); //Add custom properties to the dictionary spaceConfig.ExternalDataSourceConfig.CustomProperties.Add("[Property name]", "[Property value]"); //Starts the space with the External Data Source ISpaceProxy persistentSpace = SpaceProxyProviderFactory.Instance.FindSpace("/./mySpace", spaceConfig); Advanced OptionsThe number of objects passed between the .Net IDataEnumerator (Part of the ISqlDataSource interface) to the server on each iteration can be changed, its default value is set to 1000. This can be done by adding a custom property to the ExternalDataSourceConfig object. spaceConfig.ExternalDataSourceConfig.CustomProperties = new Dictionary<string, string>(); //Add custom properties to the dictionary spaceConfig.ExternalDataSourceConfig.CustomProperties.Add("iterator-batch-size", "[batch size]"); Server Side Logging
Creating Custom ExternalDataSource ImplementationTo create a custom implementation, implement the GigaSpaces.Core.Persistency.ISqlDataSource interface.
|
![]() |
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence |