@Test public void testCommandContext() throws Exception { QueryMetadataInterface metadata = RealMetadataFactory.example1Cached(); RequestMessage message = new RequestMessage(QUERY); DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, RealMetadataFactory.example1VDB()); Request request = helpProcessMessage(message, null, workContext); assertEquals("1", request.context.getConnectionId()); assertNotNull(request.context.getTransactionContext()); }
TransactionContext getTransactionContext(boolean startAutoWrap) throws TeiidComponentException { if (this.transactionContext != null) { return this.transactionContext; } TransactionContext tc = transactionService.getOrCreateTransactionContext(workContext.getSessionId()); if (tc.getTransactionType() == TransactionContext.Scope.REQUEST && this.workContext.isDerived()) { tc = tc.clone(); tc.setTransactionType(TransactionContext.Scope.INHERITED); } Assertion.assertTrue(tc.getTransactionType() != TransactionContext.Scope.REQUEST, "Transaction already associated with request."); if (tc.getTransactionType() == Scope.NONE && !requestMsg.isNoExec() && (explainCommand == null || !explainCommand.isNoExec())) { if (!startAutoWrap) { return null; } Boolean startAutoWrapTxn = false; if(RequestMessage.TXN_WRAP_ON.equals(requestMsg.getTxnAutoWrapMode())){ startAutoWrapTxn = true; } else if (RequestMessage.TXN_WRAP_DETECT.equals(requestMsg.getTxnAutoWrapMode())){ boolean transactionalRead = requestMsg.getTransactionIsolation() == Connection.TRANSACTION_REPEATABLE_READ || requestMsg.getTransactionIsolation() == Connection.TRANSACTION_SERIALIZABLE; startAutoWrapTxn = processPlan.requiresTransaction(transactionalRead); if (startAutoWrapTxn == null) { startAutoWrapTxn = false; } } if (startAutoWrapTxn) { try { transactionService.begin(tc); } catch (XATransactionException err) { throw new TeiidComponentException(QueryPlugin.Event.TEIID30493, err); } } } tc.setIsolationLevel(requestMsg.getTransactionIsolation()); this.transactionContext = tc; return this.transactionContext; }
Request { TransactionContext getTransactionContext(boolean startAutoWrap) throws TeiidComponentException { if (this.transactionContext != null) { return this.transactionContext; } TransactionContext tc = transactionService.getOrCreateTransactionContext(workContext.getSessionId()); if (tc.getTransactionType() == TransactionContext.Scope.REQUEST && this.workContext.isDerived()) { tc = tc.clone(); tc.setTransactionType(TransactionContext.Scope.INHERITED); } Assertion.assertTrue(tc.getTransactionType() != TransactionContext.Scope.REQUEST, "Transaction already associated with request."); if (tc.getTransactionType() == Scope.NONE && !requestMsg.isNoExec() && (explainCommand == null || !explainCommand.isNoExec())) { if (!startAutoWrap) { return null; } Boolean startAutoWrapTxn = false; if(RequestMessage.TXN_WRAP_ON.equals(requestMsg.getTxnAutoWrapMode())){ startAutoWrapTxn = true; } else if (RequestMessage.TXN_WRAP_DETECT.equals(requestMsg.getTxnAutoWrapMode())){ boolean transactionalRead = requestMsg.getTransactionIsolation() == Connection.TRANSACTION_REPEATABLE_READ || requestMsg.getTransactionIsolation() == Connection.TRANSACTION_SERIALIZABLE; startAutoWrapTxn = processPlan.requiresTransaction(transactionalRead); if (startAutoWrapTxn == null) { startAutoWrapTxn = false; } } if (startAutoWrapTxn) { try { transactionService.begin(tc); } catch (XATransactionException err) { throw new TeiidComponentException(QueryPlugin.Event.TEIID30493, err); } } } tc.setIsolationLevel(requestMsg.getTransactionIsolation()); this.transactionContext = tc; return this.transactionContext; } }
Request { TransactionContext getTransactionContext(boolean startAutoWrap) throws TeiidComponentException { if (this.transactionContext != null) { return this.transactionContext; } TransactionContext tc = transactionService.getOrCreateTransactionContext(workContext.getSessionId()); if (tc.getTransactionType() == TransactionContext.Scope.REQUEST && this.workContext.isDerived()) { tc = tc.clone(); tc.setTransactionType(TransactionContext.Scope.INHERITED); } Assertion.assertTrue(tc.getTransactionType() != TransactionContext.Scope.REQUEST, "Transaction already associated with request."); if (tc.getTransactionType() == Scope.NONE && !requestMsg.isNoExec() && (explainCommand == null || !explainCommand.isNoExec())) { if (!startAutoWrap) { return null; } Boolean startAutoWrapTxn = false; if(RequestMessage.TXN_WRAP_ON.equals(requestMsg.getTxnAutoWrapMode())){ startAutoWrapTxn = true; } else if (RequestMessage.TXN_WRAP_DETECT.equals(requestMsg.getTxnAutoWrapMode())){ boolean transactionalRead = requestMsg.getTransactionIsolation() == Connection.TRANSACTION_REPEATABLE_READ || requestMsg.getTransactionIsolation() == Connection.TRANSACTION_SERIALIZABLE; startAutoWrapTxn = processPlan.requiresTransaction(transactionalRead); if (startAutoWrapTxn == null) { startAutoWrapTxn = false; } } if (startAutoWrapTxn) { try { transactionService.begin(tc); } catch (XATransactionException err) { throw new TeiidComponentException(QueryPlugin.Event.TEIID30493, err); } } } tc.setIsolationLevel(requestMsg.getTransactionIsolation()); this.transactionContext = tc; return this.transactionContext; }  }
Request { TransactionContext getTransactionContext(boolean startAutoWrap) throws TeiidComponentException { if (this.transactionContext != null) { return this.transactionContext; } TransactionContext tc = transactionService.getOrCreateTransactionContext(workContext.getSessionId()); if (tc.getTransactionType() == TransactionContext.Scope.REQUEST && this.workContext.isDerived()) { tc = tc.clone(); tc.setTransactionType(TransactionContext.Scope.INHERITED); } Assertion.assertTrue(tc.getTransactionType() != TransactionContext.Scope.REQUEST, "Transaction already associated with request."); if (tc.getTransactionType() == Scope.NONE && !requestMsg.isNoExec() && (explainCommand == null || !explainCommand.isNoExec())) { if (!startAutoWrap) { return null; } Boolean startAutoWrapTxn = false; if(RequestMessage.TXN_WRAP_ON.equals(requestMsg.getTxnAutoWrapMode())){ startAutoWrapTxn = true; } else if (RequestMessage.TXN_WRAP_DETECT.equals(requestMsg.getTxnAutoWrapMode())){ boolean transactionalRead = requestMsg.getTransactionIsolation() == Connection.TRANSACTION_REPEATABLE_READ || requestMsg.getTransactionIsolation() == Connection.TRANSACTION_SERIALIZABLE; startAutoWrapTxn = processPlan.requiresTransaction(transactionalRead); if (startAutoWrapTxn == null) { startAutoWrapTxn = false; } } if (startAutoWrapTxn) { try { transactionService.begin(tc); } catch (XATransactionException err) { throw new TeiidComponentException(QueryPlugin.Event.TEIID30493, err); } } } tc.setIsolationLevel(requestMsg.getTransactionIsolation()); this.transactionContext = tc; return this.transactionContext; }  void setOptions(Options options); void setResultSetCacheEnabled(boolean resultSetCacheEnabled); void setAuthorizationValidator(
            AuthorizationValidator authorizationValidator); void setUserRequestConcurrency(int userRequestConcurrency); static ParseInfo createParseInfo(RequestMessage requestMsg, SessionMetadata sessionMetadata); static void validateWithVisitor(
        AbstractValidationVisitor visitor,
        QueryMetadataInterface metadata,
        Command command); void processRequest(); void setExecutor(Executor executor); boolean isReturingParams(); void setPreParser(PreParser preParser); }
