Exemplo n.º 1
0
extern int fini(void)
{
	debug("%s: unloading %s", __func__, plugin_name);
	FREE_NULL_LIST(gres_devices);
	FREE_NULL_LIST(mps_info);

	return SLURM_SUCCESS;
}
Exemplo n.º 2
0
static void _destroy_local_resv_usage(void *object)
{
	local_resv_usage_t *r_usage = (local_resv_usage_t *)object;
	if (r_usage) {
		FREE_NULL_LIST(r_usage->local_assocs);
		FREE_NULL_LIST(r_usage->loc_tres);
		xfree(r_usage);
	}
}
Exemplo n.º 3
0
/* Add clusters to be removed if "setting" a federation to a specific set of
 * clusters or clearing all clusters.
 *
 * IN cluster_list: list of slurmdb_cluster_rec_t's with cluster names set that
 *                  are to be "set" on the federation the federation.
 * IN federation: name of the federation that is being added/modified.
 */
static int _add_clusters_to_remove(List cluster_list, const char *federation)
{
	List        db_list = NULL;
	ListIterator db_itr = NULL;
	slurmdb_federation_cond_t db_cond;
	slurmdb_federation_rec_t *db_rec = NULL;
	slurmdb_cluster_rec_t    *db_cluster = NULL;

	slurmdb_init_federation_cond(&db_cond, 0);
	db_cond.federation_list = list_create(slurm_destroy_char);
	list_append(db_cond.federation_list, xstrdup(federation));

	db_list = acct_storage_g_get_federations(db_conn, my_uid, &db_cond);
	if (!db_list || !list_count(db_list)) {
		fprintf(stderr, " Problem getting federations "
			"from database. Contact your admin.\n");
		return SLURM_ERROR;
	}
	FREE_NULL_LIST(db_cond.federation_list);
	db_rec = list_peek(db_list);
	db_itr = list_iterator_create(db_rec->cluster_list);
	while ((db_cluster = list_next(db_itr))) {
		bool found_cluster = false;
		slurmdb_cluster_rec_t *orig_cluster = NULL;
		ListIterator orig_itr = list_iterator_create(cluster_list);

		/* Figure out if cluster in cluster_list is already on the
		 * federation. If if is, don't add to list to remove */
		while ((orig_cluster = list_next(orig_itr))) {
			char *db_name = db_cluster->name;
			if (*db_name == '+' || *db_name == '-')
				++db_name;
			if (!xstrcmp(orig_cluster->name, db_name)) {
				found_cluster = true;
				break;
			}
		}
		list_iterator_destroy(orig_itr);
		if (found_cluster)
			continue;

		slurmdb_cluster_rec_t *cluster =
			xmalloc(sizeof(slurmdb_cluster_rec_t));
		slurmdb_init_cluster_rec(cluster, 0);
		cluster->name = xstrdup_printf("-%s", db_cluster->name);
		list_append(cluster_list, cluster);
	}
	list_iterator_destroy(db_itr);
	FREE_NULL_LIST(db_list);

	return SLURM_SUCCESS;
}
Exemplo n.º 4
0
Arquivo: eio.c Projeto: artpol84/slurm
void eio_handle_destroy(eio_handle_t *eio)
{
	xassert(eio != NULL);
	xassert(eio->magic == EIO_MAGIC);
	close(eio->fds[0]);
	close(eio->fds[1]);
	FREE_NULL_LIST(eio->obj_list);
	FREE_NULL_LIST(eio->new_objs);
	slurm_mutex_destroy(&eio->shutdown_mutex);

	xassert(eio->magic = ~EIO_MAGIC);
	xfree(eio);
}
Exemplo n.º 5
0
/* This will destroy the *loc_tres given after it is transfered */
static void _transfer_loc_tres(List *loc_tres, local_id_usage_t *usage)
{
	if (!usage || !*loc_tres || !list_count(*loc_tres)) {
		FREE_NULL_LIST(*loc_tres);
		return;
	}

	if (!usage->loc_tres) {
		usage->loc_tres = *loc_tres;
		*loc_tres = NULL;
	} else {
		_add_job_alloc_time_to_cluster(usage->loc_tres, *loc_tres);
		FREE_NULL_LIST(*loc_tres);
	}
}
static void _block_list_del(void *object)
{
	db2_block_info_t *block_ptr = (db2_block_info_t *)object;

	if (block_ptr) {
		xfree(block_ptr->bg_block_name);
		xfree(block_ptr->slurm_part_name);
		xfree(block_ptr->mp_str);
		xfree(block_ptr->ionode_str);
		FREE_NULL_LIST(block_ptr->nodelist);
		FREE_NULL_LIST(block_ptr->job_list);
		xfree(block_ptr);

	}
}
Exemplo n.º 7
0
int run_script(const char *name, const char *pattern, uint32_t job_id,
	       int max_wait, char **env, uid_t uid)
{
	int rc = 0;
	List l;
	ListIterator i;
	char *s;

	if (pattern == NULL || pattern[0] == '\0')
		return 0;

	l = _script_list_create (pattern);
	if (l == NULL)
		return error ("Unable to run %s [%s]", name, pattern);

	i = list_iterator_create (l);
	while ((s = list_next (i))) {
		rc = _run_one_script (name, s, job_id, max_wait, env, uid);
		if (rc) {
			error ("%s: exited with status 0x%04x\n", s, rc);
			break;
		}

	}
	list_iterator_destroy (i);
	FREE_NULL_LIST (l);

	return rc;
}
Exemplo n.º 8
0
Arquivo: grid.c Projeto: jtfrey/slurm
extern int get_system_stats(GtkTable *table)
{
	int rc = SLURM_SUCCESS;
	node_info_msg_t *node_info_ptr = NULL;
	List node_list = NULL;

	if ((rc = get_new_info_node(&node_info_ptr, force_refresh))
	    == SLURM_NO_CHANGE_IN_DATA) {
	} else if (rc != SLURM_SUCCESS)
		return SLURM_ERROR;

	select_g_ba_init(node_info_ptr, 0);

	node_list = create_node_info_list(node_info_ptr, false);
	if (grid_button_list) {
		rc = update_grid_table(main_grid_table, grid_button_list,
				       node_list);
		if (rc == RESET_GRID) {
			FREE_NULL_LIST(grid_button_list);
			grid_button_list = list_create(destroy_grid_button);
			setup_grid_table(main_grid_table, grid_button_list,
					 node_list);
		}
	} else {
		grid_button_list = list_create(destroy_grid_button);
		setup_grid_table(main_grid_table, grid_button_list, node_list);
	}

	gtk_widget_show_all(GTK_WIDGET(main_grid_table));

	return SLURM_SUCCESS;
}
Exemplo n.º 9
0
static int _isdefault_old(List acct_list)
{
	int rc = 0;
	slurmdb_user_cond_t user_cond;
	List ret_list = NULL;

	if (!acct_list || !list_count(acct_list))
		return rc;

	memset(&user_cond, 0, sizeof(slurmdb_user_cond_t));
	user_cond.def_acct_list = acct_list;

	ret_list = slurmdb_users_get(db_conn, &user_cond);
	if (ret_list && list_count(ret_list)) {
		ListIterator itr = list_iterator_create(ret_list);
		slurmdb_user_rec_t *user = NULL;
		fprintf(stderr," Users listed below have these "
			"as their Default Accounts.\n");
		while((user = list_next(itr))) {
			fprintf(stderr, " User - %-10.10s Account - %s\n",
				user->name, user->default_acct);
		}
		list_iterator_destroy(itr);
		rc = 1;
	}

	FREE_NULL_LIST(ret_list);

	return rc;
}
Exemplo n.º 10
0
/* clear_old IN - if set then don't preserve old info (it might be from
 *		  another cluster) */
