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;
}
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;
}
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;
}
Aggregations