JPPF Forums

General Discussions => Forums => Topic started by: jacogeld on November 22, 2017, 12:49:37 AM

Title: JPPF + JPDA
Post by: jacogeld on November 22, 2017, 12:49:37 AM
We have hit a stumbling block in a project that combines JPPF and JPDA.  In essence, we run a  Java program P over and over with different inputs.  As P executes, we monitor it and record its behaviour.  To do this, we use JPDA: a LaunchingConnector starts a separate JVM which our application monitors using the JVM's built-in debugging support.

We want to use JPPF to distribute this task (running P over and over).  It works a treat for our monitoring application, but the VM spawned by JPDA use the usual class loader and tries to load P from the nodes' local disks, instead of from the server.  Is there an existing solution to this use-case?  In other words, is there (a hopefully easy) way to start a VM with a JPPFClassLoader without starting a new node?
Title: Re: JPPF + JPDA
Post by: lolo on November 22, 2017, 06:51:18 PM
Hello,

Unfortunately, you can only use the JPPF distributed class loader from within a node.
However, I believe it is still possible to accomplish what you need, by submitting a task that wraps the process to monitor (calling its main() method), from the task that does the monitoring - that means submitting a job from a task executing in a node.

The idea is to start a slave node exclusively for this task, using the provisioning facilty (http://www.jppf.org/doc/5.2/index.php?title=Node_provisioning) and then submit the task with a job execution policy to ensure it can only execute in that node.

Basically, the flow is as follows:
- this client appilcation submits a MonitorTask to the JPPF client
- the MonitorTask starts a slave node using the provisioning faciltiy, with all appropriate JVM options
- it also starts a new thread which performs the monitoring
- it then submits a task wrapping the process to monitor and ensures that it can only execute on the slave node
- when the task is completed it stops the monitoring thread and returns the result back to the client application

I implemented a small sample which does what is described above and attached it to this post for your convenience. I hope the code and comments are sufficiently clear. If not, please do not hesitate to get back to us.

Sincerely,
-Laurent
Title: Re: JPPF + JPDA
Post by: jacogeld on November 23, 2017, 05:57:29 AM
Thank you very much!  This is very kind of you.  I shall have a good look at the code.