use of org.glassfish.resourcebase.resources.api.PoolInfo in project Payara by payara.
the class PoolManagerImpl method resourceEnlisted.
public void resourceEnlisted(Transaction tran, com.sun.appserv.connectors.internal.api.ResourceHandle h) throws IllegalStateException {
ResourceHandle res = (ResourceHandle) h;
PoolInfo poolInfo = res.getResourceSpec().getPoolInfo();
try {
JavaEETransaction j2eeTran = (JavaEETransaction) tran;
if (poolInfo != null && j2eeTran.getResources(poolInfo) == null) {
addSyncListener(tran);
}
} catch (ClassCastException e) {
addSyncListener(tran);
}
if (poolInfo != null) {
ResourcePool pool = getPool(poolInfo);
if (pool != null) {
pool.resourceEnlisted(tran, res);
}
}
}
use of org.glassfish.resourcebase.resources.api.PoolInfo in project Payara by payara.
the class ConnectorsRecoveryResourceHandler method loadXAResourcesAndItsConnections.
/**
* {@inheritDoc}
*/
public void loadXAResourcesAndItsConnections(List xaresList, List connList) {
// Done so as to initialize connectors-runtime before loading connector-resources. need a better way ?
ConnectorRuntime crt = connectorRuntimeProvider.get();
// ApplicationLoaderService already guarantees that connectors are loaded before any other applications.
// Recovery will not start sooner than transaction is first needed on EE application startup, therefore
// it is safe to continue here without waiting for startupProvider, as that ultimately creates a deadlock
// between ApplicationLoaderService needed a transaction manager, and recovery wainting for applications
// to finish loading.
Collection<ConnectorResource> connectorResources = getAllConnectorResources();
if (connectorResources == null || connectorResources.size() == 0) {
return;
}
List<ConnectorConnectionPool> connPools = new ArrayList<ConnectorConnectionPool>();
for (Resource resource : connectorResources) {
ConnectorResource connResource = (ConnectorResource) resource;
if (getResourcesUtil().isEnabled(connResource)) {
ResourceInfo resourceInfo = ConnectorsUtil.getResourceInfo(connResource);
ConnectorConnectionPool pool = ResourcesUtil.createInstance().getConnectorConnectionPoolOfResource(resourceInfo);
if (pool != null && ConnectorConstants.XA_TRANSACTION_TX_SUPPORT_STRING.equals(getTransactionSupport(pool))) {
connPools.add(pool);
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("ConnectorsRecoveryResourceHandler loadXAResourcesAndItsConnections :: " + "adding : " + connResource.getPoolName());
}
}
}
}
loadAllConnectorResources();
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Recovering pools : " + connPools.size());
}
for (ConnectorConnectionPool connPool : connPools) {
PoolInfo poolInfo = ConnectorsUtil.getPoolInfo(connPool);
try {
String[] dbUserPassword = getdbUserPasswordOfConnectorConnectionPool(connPool);
if (dbUserPassword == null) {
continue;
}
String dbUser = dbUserPassword[0];
String dbPassword = dbUserPassword[1];
Subject subject = new Subject();
// username [pointbase interprets this as "root"]/password.
if (dbPassword == null) {
dbPassword = "";
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, "datasource.xadatasource_nullpassword_error", poolInfo);
}
}
if (dbUser == null) {
dbUser = "";
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, "datasource.xadatasource_nulluser_error", poolInfo);
}
}
String rarName = connPool.getResourceAdapterName();
// TODO V3 JMS-RA ??
if (ConnectorAdminServiceUtils.isJMSRA(rarName)) {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Performing recovery for JMS RA, poolName " + poolInfo);
}
ManagedConnectionFactory[] mcfs = crt.obtainManagedConnectionFactories(poolInfo);
_logger.log(Level.INFO, "JMS resource recovery has created CFs = " + mcfs.length);
for (int i = 0; i < mcfs.length; i++) {
PasswordCredential pc = new PasswordCredential(dbUser, dbPassword.toCharArray());
pc.setManagedConnectionFactory(mcfs[i]);
Principal prin = new ResourcePrincipal(dbUser, dbPassword);
subject.getPrincipals().add(prin);
subject.getPrivateCredentials().add(pc);
ManagedConnection mc = mcfs[i].createManagedConnection(subject, null);
connList.add(mc);
try {
XAResource xares = mc.getXAResource();
if (xares != null) {
xaresList.add(xares);
}
} catch (ResourceException ex) {
// ignored. Not at XA_TRANSACTION level
}
}
} else {
ManagedConnectionFactory mcf = crt.obtainManagedConnectionFactory(poolInfo);
PasswordCredential pc = new PasswordCredential(dbUser, dbPassword.toCharArray());
pc.setManagedConnectionFactory(mcf);
Principal prin = new ResourcePrincipal(dbUser, dbPassword);
subject.getPrincipals().add(prin);
subject.getPrivateCredentials().add(pc);
ManagedConnection mc = mcf.createManagedConnection(subject, null);
connList.add(mc);
try {
XAResource xares = mc.getXAResource();
if (xares != null) {
xaresList.add(xares);
}
} catch (ResourceException ex) {
// ignored. Not at XA_TRANSACTION level
}
}
} catch (Exception ex) {
_logger.log(Level.WARNING, "datasource.xadatasource_error", poolInfo);
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "datasource.xadatasource_error_excp", ex);
}
}
}
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Total XAResources identified for recovery is " + xaresList.size());
_logger.log(Level.FINE, "Total connections identified for recovery is " + connList.size());
}
}
use of org.glassfish.resourcebase.resources.api.PoolInfo in project Payara by payara.
the class ActiveResourceAdapterImpl method createSunRAConnectionPool.
/**
* Creates connector connection pool pertaining to sun-ra.xml. This is
* only for 1.0 complient rars.
*
* @throws ConnectorRuntimeException Thrown when pool creation fails.
*/
private void createSunRAConnectionPool() throws ConnectorRuntimeException {
String defaultPoolName = connectorRuntime_.getDefaultPoolName(moduleName_, connectionDefs_[0].getConnectionFactoryIntf());
String sunRAPoolName = defaultPoolName + ConnectorConstants.SUN_RA_POOL;
PoolInfo poolInfo = new PoolInfo(sunRAPoolName);
ConnectorDescriptorInfo connectorDescriptorInfo = ConnectorDDTransformUtils.getConnectorDescriptorInfo(connectionDefs_[0]);
connectorDescriptorInfo.setRarName(moduleName_);
connectorDescriptorInfo.setResourceAdapterClassName(desc_.getResourceAdapterClass());
ConnectorConnectionPool connectorPoolObj = ConnectionPoolObjectsUtils.createSunRaConnectorPoolObject(poolInfo, desc_, moduleName_);
connectorPoolObj.setConnectorDescriptorInfo(connectorDescriptorInfo);
connectorRuntime_.createConnectorConnectionPool(connectorPoolObj);
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Created SUN-RA connection pool:", poolInfo);
}
String jndiName = (String) desc_.getSunDescriptor().getResourceAdapter().getValue(ResourceAdapter.JNDI_NAME);
ResourceInfo resourceInfo = new ResourceInfo(jndiName);
connectorRuntime_.createConnectorResource(resourceInfo, poolInfo, null);
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Created SUN-RA connector resource : ", resourceInfo);
}
}
use of org.glassfish.resourcebase.resources.api.PoolInfo in project Payara by payara.
the class ActiveResourceAdapterImpl method deleteDefaultConnectorConnectionPools.
/**
* Deletes the default connector connection pools.
*/
protected void deleteDefaultConnectorConnectionPools() {
for (ConnectionDefDescriptor aConnectionDefs_ : connectionDefs_) {
String connectionDefName = aConnectionDefs_.getConnectionFactoryIntf();
String resourceJndiName = connectorRuntime_.getDefaultPoolName(moduleName_, connectionDefName);
try {
PoolInfo poolInfo = new PoolInfo(resourceJndiName);
connectorRuntime_.deleteConnectorConnectionPool(poolInfo);
} catch (ConnectorRuntimeException cre) {
_logger.log(Level.WARNING, "rar.undeployment.default_pool_delete_fail", resourceJndiName);
}
}
}
use of org.glassfish.resourcebase.resources.api.PoolInfo in project Payara by payara.
the class ActiveResourceAdapterImpl method createDefaultConnectorResources.
/**
* Creates default connector resource
*
* @throws ConnectorRuntimeException when unable to create connector resources
*/
protected void createDefaultConnectorResources() throws ConnectorRuntimeException {
for (ConnectionDefDescriptor descriptor : connectionDefs_) {
String connectionDefName = descriptor.getConnectionFactoryIntf();
String resourceName = connectorRuntime_.getDefaultResourceName(moduleName_, connectionDefName);
String poolName = connectorRuntime_.getDefaultPoolName(moduleName_, connectionDefName);
PoolInfo poolInfo = new PoolInfo(poolName);
ResourceInfo resourceInfo = new ResourceInfo(resourceName);
connectorRuntime_.createConnectorResource(resourceInfo, poolInfo, null);
desc_.addDefaultResourceName(resourceName);
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Created default connector resource [ " + resourceName + " ] ");
}
}
}
Aggregations