diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2024-08-15 11:11:48 +0100 |
---|---|---|
committer | adheli.tavares <adheli.tavares@est.tech> | 2024-08-15 11:12:43 +0100 |
commit | 70726d076f2eac7a6eb8a46879362f88f3ea88ac (patch) | |
tree | e34dab9a21c6bfb0aafffa7e380496df4e072d8b /controlloop/common | |
parent | 2e39e09b57e1d9484a5e0475653a1b4e7a1ec5b1 (diff) |
PostgreSQL support for Drools
- change hardcoded values to be configurable.
Issue-ID: POLICY-5107
Change-Id: I2176cb136c6a5d9cdf6153730e209418dec7bc3c
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'controlloop/common')
6 files changed, 10 insertions, 27 deletions
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerImpl.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerImpl.java index 16cf527d5..1f6dfdca3 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerImpl.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerImpl.java @@ -3,7 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2023 Nordix Foundation. + * Modifications Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -85,14 +85,14 @@ public class OperationHistoryDataManagerImpl implements OperationHistoryDataMana /** * Number of records that have been inserted into the DB by this data manager - * instance, whether or not they were committed. + * instance, whether they were committed. */ @Getter private long recordsInserted = 0; /** * Number of records that have been updated within the DB by this data manager - * instance, whether or not they were committed. + * instance, whether they were committed. */ @Getter private long recordsUpdated = 0; @@ -317,7 +317,6 @@ public class OperationHistoryDataManagerImpl implements OperationHistoryDataMana props.put("jakarta.persistence.jdbc.url", params.getUrl()); props.put("jakarta.persistence.jdbc.user", params.getUserName()); props.put("jakarta.persistence.jdbc.password", params.getPassword()); - props.put("hibernate.dialect", params.getDbHibernateDialect()); return props; } @@ -337,6 +336,8 @@ public class OperationHistoryDataManagerImpl implements OperationHistoryDataMana // the following may be overridden by junit tests protected EntityManagerFactory makeEntityManagerFactory(String opsHistPu, Properties props) { + logger.info("Starting persistence unit {}", opsHistPu); + logger.info("Properties {}", props); return Persistence.createEntityManagerFactory(opsHistPu, props); } diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerParams.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerParams.java index 054f4b1c1..1ea83761c 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerParams.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerParams.java @@ -3,7 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2023 Nordix Foundation. + * Modifications Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,6 @@ import org.onap.policy.common.parameters.annotations.NotNull; public class OperationHistoryDataManagerParams { public static final String DEFAULT_PU = "OperationsHistoryPU"; public static final String DEFAULT_DRIVER = "org.mariadb.jdbc.Driver"; - public static final String DEFAULT_TYPE = "MariaDB"; @NotBlank private String url; @@ -58,9 +57,6 @@ public class OperationHistoryDataManagerParams { @Builder.Default private String driver = DEFAULT_DRIVER; - @Builder.Default - private String dbType = DEFAULT_TYPE; - /** * Maximum number of records that can be waiting to be inserted into the DB. When the * limit is reached, the oldest records are discarded. @@ -86,12 +82,4 @@ public class OperationHistoryDataManagerParams { public ValidationResult validate(String resultName) { return new BeanValidator().validateTop(resultName, this); } - - /** - * Return the Hibernate dialect for the database type. - * @return the dialect - */ - public Object getDbHibernateDialect() { - return "org.hibernate.dialect." + dbType + "Dialect"; - } } diff --git a/controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml b/controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml index fd0ab088b..9a3e03488 100644 --- a/controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml +++ b/controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml @@ -27,7 +27,7 @@ <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> <class>org.onap.policy.guard.OperationsHistory</class> <properties> - <property name="jakarta.persistence.schema-generation.database.action" value="create"/> + <property name="jakarta.persistence.schema-generation.database.action" value="none"/> <property name="hibernate.show_sql" value="false"/> </properties> </persistence-unit> diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerImplTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerImplTest.java index a9d05bdaf..397c1c5fe 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerImplTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerImplTest.java @@ -387,7 +387,6 @@ class OperationHistoryDataManagerImplTest { private static OperationHistoryDataManagerParamsBuilder makeBuilder() { return OperationHistoryDataManagerParams.builder() .url("jdbc:h2:mem:" + OperationHistoryDataManagerImplTest.class.getSimpleName()) - .dbType("H2") .driver("org.h2.Driver") .userName("sa") .password("") diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerParamsTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerParamsTest.java index f0159aaff..623df93d0 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerParamsTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerParamsTest.java @@ -3,7 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2023 Nordix Foundation. + * Modifications Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,6 @@ class OperationHistoryDataManagerParamsTest { private static final String MY_PASS = "my-pass"; private static final String MY_PU = "my-pu"; private static final String MY_DRIVER = "my-driver"; - private static final String MY_DB_TYPE = "my-db-type"; private static final String MY_URL = "my-url"; private static final String MY_USER = "my-user"; @@ -56,7 +55,6 @@ class OperationHistoryDataManagerParamsTest { assertEquals(MY_PASS, params.getPassword()); assertEquals(OperationHistoryDataManagerParams.DEFAULT_PU, params.getPersistenceUnit()); assertEquals(OperationHistoryDataManagerParams.DEFAULT_DRIVER, params.getDriver()); - assertEquals(OperationHistoryDataManagerParams.DEFAULT_TYPE, params.getDbType()); assertEquals(MY_URL, params.getUrl()); assertEquals(MY_USER, params.getUserName()); @@ -65,9 +63,6 @@ class OperationHistoryDataManagerParamsTest { // use specified driver assertEquals(MY_DRIVER, makeBuilder().driver(MY_DRIVER).build().getDriver()); - - // use specified DB type - assertEquals(MY_DB_TYPE, makeBuilder().dbType(MY_DB_TYPE).build().getDbType()); } @Test @@ -79,7 +74,6 @@ class OperationHistoryDataManagerParamsTest { testValidateField("password", "null", params2 -> params2.setPassword(null)); testValidateField("persistenceUnit", "null", params2 -> params2.setPersistenceUnit(null)); testValidateField("driver", "null", params2 -> params2.setDriver(null)); - testValidateField("dbType", "null", params2 -> params2.setDbType(null)); // check edge cases params.setBatchSize(0); diff --git a/controlloop/common/feature-controlloop-management/src/main/feature/config/event-manager.properties b/controlloop/common/feature-controlloop-management/src/main/feature/config/event-manager.properties index 7124989b5..96d2f9aea 100644 --- a/controlloop/common/feature-controlloop-management/src/main/feature/config/event-manager.properties +++ b/controlloop/common/feature-controlloop-management/src/main/feature/config/event-manager.properties @@ -24,12 +24,13 @@ operation.history.url=${envd:JDBC_URL}operationshistory${envd:JDBC_OPTS} operation.history.userName=${envd:SQL_USER} operation.history.password=${envd:SQL_PASSWORD} +operation.history.driver=${envd:JDBC_DRIVER} # # Actor parameters # # Note: every operation must have at least one entry, otherwise it will not be -# configured and started. Thus some of them have a "placeholder" property. +# configured and started. Thus, some of them have a "placeholder" property. # actor.service.XACML.disabled=${envd:GUARD_DISABLED:false} |