Search in sources :

Example 1 with ModuleMonitoringLevels

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();
}
Also used : TransactionService(com.sun.enterprise.transaction.config.TransactionService) ModuleMonitoringLevels(com.sun.enterprise.config.serverbeans.ModuleMonitoringLevels) BaseCache(com.sun.appserv.util.cache.BaseCache) PluginPoint(org.glassfish.external.probe.provider.PluginPoint) InvocationException(org.glassfish.api.invocation.InvocationException) WorkException(javax.resource.spi.work.WorkException) RemoteException(java.rmi.RemoteException) XAException(javax.transaction.xa.XAException) TransactionServiceStatsProvider(com.sun.enterprise.transaction.monitoring.TransactionServiceStatsProvider) TransactionServiceProbeProvider(com.sun.enterprise.transaction.monitoring.TransactionServiceProbeProvider)

Example 2 with ModuleMonitoringLevels

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);
}
Also used : TransactionService(com.sun.enterprise.transaction.config.TransactionService) ModuleMonitoringLevels(com.sun.enterprise.config.serverbeans.ModuleMonitoringLevels) Config(com.sun.enterprise.config.serverbeans.Config) ObservableBean(org.jvnet.hk2.config.ObservableBean)

Example 3 with ModuleMonitoringLevels

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;
}
Also used : UnprocessedChangeEvents(org.jvnet.hk2.config.UnprocessedChangeEvents) PropertyChangeEvent(java.beans.PropertyChangeEvent) ModuleMonitoringLevels(com.sun.enterprise.config.serverbeans.ModuleMonitoringLevels) UnprocessedChangeEvent(org.jvnet.hk2.config.UnprocessedChangeEvent) Property(org.jvnet.hk2.config.types.Property)

Example 4 with ModuleMonitoringLevels

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);
    }
}
Also used : ModuleMonitoringLevels(com.sun.enterprise.config.serverbeans.ModuleMonitoringLevels) Config(com.sun.enterprise.config.serverbeans.Config) String(java.lang.String) MonitoringLevel(com.sun.enterprise.admin.monitor.registry.MonitoringLevel)

Aggregations

ModuleMonitoringLevels (com.sun.enterprise.config.serverbeans.ModuleMonitoringLevels)4 Config (com.sun.enterprise.config.serverbeans.Config)2 TransactionService (com.sun.enterprise.transaction.config.TransactionService)2 BaseCache (com.sun.appserv.util.cache.BaseCache)1 MonitoringLevel (com.sun.enterprise.admin.monitor.registry.MonitoringLevel)1 TransactionServiceProbeProvider (com.sun.enterprise.transaction.monitoring.TransactionServiceProbeProvider)1 TransactionServiceStatsProvider (com.sun.enterprise.transaction.monitoring.TransactionServiceStatsProvider)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 String (java.lang.String)1 RemoteException (java.rmi.RemoteException)1 WorkException (javax.resource.spi.work.WorkException)1 XAException (javax.transaction.xa.XAException)1 InvocationException (org.glassfish.api.invocation.InvocationException)1 PluginPoint (org.glassfish.external.probe.provider.PluginPoint)1 ObservableBean (org.jvnet.hk2.config.ObservableBean)1 UnprocessedChangeEvent (org.jvnet.hk2.config.UnprocessedChangeEvent)1 UnprocessedChangeEvents (org.jvnet.hk2.config.UnprocessedChangeEvents)1 Property (org.jvnet.hk2.config.types.Property)1