Search in sources :

Example 1 with TransactionAdminBean

use of com.sun.enterprise.transaction.api.TransactionAdminBean in project Payara by payara.

the class JavaEETransactionManagerSimplified method getActiveTransactions.

/*
    *  This method returns the details of the Currently Active Transactions
    *  Called by Admin Framework when transaction monitoring is enabled
    *  @return ArrayList of TransactionAdminBean
    *  @see TransactionAdminBean
    */
public ArrayList getActiveTransactions() {
    ArrayList tranBeans = new ArrayList();
    txnTable = new Hashtable();
    // get the clone of the active transactions
    Object[] activeCopy = activeTransactions.toArray();
    for (int i = 0; i < activeCopy.length; i++) {
        try {
            Transaction tran = (Transaction) activeCopy[i];
            TransactionAdminBean tBean = getDelegate().getTransactionAdminBean(tran);
            if (tBean == null) {
                // Shouldn't happen
                _logger.warning("enterprise_distributedtx.txbean_null" + tran);
            } else {
                if (_logger.isLoggable(Level.FINE))
                    _logger.log(Level.FINE, "TM: Adding txnId " + tBean.getId() + " to txnTable");
                txnTable.put(tBean.getId(), tran);
                tranBeans.add(tBean);
            }
        } catch (Exception ex) {
            _logger.log(Level.SEVERE, "transaction.monitor.error_while_getting_monitor_attr", ex);
        }
    }
    return tranBeans;
}
Also used : JavaEETransaction(com.sun.enterprise.transaction.api.JavaEETransaction) TransactionAdminBean(com.sun.enterprise.transaction.api.TransactionAdminBean) PluginPoint(org.glassfish.external.probe.provider.PluginPoint) InvocationException(org.glassfish.api.invocation.InvocationException) WorkException(javax.resource.spi.work.WorkException) RemoteException(java.rmi.RemoteException) XAException(javax.transaction.xa.XAException)

Example 2 with TransactionAdminBean

use of com.sun.enterprise.transaction.api.TransactionAdminBean in project Payara by payara.

the class JavaEETransactionManagerSimplified method getTransactionAdminBean.

public TransactionAdminBean getTransactionAdminBean(Transaction tran) throws javax.transaction.SystemException {
    TransactionAdminBean tBean = null;
    if (tran instanceof JavaEETransaction) {
        JavaEETransactionImpl tran1 = (JavaEETransactionImpl) tran;
        String id = tran1.getTransactionId();
        long startTime = tran1.getStartTime();
        String componentName = tran1.getComponentName();
        ArrayList<String> resourceNames = tran1.getResourceNames();
        long elapsedTime = System.currentTimeMillis() - startTime;
        String status = getStatusAsString(tran.getStatus());
        tBean = new TransactionAdminBean(tran, id, status, elapsedTime, componentName, resourceNames);
    }
    return tBean;
}
Also used : JavaEETransaction(com.sun.enterprise.transaction.api.JavaEETransaction) TransactionAdminBean(com.sun.enterprise.transaction.api.TransactionAdminBean)

Example 3 with TransactionAdminBean

use of com.sun.enterprise.transaction.api.TransactionAdminBean in project Payara by payara.

the class TransactionServiceStatsProvider method getActiveIds.

