use of org.pentaho.di.trans.step.StepStatus in project pentaho-kettle by pentaho.
the class SlaveServerTransStatus method getNrStepErrors.
public long getNrStepErrors() {
long errors = 0L;
for (int i = 0; i < stepStatusList.size(); i++) {
StepStatus stepStatus = stepStatusList.get(i);
errors += stepStatus.getErrors();
}
return errors;
}
use of org.pentaho.di.trans.step.StepStatus in project pentaho-kettle by pentaho.
the class SlaveServerTransStatus method getXML.
public String getXML(boolean sendResultXmlWithStatus) throws KettleException {
StringBuilder xml = new StringBuilder();
xml.append(XMLHandler.openTag(XML_TAG)).append(Const.CR);
xml.append(" ").append(XMLHandler.addTagValue("transname", transName));
xml.append(" ").append(XMLHandler.addTagValue("id", id));
xml.append(" ").append(XMLHandler.addTagValue("status_desc", statusDescription));
xml.append(" ").append(XMLHandler.addTagValue("error_desc", errorDescription));
xml.append(" ").append(XMLHandler.addTagValue("log_date", XMLHandler.date2string(logDate)));
xml.append(" ").append(XMLHandler.addTagValue("paused", paused));
xml.append(" ").append(XMLHandler.openTag("stepstatuslist")).append(Const.CR);
for (int i = 0; i < stepStatusList.size(); i++) {
StepStatus stepStatus = stepStatusList.get(i);
xml.append(" ").append(stepStatus.getXML()).append(Const.CR);
}
xml.append(" ").append(XMLHandler.closeTag("stepstatuslist")).append(Const.CR);
xml.append(" ").append(XMLHandler.addTagValue("first_log_line_nr", firstLoggingLineNr));
xml.append(" ").append(XMLHandler.addTagValue("last_log_line_nr", lastLoggingLineNr));
if (result != null) {
String resultXML = sendResultXmlWithStatus ? result.getXML() : result.getBasicXml();
xml.append(resultXML);
}
xml.append(" ").append(XMLHandler.addTagValue("logging_string", XMLHandler.buildCDATA(loggingString)));
xml.append(XMLHandler.closeTag(XML_TAG));
return xml.toString();
}
use of org.pentaho.di.trans.step.StepStatus in project pentaho-kettle by pentaho.
the class TransformationResource method getTransformationStatus.
@GET
@Path("/status/{id : .+}")
@Produces({ MediaType.APPLICATION_JSON })
public TransformationStatus getTransformationStatus(@PathParam("id") String id) {
TransformationStatus status = new TransformationStatus();
// find trans
Trans trans = CarteResource.getTransformation(id);
CarteObjectEntry entry = CarteResource.getCarteObjectEntry(id);
status.setId(entry.getId());
status.setName(entry.getName());
status.setStatus(trans.getStatus());
for (int i = 0; i < trans.nrSteps(); i++) {
StepInterface step = trans.getRunThread(i);
if ((step.isRunning()) || step.getStatus() != StepExecutionStatus.STATUS_EMPTY) {
StepStatus stepStatus = new StepStatus(step);
status.addStepStatus(stepStatus);
}
}
return status;
}
use of org.pentaho.di.trans.step.StepStatus in project pentaho-kettle by pentaho.
the class SubtransExecutorTest method testRunsATrans.
@Test
public void testRunsATrans() throws Exception {
TransMeta parentMeta = new TransMeta(this.getClass().getResource("subtrans-executor-parent.ktr").getPath(), new Variables());
TransMeta subMeta = new TransMeta(this.getClass().getResource("subtrans-executor-sub.ktr").getPath(), new Variables());
LoggingObjectInterface loggingObject = new LoggingObject("anything");
Trans parentTrans = spy(new Trans(parentMeta, loggingObject));
SubtransExecutor subtransExecutor = new SubtransExecutor("subtransname", parentTrans, subMeta, true, new TransExecutorParameters(), "Group By");
RowMetaInterface rowMeta = parentMeta.getStepFields("Data Grid");
List<RowMetaAndData> rows = Arrays.asList(new RowMetaAndData(rowMeta, "Pentaho", 1L), new RowMetaAndData(rowMeta, "Pentaho", 2L), new RowMetaAndData(rowMeta, "Pentaho", 3L), new RowMetaAndData(rowMeta, "Pentaho", 4L));
Optional<Result> optionalResult = subtransExecutor.execute(rows);
assertEquals(1, optionalResult.orElseThrow(AssertionError::new).getRows().size());
verify(this.logChannel).logBasic(Const.CR + "------------> Linenr 1------------------------------" + Const.CR + "name = Pentaho" + Const.CR + "sum = 10" + Const.CR + Const.CR + "====================");
Map<String, StepStatus> statuses = subtransExecutor.getStatuses();
assertEquals(3, statuses.size());
List<StepStatus> statusList = new ArrayList<>(statuses.values());
assertEquals("Get rows from result", statusList.get(0).getStepname());
assertEquals("Group by", statusList.get(1).getStepname());
assertEquals("Write to log", statusList.get(2).getStepname());
for (Map.Entry<String, StepStatus> entry : statuses.entrySet()) {
StepStatus statusSpy = spy(entry.getValue());
statuses.put(entry.getKey(), statusSpy);
}
subtransExecutor.execute(rows);
for (Map.Entry<String, StepStatus> entry : statuses.entrySet()) {
verify(entry.getValue()).updateAll(any());
}
verify(parentTrans, atLeastOnce()).addActiveSubTransformation(eq("subtransname"), any(Trans.class));
}
use of org.pentaho.di.trans.step.StepStatus in project pentaho-kettle by pentaho.
the class SpoonSlave method treeItemSelected.
public void treeItemSelected(TreeItem item) {
if (item == null) {
// there is nothing to do
return;
}
// load node upon expansion
if (item.getData("transStatus") != null) {
SlaveServerTransStatus transStatus = (SlaveServerTransStatus) item.getData("transStatus");
try {
if (log.isDetailed()) {
log.logDetailed("Getting transformation status for [{0}] on server [{1}]", transStatus.getTransName(), SpoonSlave.this.slaveServer);
}
SlaveServerTransStatus ts = SpoonSlave.this.slaveServer.getTransStatus(transStatus.getTransName(), transStatus.getId(), 0);
if (log.isDetailed()) {
log.logDetailed("Finished receiving transformation status for [{0}] from server [{1}]", transStatus.getTransName(), SpoonSlave.this.slaveServer);
}
List<StepStatus> stepStatusList = ts.getStepStatusList();
transStatus.setStepStatusList(stepStatusList);
String logging = ts.getLoggingString();
String[] lines = logging.split("\r\n|\r|\n");
if (lines.length > PropsUI.getInstance().getMaxNrLinesInLog()) {
// Trim to view the last x lines
int offset = lines.length - PropsUI.getInstance().getMaxNrLinesInLog();
StringBuilder trimmedLog = new StringBuilder();
// Keep only the text from offset to the end of the log
while (offset != lines.length) {
trimmedLog.append(lines[offset++]).append('\n');
}
logging = trimmedLog.toString();
}
currentLogText = logging;
item.removeAll();
for (StepStatus stepStatus : stepStatusList) {
TreeItem stepItem = new TreeItem(item, SWT.NONE);
stepItem.setText(stepStatus.getSpoonSlaveLogFields());
}
} catch (Exception e) {
transStatus.setErrorDescription("Unable to access transformation details : " + Const.CR + Const.getStackTracker(e));
}
} else if (item.getData("jobStatus") != null) {
SlaveServerJobStatus jobStatus = (SlaveServerJobStatus) item.getData("jobStatus");
try {
if (log.isDetailed()) {
log.logDetailed("Getting job status for [{0}] on server [{1}]", jobStatus.getJobName(), slaveServer);
}
SlaveServerJobStatus ts = slaveServer.getJobStatus(jobStatus.getJobName(), jobStatus.getId(), 0);
if (log.isDetailed()) {
log.logDetailed("Finished receiving job status for [{0}] from server [{1}]", jobStatus.getJobName(), slaveServer);
}
String logging = ts.getLoggingString();
String[] lines = logging.split("\r\n|\r|\n");
if (lines.length > PropsUI.getInstance().getMaxNrLinesInLog()) {
// Trim to view the last x lines
int offset = lines.length - PropsUI.getInstance().getMaxNrLinesInLog();
StringBuilder trimmedLog = new StringBuilder();
// Keep only the text from offset to the end of the log
while (offset != lines.length) {
trimmedLog.append(lines[offset++]).append('\n');
}
logging = trimmedLog.toString();
}
currentLogText = logging;
Result result = ts.getResult();
if (result != null) {
item.setText(2, "" + result.getNrLinesRead());
item.setText(3, "" + result.getNrLinesWritten());
item.setText(4, "" + result.getNrLinesInput());
item.setText(5, "" + result.getNrLinesOutput());
item.setText(6, "" + result.getNrLinesUpdated());
item.setText(7, "" + result.getNrLinesRejected());
item.setText(8, "" + result.getNrErrors());
}
} catch (Exception e) {
jobStatus.setErrorDescription("Unable to access transformation details : " + Const.CR + Const.getStackTracker(e));
}
}
}
Aggregations