.NET API Configuration

  Search Here
Searching XAP 6.0 Documentation

                                               

Summary: Defining parameters in XML configuration file and <Default.JvmSettings>.

JVM Configuration

It is recommended that any .NET application using the GigaSpaces .NET interface includes several parameters defined in its XML configuration file.

Using only the default parameters values (not defining them in the configuration file) might result in unexpected behavior. The .NET interface parameters and CodeMesh parameters are defined in the app.config file in specific sections:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
	<configSections>
		<sectionGroup name="codemesh">
			<sectionGroup name="runtime">
				<section name="Loader" type="System.Configuration.SingleTagSectionHandler" />
				<section name="Default.JvmSettings" type="System.Configuration.NameValueSectionHandler" />
				<section name="Default.Options" type="System.Configuration.NameValueSectionHandler" />
				<section name="Default.XOptions" type="System.Configuration.NameValueSectionHandler" />
			</sectionGroup>
		</sectionGroup>
	</configSections>
	<codemesh>
		<runtime>
			<Loader name="Default" />
			<Default.JvmSettings>
				<add key="ClassPath" value=".;..\..\..\lib\JSpaces.jar"/>
				<add key="TraceLevel" value="TraceInfo" />
				<add key="InitialHeapSize" value="64" />
				<add key="MaximumHeapSize" value="128" />
			</Default.JvmSettings>
			<Default.Options>
				<add key="com.sun.management.jmxremote.port" value="5001" />
				<add key="com.sun.management.jmxremote.ssl" value="false" />
				<add key="com.sun.management.jmxremote.authenticate" value="false" />
			</Default.Options>
			<Default.XOptions >
				<add key= "debug" value="" />
				<add key= "noagent" value="" />
				<add key= "run" value="jdwp:transport=dt_socket,server=y,suspend=n,address=8000 " />
			</Default.XOptions >
		</runtime>
	</codemesh>
</configuration>

The configuration example above has three configuration sections:

  • Default.JvmSettings – allows you to set the classpath, trace level, initial heap size, and maximum heap size.
  • Default.Options – defines connection parameters for monitoring the JVM, memory and threads using Jconsole.
  • Default.Options – enables remote debugging. Allows a Java debugger to hook on the .NET proxy.

For more configuration options, see the Codemesh configuration details in the Codemesh website, Java/.NET runtime configuration section.

Defining GigaSpaces Root Directory

When working with GigaSpaces space-based .NET API, make sure you first define the <GigaSpaces Root> directory (the directory in which GigaSpaces is installed).

This can be done using the HomeDir argument in your application configuration file (app.config/web.config).

The following example sets HomeDir to D:\Dev\Gigaspaces\builds\GigaSpacesXAP6.0:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="GigaSpaces" type="GigaSpaces.Core.Configuration.GigaSpacesCoreConfiguration, GigaSpaces.Core"/>
  </configSections>
  <GigaSpaces>
    <HomeDir Path="D:\Gigaspaces\builds\GigaSpacesXAP6.0"/>
  </GigaSpaces>  
</configuration>

You can also define a relative path from your application's running path to your <GigaSpaces Root> directory. For example:

...
 <GigaSpaces>
       <HomeDir Path="..\..\..\"/>
 </GigaSpaces>

Alternatively, the <GigaSpaces Root> directory can be defined by adding the JSHOMEDIR environment variable to your classpath. For more details, see Building Your First .NET Application.

Setting Security Context

When a space is running in secured mode, the space proxy should have user credentials using the setSecurityContext method:

SecurityContext sc = new SecurityContext("user", "password");
proxy.SetSecurityContext(sc);

If the space is running in secured mode, you need to set the security context.

With each space operation, the space performs the required authorization based on the security roles defined for the user.

For more details, refer to the Security section.

Space Proxy Serialization Mode

Gigapaces includes two PONO serialization modes:

  • Direct instructs the system to use PBS mode to convert between Java and .NET in a faster manner.
  • Standard instructs the system to use the PONO regularly.

By default, GigaSpaces uses Direct mode. If you want to switch to Standard mode, change the value of SerializationMode from SpaceSerialization.Direct to SpaceSerialization.Standard during runtime:

using GigaSpaces.Core
...
SpaceProxyProviderFactory.Instance.SerializationMode = SpaceSerialization.Direct;
using GigaSpaces.Core
...
SpaceProxyProviderFactory.Instance.SerializationMode = SpaceSerialization.Standard;

After setting proxy.SerializationMode, proxies created using the SpaceProxyProviderFactory are set with the specified serialization mode.

Changing the factory's default serialization mode affects only proxies which are created after the change, not before it.

In general, you do not need to change the default serialization mode (Direct).

Logging and Tracing

GigaSpaces XAP .NET components use the tracing mechanism for logging/tracing, built-in with the .NET framework. This gives the user control over tracing behaviour using the standard .NET configuration schema. Users can configure the level of events which are traced, assign one or more trace listeners which route the events to a logging facility, implement custom trace listeners to integrate GigaSpaces events with the application events, and more. If the user specifies no configuration, a default configuration is assumed.

Basic Configuration

To configure the GigaSpaces logger, you need to add a trace source configuration named GigaSpaces to your configuration file (app.config/web.config). Use the switchValue argument to set the trace level to one of the following: Off, Critical, Error, Warning, Information, Verbose (Naturally, each level includes all its predesessors, e.g. Error includes Critical as well). Use the <listeners> collection to add trace listeners which will handle the traced events.

The following example sets the trace level to Error, which means that only errors and critical events are processed; and defines a single trace listener, which writes traced messages to the Windows Event Log under a source called GigaSpaces.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.diagnostics>
    <sources>
      <source name="GigaSpaces" switchValue="Error">
        <listeners>
          <add name="MyListener" 
  type="System.Diagnostics.EventLogTraceListener"
  initializeData="GigaSpaces"/>
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
</configuration>

Default Configuration

The logger component loads the configuration during initialization. If it does not find a source element named GigaSpaces, it loads a default configuration, which sets the trace level to Error and configures an EventLogTraceListener with source=GigaSpaces (similar to the configuration showed in the basic example).

If the Windows Event Log does not contain the specified source, it is automatically created. However, you need administor permissions to create a source in the Event Log. If you don't create this source, the default configuration is not used. We recommend that you use an administrator's profile the first time you use the product on a machine, to make sure the source is created. Subsequent runs do not require high permissions.

Advanced Configuration

Here are some features/scenarios which might be useful:

64-bit Compilation

Use the /platform:anycpu switch when compiling and running on 64-bit windows machine platforms. Example (based on the Benchmark example):

csc.exe /target:exe /platform:anycpu  /out:Release/benchmark.exe /recurse:./*.cs /reference:..\..\lib\GigaSpaces.Core.dll

For more details, refer to the Microsoft website.


IMPORTANT: This is an old version of GigaSpaces XAP. Click here for the latest version.
GigaSpaces 6.0 Documentation Contents (Current Page in Bold)

    Java

    C++

    .NET

    Middleware Capabilities

    Configuration and Management

Add GigaSpaces wiki search to your browser search engines!
(works on Firefox 2 and Internet Explorer 7)

Labels

 
(None)