X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=rulemgt%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fholmes%2Frulemgt%2FRuleAllocator.java;h=79ffa31ae5ffd80e99bef9d2dd021c4da2667ef3;hb=a796bda2f8e2db093ce9f528f6e5960e4aa1b22c;hp=2dc05ee1a9c7b041d6503fa6a24fa9799f59f190;hpb=348ce6e112876f552a939e58d74376704537344e;p=holmes%2Frule-management.git diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/RuleAllocator.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/RuleAllocator.java index 2dc05ee..79ffa31 100644 --- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/RuleAllocator.java +++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/RuleAllocator.java @@ -1,5 +1,5 @@ /** - * Copyright 2017-2020 ZTE Corporation. + * Copyright 2017-2021 ZTE Corporation. *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,44 +17,45 @@
package org.onap.holmes.rulemgt;
import lombok.extern.slf4j.Slf4j;
-import org.jvnet.hk2.annotations.Service;
import org.onap.holmes.common.api.entity.CorrelationRule;
import org.onap.holmes.common.exception.CorrelationException;
-import org.onap.holmes.common.utils.DbDaoUtil;
import org.onap.holmes.rulemgt.bolt.enginebolt.EngineWrapper;
-import org.onap.holmes.rulemgt.db.CorrelationRuleDao;
+import org.onap.holmes.rulemgt.db.CorrelationRuleService;
import org.onap.holmes.rulemgt.tools.EngineTools;
import org.onap.holmes.rulemgt.wrapper.RuleMgtWrapper;
import org.onap.holmes.rulemgt.wrapper.RuleQueryWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
-import javax.inject.Inject;
import java.util.*;
import static java.util.concurrent.TimeUnit.SECONDS;
@Slf4j
-@Service
+@Component
public class RuleAllocator {
private static final Logger LOGGER = LoggerFactory.getLogger(RuleAllocator.class);
public final static int ENABLE = 1;
+ public final static int RETRY_TIMES = 5;
+ public final static long RETRY_INTERVAL_SEC = 15;
private RuleMgtWrapper ruleMgtWrapper;
private RuleQueryWrapper ruleQueryWrapper;
private EngineWrapper engineWrapper;
private EngineTools engineTools;
- private CorrelationRuleDao correlationRuleDao;
+ private CorrelationRuleService correlationRuleService;
- @Inject
+ @Autowired
public RuleAllocator(RuleMgtWrapper ruleMgtWrapper, RuleQueryWrapper ruleQueryWrapper,
- EngineWrapper engineWrapper, EngineTools engineTools, DbDaoUtil daoUtil) {
+ EngineWrapper engineWrapper, EngineTools engineTools, CorrelationRuleService correlationRuleService) {
this.ruleMgtWrapper = ruleMgtWrapper;
this.ruleQueryWrapper = ruleQueryWrapper;
this.engineWrapper = engineWrapper;
this.engineTools = engineTools;
- correlationRuleDao = daoUtil.getJdbiDaoByOnDemand(CorrelationRuleDao.class);
+ this.correlationRuleService = correlationRuleService;
}
@PostConstruct
@@ -87,15 +88,16 @@ public class RuleAllocator {
return;
}
- if (legacyEngineInstances.size() < numOfEngines) {
- //extend
+ if (legacyEngineInstances.size() < numOfEngines) { // extend
List