agave-jobs/jobs-core/src/main/java/org/iplantc/service/jobs/managers/JobRequestProcessor.java
/**
	 * Takes a Form representing a job request and parses it into a job object. This is a
	 * stripped down, unstructured version of the other processJob method.
	 *
	 * @param jobRequestMap a map representing the job request form
	 * @return validated job instance ready for submission
	 * @throws JobProcessingException when validation fails unexpectedly
	 */
Takes a Form representing a job request and parses it into a job object. This is a
stripped down, unstructured version of the other processJob method.

@param jobRequestMap a map representing the job request form
@return validated job instance ready for submission
@throws JobProcessingException when validation fails unexpectedly
Takes a Form representing a job request and parses it into a job object . This is a stripped down unstructured version of the other processJob method . @param jobRequestMap a map representing the job request form @return validated job instance ready for submission @throws JobProcessingException when validation fails unexpectedly
public Job processJob(Map<String, Object> jobRequestMap)
	throws JobProcessingException
	{
	    Job job = new Job();
		String name = processNameRequest(jobRequestMap);
		setSoftware(processSoftwareName(jobRequestMap));
		setExecutionSystem(processExecutionSystemRequest(jobRequestMap, getSoftware()));
		/* **************************************************************************
		 **						Batch Parameter Selection 						  **
		 ***************************************************************************/
		String currentParameter = null;
		String queueName = null;
		BatchQueue jobQueue = null;
		Long nodeCount = null;
		Double memoryPerNode = null;
		String requestedTime = null;
		Long processorsPerNode = null;
		try
		{
			/* ********************************* Queue Selection *****************************************/
			currentParameter = "batchQueue";
			setQueueProcessor(new JobRequestQueueProcessor(getSoftware(), getExecutionSystem(), getUsername()));
			getQueueProcessor().process(jobRequestMap);
			jobQueue = getQueueProcessor().getMatchingBatchQueue();
			nodeCount = getQueueProcessor().getResourceRequest().getMaxNodes();
			processorsPerNode = getQueueProcessor().getResourceRequest().getMaxProcessorsPerNode();
			memoryPerNode = getQueueProcessor().getResourceRequest().getMaxMemoryPerNode();
			if (memoryPerNode == null) memoryPerNode = jobQueue.getMaxMemoryPerNode();
			requestedTime = getQueueProcessor().getResourceRequest().getMaxRequestedTime();
			if (requestedTime == null) requestedTime = jobQueue.getMaxRequestedTime();
		}
		catch (JobProcessingException e)
		{
			throw e;
		}
		catch (NoMatchingBatchQueueException e) {
			throw new JobProcessingException(400, e.getMessage());
		}
		catch (Exception e) {
			throw new JobProcessingException(400, "Invalid " + currentParameter + " value.", e);
		}
		/* **************************************************************************
		 **						Verifying remote connectivity 					  **
		 ***************************************************************************/
		checkExecutionSystemLogin(getExecutionSystem());
		checkExecutionSystemStorage(getExecutionSystem());
		/* **************************************************************************
		 **						Verifying Input Parmaeters						  **
		 ***************************************************************************/
		getInputProcessor().process(jobRequestMap);
		ObjectNode jobInputs = getInputProcessor().getJobInputs();
		/* **************************************************************************
		 **						Verifying  Parameters							  **
		 ***************************************************************************/
		getParameterProcessor().process(jobRequestMap);
		ObjectNode jobParameters = getParameterProcessor().getJobParameters();
		/* **************************************************************************
         **                 Create and assign job data                            **
         ***************************************************************************/
        try
        {
            job.setName(name);
            job.setOwner(getUsername());
            job.setSoftwareName(getSoftware().getUniqueName());
            job.setInternalUsername(getInternalUsername());
            job.setSystem(getSoftware().getExecutionSystem().getSystemId());
            job.setSchedulerType(getSoftware().getExecutionSystem().getScheduler());
            job.setExecutionType(getSoftware().getExecutionType());
            job.setBatchQueue(jobQueue.getName());
            job.setNodeCount(nodeCount);
            job.setProcessorsPerNode(processorsPerNode);
            job.setMemoryPerNode(memoryPerNode);
            job.setMaxRunTime(requestedTime);
            job.setInputsAsJsonObject(jobInputs);
            job.setParametersAsJsonObject(jobParameters);
            job.setSubmitTime(new DateTime().toDate());
        }
        catch (JobException e) {
            throw new JobProcessingException(500, e.getMessage(), e);
        }
        /* **************************************************************************
		 **						End Batch Queue Selection 						  **
		 ***************************************************************************/
        /* **************************************************************************
		 **						Verifying optional notifications				  **
		 ***************************************************************************/
		processCallbackUrlRequest(jobRequestMap, job);
		/* **************************************************************************
		 **						Verifying archive configuration					  **
		 ***************************************************************************/
		boolean archiveOutput = processArchiveOutputRequest(jobRequestMap);
		job.setArchiveOutput(archiveOutput);
		RemoteSystem archiveSystem = processArchiveSystemRequest(archiveOutput, jobRequestMap);
		job.setArchiveSystem(archiveSystem);
		String archivePath = processArchivePath(archiveOutput, jobRequestMap, archiveSystem, job);
		try
        {
		    job.setArchivePath(archivePath);
		    DateTime created = new DateTime();
		    job.setCreated(created.toDate());
            JobDao.persist(job);
            job.setCreated(created.toDate());
            job.setStatus(JobStatusType.PENDING, JobStatusType.PENDING.getDescription());
            JobDao.persist(job);
            return job;
        }
        catch (Throwable e)
        {
            throw new JobProcessingException(500, "Failed to submit the request to the job queue.", e);
        }
	}
