jotm
| /branches/jotm-2-0-11-br/jotm/src/main/org/objectweb/jotm/TransactionImpl.java |
|---|
| 99,8 → 99,14 |
| private List enlistedXARes = Collections.synchronizedList(new ArrayList()); |
| /// store suspended resources |
| private List delistedXARes = null; |
| // propagate context |
| /** |
| * propagate context or not. |
| * No need to propagate Context when accessing TM for example |
| * TODO Add a synchro on this object, and use it also for coord accesses. |
| */ |
| private boolean propagateCtx = true; |
| private List enlistedJavaxXid = Collections.synchronizedList(new ArrayList()); |
| /** |
| 134,7 → 140,6 |
| /** |
| * New Transaction for this thread (setPropagationContext) |
| * |
| * @param pctx propagation context |
| * |
| */ |
| 146,8 → 151,6 |
| } |
| myCtx = pctx; |
| myXid = pctx.getXid(); |
| // myXidhashcode = myXid.hashCode(); |
| // myXidtostring = myXid.toString(); |
| // Make interposition in any case, to solve problems of memory leaks |
| // and bad transaction count, in case no resource will be implied. |
| 194,7 → 197,6 |
| * @exception SystemException Thrown if the transaction manager |
| * encounters an unexpected error condition |
| */ |
| public void commit() |
| throws |
| RollbackException, |
| 306,7 → 308,6 |
| * @return true if the dissociation of the Resource is successful; |
| * false otherwise. |
| */ |
| public boolean delistResource(XAResource xares, int flag) |
| throws IllegalStateException, SystemException { |
| 398,7 → 399,6 |
| * encounters an unexpected error condition |
| * |
| */ |
| public boolean enlistResource(XAResource xares) |
| throws RollbackException, IllegalStateException, SystemException { |
| 576,7 → 576,6 |
| * encounters an unexpected error condition |
| * |
| */ |
| public int getStatus() throws SystemException { |
| if (TraceTm.jta.isDebugEnabled()) { |
| TraceTm.jta.debug("TransactionImpl.getStatus()"); |
| 625,7 → 624,6 |
| * @exception SystemException Thrown if the transaction manager |
| * encounters an unexpected error condition |
| */ |
| public void registerSynchronization(Synchronization sync) |
| throws RollbackException, IllegalStateException, SystemException { |
| if (TraceTm.jta.isDebugEnabled()) { |
| 652,7 → 650,6 |
| * encounters an unexpected error condition |
| * |
| */ |
| public void rollback() throws IllegalStateException, SystemException { |
| if (TraceTm.jta.isDebugEnabled()) { |
| TraceTm.jta.debug("TransactionImpl.rollback(tx= " + this +")"); |
| 720,7 → 717,6 |
| * encounters an unexpected error condition |
| * |
| */ |
| public int prepare() throws IllegalStateException, SystemException { |
| if (TraceTm.jta.isDebugEnabled()) { |
| TraceTm.jta.debug("TransactionImpl.prepare(tx= " + this +")"); |
| 731,13 → 727,10 |
| try { |
| ret = subcoord.prepare(); |
| } catch (RemoteException e) { |
| TraceTm.jotm.error( |
| "Unexpected Exception on prepare:", |
| e); |
| TraceTm.jotm.error("Unexpected Exception on prepare:", e); |
| throw new SystemException("Unexpected Exception on prepare"); |
| } |
| } |
| return ret; |
| } |
| 753,7 → 746,6 |
| * encounters an unexpected error condition |
| * |
| */ |
| public void setRollbackOnly() throws IllegalStateException, SystemException { |
| if (TraceTm.jta.isDebugEnabled()) { |
| TraceTm.jta.debug("Tx=" + this); |
| 869,9 → 861,7 |
| genXidhashcode = true; |
| myXidhashcode = getXid().hashCode(); |
| } |
| return myXidhashcode; |
| // return getXid().hashCode(); |
| } |
| // ------------------------------------------------------------------ |
| 881,15 → 871,12 |
| /** |
| * string form |
| */ |
| public String toString() { |
| if (!genXidtostring) { |
| genXidtostring = true; |
| myXidtostring = getXid().toString(); |
| } |
| return myXidtostring; |
| // return getXid().toString(); |
| } |
| /** |
| 898,9 → 885,7 |
| * @param hold true if must increment the count to hold the object (not used!) |
| * @return PropagationContext associated with the transaction. |
| */ |
| public synchronized TransactionContext getPropagationContext(boolean hold) { |
| if (propagateCtx) { |
| return myCtx; |
| } else { |
| /branches/jotm-2-0-11-br/jotm/src/main/org/objectweb/jotm/SubCoordinator.java |
|---|
| 89,8 → 89,7 |
| static final int DECISION_TO_COMMIT = 1; |
| static final int DECISION_TO_ROLLBACK = 2; |
| public void addResource( XAResource res, Xid xid, javax.transaction.xa.Xid javaxxid ) |
| { |
| public void addResource( XAResource res, Xid xid, javax.transaction.xa.Xid javaxxid ) { |
| if (TraceTm.jta.isDebugEnabled()) { |
| TraceTm.jta.debug("res= "+ res); |
| TraceTm.jta.debug("xid= "+ xid); |
| 214,7 → 213,6 |
| /** |
| * constructor used by TransactionImpl |
| */ |
| SubCoordinator(TransactionImpl tx, Xid xid) throws RemoteException { |
| if (TraceTm.jta.isDebugEnabled()) { |
| 237,7 → 235,6 |
| * |
| * @return int vote commit, rollback, or readonly. |
| */ |
| public int prepare() throws RemoteException { |
| if (TraceTm.jta.isDebugEnabled()) { |
| 340,7 → 337,6 |
| + StatusHelper.getStatusName(status)); |
| return; |
| } |
| doBeforeCompletion(false); |
| doRollback(); |
| } |
| 348,7 → 344,6 |
| /** |
| * phase 2 of the 2PC. |
| */ |
| public void commit() throws RemoteException { |
| if (TraceTm.jta.isDebugEnabled()) { |
| 364,7 → 359,6 |
| + StatusHelper.getStatusName(status)); |
| return; |
| } |
| doCommit(); |
| } |
| 487,7 → 481,6 |
| /** |
| * forget heuristics about this transaction. |
| */ |
| public void forget() throws RemoteException { |
| if (TraceTm.jta.isDebugEnabled()) { |
| TraceTm.jta.debug("SubCoordinator.forget()"); |
| 512,7 → 505,6 |
| * target object is in prepared state or the transaction is inactive. |
| * |
| */ |
| public void addSynchronization(Synchronization synchro) |
| throws RollbackException, IllegalStateException { |
| 522,7 → 514,6 |
| } |
| // check status: should be ACTIVE. |
| boolean markedRollback = false; |
| switch (status) { |
| 541,7 → 532,6 |
| } |
| // Add synchro to the list of local synchros |
| synchroList.addElement(synchro); |
| // If transaction marked rollback only, we add synchro but we throw |
| 555,7 → 545,6 |
| } |
| throw new RollbackException(); |
| } |
| } |
| /** |
| 568,7 → 557,6 |
| * @exception IllegalStateException Thrown if the transaction in the |
| * target object is in prepared state or the transaction is inactive. |
| */ |
| public synchronized boolean addResource(XAResource xares) |
| throws IllegalStateException { |
| 578,7 → 566,6 |
| } |
| // check status: should be ACTIVE. |
| boolean markedRollback = false; |
| switch (status) { |
| 636,52 → 623,51 |
| // rolled back. |
| if (markedRollback) { |
| if (TraceTm.jta.isDebugEnabled()) { |
| TraceTm.jta.debug("SubCoordinator.addResource: transaction set rollback only"); |
| } |
| } |
| return found; |
| } |
| /** |
| * add this javaxxid to the List |
| * @param javaxxid |
| */ |
| public synchronized void addJavaxXid(javax.transaction.xa.Xid javaxxid) { |
| if (TraceTm.jta.isDebugEnabled()) { |
| TraceTm.jta.debug("addJavaxXid javaxxid="+ javaxxid); |
| } |
| // add this javaxxid to the List at the index location of XAResource |
| javaxxidList.addElement(javaxxid); |
| if (TraceTm.jta.isDebugEnabled()) { |
| TraceTm.jta.debug("new JavaxXid added to the list"); |
| } |
| } |
| /** |
| * Get the javaxxid at specified index in the list |
| * @param xaresindex |
| * @return javaxxid |
| */ |
| public javax.transaction.xa.Xid getJavaxXid(int xaresindex) { |
| javax.transaction.xa.Xid myjavaxxid = (javax.transaction.xa.Xid) javaxxidList.elementAt(xaresindex); |
| return myjavaxxid; |
| } |
| /** |
| * return the status of this transaction |
| */ |
| public int getStatus() { |
| if (TraceTm.jta.isDebugEnabled()) { |
| TraceTm.jta.debug("status="+ StatusHelper.getStatusName(status)); |
| } |
| return status; |
| } |
| public javax.transaction.xa.Xid getJavaxXid(int xaresindex) { |
| javax.transaction.xa.Xid myjavaxxid = (javax.transaction.xa.Xid) javaxxidList.elementAt(xaresindex); |
| return myjavaxxid; |
| } |
| /** |
| * set the transaction "rollback only" |
| */ |
| public void setRollbackOnly() { |
| if (TraceTm.jta.isDebugEnabled()) { |
| 715,7 → 701,6 |
| /** |
| * forget Transaction |
| */ |
| private void doForget() throws RemoteException { |
| if (TraceTm.jta.isDebugEnabled()) { |
| TraceTm.jta.debug("SubCoordinator.doForget()"); |
| 765,7 → 750,6 |
| * Basically, send prepare on each XAResource and |
| * collect the results. |
| */ |
| private synchronized int doPrepare() throws RemoteException { |
| if (TraceTm.jta.isDebugEnabled()) { |
| TraceTm.jta.debug("SubCoordinator.doPrepare()"); |
| 883,7 → 867,6 |
| * 2PC - phase 2 (commit) |
| * See JTM for heuristics management |
| */ |
| private synchronized int doCommit() throws RemoteException { |
| if (TraceTm.jta.isDebugEnabled()) { |
| TraceTm.jta.debug("SubCoordinator.doCommit()"); |
| 1261,7 → 1244,6 |
| /** |
| * 1PC (commit one phase) |
| */ |
| private synchronized void doOnePhaseCommit() throws RemoteException { |
| if (TraceTm.jta.isDebugEnabled()) { |
| TraceTm.jta.debug("SubCoordinator.doOnePhaseCommit()"); |
| 1399,7 → 1381,6 |
| Current.getCurrent().incrementRollbackCounter(); |
| doAfterCompletion(); |
| } |
| /** |
| 1407,17 → 1388,16 |
| * |
| * @param boolean true if completion ok, false if rollback |
| */ |
| private void doBeforeCompletion(boolean committing) { |
| if (TraceTm.jta.isDebugEnabled()) { |
| TraceTm.jta.debug("doBeforeCompletion committing= "+ committing); |
| } |
| if (beforeCompletionDone) |
| if (beforeCompletionDone) { |
| return; |
| } |
| // Unset the timer for this transaction, if any |
| tx.unsetTimer(); |
| // For each synchro, send beforeCompletion (not if rollback) |
| 1588,7 → 1568,6 |
| /** |
| * after completion |
| */ |
| private void doAfterCompletion() { |
| if (TraceTm.jta.isDebugEnabled()) { |
| TraceTm.jta.debug("doAfterCompletion()"); |
| 1625,15 → 1604,17 |
| try { |
| unexportObject(this); |
| } catch (Exception e) {} |
| } catch (Exception e) { |
| } |
| } |
| // ------------------------------------------------------------------ |
| // new method for TxImpl |
| // ------------------------------------------------------------------ |
| /** |
| * return index in resourceList of this XAResource |
| * @param xares the XAResource |
| * @return index |
| */ |
| public int getXaresIndex(XAResource xares) { |
| public int getXaresIndex( XAResource xares ) { |
| if (TraceTm.jta.isDebugEnabled()) { |
| TraceTm.jta.debug("getXaresIndex xares= "+ xares); |
| TraceTm.jta.debug("resourceList.size= " + resourceList.size()); |
| /branches/jotm-2-0-11-br/jotm/src/main/org/objectweb/jotm/Current.java |
|---|
| 724,7 → 724,6 |
| (tx.getStatus() != Status.STATUS_PREPARING)) { |
| TraceTm.jotm.error("resume: Invalid Transaction Status:" + StatusHelper.getStatusName(tx.getStatus())); |
| InvalidTransactionException e = new InvalidTransactionException("Invalid resume " + tobj.getClass().getName()); |
| e.printStackTrace(); |
| throw e; |
| } |
| TraceTm.jotm.debug("status = " + StatusHelper.getStatusName(tx.getStatus())); |
| 1539,16 → 1538,16 |
| } |
| } |
| List recoveredXidList = new LinkedList(); // new code |
| List recoveredXidList = new LinkedList(); |
| try { |
| boolean first = true; |
| while (true) { |
| javax.transaction.xa.Xid[] javaxids; |
| javaxids = xaresource.recover (first ? XAResource.TMSTARTRSCAN : XAResource.TMNOFLAGS); |
| if (javaxids == null || javaxids.length == 0) |
| if (javaxids == null || javaxids.length == 0) { |
| break; |
| } |
| first = false; |
| recoveredXidList.addAll(Arrays.asList(javaxids)); |
| } |
| 1613,24 → 1612,19 |
| // If the count in the TxRecovered vector entry is zero, we can then remove |
| // the TxRecovered entry from the vector. |
| Vector vTxRecovered = null; |
| TxRecovered txr = null; |
| TxxidRecovered mytxxidRecovered = null; |
| int txCount; |
| int myxacount = 0; |
| boolean mytxxidrecoveredfound = false; |
| byte [] jotmDone = new byte [11]; |
| byte [] [] jotmDoneRecord = new byte [1] [11]; |
| jotmDone = "RR3JOTMDONE".getBytes(); |
| byte [] jotmDone = "RR3JOTMDONE".getBytes(); |
| vTxRecovered = JotmRecovery.getTxRecovered(); |
| txCount = vTxRecovered.size(); |
| Vector vTxRecovered = JotmRecovery.getTxRecovered(); |
| int txCount = vTxRecovered.size(); |
| for (int i = 0; i < txCount; i++) { |
| txr = (TxRecovered) vTxRecovered.elementAt(i); |
| myxacount = txr.getxidcount(); |
| TxRecovered txr = (TxRecovered) vTxRecovered.elementAt(i); |
| int myxacount = txr.getxidcount(); |
| for (int j = 0; j < myxacount; j++) { |
| mytxxidRecovered = txr.getRecoverTxXidInfo(j); |
| 1638,7 → 1632,6 |
| if (mytxxidRecovered != null) { |
| if (pFullXid.equals(new String(mytxxidRecovered.getRecoverxid()))) { |
| // mytxxidRecovered.setRecoverstatus(Status.STATUS_NO_TRANSACTION); |
| mytxxidRecovered.setRecoverstatus(Status.STATUS_COMMITTED); |
| mytxxidrecoveredfound = true; |
| break; |