Search in sources :

Example 1 with ConnectorConnectionPool

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

the class JdbcConnectionPoolDeployer method actualDeployResource.

/**
 * Deploy the resource into the server's runtime naming context
 *
 * @param resource a resource object
 * @throws Exception thrown if fail
 */
public void actualDeployResource(Object resource, PoolInfo poolInfo) {
    if (_logger.isLoggable(Level.FINE)) {
        _logger.fine(" JdbcConnectionPoolDeployer - actualDeployResource : " + poolInfo);
    }
    JdbcConnectionPool adminPool = (JdbcConnectionPool) resource;
    try {
        ConnectorConnectionPool connConnPool = createConnectorConnectionPool(adminPool, poolInfo);
        registerTransparentDynamicReconfigPool(poolInfo, adminPool);
        // now do internal book keeping
        runtime.createConnectorConnectionPool(connConnPool);
    } catch (Exception e) {
        Object[] params = new Object[] { poolInfo, e };
        _logger.log(Level.WARNING, "error.creating.jdbc.pool", params);
    }
}
Also used : ConnectorConnectionPool(com.sun.enterprise.connectors.ConnectorConnectionPool) JdbcConnectionPool(org.glassfish.jdbc.config.JdbcConnectionPool) MissingResourceException(java.util.MissingResourceException) ResourceConflictException(org.glassfish.resourcebase.resources.api.ResourceConflictException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 2 with ConnectorConnectionPool

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

the class ConnectionPool method setPoolConfiguration.

private void setPoolConfiguration(Hashtable env) throws PoolingException {
    ConnectorConnectionPool poolResource = getPoolConfigurationFromJndi(env);
    idletime = Integer.parseInt(poolResource.getIdleTimeoutInSeconds()) * 1000L;
    maxPoolSize = Integer.parseInt(poolResource.getMaxPoolSize());
    steadyPoolSize = Integer.parseInt(poolResource.getSteadyPoolSize());
    if (maxPoolSize < steadyPoolSize) {
        maxPoolSize = steadyPoolSize;
    }
    resizeQuantity = Integer.parseInt(poolResource.getPoolResizeQuantity());
    maxWaitTime = Integer.parseInt(poolResource.getMaxWaitTimeInMillis());
    // Make sure it's not negative.
    if (maxWaitTime < 0) {
        maxWaitTime = 0;
    }
    failAllConnections = poolResource.isFailAllConnections();
    validation = poolResource.isIsConnectionValidationRequired();
    validateAtmostEveryIdleSecs = poolResource.isValidateAtmostEveryIdleSecs();
    dataStructureType = poolResource.getPoolDataStructureType();
    dataStructureParameters = poolResource.getDataStructureParameters();
    poolWaitQueueClass = poolResource.getPoolWaitQueue();
    resourceSelectionStrategyClass = poolResource.getResourceSelectionStrategyClass();
    resourceGatewayClass = poolResource.getResourceGatewayClass();
    reconfigWaitTime = poolResource.getDynamicReconfigWaitTimeout();
    setAdvancedPoolConfiguration(poolResource);
}
Also used : ConnectorConnectionPool(com.sun.enterprise.connectors.ConnectorConnectionPool)

Example 3 with ConnectorConnectionPool

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

the class ConnectorAdminServiceUtils method getDefaultResourcePrincipal.

/*
     * Returns a ResourcePrincipal object populated with a pool's
     * default USERNAME and PASSWORD
     *
     * @throws NamingException if poolname lookup fails
     */
public static ResourcePrincipal getDefaultResourcePrincipal(PoolInfo poolInfo) throws NamingException {
    // All this to get the default user name and principal
    ConnectorConnectionPool connectorConnectionPool = null;
    try {
        String jndiNameForPool = getReservePrefixedJNDINameForPool(poolInfo);
        Context ic = ConnectorRuntime.getRuntime().getNamingManager().getInitialContext();
        connectorConnectionPool = (ConnectorConnectionPool) ic.lookup(jndiNameForPool);
    } catch (NamingException ne) {
        throw ne;
    }
    ConnectorDescriptorInfo cdi = connectorConnectionPool.getConnectorDescriptorInfo();
    Set mcfConfigProperties = cdi.getMCFConfigProperties();
    Iterator mcfConfPropsIter = mcfConfigProperties.iterator();
    String userName = "";
    String password = "";
    while (mcfConfPropsIter.hasNext()) {
        ConnectorConfigProperty prop = (ConnectorConfigProperty) mcfConfPropsIter.next();
        if (prop.getName().toUpperCase(Locale.getDefault()).equals("USERNAME") || prop.getName().toUpperCase(Locale.getDefault()).equals("USER")) {
            userName = prop.getValue();
        } else if (prop.getName().toUpperCase(Locale.getDefault()).equals("PASSWORD")) {
            password = prop.getValue();
        }
    }
    // Now return the ResourcePrincipal
    return new ResourcePrincipal(userName, password);
}
Also used : Context(javax.naming.Context) ConnectorConnectionPool(com.sun.enterprise.connectors.ConnectorConnectionPool) Set(java.util.Set) Iterator(java.util.Iterator) ConnectorDescriptorInfo(com.sun.enterprise.connectors.ConnectorDescriptorInfo) ResourcePrincipal(com.sun.enterprise.deployment.ResourcePrincipal) NamingException(javax.naming.NamingException) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty)

