FileDocCategorySizeDatePackage
JTAStatsImpl.javaAPI DocGlassfish v2 API10105Fri May 04 22:35:58 BST 2007com.sun.enterprise.transaction.monitor

JTAStatsImpl

public class JTAStatsImpl extends Object implements MonitoringLevelListener, com.sun.enterprise.admin.monitor.stats.JTAStats

Fields Summary
private JTSMonitorMBean
mBean
private GenericStatsImpl
gStatsDelegate
static Logger
_logger
private static JTAStatsImpl
instance
Constructors Summary
private JTAStatsImpl(JTSMonitorMBean mBean)


    // Will be instantiated by JTSMonitorMBean
       
        this.mBean = mBean;
        try {
            gStatsDelegate = new GenericStatsImpl("com.sun.enterprise.admin.monitor.stats.JTAStats",this);
        } catch (ClassNotFoundException clex) {
            _logger.log(Level.WARNING,"transaction.monitor.error_creating_jtastatsimpl",clex);
            // log and forget. Should not happen
        }
    
Methods Summary
public voidchangeLevel(MonitoringLevel from, MonitoringLevel to, MonitoredObjectType type)

        if (from != to) {
            _logger.log(Level.FINE,"JTAStats Monitoring level changed from " + from + "  to  " + to);
            if (to == MonitoringLevel.OFF) {
                mBean.stopMonitoring();
            }
            else if (to == MonitoringLevel.LOW || to == MonitoringLevel.HIGH) {
                mBean.startMonitoring();
            }
        }
	
public voidchangeLevel(MonitoringLevel from, MonitoringLevel to, javax.management.j2ee.statistics.Stats handback)

        if (from != to) {
            _logger.log(Level.FINE,"JTAStats Monitoring level changed from " + from + "  to  " + to);
            if (to == MonitoringLevel.OFF) {
                mBean.stopMonitoring();
            }
            else if (to == MonitoringLevel.LOW || to == MonitoringLevel.HIGH) {
                mBean.startMonitoring();
            }
        }
    
public static synchronized voidcreateInstance(JTSMonitorMBean mBean)

        if (instance == null)
            instance = new JTAStatsImpl(mBean);
    
public voidfreeze()

        mBean.freeze();
    
public CountStatisticgetActiveCount()

        Integer count = null; 
        try {
            count = (Integer)mBean.getAttribute(JTSMonitorMBean.NUM_TRANSACTIONS_INFLIGHT); 
        }catch (javax.management.AttributeNotFoundException jmxex) {
           _logger.log(Level.WARNING,"transaction.monitor.attribute_not_found",jmxex);
          // log and forget. Should not happen
        }
        return new CountStatisticImpl(count.longValue(), 
                                      "ActiveCount", 
                                      // "getActiveCount", 
                                      CountStatisticImpl.DEFAULT_UNIT, 
                                      "number of active transactions", 
                                       System.currentTimeMillis(), 
                                       mBean.getStartTime());
    
public StringStatisticgetActiveIds()

        String activeStr = null;
        try {
            activeStr = (String)mBean.getAttribute(JTSMonitorMBean.INFLIGHT_TRANSACTIONS);
        }catch (javax.management.AttributeNotFoundException jmxex) {
           _logger.log(Level.WARNING,"transaction.monitor.attribute_not_found",jmxex);
        }
        return new StringStatisticImpl(activeStr, 
                                      "ActiveIds", 
                                       //"getActiveIds", 
                                       "List", 
                                       "List of inflight transactions", 
                                       mBean.getStartTime(),
                                       System.currentTimeMillis()); 
    
public CountStatisticgetCommittedCount()

        Integer count = null; 
        try {
            count = (Integer)mBean.getAttribute(JTSMonitorMBean.NUM_TRANSACTIONS_COMPLETED); 
        }catch (javax.management.AttributeNotFoundException jmxex) {
           _logger.log(Level.WARNING,"transaction.monitor.attribute_not_found",jmxex);
          // log and forget. Should not happen
        }
        return new CountStatisticImpl(count.longValue(), 
                                      "CommittedCount", 
                                      //"getCommittedCount", 
                                      CountStatisticImpl.DEFAULT_UNIT, 
                                      "number of committed transactions", 
                                       System.currentTimeMillis(), 
                                       mBean.getStartTime());
    
public static synchronized com.sun.enterprise.transaction.monitor.JTAStatsImplgetInstance()

        if (instance == null)
            throw new UnsupportedOperationException();
        return instance;
    
public CountStatisticgetRolledbackCount()

        Integer count = null; 
        try {
            count = (Integer)mBean.getAttribute(JTSMonitorMBean.NUM_TRANSACTIONS_ROLLEDBACK); 
        }catch (javax.management.AttributeNotFoundException jmxex) {
           _logger.log(Level.WARNING,"transaction.monitor.attribute_not_found",jmxex);
          // log and forget. Should not happen
        }
        return new CountStatisticImpl(count.longValue(), 
                                      "RolledbackCount", 
                                      //"getRolledbackCount", 
                                      CountStatisticImpl.DEFAULT_UNIT, 
                                      "number of rolled-back transactions", 
                                       System.currentTimeMillis(), 
                                       mBean.getStartTime());
    
public StringStatisticgetState()

        String str = null;
        try {
            str = (String)mBean.getAttribute(JTSMonitorMBean.IS_FROZEN);
        }catch (javax.management.AttributeNotFoundException jmxex) {
           _logger.log(Level.WARNING,"transaction.monitor.attribute_not_found",jmxex);
          // log and forget. Should not happen
        }
        
        return new StringStatisticImpl(str, 
                                       "State", 
                                       //"getState", 
                                       "String", 
                                       "Transaction system state: frozen?", 
                                       mBean.getStartTime(),
                                       System.currentTimeMillis()); 
    
public StatisticgetStatistic(java.lang.String statisticName)
public String[] rollback(String[] txnIds) { return mBean.rollback(txnIds); }

        return gStatsDelegate.getStatistic(statisticName);
    
public java.lang.String[]getStatisticNames()

        return gStatsDelegate.getStatisticNames();
    
public Statistic[]getStatistics()

        return gStatsDelegate.getStatistics();
    
public java.lang.BooleanisRecoveryRequired()

        return RecoveryManager.isIncompleteTxRecoveryRequired();
    
public java.util.ListlistActiveTransactions()

        return mBean.listActiveTransactions();
    
public java.lang.Stringrollback(java.lang.String txnId)
method for rolling back a single transaction

param
txnId String representing the Id of the transaction to be roled back

        String  result = (String) mBean.setRollback(txnId);
        if (_logger.isLoggable(Level.FINE))
		    _logger.log(Level.FINE, result);
        return result;
	
public voidsetLevel(MonitoringLevel level)

        if (level == MonitoringLevel.OFF) {
            mBean.stopMonitoring();
        }
        else if (level == MonitoringLevel.LOW || level == MonitoringLevel.HIGH) {
            mBean.startMonitoring();
        } 
    
public voidunfreeze()

        mBean.unfreeze();