X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=holmes-actions%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fholmes%2Fcommon%2Fdmaap%2FDmaapService.java;h=ba52262c5dc7d45dbcb9ad5d182b6b0d8719e58f;hb=81edfdbaffd9c450f37d2418bb444473ee3bbe77;hp=c64bd59992f822b1611260c37232d1dda058d0d9;hpb=8109b02052d5a66f442d8418340ad3bd7272ff99;p=holmes%2Fcommon.git 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 c64bd59..ba52262 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 @@ -15,6 +15,7 @@ */ package org.onap.holmes.common.dmaap; +import java.util.Map.Entry; import java.util.Optional; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -47,6 +48,7 @@ public class DmaapService { publisher.setUrl(DcaeConfigurationsCache.getPubSecInfo(dmaapConfigKey).getDmaapInfo() .getTopicUrl()); publisher.publish(policyMsg); + deleteRequestId(policyMsg); log.info("send policyMsg: " + GsonUtil.beanToJson(policyMsg)); } catch (CorrelationException e) { log.error("Failed to publish the control loop event to DMaaP", e); @@ -68,19 +70,9 @@ public class DmaapService { if (rootAlarm.getAlarmIsCleared() == PolicyMassgeConstant.POLICY_MESSAGE_ONSET) { enrichVnfInfo(vmEntity, childAlarm, policyMsg); policyMsg.setClosedLoopEventStatus(EVENT_STATUS.ONSET); - try { - policyMsg.getAai().put("vserver.in-maint", Boolean.valueOf(vmEntity.getInMaint()).booleanValue()); - } catch (Exception e) { - log.error("Failed to parse the field \"in-maint\". A boolean string (\"true\"/\"false\")" - + " is expected but the actual value is " + vmEntity.getInMaint() + ".", e); - } - try { - policyMsg.getAai().put("vserver.is-closed-loop-disabled", - Boolean.valueOf(vmEntity.getClosedLoopDisable()).booleanValue()); - } catch (Exception e) { - log.error("Failed to parse the field \"is-closed-loop-disabled\". A boolean string (\"true\"/\"false\")" - + " is expected but the actual value is " + vmEntity.getClosedLoopDisable() + ".", e); - } + policyMsg.getAai().put("vserver.in-maint", vmEntity.getInMaint()); + policyMsg.getAai().put("vserver.is-closed-loop-disabled", + vmEntity.getClosedLoopDisable()); policyMsg.getAai().put("vserver.prov-status", vmEntity.getProvStatus()); policyMsg.getAai().put("vserver.resource-version", vmEntity.getResourceVersion()); } else { @@ -183,4 +175,18 @@ public class DmaapService { } return vmEntity; } + + private void deleteRequestId(PolicyMsg policyMsg){ + EVENT_STATUS status = policyMsg.getClosedLoopEventStatus(); + if(EVENT_STATUS.ABATED.equals(status)) { + String requestId = policyMsg.getRequestID(); + for(Entry kv: alarmUniqueRequestID.entrySet()) { + if(kv.getValue().equals(requestId)) { + alarmUniqueRequestID.remove(kv.getKey()); + break; + } + } + log.info("An alarm is cleared and the corresponding requestId is deleted successfully"); + } + } }