public class AlertScriptDispatcher extends Object implements NotificationDispatcher
AlertScriptDispatcher
is used to dispatch
AlertNotification
s to a script via a Process
and command line
arguments. This dispatcher does not know how to work with any other types of
Notification
.
This dispatcher only deals with non-digest notifications.Modifier and Type | Field and Description |
---|---|
static String |
DISPATCH_PROPERTY_SCRIPT_CONFIG_KEY
A dispatch property that instructs this dispatcher to read a different key
from
Configuration . |
static String |
DISPATCH_PROPERTY_SCRIPT_FILENAME_KEY
A dispatch property that instructs this dispatcher to lookup script by filename
from
AlertTarget . |
protected Configuration |
m_configuration
Configuration data from the ambari.properties file.
|
static String |
SCRIPT_CONFIG_DEFAULT_KEY
The key in
ambari.properties which contains the script to execute. |
static String |
SCRIPT_CONFIG_TIMEOUT_KEY
The key in
ambari.properties which contains the timeout, in
milliseconds, of any script run by this dispatcher. |
static com.google.common.escape.Escaper |
SHELL_ESCAPE
Used to escape text being passed into the shell command.
|
Constructor and Description |
---|
AlertScriptDispatcher() |
Modifier and Type | Method and Description |
---|---|
void |
dispatch(Notification notification)
Dispatches the specified notification.
|
String |
getScriptConfigurationKey(Notification notification)
Gets the key that will be used to lookup the script to execute from
Configuration . |
long |
getScriptConfigurationTimeout()
Gets the timeout value for the script, in milliseconds, as set in
Configuration . |
String |
getType()
Gets the type of dispatcher.
|
boolean |
isDigestSupported()
Gets whether the dispatcher supports sending a digest or summary in a
single
Notification . |
boolean |
isNotificationContentGenerationRequired()
Gets whether Ambari should attempt to generate the content of the
Notification before giving it to the dispatcher. |
TargetConfigurationResult |
validateTargetConfig(Map<String,Object> properties)
Validates alert target configuration.
|
public static final String SCRIPT_CONFIG_DEFAULT_KEY
ambari.properties
which contains the script to execute.public static final String SCRIPT_CONFIG_TIMEOUT_KEY
ambari.properties
which contains the timeout, in
milliseconds, of any script run by this dispatcher.public static final String DISPATCH_PROPERTY_SCRIPT_CONFIG_KEY
Configuration
. If this value is not a part of the
Notification.DispatchProperties
then
SCRIPT_CONFIG_DEFAULT_KEY
will be used.public static final String DISPATCH_PROPERTY_SCRIPT_FILENAME_KEY
AlertTarget
.public static final com.google.common.escape.Escaper SHELL_ESCAPE
@Inject protected Configuration m_configuration
public String getScriptConfigurationKey(Notification notification)
Configuration
.Configuration
(never null
).public long getScriptConfigurationTimeout()
Configuration
. If there is no setting, then
DEFAULT_SCRIPT_TIMEOUT
will be returned.public final String getType()
getType
in interface NotificationDispatcher
null
).public final boolean isNotificationContentGenerationRequired()
Notification
before giving it to the dispatcher. Some dispatchers
may choose to format data in a way which is not easily represented in the
{alert-templates.xml}.
If false
then the Notification
will only contain the
recipients and a map of properties for the dispatcher to use.
Returns false
always.isNotificationContentGenerationRequired
in interface NotificationDispatcher
true
if Ambari should generate the Notification
content, false
otherwise.public void dispatch(Notification notification)
dispatch
in interface NotificationDispatcher
notification
- the notificationt to dispatch (not null
).public final boolean isDigestSupported()
Notification
. Some providers may not allow the
Notification
to contain information on more than a single event.
Returns false
always.isDigestSupported
in interface NotificationDispatcher
true
if digest is supported, false
otherwise.public final TargetConfigurationResult validateTargetConfig(Map<String,Object> properties)
validateTargetConfig
in interface NotificationDispatcher
properties
- alert target propertiesCopyright © 2022 Apache Software Foundation. All rights reserved.