adequate
adequate
adequate
adequate
 

JPPF, java, parallel computing, distributed computing, grid computing, parallel, distributed, cluster, grid, cloud, open source, android, .net
JPPF

The open source
grid computing
solution

 Home   About   Features   Download   Documentation   Forums 
November 22, 2017, 09:15:53 PM *
Welcome,
Please login or register.

Login with username, password and session length
Advanced search  
News: New users, please read this message. Thank you!
  Home Help Search Login Register  
Pages: [1]   Go Down

Author Topic: jobStarting event in local execution  (Read 68 times)

jim_pb

  • JPPF Master
  • ***
  • Posts: 28
jobStarting event in local execution
« on: July 07, 2017, 10:54:40 PM »

Hi Laurent,

I'm currently using JPPF 5.2.1.  My distributed application has an initialization step that occurs when a NodeLifeCycleListener captures a jobStarting event.  If I run this application with local execution only enabled, the initialization does not occur.  I assume the NodeLifeCycle events are different in the case of local execution?

I can image I could do something like poll the jppfClient to see if the local execution only property was set.  In case it was, I could call another method that mimics what my jobStarting() method does.  Is this the right approach, or is there a more direct way to cause the jobStarting event to be launched such that my listener captures it and executes the jobStarting method for that event when local execution only is enabled?

Thank you for your insight!

Jim
Logged

lolo

  • Administrator
  • JPPF Council Member
  • *****
  • Posts: 2208
    • JPPF Web site
Re: jobStarting event in local execution
« Reply #1 on: July 08, 2017, 06:16:06 AM »

Hi Jim,

Indeed, the client local executor does not have a NodeLifeCycleListener mechanism. However you can achieve something equivalent with a job listener, in particular by overriding/implementing its jobDispatched() method. In effect, in that method, the JobEvent carries information about the type of connection used to dispatch the job for execution, notably via its isRemoteExecution() method. You can do it with code like this:

Code: [Select]
JPPFJob job = new JPPFJob();
job.addJobListener(new JobListenerAdapter() {
  @Override
  public void jobDispatched(JobEvent event) {
    if (!event.isRemoteExecution()) {
      // get the locally dispatched tasks
      List<Task<?>> tasks = event.getJobTasks();
      // perform initialization for local exec
      ...
    }
  }
});

Also note that, while the isRemoteExecution() method is not mentioned in the doc link above, it is part of the public and supported API. I raised the bug JPPF-510 for this.

I hope this helps,
-Laurent
Logged

jim_pb

  • JPPF Master
  • ***
  • Posts: 28
Re: jobStarting event in local execution
« Reply #2 on: July 10, 2017, 06:32:23 PM »

Thank you very much.  Your suggestion worked beautifully!

Jim
Logged
Pages: [1]   Go Up
 
JPPF Powered by SMF 2.0 RC5 | SMF © 2006–2011, Simple Machines LLC Get JPPF at SourceForge.net. Fast, secure and Free Open Source software downloads