summaryrefslogtreecommitdiffstats
path: root/feature-active-standby-management/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-06-19 14:32:10 -0400
committerJim Hahn <jrh3@att.com>2020-06-19 15:44:28 -0400
commit56a15039437ba5bf5d0fb422551bfb12e1f59eb1 (patch)
tree1fc57df4d9462790d4c4dd811425ab029d8ec710 /feature-active-standby-management/src
parent1d810e0be1188c07ec9292b348c9d286f36963d9 (diff)
Address checkstyle version issues in drools-pdp
Also added serializationId to several classes to address eclipse warnings. Issue-ID: POLICY-2188 Change-Id: I3df5e8abaad8da9261c0d5cd19a93ed68dceb870 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.java4
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java2
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpObject.java6
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java20
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/JpaDroolsPdpsConnector.java11
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java2
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java11
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java16
8 files changed, 34 insertions, 38 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 2b75ea5e..7e853990 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
@@ -159,7 +159,7 @@ public class ActiveStandbyFeature implements ActiveStandbyFeatureApi,
synchronized (myPdpSync) {
if (myPdp == null) {
- myPdp = new DroolsPdpImpl(resourceName,false,4,MonitorTime.getInstance().getDate());
+ myPdp = new DroolsPdpImpl(resourceName, false, 4, MonitorTime.getInstance().getDate());
}
String siteName = ActiveStandbyProperties.getProperty(ActiveStandbyProperties.SITE_NAME);
if (siteName == null) {
@@ -169,7 +169,7 @@ public class ActiveStandbyFeature implements ActiveStandbyFeatureApi,
}
myPdp.setSite(siteName);
if (electionHandler == null) {
- electionHandler = new DroolsPdpsElectionHandler(conn,myPdp);
+ electionHandler = new DroolsPdpsElectionHandler(conn, myPdp);
}
}
logger.info("\n\nThis controller is a standby, waiting to be chosen as primary...\n\n");
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 078b0477..29f66e90 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
@@ -58,7 +58,7 @@ public class DroolsPdpEntity extends DroolsPdpObject implements Serializable {
private Date updatedDate;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name = "designatedDate",nullable = false)
+ @Column(name = "designatedDate", nullable = false)
private Date designatedDate;
@Column(name = "site", nullable = true, length = 50)
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 f753c0aa..fd25a6d3 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
@@ -26,7 +26,7 @@ public abstract class DroolsPdpObject implements DroolsPdp {
@Override
public boolean equals(Object other) {
if (other instanceof DroolsPdp) {
- return this.getPdpId().equals(((DroolsPdp)other).getPdpId());
+ return this.getPdpId().equals(((DroolsPdp) other).getPdpId());
} else {
return false;
}
@@ -71,13 +71,13 @@ public abstract class DroolsPdpObject implements DroolsPdp {
}
private int commonCompare(DroolsPdp other) {
- if (nullSafeCompare(this.getSite(),other.getSite()) == 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.getSite(),other.getSite());
+ 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 f51e0718..acb7cd54 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
@@ -364,7 +364,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
logger.debug("INFO: DesignatedWaiter.run: PDP= {} "
+ "designated= {}, current= {}, "
+ "designatedPdpHasFailed= {}, "
- + "standbyStatus= {}",pdp.getPdpId(),
+ + "standbyStatus= {}", pdp.getPdpId(),
pdp.isDesignated(), false, designatedPdpHasFailed, standbyStatus);
pdpNotDesignatedNotCurrent(pdp, standbyStatus);
}
@@ -452,7 +452,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
} else { //it is a remote PDP that is failed
logger.debug("\n\nDesignatedWaiter.run: PDP {} is not Current. "
+ " Executing stateManagement.disableFailed(otherResourceName)\n\n",
- pdp.getPdpId() );
+ pdp.getPdpId());
// We found a PDP is designated but not current
// We already called standdown(pdp) which will change designated to false
// Now we need to disableFail it to get its states in synch. The standbyStatus
@@ -561,7 +561,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
private void designateNoPdp() {
// Just to be sure the parameters are correctly set
myPdp.setDesignated(false);
- pdpsConnector.setDesignated(myPdp,false);
+ pdpsConnector.setDesignated(myPdp, false);
isDesignated = false;
waitTimerLastRunDate = currentTime.getDate();
@@ -597,7 +597,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
logger.error("ERROR: DesignatedWaiter.run: Caught Exception attempting to promote PDP={}"
+ ", message=", myPdp.getPdpId(), e);
myPdp.setDesignated(false);
- pdpsConnector.setDesignated(myPdp,false);
+ pdpsConnector.setDesignated(myPdp, false);
isDesignated = false;
//If you can't promote it, demote it
try {
@@ -639,7 +639,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
List<DroolsPdp> listForRemoval = new ArrayList<>();
for (DroolsPdp pdp : listOfDesignated) {
logger.debug("DesignatedWaiter.run sanitizing: pdp = {}"
- + " isDesignated = {}",pdp.getPdpId(), pdp.isDesignated());
+ + " isDesignated = {}", pdp.getPdpId(), pdp.isDesignated());
if (pdp.isDesignated()) {
containsDesignated = true;
} else {
@@ -783,7 +783,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
}
// If the rejectedPdp is myPdp, we need to stand it down and demote it. Each pdp is responsible
// for demoting itself
- if (rejectedPdp != null && nullSafeEquals(rejectedPdp.getPdpId(),myPdp.getPdpId())) {
+ if (rejectedPdp != null && nullSafeEquals(rejectedPdp.getPdpId(), myPdp.getPdpId())) {
logger.debug("\n\nDesignatedWaiter.run: myPdp: {} listOfDesignated myPdp ID: {}"
+ " is NOT the lowest priority. Executing stateManagement.demote()\n\n",
myPdp.getPdpId(),
@@ -821,11 +821,11 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
return null;
} else {
if (pdp.getPdpId().equals((lowestPrioritySameSite.getPdpId()))) {
- return null;//nothing to compare
+ return null; //nothing to compare
}
if (pdp.comparePriority(lowestPrioritySameSite) < 0) {
logger.debug("\nDesignatedWaiter.run: myPdp {} listOfDesignated pdp ID: {}"
- + " has lower priority than pdp ID: {}",myPdp.getPdpId(), pdp.getPdpId(),
+ + " has lower priority than pdp ID: {}", myPdp.getPdpId(), pdp.getPdpId(),
lowestPrioritySameSite.getPdpId());
//we need to reject lowestPrioritySameSite
DroolsPdp rejectedPdp = lowestPrioritySameSite;
@@ -834,7 +834,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
} else {
//we need to reject pdp and keep lowestPrioritySameSite
logger.debug("\nDesignatedWaiter.run: myPdp {} listOfDesignated pdp ID: {} "
- + " has higher priority than pdp ID: {}", myPdp.getPdpId(),pdp.getPdpId(),
+ + " has higher priority than pdp ID: {}", myPdp.getPdpId(), pdp.getPdpId(),
lowestPrioritySameSite.getPdpId());
return pdp;
}
@@ -851,7 +851,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
return null;
}
if (pdp.getPdpId().equals((lowestPriorityDifferentSite.getPdpId()))) {
- return null;//nothing to compare
+ return null; //nothing to compare
}
if (pdp.comparePriority(lowestPriorityDifferentSite) < 0) {
logger.debug("\nDesignatedWaiter.run: myPdp {} listOfDesignated pdp ID: {}"
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 6e456962..14ae52a0 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
@@ -24,7 +24,6 @@ import java.util.Collection;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
-
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.FlushModeType;
@@ -68,7 +67,7 @@ public class JpaDroolsPdpsConnector implements DroolsPdpsConnector {
continue;
}
//Make sure it is not a cached version
- DroolsPdp droolsPdp = (DroolsPdp)o;
+ DroolsPdp droolsPdp = (DroolsPdp) o;
em.refresh(droolsPdp);
droolsPdpsReturnList.add(droolsPdp);
if (logger.isDebugEnabled()) {
@@ -115,7 +114,7 @@ public class JpaDroolsPdpsConnector implements DroolsPdpsConnector {
.setFlushMode(FlushModeType.COMMIT).getResultList();
DroolsPdpEntity droolsPdpEntity;
if (droolsPdpsList.size() == 1 && (droolsPdpsList.get(0) instanceof DroolsPdpEntity)) {
- droolsPdpEntity = (DroolsPdpEntity)droolsPdpsList.get(0);
+ droolsPdpEntity = (DroolsPdpEntity) droolsPdpsList.get(0);
em.refresh(droolsPdpEntity); //Make sure we have current values
Date currentDate = currentTime.getDate();
long difference = currentDate.getTime() - droolsPdpEntity.getUpdatedDate().getTime();
@@ -145,7 +144,7 @@ public class JpaDroolsPdpsConnector implements DroolsPdpsConnector {
if (!droolsPdpEntity.getUpdatedDate().equals(pdp.getUpdatedDate())) {
droolsPdpEntity.setUpdatedDate(pdp.getUpdatedDate());
}
- if (!nullSafeEquals(droolsPdpEntity.getSite(),pdp.getSite())) {
+ if (!nullSafeEquals(droolsPdpEntity.getSite(), pdp.getSite())) {
droolsPdpEntity.setSite(pdp.getSite());
}
@@ -192,7 +191,7 @@ public class JpaDroolsPdpsConnector implements DroolsPdpsConnector {
if (droolsPdpsList.size() == 1 && droolsPdpsList.get(0) instanceof DroolsPdpEntity) {
logger.debug("isPdpCurrent: PDP={} designated but not current; setting designated to false",
pdp.getPdpId());
- DroolsPdpEntity droolsPdpEntity = (DroolsPdpEntity)droolsPdpsList.get(0);
+ DroolsPdpEntity droolsPdpEntity = (DroolsPdpEntity) droolsPdpsList.get(0);
droolsPdpEntity.setDesignated(false);
em.getTransaction().commit();
} else {
@@ -292,7 +291,7 @@ public class JpaDroolsPdpsConnector implements DroolsPdpsConnector {
droolsPdpEntity = (DroolsPdpEntity) droolsPdpsList.get(0);
droolsPdpEntity.setDesignated(false);
em.persist(droolsPdpEntity);
- logger.debug("standDownPdp: PDP={} persisted as non-designated.", pdpId );
+ logger.debug("standDownPdp: PDP={} persisted as non-designated.", pdpId);
} else {
logger.error("standDownPdp: Missing record in droolspdpentity for pdpId={}"
+ "; cannot stand down PDP", pdpId);
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java
index 9457ce18..0ce12dfc 100644
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java
+++ b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java
@@ -119,7 +119,7 @@ public class AllSeemsWellTest {
String userDir = System.getProperty("user.dir");
logger.debug("setUpClass: userDir={}", userDir);
System.setProperty("com.sun.management.jmxremote.port", "9980");
- System.setProperty("com.sun.management.jmxremote.authenticate","false");
+ System.setProperty("com.sun.management.jmxremote.authenticate", "false");
DroolsPdpsElectionHandler.setIsUnitTesting(true);
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 3f4a31b2..78902ec7 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
@@ -21,7 +21,6 @@
package org.onap.policy.drools.activestandby;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import java.util.Date;
@@ -29,8 +28,6 @@ import lombok.Getter;
import lombok.Setter;
import org.junit.Before;
import org.junit.Test;
-import org.onap.policy.drools.activestandby.DroolsPdp;
-import org.onap.policy.drools.activestandby.DroolsPdpObject;
public class DroolsPdpObjectTest {
private static final String PDP_ID = "my-id";
@@ -50,19 +47,19 @@ public class DroolsPdpObjectTest {
@Test
public void testEqualsObject() {
// self
- assertEquals(pdp,pdp);
+ assertEquals(pdp, pdp);
// same id
MyPdp pdp2 = new MyPdp();
pdp2.setPdpId(PDP_ID);
- assertEquals(pdp,pdp2);
+ assertEquals(pdp, pdp2);
// different id
pdp2.setPdpId(PDP_ID2);
- assertNotEquals(pdp,pdp2);
+ assertNotEquals(pdp, pdp2);
// different type of object
- assertNotEquals(pdp,"");
+ assertNotEquals(pdp, "");
}
@Test
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java
index 866ad5ef..52f8b27a 100644
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java
+++ b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java
@@ -127,7 +127,7 @@ public class StandbyStateManagementTest {
String userDir = System.getProperty("user.dir");
logger.debug("setUpClass: userDir={}", userDir);
System.setProperty("com.sun.management.jmxremote.port", "9980");
- System.setProperty("com.sun.management.jmxremote.authenticate","false");
+ System.setProperty("com.sun.management.jmxremote.authenticate", "false");
saveTime = Whitebox.getInternalState(MonitorTime.class, MONITOR_FIELD_NAME);
saveFactory = Factory.getInstance();
@@ -359,7 +359,7 @@ public class StandbyStateManagementTest {
listOfDesignated = droolsPdpsElectionHandler.santizeDesignatedList(listOfDesignated);
- logger.debug("\n\ntestSanitizeDesignatedList: listOfDesignated.size = {}\n\n",listOfDesignated.size());
+ logger.debug("\n\ntestSanitizeDesignatedList: listOfDesignated.size = {}\n\n", listOfDesignated.size());
assertEquals(4, listOfDesignated.size());
@@ -901,7 +901,7 @@ public class StandbyStateManagementTest {
sm.deleteAllStateManagementEntities();
- sm = new StateManagement(emfx, activePdpId);//pdp2
+ sm = new StateManagement(emfx, activePdpId); //pdp2
// Artificially putting a PDP into service is really a two step process, 1)
// inserting it as designated and 2) promoting it so that its standbyStatus
@@ -955,16 +955,16 @@ public class StandbyStateManagementTest {
//At this point, the newly created pdp will have set the state to disabled/failed/cold standby
//because it is stale. So, it cannot be promoted. We need to call sm.enableNotFailed() so we
//can promote it and demote the other pdp - else the other pdp will just spring back to providingservice
- sm.enableNotFailed();//pdp2
+ sm.enableNotFailed(); //pdp2
sm.promote();
String standbyStatus = sm.getStandbyStatus(activePdpId);
logger.info("testHotStandby2: After promoting, PDP= {} has standbyStatus= {}", activePdpId, standbyStatus);
// demoting PDP should ensure that state transits to hotstandby
logger.info("testHotStandby2: Runner started; demoting PDP= {}", thisPdpId);
- sm2.demote();//pdp1
+ sm2.demote(); //pdp1
standbyStatus = sm.getStandbyStatus(thisPdpId);
- logger.info("testHotStandby2: After demoting, PDP={} has standbyStatus= {}",thisPdpId , standbyStatus);
+ logger.info("testHotStandby2: After demoting, PDP={} has standbyStatus= {}", thisPdpId, standbyStatus);
logger.info("testHotStandby2: Sleeping {} ms, to allow JpaDroolsPdpsConnector "
+ "time to check droolspdpentity table", SLEEP_TIME);
@@ -1079,7 +1079,7 @@ public class StandbyStateManagementTest {
sleep(SLEEP_TIME);
logger.debug("testLocking1: Waking up and invoking startTransaction on active PDP={}"
- + ", designated= {}",thisPdpId, conn.getPdp(thisPdpId).isDesignated());
+ + ", designated= {}", thisPdpId, conn.getPdp(thisPdpId).isDesignated());
IntegrityMonitor droolsPdpIntegrityMonitor = IntegrityMonitor.getInstance();
@@ -1133,7 +1133,7 @@ public class StandbyStateManagementTest {
sleep(100);
logger.debug("testLocking1: Invoking startTransaction on locked PDP= {}"
- + ", designated= {}",thisPdpId, conn.getPdp(thisPdpId).isDesignated());
+ + ", designated= {}", thisPdpId, conn.getPdp(thisPdpId).isDesignated());
try {
droolsPdpIntegrityMonitor.startTransaction();
logger.error("testLocking1: startTransaction unexpectedly successful");