Example 4 with ConnectorConnectionPool

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

the class ConnectorResourceAdminServiceImpl method createConnectorResource.

/**
 * Creates the connector resource on a given connection pool
 *
 * @param resourceInfo     JNDI name of the resource to be created
 * @param poolInfo     PoolName to which the connector resource belongs.
 * @param resourceType Resource type Unused.
 * @throws ConnectorRuntimeException If the resouce creation fails.
 */
public void createConnectorResource(ResourceInfo resourceInfo, PoolInfo poolInfo, String resourceType) throws ConnectorRuntimeException {
    try {
        ConnectorConnectionPool ccp = null;
        String jndiNameForPool = ConnectorAdminServiceUtils.getReservePrefixedJNDINameForPool(poolInfo);
        try {
            ccp = (ConnectorConnectionPool) namingService.lookup(poolInfo, jndiNameForPool);
        } catch (NamingException ne) {
            // Probably the pool is not yet initialized (lazy-loading), try doing a lookup
            try {
                checkAndLoadPool(poolInfo);
                ccp = (ConnectorConnectionPool) namingService.lookup(poolInfo, jndiNameForPool);
            } catch (NamingException e) {
                Object[] params = new Object[] { poolInfo, e };
                _logger.log(Level.SEVERE, "unable.to.lookup.pool", params);
            }
        }
        if (ccp == null) {
            ccp = (ConnectorConnectionPool) namingService.lookup(poolInfo, jndiNameForPool);
        }
        ConnectorDescriptorInfo cdi = ccp.getConnectorDescriptorInfo();
        javax.naming.Reference ref = new javax.naming.Reference(cdi.getConnectionFactoryClass(), "com.sun.enterprise.resource.naming.ConnectorObjectFactory", null);
        RefAddr addr = new SerializableObjectRefAddr(PoolInfo.class.getName(), poolInfo);
        ref.add(addr);
        addr = new StringRefAddr("rarName", cdi.getRarName());
        ref.add(addr);
        RefAddr resAddr = new SerializableObjectRefAddr(ResourceInfo.class.getName(), resourceInfo);
        ref.add(resAddr);
        try {
            namingService.publishObject(resourceInfo, ref, true);
            _registry.addResourceInfo(resourceInfo);
        } catch (NamingException ne) {
            ConnectorRuntimeException cre = new ConnectorRuntimeException(ne.getMessage());
            cre.initCause(ne);
            Object[] params = new Object[] { resourceInfo, cre };
            _logger.log(Level.SEVERE, "rardeployment.resource_jndi_bind_failure", params);
            throw cre;
        }
        /*

            ConnectorObjectFactory cof = new ConnectorObjectFactory(jndiName, ccp.getConnectorDescriptorInfo().
                    getConnectionFactoryClass(), cdi.getRarName(), poolName);

            _runtime.getNamingManager().publishObject(jndiName, cof, true);
*/
        // To notify that a connector resource rebind has happened.
        ConnectorResourceNamingEventNotifier.getInstance().notifyListeners(new ConnectorNamingEvent(resourceInfo.toString(), ConnectorNamingEvent.EVENT_OBJECT_REBIND));
    } catch (NamingException ne) {
        ConnectorRuntimeException cre = new ConnectorRuntimeException(ne.getMessage());
        cre.initCause(ne);
        Object[] params = new Object[] { resourceInfo, cre };
        _logger.log(Level.SEVERE, "rardeployment.jndi_lookup_failed", params);
        throw cre;
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ConnectorConnectionPool(com.sun.enterprise.connectors.ConnectorConnectionPool) SerializableObjectRefAddr(org.glassfish.resources.naming.SerializableObjectRefAddr) ConnectorNamingEvent(com.sun.appserv.connectors.internal.spi.ConnectorNamingEvent) RefAddr(javax.naming.RefAddr) SerializableObjectRefAddr(org.glassfish.resources.naming.SerializableObjectRefAddr) StringRefAddr(javax.naming.StringRefAddr) StringRefAddr(javax.naming.StringRefAddr) ConnectorDescriptorInfo(com.sun.enterprise.connectors.ConnectorDescriptorInfo) NamingException(javax.naming.NamingException) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo)

Example 5 with ConnectorConnectionPool

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

the class ConnectionPoolObjectsUtils method createSunRaConnectorPoolObject.

/**
 * Creates ConnectorConnectionPool object pertaining to the pool props
 * mentioned in the sun-ra/xml i.e it represents the pool mentioned in the
 * sun-ra.xm.
 *
 * @param poolInfo Name of the pool
 * @param desc     ConnectorDescriptor which represent ra.xml and sun-ra.xml.
 * @return ConnectorConnectionPool created ConnectorConnectionPool instance
 */
public static ConnectorConnectionPool createSunRaConnectorPoolObject(PoolInfo poolInfo, ConnectorDescriptor desc, String rarName) {
    ConnectorConnectionPool connectorPoolObj = new ConnectorConnectionPool(poolInfo);
    SunConnector sundesc = desc.getSunDescriptor();
    ResourceAdapter sunRAXML = sundesc.getResourceAdapter();
    connectorPoolObj.setMaxPoolSize((String) sunRAXML.getValue(ResourceAdapter.MAX_POOL_SIZE));
    connectorPoolObj.setSteadyPoolSize((String) sunRAXML.getValue(ResourceAdapter.STEADY_POOL_SIZE));
    connectorPoolObj.setMaxWaitTimeInMillis((String) sunRAXML.getValue(ResourceAdapter.MAX_WAIT_TIME_IN_MILLIS));
    connectorPoolObj.setIdleTimeoutInSeconds((String) sunRAXML.getValue(ResourceAdapter.IDLE_TIMEOUT_IN_SECONDS));
    connectorPoolObj.setPoolResizeQuantity((String) "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");
        }
    }
    boolean validateAtmostEveryIdleSecs = false;
    // For SunRAPool, get the value of system property VALIDATE_ATMOST_EVERY_IDLE_SECS.
    if (validateAtmostEveryIdleSecsProperty != null && validateAtmostEveryIdleSecsProperty.equalsIgnoreCase("TRUE")) {
        validateAtmostEveryIdleSecs = true;
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "CCP.ValidateAtmostEveryIdleSecs.Set", poolInfo);
        }
    }
    connectorPoolObj.setValidateAtmostEveryIdleSecs(validateAtmostEveryIdleSecs);
    return connectorPoolObj;
}
Also used : ConnectorConnectionPool(com.sun.enterprise.connectors.ConnectorConnectionPool) SunConnector(com.sun.enterprise.deployment.runtime.connector.SunConnector) ResourceAdapter(com.sun.enterprise.deployment.runtime.connector.ResourceAdapter) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

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