use of fish.payara.nucleus.notification.configuration.NotifierConfigurationType in project Payara by payara.
the class HealthCheckService method bootstrapNotifierList.
/**
* Starts all notifiers that have been enable with the healthcheck service.
*/
public void bootstrapNotifierList() {
notifierExecutionOptionsList = new ArrayList<>();
if (configuration.getNotifierList() != null) {
for (Notifier notifier : configuration.getNotifierList()) {
ConfigView view = ConfigSupport.getImpl(notifier);
NotifierConfigurationType annotation = view.getProxyType().getAnnotation(NotifierConfigurationType.class);
notifierExecutionOptionsList.add(executionOptionsFactoryStore.get(annotation.type()).build(notifier));
}
}
if (notifierExecutionOptionsList.isEmpty()) {
// Add logging execution options by default
LogNotifierExecutionOptions logNotifierExecutionOptions = new LogNotifierExecutionOptions();
logNotifierExecutionOptions.setEnabled(true);
notifierExecutionOptionsList.add(logNotifierExecutionOptions);
}
}
use of fish.payara.nucleus.notification.configuration.NotifierConfigurationType in project Payara by payara.
the class MonitoringService method bootstrapNotifierList.
/**
* Starts notifiers that are enabled with the monitoring service
* @since 4.1.2.174
*/
public void bootstrapNotifierList() {
notifierExecutionOptionsList = new ArrayList<>();
if (configuration.getNotifierList() != null) {
for (Notifier notifier : configuration.getNotifierList()) {
ConfigView view = ConfigSupport.getImpl(notifier);
NotifierConfigurationType annotation = view.getProxyType().getAnnotation(NotifierConfigurationType.class);
notifierExecutionOptionsList.add(executionOptionsFactoryStore.get(annotation.type()).build(notifier));
}
}
if (notifierExecutionOptionsList.isEmpty()) {
// Add logging execution options by default
LogNotifierExecutionOptions logNotifierExecutionOptions = new LogNotifierExecutionOptions();
logNotifierExecutionOptions.setEnabled(true);
notifierExecutionOptionsList.add(logNotifierExecutionOptions);
}
}
use of fish.payara.nucleus.notification.configuration.NotifierConfigurationType in project Payara by payara.
the class GetMonitoringConfiguration method execute.
/**
* Method that is invoked when the asadmin command is performed.
* Pretty prints the Monitoring Service Configuration values.
* @param context
*/
@Override
public void execute(AdminCommandContext context) {
Config config = targetUtil.getConfig(target);
if (config == null) {
context.getActionReport().setMessage("No such config name: " + targetUtil);
context.getActionReport().setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
ActionReport actionReport = context.getActionReport();
ActionReport notifiersReport = actionReport.addSubActionsReport();
ActionReport attributeReport = actionReport.addSubActionsReport();
ColumnFormatter attributeColumnFormatter = new ColumnFormatter(ATTRIBUTE_HEADERS);
ColumnFormatter notifiersColumnFormatter = new ColumnFormatter(NOTIFIER_HEADERS);
MonitoringServiceConfiguration monitoringConfig = config.getExtensionByType(MonitoringServiceConfiguration.class);
List<ServiceHandle<BaseNotifierService>> allNotifierServiceHandles = habitat.getAllServiceHandles(BaseNotifierService.class);
actionReport.appendMessage("Monitoring Service Configuration is enabled? " + prettyBool(Boolean.valueOf(monitoringConfig.getEnabled())) + "\n");
actionReport.appendMessage("Monitoring Service Configuration has AMX enabled? " + prettyBool(Boolean.valueOf(monitoringConfig.getAmx())) + "\n");
actionReport.appendMessage("Monitoring Service Configuration log frequency? " + monitoringConfig.getLogFrequency() + " " + monitoringConfig.getLogFrequencyUnit());
actionReport.appendMessage(StringUtils.EOL);
Map<String, Object> map = new HashMap<>();
Properties extraProps = new Properties();
map.put("enabled", monitoringConfig.getEnabled());
map.put("amx", monitoringConfig.getAmx());
map.put("logfrequency", monitoringConfig.getLogFrequency());
map.put("logfrequencyunit", monitoringConfig.getLogFrequencyUnit());
extraProps.put("jmxmonitoringConfiguration", map);
List<Map<String, String>> monitoredAttributes = new ArrayList<>();
for (MonitoredAttribute monitoredBean : monitoringConfig.getMonitoredAttributes()) {
Object[] values = new Object[3];
values[0] = monitoredBean.getObjectName();
values[1] = monitoredBean.getAttributeName();
values[2] = monitoredBean.getDescription();
Map<String, String> monitoredAttribute = new HashMap<>();
monitoredAttribute.put(monitoredBean.getObjectName(), monitoredBean.getAttributeName());
monitoredAttributes.add(monitoredAttribute);
attributeColumnFormatter.addRow(values);
}
// Cannot change key in line below - required for admingui propertyDescTable.inc
extraProps.put("monitored-beans", monitoredAttributes);
actionReport.setExtraProperties(extraProps);
if (!monitoringConfig.getNotifierList().isEmpty()) {
List<Class<Notifier>> notifierClassList = Lists.transform(monitoringConfig.getNotifierList(), new Function<Notifier, Class<Notifier>>() {
@Override
public Class<Notifier> apply(Notifier input) {
return resolveNotifierClass(input);
}
});
Properties notifierProps = new Properties();
for (ServiceHandle<BaseNotifierService> serviceHandle : allNotifierServiceHandles) {
Notifier notifier = monitoringConfig.getNotifierByType(serviceHandle.getService().getNotifierType());
if (notifier != null) {
ConfigView view = ConfigSupport.getImpl(notifier);
NotifierConfigurationType annotation = view.getProxyType().getAnnotation(NotifierConfigurationType.class);
if (notifierClassList.contains(view.<Notifier>getProxyType())) {
Object[] values = new Object[2];
values[0] = annotation.type();
values[1] = notifier.getEnabled();
notifiersColumnFormatter.addRow(values);
Map<String, Object> mapNotifiers = new HashMap<>(2);
mapNotifiers.put("notifierName", values[0]);
mapNotifiers.put("notifierEnabled", values[1]);
notifierProps.put("notifierList" + annotation.type(), mapNotifiers);
}
}
actionReport.getExtraProperties().putAll(notifierProps);
}
}
notifiersReport.setMessage(notifiersColumnFormatter.toString());
notifiersReport.appendMessage(StringUtils.EOL);
attributeReport.setMessage(attributeColumnFormatter.toString());
attributeReport.appendMessage(StringUtils.EOL);
actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of fish.payara.nucleus.notification.configuration.NotifierConfigurationType in project Payara by payara.
the class RequestTracingService method bootstrapNotifierList.
/**
* Configures notifiers with request tracing and starts any enabled ones.
* If no options are set then the log notifier is automatically turned on.
* @since 4.1.2.173
*/
public void bootstrapNotifierList() {
executionOptions.resetNotifierExecutionOptions();
if (configuration.getNotifierList() != null) {
for (Notifier notifier : configuration.getNotifierList()) {
ConfigView view = ConfigSupport.getImpl(notifier);
NotifierConfigurationType annotation = view.getProxyType().getAnnotation(NotifierConfigurationType.class);
executionOptions.addNotifierExecutionOption(executionOptionsFactoryStore.get(annotation.type()).build(notifier));
}
}
if (executionOptions.getNotifierExecutionOptionsList().isEmpty()) {
// Add logging execution options by default
LogNotifierExecutionOptions logNotifierExecutionOptions = new LogNotifierExecutionOptions();
logNotifierExecutionOptions.setEnabled(true);
executionOptions.addNotifierExecutionOption(logNotifierExecutionOptions);
}
}
use of fish.payara.nucleus.notification.configuration.NotifierConfigurationType in project Payara by payara.
the class NotificationService method bootstrapNotificationService.
public void bootstrapNotificationService() {
if (configuration != null) {
executionOptions = new NotificationExecutionOptions();
executionOptions.setEnabled(Boolean.parseBoolean(configuration.getEnabled()));
for (NotifierConfiguration notifierConfiguration : configuration.getNotifierConfigurationList()) {
NotifierType type = null;
try {
ConfigView view = ConfigSupport.getImpl(notifierConfiguration);
NotifierConfigurationType annotation = view.getProxyType().getAnnotation(NotifierConfigurationType.class);
type = annotation.type();
executionOptions.addNotifierConfigurationExecutionOption(factoryStore.get(type).build(notifierConfiguration));
} catch (UnsupportedEncodingException e) {
logger.log(Level.SEVERE, "Notifier configuration with type " + type + " cannot be configured due to encoding problems in configuration parameters", e);
}
}
if (executionOptions.isEnabled()) {
logger.info("Payara Notification Service bootstrapped with configuration: " + executionOptions);
}
}
}
Aggregations