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);
}
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;
}
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());
}
Aggregations