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   On Github   Forums 
March 06, 2021, 09:24:26 AM *
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: Getting Result from BroadcastJob  (Read 24 times)

hoho23

  • JPPF Padawan
  • *
  • Posts: 5
Getting Result from BroadcastJob
« on: February 15, 2021, 01:11:54 PM »

Hello,

I am using JPPF API to optimize an application executing multiple tasks.
Actually I am using the method "jppfJob.getSLA().setBroadcastJob(true)" since I need to execute a job on all the nodes present in the grid.
At the same time, I need a result from this job, precisely I need to know whether the execution is completed or not (in other words I need to know the state of the execution), nut since the broadcast job didn't return anything I don't know what to do to solve this problem. I need your help to know if there is a solution to implement in order to get result from this job.
Waiting for your interaction, have a nice day!

hoho23.
Logged

lolo

  • Administrator
  • JPPF Council Member
  • *****
  • Posts: 2265
    • JPPF Web site
Re: Getting Result from BroadcastJob
« Reply #1 on: February 16, 2021, 07:24:36 AM »

Hello,

If all you need is to know whether the job has completed, then you can use several techniques thart are easy to implement:

- if you submit the job synchrnonously with JPPFClient.submit(), then when the submit() method returns, the job has completed. Thie list of tasks that is returned is the initial list of tasks that were put into the job.
- if you submit the job asynchronusly with JPPFClient.submitAsync(), then you can later use of the JPPFJob.awaitResults() or JPPFJob.get() methods, which will block until completion of the job
- you may also regsiter a job listener and override its jobEnded() method, so that you can trigger an action when notified of the job's completion

I hope this helps,
-Laurent
Logged

hoho23

  • JPPF Padawan
  • *
  • Posts: 5
Re: Getting Result from BroadcastJob
« Reply #2 on: February 19, 2021, 09:57:41 AM »

Hello,

For the two codes below there is no result since the job is set as Broadcast job ( jppfJob.getSLA().setBroadcastJob(true); )  :
Code: [Select]
List<Task<?>> results = jppfClient.submit(jppfJob);or
Code: [Select]
jppfClient.submitAsync(jppfJob);
List<Task<?>> results = jppfJob.awaitResults();

In this case,The only way to know whether the job is completed or not is to regsiter a job listener and override its jobEnded() method.

Thank you for your help!

hoho23
« Last Edit: February 19, 2021, 09:59:41 AM by hoho23 »
Logged

lolo

  • Administrator
  • JPPF Council Member
  • *****
  • Posts: 2265
    • JPPF Web site
Re: Getting Result from BroadcastJob
« Reply #3 on: February 19, 2021, 05:30:35 PM »

Hello,

Quote
For the two codes below there is no result since the job is set as Broadcast job

That is true, however I meant to say that the 2 methods JPPFClient.submit() and JPPFJob.awaitResults() that you mentiined are blocking, and will only return when the job has completed. I hope this clarifies.

-Laurent
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