Search in sources :

Example 1 with JobConfiguration

use of org.apache.airavata.cloud.aurora.client.sdk.JobConfiguration in project airavata by apache.

the class AuroraThriftClientUtil method getAuroraJobConfig.

/**
 * Gets the aurora job config.
 *
 * @param jobConfigBean the job config bean
 * @return the aurora job config
 * @throws Exception the exception
 */
public static JobConfiguration getAuroraJobConfig(JobConfigBean jobConfigBean) throws Exception {
    JobConfiguration jobConfig = null;
    try {
        if (jobConfigBean != null && jobConfigBean.getTaskConfig() != null) {
            JobKey jobKey = getAuroraJobKey(jobConfigBean.getJob());
            Identity owner = getAuroraIdentity(jobConfigBean.getOwner());
            // Construct the task config
            TaskConfig taskConfig = new TaskConfig();
            taskConfig.setJob(jobKey);
            taskConfig.setOwner(owner);
            taskConfig.setIsService(jobConfigBean.isService());
            taskConfig.setNumCpus(jobConfigBean.getTaskConfig().getResources().getNumCpus());
            taskConfig.setRamMb(jobConfigBean.getTaskConfig().getResources().getRamMb());
            taskConfig.setDiskMb(jobConfigBean.getTaskConfig().getResources().getDiskMb());
            taskConfig.setPriority(jobConfigBean.getPriority());
            taskConfig.setMaxTaskFailures(jobConfigBean.getMaxTaskFailures());
            taskConfig.setResources(getResourceSet(jobConfigBean.getTaskConfig().getResources()));
            // construct the executor config for this job
            taskConfig.setExecutorConfig(getExecutorConfig(getExecutorConfigJson(jobConfigBean)));
            // construct the job configuration
            jobConfig = new JobConfiguration(jobKey, owner, null, taskConfig, jobConfigBean.getInstances());
        } else {
            throw new Exception("JobConfig, TaskConfig Bean is/are NULL!");
        }
    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
        throw ex;
    }
    return jobConfig;
}
Also used : JobKey(org.apache.airavata.cloud.aurora.client.sdk.JobKey) TaskConfig(org.apache.airavata.cloud.aurora.client.sdk.TaskConfig) Identity(org.apache.airavata.cloud.aurora.client.sdk.Identity) JobConfiguration(org.apache.airavata.cloud.aurora.client.sdk.JobConfiguration)

Example 2 with JobConfiguration

use of org.apache.airavata.cloud.aurora.client.sdk.JobConfiguration in project airavata by apache.

the class AuroraThriftClient method createJob.

/**
 * Creates the job.
 *
 * @param jobConfigBean the job config bean
 * @return the response bean
 * @throws Exception the exception
 */
public ResponseBean createJob(JobConfigBean jobConfigBean) throws Exception {
    ResponseBean response = null;
    // try till we get response or scheduler connection not found
    while (response == null) {
        try {
            if (jobConfigBean != null) {
                JobConfiguration jobConfig = AuroraThriftClientUtil.getAuroraJobConfig(jobConfigBean);
                Response createJobResponse = this.auroraSchedulerManagerClient.createJob(jobConfig);
                response = AuroraThriftClientUtil.getResponseBean(createJobResponse, ResponseResultType.CREATE_JOB);
            }
        } catch (Exception ex) {
            if (ex instanceof TTransportException) {
                // if re-connection success, retry command
                if (this.reconnectWithAuroraScheduler()) {
                    continue;
                }
            }
            logger.error(ex.getMessage(), ex);
            throw ex;
        }
    }
    return response;
}
Also used : Response(org.apache.airavata.cloud.aurora.client.sdk.Response) TTransportException(org.apache.thrift.transport.TTransportException) ResponseBean(org.apache.airavata.cloud.aurora.client.bean.ResponseBean) JobDetailsResponseBean(org.apache.airavata.cloud.aurora.client.bean.JobDetailsResponseBean) GetJobsResponseBean(org.apache.airavata.cloud.aurora.client.bean.GetJobsResponseBean) JobConfiguration(org.apache.airavata.cloud.aurora.client.sdk.JobConfiguration) TTransportException(org.apache.thrift.transport.TTransportException)

Aggregations

JobConfiguration (org.apache.airavata.cloud.aurora.client.sdk.JobConfiguration)2 GetJobsResponseBean (org.apache.airavata.cloud.aurora.client.bean.GetJobsResponseBean)1 JobDetailsResponseBean (org.apache.airavata.cloud.aurora.client.bean.JobDetailsResponseBean)1 ResponseBean (org.apache.airavata.cloud.aurora.client.bean.ResponseBean)1 Identity (org.apache.airavata.cloud.aurora.client.sdk.Identity)1 JobKey (org.apache.airavata.cloud.aurora.client.sdk.JobKey)1 Response (org.apache.airavata.cloud.aurora.client.sdk.Response)1 TaskConfig (org.apache.airavata.cloud.aurora.client.sdk.TaskConfig)1 TTransportException (org.apache.thrift.transport.TTransportException)1