Package org.teiid.client.xa

Examples of org.teiid.client.xa.XATransactionException


        return new AdminProcessingException(exception);
      }
          return new AdminComponentException(exception);
    }
        if (canThrowXATransactionException) {
          return new XATransactionException(exception);
        }
        if (RuntimeException.class.isAssignableFrom(exception.getClass())) {
          return exception;
        }
        return new TeiidRuntimeException(exception);
View Full Code Here


     * Global Transaction
     */
  public int prepare(final String threadId, XidImpl xid, boolean singleTM) throws XATransactionException {
        TransactionContext tc = checkXAState(threadId, xid, true, false);
        if (!tc.getSuspendedBy().isEmpty()) {
            throw new XATransactionException(XAException.XAER_PROTO, QueryPlugin.Util.getString("TransactionServer.suspended_exist", xid)); //$NON-NLS-1$
        }   
       
        // In the container this pass though
        if (singleTM) {               
        return XAResource.XA_RDONLY;
        }
       
        try {
          return this.xaTerminator.prepare(tc.getXid());
        } catch (XAException e) {
            throw new XATransactionException(e);
        }
    }
View Full Code Here

            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

        // 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

      }
     
      try {
      return this.xaTerminator.recover(flag);
    } catch (XAException e) {
      throw new XATransactionException(e);
    }
    }
View Full Code Here

          if (singleTM) {
            return;
          }
            this.xaTerminator.forget(xid);
        } catch (XAException err) {
            throw new XATransactionException(err);
        } finally {
          this.transactions.removeTransactionContext(tc);
        }
    }
View Full Code Here

            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$
                }
                break;
            }
            default:
                throw new XATransactionException(XAException.XAER_INVAL, QueryPlugin.Util.getString("TransactionServer.unknown_flags")); //$NON-NLS-1$
        }

        tc.setThreadId(threadId);
        transactions.addTransactionContext(tc);
    }
View Full Code Here

                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

    private TransactionContext checkXAState(final String threadId, final XidImpl xid, boolean transactionExpected, boolean threadBound) throws XATransactionException {
        TransactionContext tc = transactions.getTransactionContext(xid);
       
        if (transactionExpected && tc == null) {
            throw new XATransactionException(XAException.XAER_NOTA, QueryPlugin.Util.getString("TransactionServer.no_global_transaction", xid)); //$NON-NLS-1$
        } else if (!transactionExpected) {
            if (tc != null) {
                throw new XATransactionException(XAException.XAER_DUPID, QueryPlugin.Util.getString("TransactionServer.existing_global_transaction", new Object[] {xid})); //$NON-NLS-1$
            }
            if (!threadBound) {
                tc = transactions.getOrCreateTransactionContext(threadId);
                if (tc.getTransactionType() != TransactionContext.Scope.NONE) {
                    throw new XATransactionException(XAException.XAER_PROTO, QueryPlugin.Util.getString("TransactionServer.existing_transaction", new Object[] {xid, threadId})); //$NON-NLS-1$
                }
            }
            return null;
        }
       
        if (threadBound) {
            if (!threadId.equals(tc.getThreadId())) {
                throw new XATransactionException(XAException.XAER_PROTO, QueryPlugin.Util.getString("TransactionServer.wrong_transaction", xid)); //$NON-NLS-1$
            }
        } else if (tc.getThreadId() != null) {
            throw new XATransactionException(XAException.XAER_PROTO, QueryPlugin.Util.getString("TransactionServer.concurrent_transaction", xid)); //$NON-NLS-1$
        }
       
        return tc;
    }
View Full Code Here

              transactionManager.resume(tc.getTransaction());
          } else if (transactionExpected) {
            throw new InvalidTransactionException(QueryPlugin.Util.getString("TransactionServer.no_transaction", threadId)); //$NON-NLS-1$
          }
        } catch (InvalidTransactionException e) {
          throw new XATransactionException(e);
    } catch (SystemException e) {
          throw new XATransactionException(e);
    }
        return tc;
    }
View Full Code Here

TOP

Related Classes of org.teiid.client.xa.XATransactionException

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.