Search in sources :

Example 6 with ResponseBean

use of org.apache.airavata.cloud.aurora.client.bean.ResponseBean 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 7 with ResponseBean

use of org.apache.airavata.cloud.aurora.client.bean.ResponseBean 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)

Example 8 with ResponseBean

use of org.apache.airavata.cloud.aurora.client.bean.ResponseBean in project airavata by apache.

the class AuroraThriftClientUtil method getJobResponse.

/**
 * Gets the job response.
 *
 * @param response the response
 * @return the job response
 */
private static ResponseBean getJobResponse(Response response) {
    ResponseBean responseBean = null;
    if (response != null) {
        responseBean = new ResponseBean();
        responseBean.setResponseCode(ResponseCodeEnum.findByValue(response.getResponseCode().getValue()));
        ServerInfoBean serverInfo = new ServerInfoBean(response.getServerInfo().getClusterName(), response.getServerInfo().getStatsUrlPrefix());
        responseBean.setServerInfo(serverInfo);
    }
    return responseBean;
}
Also used : ServerInfoBean(org.apache.airavata.cloud.aurora.client.bean.ServerInfoBean) JobDetailsResponseBean(org.apache.airavata.cloud.aurora.client.bean.JobDetailsResponseBean) GetJobsResponseBean(org.apache.airavata.cloud.aurora.client.bean.GetJobsResponseBean) ResponseBean(org.apache.airavata.cloud.aurora.client.bean.ResponseBean)

Aggregations

ResponseBean (org.apache.airavata.cloud.aurora.client.bean.ResponseBean)8 GetJobsResponseBean (org.apache.airavata.cloud.aurora.client.bean.GetJobsResponseBean)7 AuroraThriftClient (org.apache.airavata.cloud.aurora.client.AuroraThriftClient)5 JobKeyBean (org.apache.airavata.cloud.aurora.client.bean.JobKeyBean)5 IdentityBean (org.apache.airavata.cloud.aurora.client.bean.IdentityBean)4 JobConfigBean (org.apache.airavata.cloud.aurora.client.bean.JobConfigBean)4 ProcessBean (org.apache.airavata.cloud.aurora.client.bean.ProcessBean)4 TaskConfigBean (org.apache.airavata.cloud.aurora.client.bean.TaskConfigBean)4 LinkedHashSet (java.util.LinkedHashSet)3 JobDetailsResponseBean (org.apache.airavata.cloud.aurora.client.bean.JobDetailsResponseBean)3 ResourceBean (org.apache.airavata.cloud.aurora.client.bean.ResourceBean)3 Response (org.apache.airavata.cloud.aurora.client.sdk.Response)2 TTransportException (org.apache.thrift.transport.TTransportException)2 HashSet (java.util.HashSet)1 ServerInfoBean (org.apache.airavata.cloud.aurora.client.bean.ServerInfoBean)1 JobConfiguration (org.apache.airavata.cloud.aurora.client.sdk.JobConfiguration)1 JobKey (org.apache.airavata.cloud.aurora.client.sdk.JobKey)1 GFacException (org.apache.airavata.gfac.core.GFacException)1 GroovyMap (org.apache.airavata.gfac.core.GroovyMap)1 ProcessContext (org.apache.airavata.gfac.core.context.ProcessContext)1