modify control loop name 61/18861/1
authorShiwei Tian <tian.shiwei@zte.com.cn>
Sat, 14 Oct 2017 03:06:27 +0000 (11:06 +0800)
committerShiwei Tian <tian.shiwei@zte.com.cn>
Sat, 14 Oct 2017 03:06:27 +0000 (11:06 +0800)
Issue-ID: HOLMES-67

Change-Id: Ifa7f463855d598350c81c2aa82cce254dccba213
Signed-off-by: Shiwei Tian <tian.shiwei@zte.com.cn>
rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/CorrelationDeployRule4Engine.java
rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/DcaeConfigurationPolling.java
rulemgt/src/main/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapper.java

index 7c94395..b38ea47 100644 (file)
@@ -22,10 +22,13 @@ import lombok.Setter;
 @Getter\r
 @Setter\r
 public class CorrelationDeployRule4Engine {\r
+\r
     @JsonProperty(value = "content")\r
     private String content;\r
 \r
     @JsonProperty(value = "engineid")\r
     private String engineId;\r
 \r
+    @JsonProperty(value = "loopcontrolname")\r
+    private String loopControlName;\r
 }\r
index 1cc31d8..c9fdb70 100644 (file)
@@ -24,6 +24,7 @@ import javax.ws.rs.core.MediaType;
 import lombok.extern.slf4j.Slf4j;
 import org.glassfish.jersey.client.ClientConfig;
 import org.onap.holmes.common.config.MicroServiceConfig;
+import org.onap.holmes.common.dcae.DcaeConfigurationQuery;
 import org.onap.holmes.common.dcae.entity.DcaeConfigurations;
 import org.onap.holmes.common.dcae.entity.Rule;
 import org.onap.holmes.common.dcae.utils.DcaeConfigurationParser;
@@ -49,7 +50,7 @@ public class DcaeConfigurationPolling implements Runnable {
     public void run() {
         DcaeConfigurations dcaeConfigurations = null;
         try {
-            dcaeConfigurations = getDcaeConfigurations();
+            dcaeConfigurations = DcaeConfigurationQuery.getDcaeConfigurations(hostname);
         } catch (CorrelationException e) {
             log.error("Failed to fetch DCAE configurations" + e.getMessage());
         }
@@ -65,21 +66,6 @@ public class DcaeConfigurationPolling implements Runnable {
         }
     }
 
-    private DcaeConfigurations getDcaeConfigurations() throws CorrelationException {
-        String serviceAddrInfo = MicroServiceConfig.getServiceAddrInfoFromCBS(hostname);
-        String response = getDcaeResponse(serviceAddrInfo);
-        DcaeConfigurations dcaeConfigurations = null;
-        dcaeConfigurations = DcaeConfigurationParser.parse(response);
-        return dcaeConfigurations;
-    }
-
-    private String getDcaeResponse(String serviceAddrInfo) {
-        Client client = ClientBuilder.newClient(new ClientConfig());
-        WebTarget webTarget = client.target(serviceAddrInfo);
-        return webTarget.request("application/json").get()
-                .readEntity(String.class);
-    }
-
     private RuleQueryListResponse getAllCorrelationRules() {
         Client client = ClientBuilder.newClient(new ClientConfig());
         WebTarget webTarget = client.target(url);
index 5c2a428..c1f1917 100644 (file)
@@ -73,9 +73,7 @@ public class RuleMgtWrapper {
         if (ruleTemp != null) {\r
             throw new CorrelationException("A rule with the same name already exists.");\r
         }\r
-        \r
-        String packageName = deployRule2Engine(correlationRule);\r
-        DmaapService.loopControlNames.put(packageName, ruleCreateRequest.getLoopControlName());\r
+        String packageName = deployRule2Engine(correlationRule, ruleCreateRequest.getLoopControlName());\r
         correlationRule.setPackageName(packageName);\r
         CorrelationRule result = null;\r
         try {\r
@@ -206,6 +204,15 @@ public class RuleMgtWrapper {
         return "";\r
     }\r
 \r
+    private String deployRule2Engine(CorrelationRule correlationRule, String loopControlName)\r
+            throws CorrelationException {\r
+        if (engineWarpper.checkRuleFromEngine(correlationRules2CheckRule(correlationRule)) && (\r
+                correlationRule.getEnabled() == RuleMgtConstant.STATUS_RULE_OPEN)) {\r
+            return engineWarpper.deployEngine(correlationRules2DeployRule(correlationRule, loopControlName));\r
+        }\r
+        return "";\r
+    }\r
+\r
     public RuleQueryListResponse getCorrelationRuleByCondition(\r
             RuleQueryCondition ruleQueryCondition) throws CorrelationException {\r
         List<CorrelationRule> correlationRule = correlationRuleQueryDao\r
@@ -245,6 +252,15 @@ public class RuleMgtWrapper {
         return correlationDeployRule4Engine;\r
     }\r
 \r
+    private CorrelationDeployRule4Engine correlationRules2DeployRule(\r
+            CorrelationRule correlationRule, String loopControlName) {\r
+        CorrelationDeployRule4Engine correlationDeployRule4Engine = new CorrelationDeployRule4Engine();\r
+        correlationDeployRule4Engine.setContent(correlationRule.getContent());\r
+        correlationDeployRule4Engine.setEngineId(correlationRule.getEngineID());\r
+        correlationDeployRule4Engine.setLoopControlName(loopControlName);\r
+        return correlationDeployRule4Engine;\r
+    }\r
+\r
     private CorrelationCheckRule4Engine correlationRules2CheckRule(\r
             CorrelationRule correlationRule) {\r
         CorrelationCheckRule4Engine correlationCheckRule4Engine = new CorrelationCheckRule4Engine();\r