Blitz Stats Example

Introduction

This example provides a simple demonstration of how to use the org.dancres.blitz.stats package.

Compiling

The example consists of two classes:
  1. Lookup which handles service lookup.
  2. TestClient which actually manipulates the stats interfaces.
In order to compile these classes you will require the following .jar's: Assuming that your JINI 2.x distribution is in /jini2_1 and your Blitz distribution is in /blitz, you can compile the example as follows:
cd /blitz/examples/statsclient

javac -classpath /jini2_1/lib/jsk-lib.jar:/jini/jini2_1/lib/jsk-platform.jar:/blitz/lib/stats.jar  *.java

Running

Before starting the example, ensure that you have a Blitz instance running in a public lookup group - see the Installation Guide. This is necessary because the Lookup class does a single lookup and discover step - it does not register with discovered lookup services. Thus, if a Blitz instance isn't registered beforehand, it will not be found (I'll fix this in a future release!).

Having compiled the example, you can run it as follows (with the same assumptions about installation locations as above):
cd /blitz

java -Djava.security.policy=config/policy.all -classpath /jini2_1/lib/jsk-lib.jar:/jini2_1/lib/jsk-platform.jar:/blitz/examples/statsclient:/blitz/lib/stats.jar stats.TestClient

Configuring Defaults

In addition to passing an array of Switch objects to Blitz via the StatsAdmin interface, it's possible to configure default settings via the config file using an entry like:
// Default Stats to make available
stats = new Switch[] {new OpSwitch(OpSwitch.ALL_TYPES, OpSwitch.TAKE_OPS, true),
                      new OpSwitch(OpSwitch.ALL_TYPES, OpSwitch.READ_OPS, true),
                      new OpSwitch(OpSwitch.ALL_TYPES, OpSwitch.WRITE_OPS, true)};

Back to Documentation