Search in sources :

Example 11 with ConnectorConnectionPool

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

the class ConnectionPoolValidator method isValid.

@Override
public boolean isValid(final ResourcePool pool, final ConstraintValidatorContext constraintValidatorContext) {
    if (poolFaults == ConnectionPoolErrorMessages.MAX_STEADY_INVALID) {
        if (pool instanceof ConnectorConnectionPool) {
            ConnectorConnectionPool connPool = (ConnectorConnectionPool) pool;
            String maxPoolSize = connPool.getMaxPoolSize();
            String steadyPoolSize = connPool.getSteadyPoolSize();
            if (steadyPoolSize == null) {
                steadyPoolSize = Constants.DEFAULT_STEADY_POOL_SIZE;
            }
            if (maxPoolSize == null) {
                maxPoolSize = Constants.DEFAULT_MAX_POOL_SIZE;
            }
            if (Integer.parseInt(maxPoolSize) < (Integer.parseInt(steadyPoolSize))) {
                // max pool size fault
                return false;
            }
        }
    }
    return true;
}
Also used : ConnectorConnectionPool(org.glassfish.connectors.config.ConnectorConnectionPool)

Example 12 with ConnectorConnectionPool

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

the class FlushConnectionPool method execute.

public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    Resources resources = domain.getResources();
    String scope = "";
    if (moduleName != null) {
        if (!poolUtil.isValidModule(applicationName, moduleName, poolName, report)) {
            return;
        }
        Application application = applications.getApplication(applicationName);
        Module module = application.getModule(moduleName);
        resources = module.getResources();
        scope = ConnectorConstants.JAVA_MODULE_SCOPE_PREFIX;
    } else if (applicationName != null) {
        if (!poolUtil.isValidApplication(applicationName, poolName, report)) {
            return;
        }
        Application application = applications.getApplication(applicationName);
        resources = application.getResources();
        scope = ConnectorConstants.JAVA_APP_SCOPE_PREFIX;
    }
    if (!poolUtil.isValidPool(resources, poolName, scope, report)) {
        return;
    }
    boolean poolingEnabled = false;
    ResourcePool pool = (ResourcePool) ConnectorsUtil.getResourceByName(resources, ResourcePool.class, poolName);
    if (pool instanceof ConnectorConnectionPool) {
        ConnectorConnectionPool ccp = (ConnectorConnectionPool) pool;
        poolingEnabled = Boolean.valueOf(ccp.getPooling());
    } else {
        JdbcConnectionPool ccp = (JdbcConnectionPool) pool;
        poolingEnabled = Boolean.valueOf(ccp.getPooling());
    }
    if (!poolingEnabled) {
        String i18nMsg = localStrings.getLocalString("flush.connection.pool.pooling.disabled", "Attempt to Flush Connection Pool failed because Pooling is disabled for pool : {0}", poolName);
        report.setMessage(i18nMsg);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    try {
        PoolInfo poolInfo = new PoolInfo(poolName, applicationName, moduleName);
        _runtime.flushConnectionPool(poolInfo);
        report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    } catch (ConnectorRuntimeException e) {
        report.setMessage(localStrings.getLocalString("flush.connection.pool.fail", "Flush connection pool for {0} failed", poolName));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(e);
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorConnectionPool(org.glassfish.connectors.config.ConnectorConnectionPool) JdbcConnectionPool(org.glassfish.jdbc.config.JdbcConnectionPool) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) ActionReport(org.glassfish.api.ActionReport)

Example 13 with ConnectorConnectionPool

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

the class ListConnectorConnectionPools 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();
    try {
        Collection<ConnectorConnectionPool> connPools = domain.getResources().getResources(ConnectorConnectionPool.class);
        for (ConnectorConnectionPool pool : connPools) {
            final ActionReport.MessagePart part = report.getTopMessagePart().addChild();
            part.setMessage(pool.getName());
        }
    } catch (Exception e) {
        Logger.getLogger(ListConnectorConnectionPools.class.getName()).log(Level.SEVERE, "Something went wrong in list-connector-connection-pools", e);
        report.setMessage(localStrings.getLocalString("list.connector.connection.pools.failed", "List connector connection pools failed"));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(e);
        return;
    }
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : ConnectorConnectionPool(org.glassfish.connectors.config.ConnectorConnectionPool) ActionReport(org.glassfish.api.ActionReport)

Example 14 with ConnectorConnectionPool

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

the class ListConnectorSecurityMaps 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();
    final ActionReport.MessagePart mp = report.getTopMessagePart();
    /* Issue 5918 Used in ManifestManager to keep output sorted */
    // try {
    // PropsFileActionReporter reporter = (PropsFileActionReporter) report;
    // reporter.useMainChildrenAttribute(true);
    // } catch(ClassCastException e) {
    // ignore this is not a manifest output.
    // }
    Collection<ConnectorConnectionPool> ccPools = domain.getResources().getResources(ConnectorConnectionPool.class);
    if (!doesPoolNameExist(poolName, ccPools)) {
        report.setMessage(localStrings.getLocalString("create.connector.security.map.noSuchPoolFound", "Specified connector connection pool {0} does not exist. Please specify a valid pool name.", poolName));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    if (securityMap != null) {
        if (!doesMapNameExist(poolName, securityMap, ccPools)) {
            report.setMessage(localStrings.getLocalString("list.connector.security.maps.securityMapNotFound", "Security map {0} does not exist for connector connection pool {1}. Please give a valid map name.", securityMap, poolName));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
    }
    try {
        final List<SecurityMap> securityMaps = getAllSecurityMapsForPool(poolName, ccPools);
        if (securityMaps != null && !securityMaps.isEmpty()) {
            if (securityMap == null && long_opt) {
                for (SecurityMap sm : securityMaps) {
                    listSecurityMapDetails(sm, mp);
                }
            } else if (securityMap == null && !long_opt) {
                // print the map names .....
                for (SecurityMap sm : securityMaps) {
                    listSecurityMapNames(sm, mp);
                }
            } else {
                // map name is not null, long_opt is redundant when security map is specified
                for (SecurityMap sm : securityMaps) {
                    if (sm.getName().equals(securityMap)) {
                        // if (long_opt) {
                        listSecurityMapDetails(sm, mp);
                        break;
                    // } else {
                    // listSecurityMapNames(sm, mp);
                    // break;
                    // }
                    }
                }
            }
        }
    } catch (Exception e) {
        Logger.getLogger(ListConnectorSecurityMaps.class.getName()).log(Level.SEVERE, "list-connector-security-maps failed", e);
        report.setMessage(localStrings.getLocalString("" + "list.connector.security.maps.fail", "Unable to list security map {0} for connector connection pool {1}", securityMap, poolName) + " " + e.getLocalizedMessage());
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(e);
        return;
    }
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : ConnectorConnectionPool(org.glassfish.connectors.config.ConnectorConnectionPool) SecurityMap(org.glassfish.connectors.config.SecurityMap) ActionReport(org.glassfish.api.ActionReport)

Example 15 with ConnectorConnectionPool

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

the class ConnectorResourceDeployer method checkAndDeletePool.

/**
 * Checks if no more resource-refs to resources exists for the
 * connector connection pool and then deletes the pool
 *
 * @param cr ConnectorResource
 * @throws Exception (ConfigException / undeploy exception)
 * @since 8.1 pe/se/ee
 */
private void checkAndDeletePool(ConnectorResource cr) throws Exception {
    String poolName = cr.getPoolName();
    ResourceInfo resourceInfo = ConnectorsUtil.getResourceInfo(cr);
    PoolInfo poolInfo = new PoolInfo(poolName, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
    Resources resources = (Resources) cr.getParent();
    // Its possible that the ConnectorResource here is a ConnectorResourceeDefinition. Ignore optimization.
    if (resources != null) {
        try {
            boolean poolReferred = ResourcesUtil.createInstance().isPoolReferredInServerInstance(poolInfo);
            if (!poolReferred) {
                if (_logger.isLoggable(Level.FINE)) {
                    _logger.fine("Deleting connector connection pool [" + poolName + "] as there are no more " + "resource-refs to the pool in this server instance");
                }
                ConnectorConnectionPool ccp = (ConnectorConnectionPool) ConnectorsUtil.getResourceByName(resources, ConnectorConnectionPool.class, poolName);
                // Delete/Undeploy Pool
                runtime.getResourceDeployer(ccp).undeployResource(ccp);
            }
        } catch (Exception ce) {
            _logger.warning(ce.getMessage());
            if (_logger.isLoggable(Level.FINE)) {
                _logger.fine("Exception while deleting pool [ " + poolName + " ] : " + ce);
            }
            throw ce;
        }
    }
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ConnectorConnectionPool(org.glassfish.connectors.config.ConnectorConnectionPool) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) Resources(com.sun.enterprise.config.serverbeans.Resources) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

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