static int _get_info(bool clear_old)
{
	partition_info_msg_t *partition_msg = NULL;
	node_info_msg_t *node_msg = NULL;
	block_info_msg_t *block_msg = NULL;
	reserve_info_msg_t *reserv_msg = NULL;
	List sinfo_list = NULL;
	int rc = 0;

	if (_query_server(&partition_msg, &node_msg, &block_msg, &reserv_msg,
			  clear_old))
		rc = 1;
	else if (params.bg_flag)
		(void) _bg_report(block_msg);
	else if (params.reservation_flag)
		(void) _reservation_report(reserv_msg);
	else {
		sinfo_list = list_create(_sinfo_list_delete);
		_build_sinfo_data(sinfo_list, partition_msg, node_msg);
		sort_sinfo_list(sinfo_list);
		print_sinfo_list(sinfo_list);
		FREE_NULL_LIST(sinfo_list);
	}

	return rc;
}
Exemplo n.º 11
0
Arquivo: gang.c Projeto: corburn/slurm
/* Build the gs_part_list. The job_list will be created later,
 * once a job is added. */
static void _build_parts(void)
{
	ListIterator part_iterator;
	struct part_record *p_ptr;
	struct gs_part *gs_part_ptr;
	int num_parts;

	FREE_NULL_LIST(gs_part_list);

	/* reset the sorted list, since it's currently
	 * pointing to partitions we just destroyed */
	num_sorted_part = 0;

	num_parts = list_count(part_list);
	if (num_parts == 0)
		return;

	gs_part_list = list_create(_destroy_parts);
	part_iterator = list_iterator_create(part_list);
	while ((p_ptr = (struct part_record *) list_next(part_iterator))) {
		gs_part_ptr = xmalloc(sizeof(struct gs_part));
		gs_part_ptr->part_name = xstrdup(p_ptr->name);
		gs_part_ptr->priority = p_ptr->priority;
		/* everything else is already set to zero/NULL */
		list_append(gs_part_list, gs_part_ptr);
	}
	list_iterator_destroy(part_iterator);
}
Exemplo n.º 12
0
static List _create_resv_info_list(reserve_info_msg_t *resv_info_ptr)
{
	static List info_list = NULL;
	List last_list = NULL;
	ListIterator last_list_itr = NULL;
	int i = 0;
	static reserve_info_msg_t *last_resv_info_ptr = NULL;
	sview_resv_info_t *sview_resv_info_ptr = NULL;
	reserve_info_t *resv_ptr = NULL;

	if (info_list && (resv_info_ptr == last_resv_info_ptr))
		goto update_color;

	last_resv_info_ptr = resv_info_ptr;

	if (info_list)
		last_list = info_list;

	info_list = list_create(_resv_info_list_del);

	if (last_list)
		last_list_itr = list_iterator_create(last_list);
	for(i=0; i<resv_info_ptr->record_count; i++) {
		resv_ptr = &(resv_info_ptr->reservation_array[i]);

		sview_resv_info_ptr = NULL;

		if (last_list_itr) {
			while ((sview_resv_info_ptr =
				list_next(last_list_itr))) {
				if (!xstrcmp(sview_resv_info_ptr->resv_name,
					     resv_ptr->name)) {
					list_remove(last_list_itr);
					_resv_info_free(sview_resv_info_ptr);
					break;
				}
			}
			list_iterator_reset(last_list_itr);
		}
		if (!sview_resv_info_ptr)
			sview_resv_info_ptr =
				xmalloc(sizeof(sview_resv_info_t));
		sview_resv_info_ptr->resv_name = xstrdup(resv_ptr->name);
		sview_resv_info_ptr->pos = i;
		sview_resv_info_ptr->resv_ptr = resv_ptr;
		sview_resv_info_ptr->color_inx = i % sview_colors_cnt;
		list_append(info_list, sview_resv_info_ptr);
	}

	list_sort(info_list,
		  (ListCmpF)_sview_resv_sort_aval_dec);

	if (last_list) {
		list_iterator_destroy(last_list_itr);
		FREE_NULL_LIST(last_list);
	}

update_color:
	return info_list;
}
Exemplo n.º 13
0
/* Prepare cluster_list to be federation centric that will be passed to
 * verify_clsuters_exists in federation_functions.c.
 */
