Search in sources :

Example 1 with NodeTimer

use of org.knime.core.node.workflow.NodeTimer in project knime-core by knime.

the class NodeMonitorView method updateTimerTable.

/*
     *  Put info from node timer into table.
     */
private void updateTimerTable(final NodeContainer nc) {
    assert Display.getCurrent().getThread() == Thread.currentThread();
    // Initialize table
    m_table.removeAll();
    for (TableColumn tc : m_table.getColumns()) {
        tc.dispose();
    }
    String[] titles = { "Timer", "Value [ms]" };
    for (int i = 0; i < titles.length; i++) {
        TableColumn column = new TableColumn(m_table, SWT.NONE);
        column.setText(titles[i]);
    }
    // retrieve time
    NodeTimer nt = nc.getNodeTimer();
    // update content
    TableItem item = new TableItem(m_table, SWT.NONE);
    item.setText(0, "Last Exec Time");
    item.setText(1, nt.getLastExecutionDuration() < 0 ? "n/a" : "" + nt.getLastExecutionDuration());
    if (nt.getLastExecutionDuration() < nt.getExecutionDurationSinceReset()) {
        item = new TableItem(m_table, SWT.NONE);
        item.setText(0, "Total Execution Time since Reset");
        item.setText(1, "" + nt.getExecutionDurationSinceReset());
    }
    if (nt.getLastExecutionDuration() < nt.getExecutionDurationSinceStart()) {
        item = new TableItem(m_table, SWT.NONE);
        item.setText(0, "Total Execution Time");
        item.setText(1, "" + nt.getExecutionDurationSinceStart());
    }
    if (nt.getNrExecsSinceReset() != 1) {
        item = new TableItem(m_table, SWT.NONE);
        item.setText(0, "#Executions since Reset");
        item.setText(1, "" + nt.getNrExecsSinceReset());
    }
    item = new TableItem(m_table, SWT.NONE);
    item.setText(0, "Total #Executions");
    item.setText(1, "" + nt.getNrExecsSinceStart());
    // finalize table
    for (int i = 0; i < m_table.getColumnCount(); i++) {
        m_table.getColumn(i).pack();
    }
}
Also used : NodeTimer(org.knime.core.node.workflow.NodeTimer) TableItem(org.eclipse.swt.widgets.TableItem) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 2 with NodeTimer

use of org.knime.core.node.workflow.NodeTimer in project knime-core by knime.

the class TimerinfoNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
    BufferedDataContainer result = exec.createDataContainer(createSpec());
    WorkflowManager wfm = NodeContext.getContext().getWorkflowManager();
    for (NodeContainer nc : wfm.getNodeContainers()) {
        NodeTimer nt = nc.getNodeTimer();
        DataRow row = new DefaultRow(new RowKey("Node " + nc.getID().getIndex()), new StringCell(nc.getName()), nt.getLastExecutionDuration() >= 0 ? new LongCell(nt.getLastExecutionDuration()) : DataType.getMissingCell(), new LongCell(nt.getExecutionDurationSinceReset()), new LongCell(nt.getExecutionDurationSinceStart()), new IntCell(nt.getNrExecsSinceReset()), new IntCell(nt.getNrExecsSinceStart()), new StringCell(nc.getID().toString()), new StringCell(nc instanceof NativeNodeContainer ? ((NativeNodeContainer) nc).getNodeModel().getClass().getName() : "n/a"));
        result.addRowToTable(row);
    }
    result.close();
    return new PortObject[] { result.getTable() };
}
Also used : LongCell(org.knime.core.data.def.LongCell) BufferedDataContainer(org.knime.core.node.BufferedDataContainer) RowKey(org.knime.core.data.RowKey) StringCell(org.knime.core.data.def.StringCell) NodeTimer(org.knime.core.node.workflow.NodeTimer) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer) NodeContainer(org.knime.core.node.workflow.NodeContainer) DefaultRow(org.knime.core.data.def.DefaultRow) DataRow(org.knime.core.data.DataRow) FlowVariablePortObject(org.knime.core.node.port.flowvariable.FlowVariablePortObject) PortObject(org.knime.core.node.port.PortObject) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer) IntCell(org.knime.core.data.def.IntCell)

Aggregations

NodeTimer (org.knime.core.node.workflow.NodeTimer)2 TableColumn (org.eclipse.swt.widgets.TableColumn)1 TableItem (org.eclipse.swt.widgets.TableItem)1 DataRow (org.knime.core.data.DataRow)1 RowKey (org.knime.core.data.RowKey)1 DefaultRow (org.knime.core.data.def.DefaultRow)1 IntCell (org.knime.core.data.def.IntCell)1 LongCell (org.knime.core.data.def.LongCell)1 StringCell (org.knime.core.data.def.StringCell)1 BufferedDataContainer (org.knime.core.node.BufferedDataContainer)1 PortObject (org.knime.core.node.port.PortObject)1 FlowVariablePortObject (org.knime.core.node.port.flowvariable.FlowVariablePortObject)1 NativeNodeContainer (org.knime.core.node.workflow.NativeNodeContainer)1 NodeContainer (org.knime.core.node.workflow.NodeContainer)1 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)1