External (Non-Java) Services
We present a framework that enables a non-Java service (e.g., a Matlab engine or database) to perform some computation for a JICOS system. First, external services are defined, then the Java extension with which it is implemented. The changes required to JICOS are presented. Additional details are available on folowing pages.
JICOS is a general purpose framework that provides a framework for performing arbitrary tasks. However, there is often a non-Java service that is optimized to perform work that the system desires to use, for example, a Matlab engine. Instead of writing, debugging, testing a program to perform a gaussian elimination with partial pivoting (GEPP) to solve a system of linear equations, just use Matlab. Although Matlab has a Java engine built-in, Mathworks (the creators of Matlab) have repeatedly stated that they do not support the interface, and it is subject to change. The supported method to interface with Matlab is via the C application programming interface (API). This is considered to be typical.
One of the primary benefits of Java is the "write once, run anywhere" platform independance. However, the creators realized that there will be some features specific to a platform. Accessing the Windows Registry is a classical example of this. The Java Native Interface (JNI) was created to provide access to native platform elements. The first step is to create an interface to the functionality. This interface defines what native functionality is being exposed to Java. The next step is implementing the interface. The implementing class extends ProxyServiceExternal. This class uses JNI to expose the functions being implemented by the native code. Please refer to the JNI Developer's Tutorial for a more complete introduction, including code samples, of JNI. All classes that implement an external service must extend the ProxyServiceExternal class. For example, MatlabImpl.java implements the Matlab interface.
JICOS scheduling depends on the fact that any Task can run on any Host. However, with the introduction of External Services, this may no longer be the case. Due to licensing, resources available on the machine, or centralized services, External Services may not be available on all machines in the system. This required changing JICOS so that a particular Task could be routed to specific machine where the service is available. Since all Tasks run on a Host, the Host was chosen to provide the interface to the external service. A HostExternal is the base class of any Host that provides access to an external service. For example, HostMatlab extends HostExternal, and provides access to the Matlab engine running on that particular machine. When the HostExternal is starting up, it initializes any connectivity necessary for the service to be used. Once set up, the Host instantiates the appropriate proxy, and stores it in the local Environment for later use. For example, when a TaskMatlab is invoked, it can access the special matlab functions by getting the proxy:
We now explain how to access native code using JNI, and give an example using MatlabImpl. We then describe in detail the changes made to the Jicos components to support an external service.
|