public class AlertDispatchDAO extends Object
AlertDispatchDAO
class manages the AlertTargetEntity
,
AlertGroupEntity
, and the associations between them.Constructor and Description |
---|
AlertDispatchDAO() |
Modifier and Type | Method and Description |
---|---|
void |
create(AlertGroupEntity group)
Persists a new alert group.
|
void |
create(AlertGroupEntity group,
boolean fireEvent)
Persists a new alert group.
|
void |
create(AlertNoticeEntity alertNotice)
Persists a new notification.
|
void |
create(AlertTargetEntity alertTarget)
Persists a new alert target.
|
AlertGroupEntity |
createDefaultGroup(long clusterId,
String serviceName)
Creates a default group in the specified cluster and service.
|
void |
createGroups(List<AlertGroupEntity> entities)
Persists new alert groups.
|
List<AlertNoticeEntity> |
createNotices(List<AlertNoticeEntity> entities)
Creates new alert notices using the
EntityManager.merge(Object)
method to ensure that the associated AlertTargetEntity instances
are also updated. |
void |
createTargets(List<AlertTargetEntity> entities)
Persists new alert targets.
|
List<AlertTargetEntity> |
findAllGlobalTargets()
Gets all global alert targets stored in the database.
|
List<AlertGroupEntity> |
findAllGroups()
Gets all alert groups stored in the database across all clusters.
|
List<AlertGroupEntity> |
findAllGroups(long clusterId)
Gets all alert groups stored in the database for the specified cluster.
|
List<AlertNoticeEntity> |
findAllNotices()
Gets all alert notifications stored in the database.
|
List<AlertNoticeEntity> |
findAllNotices(AlertNoticeRequest request)
Gets all alert notifications stored in the database that match the given
predicate, pagination, and sorting.
|
List<AlertTargetEntity> |
findAllTargets()
Gets all alert targets stored in the database.
|
AlertGroupEntity |
findDefaultServiceGroup(long clusterId,
String serviceName)
Gets the default group for the specified cluster and service.
|
AlertGroupEntity |
findGroupById(long groupId)
Gets an alert group with the specified ID.
|
AlertGroupEntity |
findGroupByName(long clusterId,
String groupName)
Gets an alert group with the specified name for the given cluster.
|
List<AlertGroupEntity> |
findGroupsByDefinition(AlertDefinitionEntity definitionEntity)
Gets all of the
AlertGroupEntity instances that include the
specified alert definition. |
List<AlertGroupEntity> |
findGroupsById(List<Long> groupIds)
Gets all of the alert groups for the list of IDs given.
|
AlertNoticeEntity |
findNoticeById(long noticeId)
Gets a notification with the specified ID.
|
AlertNoticeEntity |
findNoticeByUuid(String uuid)
Gets a notification with the specified UUID.
|
List<AlertNoticeEntity> |
findPendingNotices()
Gets all
AlertNoticeEntity instances that are
NotificationState.PENDING and not yet dispatched. |
AlertTargetEntity |
findTargetById(long targetId)
Gets an alert target with the specified ID.
|
AlertTargetEntity |
findTargetByName(String targetName)
Gets an alert target with the specified name.
|
List<AlertTargetEntity> |
findTargetsById(List<Long> targetIds)
Gets all of the alert targets for the list of IDs given.
|
int |
getNoticesCount(Predicate predicate)
Gets the total count of all
AlertNoticeEntity rows that match the
specified Predicate . |
AlertGroupEntity |
merge(AlertGroupEntity alertGroup)
Merge the speicified alert group with the existing group in the database.
|
AlertNoticeEntity |
merge(AlertNoticeEntity alertNotice)
Merge the specified notification with the existing target in the database.
|
AlertTargetEntity |
merge(AlertTargetEntity alertTarget)
Merge the speicified alert target with the existing target in the database.
|
void |
refresh(AlertGroupEntity alertGroup)
Refresh the state of the alert group from the database.
|
void |
refresh(AlertNoticeEntity alertNotice)
Refresh the state of the notification from the database.
|
void |
refresh(AlertTargetEntity alertTarget)
Refresh the state of the alert target from the database.
|
void |
remove(AlertGroupEntity alertGroup)
Removes the specified alert group from the database.
|
void |
remove(AlertGroupEntity alertGroup,
boolean fireEvent)
Removes the specified alert group from the database.
|
void |
remove(AlertNoticeEntity alertNotice)
Removes the specified notification from the database.
|
void |
remove(AlertTargetEntity alertTarget)
Removes the specified alert target from the database.
|
void |
removeAllGroups(long clusterId)
Removes all
AlertDefinitionEntity that are associated with the
specified cluster ID. |
void |
removeNoticeByDefinitionId(long definitionId)
Removes notifications for the specified alert definition ID.
|
public AlertGroupEntity findGroupById(long groupId)
groupId
- the ID of the group to retrieve.null
if none exists.public List<AlertGroupEntity> findGroupsById(List<Long> groupIds)
groupIds
- the IDs of the groups to retrieve.null
).public AlertTargetEntity findTargetById(long targetId)
targetId
- the ID of the target to retrieve.null
if none exists.public List<AlertTargetEntity> findTargetsById(List<Long> targetIds)
targetIds
- the IDs of the targets to retrieve.null
).public AlertNoticeEntity findNoticeById(long noticeId)
noticeId
- the ID of the notification to retrieve.null
if none exists.public AlertNoticeEntity findNoticeByUuid(String uuid)
uuid
- the UUID of the notification to retrieve.null
if none exists.public List<AlertNoticeEntity> findPendingNotices()
AlertNoticeEntity
instances that are
NotificationState.PENDING
and not yet dispatched.null
).public AlertGroupEntity findGroupByName(long clusterId, String groupName)
clusterId
- the ID of the cluster.groupName
- the name of the group (not null
).null
if none exists.public AlertTargetEntity findTargetByName(String targetName)
targetName
- the name of the target (not null
).null
if none exists.public List<AlertGroupEntity> findAllGroups()
null
).public List<AlertGroupEntity> findAllGroups(long clusterId)
null
).public List<AlertTargetEntity> findAllTargets()
null
).public List<AlertTargetEntity> findAllGlobalTargets()
null
).public List<AlertGroupEntity> findGroupsByDefinition(AlertDefinitionEntity definitionEntity)
AlertGroupEntity
instances that include the
specified alert definition. Service default groups will also be returned.definitionEntity
- the definition that the group must include (not null
).null
).public AlertGroupEntity findDefaultServiceGroup(long clusterId, String serviceName)
clusterId
- the cluster that the group belongs toserviceName
- the name of the service (not null
).null
if the service name is not valid
for an installed service; otherwise null
should not be
possible.public List<AlertNoticeEntity> findAllNotices()
null
).public List<AlertNoticeEntity> findAllNotices(AlertNoticeRequest request)
request
- null
).public int getNoticesCount(Predicate predicate)
AlertNoticeEntity
rows that match the
specified Predicate
.predicate
- the predicate to apply, or null
for none.public void createGroups(List<AlertGroupEntity> entities)
entities
- the groups to persist (not null
).public void create(AlertGroupEntity group)
group
- the group to persist (not null
).public void create(AlertGroupEntity group, boolean fireEvent)
group
- the group to persist (not null
).fireEvent
- should alert group update event to be firedpublic AlertGroupEntity createDefaultGroup(long clusterId, String serviceName) throws org.apache.ambari.server.AmbariException
AmbariException
.clusterId
- the cluster that the group is in.serviceName
- the name of the group which is also the service name.org.apache.ambari.server.AmbariException
public void refresh(AlertGroupEntity alertGroup)
alertGroup
- the group to refresh (not null
).public AlertGroupEntity merge(AlertGroupEntity alertGroup)
alertGroup
- the group to merge (not null
).null
).public void remove(AlertGroupEntity alertGroup)
alertGroup
- the group to remove.public void remove(AlertGroupEntity alertGroup, boolean fireEvent)
alertGroup
- the group to remove.fireEvent
- should alert group update event to be fired.public void removeAllGroups(long clusterId)
AlertDefinitionEntity
that are associated with the
specified cluster ID.clusterId
- the cluster ID.public void createTargets(List<AlertTargetEntity> entities)
entities
- the targets to persist (not null
).public List<AlertNoticeEntity> createNotices(List<AlertNoticeEntity> entities)
EntityManager.merge(Object)
method to ensure that the associated AlertTargetEntity
instances
are also updated.
The method returns the newly managed entities as the ones passed in will
not be managed.entities
- the targets to create (not null
).public void create(AlertTargetEntity alertTarget)
alertTarget
- the target to persist (not null
).public void refresh(AlertTargetEntity alertTarget)
alertTarget
- the target to refresh (not null
).public AlertTargetEntity merge(AlertTargetEntity alertTarget)
alertTarget
- the target to merge (not null
).null
).public void remove(AlertTargetEntity alertTarget)
alertTarget
- the target to remove.public void create(AlertNoticeEntity alertNotice)
alertNotice
- the notification to persist (not null
).public void refresh(AlertNoticeEntity alertNotice)
alertNotice
- the notification to refresh (not null
).public AlertNoticeEntity merge(AlertNoticeEntity alertNotice)
alertNotice
- the notification to merge (not null
).null
).public void remove(AlertNoticeEntity alertNotice)
alertNotice
- the notification to remove.public void removeNoticeByDefinitionId(long definitionId)
EntityManager.clear()
when completed since the JPQL
statement will remove entries without going through the EM.definitionId
- the ID of the definition to remove.Copyright © 2022 Apache Software Foundation. All rights reserved.