[sr-dev] git:master: db_cassandra: Improved documentation and config file example

Anca Vamanu anca.vamanu at 1and1.ro
Wed Jan 9 13:20:04 CET 2013


Module: sip-router
Branch: master
Commit: b7fde2349a28e22cd9e02412d914d07ee8654f79
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b7fde2349a28e22cd9e02412d914d07ee8654f79

Author: Anca Vamanu <anca.vamanu at 1and1.ro>
Committer: Anca Vamanu <anca.vamanu at 1and1.ro>
Date:   Wed Jan  9 14:19:06 2013 +0200

db_cassandra: Improved documentation and config file example

---

 modules/db_cassandra/README                     |   41 ++++++++++++++----
 modules/db_cassandra/dbcassa_base.cpp           |    2 +-
 modules/db_cassandra/doc/db_cassandra_admin.xml |   51 +++++++++++++++++++----
 modules/db_cassandra/kamailio_cassa.cfg         |    2 +-
 4 files changed, 76 insertions(+), 20 deletions(-)

diff --git a/modules/db_cassandra/README b/modules/db_cassandra/README
index d9b955b..5ba9e4b 100644
--- a/modules/db_cassandra/README
+++ b/modules/db_cassandra/README
@@ -207,7 +207,8 @@ default_validation_class='UTF8Type' and key_validation_class='UTF8Type';
      * Third row: the columns that form the secondary key separated by
        space.
 
-   Bellow you can see the schema for the location table:
+   Bellow you can see the schema for the location table (when use_domain
+   not set):
 
    ...
    callid(string) cflags(int) contact(string) cseq(int) expires(timestamp) flags
@@ -219,10 +220,23 @@ eg_id(int)
    ...
 
    Observe first that the row key is the username and the secondary index
