diff options
Diffstat (limited to 'feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby')
5 files changed, 36 insertions, 41 deletions
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 8fada968..12c75929 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 @@ -24,27 +24,27 @@ import java.util.Date; public interface DroolsPdp { - public String getPdpId(); + String getPdpId(); - public boolean isDesignated(); + boolean isDesignated(); - public int getPriority(); + int getPriority(); - public Date getUpdatedDate(); + Date getUpdatedDate(); - public void setDesignated(boolean isDesignated); + void setDesignated(boolean isDesignated); - public void setUpdatedDate(Date updatedDate); + void setUpdatedDate(Date updatedDate); - public int comparePriority(DroolsPdp other); + int comparePriority(DroolsPdp other); - public int comparePriority(DroolsPdp other,String previousSite); + int comparePriority(DroolsPdp other, String previousSite); - public String getSite(); + String getSite(); - public void setSite(String site); + void setSite(String site); - public Date getDesignatedDate(); + Date getDesignatedDate(); - public void setDesignatedDate(Date designatedDate); + void setDesignatedDate(Date designatedDate); } diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsConnector.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsConnector.java index fdb87378..6e06272c 100644 --- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsConnector.java +++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsConnector.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. @@ -26,39 +26,39 @@ public interface DroolsPdpsConnector { //return a list of PDPs, NOT including this PDP - public Collection<DroolsPdp> getDroolsPdps(); + Collection<DroolsPdp> getDroolsPdps(); - public void update(DroolsPdp pdp); + void update(DroolsPdp pdp); - //determines if the DroolsPdp parameter is considered "current" or expired + //determines if the DroolsPdp parameter is considered "current" or expired //(has it been too long since the Pdp sent an update) - public boolean isPdpCurrent(DroolsPdp pdp); + boolean isPdpCurrent(DroolsPdp pdp); // Updates DESIGNATED boolean in PDP record. - public void setDesignated(DroolsPdp pdp, boolean designated); + void setDesignated(DroolsPdp pdp, boolean designated); // Marks droolspdpentity.DESIGNATED=false, so another PDP-D will go active. - public void standDownPdp(String pdpId); + void standDownPdp(String pdpId); // This is used in a JUnit test environment to manually // insert a PDP - public void insertPdp(DroolsPdp pdp); + void insertPdp(DroolsPdp pdp); // This is used in a JUnit test environment to manually // delete a PDP - public void deletePdp(String pdpId); + void deletePdp(String pdpId); // This is used in a JUnit test environment to manually // clear the droolspdpentity table. - public void deleteAllPdps(); + void deleteAllPdps(); // This is used in a JUnit test environment to manually // get a PDP - public DroolsPdpEntity getPdp(String pdpId); + DroolsPdpEntity getPdp(String pdpId); // Used by DroolsPdpsElectionHandler to determine if the currently designated // PDP has failed. - public boolean hasDesignatedPdpFailed(Collection<DroolsPdp> pdps); + boolean hasDesignatedPdpFailed(Collection<DroolsPdp> pdps); } 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 5308cbe6..37382e81 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 @@ -49,14 +49,8 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker { */ private static DroolsPdp myPdp; - private DesignationWaiter designationWaiter; - private Timer updateWorker; - private Timer waitTimer; private Date waitTimerLastRunDate; - // The interval between checks of the DesignationWaiter to be sure it is running. - private int pdpCheckInterval; - // The interval between runs of the DesignationWaiter private int pdpUpdateInterval; @@ -100,12 +94,14 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker { this.pdpsConnector = pdps; DroolsPdpsElectionHandler.myPdp = myPdp; this.isDesignated = false; - pdpCheckInterval = 3000; + + // The interval between checks of the DesignationWaiter to be sure it is running. + int pdpCheckInterval = 3000; try { pdpCheckInterval = Integer.parseInt(ActiveStandbyProperties.getProperty( ActiveStandbyProperties.PDP_CHECK_INVERVAL)); } catch (Exception e) { - logger.error("Could not get pdpCheckInterval property. Using default {}",pdpCheckInterval, e); + logger.error("Could not get pdpCheckInterval property. Using default {}", pdpCheckInterval, e); } pdpUpdateInterval = 2000; try { @@ -122,7 +118,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker { // Create the timer which will update the updateDate in DroolsPdpEntity table. // This is the heartbeat - updateWorker = Factory.getInstance().makeTimer(); + Timer updateWorker = Factory.getInstance().makeTimer(); // Schedule the TimerUpdateClass to run at 100 ms and run at pdpCheckInterval ms thereafter // NOTE: The first run of the TimerUpdateClass results in myPdp being added to the @@ -130,12 +126,12 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker { updateWorker.scheduleAtFixedRate(new TimerUpdateClass(), 100, pdpCheckInterval); // Create the timer which will run the election algorithm - waitTimer = Factory.getInstance().makeTimer(); + Timer waitTimer = Factory.getInstance().makeTimer(); // Schedule it to start in startMs ms // (so it will run after the updateWorker and run at pdpUpdateInterval ms thereafter long startMs = getDWaiterStartMs(); - designationWaiter = new DesignationWaiter(); + DesignationWaiter designationWaiter = new DesignationWaiter(); waitTimer.scheduleAtFixedRate(designationWaiter, startMs, pdpUpdateInterval); waitTimerLastRunDate = new Date(nowMs + startMs); 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 735e3a2a..f350bb0a 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 @@ -64,7 +64,6 @@ public class PmStandbyStateChangeNotifier extends StateChangeNotifier { // get an instance of logger private static final Logger logger = LoggerFactory.getLogger(PmStandbyStateChangeNotifier.class); private Timer delayActivateTimer; - private int pdpUpdateInterval; private boolean isWaitingForActivation; private long startTimeWaitingForActivationMs; private long waitInterval; @@ -81,8 +80,8 @@ public class PmStandbyStateChangeNotifier extends StateChangeNotifier { * */ public PmStandbyStateChangeNotifier() { - pdpUpdateInterval = - Integer.parseInt(ActiveStandbyProperties.getProperty(ActiveStandbyProperties.PDP_UPDATE_INTERVAL)); + int pdpUpdateInterval = + Integer.parseInt(ActiveStandbyProperties.getProperty(ActiveStandbyProperties.PDP_UPDATE_INTERVAL)); isWaitingForActivation = false; startTimeWaitingForActivationMs = currentTime.getMillis(); // delay the activate so the DesignatedWaiter can run twice - give it an extra 2 seconds diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ThreadRunningChecker.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ThreadRunningChecker.java index 373c373c..d359b5a6 100644 --- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ThreadRunningChecker.java +++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ThreadRunningChecker.java @@ -22,6 +22,6 @@ package org.onap.policy.drools.activestandby; @FunctionalInterface public interface ThreadRunningChecker { - public void checkThreadStatus(); + void checkThreadStatus(); } |