public static ItemWriterProxy createItemWriterProxy(String id, InjectionReferences injectionRefs, StepContextImpl stepContext) throws ArtifactValidationException { ItemWriter loadedArtifact = (ItemWriter)loadArtifact(id, injectionRefs); ItemWriterProxy proxy = new ItemWriterProxy(loadedArtifact); proxy.setStepContext(stepContext); return proxy; }
private void callReaderAndWriterCloseOnThrowable(Throwable t) { logger.fine("Caught throwable in chunk processing. Attempting to close all readers and writers."); try { writerProxy.close(); } catch (Throwable t1) { // FFDC } try { readerProxy.close(); } catch (Throwable t1) { // FFDC } }
private void positionWriterAtCheckpoint() { CheckpointData checkpointData = getStepThreadInstance().getCheckpointData(); // check for data in backing store if (checkpointData != null) { Serializable checkpointInfo = checkpointData.getWriterCheckpoint(); writerProxy.open(checkpointInfo); } else { // An entry always should have been inserted by now, even if it wrappers a null value returned by checkpointInfo() String msg = "Didn't find checkpoint data for key = " + getStepThreadInstance(); throw new IllegalStateException(msg); } }
writerOOS.writeObject(writerProxy.checkpointInfo()); writerOOS.close(); CheckpointData writerChkptData = new CheckpointData(jobInstanceID, stepId, "WRITER");
writerProxy.writeItems(theChunk);
writerOOS.writeObject(writerProxy.checkpointInfo()); writerOOS.close(); CheckpointData writerChkptData = new CheckpointData(jobInstanceID, stepId, "WRITER");
writerProxy.writeItems(theChunk);
public static ItemWriterProxy createItemWriterProxy(String id, InjectionReferences injectionRefs, RuntimeStepExecution stepContext) throws ArtifactValidationException { ItemWriter loadedArtifact = (ItemWriter)loadArtifact(id, injectionRefs); ItemWriterProxy proxy = new ItemWriterProxy(loadedArtifact); proxy.setStepContext(stepContext); return proxy; }
private void callReaderAndWriterCloseOnThrowable(Throwable t) { logger.fine("Caught throwable in chunk processing. Attempting to close all readers and writers."); try { writerProxy.close(); } catch (Throwable t1) { logWarning("Secondary throwable closing writer on rollback path. Swallow throwable and continue with rollback.", t1); } try { readerProxy.close(); } catch (Throwable t1) { logWarning("Secondary throwable closing reader on rollback path. Swallow throwable and continue to close writer.", t1); } }
private void positionWriterAtCheckpoint() { _persistenceManagerService = servicesManager.getPersistenceManagerService(); writerChkptDK = new CheckpointDataKey(jobExecutionImpl.getJobInstance().getInstanceId(), step.getId(), "WRITER"); CheckpointData writerData = _persistenceManagerService.getCheckpointData(writerChkptDK); try { // check for data in backing store if (writerData != null) { byte[] writertoken = writerData.getRestartToken(); ByteArrayInputStream writerChkptBA = new ByteArrayInputStream(writertoken); TCCLObjectInputStream writerOIS = null; try { writerOIS = new TCCLObjectInputStream(writerChkptBA); writerProxy.open((Serializable) writerOIS.readObject()); writerOIS.close(); } catch (Exception ex) { // is this what I should be throwing here? throw new BatchContainerServiceException("Cannot persist the checkpoint data for [" + step.getId() + "]", ex); } } else { // no chkpt data exists in the backing store writerData = null; writerProxy.open(null); } } catch (ClassCastException e) { throw new IllegalStateException("Expected CheckpointData but found" + writerData); } } }
public void checkpoint() { String method = "checkpoint"; if(logger.isLoggable(Level.FINER)) { logger.entering(sourceClass, method, " [executionId " + executionId + "] "); } CheckpointData data = null; try{ data = new CheckpointData(); data.setReaderCheckpoint(readerProxy.checkpointInfo()); data.setWriterCheckpoint(writerProxy.checkpointInfo()); stepThreadInstance.setCheckpointData(data); } catch (Exception ex){ throw new BatchContainerServiceException("Cannot persist the checkpoint data for " + stepThreadInstance); } if(logger.isLoggable(Level.FINER)) { logger.exiting(sourceClass, method, " [executionId " + executionId + "] ");} }
writerProxy.writeItems(theChunk);
public static ItemWriterProxy createItemWriterProxy(String id, InjectionReferences injectionRefs, StepContextImpl stepContext) throws ArtifactValidationException { ItemWriter loadedArtifact = (ItemWriter)loadArtifact(id, injectionRefs); ItemWriterProxy proxy = new ItemWriterProxy(loadedArtifact); proxy.setStepContext(stepContext); return proxy; }
private void rollbackAfterRetryableException() { writerProxy.close(); readerProxy.close(); callChunkListenerOnError(currentChunkStatus.getRetryableException()); transactionManager.rollback(); stepContext.getMetric(MetricImpl.MetricType.ROLLBACK_COUNT).incValue(); }
private void positionWriterAtCheckpoint() { _persistenceManagerService = servicesManager.getPersistenceManagerService(); writerChkptDK = new CheckpointDataKey(jobExecutionImpl.getJobInstance().getInstanceId(), step.getId(), "WRITER"); CheckpointData writerData = _persistenceManagerService.getCheckpointData(writerChkptDK); try { // check for data in backing store if (writerData != null) { byte[] writertoken = writerData.getRestartToken(); ByteArrayInputStream writerChkptBA = new ByteArrayInputStream(writertoken); TCCLObjectInputStream writerOIS = null; try { writerOIS = new TCCLObjectInputStream(writerChkptBA); writerProxy.open((Serializable) writerOIS.readObject()); writerOIS.close(); } catch (Exception ex) { // is this what I should be throwing here? throw new BatchContainerServiceException("Cannot persist the checkpoint data for [" + step.getId() + "]", ex); } } else { // no chkpt data exists in the backing store writerData = null; writerProxy.open(null); } } catch (ClassCastException e) { throw new IllegalStateException("Expected CheckpointData but found" + writerData); } } }
private void rollbackAfterRetryableException(int currentChunk) { JoblogUtil.logToJobLogAndTraceOnly(Level.FINE, "chunk.rollback.and.retry", new Object[] { runtimeStepExecution.getStepName(), getJobInstanceId(), getJobExecutionId(), runtimeStepExecution.getMetrics() }, logger); writerProxy.close(); readerProxy.close(); callChunkListenerOnError(currentChunkStatus.getRetryableException()); getTransactionManager().rollback(); runtimeStepExecution.getMetric(MetricImpl.MetricType.ROLLBACK_COUNT).incValue(); }
private void openReaderAndWriter() { String sourceMethod = "openReaderAndWriter"; if (logger.isLoggable(Level.FINE)) logger.entering(sourceClass, sourceMethod); CheckpointData checkpointData = getStepThreadInstance().getCheckpointData(); if (checkpointData != null) { Serializable readerChkpt = checkpointData.getReaderCheckpoint(); readerProxy.open(readerChkpt); Serializable writerChkpt = checkpointData.getWriterCheckpoint(); writerProxy.open(writerChkpt); } else { //Cannot have a null checkpointData if a rollback is to be performed try { checkpointData = new CheckpointData(); checkpointData.setReaderCheckpoint(null); checkpointData.setWriterCheckpoint(null); getStepThreadInstance().setCheckpointData(checkpointData); } catch (Exception ex) { throw new BatchContainerServiceException("Cannot persist the checkpoint data for " + getStepThreadInstance()); } // Null is a valid value to indicate there hasn't been a checkpoint yet. readerProxy.open(null); writerProxy.open(null); } if (logger.isLoggable(Level.FINE)) logger.exiting(sourceClass, sourceMethod); }
transactionManager.begin(); writerProxy.close(); readerProxy.close();