Search in sources :

Example 16 with ConnectorConnectionPool

use of org.glassfish.connectors.config.ConnectorConnectionPool in project Payara by payara.

the class JMSConnectionFactoryDefinitionDeployer method deployResource.

public void deployResource(Object resource) throws Exception {
    final JMSConnectionFactoryDefinitionDescriptor desc = (JMSConnectionFactoryDefinitionDescriptor) resource;
    String poolName = ConnectorsUtil.deriveResourceName(desc.getResourceId(), desc.getName(), JMSCFDDPOOL);
    String resourceName = ConnectorsUtil.deriveResourceName(desc.getResourceId(), desc.getName(), desc.getResourceType());
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, "JMSConnectionFactoryDefinitionDeployer.deployResource() : pool-name [" + poolName + "], " + " resource-name [" + resourceName + "]");
    }
    ConnectorConnectionPool connectorCp = new MyJMSConnectionFactoryConnectionPool(desc, poolName);
    // deploy pool
    getDeployer(connectorCp).deployResource(connectorCp);
    // deploy resource
    ConnectorResource connectorResource = new MyJMSConnectionFactoryResource(poolName, resourceName);
    getDeployer(connectorResource).deployResource(connectorResource);
}
Also used : JMSConnectionFactoryDefinitionDescriptor(com.sun.enterprise.deployment.JMSConnectionFactoryDefinitionDescriptor) ConnectorConnectionPool(org.glassfish.connectors.config.ConnectorConnectionPool) ConnectorResource(org.glassfish.connectors.config.ConnectorResource)

Example 17 with ConnectorConnectionPool

use of org.glassfish.connectors.config.ConnectorConnectionPool in project Payara by payara.

the class ConnectionPoolEmitterImpl method registerConnectionPool.

/**
 * Register the jdbc/connector connection pool Stats Provider object to the
 * monitoring framework under the specific application name monitoring
 * sub tree.
 *
 * @param appName
 * @return
 */
private ConnectionPoolAppProbeProvider registerConnectionPool(String appName) {
    ResourcePool pool = runtime.getConnectionPoolConfig(poolInfo);
    ConnectionPoolAppProbeProvider probeAppProvider = runtime.getProbeProviderUtil().getConnPoolBootstrap().registerPool(poolInfo, appName);
    if (pool instanceof ConnectorConnectionPool) {
        probeAppProvider = new ConnectorConnPoolAppProbeProvider();
        ConnectorConnPoolAppStatsProvider ccPoolAppStatsProvider = new ConnectorConnPoolAppStatsProvider(poolInfo, appName);
        StatsProviderManager.register("connector-connection-pool", PluginPoint.SERVER, "resources/" + ConnectorsUtil.escapeResourceNameForMonitoring(poolName) + "/" + appName, ccPoolAppStatsProvider);
        ccPoolAppStatsProviders.add(ccPoolAppStatsProvider);
    }
    return probeAppProvider;
}
Also used : ConnectorConnectionPool(org.glassfish.connectors.config.ConnectorConnectionPool) ResourcePool(com.sun.enterprise.config.serverbeans.ResourcePool)

Example 18 with ConnectorConnectionPool

use of org.glassfish.connectors.config.ConnectorConnectionPool in project Payara by payara.

the class ConnectorsRecoveryResourceHandler method loadAllConnectorResources.

/**
 * does a lookup of resources so that they are loaded for sure.
 */
