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

templedf daniel.templeton at oracle.com
Tue Aug 31 15:06:38 BST 2010

If a thread tries to use a session that has exited, it will get a 
NotActiveSessionException, so as long as it handles the exception 
correctly, you're fine.

Now, the problem you do have is that jobs are submitted as the process 
doing the submission.  In the case of a portal, it means that all jobs 
submitted by the users end up running as the id that is running the 
portal.  If that's a problem for you, I can explain how to work around 
it through clever OGE configuration.


On 08/31/10 06:53 AM, mdondrup wrote:
> 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].


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

More information about the gridengine-users mailing list