private_ha_plugin_t *this;
char *local, *remote, *secret;
u_int count;
- bool fifo;
+ bool fifo, monitor, resync;
local = lib->settings->get_str(lib->settings,
"charon.plugins.ha.local", NULL);
secret = lib->settings->get_str(lib->settings,
"charon.plugins.ha.secret", NULL);
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,
"charon.plugins.ha.segment_count", 1));
if (!local || !remote)
this->tunnel = NULL;
this->ctl = NULL;
+ if (secret)
+ {
+ this->tunnel = ha_tunnel_create(local, remote, secret);
+ }
this->socket = ha_socket_create(local, remote);
if (!this->socket)
{
+ DESTROY_IF(this->tunnel);
free(this);
return NULL;
}
this->kernel = ha_kernel_create(count);
- if (!this->kernel)
- {
- this->socket->destroy(this->socket);
- free(this);
- return NULL;
- }
-
- if (secret)
- {
- this->tunnel = ha_tunnel_create(local, remote, secret);
- }
- this->segments = ha_segments_create(this->socket, this->kernel,
- this->tunnel, local, remote, count);
+ this->segments = ha_segments_create(this->socket, this->kernel, this->tunnel,
+ count, strcmp(local, remote) > 0, monitor, resync);
if (fifo)
{
this->ctl = ha_ctl_create(this->segments);
segment_mask_t active;
/**
- * Are we the master node handling segment assignement?
+ * Node number
*/
- bool master;
+ u_int node;
};
/**
{
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);
enable_disable(this, i, TRUE, TRUE);
* See header
*/
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);
this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
this->condvar = condvar_create(CONDVAR_TYPE_DEFAULT);
this->count = count;
- this->master = strcmp(local, remote) > 0;
+ this->node = node;
this->job = NULL;
/* initially all segments are deactivated */
this->active = 0;
- send_status(this);
-
- start_watchdog(this);
+ if (monitor)
+ {
+ send_status(this);
+ start_watchdog(this);
+ }
- /* request a resync as soon as we are up */
- charon->processor->queue_job(charon->processor, (job_t*)
+ if (sync)
+ {
+ /* request a resync as soon as we are up */
+ charon->processor->queue_job(charon->processor, (job_t*)
callback_job_create((callback_job_cb_t)request_resync,
this, NULL, NULL));
+ }
return &this->public;
}
*
* @param socket socket to communicate segment (de-)activation
* @param kernel interface to control segments at kernel level
+ * @param tunnel HA tunnel
* @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
*/
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_ @}*/