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, 11:41:43 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: Assign tasks to local node and slaves only  (Read 25 times)

calkuta

  • 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 jppf.channel.local = true seems to restrict assignment to only the local node, excluding the local slave nodes.  Conversely, using jppf.channel.local = 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!

Ricky
Logged

lolo

  • Administrator
  • JPPF Council Member
  • *****
  • Posts: 2207
    • 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("jppf.channel.local", 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("jppf.channel.local", true)));
  JPPFManagementInfo info = infos.iterator().next();
  return new Equal("jppf.channel.local", 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,
-Laurent
Logged

calkuta

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

Laurent,

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!

Ricky
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