Skip to content

Commit

Permalink
dmq_usrloc: sync with multi contacts per message
Browse files Browse the repository at this point in the history
  • Loading branch information
jchavanton committed Apr 5, 2017
1 parent 6d9e020 commit f51f4df
Show file tree
Hide file tree
Showing 4 changed files with 252 additions and 61 deletions.
7 changes: 7 additions & 0 deletions src/modules/dmq_usrloc/dmq_usrloc.c
Expand Up @@ -37,6 +37,7 @@ static int child_init(int);
int dmq_usrloc_enable = 0;
int _dmq_usrloc_sync = 1;
int _dmq_usrloc_batch_size = 0;
int _dmq_usrloc_batch_msg_contacts = 1;
int _dmq_usrloc_batch_usleep = 0;
str _dmq_usrloc_domain = str_init("location");

Expand All @@ -47,6 +48,7 @@ MODULE_VERSION
static param_export_t params[] = {
{"enable", INT_PARAM, &dmq_usrloc_enable},
{"sync", INT_PARAM, &_dmq_usrloc_sync},
{"batch_msg_contacts", INT_PARAM, &_dmq_usrloc_batch_msg_contacts},
{"batch_size", INT_PARAM, &_dmq_usrloc_batch_size},
{"batch_usleep", INT_PARAM, &_dmq_usrloc_batch_usleep},
{"usrloc_domain", PARAM_STR, &_dmq_usrloc_domain},
Expand Down Expand Up @@ -74,6 +76,11 @@ static int mod_init(void)
bind_usrloc_t bind_usrloc;
LM_INFO("dmq usrloc replication mode = %d\n", dmq_usrloc_enable);

if(_dmq_usrloc_batch_msg_contacts > 150) {
LM_ERR("batch_msg_contacts too high[%d] setting to [150]\n", _dmq_usrloc_batch_msg_contacts);
_dmq_usrloc_batch_msg_contacts = 150;
}

if (dmq_usrloc_enable) {

bind_usrloc = (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0);
Expand Down
15 changes: 15 additions & 0 deletions src/modules/dmq_usrloc/doc/dmq_usrloc.xml
Expand Up @@ -39,6 +39,21 @@
<copyright>
<year>2014</year>
</copyright>
<editor>
<firstname>Julien</firstname>
<surname>Chavanton</surname>
<affiliation><orgname>flowroute.com</orgname></affiliation>
<email>jchavanton@gmail.com</email>
<address>
<otheraddr>
<ulink></ulink>
</otheraddr>
</address>
</editor>
</authorgroup>
<copyright>
<year>2017</year>
</copyright>
</bookinfo>
<toc></toc>

Expand Down
27 changes: 27 additions & 0 deletions src/modules/dmq_usrloc/doc/dmq_usrloc_admin.xml
Expand Up @@ -174,6 +174,33 @@ modparam("dmq_usrloc", "batch_size", 4000)
...
modparam("dmq_usrloc", "batch_usleep", 1000)
...
</programlisting>
</example>
</section>
<section id="usrloc_dmq.p.batch_msg_contacts">
<title><varname>batch_msg_contacts</varname> (int)</title>
<para>
The parameter controls the amount of contact per message/transaction during a sync

Note that the default maximum size of a contact is 1024, however once converted in the json format
we can add 200 characters to reach 1224 (this is only an approximation).
Considering 65536 (the maximum datagram size)/1224 = 53,
we need to leave some space for UDP and SIP headers, staying &lt;= 50 seems safe in most cases
<para>
<emphasis>
Default value is 1.
Maximum value is 150.
</emphasis>
</para>
<example>
<title>Set <varname>batch_msg_contacts</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("dmq_usrloc", "batch_msg_contacts", 50) # 50 contacts / message
modparam("dmq_usrloc", "batch_size", 10000) # 10000 contacts / batch
modparam("dmq_usrloc", "batch_usleep", 500000) # one batch every 500ms
# syncing 20K contacts/second with 50 contacts/message
...
</programlisting>
</example>
</section>
Expand Down

0 comments on commit f51f4df

Please sign in to comment.