use of com.sun.enterprise.config.serverbeans.Cluster in project Payara by payara.
the class JMSPing method createJMSResource.
void createJMSResource(JmsHost defaultJmsHost, ActionReport subReport, String tmpJMSResource, final Subject subject) {
String port = null;
String host = null;
Server targetServer = domain.getServerNamed(target);
if (targetServer != null && !targetServer.isDas()) {
port = JmsRaUtil.getJMSPropertyValue(targetServer);
host = domain.getNodeNamed(targetServer.getNodeRef()).getNodeHost();
} else {
Cluster cluster = domain.getClusterNamed(target);
if (cluster != null && cluster.getInstances().size() != 0) {
targetServer = cluster.getInstances().get(0);
port = JmsRaUtil.getJMSPropertyValue(targetServer);
host = domain.getNodeNamed(targetServer.getNodeRef()).getNodeHost();
}
}
String userName = defaultJmsHost.getAdminUserName();
String password = defaultJmsHost.getAdminPassword();
if (host == null)
host = defaultJmsHost.getHost();
if (port == null)
port = defaultJmsHost.getPort();
ParameterMap aoAttrList = new ParameterMap();
Properties properties = new Properties();
properties.put("imqDefaultUsername", userName);
if (isPasswordAlias(password)) {
// If the string is a password alias, it needs to be escapted with another pair of quotes...
properties.put("imqDefaultPassword", "\"" + password + "\"");
} else
properties.put("imqDefaultPassword", password);
// need to escape the addresslist property so that they get passed on correctly to the create-connector-connection-pool command
properties.put("AddressList", "\"mq://" + host + ":" + port + "\"");
StringBuilder builder = new StringBuilder();
for (java.util.Map.Entry<Object, Object> prop : properties.entrySet()) {
builder.append(prop.getKey()).append("=").append(prop.getValue()).append(":");
}
String propString = builder.toString();
int lastColonIndex = propString.lastIndexOf(":");
if (lastColonIndex >= 0) {
propString = propString.substring(0, lastColonIndex);
}
aoAttrList.set("property", propString);
aoAttrList.set("restype", "javax.jms.QueueConnectionFactory");
aoAttrList.set("DEFAULT", tmpJMSResource);
// aoAttrList.set("target", target);
commandRunner.getCommandInvocation("create-jms-resource", subReport, subject).parameters(aoAttrList).execute();
}
use of com.sun.enterprise.config.serverbeans.Cluster in project Payara by payara.
the class JmsHandlers method getMBeanServerConnection.
private static MBeanServerConnection getMBeanServerConnection(String target) throws ConnectorRuntimeException, Exception {
ServiceLocator habitat = GuiUtil.getHabitat();
Domain domain = habitat.getService(Domain.class);
Cluster cluster = domain.getClusterNamed(target);
String configRef = null;
if (cluster == null) {
Server server = domain.getServerNamed(target);
configRef = server.getConfigRef();
} else {
configRef = cluster.getConfigRef();
}
PhysicalDestinations pd = new PhysicalDestinations();
MQJMXConnectorInfo mqInfo = pd.getConnectorInfo(target, configRef, habitat, domain);
return mqInfo.getMQMBeanServerConnection();
}
use of com.sun.enterprise.config.serverbeans.Cluster in project Payara by payara.
the class TransactionServiceProperties method getJTSProperties.
public static synchronized Properties getJTSProperties(ServiceLocator serviceLocator, boolean isORBAvailable) {
if (orbAvailable == isORBAvailable && properties != null) {
// We will need to update the properties if ORB availability changed
return properties;
}
Properties jtsProperties = new Properties();
if (serviceLocator != null) {
jtsProperties.put(HABITAT, serviceLocator);
ProcessEnvironment processEnv = serviceLocator.getService(ProcessEnvironment.class);
if (processEnv.getProcessType().isServer()) {
TransactionService txnService = serviceLocator.getService(TransactionService.class, ServerEnvironment.DEFAULT_INSTANCE_NAME);
if (txnService != null) {
jtsProperties.put(Configuration.HEURISTIC_DIRECTION, txnService.getHeuristicDecision());
jtsProperties.put(Configuration.KEYPOINT_COUNT, txnService.getKeypointInterval());
String automaticRecovery = txnService.getAutomaticRecovery();
boolean isAutomaticRecovery = (isValueSet(automaticRecovery) && "true".equals(automaticRecovery));
if (isAutomaticRecovery) {
_logger.log(Level.FINE, "Recoverable J2EE Server");
jtsProperties.put(Configuration.MANUAL_RECOVERY, "true");
}
boolean disable_distributed_transaction_logging = false;
String dbLoggingResource = null;
for (Property prop : txnService.getProperty()) {
String name = prop.getName();
String value = prop.getValue();
if (name.equals("disable-distributed-transaction-logging")) {
if (isValueSet(value) && "true".equals(value)) {
disable_distributed_transaction_logging = true;
}
} else if (name.equals("xaresource-txn-timeout")) {
if (isValueSet(value)) {
_logger.log(Level.FINE, "XAResource transaction timeout is" + value);
TransactionManagerImpl.setXAResourceTimeOut(Integer.parseInt(value));
}
} else if (name.equals("db-logging-resource")) {
dbLoggingResource = value;
_logger.log(Level.FINE, "Transaction DB Logging Resource Name" + dbLoggingResource);
if (dbLoggingResource != null && (" ".equals(dbLoggingResource) || "".equals(dbLoggingResource))) {
dbLoggingResource = "jdbc/TxnDS";
}
} else if (name.equals("xa-servername")) {
if (isValueSet(value)) {
jtsProperties.put(JTS_XA_SERVER_NAME, value);
}
} else if (name.equals("pending-txn-cleanup-interval")) {
if (isValueSet(value)) {
jtsProperties.put("pending-txn-cleanup-interval", value);
}
} else if (name.equals(Configuration.COMMIT_ONE_PHASE_DURING_RECOVERY)) {
if (isValueSet(value)) {
jtsProperties.put(Configuration.COMMIT_ONE_PHASE_DURING_RECOVERY, value);
}
} else if (name.equals("add-wait-point-during-recovery")) {
if (isValueSet(value)) {
try {
FailureInducer.setWaitPointRecovery(Integer.parseInt(value));
} catch (Exception e) {
_logger.log(Level.WARNING, e.getMessage());
}
}
}
}
if (dbLoggingResource != null) {
disable_distributed_transaction_logging = true;
jtsProperties.put(Configuration.DB_LOG_RESOURCE, dbLoggingResource);
}
/**
* JTS_SERVER_ID needs to be unique for each for server instance.
* This will be used as recovery identifier along with the hostname
* for example: if the hostname is 'tulsa' and iiop-listener-port is 3700
* recovery identifier will be tulsa,P3700
*/
// default value
int jtsServerId = DEFAULT_SERVER_ID;
if (isORBAvailable) {
jtsServerId = serviceLocator.<GlassFishORBHelper>getService(GlassFishORBHelper.class).getORBInitialPort();
if (jtsServerId == 0) {
// XXX Can this ever happen?
// default value
jtsServerId = DEFAULT_SERVER_ID;
}
}
jtsProperties.put(JTS_SERVER_ID, String.valueOf(jtsServerId));
/* ServerId is an J2SE persistent server activation
API. ServerId is scoped at the ORBD. Since
There is no ORBD present in J2EE the value of
ServerId is meaningless - except it must have
SOME value if persistent POAs are created.
*/
// For clusters - all servers in the cluster MUST
// have the same ServerId so when failover happens
// and requests are delivered to a new server, the
// ServerId in the request will match the new server.
String serverId = String.valueOf(DEFAULT_SERVER_ID);
System.setProperty(J2EE_SERVER_ID_PROP, serverId);
ServerContext ctx = serviceLocator.getService(ServerContext.class);
String instanceName = ctx.getInstanceName();
/**
* if the auto recovery is true, always transaction logs will be written irrespective of
* disable_distributed_transaction_logging.
* if the auto recovery is false, then disable_distributed_transaction_logging will be used
* to write transaction logs are not.If disable_distributed_transaction_logging is set to
* false(by default false) logs will be written, set to true logs won't be written.
*/
if (!isAutomaticRecovery && disable_distributed_transaction_logging) {
Configuration.disableFileLogging();
} else {
// if (dbLoggingResource == null) {
Domain domain = serviceLocator.getService(Domain.class);
Server server = domain.getServerNamed(instanceName);
// Check if the server system property is set
String logdir = getTXLogDir(server);
// if not, check if the cluster system property is set
if (logdir == null) {
Cluster cluster = server.getCluster();
if (cluster != null) {
logdir = getTXLogDir(cluster);
}
}
// No system properties are set - get tx log dir from transaction service
if (logdir == null) {
logdir = txnService.getTxLogDir();
}
if (logdir == null) {
logdir = domain.getLogRoot();
if (logdir == null) {
// logdir = FileUtil.getAbsolutePath(".." + File.separator + "logs");
logdir = ".." + File.separator + "logs";
}
} else if (!(new File(logdir)).isAbsolute()) {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Relative pathname specified for transaction log directory : " + logdir);
}
String logroot = domain.getLogRoot();
if (logroot != null) {
logdir = logroot + File.separator + logdir;
} else {
// logdir = FileUtil.getAbsolutePath(".." + File.separator + "logs"
// + File.separator + logdir);
logdir = ".." + File.separator + "logs" + File.separator + logdir;
}
}
logdir += File.separator + instanceName + File.separator + "tx";
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "JTS log directory: " + logdir);
_logger.log(Level.FINE, "JTS Server id " + jtsServerId);
}
jtsProperties.put(Configuration.LOG_DIRECTORY, logdir);
}
jtsProperties.put(Configuration.COMMIT_RETRY, txnService.getRetryTimeoutInSeconds());
jtsProperties.put(Configuration.INSTANCE_NAME, instanceName);
}
}
}
properties = jtsProperties;
orbAvailable = isORBAvailable;
return properties;
}
use of com.sun.enterprise.config.serverbeans.Cluster in project Payara by payara.
the class GMSAdapterImpl method initialize.
@Override
public boolean initialize(String clusterName) {
if (initialized.compareAndSet(false, true)) {
this.clusterName = clusterName;
if (clusterName == null) {
GMS_LOGGER.log(LogLevel.SEVERE, GMS_NO_CLUSTER_NAME);
return false;
}
try {
gms = GMSFactory.getGMSModule(clusterName);
} catch (GMSException ge) {
// ignore
}
if (gms != null) {
GMS_LOGGER.log(LogLevel.SEVERE, GMS_MULTIPLE_ADAPTER, clusterName);
return false;
}
Domain domain = habitat.getService(Domain.class);
instanceName = env.getInstanceName();
isDas = env.isDas();
cluster = server.getCluster();
if (cluster == null && clusters != null) {
// iterate over all clusters to find the cluster that has name passed in.
for (Cluster clusterI : clusters.getCluster()) {
if (clusterName.compareTo(clusterI.getName()) == 0) {
cluster = clusterI;
break;
}
}
}
if (cluster == null) {
GMS_LOGGER.log(LogLevel.WARNING, GMS_NO_CLUSTER_WARNING);
// don't enable GMS
return false;
} else if (isDas) {
// only want to do this in the case of the DAS
initializeHealthHistory(cluster);
}
clusterConfig = domain.getConfigNamed(clusterName + "-config");
if (GMS_LOGGER.isLoggable(LogLevel.CONFIG)) {
GMS_LOGGER.log(LogLevel.CONFIG, "clusterName=" + clusterName + " clusterConfig=" + clusterConfig);
}
try {
initializeGMS();
} catch (GMSException e) {
GMS_LOGGER.log(LogLevel.SEVERE, GMS_FAILED_TO_START, e);
// prevent access to a malformed gms object.
return false;
// also ensure for any unchecked exceptions (such as NPE during initialization) during initialization
// that the malformed gms object is not allowed to be accesssed through the gms adapter.
} catch (Throwable t) {
GMS_LOGGER.log(LogLevel.SEVERE, GMS_FAILED_TO_START_UNEXCEPTED, t);
// prevent access to a malformed gms object.
return false;
}
initializationComplete.set(true);
}
return initialized.get();
}
use of com.sun.enterprise.config.serverbeans.Cluster in project Payara by payara.
the class EjbDeployer method getOwnerId.
private String getOwnerId(String target) {
// If target is a cluster or deployment group replace it with the instance
List<Server> instances = Collections.EMPTY_LIST;
Cluster cluster = domain.getClusterNamed(target);
if (cluster != null) {
instances = cluster.getInstances();
} else {
DeploymentGroup dg = domain.getDeploymentGroupNamed(target);
if (dg != null) {
instances = dg.getInstances();
} else {
return target;
}
}
// Try a random instance in a cluster
int useInstance = random.nextInt(instances.size());
Server s0 = instances.get(useInstance);
if (s0.isRunning()) {
return s0.getName();
} else {
// Pick the first running instead
for (Server s : instances) {
if (s.isRunning()) {
return s.getName();
}
}
}
// cluster
return s0.getName();
}
Aggregations