added all the tables for data import and created configuration diagrams.

This commit is contained in:
Radu Ioan Fericean
2012-07-10 15:57:12 +03:00
parent f3fa8e9853
commit 37053fb3f5
12 changed files with 194 additions and 184 deletions

BIN
docs/images/Complicated.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -0,0 +1 @@
<mxGraphModel dx="800" dy="800" grid="1" guides="1" tooltips="1" connect="1" fold="1" page="1" pageScale="1" pageWidth="826" pageHeight="1169" style="default-style2"><root><mxCell id="0"/><mxCell id="1" parent="0"/><mxCell id="7" value="&#xa;Balancer" style="rounded=1" vertex="1" parent="1"><mxGeometry x="320" y="100" width="120" height="60" as="geometry"/></mxCell><mxCell id="8" value="&#xa;FreeSwitch" style="rounded=1" vertex="1" parent="1"><mxGeometry x="30" y="60" width="120" height="60" as="geometry"/></mxCell><mxCell id="9" value="&#xa;&#xa;DB" style="shape=cylinder" vertex="1" parent="1"><mxGeometry x="640" y="30" width="60" height="80" as="geometry"/></mxCell><mxCell id="12" value="&#xa;Rater" style="rounded=1" vertex="1" parent="1"><mxGeometry x="490" y="40" width="60" height="60" as="geometry"/></mxCell><mxCell id="13" value="&#xa;Rater" style="rounded=1" vertex="1" parent="1"><mxGeometry x="490" y="140" width="60" height="60" as="geometry"/></mxCell><mxCell id="16" value="&#xa;&#xa;DB" style="shape=cylinder" vertex="1" parent="1"><mxGeometry x="650" y="130" width="60" height="80" as="geometry"/></mxCell><mxCell id="17" value="" style="endArrow=open;exitX=1;exitY=0.5;entryX=0;entryY=0.5;startArrow=open" edge="1" parent="1" source="7" target="12"><mxGeometry as="geometry"/></mxCell><mxCell id="18" value="" style="endArrow=open;exitX=1;exitY=0.5;entryX=0;entryY=0.5;startArrow=open" edge="1" parent="1" source="7" target="13"><mxGeometry as="geometry"/></mxCell><mxCell id="19" value="" style="endArrow=open;exitX=1;exitY=0.5;entryX=0;entryY=0.5;startArrow=open" edge="1" parent="1" source="12" target="9"><mxGeometry as="geometry"/></mxCell><mxCell id="20" value="" style="endArrow=open;exitX=1;exitY=0.5;entryX=0;entryY=0.5;startArrow=open" edge="1" parent="1" source="13" target="16"><mxGeometry as="geometry"/></mxCell><mxCell id="24" value="" style="endArrow=open;exitX=0.5;exitY=1;startArrow=open" edge="1" parent="1" source="9" target="16"><mxGeometry as="geometry"/></mxCell><mxCell id="25" value="Seesion&#xa;Manager" style="rounded=1" vertex="1" parent="1"><mxGeometry x="210" y="60" width="70" height="60" as="geometry"/></mxCell><mxCell id="26" value="Seesion&#xa;Manager" style="rounded=1" vertex="1" parent="1"><mxGeometry x="210" y="140" width="70" height="60" as="geometry"/></mxCell><mxCell id="31" value="&#xa;FreeSwitch" style="rounded=1" vertex="1" parent="1"><mxGeometry x="30" y="140" width="120" height="60" as="geometry"/></mxCell><mxCell id="32" value="" style="endArrow=open;exitX=1;exitY=0.5;entryX=0;entryY=0.5;startArrow=open" edge="1" parent="1" source="8" target="25"><mxGeometry as="geometry"/></mxCell><mxCell id="33" value="" style="endArrow=open;exitX=1;exitY=0.5;entryX=0;entryY=0.5;startArrow=open" edge="1" parent="1" source="31" target="26"><mxGeometry as="geometry"/></mxCell><mxCell id="34" value="" style="endArrow=open;exitX=1;exitY=0.5;entryX=0;entryY=0.5;startArrow=open" edge="1" parent="1" source="26" target="7"><mxGeometry as="geometry"/></mxCell><mxCell id="37" value="" style="endArrow=open;exitX=1;exitY=0.5;entryX=0;entryY=0.5;startArrow=open" edge="1" parent="1" source="25" target="7"><mxGeometry as="geometry"/></mxCell></root></mxGraphModel>

