summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShiwei Tian <tian.shiwei@zte.com.cn>2017-10-14 11:06:27 +0800
committerShiwei Tian <tian.shiwei@zte.com.cn>2017-10-14 11:06:27 +0800
commit049c1722681a7c0d564d625f2740cbc47c15a4be (patch)
tree505dee221b1fb2236cec3e9f754b7bc59c48b2cb
parent646a660b1a7828013006619b4f7ec2d2f2f02f36 (diff)
modify control loop name
Issue-ID: HOLMES-67 Change-Id: Ifa7f463855d598350c81c2aa82cce254dccba213 Signed-off-by: Shiwei Tian <tian.shiwei@zte.com.cn>
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/CorrelationDeployRule4Engine.java3
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/DcaeConfigurationPolling.java18
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapper.java22
3 files changed, 24 insertions, 19 deletions
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/CorrelationDeployRule4Engine.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/CorrelationDeployRule4Engine.java
index 7c94395..b38ea47 100644
--- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/CorrelationDeployRule4Engine.java
+++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/CorrelationDeployRule4Engine.java
@@ -22,10 +22,13 @@ import lombok.Setter;
@Getter
@Setter
public class CorrelationDeployRule4Engine {
+
@JsonProperty(value = "content")
private String content;
@JsonProperty(value = "engineid")
private String engineId;
+ @JsonProperty(value = "loopcontrolname")
+ private String loopControlName;
}
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/DcaeConfigurationPolling.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/DcaeConfigurationPolling.java
index 1cc31d8..c9fdb70 100644
--- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/DcaeConfigurationPolling.java
+++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/DcaeConfigurationPolling.java
@@ -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);
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapper.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapper.java
index 5c2a428..c1f1917 100644
--- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapper.java
+++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapper.java
@@ -73,9 +73,7 @@ public class RuleMgtWrapper {
if (ruleTemp != null) {
throw new CorrelationException("A rule with the same name already exists.");
}
-
- String packageName = deployRule2Engine(correlationRule);
- DmaapService.loopControlNames.put(packageName, ruleCreateRequest.getLoopControlName());
+ String packageName = deployRule2Engine(correlationRule, ruleCreateRequest.getLoopControlName());
correlationRule.setPackageName(packageName);
CorrelationRule result = null;
try {
@@ -206,6 +204,15 @@ public class RuleMgtWrapper {
return "";
}
+ private String deployRule2Engine(CorrelationRule correlationRule, String loopControlName)
+ throws CorrelationException {
+ if (engineWarpper.checkRuleFromEngine(correlationRules2CheckRule(correlationRule)) && (
+ correlationRule.getEnabled() == RuleMgtConstant.STATUS_RULE_OPEN)) {
+ return engineWarpper.deployEngine(correlationRules2DeployRule(correlationRule, loopControlName));
+ }
+ return "";
+ }
+
public RuleQueryListResponse getCorrelationRuleByCondition(
RuleQueryCondition ruleQueryCondition) throws CorrelationException {
List<CorrelationRule> correlationRule = correlationRuleQueryDao
@@ -245,6 +252,15 @@ public class RuleMgtWrapper {
return correlationDeployRule4Engine;
}
+ private CorrelationDeployRule4Engine correlationRules2DeployRule(
+ CorrelationRule correlationRule, String loopControlName) {
+ CorrelationDeployRule4Engine correlationDeployRule4Engine = new CorrelationDeployRule4Engine();
+ correlationDeployRule4Engine.setContent(correlationRule.getContent());
+ correlationDeployRule4Engine.setEngineId(correlationRule.getEngineID());
+ correlationDeployRule4Engine.setLoopControlName(loopControlName);
+ return correlationDeployRule4Engine;
+ }
+
private CorrelationCheckRule4Engine correlationRules2CheckRule(
CorrelationRule correlationRule) {
CorrelationCheckRule4Engine correlationCheckRule4Engine = new CorrelationCheckRule4Engine();