GemFire Enterprise Native Client

C++ Programming Example

September 2008

About the userobjects Example

The userobjects example demonstrates the native client C++ API for distributing and retrieving custom-defined user types. The example uses gemfire::CacheableKey to define a key type suitable for storage as a value in the cache. See the C++ online API documentation for a description of gemfire::CacheableKey. You can also review the example source code in the userobjects directory.

The userobjects example is located in NativeClient_xxxx/examples/userobjects.

Configuring the Environment

The following is a list of the environment configuration commands for the userobjects example. Choose the set of commands that are appropriate for your operating system. The text that you type is shown in bold.

Bourne and Korn shells (sh, ksh, bash)

% GFCPP=<path to NativeClient_xxxx directory>; export GFCPP
% PATH=$GFCPP/bin:$PATH; export PATH


The Windows native client installer sets the required environment configurations for you, so they are listed for reference only.

> GFCPP=<path to NativeClient_xxxx directory>

Running userobjects

Follow these steps to run the userobjects example. The steps reflect Windows operations, so alter them as needed for your operating system.

When you're prompted to enter the name of the native client directory, replace the xxxx in NativeClient_xxxx with the actual four-digit product version number.

  1. Create a session, then configure the session environment according to the steps listed in Configuring the Environment.

  2. Go to the userobjects example directory.

  3. cd \NativeClient_xxxx\examples\userobjects

  4. Enter this command to start the example:


  5. The process registers custom serializable types, then connects to the distributed system. It creates a cache and region, then creates a new AccountHistory and puts it in the cache. Next, it gets AccountHistory from the cache and updates it.

    This is the example output:

    Put an AccountHistory in cache keyed with BankAccount.
    BankAccount( customer: 2309, account: 123091 )
      Created account
    Found AccountHistory in the cache.
      Created account
    Updated AccountHistory in the cache.
    Found AccountHistory in the cache.
      Created account
      debit $1,000,000.

  6. Close the session by entering exit.

Changing System Parameters

By default, this product ships configured for multicast membership resolution. If your network environment does not allow multicast, you can configure GemFire for unicast. See the GemFire Enterprise System Administrator's Guide for instructions on configuring TCP transport for membership and discovery.


Copyright © 2005-2008 by GemStone Systems, Inc. All rights reserved. GemStone®, GemFire®, and the GemStone logo are trademarks or registered trademarks of GemStone Systems, Inc. All other trade names or trademarks are the property of their respective owners. Information in this document is subject to change without notice.