*/
package org.onap.holmes.common.dmaap;
-import org.jvnet.hk2.annotations.Service;
import org.onap.holmes.common.aai.AaiQuery;
import org.onap.holmes.common.aai.entity.RelationshipList.Relationship;
import org.onap.holmes.common.aai.entity.VmEntity;
import org.onap.holmes.common.utils.GsonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
-import javax.inject.Inject;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.UUID;
private ClosedLoopControlNameCache closedLoopControlNameCache;
private UniqueRequestIdCache uniqueRequestIdCache;
- @Inject
+ @Autowired
public void setAaiQuery(AaiQuery aaiQuery) {
this.aaiQuery = aaiQuery;
}
- @Inject
+ @Autowired
public void setClosedLoopControlNameCache(ClosedLoopControlNameCache closedLoopControlNameCache) {
this.closedLoopControlNameCache = closedLoopControlNameCache;
}
- @Inject
+ @Autowired
public void setUniqueRequestIdCache(UniqueRequestIdCache uniqueRequestIdCache) {
this.uniqueRequestIdCache = uniqueRequestIdCache;
}
.getTopicUrl());
publisher.publish(policyMsg);
deleteRequestIdIfNecessary(policyMsg);
+
log.info("send policyMsg: " + GsonUtil.beanToJson(policyMsg));
- } catch (CorrelationException e) {
- log.error("Failed to publish the control loop event to DMaaP", e);
} catch (NullPointerException e) {
- log.error("DMaaP configurations do not exist!");
+ log.error(String.format("DMaaP configurations do not exist!\n DCAE Configurations: \n %s",
+ DcaeConfigurationsCache.getDcaeConfigurations()), e);
+ } catch (Exception e) {
+ log.error(String.format("An error occurred when publishing a message to Policy: %s",
+ e.getMessage()), e);
}
}
}
private PolicyMsg getEnrichedPolicyMsg(VmEntity vmEntity, VesAlarm rootAlarm, VesAlarm childAlarm,
- String packageName) {
+ String packageName) {
PolicyMsg policyMsg = new PolicyMsg();
policyMsg.setRequestID(getUniqueRequestId(rootAlarm));
if (rootAlarm.getAlarmIsCleared() == PolicyMassgeConstant.POLICY_MESSAGE_ONSET) {
policyMsg.setClosedLoopEventStatus(EVENT_STATUS.ONSET);
policyMsg.getAai().put("vserver.in-maint", vmEntity.getInMaint());
policyMsg.getAai().put("vserver.is-closed-loop-disabled",
- vmEntity.getClosedLoopDisable());
+ vmEntity.getClosedLoopDisable());
policyMsg.getAai().put("vserver.prov-status", vmEntity.getProvStatus());
policyMsg.getAai().put("vserver.resource-version", vmEntity.getResourceVersion());
} else {
return vmEntity;
}
- private void deleteRequestIdIfNecessary(PolicyMsg policyMsg){
- EVENT_STATUS status = policyMsg.getClosedLoopEventStatus();
- if(EVENT_STATUS.ABATED.equals(status)) {
+ private void deleteRequestIdIfNecessary(PolicyMsg policyMsg) {
+ EVENT_STATUS status = policyMsg.getClosedLoopEventStatus();
+ if (EVENT_STATUS.ABATED.equals(status)) {
String requestId = policyMsg.getRequestID();
- for(Entry<String, String> kv: uniqueRequestIdCache.entrySet()) {
- if(kv.getValue().equals(requestId)) {
+ for (Entry<String, String> kv : uniqueRequestIdCache.entrySet()) {
+ if (kv.getValue().equals(requestId)) {
uniqueRequestIdCache.remove(kv.getKey());
break;
}