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:
First, open the
bin
folder and execute therunGuiDemo.sh
script (adjust torunGuiDemo.bat
if you are using a windows development environment) by executing the following command:./runGuiDemo.sh
If everything went well, the following screen should be displayed:
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
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.
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;
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:
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.
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.