-   is the contact. We have also defined a timestamp column - expires. In
-   this example, both the row key and the secondary index are defined by
-   only one column, but they can be formed out of more columns. You can
-   list them separated by space.
+   is the contact. We have also defined a timestamp column - expires.
+
+   If you need to use the domain part of the AOR also (you have set
+   use_domain parameter for usrloc in the script), you should include the
+   domain column in the list of columns and in the primary key. The schema
+   will then look like this:
+   ...
+   callid(string) cflags(int) contact(string) cseq(int) domain(string) expires(t
+imestamp) flags(int) last_modified(int) methods(int) path(string) q(double) rece
+ived(string) socket(string) user_agent(string) username(string) ruid(string) ins
+tance(string) reg_id(int)
+   username domain
+   contact
+   ...
+
+   Notice that a key (primary or secondary) can be composed from more
+   columns, in which case you have to specify them separated by space.
 
    To understand why the schema looks like this, we must first see which
    queries are performed on the location table. (The 'callid' condition
@@ -239,16 +253,25 @@ eg_id(int)
        secondary keys.
 
    The timestamp column that leaves the Cassandra cluster to deal with
-   deleting expired record can be used only with a modification to the
-   usrloc module that replaces the update performed at re-registration
-   with an insert operation (so that all columns are updated). This
-   behavior can be enabled by setting a parameter in the usrloc module
+   deleting the expired records. For this to work right we needed to
+   modify a bit the behavior of usrloc module and replace update sql query
+   performed at re-registration with an insert sql query (so that all
+   columns are updated and the new timestamp is set for all columns). This
+   behavior is enabled by setting a parameter in the usrloc module
    db_update_as_insert:
 
    ...
    modparam("usrloc", "db_update_as_insert", 1)
    ...
 
+   Also you should disable in usrloc module the timer routine that checks
+   for expired records. You can do this by setting the timer interval to
+   0. timer_interval:
+
+   ...
+   modparam("usrloc", "timer_interval", 0)
+   ...
+
    The alternative would have been to define an index on the expire column
    and run a external job to periodically delete the expired records.
    However, obviously, this would be more costly.
diff --git a/modules/db_cassandra/dbcassa_base.cpp b/modules/db_cassandra/dbcassa_base.cpp
index dfbf58f..e9d3a32 100644
--- a/modules/db_cassandra/dbcassa_base.cpp
+++ b/modules/db_cassandra/dbcassa_base.cpp
@@ -359,7 +359,7 @@ int cassa_constr_key( const db_key_t* _k, const db_val_t* _v,
 				break;
 		}
 		if(j == _n) {
-			LM_ERR("The key column with name [%.*s] not found in values\n", key_array[i]->name.len, key_array[i]->name.s);
+			LM_DBG("The key column with name [%.*s] not found in values\n", key_array[i]->name.len, key_array[i]->name.s);
 			break;
 		}
 		pk= dbval_to_string(_v[j], pk);
diff --git a/modules/db_cassandra/doc/db_cassandra_admin.xml b/modules/db_cassandra/doc/db_cassandra_admin.xml
index c0b3f86..0a05914 100644
--- a/modules/db_cassandra/doc/db_cassandra_admin.xml
+++ b/modules/db_cassandra/doc/db_cassandra_admin.xml
@@ -227,7 +227,8 @@ default_validation_class='UTF8Type' and key_validation_class='UTF8Type';
 		</itemizedlist>
 		</para>
 		<para>
-		Bellow you can see the schema for the <emphasis>location</emphasis> table:
+			Bellow you can see the schema for the <emphasis>location</emphasis>
+			table (when use_domain not set):
 		</para>
 	<para>
 	</para>
@@ -241,13 +242,30 @@ default_validation_class='UTF8Type' and key_validation_class='UTF8Type';
 </programlisting>
 
 	<para>
-		Observe first that the <emphasis>row key is the username</emphasis> and the <emphasis>secondary index is the contact</emphasis>.
+		Observe first that the <emphasis>row key is the username</emphasis> and
+		the <emphasis>secondary index is the contact</emphasis>. 
 		We have also defined a timestamp column - <emphasis>expires</emphasis>.
-		In this example, both the row key and the secondary index are defined by only one column,
-		but they can be formed out of more columns.  You can list them separated by space.
 	</para>
 
 	<para>
+		If you need to use the domain part of the AOR also (you have set use_domain
+		parameter for usrloc in the script), you should include the domain column in
+		the list of columns and in the primary key. The schema will then look like this:
+	</para>
+
+<programlisting format="linespecific">
+   ...
+   callid(string) cflags(int) contact(string) cseq(int) domain(string) <emphasis>expires(timestamp)</emphasis> flags(int) last_modified(int) methods(int) path(string) q(double) received(string) socket(string) user_agent(string) username(string) ruid(string) instance(string) reg_id(int)
+   <emphasis>username domain</emphasis>
+   <emphasis>contact</emphasis>
+   ...
+</programlisting>
+
+	<para>
+		Notice that a key (primary or secondary) can be composed from more columns,
+		in which case you have to specify them separated by space.
+	</para>
+	<para>
 		To understand why the schema looks like this, we must first see which
 		queries are performed on the location table. 
 		(The 'callid' condition was ignored as it doesn't really have a well defined role in the SIP RFC).
@@ -281,11 +299,11 @@ default_validation_class='UTF8Type' and key_validation_class='UTF8Type';
 		</listitem>
 	</itemizedlist>
 	<para>
-		The timestamp column that leaves the Cassandra cluster to deal with deleting expired
-		record can be used only with a modification to the usrloc module that replaces the 
-		update performed at re-registration with an insert operation (so that all columns 
-		are updated).
-		This behavior can be enabled by setting a parameter in the usrloc module 
+		The timestamp column that leaves the Cassandra cluster to deal with deleting the expired
+		records. For this to work right we needed to modify a bit the behavior of usrloc module and
+		replace update sql query performed at re-registration with an insert sql query (so that all
+		columns are updated and the new timestamp is set for all columns).
+		This behavior is enabled by setting a parameter in the usrloc module
 		<emphasis>db_update_as_insert</emphasis>:
 	</para>
 	<para>
@@ -298,6 +316,21 @@ default_validation_class='UTF8Type' and key_validation_class='UTF8Type';
 </programlisting>
 
 	<para>
+		Also you should disable in usrloc module the timer routine that checks for expired records.
+		You can do this by setting the timer interval to 0.
+		<emphasis>timer_interval</emphasis>:
+	</para>
+	<para>
+	</para>
+
+<programlisting format="linespecific">
+   ...
+   modparam("usrloc", "timer_interval", 0)
+   ...
+</programlisting>
+
+
+	<para>
 		The alternative would have been to define an index on the expire column and 
 		run a external job to periodically delete the expired records. However,
 		obviously, this would be more costly.
diff --git a/modules/db_cassandra/kamailio_cassa.cfg b/modules/db_cassandra/kamailio_cassa.cfg
index 69bad70..d0b97e4 100644
--- a/modules/db_cassandra/kamailio_cassa.cfg
+++ b/modules/db_cassandra/kamailio_cassa.cfg
@@ -313,6 +313,7 @@ modparam("acc", "db_extra",
 modparam("usrloc", "db_url", DBURL)
 modparam("usrloc", "db_mode", 3)
 modparam("usrloc", "db_update_as_insert", 1)
+modparam("usrloc", "timer_interval", 0)
 #modparam("usrloc", "use_domain", MULTIDOMAIN)
 
 
@@ -323,7 +324,6 @@ modparam("auth_db", "calculate_ha1", yes)
 modparam("auth_db", "password_column", "password")
 modparam("auth_db", "load_credentials", "")
 #modparam("auth_db", "use_domain", MULTIDOMAIN)
-modparam("auth_db", "use_domain", 1)
 
 # ----- permissions params -----
 #!ifdef WITH_IPAUTH




More information about the sr-dev mailing list