Search in sources :

Example 1 with PlatformLayerClientNotFoundException

use of org.platformlayer.PlatformLayerClientNotFoundException in project platformlayer by platformlayer.

the class GetJobLog method runCommand.

@Override
public Object runCommand() throws PlatformLayerClientException {
    PlatformLayerClient client = getPlatformLayerClient();
    if (jobId.contains("/") && executionId == null) {
        String[] tokens = jobId.split("/");
        if (tokens.length == 2) {
            jobId = tokens[0];
            executionId = tokens[1];
        }
    }
    List<JobLog> logs = Lists.newArrayList();
    if (Strings.isNullOrEmpty(executionId)) {
        JobExecutionList jobExecutions = client.listJobExecutions(jobId);
        List<JobExecutionData> runs = jobExecutions.getRuns();
        sort(runs);
        // TODO: Remove limit (or iterate)
        if (runs.size() > 10) {
            runs = Lists.newArrayList(runs.subList(runs.size() - 10, runs.size()));
        }
        // TODO: Fix 1+N slowness...
        for (JobExecutionData execution : runs) {
            if (execution.getState() == JobState.PRESTART) {
                continue;
            }
            String executionId = execution.getExecutionId();
            try {
                JobLog jobLog = client.getJobExecutionLog(jobId, executionId);
                logs.add(jobLog);
            } catch (PlatformLayerClientNotFoundException e) {
            // TODO: Warn?
            }
        }
    } else {
        JobLog jobLog = client.getJobExecutionLog(jobId, executionId);
        logs.add(jobLog);
    }
    return logs;
}
Also used : PlatformLayerClient(org.platformlayer.PlatformLayerClient) JobExecutionData(org.platformlayer.jobs.model.JobExecutionData) PlatformLayerClientNotFoundException(org.platformlayer.PlatformLayerClientNotFoundException) JobLog(org.platformlayer.jobs.model.JobLog) JobExecutionList(org.platformlayer.jobs.model.JobExecutionList)

Aggregations

PlatformLayerClient (org.platformlayer.PlatformLayerClient)1 PlatformLayerClientNotFoundException (org.platformlayer.PlatformLayerClientNotFoundException)1 JobExecutionData (org.platformlayer.jobs.model.JobExecutionData)1 JobExecutionList (org.platformlayer.jobs.model.JobExecutionList)1 JobLog (org.platformlayer.jobs.model.JobLog)1