Ejemplo n.º 1
0
/*
 * Initialize context for priority plugin
 */
extern int slurm_priority_init(void)
{
	int retval = SLURM_SUCCESS;
	char *plugin_type = "priority";
	char *type = NULL;

	if (init_run && g_priority_context)
		return retval;

	slurm_mutex_lock(&g_priority_context_lock);

	if (g_priority_context)
		goto done;

	type = slurm_get_priority_type();

	g_priority_context = plugin_context_create(
		plugin_type, type, (void **)&ops, syms, sizeof(syms));

	if (!g_priority_context) {
		error("cannot create %s context for %s", plugin_type, type);
		retval = SLURM_ERROR;
		goto done;
	}
	init_run = true;

done:
	slurm_mutex_unlock(&g_priority_context_lock);
	xfree(type);
	return retval;
}
Ejemplo n.º 2
0
/*
 * Initialize context for priority plugin
 */
extern int slurm_priority_init(void)
{
	int retval = SLURM_SUCCESS;
	char *priority_type = NULL;

	slurm_mutex_lock( &g_priority_context_lock );

	if ( g_priority_context )
		goto done;

	priority_type = slurm_get_priority_type();

	g_priority_context = _priority_context_create(priority_type);
	if ( g_priority_context == NULL ) {
		error( "cannot create priority context for %s",
		       priority_type );
		retval = SLURM_ERROR;
		goto done;
	}

	if ( _priority_get_ops( g_priority_context ) == NULL ) {
		error( "cannot resolve priority plugin operations" );
		_priority_context_destroy( g_priority_context );
		g_priority_context = NULL;
		retval = SLURM_ERROR;
	}

done:
	slurm_mutex_unlock( &g_priority_context_lock );
	xfree(priority_type);
	return retval;
}
extern int init( void )
{
	int rc = SLURM_SUCCESS;
	char *prio_type = slurm_get_priority_type();

	if (strncasecmp(prio_type, "priority/multifactor", 20)) {
		error("The priority plugin (%s) is currently loaded. "
		      "This is NOT compatible with the %s plugin. "
		      "The priority/multifactor plugin must be used",
		      prio_type, plugin_type);
		rc = SLURM_FAILURE;
	}

	xfree(prio_type);
	verbose("%s loaded", plugin_type);
	return rc;
}
Ejemplo n.º 4
0
Archivo: sprio.c Proyecto: A1ve5/slurm
int main (int argc, char *argv[])
{
	char *prio_type = NULL;
	int error_code = SLURM_SUCCESS;
	priority_factors_request_msg_t req_msg;
	priority_factors_response_msg_t *resp_msg = NULL;
	log_options_t opts = LOG_OPTS_STDERR_ONLY ;

	slurm_conf_init(NULL);
	log_init(xbasename(argv[0]), opts, SYSLOG_FACILITY_USER, NULL);

	parse_command_line( argc, argv );
	if (params.verbose) {
		opts.stderr_level += params.verbose;
		log_alter(opts, SYSLOG_FACILITY_USER, NULL);
	}

	if (working_cluster_rec) {
		slurm_ctl_conf_info_msg_t  *slurm_ctl_conf_ptr;

		error_code = slurm_load_ctl_conf((time_t) NULL,
						  &slurm_ctl_conf_ptr);
		if (error_code) {
			slurm_perror ("slurm_load_ctl_conf error");
			exit(error_code);
		}
		weight_age  = slurm_ctl_conf_ptr->priority_weight_age;
		weight_fs   = slurm_ctl_conf_ptr->priority_weight_fs;
		weight_js   = slurm_ctl_conf_ptr->priority_weight_js;
		weight_part = slurm_ctl_conf_ptr->priority_weight_part;
		weight_qos  = slurm_ctl_conf_ptr->priority_weight_qos;
		weight_tres = slurm_ctl_conf_ptr->priority_weight_tres;
		prio_type   = xstrdup(slurm_ctl_conf_ptr->priority_type);
		slurm_free_ctl_conf(slurm_ctl_conf_ptr);
	} else {
		weight_age  = slurm_get_priority_weight_age();
		weight_fs   = slurm_get_priority_weight_fairshare();
		weight_js   = slurm_get_priority_weight_job_size();
		weight_part = slurm_get_priority_weight_partition();
		weight_qos  = slurm_get_priority_weight_qos();
		weight_tres = slurm_get_priority_weight_tres();
		prio_type   = slurm_get_priority_type();
	}

	/* Check to see if we are running a supported accounting plugin */
	if (xstrcasecmp(prio_type, "priority/basic") == 0) {
		fprintf (stderr, "You are not running a supported "
			 "priority plugin\n(%s).\n"
			 "Only 'priority/multifactor' is supported.\n",
			 prio_type);
		exit(1);
	}
	xfree(prio_type);


	memset(&req_msg, 0, sizeof(priority_factors_request_msg_t));

	if (params.jobs)
		req_msg.job_id_list = params.job_list;
	else
		req_msg.job_id_list = NULL;

	if (params.users)
		req_msg.uid_list = params.user_list;
	else
		req_msg.uid_list = NULL;

	error_code = _get_info(&req_msg, &resp_msg);

	if (error_code) {
		slurm_perror("Couldn't get priority factors from controller");
		exit(error_code);
	}

	if (params.format == NULL) {
		if (params.normalized) {
			if (params.long_list)
				params.format = "%.15i %.8u %10y %10a %10f "
					"%10j %10p %10q %20t";
			else{
				params.format = xstrdup("%.15i");
				if (params.users)
					xstrcat(params.format, " %.8u");
				xstrcat(params.format, " %10y");
				if (weight_age)
					xstrcat(params.format, " %10a");
				if (weight_fs)
					xstrcat(params.format, " %10f");
				if (weight_js)
					xstrcat(params.format, " %10j");
				if (weight_part)
					xstrcat(params.format, " %10p");
				if (weight_qos)
					xstrcat(params.format, " %10q");
				if (weight_tres)
					xstrcat(params.format, " %20t");
			}
		} else {
			if (params.long_list)
				params.format = "%.15i %.8u %.10Y %.10A %.10F "
					"%.10J %.10P %.10Q %.6N %.20T";
			else{
				params.format = xstrdup("%.15i");
				if (params.users)
					xstrcat(params.format, " %.8u");
				xstrcat(params.format, " %.10Y");
				if (weight_age)
					xstrcat(params.format, " %.10A");
				if (weight_fs)
					xstrcat(params.format, " %.10F");
				if (weight_js)
					xstrcat(params.format, " %.10J");
				if (weight_part)
					xstrcat(params.format, " %.10P");
				if (weight_qos)
					xstrcat(params.format, " %.10Q");
				if (weight_tres)
					xstrcat(params.format, " %.20T");
			}
		}
	}

	/* create the format list from the format */
	parse_format(params.format);

	if (params.jobs && (!resp_msg || !resp_msg->priority_factors_list ||
			    !list_count(resp_msg->priority_factors_list))) {
		printf("Unable to find jobs matching user/id(s) specified\n");
	} else if (resp_msg) {
		print_jobs_array(resp_msg->priority_factors_list,
				 params.format_list);
	}
#if 0
	/* Free storage here if we want to verify that logic.
	 * Since we exit next, this is not important */
	FREE_NULL_LIST(params.format_list);
	slurm_free_priority_factors_response_msg(resp_msg);
#endif

	exit (error_code);
}