[GE users] Handling DRMAA sessions within a Java web-service

mdondrup michael.dondrup at uni.no
Tue Aug 31 14:53:05 BST 2010


Hi,

first , I hope that this is the right place to ask this question. I would like to know, if that is the right 
way to do it, it seems to work but there might be some hidden problems or if there is a more standard way
of doing this.

I am using the drmaa Java api inside an Axis2 SOAP web-service to submit jobs to a 
GE cluster. I understood from the documentation that there can be at most a single active DRMAA session
per process. Given I got two classes: 
- the implementation class of the service has a method 'start' which can be called by the client from the outside
- a class 'DrmaaScheduler' which makes the actual calls to the grid-engine via DRMAA.

The following code works so far, but there could be a problem in theory, if a threads try to re-use a session
which is already exited but not yet set to null? 

Thank you very much for any comments and suggestions

Michael
 

in class DrmaaScheduler I created a static variable for the session, like this:

public class DrmaaScheduler implements Scheduler {
	// store session and contact
	private static Session session = null;
	private static String contact = null;

then in the constructor:

public DrmaaScheduler() throws SchedulerException {
 if (session == null) {
    try { 
          SessionFactory factory = SessionFactory.getFactory(); 
          session = factory.getSession(); 
          if (contact != null) 
               session.init(contact); 
         else 
               session.init(""); 
         contact = session.getContact(); 
         log.debug("DRMAA session {} initialized", contact); 
    } catch (Exception e) {
       log.error("something went wrong initializing DRMAA:", e);      
    } 
[....]

I only call session.exit in the finally method like:

public void finalize() {
	try {
		super.finalize();
		session.exit();
// ** this could be a problem, because it's not atomic, right? **
		session = null;
	  } catch (Throwable e) {
			log.error("Error during finalization: ", e);
          }
}

------------------------------------------------------
http://gridengine.sunsource.net/ds/viewMessage.do?dsForumId=38&dsMessageId=278486

To unsubscribe from this discussion, e-mail: [users-unsubscribe at gridengine.sunsource.net].



More information about the gridengine-users mailing list