diff options
Diffstat (limited to 'engine-d/src')
7 files changed, 17 insertions, 27 deletions
diff --git a/engine-d/src/main/java/org/openo/holmes/engine/EngineDAppConfig.java b/engine-d/src/main/java/org/openo/holmes/engine/EngineDAppConfig.java index 8b20ac1..23600e8 100644 --- a/engine-d/src/main/java/org/openo/holmes/engine/EngineDAppConfig.java +++ b/engine-d/src/main/java/org/openo/holmes/engine/EngineDAppConfig.java @@ -21,8 +21,10 @@ import io.dropwizard.db.DataSourceFactory; import javax.validation.Valid; import javax.validation.constraints.NotNull; import org.hibernate.validator.constraints.NotEmpty; +import org.jvnet.hk2.annotations.Service; import org.openo.holmes.common.config.MQConfig; +@Service public class EngineDAppConfig extends Configuration { @NotEmpty @@ -31,6 +33,9 @@ public class EngineDAppConfig extends Configuration { @NotEmpty private String apidescription = "Holmes rule management rest API"; + @NotEmpty + private String msbServerAddr; + @JsonProperty @NotNull @Valid @@ -57,6 +62,11 @@ public class EngineDAppConfig extends Configuration { this.database = dataSourceFactory; } + @JsonProperty + public String getMsbServerAddr() { + return msbServerAddr; + } + public String getApidescription() { return apidescription; } diff --git a/engine-d/src/main/java/org/openo/holmes/engine/db/CorrelationRuleDao.java b/engine-d/src/main/java/org/openo/holmes/engine/db/CorrelationRuleDao.java index 4370054..0c00102 100644 --- a/engine-d/src/main/java/org/openo/holmes/engine/db/CorrelationRuleDao.java +++ b/engine-d/src/main/java/org/openo/holmes/engine/db/CorrelationRuleDao.java @@ -27,7 +27,7 @@ import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper; public abstract class CorrelationRuleDao { - @SqlQuery("SELECT * FROM APLUS_RULE WHERE enable=:enable") + @SqlQuery("SELECT * FROM aplus_rule WHERE enable=:enable") public abstract List<CorrelationRule> queryRuleByEnable(@Bind("enable") int enable); public List<CorrelationRule> queryRuleByRuleEnable(int enable) { diff --git a/engine-d/src/main/java/org/openo/holmes/engine/db/mapper/CorrelationRuleMapper.java b/engine-d/src/main/java/org/openo/holmes/engine/db/mapper/CorrelationRuleMapper.java index 6ce0fb6..9c46b58 100644 --- a/engine-d/src/main/java/org/openo/holmes/engine/db/mapper/CorrelationRuleMapper.java +++ b/engine-d/src/main/java/org/openo/holmes/engine/db/mapper/CorrelationRuleMapper.java @@ -39,9 +39,7 @@ public class CorrelationRuleMapper implements ResultSetMapper<CorrelationRule> { correlationRule.setModifier(resultSet.getString("updator")); correlationRule.setUpdateTime(resultSet.getDate("updateTime")); correlationRule.setParams((Properties) resultSet.getObject("params")); - correlationRule.setDomain(resultSet.getString("domain")); correlationRule.setContent(resultSet.getString("content")); - correlationRule.setIsManual(resultSet.getInt("isManual")); correlationRule.setVendor(resultSet.getString("vendor")); correlationRule.setPackageName(resultSet.getString("package")); return correlationRule; diff --git a/engine-d/src/main/java/org/openo/holmes/engine/manager/DroolsEngine.java b/engine-d/src/main/java/org/openo/holmes/engine/manager/DroolsEngine.java index 9b83002..0ed452a 100644 --- a/engine-d/src/main/java/org/openo/holmes/engine/manager/DroolsEngine.java +++ b/engine-d/src/main/java/org/openo/holmes/engine/manager/DroolsEngine.java @@ -134,11 +134,12 @@ public class DroolsEngine { private void initDeployRule() throws CorrelationException { List<CorrelationRule> rules = ruleMgtWrapper.queryRuleByEnable(ENABLE); - if (!rules.isEmpty()) { - for (CorrelationRule rule : rules) { - if (rule.getContent() != null) { - deployRuleFromDB(rule.getContent()); - } + if (rules.isEmpty()) { + return; + } + for (CorrelationRule rule : rules) { + if (rule.getContent() != null) { + deployRuleFromDB(rule.getContent()); } } } diff --git a/engine-d/src/main/java/org/openo/holmes/engine/wrapper/RuleMgtWrapper.java b/engine-d/src/main/java/org/openo/holmes/engine/wrapper/RuleMgtWrapper.java index 7df791d..5a9ce8f 100644 --- a/engine-d/src/main/java/org/openo/holmes/engine/wrapper/RuleMgtWrapper.java +++ b/engine-d/src/main/java/org/openo/holmes/engine/wrapper/RuleMgtWrapper.java @@ -39,9 +39,6 @@ public class RuleMgtWrapper { List<CorrelationRule> ruleTemp = daoUtil.getJdbiDaoByOnDemand(CorrelationRuleDao.class) .queryRuleByRuleEnable(enable); - if (ruleTemp == null) { - throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DB_ERROR); - } return ruleTemp; } } diff --git a/engine-d/src/test/java/org/openo/holmes/engine/db/mapper/CorrelationRuleMapperTest.java b/engine-d/src/test/java/org/openo/holmes/engine/db/mapper/CorrelationRuleMapperTest.java index e5eccf8..6e43f86 100644 --- a/engine-d/src/test/java/org/openo/holmes/engine/db/mapper/CorrelationRuleMapperTest.java +++ b/engine-d/src/test/java/org/openo/holmes/engine/db/mapper/CorrelationRuleMapperTest.java @@ -44,9 +44,7 @@ public class CorrelationRuleMapperTest { expect(resultSet.getString("updator")).andReturn("");
expect(resultSet.getDate("updateTime")).andReturn(new Date(System.currentTimeMillis()));
expect(resultSet.getObject("params")).andReturn(new Properties());
- expect(resultSet.getString("domain")).andReturn("");
expect(resultSet.getString("content")).andReturn("");
- expect(resultSet.getInt("isManual")).andReturn(0);
expect(resultSet.getString("vendor")).andReturn("");
expect(resultSet.getString("package")).andReturn("");
diff --git a/engine-d/src/test/java/org/openo/holmes/engine/wrapper/RuleMgtWrapperTest.java b/engine-d/src/test/java/org/openo/holmes/engine/wrapper/RuleMgtWrapperTest.java index 593b1ce..fab68df 100644 --- a/engine-d/src/test/java/org/openo/holmes/engine/wrapper/RuleMgtWrapperTest.java +++ b/engine-d/src/test/java/org/openo/holmes/engine/wrapper/RuleMgtWrapperTest.java @@ -49,20 +49,6 @@ public class RuleMgtWrapperTest { }
@Test
- public void queryRuleByEnable_ruletemp_is_null() throws CorrelationException {
- int enable = 3;
-
- thrown.expect(CorrelationException.class);
-
- CorrelationRuleDao correlationRuleDao = PowerMock.createMock(CorrelationRuleDao.class);
- expect(daoUtil.getJdbiDaoByOnDemand(anyObject(Class.class))).andReturn(correlationRuleDao);
- expect(correlationRuleDao.queryRuleByRuleEnable(anyInt())).andReturn(null);
- PowerMock.replayAll();
- ruleMgtWrapper.queryRuleByEnable(enable);
- PowerMock.verifyAll();
- }
-
- @Test
public void queryRuleByEnable_normal() throws CorrelationException {
int enable = 3;
|