Search in sources :

Example 6 with LoggingObjectInterface

use of org.pentaho.di.core.logging.LoggingObjectInterface in project pentaho-kettle by pentaho.

the class JobTrackerExecution method after.

@After
public void after() throws KettleDatabaseException {
    // DatabaseMeta databaseMeta = new DatabaseMeta( NAME, "H2", "JDBC", null, TMP, null, USER, USER );
    DatabaseMeta databaseMeta = new DatabaseMeta(NAME, "Hypersonic", "JDBC", null, "mem:HSQLDB-JUNIT-LOGJOB", null, null, null);
    LoggingObjectInterface log = new SimpleLoggingObject("junit", LoggingObjectType.GENERAL, null);
    Database db = new Database(log, databaseMeta);
    db.connect();
    db.execStatements("DROP SCHEMA PUBLIC CASCADE");
    db.commit(true);
    db.disconnect();
}
Also used : Database(org.pentaho.di.core.database.Database) LoggingObjectInterface(org.pentaho.di.core.logging.LoggingObjectInterface) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) After(org.junit.After)

Example 7 with LoggingObjectInterface

use of org.pentaho.di.core.logging.LoggingObjectInterface in project pentaho-kettle by pentaho.

the class NextSequenceValueServlet method doGet.

/**
 *<div id="mindtouch">
 *    <h1>/kettle/nextSequence</h1>
 *    <a name="GET"></a>
 *    <h2>GET</h2>
 *    <p>Increments specified pre-configured sequence.
 *  Method is used for reserving a number of IDs and incrementing a sequence pre-configured in Carte server configuration
 *  by specified amount. If no increment value provided 10000 is used by default.</p>
 *
 *    <p><b>Example Request:</b><br />
 *    <pre function="syntax.xml">
 *    GET /kettle/nextSequence?name=test_seq
 *    </pre>
 *
 *    </p>
 *    <h3>Parameters</h3>
 *    <table class="pentaho-table">
 *    <tbody>
 *    <tr>
 *      <th>name</th>
 *      <th>description</th>
 *      <th>type</th>
 *    </tr>
 *    <tr>
 *    <td>name</td>
 *    <td>name of the sequence specified in Carte configuration file.</td>
 *    <td>query</td>
 *    </tr>
 *    <tr>
 *    <td>increment</td>
 *    <td>(optional) parameter used for incrementing sequence. If no parameter specified
 *  10000 is used by default.</td>
 *    <td>integer, optional</td>
 *    </tr>
 *    </tbody>
 *    </table>
 *
 *  <h3>Response Body</h3>
 *
 *  <table class="pentaho-table">
 *    <tbody>
 *      <tr>
 *        <td align="right">text:</td>
 *        <td>HTML</td>
 *      </tr>
 *      <tr>
 *        <td align="right">media types:</td>
 *        <td>text/xml</td>
 *      </tr>
 *    </tbody>
 *  </table>
 *    <p>Response XML containing sequence value and the increment value used.</p>
 *
 *    <p><b>Example Response:</b></p>
 *  <pre function="syntax.xml">
 *  <seq><value>570000</value><increment>10000</increment></seq>
 *  </pre>
 *
 *    <h3>Status Codes</h3>
 *    <table class="pentaho-table">
 *  <tbody>
 *    <tr>
 *      <th>code</th>
 *      <th>description</th>
 *    </tr>
 *    <tr>
 *      <td>200</td>
 *      <td>Request was processed.</td>
 *    </tr>
 *    <tr>
 *      <td>404</td>
 *      <td>If the sequence was not found or error occurred during allocation</td>
 *    </tr>
 *    <tr>
 *      <td>500</td>
 *      <td>Internal server error occurs during request processing.</td>
 *    </tr>
 *  </tbody>
 *</table>
 *</div>
 */
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 {
        SlaveSequence slaveSequence = getTransformationMap().getSlaveSequence(name);
        if (slaveSequence == null && getTransformationMap().isAutomaticSlaveSequenceCreationAllowed()) {
            slaveSequence = getTransformationMap().createSlaveSequence(name);
        }
        if (slaveSequence == null) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            out.println(XMLHandler.addTagValue(XML_TAG_ERROR, "Slave sequence '" + name + "' could not be found."));
        } else {
            LoggingObjectInterface loggingObject = new SimpleLoggingObject("Carte", LoggingObjectType.CARTE, null);
            long nextValue = slaveSequence.getNextValue(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 slave sequence: " + Const.getStackTracker(e)));
    }
    out.println(XMLHandler.closeTag(XML_TAG));
}
Also used : PrintStream(java.io.PrintStream) LoggingObjectInterface(org.pentaho.di.core.logging.LoggingObjectInterface) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 8 with LoggingObjectInterface

