use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class ActiveResourceAdapterImpl method deleteDefaultConnectorResources.
/**
* Deletes the default connector resources.
*/
protected void deleteDefaultConnectorResources() {
for (ConnectionDefDescriptor aConnectionDefs_ : connectionDefs_) {
String connectionDefName = aConnectionDefs_.getConnectionFactoryIntf();
String resourceJndiName = connectorRuntime_.getDefaultResourceName(moduleName_, connectionDefName);
try {
ResourceInfo resourceInfo = new ResourceInfo(resourceJndiName);
connectorRuntime_.deleteConnectorResource(resourceInfo);
} catch (ConnectorRuntimeException cre) {
_logger.log(Level.WARNING, "rar.undeployment.default_resource_delete_fail", resourceJndiName);
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Error while trying to delete the default connector resource", cre);
}
}
}
}
use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class ActiveJmsResourceAdapter method initializeService.
// methods from LazyServiceIntializer
@Override
public boolean initializeService() {
try {
String module = ConnectorConstants.DEFAULT_JMS_ADAPTER;
String loc = ConnectorsUtil.getSystemModuleLocation(module);
ConnectorRuntime connectorRuntime = connectorRuntimeProvider.get();
connectorRuntime.createActiveResourceAdapter(loc, module, null);
return true;
} catch (ConnectorRuntimeException e) {
e.printStackTrace();
// _logger.log(Level.WARNING, "Failed to start JMS RA");
e.printStackTrace();
return false;
}
}
use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class ActiveJmsResourceAdapter method setAvailabilityProperties.
/*
* Set Availability related properties
* If JMS availability true set availability properties
* read configured pool information and set.
*/
private void setAvailabilityProperties() throws ConnectorRuntimeException {
if (!isClustered())
return;
try {
Domain domain = Globals.get(Domain.class);
ServerContext serverContext = Globals.get(ServerContext.class);
Server server = domain.getServerNamed(serverContext.getInstanceName());
JmsService jmsService = server.getConfig().getExtensionByType(JmsService.class);
if (jmsService.getType().equals(REMOTE)) {
// been configured with the right properties.
return;
}
AvailabilityService as = server.getConfig().getAvailabilityService();
if (as == null) {
if (_logger.isLoggable(Level.FINE))
logFine("Availability Service is null. Not setting AvailabilityProperties.");
return;
}
boolean useMasterBroker = true;
if (as.getExtensionByType(JmsAvailability.class) != null && !MASTERBROKER.equalsIgnoreCase(as.getExtensionByType(JmsAvailability.class).getConfigStoreType()))
useMasterBroker = false;
// jmsService.getUseMasterBroker() != null ? Boolean.valueOf(jmsService.getUseMasterBroker()) :true;
boolean isJmsAvailabilityEnabled = this.isJMSAvailabilityOn(as);
if (_logger.isLoggable(Level.FINE))
logFine("Setting AvailabilityProperties .. ");
if (!useMasterBroker || isJmsAvailabilityEnabled) {
// For conventional cluster of peer brokers and Enhanced Broker Cluster.
ConnectorDescriptor cd = getDescriptor();
String clusterName = getMQClusterName();
ConnectorConfigProperty envProp1 = new ConnectorConfigProperty(CLUSTERID, clusterName, "Cluster Id", "java.lang.String");
setProperty(cd, envProp1);
if (brokerInstanceName == null) {
brokerInstanceName = getBrokerInstanceName(jmsService);
}
ConnectorConfigProperty envProp2 = new ConnectorConfigProperty(BROKERID, brokerInstanceName, "Broker Id", "java.lang.String");
setProperty(cd, envProp2);
// Only if JMS availability is true - Enhanced Broker Cluster only.
if (isJmsAvailabilityEnabled) {
// Set HARequired as true - irrespective of whether it is REMOTE or
// LOCAL
ConnectorConfigProperty envProp3 = new ConnectorConfigProperty(HAREQUIRED, "true", "HA Required", "java.lang.String");
setProperty(cd, envProp3);
/* The broker has a property to control whether
* it starts in HA mode or not and that's represented on
* the RA by BrokerEnableHA.
* On the MQ Client connection side it is HARequired -
* this does not control the broker, it just is a client
* side requirement.
* So for AS EE, if BrokerType is LOCAL or EMBEDDED,
* and AS HA is enabled for JMS then both these must be
* set to true. */
ConnectorConfigProperty envProp4 = new ConnectorConfigProperty(BROKERENABLEHA, "true", "BrokerEnableHA flag", "java.lang.Boolean");
setProperty(cd, envProp4);
String nodeHostName = domain.getNodeNamed(server.getNodeRef()).getNodeHost();
if (nodeHostName != null) {
ConnectorConfigProperty envProp5 = new ConnectorConfigProperty(BROKERBINDADDRESS, nodeHostName, "Broker Bind Address", "java.lang.String");
setProperty(cd, envProp5);
}
loadDBProperties(as.getExtensionByType(JmsAvailability.class), ClusterMode.ENHANCED);
} else {
// Conventional cluster of peer brokers
JmsAvailability jmsAvailability = as.getExtensionByType(JmsAvailability.class);
if ("jdbc".equals(jmsAvailability.getMessageStoreType()))
loadDBProperties(jmsAvailability, ClusterMode.ENHANCED);
loadDBProperties(jmsAvailability, ClusterMode.CONVENTIONAL_OF_PEER_BROKERS);
}
/*
ConnectorConfigProperty envProp4 = new ConnectorConfigProperty (
DBTYPE , DBTYPE_HADB,"DBType",
"java.lang.String");
setProperty(cd, envProp4);
* The broker has a property to control whether
* it starts in HA mode or not and that's represented on
* the RA by BrokerEnableHA.
* On the MQ Client connection side it is HARequired -
* this does not control the broker, it just is a client
* side requirement.
* So for AS EE, if BrokerType is LOCAL or EMBEDDED,
* and AS HA is enabled for JMS then both these must be
* set to true.
ConnectorConfigProperty envProp5 = new ConnectorConfigProperty (
BROKERENABLEHA , "true",
"BrokerEnableHA flag","java.lang.Boolean");
setProperty(cd, envProp5);
String nodeHostName = domain.getNodeNamed(server.getNode()).getNodeHost();
if (nodeHostName != null) {
ConnectorConfigProperty envProp6 = new ConnectorConfigProperty (
BROKERBINDADDRESS , nodeHostName,
"Broker Bind Address","java.lang.String");
setProperty(cd, envProp6);
}
//get pool name
String poolJNDIName = as.getJmsAvailability().getMqStorePoolName();
//If no MQ store pool name is specified, use default poolname
//XXX: default pool name is jdbc/hastore but asadmin
//configure-ha-cluster creates a resource called
//"jdbc/<asclustername>-hastore" which needs to be used.
if (poolJNDIName == null || poolJNDIName =="" ) {
//get Web container's HA store's pool name
poolJNDIName = as.getWebContainerAvailability().
getHttpSessionStorePoolName();
logFine("HTTP Session store pool jndi name " +
"is " + poolJNDIName);
}
//XXX: request HADB team mq-store-pool name to be
//populated as part of configure-ha-cluster
JdbcConnectionPool jdbcConPool = getJDBCConnectionPoolInfo(
poolJNDIName);
//DBProps: compute values from pool object
String userName = getPropertyFromPool(jdbcConPool, DUSERNAME);
logFine("HA username is " + userName);
String password = getPropertyFromPool(jdbcConPool, DPASSWORD);
logFine("HA Password is " + password);
String driverClass = jdbcConPool.getDatasourceClassname();
logFine("HA driverclass" + driverClass);
dbProps = new Properties();
dbProps.setProperty(DB_HADB_USER, userName);
dbProps.setProperty(DB_HADB_PASSWORD, password);
dbProps.setProperty(DB_HADB_DRIVERCLASS, driverClass);
//DSProps: compute values from pool object
String serverList = getPropertyFromPool(jdbcConPool, DSERVERLIST);
logFine("HADB server list is " + serverList);
dsProps = new Properties();
if (serverList != null) {
dsProps.setProperty(DS_HADB_SERVERLIST, serverList);
} else {
_logger.warning("ajra.incorrect_hadb_server_list");
}
//set all other properties in dsProps as well.
Properties p = getDSPropertiesFromThePool(jdbcConPool);
Iterator iterator = p.keySet().iterator();
while (iterator.hasNext()) {
String key = (String) iterator.next();
String val = (String)p.get(key);
dsProps.setProperty(key, val);
}*/
} else {
// Conventional cluster with master broker.
if ("jdbc".equals(as.getExtensionByType(JmsAvailability.class).getMessageStoreType()))
loadDBProperties(as.getExtensionByType(JmsAvailability.class), ClusterMode.CONVENTIONAL_WITH_MASTER_BROKER);
}
} catch (Exception e) {
ConnectorRuntimeException crex = new ConnectorRuntimeException(e.getMessage());
throw (ConnectorRuntimeException) crex.initCause(e);
}
}
use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class ActiveJmsResourceAdapter method rebindDescriptor.
private void rebindDescriptor() throws ConnectorRuntimeException {
try {
String descriptorJNDIName = ConnectorAdminServiceUtils.getReservePrefixedJNDINameForDescriptor(super.getModuleName());
// GlassfishNamingManager nm = connectorRuntime.getNamingManager();
nm.publishObject(descriptorJNDIName, super.getDescriptor(), true);
// com.sun.enterprise.Switch.getSwitch().getNamingManager(). publishObject( descriptorJNDIName, super.getDescriptor(), true);
} catch (javax.naming.NamingException ne) {
ConnectorRuntimeException cre = new ConnectorRuntimeException(ne.getMessage());
throw (ConnectorRuntimeException) cre.initCause(ne);
}
}
use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class ActiveJmsResourceAdapter method updateMDBRuntimeInfo.
/**
* This is the most appropriate time (??) to update the runtime
* info of a 1.3 MDB into 1.4 MDB. <p>
*
* Assumptions : <p>
* 0. Assume it is a 1.3 MDB if no RA mid is specified.
* 1. Use the default system JMS resource adapter. <p>
* 2. The ActivationSpec of the default JMS RA will provide the
* setDestination, setDestinationType, setSubscriptionName methods.
* 3. The jndi-name of the 1.3 MDB is the value for the Destination
* property for the ActivationSpec.
* 4. The ActivationSpec provides setter methods for the properties
* defined in the CF that corresponds to the mdb-connection-factory
* JNDI name.
*
* @param descriptor_
* @param poolDescriptor
* @throws com.sun.appserv.connectors.internal.api.ConnectorRuntimeException
*/
@Override
public void updateMDBRuntimeInfo(EjbMessageBeanDescriptor descriptor_, BeanPoolDescriptor poolDescriptor) throws ConnectorRuntimeException {
String jndiName = descriptor_.getJndiName();
if (jndiName == null || "".equals(jndiName)) {
MessageDestinationDescriptor destDescriptor = descriptor_.getMessageDestination();
if (destDescriptor != null)
jndiName = destDescriptor.getJndiName();
}
String destinationLookup = descriptor_.getActivationConfigValue("destinationLookup");
String destinationProp = descriptor_.getActivationConfigValue("destination");
if (destinationLookup == null && destinationProp == null && (jndiName == null || "".equals(jndiName))) {
if (_logger.isLoggable(Level.SEVERE)) {
_logger.log(Level.SEVERE, JMSLoggerInfo.ERROR_IN_DD);
}
String msg = sm.getString("ajra.error_in_dd");
throw new ConnectorRuntimeException(msg);
}
String resourceAdapterMid = ConnectorRuntime.DEFAULT_JMS_ADAPTER;
descriptor_.setResourceAdapterMid(resourceAdapterMid);
if (destinationLookup == null && destinationProp == null) {
String appName = descriptor_.getApplication().getAppName();
String moduleName = ConnectorsUtil.getModuleName(descriptor_);
JMSDestinationDefinitionDescriptor destination = getJMSDestinationFromDescriptor(jndiName, descriptor_);
String destName = null;
if (isValidDestination(destination)) {
destName = destination.getDestinationName();
} else {
destName = getPhysicalDestinationFromConfiguration(jndiName, appName, moduleName);
}
// 1.3 jndi-name ==> 1.4 setDestination
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(DESTINATION, destName, null));
// XXX Do we really need this???
if (descriptor_.getDestinationType() != null && !"".equals(descriptor_.getDestinationType())) {
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(DESTINATION_TYPE, descriptor_.getDestinationType(), null));
if (_logger.isLoggable(Level.INFO)) {
_logger.log(Level.INFO, JMSLoggerInfo.ENDPOINT_DEST_NAME, new Object[] { descriptor_.getDestinationType(), jndiName, descriptor_.getName() });
}
} else if (isValidDestination(destination) && ConnectorConstants.DEFAULT_JMS_ADAPTER.equals(destination.getResourceAdapter())) {
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(DESTINATION_TYPE, destination.getInterfaceName(), null));
if (_logger.isLoggable(Level.INFO)) {
_logger.log(Level.INFO, JMSLoggerInfo.ENDPOINT_DEST_NAME, new Object[] { destination.getInterfaceName(), destination.getName(), descriptor_.getName() });
}
} else {
/*
* If destination type is not provided by the MDB component
* [typically used by EJB3.0 styled MDBs which create MDBs without
* a destination type activation-config property] and the MDB is for
* the default JMS RA, attempt to infer the destination type by trying
* to find out if there has been any JMS destination resource already
* defined for default JMS RA. This is a best attempt guess and if there
* are no JMS destination resources/admin-objects defined, AS would pass
* the properties as defined by the MDB.
*/
try {
AdminObjectResource aor = (AdminObjectResource) ResourcesUtil.createInstance().getResource(jndiName, appName, moduleName, AdminObjectResource.class);
if (aor != null && ConnectorConstants.DEFAULT_JMS_ADAPTER.equals(aor.getResAdapter())) {
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(DESTINATION_TYPE, aor.getResType(), null));
if (_logger.isLoggable(Level.INFO)) {
_logger.log(Level.INFO, JMSLoggerInfo.ENDPOINT_DEST_NAME, new Object[] { aor.getResType(), aor.getJndiName(), descriptor_.getName() });
}
}
} catch (Exception e) {
}
}
}
// 1.3 durable-subscription-name == 1.4 setSubscriptionName
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(SUBSCRIPTION_NAME, descriptor_.getDurableSubscriptionName(), null));
String mdbCF = null;
try {
mdbCF = descriptor_.getMdbConnectionFactoryJndiName();
} catch (NullPointerException ne) {
// Dont process connection factory.
}
if (mdbCF != null && !"".equals(mdbCF)) {
setValuesFromConfiguration(mdbCF, descriptor_);
}
if (poolDescriptor != null) {
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(MAXPOOLSIZE, "" + poolDescriptor.getMaxPoolSize(), "", "java.lang.Integer"));
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(MINPOOLSIZE, "" + poolDescriptor.getSteadyPoolSize(), "", "java.lang.Integer"));
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(RESIZECOUNT, "" + poolDescriptor.getPoolResizeQuantity(), "", "java.lang.Integer"));
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(RESIZETIMEOUT, "" + poolDescriptor.getPoolIdleTimeoutInSeconds(), "", "java.lang.Integer"));
/**
* The runtime activation config property holds all the
* vendor specific properties, unfortunately the vendor
* specific way of configuring exception count and the
* standard way of configuring redelivery attempts is
* through the same property REDELIVERYCOUNT . So, we first
* check if the user (MDB assember) has configured a value
* if not we set the one from mdb-container props
* We have to check for both cases here because it has been
* documented as "endpointExceptionRedeliveryAttempts" but
* used in the code as "EndpointExceptionRedeliveryAttempts"
*/
if ((descriptor_.getActivationConfigValue(REDELIVERYCOUNT) == null) && (descriptor_.getActivationConfigValue(LOWERCASE_REDELIVERYCOUNT) == null)) {
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(REDELIVERYCOUNT, "" + MdbContainerProps.getMaxRuntimeExceptions(), "", "java.lang.Integer"));
}
}
// Set SE/EE specific MQ-RA ActivationSpec properties
try {
boolean clustered = isClustered();
if (_logger.isLoggable(Level.FINE))
logFine("Are we in a Clustered contained ? " + clustered);
if (clustered)
setClusterActivationSpecProperties(descriptor_);
} catch (Exception e) {
ConnectorRuntimeException crex = new ConnectorRuntimeException(e.getMessage());
throw (ConnectorRuntimeException) crex.initCause(e);
}
}
Aggregations