static int _verify_fed_clusters(List cluster_list, const char *fed_name,
				bool *existing_fed)
{
	int   rc         = SLURM_SUCCESS;
	char *tmp_name   = NULL;
	List  tmp_list   = list_create(slurmdb_destroy_cluster_rec);
	ListIterator itr = list_iterator_create(cluster_list);

	while ((tmp_name = list_next(itr))) {
		slurmdb_cluster_rec_t *rec =
			xmalloc(sizeof(slurmdb_cluster_rec_t));
		slurmdb_init_cluster_rec(rec, 0);
		rec->name = xstrdup(tmp_name);
		list_append(tmp_list, rec);
	}

	if ((rc = verify_fed_clusters(tmp_list, fed_name, existing_fed)))
		goto end_it;

	/* have to reconcile lists now, clusters may have been removed from
	 * tmp_list */
	list_iterator_reset(itr);
	while ((tmp_name = list_next(itr))) {
		if (!list_find_first(tmp_list, _find_cluster_rec_in_list,
				     tmp_name))
			list_delete_item(itr);
	}

end_it:
	FREE_NULL_LIST(tmp_list);
	list_iterator_destroy(itr);

	return rc;
}
Exemplo n.º 14
0
extern List as_mysql_remove_wckeys(mysql_conn_t *mysql_conn,
				   uint32_t uid,
				   slurmdb_wckey_cond_t *wckey_cond)
{
	List ret_list = NULL;
	int rc = SLURM_SUCCESS;
	char *extra = NULL, *object = NULL;
	char *user_name = NULL;
	List use_cluster_list = as_mysql_cluster_list;
	ListIterator itr;

	if (!wckey_cond) {
		xstrcat(extra, " where deleted=0");
		goto empty;
	}

	if (check_connection(mysql_conn) != SLURM_SUCCESS)
		return NULL;

	if (!is_user_min_admin_level(mysql_conn, uid, SLURMDB_ADMIN_OPERATOR)) {
		errno = ESLURM_ACCESS_DENIED;
		return NULL;
	}

	(void) _setup_wckey_cond_limits(wckey_cond, &extra);

	if (wckey_cond->cluster_list && list_count(wckey_cond->cluster_list))
		use_cluster_list = wckey_cond->cluster_list;
empty:
	if (!extra) {
		error("Nothing to remove");
		return NULL;
	}

	user_name = uid_to_string((uid_t) uid);

	if (use_cluster_list == as_mysql_cluster_list)
		slurm_mutex_lock(&as_mysql_cluster_list_lock);
	ret_list = list_create(slurm_destroy_char);
	itr = list_iterator_create(use_cluster_list);
	while ((object = list_next(itr))) {
		if ((rc = _cluster_remove_wckeys(
			     mysql_conn, extra, object, user_name, ret_list))
		    != SLURM_SUCCESS)
			break;
	}
	list_iterator_destroy(itr);
	xfree(extra);
	xfree(user_name);

	if (use_cluster_list == as_mysql_cluster_list)
		slurm_mutex_unlock(&as_mysql_cluster_list_lock);

	if (rc == SLURM_ERROR) {
		FREE_NULL_LIST(ret_list);
		return NULL;
	}

	return ret_list;
}
Exemplo n.º 15
0
static int _pmix_p2p_send_core(const char *nodename, const char *address,
			       const char *data, uint32_t len)
{
	int rc, timeout;
	slurm_msg_t msg;
	forward_data_msg_t req;
	List ret_list;
	ret_data_info_t *ret_data_info = NULL;

	pmixp_debug_hang(0);

	slurm_msg_t_init(&msg);

	PMIXP_DEBUG("nodelist=%s, address=%s, len=%u", nodename, address, len);
	req.address = (char *)address;
	req.len = len;
	/* there is not much we can do - just cast) */
	req.data = (char*)data;

	msg.msg_type = REQUEST_FORWARD_DATA;
	msg.data = &req;

	if (slurm_conf_get_addr(nodename, &msg.address) == SLURM_ERROR) {
		PMIXP_ERROR("Can't find address for host "
			    "%s, check slurm.conf", nodename);
		return SLURM_ERROR;
	}

	timeout = slurm_get_msg_timeout() * 1000;
	msg.forward.timeout = timeout;
	msg.forward.cnt = 0;
	msg.forward.nodelist = NULL;
	ret_list = slurm_send_addr_recv_msgs(&msg, (char*)nodename, timeout);
	if (!ret_list) {
		/* This should never happen (when this was
		 * written slurm_send_addr_recv_msgs always
		 * returned a list */
		PMIXP_ERROR("No return list given from "
			    "slurm_send_addr_recv_msgs spawned for %s",
			    nodename);
		return SLURM_ERROR;
	} else if ((errno != SLURM_COMMUNICATIONS_CONNECTION_ERROR) &&
		   !list_count(ret_list)) {
		PMIXP_ERROR("failed to send to %s, errno=%d", nodename, errno);
		return SLURM_ERROR;
	}

	rc = SLURM_SUCCESS;
	while ((ret_data_info = list_pop(ret_list))) {
		int temp_rc = slurm_get_return_code(ret_data_info->type,
						    ret_data_info->data);
		if (temp_rc != SLURM_SUCCESS)
			rc = temp_rc;
		destroy_data_info(ret_data_info);
	}

	FREE_NULL_LIST(ret_list);

	return rc;
}
Exemplo n.º 16
0
/*
 * get_part_list - find record for named partition(s)
 * IN name - partition name(s) in a comma separated list
 * RET List of pointers to the partitions or NULL if not found
 * NOTE: Caller must free the returned list
 */
