Search in sources :

Example 1 with RecoveryResourceHandler

use of com.sun.enterprise.transaction.spi.RecoveryResourceHandler in project Payara by payara.

the class ResourceRecoveryManagerImpl method getAllRecoverableResources.

/**
 * get all recoverable resources
 * @param xaresList xa resources
 * @return recovery-handlers and their resources
 */
private Map<RecoveryResourceHandler, Vector> getAllRecoverableResources(Vector xaresList) {
    Map<RecoveryResourceHandler, Vector> resourcesToHandlers = new HashMap<RecoveryResourceHandler, Vector>();
    for (RecoveryResourceHandler handler : recoveryResourceHandlers) {
        // TODO V3 FINE LOG
        Vector resources = new Vector();
        handler.loadXAResourcesAndItsConnections(xaresList, resources);
        resourcesToHandlers.put(handler, resources);
    }
    return resourcesToHandlers;
}
Also used : RecoveryResourceHandler(com.sun.enterprise.transaction.spi.RecoveryResourceHandler)

Example 2 with RecoveryResourceHandler

use of com.sun.enterprise.transaction.spi.RecoveryResourceHandler in project Payara by payara.

the class ResourceRecoveryManagerImpl method registerRecoveryResourceHandler.

public static void registerRecoveryResourceHandler(final XAResource xaResource) {
    RecoveryResourceHandler recoveryResourceHandler = new RecoveryResourceHandler() {

        public void loadXAResourcesAndItsConnections(List xaresList, List connList) {
            xaresList.add(xaResource);
        }

        public void closeConnections(List connList) {
            ;
        }
    };
    externallyRegisteredRecoveryResourceHandlers.add(recoveryResourceHandler);
}
Also used : RecoveryResourceHandler(com.sun.enterprise.transaction.spi.RecoveryResourceHandler)

Example 3 with RecoveryResourceHandler

use of com.sun.enterprise.transaction.spi.RecoveryResourceHandler in project Payara by payara.

the class ResourceRecoveryManagerImpl method recoverXAResources.

/**
 * recover the xa-resources
 * @param force boolean to indicate if it has to be forced.
 */
public void recoverXAResources(boolean force) {
    if (force) {
        try {
            if (txnService == null) {
                Config c = habitat.getService(Config.class, ServerEnvironment.DEFAULT_INSTANCE_NAME);
                txnService = c.getExtensionByType(TransactionService.class);
            }
            if (!Boolean.valueOf(txnService.getAutomaticRecovery())) {
                return;
            }
            if (_logger.isLoggable(Level.FINE)) {
                _logger.log(Level.FINE, "ejbserver.recovery", "Perform recovery of XAResources...");
            }
            configure();
            Vector xaresList = new Vector();
            Map<RecoveryResourceHandler, Vector> resourcesToHandler = getAllRecoverableResources(xaresList);
            int size = xaresList.size();
            XAResource[] xaresArray = new XAResource[size];
            for (int i = 0; i < size; i++) {
                xaresArray[i] = (XAResource) xaresList.elementAt(i);
            }
            resourceRecoveryStarted();
            if (_logger.isLoggable(Level.FINE)) {
                String msg = localStrings.getStringWithDefault("xaresource.recovering", "Recovering {0} XA resources...", new Object[] { String.valueOf(size) });
                _logger.log(Level.FINE, msg);
            }
            txMgr.recover(xaresArray);
            resourceRecoveryCompleted();
            closeAllResources(resourcesToHandler);
        } catch (Exception ex) {
            _logger.log(Level.SEVERE, "xaresource.recover_error", ex);
        }
    }
}
Also used : XAResource(javax.transaction.xa.XAResource) TransactionService(com.sun.enterprise.transaction.config.TransactionService) Config(com.sun.enterprise.config.serverbeans.Config) RecoveryResourceHandler(com.sun.enterprise.transaction.spi.RecoveryResourceHandler)

Example 4 with RecoveryResourceHandler

use of com.sun.enterprise.transaction.spi.RecoveryResourceHandler in project Payara by payara.

the class ResourceRecoveryManagerImpl method closeAllResources.

/**
 * close all resources provided using their handlers
 * @param resourcesToHandlers map that holds handlers and their resources
 */
private void closeAllResources(Map<RecoveryResourceHandler, Vector> resourcesToHandlers) {
    if (resourcesToHandlers != null) {
        Set<Map.Entry<RecoveryResourceHandler, Vector>> entries = resourcesToHandlers.entrySet();
        for (Map.Entry<RecoveryResourceHandler, Vector> entry : entries) {
            RecoveryResourceHandler handler = entry.getKey();
            Vector resources = entry.getValue();
            handler.closeConnections(resources);
        }
    }
}
Also used : RecoveryResourceHandler(com.sun.enterprise.transaction.spi.RecoveryResourceHandler)

Aggregations

RecoveryResourceHandler (com.sun.enterprise.transaction.spi.RecoveryResourceHandler)4 Config (com.sun.enterprise.config.serverbeans.Config)1 TransactionService (com.sun.enterprise.transaction.config.TransactionService)1 XAResource (javax.transaction.xa.XAResource)1