use of org.teiid.client.xa.XATransactionException in project teiid by teiid.
the class TestSocketServiceRegistry method testXATransactionExceptionConversion.
public void testXATransactionExceptionConversion() throws Exception {
Method m = DQP.class.getMethod("recover", new Class[] { Integer.TYPE });
Throwable t = ExceptionUtil.convertException(m, new TeiidComponentException());
assertTrue(t instanceof XATransactionException);
}
use of org.teiid.client.xa.XATransactionException in project teiid by teiid.
the class RequestWorkItem method requestCancel.
public boolean requestCancel(String reason) throws TeiidComponentException {
synchronized (this) {
if (this.isCanceled || this.closeRequested) {
// $NON-NLS-1$ //$NON-NLS-2$
LogManager.logDetail(LogConstants.CTX_DQP, "Ignoring cancel for", requestID, "since request is already cancelled/closed");
return false;
}
this.isCanceled = true;
this.cancelReason = QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30563, requestID, reason);
}
LogManager.logDetail(LogConstants.CTX_DQP, cancelReason);
if (this.processor != null) {
this.processor.requestCanceled();
}
// Cancel Connector atomic requests
try {
for (DataTierTupleSource connectorRequest : getConnectorRequests()) {
connectorRequest.cancelRequest();
}
} finally {
try {
if (transactionService != null) {
try {
transactionService.cancelTransactions(requestID.getConnectionID(), true);
} catch (XATransactionException err) {
throw new TeiidComponentException(QueryPlugin.Event.TEIID30544, err);
}
}
} finally {
this.moreWork();
}
}
return true;
}
use of org.teiid.client.xa.XATransactionException in project teiid by teiid.
the class TransactionServerImpl method beginDirect.
private void beginDirect(TransactionContext tc) throws XATransactionException {
try {
transactionManager.begin();
Transaction tx = transactionManager.suspend();
tc.setTransaction(tx);
tc.setCreationTime(System.currentTimeMillis());
} catch (javax.transaction.NotSupportedException err) {
throw new XATransactionException(QueryPlugin.Event.TEIID30528, err);
} catch (SystemException err) {
throw new XATransactionException(QueryPlugin.Event.TEIID30528, err);
}
}
use of org.teiid.client.xa.XATransactionException in project teiid by teiid.
the class TransactionServerImpl method end.
/**
* 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(QueryPlugin.Event.TEIID30520, XAException.XAER_INVAL, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30520));
}
} finally {
tc.setThreadId(null);
transactions.removeTransactionContext(threadId);
}
}
use of org.teiid.client.xa.XATransactionException in project teiid by teiid.
the class TransactionServerImpl method start.
/**
* 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(QueryPlugin.Event.TEIID30517, XAException.XAER_PROTO, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30517));
}
tc.setTransactionTimeout(timeout);
tc.setXid(xid);
tc.setTransactionType(TransactionContext.Scope.GLOBAL);
if (singleTM) {
tc.setTransaction(transactionManager.getTransaction());
if (tc.getTransaction() == null) {
// in theory we could inflow the txn and then change all of the methods to check singleTM off of the context
throw new XATransactionException(QueryPlugin.Event.TEIID30590, XAException.XAER_INVAL, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30590));
}
} 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(QueryPlugin.Event.TEIID30512, XAException.XAER_INVAL, e);
} catch (WorkException e) {
throw new XATransactionException(QueryPlugin.Event.TEIID30512, XAException.XAER_INVAL, e);
} catch (InterruptedException e) {
throw new XATransactionException(QueryPlugin.Event.TEIID30512, XAException.XAER_INVAL, e);
} catch (ExecutionException e) {
throw new XATransactionException(QueryPlugin.Event.TEIID30512, XAException.XAER_INVAL, e);
} catch (SystemException e) {
throw new XATransactionException(QueryPlugin.Event.TEIID30512, XAException.XAER_INVAL, e);
}
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(QueryPlugin.Event.TEIID30517, XAException.XAER_PROTO, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30517));
}
if (flags == XAResource.TMRESUME && !tc.getSuspendedBy().remove(threadId)) {
throw new XATransactionException(QueryPlugin.Event.TEIID30518, XAException.XAER_PROTO, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30518, new Object[] { xid, threadId }));
}
break;
}
default:
throw new XATransactionException(QueryPlugin.Event.TEIID30519, XAException.XAER_INVAL, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30519));
}
tc.setThreadId(threadId);
transactions.addTransactionContext(tc);
}
Aggregations