extern List get_part_list(char *name)
{
	struct part_record *part_ptr;
	List job_part_list = NULL;
	char *token, *last = NULL, *tmp_name;

	if (name == NULL)
		return job_part_list;

	tmp_name = xstrdup(name);
	token = strtok_r(tmp_name, ",", &last);
	while (token) {
		part_ptr = list_find_first(part_list, &list_find_part, token);
		if (part_ptr) {
			if (job_part_list == NULL) {
				job_part_list = list_create(NULL);
			}
			list_append(job_part_list, part_ptr);
		} else {
			FREE_NULL_LIST(job_part_list);
			break;
		}
		token = strtok_r(NULL, ",", &last);
	}
	xfree(tmp_name);
	return job_part_list;
}
Exemplo n.º 17
0
static void _destroy_local_id_usage(void *object)
{
	local_id_usage_t *a_usage = (local_id_usage_t *)object;
	if (a_usage) {
		FREE_NULL_LIST(a_usage->loc_tres);
		xfree(a_usage);
	}
}
Exemplo n.º 18
0
static void _destroy_local_cluster_usage(void *object)
{
	local_cluster_usage_t *c_usage = (local_cluster_usage_t *)object;
	if (c_usage) {
		FREE_NULL_LIST(c_usage->loc_tres);
		xfree(c_usage);
	}
}
Exemplo n.º 19
0
extern void
stepd_step_rec_destroy(stepd_step_rec_t *job)
{
	uint16_t multi_prog = 0;
	int i;

	_array_free(&job->env);
	_array_free(&job->argv);

	if (job->flags & LAUNCH_MULTI_PROG)
		multi_prog = 1;
	for (i = 0; i < job->node_tasks; i++)
		_task_info_destroy(job->task[i], multi_prog);
	eio_handle_destroy(job->eio);
	FREE_NULL_LIST(job->sruns);
	FREE_NULL_LIST(job->clients);
	FREE_NULL_LIST(job->stdout_eio_objs);
	FREE_NULL_LIST(job->stderr_eio_objs);
	FREE_NULL_LIST(job->free_incoming);
	FREE_NULL_LIST(job->free_outgoing);
	FREE_NULL_LIST(job->outgoing_cache);
	xfree(job->envtp);
	xfree(job->node_name);
	mpmd_free(job);
	xfree(job->task_prolog);
	xfree(job->task_epilog);
	xfree(job->job_alloc_cores);
	xfree(job->step_alloc_cores);
	xfree(job->task_cnts);
	xfree(job->user_name);
	xfree(job);
}
Exemplo n.º 20
0
/*
 * license_job_merge - The licenses from one job have just been merged into
 *	another job by appending one job's licenses to another, possibly
 *	including duplicate names. Reconstruct this job's licenses and
 *	license_list fields to eliminate duplicates.
 */