Request { TransactionContext getTransactionContext(boolean startAutoWrap) throws TeiidComponentException { if (this.transactionContext != null) { return this.transactionContext; } TransactionContext tc = transactionService.getOrCreateTransactionContext(workContext.getSessionId()); if (tc.getTransactionType() == TransactionContext.Scope.REQUEST && this.workContext.isDerived()) { tc = tc.clone(); tc.setTransactionType(TransactionContext.Scope.INHERITED); } Assertion.assertTrue(tc.getTransactionType() != TransactionContext.Scope.REQUEST, "Transaction already associated with request."); if (tc.getTransactionType() == Scope.NONE && !requestMsg.isNoExec() && (explainCommand == null || !explainCommand.isNoExec())) { if (!startAutoWrap) { return null; } Boolean startAutoWrapTxn = false; if(RequestMessage.TXN_WRAP_ON.equals(requestMsg.getTxnAutoWrapMode())){ startAutoWrapTxn = true; } else if (RequestMessage.TXN_WRAP_DETECT.equals(requestMsg.getTxnAutoWrapMode())){ boolean transactionalRead = requestMsg.getTransactionIsolation() == Connection.TRANSACTION_REPEATABLE_READ || requestMsg.getTransactionIsolation() == Connection.TRANSACTION_SERIALIZABLE; startAutoWrapTxn = processPlan.requiresTransaction(transactionalRead); if (startAutoWrapTxn == null) { startAutoWrapTxn = false; } } if (startAutoWrapTxn) { try { transactionService.begin(tc); } catch (XATransactionException err) { throw new TeiidComponentException(QueryPlugin.Event.TEIID30493, err); } } } tc.setIsolationLevel(requestMsg.getTransactionIsolation()); this.transactionContext = tc; return this.transactionContext; }  void setOptions(Options options); void setResultSetCacheEnabled(boolean resultSetCacheEnabled); void setAuthorizationValidator(
            AuthorizationValidator authorizationValidator); void setUserRequestConcurrency(int userRequestConcurrency); static ParseInfo createParseInfo(RequestMessage requestMsg, SessionMetadata sessionMetadata); static void validateWithVisitor(
        AbstractValidationVisitor visitor,
        QueryMetadataInterface metadata,
        Command command); void processRequest(); void setExecutor(Executor executor); boolean isReturingParams(); void setPreParser(PreParser preParser);  }