along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-#include "includes.h"
+#include "replace.h"
#include "system/filesys.h"
+#include "system/network.h"
#include "system/wait.h"
-#include "../include/ctdb_private.h"
+
+#include <talloc.h>
+#include <tevent.h>
+
+#include "lib/util/debug.h"
+#include "lib/util/samba_util.h"
+
+#include "ctdb_private.h"
+
+#include "common/system.h"
+#include "common/common.h"
+#include "common/logging.h"
struct ctdb_monitor_state {
uint32_t monitoring_mode;
TALLOC_CTX *monitor_context;
uint32_t next_interval;
+ uint32_t event_script_timeouts;
};
-static void ctdb_check_health(struct event_context *ev, struct timed_event *te,
+static void ctdb_check_health(struct tevent_context *ev,
+ struct tevent_timer *te,
struct timeval t, void *private_data);
/*
uint32_t next_interval;
int ret;
TDB_DATA rddata;
- struct srvid_request rd;
+ struct ctdb_srvid_message rd;
const char *state_str = NULL;
c.pnn = ctdb->pnn;
}
if (status == -ETIME) {
- ctdb->event_script_timeouts++;
+ ctdb->monitor->event_script_timeouts++;
- if (ctdb->event_script_timeouts >= ctdb->tunable.script_timeout_count) {
- DEBUG(DEBUG_ERR, ("Maximum timeout count %u reached for eventscript. Making node unhealthy\n", ctdb->tunable.script_timeout_count));
+ if (ctdb->monitor->event_script_timeouts >=
+ ctdb->tunable.monitor_timeout_count) {
+ DEBUG(DEBUG_ERR,
+ ("Maximum monitor timeout count %u reached."
+ " Making node unhealthy\n",
+ ctdb->tunable.monitor_timeout_count));
} else {
/* We pretend this is OK. */
goto after_change_status;
}
+ } else {
+ ctdb->monitor->event_script_timeouts = 0;
}
if (status != 0 && !(node->flags & NODE_FLAGS_UNHEALTHY)) {
ctdb->monitor->next_interval = ctdb->tunable.monitor_interval;
}
- event_add_timed(ctdb->ev, ctdb->monitor->monitor_context,
- timeval_current_ofs(next_interval, 0),
- ctdb_check_health, ctdb);
+ tevent_add_timer(ctdb->ev, ctdb->monitor->monitor_context,
+ timeval_current_ofs(next_interval, 0),
+ ctdb_check_health, ctdb);
if (c.old_flags == node->flags) {
return;
}
-static void ctdb_run_startup(struct event_context *ev, struct timed_event *te,
+static void ctdb_run_startup(struct tevent_context *ev,
+ struct tevent_timer *te,
struct timeval t, void *private_data);
/*
called when the startup event script finishes
{
if (status != 0) {
DEBUG(DEBUG_ERR,("startup event failed\n"));
- event_add_timed(ctdb->ev, ctdb->monitor->monitor_context,
- timeval_current_ofs(5, 0),
- ctdb_run_startup, ctdb);
+ tevent_add_timer(ctdb->ev, ctdb->monitor->monitor_context,
+ timeval_current_ofs(5, 0),
+ ctdb_run_startup, ctdb);
return;
}
ctdb->monitor->monitoring_mode = CTDB_MONITORING_ACTIVE;
- event_add_timed(ctdb->ev, ctdb->monitor->monitor_context,
- timeval_current_ofs(ctdb->monitor->next_interval, 0),
- ctdb_check_health, ctdb);
+ tevent_add_timer(ctdb->ev, ctdb->monitor->monitor_context,
+ timeval_current_ofs(ctdb->monitor->next_interval, 0),
+ ctdb_check_health, ctdb);
}
-static void ctdb_run_startup(struct event_context *ev, struct timed_event *te,
+static void ctdb_run_startup(struct tevent_context *ev,
+ struct tevent_timer *te,
struct timeval t, void *private_data)
{
struct ctdb_context *ctdb = talloc_get_type(private_data,
if (ctdb->runstate < CTDB_RUNSTATE_STARTUP) {
DEBUG(DEBUG_NOTICE,
("Not yet in startup runstate. Wait one more second\n"));
- event_add_timed(ctdb->ev, ctdb->monitor->monitor_context,
- timeval_current_ofs(1, 0),
- ctdb_run_startup, ctdb);
+ tevent_add_timer(ctdb->ev, ctdb->monitor->monitor_context,
+ timeval_current_ofs(1, 0),
+ ctdb_run_startup, ctdb);
return;
}
if (ret != 0) {
DEBUG(DEBUG_ERR,("Unable to launch startup event script\n"));
- event_add_timed(ctdb->ev, ctdb->monitor->monitor_context,
- timeval_current_ofs(5, 0),
- ctdb_run_startup, ctdb);
+ tevent_add_timer(ctdb->ev, ctdb->monitor->monitor_context,
+ timeval_current_ofs(5, 0),
+ ctdb_run_startup, ctdb);
}
}
wait until we have finished initial recoveries before we start the
monitoring events
*/
-static void ctdb_wait_until_recovered(struct event_context *ev, struct timed_event *te,
- struct timeval t, void *private_data)
+static void ctdb_wait_until_recovered(struct tevent_context *ev,
+ struct tevent_timer *te,
+ struct timeval t, void *private_data)
{
struct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context);
int ret;
if (ctdb->vnn_map->generation == INVALID_GENERATION) {
ctdb->db_persistent_startup_generation = INVALID_GENERATION;
- event_add_timed(ctdb->ev, ctdb->monitor->monitor_context,
- timeval_current_ofs(1, 0),
- ctdb_wait_until_recovered, ctdb);
+ tevent_add_timer(ctdb->ev, ctdb->monitor->monitor_context,
+ timeval_current_ofs(1, 0),
+ ctdb_wait_until_recovered, ctdb);
return;
}
ctdb->db_persistent_startup_generation = INVALID_GENERATION;
DEBUG(DEBUG_NOTICE,(__location__ " in recovery. Wait one more second\n"));
- event_add_timed(ctdb->ev, ctdb->monitor->monitor_context,
- timeval_current_ofs(1, 0),
- ctdb_wait_until_recovered, ctdb);
+ tevent_add_timer(ctdb->ev, ctdb->monitor->monitor_context,
+ timeval_current_ofs(1, 0),
+ ctdb_wait_until_recovered, ctdb);
return;
}
DEBUG(DEBUG_NOTICE,(__location__ " wait for pending recoveries to end. Wait one more second.\n"));
- event_add_timed(ctdb->ev, ctdb->monitor->monitor_context,
- timeval_current_ofs(1, 0),
- ctdb_wait_until_recovered, ctdb);
+ tevent_add_timer(ctdb->ev, ctdb->monitor->monitor_context,
+ timeval_current_ofs(1, 0),
+ ctdb_wait_until_recovered, ctdb);
return;
}
if (ctdb->vnn_map->generation == ctdb->db_persistent_startup_generation) {
DEBUG(DEBUG_INFO,(__location__ " skip ctdb_recheck_persistent_health() "
"until the next recovery\n"));
- event_add_timed(ctdb->ev, ctdb->monitor->monitor_context,
- timeval_current_ofs(1, 0),
- ctdb_wait_until_recovered, ctdb);
+ tevent_add_timer(ctdb->ev, ctdb->monitor->monitor_context,
+ timeval_current_ofs(1, 0),
+ ctdb_wait_until_recovered, ctdb);
return;
}
"failed (%llu of %llu times) - retry later\n",
(unsigned long long)ctdb->db_persistent_check_errors,
(unsigned long long)ctdb->max_persistent_check_errors));
- event_add_timed(ctdb->ev,
- ctdb->monitor->monitor_context,
- timeval_current_ofs(1, 0),
- ctdb_wait_until_recovered, ctdb);
+ tevent_add_timer(ctdb->ev,
+ ctdb->monitor->monitor_context,
+ timeval_current_ofs(1, 0),
+ ctdb_wait_until_recovered, ctdb);
return;
}
DEBUG(DEBUG_ALERT,(__location__
}
ctdb->db_persistent_check_errors = 0;
- event_add_timed(ctdb->ev, ctdb->monitor->monitor_context,
- timeval_current(), ctdb_run_startup, ctdb);
+ tevent_add_timer(ctdb->ev, ctdb->monitor->monitor_context,
+ timeval_current(), ctdb_run_startup, ctdb);
}
/*
see if the event scripts think we are healthy
*/
-static void ctdb_check_health(struct event_context *ev, struct timed_event *te,
+static void ctdb_check_health(struct tevent_context *ev,
+ struct tevent_timer *te,
struct timeval t, void *private_data)
{
struct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context);
}
if (skip_monitoring) {
- event_add_timed(ctdb->ev, ctdb->monitor->monitor_context,
- timeval_current_ofs(ctdb->monitor->next_interval, 0),
- ctdb_check_health, ctdb);
+ tevent_add_timer(ctdb->ev, ctdb->monitor->monitor_context,
+ timeval_current_ofs(ctdb->monitor->next_interval, 0),
+ ctdb_check_health, ctdb);
return;
}
if (ret != 0) {
DEBUG(DEBUG_ERR,("Unable to launch monitor event script\n"));
ctdb->monitor->next_interval = 5;
- event_add_timed(ctdb->ev, ctdb->monitor->monitor_context,
- timeval_current_ofs(5, 0),
- ctdb_check_health, ctdb);
+ tevent_add_timer(ctdb->ev, ctdb->monitor->monitor_context,
+ timeval_current_ofs(5, 0),
+ ctdb_check_health, ctdb);
}
}
ctdb->monitor->monitor_context = talloc_new(ctdb->monitor);
CTDB_NO_MEMORY_FATAL(ctdb, ctdb->monitor->monitor_context);
- event_add_timed(ctdb->ev, ctdb->monitor->monitor_context,
- timeval_current_ofs(1, 0),
- ctdb_wait_until_recovered, ctdb);
+ tevent_add_timer(ctdb->ev, ctdb->monitor->monitor_context,
+ timeval_current_ofs(1, 0),
+ ctdb_wait_until_recovered, ctdb);
}
node->flags = c->new_flags & ~NODE_FLAGS_DISCONNECTED;
node->flags |= (c->old_flags & NODE_FLAGS_DISCONNECTED);
- /* we dont let other nodes modify our STOPPED status */
+ /* we don't let other nodes modify our STOPPED status */
if (c->pnn == ctdb->pnn) {
node->flags &= ~NODE_FLAGS_STOPPED;
if (old_flags & NODE_FLAGS_STOPPED) {
}
}
- /* we dont let other nodes modify our BANNED status */
+ /* we don't let other nodes modify our BANNED status */
if (c->pnn == ctdb->pnn) {
node->flags &= ~NODE_FLAGS_BANNED;
if (old_flags & NODE_FLAGS_BANNED) {