Tiered, or hierarchical caching, lets you isolate data management to one or more servers, allowing multiple clients to connect and use the server caches. This is the model for scalability, with many clients benefitting from the management resources of just a few servers.
In GemFire Enterprise hierarchical caching, there is a server-side distributed system and one or more client-side distributed systems. The server VMs run BridgeServers that listen on unique ports for data requests and updates from clients. The clients forward all data requests their caches cannot fulfill to the servers. To do this, they use a custom data loader, the BridgeLoader. The clients might also be configured with a custom listener, called the BridgeWriter, that updates the servers when data is modified on the client side. In the HierarchicalServer.xml file for the cache server used in this example, note that the BridgeServer is defined for the entire cache. It services requests from any client for any region in the cache.
The HierarchicalClient example is an interactive C# program that uses Microsoft .NET Framework 2.0 to access the GemFire C++ API for modifying and viewing cache contents.
Microsoft .NET Framework 2.0 must be installed before running this example. For information about installing the .NET Framework, see Chapter 1 in the GemFire Enterprise Native Client Guide.
HierarchicalClient demonstrates a server in a tiered hierarchical caching setup. The client application comes with a cache configuration file, HierarchicalClient.xml, which is configured to create a root region and establish the native client endpoints to the locally-run server by specifying localhost:40404.
The HierarchicalClient cache listens for client requests at a specific port (see HierarchicalServer.xml). The client connects to the cache server's port, sending data requests and updates. At the beginning, both the server and client cache regions are empty.
When you run the example it will:
Examples that interact with a Java cache server require specific environment configurations so the Java cache server will run properly. Follow the configuration steps listed below that apply to your operating system:
bin/setenv script for your system. Refer to the developer's
guide if you need help with this step.JAVA_HOME and GF_JAVA_HOME environment variables to your installed Java JRE or JDK. See the Installation chapter of the GemFire Enterprise System Administrator's Guide for the versions of Java that are compatible with GemFire Enterprise. The JAVA_HOME setting is for your applications, and GF_JAVA_HOME is for the GemFire scripts. Some downloads of GemFire include a JRE in the jre directory of the installation. If you have a $GEMFIRE/jre directory, the GemFire scripts will automatically use it and you could also use it for your JAVA_HOME setting. If you have no $GEMFIRE/jre directory (such as the .zip file download of the product), then you must have a compatible Java JRE or JDK installed and you must set JAVA_HOME and GF_JAVA_HOME to point to it.$JAVA_HOME/bin to the start of your PATH. The following is a list of the environment configuration commands for the HierarchicalClient example. Choose the set of commands that are appropriate for your operating system. The text that you type is shown in bold.
These configurations only need to be performed for the sessions that invoke the Java cache server.
Bourne and Korn shells (sh, ksh, bash)
% cd GemFireInstallDirectory
% . bin/setenv.sh
% CLASSPATH=$CLASSPATH:$GEMFIRE/quickstart/classes;export CLASSPATH
% cd $GEMFIRE/quickstart
% JAVA_HOME=$GEMFIRE/jre;export JAVA_HOME
% GF_JAVA_HOME=$GEMFIRE/jre;export GF_JAVA_HOME
% PATH=$JAVA_HOME/bin:$PATH;export PATH
C shells (csh, tcsh)
% cd GemFireInstallDirectory
% source bin/setenv.csh
% setenv CLASSPATH ${CLASSPATH}:$GEMFIRE/quickstart/classes
% cd $GEMFIRE/quickstart
% setenv JAVA_HOME $GEMFIRE/jre
% setenv GF_JAVA_HOME $GEMFIRE/jre
% setenv PATH $JAVA_HOME/bin;${PATH}
Windows
> cd GemFireInstallDirectory
> bin\setenv.bat
> set CLASSPATH=%GEMFIRE%\quickstart\classes;%CLASSPATH%
> cd %GEMFIRE%\quickstart
> set JAVA_HOME=%GEMFIRE%\jre
> set GF_JAVA_HOME=%GEMFIRE%\jre
> set PATH=%JAVA_HOME%\bin;%PATH%
To run the HierarchicalClient example, create a session and complete the following steps. This first session will start the Java cache server.
Configure the session environment according to the steps listed in Configuring the Environment.
%GEMFIRE%/quickstart directory.
cd %GEMFIRE%/quickstart
java quickstart.HierarchicalServer
The server creates /root/exampleRegion and prompts you to start the HierarchicalClient application.
cli_HierarchicalClient example directory:
cd %GEMFIRE%/native_client/examples/cli_HierarchicalClient
HierarchicalClient application:
HierarchicalClient.exe
The client session does a get for Key0, Key1, Key2, and Key3, then forwards the requests to the cache server. The server session reports that the values have been retrieved.
In the client session
Press
Enter, as prompted. The client session reports a series of entry updates and destroys, which are forwarded to the cache server.
In the server session
The listener for the cache server reports create, update, and destroy events resulting from the modified entries.
In the client session
Press
Enterto end the application, then typeExitto close the session.
In the server session
Press
Enterto end the cache server, then typeExitto close the session.
First copy the gfcpp.properties file into your cli_BenchmarkHierarchi
calClient directory from the defaultSystem directory. Then edit the gfcpp.properties file in your
cli_BenchmarkHierarchicalClient directory as needed.
gfcpp.properties file into your cli_HierarchicalClient directory from the defaultSystem directory. Then edit the gfcpp.properties file in your cli_HierarchicalClient directory as needed.
If you also need to make a non-default configuration for the Java cache server, first make a copy of the gemfire.properties file in the %GEMFIRE%/quickstart directory and then edit it. For example, to change the name of the cache.xml file, uncomment this line and change the file name:
#cache-xml-file=cache.xml
When you're done with this example, delete your edited version of the gemfire.properties file and restore the renamed original version so other examples can use the unedited file.
Copyright © 2005-2007 by GemStone Systems, Inc. All rights reserved. GemStone®, GemFireTM, 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.