Search in sources :

Example 1 with ResourcesUtil

use of com.sun.enterprise.connectors.util.ResourcesUtil in project Payara by payara.

the class ConnectionPoolStatsProviderBootstrap method registerCcPool.

/**
 * Register connector connection pool to the StatsProviderManager.
 * Add the pool lifecycle listeners for the pool to receive events on
 * change of any of the monitoring attribute values.
 * Finally, add this provider to the list of connector connection pool
 * providers maintained.
 * @param poolInfo
 */
private void registerCcPool(PoolInfo poolInfo) {
    if (poolManager.getPool(poolInfo) != null) {
        getProbeProviderUtil().createJcaProbeProvider();
        // Found in the pool table (pool has been initialized/created)
        ConnectorConnPoolStatsProvider ccPoolStatsProvider = new ConnectorConnPoolStatsProvider(poolInfo, logger);
        StatsProviderManager.register("connector-connection-pool", PluginPoint.SERVER, ConnectorsUtil.getPoolMonitoringSubTreeRoot(poolInfo, true), ccPoolStatsProvider);
        PoolLifeCycleListenerRegistry registry = registerPool(poolInfo, getProbeProviderUtil().getJcaProbeProvider());
        ccPoolStatsProvider.setPoolRegistry(registry);
        ccStatsProviders.add(ccPoolStatsProvider);
        if (!ConnectorsUtil.isApplicationScopedResource(poolInfo)) {
            ResourcesUtil resourcesUtil = ResourcesUtil.createInstance();
            ResourcePool pool = resourcesUtil.getPoolConfig(poolInfo);
            Resources resources = resourcesUtil.getResources(poolInfo);
            String raName = resourcesUtil.getRarNameOfResource(pool, resources);
            ConnectorConnPoolStatsProvider connectorServicePoolStatsProvider = new ConnectorConnPoolStatsProvider(poolInfo, logger);
            String dottedNamesHierarchy = null;
            String monitoringModuleName = null;
            if (ConnectorsUtil.isJMSRA(raName)) {
                monitoringModuleName = ConnectorConstants.MONITORING_JMS_SERVICE_MODULE_NAME;
                dottedNamesHierarchy = ConnectorConstants.MONITORING_JMS_SERVICE + ConnectorConstants.MONITORING_SEPARATOR + ConnectorConstants.MONITORING_CONNECTION_FACTORIES + ConnectorConstants.MONITORING_SEPARATOR + ConnectorsUtil.escapeResourceNameForMonitoring(poolInfo.getName());
            } else {
                monitoringModuleName = ConnectorConstants.MONITORING_CONNECTOR_SERVICE_MODULE_NAME;
                dottedNamesHierarchy = ConnectorConstants.MONITORING_CONNECTOR_SERVICE_MODULE_NAME + ConnectorConstants.MONITORING_SEPARATOR + raName + ConnectorConstants.MONITORING_SEPARATOR + ConnectorsUtil.escapeResourceNameForMonitoring(poolInfo.getName());
            }
            StatsProviderManager.register(monitoringModuleName, PluginPoint.SERVER, dottedNamesHierarchy, connectorServicePoolStatsProvider);
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, "Registered pool-monitoring stats [ " + dottedNamesHierarchy + " ]  " + "for [ " + raName + " ] with monitoring-stats-registry.");
            }
            /* no need to create multiple probe provider instances, one per pool will
                   work for multiple stats providers 
                PoolLifeCycleListenerRegistry poolLifeCycleListenerRegistry = registerPool(
                        poolInfo, getProbeProviderUtil().getJcaProbeProvider());
                */
            connectorServicePoolStatsProvider.setPoolRegistry(registry);
            ccStatsProviders.add(connectorServicePoolStatsProvider);
        }
    }
}
Also used : PoolLifeCycleListenerRegistry(com.sun.enterprise.resource.pool.PoolLifeCycleListenerRegistry) ResourcesUtil(com.sun.enterprise.connectors.util.ResourcesUtil) ResourcePool(com.sun.enterprise.config.serverbeans.ResourcePool) Resources(com.sun.enterprise.config.serverbeans.Resources)

Example 2 with ResourcesUtil

use of com.sun.enterprise.connectors.util.ResourcesUtil in project Payara by payara.

the class ConnectorDeployer method event.