extern void license_job_merge(struct job_record *job_ptr)
{
	bool valid;

	FREE_NULL_LIST(job_ptr->license_list);
	job_ptr->license_list = _build_license_list(job_ptr->licenses, &valid);
	xfree(job_ptr->licenses);
	job_ptr->licenses = _build_license_string(job_ptr->license_list);
}
Exemplo n.º 21
0
/* node_fini2 - free memory associated with node records (except bitmaps) */
extern void node_fini2 (void)
{
	int i;
	struct node_record *node_ptr;

	if (config_list) {
		FREE_NULL_LIST(config_list);
		FREE_NULL_LIST(front_end_list);
	}

	xhash_free(node_hash_table);
	node_ptr = node_record_table_ptr;
	for (i = 0; i < node_record_count; i++, node_ptr++)
		purge_node_rec(node_ptr);

	xfree(node_record_table_ptr);
	node_record_count = 0;
}
Exemplo n.º 22
0
extern void slurm_job_step_stat_response_msg_free(void *object)
{
	job_step_stat_response_msg_t *step_stat_msg =
		(job_step_stat_response_msg_t *) object;
	if (step_stat_msg) {
		FREE_NULL_LIST(step_stat_msg->stats_list);
		xfree(step_stat_msg);
	}
}
Exemplo n.º 23
0
int main(int argc, char **argv)
{
	log_options_t opts = LOG_OPTS_STDERR_ONLY;
	update_block_msg_t msg;
	ListIterator itr = NULL;
	char *block_name = NULL;
	int rc = SLURM_SUCCESS;

	log_init(xbasename(argv[0]), opts, SYSLOG_FACILITY_DAEMON, NULL);
	parse_command_line(argc, argv);

	memset(&msg, 0, sizeof(update_block_msg_t));
	if (!all_blocks && (!block_list || !list_count(block_list))) {
		error("you need at least one block to remove.");
		exit(1);
	}

	if (all_blocks) {
		int i=0;
		block_info_msg_t *block_ptr = NULL;
		_get_new_info_block(&block_ptr);
		if (!block_ptr) {
			error("there was no block_ptr filled in.");
			return 1;
		}
		if (block_list)
			list_flush(block_list);
		else
			block_list = list_create(slurm_destroy_char);

		for (i=0; i<block_ptr->record_count; i++) {
			list_append(block_list,
				    xstrdup(block_ptr->
					    block_array[i].bg_block_id));
		}
	}

	itr = list_iterator_create(block_list);
	while ((block_name = list_next(itr))) {
		if (remove_blocks)
			msg.state = BG_BLOCK_NAV;
		else
			msg.state = BG_BLOCK_FREE;
		msg.bg_block_id = block_name;
		rc = slurm_update_block(&msg);
		if (rc != SLURM_SUCCESS)
			error("Error trying to free block %s: %s",
			      block_name, slurm_strerror(rc));
	}
	list_iterator_destroy(itr);
	if (wait_full)
		_check_status();

	FREE_NULL_LIST(block_list);
	info("done");
	return 0;
}
Exemplo n.º 24
0
extern void destroy_image(void *ptr)
{
	image_t *n = (image_t *)ptr;
	if (n) {
		xfree(n->name);
		FREE_NULL_LIST(n->groups);
		xfree(n);
	}
}
Exemplo n.º 25
0
static void _build_tres_list(void)
{
	ListIterator iter;
	slurmdb_tres_rec_t *tres;
	char *tres_tmp = NULL, *tres_tmp2 = NULL, *save_ptr = NULL, *tok;

	if (!g_tres_list) {
		slurmdb_tres_cond_t cond = {0};
		g_tres_list = slurmdb_tres_get(db_conn, &cond);
		if (!g_tres_list) {
			fatal("Problem getting TRES data: %m");
			exit(1);
		}
	}
	FREE_NULL_LIST(tres_list);

	tres_list = list_create(slurmdb_destroy_tres_rec);
	if (!tres_str) {
		int tres_cpu_id = TRES_CPU;
		slurmdb_tres_rec_t *tres2;
		if (!(tres = list_find_first(g_tres_list,
					     slurmdb_find_tres_in_list,
					     &tres_cpu_id)))
			fatal("Failed to find CPU TRES!");
		tres2 = slurmdb_copy_tres_rec(tres);
		list_append(tres_list, tres2);

		return;
	}

	tres_usage_str = "TRES";
	iter = list_iterator_create(g_tres_list);
	while ((tres = list_next(iter))) {
		tres_tmp = xstrdup(tres_str);
		xstrfmtcat(tres_tmp2, "%s%s%s",
			   tres->type,
			   tres->name ? "/" : "",
			   tres->name ? tres->name : "");
		tok = strtok_r(tres_tmp, ",", &save_ptr);
		while (tok) {
			if (!xstrcasecmp(tres_tmp2, tok))
				break;
			tok = strtok_r(NULL, ",", &save_ptr);
		}
		if (tok) {
			slurmdb_tres_rec_t *tres2 =
				slurmdb_copy_tres_rec(tres);
			list_append(tres_list, tres2);
		}
		xfree(tres_tmp2);
		xfree(tres_tmp);
	}
	if (!list_count(tres_list))
		fatal("No valid TRES given");
	list_iterator_destroy(iter);
}
Exemplo n.º 26
0
static int _process_purge(mysql_conn_t *mysql_conn,
			  char *cluster_name,
			  uint16_t archive_data,
			  uint32_t purge_period)
{
	int rc = SLURM_SUCCESS;
	slurmdb_archive_cond_t arch_cond;
	slurmdb_job_cond_t job_cond;

	/* if we didn't ask for archive data return here and don't do
	   anything extra just rollup */

	if (!archive_data)
		return SLURM_SUCCESS;

	if (!slurmdbd_conf)
		return SLURM_SUCCESS;

	memset(&job_cond, 0, sizeof(job_cond));
	memset(&arch_cond, 0, sizeof(arch_cond));
	arch_cond.archive_dir = slurmdbd_conf->archive_dir;
	arch_cond.archive_script = slurmdbd_conf->archive_script;

	if (purge_period & slurmdbd_conf->purge_event)
		arch_cond.purge_event = slurmdbd_conf->purge_event;
	else
		arch_cond.purge_event = NO_VAL;
	if (purge_period & slurmdbd_conf->purge_job)
		arch_cond.purge_job = slurmdbd_conf->purge_job;
	else
		arch_cond.purge_job = NO_VAL;

	if (purge_period & slurmdbd_conf->purge_resv)
		arch_cond.purge_resv = slurmdbd_conf->purge_resv;
	else
		arch_cond.purge_resv = NO_VAL;

	if (purge_period & slurmdbd_conf->purge_step)
		arch_cond.purge_step = slurmdbd_conf->purge_step;
	else
		arch_cond.purge_step = NO_VAL;
	if (purge_period & slurmdbd_conf->purge_suspend)
		arch_cond.purge_suspend = slurmdbd_conf->purge_suspend;
	else
		arch_cond.purge_suspend = NO_VAL;

	job_cond.cluster_list = list_create(NULL);
	list_append(job_cond.cluster_list, cluster_name);

	arch_cond.job_cond = &job_cond;
	rc = as_mysql_jobacct_process_archive(mysql_conn, &arch_cond);
	FREE_NULL_LIST(job_cond.cluster_list);

	return rc;
}
Exemplo n.º 27
0
/*
 *  Destroy container, freeing all data associated with options.
 */
