Search in sources :

Example 1 with ILoggingObject

use of org.apache.hop.core.logging.ILoggingObject in project hop by apache.

the class MySqlDatabaseMetaTest method testVarBinaryIsConvertedToStringType.

@Test
public void testVarBinaryIsConvertedToStringType() throws Exception {
    ILoggingObject log = mock(ILoggingObject.class);
    PreparedStatement ps = mock(PreparedStatement.class);
    DatabaseMetaData dbMetaData = mock(DatabaseMetaData.class);
    IVariables variables = mock(IVariables.class);
    ResultSet rs = mock(ResultSet.class);
    ResultSetMetaData rsMeta = mock(ResultSetMetaData.class);
    when(rsMeta.getColumnCount()).thenReturn(1);
    when(rsMeta.getColumnLabel(1)).thenReturn("column");
    when(rsMeta.getColumnName(1)).thenReturn("column");
    when(rsMeta.getColumnType(1)).thenReturn(java.sql.Types.VARBINARY);
    when(rs.getMetaData()).thenReturn(rsMeta);
    when(ps.executeQuery()).thenReturn(rs);
    DatabaseMeta meta = new DatabaseMeta();
    meta.setIDatabase(new MySqlDatabaseMeta());
    Database db = new Database(log, variables, meta);
    db.setConnection(mockConnection(dbMetaData));
    db.getLookup(ps, false);
    IRowMeta rowMeta = db.getReturnRowMeta();
    assertEquals(1, db.getReturnRowMeta().size());
    IValueMeta valueMeta = rowMeta.getValueMeta(0);
    assertEquals(IValueMeta.TYPE_BINARY, valueMeta.getType());
}
Also used : ILoggingObject(org.apache.hop.core.logging.ILoggingObject) IValueMeta(org.apache.hop.core.row.IValueMeta) IVariables(org.apache.hop.core.variables.IVariables) IRowMeta(org.apache.hop.core.row.IRowMeta) Database(org.apache.hop.core.database.Database) DatabaseMeta(org.apache.hop.core.database.DatabaseMeta) Test(org.junit.Test)

Example 2 with ILoggingObject

use of org.apache.hop.core.logging.ILoggingObject in project hop by apache.

the class NextSequenceValueServlet method doGet.

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    if (isJettyMode() && !request.getContextPath().startsWith(CONTEXT_PATH)) {
        return;
    }
    if (log.isDebug()) {
        logDebug(toString());
    }
    String name = request.getParameter(PARAM_NAME);
    long increment = Const.toLong(request.getParameter(PARAM_INCREMENT), 10000);
    response.setStatus(HttpServletResponse.SC_OK);
    response.setContentType("text/xml");
    response.setCharacterEncoding(Const.XML_ENCODING);
    PrintStream out = new PrintStream(response.getOutputStream());
    out.println(XmlHandler.getXmlHeader(Const.XML_ENCODING));
    out.println(XmlHandler.openTag(XML_TAG));
    try {
        HopServerSequence hopServerSequence = getPipelineMap().getServerSequence(name);
        if (hopServerSequence == null && getPipelineMap().isAutomaticServerSequenceCreationAllowed()) {
            hopServerSequence = getPipelineMap().createServerSequence(name);
        }
        if (hopServerSequence == null) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            out.println(XmlHandler.addTagValue(XML_TAG_ERROR, "Server sequence '" + name + "' could not be found."));
        } else {
            ILoggingObject loggingObject = new SimpleLoggingObject("HopServer", LoggingObjectType.HOP_SERVER, null);
            long nextValue = hopServerSequence.getNextValue(variables, loggingObject, increment);
            out.println(XmlHandler.addTagValue(XML_TAG_VALUE, nextValue));
            out.println(XmlHandler.addTagValue(XML_TAG_INCREMENT, increment));
        }
    } catch (Exception e) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
        out.println(XmlHandler.addTagValue(XML_TAG_ERROR, "Error retrieving next value from server sequence: " + Const.getStackTracker(e)));
    }
    out.println(XmlHandler.closeTag(XML_TAG));
}
Also used : ILoggingObject(org.apache.hop.core.logging.ILoggingObject) PrintStream(java.io.PrintStream) SimpleLoggingObject(org.apache.hop.core.logging.SimpleLoggingObject) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 3 with ILoggingObject

use of org.apache.hop.core.logging.ILoggingObject in project hop by apache.

the class MetricsSnapshot method toString.

@Override
public String toString() {
    ILoggingObject loggingObject = LoggingRegistry.getInstance().getLoggingObject(logChannelId);
    String subject = null;
    if (loggingObject != null) {
        subject = loggingObject.getObjectName() + "(" + loggingObject.getObjectType() + ")";
    } else {
        subject = "-";
    }
    return subject + " - " + getKey() + " @ " + StringUtil.getFormattedDateTime(date, true) + " : " + type.toString();
}
Also used : ILoggingObject(org.apache.hop.core.logging.ILoggingObject)

