Search in sources :

Example 11 with JobExecutionData

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

the class JdbcJobRepository method listExecutions.

// @Override
// @JdbcTransaction
// public void recordJob(PlatformLayerKey jobId, PlatformLayerKey itemKey, JobState jobState, JobLog jobLog)
// throws RepositoryException {
// DbHelper db = new DbHelper();
// try {
// String data;
// 
// // TODO: More compact encoding?? XML InfoSet? GZIP?
// try {
// data = JaxbHelper.toXml(jobLog, false);
// } catch (JAXBException e) {
// throw new RepositoryException("Error serializing job log", e);
// }
// 
// int updateCount = db.insertJobLog(itemKey.getServiceType(), itemKey.getItemType(), itemKey.getProject(),
// itemKey.getItemId(), jobState, data);
// 
// if (updateCount != 1) {
// throw new IllegalStateException("Unexpected number of rows inserted");
// }
// } catch (SQLException e) {
// throw new RepositoryException("Error saving job log", e);
// } finally {
// db.close();
// }
// }
@Override
@JdbcTransaction
public List<JobExecutionData> listExecutions(PlatformLayerKey jobKey) throws RepositoryException {
    DbHelper db = new DbHelper();
    try {
        ProjectId projectId = jobKey.getProject();
        String jobId = jobKey.getItemIdString();
        List<JobExecutionEntity> executions = db.queries.listExecutions(db.mapToValue(projectId), jobId);
        List<JobExecutionData> ret = Lists.newArrayList();
        for (JobExecutionEntity execution : executions) {
            ret.add(mapFromEntity(execution, jobKey));
        }
        sort(ret);
        return ret;
    } catch (SQLException e) {
        throw new RepositoryException("Error listing job executions", e);
    } finally {
        db.close();
    }
}
Also used : JobExecutionData(org.platformlayer.jobs.model.JobExecutionData) SQLException(java.sql.SQLException) ProjectId(org.platformlayer.ids.ProjectId) RepositoryException(org.platformlayer.RepositoryException) JdbcTransaction(com.fathomdb.jdbc.JdbcTransaction)

Example 12 with JobExecutionData

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

the class JdbcJobRepository method mapFromEntity.

private JobExecutionData mapFromEntity(JobExecutionEntity execution, PlatformLayerKey jobKey) {
    JobExecutionData data = new JobExecutionData();
    data.executionId = execution.executionId;
    data.endedAt = execution.endedAt;
    data.startedAt = execution.startedAt;
    data.state = execution.state;
    data.executionId = execution.executionId;
    data.jobKey = jobKey;
    data.logCookie = execution.logCookie;
    return data;
}
Also used : JobExecutionData(org.platformlayer.jobs.model.JobExecutionData)

Aggregations

JobExecutionData (org.platformlayer.jobs.model.JobExecutionData)12 JobExecutionList (org.platformlayer.jobs.model.JobExecutionList)5 JobLog (org.platformlayer.jobs.model.JobLog)3 OpsException (org.platformlayer.ops.OpsException)3 IOException (java.io.IOException)2 Date (java.util.Date)2 PlatformLayerClient (org.platformlayer.PlatformLayerClient)2 RepositoryException (org.platformlayer.RepositoryException)2 JobData (org.platformlayer.jobs.model.JobData)2 JobLogLine (org.platformlayer.jobs.model.JobLogLine)2 JobState (org.platformlayer.jobs.model.JobState)2 CliException (com.fathomdb.cli.CliException)1 Ansi (com.fathomdb.cli.commands.Ansi)1 JdbcTransaction (com.fathomdb.jdbc.JdbcTransaction)1 PrintWriter (java.io.PrintWriter)1 SQLException (java.sql.SQLException)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 PlatformLayerClientNotFoundException (org.platformlayer.PlatformLayerClientNotFoundException)1