void job_options_destroy (job_options_t opts)
{
	xassert (opts != NULL);
	xassert (opts->magic == JOB_OPTIONS_MAGIC);

	FREE_NULL_LIST (opts->options);

	xassert (opts->magic = ~JOB_OPTIONS_MAGIC);
	xfree (opts);
	return;
}
Exemplo n.º 28
0
static void _destroy_filetxt_job_rec(void *object)
{
	filetxt_job_rec_t *job = (filetxt_job_rec_t *)object;
	if (job) {
		FREE_NULL_LIST(job->steps);
		_free_filetxt_header(&job->header);
		xfree(job->jobname);
		xfree(job->account);
		xfree(job->nodes);
		xfree(job);
	}
}
Exemplo n.º 29
0
extern void msg_aggr_sender_fini(void)
{
	if (!msg_collection.running)
		return;
	msg_collection.running = 0;
	slurm_mutex_lock(&msg_collection.mutex);

	slurm_cond_signal(&msg_collection.cond);
	slurm_mutex_unlock(&msg_collection.mutex);

	pthread_join(msg_collection.thread_id, NULL);
	msg_collection.thread_id = (pthread_t) 0;

	slurm_cond_destroy(&msg_collection.cond);
	/* signal and clear the waiting list */
	slurm_mutex_lock(&msg_collection.aggr_mutex);
	_handle_msg_aggr_ret(0, 1);
	FREE_NULL_LIST(msg_collection.msg_aggr_list);
	slurm_mutex_unlock(&msg_collection.aggr_mutex);
	FREE_NULL_LIST(msg_collection.msg_list);
	slurm_mutex_destroy(&msg_collection.mutex);
}
Exemplo n.º 30
0
extern int destroy_mysql_conn(mysql_conn_t *mysql_conn)
{
	if (mysql_conn) {
		mysql_db_close_db_connection(mysql_conn);
		xfree(mysql_conn->pre_commit_query);
		xfree(mysql_conn->cluster_name);
		slurm_mutex_destroy(&mysql_conn->lock);
		FREE_NULL_LIST(mysql_conn->update_list);
		xfree(mysql_conn);
	}

	return SLURM_SUCCESS;
}