use of org.pentaho.di.trans.dataservice.execution.TransStarter in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceExecutor method prepareExecution.
protected void prepareExecution() throws KettleException {
// Setup executor with streaming execution plan
ImmutableMultimap.Builder<ExecutionPoint, Runnable> builder = ImmutableMultimap.builder();
builder.putAll(ExecutionPoint.PREPARE, new CopyParameters(parameters, serviceTrans), new PrepareExecution(serviceTrans));
if (!service.isStreaming()) {
builder.put(ExecutionPoint.PREPARE, new PrepareExecution(genTrans));
builder.putAll(ExecutionPoint.READY, new DefaultTransWiring(this));
builder.putAll(ExecutionPoint.START, new TransStarter(genTrans), new TransStarter(serviceTrans));
}
listenerMap.putAll(builder.build());
}
use of org.pentaho.di.trans.dataservice.execution.TransStarter in project pdi-dataservice-server-plugin by pentaho.
the class CachedServiceLoader method replay.
ListenableFuture<Integer> replay(DataServiceExecutor dataServiceExecutor) throws KettleException {
final Trans serviceTrans = dataServiceExecutor.getServiceTrans(), genTrans = dataServiceExecutor.getGenTrans();
final CountDownLatch startReplay = new CountDownLatch(1);
final RowProducer rowProducer = dataServiceExecutor.addRowProducer();
List<Runnable> startTrans = dataServiceExecutor.getListenerMap().get(DataServiceExecutor.ExecutionPoint.START), postOptimization = dataServiceExecutor.getListenerMap().get(DataServiceExecutor.ExecutionPoint.READY);
Iterables.removeIf(postOptimization, Predicates.instanceOf(DefaultTransWiring.class));
Iterables.removeIf(startTrans, new Predicate<Runnable>() {
@Override
public boolean apply(Runnable runnable) {
return runnable instanceof TransStarter && ((TransStarter) runnable).getTrans().equals(serviceTrans);
}
});
postOptimization.add(new Runnable() {
@Override
public void run() {
serviceTrans.stopAll();
for (StepMetaDataCombi stepMetaDataCombi : serviceTrans.getSteps()) {
stepMetaDataCombi.step.setOutputDone();
stepMetaDataCombi.step.dispose(stepMetaDataCombi.meta, stepMetaDataCombi.data);
stepMetaDataCombi.step.markStop();
}
}
});
startTrans.add(new Runnable() {
@Override
public void run() {
startReplay.countDown();
}
});
ListenableFutureTask<Integer> replay = ListenableFutureTask.create(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
Preconditions.checkState(startReplay.await(30, TimeUnit.SECONDS), "Cache replay did not start");
int rowCount = 0;
for (Iterator<RowMetaAndData> iterator = rowSupplier.get(); iterator.hasNext() && genTrans.isRunning(); ) {
RowMetaAndData metaAndData = iterator.next();
boolean rowAdded = false;
RowMetaInterface rowMeta = metaAndData.getRowMeta();
Object[] rowData = rowMeta.cloneRow(metaAndData.getData());
while (!rowAdded && genTrans.isRunning()) {
rowAdded = rowProducer.putRowWait(rowMeta, rowData, 10, TimeUnit.SECONDS);
}
if (rowAdded) {
rowCount += 1;
}
}
rowProducer.finished();
return rowCount;
}
});
executor.execute(replay);
return replay;
}
Aggregations