|
Summary: Defining parameters in XML configuration file and <Default.JvmSettings>.
JVM ConfigurationIt 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:
Defining GigaSpaces Root DirectoryWhen 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>
Setting Security ContextWhen 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.
Space Proxy Serialization ModeGigapaces includes two PONO serialization modes:
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.
In general, you do not need to change the default serialization mode (Direct). Logging and TracingGigaSpaces 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 ConfigurationTo 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 ConfigurationThe 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).
Advanced ConfigurationHere are some features/scenarios which might be useful:
64-bit Compilation
csc.exe /target:exe /platform:anycpu /out:Release/benchmark.exe /recurse:./*.cs /reference:..\..\lib\GigaSpaces.Core.dll
|
(works on Firefox 2 and Internet Explorer 7)
For more configuration options, see the Codemesh configuration details in the