spacer spacer spacer
spacer spacer spacer
spacer
NASA Jet Propulsion Laboratory, California Institute of Technology + View the NASA Portal

+ NASA en Español

+ Contact NASA
Search JPL     

Concurrent Specimen Query Engine

The Concurrent Specimen Query Engine for the Early Detection Research Network's Resource Network Exchange (ERNE) provides an efficient mechanism for sending queries concurrently to ERNE product servers. It presents an event-based callback interface that makes it easy to get structured results from ERNE product servers. It enables you to make concurrent queries instead of manually multithreading the queries or serializing them.

Using the Engine

To use the Concurrent Specimen Query Engine, download the prerequisite jars, instantiate an Engine, create a QueryListener, add the listener to the Engine, then run a query. The Engine will notify the QueryListener as QueryEvents occur.

Dependent Jars

The Concurrent Specimen Query Engine relies on its own jar which you can download from this page in a binary distribution. You can also download the jar file only . The engine also relies on the following dependent jars:

You will also need erne-ps-1.1.0.jar ; for security reasons, this file is not available for download. A copy exists on ginger in /usr/local/edrn/lib.

Communications Setup

To set up your program for encrypted communication with ERNE product servers, you will need to set the system property initializers to the value edrn.RMIInitializer . You can do this using System.setProperty or by passing -Dinitializers=edrn.RMIInitializer on the Java command-line when you execute your program. It must be done before you run any queries with the Engine.

Executing a Query

With the dependent jars installed in your build/run environment, you can execute a query. First, instantiate the engine:

import gov.nasa.jpl.oodt.erne.query.Engine;
...
Engine engine = new Engine();

This Engine can be used for any number of queries. Next, create a class that implements the QueryListener interface. For this example, we'll just print the SPECIMEN_COLLECTED_CODE for each specimen at each site:

import gov.nasa.jpl.oodt.erne.query.QueryListener;
import gov.nasa.jpl.oodt.erne.query.QueryEvent;
...
class SpecimenCollectedCode implements QueryListener {
        public void rowReceived(QueryEvent e) {
                String site = e.getSiteName();
                List columns = e.getColumns();
                String code = (String) columns.get(0);
                System.out.println(site + ": " + code);
        }
        public void errorOccurred(QueryEvent e) {
                String site = e.getSiteName();
                Throwable error = e.getError();
                System.err.println(site + ": " + error);
        }
}
...
SpecimenCollectedCode x = new SpecimenCollectedCode();
engine.addQueryListener(x);

Note that listeners must implement two methods: rowReceived for each row of data received from product servers, and errorOccurred , which is invoked by the engine if an error occurs at a sp ecific site.

The Engine calls the rowReceived method once for each row received from each site. The calls are serialized so you don't have to worry about thread safety in your listener class; only one rowReceived call is ever active per Engine. The rows come in order from each site, but rowReceived may interleave calls from multiple sites.

The QueryEvent encapsulates the event. For each row received, getSiteName tells from which site the row came, and getColumns gives each column's value in the current row in order. For errors, getSiteName tells which site suffered the error, and getError returns the exception object.

Finally, to start the queries, create a List of String s containing the object name of each site to query, and an XMLQuery object representing the query to send:

import jpl.eda.xmlquery.XMLQuery;
...
List sites = new ArrayList();
sites.add("urn:eda:rmi:NIH.NCI.EDRN.BRIGHAM.PRODUCT_SERVER");
sites.add("urn:eda:rmi:NIH.NCI.EDRN.COLORADO.PRODUCT_SERVER");
sites.add("urn:eda:rmi:NIH.NCI.EDRN.CREIGHTON.PRODUCT_SERVER");
sites.add("urn:eda:rmi:NIH.NCI.EDRN.DARTMOUTH.PRODUCT_SERVER");
sites.add("urn:eda:rmi:NIH.NCI.EDRN.MDANDERSON.PRODUCT_SERVER");
sites.add("urn:eda:rmi:NIH.NCI.EDRN.MOFFITT.PRODUCT_SERVER");
sites.add("urn:eda:rmi:NIH.NCI.EDRN.PITTSBURGH.PRODUCT_SERVER");
sites.add("urn:eda:rmi:NIH.NCI.EDRN.SANANTONIO.PRODUCT_SERVER");

XMLQuery q = new XMLQuery("RETURN = SPECIMEN_COLLECTED_CODE",
        null, null, null, null, null, null, null, 999);

engine.run(sites, q);

The Engine will call your registered listeners as rows are recieved or errors occur. The call to Engine.run won't return until all the sites have responded. You can call Engine.run on the same Engine object from another thread; it is internally thread-safe.

FirstGov - Your First Click to the US Governmnet

+ Freedom of Information Act

+ NASA Privacy Statement, Disclaimer,

and Accessibility Certification


+ Freedom to Manage
NASA

Editor: Sean Kelly

NASA Official: Dan Crichton

Last Published: 04 April 2005

+ Contact NASA
spacer
spacer spacer spacer
spacer spacer spacer