[GE users] Invoking a java class using DRMAA

anand_jayaraman anand_jayaraman1 at dell.com
Wed Mar 24 10:02:21 GMT 2010


Daniel,

I was trying out the approach you suggested. I guess the class you need to pass to the JobRunner method needs to implement Runnable and override the run method. Otherwise it would throw a class cast exception.

I am trying to understand the later part of the solution. I need some help in how a custom starter method can be specified to a default queue.

Any documentation, links would help.

Regards,
Anand

-----Original Message-----
From: Daniel Templeton [mailto:daniel.templeton at oracle.com] 
Sent: Tuesday, March 23, 2010 7:39 PM
To: users
Cc: Jayaraman, Anand
Subject: Re: [GE users] Invoking a java class using DRMAA

Oops.  The custom starter should be:

---
#!/bin/sh

java JobRunner "$@"
---

Daniel

On 03/23/10 06:59, templedf wrote:
> Anand,
>
> Grid Engine is what we call a zero-touch workload manager.  You don't
> need to change your code or recompile or anything to run your app over
> Grid Engine.  You could, for example, submit firefox as a job to Grid
> Engine, and it would run just fine (as long as you have the xhosting
> thing worked out).
>
> What you're looking for is a job-side API, which we don't have for the
> above reason.  What you want to do would be pretty simple to configure,
> though.  Write a class like this:
>
> ---
> public class JobRunner {
>     public static void main(String[] args) {
>       Runnable job = null;
>
>       try {
>         Class clazz = Class.forName(args[0]);
>         job = (Runnable)clazz.newInstance();
>
>         job.run();
>       } catch (Exception e) {
>         System.err.println("Problem loading job:");
>         e.printStackTrace();
>       }
>
>       try {
>         job.run();
>       } catch (Exception e) {
>         System.err.println("Problem while executing job:");
>         e.printStackTrace();
>       }
>     }
> }
> ---
>
> You then create a queue just for Java class jobs, and you assign it a
> custom starter method something like this:
>
> ---
> #!/bin/sh
>
> java "$@"
> ---
>
> You can then just set the remote command to your class name in DRMAA,
> and you're good to go.  You're still left figuring out the classpath
> issues, but that's a good start.  If you're expecting to be able to pass
> an object rather than a class, then you'll also have to worry about
> serializing the object out and then deserializing it in the JobRunner.
>
> Daniel
>
> On 03/22/10 22:53, Jayaraman, Anand wrote:
>> Hi,
>>
>> Thanks so much for the response.
>>
>> What I essentially meant here was when a java job is thought out to be executed. The API may not expect a java executable to be provided to it as a remote command.
>>
>> Let me explain where I am coming from, I was evaluating another job scheduler (open source) called Open source job scheduler. In this product if you want to execute a job as a java job the expectation is that you extend one of their classes and override the methods of their class with your implementation. Once this is done the execution of this job happens without really passing the java executable in the API (but the PATH environment variable should definitely be set). Just to illustrate this in an example:
>>
>> public class YourClass extends Job_impl /*Job_Impl is a class exposed by the framework */
>> {
>>
>> 		public boolean spooler_process() {
>> 			//Put your implementation here. It could mean 					  instantiating your class or putting the direct 				  implementation.
>> 		}
>> }
>>
>> Now YourClass can be submitted as a job to the scheduler and it takes care of running it.
>>
>> Coming to Grid Engine one glitch I see is passing a remote command to a job (aka JobTemplate) is if there are issues in running the job you may not be able to do an exact cause analysis of the issue. I am trying to draw a parallel with Runtime.exec(String command) approach.
>>
>> Please do let me know if I have overlooked something which is available in Grid Engine.
>>
>> Regards,
>> Anand	
>>
>> -----Original Message-----
>> From: Daniel Templeton [mailto:daniel.templeton at oracle.com]
>> Sent: Tuesday, March 23, 2010 2:59 AM
>> To: users
>> Cc: Jayaraman, Anand
>> Subject: Re: [GE users] Invoking a java class using DRMAA
>>
>> What do you expect the behavior to be for that operation?  How would
>> that object be "executed?"
>>
>> The most straight-forward approach is to set the remote command to
>> "java" and set the args to include the name of the class to execute.
>> Depending on exactly what you're trying to accomplish, there are other
>> approaches.
>>
>> Daniel
>>
>> On 03/19/10 06:02, anand_jayaraman wrote:
>>> Hi,
>>>
>>> I understand there is a notion of DRMAA wherein you can run Grid jobs using Java API. I find the examples for only running some sh files. I am interested in an implementation like this, Please read the comments i have written in this code snippet:
>>>
>>>              JobTemplate jt = session.createJobTemplate();
>>>              /*
>>> I want a java class to become the content for JobTemplate. I am not interested in invoking this through a shell script file.
>>>
>>> Something like:
>>>
>>>           jt.setXXX(java class)
>>>
>>> Once the job executes it essentially executes the java class. Is this supported?
>>>
>>>
>>>              */
>>>
>>>              String id = session.runJob(jt);
>>>
>>>              System.out.println("Your job has been submitted with id " + id);
>>>
>>>              session.deleteJobTemplate(jt);
>>>              session.exit();
>>>
>>> ------------------------------------------------------
>>> http://gridengine.sunsource.net/ds/viewMessage.do?dsForumId=38&dsMessageId=249681
>>>
>>> To unsubscribe from this discussion, e-mail: [users-unsubscribe at gridengine.sunsource.net].
>
> ------------------------------------------------------
> http://gridengine.sunsource.net/ds/viewMessage.do?dsForumId=38&dsMessageId=250819
>
> To unsubscribe from this discussion, e-mail: [users-unsubscribe at gridengine.sunsource.net].

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

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



More information about the gridengine-users mailing list