BIN
docs/images/Normal.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

1
docs/images/Normal.xml Normal file
View File

@@ -0,0 +1 @@
<mxGraphModel dx="800" dy="800" grid="1" guides="1" tooltips="1" connect="1" fold="1" page="1" pageScale="1" pageWidth="826" pageHeight="1169" style="default-style2"><root><mxCell id="0"/><mxCell id="1" parent="0"/><mxCell id="7" value="Session manager&#xa;+&#xa;Balancer" style="rounded=1" vertex="1" parent="1"><mxGeometry x="310" y="60" width="120" height="60" as="geometry"/></mxCell><mxCell id="8" value="&#xa;FreeSwitch" style="rounded=1" vertex="1" parent="1"><mxGeometry x="80" y="60" width="120" height="60" as="geometry"/></mxCell><mxCell id="9" value="&#xa;&#xa;DB" style="shape=cylinder" vertex="1" parent="1"><mxGeometry x="640" y="30" width="60" height="80" as="geometry"/></mxCell><mxCell id="10" value="" style="endArrow=open;exitX=1;exitY=0.5;entryX=0;entryY=0.5;startArrow=open" edge="1" parent="1" source="8" target="7"><mxGeometry as="geometry"/></mxCell><mxCell id="12" value="&#xa;Rater" style="rounded=1" vertex="1" parent="1"><mxGeometry x="490" y="40" width="60" height="60" as="geometry"/></mxCell><mxCell id="13" value="&#xa;Rater" style="rounded=1" vertex="1" parent="1"><mxGeometry x="490" y="140" width="60" height="60" as="geometry"/></mxCell><mxCell id="16" value="&#xa;&#xa;DB" style="shape=cylinder" vertex="1" parent="1"><mxGeometry x="650" y="130" width="60" height="80" as="geometry"/></mxCell><mxCell id="17" value="" style="endArrow=open;exitX=1;exitY=0.5;entryX=0;entryY=0.5;startArrow=open" edge="1" parent="1" source="7" target="12"><mxGeometry as="geometry"/></mxCell><mxCell id="18" value="" style="endArrow=open;exitX=1;exitY=0.5;entryX=0;entryY=0.5;startArrow=open" edge="1" parent="1" source="7" target="13"><mxGeometry as="geometry"/></mxCell><mxCell id="19" value="" style="endArrow=open;exitX=1;exitY=0.5;entryX=0;entryY=0.5;startArrow=open" edge="1" parent="1" source="12" target="9"><mxGeometry as="geometry"/></mxCell><mxCell id="20" value="" style="endArrow=open;exitX=1;exitY=0.5;entryX=0;entryY=0.5;startArrow=open" edge="1" parent="1" source="13" target="16"><mxGeometry as="geometry"/></mxCell><mxCell id="24" value="" style="endArrow=open;exitX=0.5;exitY=1;startArrow=open" edge="1" parent="1" source="9" target="16"><mxGeometry as="geometry"/></mxCell></root></mxGraphModel>

BIN
docs/images/Simple.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

1
docs/images/Simple.xml Normal file
View File

