use of org.teiid.logging.CommandLogMessage in project teiid by teiid.
the class ConnectorManager method logSRCCommand.
/**
* Add begin point to transaction monitoring table.
* @param qr Request that contains the MetaMatrix command information in the transaction.
*/
void logSRCCommand(AtomicRequestMessage qr, ExecutionContext context, Event cmdStatus, Long finalRowCnt, Long cpuTime, Object[] command) {
if (!LogManager.isMessageToBeRecorded(LogConstants.CTX_COMMANDLOGGING, MessageLevel.DETAIL)) {
return;
}
String sqlStr = null;
if (cmdStatus == Event.NEW) {
Command cmd = qr.getCommand();
sqlStr = cmd != null ? cmd.toString() : null;
}
String userName = qr.getWorkContext().getUserName();
String transactionID = null;
if (qr.isTransactional()) {
transactionID = qr.getTransactionContext().getTransactionId();
}
String modelName = qr.getModelName();
AtomicRequestID sid = qr.getAtomicRequestID();
// $NON-NLS-1$
String principal = userName == null ? "unknown" : userName;
CommandLogMessage message = null;
if (cmdStatus == Event.NEW) {
message = new CommandLogMessage(System.currentTimeMillis(), qr.getRequestID().toString(), sid.getNodeID(), transactionID, modelName, translatorName, qr.getWorkContext().getSessionId(), principal, sqlStr, context);
} else {
message = new CommandLogMessage(System.currentTimeMillis(), qr.getRequestID().toString(), sid.getNodeID(), transactionID, modelName, translatorName, qr.getWorkContext().getSessionId(), principal, finalRowCnt, cmdStatus, context, cpuTime);
if (cmdStatus == Event.SOURCE) {
message.setSourceCommand(command);
}
}
LogManager.log(MessageLevel.DETAIL, LogConstants.CTX_COMMANDLOGGING, message);
}
use of org.teiid.logging.CommandLogMessage in project teiid by teiid.
the class DQPCore method logMMCommand.
void logMMCommand(RequestWorkItem workItem, Event status, Long rowCount, Long cpuTime) {
if ((status != Event.PLAN && !LogManager.isMessageToBeRecorded(LogConstants.CTX_COMMANDLOGGING, MessageLevel.INFO)) || (status == Event.PLAN && !LogManager.isMessageToBeRecorded(LogConstants.CTX_COMMANDLOGGING, MessageLevel.TRACE))) {
return;
}
RequestMessage msg = workItem.requestMsg;
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
RequestID rID = workItem.requestID;
String txnID = null;
TransactionContext tc = workItem.getTransactionContext();
if (tc != null && tc.getTransactionType() != Scope.NONE) {
txnID = tc.getTransactionId();
}
String appName = workContext.getAppName();
// Log to request log
CommandLogMessage message = null;
if (status == Event.NEW) {
message = new CommandLogMessage(System.currentTimeMillis(), rID.toString(), txnID, workContext.getSessionId(), appName, workContext.getUserName(), workContext.getVdbName(), workContext.getVdbVersion(), msg.getCommandString(), cpuTime);
} else {
QueryProcessor qp = workItem.getProcessor();
PlanNode plan = null;
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_COMMANDLOGGING, MessageLevel.TRACE) && qp != null) {
plan = qp.getProcessorPlan().getDescriptionProperties();
}
message = new CommandLogMessage(System.currentTimeMillis(), rID.toString(), txnID, workContext.getSessionId(), workContext.getUserName(), workContext.getVdbName(), workContext.getVdbVersion(), rowCount, status, plan);
}
LogManager.log(status == Event.PLAN ? MessageLevel.TRACE : MessageLevel.INFO, LogConstants.CTX_COMMANDLOGGING, message);
}
Aggregations