public Job processJob ( Map < String , Object > jobRequestMap ) throws JobProcessingException { Job job = new Job ( ) ; String name = processNameRequest ( jobRequestMap ) ; setSoftware ( processSoftwareName ( jobRequestMap ) ) ; setExecutionSystem ( processExecutionSystemRequest ( jobRequestMap , getSoftware ( ) ) ) ; /* **************************************************************************
		 **						Batch Parameter Selection 						  **
		 ***************************************************************************/ String currentParameter = null ; String queueName = null ; BatchQueue jobQueue = null ; Long nodeCount = null ; Double memoryPerNode = null ; String requestedTime = null ; Long processorsPerNode = null ; try { /* ********************************* Queue Selection *****************************************/ currentParameter = "batchQueue" ; setQueueProcessor ( new JobRequestQueueProcessor ( getSoftware ( ) , getExecutionSystem ( ) , getUsername ( ) ) ) ; getQueueProcessor ( ) . process ( jobRequestMap ) ; jobQueue = getQueueProcessor ( ) . getMatchingBatchQueue ( ) ; nodeCount = getQueueProcessor ( ) . getResourceRequest ( ) . getMaxNodes ( ) ; processorsPerNode = getQueueProcessor ( ) . getResourceRequest ( ) . getMaxProcessorsPerNode ( ) ; memoryPerNode = getQueueProcessor ( ) . getResourceRequest ( ) . getMaxMemoryPerNode ( ) ; if ( memoryPerNode == null ) memoryPerNode = jobQueue . getMaxMemoryPerNode ( ) ; requestedTime = getQueueProcessor ( ) . getResourceRequest ( ) . getMaxRequestedTime ( ) ; if ( requestedTime == null ) requestedTime = jobQueue . getMaxRequestedTime ( ) ; } catch ( JobProcessingException e ) { throw e ; } catch ( NoMatchingBatchQueueException e ) { throw new JobProcessingException ( 400 , e . getMessage ( ) ) ; } catch ( Exception e ) { throw new JobProcessingException ( 400 , "Invalid " + currentParameter + " value." , e ) ; } /* **************************************************************************
		 **						Verifying remote connectivity 					  **
		 ***************************************************************************/ checkExecutionSystemLogin ( getExecutionSystem ( ) ) ; checkExecutionSystemStorage ( getExecutionSystem ( ) ) ; /* **************************************************************************
		 **						Verifying Input Parmaeters						  **
		 ***************************************************************************/ getInputProcessor ( ) . process ( jobRequestMap ) ; ObjectNode jobInputs = getInputProcessor ( ) . getJobInputs ( ) ; /* **************************************************************************
		 **						Verifying  Parameters							  **
		 ***************************************************************************/ getParameterProcessor ( ) . process ( jobRequestMap ) ; ObjectNode jobParameters = getParameterProcessor ( ) . getJobParameters ( ) ; /* **************************************************************************
         **                 Create and assign job data                            **
         ***************************************************************************/ try { job . setName ( name ) ; job . setOwner ( getUsername ( ) ) ; job . setSoftwareName ( getSoftware ( ) . getUniqueName ( ) ) ; job . setInternalUsername ( getInternalUsername ( ) ) ; job . setSystem ( getSoftware ( ) . getExecutionSystem ( ) . getSystemId ( ) ) ; job . setSchedulerType ( getSoftware ( ) . getExecutionSystem ( ) . getScheduler ( ) ) ; job . setExecutionType ( getSoftware ( ) . getExecutionType ( ) ) ; job . setBatchQueue ( jobQueue . getName ( ) ) ; job . setNodeCount ( nodeCount ) ; job . setProcessorsPerNode ( processorsPerNode ) ; job . setMemoryPerNode ( memoryPerNode ) ; job . setMaxRunTime ( requestedTime ) ; job . setInputsAsJsonObject ( jobInputs ) ; job . setParametersAsJsonObject ( jobParameters ) ; job . setSubmitTime ( new DateTime ( ) . toDate ( ) ) ; } catch ( JobException e ) { throw new JobProcessingException ( 500 , e . getMessage ( ) , e ) ; } /* **************************************************************************
		 **						End Batch Queue Selection 						  **
		 ***************************************************************************/ /* **************************************************************************
		 **						Verifying optional notifications				  **
		 ***************************************************************************/ processCallbackUrlRequest ( jobRequestMap , job ) ; /* **************************************************************************
		 **						Verifying archive configuration					  **
		 ***************************************************************************/ boolean archiveOutput = processArchiveOutputRequest ( jobRequestMap ) ; job . setArchiveOutput ( archiveOutput ) ; RemoteSystem archiveSystem = processArchiveSystemRequest ( archiveOutput , jobRequestMap ) ; job . setArchiveSystem ( archiveSystem ) ; String archivePath = processArchivePath ( archiveOutput , jobRequestMap , archiveSystem , job ) ; try { job . setArchivePath ( archivePath ) ; DateTime created = new DateTime ( ) ; job . setCreated ( created . toDate ( ) ) ; JobDao . persist ( job ) ; job . setCreated ( created . toDate ( ) ) ; job . setStatus ( JobStatusType . PENDING , JobStatusType . PENDING . getDescription ( ) ) ; JobDao . persist ( job ) ; return job ; } catch ( Throwable e ) { throw new JobProcessingException ( 500 , "Failed to submit the request to the job queue." , e ) ; } }
Takes a Form representing a job request and parses it into a job object.
Takes a Form representing a job request and parses it into a job object .
// validate the user gave a valid job name // validate the user gave a valid software description // validate the optional execution system matches the software execution system // we pass the queue processor the job request and let it validate the resource request and handle // queue selection. If no queue can be matched with the request, a NoMatchingBatchQueueException // exception will be thrown. If a queue was matched, we can use the matching BatchQueue in our job // and get the final, resolved resource requests from the queue processor. // node count defaults to 1 if not specified in the request, so no need to null check here. // processors per node defaults to 1 if not specified in the request, so no need to null check here. // memory can be omitted from the request and software. If so, then we assign the max memory per node of // for the queue to be safe. // requeted time can be ommitted from the request and software. If so, then we assign the max runtime of // the queue to be safe. // Verify the inputs by their keys given in the SoftwareInputs // in the Software object.  // create a job object // determine whether the user wanted to archiving the output // find the archive system  // process the path now that we have all the info to resolve runtime job macros used // in a user-supplied archive path. // persisting the job makes it available to the job queue // for submission