public ConnectorWork registerRequest(AtomicRequestMessage message) throws TeiidComponentException { checkStatus(); AtomicRequestID atomicRequestId = message.getAtomicRequestID(); LogManager.logDetail( LogConstants.CTX_CONNECTOR, new Object[] {atomicRequestId, "Create State"}); // $NON-NLS-1$ 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); } } }); Assertion.isNull( requestStates.put(atomicRequestId, proxy), "State already existed"); // $NON-NLS-1$ return proxy; }
/** * 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, Integer 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(); String principal = userName == null ? "unknown" : userName; // $NON-NLS-1$ 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); }