Added node name (for clustering) and use it in heartbeat and regexroute.
git-svn-id: http://yate.null.ro/svn/yate/trunk@1651 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
ed51e4aa24
commit
6ca62a64ca
|
@ -4,7 +4,7 @@
|
||||||
; enabled: bool: Enable operation of this module
|
; enabled: bool: Enable operation of this module
|
||||||
;enabled=true
|
;enabled=true
|
||||||
|
|
||||||
; node: string: Name of this cluster node, must be set to enable module
|
; node: string: Name of this cluster node, default to engine's node name
|
||||||
;node=
|
;node=
|
||||||
|
|
||||||
; host: ipaddress: IP address to send heartbeat packets to, must be set
|
; host: ipaddress: IP address to send heartbeat packets to, must be set
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
; Note that you MUST NOT add a path separator at the end
|
; Note that you MUST NOT add a path separator at the end
|
||||||
;extrapath=
|
;extrapath=
|
||||||
|
|
||||||
|
; nodename: string: Name of this node in a cluster
|
||||||
|
;nodename=
|
||||||
|
|
||||||
; maxworkers: int: Maximum number of worker threads the engine can create
|
; maxworkers: int: Maximum number of worker threads the engine can create
|
||||||
;maxworkers=10
|
;maxworkers=10
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,9 @@ Relative path to extra modules directory (can be repeated)
|
||||||
.TP
|
.TP
|
||||||
.B \-w \fIdirectory\fR
|
.B \-w \fIdirectory\fR
|
||||||
Change working directory
|
Change working directory
|
||||||
|
.TP
|
||||||
|
.B \-N \fInodename\fR
|
||||||
|
Set the name of the node in a cluster
|
||||||
.SS Debugging options (may not be compiled in)
|
.SS Debugging options (may not be compiled in)
|
||||||
.TP
|
.TP
|
||||||
.B \-C
|
.B \-C
|
||||||
|
|
|
@ -101,6 +101,10 @@ using namespace TelEngine;
|
||||||
#define INIT_SANITY 30
|
#define INIT_SANITY 30
|
||||||
#define MAX_LOGBUFF 4096
|
#define MAX_LOGBUFF 4096
|
||||||
|
|
||||||
|
#ifndef HOST_NAME_MAX
|
||||||
|
#define HOST_NAME_MAX 255
|
||||||
|
#endif
|
||||||
|
|
||||||
static u_int64_t s_nextinit = 0;
|
static u_int64_t s_nextinit = 0;
|
||||||
static u_int64_t s_restarts = 0;
|
static u_int64_t s_restarts = 0;
|
||||||
static bool s_makeworker = true;
|
static bool s_makeworker = true;
|
||||||
|
@ -136,6 +140,7 @@ static void sighandler(int signal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String Engine::s_node;
|
||||||
String Engine::s_shrpath(SHR_PATH);
|
String Engine::s_shrpath(SHR_PATH);
|
||||||
String Engine::s_cfgpath(CFG_PATH);
|
String Engine::s_cfgpath(CFG_PATH);
|
||||||
String Engine::s_cfgsuffix(CFG_SUFFIX);
|
String Engine::s_cfgsuffix(CFG_SUFFIX);
|
||||||
|
@ -612,6 +617,13 @@ int Engine::run()
|
||||||
#endif
|
#endif
|
||||||
SysUsage::init();
|
SysUsage::init();
|
||||||
s_runid = Time::secNow();
|
s_runid = Time::secNow();
|
||||||
|
if (s_node.trimBlanks().null()) {
|
||||||
|
char hostName[HOST_NAME_MAX+1];
|
||||||
|
if (::gethostname(hostName,sizeof(hostName)))
|
||||||
|
hostName[0] = '\0';
|
||||||
|
s_node = s_cfg.getValue("general","nodename",hostName);
|
||||||
|
s_node.trimBlanks();
|
||||||
|
}
|
||||||
DDebug(DebugAll,"Engine::run()");
|
DDebug(DebugAll,"Engine::run()");
|
||||||
install(new EngineStatusHandler);
|
install(new EngineStatusHandler);
|
||||||
extraPath(clientMode() ? "client" : "server");
|
extraPath(clientMode() ? "client" : "server");
|
||||||
|
@ -642,7 +654,8 @@ int Engine::run()
|
||||||
::signal(SIGUSR1,sighandler);
|
::signal(SIGUSR1,sighandler);
|
||||||
::signal(SIGUSR2,sighandler);
|
::signal(SIGUSR2,sighandler);
|
||||||
#endif
|
#endif
|
||||||
Output("Yate%s engine is initialized and starting up",clientMode() ? " client" : "");
|
Output("Yate%s engine is initialized and starting up%s%s",
|
||||||
|
clientMode() ? " client" : "",s_node.null() ? "" : " on " ,s_node.safe());
|
||||||
while (s_haltcode == -1) {
|
while (s_haltcode == -1) {
|
||||||
if (s_cmds) {
|
if (s_cmds) {
|
||||||
Output("Executing initial commands");
|
Output("Executing initial commands");
|
||||||
|
@ -1036,6 +1049,7 @@ static void usage(bool client, FILE* f)
|
||||||
" -m pathname Path to modules directory (" MOD_PATH ")\n"
|
" -m pathname Path to modules directory (" MOD_PATH ")\n"
|
||||||
" -x relpath Relative path to extra modules directory (can be repeated)\n"
|
" -x relpath Relative path to extra modules directory (can be repeated)\n"
|
||||||
" -w directory Change working directory\n"
|
" -w directory Change working directory\n"
|
||||||
|
" -N nodename Set the name of this node in a cluster\n"
|
||||||
#ifdef RLIMIT_CORE
|
#ifdef RLIMIT_CORE
|
||||||
" -C Enable core dumps if possible\n"
|
" -C Enable core dumps if possible\n"
|
||||||
#endif
|
#endif
|
||||||
|
@ -1237,6 +1251,14 @@ int Engine::main(int argc, const char** argv, const char** env, RunMode mode, bo
|
||||||
pc = 0;
|
pc = 0;
|
||||||
extraPath(argv[++i]);
|
extraPath(argv[++i]);
|
||||||
break;
|
break;
|
||||||
|
case 'N':
|
||||||
|
if (i+1 >= argc) {
|
||||||
|
noarg(client,argv[i]);
|
||||||
|
return ENOENT;
|
||||||
|
}
|
||||||
|
pc = 0;
|
||||||
|
s_node=argv[++i];
|
||||||
|
break;
|
||||||
#ifdef RLIMIT_CORE
|
#ifdef RLIMIT_CORE
|
||||||
case 'C':
|
case 'C':
|
||||||
s_coredump = true;
|
s_coredump = true;
|
||||||
|
|
|
@ -246,6 +246,8 @@ static void evalFunc(String& str)
|
||||||
str.clear();
|
str.clear();
|
||||||
str << Engine::runId();
|
str << Engine::runId();
|
||||||
}
|
}
|
||||||
|
else if (str == "nodename")
|
||||||
|
str = Engine::nodeName();
|
||||||
else if ((sep >= 0) && (str == "transcode")) {
|
else if ((sep >= 0) && (str == "transcode")) {
|
||||||
str = par.substr(0,sep);
|
str = par.substr(0,sep);
|
||||||
par = par.substr(sep+1).trimBlanks();
|
par = par.substr(sep+1).trimBlanks();
|
||||||
|
|
|
@ -149,6 +149,7 @@ void HBeatPlugin::sendHeartbeat(const Time& tStamp, bool goDown)
|
||||||
if (m_socket.valid()) {
|
if (m_socket.valid()) {
|
||||||
char hex[16];
|
char hex[16];
|
||||||
String buf;
|
String buf;
|
||||||
|
// Linux-HA relies on the fields order so don't change it. Thanks.
|
||||||
buf << "t=status\n";
|
buf << "t=status\n";
|
||||||
if (goDown)
|
if (goDown)
|
||||||
buf << "st=dead\n";
|
buf << "st=dead\n";
|
||||||
|
@ -286,7 +287,7 @@ void HBeatPlugin::initialize()
|
||||||
if (!m_socket.valid()) {
|
if (!m_socket.valid()) {
|
||||||
if (!cfg.getBoolValue("general","enabled",true))
|
if (!cfg.getBoolValue("general","enabled",true))
|
||||||
return;
|
return;
|
||||||
m_node = cfg.getValue("general","node");
|
m_node = cfg.getValue("general","node",Engine::nodeName());
|
||||||
if (m_node.null())
|
if (m_node.null())
|
||||||
return;
|
return;
|
||||||
SocketAddr addr(AF_INET);
|
SocketAddr addr(AF_INET);
|
||||||
|
|
18
yatengine.h
18
yatengine.h
|
@ -775,11 +775,18 @@ public:
|
||||||
*/
|
*/
|
||||||
static bool Register(const Plugin* plugin, bool reg = true);
|
static bool Register(const Plugin* plugin, bool reg = true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the server node name, should be unique in a cluster
|
||||||
|
* @return Node identifier string, defaults to host name
|
||||||
|
*/
|
||||||
|
inline static const String& nodeName()
|
||||||
|
{ return s_node; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the application's shared directory path
|
* Get the application's shared directory path
|
||||||
* @return The base path for shared files and directories
|
* @return The base path for shared files and directories
|
||||||
*/
|
*/
|
||||||
inline static String& sharedPath()
|
inline static const String& sharedPath()
|
||||||
{ return s_shrpath; }
|
{ return s_shrpath; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -794,20 +801,20 @@ public:
|
||||||
* Get the system configuration directory path
|
* Get the system configuration directory path
|
||||||
* @return The directory path for system configuration files
|
* @return The directory path for system configuration files
|
||||||
*/
|
*/
|
||||||
inline static String& configPath()
|
inline static const String& configPath()
|
||||||
{ return s_cfgpath; }
|
{ return s_cfgpath; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the configuration file suffix
|
* Get the configuration file suffix
|
||||||
* @return The suffix for configuration files
|
* @return The suffix for configuration files
|
||||||
*/
|
*/
|
||||||
inline static String& configSuffix()
|
inline static const String& configSuffix()
|
||||||
{ return s_cfgsuffix; }
|
{ return s_cfgsuffix; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The module loading path
|
* The module loading path
|
||||||
*/
|
*/
|
||||||
inline static String& modulePath()
|
inline static const String& modulePath()
|
||||||
{ return s_modpath; }
|
{ return s_modpath; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -821,7 +828,7 @@ public:
|
||||||
* Get the module filename suffix
|
* Get the module filename suffix
|
||||||
* @return The suffix for module files
|
* @return The suffix for module files
|
||||||
*/
|
*/
|
||||||
inline static String& moduleSuffix()
|
inline static const String& moduleSuffix()
|
||||||
{ return s_modsuffix; }
|
{ return s_modsuffix; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -994,6 +1001,7 @@ private:
|
||||||
ObjList m_libs;
|
ObjList m_libs;
|
||||||
MessageDispatcher m_dispatcher;
|
MessageDispatcher m_dispatcher;
|
||||||
static Engine* s_self;
|
static Engine* s_self;
|
||||||
|
static String s_node;
|
||||||
static String s_shrpath;
|
static String s_shrpath;
|
||||||
static String s_cfgpath;
|
static String s_cfgpath;
|
||||||
static String s_cfgsuffix;
|
static String s_cfgsuffix;
|
||||||
|
|
Loading…
Reference in New Issue