use of org.pentaho.di.core.logging.LogStatus in project pentaho-kettle by pentaho.
the class Trans method endProcessing.
/**
* End processing. Also handle any logging operations associated with the end of a transformation
*
* @return true if all end processing is successful, false otherwise
* @throws KettleException if any errors occur during processing
*/
private synchronized boolean endProcessing() throws KettleException {
LogStatus status;
if (isStopped()) {
status = LogStatus.STOP;
} else if (isFinished()) {
status = LogStatus.END;
} else if (isPaused()) {
status = LogStatus.PAUSED;
} else {
status = LogStatus.RUNNING;
}
TransLogTable transLogTable = transMeta.getTransLogTable();
int intervalInSeconds = Const.toInt(environmentSubstitute(transLogTable.getLogInterval()), -1);
logDate = new Date();
// OK, we have some logging to do...
//
DatabaseMeta logcon = transMeta.getTransLogTable().getDatabaseMeta();
String logTable = transMeta.getTransLogTable().getActualTableName();
if (logcon != null) {
Database ldb = null;
try {
//
if (transLogTableDatabaseConnection == null) {
ldb = new Database(this, logcon);
ldb.shareVariablesWith(this);
ldb.connect();
ldb.setCommit(logCommitSize);
transLogTableDatabaseConnection = ldb;
} else {
ldb = transLogTableDatabaseConnection;
}
//
if (!Utils.isEmpty(logTable)) {
ldb.writeLogRecord(transLogTable, status, this, null);
}
//
if (status.equals(LogStatus.END) || status.equals(LogStatus.STOP)) {
ldb.cleanupLogRecords(transLogTable, getName());
}
//
if (!ldb.isAutoCommit()) {
ldb.commitLog(true, transMeta.getTransLogTable());
}
} catch (KettleDatabaseException e) {
// PDI-9790 error write to log db is transaction error
log.logError(BaseMessages.getString(PKG, "Database.Error.WriteLogTable", logTable), e);
errors.incrementAndGet();
// end PDI-9790
} catch (Exception e) {
throw new KettleException(BaseMessages.getString(PKG, "Trans.Exception.ErrorWritingLogRecordToTable", transMeta.getTransLogTable().getActualTableName()), e);
} finally {
if (intervalInSeconds <= 0 || (status.equals(LogStatus.END) || status.equals(LogStatus.STOP))) {
ldb.disconnect();
// disconnected
transLogTableDatabaseConnection = null;
}
}
}
return true;
}
use of org.pentaho.di.core.logging.LogStatus in project pentaho-kettle by pentaho.
the class JobHistoryDelegate method displayHistoryData.
private void displayHistoryData(final int index) {
JobHistoryLogTab model = models[index];
if (model.logDisplayTableView == null || model.logDisplayTableView.isDisposed()) {
return;
}
// display the data in the table view
ColumnInfo[] colinf = model.logDisplayTableView.getColumns();
int selectionIndex = model.logDisplayTableView.getSelectionIndex();
model.logDisplayTableView.table.clearAll();
List<Object[]> rows = model.rows;
LogTableField errorsField = model.logTable.getErrorsField();
LogTableField statusField = model.logTable.getStatusField();
if (rows != null && rows.size() > 0) {
// we need to map ui columns to db columns before rendering data
Map<String, Integer> map = getColumnMappings(model);
// add row data to the table view
for (Object[] rowData : rows) {
TableItem item = new TableItem(model.logDisplayTableView.table, SWT.NONE);
for (int c = 0; c < colinf.length; c++) {
ColumnInfo column = colinf[c];
ValueMetaInterface valueMeta = column.getValueMeta();
String string = null;
try {
string = valueMeta.getString(rowData[map.get(column.getValueMeta().getName())]);
} catch (KettleValueException e) {
log.logError("history data conversion issue", e);
}
item.setText(c + 1, Const.NVL(string, ""));
}
// Add some color
//
Long errors = null;
LogStatus status = null;
if (errorsField != null) {
ValueMetaInterface valueMeta = getValueMetaForColumn(colinf, errorsField);
try {
errors = valueMeta.getInteger(rowData[map.get(valueMeta.getName())]);
} catch (KettleValueException e) {
log.logError("history data conversion issue", e);
}
}
if (statusField != null) {
ValueMetaInterface valueMeta = getValueMetaForColumn(colinf, statusField);
String statusString = null;
try {
statusString = valueMeta.getString(rowData[map.get(valueMeta.getName())]);
} catch (KettleValueException e) {
log.logError("history data conversion issue", e);
}
if (statusString != null) {
status = LogStatus.findStatus(statusString);
}
}
if (errors != null && errors > 0L) {
item.setBackground(GUIResource.getInstance().getColorRed());
} else if (status != null && LogStatus.STOP.equals(status)) {
item.setBackground(GUIResource.getInstance().getColorYellow());
}
}
model.logDisplayTableView.removeEmptyRows();
model.logDisplayTableView.setRowNums();
model.logDisplayTableView.optWidth(true);
} else {
model.logDisplayTableView.clearAll(false);
}
if (selectionIndex >= 0 && selectionIndex < model.logDisplayTableView.getItemCount()) {
model.logDisplayTableView.table.select(selectionIndex);
showLogEntry();
}
}
use of org.pentaho.di.core.logging.LogStatus in project pentaho-kettle by pentaho.
the class TransHistoryDelegate method displayHistoryData.
private void displayHistoryData(final int index) {
TransHistoryLogTab model = models[index];
if (model.logDisplayTableView == null || model.logDisplayTableView.isDisposed()) {
return;
}
// display the data in the table view
ColumnInfo[] colinf = model.logDisplayTableView.getColumns();
int selectionIndex = model.logDisplayTableView.getSelectionIndex();
model.logDisplayTableView.table.clearAll();
List<Object[]> rows = model.rows;
LogTableField errorsField = model.logTable.getErrorsField();
LogTableField statusField = model.logTable.getStatusField();
if (rows != null && rows.size() > 0) {
// we need to map ui columns to db columns before rendering data
Map<String, Integer> map = getColumnMappings(model);
// add row data to the table view
for (Object[] rowData : rows) {
TableItem item = new TableItem(model.logDisplayTableView.table, SWT.NONE);
for (int c = 0; c < colinf.length; c++) {
ColumnInfo column = colinf[c];
ValueMetaInterface valueMeta = column.getValueMeta();
String string = null;
try {
string = valueMeta.getString(rowData[map.get(column.getValueMeta().getName())]);
} catch (KettleValueException e) {
log.logError("history data conversion issue", e);
}
item.setText(c + 1, Const.NVL(string, ""));
}
// Add some color
//
Long errors = null;
LogStatus status = null;
if (errorsField != null) {
ValueMetaInterface valueMeta = getValueMetaForColumn(colinf, errorsField);
try {
errors = valueMeta.getInteger(rowData[map.get(valueMeta.getName())]);
} catch (KettleValueException e) {
log.logError("history data conversion issue", e);
}
}
if (statusField != null) {
ValueMetaInterface valueMeta = getValueMetaForColumn(colinf, statusField);
String statusString = null;
try {
statusString = valueMeta.getString(rowData[map.get(valueMeta.getName())]);
} catch (KettleValueException e) {
log.logError("history data conversion issue", e);
}
if (statusString != null) {
status = LogStatus.findStatus(statusString);
}
}
if (errors != null && errors > 0L) {
item.setBackground(GUIResource.getInstance().getColorRed());
} else if (status != null && LogStatus.STOP.equals(status)) {
item.setBackground(GUIResource.getInstance().getColorYellow());
}
}
model.logDisplayTableView.removeEmptyRows();
model.logDisplayTableView.setRowNums();
model.logDisplayTableView.optWidth(true);
} else {
model.logDisplayTableView.clearAll(false);
}
if (selectionIndex >= 0 && selectionIndex < model.logDisplayTableView.getItemCount()) {
model.logDisplayTableView.table.select(selectionIndex);
showLogEntry();
}
}
use of org.pentaho.di.core.logging.LogStatus in project pentaho-kettle by pentaho.
the class Job method endProcessing.
//
// Handle logging at end
/**
* End processing.
*
* @return true, if successful
* @throws KettleJobException
* the kettle job exception
*/
private boolean endProcessing() throws KettleJobException {
LogStatus status;
if (!isActive()) {
if (isStopped()) {
status = LogStatus.STOP;
} else {
status = LogStatus.END;
}
} else {
status = LogStatus.RUNNING;
}
try {
if (errors.get() == 0 && result != null && !result.getResult()) {
errors.incrementAndGet();
}
logDate = new Date();
/*
* Sums errors, read, written, etc.
*/
JobLogTable jobLogTable = jobMeta.getJobLogTable();
if (jobLogTable.isDefined()) {
writeLogTableInformation(jobLogTable, status);
}
return true;
} catch (Exception e) {
// In case something else goes wrong.
throw new KettleJobException(e);
}
}
Aggregations