Merge "Pass link and lifecycle state in state transitions"
This commit is contained in:
commit
78a8a1d0f1
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
* Copyright (c) 2014,2016 Hewlett Packard Enterprise Development Company, L.P.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -42,6 +42,8 @@ public class Alarm extends AbstractEntity {
|
|||||||
private Map<String, SubAlarm> subAlarms;
|
private Map<String, SubAlarm> subAlarms;
|
||||||
private Set<MetricDefinitionAndTenantId> alarmedMetrics = new HashSet<>();
|
private Set<MetricDefinitionAndTenantId> alarmedMetrics = new HashSet<>();
|
||||||
private AlarmState state;
|
private AlarmState state;
|
||||||
|
private String link;
|
||||||
|
private String lifecycleState;
|
||||||
private String stateChangeReason;
|
private String stateChangeReason;
|
||||||
private String alarmDefinitionId;
|
private String alarmDefinitionId;
|
||||||
private List<AlarmTransitionSubAlarm> transitionSubAlarms = new ArrayList<>();
|
private List<AlarmTransitionSubAlarm> transitionSubAlarms = new ArrayList<>();
|
||||||
@ -97,6 +99,12 @@ public class Alarm extends AbstractEntity {
|
|||||||
if (state != other.state) {
|
if (state != other.state) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!compareObjects(link, other.link)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!compareObjects(lifecycleState, other.lifecycleState)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (!compareObjects(alarmDefinitionId, other.alarmDefinitionId)) {
|
if (!compareObjects(alarmDefinitionId, other.alarmDefinitionId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -179,6 +187,10 @@ public class Alarm extends AbstractEntity {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLink() { return link; }
|
||||||
|
|
||||||
|
public String getLifecycleState() { return lifecycleState; }
|
||||||
|
|
||||||
public String getStateChangeReason() {
|
public String getStateChangeReason() {
|
||||||
return stateChangeReason;
|
return stateChangeReason;
|
||||||
}
|
}
|
||||||
@ -192,6 +204,8 @@ public class Alarm extends AbstractEntity {
|
|||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = super.hashCode();
|
int result = super.hashCode();
|
||||||
result = prime * result + ((state == null) ? 0 : state.hashCode());
|
result = prime * result + ((state == null) ? 0 : state.hashCode());
|
||||||
|
result = prime * result + ((link == null) ? 0 : link.hashCode());
|
||||||
|
result = prime * result + ((lifecycleState == null) ? 0 : lifecycleState.hashCode());
|
||||||
result = prime * result + ((subAlarms == null) ? 0 : subAlarms.hashCode());
|
result = prime * result + ((subAlarms == null) ? 0 : subAlarms.hashCode());
|
||||||
result = prime * result + ((alarmDefinitionId == null) ? 0 : alarmDefinitionId.hashCode());
|
result = prime * result + ((alarmDefinitionId == null) ? 0 : alarmDefinitionId.hashCode());
|
||||||
result = prime * result + ((stateChangeReason == null) ? 0 : stateChangeReason.hashCode());
|
result = prime * result + ((stateChangeReason == null) ? 0 : stateChangeReason.hashCode());
|
||||||
@ -207,6 +221,14 @@ public class Alarm extends AbstractEntity {
|
|||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLink(String newLink) {
|
||||||
|
this.link = newLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLifecycleState(String newLifecycleState) {
|
||||||
|
this.lifecycleState = newLifecycleState;
|
||||||
|
}
|
||||||
|
|
||||||
public void setSubAlarms(List<SubAlarm> subAlarms) {
|
public void setSubAlarms(List<SubAlarm> subAlarms) {
|
||||||
this.subAlarms = new HashMap<String, SubAlarm>();
|
this.subAlarms = new HashMap<String, SubAlarm>();
|
||||||
for (SubAlarm subAlarm : subAlarms) {
|
for (SubAlarm subAlarm : subAlarms) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
* Copyright (c) 2014,2016 Hewlett Packard Enterprise Development Company, L.P.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -236,7 +236,8 @@ public class AlarmThresholdingBolt extends BaseRichBolt {
|
|||||||
new AlarmStateTransitionedEvent(alarmDefinition.getTenantId(), alarm.getId(),
|
new AlarmStateTransitionedEvent(alarmDefinition.getTenantId(), alarm.getId(),
|
||||||
alarmDefinition.getId(), alarmedMetrics, alarmDefinition.getName(),
|
alarmDefinition.getId(), alarmedMetrics, alarmDefinition.getName(),
|
||||||
alarmDefinition.getDescription(), initialState, alarm.getState(),
|
alarmDefinition.getDescription(), initialState, alarm.getState(),
|
||||||
alarmDefinition.getSeverity(), alarmDefinition.isActionsEnabled(), stateChangeReason,
|
alarmDefinition.getSeverity(), alarm.getLink(), alarm.getLifecycleState(),
|
||||||
|
alarmDefinition.isActionsEnabled(), stateChangeReason,
|
||||||
alarm.getTransitionSubAlarms(), getTimestamp());
|
alarm.getTransitionSubAlarms(), getTimestamp());
|
||||||
try {
|
try {
|
||||||
alarmEventForwarder.send(Serialization.toJson(event));
|
alarmEventForwarder.send(Serialization.toJson(event));
|
||||||
@ -262,6 +263,8 @@ public class AlarmThresholdingBolt extends BaseRichBolt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
oldAlarm.setState(alarmUpdatedEvent.alarmState);
|
oldAlarm.setState(alarmUpdatedEvent.alarmState);
|
||||||
|
oldAlarm.setLink(alarmUpdatedEvent.link);
|
||||||
|
oldAlarm.setLifecycleState(alarmUpdatedEvent.lifecycleState);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
* Copyright (c) 2014,2016 Hewlett Packard Enterprise Development Company, L.P.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -124,6 +124,7 @@ public class AlarmThresholdingBoltTest {
|
|||||||
+ "\"actionsEnabled\":true,"
|
+ "\"actionsEnabled\":true,"
|
||||||
+ "\"stateChangeReason\":\"Thresholds were exceeded for the sub-alarms: "
|
+ "\"stateChangeReason\":\"Thresholds were exceeded for the sub-alarms: "
|
||||||
+ subAlarm.getExpression().getExpression() + " with the values: []\"," + "\"severity\":\"LOW\","
|
+ subAlarm.getExpression().getExpression() + " with the values: []\"," + "\"severity\":\"LOW\","
|
||||||
|
+ "\"link\":null," + "\"lifecycleState\":null,"
|
||||||
+ "\"subAlarms\":[" + buildSubAlarmJson(alarm.getSubAlarms()) + "],"
|
+ "\"subAlarms\":[" + buildSubAlarmJson(alarm.getSubAlarms()) + "],"
|
||||||
+ "\"timestamp\":1395587091003}}";
|
+ "\"timestamp\":1395587091003}}";
|
||||||
|
|
||||||
@ -149,6 +150,7 @@ public class AlarmThresholdingBoltTest {
|
|||||||
+ subAlarms.get(1).getExpression().getExpression() + " with the values: [], "
|
+ subAlarms.get(1).getExpression().getExpression() + " with the values: [], "
|
||||||
+ subAlarms.get(2).getExpression().getExpression() + " with the values: []"
|
+ subAlarms.get(2).getExpression().getExpression() + " with the values: []"
|
||||||
+ "\",\"severity\":\"LOW\","
|
+ "\",\"severity\":\"LOW\","
|
||||||
|
+ "\"link\":null," + "\"lifecycleState\":null,"
|
||||||
+ "\"subAlarms\":[" + buildSubAlarmJson(alarm.getSubAlarms()) + "],"
|
+ "\"subAlarms\":[" + buildSubAlarmJson(alarm.getSubAlarms()) + "],"
|
||||||
+ "\"timestamp\":1395587091003}}";
|
+ "\"timestamp\":1395587091003}}";
|
||||||
verify(alarmEventForwarder, times(1)).send(okJson);
|
verify(alarmEventForwarder, times(1)).send(okJson);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
* Copyright (c) 2014,2016 Hewlett Packard Enterprise Development Company, L.P.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -216,7 +216,8 @@ public class EventProcessingBoltTest {
|
|||||||
}
|
}
|
||||||
final AlarmUpdatedEvent event =
|
final AlarmUpdatedEvent event =
|
||||||
new AlarmUpdatedEvent(alarm.getId(), alarmDefinition.getId(),
|
new AlarmUpdatedEvent(alarm.getId(), alarmDefinition.getId(),
|
||||||
alarmDefinition.getTenantId(), alarmedMetrics, subAlarmMap, newState, alarm.getState());
|
alarmDefinition.getTenantId(), alarmedMetrics, subAlarmMap, newState, alarm.getState(),
|
||||||
|
alarm.getLink(), alarm.getLifecycleState());
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
* Copyright (c) 2014,2016 Hewlett Packard Enterprise Development Company, L.P.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -86,7 +86,7 @@ public class EventDeserializerTest {
|
|||||||
final MetricDefinition md = new MetricDefinition("load", dimensions);
|
final MetricDefinition md = new MetricDefinition("load", dimensions);
|
||||||
alarmMetrics.add(md);
|
alarmMetrics.add(md);
|
||||||
roundTrip(new AlarmUpdatedEvent(ALARM_ID, ALARM_DEFINITION_ID, TENANT_ID, alarmMetrics,
|
roundTrip(new AlarmUpdatedEvent(ALARM_ID, ALARM_DEFINITION_ID, TENANT_ID, alarmMetrics,
|
||||||
subAlarms, AlarmState.OK, AlarmState.UNDETERMINED));
|
subAlarms, AlarmState.OK, AlarmState.UNDETERMINED, null, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void roundTrip(Object event) {
|
private void roundTrip(Object event) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user