Search in sources :

Example 1 with Response

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

the class AuroraThriftClient method getJobList.

/**
 * Gets the job list.
 *
 * @param ownerRole the owner role
 * @return the job list
 * @throws Exception the exception
 */
public GetJobsResponseBean getJobList(String ownerRole) throws Exception {
    GetJobsResponseBean response = null;
    // try till we get response or scheduler connection not found
    while (response == null) {
        try {
            Response jobListResponse = this.readOnlySchedulerClient.getJobs(ownerRole);
            response = (GetJobsResponseBean) AuroraThriftClientUtil.getResponseBean(jobListResponse, ResponseResultType.GET_JOBS);
        } 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) GetJobsResponseBean(org.apache.airavata.cloud.aurora.client.bean.GetJobsResponseBean) TTransportException(org.apache.thrift.transport.TTransportException) TTransportException(org.apache.thrift.transport.TTransportException)

Example 2 with Response

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

the class AuroraThriftClient method killTasks.

/**
 * Kill tasks.
 *
 * @param jobKeyBean the job key bean
 * @param instances the instances
 * @return the response bean
 * @throws Exception the exception
 */
public ResponseBean killTasks(JobKeyBean jobKeyBean, Set<Integer> instances) throws Exception {
    ResponseBean response = null;
    // try till we get response or scheduler connection not found
    while (response == null) {
        try {
            if (jobKeyBean != null) {
                JobKey jobKey = AuroraThriftClientUtil.getAuroraJobKey(jobKeyBean);
                Response killTaskResponse = this.auroraSchedulerManagerClient.killTasks(jobKey, instances);
                response = AuroraThriftClientUtil.getResponseBean(killTaskResponse, ResponseResultType.KILL_TASKS);
            }
        } 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) JobKey(org.apache.airavata.cloud.aurora.client.sdk.JobKey) 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) TTransportException(org.apache.thrift.transport.TTransportException)

Example 3 with Response

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

the class AuroraThriftClient method getJobDetails.

/**
 * Gets the job details.
 *
 * @param jobKeyBean the job key bean
 * @return the job details
 * @throws Exception the exception
 */
public JobDetailsResponseBean getJobDetails(JobKeyBean jobKeyBean) throws Exception {
    JobDetailsResponseBean response = null;
    // try till we get response or scheduler connection not found
    while (response == null) {
        try {
            if (jobKeyBean != null) {
                JobKey jobKey = AuroraThriftClientUtil.getAuroraJobKey(jobKeyBean);
                Set<JobKey> jobKeySet = new HashSet<>();
                jobKeySet.add(jobKey);
                TaskQuery query = new TaskQuery();
                query.setJobKeys(jobKeySet);
                Response jobDetailsResponse = this.readOnlySchedulerClient.getTasksStatus(query);
                response = (JobDetailsResponseBean) AuroraThriftClientUtil.getResponseBean(jobDetailsResponse, ResponseResultType.GET_JOB_DETAILS);
            }
        } 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) JobKey(org.apache.airavata.cloud.aurora.client.sdk.JobKey) JobDetailsResponseBean(org.apache.airavata.cloud.aurora.client.bean.JobDetailsResponseBean) TaskQuery(org.apache.airavata.cloud.aurora.client.sdk.TaskQuery) TTransportException(org.apache.thrift.transport.TTransportException) TTransportException(org.apache.thrift.transport.TTransportException) HashSet(java.util.HashSet)

Example 4 with Response

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

the class AuroraThriftClient method getPendingReasonForJob.

/**
 * Gets the pending reason for job.
 *
 * @param jobKeyBean the job key bean
 * @return the pending reason for job
 * @throws Exception the exception
 */
public PendingJobReasonBean getPendingReasonForJob(JobKeyBean jobKeyBean) throws Exception {
    PendingJobReasonBean response = null;
    // try till we get response or scheduler connection not found
    while (response == null) {
        try {
            JobKey jobKey = AuroraThriftClientUtil.getAuroraJobKey(jobKeyBean);
            Set<JobKey> jobKeySet = new HashSet<>();
            jobKeySet.add(jobKey);
            TaskQuery query = new TaskQuery();
            query.setJobKeys(jobKeySet);
            Response pendingReasonResponse = this.readOnlySchedulerClient.getPendingReason(query);
            response = (PendingJobReasonBean) AuroraThriftClientUtil.getResponseBean(pendingReasonResponse, ResponseResultType.GET_PENDING_JOB_REASON);
        } 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) JobKey(org.apache.airavata.cloud.aurora.client.sdk.JobKey) PendingJobReasonBean(org.apache.airavata.cloud.aurora.client.bean.PendingJobReasonBean) TaskQuery(org.apache.airavata.cloud.aurora.client.sdk.TaskQuery) TTransportException(org.apache.thrift.transport.TTransportException) TTransportException(org.apache.thrift.transport.TTransportException) HashSet(java.util.HashSet)

Example 5 with Response

use of org.apache.airavata.cloud.aurora.client.sdk.Response 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

Response (org.apache.airavata.cloud.aurora.client.sdk.Response)5 TTransportException (org.apache.thrift.transport.TTransportException)5 GetJobsResponseBean (org.apache.airavata.cloud.aurora.client.bean.GetJobsResponseBean)3 JobDetailsResponseBean (org.apache.airavata.cloud.aurora.client.bean.JobDetailsResponseBean)3 JobKey (org.apache.airavata.cloud.aurora.client.sdk.JobKey)3 HashSet (java.util.HashSet)2 ResponseBean (org.apache.airavata.cloud.aurora.client.bean.ResponseBean)2 TaskQuery (org.apache.airavata.cloud.aurora.client.sdk.TaskQuery)2 PendingJobReasonBean (org.apache.airavata.cloud.aurora.client.bean.PendingJobReasonBean)1 JobConfiguration (org.apache.airavata.cloud.aurora.client.sdk.JobConfiguration)1