Browse Source

- finish refactoring of carrierroute module
- replace O(n) matching logic for carrier and domain names with a efficient
binary search implementation
- use qsort and bsearch of glibc in most of the cases, where its possible
(basically all carrier/domain searches are O(log n) now, only when dynamic
strings for are used in the cfg, it needs to search the whole list)
- change carrier and domain names from string to integer, to allow the lookup
- instead of storing the carrier/domain name string in the memory structure,
a pointer to the name is used to save space
- get rid of this internal ID vs. external ID stuff, we use now only one
- rename the route_tree table to carrier_name
- add a new table domain_name, to hold the domain names (like route_tree tbl)
- adapt tests for the new or changed functionality
- extend documentation with a paragraph about the used matching logic
- Credits for this work belongs to Hardy Kahl, hardy dot kahl at 1und1 dot de
- fix a few errors in the postgres cr test, fix a few doxygen statements
- move some parts of log messages to DBG log level
- update documentation and database schemes


git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@5189 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt 17 years ago
parent
commit
2d0ae74699

+ 2 - 2
lib/srdb1/schema/route_tree.xml → lib/srdb1/schema/carrier_name.xml

@@ -7,8 +7,8 @@
 	  
 	  ]>
 	  
-	  <table id="route_tree" xmlns:db="http://docbook.org/ns/docbook">
-		  <name>route_tree</name>
+	  <table id="carrier_name" xmlns:db="http://docbook.org/ns/docbook">
+		  <name>carrier_name</name>
 		  <version>1</version>
 		  <type db="mysql">&MYSQL_TABLE_TYPE;</type>
 		  <description>

+ 11 - 9
lib/srdb1/schema/carrierfailureroute.xml

@@ -9,7 +9,7 @@
 	  
 	  <table id="carrierfailureroute" xmlns:db="http://docbook.org/ns/docbook">
 		  <name>carrierfailureroute</name>
-		  <version>1</version>
+		  <version>2</version>
 		  <type db="mysql">&MYSQL_TABLE_TYPE;</type>
 		  <description>
 			  <db:para>This table is used by the carrierroute module to provide failure routing capabilities. It contains the 
@@ -38,10 +38,11 @@
 		  
 		  <column>
 			  <name>domain</name>
-			  <type>string</type>
-			  <size>&user_len;</size>
-			  <default/>
-			  <description>Name of column contains the rule domain. You can define several routing domains
+			  <type>unsigned int</type>
+			  <size>&table_id_len;</size>
+			  <default>0</default>
+			  <natural/>
+			  <description>This column contains the routing domain id. You can define several routing domains
 			  to have different routing rules. Maybe you use domain 0 for normal routing and domain 1 if
 			  domain 0 failed.</description>
 		  </column>
@@ -93,10 +94,11 @@
 		  
 		  <column>
 			  <name>next_domain</name>
-			  <type>string</type>
-			  <size>&user_len;</size>
-			  <default/>
-			  <description>This column contains the route domain that should be used for the next routing attempt.</description>
+			  <type>unsigned int</type>
+			  <size>&table_id_len;</size>
+			  <default>0</default>
+			  <natural/>
+			  <description>This column contains the route domain id that should be used for the next routing attempt.</description>
 		  </column>
 		  
 		  <column>

+ 6 - 5
lib/srdb1/schema/carrierroute.xml

@@ -9,7 +9,7 @@
 	  
 	  <table id="carrierroute" xmlns:db="http://docbook.org/ns/docbook">
 		  <name>carrierroute</name>
-		  <version>2</version>
+		  <version>3</version>
 		  <type db="mysql">&MYSQL_TABLE_TYPE;</type>
 		  <description>
 			  <db:para>This table is used by the carrierroute module to provides routing, balancing and blacklisting 
@@ -38,10 +38,11 @@
 		  
 		  <column>
 			  <name>domain</name>
-			  <type>string</type>
-			  <size>&user_len;</size>
-			  <default/>
-			  <description>Name of column contains the rule domain. You can define several routing
+			  <type>unsigned int</type>
+			  <size>&table_id_len;</size>
+			  <default>0</default>
+			  <natural/>
+			  <description>This column contains the routing domain id. You can define several routing
 			  domains to have different routing rules. Maybe you use domain 0 for normal routing and
 			  domain 1 if domain 0 failed.</description>
 		  </column>

+ 39 - 0
lib/srdb1/schema/domain_name.xml

@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE table PUBLIC "-//kamailio.org//DTD DBSchema V1.1//EN" 
+	  "http://kamailio.org/pub/kamailio/dbschema/dtd/1.1/dbschema.dtd" [
+	  
+	  <!ENTITY % entities SYSTEM "entities.xml">
+	  %entities;
+	  
+	  ]>
+	  
+	  <table id="domain_name" xmlns:db="http://docbook.org/ns/docbook">
+		  <name>domain_name</name>
+		  <version>1</version>
+		  <type db="mysql">&MYSQL_TABLE_TYPE;</type>
+		  <description>
+			  <db:para>This table is used by the carrierroute module to provides routing, balancing and blacklisting capabilities. It contains the existing domains, consisting of the ids and corresponding names. More
+			  information is available at: &KAMAILIO_MOD_DOC;carrierroute.html
+			  </db:para>
+		  </description>
+		  
+		  <column id="id">
+			  <name>id</name>
+			  <type>unsigned int</type>
+			  <size>&table_id_len;</size>
+			  <natural/>
+			  <autoincrement/>
+			  <primary/>
+			  <type db="dbtext">int,auto</type>
+			  <description>Name of the column containing the unique identifier of a domain.</description>
+		  </column>
+		  
+		  <column>
+			  <name>domain</name>
+			  <type>string</type>
+			  <size>&user_len;</size>
+			  <null/>
+			  <default><null/></default>
+			  <description>This column contains the domain name.</description>
+		  </column>
+	  </table>

+ 2 - 1
lib/srdb1/schema/kamailio-carrierroute.xml

@@ -11,5 +11,6 @@
     <name>carrierroute</name>
     <xi:include href="carrierroute.xml"/>
     <xi:include href="carrierfailureroute.xml"/>
-    <xi:include href="route_tree.xml"/>
+    <xi:include href="carrier_name.xml"/>
+    <xi:include href="domain_name.xml"/>
 </database>