User: fleury  
  Date: 00/09/26 12:09:50

  Modified:    src/main/org/jboss/tm TxCapsule.java
  Log:
  TxCapsule with traces
  
  Revision  Changes    Path
  1.6       +55 -8     jboss/src/main/org/jboss/tm/TxCapsule.java
  
  Index: TxCapsule.java
  ===================================================================
  RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/tm/TxCapsule.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TxCapsule.java    2000/09/10 18:39:08     1.5
  +++ TxCapsule.java    2000/09/26 19:09:50     1.6
  @@ -46,7 +46,7 @@
    *  @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
    *  @author <a href="mailto:[EMAIL PROTECTED]">Ole Husgaard</a>
    *
  - *  @version $Revision: 1.5 $
  + *  @version $Revision: 1.6 $
    */
   class TxCapsule implements TimeoutTarget
   {
  @@ -56,7 +56,7 @@
      static private final int HEUR_NONE     = XAException.XA_RETRY;
   
      // Attributes ----------------------------------------------------
  -
  +   
      // Static --------------------------------------------------------
   
      static private int nextId = 0;
  @@ -186,8 +186,10 @@
                SystemException
      {
         try {
  -         lock();
  -
  +         Logger.log("TxCapsule before lock");
  +              lock();
  +         Logger.log("TxCapsule after lock status is "+getStringStatus(status));
  +              
            switch (status) {
            case Status.STATUS_PREPARING:
               throw new IllegalStateException("Already started preparing.");
  @@ -213,6 +215,7 @@
               doAfterCompletion();
               throw new RollbackException("Already marked for rollback");
            case Status.STATUS_ACTIVE:
  +                      Logger.log("Commiting tx with status Active");
               break;
            default:
               throw new IllegalStateException("Illegal status: " + status);
  @@ -222,14 +225,21 @@
   
            doBeforeCompletion();
   
  +              Logger.log("Before completion is done status is 
"+getStringStatus(status));
  +              
            if (status == Status.STATUS_ACTIVE) {
               if (resources.size() == 0) {
  +                             Logger.log("no resources 0 phi commit");
                  // Zero phase commit is really fast ;-)
                  status = Status.STATUS_COMMITTED;
               } else if (resources.size() == 1) {
  -               // One phase commit
  +               Logger.log("1 resource 1 phi commit");
  +                        // One phase commit
  +                        
                  commitResources(true);
               } else {
  +                             
  +                             Logger.log("many resources 2 phi commit");
                  // Two phase commit
   
                  if (!prepareResources()) {
  @@ -252,7 +262,7 @@
               rollbackResources();
               doAfterCompletion();
               cancelTimeout();
  -            throw new RollbackException("Unable to commit.");
  +            throw new RollbackException("Unable to commit transaction has status. 
"+getStringStatus(status));
            }
   
            cancelTimeout();
  @@ -265,6 +275,35 @@
         }
      }
   
  +     private String getStringStatus(int status) {
  +             
  +              switch (status) {
  +         case Status.STATUS_PREPARING:
  +            return "STATUS_PREPARING";
  +         case Status.STATUS_PREPARED:
  +            return "STATUS_PREPARED";
  +         case Status.STATUS_ROLLING_BACK:
  +            return "STATUS_ROLLING_BACK";
  +         case Status.STATUS_ROLLEDBACK:
  +            return "STATUS_ROLLEDBACK";
  +         case Status.STATUS_COMMITTING:
  +            return "STATUS_COMMITING";
  +         case Status.STATUS_COMMITTED:
  +            return "STATUS_COMMITED";
  +         case Status.STATUS_NO_TRANSACTION:
  +            return "STATUS_NO_TRANSACTION";
  +         case Status.STATUS_UNKNOWN:
  +            return "STATUS_UNKNOWN";
  +         case Status.STATUS_MARKED_ROLLBACK:
  +            return "STATUS_MARKED_ROLLBACK";
  +         case Status.STATUS_ACTIVE:
  +                     return "STATUS_ACTIVE"; 
  +          
  +         default:
  +                     return "STATUS_UNKNOWN";
  +             }
  +            
  +     }
      /**
       *  Rollback the transaction encapsulated here.
       *  Should not be called directly, use <code>TxManager.rollback()</code>
  @@ -695,8 +734,12 @@
      {
         unlock();
         try {
  -         for (int i = 0; i < sync.size(); i++)
  +         for (int i = 0; i < sync.size(); i++) {
  +                      Logger.log("calling beforeCompletion on synch status is 
"+getStringStatus(status));
               ((Synchronization)sync.get(i)).beforeCompletion();
  +                      Logger.log("Done calling beforeCompletion on synch status is 
"+getStringStatus(status));
  +            
  +             }
         } finally {
            lock();
         }
  @@ -808,6 +851,7 @@
         boolean readOnly = true;
   
         status = Status.STATUS_PREPARING;
  +      Logger.log("Status Preparing: "+status);
   
         for (int i = 0; i < resources.size(); i++) {
            // Abort prepare on state change.
  @@ -821,7 +865,10 @@
   
               unlock();
               try {
  -               vote = resource.prepare(xid);
  +                        vote = resource.prepare(xid);
  +                        
  +               Logger.log("resource vote is "+vote);
  +                        
               } finally {
                  lock();
               }
  
  
  

Reply via email to