Make resync/monitoring functionality optional
This commit is contained in:
committed by
Martin Willi
parent
f24ca1dd55
commit
3e8caf6af6
@@ -105,7 +105,7 @@ plugin_t *plugin_create()
|
|||||||
private_ha_plugin_t *this;
|
private_ha_plugin_t *this;
|
||||||
char *local, *remote, *secret;
|
char *local, *remote, *secret;
|
||||||
u_int count;
|
u_int count;
|
||||||
bool fifo;
|
bool fifo, monitor, resync;
|
||||||
|
|
||||||
local = lib->settings->get_str(lib->settings,
|
local = lib->settings->get_str(lib->settings,
|
||||||
"charon.plugins.ha.local", NULL);
|
"charon.plugins.ha.local", NULL);
|
||||||
@@ -114,7 +114,11 @@ plugin_t *plugin_create()
|
|||||||
secret = lib->settings->get_str(lib->settings,
|
secret = lib->settings->get_str(lib->settings,
|
||||||
"charon.plugins.ha.secret", NULL);
|
"charon.plugins.ha.secret", NULL);
|
||||||
fifo = lib->settings->get_bool(lib->settings,
|
fifo = lib->settings->get_bool(lib->settings,
|
||||||
"charon.plugins.ha.fifo_interface", FALSE);
|
"charon.plugins.ha.fifo_interface", TRUE);
|
||||||
|
monitor = lib->settings->get_bool(lib->settings,
|
||||||
|
"charon.plugins.ha.monitor", TRUE);
|
||||||
|
resync = lib->settings->get_bool(lib->settings,
|
||||||
|
"charon.plugins.ha.resync", TRUE);
|
||||||
count = min(SEGMENTS_MAX, lib->settings->get_int(lib->settings,
|
count = min(SEGMENTS_MAX, lib->settings->get_int(lib->settings,
|
||||||
"charon.plugins.ha.segment_count", 1));
|
"charon.plugins.ha.segment_count", 1));
|
||||||
if (!local || !remote)
|
if (!local || !remote)
|
||||||
@@ -129,26 +133,20 @@ plugin_t *plugin_create()
|
|||||||
this->tunnel = NULL;
|
this->tunnel = NULL;
|
||||||
this->ctl = NULL;
|
this->ctl = NULL;
|
||||||
|
|
||||||
this->socket = ha_socket_create(local, remote);
|
|
||||||
if (!this->socket)
|
|
||||||
{
|
|
||||||
free(this);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
this->kernel = ha_kernel_create(count);
|
|
||||||
if (!this->kernel)
|
|
||||||
{
|
|
||||||
this->socket->destroy(this->socket);
|
|
||||||
free(this);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (secret)
|
if (secret)
|
||||||
{
|
{
|
||||||
this->tunnel = ha_tunnel_create(local, remote, secret);
|
this->tunnel = ha_tunnel_create(local, remote, secret);
|
||||||
}
|
}
|
||||||
this->segments = ha_segments_create(this->socket, this->kernel,
|
this->socket = ha_socket_create(local, remote);
|
||||||
this->tunnel, local, remote, count);
|
if (!this->socket)
|
||||||
|
{
|
||||||
|
DESTROY_IF(this->tunnel);
|
||||||
|
free(this);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
this->kernel = ha_kernel_create(count);
|
||||||
|
this->segments = ha_segments_create(this->socket, this->kernel, this->tunnel,
|
||||||
|
count, strcmp(local, remote) > 0, monitor, resync);
|
||||||
if (fifo)
|
if (fifo)
|
||||||
{
|
{
|
||||||
this->ctl = ha_ctl_create(this->segments);
|
this->ctl = ha_ctl_create(this->segments);
|
||||||
|
|||||||
@@ -77,9 +77,9 @@ struct private_ha_segments_t {
|
|||||||
segment_mask_t active;
|
segment_mask_t active;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Are we the master node handling segment assignement?
|
* Node number
|
||||||
*/
|
*/
|
||||||
bool master;
|
u_int node;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -388,7 +388,7 @@ static void handle_status(private_ha_segments_t *this, segment_mask_t mask)
|
|||||||
{
|
{
|
||||||
if (missing & SEGMENTS_BIT(i))
|
if (missing & SEGMENTS_BIT(i))
|
||||||
{
|
{
|
||||||
if (this->master != i % 2)
|
if (this->node == i % 2)
|
||||||
{
|
{
|
||||||
DBG1(DBG_CFG, "HA segment %d was not handled, taking", i);
|
DBG1(DBG_CFG, "HA segment %d was not handled, taking", i);
|
||||||
enable_disable(this, i, TRUE, TRUE);
|
enable_disable(this, i, TRUE, TRUE);
|
||||||
@@ -458,7 +458,8 @@ static void destroy(private_ha_segments_t *this)
|
|||||||
* See header
|
* See header
|
||||||
*/
|
*/
|
||||||
ha_segments_t *ha_segments_create(ha_socket_t *socket, ha_kernel_t *kernel,
|
ha_segments_t *ha_segments_create(ha_socket_t *socket, ha_kernel_t *kernel,
|
||||||
ha_tunnel_t *tunnel, char *local, char *remote, u_int count)
|
ha_tunnel_t *tunnel, u_int count, u_int node,
|
||||||
|
bool monitor, bool sync)
|
||||||
{
|
{
|
||||||
private_ha_segments_t *this = malloc_thing(private_ha_segments_t);
|
private_ha_segments_t *this = malloc_thing(private_ha_segments_t);
|
||||||
|
|
||||||
@@ -476,20 +477,25 @@ ha_segments_t *ha_segments_create(ha_socket_t *socket, ha_kernel_t *kernel,
|
|||||||
this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
|
this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
|
||||||
this->condvar = condvar_create(CONDVAR_TYPE_DEFAULT);
|
this->condvar = condvar_create(CONDVAR_TYPE_DEFAULT);
|
||||||
this->count = count;
|
this->count = count;
|
||||||
this->master = strcmp(local, remote) > 0;
|
this->node = node;
|
||||||
this->job = NULL;
|
this->job = NULL;
|
||||||
|
|
||||||
/* initially all segments are deactivated */
|
/* initially all segments are deactivated */
|
||||||
this->active = 0;
|
this->active = 0;
|
||||||
|
|
||||||
send_status(this);
|
if (monitor)
|
||||||
|
{
|
||||||
|
send_status(this);
|
||||||
|
start_watchdog(this);
|
||||||
|
}
|
||||||
|
|
||||||
start_watchdog(this);
|
if (sync)
|
||||||
|
{
|
||||||
/* request a resync as soon as we are up */
|
/* request a resync as soon as we are up */
|
||||||
charon->processor->queue_job(charon->processor, (job_t*)
|
charon->processor->queue_job(charon->processor, (job_t*)
|
||||||
callback_job_create((callback_job_cb_t)request_resync,
|
callback_job_create((callback_job_cb_t)request_resync,
|
||||||
this, NULL, NULL));
|
this, NULL, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,11 +97,15 @@ struct ha_segments_t {
|
|||||||
*
|
*
|
||||||
* @param socket socket to communicate segment (de-)activation
|
* @param socket socket to communicate segment (de-)activation
|
||||||
* @param kernel interface to control segments at kernel level
|
* @param kernel interface to control segments at kernel level
|
||||||
|
* @param tunnel HA tunnel
|
||||||
* @param count number of segments the cluster uses
|
* @param count number of segments the cluster uses
|
||||||
* @param active bit mask of initially active segments
|
* @param node node, currently 1 or 0
|
||||||
|
* @param monitor should we use monitoring functionality
|
||||||
|
* @param resync request a complete resync on startup
|
||||||
* @return segment object
|
* @return segment object
|
||||||
*/
|
*/
|
||||||
ha_segments_t *ha_segments_create(ha_socket_t *socket, ha_kernel_t *kernel,
|
ha_segments_t *ha_segments_create(ha_socket_t *socket, ha_kernel_t *kernel,
|
||||||
ha_tunnel_t *tunnel, char *local, char *remote, u_int count);
|
ha_tunnel_t *tunnel, u_int count, u_int node,
|
||||||
|
bool monitor, bool resync);
|
||||||
|
|
||||||
#endif /* HA_SEGMENTS_ @}*/
|
#endif /* HA_SEGMENTS_ @}*/
|
||||||
|
|||||||
Reference in New Issue
Block a user