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 
April 14, 2021, 10:49: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: Configuration file specification and lookup question  (Read 1707 times)

spacitron

  • JPPF Padawan
  • *
  • Posts: 5
Configuration file specification and lookup question
« on: July 09, 2013, 01:43:17 AM »

So I'm trying to load configuration files using the config plugin. This is just a simple test that I will expand on later. This is what I did so far:

-opened the build.xml and startDriver.bat files

-chanced the lines
    -Djppf.config=jppf-driver.properties
  to
    -Djppf.config.plugin=C:/Users/spacitron/Projects/workspace/JPPFTest/bin/JPPFServerCon.class

-this seems to work as the server reacts to me changing the code within that class However I'm not too sure what I'm doing with the class itself. Here's what I have:

Code: [Select]
public class JPPFServerCon implements JPPFConfiguration.ConfigurationSource {
JPPFConfiguration jc;

public JPPFServerCon() {
jc = new JPPFConfiguration();
}

@Override
public InputStream getPropertyStream() throws IOException {
InputStream stream = null;
try {
stream = jc.getConfigurationStream("C:/Users/spacitron/Desktop/jppf-driver.properties", "[b][i]What goes here???[/i][/b]");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return stream;
}

}

So what goes in the second argument in the getConfigurationStream method? Also, is there anything wrong with the rest of the code?
Logged

lolo

  • Administrator
  • JPPF Council Member
  • *****
  • Posts: 2268
    • JPPF Web site
Re: Configuration file specification and lookup question
« Reply #1 on: July 09, 2013, 07:16:30 AM »

Hello,

In fact there are 2 small issues in what you have done:

1) In the .bat file, you should specify -Djppf.config.plugin=JPPFServerCon. The value must be the fully qualified name of the class that implements ConfigurationSource, in the Java notation mypackage.MyClass. This also means that your class, and any supporting class, must be added to the driver's classpath. So in startDriver.bat, you should have -cp C:/Users/spacitron/Projects/workspace/JPPFTest/bin;config;lib/* instead of just -cp config;lib/*

Here it is likely that your implementation is not taken into account because JPPF is unable to load the class, and the server uses default values for the configuration properties.

2) This one is mostly our fault. JPPFConfiguration is a essentially utility class with only static members. It's not supposed to be instantiable from another class. Furthermore the method getConfigurationStream() is an internal one and we (in fact I) should have made it private. I registered a bug report for this: JPPF-165 JPPFConfiguration constructor and getConfigurationStream() method should be private. Thanks a lot for finding this out!

So a proper way to handle the configuration source would be as follows:

Code: [Select]
public class MyConfigurationSource implements JPPFConfiguration.ConfigurationSource {
  public TestConfigurationSource() {
  }

  @Override
  public InputStream getPropertyStream() throws IOException {
    StringBuilder sb = new StringBuilder();
    sb.append("jppf.server.port = 11111\n");
    // disable discovery since UDP multicast doesn't work on EC2
    sb.append("jppf.discovery.enabled = false\n");
    // ... add other properties ...
    return new ByteArrayInputStream(sb.toString().getBytes());
  }
}

I hope this clarifies,
-Laurent
Logged

spacitron

  • JPPF Padawan
  • *
  • Posts: 5
Re: Configuration file specification and lookup question
« Reply #2 on: July 09, 2013, 04:02:31 PM »

I still have problems with. The driver definitely reads my class but it either ignores it or it causes it to crash. I tried both to copy your code and to read from a .properties file. Neither seemed to work.
Logged

lolo

  • Administrator
  • JPPF Council Member
  • *****
  • Posts: 2268
    • JPPF Web site
Re: Configuration file specification and lookup question
« Reply #3 on: July 10, 2013, 08:21:11 AM »

Hello,

After further investigation, I found that there is an issue in our code that prevents the driver or node from properly handling the configuration source.
I registered a detailed bug report for it: JPPF-166 Alternate configuration source incorrectly handled.
However there is an easy workaround for this, which consists in having your configuration source implementation specify the configuration plugin as port of the value of the property "jppf.jvm.options".
For example:
Code: [Select]
StringBuilder sb = new StringBuilder();
sb.append("jppf.jvm.options = -Xmx512m -Djppf.config.plugin=").append(this.getClass().getName()).append("\n");
I'd call that a "dirty trick", but it should get you going while we are fixing the issue.
Note: you still need to add the -Djppf.config.plugin=... to the script that launches the driver or node, along with the classpath to the implementation of the configuration source.

Sincerely,
-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