Search in sources :

Example 1 with GetJobsResponseBean

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

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

the class AuroraClientSample method getRunningJobsList.

/**
 * Gets the job summary.
 *
 * @param client the client
 * @return the job summary
 * @throws Exception
 */
public static void getRunningJobsList(String ownerRole) throws Exception {
    try {
        AuroraThriftClient client = AuroraThriftClient.getAuroraThriftClient();
        ResponseBean response = client.getJobList(ownerRole);
        System.out.println("Response status: " + response.getResponseCode().name());
        if (response instanceof GetJobsResponseBean) {
            GetJobsResponseBean result = (GetJobsResponseBean) response;
            System.out.println(result);
            Set<JobConfigBean> jobConfigs = result.getJobConfigs();
            for (JobConfigBean jobConfig : jobConfigs) {
                System.out.println(jobConfig);
                JobKeyBean jobKey = jobConfig.getJob();
                IdentityBean owner = jobConfig.getOwner();
                TaskConfigBean taskConfig = jobConfig.getTaskConfig();
                Set<ProcessBean> processes = taskConfig.getProcesses();
                System.out.println("\n**** JOB CONFIG ****");
                System.out.println("\t # cluster: " + jobConfig.getCluster());
                System.out.println("\t # instanceCount: " + jobConfig.getInstances());
                System.out.println("\t # isService: " + jobConfig.isService());
                System.out.println("\t\t # priority: " + jobConfig.getPriority());
                System.out.println("\t >> Job Key <<");
                System.out.println("\t\t # name: " + jobKey.getName());
                System.out.println("\t\t # role: " + jobKey.getRole());
                System.out.println("\t\t # environment: " + jobKey.getEnvironment());
                System.out.println("\t >> Identity <<");
                System.out.println("\t\t # owner: " + owner.getUser());
                System.out.println("\t >> Task Config <<");
                System.out.println("\t\t >> Resources <<");
                System.out.println("\t\t\t # numCPUs: " + taskConfig.getResources().getNumCpus());
                System.out.println("\t\t\t # diskMb: " + taskConfig.getResources().getDiskMb());
                System.out.println("\t\t\t # ramMb: " + taskConfig.getResources().getRamMb());
                System.out.println("\t\t >> Processes <<");
                for (ProcessBean process : processes) {
                    System.out.println("\t\t\t ***** PROCESS *****");
                    System.out.println("\t\t\t # name: " + process.getName());
                    System.out.println("\t\t\t # cmdline: " + process.getCmdLine());
                }
            }
        }
    } catch (TException e) {
        e.printStackTrace();
    }
}
Also used : TException(org.apache.thrift.TException) JobConfigBean(org.apache.airavata.cloud.aurora.client.bean.JobConfigBean) GetJobsResponseBean(org.apache.airavata.cloud.aurora.client.bean.GetJobsResponseBean) ResponseBean(org.apache.airavata.cloud.aurora.client.bean.ResponseBean) GetJobsResponseBean(org.apache.airavata.cloud.aurora.client.bean.GetJobsResponseBean) ProcessBean(org.apache.airavata.cloud.aurora.client.bean.ProcessBean) AuroraThriftClient(org.apache.airavata.cloud.aurora.client.AuroraThriftClient) JobKeyBean(org.apache.airavata.cloud.aurora.client.bean.JobKeyBean) IdentityBean(org.apache.airavata.cloud.aurora.client.bean.IdentityBean) TaskConfigBean(org.apache.airavata.cloud.aurora.client.bean.TaskConfigBean)

Aggregations

GetJobsResponseBean (org.apache.airavata.cloud.aurora.client.bean.GetJobsResponseBean)2 AuroraThriftClient (org.apache.airavata.cloud.aurora.client.AuroraThriftClient)1 IdentityBean (org.apache.airavata.cloud.aurora.client.bean.IdentityBean)1 JobConfigBean (org.apache.airavata.cloud.aurora.client.bean.JobConfigBean)1 JobKeyBean (org.apache.airavata.cloud.aurora.client.bean.JobKeyBean)1 ProcessBean (org.apache.airavata.cloud.aurora.client.bean.ProcessBean)1 ResponseBean (org.apache.airavata.cloud.aurora.client.bean.ResponseBean)1 TaskConfigBean (org.apache.airavata.cloud.aurora.client.bean.TaskConfigBean)1 Response (org.apache.airavata.cloud.aurora.client.sdk.Response)1 TException (org.apache.thrift.TException)1 TTransportException (org.apache.thrift.transport.TTransportException)1