Search in sources :

Example 11 with UnprocessedChangeEvent

use of org.jvnet.hk2.config.UnprocessedChangeEvent in project Payara by payara.

the class EJBTimerServiceConfigListener method changed.

/**
 *************************************************************************
 */
/**
 * Implementation of org.jvnet.hk2.config.ConfigListener ********************
 */
/**
 *************************************************************************
 */
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) {
        if (event.getSource() instanceof EjbTimerService) {
            Object oldValue = event.getOldValue();
            Object newValue = event.getNewValue();
            if (_logger.isLoggable(Level.FINE)) {
                _logger.log(Level.FINE, "Got EjbTimerService change event ==== " + event.getSource() + " " + event.getPropertyName() + " " + oldValue + " " + newValue);
            }
            if (oldValue != null && oldValue.equals(newValue)) {
                if (_logger.isLoggable(Level.FINE)) {
                    _logger.log(Level.FINE, "Event " + event.getPropertyName() + " did not change existing value of " + oldValue);
                }
            } else {
                unprocessedEvents.add(new UnprocessedChangeEvent(event, "Restart required to reconfigure EJB Timer Service"));
            }
        }
    }
    return (unprocessedEvents.size() > 0) ? new UnprocessedChangeEvents(unprocessedEvents) : null;
}
Also used : UnprocessedChangeEvents(org.jvnet.hk2.config.UnprocessedChangeEvents) PropertyChangeEvent(java.beans.PropertyChangeEvent) UnprocessedChangeEvent(org.jvnet.hk2.config.UnprocessedChangeEvent) ArrayList(java.util.ArrayList) EjbTimerService(org.glassfish.ejb.config.EjbTimerService)

Example 12 with UnprocessedChangeEvent

use of org.jvnet.hk2.config.UnprocessedChangeEvent in project Payara by payara.

the class RestMonitoringService method changed.

@Override
public UnprocessedChangeEvents changed(PropertyChangeEvent[] propertyChangeEvents) {
    List<UnprocessedChangeEvent> unprocessedChanges = new ArrayList<>();
    boolean dynamicStart = false;
    for (PropertyChangeEvent propertyChangeEvent : propertyChangeEvents) {
        // Check that the property change event is for us.
        if (propertyChangeEvent.getSource().toString().equals("GlassFishConfigBean." + RestMonitoringConfiguration.class.getName()) && isCurrentInstanceMatchTarget(propertyChangeEvent)) {
            // Check if the property has actually changed
            if (!propertyChangeEvent.getOldValue().equals(propertyChangeEvent.getNewValue())) {
                // If the application hasn't attempted to start yet
                if (!startAttempted) {
                    // property, we don't need to compare it to the current value - it can only be true
                    if (propertyChangeEvent.getPropertyName().equals("enabled")) {
                        // Flag that we want to dynamically start Rest Monitoring
                        dynamicStart = true;
                    } else if (propertyChangeEvent.getPropertyName().equals("context-root")) {
                        // If we haven't attempted to start the app yet, grab the new context root
                        Config serverConfig = domain.getServerNamed(serverEnv.getInstanceName()).getConfig();
                        RestMonitoringEndpointDecider endpointDecider = new RestMonitoringEndpointDecider(serverConfig, restMonitoringConfiguration);
                        contextRoot = endpointDecider.getContextRoot();
                    }
                } else if (!propertyChangeEvent.getPropertyName().equals("security-enabled")) {
                    // If a startup has been attempted and the changed property isn't securityEnabled, throw an
                    // unprocessed change event as we need to restart
                    unprocessedChanges.add(new UnprocessedChangeEvent(propertyChangeEvent, "Rest monitoring redeployment required"));
                }
            }
        }
    }
    // This should only be true if rest monitoring was not enabled at startup, and we've just enabled the service
    if (dynamicStart) {
        loadApplication(true);
    }
    // If we need to restart, throw an unprocessed change event
    if (unprocessedChanges.isEmpty()) {
        return null;
    } else {
        return new UnprocessedChangeEvents(unprocessedChanges);
    }
}
Also used : UnprocessedChangeEvents(org.jvnet.hk2.config.UnprocessedChangeEvents) PropertyChangeEvent(java.beans.PropertyChangeEvent) UnprocessedChangeEvent(org.jvnet.hk2.config.UnprocessedChangeEvent) Config(com.sun.enterprise.config.serverbeans.Config) ArrayList(java.util.ArrayList) RestMonitoringConfiguration(fish.payara.appserver.monitoring.rest.service.configuration.RestMonitoringConfiguration) RestMonitoringEndpointDecider(fish.payara.appserver.monitoring.rest.service.adapter.RestMonitoringEndpointDecider)