Example 4 with ILoggingObject

use of org.apache.hop.core.logging.ILoggingObject in project hop by apache.

the class WorkflowLogging method processRow.

@Override
public boolean processRow() throws HopException {
    if (loggingWorkflow == null) {
        logBasic("This transform will produce output when called by the Pipeline Log configuration");
        setOutputDone();
        return false;
    }
    // Calculate the output fields of this transform
    // 
    IRowMeta outputRowMeta = new RowMeta();
    meta.getFields(outputRowMeta, getTransformName(), null, null, this, metadataProvider);
    WorkflowMeta workflowMeta = loggingWorkflow.getWorkflowMeta();
    // Generate the pipeline row...
    // 
    Object[] pipelineRow = RowDataUtil.allocateRowData(outputRowMeta.size());
    int index = 0;
    // Logging date: start date of the logging pipeline
    pipelineRow[index++] = getPipeline().getExecutionStartDate();
    // The logging phase
    pipelineRow[index++] = loggingPhase;
    // Name of the workflow
    pipelineRow[index++] = workflowMeta.getName();
    // Filename of the workflow
    pipelineRow[index++] = workflowMeta.getFilename();
    // Start date the workflow
    pipelineRow[index++] = loggingWorkflow.getExecutionStartDate();
    // End date the workflow
    pipelineRow[index++] = loggingWorkflow.getExecutionEndDate();
    // Log channel ID of the workflow
    pipelineRow[index++] = loggingWorkflow.getLogChannelId();
    // Log channel ID of the parent
    ILoggingObject parent = loggingWorkflow.getParent();
    pipelineRow[index++] = parent == null ? null : parent.getLogChannelId();
    // Logging text of the workflow
    pipelineRow[index++] = HopLogStore.getAppender().getBuffer(loggingWorkflow.getLogChannelId(), false).toString();
    // Result object *after* execution:
    Result result = loggingWorkflow.getResult();
    // Current number of errors in the workflow
    pipelineRow[index++] = result == null ? null : (long) result.getNrErrors();
    // Workflow status description
    pipelineRow[index++] = loggingWorkflow.getStatusDescription();
    int startIndex = index;
    List<ActionResult> actionResults = loggingWorkflow.getActionResults();
    // 
    if (meta.isLoggingActionResults() && !actionResults.isEmpty()) {
        // 
        for (ActionResult actionResult : actionResults) {
            index = startIndex;
            result = actionResult.getResult();
            Object[] transformRow = RowDataUtil.createResizedCopy(pipelineRow, outputRowMeta.size());
            // Name of the action
            transformRow[index++] = actionResult.getActionName();
            // Copy number...
            transformRow[index++] = result.getEntryNr();
            // Result (true/false)
            transformRow[index++] = result.getResult();
            // Log channel ID
            transformRow[index++] = actionResult.getLogChannelId();
            // Logging text of action
            transformRow[index++] = result.getLogText();
            // Errors
            transformRow[index++] = result.getNrErrors();
            // Action log date
            transformRow[index++] = actionResult.getLogDate();
            // Execution duration
            transformRow[index++] = result.getElapsedTimeMillis();
            // Exit status
            transformRow[index++] = (long) result.getExitStatus();
            // Exit status
            transformRow[index++] = result.getNrFilesRetrieved();
            // Action filename
            transformRow[index++] = actionResult.getActionFilename();
            // Action comment
            transformRow[index++] = actionResult.getComment();
            // Action reason
            transformRow[index++] = actionResult.getReason();
            // Send it on its way...
            // 
            putRow(outputRowMeta, transformRow);
        }
    } else {
        putRow(outputRowMeta, pipelineRow);
    }
    // All done in one go!
    // 
    setOutputDone();
    return false;
}
Also used : ILoggingObject(org.apache.hop.core.logging.ILoggingObject) ActionResult(org.apache.hop.workflow.ActionResult) IRowMeta(org.apache.hop.core.row.IRowMeta) RowMeta(org.apache.hop.core.row.RowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) ILoggingObject(org.apache.hop.core.logging.ILoggingObject) WorkflowMeta(org.apache.hop.workflow.WorkflowMeta) ActionResult(org.apache.hop.workflow.ActionResult) Result(org.apache.hop.core.Result)

Example 5 with ILoggingObject

use of org.apache.hop.core.logging.ILoggingObject in project hop by apache.

the class PipelineLogging method processRow.

