Dashboard > GridGain User Guide > Table Of Contents > Developers Guide > Load Balancing SPI > GridWeightedRandomLoadBalancingSpi
GridWeightedRandomLoadBalancingSpi
Added by morpheus, last edited by morpheus on Feb 05, 2008  (view change)
Labels: 
(None)


Click on Javadoc link to open Javadoc documentation.

Package

org.gridgain.grid.spi.loadbalancing.weightedrandom Javadoc

Available starting with GridGain

Description

GridWeightedRandomLoadBalancingSpi Javadoc picks a random node for job execution. Note that you can optionally assign weights to nodes, so nodes with larger weights will end up getting proportionally more jobs routed to them (see GridWeightedRandomLoadBalancingSpi Javadoc configuration property). By default all nodes get equal weight defined by DFLT_NODE_WEIGHT Javadoc (value is 10).

Configuration

The following configuration parameters can be used to configure GridWeightedRandomLoadBalancingSpi Javadoc

Setter Method Description Optional Default
setUseWeights(boolean) Javadoc Configuration parameter indicating whether node weights should be checked when doing random load balancing. Yes Default value is false which means that node weights are disregarded for load balancing logic.
setNodeWeight(int) Javadoc Configuration parameter for weight of the node. Nodes with more processing capacity should be assigned proportionally larger weight. Yes Default value is DFLT_NODE_WEIGHT Javadoc and is equal for all nodes.

Examples

As any GridGain SPI, GridWeightedRandomLoadBalancingSpi Javadoc SPI can be configured either directly from code or from Spring configuration file. Here is an example of GridWeightedRandomLoadBalancingSpi configuration from code:

GridWeightedRandomLoadBalancingSpi = new GridWeightedRandomLoadBalancingSpi();
 
// Configure SPI to used weighted
// random load balancing.
spi.setUseWeights(true);

// Set weight for the local node.
spi.setWeight(10);

GridConfigurationAdapter cfg = new GridConfigurationAdapter();

// Override default load balancing SPI.
cfg.setLoadBalancingSpi(spi);

// Start grid.
GridFactory.start(cfg);

or from Spring configuration file

<bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true">
    ...
    <property name="loadBalancingSpi">
         <bean class="org.gridgain.grid.spi.loadbalancing.weightedrandom.GridWeightedRandomLoadBalancingSpi">
             <property name="useWeights" value="true"/>
             <property name="nodeWeight" value="10"/>
         </bean>
    </property>
    ...
</bean>


For more information about using Spring framework for configuration click here.

Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.10 Build:#528 Nov 29, 2006) - Bug/feature request - Contact Administrators