Example 13 with UnprocessedChangeEvent

use of org.jvnet.hk2.config.UnprocessedChangeEvent in project Payara by payara.

the class PayaraExecutorService method changed.

@Override
public UnprocessedChangeEvents changed(PropertyChangeEvent[] propertyChangeEvents) {
    List<UnprocessedChangeEvent> unprocessedChanges = new ArrayList<>();
    boolean keepAliveChanged = false;
    for (PropertyChangeEvent propertyChangeEvent : propertyChangeEvents) {
        switch(propertyChangeEvent.getPropertyName()) {
            case "thread-pool-executor-core-pool-size":
                if (isCurrentInstanceMatchTarget(propertyChangeEvent) && !propertyChangeEvent.getOldValue().equals(propertyChangeEvent.getNewValue())) {
                    threadPoolExecutor.setCorePoolSize((Integer) propertyChangeEvent.getNewValue());
                }
                break;
            case "thread-pool-executor-max-pool-size":
                if (isCurrentInstanceMatchTarget(propertyChangeEvent) && !propertyChangeEvent.getOldValue().equals(propertyChangeEvent.getNewValue())) {
                    threadPoolExecutor.setMaximumPoolSize((Integer) propertyChangeEvent.getNewValue());
                }
                break;
            case "thread-pool-executor-keep-alive-time":
                if (isCurrentInstanceMatchTarget(propertyChangeEvent) && !propertyChangeEvent.getOldValue().equals(propertyChangeEvent.getNewValue())) {
                    if (!keepAliveChanged) {
                        for (PropertyChangeEvent pce : propertyChangeEvents) {
                            if (isCurrentInstanceMatchTarget(pce) && pce.getPropertyName().equals("thread-pool-executor-keep-alive-time-unit")) {
                                if (!pce.getOldValue().equals(pce.getNewValue())) {
                                    keepAliveChanged = true;
                                    threadPoolExecutor.setKeepAliveTime(Long.valueOf((String) propertyChangeEvent.getNewValue()), TimeUnit.valueOf((String) pce.getNewValue()));
                                } else {
                                    threadPoolExecutor.setKeepAliveTime((Integer) propertyChangeEvent.getNewValue(), TimeUnit.valueOf(payaraExecutorServiceConfiguration.getThreadPoolExecutorKeepAliveTimeUnit()));
                                }
                            }
                        }
                        if (!keepAliveChanged) {
                            threadPoolExecutor.setKeepAliveTime(Long.valueOf((String) propertyChangeEvent.getNewValue()), TimeUnit.valueOf(payaraExecutorServiceConfiguration.getThreadPoolExecutorKeepAliveTimeUnit()));
                        }
                    }
                }
                break;
            case "thread-pool-executor-keep-alive-time-unit":
                if (isCurrentInstanceMatchTarget(propertyChangeEvent) && !propertyChangeEvent.getOldValue().equals(propertyChangeEvent.getNewValue())) {
                    if (!keepAliveChanged) {
                        for (PropertyChangeEvent pce : propertyChangeEvents) {
                            if (isCurrentInstanceMatchTarget(pce) && pce.getPropertyName().equals("thread-pool-executor-keep-alive-time")) {
                                if (!pce.getOldValue().equals(pce.getNewValue())) {
                                    keepAliveChanged = true;
                                    threadPoolExecutor.setKeepAliveTime(Long.valueOf((String) pce.getNewValue()), TimeUnit.valueOf((String) propertyChangeEvent.getNewValue()));
                                } else {
                                    threadPoolExecutor.setKeepAliveTime(Long.valueOf((String) payaraExecutorServiceConfiguration.getThreadPoolExecutorKeepAliveTime()), TimeUnit.valueOf((String) propertyChangeEvent.getNewValue()));
                                }
                            }
                        }
                        if (!keepAliveChanged) {
                            threadPoolExecutor.setKeepAliveTime(Long.valueOf((String) payaraExecutorServiceConfiguration.getThreadPoolExecutorKeepAliveTime()), TimeUnit.valueOf((String) propertyChangeEvent.getNewValue()));
                        }
                    }
                }
                break;
            case "thread-pool-executor-queue-size":
                if (isCurrentInstanceMatchTarget(propertyChangeEvent) && !propertyChangeEvent.getOldValue().equals(propertyChangeEvent.getNewValue())) {
                    unprocessedChanges.add(new UnprocessedChangeEvent(propertyChangeEvent, "Payara Executor Service requires restarting"));
                }
                break;
            case "scheduled-thread-pool-executor-core-pool-size":
                if (isCurrentInstanceMatchTarget(propertyChangeEvent) && !propertyChangeEvent.getOldValue().equals(propertyChangeEvent.getNewValue())) {
                    scheduledThreadPoolExecutor.setCorePoolSize((Integer) propertyChangeEvent.getNewValue());
                }
                break;
        }
    }
    if (unprocessedChanges.isEmpty()) {
        return null;
    } else {
        return new UnprocessedChangeEvents(unprocessedChanges);
    }
}
Also used : UnprocessedChangeEvents(org.jvnet.hk2.config.UnprocessedChangeEvents) PropertyChangeEvent(java.beans.PropertyChangeEvent) UnprocessedChangeEvent(org.jvnet.hk2.config.UnprocessedChangeEvent) ArrayList(java.util.ArrayList)

