Actions

Adding Load Sharing to Routing Script

Revision as of 10:54, 27 June 2018 by Luc Morissette (talk | contribs) (Added note on Load sharing script)

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:

  1. priority: a lower value will have higher priority
  2. 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

NOTE: starting from version 3.0.80 this script is installed by default (only for new installations, or a fresh routing script)

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