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 
June 04, 2023, 06:54:27 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: [5.2.6] Client-side configuration for different job execution policy  (Read 1837 times)

kardigen

  • JPPF Padawan
  • *
  • Posts: 11

Hello All,
  I'd like to configure JPPF [5.2.6] client to work in configuration: JBoss 6 with JEE connector and client-side load balancing + n x drivers with local node. This configuration suits me best for different reasons. Beside that, I'd like to run different jobs with different execution policies. I was able to run client side balancing with configuration:
client:
Code: [Select]
jppf.drivers = driver1
driver1.jppf.priority = 10
driver1.jppf.pool.size = 2
//driver 2 and next with similar configuration

jppf.local.execution.enabled = true
jppf.local.execution.priority = 1
jppf.remote.execution.enabled = true

jppf.load.balancing.algorithm = manual
jppf.load.balancing.profile.manual_profile.size = 100

Driver configuration:
Code: [Select]
jppf.local.node.enabled = true

Beside that I added following code when job is created:

Code: [Select]
job.getClientSLA().setMaxChannels(20);

Question 1
Now, I have 2 different jobs: A and B.
I'd like to run job A on standard configuration - this part works fine.
Job B instead I would like to run with client local execution only.

I found this way in documentation
Code: [Select]
ExecutionPolicy localExecutionPolicy = new Equal("jppf.channel.local", true);
job.getClientSLA().setExecutionPolicy(localExecutionPolicy);

Firstly I run job A and all is good. It runs on remote JPPF Driver. Then I run job B and it stops - freezes. I didn't want to go into debugging etc, probably I configured sth wrongly.

Question 2
If I have different tasks in job A, and I would like to change jppf.load.balancing.profile.manual_profile.size parameter depends on tasks I added to job, can I do that using client JEE connector or job API?

Any help would be grateful.

Regards
Logged

lolo

  • Administrator
  • JPPF Council Member
  • *****
  • Posts: 2272
    • JPPF Web site
Re: [5.2.6] Client-side configuration for different job execution policy
« Reply #1 on: June 01, 2017, 07:21:56 AM »

Hello,

Regarding question 1: the problem with job B is that you set it to run locally in the client with the localExecutionPolicy, but you have set the local execution priority too low.
The priority of an execution channel, either local or remote, is used to define a failover hierarchy over the declared connection pools. Here you have set "driver1.jppf.priority = 10" and "jppf.local.execution.priority = 1". What this means, is that local execution will only be activated when remote connections for the "driver1" pool are no longer available for any reason.
To resolve this, you need to set both pools to the same priority, for instance with "jppf.local.execution.priority = 10"

Regarding your second question, unfortunately the settings of the load-balancer cannot be changed dynamically in the JPPF client. I created an enhancement request for that: JPPF-502 Ability to dynamically change the settings of the client load balancer.
However, you can achieve the same thing by using a job-aware, custom load balancer. As an example, here is a simple load-balancer implementation that sends as many tasks as there are in the job:

Code: [Select]
public class MyLoadBalancer extends AbstractBundler<LoadBalancingProfile> implements JobAwarenessEx {
  private int nbTasksToSend = 1;

  public MyLoadBalancer(LoadBalancingProfile profile) {
    super(profile);
  }

  @Override
  public int getBundleSize() {
    return nbTasksToSend;
  }

  @Override
  public void setJob(JPPFDistributedJob job) {
    // number of tasks to send = number of tasks in the job
    this.nbTasksToSend = job.getTaskCount();
  }

  @Override
  public JPPFDistributedJob getJob() {
    return null;
  }
}

the bundle provider to plug it to JPPF via SPI:

Code: [Select]
public class MyProvider implements JPPFBundlerProvider<LoadBalancingProfile> {
  @Override
  public String getAlgorithmName() {
    // name of the algorithm, to use in the configuration, e.g. "jppf.load.balancing.algorithm = MyLoadBalancer"
    return "MyLoadBalancer";
  }

  @Override
  public Bundler<LoadBalancingProfile> createBundler(LoadBalancingProfile profile) {
    return new MyLoadBalancer(profile);
  }

  @Override
  public LoadBalancingProfile createProfile(TypedProperties configuration) {
    return null;
  }
}

For your convenience, I attached the full source to this post. Feel free to use it as a starting point.

Sincerely,
-Laurent
« Last Edit: June 01, 2017, 07:44:54 AM by lolo »
Logged

kardigen

  • JPPF Padawan
  • *
  • Posts: 11
Re: [5.2.6] Client-side configuration for different job execution policy
« Reply #2 on: June 01, 2017, 09:10:13 AM »

Hi all
Many thanks Lolo for comprehensive explanation!

I'm using priority, because it's comfortable to run remotely jobs when grid is available or locally when it's not.
So the question now is, how can I make similar policy using the same priority?

Sth like that: when grid is available the job A is executed on grid and job B is executed locally. Whereas when grid is off job A and job B will run locally. Any idea how to achieve that?

Other approach I would accept is that I can configure it manually. So I want to set if job A will run on grid or locally being sure that job B will be executed locally always. So for example I could set

Code: [Select]
jppf.local.execution.enabled = false

when the grid is available. Than, can I alter this setting with execution policy/any other API when running job B? Is it going to work this way?
Basically I would like to have more control of what and where will be executed.

Regards,
Kardigen
Logged

lolo

  • Administrator
  • JPPF Council Member
  • *****
  • Posts: 2272
    • JPPF Web site
Re: [5.2.6] Client-side configuration for different job execution policy
« Reply #3 on: June 02, 2017, 10:14:26 AM »

Hi Kardigen,

The requirement for job A to be executed remotely when the grid is available, and locally when it is not, can be fullfilled with a custom execution policy on the client side, like this:

Code: [Select]
public class RemoteFirstPolicy extends CustomPolicy {
  private transient JPPFClient client;

  @Override
  public boolean accepts(final PropertiesCollection info) {
    // safely cast to JPPFSystemInformation for convenience
    JPPFSystemInformation sinfo = (JPPFSystemInformation) info;
    // whether the channel this policy is evaluated against is local
    boolean local = sinfo.getJppf().getBoolean("jppf.channel.local", false);
    // whether at least one remote server connection is in a working state
    boolean remoteAvailable = !client.findConnectionPools(JPPFClientConnectionStatus.ACTIVE, JPPFClientConnectionStatus.EXECUTING).isEmpty();
    return (local && !remoteAvailable) || !local;
  }

  public RemoteFirstPolicy setClient(final JPPFClient client) {
    this.client = client;
    return this;
  }
}

In your client application, you can then use it like this:

Code: [Select]
JPPFClient client = ...;
JPPFJob jobA = new JPPFJob();
jobA.getClientSLA().setExecutionPolicy(new RemoteFirstPolicy().setClient(client));

I've tested it, submitting concurrently a job A with this policy and a job B with a local-only policy, in scenarios where the grid is available and where it is not, and this works as expected.

To answer your last question, yes it is possible to enable/disable local execution dynamically, using the JPPFClient.setLocalExecutionEnabled(boolean enabled) method.

I hope this helps,
-Laurent
Logged

kardigen

  • JPPF Padawan
  • *
  • Posts: 11
Re: [5.2.6] Client-side configuration for different job execution policy
« Reply #4 on: June 02, 2017, 01:55:22 PM »

Laurent,
Many thanks for your support! You are great!  :)

Best,
Kardigen
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