@Override
public boolean processRow() throws HopException {
    if (loggingPipeline == null) {
        logBasic("This transform will produce output when called by the Pipeline Log configuration");
        setOutputDone();
        return false;
    }
    // Calculate the output fields of this transform
    // 
    IRowMeta outputRowMeta = new RowMeta();
    meta.getFields(outputRowMeta, getTransformName(), null, null, this, metadataProvider);
    PipelineMeta pipelineMeta = loggingPipeline.getPipelineMeta();
    // Generate the pipeline row...
    // 
    Object[] pipelineRow = RowDataUtil.allocateRowData(outputRowMeta.size());
    int index = 0;
    // Logging date: start date of the logging pipeline
    pipelineRow[index++] = getPipeline().getExecutionStartDate();
    // The logging phase
    pipelineRow[index++] = loggingPhase;
    // Name of the pipeline
    pipelineRow[index++] = pipelineMeta.getName();
    // Filename of the pipeline
    pipelineRow[index++] = pipelineMeta.getFilename();
    // Start date the pipeline
    pipelineRow[index++] = loggingPipeline.getExecutionStartDate();
    // End date the pipeline
    pipelineRow[index++] = loggingPipeline.getExecutionEndDate();
    // Log channel ID of the pipeline
    pipelineRow[index++] = loggingPipeline.getLogChannelId();
    // Parent Log channel ID
    ILoggingObject parent = loggingPipeline.getParent();
    pipelineRow[index++] = parent == null ? null : parent.getLogChannelId();
    // Logging text of the pipeline
    pipelineRow[index++] = HopLogStore.getAppender().getBuffer(loggingPipeline.getLogChannelId(), false).toString();
    // Number of errors in the pipeline
    pipelineRow[index++] = (long) loggingPipeline.getErrors();
    // Pipeline status description
    pipelineRow[index++] = loggingPipeline.getStatusDescription();
    int startIndex = index;
    List<IEngineComponent> components = loggingPipeline.getComponents();
    // 
    if (meta.isLoggingTransforms() && !components.isEmpty()) {
        // 
        for (IEngineComponent component : components) {
            index = startIndex;
            Object[] transformRow = RowDataUtil.createResizedCopy(pipelineRow, outputRowMeta.size());
            // Name of the transform
            transformRow[index++] = component.getName();
            // Copy number...
            transformRow[index++] = (long) component.getCopyNr();
            // Status description
            transformRow[index++] = component.getStatusDescription();
            // Log channel ID
            transformRow[index++] = component.getLogChannelId();
            // Logging text of transform
            transformRow[index++] = component.getLogText();
            // Lines read
            transformRow[index++] = component.getLinesRead();
            // Lines written
            transformRow[index++] = component.getLinesWritten();
            // Lines input
            transformRow[index++] = component.getLinesInput();
            // Lines output
            transformRow[index++] = component.getLinesOutput();
            // Lines updated
            transformRow[index++] = component.getLinesUpdated();
            // Lines rejected
            transformRow[index++] = component.getLinesRejected();
            // Errors
            transformRow[index++] = component.getErrors();
            // Execution start
            transformRow[index++] = component.getExecutionStartDate();
            // Execution end
            transformRow[index++] = component.getExecutionEndDate();
            // Execution duration
            transformRow[index] = component.getExecutionDuration();
            // Send it on its way...
            // 
            putRow(outputRowMeta, transformRow);
        }
    } else {
        putRow(outputRowMeta, pipelineRow);
    }
    // All done in one go!
    // 
    setOutputDone();
    return false;
}
Also used : ILoggingObject(org.apache.hop.core.logging.ILoggingObject) IRowMeta(org.apache.hop.core.row.IRowMeta) RowMeta(org.apache.hop.core.row.RowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) ILoggingObject(org.apache.hop.core.logging.ILoggingObject) IEngineComponent(org.apache.hop.pipeline.engine.IEngineComponent) PipelineMeta(org.apache.hop.pipeline.PipelineMeta)

Aggregations

ILoggingObject (org.apache.hop.core.logging.ILoggingObject)5 IRowMeta (org.apache.hop.core.row.IRowMeta)3 RowMeta (org.apache.hop.core.row.RowMeta)2 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 ServletException (javax.servlet.ServletException)1 Result (org.apache.hop.core.Result)1 Database (org.apache.hop.core.database.Database)1 DatabaseMeta (org.apache.hop.core.database.DatabaseMeta)1 SimpleLoggingObject (org.apache.hop.core.logging.SimpleLoggingObject)1 IValueMeta (org.apache.hop.core.row.IValueMeta)1 IVariables (org.apache.hop.core.variables.IVariables)1 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)1 IEngineComponent (org.apache.hop.pipeline.engine.IEngineComponent)1 ActionResult (org.apache.hop.workflow.ActionResult)1 WorkflowMeta (org.apache.hop.workflow.WorkflowMeta)1 Test (org.junit.Test)1