Search in sources :

Example 6 with StepExecutionImpl

use of com.ibm.jbatch.container.jobinstance.StepExecutionImpl in project Payara by payara.

the class JBatchJDBCPersistenceManager method getStepExecutionByStepExecutionId.

@Override
public StepExecution getStepExecutionByStepExecutionId(long stepExecId) {
    Connection conn = null;
    PreparedStatement statement = null;
    ResultSet rs = null;
    long jobexecid = 0;
    long stepexecid = 0;
    String stepname = null;
    String batchstatus = null;
    String exitstatus = null;
    Exception ex = null;
    long readCount = 0;
    long writeCount = 0;
    long commitCount = 0;
    long rollbackCount = 0;
    long readSkipCount = 0;
    long processSkipCount = 0;
    long filterCount = 0;
    long writeSkipCount = 0;
    Timestamp startTS = null;
    Timestamp endTS = null;
    StepExecutionImpl stepEx = null;
    ObjectInputStream objectIn = null;
    try {
        conn = getConnection();
        statement = conn.prepareStatement(queryStrings.get(STEP_EXECUTIONS_BY_STEP_ID));
        statement.setLong(1, stepExecId);
        rs = statement.executeQuery();
        while (rs.next()) {
            jobexecid = rs.getLong("jobexecid");
            stepexecid = rs.getLong("stepexecid");
            stepname = rs.getString("stepname");
            batchstatus = rs.getString("batchstatus");
            exitstatus = rs.getString("exitstatus");
            readCount = rs.getLong("readcount");
            writeCount = rs.getLong("writecount");
            commitCount = rs.getLong("commitcount");
            rollbackCount = rs.getLong("rollbackcount");
            readSkipCount = rs.getLong("readskipcount");
            processSkipCount = rs.getLong("processskipcount");
            filterCount = rs.getLong("filtercount");
            writeSkipCount = rs.getLong("writeSkipCount");
            startTS = rs.getTimestamp("startTime");
            endTS = rs.getTimestamp("endTime");
            // get the object based data
            Serializable persistentData = null;
            byte[] pDataBytes = rs.getBytes("persistentData");
            if (pDataBytes != null) {
                objectIn = new TCCLObjectInputStream(new ByteArrayInputStream(pDataBytes));
                persistentData = (Serializable) objectIn.readObject();
            }
            stepEx = new StepExecutionImpl(jobexecid, stepexecid);
            stepEx.setBatchStatus(BatchStatus.valueOf(batchstatus));
            stepEx.setExitStatus(exitstatus);
            stepEx.setStepName(stepname);
            stepEx.setReadCount(readCount);
            stepEx.setWriteCount(writeCount);
            stepEx.setCommitCount(commitCount);
            stepEx.setRollbackCount(rollbackCount);
            stepEx.setReadSkipCount(readSkipCount);
            stepEx.setProcessSkipCount(processSkipCount);
            stepEx.setFilterCount(filterCount);
            stepEx.setWriteSkipCount(writeSkipCount);
            stepEx.setStartTime(startTS);
            stepEx.setEndTime(endTS);
            stepEx.setPersistentUserData(persistentData);
            logger.fine("stepExecution BatchStatus: " + batchstatus + " StepName: " + stepname);
        }
    } catch (SQLException e) {
        throw new PersistenceException(e);
    } catch (IOException e) {
        throw new PersistenceException(e);
    } catch (ClassNotFoundException e) {
        throw new PersistenceException(e);
    } finally {
        cleanupConnection(conn, rs, statement);
    }
    return stepEx;
}
Also used : Serializable(java.io.Serializable) SQLException(java.sql.SQLException) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) IOException(java.io.IOException) Timestamp(java.sql.Timestamp) PersistenceException(com.ibm.jbatch.container.exception.PersistenceException) NamingException(javax.naming.NamingException) BatchContainerServiceException(com.ibm.jbatch.container.exception.BatchContainerServiceException) SQLException(java.sql.SQLException) IOException(java.io.IOException) NoSuchJobExecutionException(javax.batch.operations.NoSuchJobExecutionException) TCCLObjectInputStream(com.ibm.jbatch.container.util.TCCLObjectInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ResultSet(java.sql.ResultSet) StepExecutionImpl(com.ibm.jbatch.container.jobinstance.StepExecutionImpl) PersistenceException(com.ibm.jbatch.container.exception.PersistenceException) ObjectInputStream(java.io.ObjectInputStream) TCCLObjectInputStream(com.ibm.jbatch.container.util.TCCLObjectInputStream)

Aggregations

StepExecutionImpl (com.ibm.jbatch.container.jobinstance.StepExecutionImpl)6 PersistenceException (com.ibm.jbatch.container.exception.PersistenceException)5 IOException (java.io.IOException)5 Connection (java.sql.Connection)5 PreparedStatement (java.sql.PreparedStatement)5 ResultSet (java.sql.ResultSet)5 SQLException (java.sql.SQLException)5 Serializable (java.io.Serializable)4 Timestamp (java.sql.Timestamp)4 BatchContainerServiceException (com.ibm.jbatch.container.exception.BatchContainerServiceException)3 TCCLObjectInputStream (com.ibm.jbatch.container.util.TCCLObjectInputStream)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ObjectInputStream (java.io.ObjectInputStream)3 NoSuchJobExecutionException (javax.batch.operations.NoSuchJobExecutionException)3 NamingException (javax.naming.NamingException)3 StepExecution (javax.batch.runtime.StepExecution)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Metric (javax.batch.runtime.Metric)1