|
@@ -19,6 +19,7 @@ package org.apache.ambari.server.orm.entities;
|
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
+import javax.persistence.Basic;
|
|
|
import javax.persistence.CascadeType;
|
|
|
import javax.persistence.Column;
|
|
|
import javax.persistence.Entity;
|
|
@@ -28,6 +29,7 @@ import javax.persistence.Enumerated;
|
|
|
import javax.persistence.GeneratedValue;
|
|
|
import javax.persistence.GenerationType;
|
|
|
import javax.persistence.Id;
|
|
|
+import javax.persistence.Lob;
|
|
|
import javax.persistence.ManyToMany;
|
|
|
import javax.persistence.NamedQueries;
|
|
|
import javax.persistence.NamedQuery;
|
|
@@ -58,6 +60,8 @@ public class AlertDefinitionEntity {
|
|
|
@Column(name = "definition_id", nullable = false, updatable = false)
|
|
|
private Long definitionId;
|
|
|
|
|
|
+ @Lob
|
|
|
+ @Basic
|
|
|
@Column(name = "alert_source", nullable = false, length = 32672)
|
|
|
private String source;
|
|
|
|
|
@@ -69,7 +73,7 @@ public class AlertDefinitionEntity {
|
|
|
|
|
|
@Column(name = "definition_name", nullable = false, length = 255)
|
|
|
private String definitionName;
|
|
|
-
|
|
|
+
|
|
|
@Column(name = "scope", length = 255)
|
|
|
@Enumerated(value = EnumType.STRING)
|
|
|
private Scope scope;
|
|
@@ -104,7 +108,7 @@ public class AlertDefinitionEntity {
|
|
|
|
|
|
/**
|
|
|
* Gets the unique identifier for this alert definition.
|
|
|
- *
|
|
|
+ *
|
|
|
* @return the ID.
|
|
|
*/
|
|
|
public Long getDefinitionId() {
|
|
@@ -113,7 +117,7 @@ public class AlertDefinitionEntity {
|
|
|
|
|
|
/**
|
|
|
* Sets the unique identifier for this alert definition.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param definitionId
|
|
|
* the ID (not {@code null}).
|
|
|
*/
|
|
@@ -125,7 +129,7 @@ public class AlertDefinitionEntity {
|
|
|
* Gets the source that defines the type of alert and the alert properties.
|
|
|
* This is typically a JSON structure that can be mapped to a first-class
|
|
|
* object.
|
|
|
- *
|
|
|
+ *
|
|
|
* @return the alert source (never {@code null}).
|
|
|
*/
|
|
|
public String getSource() {
|
|
@@ -135,19 +139,19 @@ public class AlertDefinitionEntity {
|
|
|
/**
|
|
|
* Sets the source of the alert, typically in JSON, that defines the type of
|
|
|
* the alert and its properties.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param alertSource
|
|
|
* the alert source (not {@code null}).
|
|
|
*/
|
|
|
public void setSource(String alertSource) {
|
|
|
- this.source = alertSource;
|
|
|
+ source = alertSource;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Gets the ID of the cluster that this alert definition is created for. Each
|
|
|
* cluster has their own set of alert definitions that are not shared with any
|
|
|
* other cluster.
|
|
|
- *
|
|
|
+ *
|
|
|
* @return the ID of the cluster (never {@code null}).
|
|
|
*/
|
|
|
public Long getClusterId() {
|
|
@@ -158,7 +162,7 @@ public class AlertDefinitionEntity {
|
|
|
* Sets the ID of the cluster that this alert definition is created for. Each
|
|
|
* cluster has their own set of alert definitions that are not shared with any
|
|
|
* other cluster.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param clusterId
|
|
|
* the ID of the cluster (not {@code null}).
|
|
|
*/
|
|
@@ -169,7 +173,7 @@ public class AlertDefinitionEntity {
|
|
|
/**
|
|
|
* Gets the component name that this alert is associated with, if any. Some
|
|
|
* alerts are scoped at the service level and will not have a component name.
|
|
|
- *
|
|
|
+ *
|
|
|
* @return the component name or {@code null} if none.
|
|
|
*/
|
|
|
public String getComponentName() {
|
|
@@ -179,7 +183,7 @@ public class AlertDefinitionEntity {
|
|
|
/**
|
|
|
* Sets the component name that this alert is associated with, if any. Some
|
|
|
* alerts are scoped at the service level and will not have a component name.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param componentName
|
|
|
* the component name or {@code null} if none.
|
|
|
*/
|
|
@@ -190,7 +194,7 @@ public class AlertDefinitionEntity {
|
|
|
/**
|
|
|
* Gets the scope of the alert definition. The scope is defined as either
|
|
|
* being for a {@link Scope#SERVICE} or {@link Scope#HOST}.
|
|
|
- *
|
|
|
+ *
|
|
|
* @return the scope, or {@code null} if not defined.
|
|
|
*/
|
|
|
public Scope getScope() {
|
|
@@ -200,7 +204,7 @@ public class AlertDefinitionEntity {
|
|
|
/**
|
|
|
* Sets the scope of the alert definition. The scope is defined as either
|
|
|
* being for a {@link Scope#SERVICE} or {@link Scope#HOST}.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param scope
|
|
|
* the scope to set, or {@code null} for none.
|
|
|
*/
|
|
@@ -211,7 +215,7 @@ public class AlertDefinitionEntity {
|
|
|
/**
|
|
|
* Gets the name of this alert definition. Alert definition names are unique
|
|
|
* within a cluster.
|
|
|
- *
|
|
|
+ *
|
|
|
* @return the name of the alert definition (never {@code null}).
|
|
|
*/
|
|
|
public String getDefinitionName() {
|
|
@@ -221,7 +225,7 @@ public class AlertDefinitionEntity {
|
|
|
/**
|
|
|
* Sets the name of this alert definition. Alert definition names are unique
|
|
|
* within a cluster.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param definitionName
|
|
|
* the name of the alert definition (not {@code null}).
|
|
|
*/
|
|
@@ -233,7 +237,7 @@ public class AlertDefinitionEntity {
|
|
|
* Gets whether this alert definition is enabled. Disabling an alert
|
|
|
* definition will prevent agents from scheduling the alerts. No alerts will
|
|
|
* be triggered and no alert data will be collected.
|
|
|
- *
|
|
|
+ *
|
|
|
* @return {@code true} if this alert definition is enabled, {@code false}
|
|
|
* otherwise.
|
|
|
*/
|
|
@@ -243,7 +247,7 @@ public class AlertDefinitionEntity {
|
|
|
|
|
|
/**
|
|
|
* Sets whether this alert definition is enabled.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param enabled
|
|
|
* {@code true} if this alert definition is enabled, {@code false}
|
|
|
* otherwise.
|
|
@@ -255,7 +259,7 @@ public class AlertDefinitionEntity {
|
|
|
/**
|
|
|
* Gets the unique hash for the current state of this definition. If a
|
|
|
* property of this definition changes, a new hash is calculated.
|
|
|
- *
|
|
|
+ *
|
|
|
* @return the unique hash or {@code null} if there is none.
|
|
|
*/
|
|
|
public String getHash() {
|
|
@@ -265,7 +269,7 @@ public class AlertDefinitionEntity {
|
|
|
/**
|
|
|
* Gets the unique hash for the current state of this definition. If a
|
|
|
* property of this definition changes, a new hash is calculated.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param hash
|
|
|
* the unique hash to set or {@code null} for none.
|
|
|
*/
|
|
@@ -275,7 +279,7 @@ public class AlertDefinitionEntity {
|
|
|
|
|
|
/**
|
|
|
* Gets the alert trigger interval, in seconds.
|
|
|
- *
|
|
|
+ *
|
|
|
* @return the interval, in seconds.
|
|
|
*/
|
|
|
public Integer getScheduleInterval() {
|
|
@@ -284,7 +288,7 @@ public class AlertDefinitionEntity {
|
|
|
|
|
|
/**
|
|
|
* Sets the alert trigger interval, in seconds.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param scheduleInterval
|
|
|
* the interval, in seconds.
|
|
|
*/
|
|
@@ -295,7 +299,7 @@ public class AlertDefinitionEntity {
|
|
|
/**
|
|
|
* Gets the name of the service that this alert definition is associated with.
|
|
|
* Every alert definition is associated with exactly one service.
|
|
|
- *
|
|
|
+ *
|
|
|
* @return the name of the service (never {@code null}).
|
|
|
*/
|
|
|
public String getServiceName() {
|
|
@@ -305,7 +309,7 @@ public class AlertDefinitionEntity {
|
|
|
/**
|
|
|
* Gets the name of the service that this alert definition is associated with.
|
|
|
* Every alert definition is associated with exactly one service.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param serviceName
|
|
|
* the name of the service (not {@code null}).
|
|
|
*/
|
|
@@ -331,7 +335,7 @@ public class AlertDefinitionEntity {
|
|
|
|
|
|
/**
|
|
|
* Gets the alert groups that this alert definition is associated with.
|
|
|
- *
|
|
|
+ *
|
|
|
* @return the groups, or {@code null} if none.
|
|
|
*/
|
|
|
public Set<AlertGroupEntity> getAlertGroups() {
|
|
@@ -340,7 +344,7 @@ public class AlertDefinitionEntity {
|
|
|
|
|
|
/**
|
|
|
* Sets the alert groups that this alert definition is associated with.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param alertGroups
|
|
|
* the groups, or {@code null} for none.
|
|
|
*/
|
|
@@ -355,13 +359,15 @@ public class AlertDefinitionEntity {
|
|
|
@PreRemove
|
|
|
public void preRemove() {
|
|
|
Set<AlertGroupEntity> groups = getAlertGroups();
|
|
|
- if (null == groups || groups.size() == 0)
|
|
|
+ if (null == groups || groups.size() == 0) {
|
|
|
return;
|
|
|
+ }
|
|
|
|
|
|
for (AlertGroupEntity group : groups) {
|
|
|
Set<AlertDefinitionEntity> definitions = group.getAlertDefinitions();
|
|
|
- if (null != definitions)
|
|
|
+ if (null != definitions) {
|
|
|
definitions.remove(this);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -370,17 +376,20 @@ public class AlertDefinitionEntity {
|
|
|
*/
|
|
|
@Override
|
|
|
public boolean equals(Object object) {
|
|
|
- if (this == object)
|
|
|
+ if (this == object) {
|
|
|
return true;
|
|
|
+ }
|
|
|
|
|
|
- if (object == null || getClass() != object.getClass())
|
|
|
+ if (object == null || getClass() != object.getClass()) {
|
|
|
return false;
|
|
|
+ }
|
|
|
|
|
|
AlertDefinitionEntity that = (AlertDefinitionEntity) object;
|
|
|
|
|
|
if (definitionId != null ? !definitionId.equals(that.definitionId)
|
|
|
- : that.definitionId != null)
|
|
|
+ : that.definitionId != null) {
|
|
|
return false;
|
|
|
+ }
|
|
|
|
|
|
return true;
|
|
|
}
|