Search in sources :

Example 1 with AtomicRequestID

use of org.teiid.dqp.message.AtomicRequestID 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 AtomicRequestID

use of org.teiid.dqp.message.AtomicRequestID in project teiid by teiid.

the class ConnectorManager method registerRequest.

public ConnectorWork registerRequest(AtomicRequestMessage message) throws TeiidComponentException {
    checkStatus();
    AtomicRequestID atomicRequestId = message.getAtomicRequestID();
    // $NON-NLS-1$
    LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] { atomicRequestId, "Create State" });
    final ConnectorWorkItem item = new ConnectorWorkItem(message, this);
    ConnectorWork proxy = (ConnectorWork) Proxy.newProxyInstance(ConnectorWork.class.getClassLoader(), new Class[] { ConnectorWork.class }, new InvocationHandler() {

        @Override
        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            ClassLoader originalCL = Thread.currentThread().getContextClassLoader();
            try {
                Thread.currentThread().setContextClassLoader(getExecutionFactory().getClass().getClassLoader());
                return method.invoke(item, args);
            } catch (InvocationTargetException e) {
                throw e.getTargetException();
            } finally {
                Thread.currentThread().setContextClassLoader(originalCL);
            }
        }
    });
    // $NON-NLS-1$
    Assertion.isNull(requestStates.put(atomicRequestId, proxy), "State already existed");
    return proxy;
}
Also used : AtomicRequestID(org.teiid.dqp.message.AtomicRequestID) Method(java.lang.reflect.Method) FunctionMethod(org.teiid.metadata.FunctionMethod) InvocationHandler(java.lang.reflect.InvocationHandler) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 3 with AtomicRequestID

use of org.teiid.dqp.message.AtomicRequestID in project teiid by teiid.

the class TestConnectorManager method testRemoveUnknownRequestState.

@Test
public void testRemoveUnknownRequestState() throws Exception {
    helpAssureOneState();
    // $NON-NLS-1$
    csm.removeState(new AtomicRequestID(new RequestID("ZZZZ", 3210), 5, 5));
    // $NON-NLS-1$
    assertEquals("Expected size of 1", 1, csm.size());
}
Also used : AtomicRequestID(org.teiid.dqp.message.AtomicRequestID) RequestID(org.teiid.dqp.message.RequestID) AtomicRequestID(org.teiid.dqp.message.AtomicRequestID) Test(org.junit.Test)

Aggregations

AtomicRequestID (org.teiid.dqp.message.AtomicRequestID)3 InvocationHandler (java.lang.reflect.InvocationHandler)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 Test (org.junit.Test)1 RequestID (org.teiid.dqp.message.RequestID)1 CommandLogMessage (org.teiid.logging.CommandLogMessage)1 FunctionMethod (org.teiid.metadata.FunctionMethod)1 Command (org.teiid.query.sql.lang.Command)1