Skip to content
Snippets Groups Projects
sched_upcalls.c 33.7 KiB
Newer Older
	list_iterator_destroy( i );
	
	return rc;
}


/* ************************************************************************ */
/*  TAG(                       sched_start_job                           )  */
/* ************************************************************************ */
int
sched_start_job( const uint32_t job_id )
{
	ListIterator i;
	struct job_record *job;
	int rc;
	time_t now = time( NULL );
	
	slurmctld_lock_t job_write_lock = { 
                NO_LOCK,
		WRITE_LOCK,
		WRITE_LOCK,
		NO_LOCK
	};

	debug3( "Scheduler plugin requested launch of job %u", job_id );
	lock_slurmctld( job_write_lock );
	i = list_iterator_create( job_list );
	rc = SLURM_ERROR;
	while ( ( job = (struct job_record *) list_next( i ) ) != NULL ) {
		if ( job->job_id == job_id ) {
			job->priority = 1;
			job->time_last_active = now;
			last_job_update = now;
			rc = SLURM_SUCCESS;
			break;
		}
	}
	list_iterator_destroy( i );
	unlock_slurmctld( job_write_lock );
	schedule();
	return rc;
}


/* ************************************************************************ */
/*  TAG(                       sched_cancel_job                          )  */
/* ************************************************************************ */
int
sched_cancel_job( const uint32_t job_id )
{
	int rc = SLURM_SUCCESS;
	
	slurmctld_lock_t job_write_lock = {
		NO_LOCK, WRITE_LOCK, WRITE_LOCK, NO_LOCK };

	/*
	 * The nice way to do things would be to send SIGTERM, wait for
	 * about five seconds, and then send SIGKILL.  But rather than
	 * pre-empt the controller for five seconds, and rather than
	 * spawning a thread and then trying to rendezvous again with
	 * the plugin, we do the heavy-handed thing.
	 */
	debug3( "Scheduler plugin requested cancellation of job %u", job_id );
	lock_slurmctld( job_write_lock );
	rc = job_signal( job_id, SIGKILL, getuid() );
	unlock_slurmctld( job_write_lock );

	return rc;
}