Search in sources :

Example 6 with StepStatus

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;
}
Also used : StepStatus(org.pentaho.di.trans.step.StepStatus)

Example 7 with StepStatus

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();
}
Also used : StepStatus(org.pentaho.di.trans.step.StepStatus)

Example 8 with StepStatus

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;
}
Also used : StepInterface(org.pentaho.di.trans.step.StepInterface) StepStatus(org.pentaho.di.trans.step.StepStatus) Trans(org.pentaho.di.trans.Trans) CarteObjectEntry(org.pentaho.di.www.CarteObjectEntry) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 9 with StepStatus

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));
}
Also used : ArrayList(java.util.ArrayList) LoggingObject(org.pentaho.di.core.logging.LoggingObject) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) StepStatus(org.pentaho.di.trans.step.StepStatus) Result(org.pentaho.di.core.Result) Variables(org.pentaho.di.core.variables.Variables) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LoggingObjectInterface(org.pentaho.di.core.logging.LoggingObjectInterface) TransExecutorParameters(org.pentaho.di.trans.steps.transexecutor.TransExecutorParameters) Map(java.util.Map) Test(org.junit.Test)

Example 10 with StepStatus

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));
        }
    }
}
Also used : SlaveServerJobStatus(org.pentaho.di.www.SlaveServerJobStatus) TreeItem(org.eclipse.swt.widgets.TreeItem) SlaveServerTransStatus(org.pentaho.di.www.SlaveServerTransStatus) StepStatus(org.pentaho.di.trans.step.StepStatus) WebResult(org.pentaho.di.www.WebResult) Result(org.pentaho.di.core.Result)

Aggregations

StepStatus (org.pentaho.di.trans.step.StepStatus)10 StepInterface (org.pentaho.di.trans.step.StepInterface)4 Result (org.pentaho.di.core.Result)3 ArrayList (java.util.ArrayList)2 Point (org.pentaho.di.core.gui.Point)2 Trans (org.pentaho.di.trans.Trans)2 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 PrintWriter (java.io.PrintWriter)1 Date (java.util.Date)1 Map (java.util.Map)1 ServletException (javax.servlet.ServletException)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Table (org.eclipse.swt.widgets.Table)1 TableItem (org.eclipse.swt.widgets.TableItem)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1 Test (org.junit.Test)1 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)1