/** * 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); }
@Override public ConnectorWork registerRequest(AtomicRequestMessage message) throws TeiidComponentException { List projectedSymbols = (message.getCommand()).getProjectedSymbols(); List[] results = createResults(projectedSymbols, rows, useIntCounter); if (RelationalNodeUtil.isUpdate(message.getCommand())) { results = new List[] {Arrays.asList(1)}; } final AtomicResultsMessage msg = ConnectorWorkItem.createResultsMessage(results); msg.setFinalRow(rows); return new ConnectorWork() { boolean returnedInitial; @Override public boolean isDataAvailable() { return dataAvailable; } @Override public AtomicResultsMessage more() throws TranslatorException { if (dataNotAvailable != null) { int delay = dataNotAvailable; dataNotAvailable = null; DataNotAvailableException dnae = new DataNotAvailableException(delay); dnae.setStrict(strict); throw dnae; } if (addWarning) { msg.setWarnings(Arrays.asList(new Exception())); } if (!returnedInitial) { returnedInitial = true; return msg; } throw new RuntimeException("Should not be called"); // $NON-NLS-1$ } @Override public void execute() throws TranslatorException { executeCount.incrementAndGet(); if (sleep > 0) { try { Thread.sleep(sleep); } catch (InterruptedException e) { throw new RuntimeException(e); } } if (throwExceptionOnExecute) { throw new TranslatorException("Connector Exception"); // $NON-NLS-1$ } } @Override public void close() { closeCount.incrementAndGet(); } @Override public void cancel() {} @Override public CacheDirective getCacheDirective() { return cacheDirective; } @Override public boolean isForkable() { return true; } @Override public boolean isThreadBound() { return threadBound; } @Override public AtomicRequestID getId() { return null; } }; }