(2012-03-11) Exploiting the Univa Grid Engine JGDI API Java Interface - A JGDI Hello World Example

Doing evil things! The JGDI API is an unsupported (but available) Java interface for accessing and controlling Grid Engine. It is unsupported because there are no guarantees that the interface will change over time and that the methods are working like expected. Much of the underlaying code is automatically generated during the compile process.

Since the first steps are always the hardest, here is a short example of how to get a very simple JGDI program to work with your Univa Grid Engine installation.

First of all you can download a 48-core limited trial version of Univa Grid Engine 8.0.1 at Univa (http://www.univa.com). After unpacking you can use the Java GUI installer for performing a test installation (./start_gui_installer). Please activate the JMX port but for simplicity without certificates. If you have already an installation without an activated JMX port you can simply add this functionality later on. Here is how it is done.

1. Activating the JMX port on the qmaster

Check if it is deactivated.

> cat $SGE_ROOT/default/common/bootstrap | grep jvm
jvm_threads             0

0 indicates that the Java thread in the qmaster is turned off, if it is 1 you are done (qconf -at jmx will give you the information that the Java thread already runs).

Enabling the qmaster Java thread is easy:

Go to the master host (qconf -sss will show you the host, but only when your real master is currently running and not the shadow daemon).

(assuming that $SGE_ROOT/default/common/settings.sh is sourced)

> cd $SGE_ROOT
> ./inst_sge -add-jmx

(enter for SGE_ROOT location)
(enter for CELL)
(„y“ for enabling JMX port)
(set JAVA_HOME to your Java installation directory)
(accept default settings)
(set JMX port you want to use on the qmaster host)
(for simplicity no security is chosen in this example (-> no to SSL Server))
(yes to enable Java thread now)
(update shadowd hosts with qconf -mconf <hostname> with jvm path if needed)

That's it!

2. Create the JGDI Example Code

Since this is the very first JGDI program it should be very simple, like printing out the scheduler configuration. You just have to replace MASTER_PORT by the port number of the qmaster (not the JMX port number!), which can be get from the environment (echo $SGE_QMASTER_PORT) and /opt/uge has to be changed to your path to SGE_ROOT (echo $SGE_ROOT). You can find the Test.java code below.

3. Compile the JGDI Example

In order to compile the example be sure that you source the settings.sh file (having the right environment set) and do following:

javac -cp $SGE_ROOT/lib/jgdi.jar Test.java

4. Run the JGDI Example

export LD_LIBRARY_PATH=$SGE_ROOT/lib/lx-amd64/
java -cp $SGE_ROOT/lib/jgdi.jar:./ Test

You can find detailed documentation of the complete JGDI interface here (generated out of the code based on the free Sun SISSL License):  http://www.gridengine.eu/jgdidoc/index.html

But be warned - the interface might change overtime...always test your application first in a test cluster with any newer version of Grid Engine and look if it behaves well and does not evil things on your Grid Engine qmaster process in your production environment.

Here is the sample source code for Test.java:


import java.util.*;
import com.sun.grid.jgdi.*;
import com.sun.grid.jgdi.configuration.*;

public class Test {

   public static void main(String[] args) {
      String url = "bootstrap:///nfs/installation/ts_ge@default:2000";
      try {
         JGDI jgdi = JGDIFactory.newInstance(url);
         SchedConf sc = jgdi.getSchedConf();
      } catch (JGDIException ex) {