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;
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());
}
}
}
- 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);
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
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
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