Book Image

Infinispan data grid platform definitive guide

Book Image

Infinispan data grid platform definitive guide

Overview of this book

Table of Contents (20 chapters)
Infinispan Data Grid Platform Definitive Guide
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Running the sample application


To get a feel of how Infinispan looks, we are going to execute a Swing GUI demo that ships with Infinispan and can be used to test its basic caching functionalities, either as a standalone server or as a clustered server.

It's a good way to test our environment without the need to write a single line of code. Perform the following steps:

  1. First, open the bin folder and execute the runGuiDemo.sh script (adjust to runGuiDemo.bat if you are using a windows development environment) by executing the following command:

    ./runGuiDemo.sh
    
  2. If everything went well, the following screen should be displayed:

  3. To start the cache, press the Start Cache button, which will instantiate a cache:

    Note that the GUI Demo highlights the path to the configuration file used for initialization and presents its content in the text area.

    This demo application provides a very useful way to quickly test your own configuration files; to do so, execute the script passing your configuration's file directory as a JVM parameter beginning with the file protocol:

    ./runGuiDemo.sh file:/devenv/infinispan/configs/config-samples/sample.xml
    
  4. The most attentive readers will probably notice that now the toolbar is activated. Move to the Manipulate data tab; in this tab, you can perform CRUD operations on the cache, including a button to generate from 1 to 1000 random entries in the cache.

    Note

    CRUD is a well-known acronym that stands for Create, Read, Update, and Delete

  5. In the following example, we will add a sample entry in the cache by filling the Key and Value textboxes and hitting the Go button, which is shown in the following screenshot;

    Note

    Option Lifespan (millis) sets the lifespan of the cache entry, in milliseconds.

    MaxIdle (millis) sets the max idle of the cache entry, also in milliseconds.

    All these parameters can be set in the configuration.xml file.

  6. Once added, the application will switch automatically to the Data view tab, which will display all entries contained in the cache, as shown in the following screenshot:

  7. To test the cluster capabilities of Infinispan, let's open another command prompt and repeat the steps above, only changing the values in step 4. In both applications, move to the Data view tab, as shown in the following screenshot:

    You can see that both applications now have the same data.

    Note

    If one of the applications shows different values, hit the Refresh view button.

    Invoking the runGuiDemo script a few more times will create GUI frames, and you'll be able to start a new cache instance in each JVMs.

  8. Finally, in both applications, move to the Cluster view tab, as shown in the following screenshot:

As you can see, despite the fact that the GUI Demo applications are running in the same environment, they are running on different JVMs and we can see that the caches have discovered each other and formed a cluster.