Search in sources :

Example 1 with CommandLogMessage

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);
}
Also used : AtomicRequestID(org.teiid.dqp.message.AtomicRequestID) Command(org.teiid.query.sql.lang.Command) CommandLogMessage(org.teiid.logging.CommandLogMessage)

Example 2 with CommandLogMessage

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);
}
Also used : PlanNode(org.teiid.client.plan.PlanNode) RequestID(org.teiid.dqp.message.RequestID) TransactionContext(org.teiid.dqp.service.TransactionContext) AtomicRequestMessage(org.teiid.dqp.message.AtomicRequestMessage) RequestMessage(org.teiid.client.RequestMessage) CommandLogMessage(org.teiid.logging.CommandLogMessage) QueryProcessor(org.teiid.query.processor.QueryProcessor)

Aggregations

CommandLogMessage (org.teiid.logging.CommandLogMessage)2 RequestMessage (org.teiid.client.RequestMessage)1 PlanNode (org.teiid.client.plan.PlanNode)1 AtomicRequestID (org.teiid.dqp.message.AtomicRequestID)1 AtomicRequestMessage (org.teiid.dqp.message.AtomicRequestMessage)1 RequestID (org.teiid.dqp.message.RequestID)1 TransactionContext (org.teiid.dqp.service.TransactionContext)1 QueryProcessor (org.teiid.query.processor.QueryProcessor)1 Command (org.teiid.query.sql.lang.Command)1