@ManagedAttribute(id = "activeids")
@Description("List of inflight transactions.")
public StringStatistic getActiveIds() {
    if (txMgr == null) {
        _logger.warning("transaction.monitor.tm_null");
        inflightTransactions.setCurrent("");
        return inflightTransactions;
    }
    List aList = txMgr.getActiveTransactions();
    StringBuffer strBuf = new StringBuffer(1024);
    if (!aList.isEmpty()) {
        // Set the headings for the tabular output
        int componentNameLength = COLUMN_LENGTH;
        int txIdLength = COLUMN_LENGTH + 15;
        for (int i = 0; i < aList.size(); i++) {
            TransactionAdminBean txnBean = (TransactionAdminBean) aList.get(i);
            String componentName = txnBean.getComponentName();
            if (componentName.length() > componentNameLength) {
                componentNameLength = componentName.length() + 1;
            }
            String txnId = txnBean.getId();
            if (txnId.length() > txIdLength) {
                txIdLength = txnId.length() + 1;
            }
        }
        if (aList.size() > 0) {
            strBuf.append(LINE_BREAK).append(LINE_BREAK);
            appendColumn(strBuf, "Transaction Id", txIdLength);
            appendColumn(strBuf, "Status", COLUMN_LENGTH);
            appendColumn(strBuf, "ElapsedTime(ms)", COLUMN_LENGTH);
            appendColumn(strBuf, "ComponentName", componentNameLength);
            strBuf.append("ResourceNames ").append(LINE_BREAK);
        }
        for (int i = 0; i < aList.size(); i++) {
            TransactionAdminBean txnBean = (TransactionAdminBean) aList.get(i);
            String txnId = txnBean.getId();
            _logger.fine("=== Processing txnId: " + txnId);
            appendColumn(strBuf, txnId, txIdLength);
            appendColumn(strBuf, txnBean.getStatus(), COLUMN_LENGTH);
            appendColumn(strBuf, String.valueOf(txnBean.getElapsedTime()), COLUMN_LENGTH);
            appendColumn(strBuf, txnBean.getComponentName(), componentNameLength);
            List<String> resourceList = txnBean.getResourceNames();
            if (resourceList != null) {
                for (int k = 0; k < resourceList.size(); k++) {
                    if (k != 0)
                        strBuf.append(",");
                    strBuf.append(resourceList.get(k));
                }
            }
            strBuf.append(LINE_BREAK);
        }
    }
    _logger.fine("Prepared inflightTransactions text: \n" + strBuf);
    inflightTransactions.setCurrent(strBuf.toString());
    return inflightTransactions;
}
Also used : TransactionAdminBean(com.sun.enterprise.transaction.api.TransactionAdminBean) List(java.util.List) Description(org.glassfish.gmbal.Description) ManagedAttribute(org.glassfish.gmbal.ManagedAttribute)

Example 4 with TransactionAdminBean

use of com.sun.enterprise.transaction.api.TransactionAdminBean in project Payara by payara.

the class JavaEETransactionManagerJTSDelegate method getTransactionAdminBean.

public TransactionAdminBean getTransactionAdminBean(Transaction t) throws javax.transaction.SystemException {
    TransactionAdminBean tBean = null;
    if (t instanceof com.sun.jts.jta.TransactionImpl) {
        String id = ((com.sun.jts.jta.TransactionImpl) t).getTransactionId();
        long startTime = ((com.sun.jts.jta.TransactionImpl) t).getStartTime();
        long elapsedTime = System.currentTimeMillis() - startTime;
        String status = JavaEETransactionManagerSimplified.getStatusAsString(t.getStatus());
        JavaEETransactionImpl tran = (JavaEETransactionImpl) globalTransactions.get(t);
        if (tran != null) {
            tBean = ((JavaEETransactionManagerSimplified) javaEETM).getTransactionAdminBean(tran);
            // Override with JTS values
            tBean.setIdentifier(t);
            tBean.setId(id);
            tBean.setStatus(status);
            tBean.setElapsedTime(elapsedTime);
            if (tBean.getComponentName() == null) {
                tBean.setComponentName("unknown");
            }
        } else {
            tBean = new TransactionAdminBean(t, id, status, elapsedTime, "unknown", null);
        }
    } else {
        tBean = ((JavaEETransactionManagerSimplified) javaEETM).getTransactionAdminBean(t);
    }
    return tBean;
}
Also used : JavaEETransactionImpl(com.sun.enterprise.transaction.JavaEETransactionImpl) TransactionAdminBean(com.sun.enterprise.transaction.api.TransactionAdminBean) JavaEETransactionImpl(com.sun.enterprise.transaction.JavaEETransactionImpl)

Aggregations

TransactionAdminBean (com.sun.enterprise.transaction.api.TransactionAdminBean)4 JavaEETransaction (com.sun.enterprise.transaction.api.JavaEETransaction)2 JavaEETransactionImpl (com.sun.enterprise.transaction.JavaEETransactionImpl)1 RemoteException (java.rmi.RemoteException)1 List (java.util.List)1 WorkException (javax.resource.spi.work.WorkException)1 XAException (javax.transaction.xa.XAException)1 InvocationException (org.glassfish.api.invocation.InvocationException)1 PluginPoint (org.glassfish.external.probe.provider.PluginPoint)1 Description (org.glassfish.gmbal.Description)1 ManagedAttribute (org.glassfish.gmbal.ManagedAttribute)1