public void event(Event event) {
    if (/*env.isDas() && */
    Deployment.UNDEPLOYMENT_VALIDATION.equals(event.type())) {
        // this is an application undeploy event
        DeploymentContext dc = (DeploymentContext) event.hook();
        UndeployCommandParameters dcp = dc.getCommandParameters(UndeployCommandParameters.class);
        String appName = dcp.name;
        Boolean cascade = dcp.cascade;
        Boolean ignoreCascade = dcp._ignoreCascade;
        if (cascade != null && ignoreCascade != null) {
            if (cascade || ignoreCascade) {
                return;
            }
        }
        com.sun.enterprise.config.serverbeans.Application app = domain.getApplications().getApplication(appName);
        boolean isRAR = false;
        if (app != null && Boolean.valueOf(app.getEnabled())) {
            isRAR = app.containsSnifferType(ConnectorConstants.CONNECTOR_MODULE);
        }
        if (!isRAR) {
            return;
        }
        boolean isAppRefEnabled = false;
        Server server = domain.getServers().getServer(env.getInstanceName());
        ApplicationRef appRef = server.getApplicationRef(appName);
        if (appRef != null && Boolean.valueOf(appRef.getEnabled())) {
            isAppRefEnabled = true;
        }
        if (isAppRefEnabled) {
            return;
        }
        boolean isEAR = app.containsSnifferType(EAR);
        String moduleName = appName;
        ResourcesUtil resourcesUtil = ResourcesUtil.createInstance();
        if (isEAR) {
            List<Module> modules = app.getModule();
            for (Module module : modules) {
                moduleName = module.getName();
                if (module.getEngine(ConnectorConstants.CONNECTOR_MODULE) != null) {
                    moduleName = appName + ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER + moduleName;
                    if (moduleName.toLowerCase(Locale.getDefault()).endsWith(".rar")) {
                        int index = moduleName.lastIndexOf(".rar");
                        moduleName = moduleName.substring(0, index);
                        if (resourcesUtil.filterConnectorResources(resourceManager.getAllResources(), moduleName, true).size() > 0) {
                            setFailureStatus(dc, moduleName);
                            return;
                        }
                    }
                }
            }
        } else {
            if (resourcesUtil.filterConnectorResources(resourceManager.getAllResources(), moduleName, true).size() > 0) {
                setFailureStatus(dc, moduleName);
            }
        }
    }
}
Also used : ResourcesUtil(com.sun.enterprise.connectors.util.ResourcesUtil) com.sun.enterprise.config.serverbeans(com.sun.enterprise.config.serverbeans) DeploymentContext(org.glassfish.api.deployment.DeploymentContext) UndeployCommandParameters(org.glassfish.api.deployment.UndeployCommandParameters)

Example 3 with ResourcesUtil

use of com.sun.enterprise.connectors.util.ResourcesUtil in project Payara by payara.

the class ConnectionManagerImpl method validateResourceAndPool.

