Search in sources :

Example 6 with JobExecutionList

use of org.platformlayer.jobs.model.JobExecutionList in project platformlayer by platformlayer.

the class ListJobExecutions method runCommand.

@Override
public Object runCommand() throws PlatformLayerClientException {
    PlatformLayerClient client = getPlatformLayerClient();
    JobExecutionList runs;
    if (jobId == null) {
        runs = client.listJobExecutions();
    } else {
        runs = client.listJobExecutions(jobId);
    }
    return runs;
}
Also used : PlatformLayerClient(org.platformlayer.PlatformLayerClient) JobExecutionList(org.platformlayer.jobs.model.JobExecutionList)

Example 7 with JobExecutionList

use of org.platformlayer.jobs.model.JobExecutionList in project platformlayer by platformlayer.

the class ListJobExecutions method formatRaw.

@Override
public void formatRaw(Object o, PrintWriter writer) {
    JobExecutionList jobs = (JobExecutionList) o;
    switch(getFormat()) {
        case JSON:
            JsonHelper<JobExecutionList> jsonHelper = JsonHelper.build(JobExecutionList.class);
            boolean formatted = true;
            try {
                String json = jsonHelper.marshal(jobs, formatted);
                writer.println(json);
                return;
            } catch (IOException e) {
                throw new CliException("Error formatting for output", e);
            }
    }
    Ansi ansi = new Ansi(writer);
    for (JobExecutionData job : jobs) {
        JobState state = job.state;
        if (state != null) {
            switch(job.state) {
                case FAILED:
                    ansi.setColorRed();
                    break;
                case SUCCESS:
                    ansi.setColorGreen();
                    break;
                case RUNNING:
                    ansi.setColorBlue();
                    break;
                default:
                    ansi.setColorBlue();
                    break;
            }
        } else {
            ansi.setColorBlue();
        }
        writer.println(job.getJobId() + "/" + job.executionId);
    }
    ansi.reset();
}
Also used : CliException(com.fathomdb.cli.CliException) JobExecutionData(org.platformlayer.jobs.model.JobExecutionData) JobState(org.platformlayer.jobs.model.JobState) IOException(java.io.IOException) JobExecutionList(org.platformlayer.jobs.model.JobExecutionList) Ansi(com.fathomdb.cli.commands.Ansi)

Example 8 with JobExecutionList

use of org.platformlayer.jobs.model.JobExecutionList in project platformlayer by platformlayer.

the class JobResource method getRuns.

@GET
@Path("runs")
@Produces({ XML, JSON })
public JobExecutionList getRuns() throws OpsException {
    List<JobExecutionData> jobList = jobRegistry.listExecutions(job.getJobKey());
    JobExecutionList runs = JobExecutionList.create(jobList);
    return runs;
}
Also used : JobExecutionData(org.platformlayer.jobs.model.JobExecutionData) JobExecutionList(org.platformlayer.jobs.model.JobExecutionList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 9 with JobExecutionList

use of org.platformlayer.jobs.model.JobExecutionList in project platformlayer by platformlayer.

the class JobsCollectionResource method getExecutions.

@GET
@Path("runs")
@Produces({ XML, JSON })
public JobExecutionList getExecutions() throws OpsException {
    JobQuery jobQuery = JobQuery.build(getProject(), filterTarget);
    JobExecutionList executions = jobRegistry.listRecentExecutions(jobQuery);
    return executions;
}
Also used : JobQuery(org.platformlayer.ops.tasks.JobQuery) JobExecutionList(org.platformlayer.jobs.model.JobExecutionList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

JobExecutionList (org.platformlayer.jobs.model.JobExecutionList)9 JobExecutionData (org.platformlayer.jobs.model.JobExecutionData)5 PlatformLayerClient (org.platformlayer.PlatformLayerClient)3 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 JobLog (org.platformlayer.jobs.model.JobLog)2 JobState (org.platformlayer.jobs.model.JobState)2 CliException (com.fathomdb.cli.CliException)1 Ansi (com.fathomdb.cli.commands.Ansi)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 PlatformLayerClientNotFoundException (org.platformlayer.PlatformLayerClientNotFoundException)1 TypedPlatformLayerClient (org.platformlayer.TypedPlatformLayerClient)1 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)1 JobData (org.platformlayer.jobs.model.JobData)1 JobLogLine (org.platformlayer.jobs.model.JobLogLine)1 OpsException (org.platformlayer.ops.OpsException)1 JobQuery (org.platformlayer.ops.tasks.JobQuery)1