Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 5 Using the Example Code : Running the Examples

Running the Examples
As long as your PATH/LD_LIBRARY_PATH and CLASSPATH environment variables are correctly set up, it should be straightforward to run the examples.
Since many examples are distributed, you should run multiple instances of the example applications at the same time to see how easy it is to create a coherent and consistent distributed system using ActiveSpaces.
The following sections contain information on setting up your environment and the commands to use for running the ActiveSpaces examples for each of the language APIs.
Running the Java API Examples
Prior to running the Java examples, ensure that your environment variables have been set up for running ActiveSpaces as discussed in 'Chapter 2 Setting Environment Variables' of the document 'TIBCO ActiveSpaces Installation'.
Examples.jar or ASPaint.jar must be appended to your CLASSPATH depending upon which example you are running. For example, on a Microsoft Windows platform, you might set your CLASSPATH variable as follows:
C:\tibco\as\2.1\examples\java\Examples.jar;C:\tibco\as\2.1
\examples\java\\ASPaint.jar
If any additional jar files need to be appended to your CLASSPATH for running an example, the section on that example will have the additional information.
After your CLASSPATH is set appropriately, you can invoke all of the Java examples by using the following basic command:
java example_name command_line_arguments
For example, to run ASOperations with the default settings, enter:
java ASOperations
See Command Line Arguments for information on the command line arguments that you can use when invoking the examples.
Alternatively, in Java, you can launch the example programs using the java command with the classpath (-cp) parameter.
java -cp Examples.jar class_name command_line_arguments
where class_name is the name of the example class. For example:
java -cp Examples.jar ASChat
ASOperations is the default class for the jar file and can be launched directly using
java -jar Examples.jar
Running the C API Examples
To run a C API example program:
Windows
1.
Set your PATH environment variable to the directory where you have compiled the example programs (e.g. AS_HOME/examples/c).
2.
Ensure AS_HOME/lib is set in your library path environment variable (e.g. PATH, LIBPATH, LD_LIBRARY_PATH, etc.).
3.
The following section on command line arguments applies to all three API sets.
UNIX/Linux/AIX/HP UX
1.
Use a text editor to edit the Makefile.mk file provided with the TIBCO ActiveSpaces C example programs.
The Makefile is located in the /AS_HOME/examples/c directory.
2.
CC=<compiler>
For UNIX, this line reads CC = CC; for Linux, CC = gcc; for AIX, it reads CC = xlC; for HP-UX, CC = aCC.
3.
CC= <path>/<compiler>
where path is the path to the C compiler that you are using and compiler is the compiler name.
4.
5.
Running the .NET API Examples
To run a .NET API example program:
1.
2.
Ensure AS_HOME/lib is also set in your PATH environment variable.
3.
The following section on command line arguments applies to all three API sets.
Command Line Arguments
Many of the examples use the same basic set of command line arguments, which you can use to change the default settings used by the examples. For example, you might want to use a different metaspace name so you will not run into conflicts with other users who are running the ActiveSpaces examples on the same network.
When an example does not support certain command line arguments or supports additional command line arguments, those argument differences will be described in the sections relating to that particular example.
The following sections contain detailed information about the basic command line arguments supported by most of the examples.
Command Line Help
Invoking any example with the following argument displays the list of possible command line arguments for that example:
-help
Metaspace Command Line Arguments
All of the ActiveSpaces examples default to using the same metaspace.
You can use the following command line arguments to change metaspace settings when invoking the examples:
-metaspace metaspace_name      (default: ms)
-discovery discovery_URL       (default: tibpgm)
-listen listen_URL             (default: tcp)
-member_name member_name (Must specify a unique string identifying the member; default: auto-generated member name)
SpaceMemberDef Command Line Arguments
The following command line arguments can be used to change the SpaceMemberDef settings when invoking the examples:
-role leech | seeder (default: leech)
-persistence shared_nothing | shared_all
SpaceDef Command Line Arguments
Most of the ActiveSpaces examples default to using the same SpaceDef.
When an example uses other settings, this is indicated in the section covering that example. The following command line arguments can be used to change the SpaceDef setting when invoking the examples:
-space space_name (default: myspace)
-capacity entries_per_seeder where entries_per_seeder specifies the number of entries per seeder; -1= infinite (default)
-eviction none | lru (default: none)
-data_store directory_path (default: AS_HOME/examples/data_store)
-_count num_copies (default: 0)
-min_seeders num_seeders (default: 1)
Default Metaspace Name
The default metaspace name used by all of the examples is ms. Since the default discovery URL is tibpgm, conflicts might occur when multiple users are on the same network and using the default metaspace ms. Therefore, it is recommended that when running the examples, you specify a unique metaspace name on the command line using the -metaspace command line option.
Default Discovery URL
The default discovery URL used by all of the examples is tibpgm. This means that the PGM transport is used by ActiveSpaces applications (peers) to “discover” each other. If multiple versions of ActiveSpaces are being used on the same network, message deserialization errors can occur, because the message formats are typically not compatible between the various versions of ActiveSpaces.
When tibpgm is specified as the discovery URL, the default destination port used is 7888. To prevent conflicts when multiple versions of ActiveSpaces are being used with PGM as the discovery transport, it is recommended that a unique discovery URL be specified on the command line using the -discovery command line option.
For example,
-discovery tibpgm://7900
This discovery URL indicates that the destination port used by the PGM transport will be port 7900. As long as no other version of ActiveSpaces is run using the same port, you will not get discovery message deserialization errors.
Default Space Fields
Unless otherwise noted, the default space (myspace) that is defined for use by the examples has a definition consisting of three fields:
An optional field called value of type String

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved