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

The open source
grid computing

 Home   About   Features   Download   Documentation   On Github   Forums 
June 04, 2023, 10:00:22 AM *
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: Assign tasks to local node and slaves only  (Read 1512 times)


  • JPPF Padawan
  • *
  • Posts: 2
Assign tasks to local node and slaves only
« on: October 20, 2017, 02:59:52 AM »

I am running JPPF 5.2 on Windows 10 machines.  I have a computer running a JPPF driver with a local node, and several slave nodes off the local node.  I also have networked computers running nodes.  I would like to be able to specify a job to only assign tasks to the local node and its slave nodes, or only to remote nodes.  However, creating a server execution policy with = true seems to restrict assignment to only the local node, excluding the local slave nodes.  Conversely, using = false allows assignment to all the local slave nodes, and only prevents task assignment to the local master node itself.

Any help in creating this configurability is greatly appreciated!



  • Administrator
  • JPPF Council Member
  • *****
  • Posts: 2272
    • JPPF Web site
Re: Assign tasks to local node and slaves only
« Reply #1 on: October 20, 2017, 11:10:36 AM »

Hello Ricky,

There are several ways you can accomplish this.

1) You can create a policy that accepts either a local node or a slave node:

Code: [Select]
public static ExecutionPolicy createLocalOrSlavePolicy() {
  return new Equal("", true).or(new Equal("jppf.node.provisioning.slave", true));

Here, we use the fact that each master or slave carries 2 boolean configuration properties, "jppf.node.provisioning.master" and "jppf.node.provisioning.slave". Their values are (true, false) for a master node and (false, true) for a slave node. These values are automatically set by JPPF.

2) You can use the fact that the local node and its slaves are all on the same machine, and create an IP address-based policy, using the IP address of the driver which is also on the same machine:

Code: [Select]
public static ExecutionPolicy createIPPolicy(JPPFClient jppfClient) throws Exception {
  // obtain the ip address from the driver connection pool
  String ip = jppfClient.awaitWorkingConnectionPool().getDriverIPAddress();
  // return a policy based on whether this is an IPv4 or IPv6 address
  InetAddress addr = InetAddress.getByName(ip);
  return (addr instanceof Inet4Address) ? new IsInIPv4Subnet(ip) : new IsInIPv6Subnet(ip);

Note that a drawback of this method is that it won't work if you have another master node on the same machine. For more details, I invite you to look at the javadoc for IsInIPv4Subnet and IsInIPv6Subnet.

3) You can also use the fact that each slave node carries the UUID of its master node via the string property "jppf.node.provisioning.master.uuid". Unfortunately, this property is not well documented, see the doc bug JPPF-521 Document the "jppf.node.provisioning.master.uuid" configuration property. Example:

Code: [Select]
public static ExecutionPolicy createMasterGroupPolicy(JPPFClient jppfClient) throws Exception {
  // find the uuid of the master node via JMX
  JMXDriverConnectionWrapper jmx = jppfClient.awaitWorkingConnectionPool().awaitWorkingJMXConnection();
  // restrict the node search to the local node via a node selector
  Collection<JPPFManagementInfo> infos = jmx.nodesInformation(new ExecutionPolicySelector(new Equal("", true)));
  JPPFManagementInfo info = infos.iterator().next();
  return new Equal("", true).or(new Equal("jppf.node.provisioning.master.uuid", false, info.getUuid()));

Lastly, if you wish to exclude the local node and its slaves, you can simply negate the execution policy that includes them:

Code: [Select]
ExecutionPolicy includePolicy = ...;
ExecutionPolicy excludePolicy;
// the following 2 lines are equivalent
excludePolicy = includePolicy.not();
excludePolicy = new ExecutionPolicy.NotRule(includePolicy);

I hope this helps,


  • JPPF Padawan
  • *
  • Posts: 2
Re: Assign tasks to local node and slaves only
« Reply #2 on: October 21, 2017, 09:36:43 AM »


Thank you very much for your detailed reply!  I don't think solution #1 is applicable because (I failed to mention) the networked machines also have slave nodes running.  However, I have implemented the IP based execution policy and things are looking good.  Solution #3 will be kept in the back pocket if needed :)

Thanks again!

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