Determine the Openshift Internally Assigned IP Address
First, lets make our cartridge capable of being installed onto any Openshift web framework application, not just the DIY cartridge.
In Openshift, an internal IP address is assigned to your application when the web framework is used to create the initial application. For example, with the DIY cartridge, the internally assigned IP address is found in the environment variable called OPENSHIFT_DIY_IP. And if you were to select the Python web framework, the environment variable is called OPENSHIFT_PYTHON_IP, and for the PHP framework the variable is called OPENSHIFT_PHP_IP, and so on.
The naming convention would tend to cause you to write scripts, like the ones for our VoltDB cartridge as follows:
This is however not required given that within the OPENSHIFT_BASH_SDK script there exists two useful bash functions named:
These two functions can be used to determine the underlying web framework’s IP address as follows:
Including this function into the VoltDB’s bin/control script now allows us to start and stop VoltDB using a generic internal IP address as follows:
You now see that our control script is agnostic as to what web framework we are installing VoltDB on.
Deploying Our Own Catalog
Next, we would like to alter the cartridge to allow us to run any VoltDB schema of our choosing. This is accomplished simply by changing the scripts to use a generic application schema name and deployment file name in the start() function as follows:
Instead of running the sample catalog for voltcache everytime, we will adjust our cartridge scripts to allow us to run a catalog of your choosing.
In the cartridge control script, we will modify the paths to the catalogs being executed as follows:
Notice that we make use of the OPENSHIFT_DATA_DIR environment variable. This location is writable by your account and is more generic than the sample directory which gets deployed with the cartridge itself. Now, the cartridge will look in this location for a catalog to start.
Initially when the cartridge is installed, the generic name will point to the voltcache example to provide a default example to install the cartridge with. This is performed by means of the cartridge’s setup script as follows:
To supply your own schema and deployment files is simple if we make use of the rhc client utilities. In this example, we’ll upload the voltkv example that ships with VoltDB. Make sure to build the voltkv example on your local workstation before running these commands! In the following example, the application name we created is called voltdb. From your client workstation (e.g. Fedora 20), you will enter the following commands to upload your own schema and deployment files:
Remember to add the http port setting of 16000 (port=”16000″) in your deployment.xml files or VoltDB will not start on Openshift!
Now, on your client workstation, start port forwarding in one terminal window:
Then in another terminal window, run the voltkv client:
Average throughput: 921 txns/sec
After this set of changes to the cartridge, you can now run VoltDB on any of the supported Openshift web frameworks, and also deploy your own VoltDB catalog.
Whats next? Well, VoltDB has many features that relate to high availability and multi-node configuration, those are enterprise style features that are particularly challenging to implement and I’ll address those in upcoming blogs.