use of org.pentaho.di.trans.steps.mappinginput.MappingInputData in project pentaho-kettle by pentaho.
the class SingleThreader method prepareMappingExecution.
public void prepareMappingExecution() throws KettleException {
SingleThreaderData singleThreaderData = getData();
// Set the type to single threaded in case the user forgot...
//
singleThreaderData.mappingTransMeta.setTransformationType(TransformationType.SingleThreaded);
// Create the transformation from meta-data...
singleThreaderData.mappingTrans = new Trans(singleThreaderData.mappingTransMeta, getTrans());
// Pass the parameters down to the sub-transformation.
//
StepWithMappingMeta.activateParams(getData().mappingTrans, getData().mappingTrans, this, getData().mappingTrans.listParameters(), meta.getParameters(), meta.getParameterValues(), meta.isPassingAllParameters());
getData().mappingTrans.activateParameters();
// Disable thread priority managment as it will slow things down needlessly.
// The single threaded engine doesn't use threads and doesn't need row locking.
//
singleThreaderData.mappingTrans.getTransMeta().setUsingThreadPriorityManagment(false);
// Leave a path up so that we can set variables in sub-transformations...
//
singleThreaderData.mappingTrans.setParentTrans(getTrans());
// Pass down the safe mode flag to the mapping...
//
singleThreaderData.mappingTrans.setSafeModeEnabled(getTrans().isSafeModeEnabled());
// Pass down the metrics gathering flag to the mapping...
//
singleThreaderData.mappingTrans.setGatheringMetrics(getTrans().isGatheringMetrics());
// Also set the name of this step in the mapping transformation for logging purposes
//
singleThreaderData.mappingTrans.setMappingStepName(getStepname());
initServletConfig();
// prepare the execution
//
singleThreaderData.mappingTrans.prepareExecution(null);
//
if (singleThreaderData.injectStepMeta.isMappingInput()) {
MappingInputData mappingInputData = (MappingInputData) singleThreaderData.mappingTrans.findDataInterface(singleThreaderData.injectStepMeta.getName());
mappingInputData.sourceSteps = new StepInterface[0];
mappingInputData.valueRenames = new ArrayList<MappingValueRename>();
}
// Add row producer & row listener
singleThreaderData.rowProducer = singleThreaderData.mappingTrans.addRowProducer(meta.getInjectStep(), 0);
StepInterface retrieveStep = singleThreaderData.mappingTrans.getStepInterface(meta.getRetrieveStep(), 0);
retrieveStep.addRowListener(new RowAdapter() {
@Override
public void rowWrittenEvent(RowMetaInterface rowMeta, Object[] row) throws KettleStepException {
// Simply pass it along to the next steps after the SingleThreader
//
SingleThreader.this.putRow(rowMeta, row);
}
});
singleThreaderData.mappingTrans.startThreads();
// Create the executor...
singleThreaderData.executor = new SingleThreadedTransExecutor(singleThreaderData.mappingTrans);
//
try {
boolean ok = singleThreaderData.executor.init();
if (!ok) {
throw new KettleException(BaseMessages.getString(PKG, "SingleThreader.Exception.UnableToInitSingleThreadedTransformation"));
}
} catch (KettleException e) {
throw new KettleException(BaseMessages.getString(PKG, "SingleThreader.Exception.UnableToPrepareExecutionOfMapping"), e);
}
// Add the mapping transformation to the active sub-transformations map in the parent transformation
//
getTrans().addActiveSubTransformation(getStepname(), singleThreaderData.mappingTrans);
}
Aggregations