Search in sources :

Example 6 with ConnectorConnectionPool

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

the class ConnectionPoolObjectsUtils method createDefaultConnectorPoolObject.

/**
 * Creates default ConnectorConnectionPool consisting of default
 * pool values.
 *
 * @param poolInfo Name of the pool
 * @return ConnectorConnectionPool created ConnectorConnectionPool instance
 */
public static ConnectorConnectionPool createDefaultConnectorPoolObject(PoolInfo poolInfo, String rarName) {
    ConnectorConnectionPool connectorPoolObj = new ConnectorConnectionPool(poolInfo);
    connectorPoolObj.setMaxPoolSize("20");
    connectorPoolObj.setSteadyPoolSize("10");
    connectorPoolObj.setMaxWaitTimeInMillis("7889");
    connectorPoolObj.setIdleTimeoutInSeconds("789");
    connectorPoolObj.setPoolResizeQuantity("2");
    connectorPoolObj.setFailAllConnections(false);
    // always
    connectorPoolObj.setMatchConnections(true);
    setDefaultAdvancedPoolAttributes(connectorPoolObj);
    try {
        connectorPoolObj.setTransactionSupport(getTransactionSupportFromRaXml(rarName));
    } catch (Exception ex) {
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("error in setting txSupport");
        }
    }
    return connectorPoolObj;
}
Also used : ConnectorConnectionPool(com.sun.enterprise.connectors.ConnectorConnectionPool) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 7 with ConnectorConnectionPool

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

the class ConnectorConnectionPoolDeployer method redeployResource.

/**
 * {@inheritDoc}
 */
public synchronized void redeployResource(Object resource) throws Exception {
    // Connector connection pool reconfiguration or
    // change in security maps
    org.glassfish.connectors.config.ConnectorConnectionPool domainCcp = (org.glassfish.connectors.config.ConnectorConnectionPool) resource;
    List<SecurityMap> securityMaps = domainCcp.getSecurityMap();
    // Since 8.1 PE/SE/EE, only if pool has already been deployed in this
    // server-instance earlier, reconfig this pool
    PoolInfo poolInfo = ConnectorsUtil.getPoolInfo(domainCcp);
    if (!runtime.isConnectorConnectionPoolDeployed(poolInfo)) {
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("The connector connection pool " + poolInfo + " is either not referred or not yet created in " + "this server instance and pool and hence " + "redeployment is ignored");
        }
        return;
    }
    String rarName = domainCcp.getResourceAdapterName();
    String connDefName = domainCcp.getConnectionDefinitionName();
    List<Property> props = domainCcp.getProperty();
    ConnectorConnectionPool ccp = getConnectorConnectionPool(domainCcp, poolInfo);
    populateConnectorConnectionPool(ccp, connDefName, rarName, props, securityMaps);
    boolean poolRecreateRequired = false;
    try {
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("Calling reconfigure pool");
        }
        poolRecreateRequired = runtime.reconfigureConnectorConnectionPool(ccp, new HashSet());
    } catch (ConnectorRuntimeException cre) {
        Object[] params = new Object[] { poolInfo, cre };
        _logger.log(Level.WARNING, "error.reconfiguring.pool", params);
    }
    if (poolRecreateRequired) {
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("Pool recreation required");
        }
        runtime.recreateConnectorConnectionPool(ccp);
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("Pool recreation done");
        }
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorConnectionPool(com.sun.enterprise.connectors.ConnectorConnectionPool) SecurityMap(org.glassfish.connectors.config.SecurityMap) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty) Property(org.jvnet.hk2.config.types.Property)

Example 8 with ConnectorConnectionPool

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

the class ConnectorConnectionPoolDeployer method getConnectorConnectionPool.

