示例#1
0
static void _cs_cmap_link_added_removed (
	cmap_handle_t cmap_handle_c,
	cmap_track_handle_t track_handle,
	int32_t event,
	const char *key_name,
	struct cmap_notify_value new_value,
	struct cmap_notify_value old_value,
	void *user_data)
{
	struct track_item *track_item;

	/* Add/remove a tracker for a new/removed knet link */
	if (strstr(key_name, ".connected")) {
		if (event == CMAP_TRACK_ADD) {

			track_item = malloc(sizeof(struct track_item));
			if (!track_item) {
				return;
			}
			cmap_track_add(stats_handle, key_name, CMAP_TRACK_MODIFY, _cs_cmap_link_faulty_key_changed, NULL, &track_handle);

			strcpy(track_item->key_name, key_name);
			track_item->track_handle = track_handle;
			qb_map_put(tracker_map, track_item->key_name, track_item);
		} else {
			track_item = qb_map_get(tracker_map, key_name);
			if (track_item) {
				cmap_track_delete(stats_handle, track_item->track_handle);
				qb_map_rm(tracker_map, track_item->key_name);
				free(track_item);
			}
		}
	}
}
示例#2
0
static void node_op_history_clear(struct assembly *assembly)
{
	qb_map_iter_t *iter;
	struct operation_history *oh;
	const char *key;
	struct resource *r;

	qb_enter();

	iter = qb_map_iter_create(op_history_map);
	while ((key = qb_map_iter_next(iter, (void **)&oh)) != NULL) {
		r = oh->resource;

		if (r->assembly == assembly) {
			/* stop the recurring monitor.
			 */
			if (qb_loop_timer_is_running(NULL, r->monitor_timer) &&
			    r->monitor_op) {
				recurring_monitor_stop(r->monitor_op);
			}

			qb_map_rm(op_history_map, key);
			free(oh->rsc_id);
			free(oh->operation);
			free(oh->op_digest);
			free(oh);
		}
	}
	qb_map_iter_free(iter);

	qb_leave();
}
示例#3
0
int
main(void)
{
	qb_map_t *trie;
	int *i1, *i2, *i3;
	qb_map_iter_t *iter;
	const char *key;
	void *val;
	uint32_t revents = (QB_MAP_NOTIFY_DELETED |
			    QB_MAP_NOTIFY_REPLACED |
			    QB_MAP_NOTIFY_INSERTED |
			    QB_MAP_NOTIFY_RECURSIVE);

	trie = qb_trie_create();
	assert(trie != NULL);
	qb_trie_dump(trie);
	add_cs_keys(trie);

	i1 = malloc(sizeof(int));
	assert(i1 != NULL);
	*i1 = 1;

	i2 = malloc(sizeof(int));
	assert(i2 != NULL);
	*i2 = 2;

	i3 = malloc(sizeof(int));
	assert(i3 != NULL);
	*i3 = 3;

	qb_map_notify_add(trie, NULL, notify_fn, QB_MAP_NOTIFY_FREE, NULL);

	qb_map_put(trie, "test.key1", i1);
	qb_map_put(trie, "test.key2", i2);

	qb_map_notify_add(trie, "test.", notify_fn, revents, NULL);
	qb_trie_dump(trie);

	qb_map_put(trie, "test.key1", i3);

	iter = qb_map_pref_iter_create(trie, "test.");
	while ((key = qb_map_iter_next(iter, &val)) != NULL) {
		fprintf(stderr, "Iter %s [%d]\n", key, *(int *)val);
		qb_map_rm(trie, key);
	}
	qb_map_iter_free(iter);
	qb_map_notify_del_2(trie, "test.", notify_fn, revents, NULL);
	qb_map_destroy(trie);

	return (0);
}
示例#4
0
cs_error_t icmap_delete(const char *key_name)
{
	struct icmap_item *item;

	if (key_name == NULL) {
		return (CS_ERR_INVALID_PARAM);
	}

	item = qb_map_get(icmap_map, key_name);
	if (item == NULL) {
		return (CS_ERR_NOT_EXIST);
	}

	if (qb_map_rm(icmap_map, item->key_name) != QB_TRUE) {
		return (CS_ERR_NOT_EXIST);
	}

	return (CS_OK);
}
示例#5
0
static void op_history_delete(struct pe_operation *op)
{
	struct resource *r;
	qb_map_iter_t *iter;
	const char *key;
	struct operation_history *oh;

	qb_enter();

	/*
	 * Delete this resource from any operational histories
	 */
	iter = qb_map_iter_create(op_history_map);
	while ((key = qb_map_iter_next(iter, (void **)&oh)) != NULL) {
		r = (struct resource *)oh->resource;

		if (r == op->resource) {
			/* stop the recurring monitor.
			 */
			if (qb_loop_timer_is_running(NULL, r->monitor_timer) &&
			    r->monitor_op) {
				recurring_monitor_stop(r->monitor_op);
			}

			qb_map_rm(op_history_map, key);
			free(oh->rsc_id);
			free(oh->operation);
			free(oh->op_digest);
			free(oh);
		}
	}
	qb_map_iter_free(iter);

	qb_util_stopwatch_stop(op->time_execed);
	pe_resource_completed(op, OCF_OK);
	pe_resource_unref(op);

	qb_leave();
}