FileDocCategorySizeDatePackage
AdminUtil.javaAPI DocGlassfish v2 API13375Fri May 04 22:36:36 BST 2007com.sun.jts.CosTransactions

AdminUtil

public class AdminUtil extends Object
AdminUtil - Utility class for monitoring and administering jts. This class is used by admin utilities for performing monitoring and administration.
author
Ajay Kumar
version
1.0

Fields Summary
private static RWLock
statisticsLock
private static long
lSampleStartTime
private static long
lSampleEndTime
static boolean
bSampling
private static int
iCommits
private static int
iAborts
private static int
iUAborts
private static int
iPending
static int
iRecCommits
static int
iRecAborts
private static Object
lkCommits
private static Object
lkAborts
private static Object
lkUAborts
private static Object
lkPending
static Object
lkRecCommits
static Object
lkRecAborts
Constructors Summary
Methods Summary
public static voidfreezeAll()
freezeAll Freeze all transactional activity. Part of freezing functions that will be used to achive a transactional quiet period before taking any action or collecting any statistics. This call returns when all the activities are frozen. All the states would be allowed to complete before freezing on. For example a transaction in preparing state would be allowed to transition to next state - the prepared state.

        TransactionState.freezeLock.acquireWriteLock();
    
public static longgetAbortedTransactionCount()
Return the count of rolledback transactions.

        return iAborts;
    
public static longgetActiveTransactionCount()
Return the number of transactions that are active currently.

        return RecoveryManager.getCoordsByGlobalTID().size() 
            - getPendingTransactionCount();
    
public static java.util.EnumerationgetAllTIDs()
Returned enumeration of globaltids of existing transactions.

        return RecoveryManager.getCoordsByGlobalTID().keys(); 
    
public static java.util.CollectiongetAllTransactions()
Returns the collection of existing coordinators.

        return RecoveryManager.getCoordsByGlobalTID().values(); 
    
public static longgetCommitedTransactionCount()
Return the committed transactions count.

        return iCommits;
    
public static longgetPendingTransactionCount()
Return the count of transactions that are prepared - but not completed. This includes the total transactions that ever entered into prepared state minus ones which got committed, rolledback, taking care of ones that were rolledback without entering prepared state.

        return iPending-iAborts-iCommits+iUAborts;
    
public static longgetRecoveryAbortedTransactionCount()
Return the number of transactions that were rolled back as part of the recovery process.

        return iRecAborts;
    
public static longgetRecoveryCommitedTransactionCount()
Return the count of transactions that were commited as part of the recovery process.

        return iRecCommits;
    
public static longgetSamplingDuration()
Returns the duration for which the last sampling window was open, in milliseconds. If the sampling window is still open, then the running duration is returned.

        return ( lSampleEndTime == 0 && lSampleStartTime != 0 )
            ? System.currentTimeMillis() - lSampleStartTime
            : lSampleEndTime - lSampleStartTime;
    
public static longgetSamplingEndTime()
Returns the time in millisecond , since the begining of time, when the sampling window was closed.

        return lSampleEndTime;
    
public static longgetSamplingStartTime()
Returns the time in milliseconds, since the begining of time, when the sampling window was started.

        return lSampleStartTime;
    
static voidincrementAbortedTransactionCount()
Increment the count of transactions that were rolled back.

        try
        {
            statisticsLock.acquireReadLock();
            synchronized ( lkAborts )
            {
                iAborts++;
            }
        }
        finally
        {
            statisticsLock.releaseReadLock();
        }
    
static voidincrementCommitedTransactionCount()
Increment the count of committed transactions.

        try
        {
            statisticsLock.acquireReadLock();
            synchronized ( lkCommits )
            {
                iCommits++;
            }
        }
        finally
        {
            statisticsLock.releaseReadLock();
        }
    
static voidincrementPendingTransactionCount()
Increment the count of pending transactions - i.e. the transactions entering the prepared state.

        try
        {
            statisticsLock.acquireReadLock();
            synchronized ( lkPending )
            {
                iPending++;
            }
        }
        finally
        {
            statisticsLock.releaseReadLock();
        }
    
public static voidincrementRecoveryAbortedTransactionCount()
Increments the number of transactions that were rolled back as part of the recovery process.

        try
        {
            statisticsLock.acquireReadLock();
            synchronized ( lkRecAborts )
            {
                iRecAborts++;
            }
        }
        finally
        {
            statisticsLock.releaseReadLock();
        }
    
public static voidincrementRecoveryCommitedTransactionCount()
Increments the number of transactions that were commited as part of the recovery process.

        try
        {
            statisticsLock.acquireReadLock();
            synchronized ( lkRecCommits )
            {
                iRecCommits++;
            }
        }
        finally
        {
            statisticsLock.releaseReadLock();
        }
    
static voidincrementUnpreparedAbortedTransactionCount()
Increment the count of transactions that were rolled back and ne'er went through prepare phase.

        try
        {
            statisticsLock.acquireReadLock();
            synchronized ( lkUAborts )
            {
                iUAborts++;
            }
        }
        finally
        {
            statisticsLock.releaseReadLock();
        }
    
public static booleanisFrozenAll()
isFrozenAll Get the current state. Part of freezing functions that will be used to achive a transactional quiet period before taking any action or collecting any statistics. This call returns almost immediately.

        return TransactionState.freezeLock.isWriteLocked();
    
public static voidstartSampling()
startSampling Start the sampling window. The sample window determines the duration in which the data is collected. Start and stop calls demarcate the the window. The sampling data could be number of transactions committed ,rolledback etc and transient data like pending etc. It also resets various counters.

see
stopSampling

		if(!bSampling){
	        try
    	    {
            	statisticsLock.acquireWriteLock();
	            lSampleEndTime = 0 ;
   	         	lSampleStartTime = System.currentTimeMillis();
   	         	iCommits = 0;
            	iAborts = 0;
            	iPending = 0;
            	iRecCommits = 0;
            	iRecAborts = 0;
            	//iImmigerent = 0;
            	//iEmmigerent = 0;
            	Iterator iter = getAllTransactions().iterator();
            	
				while ( iter.hasNext() )
            	{
               	 CoordinatorImpl coord = (CoordinatorImpl)iter.next();
               	 if ( coord.get_status() == 
                     org.omg.CosTransactions.Status.StatusPrepared )
                    iPending++;
           		}
            
				bSampling = true;
        	}
	        finally
   		    {
       		     statisticsLock.releaseWriteLock();
        	}
		}
    
public static voidstopSampling()
stopSampling Stop sampling the statitics values. This is used to indicate end of sampling window.

see
startSampling

        try
        {
            statisticsLock.acquireWriteLock();
            lSampleEndTime = System.currentTimeMillis();
            bSampling = false;
        }
        finally
        {
            statisticsLock.releaseWriteLock();
        }
    
public static voidunfreezeAll()
unfreezeAll Unfreeze all transactional activity frozen by a freezeAll call. Part of freezing functions that will be used to achive a transactional quiet period before taking any action or collecting any statistics. This call returns almost immediately.

        TransactionState.freezeLock.releaseWriteLock();