private void validateResourceAndPool() throws ResourceException {
    ResourceInfo resourceInfo = this.resourceInfo;
    ResourcesUtil resourcesUtil = ResourcesUtil.createInstance();
    ConnectorRuntime runtime = ConnectorRuntime.getRuntime();
    ConnectorRegistry registry = ConnectorRegistry.getInstance();
    // are disabled.
    if (!registry.isResourceDeployed(resourceInfo)) {
        if (logger.isLoggable(Level.FINEST)) {
            logger.log(Level.FINEST, "resourceInfo not found in connector-registry : " + resourceInfo);
        }
        boolean isDefaultResource = false;
        boolean isSunRAResource = false;
        ConnectorDescriptor descriptor = registry.getDescriptor(rarName);
        if (descriptor != null) {
            isDefaultResource = descriptor.getDefaultResourcesNames().contains(resourceInfo.getName());
            if (descriptor.getSunDescriptor() != null) {
                com.sun.enterprise.deployment.runtime.connector.ResourceAdapter rar = descriptor.getSunDescriptor().getResourceAdapter();
                if (rar != null) {
                    String sunRAJndiName = (String) rar.getValue(com.sun.enterprise.deployment.runtime.connector.ResourceAdapter.JNDI_NAME);
                    isSunRAResource = resourceInfo.getName().equals(sunRAJndiName);
                }
            }
        }
        if ((runtime.isServer() || runtime.isEmbedded()) && (!resourceInfo.getName().contains(ConnectorConstants.DATASOURCE_DEFINITION_JNDINAME_PREFIX) && (!isDefaultResource) && (!isSunRAResource))) {
            // resources config bean each time.
            if (resourceConfiguration == null) {
                resourceConfiguration = (BindableResource) resourcesUtil.getResource(resourceInfo, BindableResource.class);
                if (resourceConfiguration == null) {
                    String suffix = ConnectorsUtil.getValidSuffix(resourceInfo.getName());
                    // check for the enabled status and existence using non-prefixed resource-name
                    if (suffix != null) {
                        String nonPrefixedName = resourceInfo.getName().substring(0, resourceInfo.getName().lastIndexOf(suffix));
                        resourceInfo = new ResourceInfo(nonPrefixedName, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
                        resourceConfiguration = (BindableResource) resourcesUtil.getResource(resourceInfo, BindableResource.class);
                    }
                }
            } else {
                // we cache the resourceConfiguration for performance optimization.
                // make sure that appropriate (actual) resourceInfo is used for validation.
                String suffix = ConnectorsUtil.getValidSuffix(resourceInfo.getName());
                // check for the enabled status and existence using non-prefixed resource-name
                if (suffix != null) {
                    String nonPrefixedName = resourceInfo.getName().substring(0, resourceInfo.getName().lastIndexOf(suffix));
                    resourceInfo = new ResourceInfo(nonPrefixedName, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
                }
            }
            if (resourceConfiguration == null) {
                throw new ResourceException("No such resource : " + resourceInfo);
            }
            if (!resourcesUtil.isEnabled(resourceConfiguration, resourceInfo)) {
                throw new ResourceException(resourceInfo + " is not enabled");
            }
        }
    }
    if (registry.getPoolMetaData(poolInfo) == null) {
        String msg = getLocalStrings().getString("con_mgr.no_pool_meta_data", poolInfo);
        throw new ResourceException(poolInfo + ": " + msg);
    }
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) ResourcesUtil(com.sun.enterprise.connectors.util.ResourcesUtil) ResourceException(javax.resource.ResourceException)

Example 4 with ResourcesUtil

use of com.sun.enterprise.connectors.util.ResourcesUtil in project Payara by payara.

the class ResourceAdapterAdminServiceImpl method destroyActiveResourceAdapter.

/**
 * Destroys/deletes the Active resource adapter object from the connector
 * container. Active resource adapter abstracts the rar deployed.
 *
 * @param moduleName Name of the rarModule to destroy/delete
 * @throws ConnectorRuntimeException if the deletion fails
 */
private void destroyActiveResourceAdapter(String moduleName) throws ConnectorRuntimeException {
    ResourcesUtil resutil = ResourcesUtil.createInstance();
    if (resutil == null) {
        ConnectorRuntimeException cre = new ConnectorRuntimeException("Failed to get ResourcesUtil object");
        _logger.log(Level.SEVERE, "rardeployment.resourcesutil_get_failure", moduleName);
        _logger.log(Level.SEVERE, "", cre);
        throw cre;
    }
    if (!stopAndRemoveActiveResourceAdapter(moduleName)) {
        ConnectorRuntimeException cre = new ConnectorRuntimeException("Failed to remove Active Resource Adapter");
        _logger.log(Level.SEVERE, "rardeployment.ra_removal_registry_failure", moduleName);
        _logger.log(Level.SEVERE, "", cre);
        throw cre;
    }
    unbindConnectorDescriptor(moduleName);
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ResourcesUtil(com.sun.enterprise.connectors.util.ResourcesUtil)

Example 5 with ResourcesUtil

use of com.sun.enterprise.connectors.util.ResourcesUtil in project Payara by payara.

the class ConnectorService method loadConnectorDescriptorForEmbeddedRAR.

// TODO V3 with annotations, is it right a approach to load the descriptor using Archivist ?
private ConnectorDescriptor loadConnectorDescriptorForEmbeddedRAR(String rarName) throws ConnectorRuntimeException {
    // If the RAR is embedded try loading the descriptor directly
    // using the applicationarchivist
    ResourcesUtil resutil = ResourcesUtil.createInstance();
    String rarFileName = ConnectorAdminServiceUtils.getConnectorModuleName(rarName) + ".rar";
    return resutil.getConnectorDescriptorFromUri(rarName, rarFileName);
}
Also used : ResourcesUtil(com.sun.enterprise.connectors.util.ResourcesUtil)

Aggregations

ResourcesUtil (com.sun.enterprise.connectors.util.ResourcesUtil)6 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)2 com.sun.enterprise.config.serverbeans (com.sun.enterprise.config.serverbeans)1 ResourcePool (com.sun.enterprise.config.serverbeans.ResourcePool)1 Resources (com.sun.enterprise.config.serverbeans.Resources)1 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)1 PoolLifeCycleListenerRegistry (com.sun.enterprise.resource.pool.PoolLifeCycleListenerRegistry)1 ResourceException (javax.resource.ResourceException)1 DeploymentContext (org.glassfish.api.deployment.DeploymentContext)1 UndeployCommandParameters (org.glassfish.api.deployment.UndeployCommandParameters)1 JdbcResource (org.glassfish.jdbc.config.JdbcResource)1 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)1