Package org.apache.nifi.bootstrap
Class NotificationServiceManager
java.lang.Object
org.apache.nifi.bootstrap.NotificationServiceManager
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.Loggerprivate intprivate final ScheduledExecutorServiceprivate final Map<String, NotificationServiceManager.ConfiguredNotificationService> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate NotificationContextcreateService(Element serviceElement) Creates a Notification Service and initializes it.static ElementgetChildElementsByTagName(Element element, String tagName) voidloadNotificationServices(File servicesFile) Loads the Notification Services from the given XML configuration file.voidnotify(NotificationType type, String subject, String message) voidregisterNotificationService(NotificationType type, String serviceId) Registers the service that has the given identifier to respond to notifications of the given typevoidsetMaxNotificationAttempts(int maxAttempts)
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
servicesById
-
servicesByNotificationType
private final Map<NotificationType,List<NotificationServiceManager.ConfiguredNotificationService>> servicesByNotificationType -
notificationExecutor
-
maxAttempts
private int maxAttempts
-
-
Constructor Details
-
NotificationServiceManager
public NotificationServiceManager()
-
-
Method Details
-
setMaxNotificationAttempts
public void setMaxNotificationAttempts(int maxAttempts) -
loadNotificationServices
Loads the Notification Services from the given XML configuration file. File is expected to have the following format:<services> <service> <id>service-identifier</id> <class>org.apache.nifi.MyNotificationService</class> <property name="My First Property">Property Value</property> </service> <service> <id>other-service</id> <class>org.apache.nifi.MyOtherNotificationService</class> <property name="Another Property">Property Value 2</property> </service> ... <service> <id>service-identifier-2</id> <class>org.apache.nifi.FinalNotificationService</class> <property name="Yet Another Property">3rd Prop Value</property> </service> </services>Note that as long as the file can be interpreted properly, a misconfigured service will result in a warning or error being logged and the service will be unavailable but will not prevent the rest of the services from loading.- Parameters:
servicesFile- the XML file to load services from.- Throws:
IOException- if unable to read from the given file
-
notify
-
buildNotificationContext
private NotificationContext buildNotificationContext(NotificationServiceManager.ConfiguredNotificationService config) -
registerNotificationService
Registers the service that has the given identifier to respond to notifications of the given type- Parameters:
type- the type of notification to register the service forserviceId- the identifier of the service
-
createService
private NotificationServiceManager.ConfiguredNotificationService createService(Element serviceElement) Creates a Notification Service and initializes it. Then returns the service and its configured properties- Parameters:
serviceElement- the XML element from which to build the Notification Service- Returns:
- a Tuple with the NotificationService as the key and the configured properties as the value, or
nullif unable to create the service
-
getChild
-
getChildElementsByTagName
-