Example 14 with UnprocessedChangeEvent

use of org.jvnet.hk2.config.UnprocessedChangeEvent in project Payara by payara.

the class UnprocessedEventsTest method changed.

public UnprocessedChangeEvents changed(PropertyChangeEvent[] propertyChangeEvents) {
    assertEquals("Array size", propertyChangeEvents.length, 1);
    final UnprocessedChangeEvent unp = new UnprocessedChangeEvent(propertyChangeEvents[0], "Java NIO port listener cannot reconfigure its port dynamically");
    unprocessed = new UnprocessedChangeEvents(unp);
    return unprocessed;
}
Also used : UnprocessedChangeEvents(org.jvnet.hk2.config.UnprocessedChangeEvents) UnprocessedChangeEvent(org.jvnet.hk2.config.UnprocessedChangeEvent)

Aggregations

UnprocessedChangeEvent (org.jvnet.hk2.config.UnprocessedChangeEvent)14 UnprocessedChangeEvents (org.jvnet.hk2.config.UnprocessedChangeEvents)14 PropertyChangeEvent (java.beans.PropertyChangeEvent)12 ArrayList (java.util.ArrayList)11 ActionReport (org.glassfish.api.ActionReport)4 NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)3 Config (com.sun.enterprise.config.serverbeans.Config)2 DasConfig (com.sun.enterprise.config.serverbeans.DasConfig)2 PropertyVetoException (java.beans.PropertyVetoException)2 File (java.io.File)2 Logger (java.util.logging.Logger)2 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)2 ModuleMonitoringLevels (com.sun.enterprise.config.serverbeans.ModuleMonitoringLevels)1 JmsHost (com.sun.enterprise.connectors.jms.config.JmsHost)1 JmsService (com.sun.enterprise.connectors.jms.config.JmsService)1 CurrentBeforeParentClassLoader (com.sun.enterprise.loader.CurrentBeforeParentClassLoader)1 DummyNetworkListener (com.sun.enterprise.v3.services.impl.DummyNetworkListener)1 GrizzlyService (com.sun.enterprise.v3.services.impl.GrizzlyService)1 RestMonitoringEndpointDecider (fish.payara.appserver.monitoring.rest.service.adapter.RestMonitoringEndpointDecider)1 RestMonitoringConfiguration (fish.payara.appserver.monitoring.rest.service.configuration.RestMonitoringConfiguration)1