Adding Load Sharing to Routing Script
(New page) |
(→Setting up Filter Scripts) |
||
Line 27: | Line 27: | ||
require 'nap_group_weight_load_balancer' | require 'nap_group_weight_load_balancer' | ||
− | class | + | class SimpleRouting < BaseRouting |
include NapGroupAndWeightLoadBalancer | include NapGroupAndWeightLoadBalancer | ||
Line 41: | Line 41: | ||
end | end | ||
− | </pre> | + | </pre> |
+ | |||
== Adding New Custom Variables <br> == | == Adding New Custom Variables <br> == | ||
You need to add two custom columns to use this script. There is a default value creates and it can be changed in each route afterwards. | You need to add two custom columns to use this script. There is a default value creates and it can be changed in each route afterwards. |
Revision as of 04:36, 23 April 2015
This shows how to add Priority and Load sharing to any Routing scripts. This is a powerful script that allows to regroup Routes of the same kind, distribute load among them and prioritize one group versus another. Alternatively, you can do the same on NAPs. You will use two additional parameters in the routes: group and weight.
group serves as two purpose:
- priority: a lower value will have higher priority
- matching routes of the same group will load share according to the weight parameter
weight will load share calls among matching routes of the same group
Setting up Filter Scripts
To setup a Filter, the main script needs to be modified. The main script can be either simple_routing.rb, or any other script.
First, go to the routing script section of the Web portal
Gateway -> Routing scripts -> Example Scripts -> simple_routing.rb [Edit]
Three things need to be added. At the start of the script:
require 'nap_group_weight_load_balancer'
In the main class:
include NapGroupAndWeightLoadBalancer
after_filter :method => :filter_by_group_and_weight
The final script will look like this:
require 'base_routing' require 'nap_group_weight_load_balancer' class SimpleRouting < BaseRouting include NapGroupAndWeightLoadBalancer route_match :call_field_name => :called route_match :call_field_name => :calling route_match :call_field_name => :nap route_match :method => :match_nap_availability route_remap :call_field_name => :called, :route_field_name => :remapped_called route_remap :call_field_name => :calling, :route_field_name => :remapped_calling route_remap :call_field_name => :nap, :route_field_name => :remapped_nap after_filter :method => :filter_by_group_and_weight end
Adding New Custom Variables
You need to add two custom columns to use this script. There is a default value creates and it can be changed in each route afterwards.
Gateway -> Routes -> Create New Route Column
Name: group
Type attributes: integer
Default: 10
Gateway -> Routes -> Create New Route Column
Name: Weight
Type attributes: integer
Default: 100