Click on Javadoc link to open Javadoc documentation.
Package
org.gridgain.grid.spi.loadbalancing.weightedrandom Javadoc![]()
Available starting with GridGain 
Description
GridWeightedRandomLoadBalancingSpi ![]()
![]()
![]()
Configuration
The following configuration parameters can be used to configure GridWeightedRandomLoadBalancingSpi ![]()
| Setter Method | Description | Optional | Default |
|---|---|---|---|
| setUseWeights(boolean) |
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) |
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 |
Examples
As any GridGain SPI, GridWeightedRandomLoadBalancingSpi ![]()
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.