use of org.pentaho.di.core.logging.LoggingObjectInterface in project pentaho-kettle by pentaho.

the class TransGraph method dumpLoggingRegistry.

public void dumpLoggingRegistry() {
    LoggingRegistry registry = LoggingRegistry.getInstance();
    Map<String, LoggingObjectInterface> loggingMap = registry.getMap();
    for (LoggingObjectInterface loggingObject : loggingMap.values()) {
        System.out.println(loggingObject.getLogChannelId() + " - " + loggingObject.getObjectName() + " - " + loggingObject.getObjectType());
    }
}
Also used : LoggingRegistry(org.pentaho.di.core.logging.LoggingRegistry) LoggingObjectInterface(org.pentaho.di.core.logging.LoggingObjectInterface)

Example 9 with LoggingObjectInterface

use of org.pentaho.di.core.logging.LoggingObjectInterface in project pentaho-kettle by pentaho.

the class SlaveServerConfig method readAutoSequences.

public void readAutoSequences() throws KettleException {
    if (autoSequence == null) {
        return;
    }
    Database database = null;
    try {
        DatabaseMeta databaseMeta = autoSequence.getDatabaseMeta();
        LoggingObjectInterface loggingInterface = new SimpleLoggingObject("auto-sequence", LoggingObjectType.GENERAL, null);
        database = new Database(loggingInterface, databaseMeta);
        database.connect();
        String schemaTable = databaseMeta.getQuotedSchemaTableCombination(autoSequence.getSchemaName(), autoSequence.getTableName());
        String seqField = databaseMeta.quoteField(autoSequence.getSequenceNameField());
        String valueField = databaseMeta.quoteField(autoSequence.getValueField());
        String sql = "SELECT " + seqField + ", " + valueField + " FROM " + schemaTable;
        List<Object[]> rows = database.getRows(sql, 0);
        RowMetaInterface rowMeta = database.getReturnRowMeta();
        for (Object[] row : rows) {
            // Automatically create a new sequence for each sequence found...
            // 
            String sequenceName = rowMeta.getString(row, seqField, null);
            if (!Utils.isEmpty(sequenceName)) {
                Long value = rowMeta.getInteger(row, valueField, null);
                if (value != null) {
                    SlaveSequence slaveSequence = new SlaveSequence(sequenceName, value, databaseMeta, autoSequence.getSchemaName(), autoSequence.getTableName(), autoSequence.getSequenceNameField(), autoSequence.getValueField());
                    slaveSequences.add(slaveSequence);
                    LogChannel.GENERAL.logBasic("Automatically created slave sequence '" + slaveSequence.getName() + "' with start value " + slaveSequence.getStartValue());
                }
            }
        }
    } catch (Exception e) {
        throw new KettleException("Unable to automatically configure slave sequences", e);
    } finally {
        if (database != null) {
            database.disconnect();
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) KettleException(org.pentaho.di.core.exception.KettleException) SocketException(java.net.SocketException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) Database(org.pentaho.di.core.database.Database) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) LoggingObjectInterface(org.pentaho.di.core.logging.LoggingObjectInterface)

Example 10 with LoggingObjectInterface

use of org.pentaho.di.core.logging.LoggingObjectInterface in project pentaho-kettle by pentaho.

the class MetricsSnapshot method toString.

@Override
public String toString() {
    LoggingObjectInterface 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 : LoggingObjectInterface(org.pentaho.di.core.logging.LoggingObjectInterface)

Aggregations

LoggingObjectInterface (org.pentaho.di.core.logging.LoggingObjectInterface)17 SimpleLoggingObject (org.pentaho.di.core.logging.SimpleLoggingObject)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)3 Database (org.pentaho.di.core.database.Database)3 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)3 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)3 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)3 Timer (java.util.Timer)2 TimerTask (java.util.TimerTask)2 ControlAdapter (org.eclipse.swt.events.ControlAdapter)2 ControlEvent (org.eclipse.swt.events.ControlEvent)2 DisposeEvent (org.eclipse.swt.events.DisposeEvent)2 DisposeListener (org.eclipse.swt.events.DisposeListener)2 MouseAdapter (org.eclipse.swt.events.MouseAdapter)2 MouseEvent (org.eclipse.swt.events.MouseEvent)2 PaintEvent (org.eclipse.swt.events.PaintEvent)2 PaintListener (org.eclipse.swt.events.PaintListener)2 Rectangle (org.eclipse.swt.graphics.Rectangle)2