@@ -0,0 +1 @@
<mxGraphModel dx="800" dy="800" grid="1" guides="1" tooltips="1" connect="1" fold="1" page="1" pageScale="1" pageWidth="826" pageHeight="1169" style="default-style2"><root><mxCell id="0"/><mxCell id="1" parent="0"/><mxCell id="7" value="Session manager&#xa;+&#xa;Rater" style="rounded=1" vertex="1" parent="1"><mxGeometry x="380" y="60" width="120" height="60" as="geometry"/></mxCell><mxCell id="8" value="&#xa;FreeSwitch" style="rounded=1" vertex="1" parent="1"><mxGeometry x="80" y="60" width="120" height="60" as="geometry"/></mxCell><mxCell id="9" value="&#xa;&#xa;DB" style="shape=cylinder" vertex="1" parent="1"><mxGeometry x="640" y="50" width="60" height="80" as="geometry"/></mxCell><mxCell id="10" value="" style="endArrow=open;exitX=1;exitY=0.5;entryX=0;entryY=0.5;startArrow=open" edge="1" parent="1" source="8" target="7"><mxGeometry as="geometry"/></mxCell><mxCell id="11" value="" style="endArrow=open;exitX=1;exitY=0.5;startArrow=open" edge="1" parent="1" source="7" target="9"><mxGeometry as="geometry"/></mxCell></root></mxGraphModel>

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

169
docs/importing.rst Normal file
View File

@@ -0,0 +1,169 @@
Data importing
=============
Rates profile
--------------
+------------+-----+-----------+-------------+----------------------+----------------+----------------------+
| Tenant | TOR | Direction | Subject | RatesFallbackSubject | RatesTimingTag | ActivationTime |
+============+=====+===========+=============+======================+================+======================+
| CUSTOMER_1 | 0 | OUT | rif:from:tm | danb | PREMIUM | 2012-01-01T00:00:00Z |
+------------+-----+-----------+-------------+----------------------+----------------+----------------------+
| CUSTOMER_1 | 0 | OUT | rif:from:tm | danb | STANDARD | 2012-02-28T00:00:00Z |
+------------+-----+-----------+-------------+----------------------+----------------+----------------------+
+ Tenant
Ceva text explicativ.
+ TOR
+ Direction
+ Subject
+ RatesFallbackSubject
+ RatesTimingTag
+ ActivationTime
Rates timings
-------------
+----------+----------------+--------------+
| Tag | RatesTag | TimingTag |
+==========+================+==============+
| STANDARD | RT_STANDARD | WORKDAYS_00 |
+----------+----------------+--------------+
| STANDARD | RT_STD_WEEKEND | WORKDAYS_18 |
+----------+----------------+--------------+
+ Tag
A string by witch this timing will be referenced in other places by.
+ RatesTag
+ TimingTag
Rates
-----
+---------------------+-----------------+------------+-------+-------------+--------+
| Tag | DestinationsTag | ConnectFee | Price | BillingUnit | Weight |
+=====================+=================+============+=======+=============+========+
| RT_STANDARD | GERMANY | 0 | 0.2 | 1 | 10 |
+---------------------+-----------------+------------+-------+-------------+--------+
| RT_STANDARD | GERMANY_O2 | 0 | 0.1 | 1 | 10 |
+---------------------+-----------------+------------+-------+-------------+--------+
+ Tag
A string by witch this rate will be referenced in other places by.
+ DestinationsTag
+ ConnectFee
+ Price
+ BillingUnit
+ Weight
Destinations
------------
The destinations are binding together various prefixes / caller ids to define a logical destination group. A prefix can appear in multiple destination groups.
+------------+-------+
| Tag | Prefix|
+============+=======+
| GERMANY | 49 |
+------------+-------+
| GERMANY_O2 | 49176 |
+------------+-------+
+ Tag
A string by witch this destination will be referenced in other places by.
+ Prefix
The prefix or caller id to be added to the specified destination.
Timings
-------
+-------------+--------+-----------+-----------+----------+
| Tag | Months | MonthDays | WeekDays | StartTime|
+=============+========+===========+===========+==========+
| WORKDAYS_00 | *all | *all | 1;2;3;4;5 | 00:00:00 |
+-------------+--------+-----------+-----------+----------+
| WORKDAYS_18 | *all | *all | 1;2;3;4;5 | 18:00:00 |
+-------------+--------+-----------+-----------+----------+
+ Tag
A string by witch this timing will be referenced in other places by.
+ Months
+ MonthDays
+ WeekDays
+ StartTime
Account actions
---------------
+------------+---------+-----------+------------------+------------------+
|Tenant | Account | Direction | ActionTimingsTag | ActionTriggersTag|
+============+=========+===========+==================+==================+
| CUSTOMER_1 | rif | OUT | STANDARD_ABO | STANDARD_TRIGGER |
+------------+---------+-----------+------------------+------------------+
| CUSTOMER_1 | dan | OUT | STANDARD_ABO | STANDARD_TRIGGER |
+------------+---------+-----------+------------------+------------------+
+ Tenant
+ Account
+ Direction
+ ActionTimingsTag
+ ActionTriggersTag
Action triggers
---------------
+------------------+------------+----------------+----------------+------------+--------+
| Tag | BalanceTag | ThresholdValue | DestinationTag | ActionsTag | Weight |
+==================+============+================+================+============+========+
| STANDARD_TRIGGER | MONETARY | 30 | *all | SOME_1 | 10 |
+------------------+------------+----------------+----------------+------------+--------+
| STANDARD_TRIGGER | SMS | 30 | *all |SOME_2 | 10 |
+------------------+------------+----------------+----------------+------------+--------+
+ Tag
A string by witch this action trigger will be referenced in other places by.
+ BalanceTag
+ ThresholdValue
+ DestinationTag
+ ActionsTag
+ Weight
Action timings
--------------
+--------------+------------+------------------+--------+
| Tag | ActionsTag | TimingTag | Weight |
+==============+============+==================+========+
| STANDARD_ABO | SOME | WEEKLY_SAME_TIME | 10 |
+--------------+------------+------------------+--------+
| STANDARD_ABO | SOME | WEEKLY_SAME_TIME | 10 |
+--------------+------------+------------------+--------+
+ Tag
A string by witch this action timing will be referenced in other places by.
+ ActionsTag
+ TimingTag
+ Weight
Actions
-------
+--------+-------------+------------+-------+----------------+-----------+------------+---------------+--------+
| Tag | Action | BalanceTag | Units | DestinationTag | PriceType | PriceValue | MinutesWeight | Weight |
+========+=============+============+=======+================+===========+============+===============+========+
| SOME | TOPUP_RESET | MONETARY | 10 | *all | | 10 |
+--------+-------------+------------+-------+----------------+-----------+------------+---------------+--------+
| SOME_1 | DEBIT | MINUTES | 10 | GERMANY_O2 | PERCENT | 25 | 10 | 10 |
+--------+-------------+------------+-------+----------------+-----------+------------+---------------+--------+
+ Tag
A string by witch this action will be referenced in other places by.
+ Action
+ BalanceTag
+ Units
+ DestinationTag
+ PriceType
+ PriceValue
+ MinutesWeight
+ Weight

