Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2006, Red Hat Middleware LLC, and individual contributors
   * as indicated by the @author tags.
   * See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   * This copyrighted material is made available to anyone wishing to use,
   * modify, copy, or redistribute it subject to the terms and conditions
   * of the GNU Lesser General Public License, v. 2.1.
  * This program is distributed in the hope that it will be useful, but WITHOUT A
  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
  * You should have received a copy of the GNU Lesser General Public License,
  * v.2.1 along with this distribution; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  * MA  02110-1301, USA.
  *
  * (C) 2005-2006,
  * @author JBoss Inc.
  */
 /*
  * Copyright (C) 1999-2001 by HP Bluestone Software, Inc. All rights Reserved.
  *
  * HP Arjuna Labs,
  * Newcastle upon Tyne,
  * Tyne and Wear,
  * UK.
  *
  * $Id: ActionStatusService.java 2342 2006-03-30 13:06:17Z  $
  */
 
 package com.arjuna.ats.arjuna.recovery;
 
 
 
 public class ActionStatusService implements Service
 {
   
Get a reference to the Transaction Store.
 
    public ActionStatusService()
    {
       if (  == null )
       {
           = StoreManager.getRecoveryStore();
       }
    }

   
Retrieve the transaction status for the specified Uid and if available transaction type.
 
 
    public int getTransactionStatusString transactionTypeString strUid )
    {
       int action_status = .;
 
       if (strUid != null)
       {
 	  Uid tranUid = new UidstrUid );
 
 	  if ( transactionType == null || transactionType.equals("") )
 	  {
 	      action_status = getTranStatustranUid );
 	  }
 	  else
 	  {
               action_status = getActionStatustranUidtransactionType );
 	  }
       }
 
       return action_status;
    }

   
Does the main work of reading in a uid and transaction type from the recovery manager, retrieving the status of the transaction and sending it back to the Recovery Manager.
 
 
   public void doWorkInputStream isOutputStream os )
      throws IOException
   {
      BufferedReader in  = new BufferedReader ( new InputStreamReader(is) );
      PrintWriter    out = new PrintWriter ( new OutputStreamWriter(os) );
      try
      {
         // Send the process id to the recovery module so that it
         // can verify that it is talking to the right process.
         out.println ( Utility.intToHexString( Utility.getpid() ));
         out.flush();
         // recovery module returns either "OK" or "DEAD"
         String rmStatus = in.readLine();
         if ( rmStatus.equals"OK" ) )
         {
            for (;;)
            {
               // read in a transaction type and its Uid sent by the
               // recovery module.
               String transactionType = null;
               String strUid = null;
	       try
	       {
		   transactionType = in.readLine();
		   strUid = in.readLine();
	       }
	       catch (IOException ex)
	       {
		   // recovery manager has torn down connection, so end loop
	       }
	       /*
	        * check for null - in theory we get this from readLine when EOF has been reached, although in practice
	        * since we are reading from a socket we will probably get an IOException in which case we will still
	        * see null
		    */
	       if ((transactionType == null) && (strUid == null))
		   return;
               int status = getTransactionStatustransactionTypestrUid );
               String strStatus = Integer.toStringstatus );
               out.printlnstrStatus );
               out.flush();
	           ..info_recovery_ActionStatusService_1(transactionTypestrUidstrStatus);
	    }
         }
      }
      catch ( IOException ex ) {
      }
      catch ( Exception ex ) {
      }
   }

    
Check for transaction status in the local hash table, if does not exist, then retrieve the status from the Object Store.
    private int getActionStatusUid tranUidString transactionType )
    {
	int action_status = .;
	try
	{
	    // check in local hash table
	    BasicAction basic_action = null;
	    synchronized ( ActionManager.manager() )
	    {
		basic_action = (BasicAction)ActionManager.manager().gettranUid );
	    }
	    if ( basic_action != null)
	    {
		action_status = basic_action.status();
	    }
	    else
	    {
		/*
		 * If there is a persistent representation for this
		 * transaction, then return that status.
		 */
		action_status = getObjectStoreStatustranUidtransactionType );
	    }
	}
	catch ( Exception ex ) {
    }
	return action_status;
    }

   
