use of com.sun.enterprise.config.serverbeans.ModuleMonitoringLevels in project Payara by payara.
the class JavaEETransactionManagerSimplified method initProperties.
private void initProperties() {
// FIXME: this maxEntry should be a config
int maxEntries = 8192;
// FIXME: this loadFactor should be a config
float loadFactor = 0.75f;
// for now, let's get it from system prop
try {
String mEnlistDelists = System.getProperty("ALLOW_MULTIPLE_ENLISTS_DELISTS");
if ("true".equals(mEnlistDelists)) {
multipleEnlistDelists = true;
if (_logger.isLoggable(Level.FINE))
_logger.log(Level.FINE, "TM: multiple enlists, delists are enabled");
}
String maxEntriesValue = System.getProperty("JTA_RESOURCE_TABLE_MAX_ENTRIES");
if (maxEntriesValue != null) {
int temp = Integer.parseInt(maxEntriesValue);
if (temp > 0) {
maxEntries = temp;
}
}
String loadFactorValue = System.getProperty("JTA_RESOURCE_TABLE_DEFAULT_LOAD_FACTOR");
if (loadFactorValue != null) {
float f = Float.parseFloat(loadFactorValue);
if (f > 0) {
loadFactor = f;
}
}
} catch (Exception ex) {
// ignore
}
resourceTable = new BaseCache();
((BaseCache) resourceTable).init(maxEntries, loadFactor, null);
if (habitat != null) {
TransactionService txnService = habitat.getService(TransactionService.class, ServerEnvironment.DEFAULT_INSTANCE_NAME);
// running on the server side ?
if (txnService != null) {
transactionTimeout = Integer.parseInt(txnService.getTimeoutInSeconds());
// the delegates will do the rest if they support it
String v = txnService.getPropertyValue("purge-cancelled-transactions-after");
if (v != null && v.length() > 0) {
purgeCancelledTtransactions = Integer.parseInt(v);
}
TransactionServiceConfigListener listener = habitat.getService(TransactionServiceConfigListener.class);
listener.setTM(this);
}
ModuleMonitoringLevels levels = habitat.getService(ModuleMonitoringLevels.class);
// running on the server side ?
if (levels != null) {
String level = levels.getTransactionService();
if (!("OFF".equals(level))) {
monitoringEnabled = true;
}
}
}
// ENF OF BUG 4665539
if (_logger.isLoggable(Level.FINE))
_logger.log(Level.FINE, "TM: Tx Timeout = " + transactionTimeout);
// START IASRI 4705808 TTT004 -- monitor resource table stats
try {
// XXX TODO:
if (Boolean.getBoolean("MONITOR_JTA_RESOURCE_TABLE_STATISTICS")) {
registerStatisticMonitorTask();
}
StatsProviderManager.register(// element in domain.xml <monitoring-service>/<monitoring-level>
"transaction-service", // server.transaction-service node in asadmin get
PluginPoint.SERVER, // server.transaction-service node in asadmin get
"transaction-service", new TransactionServiceStatsProvider(this, _logger));
} catch (Exception ex) {
// ignore
}
monitor = new TransactionServiceProbeProvider();
}
use of com.sun.enterprise.config.serverbeans.ModuleMonitoringLevels in project Payara by payara.
the class TransactionServiceConfigListener method postConstruct.
@Override
public void postConstruct() {
// Listen to monitoring level changes
Config c = habitat.getService(Config.class, ServerEnvironment.DEFAULT_INSTANCE_NAME);
ts = c.getExtensionByType(TransactionService.class);
ModuleMonitoringLevels mml = c.getMonitoringService().getModuleMonitoringLevels();
((ObservableBean) ConfigSupport.getImpl(mml)).addListener(this);
}
use of com.sun.enterprise.config.serverbeans.ModuleMonitoringLevels in project Payara by payara.
the class TransactionServiceConfigListener method changed.
/**
*************************************************************************
*/
/**
* Implementation of org.jvnet.hk2.config.ConfigListener ********************
*/
/**
*************************************************************************
*/
@Override
public UnprocessedChangeEvents changed(PropertyChangeEvent[] events) {
// Events that we can't process now because they require server restart.
List<UnprocessedChangeEvent> unprocessedEvents = new ArrayList<UnprocessedChangeEvent>();
for (PropertyChangeEvent event : events) {
String eventName = event.getPropertyName();
Object oldValue = event.getOldValue();
Object newValue = event.getNewValue();
boolean accepted = true;
_logger.log(Level.FINE, "Got TransactionService change event ==== {0} {1} {2} {3}", new Object[] { event.getSource(), eventName, oldValue, newValue });
if (oldValue != null && oldValue.equals(newValue)) {
_logger.log(Level.FINE, "Event {0} did not change existing value of {1}", new Object[] { eventName, oldValue });
continue;
}
if (event.getSource() instanceof ModuleMonitoringLevels) {
if (eventName.equals(ServerTags.TRANSACTION_SERVICE)) {
String newlevel = newValue.toString();
_logger.log(Level.FINE, "Changing transaction monitoring level");
if ("OFF".equals(newlevel)) {
tm.setMonitoringEnabled(false);
} else if ("LOW".equals(newlevel) || "HIGH".equals(newlevel)) {
tm.setMonitoringEnabled(true);
}
}
// else skip
} else if (eventName.equals(ServerTags.TIMEOUT_IN_SECONDS)) {
try {
tm.setDefaultTransactionTimeout(Integer.parseInt((String) newValue, 10));
_logger.log(Level.FINE, " Transaction Timeout interval event processed for: {0}", newValue);
} catch (Exception ex) {
_logger.log(Level.WARNING, "transaction.reconfig_txn_timeout_failed", ex);
}
// timeout-in-seconds
} else if (eventName.equals(ServerTags.KEYPOINT_INTERVAL) || eventName.equals(ServerTags.RETRY_TIMEOUT_IN_SECONDS)) {
tm.handlePropertyUpdate(eventName, newValue);
_logger.log(Level.FINE, "{0} reconfig event processed for new value: {1}", new Object[] { eventName, newValue });
} else if (event.getPropertyName().equals("value")) {
eventName = ((Property) event.getSource()).getName();
_logger.log(Level.FINE, "Got Property change event for {0}", eventName);
if (eventName.equals("purge-cancelled-transactions-after")) {
String v = (String) newValue;
if (v == null || v.length() == 0) {
tm.setPurgeCancelledTtransactionsAfter(0);
} else {
tm.setPurgeCancelledTtransactionsAfter(Integer.parseInt(v, 10));
}
} else {
// Not handled dynamically. Restart is required.
accepted = false;
}
} else if (event.getPropertyName().equals("name") || event.getPropertyName().equals("property")) {
// skip - means a new property added, was processed above as "value".
_logger.log(Level.FINE, "...skipped");
} else {
// Not handled dynamically. Restart is required.
accepted = false;
}
if (!accepted) {
String msg = sm.getString("enterprise_distributedtx.restart_required", eventName);
_logger.log(Level.INFO, msg);
unprocessedEvents.add(new UnprocessedChangeEvent(event, msg));
}
}
return (unprocessedEvents.size() > 0) ? new UnprocessedChangeEvents(unprocessedEvents) : null;
}
use of com.sun.enterprise.config.serverbeans.ModuleMonitoringLevels in project Payara by payara.
the class GrizzlyConfig method initMonitoringLevel.
private void initMonitoringLevel() {
try {
Config cfg = services.getService(Config.class, ServerEnvironment.DEFAULT_INSTANCE_NAME);
// default per DTD
MonitoringLevel monitoringLevel = MonitoringLevel.OFF;
if (cfg.getMonitoringService() != null) {
ModuleMonitoringLevels levels = cfg.getMonitoringService().getModuleMonitoringLevels();
if (levels != null) {
monitoringLevel = MonitoringLevel.instance(levels.getHttpService());
}
}
if (MonitoringLevel.OFF.equals(monitoringLevel)) {
isMonitoringEnabled = false;
} else {
isMonitoringEnabled = true;
}
String methodToInvoke = isMonitoringEnabled ? "enableMonitoring" : "disableMonitoring";
invokeGrizzly(methodToInvoke);
} catch (Exception ex) {
String msg = rb.getString(LogFacade.INIT_MONITORING_EXCEPTION);
msg = MessageFormat.format(msg, Integer.valueOf(port));
logger.log(Level.WARNING, msg, ex);
}
}
Aggregations