View File

@@ -12,8 +12,9 @@ Contents:
:maxdepth: 2
intro
importing
tutorial
apicalls
apicalls
arhitecture

View File

@@ -4,11 +4,23 @@ CGRateS is a very fast and easy scalable rating engine targeted especially for t
It is written in go (http://golang.net) and accessible from any language via JSON RPC. The code is well documented (go doc compliant API docs) and heavily tested.
Supported databases: kyoto_ cabinet, redis_, mongodb_.
After testing various databases like Kyoto_ cabinet, Redis_ or Mongodb_, the project focused on Redis as it delivers the best trade-off between speed, configuration and scalability.
.. _kyoto: http://fallabs.com/kyotocabinet
.. _redis: http://redis.io
.. _mongodb: http://www.mongodb.org
.. _Redis: http://redis.io
.. _Mongodb: http://www.mongodb.org
Here are some of the configurations in which CGRateS can operate:
.. image:: images/Simple.png
If the network does not require more than one rater to handle the calls. The balancer can be left out and the rater can be queried directly. In this case the rater must be started with -standalone=true and -freeswitch=true options.
.. image:: images/Normal.png
While the network grows more raters can be thrown into the stack to offer more requests per seconds workload. This implies the usage of the balancer to distribute the requests to the raters running on the different machines.
.. image:: images/Complicated.png
Of course more session managers can serve multiple call switches and all of them are connected to the same balancer. We are planning to support multiple balancers for huge networks if the need arises.
Features
--------

View File

@@ -10,10 +10,6 @@ The general steps to get up and running with CGRateS are:
#. Start one ore more raters.
#. Make API calls to the balancer/rater.
.. image:: images/general.png
If the network does not require more than one rater to handle the calls. The balancer can be left out and the rater can be queried directly. In this case the rater must be started with --json=true option to instruct the application to offer the JSON-RPC interface.
CallDescriptor structure
------------------------
- TOR int
@@ -62,10 +58,9 @@ Instalation
After the go environment is installed_ and setup_ just issue the following commands:
::
go get github.com/rif/cgrates/cmd/cgr-rater
go get github.com/rif/cgrates/cmd/cgr-balancer
go get github.com/rif/cgrates/cmd/cgr-loader
go get github.com/rif/cgrates/cmd/cgr-console
go get github.com/cgrate/cgrates
This will install the sources and compile all available tools
After that navigate
@@ -91,7 +86,7 @@ cgr-balancer
cgr-rater
The cgr-rater can be provided with the balancer server address and can be configured to listen to a specific interface and port.
::
rif@grace:~$ cgr-rater --help
Usage of cgr-rater:
-balancer="127.0.0.1:2000": balancer address host:port
@@ -101,7 +96,7 @@ cgr-rater
cgr-console
The cgr-console is a command line tool used to access the balancer (or the rater directly) to call all the API methods offered by CGRateS.
::
rif@grace:~$ cgr-console --help
Usage of cgr-console:
-amount=100: Amount for different operations
@@ -151,173 +146,3 @@ cgr-loader
.. _data-importing:
Data importing
--------------
**Activation periods**
::
{"TOR": 0,"CstmId":"vdf","Subject":"rif","DestinationPrefix":"0257", "ActivationPeriods": [
{"ActivationTime": "2012-01-01T00:00:00Z", "Intervals": [
{"BillingUnit":1,"ConnectFee":0,"Month":0,"MonthDay":0,"Ponder":0,"Price":0.1,
"StartTime":"18:00:00","EndTime":"","WeekDays":[1,2,3,4,5]},
{"BillingUnit":1,"ConnectFee":0,"Month":0,"MonthDay":0,"Ponder":0,"Price":0.2,
"StartTime":"","EndTime":"18:00:00","WeekDays":[1,2,3,4,5]},
{"BillingUnit":1,"ConnectFee":0,"Month":0,"MonthDay":0,"Ponder":0,"Price":0.1,
"StartTime":"","EndTime":"","WeekDays":[6,0]}
]
},
{"ActivationTime": "2012-02-08T00:00:00Z", "Intervals": [
{"BillingUnit":60,"ConnectFee":0,"Month":0,"MonthDay":0,"Ponder":0,"Price":10,
"StartTime":"","EndTime":"18:00:00","WeekDays":[1,2,3,4,5]},
{"BillingUnit":60,"ConnectFee":0,"Month":0,"MonthDay":0,"Ponder":0,"Price":1,
"StartTime":"18:00:00","EndTime":"","WeekDays":[1,2,3,4,5]},
{"BillingUnit":60,"ConnectFee":0,"Month":0,"MonthDay":0,"Ponder":0,"Price":1,
"StartTime":"","EndTime":"","WeekDays":[6,0]}
]
}
]
}
The above snippet describes prices for subject "rif" and destination "0257". There are two activation periods, the first one is active starting 2012-01-01 and the second one starting from 2012-02-08. Each define multiple intervals with different prices for various time periods.
Parameters:
TOR
Type Of Service. For future extensions.
CstmId
Customer Id. Used for multi tenant databases.
Subject
The code that uniquely identifies a user.
DestinationPrefix
The destination network number. For speed reasons we are not using here the below described destinations. We are trading memory space for speed.
ActivationPeriods
A list of one ore more price descriptive periods. These periods must be contiguous and non overlapping.
ActivationTime
The time when current period becomes active.
Intervals
A list of price intervals intervals
Month
The month for this interval. Zero value means all months.
MonthDay
The day of the month for this interval. Zero value means all month days.
WeekDays
A list with the days of the week for this interval. An empty list means all week days.
StartTime, EndTime
The start and end hours in a day for this interval. Zero value means from/to start/end of the day.
Ponder
Used to set the priority of the interval in relation with other applicable intervals.
ConnectFee
The connection price for this interval.
Price
The unit price for this interval.
BillingUnit
The billing unit for this interval (in seconds). Value can be below one up to nanoseconds.
**Destinations**
::
{"Id":"nationale", "Prefixes":["0256","0257","0723","0740"]},
{"Id":"retea", "Prefixes":["0723","0724"]},
{"Id":"mobil", "Prefixes":["0723","0740"]},
{"Id":"radu", "Prefixes":["0723045326"]}
Destinations are list of prefixes that together define a destination. These destinations are used for definition of minute buckets.
Parameters:
Id
The Id of this destination. Can be anything (letters and/or numbers).
Prefixes
List with destination's prefixes. A prefix can appear in more than one destination.
**Tariff plans**
::
{"Id":"dimineata","SmsCredit":100,"ReceivedCallsSecondsLimit": 100,
"RecivedCallBonus" : {"Credit": 100},
"MinuteBuckets":
[{"Seconds":100,"Priority":10,"Price":0.01,"DestinationId":"nationale"},
{"Seconds":1000,"Priority":20,"Price":0,"DestinationId":"retea"}],
"VolumeDiscountThresholds":
[{"Volume": 100, "Discount": 10},
{"Volume": 500, "Discount": 15},
{"Volume": 1000, "Discount": 20}]
}
Tariff plans define the free quotas for network users. These amount are refilling the user budgets at specified intervals.
Parameters:
Id
An Id for this tariff plan. Can be anything (letters and/or numbers).
SmsCredit
The available free number of SMS.
Traffic
The available free amount of traffic.
ReceivedCallSecondsLimit
The threshold for receiving the incoming call volume bonus. When the user will receive this amount of incoming call seconds he/she will get the below described bonus.
RecivedCallBonus
The bonus that will be awarded when the incoming calls amount of seconds is reached. It can be one ore more of the following entities: Credit, SmsCredit, Traffic, MinuteBucket (an amount of free / cheaper seconds to a specific destination).
MinuteBuckets
A list of available special minutes for specific destinations. Each bucket can specify the available number of Seconds for a specific destination. It can also specify a priority Priority to establish the order of the bucket usage and a Price if he minutes are not free (but cheaper).
VolumeDiscountThresholds
A list threshold for placed calls volume discounts. Each threshold specifies a Volume and a Discount discount percentage.
**User budgets**
::
{"Id":"broker","Credit":0,"SmsCredit":0,"Traffic":0,"VolumeDiscountSeconds":0,
"ReceivedCallSeconds":0,"ResetDayOfTheMonth":10,"TariffPlanId":"seara","MinuteBuckets":
[{"Seconds":10,"Priority":10,"Price":0.01,"DestinationId":"nationale"},
{"Seconds":100,"Priority":20,"Price":0,"DestinationId":"retea"}]
}
User budget describes the amount of various free quotas for every client of the network. It contains the entities from the tariff plan plus more items to track user status.
Parameters:
Id
The Id uniquely identifies the client.
Credit
The amount of the available credit for prepaid or the total cost for postpaid.
SmsCredit
The number of available free SMS.
Traffic
The amount of available free Internet traffic.
VolumeDiscountSeconds
The accumulated number of placed call seconds to be used for volume discounts.
ReceivedCallSeconds
The accumulated amount of received call seconds to be used for received call bonus.
ResetDayOfTheMonth
The day of the month when the free quotas will be refiled.
TariffPlanId
The Id of the client's tariff plan. This is used to refill the free quotas
MinuteBuckets
A list of buckets containing the available seconds to various destinations.
Database selection
-------------------
**Kyoto cabinet**
Pros:
- super fast (the in memory data is accessed directly by the rater processes)
- easy backup
Cons:
- harder to synchronize different raters
**Redis**
Pros:
- easy configuration
- easy master-server configuration
Cons:
- slower than kyoto
- less features than mongodb
**MongoDB**
Pros:
- most features
- most advanced clustering options
Cons:
- slowest of the three