Get transaction status for a transaction when the transactionType is unknown.
   private int getTranStatusUid tranUid )
   {
      int action_status = .;
      try
      {
         BasicAction basic_action = null;
	 synchronized ( ActionManager.manager() )
         {
            basic_action = (BasicAction)ActionManager.manager().gettranUid );
         }
         if ( basic_action != null)
         {
            action_status = basic_action.status();
         }
         else
         {
            
Run through the object store and try and find the matching id.
            action_status = getOsStatustranUid );
         }
      }
      catch ( Exception ex ) {
      }
      return action_status;
   }

   
Obtains the status for the specified transaction Uid when the transaction type is unknown.
   private int getOsStatusUid tranUid )
   {
      int action_status = .;
      Vector matchingUidVector = new Vector();
      Vector matchingUidTypeVector = new Vector();
      try
      {
         InputObjectState types = new InputObjectState();
         // find all types
         if ( .allTypes(types) )
         {
            String theTypeName = null;
            try
            {
               boolean endOfList = false;
               while ( !endOfList )
               {
                  // extract a type
                  theTypeName = types.unpackString();
                  if ( theTypeName.compareTo("") == 0 )
                  {
                     endOfList = true;
                  }
                  else
                  {
                     InputObjectState uids = new InputObjectState();
                     try
                     {
                        boolean endOfUids = false;
                        if ( .allObjUidstheTypeNameuids ) )
                        {
                           Uid theUid = null;
                           while ( !endOfUids )
                           {
                              // extract a uid
                               theUid = UidHelper.unpackFrom(uids);
                              if (theUid.equals( Uid.nullUid() ))
                              {
                                 endOfUids = true;
                              }
                              else if ( theUid.equalstranUid ) )
                              {
                                 // add to vector
                                 matchingUidVector.addElementtranUid );
                                 matchingUidTypeVector.addElementtheTypeName );
                                 ..info_recovery_ActionStatusService_4(tranUid);
			      }
                           }
                        }
                     }
                     catch ( Exception ex ) {
                         ..warn_recovery_ActionStatusService_5(tranUidex);
                     }
                  }
               }
            }
            catch ( IOException ex ) {
                ..warn_recovery_ActionStatusService_5(tranUidex);
            }
            catch ( Exception ex ) {
                ..warn_recovery_ActionStatusService_5(tranUidex);
            }
         }
      }
      catch ( Exception ex ) {
      }
      int uidVectorSize = matchingUidVector.size();
      int first_index = 0;
      if ( uidVectorSize == 0 )
      {
         // no state means aborted because of presumed abort rules
         action_status = .;
      }
      else if ( uidVectorSize == 1 )
      {
         Uid uid = (Uid)matchingUidVector.getfirst_index );
         String typeName = (String)matchingUidTypeVector.getfirst_index );
         action_status = getObjectStoreStatusuidtypeName );
      }
      else if ( uidVectorSize > 1 )
      {
         // find root of hierarchy
         Uid rootUid = (Uid)matchingUidVector.getfirst_index );
         String rootTypeName = (String)matchingUidTypeVector.getfirst_index );
         for ( int index = first_index+1; index < uidVectorSizeindex++ )
         {
            String typeName = (String)matchingUidTypeVector.getindex );
            if ( typeName.length() < rootTypeName.length() )
            {
               rootTypeName = typeName;
               rootUid = (Uid)matchingUidVector.getindex );
            }
         }
         action_status = getObjectStoreStatusrootUidrootTypeName );
      }
      return action_status;
   }

   
Retrieve the status of the transaction from the object store.
   private int getObjectStoreStatusUid tranUidString transactionType )
   {
      int action_status = .;
      try
      {
         int osState = .currentStatetranUidtransactionType );
         switch ( osState )
         {
	     action_status = .;
	     break;
	     action_status = .;  // no state means aborted because of presumed abort rules
	     break;
	 case .        :
	 case .             :
	     action_status = .;
	     break;
         }
      }
      catch ( Exception ex ) {
      }
      return action_status;
   }

   
Reference to transaction object store.
   private static RecoveryStore _recoveryStore = null;
New to GrepCode? Check out our FAQ X