private ConnectorConnectionPool getConnectorConnectionPool(org.glassfish.connectors.config.ConnectorConnectionPool domainCcp, PoolInfo poolInfo) throws Exception {
    ConnectorConnectionPool ccp;
    ccp = new ConnectorConnectionPool(poolInfo);
    ccp.setSteadyPoolSize(domainCcp.getSteadyPoolSize());
    ccp.setMaxPoolSize(domainCcp.getMaxPoolSize());
    ccp.setMaxWaitTimeInMillis(domainCcp.getMaxWaitTimeInMillis());
    ccp.setPoolResizeQuantity(domainCcp.getPoolResizeQuantity());
    ccp.setIdleTimeoutInSeconds(domainCcp.getIdleTimeoutInSeconds());
    ccp.setFailAllConnections(Boolean.valueOf(domainCcp.getFailAllConnections()));
    ccp.setAuthCredentialsDefinedInPool(isAuthCredentialsDefinedInPool(domainCcp));
    // The line below will change for 9.0. We will get this from
    // the domain.xml
    ccp.setConnectionValidationRequired(Boolean.valueOf(domainCcp.getIsConnectionValidationRequired()));
    String txSupport = domainCcp.getTransactionSupport();
    int txSupportIntVal = parseTransactionSupportString(txSupport);
    if (txSupportIntVal == -1) {
        // from the ra.xml
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("Got transaction-support attr null from domain.xml");
        }
        txSupportIntVal = ConnectionPoolObjectsUtils.getTransactionSupportFromRaXml(domainCcp.getResourceAdapterName());
    } else {
        // the value specified in the ra.xml
        if (!ConnectionPoolObjectsUtils.isTxSupportConfigurationSane(txSupportIntVal, domainCcp.getResourceAdapterName())) {
            String i18nMsg = localStrings.getString("ccp_deployer.incorrect_tx_support");
            ConnectorRuntimeException cre = new ConnectorRuntimeException(i18nMsg);
            _logger.log(Level.SEVERE, "rardeployment.incorrect_tx_support", ccp.getName());
            throw cre;
        }
    }
    if (_logger.isLoggable(Level.FINE)) {
        _logger.fine("setting txSupportVal to " + txSupportIntVal + " in pool " + domainCcp.getName());
    }
    ccp.setTransactionSupport(txSupportIntVal);
    // Always for ccp
    ccp.setNonComponent(false);
    ccp.setNonTransactional(false);
    ccp.setConnectionLeakTracingTimeout(domainCcp.getConnectionLeakTimeoutInSeconds());
    ccp.setConnectionReclaim(Boolean.valueOf(domainCcp.getConnectionLeakReclaim()));
    ccp.setMatchConnections(Boolean.valueOf(domainCcp.getMatchConnections()));
    ccp.setAssociateWithThread(Boolean.valueOf(domainCcp.getAssociateWithThread()));
    ccp.setPooling(Boolean.valueOf(domainCcp.getPooling()));
    ccp.setPingDuringPoolCreation(Boolean.valueOf(domainCcp.getPing()));
    boolean lazyConnectionEnlistment = Boolean.valueOf(domainCcp.getLazyConnectionEnlistment());
    boolean lazyConnectionAssociation = Boolean.valueOf(domainCcp.getLazyConnectionAssociation());
    if (lazyConnectionAssociation) {
        if (lazyConnectionEnlistment) {
            ccp.setLazyConnectionAssoc(true);
            ccp.setLazyConnectionEnlist(true);
        } else {
            _logger.log(Level.SEVERE, "conn_pool_obj_utils.lazy_enlist-lazy_assoc-invalid-combination", domainCcp.getName());
            String i18nMsg = localStrings.getString("cpou.lazy_enlist-lazy_assoc-invalid-combination", domainCcp.getName());
            throw new RuntimeException(i18nMsg);
        }
    } else {
        ccp.setLazyConnectionAssoc(lazyConnectionAssociation);
        ccp.setLazyConnectionEnlist(lazyConnectionEnlistment);
    }
    boolean pooling = Boolean.valueOf(domainCcp.getPooling());
    // TODO: should this be added to the beginning of this method?
    if (!pooling) {
        // Throw exception if assoc with thread is set to true.
        if (Boolean.valueOf(domainCcp.getAssociateWithThread())) {
            _logger.log(Level.SEVERE, "conn_pool_obj_utils.pooling_disabled_assocwiththread_invalid_combination", domainCcp.getName());
            String i18nMsg = localStrings.getString("cpou.pooling_disabled_assocwiththread_invalid_combination", domainCcp.getName());
            throw new RuntimeException(i18nMsg);
        }
        // match-connections/max-connection-usage-count/idele-timeout
        if (Boolean.valueOf(domainCcp.getIsConnectionValidationRequired())) {
            _logger.log(Level.WARNING, "conn_pool_obj_utils.pooling_disabled_conn_validation_invalid_combination", domainCcp.getName());
        }
        if (Integer.parseInt(domainCcp.getValidateAtmostOncePeriodInSeconds()) > 0) {
            _logger.log(Level.WARNING, "conn_pool_obj_utils.pooling_disabled_validate_atmost_once_invalid_combination", domainCcp.getName());
        }
        if (Boolean.valueOf(domainCcp.getMatchConnections())) {
            _logger.log(Level.WARNING, "conn_pool_obj_utils.pooling_disabled_match_connections_invalid_combination", domainCcp.getName());
        }
        if (Integer.parseInt(domainCcp.getMaxConnectionUsageCount()) > 0) {
            _logger.log(Level.WARNING, "conn_pool_obj_utils.pooling_disabled_max_conn_usage_invalid_combination", domainCcp.getName());
        }
        if (Integer.parseInt(domainCcp.getIdleTimeoutInSeconds()) > 0) {
            _logger.log(Level.WARNING, "conn_pool_obj_utils.pooling_disabled_idle_timeout_invalid_combination", domainCcp.getName());
        }
    }
    ccp.setPooling(pooling);
    ccp.setMaxConnectionUsage(domainCcp.getMaxConnectionUsageCount());
    ccp.setValidateAtmostOncePeriod(domainCcp.getValidateAtmostOncePeriodInSeconds());
    ccp.setConCreationRetryAttempts(domainCcp.getConnectionCreationRetryAttempts());
    ccp.setConCreationRetryInterval(domainCcp.getConnectionCreationRetryIntervalInSeconds());
    // IMPORTANT
    // Here all properties that will be checked by the
    // convertElementPropertyToPoolProperty method need to be set to
    // their default values
    convertElementPropertyToPoolProperty(ccp, domainCcp);
    return ccp;
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorConnectionPool(com.sun.enterprise.connectors.ConnectorConnectionPool) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 9 with ConnectorConnectionPool

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

