/** * Simple constructor. * * @param transaction the transaction created * @param lease the lease granted */ public Created(Transaction transaction, Lease lease) { this.transaction = transaction; this.lease = lease; if (lease != null) { ITransactionLease txlease = (ITransactionLease) lease; txlease.setCreatedTransaction(transaction); } }
public NestableTransaction.Created create(NestableTransactionManager mgr, long leaseTime) throws UnknownTransactionException, CannotJoinException, LeaseDeniedException, RemoteException { TransactionManager.Created rawTxn = mgr.create((NestableTransactionManager) this.mgr, id, leaseTime); NestableServerTransaction tx = new NestableServerTransaction(mgr, rawTxn.id, this, leaseTime); return new NestableTransaction.Created(tx, rawTxn.lease); }
@Override public boolean sameFailure(IDataConsumeResult otherResult) { if (!(otherResult instanceof UnknownTransactionConsumeResult)) return false; UnknownTransactionConsumeResult typedOtherResult = (UnknownTransactionConsumeResult) otherResult; return typedOtherResult._exception.toString().equals(_exception.toString()); }
public void commit(Xid xid, boolean onePhase) throws XAException { if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "XAResourceImpl:commit(), the xid is:" + xid + ", the onePhase:" + onePhase + " rmid=" + _rmid + " thread=" + Thread.currentThread().getId()); } xid = createGSXid(xid); try { m_txnManger.commit(xid, COMMIT_ABORT_DEFAULT_TIMEOUT); } catch (UnknownTransactionException e) { _logger.log(Level.SEVERE, "XAResourceImpl:commit() , unknowntxnException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XAER_RMERR, e); } catch (CannotCommitException e) { _logger.log(Level.SEVERE, "XAResourceImpl:commit() , cannotcommitException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XAER_RMERR, e); } catch (RemoteException e) { _logger.log(Level.SEVERE, "XAResourceImpl:commit() , remoteException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XAER_RMFAIL, e); } catch (TimeoutExpiredException e) { _logger.log(Level.SEVERE, "XAResourceImpl:commit() , timeoutexpiredException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XAER_RMFAIL, e); } finally { _activeEmptyTransactions.remove(xid); _suspendedXtns.remove(xid); if (_resourcePerSingleTxn) _relevantTx = false; } }
public void rollback(Xid xid) throws XAException { if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "XAResourceImpl:rollback(), the Xid is:" + xid + " rmid=" + _rmid + " thread=" + Thread.currentThread().getId()); } xid = createGSXid(xid); try { m_txnManger.abort(xid, COMMIT_ABORT_DEFAULT_TIMEOUT); } catch (UnknownTransactionException e) { if (failOnInvalidRollback) _logger.log(Level.SEVERE, "XAResourceImpl:rollback() , unknownTxnException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XA_RBPROTO, e); } catch (CannotAbortException e) { _logger.log(Level.SEVERE, "XAResourceImpl:rollback() , CannotAbortException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XA_RBPROTO, e); } catch (RemoteException e) { _logger.log(Level.SEVERE, "XAResourceImpl:rollback() , remoteException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XA_RBCOMMFAIL, e); } catch (TimeoutExpiredException e) { _logger.log(Level.SEVERE, "XAResourceImpl:rollback() , timeoutException rmid=" + _rmid + " thread=" + Thread.currentThread().getId() + " exception:" + e + e.getStackTrace()); throw createsXAException(XAException.XAER_RMFAIL, e); } finally { _activeEmptyTransactions.remove(xid); _suspendedXtns.remove(xid); if (_resourcePerSingleTxn) _relevantTx = false; } }
/** * Create new transaction using the local transaction manager * * @return created transaction */ private Transaction createTransaction() throws LeaseDeniedException, RemoteException, TransactionException { ITransactionManagerProvider transactionManagerProvider = getTransactionManagerProvider(); return (TransactionFactory.create(transactionManagerProvider.getTransactionManager(), _config.getTransactionTimeout())).transaction; }
/** * Commits the transaction if it was forced by the query. */ private void commitForcedTransaction(Query query, QuerySession session) throws UnknownTransactionException, CannotCommitException, RemoteException { if (session.isAutoCommit() && query.isForceUnderTransaction()) { session.getTransaction().commit(); session.setSelectedForUpdate(null); session.setTransaction(null); } }
int prepare(long waitFor) throws CannotCommitException, UnknownTransactionException, RemoteException { try { return commitImpl(waitFor, true /*prepareOnly*/); } catch (TimeoutExpiredException ex) { throw new CannotCommitException(getExternalXid().toString() + " " + ex.toString(), ex); } }
/** * Get the transaction entry for given transaction. Check if transaction is valid * * @return XtnEntry */ public XtnEntry getTransactionEntry(ServerTransaction txn) throws TransactionException { XtnEntry xtnEntry = m_XtnTable.get(txn); // check if this transaction is still active if (xtnEntry != null && !xtnEntry.isActive()) throw new TransactionException("Transaction is not active: " + txn.toString()); return xtnEntry; }
public void setReenteredPreparedXid() throws CannotCommitException { if (_externalXid == null) throw new UnsupportedOperationException(); if (getState() == ABORTED) throw new CannotCommitException(" xtn is aborted"); _reenteredPreparedXid = true; modifyTxnState(VOTING); modifyTxnState(PREPARED); } }
public DistributedTransactionManagerProvider() throws TransactionException { synchronized (_lock) { if (_transactionManager == null) { try { TxnManager impl = MahaloFactory.createMahalo(); _transactionManager = impl.getLocalProxy(); _txnManagerReferencesCount = 0; } catch (Exception e) { throw new TransactionException(e.getMessage(), e); } } _txnManagerReferencesCount++; } }
/** * AtomicSerial constructor * * @param arg atomic deserialization parameter * @throws IOException if there are I/O errors while reading from GetArg's * underlying <code>InputStream</code> */ public TimeoutExpiredException(GetArg arg) throws IOException, ClassNotFoundException{ super(check(arg)); committed = arg.get("committed", false); }
private ServerTransaction serverTransaction(Transaction baseTr) throws UnknownTransactionException { if (operationsLogger.isLoggable(Level.FINER)) { operationsLogger.entering( TxnManagerImpl.class.getName(), "serverTransaction", baseTr); } try { if (operationsLogger.isLoggable(Level.FINER)) { operationsLogger.exiting(TxnManagerImpl.class.getName(), "serverTransaction", baseTr); } return (ServerTransaction) baseTr; } catch (ClassCastException e) { throw new UnknownTransactionException("unexpected transaction type"); } }
public TransactionManager getLocalTransactionManager() throws JMSException { if (distributedTransactionManagerProvider == null) { try { synchronized (distributedTransactionManagerProviderLock) { if (distributedTransactionManagerProvider == null) distributedTransactionManagerProvider = new DistributedTransactionManagerProvider(); } } catch (TransactionException re) { if (_logger.isLoggable(Level.SEVERE)) _logger.log(Level.SEVERE, "Exception inside GSConnectionFactoryImpl.createLocalTransactionManager() : " + re.toString(), re); JMSException e = new JMSException("RemoteException: " + re.toString()); e.setLinkedException(re); throw e; } } return distributedTransactionManagerProvider.getTransactionManager(); }
private void throwCannotCommitExceptionIfNeeded(ParticipantHandle[] phs) throws CannotCommitException { Map<Integer, Exception> participantsExceptions = new HashMap<Integer, Exception>(); for (ParticipantHandle ph : phs) { if (ph.getCommitException() != null) { participantsExceptions.put(ph.getPartionId(), ph.getCommitException()); } } if (!participantsExceptions.isEmpty()) { throw new CannotCommitDistributedException("some participants failed in commit after prepare [ID=" + getTransaction().id +"]: - risk of partial transaction", participantsExceptions); } }
public NestableTransaction.Created create(NestableTransactionManager mgr, long leaseTime) throws UnknownTransactionException, CannotJoinException, LeaseDeniedException, RemoteException { TransactionManager.Created rawTxn = mgr.create((NestableTransactionManager)this.mgr, id, leaseTime); return new NestableTransaction.Created( new NestableServerTransaction(mgr, rawTxn.id, this), rawTxn.lease); }
private void prepareAndCommitPartitionWithEnabledFailover( ParticipantHandle singleHandle) throws CannotCommitException { TxnMgrProxy cur = (TxnMgrProxy) str.mgr; int res = PrepareAndCommitJob.commitAndPreparePartitionWithEnabledFailover(singleHandle, cur, str.id, _externalXid); if (res != COMMITTED) throw new CannotCommitException( "Unable to commit transaction: " + getParticipantInfo(), singleHandle.getCommitException()); modifyTxnState(COMMITTED); }
public LookupDistributedTransactionManagerProvider(LookupTransactionManagerConfiguration config) throws TransactionException { try { LookupRequest request = LookupRequest.TransactionManager() .setServiceName(config.getLookupTransactionName()) .setLocators(config.getLookupTransactionLocators()) .setGroups(config.getLookupTransactionGroups()) .setTimeout(config.getLookupTransactionTimeout()); _transactionManager = (TransactionManager) LookupFinder.find(request); } catch (FinderException e) { throw new TransactionException(e.getMessage(), e); } }
/** * Create a new top-level transaction, under which nested transactions can be created. * * @param mgr the transaction manager to use for this transaction * @param leaseTime the requested lease time for the transaction * @return the created transaction and the lease granted * @throws LeaseDeniedException if this manager is unwilling to grant the requested lease time * @throws RemoteException if a communication error occurs. */ public static NestableTransaction.Created create(NestableTransactionManager mgr, long leaseTime) throws LeaseDeniedException, RemoteException { TransactionManager.Created rawTxn = mgr.create(leaseTime); NestableServerTransaction tx = new NestableServerTransaction(mgr, rawTxn.id, null, leaseTime); return new NestableTransaction.Created(tx, rawTxn.lease); } }
/** * Create a new top-level transaction, under which nested transactions * can be created. * * @param mgr the transaction manager to use for this transaction * @param leaseTime the requested lease time for the transaction * @return the created transaction and the lease granted * * @throws LeaseDeniedException if this manager is unwilling to * grant the requested lease time * @throws RemoteException if a communication error occurs. */ public static NestableTransaction.Created create(NestableTransactionManager mgr, long leaseTime) throws LeaseDeniedException, RemoteException { TransactionManager.Created rawTxn = mgr.create(leaseTime); return new NestableTransaction.Created( new NestableServerTransaction(mgr, rawTxn.id, null), rawTxn.lease); } }