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=e3f6e584c0b58e288a3314aa44054c77033ad4a1;hb=4f48419205730ecc3e34d93efc99cd76b81f9a59;hp=65058c5c1d2a0fa7482956b5a1c006ab585447d8;hpb=503068f2472e88d88d4f896557be276ff4d208e9;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 65058c5..e3f6e58 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,7 +15,7 @@ */ package org.onap.holmes.common.dmaap; -import com.fasterxml.jackson.core.JsonProcessingException; +import java.util.Map.Entry; import java.util.Optional; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -31,7 +31,7 @@ import org.onap.holmes.common.dcae.DcaeConfigurationsCache; import org.onap.holmes.common.dmaap.entity.PolicyMsg; import org.onap.holmes.common.dmaap.entity.PolicyMsg.EVENT_STATUS; import org.onap.holmes.common.exception.CorrelationException; -import org.onap.holmes.common.utils.JacksonUtil; +import org.onap.holmes.common.utils.GsonUtil; @Slf4j @Service @@ -39,8 +39,8 @@ public class DmaapService { @Inject private AaiQuery aaiQuery; - public static ConcurrentHashMap loopControlNames = new ConcurrentHashMap<>(); - public static ConcurrentHashMap alarmUniqueRequestID = new ConcurrentHashMap<>(); + public static final ConcurrentHashMap loopControlNames = new ConcurrentHashMap<>(); + public static final ConcurrentHashMap alarmUniqueRequestID = new ConcurrentHashMap<>(); public void publishPolicyMsg(PolicyMsg policyMsg, String dmaapConfigKey) { try { @@ -48,11 +48,10 @@ public class DmaapService { publisher.setUrl(DcaeConfigurationsCache.getPubSecInfo(dmaapConfigKey).getDmaapInfo() .getTopicUrl()); publisher.publish(policyMsg); - log.info("send policyMsg: " + JacksonUtil.beanToJson(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); - } catch (JsonProcessingException e) { - log.info("Failed to convert the control loop event to json"); } catch (NullPointerException e) { log.error("DMaaP configurations do not exist!"); } @@ -72,14 +71,14 @@ public class DmaapService { enrichVnfInfo(vmEntity, childAlarm, policyMsg); policyMsg.setClosedLoopEventStatus(EVENT_STATUS.ONSET); try { - policyMsg.getAai().put("vserver.in-maint", Boolean.valueOf(vmEntity.getInMaint()).booleanValue()); + policyMsg.getAai().put("vserver.in-maint", vmEntity.getInMaint()); } 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()); + vmEntity.getClosedLoopDisable()); } 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); @@ -186,4 +185,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("Clear alarm, requestId deleted successful"); + } + } }