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;
}
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);
}
}
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);
}
}
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;
}
Aggregations