Bridge configuration
From JPPF 6.1 Documentation
|
Main Page > .Net Bridge > Bridge configuration |
The configuration's main goal is to tell the .Net bridge where to find the required .Net assemblies and to setup the JVM class path and options. The following sections describe how this is done for a .Net client application and JPPF nodes. The JPPF server does not require any specific configuration.
1 Configuring a .Net client application
For a .Net application to work with JPPF, three types of elements must be configured: JVM class path, JVM options and paths to the required assemblies. This is done in the application's settings XML file (i.e. MyApp.exe.config).
In the following sections, all settings keys are suffixed with ".<id>" where <id> is an arbitrary string with the sole constraint of being unique among settings of the same kind. Using a sequence of numbers as suffixes generally makes them easier to read, however it is not mandatory.
1.1 JVM class path
One or more JVM class paths can be specified with three different kinds of settings:
- key="ClassPath.id" value="jar_file_or_dir" specifies a single class path element to add to the JVM
- key="ClassPaths.id" value="root_dir|file_or_subdir1; ... ;file_or_subdir_n" specifies n class path elements, all children of the specified root directory. Note that each subpath can be relative to the root directory.
- key="ClassPathDir.id" value="root_dir" specifies that all jar files and sub-directories of the specified root directories are to be added to the JVM class path
Examples:
<configuration> <appSettings> <!-- add the current working directory to the class path --> <add key="ClassPath.1" value="."/> <!-- add 2 jar files from the C:\dev\external-libs directory --> <add key="ClassPaths.2" value="C:/dev/external-libs|lib1.jar;lib2.jar"/> <!-- add 2 jar files from subdirs of the C:\dev\libs directory --> <add key="ClassPaths.3" value="C:/dev/libs|subdir1/lib1.jar;subdir2/lib2.jar"/> <!-- add all jar files in the lib directory --> <add key="ClassPathDir.4" value="lib"/> ... </appSettings> </configuration>
1.2 JVM options
The JVM options are specified with a single setting key, as in this example:
<appSettings> <!-- set the options for the JVM --> <add key="jppf.jvm.options" value="-Xmx256m -Dlog4j.configuration=log4j.properties -Djppf.config=jppf.properties -Djava.util.logging.config.file=cfg/logging.properties"/> ... </appSettings>
Please note that no classpath should be specified here with either the -cp or -classpath options.
1.3 Assembly paths
Assembly paths can be configured with tho different kinds of settings, with the .dll extension always omitted:
- key="AssemblyPath.id" value="dll_path" specifies a single assembly path
- key="AssemblyPaths.id" value="root_dir|dll_1; ... ;dll_n" specifies n assemblies, located in the specified root directory. Note that each subpath can be relative to the root directory.
Examples:
<appSettings> <!-- specify a single dll --> <add key="AssemblyPath.1" value="jni4net.n-0.8.8.0"/> <!-- specify 2 dlls in the current working directory --> <add key="AssemblyPaths.2" value=".|JPPFDotnet;jppf.dotnet.demo.tasks"/> <!-- specify 2 dlls in subdirs of C:\dev\assemblies working directory --> <add key="AssemblyPaths.3" value="C:/dev/assemblies|subdir1/dll_1;subdir2/dll_2"/> ... </appSettings>
1.4 Full configuration example
As an example, here is the configuration of the demo application found in the distribution:
<configuration> <appSettings> <!-- JVM classpath for the JPPF client --> <add key="ClassPath.1" value="."/> <add key="ClassPath.2" value="config/client"/> <add key="ClassPathDir.3" value="lib"/> <!-- JVM options for the JPPF client --> <add key="jppf.jvm.options" value="-Xmx256m -Dlog4j.configuration=log4j.properties -Djppf.config=jppf.properties -Djava.util.logging.config.file=config/client/logging.properties"/> <!-- Required assemblies for the .Net JPPF client --> <add key="AssemblyPath.1" value="jni4net.n-0.8.8.0"/> <add key="AssemblyPath.2" value="JPPFDotnet"/> <add key="AssemblyPath.3" value="jppf.dotnet.demo.tasks"/> </appSettings> </configuration>
2 Configuring a Java node
The .Net bridge initialization in a node is transparently performed by a node initialization hook which is included in the "lib/JPPFDotnet.jar" library found in the .Net node distribution. It relies on specific configuration properties described in the following sections.
2.1 Location of the Jni4net native dlls
The location of the native dlls provided by Jni4net (the jni4net.n.wXX.vYY-a.b.c.d.dll files in the node's /lib directory) can be specified in two ways:
a) By adding the directory which contains them to the PATH environment variable
b) Or, when starting the node, by specifying the value of the "java.library.path" system property. The .Net node distribution does this in the node's configuration as follows:
# compute the absolute path to the dll directory with a scripted propery value dll.dir = $script:javascript{ new java.io.File("lib").getCanonicalPath() }$ # specify java.library.path in the JVM options jppf.jvm.options = -server -Xmx128m "-Djava.library.path=${dll.dir};${env.PATH}" # propagate the java.library.path property to the slave nodes jppf.node.provisioning.slave.jvm.options = \ -Dlog4j.configuration=config/log4j-slave.properties \ "-Djava.library.path=${dll.dir};${env.PATH}"
Note how the dll directory's absolute path is computed, so it can be correctly propagated to eventual slave nodes started with the provisioning facility.
2.2 Location of the required assemblies
The required assemblies include both the .Net bridge JPPF API and your own assemblies holding the code to execute .Net tasks, along with the assemblies that support them.
As for the .Net client application, required assemblies can be specified in the node's configuration using two kinds of properties:
- "AssemblyPath.id = dll_path" specifies a single class path element to add to the JVM
- "AssemblyPaths.id = root_dir|assembly_1.dll; ... ;assembly_n.dll" specifies n assemblies, located in the specified root directory. Note that each subpath can be relative to the root directory.
Examples:
# specify a single dll AssemblyPath.1 = C:/dev/assemblies/MyAssembly.dll # specify 2 dlls in the current working directory AssemblyPaths.2 = .|JPPFDotnet.dll;jppf.dotnet.demo.tasks.dll # specify 2 dlls in subdirs of C:\dev\assemblies working directory AssemblyPaths.3 = C:/dev/assemblies|subdir1/assembly1.dll;subdir2/assembly2.dll
Note that here, the ".dll" file extension is required.
2.3 Additional required Java libraries
Compared to standard nodes, .Net-capable nodes require the following additional jar files, without which they cannot work: "jppf-client.jar", "JPPFDotnet.jar" and "jni4net.j-0.8.8.0.jar". These jar files are included in the "/lib" directory of the .Net node distribution.
Main Page > .Net Bridge > Bridge configuration |