Package org.teiid.dqp.service

Examples of org.teiid.dqp.service.TransactionContext


   
    /**
     * Global Transaction
     */   
    public void commit(final String threadId, XidImpl xid, boolean onePhase, boolean singleTM) throws XATransactionException {
      TransactionContext tc = checkXAState(threadId, xid, true, false)
      try {
          if (singleTM || (onePhase && XAResource.XA_RDONLY == prepare(threadId, xid, singleTM))) {
            return; //nothing to do
          }
          //TODO: we have no way of knowing for sure if we can safely use the onephase optimization
          this.xaTerminator.commit(tc.getXid(), false);
      } catch (XAException e) {
            throw new XATransactionException(e);
        } finally {
        this.transactions.removeTransactionContext(tc);
      }
View Full Code Here


   
    /**
     * Global Transaction
     */
    public void rollback(final String threadId, XidImpl xid, boolean singleTM) throws XATransactionException {
      TransactionContext tc = checkXAState(threadId, xid, true, false)
      try {
        // In the case of single TM, the container directly roll backs the sources.
          if (!singleTM) {
            this.xaTerminator.rollback(tc.getXid());
          }
      } catch (XAException e) {
            throw new XATransactionException(e);
        } finally {
        this.transactions.removeTransactionContext(tc);
View Full Code Here

    /**
     * Global Transaction
     */   
    public void forget(final String threadId, XidImpl xid, boolean singleTM) throws XATransactionException {
      TransactionContext tc = checkXAState(threadId, xid, true, false);
        try {
          if (singleTM) {
            return;
          }
            this.xaTerminator.forget(xid);
View Full Code Here

    /**
     * Global Transaction
     */
    public void start(final String threadId, final XidImpl xid, int flags, int timeout, boolean singleTM) throws XATransactionException {
       
        TransactionContext tc = null;

        switch (flags) {
            case XAResource.TMNOFLAGS: {
                try {
          checkXAState(threadId, xid, false, false);
          tc = transactions.getOrCreateTransactionContext(threadId);
          if (tc.getTransactionType() != TransactionContext.Scope.NONE) {
              throw new XATransactionException(XAException.XAER_PROTO, QueryPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
          }
          tc.setTransactionTimeout(timeout);
          tc.setXid(xid);
          tc.setTransactionType(TransactionContext.Scope.GLOBAL);
          if (singleTM) {
            tc.setTransaction(transactionManager.getTransaction());
            assert tc.getTransaction() != null;
          } else {
            FutureWork<Transaction> work = new FutureWork<Transaction>(new Callable<Transaction>() {
              @Override
              public Transaction call() throws Exception {
                return transactionManager.getTransaction();
              }
            }, 0);
            workManager.doWork(work, WorkManager.INDEFINITE, tc, null);
            tc.setTransaction(work.get());
          }
        } catch (NotSupportedException e) {
          throw new XATransactionException(e, XAException.XAER_INVAL);
        } catch (WorkException e) {
          throw new XATransactionException(e, XAException.XAER_INVAL);
        } catch (InterruptedException e) {
          throw new XATransactionException(e, XAException.XAER_INVAL);
        } catch (ExecutionException e) {
          throw new XATransactionException(e, XAException.XAER_INVAL);
        } catch (SystemException e) {
          throw new XATransactionException(e, XAException.XAER_INVAL);
        }
                break;
            }
            case XAResource.TMJOIN:
            case XAResource.TMRESUME: {
                tc = checkXAState(threadId, xid, true, false);
                TransactionContext threadContext = transactions.getOrCreateTransactionContext(threadId);
                if (threadContext.getTransactionType() != TransactionContext.Scope.NONE) {
                    throw new XATransactionException(XAException.XAER_PROTO, QueryPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
                }
               
                if (flags == XAResource.TMRESUME && !tc.getSuspendedBy().remove(threadId)) {
                    throw new XATransactionException(XAException.XAER_PROTO, QueryPlugin.Util.getString("TransactionServer.resume_failed", new Object[] {xid, threadId})); //$NON-NLS-1$
View Full Code Here

    /**
     * Global Transaction
     */   
    public void end(final String threadId, XidImpl xid, int flags, boolean singleTM) throws XATransactionException {
        TransactionContext tc = checkXAState(threadId, xid, true, true);
        try {
            switch (flags) {
                case XAResource.TMSUSPEND: {
                    tc.getSuspendedBy().add(threadId);
                    break;
                }
                case XAResource.TMSUCCESS: {
                    //TODO: should close all statements
                    break;
                }
                case XAResource.TMFAIL: {
                  cancelTransactions(threadId, false);
                    break;
                }
                default:
                    throw new XATransactionException(XAException.XAER_INVAL, QueryPlugin.Util.getString("TransactionServer.unknown_flags")); //$NON-NLS-1$
            }
        } finally {
            tc.setThreadId(null);
            transactions.removeTransactionContext(threadId);
        }
    }
View Full Code Here

     
        RequestMessage msg = workItem.requestMsg;
        DQPWorkContext workContext = DQPWorkContext.getWorkContext();
        RequestID rID = new RequestID(workContext.getSessionId(), msg.getExecutionId());
      String txnID = null;
    TransactionContext tc = workItem.getTransactionContext();
    if (tc != null && tc.getTransactionType() != Scope.NONE) {
      txnID = tc.getTransactionId();
    }
      String appName = workContext.getAppName();
        // Log to request log
        CommandLogMessage message = null;
        if (status == Event.NEW) {
View Full Code Here

TOP

Related Classes of org.teiid.dqp.service.TransactionContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.