diff options
author | Shiwei Tian <tian.shiwei@zte.com.cn> | 2017-10-23 16:06:41 +0800 |
---|---|---|
committer | Shiwei Tian <tian.shiwei@zte.com.cn> | 2017-10-24 10:01:23 +0800 |
commit | 80aa5b49e5e3fb696231ce66acf198ff50d74731 (patch) | |
tree | 869683ed98ca1abf7050929c5169f34fd6d50353 /holmes-actions/src/main/java | |
parent | 75b8b484b7207c393026ee6509a22b2016a22475 (diff) |
modify unique bug
Issue-ID: HOLMES-71
Change-Id: I7b19e161f74c6dd97b6aeb93ae0d0247ce02b91e
Signed-off-by: Shiwei Tian <tian.shiwei@zte.com.cn>
Diffstat (limited to 'holmes-actions/src/main/java')
3 files changed, 30 insertions, 25 deletions
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/api/stat/VesAlarm.java b/holmes-actions/src/main/java/org/onap/holmes/common/api/stat/VesAlarm.java index f43d3bd..ead8464 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/api/stat/VesAlarm.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/api/stat/VesAlarm.java @@ -57,7 +57,7 @@ public class VesAlarm implements Cloneable, Serializable{ @Override public int hashCode() { - return this.version.hashCode(); + return (this.getSourceId() + this.eventName.replace("Cleared", "")).hashCode(); } @Override @@ -65,7 +65,9 @@ public class VesAlarm implements Cloneable, Serializable{ if (object == null || !(object instanceof VesAlarm)) { return false; } - return this.version.equals(((VesAlarm) object).getVersion()); + return this.eventName.replace("Cleared", "") + .equals(((VesAlarm) object).getEventName().replace("Cleared", "")) + && this.getSourceId().equals(((VesAlarm) object).getSourceId()); } @Override diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/DmaapService.java b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/DmaapService.java index 3ddf126..fc79539 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/DmaapService.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/DmaapService.java @@ -38,14 +38,12 @@ import org.onap.holmes.common.utils.JacksonUtil; @Slf4j @Service public class DmaapService { - public static final int POLICY_MESSAGE_ABATED = 1; - + public static final String SERVICE_INSTANCE = "service-instance"; + public static final String SERVICE_INSTANCE_ID = "service-instance.service-instance-id"; @Inject private AaiQuery aaiQuery; - public static ConcurrentHashMap<String, String> loopControlNames = new ConcurrentHashMap<>(); - public static ConcurrentHashMap<String, String> alarmUniqueRequestID = new ConcurrentHashMap<>(); public void publishPolicyMsg(PolicyMsg policyMsg, String dmaapConfigKey) { @@ -75,7 +73,7 @@ public class DmaapService { List<Relationship> relationshipList = vnfEntity.getRelationshipList().getRelationships(); Relationship relationship = null; for(int i = 0; i < relationshipList.size(); i++) { - if ("service-instance".equals(relationshipList.get(i).getRelatedTo())) { + if (SERVICE_INSTANCE.equals(relationshipList.get(i).getRelatedTo())) { relationship = relationshipList.get(i); break; } @@ -83,7 +81,7 @@ public class DmaapService { if (relationship != null) { List<RelationshipData> relationshipDataList = relationship.getRelationshipDataList(); for(int i = 0; i < relationshipDataList.size(); i++) { - if ("service-instance.service-instance-id" + if (SERVICE_INSTANCE_ID .equals(relationshipDataList.get(i).getRelationshipKey())) { vserverInstanceId = relationshipDataList.get(i).getRelationshipValue(); break; @@ -97,30 +95,34 @@ public class DmaapService { private PolicyMsg getEnrichedPolicyMsg(VmEntity vmEntity, VesAlarm rootAlarm, VesAlarm childAlarm, String packageName) { PolicyMsg policyMsg = new PolicyMsg(); + String alarmUniqueKey = ""; if (rootAlarm.getAlarmIsCleared() == POLICY_MESSAGE_ABATED) { policyMsg.setClosedLoopEventStatus(EVENT_STATUS.ABATED); + alarmUniqueKey = + rootAlarm.getSourceId() + ":" + rootAlarm.getEventName().replace("Cleared", ""); } else { policyMsg.setClosedLoopEventStatus(EVENT_STATUS.ONSET); enrichVnfInfo(childAlarm, policyMsg); + alarmUniqueKey = rootAlarm.getSourceId() + ":" + rootAlarm.getEventName(); } - if (alarmUniqueRequestID.containsKey(rootAlarm.getSourceId())) { - policyMsg.setRequestID(alarmUniqueRequestID.get(rootAlarm.getSourceId())); + if (alarmUniqueRequestID.containsKey(alarmUniqueKey)) { + policyMsg.setRequestID(alarmUniqueRequestID.get(alarmUniqueKey)); } else { String requestID = UUID.randomUUID().toString(); policyMsg.setRequestID(requestID); - alarmUniqueRequestID.put(rootAlarm.getSourceId(), requestID); + alarmUniqueRequestID.put(alarmUniqueKey, requestID); } policyMsg.setClosedLoopControlName(loopControlNames.get(packageName)); policyMsg.setTarget(vmEntity.getVserverName()); - policyMsg.getAAI().put("vserver.in-maint", String.valueOf(vmEntity.getInMaint())); - policyMsg.getAAI().put("vserver.is-closed-loop-disabled", + policyMsg.getAai().put("vserver.in-maint", String.valueOf(vmEntity.getInMaint())); + policyMsg.getAai().put("vserver.is-closed-loop-disabled", String.valueOf(vmEntity.getClosedLoopDisable())); - policyMsg.getAAI().put("vserver.prov-status", vmEntity.getProvStatus()); - policyMsg.getAAI().put("vserver.resource-version", vmEntity.getResourceVersion()); - policyMsg.getAAI().put("vserver.vserver-id", vmEntity.getVserverId()); - policyMsg.getAAI().put("vserver.vserver-name", vmEntity.getVserverName()); - policyMsg.getAAI().put("vserver.vserver-name2", vmEntity.getVserverName2()); - policyMsg.getAAI().put("vserver.vserver-selflink", vmEntity.getVserverSelflink()); + policyMsg.getAai().put("vserver.prov-status", vmEntity.getProvStatus()); + policyMsg.getAai().put("vserver.resource-version", vmEntity.getResourceVersion()); + policyMsg.getAai().put("vserver.vserver-id", vmEntity.getVserverId()); + policyMsg.getAai().put("vserver.vserver-name", vmEntity.getVserverName()); + policyMsg.getAai().put("vserver.vserver-name2", vmEntity.getVserverName2()); + policyMsg.getAai().put("vserver.vserver-selflink", vmEntity.getVserverSelflink()); return policyMsg; } @@ -128,16 +130,16 @@ public class DmaapService { PolicyMsg policyMsg = new PolicyMsg(); policyMsg.setTarget("vserver.vserver-name"); policyMsg.setTargetType("VM"); - policyMsg.getAAI().put("vserver.vserver-name", sourceName); + policyMsg.getAai().put("vserver.vserver-name", sourceName); return policyMsg; } private void enrichVnfInfo(VesAlarm childAlarm, PolicyMsg policyMsg) { VnfEntity vnfEntity = getVnfEntity(childAlarm.getSourceId(), childAlarm.getSourceName()); String vserverInstatnceId = getVserverInstanceId(vnfEntity); - policyMsg.getAAI().put("generic-vnf.vnf-id", childAlarm.getSourceId()); - policyMsg.getAAI().put("generic-vnf.vnf-name", childAlarm.getSourceName()); - policyMsg.getAAI().put("generic-vnf.service-instance-id", vserverInstatnceId); + policyMsg.getAai().put("generic-vnf.vnf-id", childAlarm.getSourceId()); + policyMsg.getAai().put("generic-vnf.vnf-name", childAlarm.getSourceName()); + policyMsg.getAai().put("generic-vnf.service-instance-id", vserverInstatnceId); } private VnfEntity getVnfEntity(String vnfId, String vnfName) { diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/entity/PolicyMsg.java b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/entity/PolicyMsg.java index 4462474..37713b4 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/entity/PolicyMsg.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/entity/PolicyMsg.java @@ -36,11 +36,12 @@ public class PolicyMsg { private String policyVersion;
private String policyName;
private String policyScope;
- private String from = "HOLMES";
+ private String from = "DCAE";
@JsonProperty(value = "target_type")
private String targetType = "VM";
private String target;
- private Map<String, String> AAI = new HashMap<>();
+ @JsonProperty(value = "AAI")
+ private Map<String, String> aai = new HashMap<>();
public static enum EVENT_STATUS {
ONSET, ABATED;
|