Apache Ignite. I try to use WeightedRandomLoadBalancingSpi as loadBalancingSpi. At one node I set weight 10, at the other - 100. At a node with weight 10 a weaker configuration. Logs show that the number of tasks goes to both nodes the same.

How to make so that on a node with a large weight a larger number of tasks left?

Config 1

<property name="loadBalancingSpi"> <bean class="org.apache.ignite.spi.loadbalancing.weightedrandom.WeightedRandomLoadBalancingSpi"> <property name="useWeights" value="true"/> <property name="nodeWeight" value="10"/> </bean> </property> 

Config 2

  <property name="loadBalancingSpi"> <bean class="org.apache.ignite.spi.loadbalancing.weightedrandom.WeightedRandomLoadBalancingSpi"> <property name="useWeights" value="true"/> <property name="nodeWeight" value="100"/> </bean> </property> 

    1 answer 1

    As indicated in the WeightedRandomLoadBalancingSpi javadoc, you can use the ComputeTaskSplitAdapter or the usual ComputeTask with an embedded dependency.

     @LoadBalancerResource ComputeLoadBalancer balancer; 

    which can be used in the map method.

      public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, String arg) throws IgniteCheckedException { Map<MyFooBarJob, ClusterNode> jobs = new HashMap<>(); jobs.put(new MyFooBarJob(arg), balancer.getBalancedNode()); return jobs; } 
    New member
    Max is a new member of the site. Be lenient in asking clarifying questions, commenting and answering. Read about the norms of behavior .