Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nathelper] Added clustering support
Only the nodes owning the active tag will be able to do the pinging to the contacts.
- Loading branch information
1 parent
6c28166
commit 14c3570
Showing
4 changed files
with
193 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (C) 2019 OpenSIPS Project | ||
* | ||
* This file is part of opensips, a free SIP server. | ||
* | ||
* opensips is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* opensips is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
*/ | ||
|
||
#include "nh_clustering.h" | ||
|
||
#define BIN_VERSION 1 | ||
|
||
/* the cluster ID */ | ||
int nh_cluster_id = 0; | ||
|
||
str nh_cluster_shtag = {NULL,0}; | ||
|
||
static struct clusterer_binds c_api; | ||
|
||
|
||
int nh_cluster_shtag_is_active(void) | ||
{ | ||
if ( nh_cluster_id<=0 || (nh_cluster_shtag.s && | ||
c_api.shtag_get(&nh_cluster_shtag,nh_cluster_id)!=SHTAG_STATE_ACTIVE) ) | ||
/* no clustering support or sharing tag found on not-active */ | ||
return 0; | ||
|
||
return 1; | ||
} | ||
|
||
|
||
int nh_init_cluster(void) | ||
{ | ||
if (load_clusterer_api(&c_api)!=0) { | ||
LM_ERR("failed to find clusterer API - is clusterer " | ||
"module loaded?\n"); | ||
return -1; | ||
} | ||
|
||
/* "register" the sharing tag */ | ||
if (nh_cluster_shtag.s) { | ||
nh_cluster_shtag.len = strlen(nh_cluster_shtag.s); | ||
if (c_api.shtag_get( &nh_cluster_shtag, nh_cluster_id)<0) { | ||
LM_ERR("failed to initialized the sharing tag <%.*s>\n", | ||
nh_cluster_shtag.len, nh_cluster_shtag.s); | ||
return -1; | ||
} | ||
} else { | ||
nh_cluster_shtag.len = 0; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (C) 2019 OpenSIPS Project | ||
* | ||
* This file is part of opensips, a free SIP server. | ||
* | ||
* opensips is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* opensips is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
*/ | ||
|
||
#ifndef _NATHELPER_CLUSTERING_H_ | ||
#define _NATHELPER_CLUSTERING_H_ | ||
|
||
#include "../../sr_module.h" | ||
#include "../../bin_interface.h" | ||
#include "../clusterer/api.h" | ||
|
||
extern int nh_cluster_id; | ||
extern str nh_cluster_shtag; | ||
|
||
int nh_init_cluster(void); | ||
|
||
/* checks if the sharing tag is on active */ | ||
int nh_cluster_shtag_is_active(void); | ||
|
||
#endif |