summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuangrong Fu <fu.guangrong@zte.com.cn>2017-11-04 12:51:41 +0800
committerGuangrong Fu <fu.guangrong@zte.com.cn>2017-11-04 13:15:24 +0800
commit9029c44d097b3bab81e673329e46db6e73ed3fd9 (patch)
treecd3848e9e61a4c5c86f67789c50cfb2b86b3e43a
parentfc6503378a1fc638efb6946645323f6befeb8fc3 (diff)
Fix the DCAE integration Bugs
Change-Id: I87d8fbd71edc2ceaf39ca4d0c4df0ef62115a3d2 Issue-ID: HOLMES-81 Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn>
-rw-r--r--engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java4
-rw-r--r--engine-d/src/main/java/org/onap/holmes/engine/dcae/DcaeConfigurationPolling.java24
-rw-r--r--engine-d/src/test/java/org/onap/holmes/engine/EngineDActiveAppTest.java92
3 files changed, 105 insertions, 15 deletions
diff --git a/engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java b/engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java
index 9f604b1..4f5593c 100644
--- a/engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java
+++ b/engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java
@@ -42,7 +42,6 @@ public class EngineDActiveApp extends IOCApplication<EngineDAppConfig> {
super.run(configuration, environment);
environment.jersey().register(new EngineResources());
-
try {
new MSBRegisterUtil().register2Msb(createMicroServiceInfo());
} catch (CorrelationException e) {
@@ -50,7 +49,8 @@ public class EngineDActiveApp extends IOCApplication<EngineDAppConfig> {
}
ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
- service.scheduleAtFixedRate(new DcaeConfigurationPolling("holmes-engine-mgmt"), 0,
+ service.scheduleAtFixedRate(
+ new DcaeConfigurationPolling(MicroServiceConfig.getEnv(MicroServiceConfig.HOSTNAME)), 0,
DcaeConfigurationPolling.POLLING_PERIOD, TimeUnit.MILLISECONDS);
}
diff --git a/engine-d/src/main/java/org/onap/holmes/engine/dcae/DcaeConfigurationPolling.java b/engine-d/src/main/java/org/onap/holmes/engine/dcae/DcaeConfigurationPolling.java
index 4808009..9f892de 100644
--- a/engine-d/src/main/java/org/onap/holmes/engine/dcae/DcaeConfigurationPolling.java
+++ b/engine-d/src/main/java/org/onap/holmes/engine/dcae/DcaeConfigurationPolling.java
@@ -25,13 +25,11 @@ import org.onap.holmes.dsa.dmaappolling.Subscriber;
import org.onap.holmes.engine.dmaap.SubscriberAction;
@Slf4j
-public class DcaeConfigurationPolling implements Runnable{
+public class DcaeConfigurationPolling implements Runnable {
private String hostname;
- private String subscriberKey = "sec_fault_unsecure";
-
- public static long POLLING_PERIOD = 10 * 1000L;
+ public static long POLLING_PERIOD = 30 * 1000L;
public DcaeConfigurationPolling(String hostname) {
this.hostname = hostname;
@@ -44,21 +42,23 @@ public class DcaeConfigurationPolling implements Runnable{
dcaeConfigurations = DcaeConfigurationQuery
.getDcaeConfigurations(hostname);
} catch (CorrelationException e) {
- log.error("Failed to polling dcae configurations" + e.getMessage());
+ log.error("Failed to poll the DCAE configurations. " + e.getMessage());
}
if (dcaeConfigurations != null) {
DcaeConfigurationsCache.setDcaeConfigurations(dcaeConfigurations);
- addSubscriber(dcaeConfigurations);
+ addSubscribers(dcaeConfigurations);
}
}
- private void addSubscriber(DcaeConfigurations dcaeConfigurations) {
+ private void addSubscribers(DcaeConfigurations dcaeConfigurations) {
SubscriberAction subscriberAction = ServiceLocatorHolder.getLocator()
.getService(SubscriberAction.class);
- Subscriber subscriber = new Subscriber();
- subscriber.setTopic(subscriberKey);
- subscriber.setUrl(dcaeConfigurations.getSubSecInfo(subscriberKey).getDmaapInfo()
- .getTopicUrl());
- subscriberAction.addSubscriber(subscriber);
+ for (String key : dcaeConfigurations.getSubKeys()) {
+ Subscriber subscriber = new Subscriber();
+ subscriber.setTopic(key);
+ subscriber.setUrl(dcaeConfigurations.getSubSecInfo(key).getDmaapInfo()
+ .getTopicUrl());
+ subscriberAction.addSubscriber(subscriber);
+ }
}
}
diff --git a/engine-d/src/test/java/org/onap/holmes/engine/EngineDActiveAppTest.java b/engine-d/src/test/java/org/onap/holmes/engine/EngineDActiveAppTest.java
index 2c6cdb7..b96dc74 100644
--- a/engine-d/src/test/java/org/onap/holmes/engine/EngineDActiveAppTest.java
+++ b/engine-d/src/test/java/org/onap/holmes/engine/EngineDActiveAppTest.java
@@ -17,7 +17,97 @@ package org.onap.holmes.engine;
public class EngineDActiveAppTest {
public static void main(String[] args) throws Exception {
- String filePath = "C:\\engine-d.yml";
+ String test = "package org.onap.holmes.droolsRule;\n"
+ + "\n"
+ + "import org.onap.holmes.common.dmaap.DmaapService;\n"
+ + "import org.onap.holmes.common.api.stat.VesAlarm;\n"
+ + "import org.onap.holmes.common.aai.CorrelationUtil;\n"
+ + "import org.onap.holmes.common.dmaap.entity.PolicyMsg;\n"
+ + "import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;\n"
+ + "import org.onap.holmes.common.utils.DroolsLog;\n"
+ + " \n"
+ + "\n"
+ + "rule \"Relation_analysis_Rule\"\n"
+ + "salience 200\n"
+ + "no-loop true\n"
+ + " when\n"
+ + " $root : VesAlarm(alarmIsCleared == 0,\n"
+ + " $sourceId: sourceId, sourceId != null && !sourceId.equals(\"\"),\n"
+ + "\t\t\t$sourceName: sourceName, sourceName != null && !sourceName.equals(\"\"),\n"
+ + "\t\t\t$startEpochMicrosec: startEpochMicrosec,\n"
+ + " specificProblem in (\"Fault_MultiCloud_VMFailure\"),\n"
+ + " $eventId: eventId)\n"
+ + " $child : VesAlarm( eventId != $eventId, parentId == null,\n"
+ + " CorrelationUtil.getInstance().isTopologicallyRelated(sourceId, $sourceId, $sourceName),\n"
+ + " specificProblem in (\"Slave MPU is offline\"),\n"
+ + " startEpochMicrosec < $startEpochMicrosec + 60000 && startEpochMicrosec > $startEpochMicrosec - 60000 )\n"
+ + " then\n"
+ + "\t\tDroolsLog.printInfo(\"===========================================================\");\n"
+ + "\t\tDroolsLog.printInfo(\"Relation_analysis_Rule: rootId=\" + $root.getEventId() + \", childId=\" + $child.getEventId());\n"
+ + "\t\t$child.setParentId($root.getEventId());\n"
+ + "\t\tupdate($child);\n"
+ + "\t\t\n"
+ + "end\n"
+ + "\n"
+ + "rule \"root_has_child_handle_Rule\"\n"
+ + "salience 150\n"
+ + "no-loop true\n"
+ + "\twhen\n"
+ + "\t\t$root : VesAlarm(alarmIsCleared == 0, rootFlag == 0, $eventId: eventId)\n"
+ + "\t\t$child : VesAlarm(eventId != $eventId, parentId == $eventId)\n"
+ + "\tthen\n"
+ + "\t\tDroolsLog.printInfo(\"===========================================================\");\n"
+ + "\t\tDroolsLog.printInfo(\"root_has_child_handle_Rule: rootId=\" + $root.getEventId() + \", childId=\" + $child.getEventId());\n"
+ + "\t\tDmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);\n"
+ + "\t\tPolicyMsg policyMsg = dmaapService.getPolicyMsg($root, $child, \"org.onap.holmes.droolsRule\");\n"
+ + " dmaapService.publishPolicyMsg(policyMsg, \"unauthenticated.DCAE_CL_OUTPUT\");\n"
+ + "\t\t$root.setRootFlag(1);\n"
+ + "\t\tupdate($root);\n"
+ + "end\n"
+ + "\n"
+ + "rule \"root_no_child_handle_Rule\"\n"
+ + "salience 100\n"
+ + "no-loop true\n"
+ + " when\n"
+ + " $root : VesAlarm(alarmIsCleared == 0, rootFlag == 0,\n"
+ + " sourceId != null && !sourceId.equals(\"\"),\n"
+ + "\t\t\tsourceName != null && !sourceName.equals(\"\"),\n"
+ + " specificProblem in (\"Fault_MultiCloud_VMFailure\"))\n"
+ + " then\n"
+ + "\t\tDroolsLog.printInfo(\"===========================================================\");\n"
+ + "\t\tDroolsLog.printInfo(\"root_no_child_handle_Rule: rootId=\" + $root.getEventId());\n"
+ + "\t\tDmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);\n"
+ + "\t\tPolicyMsg policyMsg = dmaapService.getPolicyMsg($root, null, \"org.onap.holmes.droolsRule\");\n"
+ + " dmaapService.publishPolicyMsg(policyMsg, \"unauthenticated.DCAE_CL_OUTPUT\");\n"
+ + "\t\t$root.setRootFlag(1);\n"
+ + "\t\tupdate($root);\n"
+ + "end\n"
+ + "\n"
+ + "rule \"root_cleared_handle_Rule\"\n"
+ + "salience 100\n"
+ + "no-loop true\n"
+ + " when\n"
+ + " $root : VesAlarm(alarmIsCleared == 1, rootFlag == 1)\n"
+ + " then\n"
+ + "\t\tDroolsLog.printInfo(\"===========================================================\");\n"
+ + "\t\tDroolsLog.printInfo(\"root_cleared_handle_Rule: rootId=\" + $root.getEventId());\n"
+ + "\t\tDmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);\n"
+ + "\t\tPolicyMsg policyMsg = dmaapService.getPolicyMsg($root, null, \"org.onap.holmes.droolsRule\");\n"
+ + " dmaapService.publishPolicyMsg(policyMsg, \"unauthenticated.DCAE_CL_OUTPUT\");\n"
+ + "\t\tretract($root);\n"
+ + "end\n"
+ + "\n"
+ + "rule \"child_handle_Rule\"\n"
+ + "salience 100\n"
+ + "no-loop true\n"
+ + " when\n"
+ + " $child : VesAlarm(alarmIsCleared == 1, rootFlag == 0)\n"
+ + " then\n"
+ + "\t\tDroolsLog.printInfo(\"===========================================================\");\n"
+ + "\t\tDroolsLog.printInfo(\"child_handle_Rule: childId=\" + $child.getEventId());\n"
+ + "\t\tretract($child);\n"
+ + "end";
+ String filePath = "E:\\项目代码\\ONAP\\holmes\\engine-management\\engine-d-standalone\\src\\main\\assembly\\conf\\engine-d.yml";
new EngineDActiveApp().run(new String[]{"server", filePath});
}
}