Search in sources :

Example 1 with TCCLObjectInputStream

use of com.ibm.jbatch.container.util.TCCLObjectInputStream in project Payara by payara.

the class JBatchJDBCPersistenceManager method getStepExecutionsForJobExecution.

@Override
public List<StepExecution> getStepExecutionsForJobExecution(long execid) {
    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;
    List<StepExecution> data = new ArrayList<StepExecution>();
    try {
        conn = getConnection();
        statement = conn.prepareStatement(queryStrings.get(STEP_EXECUTIONS_FOR_JOB_EXECUTION));
        statement.setLong(1, execid);
        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("BatchStatus: " + batchstatus + " | StepName: " + stepname + " | JobExecID: " + jobexecid + " | StepExecID: " + stepexecid);
            data.add(stepEx);
        }
    } 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 data;
}
Also used : Serializable(java.io.Serializable) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) IOException(java.io.IOException) Timestamp(java.sql.Timestamp) StepExecution(javax.batch.runtime.StepExecution) 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)

Example 2 with TCCLObjectInputStream

use of com.ibm.jbatch.container.util.TCCLObjectInputStream in project Payara by payara.

the class JBatchJDBCPersistenceManager method getMostRecentStepExecutionsForJobInstance.

public Map<String, StepExecution> getMostRecentStepExecutionsForJobInstance(long instanceId) {
    Map<String, StepExecution> data = new HashMap<String, StepExecution>();
    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(MOST_RECENT_STEPS_FOR_JOB));
        statement.setLong(1, instanceId);
        rs = statement.executeQuery();
        while (rs.next()) {
            stepname = rs.getString("stepname");
            if (data.containsKey(stepname)) {
                continue;
            } else {
                jobexecid = rs.getLong("jobexecid");
                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);
                data.put(stepname, stepEx);
            }
        }
    } 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 data;
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) SQLException(java.sql.SQLException) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) IOException(java.io.IOException) StepExecution(javax.batch.runtime.StepExecution) 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)

Example 3 with TCCLObjectInputStream

use of com.ibm.jbatch.container.util.TCCLObjectInputStream 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

BatchContainerServiceException (com.ibm.jbatch.container.exception.BatchContainerServiceException)3 PersistenceException (com.ibm.jbatch.container.exception.PersistenceException)3 StepExecutionImpl (com.ibm.jbatch.container.jobinstance.StepExecutionImpl)3 TCCLObjectInputStream (com.ibm.jbatch.container.util.TCCLObjectInputStream)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 IOException (java.io.IOException)3 ObjectInputStream (java.io.ObjectInputStream)3 Serializable (java.io.Serializable)3 Connection (java.sql.Connection)3 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 Timestamp (java.sql.Timestamp)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