Example #1
0
void
resource_action_completed(struct pe_operation *op,
			  enum ocf_exitcode pe_exitcode)
{
	uint64_t el;
	struct assembly *a = qb_map_get(assembly_map, op->hostname);;
	struct resource *r = qb_map_get(a->resource_map, op->rname);

	qb_enter();

	op->times_executed++;
	qb_util_stopwatch_stop(op->time_execed);
	el = qb_util_stopwatch_us_elapsed_get(op->time_execed);

	qb_log(LOG_INFO, "%s_%s_%d [%s] on %s rc:[%d/%d] time:[%"PRIu64"/%ums]",
	       op->rname, op->method, op->interval, op->rclass, op->hostname,
	       pe_exitcode, op->target_outcome,
	       el / QB_TIME_US_IN_MSEC, op->timeout);

	if (strstr(op->rname, op->hostname) != NULL) {
		op_history_save(r, op, pe_exitcode);
	}

	if (op->times_executed <= 1) {
		pe_resource_completed(op, pe_exitcode);
	}

	resource_state_set(r, op, pe_exitcode);

	if (pe_exitcode != op->target_outcome) {
		schedule_processing();
	}
	if (op->interval > 0) {
		if (pe_exitcode != op->target_outcome) {
			/* unreference as not used by the timer anymore.
			 */
			pe_resource_unref(op);
		} else {
			qb_loop_timer_add(NULL, QB_LOOP_LOW,
					  op->interval * QB_TIME_NS_IN_MSEC, op,
					  resource_monitor_execute,
					  &r->monitor_timer);
		}
	} else {
		pe_resource_unref(op);
	}

	qb_leave();
}
Example #2
0
static void job_add_self(void *data)
{
	int32_t res;
	uint64_t elapsed1;
	qb_loop_t *l = (qb_loop_t *)data;

	job_1_run_count++;
	qb_util_stopwatch_stop(rl_sw);
	elapsed1 = qb_util_stopwatch_us_elapsed_get(rl_sw);
	if (elapsed1 > (RATE_LIMIT_RUNTIME_SEC * QB_TIME_US_IN_SEC)) {
		/* run for 3 seconds */
		qb_loop_stop(l);
		return;
	}
	res = qb_loop_job_add(l, QB_LOOP_MED, data, job_add_self);
	ck_assert_int_eq(res, 0);
}
Example #3
0
static void instance_state_completion(char *state, char *address, void *data)
{
	struct assembly *assembly = (struct assembly *)data;

	if (strcmp(state, "ACTIVE") == 0) {
		assembly->address = strdup(address);
		qb_util_stopwatch_stop(assembly->sw_instance_create);
		qb_log(LOG_INFO, "Instance '%s' with address '%s' changed to RUNNING in (%lld ms).",
			assembly->name, assembly->address,
			qb_util_stopwatch_us_elapsed_get(assembly->sw_instance_create) / 1000);
		qb_util_stopwatch_start(assembly->sw_instance_connected);
		transport_connect(assembly);
	} else {
		recover_state_set(&assembly->recover, RECOVER_STATE_UNKNOWN);
		qb_loop_timer_add(NULL, QB_LOOP_LOW,
			PENDING_TIMEOUT * QB_TIME_NS_IN_MSEC, assembly,
			my_instance_state_get, NULL);
	}
}
Example #4
0
static void
node_state_change_event(void* inst,
			enum recover_state from,
			enum recover_state to)
{
	struct assembly *a = (struct assembly *)inst;

	qb_enter();

	qb_log(LOG_INFO, "Node (%s): changing state from %s to %s",
	       a->name, state_name_str[from], state_name_str[to]);
	cape_admin_event_send(application->name, a, NULL,
			      state_str[from][to],
			      "bla");
	if (to == RECOVER_STATE_RUNNING) {
		qb_util_stopwatch_stop(a->sw_instance_connected);
		qb_log(LOG_INFO, "Assembly '%s' connected in (%"PRIu64" ms).",
			a->name,
			qb_util_stopwatch_us_elapsed_get(a->sw_instance_connected) / QB_TIME_US_IN_MSEC);
		node_update_addr_info(a);
	}
	schedule_processing();
	qb_leave();
}