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 
May 30, 2023, 12:40:09 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: METADATA PARAMETER OBJECT  (Read 575 times)

hoho23

  • JPPF Padawan
  • *
  • Posts: 13
METADATA PARAMETER OBJECT
« on: March 29, 2021, 12:04:24 PM »

Hello JPPF Community,

I am working on a project that needs to execute specific code snippet before executing some jobs, the code snippet to execute depends on the job metadata. For that, I am using a NodeLifeCycleListenerAdapater, then overriding the jobHeadLoaded(final NodeLifeCycleEvent event) method, on which I try to get the metadata parameter which is a Runnable object that contains the code to execute. Unfortunately, the connection I lose the connection to the class server and the task server. I think the problem is caused by passing a runnable object as a parameter through the job metadata, since it works with other types of object such as String object. I need your help to know if there is a method to pass a runnable as a parameter on the job metadata, or if there is another option to do it using some jppf tools.
Below the error code I get, it would be helpful.
Code: [Select]
2021-03-26 11:43:51,425 - [ForkJoinPool.commonPool-worker-3] - INFO  - org.my.package.Main - Do JPPF distributed task
[client: jppf_discovery-1-1 - ClassServer] Attempting connection to the class server at address:port
[client: jppf_discovery-1-1 - ClassServer] Reconnected to the class server
[client: jppf_discovery-1-1 - TasksServer] Attempting connection to the task server at address:port
[client: jppf_discovery-1-1 - TasksServer] Reconnected to the JPPF task server
[client: jppf_discovery-1-1 - ClassServer] Attempting connection to the class server at address:port
[client: jppf_discovery-1-1 - ClassServer] Reconnected to the class server
[client: jppf_discovery-1-1 - TasksServer] Attempting connection to the task server at address:port
[client: jppf_discovery-1-1 - TasksServer] Reconnected to the JPPF task server

Thank you,
hoho23
Logged

lolo

  • Administrator
  • JPPF Council Member
  • *****
  • Posts: 2272
    • JPPF Web site
Re: METADATA PARAMETER OBJECT
« Reply #1 on: March 31, 2021, 05:15:07 AM »

Hello,

Did you ensure that your Runnable object is also Serializable? If not, this could explain the disconnection problem when you submit the job.

I hope this helps,
-Laurent
« Last Edit: March 31, 2021, 05:19:16 AM by lolo »
Logged

hoho23

  • JPPF Padawan
  • *
  • Posts: 13
Re: METADATA PARAMETER OBJECT
« Reply #2 on: March 31, 2021, 12:00:34 PM »

Yes, it's serializable. I'am using a SerializableRunnable object, Here is the code:
Code: [Select]
JPPFJob jppfJob = new JPPFJob();
JobMetadata metadata = jppfJob.getMetadata();
metadata.setParameter(1, "hey");
SerializableRunnable runnable =()-> {
System.err.println(" I am the runnable! ");
};
metadata.setParameter(2, runnable);
Logged

lolo

  • Administrator
  • JPPF Council Member
  • *****
  • Posts: 2272
    • JPPF Web site
Re: METADATA PARAMETER OBJECT
« Reply #3 on: April 01, 2021, 06:15:38 AM »

Hello,

Thank you for the vital information you provided. I believe this is a class loading issue with regards to your NodeLifeCycleListener. By design, in the jobHeaderLoaded() method, the class loader used does not have access to the classes in the classpath of the JPPF client. It can only access classes in the driver's or node's classpath. Here, you're using a SerializableRunnable, which is not part of the JPPF API, and thus is probably only in tour client classpath. In the log of the node where it happens, you should see a ClassNotFoundException, can you check this?

Also, as an experiment, could you try not using SerializableRunnable and instead use the following lambda construct, which only refers to JDK interfaces:
Code: [Select]
Runnable runnable = (Serializable & Runnable) () -> System.err.println(" I am the runnable! ");
Could you please try that and let us know if this works?

Sincerely,
-Laurent
« Last Edit: April 01, 2021, 07:03:37 AM by lolo »
Logged

hoho23

  • JPPF Padawan
  • *
  • Posts: 13
Re: METADATA PARAMETER OBJECT
« Reply #4 on: April 01, 2021, 11:50:24 AM »

I tried to replace my code snippet with the code you sent below, but it still not working.
Code: [Select]
Runnable runnable = (Serializable & Runnable) () -> System.err.println(" I am the runnable! ");I have always the same problem!
I also tried to copy the jar file of the external lib I am using (the one that contains the SerializableRunnable) in the lib directory of the driver and the problem always exists.
tell me if you need any additional information that can help to solve this problem, and I am really grateful for your help!

regards,
hoho23
« Last Edit: April 01, 2021, 11:54:13 AM by hoho23 »
Logged

hoho23

  • JPPF Padawan
  • *
  • Posts: 13
Re: METADATA PARAMETER OBJECT
« Reply #5 on: April 08, 2021, 09:47:33 AM »

The problem is solved  :)
Actually, it was a dependency issue and now it works well.
Thank you for your help and explanation Mr. 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