3.11. Running the Hello World Application

Running VoltDB applications consists of two separate actions: starting the database server and running the client application.

It is easiest to execute these two actions in separate processes. Create two terminal sessions and set default to the working directory you created at the beginning of this tutorial. To run your client application, you will need to redefine CLASSPATH. For example:

$ cd $HOME/helloworld
$ export CLASSPATH="./:/opt/voltdb/lib/*:/opt/voltdb/voltdb/*"

In one terminal session, start your database server. You do this by invoking the voltdb command and specifying:

  • The desired action, in this case create

  • The application catalog

  • The deployment file

  • The host node of the cluster

When running a cluster with multiple machines, the host node provides startup services for the cluster as a whole, including coordinating the cluster configuration and hosting the application catalog. Once startup is complete, the host's role is complete and it becomes a peer of all the other nodes.

Since you are running the sample locally, the host (and only) node in the cluster is localhost.

Finally, if you are using the VoltDB Enterprise Edition, you must specify the location of your VoltDB license file. Since the license file is ignored in the Community Edition, you can include the license argument whichever version you are using. For example:

$ voltdb create \
         catalog helloworld.jar   \
         deployment deployment.xml   \
         host localhost \
         license /opt/voltdb/voltdb/license.xml

VoltDB display information about the catalog and creates a new copy of the database.

Now switch to your second terminal session and start the client application, which in this case is Client. The client will start and display the words "hello world" in the language you specified in the source file:

$ java Client
Hola, Mundo!
$ 

Congratulations! You have completed your first complete VoltDB application. You will find the finished source files in Appendix A, The Completed Hello World Application.