private void loadAllConnectorResources() {
    try {
        Collection<ConnectorResource> connResources = getAllConnectorResources();
        InitialContext ic = new InitialContext();
        for (ConnectorResource connResource : connResources) {
            if (getResourcesUtil().isEnabled(connResource)) {
                try {
                    ic.lookup(connResource.getJndiName());
                // } catch (NameNotFoundException ne) {
                } catch (NamingException ne) {
                    // So we need to explicitly load that rar and create the resources
                    try {
                        ResourceInfo resourceInfo = ConnectorsUtil.getResourceInfo(connResource);
                        ConnectorConnectionPool connConnectionPool = ResourcesUtil.createInstance().getConnectorConnectionPoolOfResource(resourceInfo);
                        if (connConnectionPool != null) {
                            // TODO V3 ideally this should not happen if connector modules (and embedded rars)
                            // TODO  are loaded before recovery
                            createActiveResourceAdapter(connConnectionPool.getResourceAdapterName());
                            getConnectorResourceDeployer().deployResource(connResource);
                        }
                    } catch (Exception ex) {
                        _logger.log(Level.SEVERE, "error.loading.connector.resources.during.recovery", connResource.getJndiName());
                        if (_logger.isLoggable(Level.FINE)) {
                            _logger.log(Level.FINE, ne.toString(), ne);
                        }
                        _logger.log(Level.SEVERE, "error.loading.connector.resources.during.recovery", connResource.getJndiName());
                        if (_logger.isLoggable(Level.FINE)) {
                            _logger.log(Level.FINE, ex.toString(), ex);
                        }
                    }
                } catch (Exception ex) {
                    _logger.log(Level.SEVERE, "error.loading.connector.resources.during.recovery", connResource.getJndiName());
                    if (_logger.isLoggable(Level.FINE)) {
                        _logger.log(Level.FINE, ex.toString(), ex);
                    }
                }
            }
        }
    } catch (NamingException ne) {
        _logger.log(Level.SEVERE, "error.loading.connector.resources.during.recovery", ne.getMessage());
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, ne.toString(), ne);
        }
    }
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ConnectorConnectionPool(org.glassfish.connectors.config.ConnectorConnectionPool) NamingException(javax.naming.NamingException) ConnectorResource(org.glassfish.connectors.config.ConnectorResource) InitialContext(javax.naming.InitialContext) ResourceException(javax.resource.ResourceException) NamingException(javax.naming.NamingException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 19 with ConnectorConnectionPool

use of org.glassfish.connectors.config.ConnectorConnectionPool in project Payara by payara.

the class DeleteConnectorConnectionPool method execute.

/**
 * Executes the command with the command parameters passed as Properties
 * where the keys are the paramter names and the values the parameter values
 *
 * @param context information
 */
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    if (poolname == null) {
        report.setMessage(localStrings.getLocalString("delete.connector.connection.pool.noJndiName", "No id defined for connector connection pool."));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    // ensure we already have this resource
    if (ConnectorsUtil.getResourceByName(domain.getResources(), ConnectorConnectionPool.class, poolname) == null) {
        report.setMessage(localStrings.getLocalString("delete.connector.connection.pool.notfound", "A connector connection pool named {0} does not exist.", poolname));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    try {
        // if cascade=true delete all the resources associated with this pool
        // if cascade=false don't delete this connection pool if a resource is referencing it
        Object obj = deleteAssociatedResources(servers, clusters, domain.getResources(), cascade, poolname);
        if (obj instanceof Integer && (Integer) obj == ResourceStatus.FAILURE) {
            report.setMessage(localStrings.getLocalString("delete.connector.connection.pool.pool_in_use", "Some connector resources are referencing connection pool {0}. Use 'cascade' " + "option to delete them as well.", poolname));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
        // delete connector connection pool
        if (ConfigSupport.apply(new SingleConfigCode<Resources>() {

            public Object run(Resources param) throws PropertyVetoException, TransactionFailure {
                ConnectorConnectionPool cp = (ConnectorConnectionPool) ConnectorsUtil.getResourceByName(domain.getResources(), ConnectorConnectionPool.class, poolname);
                if (cp != null) {
                    return param.getResources().remove(cp);
                }
                // not found
                return null;
            }
        }, domain.getResources()) == null) {
            report.setMessage(localStrings.getLocalString("delete.connector.connection.pool.notfound", "A connector connection pool named {0} does not exist.", poolname));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
    } catch (TransactionFailure tfe) {
        Logger.getLogger(DeleteConnectorConnectionPool.class.getName()).log(Level.SEVERE, "Something went wrong in delete-connector-connection-pool", tfe);
        report.setMessage(tfe.getMessage() != null ? tfe.getLocalizedMessage() : localStrings.getLocalString("delete.connector.connection.pool.fail", "Connector connection pool {0} delete failed ", poolname));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(tfe);
    }
    report.setMessage(localStrings.getLocalString("delete.connector.connection.pool.success", "Connector connection pool {0} deleted successfully", poolname));
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ConnectorConnectionPool(org.glassfish.connectors.config.ConnectorConnectionPool) SingleConfigCode(org.jvnet.hk2.config.SingleConfigCode) ActionReport(org.glassfish.api.ActionReport)

Example 20 with ConnectorConnectionPool

use of org.glassfish.connectors.config.ConnectorConnectionPool in project Payara by payara.

the class DeleteConnectorSecurityMap method execute.

/**
 * Executes the command with the command parameters passed as Properties
 * where the keys are the paramter names and the values the parameter values
 *
 * @param context information
 */
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    Collection<ConnectorConnectionPool> ccPools = domain.getResources().getResources(ConnectorConnectionPool.class);
    // ensure we already have this resource
    if (!isResourceExists(ccPools)) {
        report.setMessage(localStrings.getLocalString("delete.connector.security.map.notFound", "A security map named {0} for connector connection pool {1} does not exist.", mapName, poolName));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    try {
        final ConnectorConnectionPool pool = getPool(poolName, ccPools);
        // delete connector-security-map
        ConfigSupport.apply(new SingleConfigCode<ConnectorConnectionPool>() {

            public Object run(ConnectorConnectionPool param) throws PropertyVetoException, TransactionFailure {
                final List<SecurityMap> securityMaps = param.getSecurityMap();
                if (securityMaps != null) {
                    for (SecurityMap map : securityMaps) {
                        if (map.getName().equals(mapName)) {
                            param.getSecurityMap().remove(map);
                            break;
                        }
                    }
                }
                return param;
            }
        }, pool);
    } catch (TransactionFailure tfe) {
        Logger.getLogger(DeleteConnectorSecurityMap.class.getName()).log(Level.SEVERE, "delete-connector-security-map failed", tfe);
        report.setMessage(localStrings.getLocalString("delete.connector.security.map.fail", "Unable to delete security map {0} for connector connection pool {1}", mapName, poolName) + " " + tfe.getLocalizedMessage());
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(tfe);
        return;
    }
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ConnectorConnectionPool(org.glassfish.connectors.config.ConnectorConnectionPool) SecurityMap(org.glassfish.connectors.config.SecurityMap) List(java.util.List) ActionReport(org.glassfish.api.ActionReport)

Aggregations

ConnectorConnectionPool (org.glassfish.connectors.config.ConnectorConnectionPool)23 ConnectorResource (org.glassfish.connectors.config.ConnectorResource)10 ActionReport (org.glassfish.api.ActionReport)9 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)5 SecurityMap (org.glassfish.connectors.config.SecurityMap)4 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)4 ResourcePool (com.sun.enterprise.config.serverbeans.ResourcePool)3 PropertyVetoException (java.beans.PropertyVetoException)3 AdminObjectResource (org.glassfish.connectors.config.AdminObjectResource)3 PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)3 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)3 ConnectionFactoryDefinitionDescriptor (com.sun.enterprise.deployment.ConnectionFactoryDefinitionDescriptor)2 JMSConnectionFactoryDefinitionDescriptor (com.sun.enterprise.deployment.JMSConnectionFactoryDefinitionDescriptor)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Properties (java.util.Properties)2 NamingException (javax.naming.NamingException)2 ResourceException (javax.resource.ResourceException)2 BackendPrincipal (org.glassfish.connectors.config.BackendPrincipal)2