aboutsummaryrefslogtreecommitdiffstats
path: root/feature-active-standby-management/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-08-05 15:27:16 -0400
committerJim Hahn <jrh3@att.com>2019-08-13 15:58:15 -0400
commita156cf3cbad6512510ae9a02a13c0408f901c734 (patch)
tree0a69bffb2a6c9f961bda1408153cf44f360c6a17 /feature-active-standby-management/src
parent62d1ff054b0ec6348ab6f7415063fdaa3f425215 (diff)
Fix sonar issues in drools-pdp
Address sonar issue, "Move constants to a class or enum", by moving them from interfaces to classes: ActiveStandbyFeatureApi StateManagementFeatureApi PolicyResourceLockFeatureApi PolicySessionFeatureApi DroolsController DroolsControllerFeatureApi PolicyControllerFeatureApi PolicyEngineFeatureApi HealthCheck SystemPersistence EventProtocolCoder PolicyController PolicyEngine TestTransaction MdcTransaction Address sonar issue, "Move constants to a class or enum", by change the interface to a class: DroolsProperties Address sonar issue, "Override the "equals" method in this class", by adding equals & hashCode to: DroolsPdpEntity DroolsPdpImpl Use lombok for a number of getters & setters. Address sonar issue, "Define a constant instead of duplicating this literal" in: DroolsPdpsElectionHandler JpaDroolsPdpsConnector MavenDroolsController GenericEventProtocolCoder GsonProtocolCoderToolset RestManager Address sonar issue, "Remove the parentheses around the parameter" in: MavenDroolsController Address sonar issue, "Replace this lambda with a method reference" in: LifecycleFsm Address sonar issue, "Move this constructor to comply with Java Code Conventions" in: LifecycleStateRunning Address sonar issue, "Replace this 'switch' statement by 'if' statements to increase readability", as specified in: PolicyEngineManager Address sonar issue, "Rename field to prevent any misunderstanding/clash with field" in: MdcTransactionImpl Address sonar issue, "Either log or rethrow this exception", in: RestManager Address sonar issue, "Rename this constant name to" uppercase, by replacing enums with static lists in: RestManager Addressed review comments: Fixed license dates. Renamed getSiteName/setSiteName methods to getSite/setSite in the interface to match the field names in the implementation classes. Renamed *Instance classes to *Constants. Next round of review comments. Change-Id: I1c26af9f194833dd773f2b25dc5f60cde163201c Issue-ID: POLICY-1968 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'feature-active-standby-management/src')
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeature.java8
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdp.java32
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java63
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpImpl.java57
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpObject.java4
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java24
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/JpaDroolsPdpsConnector.java29
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PmStandbyStateChangeNotifier.java5
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java8
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/AllSeemsWellTest.java6
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java36
11 files changed, 98 insertions, 174 deletions
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeature.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeature.java
index 2be44458..d7c153db 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeature.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeature.java
@@ -32,7 +32,9 @@ import javax.persistence.Persistence;
import org.onap.policy.drools.core.PolicySessionFeatureApi;
import org.onap.policy.drools.features.PolicyEngineFeatureApi;
import org.onap.policy.drools.statemanagement.StateManagementFeatureApi;
+import org.onap.policy.drools.statemanagement.StateManagementFeatureApiConstants;
import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.system.PolicyEngineConstants;
import org.onap.policy.drools.utils.PropertyUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -82,7 +84,7 @@ public class ActiveStandbyFeature implements ActiveStandbyFeatureApi,
// This must come first since it initializes myPdp
initializePersistence(configDir);
- for (StateManagementFeatureApi feature : StateManagementFeatureApi.impl.getList()) {
+ for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
if (feature.getResourceName().equals(myPdp.getPdpId())) {
logger.debug("ActiveStandbyFeature.globalInit: Found StateManagementFeature"
+ " with resourceName: {}", myPdp.getPdpId());
@@ -120,7 +122,7 @@ public class ActiveStandbyFeature implements ActiveStandbyFeatureApi,
@Override
public boolean afterStart(PolicyEngine engine) {
// ASSERTION: engine == PolicyEngine.manager
- PolicyEngine.manager.lock();
+ PolicyEngineConstants.getManager().lock();
return false;
}
@@ -169,7 +171,7 @@ public class ActiveStandbyFeature implements ActiveStandbyFeatureApi,
} else {
siteName = siteName.trim();
}
- myPdp.setSiteName(siteName);
+ myPdp.setSite(siteName);
if (electionHandler == null) {
electionHandler = new DroolsPdpsElectionHandler(conn,myPdp);
}
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdp.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdp.java
index 46096bdd..8fada968 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdp.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdp.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* feature-active-standby-management
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,26 +25,26 @@ import java.util.Date;
public interface DroolsPdp {
public String getPdpId();
-
+
public boolean isDesignated();
-
+
public int getPriority();
-
+
public Date getUpdatedDate();
-
+
public void setDesignated(boolean isDesignated);
-
+
public void setUpdatedDate(Date updatedDate);
-
+
public int comparePriority(DroolsPdp other);
-
+
public int comparePriority(DroolsPdp other,String previousSite);
-
- public String getSiteName();
-
- public void setSiteName(String siteName);
-
+
+ public String getSite();
+
+ public void setSite(String site);
+
public Date getDesignatedDate();
-
+
public void setDesignatedDate(Date designatedDate);
}
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java
index 0055b9cb..38ab6e4b 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java
@@ -30,7 +30,8 @@ import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
-
+import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.drools.activestandby.DroolsPdpObject;
@Entity
@@ -40,6 +41,8 @@ import org.onap.policy.drools.activestandby.DroolsPdpObject;
@NamedQuery(name = "DroolsPdpEntity.findAll", query = "SELECT e FROM DroolsPdpEntity e "),
@NamedQuery(name = "DroolsPdpEntity.deleteAll", query = "DELETE FROM DroolsPdpEntity WHERE 1=1")
})
+@Getter
+@Setter
public class DroolsPdpEntity extends DroolsPdpObject implements Serializable {
private static final long serialVersionUID = 1L;
@@ -77,62 +80,12 @@ public class DroolsPdpEntity extends DroolsPdpObject implements Serializable {
}
@Override
- public String getPdpId() {
- return this.pdpId;
- }
-
- public void setPdpId(String pdpId) {
- this.pdpId = pdpId;
- }
-
- @Override
- public boolean isDesignated() {
- return this.designated;
- }
-
- @Override
- public int getPriority() {
- return this.priority;
- }
-
- public void setPriority(int priority) {
- this.priority = priority;
- }
-
- @Override
- public Date getUpdatedDate() {
- return this.updatedDate;
- }
-
- @Override
- public void setDesignated(boolean isDesignated) {
- this.designated = isDesignated;
- }
-
- @Override
- public void setUpdatedDate(Date updatedDate) {
- this.updatedDate = updatedDate;
- }
-
-
- @Override
- public String getSiteName() {
- return site;
- }
-
- @Override
- public void setSiteName(String siteName) {
- site = siteName;
-
- }
-
- @Override
- public Date getDesignatedDate() {
- return designatedDate;
+ public int hashCode() {
+ return super.hashCode();
}
@Override
- public void setDesignatedDate(Date designatedDate) {
- this.designatedDate = designatedDate;
+ public boolean equals(Object obj) {
+ return super.equals(obj);
}
}
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpImpl.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpImpl.java
index 0c50f82d..41d58602 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpImpl.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpImpl.java
@@ -21,7 +21,11 @@
package org.onap.policy.drools.activestandby;
import java.util.Date;
+import lombok.Getter;
+import lombok.Setter;
+@Getter
+@Setter
public class DroolsPdpImpl extends DroolsPdpObject {
private boolean designated;
@@ -48,60 +52,15 @@ public class DroolsPdpImpl extends DroolsPdpObject {
//to the local timezone. So, a value of Date(0) is actually Dec 31 18:00:00 CST 1969
//which is an invalid value for the MySql TimeStamp
this.designatedDate = new Date(864000000);
-
- }
-
- @Override
- public boolean isDesignated() {
-
- return designated;
- }
-
- @Override
- public int getPriority() {
- return priority;
}
@Override
- public void setUpdatedDate(Date date) {
- this.updatedDate = date;
+ public int hashCode() {
+ return super.hashCode();
}
@Override
- public Date getUpdatedDate() {
- return updatedDate;
- }
-
- @Override
- public String getPdpId() {
- return pdpId;
- }
-
- @Override
- public void setDesignated(boolean isDesignated) {
- this.designated = isDesignated;
-
- }
-
- @Override
- public String getSiteName() {
- return site;
- }
-
- @Override
- public void setSiteName(String siteName) {
- this.site = siteName;
-
- }
-
- @Override
- public Date getDesignatedDate() {
- return designatedDate;
- }
-
- @Override
- public void setDesignatedDate(Date designatedDate) {
- this.designatedDate = designatedDate;
-
+ public boolean equals(Object obj) {
+ return super.equals(obj);
}
}
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpObject.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpObject.java
index 75157bbe..f753c0aa 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpObject.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpObject.java
@@ -71,13 +71,13 @@ public abstract class DroolsPdpObject implements DroolsPdp {
}
private int commonCompare(DroolsPdp other) {
- if (nullSafeCompare(this.getSiteName(),other.getSiteName()) == 0) {
+ if (nullSafeCompare(this.getSite(),other.getSite()) == 0) {
if (this.getPriority() != other.getPriority()) {
return this.getPriority() - other.getPriority();
}
return this.getPdpId().compareTo(other.getPdpId());
} else {
- return nullSafeCompare(this.getSiteName(),other.getSiteName());
+ return nullSafeCompare(this.getSite(),other.getSite());
}
}
}
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java
index cd8d369f..33c8a8d8 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java
@@ -29,10 +29,13 @@ import java.util.TimerTask;
import org.onap.policy.common.im.StateManagement;
import org.onap.policy.drools.statemanagement.StateManagementFeatureApi;
+import org.onap.policy.drools.statemanagement.StateManagementFeatureApiConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
+ private static final String RUN_PRIMARY_MSG = "DesignatedWaiter.run mostRecentPrimary = {}";
+
// get an instance of logger
private static final Logger logger = LoggerFactory.getLogger(DroolsPdpsElectionHandler.class);
private DroolsPdpsConnector pdpsConnector;
@@ -135,7 +138,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
//Get the StateManagementFeature instance
- for (StateManagementFeatureApi feature : StateManagementFeatureApi.impl.getList()) {
+ for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
if (feature.getResourceName().equals(myPdp.getPdpId())) {
logger.debug("DroolsPdpsElectionHandler: Found StateManagementFeature"
+ " with resourceName: {}", myPdp.getPdpId());
@@ -625,7 +628,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
}
}
DroolsPdp mostRecentPrimary = new DroolsPdpImpl(null, true, 1, new Date(0));
- mostRecentPrimary.setSiteName(null);
+ mostRecentPrimary.setSite(null);
logger.debug("DesignatedWaiter.run listOfDesignated.size() = {}", listOfDesignated.size());
if (listOfDesignated.size() <= 1) {
logger.debug("DesignatedWainter.run: listOfDesignated.size <=1");
@@ -636,8 +639,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
pdp.getPdpId(), pdp.getDesignatedDate());
if (pdp.getDesignatedDate().compareTo(mostRecentPrimary.getDesignatedDate()) > 0) {
mostRecentPrimary = pdp;
- logger.debug("DesignatedWaiter.run mostRecentPrimary = {}",
- mostRecentPrimary.getPdpId());
+ logger.debug(RUN_PRIMARY_MSG, mostRecentPrimary.getPdpId());
}
}
} else if (listOfDesignated.size() == pdps.size()) {
@@ -652,12 +654,12 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
if (containsDesignated) { //Choose the site of the first designated date
if (pdp.getDesignatedDate().compareTo(mostRecentPrimary.getDesignatedDate()) < 0) {
mostRecentPrimary = pdp;
- logger.debug("DesignatedWaiter.run mostRecentPrimary = {}", mostRecentPrimary.getPdpId());
+ logger.debug(RUN_PRIMARY_MSG, mostRecentPrimary.getPdpId());
}
} else { //Choose the site with the latest designated date
if (pdp.getDesignatedDate().compareTo(mostRecentPrimary.getDesignatedDate()) > 0) {
mostRecentPrimary = pdp;
- logger.debug("DesignatedWaiter.run mostRecentPrimary = {}", mostRecentPrimary.getPdpId());
+ logger.debug(RUN_PRIMARY_MSG, mostRecentPrimary.getPdpId());
}
}
}
@@ -679,7 +681,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
}
if (pdp.getDesignatedDate().compareTo(mostRecentPrimary.getDesignatedDate()) > 0) {
mostRecentPrimary = pdp;
- logger.debug("DesignatedWaiter.run mostRecentPrimary = {}", mostRecentPrimary.getPdpId());
+ logger.debug(RUN_PRIMARY_MSG, mostRecentPrimary.getPdpId());
}
}
} else {
@@ -688,7 +690,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
for (DroolsPdp pdp : pdps) {
if (pdp.getDesignatedDate().compareTo(mostRecentPrimary.getDesignatedDate()) > 0) {
mostRecentPrimary = pdp;
- logger.debug("DesignatedWaiter.run mostRecentPrimary = {}", mostRecentPrimary.getPdpId());
+ logger.debug(RUN_PRIMARY_MSG, mostRecentPrimary.getPdpId());
}
}
}
@@ -714,7 +716,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
DroolsPdp lowestPriorityDifferentSite = null;
for (DroolsPdp pdp : listOfDesignated) {
// We need to determine if another PDP is the lowest priority
- if (nullSafeEquals(pdp.getSiteName(),mostRecentPrimary.getSiteName())) {
+ if (nullSafeEquals(pdp.getSite(),mostRecentPrimary.getSite())) {
if (lowestPrioritySameSite == null) {
if (lowestPriorityDifferentSite != null) {
rejectedPdp = lowestPriorityDifferentSite;
@@ -858,7 +860,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
allSeemsWell = false;
logger.debug("checkWaitTimer: calling allSeemsWell with ALLNOTWELL param");
stateManagementFeature.allSeemsWell(this.getClass().getName(),
- StateManagementFeatureApi.ALLNOTWELL_STATE,
+ StateManagementFeatureApiConstants.ALLNOTWELL_STATE,
"DesignationWaiter/ElectionHandler has STALLED");
}
logger.error("checkWaitTimer: nowMs - waitTimerMs = {}"
@@ -867,7 +869,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
} else if (allSeemsWell == null || !allSeemsWell) {
allSeemsWell = true;
stateManagementFeature.allSeemsWell(this.getClass().getName(),
- StateManagementFeatureApi.ALLSEEMSWELL_STATE,
+ StateManagementFeatureApiConstants.ALLSEEMSWELL_STATE,
"DesignationWaiter/ElectionHandler has RESUMED");
logger.info("DesignationWaiter/ElectionHandler has RESUMED");
}
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/JpaDroolsPdpsConnector.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/JpaDroolsPdpsConnector.java
index 30952af1..078c891f 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/JpaDroolsPdpsConnector.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/JpaDroolsPdpsConnector.java
@@ -36,6 +36,9 @@ import org.slf4j.LoggerFactory;
public class JpaDroolsPdpsConnector implements DroolsPdpsConnector {
+ private static final String SELECT_PDP_BY_ID = "SELECT p FROM DroolsPdpEntity p WHERE p.pdpId=:pdpId";
+ private static final String PDP_ID_PARAM = "pdpId";
+
// get an instance of logger
private static final Logger logger = LoggerFactory.getLogger(JpaDroolsPdpsConnector.class);
private EntityManagerFactory emf;
@@ -102,8 +105,8 @@ public class JpaDroolsPdpsConnector implements DroolsPdpsConnector {
EntityManager em = emf.createEntityManager();
try {
em.getTransaction().begin();
- Query droolsPdpsListQuery = em.createQuery("SELECT p FROM DroolsPdpEntity p WHERE p.pdpId=:pdpId");
- droolsPdpsListQuery.setParameter("pdpId", pdp.getPdpId());
+ Query droolsPdpsListQuery = em.createQuery(SELECT_PDP_BY_ID);
+ droolsPdpsListQuery.setParameter(PDP_ID_PARAM, pdp.getPdpId());
List<?> droolsPdpsList = droolsPdpsListQuery.setLockMode(LockModeType.NONE)
.setFlushMode(FlushModeType.COMMIT).getResultList();
DroolsPdpEntity droolsPdpEntity;
@@ -138,8 +141,8 @@ public class JpaDroolsPdpsConnector implements DroolsPdpsConnector {
if (!droolsPdpEntity.getUpdatedDate().equals(pdp.getUpdatedDate())) {
droolsPdpEntity.setUpdatedDate(pdp.getUpdatedDate());
}
- if (!nullSafeEquals(droolsPdpEntity.getSiteName(),pdp.getSiteName())) {
- droolsPdpEntity.setSiteName(pdp.getSiteName());
+ if (!nullSafeEquals(droolsPdpEntity.getSite(),pdp.getSite())) {
+ droolsPdpEntity.setSite(pdp.getSite());
}
if (droolsPdpEntity.isDesignated() != pdp.isDesignated()) {
@@ -178,8 +181,8 @@ public class JpaDroolsPdpsConnector implements DroolsPdpsConnector {
try {
if (!isCurrent && pdp.isDesignated()) {
em.getTransaction().begin();
- Query droolsPdpsListQuery = em.createQuery("SELECT p FROM DroolsPdpEntity p WHERE p.pdpId=:pdpId");
- droolsPdpsListQuery.setParameter("pdpId", pdp.getPdpId());
+ Query droolsPdpsListQuery = em.createQuery(SELECT_PDP_BY_ID);
+ droolsPdpsListQuery.setParameter(PDP_ID_PARAM, pdp.getPdpId());
List<?> droolsPdpsList = droolsPdpsListQuery.setLockMode(LockModeType.NONE)
.setFlushMode(FlushModeType.COMMIT).getResultList();
if (droolsPdpsList.size() == 1 && droolsPdpsList.get(0) instanceof DroolsPdpEntity) {
@@ -217,8 +220,8 @@ public class JpaDroolsPdpsConnector implements DroolsPdpsConnector {
em = emf.createEntityManager();
em.getTransaction().begin();
Query droolsPdpsListQuery = em
- .createQuery("SELECT p FROM DroolsPdpEntity p WHERE p.pdpId=:pdpId");
- droolsPdpsListQuery.setParameter("pdpId", pdp.getPdpId());
+ .createQuery(SELECT_PDP_BY_ID);
+ droolsPdpsListQuery.setParameter(PDP_ID_PARAM, pdp.getPdpId());
List<?> droolsPdpsList = droolsPdpsListQuery.setLockMode(
LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
if (droolsPdpsList.size() == 1
@@ -271,8 +274,8 @@ public class JpaDroolsPdpsConnector implements DroolsPdpsConnector {
* false.
*/
Query droolsPdpsListQuery = em
- .createQuery("SELECT p FROM DroolsPdpEntity p WHERE p.pdpId=:pdpId");
- droolsPdpsListQuery.setParameter("pdpId", pdpId);
+ .createQuery(SELECT_PDP_BY_ID);
+ droolsPdpsListQuery.setParameter(PDP_ID_PARAM, pdpId);
List<?> droolsPdpsList = droolsPdpsListQuery.setLockMode(
LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
DroolsPdpEntity droolsPdpEntity;
@@ -398,8 +401,8 @@ public class JpaDroolsPdpsConnector implements DroolsPdpsConnector {
em = emf.createEntityManager();
em.getTransaction().begin();
Query droolsPdpsListQuery = em
- .createQuery("SELECT p FROM DroolsPdpEntity p WHERE p.pdpId=:pdpId");
- droolsPdpsListQuery.setParameter("pdpId", pdpId);
+ .createQuery(SELECT_PDP_BY_ID);
+ droolsPdpsListQuery.setParameter(PDP_ID_PARAM, pdpId);
List<?> droolsPdpsList = droolsPdpsListQuery.setLockMode(
LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
if (droolsPdpsList.size() == 1
@@ -454,7 +457,7 @@ public class JpaDroolsPdpsConnector implements DroolsPdpsConnector {
droolsPdpEntity.setDesignated(pdp.isDesignated());
droolsPdpEntity.setPriority(pdp.getPriority());
droolsPdpEntity.setUpdatedDate(pdp.getUpdatedDate());
- droolsPdpEntity.setSiteName(pdp.getSiteName());
+ droolsPdpEntity.setSite(pdp.getSite());
/*
* End transaction.
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PmStandbyStateChangeNotifier.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PmStandbyStateChangeNotifier.java
index bdd9a958..3f4ae557 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PmStandbyStateChangeNotifier.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PmStandbyStateChangeNotifier.java
@@ -46,6 +46,7 @@ import java.util.TimerTask;
import org.onap.policy.common.im.StateChangeNotifier;
import org.onap.policy.common.im.StateManagement;
import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.system.PolicyEngineConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -287,7 +288,7 @@ public class PmStandbyStateChangeNotifier extends StateChangeNotifier {
isWaitingForActivation = false;
isNowActivating = false;
logger.warn("DelayActivateClass.run: caught an unexpected exception "
- + "calling PolicyEngine.manager.activate: ", e);
+ + "calling PolicyEngineConstants.getManager().activate: ", e);
}
}
}
@@ -299,7 +300,7 @@ public class PmStandbyStateChangeNotifier extends StateChangeNotifier {
// these may be overridden by junit tests
protected PolicyEngine getPolicyEngineManager() {
- return PolicyEngine.manager;
+ return PolicyEngineConstants.getManager();
}
protected Timer makeTimer() {
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java
index 842d6c7f..52000fd5 100644
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java
+++ b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java
@@ -87,7 +87,7 @@ public class DroolsPdpObjectTest {
@Test
public void testNullSafeCompare() {
// self, when null
- pdp.setSiteName(null);
+ pdp.setSite(null);
assertEquals(0, pdp.comparePriority(pdp));
// both null
@@ -138,7 +138,7 @@ public class DroolsPdpObjectTest {
};
pdp2.setPdpId(PDP_ID);
- pdp2.setSiteName(SITE2);
+ pdp2.setSite(SITE2);
pdp2.setPriority(PRIORITY);
// should use overridden comparison method
@@ -152,7 +152,7 @@ public class DroolsPdpObjectTest {
private MyPdp makePdp(String id, String site, int priority) {
MyPdp pdp2 = new MyPdp();
- pdp2.setSiteName(site);
+ pdp2.setSite(site);
pdp2.setPdpId(id);
pdp2.setPriority(priority);
@@ -166,7 +166,7 @@ public class DroolsPdpObjectTest {
private boolean designated;
private int priority;
private Date updatedDate;
- private String siteName;
+ private String site;
private Date designatedDate;
}
}
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/AllSeemsWellTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/AllSeemsWellTest.java
index b5b89941..5e9b360f 100644
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/AllSeemsWellTest.java
+++ b/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/AllSeemsWellTest.java
@@ -39,6 +39,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.common.im.StateManagement;
import org.onap.policy.drools.activestandby.ActiveStandbyFeatureApi;
+import org.onap.policy.drools.activestandby.ActiveStandbyFeatureApiConstants;
import org.onap.policy.drools.activestandby.ActiveStandbyProperties;
import org.onap.policy.drools.activestandby.DroolsPdpEntity;
import org.onap.policy.drools.activestandby.DroolsPdpImpl;
@@ -47,6 +48,7 @@ import org.onap.policy.drools.activestandby.DroolsPdpsElectionHandler;
import org.onap.policy.drools.activestandby.JpaDroolsPdpsConnector;
import org.onap.policy.drools.core.PolicySessionFeatureApi;
import org.onap.policy.drools.statemanagement.StateManagementFeatureApi;
+import org.onap.policy.drools.statemanagement.StateManagementFeatureApiConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -235,7 +237,7 @@ public class AllSeemsWellTest {
// discovered by the ActiveStandbyFeature when the election handler initializes.
StateManagementFeatureApi stateManagementFeatureApi = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApi.impl.getList()) {
+ for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
stateManagementFeatureApi = feature;
logger.debug("testAllSeemsWell stateManagementFeature.getResourceName(): {}",
@@ -255,7 +257,7 @@ public class AllSeemsWellTest {
// Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
// that has been created.
ActiveStandbyFeatureApi activeStandbyFeature = null;
- for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApi.impl.getList()) {
+ for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
activeStandbyFeature = feature;
logger.debug("testAllSeemsWell activeStandbyFeature.getResourceName(): {}",
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java
index b277850c..8bc8489a 100644
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java
+++ b/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java
@@ -44,6 +44,7 @@ import org.onap.policy.common.im.IntegrityMonitor;
import org.onap.policy.common.im.StandbyStatusException;
import org.onap.policy.common.im.StateManagement;
import org.onap.policy.drools.activestandby.ActiveStandbyFeatureApi;
+import org.onap.policy.drools.activestandby.ActiveStandbyFeatureApiConstants;
import org.onap.policy.drools.activestandby.ActiveStandbyProperties;
import org.onap.policy.drools.activestandby.DroolsPdp;
import org.onap.policy.drools.activestandby.DroolsPdpEntity;
@@ -54,6 +55,7 @@ import org.onap.policy.drools.activestandby.JpaDroolsPdpsConnector;
import org.onap.policy.drools.activestandby.PmStandbyStateChangeNotifier;
import org.onap.policy.drools.core.PolicySessionFeatureApi;
import org.onap.policy.drools.statemanagement.StateManagementFeatureApi;
+import org.onap.policy.drools.statemanagement.StateManagementFeatureApiConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -352,7 +354,7 @@ public class StandbyStateManagementTest {
// discovered by the ActiveStandbyFeature when the election handler initializes.
StateManagementFeatureApi stateManagementFeature = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApi.impl.getList()) {
+ for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
stateManagementFeature = feature;
logger.debug("testColdStandby stateManagementFeature.getResourceName(): {}",
@@ -471,7 +473,7 @@ public class StandbyStateManagementTest {
// discovered by the ActiveStandbyFeature when the election handler initializes.
StateManagementFeatureApi stateManagementFeature = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApi.impl.getList()) {
+ for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
stateManagementFeature = feature;
logger.debug("testComputeMostRecentPrimary stateManagementFeature.getResourceName(): {}",
@@ -620,21 +622,21 @@ public class StandbyStateManagementTest {
long designatedDateMs = new Date().getTime();
DroolsPdp pdp1 = new DroolsPdpImpl("pdp1", false, 4, new Date());
pdp1.setDesignatedDate(new Date(designatedDateMs - 2));
- pdp1.setSiteName("site1");
+ pdp1.setSite("site1");
DroolsPdp pdp2 = new DroolsPdpImpl("pdp2", false, 4, new Date());
pdp2.setDesignatedDate(new Date(designatedDateMs - 3));
- pdp2.setSiteName("site1");
+ pdp2.setSite("site1");
//oldest
DroolsPdp pdp3 = new DroolsPdpImpl("pdp3", false, 4, new Date());
pdp3.setDesignatedDate(new Date(designatedDateMs - 4));
- pdp3.setSiteName("site2");
+ pdp3.setSite("site2");
DroolsPdp pdp4 = new DroolsPdpImpl("pdp4", false, 4, new Date());
//most recent
pdp4.setDesignatedDate(new Date(designatedDateMs));
- pdp4.setSiteName("site2");
+ pdp4.setSite("site2");
ArrayList<DroolsPdp> listOfAllPdps = new ArrayList<DroolsPdp>();
listOfAllPdps.add(pdp1);
@@ -653,7 +655,7 @@ public class StandbyStateManagementTest {
// discovered by the ActiveStandbyFeature when the election handler initializes.
StateManagementFeatureApi stateManagementFeature = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApi.impl.getList()) {
+ for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
stateManagementFeature = feature;
logger.debug("testComputeDesignatedPdp stateManagementFeature.getResourceName(): {}",
@@ -793,7 +795,7 @@ public class StandbyStateManagementTest {
// discovered by the ActiveStandbyFeature when the election handler initializes.
StateManagementFeatureApi smf = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApi.impl.getList()) {
+ for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
smf = feature;
logger.debug("testColdStandby stateManagementFeature.getResourceName(): {}", smf.getResourceName());
@@ -811,7 +813,7 @@ public class StandbyStateManagementTest {
// Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
// that has been created.
ActiveStandbyFeatureApi activeStandbyFeature = null;
- for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApi.impl.getList()) {
+ for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
activeStandbyFeature = feature;
logger.debug("testColdStandby activeStandbyFeature.getResourceName(): {}",
@@ -924,7 +926,7 @@ public class StandbyStateManagementTest {
// discovered by the ActiveStandbyFeature when the election handler initializes.
StateManagementFeatureApi smf = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApi.impl.getList()) {
+ for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
smf = feature;
logger.debug("testHotStandby1 stateManagementFeature.getResourceName(): {}", smf.getResourceName());
@@ -942,7 +944,7 @@ public class StandbyStateManagementTest {
// Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
// that has been created.
ActiveStandbyFeatureApi activeStandbyFeature = null;
- for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApi.impl.getList()) {
+ for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
activeStandbyFeature = feature;
logger.debug("testHotStandby1 activeStandbyFeature.getResourceName(): {}",
@@ -1081,7 +1083,7 @@ public class StandbyStateManagementTest {
// discovered by the ActiveStandbyFeature when the election handler initializes.
StateManagementFeatureApi sm2 = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApi.impl.getList()) {
+ for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
sm2 = feature;
logger.debug("testHotStandby2 stateManagementFeature.getResourceName(): {}", sm2.getResourceName());
@@ -1099,7 +1101,7 @@ public class StandbyStateManagementTest {
// Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
// that has been created.
ActiveStandbyFeatureApi activeStandbyFeature = null;
- for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApi.impl.getList()) {
+ for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
activeStandbyFeature = feature;
logger.debug("testHotStandby2 activeStandbyFeature.getResourceName(): {}",
@@ -1238,7 +1240,7 @@ public class StandbyStateManagementTest {
// discovered by the ActiveStandbyFeature when the election handler initializes.
StateManagementFeatureApi sm = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApi.impl.getList()) {
+ for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
sm = feature;
logger.debug("testLocking1 stateManagementFeature.getResourceName(): {}", sm.getResourceName());
@@ -1256,7 +1258,7 @@ public class StandbyStateManagementTest {
// Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
// that has been created.
ActiveStandbyFeatureApi activeStandbyFeature = null;
- for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApi.impl.getList()) {
+ for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
activeStandbyFeature = feature;
logger.debug("testLocking1 activeStandbyFeature.getResourceName(): {}",
@@ -1486,7 +1488,7 @@ public class StandbyStateManagementTest {
// discovered by the ActiveStandbyFeature when the election handler initializes.
StateManagementFeatureApi sm = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApi.impl.getList()) {
+ for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
sm = feature;
logger.debug("testLocking2 stateManagementFeature.getResourceName(): {}", sm.getResourceName());
@@ -1504,7 +1506,7 @@ public class StandbyStateManagementTest {
// Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
// that has been created.
ActiveStandbyFeatureApi activeStandbyFeature = null;
- for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApi.impl.getList()) {
+ for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
activeStandbyFeature = feature;
logger.debug("testLocking2 activeStandbyFeature.getResourceName(): {}",