public class AlertDefinitionHash extends Object
AlertDefinitionHash
class is used to generate an MD5 hash for a
list of AlertDefinitionEntity
s. It is used in order to represent the
state of a group of definitions by using
AlertDefinitionEntity.getHash()
Modifier and Type | Field and Description |
---|---|
static String |
NULL_MD5_HASH
The hash returned when there are no definitions to hash.
|
Constructor and Description |
---|
AlertDefinitionHash() |
Modifier and Type | Method and Description |
---|---|
void |
enqueueAgentCommands(long clusterId)
Enqueue
AlertDefinitionCommand s for every host in the cluster so
that they will receive a payload of alert definitions that they should be
running. |
void |
enqueueAgentCommands(long clusterId,
Collection<String> hosts)
Enqueue
AlertDefinitionCommand s for every host specified so that
they will receive a payload of alert definitions that they should be
running. |
Map<Long,AlertDefinition> |
findByServiceComponent(long clusterId,
String serviceName,
String componentName) |
Map<Long,AlertDefinition> |
findByServiceMaster(long clusterId,
String... serviceName) |
Map<Long,Map<Long,AlertDefinition>> |
getAlertDefinitions(Long hostId) |
List<AlertDefinition> |
getAlertDefinitions(String clusterName,
String hostName)
Gets the alert definitions for the specified host.
|
Set<String> |
getAssociatedHosts(Cluster cluster,
SourceType definitionSourceType,
String definitionName,
String definitionServiceName,
String definitionComponentName)
Gets the hosts that are associated with the specified definition.
|
String |
getHash(String clusterName,
String hostName)
Gets a unique hash value reprssenting all of the alert definitions that
should be scheduled to run on a given host.
|
void |
invalidate(String hostName)
Invalidates the cached hash for the specified agent host across all
clusters.
|
void |
invalidate(String clusterName,
String hostName)
Invalidates the cached hash for the specified agent host in the specified
cluster.
|
void |
invalidateAll()
Invalidate all cached hashes causing subsequent lookups to recalculate.
|
Set<String> |
invalidateHosts(AlertDefinition definition)
Invalidate the hashes of any host that would be affected by the specified
definition.
|
Set<String> |
invalidateHosts(AlertDefinitionEntity definition)
Invalidate the hashes of any host that would be affected by the specified
definition.
|
boolean |
isHashCached(String clusterName,
String hostName)
Gets whether the alert definition hash for the specified host has been
calculated and cached.
|
public static final String NULL_MD5_HASH
public String getHash(String clusterName, String hostName)
SourceType.AGGREGATE
since aggregate definitions are not scheduled
to run on agent hosts.
Hash values from this method are cached.clusterName
- the cluster name (not null
).hostName
- the host name (not null
).public void invalidateAll()
public void invalidate(String hostName)
hostName
- the host to invalidate the cache for (not null
).public void invalidate(String clusterName, String hostName)
clusterName
- the name of the cluster (not null
).hostName
- the host to invalidate the cache for (not null
).public boolean isHashCached(String clusterName, String hostName)
hostName
- the host.true
if the hash was calculated; false
otherwise.public List<AlertDefinition> getAlertDefinitions(String clusterName, String hostName)
clusterName
- the cluster name (not null
).hostName
- the host name (not null
).null
).public Map<Long,Map<Long,AlertDefinition>> getAlertDefinitions(Long hostId) throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
public Map<Long,AlertDefinition> findByServiceComponent(long clusterId, String serviceName, String componentName)
public Map<Long,AlertDefinition> findByServiceMaster(long clusterId, String... serviceName)
public Set<String> invalidateHosts(AlertDefinitionEntity definition)
SourceType.AGGREGATE
, this will
return an empty set since aggregates do not affect hosts.definition
- the definition to use to find the hosts to invlidate (not
null
).null
).public Set<String> invalidateHosts(AlertDefinition definition)
SourceType.AGGREGATE
, this will
return an empty set since aggregates do not affect hosts.definition
- the definition to use to find the hosts to invlidate (not
null
).null
).public Set<String> getAssociatedHosts(Cluster cluster, SourceType definitionSourceType, String definitionName, String definitionServiceName, String definitionComponentName)
SourceType.AGGREGATE
, this will return an
empty set since aggregates do not affect hosts.cluster
- definitionName
- definitionServiceName
- definitionComponentName
- null
.public void enqueueAgentCommands(long clusterId)
AlertDefinitionCommand
s for every host in the cluster so
that they will receive a payload of alert definitions that they should be
running.
This method is typically called after invalidateAll()
has caused a
cache invalidation of all alert definitions.clusterId
- the ID of the cluster.public void enqueueAgentCommands(long clusterId, Collection<String> hosts)
AlertDefinitionCommand
s for every host specified so that
they will receive a payload of alert definitions that they should be
running.
This method is typically called after
invalidateHosts(AlertDefinitionEntity)
has caused a cache
invalidation of the alert definition hash.clusterId
- the ID of the cluster.hosts
- the hosts to push AlertDefinitionCommand
s for.Copyright © 2022 Apache Software Foundation. All rights reserved.