public class AlertDefinitionFactory extends Object
AlertDefinitionFactory
class is used to construct
AlertDefinition
instances from a variety of sources.Constructor and Description |
---|
AlertDefinitionFactory()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
AlertDefinition |
coerce(AlertDefinitionEntity entity)
Gets an
AlertDefinition constructed from the specified
AlertDefinitionEntity . |
AlertDefinitionEntity |
coerce(long clusterId,
AlertDefinition definition)
Gets an
AlertDefinitionEntity constructed from the specified
AlertDefinition . |
Set<AlertDefinition> |
getAlertDefinitions(File alertDefinitionFile,
String serviceName)
Gets a list of all of the alert definitions defined in the specified JSON
File for the given service. |
Set<AlertDefinition> |
getAlertDefinitions(Reader reader,
String serviceName)
Gets a list of all of the alert definitions defined in the resource pointed
to by the specified reader for the given service.
|
com.google.gson.Gson |
getGson()
Gets an instance of
Gson that can correctly serialize and
deserialize an AlertDefinition . |
AlertDefinitionEntity |
merge(AlertDefinition definition,
AlertDefinitionEntity entity)
Merges the specified
AlertDefinition into the
AlertDefinitionEntity , leaving any fields not merged intact. |
AlertDefinitionEntity |
mergeSource(Source source,
AlertDefinitionEntity entity)
Updates source and source type of
entity from source . |
public Set<AlertDefinition> getAlertDefinitions(File alertDefinitionFile, String serviceName) throws org.apache.ambari.server.AmbariException
File
for the given service. Each of the JSON files should have a
mapping between the service and the alerts defined for that service. This
is necessary since some services are combined in a single
metainfo.xml
and only have a single directory on the stack.alertDefinitionFile
- the JSON file from the stack to read (not null
).serviceName
- the name of the service to extract definitions for (not
null
).org.apache.ambari.server.AmbariException
- if there was a problem reading the file or parsing the JSON.public Set<AlertDefinition> getAlertDefinitions(Reader reader, String serviceName) throws org.apache.ambari.server.AmbariException
metainfo.xml
and only have a single directory on the stack.
The supplied reader is closed when this method completes.reader
- the reader to read from (not null
). This will be closed
after reading is done.serviceName
- the name of the service to extract definitions for (not
null
).org.apache.ambari.server.AmbariException
- if there was a problem reading or parsing the JSON.public AlertDefinition coerce(AlertDefinitionEntity entity)
AlertDefinition
constructed from the specified
AlertDefinitionEntity
.entity
- the entity to use to construct the AlertDefinition
(not
null
).null
if it could not be coerced.public AlertDefinitionEntity coerce(long clusterId, AlertDefinition definition)
AlertDefinitionEntity
constructed from the specified
AlertDefinition
.
The new entity will have a UUID already set.clusterId
- the ID of the cluster.definition
- the definition to use to construct the
AlertDefinitionEntity
(not null
).null
if it could not be coerced.public AlertDefinitionEntity merge(AlertDefinition definition, AlertDefinitionEntity entity)
AlertDefinition
into the
AlertDefinitionEntity
, leaving any fields not merged intact.
The merged entity will have a new UUID.definition
- the definition to merge into the entity (not null
).entity
- the entity to merge into (not null
).null
if the
merge could not be done.public AlertDefinitionEntity mergeSource(Source source, AlertDefinitionEntity entity)
entity
from source
.
Also updates UUID, which must be done for any change in to the entity for it
to take effect on the agents.public com.google.gson.Gson getGson()
Gson
that can correctly serialize and
deserialize an AlertDefinition
.Gson
instance (not null
).Copyright © 2022 Apache Software Foundation. All rights reserved.