use of org.jvnet.hk2.config.ConfigModel.Property 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 org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class UpgradeService method upgradeV3_0_1_AppClientElements.
private void upgradeV3_0_1_AppClientElements() {
/*
* If an app client has a property setting for javaWebStartEnabled we
* convert it to java-web-start-enabled which is the documented name.
* App clients can be either applications or modules within an EAR.
*/
final Transaction t = new Transaction();
try {
for (Application app : domain.getApplications().getApplications()) {
System.out.println("Checking app " + app.getName());
Application app_w = null;
Property oldSetting = app.getProperty(V3_0_1_JAVA_WEB_START_ENABLED_PROPERTY_NAME);
if (oldSetting != null) {
logger.log(Level.INFO, "For application {0} converting property {1} to {2}", new Object[] { app.getName(), V3_0_1_JAVA_WEB_START_ENABLED_PROPERTY_NAME, GF3_1_JAVA_WEB_START_ENABLED_PROPERTY_NAME });
app_w = t.enroll(app);
addProperty(GF3_1_JAVA_WEB_START_ENABLED_PROPERTY_NAME, oldSetting.getValue(), app_w);
app_w.getProperty().remove(oldSetting);
}
for (Module mod : app.getModule()) {
if (mod.getEngine(APPCLIENT_SNIFFER_NAME) != null) {
/*
* This is an app client. See if the client has
* a property setting using the old name.
*/
oldSetting = mod.getProperty(V3_0_1_JAVA_WEB_START_ENABLED_PROPERTY_NAME);
if (oldSetting != null) {
logger.log(Level.INFO, "For application {0}/module {1} converting property {2} to {3}", new Object[] { app.getName(), mod.getName(), V3_0_1_JAVA_WEB_START_ENABLED_PROPERTY_NAME, GF3_1_JAVA_WEB_START_ENABLED_PROPERTY_NAME });
final Module mod_w = t.enroll(mod);
addProperty(GF3_1_JAVA_WEB_START_ENABLED_PROPERTY_NAME, oldSetting.getValue(), mod_w);
mod_w.getProperty().remove(oldSetting);
}
}
}
}
t.commit();
} catch (Exception ex) {
t.rollback();
throw new RuntimeException("Error upgrading application", ex);
}
}
use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class ConfigDomainParser method parseIDEntry.
private void parseIDEntry(ProviderConfig pConfig, Map<String, GFServerConfigProvider.InterceptEntry> newConfig, String intercept) throws IOException {
String id = pConfig.getProviderId();
String type = pConfig.getProviderType();
String moduleClass = pConfig.getClassName();
MessagePolicy requestPolicy = parsePolicy((RequestPolicy) pConfig.getRequestPolicy());
MessagePolicy responsePolicy = parsePolicy((ResponsePolicy) pConfig.getResponsePolicy());
// get the module options
Map<String, Object> options = new HashMap<>();
List<Property> pList = pConfig.getProperty();
if (pList != null) {
Iterator<Property> pit = pList.iterator();
while (pit.hasNext()) {
Property property = pit.next();
try {
options.put(property.getName(), PropertyExpander.expand(property.getValue(), false));
} catch (ExpandException ee) {
// interpret value itself.
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "jmac.unexpandedproperty");
}
options.put(property.getName(), property.getValue());
}
}
}
if (_logger.isLoggable(FINE)) {
_logger.fine("ID Entry: " + "\n module class: " + moduleClass + "\n id: " + id + "\n type: " + type + "\n request policy: " + requestPolicy + "\n response policy: " + responsePolicy + "\n options: " + options);
}
// create ID entry
GFServerConfigProvider.IDEntry idEntry = new GFServerConfigProvider.IDEntry(type, moduleClass, requestPolicy, responsePolicy, options);
GFServerConfigProvider.InterceptEntry intEntry = newConfig.get(intercept);
if (intEntry == null) {
throw new IOException("intercept entry for " + intercept + " must be specified before ID entries");
}
if (intEntry.idMap == null) {
intEntry.idMap = new HashMap<>();
}
// map id to Intercept
intEntry.idMap.put(id, idEntry);
}
use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class GMSAdapterImpl method generateDiscoveryUriList.
/*
* Get existing nodes based on cluster element in domain.
* Then check for DAS address in das.properties. When the
* list is set to 'generate' then the gms listener port
* must also be specified. So the same port is used for
* each cluster member.
*/
private String generateDiscoveryUriList() {
String clusterPort = null;
Property gmsPortProp = cluster.getProperty("GMS_LISTENER_PORT");
if (gmsPortProp == null || gmsPortProp.getValue() == null || gmsPortProp.getValue().trim().charAt(0) == '$') {
clusterPort = "9090";
GMS_LOGGER.log(LogLevel.WARNING, GMS_LISTENER_PORT_REQUIRED, new Object[] { cluster.getName(), clusterPort });
} else {
clusterPort = gmsPortProp.getValue();
if (GMS_LOGGER.isLoggable(LogLevel.FINE)) {
GMS_LOGGER.log(LogLevel.FINE, "will use gms listener port: " + clusterPort);
}
}
// get cluster member server refs
Set<String> instanceNames = new HashSet<String>();
if (GMS_LOGGER.isLoggable(LogLevel.FINE)) {
GMS_LOGGER.log(LogLevel.FINE, String.format("checking cluster.getServerRef() for '%s'", cluster.getName()));
}
for (ServerRef sRef : cluster.getServerRef()) {
/*
* When an instance (not DAS) starts up, it will add
* its own address to the discovery list. This is ok
* now. If we want to skip it, here's the place to
* check.
*/
if (GMS_LOGGER.isLoggable(LogLevel.FINE)) {
GMS_LOGGER.log(LogLevel.FINE, String.format("adding server ref %s to set of instance names", sRef.getRef()));
}
instanceNames.add(sRef.getRef());
}
StringBuilder sb = new StringBuilder();
final String SEP = ",";
final String scheme = "tcp://";
// use server refs to find matching nodes
for (String name : instanceNames) {
Server server = servers.getServer(name);
if (server != null) {
if (GMS_LOGGER.isLoggable(LogLevel.FINE)) {
GMS_LOGGER.log(LogLevel.FINE, String.format("found server for name %s", name));
}
Node node = nodes.getNode(server.getNodeRef());
if (node != null) {
String host = scheme + node.getNodeHost() + ":" + clusterPort;
if (GMS_LOGGER.isLoggable(LogLevel.FINE)) {
GMS_LOGGER.log(LogLevel.FINE, String.format("Adding host '%s' to discovery list", host));
}
sb.append(host).append(SEP);
}
}
}
// add das location from das.properties if needed
if (server.isInstance()) {
try {
ServerDirs sDirs = new ServerDirs(env.getInstanceRoot());
File dasPropsFile = sDirs.getDasPropertiesFile();
if (GMS_LOGGER.isLoggable(LogLevel.FINE)) {
GMS_LOGGER.log(LogLevel.FINE, String.format("found das.props file at %s", dasPropsFile.getAbsolutePath()));
}
Properties dasProps = getProperties(dasPropsFile);
String host = scheme + dasProps.getProperty("agent.das.host") + ":" + clusterPort;
if (GMS_LOGGER.isLoggable(LogLevel.FINE)) {
GMS_LOGGER.log(LogLevel.FINE, String.format("adding '%s' from das.props file", host));
}
sb.append(host).append(SEP);
} catch (IOException ioe) {
GMS_LOGGER.log(LogLevel.WARNING, ioe.toString());
}
}
// trim list if needed and return
int lastCommaIndex = sb.lastIndexOf(SEP);
if (lastCommaIndex != -1) {
sb.deleteCharAt(lastCommaIndex);
}
if (GMS_LOGGER.isLoggable(LogLevel.FINE)) {
GMS_LOGGER.log(LogLevel.FINE, String.format("returning discovery list '%s'", sb.toString()));
}
return sb.toString();
}
use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class GMSAdapterImpl method readGMSConfigProps.
private void readGMSConfigProps(Properties configProps) {
configProps.put(MEMBERTYPE_STRING, isDas ? SPECTATOR : CORE);
for (ServiceProviderConfigurationKeys key : ServiceProviderConfigurationKeys.values()) {
String keyName = key.toString();
try {
switch(key) {
case MULTICASTADDRESS:
if (cluster != null) {
String value = cluster.getGmsMulticastAddress();
if (value != null) {
configProps.put(keyName, value);
}
}
break;
case MULTICASTPORT:
if (cluster != null) {
String value = cluster.getGmsMulticastPort();
if (value != null) {
configProps.put(keyName, value);
}
}
break;
case FAILURE_DETECTION_TIMEOUT:
if (clusterConfig != null) {
String value = clusterConfig.getGroupManagementService().getFailureDetection().getHeartbeatFrequencyInMillis();
if (value != null) {
configProps.put(keyName, value);
}
}
break;
case FAILURE_DETECTION_RETRIES:
if (clusterConfig != null) {
String value = clusterConfig.getGroupManagementService().getFailureDetection().getMaxMissedHeartbeats();
if (value != null) {
configProps.put(keyName, value);
}
}
break;
case FAILURE_VERIFICATION_TIMEOUT:
if (clusterConfig != null) {
String value = clusterConfig.getGroupManagementService().getFailureDetection().getVerifyFailureWaittimeInMillis();
if (value != null) {
configProps.put(keyName, value);
}
}
break;
case DISCOVERY_TIMEOUT:
if (clusterConfig != null) {
String value = clusterConfig.getGroupManagementService().getGroupDiscoveryTimeoutInMillis();
if (value != null) {
configProps.put(keyName, value);
}
}
break;
case IS_BOOTSTRAPPING_NODE:
configProps.put(keyName, isDas ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
break;
case BIND_INTERFACE_ADDRESS:
if (cluster != null) {
String value = cluster.getGmsBindInterfaceAddress();
if (value != null) {
value = value.trim();
}
if (value != null && value.length() > 1 && value.charAt(0) != '$') {
// Only supported IPv4 address in gf v2.
if (NetworkUtility.isBindAddressValid(value)) {
configProps.put(keyName, value);
} else {
GMS_LOGGER.log(LogLevel.SEVERE, GMS_BIND_INT_ADDRESS_INVALID, value);
}
}
}
break;
case FAILURE_DETECTION_TCP_RETRANSMIT_TIMEOUT:
if (clusterConfig != null) {
String value = clusterConfig.getGroupManagementService().getFailureDetection().getVerifyFailureConnectTimeoutInMillis();
if (value != null) {
configProps.put(keyName, value);
}
}
break;
case MULTICAST_POOLSIZE:
case INCOMING_MESSAGE_QUEUE_SIZE:
// case MAX_MESSAGE_LENGTH: todo uncomment with shoal-gms.jar with this defined is promoted.
case FAILURE_DETECTION_TCP_RETRANSMIT_PORT:
if (clusterConfig != null) {
Property prop = clusterConfig.getGroupManagementService().getProperty(keyName);
if (prop == null) {
if (GMS_LOGGER.isLoggable(LogLevel.FINE)) {
GMS_LOGGER.log(LogLevel.FINE, String.format("No config property found for %s", keyName));
}
break;
}
String value = prop.getValue().trim();
if (value != null) {
configProps.put(keyName, value);
}
/*
int positiveint = 0;
try {
positiveint = Integer.getInteger(value);
} catch (Throwable t) {}
// todo
if (positiveint > 0) {
configProps.put(keyName, positiveint);
} // todo else log event that invalid value was provided.
*/
}
break;
// Must place here or they will get flagged as not handled.
case LOOPBACK:
case VIRTUAL_MULTICAST_URI_LIST:
break;
default:
if (GMS_LOGGER.isLoggable(LogLevel.FINE)) {
GMS_LOGGER.log(LogLevel.FINE, String.format("service provider key %s ignored", keyName));
}
break;
}
/* end switch over ServiceProviderConfigurationKeys enum */
} catch (Throwable t) {
GMS_LOGGER.log(LogLevel.WARNING, GMS_EXCEPTION_PROCESSING_CONFIG, t.getLocalizedMessage());
}
}
/* end for loop over ServiceProviderConfigurationKeys */
// check for Grizzly transport specific properties in GroupManagementService property list and then cluster property list.
// cluster property is more specific than group-mangement-service, so allow cluster property to override group-management-service proeprty
// if a GrizzlyConfigConstant property is in both list.
List<Property> props = null;
if (clusterConfig != null) {
props = clusterConfig.getGroupManagementService().getProperty();
for (Property prop : props) {
String name = prop.getName().trim();
String value = prop.getValue().trim();
if (name == null || value == null) {
continue;
}
if (GMS_LOGGER.isLoggable(LogLevel.CONFIG)) {
GMS_LOGGER.log(LogLevel.CONFIG, "processing group-management-service property name=" + name + " value= " + value);
}
if (value.startsWith("${")) {
if (GMS_LOGGER.isLoggable(LogLevel.CONFIG)) {
GMS_LOGGER.log(LogLevel.CONFIG, "skipping group-management-service property name=" + name + " since value is unresolved symbolic token=" + value);
}
} else {
if (GMS_LOGGER.isLoggable(LogLevel.CONFIG)) {
GMS_LOGGER.log(LogLevel.CONFIG, "processing group-management-service property name=" + name + " value= " + value);
}
if (name.startsWith(GMS_PROPERTY_PREFIX)) {
name = name.replaceFirst(GMS_PROPERTY_PREFIX_REGEXP, "");
}
configProps.put(name, value);
if (!validateGMSProperty(name)) {
GMS_LOGGER.log(LogLevel.WARNING, GMS_EXCEPTION_IGNORING_PROPERTY, new Object[] { name, value, "" });
}
}
}
}
if (cluster != null) {
props = cluster.getProperty();
for (Property prop : props) {
String name = prop.getName().trim();
String value = prop.getValue().trim();
if (name == null || value == null) {
continue;
}
if (GMS_LOGGER.isLoggable(LogLevel.CONFIG)) {
GMS_LOGGER.log(LogLevel.CONFIG, "processing cluster property name=" + name + " value= " + value);
}
if (value.startsWith("${")) {
if (GMS_LOGGER.isLoggable(LogLevel.CONFIG)) {
GMS_LOGGER.log(LogLevel.CONFIG, "skipping cluster property name=" + name + " since value is unresolved symbolic token=" + value);
}
} else {
if (name.startsWith(GMS_PROPERTY_PREFIX)) {
name = name.replaceFirst(GMS_PROPERTY_PREFIX_REGEXP, "");
}
// impossible to register handlers in a regular app before gms starts up.
if (name.compareTo("ALIVEANDREADY_LOGGING") == 0) {
aliveAndReadyLoggingEnabled = Boolean.parseBoolean(value);
} else if (name.compareTo("LISTENER_PORT") == 0) {
// special case mapping. Glassfish Cluster property GMS_LISTENER_PORT maps to Grizzly Config Constants TCPSTARTPORT and TCPENDPORT.
configProps.put(GrizzlyConfigConstants.TCPSTARTPORT.toString(), value);
configProps.put(GrizzlyConfigConstants.TCPENDPORT.toString(), value);
} else if (name.compareTo("TEST_FAILURE_RECOVERY") == 0) {
testFailureRecoveryHandler = Boolean.parseBoolean(value);
} else if (ServiceProviderConfigurationKeys.DISCOVERY_URI_LIST.name().equals(name) && "generate".equals(value)) {
value = generateDiscoveryUriList();
configProps.put(name, value);
} else {
// handle normal case. one to one mapping.
configProps.put(name, value);
GMS_LOGGER.log(LogLevel.CONFIG, "processing cluster property name=" + name + " value= " + value);
if (!validateGMSProperty(name)) {
GMS_LOGGER.log(LogLevel.WARNING, GMS_EXCEPTION_CLUSTER_PROPERTY_ERROR, new Object[] { name, value, "" });
}
}
}
}
}
}
Aggregations