the class ConnectorConnectionPoolDeployer method deployResource.

/**
 * {@inheritDoc}
 */
public void deployResource(Object resource, String applicationName, String moduleName) throws Exception {
    if (_logger.isLoggable(Level.FINE)) {
        _logger.fine("ConnectorConnectionPoolDeployer : deployResource ");
    }
    final org.glassfish.connectors.config.ConnectorConnectionPool domainCcp = (org.glassfish.connectors.config.ConnectorConnectionPool) resource;
    // redirect call to redeployResource
    if (ConnectionPoolObjectsUtils.isPoolSystemPool(domainCcp)) {
        this.redeployResource(resource);
        return;
    }
    PoolInfo poolInfo = new PoolInfo(domainCcp.getName(), applicationName, moduleName);
    final ConnectorConnectionPool ccp = getConnectorConnectionPool(domainCcp, poolInfo);
    String rarName = domainCcp.getResourceAdapterName();
    String connDefName = domainCcp.getConnectionDefinitionName();
    List<Property> props = domainCcp.getProperty();
    List<SecurityMap> securityMaps = domainCcp.getSecurityMap();
    populateConnectorConnectionPool(ccp, connDefName, rarName, props, securityMaps);
    final String defName = domainCcp.getConnectionDefinitionName();
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, "Calling backend to add connectorConnectionPool", domainCcp.getResourceAdapterName());
    }
    runtime.createConnectorConnectionPool(ccp, defName, domainCcp.getResourceAdapterName(), domainCcp.getProperty(), domainCcp.getSecurityMap());
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, "Added connectorConnectionPool in backend", domainCcp.getResourceAdapterName());
    }
}
Also used : ConnectorConnectionPool(com.sun.enterprise.connectors.ConnectorConnectionPool) SecurityMap(org.glassfish.connectors.config.SecurityMap) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty) Property(org.jvnet.hk2.config.types.Property)

Example 10 with ConnectorConnectionPool

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

the class ConnectionPool method getPoolConfigurationFromJndi.

protected ConnectorConnectionPool getPoolConfigurationFromJndi(Hashtable env) throws PoolingException {
    ConnectorConnectionPool poolResource;
    try {
        String jndiNameOfPool = ConnectorAdminServiceUtils.getReservePrefixedJNDINameForPool(poolInfo);
        poolResource = (ConnectorConnectionPool) ConnectorRuntime.getRuntime().getResourceNamingService().lookup(poolInfo, jndiNameOfPool, env);
    } catch (NamingException ex) {
        throw new PoolingException(ex);
    }
    return poolResource;
}
Also used : PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ConnectorConnectionPool(com.sun.enterprise.connectors.ConnectorConnectionPool) NamingException(javax.naming.NamingException)

Aggregations

ConnectorConnectionPool (com.sun.enterprise.connectors.ConnectorConnectionPool)13 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)7 NamingException (javax.naming.NamingException)4 PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)4 ConnectorDescriptorInfo (com.sun.enterprise.connectors.ConnectorDescriptorInfo)3 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)3 SecurityMap (org.glassfish.connectors.config.SecurityMap)2 JdbcConnectionPool (org.glassfish.jdbc.config.JdbcConnectionPool)2 Property (org.jvnet.hk2.config.types.Property)2 PoolingException (com.sun.appserv.connectors.internal.api.PoolingException)1 ConnectorNamingEvent (com.sun.appserv.connectors.internal.spi.ConnectorNamingEvent)1 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)1 ResourcePrincipal (com.sun.enterprise.deployment.ResourcePrincipal)1 ResourceAdapter (com.sun.enterprise.deployment.runtime.connector.ResourceAdapter)1 SunConnector (com.sun.enterprise.deployment.runtime.connector.SunConnector)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 MissingResourceException (java.util.MissingResourceException)1 Set (java.util.Set)1 Context (javax.naming.Context)1