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);
}
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;
}
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);
}
}
}
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);
}
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);
}
Aggregations