summaryrefslogtreecommitdiffstats
path: root/integrity-monitor/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'integrity-monitor/src/main')
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/AdministrativeStateException.java29
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/AllSeemsWellException.java33
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/ForwardProgressException.java29
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java3814
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorException.java44
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java72
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorPropertiesException.java29
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/StandbyStatusException.java53
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/StateChangeNotifier.java74
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/StateElement.java250
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java1835
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransition.java1620
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransitionException.java29
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdmin.java370
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdminException.java26
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdminMBean.java41
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/JmxAgentConnection.java171
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ForwardProgressEntity.java184
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ImTestEntity.java217
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ResourceRegistrationEntity.java226
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/StateManagementEntity.java215
21 files changed, 4807 insertions, 4554 deletions
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/AdministrativeStateException.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/AdministrativeStateException.java
index 600d8601..14e0f0a8 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/AdministrativeStateException.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/AdministrativeStateException.java
@@ -21,18 +21,21 @@
package org.onap.policy.common.im;
public class AdministrativeStateException extends IntegrityMonitorException {
- private static final long serialVersionUID = 1L;
- public AdministrativeStateException() {
- super();
- }
- public AdministrativeStateException(String message) {
- super(message);
- }
+ private static final long serialVersionUID = 1L;
- public AdministrativeStateException(Throwable cause) {
- super(cause);
- }
- public AdministrativeStateException(String message, Throwable cause) {
- super(message, cause);
- }
+ public AdministrativeStateException() {
+ super();
+ }
+
+ public AdministrativeStateException(String message) {
+ super(message);
+ }
+
+ public AdministrativeStateException(Throwable cause) {
+ super(cause);
+ }
+
+ public AdministrativeStateException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/AllSeemsWellException.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/AllSeemsWellException.java
index 588a4d61..1583a9d5 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/AllSeemsWellException.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/AllSeemsWellException.java
@@ -21,25 +21,22 @@
package org.onap.policy.common.im;
public class AllSeemsWellException extends IntegrityMonitorException {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- public AllSeemsWellException(){
- super();
- }
+ private static final long serialVersionUID = 1L;
- public AllSeemsWellException(String msg) {
- super(msg);
- }
-
- public AllSeemsWellException(String msg, Exception cause) {
- super(msg, cause);
- }
+ public AllSeemsWellException() {
+ super();
+ }
- public AllSeemsWellException(Exception cause) {
- super(cause);
- }
+ public AllSeemsWellException(String msg) {
+ super(msg);
+ }
+
+ public AllSeemsWellException(String msg, Exception cause) {
+ super(msg, cause);
+ }
+
+ public AllSeemsWellException(Exception cause) {
+ super(cause);
+ }
}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/ForwardProgressException.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/ForwardProgressException.java
index 5825c3a0..a72fe9e2 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/ForwardProgressException.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/ForwardProgressException.java
@@ -21,18 +21,21 @@
package org.onap.policy.common.im;
public class ForwardProgressException extends IntegrityMonitorException {
- private static final long serialVersionUID = 1L;
- public ForwardProgressException() {
- super();
- }
- public ForwardProgressException(String message) {
- super(message);
- }
+ private static final long serialVersionUID = 1L;
- public ForwardProgressException(Throwable cause) {
- super(cause);
- }
- public ForwardProgressException(String message, Throwable cause) {
- super(message, cause);
- }
+ public ForwardProgressException() {
+ super();
+ }
+
+ public ForwardProgressException(String message) {
+ super(message);
+ }
+
+ public ForwardProgressException(Throwable cause) {
+ super(cause);
+ }
+
+ public ForwardProgressException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java
index 880d39f5..c32a2213 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java
@@ -54,1917 +54,1919 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * IntegrityMonitor Main class for monitoring the integrity of a resource and
- * managing its state. State management follows the X.731 ITU standard.
+ * IntegrityMonitor Main class for monitoring the integrity of a resource and managing its state.
+ * State management follows the X.731 ITU standard.
*/
public class IntegrityMonitor {
- private static final Logger logger = LoggerFactory.getLogger(IntegrityMonitor.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(IntegrityMonitor.class.getName());
- // only allow one instance of IntegrityMonitor
- private static IntegrityMonitor instance = null;
+ // only allow one instance of IntegrityMonitor
+ private static IntegrityMonitor instance = null;
- private static String resourceName = null;
- boolean alarmExists = false;
+ private static String resourceName = null;
+ boolean alarmExists = false;
- /*
- * Error message that is written by the dependencyCheck() method. It is made
- * available externally through the evaluateSanity() method.
- */
- private String dependencyCheckErrorMsg = "";
+ /*
+ * Error message that is written by the dependencyCheck() method. It is made available
+ * externally through the evaluateSanity() method.
+ */
+ private String dependencyCheckErrorMsg = "";
- // The entity manager factory for JPA access
- private EntityManagerFactory emf;
- private EntityManager em;
+ // The entity manager factory for JPA access
+ private EntityManagerFactory emf;
+ private EntityManager em;
- // Persistence Unit for JPA
- public static final String PERSISTENCE_UNIT = "operationalPU";
-
- private static String persistenceUnit = PERSISTENCE_UNIT;
-
- private static final long CYCLE_INTERVAL_MILLIS = 1000l;
-
- private static long cycleIntervalMillis = CYCLE_INTERVAL_MILLIS;
-
- /**
- * Units used for intervals extracted from the properties, which are
- * typically given in seconds.
- */
- private static TimeUnit propertyUnits = TimeUnit.SECONDS;
-
- private StateManagement stateManager = null;
-
- private FPManager fpManager = null;
-
- // The forward progress counter is incremented as the
- // process being monitored makes forward progress
- private int fpCounter = 0;
- private int lastFpCounter = 0;
-
- // elapsed time since last FP counter check
- private long elapsedTime = 0;
-
- // elapsed time since last test transaction check
- private long elapsedTestTransTime = 0;
-
- // elapsed time since last write Fpc check
- private long elapsedWriteFpcTime = 0;
-
- // last dependency health check time. Initialize so that the periodic check
- // starts after 60 seconds.
- // This allows time for dependents to come up.
- private long lastDependencyCheckTime = System.currentTimeMillis();
-
- // Time of the last state audit. It is initialized at the time of the IM
- // construction
- private Date lastStateAuditTime = new Date();
-
- // Interval between state audits in ms. We leave it turned off by default so
- // that it will only
- // be run on the nodes which we want doing the audit. In particular, we only
- // want it to run
- // on the droolspdps
- private static long stateAuditIntervalMs = 0L;
-
- // the number of cycles since 'fpCounter' was last changed
- private int missedCycles = 0;
-
- // forward progress monitoring interval
- private static long monitorIntervalMs = 1000L * IntegrityMonitorProperties.DEFAULT_MONITOR_INTERVAL;
- // The number of periods the counter fails to increment before an alarm is
- // raised.
- private static int failedCounterThreshold = IntegrityMonitorProperties.DEFAULT_FAILED_COUNTER_THRESHOLD;
- // test transaction interval
- private static long testTransIntervalMs = 1000L * IntegrityMonitorProperties.DEFAULT_TEST_INTERVAL;
- // write Fpc to DB interval
- private static long writeFpcIntervalMs = 1000L * IntegrityMonitorProperties.DEFAULT_WRITE_FPC_INTERVAL;
- // check the health of dependencies
- private static long checkDependencyIntervalMs = 1000L
- * IntegrityMonitorProperties.DEFAULT_CHECK_DEPENDENCY_INTERVAL;
-
- // A lead subsystem will have dependency groups with resource names in the
- // properties file.
- // For non-lead subsystems, the dependency_group property will be absent.
- private static String[] depGroups = null;
-
- private static boolean isUnitTesting = false;
-
- // can turn on health checking of dependents via jmx test() call by setting
- // this property to true
- private static boolean testViaJmx = false;
-
- private static String jmxFqdn = null;
-
- // this is the max interval allowed without any forward progress
- // counter updates
- private static long maxFpcUpdateIntervalMs = 1000L * IntegrityMonitorProperties.DEFAULT_MAX_FPC_UPDATE_INTERVAL;
-
- // Node types
- private enum NodeType {
- PDP_XACML, PDP_DROOLS, PAP, PAP_ADMIN, LOGPARSER, BRMS_GATEWAY, ASTRA_GATEWAY, ELK_SERVER, PYPDP
-
- }
-
- private static String siteName;
- private static String nodeType;
- private Date refreshStateAuditLastRunDate;
- private static long refreshStateAuditIntervalMs = 600000; // run it once per
- // 10 minutes
-
- // lock objects
- private final Object evaluateSanityLock = new Object();
- private final Object fpMonitorCycleLock = new Object();
- private final Object dependencyCheckLock = new Object();
- private final Object testTransactionLock = new Object();
- private final Object startTransactionLock = new Object();
- private final Object endTransactionLock = new Object();
- private final Object checkTestTransactionLock = new Object();
- private final Object checkWriteFpcLock = new Object();
- private static final Object getInstanceLock = new Object();
- private final Object refreshStateAuditLock = new Object();
- private final Object imFlushLock = new Object();
-
- private Map<String, String> allSeemsWellMap;
- private Map<String, String> allNotWellMap;
-
- /**
- * IntegrityMonitor constructor. It is invoked from the getInstance() method
- * in this class or from the constructor of a child or sub-class. A class
- * can extend the IntegrityMonitor class if there is a need to override any
- * of the base methods (ex. subsystemTest()). Only one instance is allowed
- * to be created per resource name.
- *
- * @param resourceName
- * The resource name of the resource
- * @param properties
- * a set of properties passed in from the resource
- * @throws IntegrityMonitorException
- * if any errors are encountered in the constructor
- */
- protected IntegrityMonitor(String resourceName, Properties properties) throws IntegrityMonitorException {
-
- this(resourceName, properties, null);
- }
-
- /**
- * IntegrityMonitor constructor. It is invoked from the getInstance() method
- * in this class or from the constructor of a child or sub-class. A class
- * can extend the IntegrityMonitor class if there is a need to override any
- * of the base methods (ex. subsystemTest()). Only one instance is allowed
- * to be created per resource name.
- *
- * @param resourceName
- * The resource name of the resource
- * @param properties
- * a set of properties passed in from the resource
- * @param queue
- * queue to use to control the FPManager thread, or {@code null}
- * @throws IntegrityMonitorException
- * if any errors are encountered in the constructor
- */
- protected IntegrityMonitor(String resourceName, Properties properties, BlockingQueue<CountDownLatch> queue)
- throws IntegrityMonitorException {
-
- // singleton check since this constructor can be called from a child or
- // sub-class
- if (instance != null) {
- String msg = "IM object exists and only one instance allowed";
- logger.error("{}", msg);
- throw new IntegrityMonitorException("IntegrityMonitor constructor exception: " + msg);
- }
- instance = this;
-
- IntegrityMonitor.resourceName = resourceName;
-
- /*
- * Validate that the properties file contains all the needed properties.
- * Throws an IntegrityMonitorPropertiesException
- */
- validateProperties(properties);
-
- // construct jmx url
- String jmxUrl = getJmxUrl();
-
- //
- // Create the entity manager factory
- //
- emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
- //
- // Did it get created?
- //
- if (emf == null) {
- logger.error("Error creating IM entity manager factory with persistence unit: {}", persistenceUnit);
- throw new IntegrityMonitorException("Unable to create IM Entity Manager Factory");
- }
-
- // add entry to forward progress and resource registration tables in DB
-
- // Start a transaction
- em = emf.createEntityManager();
- EntityTransaction et = em.getTransaction();
-
- et.begin();
-
- try {
- // if ForwardProgress entry exists for resourceName, update it. If
- // not found, create a new entry
- Query fquery = em.createQuery("Select f from ForwardProgressEntity f where f.resourceName=:rn");
- fquery.setParameter("rn", resourceName);
-
- @SuppressWarnings("rawtypes")
- List fpList = fquery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
- ForwardProgressEntity fpx = null;
- if (!fpList.isEmpty()) {
- // ignores multiple results
- fpx = (ForwardProgressEntity) fpList.get(0);
- // refresh the object from DB in case cached data was returned
- em.refresh(fpx);
- if (logger.isDebugEnabled()) {
- logger.debug("Resource {} exists and will be updated - old fpc= {}, lastUpdated= {}", resourceName,
- fpx.getFpcCount(), fpx.getLastUpdated());
- }
- fpx.setFpcCount(fpCounter);
- } else {
- // Create a forward progress object
- logger.debug("Adding resource {} to ForwardProgress table", resourceName);
- fpx = new ForwardProgressEntity();
- }
- // update/set columns in entry
- fpx.setResourceName(resourceName);
- em.persist(fpx);
- // flush to the DB
- synchronized (imFlushLock) {
- em.flush();
- }
-
- // if ResourceRegistration entry exists for resourceName, update it.
- // If not found, create a new entry
- Query rquery = em.createQuery("Select r from ResourceRegistrationEntity r where r.resourceName=:rn");
- rquery.setParameter("rn", resourceName);
-
- @SuppressWarnings("rawtypes")
- List rrList = rquery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
- ResourceRegistrationEntity rrx = null;
- if (!rrList.isEmpty()) {
- // ignores multiple results
- rrx = (ResourceRegistrationEntity) rrList.get(0);
- // refresh the object from DB in case cached data was returned
- em.refresh(rrx);
- if (logger.isDebugEnabled()) {
- logger.debug("Resource {} exists and will be updated - old url= {}, createdDate={}", resourceName,
- rrx.getResourceUrl(), rrx.getCreatedDate());
- }
- rrx.setLastUpdated(new Date());
- } else {
- // register resource by adding entry to table in DB
- logger.debug("Adding resource {} to ResourceRegistration table", resourceName);
- rrx = new ResourceRegistrationEntity();
- }
- // update/set columns in entry
- rrx.setResourceName(resourceName);
- rrx.setResourceUrl(jmxUrl);
- rrx.setNodeType(nodeType);
- rrx.setSite(siteName);
- em.persist(rrx);
- // flush to the DB
- synchronized (imFlushLock) {
- et.commit();
- }
-
- } catch (Exception e) {
- logger.error("IntegrityMonitor constructor DB table update failed with exception: ", e);
- try {
- if (et.isActive()) {
- synchronized (imFlushLock) {
- et.rollback();
- }
- }
- } catch (Exception e1) {
- logger.error("IntegrityMonitor constructor threw exception: ", e1);
- }
- throw e;
- }
-
- try {
- // create instance of StateMangement class and pass emf to it
- stateManager = new StateManagement(emf, resourceName);
-
- /**
- * Initialize the state and status attributes. This will maintain any
- * Administrative state value but will set the operational state =
- * enabled, availability status = null, standby status = null. The
- * integrity monitor will set the operational state via the FPManager
- * and the owning application must set the standby status by calling
- * promote/demote on the StateManager.
- */
- stateManager.initializeState();
-
- } catch(StateManagementException e) {
- throw new IntegrityMonitorException(e);
- }
-
- // create management bean
- try {
- new ComponentAdmin(resourceName, this, stateManager);
- } catch (Exception e) {
- logger.error("ComponentAdmin constructor exception: {}", e.toString(), e);
- }
-
- fpManager = new FPManager(queue);
-
- }
-
- /**
- * Get an instance of IntegrityMonitor for a given resource name. It creates
- * one if it does not exist. Only one instance is allowed to be created per
- * resource name.
- *
- * @param resourceName
- * The resource name of the resource
- * @param properties
- * a set of properties passed in from the resource
- * @return The new instance of IntegrityMonitor
- * @throws IntegrityMonitorException
- * if unable to create jmx url or the constructor returns an
- * exception
- */
- public static IntegrityMonitor getInstance(String resourceName, Properties properties) throws IntegrityMonitorException {
- return getInstance(resourceName, properties, null);
- }
-
- /**
- * Get an instance of IntegrityMonitor for a given resource name. It creates
- * one if it does not exist. Only one instance is allowed to be created per
- * resource name.
- *
- * @param resourceName
- * The resource name of the resource
- * @param properties
- * a set of properties passed in from the resource
- * @param queue
- * queue to use to control the FPManager thread, or {@code null}
- * @return The new instance of IntegrityMonitor
- * @throws IntegrityMonitorException
- * if unable to create jmx url or the constructor returns an
- * exception
- */
- protected static IntegrityMonitor getInstance(String resourceName, Properties properties,
- BlockingQueue<CountDownLatch> queue) throws IntegrityMonitorException {
-
- synchronized (getInstanceLock) {
- logger.debug("getInstance() called - resourceName= {}", resourceName);
- if (resourceName == null || resourceName.isEmpty() || properties == null) {
- logger.error("Error: getIntegrityMonitorInstance() called with invalid input");
- return null;
- }
-
- if (instance == null) {
- logger.debug("Creating new instance of IntegrityMonitor");
- instance = new IntegrityMonitor(resourceName, properties, queue);
- }
- return instance;
- }
- }
-
- public static IntegrityMonitor getInstance() throws IntegrityMonitorException {
- logger.debug("getInstance() called");
- if (instance == null) {
- String msg = "No IntegrityMonitor instance exists."
- + " Please use the method IntegrityMonitor.getInstance(String resourceName, Properties properties)";
- throw new IntegrityMonitorPropertiesException(msg);
- } else {
- return instance;
- }
- }
-
- /*
- * This is a facility used by JUnit testing to destroy the IntegrityMonitor
- * instance before creating a new one. It waits a bit to allow the FPManager
- * to fully exit.
- */
- public static void deleteInstance() throws IntegrityMonitorException {
- logger.debug("deleteInstance() called");
- synchronized (getInstanceLock) {
- if (isUnitTesting() && instance != null && instance.getFPManager() != null) {
- FPManager fpm = instance.getFPManager();
-
- // Stop the FPManager thread
- fpm.stopAndExit();
-
- try {
- // Make sure it has exited
- fpm.join(2000L);
- } catch (InterruptedException e) {
- logger.error("deleteInstance: Interrupted while waiting for FPManaager to fully exit", e);
- Thread.currentThread().interrupt();
- }
-
- if (fpm.isAlive()) {
- logger.error("IntegrityMonitor.deleteInstance() Failed to kill FPManager thread");
- throw new IntegrityMonitorException(
- "IntegrityMonitor.deleteInstance() Failed to kill FPManager thread");
- }
-
- instance = null;
- }
- }
- logger.debug("deleteInstance() exit");
- }
-
- private FPManager getFPManager() {
- return fpManager;
- }
-
- private static String getJmxUrl() throws IntegrityMonitorException {
-
- // get the jmx remote port and construct the JMX URL
- Properties systemProps = System.getProperties();
- String jmxPort = systemProps.getProperty("com.sun.management.jmxremote.port");
- String jmxErrMsg;
- if (jmxPort == null) {
- jmxErrMsg = "System property com.sun.management.jmxremote.port for JMX remote port is not set";
- logger.error("{}", jmxErrMsg);
- throw new IntegrityMonitorException("getJmxUrl exception: " + jmxErrMsg);
- }
-
- int port = 0;
- try {
- port = Integer.parseInt(jmxPort);
- } catch (NumberFormatException e) {
- jmxErrMsg = "JMX remote port is not a valid integer value - " + jmxPort;
- logger.error("{}", jmxErrMsg);
- throw new IntegrityMonitorException("getJmxUrl exception: " + jmxErrMsg);
- }
-
- try {
- if (jmxFqdn == null) {
- jmxFqdn = InetAddress.getLocalHost().getCanonicalHostName(); // get
- // FQDN
- // of
- // this
- // host
- }
- } catch (Exception e) {
- String msg = "getJmxUrl could not get hostname";
- logger.error("{}", msg, e);
- throw new IntegrityMonitorException("getJmxUrl Exception: " + msg);
- }
- if (jmxFqdn == null) {
- String msg = "getJmxUrl encountered null hostname";
- logger.error("{}", msg);
- throw new IntegrityMonitorException("getJmxUrl error: " + msg);
- }
-
- // assemble the jmx url
- String jmxUrl = "service:jmx:rmi:///jndi/rmi://" + jmxFqdn + ":" + port + "/jmxrmi";
-
- logger.debug("IntegerityMonitor - jmx url={}", jmxUrl);
-
- return jmxUrl;
- }
-
- /**
- * evaluateSanity() is designed to be called by an external entity to
- * evealuate the sanity of the node. It checks the operational and
- * administrative states and the standby status. If the operational state is
- * disabled, it will include the dependencyCheckErrorMsg which includes
- * information about any dependency (node) which has failed.
- */
- public void evaluateSanity() throws IntegrityMonitorException {
- logger.debug("evaluateSanity called ....");
- synchronized (evaluateSanityLock) {
-
- String errorMsg = dependencyCheckErrorMsg;
- logger.debug("evaluateSanity dependencyCheckErrorMsg = {}", errorMsg);
- // check op state and throw exception if disabled
- if ((stateManager.getOpState() != null) && stateManager.getOpState().equals(StateManagement.DISABLED)) {
- String msg = "Resource " + resourceName + " operation state is disabled. " + errorMsg;
- logger.debug("{}", msg);
- throw new IntegrityMonitorException(msg);
- }
-
- // check admin state and throw exception if locked
- if ((stateManager.getAdminState() != null) && stateManager.getAdminState().equals(StateManagement.LOCKED)) {
- String msg = "Resource " + resourceName + " is administratively locked";
- logger.debug("{}", msg);
- throw new AdministrativeStateException("IntegrityMonitor Admin State Exception: " + msg);
- }
- // check standby state and throw exception if cold standby
- if ((stateManager.getStandbyStatus() != null)
- && stateManager.getStandbyStatus().equals(StateManagement.COLD_STANDBY)) {
- String msg = "Resource " + resourceName + " is cold standby";
- logger.debug("{}", msg);
- throw new StandbyStatusException("IntegrityMonitor Standby Status Exception: " + msg);
- }
-
- }
-
- }
-
- /*
- * This method checks the forward progress counter and the state of a
- * dependency. If the dependency is unavailable or failed, an error message
- * is created which is checked when evaluateSanity interface is called. If
- * the error message is set then the evaluateSanity will return an error.
- */
- public String stateCheck(String dep) {
- logger.debug("checking state of dependent resource: {}", dep);
- String errorMsg = null;
- ForwardProgressEntity forwardProgressEntity = null;
- StateManagementEntity stateManagementEntity = null;
-
- // Start a transaction
- EntityTransaction et = em.getTransaction();
- et.begin();
-
- try {
- Query query = em.createQuery("Select p from ForwardProgressEntity p where p.resourceName=:resource");
- query.setParameter("resource", dep);
-
- @SuppressWarnings("rawtypes")
- List fpList = query.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
-
- if (!fpList.isEmpty()) {
- // exists
- forwardProgressEntity = (ForwardProgressEntity) fpList.get(0);
- // refresh the object from DB in case cached data was returned
- em.refresh(forwardProgressEntity);
- logger.debug("Found entry in ForwardProgressEntity table for dependent Resource={}", dep);
- } else {
- errorMsg = dep + ": resource not found in ForwardProgressEntity database table";
- logger.error("{}", errorMsg);
- }
- synchronized (imFlushLock) {
- et.commit();
- }
- } catch (Exception ex) {
- // log an error
- errorMsg = dep + ": ForwardProgressEntity DB operation failed with exception: ";
- logger.error("{}", errorMsg, ex);
- synchronized (imFlushLock) {
- if (et.isActive()) {
- et.rollback();
- }
- }
- }
-
- if (errorMsg == null) {
- // Start a transaction
- et = em.getTransaction();
- et.begin();
- try {
- // query if StateManagement entry exists for dependent resource
- Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
- query.setParameter("resource", dep);
-
- @SuppressWarnings("rawtypes")
- List smList = query.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
- if (!smList.isEmpty()) {
- // exist
- stateManagementEntity = (StateManagementEntity) smList.get(0);
- // refresh the object from DB in case cached data was
- // returned
- em.refresh(stateManagementEntity);
- logger.debug("Found entry in StateManagementEntity table for dependent Resource={}", dep);
- } else {
- errorMsg = dep + ": resource not found in state management entity database table";
- logger.error("{}", errorMsg);
- }
-
- synchronized (imFlushLock) {
- et.commit();
- }
- } catch (Exception e) {
- // log an error
- errorMsg = dep + ": StateManagementEntity DB read failed with exception: ";
- logger.error("{}", errorMsg, e);
- synchronized (imFlushLock) {
- if (et.isActive()) {
- et.rollback();
- }
- }
- }
- }
-
- // verify that the ForwardProgress is current (check last_updated)
- if (errorMsg == null) {
- if (forwardProgressEntity != null && stateManagementEntity != null) {
- Date date = new Date();
- long diffMs = date.getTime() - forwardProgressEntity.getLastUpdated().getTime();
- logger.debug("IntegrityMonitor.stateCheck(): diffMs = {}", diffMs);
-
- // Threshold for a stale entry
- long staleMs = maxFpcUpdateIntervalMs;
- logger.debug("IntegrityMonitor.stateCheck(): staleMs = {}", staleMs);
-
- if (diffMs > staleMs) {
- // ForwardProgress is stale. Disable it
- try {
- if (!stateManagementEntity.getOpState().equals(StateManagement.DISABLED)) {
- logger.debug("IntegrityMonitor.stateCheck(): Changing OpStat = disabled for {}", dep);
- stateManager.disableFailed(dep);
- }
- } catch (Exception e) {
- String msg = "IntegrityMonitor.stateCheck(): Failed to diableFail dependent resource = " + dep
- + "; " + e.getMessage();
- logger.error("{}", msg, e);
- }
- }
- } else {
-
- if (forwardProgressEntity == null) {
- String msg = "IntegrityMonitor.stateCheck(): Failed to diableFail dependent resource = " + dep
- + "; " + " forwardProgressEntity == null.";
- logger.error("{}", msg);
- }
-
- else {
- String msg = "IntegrityMonitor.stateCheck(): Failed to diableFail dependent resource = " + dep
- + "; " + " stateManagementEntity == null.";
- logger.error("{}", msg);
- }
- }
- }
-
- // check operation, admin and standby states of dependent resource
- if (errorMsg == null) {
- if (stateManagementEntity != null) {
- if ((stateManager.getAdminState() != null)
- && stateManagementEntity.getAdminState().equals(StateManagement.LOCKED)) {
- errorMsg = dep + ": resource is administratively locked";
- logger.error("{}", errorMsg);
- } else if ((stateManager.getOpState() != null)
- && stateManagementEntity.getOpState().equals(StateManagement.DISABLED)) {
- errorMsg = dep + ": resource is operationally disabled";
- logger.error("{}", errorMsg);
- } else if ((stateManager.getStandbyStatus() != null)
- && stateManagementEntity.getStandbyStatus().equals(StateManagement.COLD_STANDBY)) {
- errorMsg = dep + ": resource is cold standby";
- logger.error("{}", errorMsg);
- }
- } else {
- errorMsg = dep + ": could not check standy state of resource. stateManagementEntity == null.";
- logger.error("{}", errorMsg);
- }
- }
-
- String returnMsg = "IntegrityMonitor.stateCheck(): returned error_msg: " + errorMsg;
- logger.debug("{}", returnMsg);
- return errorMsg;
- }
-
- private String fpCheck(String dep) {
- logger.debug("checking forward progress count of dependent resource: {}", dep);
-
- String errorMsg = null;
-
- // check FPC count - a changing FPC count indicates the resource JVM is
- // running
-
- // Start a transaction
- EntityTransaction et = em.getTransaction();
- et.begin();
- try {
- Query fquery = em.createQuery("Select f from ForwardProgressEntity f where f.resourceName=:rn");
- fquery.setParameter("rn", dep);
-
- @SuppressWarnings("rawtypes")
- List fpList = fquery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
- ForwardProgressEntity fpx;
- if (!fpList.isEmpty()) {
- // ignores multiple results
- fpx = (ForwardProgressEntity) fpList.get(0);
- // refresh the object from DB in case cached data was returned
- em.refresh(fpx);
- if (logger.isDebugEnabled()) {
- logger.debug("Dependent resource {} - fpc= {}, lastUpdated={}", dep, fpx.getFpcCount(),
- fpx.getLastUpdated());
- }
- long currTime = System.currentTimeMillis();
- // if dependent resource FPC has not been updated, consider it
- // an error
- if ((currTime - fpx.getLastUpdated().getTime()) > maxFpcUpdateIntervalMs) {
- errorMsg = dep + ": FP count has not been updated in the last " + maxFpcUpdateIntervalMs + "ms";
- logger.error("{}", errorMsg);
- try {
- // create instance of StateMangement class for dependent
- StateManagement depStateManager = new StateManagement(emf, dep);
- if (!depStateManager.getOpState().equals(StateManagement.DISABLED)) {
- logger.debug(
- "Forward progress not detected for dependent resource {}. Setting dependent's state to disable failed.",
- dep);
- depStateManager.disableFailed();
- }
- } catch (Exception e) {
- // ignore errors
- logger.error("Update dependent state failed with exception: ", e);
- }
- }
- } else {
- // resource entry not found in FPC table
- errorMsg = dep + ": resource not found in ForwardProgressEntity table in the DB";
- logger.error("{}", errorMsg);
- }
- synchronized (imFlushLock) {
- et.commit();
- }
- } catch (Exception e) {
- // log an error and continue
- errorMsg = dep + ": ForwardProgressEntity DB read failed with exception: ";
- logger.error("{}", errorMsg, e);
- synchronized (imFlushLock) {
- if (et.isActive()) {
- et.rollback();
- }
- }
- }
-
- return errorMsg;
- }
-
- public List<ForwardProgressEntity> getAllForwardProgressEntity() {
- logger.debug("getAllForwardProgressEntity: entry");
- ArrayList<ForwardProgressEntity> fpList = new ArrayList<>();
- // Start a transaction
- EntityTransaction et = em.getTransaction();
- et.begin();
- try {
- Query fquery = em.createQuery("Select e from ForwardProgressEntity e");
- @SuppressWarnings("rawtypes")
- List myList = fquery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
- synchronized (imFlushLock) {
- et.commit();
- }
- logger.debug("getAllForwardProgressEntity: myList.size(): {}", myList.size());
- if (!myList.isEmpty()) {
- for (int i = 0; i < myList.size(); i++) {
- if (logger.isDebugEnabled()) {
- logger.debug("getAllForwardProgressEntity: myList.get({}).getResourceName(): {}", i,
- ((ForwardProgressEntity) myList.get(i)).getResourceName());
- }
- fpList.add((ForwardProgressEntity) myList.get(i));
- }
- }
- synchronized (imFlushLock) {
- if (et.isActive()) {
- et.commit();
- }
- }
- } catch (Exception e) {
- // log an error and continue
- String msg = "getAllForwardProgessEntity DB read failed with exception: ";
- logger.error("{}", msg, e);
- synchronized (imFlushLock) {
- if (et.isActive()) {
- et.rollback();
- }
- }
- }
- return fpList;
- }
-
- private String jmxCheck(String dep) {
- logger.debug("checking health of dependent by calling test() via JMX on resource: {}", dep);
-
- String errorMsg = null;
-
- // get the JMX URL from the database
- String jmxUrl = null;
- // Start a transaction
- EntityTransaction et = em.getTransaction();
- et.begin();
- try {
- // query if ResourceRegistration entry exists for resourceName
- Query rquery = em.createQuery("Select r from ResourceRegistrationEntity r where r.resourceName=:rn");
- rquery.setParameter("rn", dep);
-
- @SuppressWarnings("rawtypes")
- List rrList = rquery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
- ResourceRegistrationEntity rrx = null;
-
- if (!rrList.isEmpty()) {
- // ignores multiple results
- rrx = (ResourceRegistrationEntity) rrList.get(0);
- // refresh the object from DB in case cached data was returned
- em.refresh(rrx);
- jmxUrl = rrx.getResourceUrl();
- if (logger.isDebugEnabled()) {
- logger.debug("Dependent Resource={}, url={}, createdDate={}", dep, jmxUrl, rrx.getCreatedDate());
- }
- } else {
- errorMsg = dep + ": resource not found in ResourceRegistrationEntity table in the DB";
- logger.error("{}", errorMsg);
- }
-
- synchronized (imFlushLock) {
- et.commit();
- }
- } catch (Exception e) {
- errorMsg = dep + ": ResourceRegistrationEntity DB read failed with exception: ";
- logger.error("{}", errorMsg, e);
- synchronized (imFlushLock) {
- if (et.isActive()) {
- et.rollback();
- }
- }
- }
-
- if (jmxUrl != null) {
- JmxAgentConnection jmxAgentConnection = null;
- try {
- jmxAgentConnection = new JmxAgentConnection(jmxUrl);
- MBeanServerConnection mbeanServer = jmxAgentConnection.getMBeanConnection();
- ComponentAdminMBean admin = JMX.newMXBeanProxy(mbeanServer, ComponentAdmin.getObjectName(dep),
- ComponentAdminMBean.class);
-
- // invoke the test method via the jmx proxy
- admin.test();
- logger.debug("Dependent resource {} sanity test passed", dep);
- } catch (Exception e) {
- errorMsg = dep + ": resource sanity test failed with exception: ";
- logger.error("{}", errorMsg, e);
- } finally {
- // close the JMX connector
- if (jmxAgentConnection != null) {
- jmxAgentConnection.disconnect();
- }
- }
- }
-
- return errorMsg;
- }
-
- public String dependencyCheck() {
- logger.debug("dependencyCheck: entry");
- synchronized (dependencyCheckLock) {
-
- // Start with the error message empty
- String errorMsg = "";
- boolean dependencyFailure = false;
-
- /*
- * Before we check dependency groups we need to check subsystemTest.
- */
- try {
- // Test any subsystems that are not covered under the dependency
- // relationship
- subsystemTest();
- } catch (Exception e) {
- logger.error("IntegrityMonitor threw exception", e);
- dependencyFailure = true;
- // This indicates a subsystemTest failure
- try {
- if (logger.isDebugEnabled()) {
- logger.debug(
- "{}: There has been a subsystemTest failure with error:{} Updating this resource's state to disableDependency",
- resourceName, e.getMessage());
- }
- // Capture the subsystemTest failure info
- if (!errorMsg.isEmpty()) {
- errorMsg = errorMsg.concat(",");
- }
- errorMsg = errorMsg.concat(resourceName + ": " + e.getMessage());
- this.stateManager.disableDependency();
- } catch (Exception ex) {
- logger.error("IntegrityMonitor threw exception.", ex);
- if (!errorMsg.isEmpty()) {
- errorMsg = errorMsg.concat(",");
- }
- errorMsg = errorMsg.concat("\n" + resourceName
- + ": Failed to disable dependency after subsystemTest failure due to: " + ex.getMessage());
- }
- }
-
- // Check the sanity of dependents for lead subcomponents
- if (depGroups != null && depGroups.length > 0) {
- // check state of resources in dependency groups
- for (String group : depGroups) {
- group = group.trim();
- if (group.isEmpty()) {
- // ignore empty group
- continue;
- }
- String[] dependencies = group.split(",");
- if (logger.isDebugEnabled()) {
- logger.debug("group dependencies = {}", Arrays.toString(dependencies));
- }
- int realDepCount = 0;
- int failDepCount = 0;
- for (String dep : dependencies) {
- dep = dep.trim();
- if (dep.isEmpty()) {
- // ignore empty dependency
- continue;
- }
- realDepCount++; // this is a valid dependency whose
- // state is tracked
- String failMsg = fpCheck(dep); // if a resource is
- // down, its FP count
- // will not be
- // incremented
- if (failMsg == null) {
- if (testViaJmx) {
- failMsg = jmxCheck(dep);
- } else {
- failMsg = stateCheck(dep);
- }
- }
- if (failMsg != null) {
- failDepCount++;
- if (!errorMsg.isEmpty()) {
- errorMsg = errorMsg.concat(", ");
- }
- errorMsg = errorMsg.concat(failMsg);
- }
- } // end for (String dep : dependencies)
-
- // if all dependencies in a group are failed, set this
- // resource's state to disable dependency
- if ((realDepCount > 0) && (failDepCount == realDepCount)) {
- dependencyFailure = true;
- try {
- logger.debug(
- "All dependents in group {} have failed their health check. Updating this resource's state to disableDependency",
- group);
- if (stateManager.getAvailStatus() == null || !((stateManager.getAvailStatus())
- .equals(StateManagement.DEPENDENCY)
- || (stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY_FAILED))) {
- // Note: redundant calls are made by
- // refreshStateAudit
- this.stateManager.disableDependency();
- }
- } catch (Exception e) {
- logger.error("IntegrityMonitor threw exception.", e);
- if (!errorMsg.isEmpty()) {
- errorMsg = errorMsg.concat(",");
- }
- errorMsg = errorMsg.concat(resourceName + ": Failed to disable dependency");
- break; // break out on failure and skip checking
- // other groups
- }
- }
- // check the next group
-
- } // end for (String group : depGroups)
-
- /*
- * We have checked all the dependency groups. If all are ok and
- * subsystemTest passed, dependencyFailure == false
- */
- if (!dependencyFailure) {
- try {
- logger.debug(
- "All dependency groups have at least one viable member. Updating this resource's state to enableNoDependency");
- if (stateManager.getAvailStatus() != null
- && ((stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY)
- || (stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY_FAILED))) {
- // Note: redundant calls are made by
- // refreshStateAudit
- this.stateManager.enableNoDependency();
- } // The refreshStateAudit will catch the case where it
- // is disabled but availStatus != failed
- } catch (Exception e) {
- logger.error("IntegrityMonitor threw exception.", e);
- if (!errorMsg.isEmpty()) {
- errorMsg = errorMsg.concat(",");
- }
- errorMsg = errorMsg.concat(resourceName + ": Failed to enable no dependency");
- }
- }
- } else if (!dependencyFailure) {
- /*
- * This is put here to clean up when no dependency group should
- * exist, but one was erroneously added which caused the state
- * to be disabled/dependency/coldstandby and later removed. We
- * saw this happen in the lab, but is not very likely in a
- * production environment...but you never know.
- */
- try {
- logger.debug("There are no dependents. Updating this resource's state to enableNoDependency");
- if (stateManager.getAvailStatus() != null
- && ((stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY)
- || (stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY_FAILED))) {
- // Note: redundant calls are made by refreshStateAudit
- this.stateManager.enableNoDependency();
- } // The refreshStateAudit will catch the case where it is
- // disabled but availStatus != failed
- } catch (Exception e) {
- logger.error("IntegrityMonitor threw exception.", e);
- if (!errorMsg.isEmpty()) {
- errorMsg = errorMsg.concat(",");
- }
- errorMsg = errorMsg.concat(resourceName + ": Failed to enable no dependency");
- }
- }
-
- if (!errorMsg.isEmpty()) {
- logger.error("Sanity failure detected in a dependent resource: {}", errorMsg);
-
- }
-
- dependencyCheckErrorMsg = errorMsg;
- lastDependencyCheckTime = System.currentTimeMillis();
- logger.debug("dependencyCheck: exit");
- return errorMsg;
- }
- }
-
- /**
- * Execute a test transaction. It is called when the test transaction timer
- * fires. It could be overridden to provide additional test functionality.
- * If overridden, the overriding method must invoke startTransaction() and
- * endTransaction() and check if the allNotWellMap is empty.
- */
- public void testTransaction() {
- synchronized (testTransactionLock) {
- logger.debug("testTransaction: entry");
- //
- // startTransaction() not required for testTransaction
- //
-
- // end transaction - increments local FP counter
- endTransaction();
- }
- }
-
- /**
- * Additional testing for subsystems that do not have a /test interface (for
- * ex. 3rd party processes like elk). This method would be overridden by the
- * subsystem.
- */
- public void subsystemTest() throws IntegrityMonitorException {
- // Testing provided by subsystem
- logger.debug("IntegrityMonitor subsystemTest() OK");
- }
-
- /**
- * Checks admin state and resets transaction timer. Called by application at
- * the start of a transaction.
- *
- * @throws AdministrativeStateException
- * throws admin state exception if resource is locked
- * @throws StandbyStatusException
- */
- public void startTransaction() throws IntegrityMonitorException {
-
- synchronized (startTransactionLock) {
- // check admin state and throw exception if locked
- if ((stateManager.getAdminState() != null) && stateManager.getAdminState().equals(StateManagement.LOCKED)) {
- String msg = "Resource " + resourceName + " is administratively locked";
-
- throw new AdministrativeStateException("IntegrityMonitor Admin State Exception: " + msg);
- }
- // check standby state and throw exception if locked
-
- if ((stateManager.getStandbyStatus() != null)
- && (stateManager.getStandbyStatus().equals(StateManagement.HOT_STANDBY)
- || stateManager.getStandbyStatus().equals(StateManagement.COLD_STANDBY))) {
- String msg = "Resource " + resourceName + " is standby";
-
- throw new StandbyStatusException("IntegrityMonitor Standby Status Exception: " + msg);
- }
-
- // reset transactionTimer so it will not fire
- elapsedTestTransTime = 0;
- }
- }
-
- /**
- * Increment the local forward progress counter. Called by application at
- * the end of each transaction (successful or not).
- */
- public void endTransaction() {
- synchronized (endTransactionLock) {
- if (getAllNotWellMap() != null) {
- if (!(getAllNotWellMap().isEmpty())) {
- /*
- * An entity has reported that it is not well. We must not
- * allow the the forward progress counter to advance.
- */
- String msg = "allNotWellMap:";
- for (Entry<String, String> entry : allNotWellMap.entrySet()) {
- msg = msg.concat("\nkey = " + entry.getKey() + " msg = " + entry.getValue());
- }
- logger.error("endTransaction: allNotWellMap is NOT EMPTY. Not advancing forward"
- + "progress counter. \n{}\n", msg);
- return;
- } else {
- if (logger.isDebugEnabled()) {
- if (getAllSeemsWellMap() != null) {
- if (!(getAllSeemsWellMap().isEmpty())) {
- String msg = "allSeemsWellMap:";
- for (Entry<String, String> entry : allSeemsWellMap.entrySet()) {
- msg = msg.concat("\nkey = " + entry.getKey() + " msg = " + entry.getValue());
- }
- logger.debug(
- "endTransaction: allNotWellMap IS EMPTY and allSeemsWellMap is NOT EMPTY. Advancing forward"
- + "progress counter. \n{}\n",
- msg);
- }
- }
- }
- }
- }
- // increment local FPC
- fpCounter++;
- }
- }
-
- // update FP count in DB with local FP count
- private void writeFpc() throws IntegrityMonitorException {
-
- // Start a transaction
- EntityTransaction et = em.getTransaction();
-
- if (!et.isActive()) {
- et.begin();
- }
-
- try {
- // query if ForwardProgress entry exists for resourceName
- Query fquery = em.createQuery("Select f from ForwardProgressEntity f where f.resourceName=:rn");
- fquery.setParameter("rn", resourceName);
-
- @SuppressWarnings("rawtypes")
- List fpList = fquery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
- ForwardProgressEntity fpx;
- if (!fpList.isEmpty()) {
- // ignores multiple results
- fpx = (ForwardProgressEntity) fpList.get(0);
- // refresh the object from DB in case cached data was returned
- em.refresh(fpx);
- if (logger.isDebugEnabled()) {
- logger.debug("Updating FP entry: Resource={}, fpcCount={}, lastUpdated={}, new fpcCount={}",
- resourceName, fpx.getFpcCount(), fpx.getLastUpdated(), fpCounter);
- }
- fpx.setFpcCount(fpCounter);
- em.persist(fpx);
- // flush to the DB and commit
- synchronized (imFlushLock) {
- et.commit();
- }
- } else {
- // Error - FP entry does not exist
- String msg = "FP entry not found in database for resource " + resourceName;
- throw new IntegrityMonitorException(msg);
- }
- } catch (Exception e) {
- try {
- synchronized (imFlushLock) {
- if (et.isActive()) {
- et.rollback();
- }
- }
- } catch (Exception e1) {
- logger.error("IntegrityMonitor threw exception.", e1);
- }
- logger.error("writeFpc DB table commit failed with exception: {}", e);
- throw e;
- }
- }
-
- // retrieve state manager reference
- public final StateManagement getStateManager() {
- return this.stateManager;
- }
-
- /**
- * Read and validate properties
- *
- * @throws IntegrityMonitorPropertiesException
- */
- private static void validateProperties(Properties prop) throws IntegrityMonitorPropertiesException {
-
- if (prop.getProperty(IntegrityMonitorProperties.DB_DRIVER) == null) {
- String msg = IntegrityMonitorProperties.DB_DRIVER + " property is null";
- logger.error("{}", msg);
- throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
- }
-
- if (prop.getProperty(IntegrityMonitorProperties.DB_URL) == null) {
- String msg = IntegrityMonitorProperties.DB_URL + " property is null";
- logger.error("{}", msg);
- throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
- }
-
- if (prop.getProperty(IntegrityMonitorProperties.DB_USER) == null) {
- String msg = IntegrityMonitorProperties.DB_USER + " property is null";
- logger.error("{}", msg);
- throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
- }
-
- if (prop.getProperty(IntegrityMonitorProperties.DB_PWD) == null) {
- String msg = IntegrityMonitorProperties.DB_PWD + " property is null";
- logger.error("{}", msg);
- throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
- }
-
- if (prop.getProperty(IntegrityMonitorProperties.FP_MONITOR_INTERVAL) != null) {
- try {
- monitorIntervalMs = toMillis(
- Integer.parseInt(prop.getProperty(IntegrityMonitorProperties.FP_MONITOR_INTERVAL).trim()));
- } catch (NumberFormatException e) {
- logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.FP_MONITOR_INTERVAL, e);
- }
- }
-
- if (prop.getProperty(IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD) != null) {
- try {
- failedCounterThreshold = Integer
- .parseInt(prop.getProperty(IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD).trim());
- } catch (NumberFormatException e) {
- logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD, e);
- }
- }
-
- if (prop.getProperty(IntegrityMonitorProperties.TEST_TRANS_INTERVAL) != null) {
- try {
- testTransIntervalMs = toMillis(
- Integer.parseInt(prop.getProperty(IntegrityMonitorProperties.TEST_TRANS_INTERVAL).trim()));
- } catch (NumberFormatException e) {
- logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.TEST_TRANS_INTERVAL, e);
- }
- }
-
- if (prop.getProperty(IntegrityMonitorProperties.WRITE_FPC_INTERVAL) != null) {
- try {
- writeFpcIntervalMs = toMillis(
- Integer.parseInt(prop.getProperty(IntegrityMonitorProperties.WRITE_FPC_INTERVAL).trim()));
- } catch (NumberFormatException e) {
- logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.WRITE_FPC_INTERVAL, e);
- }
- }
-
- if (prop.getProperty(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL) != null) {
- try {
- checkDependencyIntervalMs = toMillis(Integer
- .parseInt(prop.getProperty(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL).trim()));
- } catch (NumberFormatException e) {
- logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, e);
- }
- }
-
- // dependency_groups are a semi-colon separated list of groups
- // each group is a comma separated list of resource names
- // For ex. dependency_groups = site_1.pap_1,site_1.pap_2 ; site_1.pdp_1,
- // site_1.pdp_2
- if (prop.getProperty(IntegrityMonitorProperties.DEPENDENCY_GROUPS) != null) {
- try {
- depGroups = prop.getProperty(IntegrityMonitorProperties.DEPENDENCY_GROUPS).split(";");
- if (logger.isDebugEnabled()) {
- logger.debug("dependency groups property = {}", Arrays.toString(depGroups));
- }
- } catch (Exception e) {
- logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.DEPENDENCY_GROUPS, e);
- }
- }
-
- siteName = prop.getProperty(IntegrityMonitorProperties.SITE_NAME);
- if (siteName == null) {
- String msg = IntegrityMonitorProperties.SITE_NAME + " property is null";
- logger.error("{}", msg);
- throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
- } else {
- siteName = siteName.trim();
- }
-
- nodeType = prop.getProperty(IntegrityMonitorProperties.NODE_TYPE);
- if (nodeType == null) {
- String msg = IntegrityMonitorProperties.NODE_TYPE + " property is null";
- logger.error("{}", msg);
- throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
- } else {
- nodeType = nodeType.trim();
- if (!isNodeTypeEnum(nodeType)) {
- String msg = IntegrityMonitorProperties.NODE_TYPE + " property " + nodeType + " is invalid";
- logger.error("{}", msg);
- throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
- }
- }
-
- if (prop.getProperty(IntegrityMonitorProperties.TEST_VIA_JMX) != null) {
- String jmxTest = prop.getProperty(IntegrityMonitorProperties.TEST_VIA_JMX).trim();
- testViaJmx = Boolean.parseBoolean(jmxTest);
- }
-
- if (prop.getProperty(IntegrityMonitorProperties.JMX_FQDN) != null) {
- jmxFqdn = prop.getProperty(IntegrityMonitorProperties.JMX_FQDN).trim();
- if (jmxFqdn.isEmpty()) {
- jmxFqdn = null;
- }
- }
-
- if (prop.getProperty(IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL) != null) {
- try {
- maxFpcUpdateIntervalMs = toMillis(
- Integer.parseInt(prop.getProperty(IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL).trim()));
- } catch (NumberFormatException e) {
- logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL, e);
- }
- }
-
- if (prop.getProperty(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS) != null) {
- try {
- stateAuditIntervalMs = Long
- .parseLong(prop.getProperty(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS));
- } catch (NumberFormatException e) {
- logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, e);
- }
- }
-
- if (prop.getProperty(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS) != null) {
- try {
- refreshStateAuditIntervalMs = Long
- .parseLong(prop.getProperty(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS));
- } catch (NumberFormatException e) {
- logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS,
- e);
- }
- }
-
- logger.debug("IntegrityMonitor.validateProperties(): Property values \n" + "maxFpcUpdateIntervalMs = {}\n",
- maxFpcUpdateIntervalMs);
-
- return;
- }
-
- public static void updateProperties(Properties newprop) {
- if (isUnitTesting()) {
- try {
- validateProperties(newprop);
- } catch (IntegrityMonitorPropertiesException e) {
- logger.error("IntegrityMonitor threw exception.", e);
- }
- } else {
- logger.debug("Update integrity monitor properties not allowed");
- }
- }
-
- private static boolean isNodeTypeEnum(String nodeType) {
- String upper = nodeType.toUpperCase();
- for (NodeType n : NodeType.values()) {
- if (n.toString().equals(upper)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Look for "Forward Progress" -- if the 'FPMonitor' is stalled for too
- * long, the operational state is changed to 'Disabled', and an alarm is
- * set. The state is restored when forward progress continues.
- */
- private void fpMonitorCycle() {
- logger.debug("fpMonitorCycle(): entry");
- synchronized (fpMonitorCycleLock) {
- // monitoring interval checks
- if (monitorIntervalMs <= 0) {
- logger.debug("fpMonitorCycle(): disabled");
- elapsedTime = 0;
- return; // monitoring is disabled
- }
-
- elapsedTime = elapsedTime + cycleIntervalMillis;
- if (elapsedTime < monitorIntervalMs) {
- return; // monitoring interval not reached
- }
-
- elapsedTime = 0; // reset elapsed time
-
- try {
- if (fpCounter == lastFpCounter) {
- // no forward progress
- missedCycles += 1;
- if (missedCycles >= failedCounterThreshold && !alarmExists) {
- logger.debug("Forward progress not detected for resource {}. Setting state to disable failed.",
- resourceName);
- if (!(stateManager.getOpState()).equals(StateManagement.DISABLED)) {
- // Note: The refreshStateAudit will make redundant
- // calls
- stateManager.disableFailed();
- } // The refreshStateAudit will catch the case where
- // opStat = disabled and availState !
- // failed/dependency.failed
- alarmExists = true;
- }
- } else {
- // forward progress has occurred
- lastFpCounter = fpCounter;
- missedCycles = 0;
- // set op state to enabled
- logger.debug("Forward progress detected for resource {}. Setting state to enable not failed.",
- resourceName);
- if (!(stateManager.getOpState()).equals(StateManagement.ENABLED)) {
- // Note: The refreshStateAudit will make redundant calls
- stateManager.enableNotFailed();
- } // The refreshStateAudit will catch the case where
- // opState=enabled and availStatus != null
- alarmExists = false;
- }
- } catch (Exception e) {
- // log error
- logger.error("FP Monitor encountered error. ", e);
- }
- }
- logger.debug("fpMonitorCycle(): exit");
- }
-
- /**
- * Look for "Forward Progress" on other nodes. If they are not making
- * forward progress, check their operational state. If it is not disabled,
- * then disable them.
- */
- private void stateAudit() {
- logger.debug("IntegrityMonitor.stateAudit(): entry");
- if (stateAuditIntervalMs <= 0) {
- logger.debug("IntegrityMonitor.stateAudit(): disabled");
- return; // stateAudit is disabled
- }
-
- // Only run from nodes that are operational
- if (stateManager.getOpState().equals(StateManagement.DISABLED)) {
- logger.debug("IntegrityMonitor.stateAudit(): DISABLED. returning");
- return;
- }
- if (stateManager.getAdminState().equals(StateManagement.LOCKED)) {
- logger.debug("IntegrityMonitor.stateAudit(): LOCKED. returning");
- return;
- }
- if (!stateManager.getStandbyStatus().equals(StateManagement.NULL_VALUE)
- && stateManager.getStandbyStatus() != null) {
- if (!stateManager.getStandbyStatus().equals(StateManagement.PROVIDING_SERVICE)) {
- logger.debug("IntegrityMonitor.stateAudit(): NOT PROVIDING_SERVICE. returning");
- return;
- }
- }
-
- Date date = new Date();
- long timeSinceLastStateAudit = date.getTime() - lastStateAuditTime.getTime();
- if (timeSinceLastStateAudit < stateAuditIntervalMs) {
- logger.debug("IntegrityMonitor.stateAudit(): Not time to run. returning");
- return;
- }
-
- executeStateAudit();
-
- lastStateAuditTime = date;
-
- logger.debug("IntegrityMonitor.stateAudit(): exit");
- }// end stateAudit()
-
- public void executeStateAudit() {
- logger.debug("IntegrityMonitor.executeStateAudit(): entry");
- Date date = new Date();
-
- // Get all entries in the forwardprogressentity table
- List<ForwardProgressEntity> fpList = getAllForwardProgressEntity();
-
- // Check if each forwardprogressentity entry is current
- for (ForwardProgressEntity fpe : fpList) {
- // If the this is my ForwardProgressEntity, continue
- if (fpe.getResourceName().equals(IntegrityMonitor.resourceName)) {
- continue;
- }
- // Make sure you are not getting a cached version
- em.refresh(fpe);
- long diffMs = date.getTime() - fpe.getLastUpdated().getTime();
- if (logger.isDebugEnabled()) {
- logger.debug("IntegrityMonitor.executeStateAudit(): resource = {}, diffMs = {}", fpe.getResourceName(),
- diffMs);
- }
-
- // Threshold for a stale entry
- long staleMs = maxFpcUpdateIntervalMs;
- if (logger.isDebugEnabled()) {
- logger.debug("IntegrityMonitor.executeStateAudit(): resource = {}, staleMs = {}", fpe.getResourceName(),
- staleMs);
- }
-
- if (diffMs > staleMs) {
- // ForwardProgress is stale. Disable it
- // Start a transaction
- logger.debug("IntegrityMonitor.executeStateAudit(): resource = {}, FPC is stale. Disabling it");
- EntityTransaction et = em.getTransaction();
- et.begin();
- StateManagementEntity sme = null;
- try {
- // query if StateManagement entry exists for fpe resource
- Query query = em
- .createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
- query.setParameter("resource", fpe.getResourceName());
-
- @SuppressWarnings("rawtypes")
- List smList = query.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT)
- .getResultList();
- if (!smList.isEmpty()) {
- // exists
- sme = (StateManagementEntity) smList.get(0);
- // refresh the object from DB in case cached data was
- // returned
- em.refresh(sme);
- if (logger.isDebugEnabled()) {
- logger.debug(
- "IntegrityMonitor.executeStateAudit(): Found entry in StateManagementEntity table for Resource={}",
- sme.getResourceName());
- }
- } else {
- String msg = "IntegrityMonitor.executeStateAudit(): " + fpe.getResourceName()
- + ": resource not found in state management entity database table";
- logger.error("{}", msg);
- }
- synchronized (imFlushLock) {
- et.commit();
- }
- } catch (Exception e) {
- // log an error
- logger.error(
- "IntegrityMonitor.executeStateAudit(): {}: StateManagementEntity DB read failed with exception: ",
- fpe.getResourceName(), e);
- synchronized (imFlushLock) {
- if (et.isActive()) {
- et.rollback();
- }
- }
- }
-
- if (sme != null && !sme.getOpState().equals(StateManagement.DISABLED)) {
- if (logger.isDebugEnabled()) {
- logger.debug("IntegrityMonitor.executeStateAudit(): Changing OpStat = disabled for {}",
- sme.getResourceName());
- }
- try {
- stateManager.disableFailed(sme.getResourceName());
- } catch (Exception e) {
- String msg = "IntegrityMonitor.executeStateAudit(): Failed to disable " + sme.getResourceName();
- logger.error("{}", msg, e);
- }
- }
- } // end if(diffMs > staleMs)
- } // end for(ForwardProgressEntity fpe : fpList)
- logger.debug("IntegrityMonitor.executeStateAudit(): exit");
- }
-
- /**
- * Execute a test transaction when test transaction interval has elapsed.
- */
- private void checkTestTransaction() {
- logger.debug("checkTestTransaction(): entry");
- synchronized (checkTestTransactionLock) {
-
- // test transaction timer checks
- if (testTransIntervalMs <= 0) {
- logger.debug("checkTestTransaction(): disabled");
- elapsedTestTransTime = 0;
- return; // test transaction is disabled
- }
-
- elapsedTestTransTime = elapsedTestTransTime + cycleIntervalMillis;
- if (elapsedTestTransTime < testTransIntervalMs) {
- return; // test transaction interval not reached
- }
-
- elapsedTestTransTime = 0; // reset elapsed time
-
- // execute test transaction
- testTransaction();
- }
- logger.debug("checkTestTransaction(): exit");
- }
-
- /**
- * Updates Fpc counter in database when write Fpc interval has elapsed.
- */
- private void checkWriteFpc() {
- logger.debug("checkWriteFpc(): entry");
- synchronized (checkWriteFpcLock) {
-
- // test transaction timer checks
- if (writeFpcIntervalMs <= 0) {
- logger.debug("checkWriteFpc(): disabled");
- elapsedWriteFpcTime = 0;
- return; // write Fpc is disabled
- }
-
- elapsedWriteFpcTime = elapsedWriteFpcTime + cycleIntervalMillis;
- if (elapsedWriteFpcTime < writeFpcIntervalMs) {
- return; // write Fpc interval not reached
- }
-
- elapsedWriteFpcTime = 0; // reset elapsed time
-
- // write Fpc to database
- try {
- writeFpc();
- } catch (Exception e) {
- logger.error("IntegrityMonitor threw exception.", e);
- }
- }
- logger.debug("checkWriteFpc(): exit");
- }
-
- /**
- * Execute a dependency health check periodically which also updates this
- * resource's state.
- */
- private void checkDependentHealth() {
- logger.debug("checkDependentHealth: entry");
- if (checkDependencyIntervalMs <= 0) {
- logger.debug("checkDependentHealth: disabled");
- return; // dependency monitoring is disabled
- }
-
- long currTime = System.currentTimeMillis();
- logger.debug("checkDependentHealth currTime - lastDependencyCheckTime = {}",
- currTime - lastDependencyCheckTime);
- if ((currTime - lastDependencyCheckTime) > checkDependencyIntervalMs) {
- // execute dependency check and update this resource's state
-
- dependencyCheck();
- }
- logger.debug("checkDependentHealth: exit");
- }
-
- /*
- * This is a simple refresh audit which is periodically run to assure that
- * the states and status attributes are aligned and notifications are sent
- * to any listeners. It is possible for state/status to get out of synch and
- * notified systems to be out of synch due to database corruption (manual or
- * otherwise) or because a node became isolated.
- *
- * When the operation (lock/unlock) is called, it will cause a re-evaluation
- * of the state and send a notification to all registered observers.
- */
- private void refreshStateAudit() {
- logger.debug("refreshStateAudit(): entry");
- if (refreshStateAuditIntervalMs <= 0) {
- // The audit is disabled
- logger.debug("refreshStateAudit(): disabled");
- return;
- }
- executeRefreshStateAudit();
- logger.debug("refreshStateAudit(): exit");
- }
-
- public void executeRefreshStateAudit() {
- logger.debug("executeRefreshStateAudit(): entry");
- synchronized (refreshStateAuditLock) {
- logger.debug("refreshStateAudit: entry");
- Date now = new Date();
- long nowMs = now.getTime();
- long lastTimeMs = refreshStateAuditLastRunDate.getTime();
- logger.debug("refreshStateAudit: ms since last run = {}", nowMs - lastTimeMs);
-
- if ((nowMs - lastTimeMs) > refreshStateAuditIntervalMs) {
- String adminState = stateManager.getAdminState();
- logger.debug("refreshStateAudit: adminState = {}", adminState);
- if (adminState.equals(StateManagement.LOCKED)) {
- try {
- logger.debug("refreshStateAudit: calling lock()");
- stateManager.lock();
- } catch (Exception e) {
- logger.error("refreshStateAudit: caught unexpected exception from stateManager.lock(): ", e);
- }
- } else {// unlocked
- try {
- logger.debug("refreshStateAudit: calling unlock()");
- stateManager.unlock();
- } catch (Exception e) {
- logger.error("refreshStateAudit: caught unexpected exception from stateManager.unlock(): ", e);
- }
- }
- refreshStateAuditLastRunDate = new Date();
- logger.debug("refreshStateAudit: exit");
- }
- }
- logger.debug("executeRefreshStateAudit(): exit");
- }
-
- /**
- * The following nested class periodically performs the forward progress
- * check, checks dependencies, does a refresh state audit and runs the
- * stateAudit.
- */
- class FPManager extends Thread {
- private final CountDownLatch stopper = new CountDownLatch(1);
-
- private BlockingQueue<CountDownLatch> queue;
- private CountDownLatch progressLatch = null;
-
- // Constructor - start FP manager thread
- FPManager(BlockingQueue<CountDownLatch> queue) {
- this.queue = queue;
- // set now as the last time the refreshStateAudit ran
- IntegrityMonitor.this.refreshStateAuditLastRunDate = new Date();
- // start thread
- this.start();
- }
-
- @Override
- public void run() {
- logger.debug("FPManager thread running");
-
- try {
- getLatch();
- decrementLatch();
-
- while (!stopper.await(cycleIntervalMillis, TimeUnit.MILLISECONDS)) {
- getLatch();
- IntegrityMonitor.this.runOnce();
- decrementLatch();
- }
-
- } catch (InterruptedException e) {
- logger.debug("IntegrityMonitor threw exception.", e);
- Thread.currentThread().interrupt();
- }
- }
-
- public void stopAndExit() {
- stopper.countDown();
- this.interrupt();
- }
-
- /**
- * Gets the next latch from the queue.
- *
- * @throws InterruptedException
- *
- */
- private void getLatch() throws InterruptedException {
- if (queue != null) {
- progressLatch = queue.take();
- }
- }
-
- /**
- * Decrements the current latch.
- */
- private void decrementLatch() {
- if (progressLatch != null) {
- progressLatch.countDown();
- }
- }
-
- }
-
- private void runOnce() {
- try {
- logger.debug("FPManager calling fpMonitorCycle()");
- // check forward progress timer
- fpMonitorCycle();
-
- logger.debug("FPManager calling checkTestTransaction()");
- // check test transaction timer
- checkTestTransaction();
-
- logger.debug("FPManager calling checkWriteFpc()");
- // check write Fpc timer
- checkWriteFpc();
-
- logger.debug("FPManager calling checkDependentHealth()");
- // check dependency health
- checkDependentHealth();
-
- logger.debug("FPManager calling refreshStateAudit()");
- // check if it is time to run the refreshStateAudit
- refreshStateAudit();
-
- logger.debug("FPManager calling stateAudit()");
- // check if it is time to run the stateAudit
- stateAudit();
-
- } catch (Exception e) {
- logger.error("Ignore FPManager thread processing timer(s) exception: ", e);
- }
- }
-
- public void allSeemsWell(@NotNull String key, @NotNull Boolean asw, @NotNull String msg)
- throws AllSeemsWellException {
-
- logger.debug("allSeemsWell entry: key = {}, asw = {}, msg = {}", key, asw, msg);
- if (key == null || key.isEmpty()) {
- logger.error("allSeemsWell: 'key' has no visible content");
- throw new IllegalArgumentException("allSeemsWell: 'key' has no visible content");
- }
- if (asw == null) {
- logger.error("allSeemsWell: 'asw' is null");
- throw new IllegalArgumentException("allSeemsWell: 'asw' is null");
- }
- if (msg == null || msg.isEmpty()) {
- logger.error("allSeemsWell: 'msg' has no visible content");
- throw new IllegalArgumentException("allSeemsWell: 'msg' has no visible content");
- }
-
- if (allSeemsWellMap == null) {
- allSeemsWellMap = new HashMap<>();
- }
-
- if (allNotWellMap == null) {
- allNotWellMap = new HashMap<>();
- }
-
- if (asw) {
- logger.info("allSeemsWell: ALL SEEMS WELL: key = {}, msg = {}", key, msg);
- try {
- allSeemsWellMap.put(key, msg);
- } catch (Exception e) {
- String exceptMsg = "allSeemsWell: encountered an exception with allSeemsWellMap.put(" + key + "," + msg
- + ")";
- logger.error(exceptMsg);
- throw new AllSeemsWellException(exceptMsg, e);
- }
-
- try {
- allNotWellMap.remove(key);
- } catch (Exception e) {
- String exceptMsg = "allSeemsWell: encountered an exception with allNotWellMap.delete(" + key + ")";
- logger.error(exceptMsg);
- throw new AllSeemsWellException(exceptMsg, e);
- }
-
- } else {
- logger.error("allSeemsWell: ALL NOT WELL: key = {}, msg = {}", key, msg);
- try {
- allSeemsWellMap.remove(key);
- } catch (Exception e) {
- String exceptMsg = "allSeemsWell: encountered an exception with allSeemsWellMap.remove(" + key + ")";
- logger.error(exceptMsg);
- throw new AllSeemsWellException(exceptMsg, e);
- }
-
- try {
- allNotWellMap.put(key, msg);
- } catch (Exception e) {
- String exceptMsg = "allSeemsWell: encountered an exception with allNotWellMap.put(" + key + msg + ")";
- logger.error(exceptMsg);
- throw new AllSeemsWellException(exceptMsg, e);
- }
- }
-
- if (logger.isDebugEnabled()) {
- for (Entry<String, String> entry : allSeemsWellMap.entrySet()) {
- logger.debug("allSeemsWellMap: key = {} msg = {}", entry.getKey(), entry.getValue());
- }
- for (Entry<String, String> entry : allNotWellMap.entrySet()) {
- logger.debug("allNotWellMap: key = {} msg = {}", entry.getKey(), entry.getValue());
- }
- logger.debug("allSeemsWell exit");
- }
- }
-
- /**
- * Converts the given value to milliseconds using the current
- * {@link #propertyUnits}.
- *
- * @param value
- * value to be converted, or -1
- * @return the value, in milliseconds, or -1
- */
- private static long toMillis(long value) {
- return (value < 0 ? -1 : propertyUnits.toMillis(value));
- }
-
- public Map<String, String> getAllSeemsWellMap() {
- return allSeemsWellMap;
- }
-
- public Map<String, String> getAllNotWellMap() {
- return allNotWellMap;
- }
-
- /*
- * The remaining methods are used by JUnit tests.
- */
-
- public static boolean isUnitTesting() {
- return isUnitTesting;
- }
-
- public static void setUnitTesting(boolean isUnitTesting) {
- IntegrityMonitor.isUnitTesting = isUnitTesting;
- }
-
- protected static TimeUnit getPropertyUnits() {
- return propertyUnits;
- }
-
- protected static void setPropertyUnits(TimeUnit propertyUnits) {
- IntegrityMonitor.propertyUnits = propertyUnits;
- }
-
- protected static long getCycleIntervalMillis() {
- return cycleIntervalMillis;
- }
-
- protected static void setCycleIntervalMillis(long cycleIntervalMillis) {
- IntegrityMonitor.cycleIntervalMillis = cycleIntervalMillis;
- }
-
- protected static String getPersistenceUnit() {
- return persistenceUnit;
- }
-
- protected static void setPersistenceUnit(String persistenceUnit) {
- IntegrityMonitor.persistenceUnit = persistenceUnit;
- }
+ // Persistence Unit for JPA
+ public static final String PERSISTENCE_UNIT = "operationalPU";
+
+ private static String persistenceUnit = PERSISTENCE_UNIT;
+
+ private static final long CYCLE_INTERVAL_MILLIS = 1000L;
+
+ private static long cycleIntervalMillis = CYCLE_INTERVAL_MILLIS;
+
+ /**
+ * Units used for intervals extracted from the properties, which are typically given in seconds.
+ */
+ private static TimeUnit propertyUnits = TimeUnit.SECONDS;
+
+ private StateManagement stateManager = null;
+
+ private FpManager fpManager = null;
+
+ // The forward progress counter is incremented as the
+ // process being monitored makes forward progress
+ private int fpCounter = 0;
+ private int lastFpCounter = 0;
+
+ // elapsed time since last FP counter check
+ private long elapsedTime = 0;
+
+ // elapsed time since last test transaction check
+ private long elapsedTestTransTime = 0;
+
+ // elapsed time since last write Fpc check
+ private long elapsedWriteFpcTime = 0;
+
+ // last dependency health check time. Initialize so that the periodic check
+ // starts after 60 seconds.
+ // This allows time for dependents to come up.
+ private long lastDependencyCheckTime = System.currentTimeMillis();
+
+ // Time of the last state audit. It is initialized at the time of the IM
+ // construction
+ private Date lastStateAuditTime = new Date();
+
+ // Interval between state audits in ms. We leave it turned off by default so
+ // that it will only
+ // be run on the nodes which we want doing the audit. In particular, we only
+ // want it to run
+ // on the droolspdps
+ private static long stateAuditIntervalMs = 0L;
+
+ // the number of cycles since 'fpCounter' was last changed
+ private int missedCycles = 0;
+
+ // forward progress monitoring interval
+ private static long monitorIntervalMs = 1000L * IntegrityMonitorProperties.DEFAULT_MONITOR_INTERVAL;
+ // The number of periods the counter fails to increment before an alarm is
+ // raised.
+ private static int failedCounterThreshold = IntegrityMonitorProperties.DEFAULT_FAILED_COUNTER_THRESHOLD;
+ // test transaction interval
+ private static long testTransIntervalMs = 1000L * IntegrityMonitorProperties.DEFAULT_TEST_INTERVAL;
+ // write Fpc to DB interval
+ private static long writeFpcIntervalMs = 1000L * IntegrityMonitorProperties.DEFAULT_WRITE_FPC_INTERVAL;
+ // check the health of dependencies
+ private static long checkDependencyIntervalMs =
+ 1000L * IntegrityMonitorProperties.DEFAULT_CHECK_DEPENDENCY_INTERVAL;
+
+ // A lead subsystem will have dependency groups with resource names in the
+ // properties file.
+ // For non-lead subsystems, the dependency_group property will be absent.
+ private static String[] depGroups = null;
+
+ private static boolean isUnitTesting = false;
+
+ // can turn on health checking of dependents via jmx test() call by setting
+ // this property to true
+ private static boolean testViaJmx = false;
+
+ private static String jmxFqdn = null;
+
+ // this is the max interval allowed without any forward progress
+ // counter updates
+ private static long maxFpcUpdateIntervalMs = 1000L * IntegrityMonitorProperties.DEFAULT_MAX_FPC_UPDATE_INTERVAL;
+
+ // Node types
+ private enum NodeType {
+ PDP_XACML, PDP_DROOLS, PAP, PAP_ADMIN, LOGPARSER, BRMS_GATEWAY, ASTRA_GATEWAY, ELK_SERVER, PYPDP
+
+ }
+
+ private static String siteName;
+ private static String nodeType;
+ private Date refreshStateAuditLastRunDate;
+ private static long refreshStateAuditIntervalMs = 600000; // run it once per 10 minutes
+
+ // lock objects
+ private final Object evaluateSanityLock = new Object();
+ private final Object fpMonitorCycleLock = new Object();
+ private final Object dependencyCheckLock = new Object();
+ private final Object testTransactionLock = new Object();
+ private final Object startTransactionLock = new Object();
+ private final Object endTransactionLock = new Object();
+ private final Object checkTestTransactionLock = new Object();
+ private final Object checkWriteFpcLock = new Object();
+ private static final Object getInstanceLock = new Object();
+ private final Object refreshStateAuditLock = new Object();
+ private final Object imFlushLock = new Object();
+
+ private Map<String, String> allSeemsWellMap;
+ private Map<String, String> allNotWellMap;
+
+ /**
+ * IntegrityMonitor constructor. It is invoked from the getInstance() method in this class or
+ * from the constructor of a child or sub-class. A class can extend the IntegrityMonitor class
+ * if there is a need to override any of the base methods (ex. subsystemTest()). Only one
+ * instance is allowed to be created per resource name.
+ *
+ * @param resourceName The resource name of the resource
+ * @param properties a set of properties passed in from the resource
+ * @throws IntegrityMonitorException if any errors are encountered in the constructor
+ */
+ protected IntegrityMonitor(String resourceName, Properties properties) throws IntegrityMonitorException {
+
+ this(resourceName, properties, null);
+ }
+
+ /**
+ * IntegrityMonitor constructor. It is invoked from the getInstance() method in this class or
+ * from the constructor of a child or sub-class. A class can extend the IntegrityMonitor class
+ * if there is a need to override any of the base methods (ex. subsystemTest()). Only one
+ * instance is allowed to be created per resource name.
+ *
+ * @param resourceName The resource name of the resource
+ * @param properties a set of properties passed in from the resource
+ * @param queue queue to use to control the FPManager thread, or {@code null}
+ * @throws IntegrityMonitorException if any errors are encountered in the constructor
+ */
+ protected IntegrityMonitor(String resourceName, Properties properties, BlockingQueue<CountDownLatch> queue)
+ throws IntegrityMonitorException {
+
+ // singleton check since this constructor can be called from a child or
+ // sub-class
+ if (instance != null) {
+ String msg = "IM object exists and only one instance allowed";
+ logger.error("{}", msg);
+ throw new IntegrityMonitorException("IntegrityMonitor constructor exception: " + msg);
+ }
+ instance = this;
+
+ IntegrityMonitor.resourceName = resourceName;
+
+ /*
+ * Validate that the properties file contains all the needed properties. Throws an
+ * IntegrityMonitorPropertiesException
+ */
+ validateProperties(properties);
+
+ // construct jmx url
+ String jmxUrl = getJmxUrl();
+
+ //
+ // Create the entity manager factory
+ //
+ emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+ //
+ // Did it get created?
+ //
+ if (emf == null) {
+ logger.error("Error creating IM entity manager factory with persistence unit: {}", persistenceUnit);
+ throw new IntegrityMonitorException("Unable to create IM Entity Manager Factory");
+ }
+
+ // add entry to forward progress and resource registration tables in DB
+
+ // Start a transaction
+ em = emf.createEntityManager();
+ EntityTransaction et = em.getTransaction();
+
+ et.begin();
+
+ try {
+ // if ForwardProgress entry exists for resourceName, update it. If
+ // not found, create a new entry
+ Query fquery = em.createQuery("Select f from ForwardProgressEntity f where f.resourceName=:rn");
+ fquery.setParameter("rn", resourceName);
+
+ @SuppressWarnings("rawtypes")
+ List fpList = fquery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+ ForwardProgressEntity fpx = null;
+ if (!fpList.isEmpty()) {
+ // ignores multiple results
+ fpx = (ForwardProgressEntity) fpList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(fpx);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Resource {} exists and will be updated - old fpc= {}, lastUpdated= {}", resourceName,
+ fpx.getFpcCount(), fpx.getLastUpdated());
+ }
+ fpx.setFpcCount(fpCounter);
+ } else {
+ // Create a forward progress object
+ logger.debug("Adding resource {} to ForwardProgress table", resourceName);
+ fpx = new ForwardProgressEntity();
+ }
+ // update/set columns in entry
+ fpx.setResourceName(resourceName);
+ em.persist(fpx);
+ // flush to the DB
+ synchronized (imFlushLock) {
+ em.flush();
+ }
+
+ // if ResourceRegistration entry exists for resourceName, update it.
+ // If not found, create a new entry
+ Query rquery = em.createQuery("Select r from ResourceRegistrationEntity r where r.resourceName=:rn");
+ rquery.setParameter("rn", resourceName);
+
+ @SuppressWarnings("rawtypes")
+ List rrList = rquery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+ ResourceRegistrationEntity rrx = null;
+ if (!rrList.isEmpty()) {
+ // ignores multiple results
+ rrx = (ResourceRegistrationEntity) rrList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(rrx);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Resource {} exists and will be updated - old url= {}, createdDate={}", resourceName,
+ rrx.getResourceUrl(), rrx.getCreatedDate());
+ }
+ rrx.setLastUpdated(new Date());
+ } else {
+ // register resource by adding entry to table in DB
+ logger.debug("Adding resource {} to ResourceRegistration table", resourceName);
+ rrx = new ResourceRegistrationEntity();
+ }
+ // update/set columns in entry
+ rrx.setResourceName(resourceName);
+ rrx.setResourceUrl(jmxUrl);
+ rrx.setNodeType(nodeType);
+ rrx.setSite(siteName);
+ em.persist(rrx);
+ // flush to the DB
+ synchronized (imFlushLock) {
+ et.commit();
+ }
+
+ } catch (Exception e) {
+ logger.error("IntegrityMonitor constructor DB table update failed with exception: ", e);
+ try {
+ if (et.isActive()) {
+ synchronized (imFlushLock) {
+ et.rollback();
+ }
+ }
+ } catch (Exception e1) {
+ logger.error("IntegrityMonitor constructor threw exception: ", e1);
+ }
+ throw e;
+ }
+
+ try {
+ // create instance of StateMangement class and pass emf to it
+ stateManager = new StateManagement(emf, resourceName);
+
+ /**
+ * Initialize the state and status attributes. This will maintain any Administrative
+ * state value but will set the operational state = enabled, availability status = null,
+ * standby status = null. The integrity monitor will set the operational state via the
+ * FPManager and the owning application must set the standby status by calling
+ * promote/demote on the StateManager.
+ */
+ stateManager.initializeState();
+
+ } catch (StateManagementException e) {
+ throw new IntegrityMonitorException(e);
+ }
+
+ // create management bean
+ try {
+ new ComponentAdmin(resourceName, this, stateManager);
+ } catch (Exception e) {
+ logger.error("ComponentAdmin constructor exception: {}", e.toString(), e);
+ }
+
+ fpManager = new FpManager(queue);
+
+ }
+
+ /**
+ * Get an instance of IntegrityMonitor for a given resource name. It creates one if it does not
+ * exist. Only one instance is allowed to be created per resource name.
+ *
+ * @param resourceName The resource name of the resource
+ * @param properties a set of properties passed in from the resource
+ * @return The new instance of IntegrityMonitor
+ * @throws IntegrityMonitorException if unable to create jmx url or the constructor returns an
+ * exception
+ */
+ public static IntegrityMonitor getInstance(String resourceName, Properties properties)
+ throws IntegrityMonitorException {
+ return getInstance(resourceName, properties, null);
+ }
+
+ /**
+ * Get an instance of IntegrityMonitor for a given resource name. It creates one if it does not
+ * exist. Only one instance is allowed to be created per resource name.
+ *
+ * @param resourceName The resource name of the resource
+ * @param properties a set of properties passed in from the resource
+ * @param queue queue to use to control the FPManager thread, or {@code null}
+ * @return The new instance of IntegrityMonitor
+ * @throws IntegrityMonitorException if unable to create jmx url or the constructor returns an
+ * exception
+ */
+ protected static IntegrityMonitor getInstance(String resourceName, Properties properties,
+ BlockingQueue<CountDownLatch> queue) throws IntegrityMonitorException {
+
+ synchronized (getInstanceLock) {
+ logger.debug("getInstance() called - resourceName= {}", resourceName);
+ if (resourceName == null || resourceName.isEmpty() || properties == null) {
+ logger.error("Error: getIntegrityMonitorInstance() called with invalid input");
+ return null;
+ }
+
+ if (instance == null) {
+ logger.debug("Creating new instance of IntegrityMonitor");
+ instance = new IntegrityMonitor(resourceName, properties, queue);
+ }
+ return instance;
+ }
+ }
+
+ /**
+ * Get the single instance.
+ *
+ * @return the instance
+ * @throws IntegrityMonitorException if no instance exists
+ */
+ public static IntegrityMonitor getInstance() throws IntegrityMonitorException {
+ logger.debug("getInstance() called");
+ if (instance == null) {
+ String msg = "No IntegrityMonitor instance exists."
+ + " Please use the method IntegrityMonitor.getInstance(String resourceName, Properties properties)";
+ throw new IntegrityMonitorPropertiesException(msg);
+ } else {
+ return instance;
+ }
+ }
+
+ /**
+ * This is a facility used by JUnit testing to destroy the IntegrityMonitor instance before
+ * creating a new one. It waits a bit to allow the FPManager to fully exit.
+ */
+ public static void deleteInstance() throws IntegrityMonitorException {
+ logger.debug("deleteInstance() called");
+ synchronized (getInstanceLock) {
+ if (isUnitTesting() && instance != null && instance.getFpManager() != null) {
+ FpManager fpm = instance.getFpManager();
+
+ // Stop the FPManager thread
+ fpm.stopAndExit();
+
+ try {
+ // Make sure it has exited
+ fpm.join(2000L);
+ } catch (InterruptedException e) {
+ logger.error("deleteInstance: Interrupted while waiting for FPManaager to fully exit", e);
+ Thread.currentThread().interrupt();
+ }
+
+ if (fpm.isAlive()) {
+ logger.error("IntegrityMonitor.deleteInstance() Failed to kill FPManager thread");
+ throw new IntegrityMonitorException(
+ "IntegrityMonitor.deleteInstance() Failed to kill FPManager thread");
+ }
+
+ instance = null;
+ }
+ }
+ logger.debug("deleteInstance() exit");
+ }
+
+ private FpManager getFpManager() {
+ return fpManager;
+ }
+
+ private static String getJmxUrl() throws IntegrityMonitorException {
+
+ // get the jmx remote port and construct the JMX URL
+ Properties systemProps = System.getProperties();
+ String jmxPort = systemProps.getProperty("com.sun.management.jmxremote.port");
+ String jmxErrMsg;
+ if (jmxPort == null) {
+ jmxErrMsg = "System property com.sun.management.jmxremote.port for JMX remote port is not set";
+ logger.error("{}", jmxErrMsg);
+ throw new IntegrityMonitorException("getJmxUrl exception: " + jmxErrMsg);
+ }
+
+ int port = 0;
+ try {
+ port = Integer.parseInt(jmxPort);
+ } catch (NumberFormatException e) {
+ jmxErrMsg = "JMX remote port is not a valid integer value - " + jmxPort;
+ logger.error("{}", jmxErrMsg);
+ throw new IntegrityMonitorException("getJmxUrl exception: " + jmxErrMsg);
+ }
+
+ try {
+ if (jmxFqdn == null) {
+ // get FQDN of this host
+ jmxFqdn = InetAddress.getLocalHost().getCanonicalHostName();
+ }
+ } catch (Exception e) {
+ String msg = "getJmxUrl could not get hostname";
+ logger.error("{}", msg, e);
+ throw new IntegrityMonitorException("getJmxUrl Exception: " + msg);
+ }
+ if (jmxFqdn == null) {
+ String msg = "getJmxUrl encountered null hostname";
+ logger.error("{}", msg);
+ throw new IntegrityMonitorException("getJmxUrl error: " + msg);
+ }
+
+ // assemble the jmx url
+ String jmxUrl = "service:jmx:rmi:///jndi/rmi://" + jmxFqdn + ":" + port + "/jmxrmi";
+
+ logger.debug("IntegerityMonitor - jmx url={}", jmxUrl);
+
+ return jmxUrl;
+ }
+
+ /**
+ * evaluateSanity() is designed to be called by an external entity to evealuate the sanity of
+ * the node. It checks the operational and administrative states and the standby status. If the
+ * operational state is disabled, it will include the dependencyCheckErrorMsg which includes
+ * information about any dependency (node) which has failed.
+ */
+ public void evaluateSanity() throws IntegrityMonitorException {
+ logger.debug("evaluateSanity called ....");
+ synchronized (evaluateSanityLock) {
+
+ String errorMsg = dependencyCheckErrorMsg;
+ logger.debug("evaluateSanity dependencyCheckErrorMsg = {}", errorMsg);
+ // check op state and throw exception if disabled
+ if ((stateManager.getOpState() != null) && stateManager.getOpState().equals(StateManagement.DISABLED)) {
+ String msg = "Resource " + resourceName + " operation state is disabled. " + errorMsg;
+ logger.debug("{}", msg);
+ throw new IntegrityMonitorException(msg);
+ }
+
+ // check admin state and throw exception if locked
+ if ((stateManager.getAdminState() != null) && stateManager.getAdminState().equals(StateManagement.LOCKED)) {
+ String msg = "Resource " + resourceName + " is administratively locked";
+ logger.debug("{}", msg);
+ throw new AdministrativeStateException("IntegrityMonitor Admin State Exception: " + msg);
+ }
+ // check standby state and throw exception if cold standby
+ if ((stateManager.getStandbyStatus() != null)
+ && stateManager.getStandbyStatus().equals(StateManagement.COLD_STANDBY)) {
+ String msg = "Resource " + resourceName + " is cold standby";
+ logger.debug("{}", msg);
+ throw new StandbyStatusException("IntegrityMonitor Standby Status Exception: " + msg);
+ }
+
+ }
+
+ }
+
+ /**
+ * This method checks the forward progress counter and the state of a dependency. If the
+ * dependency is unavailable or failed, an error message is created which is checked when
+ * evaluateSanity interface is called. If the error message is set then the evaluateSanity will
+ * return an error.
+ *
+ * @param dep the dependency
+ */
+ public String stateCheck(String dep) {
+ logger.debug("checking state of dependent resource: {}", dep);
+ String errorMsg = null;
+ ForwardProgressEntity forwardProgressEntity = null;
+ StateManagementEntity stateManagementEntity = null;
+
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+ et.begin();
+
+ try {
+ Query query = em.createQuery("Select p from ForwardProgressEntity p where p.resourceName=:resource");
+ query.setParameter("resource", dep);
+
+ @SuppressWarnings("rawtypes")
+ List fpList = query.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+
+ if (!fpList.isEmpty()) {
+ // exists
+ forwardProgressEntity = (ForwardProgressEntity) fpList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(forwardProgressEntity);
+ logger.debug("Found entry in ForwardProgressEntity table for dependent Resource={}", dep);
+ } else {
+ errorMsg = dep + ": resource not found in ForwardProgressEntity database table";
+ logger.error("{}", errorMsg);
+ }
+ synchronized (imFlushLock) {
+ et.commit();
+ }
+ } catch (Exception ex) {
+ // log an error
+ errorMsg = dep + ": ForwardProgressEntity DB operation failed with exception: ";
+ logger.error("{}", errorMsg, ex);
+ synchronized (imFlushLock) {
+ if (et.isActive()) {
+ et.rollback();
+ }
+ }
+ }
+
+ if (errorMsg == null) {
+ // Start a transaction
+ et = em.getTransaction();
+ et.begin();
+ try {
+ // query if StateManagement entry exists for dependent resource
+ Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
+ query.setParameter("resource", dep);
+
+ @SuppressWarnings("rawtypes")
+ List smList = query.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+ if (!smList.isEmpty()) {
+ // exist
+ stateManagementEntity = (StateManagementEntity) smList.get(0);
+ // refresh the object from DB in case cached data was
+ // returned
+ em.refresh(stateManagementEntity);
+ logger.debug("Found entry in StateManagementEntity table for dependent Resource={}", dep);
+ } else {
+ errorMsg = dep + ": resource not found in state management entity database table";
+ logger.error("{}", errorMsg);
+ }
+
+ synchronized (imFlushLock) {
+ et.commit();
+ }
+ } catch (Exception e) {
+ // log an error
+ errorMsg = dep + ": StateManagementEntity DB read failed with exception: ";
+ logger.error("{}", errorMsg, e);
+ synchronized (imFlushLock) {
+ if (et.isActive()) {
+ et.rollback();
+ }
+ }
+ }
+ }
+
+ // verify that the ForwardProgress is current (check last_updated)
+ if (errorMsg == null) {
+ if (forwardProgressEntity != null && stateManagementEntity != null) {
+ Date date = new Date();
+ long diffMs = date.getTime() - forwardProgressEntity.getLastUpdated().getTime();
+ logger.debug("IntegrityMonitor.stateCheck(): diffMs = {}", diffMs);
+
+ // Threshold for a stale entry
+ long staleMs = maxFpcUpdateIntervalMs;
+ logger.debug("IntegrityMonitor.stateCheck(): staleMs = {}", staleMs);
+
+ if (diffMs > staleMs) {
+ // ForwardProgress is stale. Disable it
+ try {
+ if (!stateManagementEntity.getOpState().equals(StateManagement.DISABLED)) {
+ logger.debug("IntegrityMonitor.stateCheck(): Changing OpStat = disabled for {}", dep);
+ stateManager.disableFailed(dep);
+ }
+ } catch (Exception e) {
+ String msg = "IntegrityMonitor.stateCheck(): Failed to diableFail dependent resource = " + dep
+ + "; " + e.getMessage();
+ logger.error("{}", msg, e);
+ }
+ }
+ } else {
+
+ if (forwardProgressEntity == null) {
+ String msg = "IntegrityMonitor.stateCheck(): Failed to diableFail dependent resource = " + dep
+ + "; " + " forwardProgressEntity == null.";
+ logger.error("{}", msg);
+ }
+
+ else {
+ String msg = "IntegrityMonitor.stateCheck(): Failed to diableFail dependent resource = " + dep
+ + "; " + " stateManagementEntity == null.";
+ logger.error("{}", msg);
+ }
+ }
+ }
+
+ // check operation, admin and standby states of dependent resource
+ if (errorMsg == null) {
+ if (stateManagementEntity != null) {
+ if ((stateManager.getAdminState() != null)
+ && stateManagementEntity.getAdminState().equals(StateManagement.LOCKED)) {
+ errorMsg = dep + ": resource is administratively locked";
+ logger.error("{}", errorMsg);
+ } else if ((stateManager.getOpState() != null)
+ && stateManagementEntity.getOpState().equals(StateManagement.DISABLED)) {
+ errorMsg = dep + ": resource is operationally disabled";
+ logger.error("{}", errorMsg);
+ } else if ((stateManager.getStandbyStatus() != null)
+ && stateManagementEntity.getStandbyStatus().equals(StateManagement.COLD_STANDBY)) {
+ errorMsg = dep + ": resource is cold standby";
+ logger.error("{}", errorMsg);
+ }
+ } else {
+ errorMsg = dep + ": could not check standy state of resource. stateManagementEntity == null.";
+ logger.error("{}", errorMsg);
+ }
+ }
+
+ String returnMsg = "IntegrityMonitor.stateCheck(): returned error_msg: " + errorMsg;
+ logger.debug("{}", returnMsg);
+ return errorMsg;
+ }
+
+ private String fpCheck(String dep) {
+ logger.debug("checking forward progress count of dependent resource: {}", dep);
+
+ String errorMsg = null;
+
+ // check FPC count - a changing FPC count indicates the resource JVM is
+ // running
+
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+ et.begin();
+ try {
+ Query fquery = em.createQuery("Select f from ForwardProgressEntity f where f.resourceName=:rn");
+ fquery.setParameter("rn", dep);
+
+ @SuppressWarnings("rawtypes")
+ List fpList = fquery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+ ForwardProgressEntity fpx;
+ if (!fpList.isEmpty()) {
+ // ignores multiple results
+ fpx = (ForwardProgressEntity) fpList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(fpx);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Dependent resource {} - fpc= {}, lastUpdated={}", dep, fpx.getFpcCount(),
+ fpx.getLastUpdated());
+ }
+ long currTime = System.currentTimeMillis();
+ // if dependent resource FPC has not been updated, consider it
+ // an error
+ if ((currTime - fpx.getLastUpdated().getTime()) > maxFpcUpdateIntervalMs) {
+ errorMsg = dep + ": FP count has not been updated in the last " + maxFpcUpdateIntervalMs + "ms";
+ logger.error("{}", errorMsg);
+ try {
+ // create instance of StateMangement class for dependent
+ StateManagement depStateManager = new StateManagement(emf, dep);
+ if (!depStateManager.getOpState().equals(StateManagement.DISABLED)) {
+ logger.debug("Forward progress not detected for dependent resource {}. Setting dependent's "
+ + "state to disable failed.", dep);
+ depStateManager.disableFailed();
+ }
+ } catch (Exception e) {
+ // ignore errors
+ logger.error("Update dependent state failed with exception: ", e);
+ }
+ }
+ } else {
+ // resource entry not found in FPC table
+ errorMsg = dep + ": resource not found in ForwardProgressEntity table in the DB";
+ logger.error("{}", errorMsg);
+ }
+ synchronized (imFlushLock) {
+ et.commit();
+ }
+ } catch (Exception e) {
+ // log an error and continue
+ errorMsg = dep + ": ForwardProgressEntity DB read failed with exception: ";
+ logger.error("{}", errorMsg, e);
+ synchronized (imFlushLock) {
+ if (et.isActive()) {
+ et.rollback();
+ }
+ }
+ }
+
+ return errorMsg;
+ }
+
+ /**
+ * Get all forward progress entities.
+ *
+ * @return list of all forward progress entities
+ */
+ public List<ForwardProgressEntity> getAllForwardProgressEntity() {
+ logger.debug("getAllForwardProgressEntity: entry");
+ ArrayList<ForwardProgressEntity> fpList = new ArrayList<>();
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+ et.begin();
+ try {
+ Query fquery = em.createQuery("Select e from ForwardProgressEntity e");
+ @SuppressWarnings("rawtypes")
+ List myList = fquery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+ synchronized (imFlushLock) {
+ et.commit();
+ }
+ logger.debug("getAllForwardProgressEntity: myList.size(): {}", myList.size());
+ if (!myList.isEmpty()) {
+ for (int i = 0; i < myList.size(); i++) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("getAllForwardProgressEntity: myList.get({}).getResourceName(): {}", i,
+ ((ForwardProgressEntity) myList.get(i)).getResourceName());
+ }
+ fpList.add((ForwardProgressEntity) myList.get(i));
+ }
+ }
+ synchronized (imFlushLock) {
+ if (et.isActive()) {
+ et.commit();
+ }
+ }
+ } catch (Exception e) {
+ // log an error and continue
+ String msg = "getAllForwardProgessEntity DB read failed with exception: ";
+ logger.error("{}", msg, e);
+ synchronized (imFlushLock) {
+ if (et.isActive()) {
+ et.rollback();
+ }
+ }
+ }
+ return fpList;
+ }
+
+ private String jmxCheck(String dep) {
+ logger.debug("checking health of dependent by calling test() via JMX on resource: {}", dep);
+
+ String errorMsg = null;
+
+ // get the JMX URL from the database
+ String jmxUrl = null;
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+ et.begin();
+ try {
+ // query if ResourceRegistration entry exists for resourceName
+ Query rquery = em.createQuery("Select r from ResourceRegistrationEntity r where r.resourceName=:rn");
+ rquery.setParameter("rn", dep);
+
+ @SuppressWarnings("rawtypes")
+ List rrList = rquery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+ ResourceRegistrationEntity rrx = null;
+
+ if (!rrList.isEmpty()) {
+ // ignores multiple results
+ rrx = (ResourceRegistrationEntity) rrList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(rrx);
+ jmxUrl = rrx.getResourceUrl();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Dependent Resource={}, url={}, createdDate={}", dep, jmxUrl, rrx.getCreatedDate());
+ }
+ } else {
+ errorMsg = dep + ": resource not found in ResourceRegistrationEntity table in the DB";
+ logger.error("{}", errorMsg);
+ }
+
+ synchronized (imFlushLock) {
+ et.commit();
+ }
+ } catch (Exception e) {
+ errorMsg = dep + ": ResourceRegistrationEntity DB read failed with exception: ";
+ logger.error("{}", errorMsg, e);
+ synchronized (imFlushLock) {
+ if (et.isActive()) {
+ et.rollback();
+ }
+ }
+ }
+
+ if (jmxUrl != null) {
+ JmxAgentConnection jmxAgentConnection = null;
+ try {
+ jmxAgentConnection = new JmxAgentConnection(jmxUrl);
+ MBeanServerConnection mbeanServer = jmxAgentConnection.getMBeanConnection();
+ ComponentAdminMBean admin =
+ JMX.newMXBeanProxy(mbeanServer, ComponentAdmin.getObjectName(dep), ComponentAdminMBean.class);
+
+ // invoke the test method via the jmx proxy
+ admin.test();
+ logger.debug("Dependent resource {} sanity test passed", dep);
+ } catch (Exception e) {
+ errorMsg = dep + ": resource sanity test failed with exception: ";
+ logger.error("{}", errorMsg, e);
+ } finally {
+ // close the JMX connector
+ if (jmxAgentConnection != null) {
+ jmxAgentConnection.disconnect();
+ }
+ }
+ }
+
+ return errorMsg;
+ }
+
+ /**
+ * Perform a dependency check.
+ *
+ * @return an error message detailing any issues found
+ */
+ public String dependencyCheck() {
+ logger.debug("dependencyCheck: entry");
+ synchronized (dependencyCheckLock) {
+
+ // Start with the error message empty
+ String errorMsg = "";
+ boolean dependencyFailure = false;
+
+ /*
+ * Before we check dependency groups we need to check subsystemTest.
+ */
+ try {
+ // Test any subsystems that are not covered under the dependency
+ // relationship
+ subsystemTest();
+ } catch (Exception e) {
+ logger.error("IntegrityMonitor threw exception", e);
+ dependencyFailure = true;
+ // This indicates a subsystemTest failure
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "{}: There has been a subsystemTest failure with error:{} Updating this resource's "
+ + "state to disableDependency",
+ resourceName, e.getMessage());
+ }
+ // Capture the subsystemTest failure info
+ if (!errorMsg.isEmpty()) {
+ errorMsg = errorMsg.concat(",");
+ }
+ errorMsg = errorMsg.concat(resourceName + ": " + e.getMessage());
+ this.stateManager.disableDependency();
+ } catch (Exception ex) {
+ logger.error("IntegrityMonitor threw exception.", ex);
+ if (!errorMsg.isEmpty()) {
+ errorMsg = errorMsg.concat(",");
+ }
+ errorMsg = errorMsg.concat("\n" + resourceName
+ + ": Failed to disable dependency after subsystemTest failure due to: " + ex.getMessage());
+ }
+ }
+
+ // Check the sanity of dependents for lead subcomponents
+ if (depGroups != null && depGroups.length > 0) {
+ // check state of resources in dependency groups
+ for (String group : depGroups) {
+ group = group.trim();
+ if (group.isEmpty()) {
+ // ignore empty group
+ continue;
+ }
+ String[] dependencies = group.split(",");
+ if (logger.isDebugEnabled()) {
+ logger.debug("group dependencies = {}", Arrays.toString(dependencies));
+ }
+ int realDepCount = 0;
+ int failDepCount = 0;
+ for (String dep : dependencies) {
+ dep = dep.trim();
+ if (dep.isEmpty()) {
+ // ignore empty dependency
+ continue;
+ }
+ realDepCount++; // this is a valid dependency whose state is tracked
+ // if a resource is down, its FP count will not be incremented
+ String failMsg = fpCheck(dep);
+ if (failMsg == null) {
+ if (testViaJmx) {
+ failMsg = jmxCheck(dep);
+ } else {
+ failMsg = stateCheck(dep);
+ }
+ }
+ if (failMsg != null) {
+ failDepCount++;
+ if (!errorMsg.isEmpty()) {
+ errorMsg = errorMsg.concat(", ");
+ }
+ errorMsg = errorMsg.concat(failMsg);
+ }
+ } // end for (String dep : dependencies)
+
+ // if all dependencies in a group are failed, set this
+ // resource's state to disable dependency
+ if ((realDepCount > 0) && (failDepCount == realDepCount)) {
+ dependencyFailure = true;
+ try {
+ logger.debug("All dependents in group {} have failed their health check. Updating this "
+ + "resource's state to disableDependency", group);
+ if (stateManager.getAvailStatus() == null || !((stateManager.getAvailStatus())
+ .equals(StateManagement.DEPENDENCY)
+ || (stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY_FAILED))) {
+ // Note: redundant calls are made by
+ // refreshStateAudit
+ this.stateManager.disableDependency();
+ }
+ } catch (Exception e) {
+ logger.error("IntegrityMonitor threw exception.", e);
+ if (!errorMsg.isEmpty()) {
+ errorMsg = errorMsg.concat(",");
+ }
+ errorMsg = errorMsg.concat(resourceName + ": Failed to disable dependency");
+ break; // break out on failure and skip checking other groups
+ }
+ }
+ // check the next group
+
+ } // end for (String group : depGroups)
+
+ /*
+ * We have checked all the dependency groups. If all are ok and subsystemTest
+ * passed, dependencyFailure == false
+ */
+ if (!dependencyFailure) {
+ try {
+ logger.debug(
+ "All dependency groups have at least one viable member. Updating this resource's state"
+ + " to enableNoDependency");
+ if (stateManager.getAvailStatus() != null
+ && ((stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY)
+ || (stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY_FAILED))) {
+ // Note: redundant calls are made by
+ // refreshStateAudit
+ this.stateManager.enableNoDependency();
+ }
+ // The refreshStateAudit will catch the case where it is disabled but
+ // availStatus != failed
+ } catch (Exception e) {
+ logger.error("IntegrityMonitor threw exception.", e);
+ if (!errorMsg.isEmpty()) {
+ errorMsg = errorMsg.concat(",");
+ }
+ errorMsg = errorMsg.concat(resourceName + ": Failed to enable no dependency");
+ }
+ }
+ } else if (!dependencyFailure) {
+ /*
+ * This is put here to clean up when no dependency group should exist, but one was
+ * erroneously added which caused the state to be disabled/dependency/coldstandby
+ * and later removed. We saw this happen in the lab, but is not very likely in a
+ * production environment...but you never know.
+ */
+ try {
+ logger.debug("There are no dependents. Updating this resource's state to enableNoDependency");
+ if (stateManager.getAvailStatus() != null
+ && ((stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY)
+ || (stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY_FAILED))) {
+ // Note: redundant calls are made by refreshStateAudit
+ this.stateManager.enableNoDependency();
+ }
+ // The refreshStateAudit will catch the case where it is disabled but
+ // availStatus != failed
+ } catch (Exception e) {
+ logger.error("IntegrityMonitor threw exception.", e);
+ if (!errorMsg.isEmpty()) {
+ errorMsg = errorMsg.concat(",");
+ }
+ errorMsg = errorMsg.concat(resourceName + ": Failed to enable no dependency");
+ }
+ }
+
+ if (!errorMsg.isEmpty()) {
+ logger.error("Sanity failure detected in a dependent resource: {}", errorMsg);
+
+ }
+
+ dependencyCheckErrorMsg = errorMsg;
+ lastDependencyCheckTime = System.currentTimeMillis();
+ logger.debug("dependencyCheck: exit");
+ return errorMsg;
+ }
+ }
+
+ /**
+ * Execute a test transaction. It is called when the test transaction timer fires. It could be
+ * overridden to provide additional test functionality. If overridden, the overriding method
+ * must invoke startTransaction() and endTransaction() and check if the allNotWellMap is empty.
+ */
+ public void testTransaction() {
+ synchronized (testTransactionLock) {
+ logger.debug("testTransaction: entry");
+ //
+ // startTransaction() not required for testTransaction
+ //
+
+ // end transaction - increments local FP counter
+ endTransaction();
+ }
+ }
+
+ /**
+ * Additional testing for subsystems that do not have a /test interface (for ex. 3rd party
+ * processes like elk). This method would be overridden by the subsystem.
+ */
+ public void subsystemTest() throws IntegrityMonitorException {
+ // Testing provided by subsystem
+ logger.debug("IntegrityMonitor subsystemTest() OK");
+ }
+
+ /**
+ * Checks admin state and resets transaction timer. Called by application at the start of a
+ * transaction.
+ *
+ * @throws AdministrativeStateException throws admin state exception if resource is locked
+ * @throws StandbyStatusException if resource is in standby
+ */
+ public void startTransaction() throws AdministrativeStateException, StandbyStatusException {
+
+ synchronized (startTransactionLock) {
+ // check admin state and throw exception if locked
+ if ((stateManager.getAdminState() != null) && stateManager.getAdminState().equals(StateManagement.LOCKED)) {
+ String msg = "Resource " + resourceName + " is administratively locked";
+
+ throw new AdministrativeStateException("IntegrityMonitor Admin State Exception: " + msg);
+ }
+ // check standby state and throw exception if locked
+
+ if ((stateManager.getStandbyStatus() != null)
+ && (stateManager.getStandbyStatus().equals(StateManagement.HOT_STANDBY)
+ || stateManager.getStandbyStatus().equals(StateManagement.COLD_STANDBY))) {
+ String msg = "Resource " + resourceName + " is standby";
+
+ throw new StandbyStatusException("IntegrityMonitor Standby Status Exception: " + msg);
+ }
+
+ // reset transactionTimer so it will not fire
+ elapsedTestTransTime = 0;
+ }
+ }
+
+ /**
+ * Increment the local forward progress counter. Called by application at the end of each
+ * transaction (successful or not).
+ */
+ public void endTransaction() {
+ synchronized (endTransactionLock) {
+ if (getAllNotWellMap() != null) {
+ if (!(getAllNotWellMap().isEmpty())) {
+ /*
+ * An entity has reported that it is not well. We must not allow the the forward
+ * progress counter to advance.
+ */
+ String msg = "allNotWellMap:";
+ for (Entry<String, String> entry : allNotWellMap.entrySet()) {
+ msg = msg.concat("\nkey = " + entry.getKey() + " msg = " + entry.getValue());
+ }
+ logger.error("endTransaction: allNotWellMap is NOT EMPTY. Not advancing forward"
+ + "progress counter. \n{}\n", msg);
+ return;
+ } else {
+ if (logger.isDebugEnabled()) {
+ if (getAllSeemsWellMap() != null) {
+ if (!(getAllSeemsWellMap().isEmpty())) {
+ String msg = "allSeemsWellMap:";
+ for (Entry<String, String> entry : allSeemsWellMap.entrySet()) {
+ msg = msg.concat("\nkey = " + entry.getKey() + " msg = " + entry.getValue());
+ }
+ logger.debug(
+ "endTransaction: allNotWellMap IS EMPTY and allSeemsWellMap is NOT EMPTY. "
+ + "Advancing forward progress counter. \n{}\n",
+ msg);
+ }
+ }
+ }
+ }
+ }
+ // increment local FPC
+ fpCounter++;
+ }
+ }
+
+ // update FP count in DB with local FP count
+ private void writeFpc() throws IntegrityMonitorException {
+
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ if (!et.isActive()) {
+ et.begin();
+ }
+
+ try {
+ // query if ForwardProgress entry exists for resourceName
+ Query fquery = em.createQuery("Select f from ForwardProgressEntity f where f.resourceName=:rn");
+ fquery.setParameter("rn", resourceName);
+
+ @SuppressWarnings("rawtypes")
+ List fpList = fquery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+ ForwardProgressEntity fpx;
+ if (!fpList.isEmpty()) {
+ // ignores multiple results
+ fpx = (ForwardProgressEntity) fpList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(fpx);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Updating FP entry: Resource={}, fpcCount={}, lastUpdated={}, new fpcCount={}",
+ resourceName, fpx.getFpcCount(), fpx.getLastUpdated(), fpCounter);
+ }
+ fpx.setFpcCount(fpCounter);
+ em.persist(fpx);
+ // flush to the DB and commit
+ synchronized (imFlushLock) {
+ et.commit();
+ }
+ } else {
+ // Error - FP entry does not exist
+ String msg = "FP entry not found in database for resource " + resourceName;
+ throw new IntegrityMonitorException(msg);
+ }
+ } catch (Exception e) {
+ try {
+ synchronized (imFlushLock) {
+ if (et.isActive()) {
+ et.rollback();
+ }
+ }
+ } catch (Exception e1) {
+ logger.error("IntegrityMonitor threw exception.", e1);
+ }
+ logger.error("writeFpc DB table commit failed with exception: {}", e);
+ throw e;
+ }
+ }
+
+ // retrieve state manager reference
+ public final StateManagement getStateManager() {
+ return this.stateManager;
+ }
+
+ /**
+ * Read and validate properties.
+ *
+ * @throws IntegrityMonitorPropertiesException if a property is invalid
+ */
+ private static void validateProperties(Properties prop) throws IntegrityMonitorPropertiesException {
+
+ if (prop.getProperty(IntegrityMonitorProperties.DB_DRIVER) == null) {
+ String msg = IntegrityMonitorProperties.DB_DRIVER + " property is null";
+ logger.error("{}", msg);
+ throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
+ }
+
+ if (prop.getProperty(IntegrityMonitorProperties.DB_URL) == null) {
+ String msg = IntegrityMonitorProperties.DB_URL + " property is null";
+ logger.error("{}", msg);
+ throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
+ }
+
+ if (prop.getProperty(IntegrityMonitorProperties.DB_USER) == null) {
+ String msg = IntegrityMonitorProperties.DB_USER + " property is null";
+ logger.error("{}", msg);
+ throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
+ }
+
+ if (prop.getProperty(IntegrityMonitorProperties.DB_PWD) == null) {
+ String msg = IntegrityMonitorProperties.DB_PWD + " property is null";
+ logger.error("{}", msg);
+ throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
+ }
+
+ if (prop.getProperty(IntegrityMonitorProperties.FP_MONITOR_INTERVAL) != null) {
+ try {
+ monitorIntervalMs = toMillis(
+ Integer.parseInt(prop.getProperty(IntegrityMonitorProperties.FP_MONITOR_INTERVAL).trim()));
+ } catch (NumberFormatException e) {
+ logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.FP_MONITOR_INTERVAL, e);
+ }
+ }
+
+ if (prop.getProperty(IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD) != null) {
+ try {
+ failedCounterThreshold =
+ Integer.parseInt(prop.getProperty(IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD).trim());
+ } catch (NumberFormatException e) {
+ logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD, e);
+ }
+ }
+
+ if (prop.getProperty(IntegrityMonitorProperties.TEST_TRANS_INTERVAL) != null) {
+ try {
+ testTransIntervalMs = toMillis(
+ Integer.parseInt(prop.getProperty(IntegrityMonitorProperties.TEST_TRANS_INTERVAL).trim()));
+ } catch (NumberFormatException e) {
+ logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.TEST_TRANS_INTERVAL, e);
+ }
+ }
+
+ if (prop.getProperty(IntegrityMonitorProperties.WRITE_FPC_INTERVAL) != null) {
+ try {
+ writeFpcIntervalMs = toMillis(
+ Integer.parseInt(prop.getProperty(IntegrityMonitorProperties.WRITE_FPC_INTERVAL).trim()));
+ } catch (NumberFormatException e) {
+ logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.WRITE_FPC_INTERVAL, e);
+ }
+ }
+
+ if (prop.getProperty(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL) != null) {
+ try {
+ checkDependencyIntervalMs = toMillis(Integer
+ .parseInt(prop.getProperty(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL).trim()));
+ } catch (NumberFormatException e) {
+ logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, e);
+ }
+ }
+
+ // dependency_groups are a semi-colon separated list of groups
+ // each group is a comma separated list of resource names
+ // For ex. dependency_groups = site_1.pap_1,site_1.pap_2 ; site_1.pdp_1,
+ // site_1.pdp_2
+ if (prop.getProperty(IntegrityMonitorProperties.DEPENDENCY_GROUPS) != null) {
+ try {
+ depGroups = prop.getProperty(IntegrityMonitorProperties.DEPENDENCY_GROUPS).split(";");
+ if (logger.isDebugEnabled()) {
+ logger.debug("dependency groups property = {}", Arrays.toString(depGroups));
+ }
+ } catch (Exception e) {
+ logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.DEPENDENCY_GROUPS, e);
+ }
+ }
+
+ siteName = prop.getProperty(IntegrityMonitorProperties.SITE_NAME);
+ if (siteName == null) {
+ String msg = IntegrityMonitorProperties.SITE_NAME + " property is null";
+ logger.error("{}", msg);
+ throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
+ } else {
+ siteName = siteName.trim();
+ }
+
+ nodeType = prop.getProperty(IntegrityMonitorProperties.NODE_TYPE);
+ if (nodeType == null) {
+ String msg = IntegrityMonitorProperties.NODE_TYPE + " property is null";
+ logger.error("{}", msg);
+ throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
+ } else {
+ nodeType = nodeType.trim();
+ if (!isNodeTypeEnum(nodeType)) {
+ String msg = IntegrityMonitorProperties.NODE_TYPE + " property " + nodeType + " is invalid";
+ logger.error("{}", msg);
+ throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
+ }
+ }
+
+ if (prop.getProperty(IntegrityMonitorProperties.TEST_VIA_JMX) != null) {
+ String jmxTest = prop.getProperty(IntegrityMonitorProperties.TEST_VIA_JMX).trim();
+ testViaJmx = Boolean.parseBoolean(jmxTest);
+ }
+
+ if (prop.getProperty(IntegrityMonitorProperties.JMX_FQDN) != null) {
+ jmxFqdn = prop.getProperty(IntegrityMonitorProperties.JMX_FQDN).trim();
+ if (jmxFqdn.isEmpty()) {
+ jmxFqdn = null;
+ }
+ }
+
+ if (prop.getProperty(IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL) != null) {
+ try {
+ maxFpcUpdateIntervalMs = toMillis(
+ Integer.parseInt(prop.getProperty(IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL).trim()));
+ } catch (NumberFormatException e) {
+ logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL, e);
+ }
+ }
+
+ if (prop.getProperty(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS) != null) {
+ try {
+ stateAuditIntervalMs =
+ Long.parseLong(prop.getProperty(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS));
+ } catch (NumberFormatException e) {
+ logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, e);
+ }
+ }
+
+ if (prop.getProperty(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS) != null) {
+ try {
+ refreshStateAuditIntervalMs =
+ Long.parseLong(prop.getProperty(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS));
+ } catch (NumberFormatException e) {
+ logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS,
+ e);
+ }
+ }
+
+ logger.debug("IntegrityMonitor.validateProperties(): Property values \n" + "maxFpcUpdateIntervalMs = {}\n",
+ maxFpcUpdateIntervalMs);
+
+ return;
+ }
+
+ /**
+ * Update properties.
+ *
+ * @param newprop the new properties
+ */
+ public static void updateProperties(Properties newprop) {
+ if (isUnitTesting()) {
+ try {
+ validateProperties(newprop);
+ } catch (IntegrityMonitorPropertiesException e) {
+ logger.error("IntegrityMonitor threw exception.", e);
+ }
+ } else {
+ logger.debug("Update integrity monitor properties not allowed");
+ }
+ }
+
+ private static boolean isNodeTypeEnum(String nodeType) {
+ String upper = nodeType.toUpperCase();
+ for (NodeType n : NodeType.values()) {
+ if (n.toString().equals(upper)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Look for "Forward Progress" -- if the 'FPMonitor' is stalled for too long, the operational
+ * state is changed to 'Disabled', and an alarm is set. The state is restored when forward
+ * progress continues.
+ */
+ private void fpMonitorCycle() {
+ logger.debug("fpMonitorCycle(): entry");
+ synchronized (fpMonitorCycleLock) {
+ // monitoring interval checks
+ if (monitorIntervalMs <= 0) {
+ logger.debug("fpMonitorCycle(): disabled");
+ elapsedTime = 0;
+ return; // monitoring is disabled
+ }
+
+ elapsedTime = elapsedTime + cycleIntervalMillis;
+ if (elapsedTime < monitorIntervalMs) {
+ return; // monitoring interval not reached
+ }
+
+ elapsedTime = 0; // reset elapsed time
+
+ try {
+ if (fpCounter == lastFpCounter) {
+ // no forward progress
+ missedCycles += 1;
+ if (missedCycles >= failedCounterThreshold && !alarmExists) {
+ logger.debug("Forward progress not detected for resource {}. Setting state to disable failed.",
+ resourceName);
+ if (!(stateManager.getOpState()).equals(StateManagement.DISABLED)) {
+ // Note: The refreshStateAudit will make redundant
+ // calls
+ stateManager.disableFailed();
+ }
+ // The refreshStateAudit will catch the case where opStat = disabled and
+ // availState ! failed/dependency.failed
+ alarmExists = true;
+ }
+ } else {
+ // forward progress has occurred
+ lastFpCounter = fpCounter;
+ missedCycles = 0;
+ // set op state to enabled
+ logger.debug("Forward progress detected for resource {}. Setting state to enable not failed.",
+ resourceName);
+ if (!(stateManager.getOpState()).equals(StateManagement.ENABLED)) {
+ // Note: The refreshStateAudit will make redundant calls
+ stateManager.enableNotFailed();
+ }
+ // The refreshStateAudit will catch the case where opState=enabled and
+ // availStatus != null
+ alarmExists = false;
+ }
+ } catch (Exception e) {
+ // log error
+ logger.error("FP Monitor encountered error. ", e);
+ }
+ }
+ logger.debug("fpMonitorCycle(): exit");
+ }
+
+ /**
+ * Look for "Forward Progress" on other nodes. If they are not making forward progress, check
+ * their operational state. If it is not disabled, then disable them.
+ */
+ private void stateAudit() {
+ logger.debug("IntegrityMonitor.stateAudit(): entry");
+ if (stateAuditIntervalMs <= 0) {
+ logger.debug("IntegrityMonitor.stateAudit(): disabled");
+ return; // stateAudit is disabled
+ }
+
+ // Only run from nodes that are operational
+ if (stateManager.getOpState().equals(StateManagement.DISABLED)) {
+ logger.debug("IntegrityMonitor.stateAudit(): DISABLED. returning");
+ return;
+ }
+ if (stateManager.getAdminState().equals(StateManagement.LOCKED)) {
+ logger.debug("IntegrityMonitor.stateAudit(): LOCKED. returning");
+ return;
+ }
+ if (!stateManager.getStandbyStatus().equals(StateManagement.NULL_VALUE)
+ && stateManager.getStandbyStatus() != null) {
+ if (!stateManager.getStandbyStatus().equals(StateManagement.PROVIDING_SERVICE)) {
+ logger.debug("IntegrityMonitor.stateAudit(): NOT PROVIDING_SERVICE. returning");
+ return;
+ }
+ }
+
+ Date date = new Date();
+ long timeSinceLastStateAudit = date.getTime() - lastStateAuditTime.getTime();
+ if (timeSinceLastStateAudit < stateAuditIntervalMs) {
+ logger.debug("IntegrityMonitor.stateAudit(): Not time to run. returning");
+ return;
+ }
+
+ executeStateAudit();
+
+ lastStateAuditTime = date;
+
+ logger.debug("IntegrityMonitor.stateAudit(): exit");
+ }
+
+ /**
+ * Execute state audit.
+ */
+ public void executeStateAudit() {
+ logger.debug("IntegrityMonitor.executeStateAudit(): entry");
+ Date date = new Date();
+
+ // Get all entries in the forwardprogressentity table
+ List<ForwardProgressEntity> fpList = getAllForwardProgressEntity();
+
+ // Check if each forwardprogressentity entry is current
+ for (ForwardProgressEntity fpe : fpList) {
+ // If the this is my ForwardProgressEntity, continue
+ if (fpe.getResourceName().equals(IntegrityMonitor.resourceName)) {
+ continue;
+ }
+ // Make sure you are not getting a cached version
+ em.refresh(fpe);
+ long diffMs = date.getTime() - fpe.getLastUpdated().getTime();
+ if (logger.isDebugEnabled()) {
+ logger.debug("IntegrityMonitor.executeStateAudit(): resource = {}, diffMs = {}", fpe.getResourceName(),
+ diffMs);
+ }
+
+ // Threshold for a stale entry
+ long staleMs = maxFpcUpdateIntervalMs;
+ if (logger.isDebugEnabled()) {
+ logger.debug("IntegrityMonitor.executeStateAudit(): resource = {}, staleMs = {}", fpe.getResourceName(),
+ staleMs);
+ }
+
+ if (diffMs > staleMs) {
+ // ForwardProgress is stale. Disable it
+ // Start a transaction
+ logger.debug("IntegrityMonitor.executeStateAudit(): resource = {}, FPC is stale. Disabling it");
+ EntityTransaction et = em.getTransaction();
+ et.begin();
+ StateManagementEntity sme = null;
+ try {
+ // query if StateManagement entry exists for fpe resource
+ Query query =
+ em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
+ query.setParameter("resource", fpe.getResourceName());
+
+ @SuppressWarnings("rawtypes")
+ List smList =
+ query.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+ if (!smList.isEmpty()) {
+ // exists
+ sme = (StateManagementEntity) smList.get(0);
+ // refresh the object from DB in case cached data was
+ // returned
+ em.refresh(sme);
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "IntegrityMonitor.executeStateAudit(): Found entry in StateManagementEntity table "
+ + "for Resource={}",
+ sme.getResourceName());
+ }
+ } else {
+ String msg = "IntegrityMonitor.executeStateAudit(): " + fpe.getResourceName()
+ + ": resource not found in state management entity database table";
+ logger.error("{}", msg);
+ }
+ synchronized (imFlushLock) {
+ et.commit();
+ }
+ } catch (Exception e) {
+ // log an error
+ logger.error("IntegrityMonitor.executeStateAudit(): {}: StateManagementEntity DB read failed with "
+ + "exception: ", fpe.getResourceName(), e);
+ synchronized (imFlushLock) {
+ if (et.isActive()) {
+ et.rollback();
+ }
+ }
+ }
+
+ if (sme != null && !sme.getOpState().equals(StateManagement.DISABLED)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("IntegrityMonitor.executeStateAudit(): Changing OpStat = disabled for {}",
+ sme.getResourceName());
+ }
+ try {
+ stateManager.disableFailed(sme.getResourceName());
+ } catch (Exception e) {
+ String msg = "IntegrityMonitor.executeStateAudit(): Failed to disable " + sme.getResourceName();
+ logger.error("{}", msg, e);
+ }
+ }
+ } // end if(diffMs > staleMs)
+ } // end for(ForwardProgressEntity fpe : fpList)
+ logger.debug("IntegrityMonitor.executeStateAudit(): exit");
+ }
+
+ /**
+ * Execute a test transaction when test transaction interval has elapsed.
+ */
+ private void checkTestTransaction() {
+ logger.debug("checkTestTransaction(): entry");
+ synchronized (checkTestTransactionLock) {
+
+ // test transaction timer checks
+ if (testTransIntervalMs <= 0) {
+ logger.debug("checkTestTransaction(): disabled");
+ elapsedTestTransTime = 0;
+ return; // test transaction is disabled
+ }
+
+ elapsedTestTransTime = elapsedTestTransTime + cycleIntervalMillis;
+ if (elapsedTestTransTime < testTransIntervalMs) {
+ return; // test transaction interval not reached
+ }
+
+ elapsedTestTransTime = 0; // reset elapsed time
+
+ // execute test transaction
+ testTransaction();
+ }
+ logger.debug("checkTestTransaction(): exit");
+ }
+
+ /**
+ * Updates Fpc counter in database when write Fpc interval has elapsed.
+ */
+ private void checkWriteFpc() {
+ logger.debug("checkWriteFpc(): entry");
+ synchronized (checkWriteFpcLock) {
+
+ // test transaction timer checks
+ if (writeFpcIntervalMs <= 0) {
+ logger.debug("checkWriteFpc(): disabled");
+ elapsedWriteFpcTime = 0;
+ return; // write Fpc is disabled
+ }
+
+ elapsedWriteFpcTime = elapsedWriteFpcTime + cycleIntervalMillis;
+ if (elapsedWriteFpcTime < writeFpcIntervalMs) {
+ return; // write Fpc interval not reached
+ }
+
+ elapsedWriteFpcTime = 0; // reset elapsed time
+
+ // write Fpc to database
+ try {
+ writeFpc();
+ } catch (Exception e) {
+ logger.error("IntegrityMonitor threw exception.", e);
+ }
+ }
+ logger.debug("checkWriteFpc(): exit");
+ }
+
+ /**
+ * Execute a dependency health check periodically which also updates this resource's state.
+ */
+ private void checkDependentHealth() {
+ logger.debug("checkDependentHealth: entry");
+ if (checkDependencyIntervalMs <= 0) {
+ logger.debug("checkDependentHealth: disabled");
+ return; // dependency monitoring is disabled
+ }
+
+ long currTime = System.currentTimeMillis();
+ logger.debug("checkDependentHealth currTime - lastDependencyCheckTime = {}",
+ currTime - lastDependencyCheckTime);
+ if ((currTime - lastDependencyCheckTime) > checkDependencyIntervalMs) {
+ // execute dependency check and update this resource's state
+
+ dependencyCheck();
+ }
+ logger.debug("checkDependentHealth: exit");
+ }
+
+ /*
+ * This is a simple refresh audit which is periodically run to assure that the states and status
+ * attributes are aligned and notifications are sent to any listeners. It is possible for
+ * state/status to get out of synch and notified systems to be out of synch due to database
+ * corruption (manual or otherwise) or because a node became isolated.
+ *
+ * When the operation (lock/unlock) is called, it will cause a re-evaluation of the state and
+ * send a notification to all registered observers.
+ */
+ private void refreshStateAudit() {
+ logger.debug("refreshStateAudit(): entry");
+ if (refreshStateAuditIntervalMs <= 0) {
+ // The audit is disabled
+ logger.debug("refreshStateAudit(): disabled");
+ return;
+ }
+ executeRefreshStateAudit();
+ logger.debug("refreshStateAudit(): exit");
+ }
+
+ /**
+ * Execute refresh state audit.
+ */
+ public void executeRefreshStateAudit() {
+ logger.debug("executeRefreshStateAudit(): entry");
+ synchronized (refreshStateAuditLock) {
+ logger.debug("refreshStateAudit: entry");
+ Date now = new Date();
+ long nowMs = now.getTime();
+ long lastTimeMs = refreshStateAuditLastRunDate.getTime();
+ logger.debug("refreshStateAudit: ms since last run = {}", nowMs - lastTimeMs);
+
+ if ((nowMs - lastTimeMs) > refreshStateAuditIntervalMs) {
+ String adminState = stateManager.getAdminState();
+ logger.debug("refreshStateAudit: adminState = {}", adminState);
+ if (adminState.equals(StateManagement.LOCKED)) {
+ try {
+ logger.debug("refreshStateAudit: calling lock()");
+ stateManager.lock();
+ } catch (Exception e) {
+ logger.error("refreshStateAudit: caught unexpected exception from stateManager.lock(): ", e);
+ }
+ } else { // unlocked
+ try {
+ logger.debug("refreshStateAudit: calling unlock()");
+ stateManager.unlock();
+ } catch (Exception e) {
+ logger.error("refreshStateAudit: caught unexpected exception from stateManager.unlock(): ", e);
+ }
+ }
+ refreshStateAuditLastRunDate = new Date();
+ logger.debug("refreshStateAudit: exit");
+ }
+ }
+ logger.debug("executeRefreshStateAudit(): exit");
+ }
+
+ /**
+ * The following nested class periodically performs the forward progress check, checks
+ * dependencies, does a refresh state audit and runs the stateAudit.
+ */
+ class FpManager extends Thread {
+ private final CountDownLatch stopper = new CountDownLatch(1);
+
+ private BlockingQueue<CountDownLatch> queue;
+ private CountDownLatch progressLatch = null;
+
+ // Constructor - start FP manager thread
+ FpManager(BlockingQueue<CountDownLatch> queue) {
+ this.queue = queue;
+ // set now as the last time the refreshStateAudit ran
+ IntegrityMonitor.this.refreshStateAuditLastRunDate = new Date();
+ // start thread
+ this.start();
+ }
+
+ @Override
+ public void run() {
+ logger.debug("FPManager thread running");
+
+ try {
+ getLatch();
+ decrementLatch();
+
+ while (!stopper.await(cycleIntervalMillis, TimeUnit.MILLISECONDS)) {
+ getLatch();
+ IntegrityMonitor.this.runOnce();
+ decrementLatch();
+ }
+
+ } catch (InterruptedException e) {
+ logger.debug("IntegrityMonitor threw exception.", e);
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ public void stopAndExit() {
+ stopper.countDown();
+ this.interrupt();
+ }
+
+ /**
+ * Gets the next latch from the queue.
+ *
+ * @throws InterruptedException
+ *
+ */
+ private void getLatch() throws InterruptedException {
+ if (queue != null) {
+ progressLatch = queue.take();
+ }
+ }
+
+ /**
+ * Decrements the current latch.
+ */
+ private void decrementLatch() {
+ if (progressLatch != null) {
+ progressLatch.countDown();
+ }
+ }
+
+ }
+
+ private void runOnce() {
+ try {
+ logger.debug("FPManager calling fpMonitorCycle()");
+ // check forward progress timer
+ fpMonitorCycle();
+
+ logger.debug("FPManager calling checkTestTransaction()");
+ // check test transaction timer
+ checkTestTransaction();
+
+ logger.debug("FPManager calling checkWriteFpc()");
+ // check write Fpc timer
+ checkWriteFpc();
+
+ logger.debug("FPManager calling checkDependentHealth()");
+ // check dependency health
+ checkDependentHealth();
+
+ logger.debug("FPManager calling refreshStateAudit()");
+ // check if it is time to run the refreshStateAudit
+ refreshStateAudit();
+
+ logger.debug("FPManager calling stateAudit()");
+ // check if it is time to run the stateAudit
+ stateAudit();
+
+ } catch (Exception e) {
+ logger.error("Ignore FPManager thread processing timer(s) exception: ", e);
+ }
+ }
+
+ /**
+ * Set all seems well or not well for the specified key.
+ *
+ * @param key the key
+ * @param asw <code>true</code> if all seems well for the key, <code>false</code> if all seems
+ * not well for the key
+ * @param msg message to add for the key
+ * @throws AllSeemsWellException if an error occurs
+ */
+ public void allSeemsWell(@NotNull String key, @NotNull Boolean asw, @NotNull String msg)
+ throws AllSeemsWellException {
+
+ logger.debug("allSeemsWell entry: key = {}, asw = {}, msg = {}", key, asw, msg);
+ if (key == null || key.isEmpty()) {
+ logger.error("allSeemsWell: 'key' has no visible content");
+ throw new IllegalArgumentException("allSeemsWell: 'key' has no visible content");
+ }
+ if (asw == null) {
+ logger.error("allSeemsWell: 'asw' is null");
+ throw new IllegalArgumentException("allSeemsWell: 'asw' is null");
+ }
+ if (msg == null || msg.isEmpty()) {
+ logger.error("allSeemsWell: 'msg' has no visible content");
+ throw new IllegalArgumentException("allSeemsWell: 'msg' has no visible content");
+ }
+
+ if (allSeemsWellMap == null) {
+ allSeemsWellMap = new HashMap<>();
+ }
+
+ if (allNotWellMap == null) {
+ allNotWellMap = new HashMap<>();
+ }
+
+ if (asw) {
+ logger.info("allSeemsWell: ALL SEEMS WELL: key = {}, msg = {}", key, msg);
+ try {
+ allSeemsWellMap.put(key, msg);
+ } catch (Exception e) {
+ String exceptMsg =
+ "allSeemsWell: encountered an exception with allSeemsWellMap.put(" + key + "," + msg + ")";
+ logger.error(exceptMsg);
+ throw new AllSeemsWellException(exceptMsg, e);
+ }
+
+ try {
+ allNotWellMap.remove(key);
+ } catch (Exception e) {
+ String exceptMsg = "allSeemsWell: encountered an exception with allNotWellMap.delete(" + key + ")";
+ logger.error(exceptMsg);
+ throw new AllSeemsWellException(exceptMsg, e);
+ }
+
+ } else {
+ logger.error("allSeemsWell: ALL NOT WELL: key = {}, msg = {}", key, msg);
+ try {
+ allSeemsWellMap.remove(key);
+ } catch (Exception e) {
+ String exceptMsg = "allSeemsWell: encountered an exception with allSeemsWellMap.remove(" + key + ")";
+ logger.error(exceptMsg);
+ throw new AllSeemsWellException(exceptMsg, e);
+ }
+
+ try {
+ allNotWellMap.put(key, msg);
+ } catch (Exception e) {
+ String exceptMsg = "allSeemsWell: encountered an exception with allNotWellMap.put(" + key + msg + ")";
+ logger.error(exceptMsg);
+ throw new AllSeemsWellException(exceptMsg, e);
+ }
+ }
+
+ if (logger.isDebugEnabled()) {
+ for (Entry<String, String> entry : allSeemsWellMap.entrySet()) {
+ logger.debug("allSeemsWellMap: key = {} msg = {}", entry.getKey(), entry.getValue());
+ }
+ for (Entry<String, String> entry : allNotWellMap.entrySet()) {
+ logger.debug("allNotWellMap: key = {} msg = {}", entry.getKey(), entry.getValue());
+ }
+ logger.debug("allSeemsWell exit");
+ }
+ }
+
+ /**
+ * Converts the given value to milliseconds using the current {@link #propertyUnits}.
+ *
+ * @param value value to be converted, or -1
+ * @return the value, in milliseconds, or -1
+ */
+ private static long toMillis(long value) {
+ return (value < 0 ? -1 : propertyUnits.toMillis(value));
+ }
+
+ public Map<String, String> getAllSeemsWellMap() {
+ return allSeemsWellMap;
+ }
+
+ public Map<String, String> getAllNotWellMap() {
+ return allNotWellMap;
+ }
+
+ /*
+ * The remaining methods are used by JUnit tests.
+ */
+
+ public static boolean isUnitTesting() {
+ return isUnitTesting;
+ }
+
+ public static void setUnitTesting(boolean isUnitTesting) {
+ IntegrityMonitor.isUnitTesting = isUnitTesting;
+ }
+
+ protected static TimeUnit getPropertyUnits() {
+ return propertyUnits;
+ }
+
+ protected static void setPropertyUnits(TimeUnit propertyUnits) {
+ IntegrityMonitor.propertyUnits = propertyUnits;
+ }
+
+ protected static long getCycleIntervalMillis() {
+ return cycleIntervalMillis;
+ }
+
+ protected static void setCycleIntervalMillis(long cycleIntervalMillis) {
+ IntegrityMonitor.cycleIntervalMillis = cycleIntervalMillis;
+ }
+
+ protected static String getPersistenceUnit() {
+ return persistenceUnit;
+ }
+
+ protected static void setPersistenceUnit(String persistenceUnit) {
+ IntegrityMonitor.persistenceUnit = persistenceUnit;
+ }
}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorException.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorException.java
index f01be279..6e1d0c00 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorException.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorException.java
@@ -20,26 +20,28 @@
package org.onap.policy.common.im;
-public class IntegrityMonitorException extends Exception{
- private static final long serialVersionUID = 1L;
- public IntegrityMonitorException() {
- super();
- }
- public IntegrityMonitorException(String message) {
- super(message);
- }
-
- public IntegrityMonitorException(Throwable cause) {
- super(cause);
- }
- public IntegrityMonitorException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public IntegrityMonitorException(String message, Throwable cause,
- boolean enableSuppression, boolean writableStackTrace)
- {
- super(message, cause, enableSuppression, writableStackTrace);
- }
+public class IntegrityMonitorException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public IntegrityMonitorException() {
+ super();
+ }
+
+ public IntegrityMonitorException(String message) {
+ super(message);
+ }
+
+ public IntegrityMonitorException(Throwable cause) {
+ super(cause);
+ }
+
+ public IntegrityMonitorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public IntegrityMonitorException(String message, Throwable cause, boolean enableSuppression,
+ boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java
index b495db71..8589170d 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java
@@ -22,40 +22,40 @@ package org.onap.policy.common.im;
public class IntegrityMonitorProperties {
- private IntegrityMonitorProperties() {}
-
- public static final String DB_DRIVER = "javax.persistence.jdbc.driver";
- public static final String DB_URL = "javax.persistence.jdbc.url";
- public static final String DB_USER = "javax.persistence.jdbc.user";
- public static final String DB_PWD = "javax.persistence.jdbc.password";
-
- // intervals specified are in seconds
- public static final int DEFAULT_MONITOR_INTERVAL = 30;
- public static final int DEFAULT_FAILED_COUNTER_THRESHOLD = 3;
- public static final int DEFAULT_TEST_INTERVAL = 10;
- public static final int DEFAULT_WRITE_FPC_INTERVAL = 5;
- public static final int DEFAULT_MAX_FPC_UPDATE_INTERVAL = 120;
- public static final int DEFAULT_CHECK_DEPENDENCY_INTERVAL = 10;
-
- public static final String FP_MONITOR_INTERVAL = "fp_monitor_interval";
- public static final String FAILED_COUNTER_THRESHOLD = "failed_counter_threshold";
- public static final String TEST_TRANS_INTERVAL = "test_trans_interval";
- public static final String WRITE_FPC_INTERVAL = "write_fpc_interval";
- public static final String CHECK_DEPENDENCY_INTERVAL = "check_dependency_interval";
-
- public static final String DEPENDENCY_GROUPS = "dependency_groups";
- public static final String SITE_NAME = "site_name";
- public static final String NODE_TYPE = "node_type";
-
- public static final String TEST_VIA_JMX = "test_via_jmx";
- public static final String JMX_FQDN = "jmx_fqdn";
- public static final String MAX_FPC_UPDATE_INTERVAL = "max_fpc_update_interval";
- public static final String STATE_AUDIT_INTERVAL_MS = "state_audit_interval_ms";
- public static final String REFRESH_STATE_AUDIT_INTERVAL_MS = "refresh_state_audit_interval_ms";
-
- // AllSeemsWell types
- public static final Boolean ALLNOTWELL=Boolean.FALSE;
- public static final Boolean ALLSEEMSWELL=Boolean.TRUE;
-
-
+ private IntegrityMonitorProperties() {}
+
+ public static final String DB_DRIVER = "javax.persistence.jdbc.driver";
+ public static final String DB_URL = "javax.persistence.jdbc.url";
+ public static final String DB_USER = "javax.persistence.jdbc.user";
+ public static final String DB_PWD = "javax.persistence.jdbc.password";
+
+ // intervals specified are in seconds
+ public static final int DEFAULT_MONITOR_INTERVAL = 30;
+ public static final int DEFAULT_FAILED_COUNTER_THRESHOLD = 3;
+ public static final int DEFAULT_TEST_INTERVAL = 10;
+ public static final int DEFAULT_WRITE_FPC_INTERVAL = 5;
+ public static final int DEFAULT_MAX_FPC_UPDATE_INTERVAL = 120;
+ public static final int DEFAULT_CHECK_DEPENDENCY_INTERVAL = 10;
+
+ public static final String FP_MONITOR_INTERVAL = "fp_monitor_interval";
+ public static final String FAILED_COUNTER_THRESHOLD = "failed_counter_threshold";
+ public static final String TEST_TRANS_INTERVAL = "test_trans_interval";
+ public static final String WRITE_FPC_INTERVAL = "write_fpc_interval";
+ public static final String CHECK_DEPENDENCY_INTERVAL = "check_dependency_interval";
+
+ public static final String DEPENDENCY_GROUPS = "dependency_groups";
+ public static final String SITE_NAME = "site_name";
+ public static final String NODE_TYPE = "node_type";
+
+ public static final String TEST_VIA_JMX = "test_via_jmx";
+ public static final String JMX_FQDN = "jmx_fqdn";
+ public static final String MAX_FPC_UPDATE_INTERVAL = "max_fpc_update_interval";
+ public static final String STATE_AUDIT_INTERVAL_MS = "state_audit_interval_ms";
+ public static final String REFRESH_STATE_AUDIT_INTERVAL_MS = "refresh_state_audit_interval_ms";
+
+ // AllSeemsWell types
+ public static final Boolean ALLNOTWELL = Boolean.FALSE;
+ public static final Boolean ALLSEEMSWELL = Boolean.TRUE;
+
+
}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorPropertiesException.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorPropertiesException.java
index 0d73e8b4..d3533f10 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorPropertiesException.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorPropertiesException.java
@@ -21,18 +21,21 @@
package org.onap.policy.common.im;
public class IntegrityMonitorPropertiesException extends IntegrityMonitorException {
- private static final long serialVersionUID = 1L;
- public IntegrityMonitorPropertiesException() {
- super();
- }
- public IntegrityMonitorPropertiesException(String message) {
- super(message);
- }
+ private static final long serialVersionUID = 1L;
- public IntegrityMonitorPropertiesException(Throwable cause) {
- super(cause);
- }
- public IntegrityMonitorPropertiesException(String message, Throwable cause) {
- super(message, cause);
- }
+ public IntegrityMonitorPropertiesException() {
+ super();
+ }
+
+ public IntegrityMonitorPropertiesException(String message) {
+ super(message);
+ }
+
+ public IntegrityMonitorPropertiesException(Throwable cause) {
+ super(cause);
+ }
+
+ public IntegrityMonitorPropertiesException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/StandbyStatusException.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/StandbyStatusException.java
index 3d27a4c6..352df386 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/StandbyStatusException.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/StandbyStatusException.java
@@ -21,34 +21,27 @@
package org.onap.policy.common.im;
public class StandbyStatusException extends IntegrityMonitorException {
- /**
- *
- */
- private static final long serialVersionUID = -5262512285108747134L;
-
- public StandbyStatusException()
- {
- super();
- }
-
- public StandbyStatusException(String message)
- {
- super(message);
- }
-
- public StandbyStatusException(Throwable cause)
- {
- super(cause);
- }
-
- public StandbyStatusException(String message, Throwable cause)
- {
- super(message, cause);
- }
-
- public StandbyStatusException(String message, Throwable cause,
- boolean enableSuppression, boolean writableStackTrace)
- {
- super(message, cause, enableSuppression, writableStackTrace);
- }
+
+ private static final long serialVersionUID = -5262512285108747134L;
+
+ public StandbyStatusException() {
+ super();
+ }
+
+ public StandbyStatusException(String message) {
+ super(message);
+ }
+
+ public StandbyStatusException(Throwable cause) {
+ super(cause);
+ }
+
+ public StandbyStatusException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public StandbyStatusException(String message, Throwable cause, boolean enableSuppression,
+ boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateChangeNotifier.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateChangeNotifier.java
index 0d4bd029..a678319f 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateChangeNotifier.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateChangeNotifier.java
@@ -19,9 +19,10 @@
*/
package org.onap.policy.common.im;
-
-import java.util.Observable;
-import java.util.Observer;
+
+import java.util.Observable;
+import java.util.Observer;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
@@ -39,41 +40,42 @@ import org.slf4j.LoggerFactory;
-
/**
- *
- * StateChangeNotifier class implements the Observer pattern and is used to distribute
- * state change notifications to any entity that registers a derived class with an
- * instance of the StateManagement class.
+ * StateChangeNotifier class implements the Observer pattern and is used to distribute state change
+ * notifications to any entity that registers a derived class with an instance of the
+ * StateManagement class.
*
*/
-public class StateChangeNotifier implements Observer {
- private static final Logger logger = LoggerFactory.getLogger(StateChangeNotifier.class);
- //The observable class
- StateManagement stateManagement;
-
- // A string argument passed by the observable class when
- // Observable:notifyObservers(Object arg) is called
- String message;
-
- @Override
- public void update(Observable o, Object arg) {
- this.stateManagement = (StateManagement) o;
- this.message = (String) arg;
- handleStateChange();
- }
-
- public void handleStateChange() {
- if(logger.isDebugEnabled()){
- logger.debug("handleStateChange, message: {}", this.message);
- }
- }
+public class StateChangeNotifier implements Observer {
+ private static final Logger logger = LoggerFactory.getLogger(StateChangeNotifier.class);
+ // The observable class
+ StateManagement stateManagement;
+
+ // A string argument passed by the observable class when
+ // Observable:notifyObservers(Object arg) is called
+ String message;
+
+ @Override
+ public void update(Observable observable, Object arg) {
+ this.stateManagement = (StateManagement) observable;
+ this.message = (String) arg;
+ handleStateChange();
+ }
+
+ /**
+ * Handle state change.
+ */
+ public void handleStateChange() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("handleStateChange, message: {}", this.message);
+ }
+ }
- public StateManagement getStateManagement() {
- return stateManagement;
- }
+ public StateManagement getStateManagement() {
+ return stateManagement;
+ }
- public String getMessage() {
- return message;
- }
-} \ No newline at end of file
+ public String getMessage() {
+ return message;
+ }
+}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateElement.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateElement.java
index fd5afc6a..030a0371 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateElement.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateElement.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -20,145 +20,119 @@
package org.onap.policy.common.im;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class StateElement {
- private static final Logger logger = LoggerFactory.getLogger(StateElement.class);
-
- String adminState = null;
- String opState = null;
- String availStatus = null;
- String standbyStatus = null;
- String actionName = null;
- String endingAdminState = null;
- String endingOpState = null;
- String endingAvailStatus = null;
- String endingStandbyStatus = null;
- String exception = null;
-
- public StateElement()
- {
- // Empty constructor
- }
-
- public String getAdminState()
- {
- return this.adminState;
- }
-
- public void setAdminState(String adminState)
- {
- this.adminState = adminState;
- }
-
- public String getOpState()
- {
- return this.opState;
- }
-
- public void setOpState(String opState)
- {
- this.opState = opState;
- }
-
- public String getAvailStatus()
- {
- return this.availStatus;
- }
-
- public void setAvailStatus(String availStatus)
- {
- this.availStatus = availStatus;
- }
-
- public String getStandbyStatus()
- {
- return this.standbyStatus;
- }
-
- public void setStandbyStatus(String standbyStatus)
- {
- this.standbyStatus = standbyStatus;
- }
-
- public String getActionName()
- {
- return this.actionName;
- }
-
- public void setActionName(String actionName)
- {
- this.actionName = actionName;
- }
-
- public String getEndingAdminState()
- {
- return this.endingAdminState;
- }
-
- public void setEndingAdminState(String endingAdminState)
- {
- this.endingAdminState = endingAdminState;
- }
-
- public String getEndingOpState()
- {
- return this.endingOpState;
- }
-
- public void setEndingOpState(String endingOpState)
- {
- this.endingOpState = endingOpState;
- }
-
- public String getEndingAvailStatus()
- {
- return this.endingAvailStatus;
- }
-
- public void setEndingAvailStatus(String endingAvailStatus)
- {
- this.endingAvailStatus = endingAvailStatus;
- }
-
- public String getEndingStandbyStatus()
- {
- return this.endingStandbyStatus;
- }
-
- public void setEndingStandbyStatus(String endingStandbyStatus)
- {
- this.endingStandbyStatus = endingStandbyStatus;
- }
-
- public String getException()
- {
- return this.exception;
- }
-
- public void setException(String exception)
- {
- this.exception = exception;
- }
-
- public void displayStateElement()
- {
- if(logger.isDebugEnabled()){
- logger.debug("adminState=[{}], opState=[{}], availStatus=[{}], standbyStatus=[{}], " +
- "actionName=[{}], endingAdminState=[{}], endingOpState=[{}], " +
- "endingAvailStatus=[{}], endingStandbyStatus=[{}], exception=[{}]",
- getAdminState(),
- getOpState(),
- getAvailStatus(),
- getStandbyStatus(),
- getActionName(),
- getEndingAdminState(),
- getEndingOpState(),
- getEndingAvailStatus(),
- getEndingStandbyStatus(),
- getException());
- }
- }
+ private static final Logger logger = LoggerFactory.getLogger(StateElement.class);
+
+ String adminState = null;
+ String opState = null;
+ String availStatus = null;
+ String standbyStatus = null;
+ String actionName = null;
+ String endingAdminState = null;
+ String endingOpState = null;
+ String endingAvailStatus = null;
+ String endingStandbyStatus = null;
+ String exception = null;
+
+ public StateElement() {
+ // Empty constructor
+ }
+
+ public String getAdminState() {
+ return this.adminState;
+ }
+
+ public void setAdminState(String adminState) {
+ this.adminState = adminState;
+ }
+
+ public String getOpState() {
+ return this.opState;
+ }
+
+ public void setOpState(String opState) {
+ this.opState = opState;
+ }
+
+ public String getAvailStatus() {
+ return this.availStatus;
+ }
+
+ public void setAvailStatus(String availStatus) {
+ this.availStatus = availStatus;
+ }
+
+ public String getStandbyStatus() {
+ return this.standbyStatus;
+ }
+
+ public void setStandbyStatus(String standbyStatus) {
+ this.standbyStatus = standbyStatus;
+ }
+
+ public String getActionName() {
+ return this.actionName;
+ }
+
+ public void setActionName(String actionName) {
+ this.actionName = actionName;
+ }
+
+ public String getEndingAdminState() {
+ return this.endingAdminState;
+ }
+
+ public void setEndingAdminState(String endingAdminState) {
+ this.endingAdminState = endingAdminState;
+ }
+
+ public String getEndingOpState() {
+ return this.endingOpState;
+ }
+
+ public void setEndingOpState(String endingOpState) {
+ this.endingOpState = endingOpState;
+ }
+
+ public String getEndingAvailStatus() {
+ return this.endingAvailStatus;
+ }
+
+ public void setEndingAvailStatus(String endingAvailStatus) {
+ this.endingAvailStatus = endingAvailStatus;
+ }
+
+ public String getEndingStandbyStatus() {
+ return this.endingStandbyStatus;
+ }
+
+ public void setEndingStandbyStatus(String endingStandbyStatus) {
+ this.endingStandbyStatus = endingStandbyStatus;
+ }
+
+ public String getException() {
+ return this.exception;
+ }
+
+ public void setException(String exception) {
+ this.exception = exception;
+ }
+
+ /**
+ * Display the state element.
+ */
+ public void displayStateElement() {
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "adminState=[{}], opState=[{}], availStatus=[{}], standbyStatus=[{}], "
+ + "actionName=[{}], endingAdminState=[{}], endingOpState=[{}], "
+ + "endingAvailStatus=[{}], endingStandbyStatus=[{}], exception=[{}]",
+ getAdminState(), getOpState(), getAvailStatus(), getStandbyStatus(), getActionName(),
+ getEndingAdminState(), getEndingOpState(), getEndingAvailStatus(), getEndingStandbyStatus(),
+ getException());
+ }
+ }
}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java
index 5cafd876..dbb278e7 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java
@@ -23,927 +23,952 @@ package org.onap.policy.common.im;
import java.util.Date;
import java.util.List;
import java.util.Observable;
+
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.FlushModeType;
import javax.persistence.LockModeType;
import javax.persistence.TypedQuery;
+
import org.onap.policy.common.im.exceptions.EntityRetrievalException;
import org.onap.policy.common.im.jpa.StateManagementEntity;
import org.onap.policy.common.utils.jpa.EntityMgrCloser;
import org.onap.policy.common.utils.jpa.EntityTransCloser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
/**
- *
- * StateManagement class handles all state changes per the Telecom standard X.731.
- * It extends the Observable class and, thus, has an interface to register
- * instances of the StateChangeNotifier/Observer class. When any state change
- * occurs, the registered observers are notified.
+ * StateManagement class handles all state changes per the Telecom standard X.731. It extends the
+ * Observable class and, thus, has an interface to register instances of the
+ * StateChangeNotifier/Observer class. When any state change occurs, the registered observers are
+ * notified.
*
*/
public class StateManagement extends Observable {
- private static final String RESOURCE_NAME = "resource";
- private static final String GET_STATE_MANAGEMENT_ENTITY_QUERY =
+ private static final String RESOURCE_NAME = "resource";
+ private static final String GET_STATE_MANAGEMENT_ENTITY_QUERY =
"Select p from StateManagementEntity p where p.resourceName=:" + RESOURCE_NAME;
- private static final Logger logger = LoggerFactory.getLogger(StateManagement.class);
- public static final String LOCKED = "locked";
- public static final String UNLOCKED = "unlocked";
- public static final String ENABLED = "enabled";
- public static final String DISABLED = "disabled";
- public static final String ENABLE_NOT_FAILED = "enableNotFailed";
- public static final String DISABLE_FAILED = "disableFailed";
- public static final String FAILED = "failed";
- public static final String DEPENDENCY = "dependency";
- public static final String DEPENDENCY_FAILED = "dependency,failed";
- public static final String DISABLE_DEPENDENCY = "disableDependency";
- public static final String ENABLE_NO_DEPENDENCY = "enableNoDependency";
- public static final String NULL_VALUE = "null";
- public static final String LOCK = "lock";
- public static final String UNLOCK = "unlock";
- public static final String PROMOTE = "promote";
- public static final String DEMOTE = "demote";
- public static final String HOT_STANDBY = "hotstandby";
- public static final String COLD_STANDBY = "coldstandby";
- public static final String PROVIDING_SERVICE = "providingservice";
-
- public static final String ADMIN_STATE = "adminState";
- public static final String OPERATION_STATE = "opState";
- public static final String AVAILABLE_STATUS= "availStatus";
- public static final String STANDBY_STATUS = "standbyStatus";
-
- private String resourceName = null;
- private String adminState = null;
- private String opState = null;
- private String availStatus = null;
- private String standbyStatus = null;
- private final EntityManagerFactory emf;
- private StateTransition st = null;
-
- /*
- * Guarantees single-threadedness of all actions. Only one action can execute
- * at a time. That avoids race conditions between actions being called
- * from different places.
- *
- * Some actions can take significant time to complete and, if another conflicting
- * action is called during its execution, it could put the system in an inconsistent
- * state. This very thing happened when demote was called and the active/standby
- * algorithm, seeing the state attempted to promote the PDP-D.
- *
- */
- private static final Object SYNCLOCK = new Object();
- private static final Object FLUSHLOCK = new Object();
-
- /**
- * StateManagement constructor
- * @param entityManagerFactory
- * @param resourceName
- * @throws StateManagementException
- */
- public StateManagement(final EntityManagerFactory entityManagerFactory, final String resourceName) throws StateManagementException
- {
- emf = entityManagerFactory;
- if(logger.isDebugEnabled()){
- logger.debug("StateManagement: constructor, resourceName: {}", resourceName);
- }
-
- final EntityManager em = emf.createEntityManager();
- try(EntityMgrCloser emc = new EntityMgrCloser(em);
- MyTransaction et = new MyTransaction(em)) {
-
- this.resourceName = resourceName;
- if(logger.isDebugEnabled()){
- logger.debug("resourceName = {}", this.resourceName);
- }
-
-
- try {
- //Create a StateManagementEntity object
- if(logger.isDebugEnabled()){
- logger.debug("findStateManagementEntity for {}", this.resourceName);
- }
- final StateManagementEntity sm = findStateManagementEntity(em, this.resourceName);
-
- //persist the administrative state
- if(logger.isDebugEnabled()){
- logger.debug("Persist adminstrative state, resourceName = {}", this.resourceName);
- }
- em.persist(sm);
+ private static final Logger logger = LoggerFactory.getLogger(StateManagement.class);
+ public static final String LOCKED = "locked";
+ public static final String UNLOCKED = "unlocked";
+ public static final String ENABLED = "enabled";
+ public static final String DISABLED = "disabled";
+ public static final String ENABLE_NOT_FAILED = "enableNotFailed";
+ public static final String DISABLE_FAILED = "disableFailed";
+ public static final String FAILED = "failed";
+ public static final String DEPENDENCY = "dependency";
+ public static final String DEPENDENCY_FAILED = "dependency,failed";
+ public static final String DISABLE_DEPENDENCY = "disableDependency";
+ public static final String ENABLE_NO_DEPENDENCY = "enableNoDependency";
+ public static final String NULL_VALUE = "null";
+ public static final String LOCK = "lock";
+ public static final String UNLOCK = "unlock";
+ public static final String PROMOTE = "promote";
+ public static final String DEMOTE = "demote";
+ public static final String HOT_STANDBY = "hotstandby";
+ public static final String COLD_STANDBY = "coldstandby";
+ public static final String PROVIDING_SERVICE = "providingservice";
+
+ public static final String ADMIN_STATE = "adminState";
+ public static final String OPERATION_STATE = "opState";
+ public static final String AVAILABLE_STATUS = "availStatus";
+ public static final String STANDBY_STATUS = "standbyStatus";
+
+ private String resourceName = null;
+ private String adminState = null;
+ private String opState = null;
+ private String availStatus = null;
+ private String standbyStatus = null;
+ private final EntityManagerFactory emf;
+ private StateTransition st = null;
+
+ /*
+ * Guarantees single-threadedness of all actions. Only one action can execute at a time. That
+ * avoids race conditions between actions being called from different places.
+ *
+ * Some actions can take significant time to complete and, if another conflicting action is
+ * called during its execution, it could put the system in an inconsistent state. This very
+ * thing happened when demote was called and the active/standby algorithm, seeing the state
+ * attempted to promote the PDP-D.
+ *
+ */
+ private static final Object SYNCLOCK = new Object();
+ private static final Object FLUSHLOCK = new Object();
+
+ /**
+ * StateManagement constructor.
+ *
+ * @param entityManagerFactory the entity manager factory
+ * @param resourceName the resource name
+ * @throws StateManagementException if an error occurs
+ */
+ public StateManagement(final EntityManagerFactory entityManagerFactory, final String resourceName)
+ throws StateManagementException {
+ emf = entityManagerFactory;
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateManagement: constructor, resourceName: {}", resourceName);
+ }
+
+ final EntityManager em = emf.createEntityManager();
+ try (EntityMgrCloser emc = new EntityMgrCloser(em); MyTransaction et = new MyTransaction(em)) {
+
+ this.resourceName = resourceName;
+ if (logger.isDebugEnabled()) {
+ logger.debug("resourceName = {}", this.resourceName);
+ }
+
+
+ try {
+ // Create a StateManagementEntity object
+ if (logger.isDebugEnabled()) {
+ logger.debug("findStateManagementEntity for {}", this.resourceName);
+ }
+ final StateManagementEntity sm = findStateManagementEntity(em, this.resourceName);
+
+ // persist the administrative state
+ if (logger.isDebugEnabled()) {
+ logger.debug("Persist adminstrative state, resourceName = {}", this.resourceName);
+ }
+ em.persist(sm);
+ et.commit();
+
+ // Load the StateTransition hash table
+ st = new StateTransition();
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateManagement: constructor end, resourceName: {}", this.resourceName);
+ }
+ } catch (final Exception ex) {
+ logger.error("StateManagement: constructor caught unexpected exception: ", ex);
+ throw new StateManagementException("StateManagement: Exception: " + ex.toString(), ex);
+ }
+ }
+ }
+
+ /**
+ * initializeState() is called when it is necessary to set the StateManagement to a known
+ * initial state. It preserves the Administrative State since it must persist across node
+ * reboots. Starting from this state, the IntegrityMonitory will determine the Operational State
+ * and the owning application will set the StandbyStatus.
+ */
+ public void initializeState() throws StateManagementException {
+ synchronized (SYNCLOCK) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("\nStateManagement: SYNCLOCK initializeState() operation for resourceName = {}\n",
+ this.resourceName);
+ logger.debug("StateManagement: initializeState() operation started, resourceName = {}",
+ this.resourceName);
+ }
+ final EntityManager em = emf.createEntityManager();
+
+ try (EntityMgrCloser emc = new EntityMgrCloser(em); MyTransaction et = new MyTransaction(em)) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("findStateManagementEntity for {}", this.resourceName);
+ }
+ final StateManagementEntity sm = findStateManagementEntity(em, this.resourceName);
+ // set state
+ sm.setAdminState(sm.getAdminState()); // preserve the Admin state
+ sm.setOpState(StateManagement.ENABLED);
+ sm.setAvailStatus(StateManagement.NULL_VALUE);
+ sm.setStandbyStatus(StateManagement.NULL_VALUE);
+
+ em.persist(sm);
+ et.commit();
+ setChanged();
+ notifyObservers(ADMIN_STATE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateManagement: initializeState() operation completed, resourceName = {}",
+ this.resourceName);
+ }
+ } catch (final Exception ex) {
+ logger.error("StateManagement.initializeState() caught unexpected exception: ", ex);
+ throw new StateManagementException("StateManagement.initializeState() Exception: " + ex);
+ }
+ }
+ }
+
+ /**
+ * lock() changes the administrative state to locked.
+ *
+ * @throws StateManagementException if an error occurs
+ */
+ public void lock() throws StateManagementException {
+ synchronized (SYNCLOCK) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("\nStateManagement: SYNCLOCK lock() operation for resourceName = {}\n", this.resourceName);
+ logger.debug("StateManagement: lock() operation started, resourceName = {}", this.resourceName);
+ }
+ final EntityManager em = emf.createEntityManager();
+
+ try (EntityMgrCloser emc = new EntityMgrCloser(em); MyTransaction et = new MyTransaction(em)) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("findStateManagementEntity for {}", this.resourceName);
+ }
+ final StateManagementEntity sm = findStateManagementEntity(em, this.resourceName);
+
+ final StateElement stateElement = st.getEndingState(sm.getAdminState(), sm.getOpState(),
+ sm.getAvailStatus(), sm.getStandbyStatus(), LOCK);
+
+ sm.setAdminState(stateElement.getEndingAdminState());
+ sm.setOpState(stateElement.getEndingOpState());
+ sm.setAvailStatus(stateElement.getEndingAvailStatus());
+ sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
+
+ em.persist(sm);
+ et.commit();
+ setChanged();
+ notifyObservers(ADMIN_STATE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateManagement: lock() operation completed, resourceName = {}", this.resourceName);
+ }
+ } catch (final Exception ex) {
+ logger.error("StateManagement.lock() caught unexpected exception: ", ex);
+ throw new StateManagementException("StateManagement.lock() Exception: " + ex.toString());
+ }
+ }
+ }
+
+ /**
+ * unlock() changes the administrative state to unlocked.
+ *
+ * @throws StateManagementException if an error occurs
+ */
+ public void unlock() throws StateManagementException {
+ synchronized (SYNCLOCK) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("\nStateManagement: SYNCLOCK unlock() operation for resourceName = {}\n",
+ this.resourceName);
+ logger.debug("StateManagement: unlock() operation started, resourceName = {}", this.resourceName);
+ }
+ final EntityManager em = emf.createEntityManager();
+
+ try (EntityMgrCloser emc = new EntityMgrCloser(em); MyTransaction et = new MyTransaction(em)) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("findStateManagementEntity for {}", this.resourceName);
+ }
+ final StateManagementEntity sm = findStateManagementEntity(em, this.resourceName);
+ final StateElement stateElement = st.getEndingState(sm.getAdminState(), sm.getOpState(),
+ sm.getAvailStatus(), sm.getStandbyStatus(), UNLOCK);
+ // set transition state
+ sm.setAdminState(stateElement.getEndingAdminState());
+ sm.setOpState(stateElement.getEndingOpState());
+ sm.setAvailStatus(stateElement.getEndingAvailStatus());
+ sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
+
+ em.persist(sm);
+ et.commit();
+ setChanged();
+ notifyObservers(ADMIN_STATE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateManagement: unlock() operation completed, resourceName = {}", this.resourceName);
+ }
+ } catch (final Exception ex) {
+ logger.error("StateManagement.unlock() caught unexpected exception: ", ex);
+ throw new StateManagementException("StateManagement.unlock() Exception: " + ex);
+ }
+ }
+ }
+
+ /**
+ * enableNotFailed() removes the "failed" availability status and changes the operational state
+ * to enabled if no dependency is also failed.
+ *
+ * @throws StateManagementException if an error occurs
+ */
+ public void enableNotFailed() throws StateManagementException {
+ synchronized (SYNCLOCK) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("\nStateManagement: SYNCLOCK enabledNotFailed() operation for resourceName = {}\n",
+ this.resourceName);
+ logger.debug("StateManagement: enableNotFailed() operation started, resourceName = {}",
+ this.resourceName);
+ }
+ final EntityManager em = emf.createEntityManager();
+
+ try (EntityMgrCloser emc = new EntityMgrCloser(em); MyTransaction et = new MyTransaction(em)) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("findStateManagementEntity for {}", this.resourceName);
+ }
+ final StateManagementEntity sm = findStateManagementEntity(em, this.resourceName);
+ final StateElement stateElement = st.getEndingState(sm.getAdminState(), sm.getOpState(),
+ sm.getAvailStatus(), sm.getStandbyStatus(), ENABLE_NOT_FAILED);
+ // set transition state
+ sm.setAdminState(stateElement.getEndingAdminState());
+ sm.setOpState(stateElement.getEndingOpState());
+ sm.setAvailStatus(stateElement.getEndingAvailStatus());
+ sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
+
+ em.persist(sm);
+ et.commit();
+
+ setChanged();
+ notifyObservers(OPERATION_STATE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateManagement enableNotFailed() operation completed, resourceName = {}",
+ this.resourceName);
+ }
+ } catch (final Exception ex) {
+ logger.error("StateManagement.enableNotFailed() caught unexpected exception: ", ex);
+ throw new StateManagementException("StateManagement.enableNotFailed() Exception: " + ex);
+ }
+ }
+ }
+
+ /**
+ * disableFailed() changes the operational state to disabled and adds availability status of
+ * "failed".
+ *
+ * @throws StateManagementException if an error occurs
+ */
+ public void disableFailed() throws StateManagementException {
+ synchronized (SYNCLOCK) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("\nStateManagement: SYNCLOCK disabledFailed() operation for resourceName = {}\n",
+ this.resourceName);
+ logger.debug("StateManagement: disableFailed() operation started, resourceName = {}",
+ this.resourceName);
+ }
+ final EntityManager em = emf.createEntityManager();
+
+ try (EntityMgrCloser emc = new EntityMgrCloser(em); MyTransaction et = new MyTransaction(em)) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("findStateManagementEntity for {}", this.resourceName);
+ }
+ final StateManagementEntity sm = findStateManagementEntity(em, this.resourceName);
+ final StateElement stateElement = st.getEndingState(sm.getAdminState(), sm.getOpState(),
+ sm.getAvailStatus(), sm.getStandbyStatus(), DISABLE_FAILED);
+ // set transition state
+ sm.setAdminState(stateElement.getEndingAdminState());
+ sm.setOpState(stateElement.getEndingOpState());
+ sm.setAvailStatus(stateElement.getEndingAvailStatus());
+ sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
+
+ em.persist(sm);
+ et.commit();
+ setChanged();
+ notifyObservers(OPERATION_STATE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateManagement: disableFailed() operation completed, resourceName = {}",
+ this.resourceName);
+ }
+ } catch (final Exception ex) {
+ logger.error("StateManagement.disableFailed() caught unexpected exception: ", ex);
+ throw new StateManagementException("StateManagement.disableFailed() Exception: " + ex);
+ }
+ }
+ }
+
+ /**
+ * This version of disableFailed is to be used to manipulate the state of a remote resource in
+ * the event that remote resource has failed but its state is still showing that it is viable.
+ *
+ * @throws StateManagementException if an error occurs
+ */
+ public void disableFailed(final String otherResourceName) throws StateManagementException {
+ synchronized (SYNCLOCK) {
+ if (otherResourceName == null) {
+ logger.error("\nStateManagement: SYNCLOCK disableFailed(otherResourceName) operation: resourceName is "
+ + "NULL.\n");
+ return;
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("\nStateManagement: SYNCLOCK disabledFailed(otherResourceName) operation for resourceName "
+ + "= {}\n", otherResourceName);
+ logger.debug("StateManagement: disableFailed(otherResourceName) operation started, resourceName = {}",
+ otherResourceName);
+ }
+ final EntityManager em = emf.createEntityManager();
+
+ try (EntityMgrCloser emc = new EntityMgrCloser(em); MyTransaction et = new MyTransaction(em)) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("findStateManagementEntity for " + otherResourceName);
+ }
+ final StateManagementEntity sm = findStateManagementEntity(em, otherResourceName);
+ final StateElement stateElement = st.getEndingState(sm.getAdminState(), sm.getOpState(),
+ sm.getAvailStatus(), sm.getStandbyStatus(), DISABLE_FAILED);
+ // set transition state
+ sm.setAdminState(stateElement.getEndingAdminState());
+ sm.setOpState(stateElement.getEndingOpState());
+ sm.setAvailStatus(stateElement.getEndingAvailStatus());
+ sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
+
+ em.persist(sm);
+ et.commit();
+ setChanged();
+ notifyObservers(OPERATION_STATE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "StateManagement: disableFailed(otherResourceName) operation completed, resourceName = {}",
+ otherResourceName);
+ }
+ } catch (final Exception ex) {
+ logger.error("StateManagement.disableFailed(otherResourceName) caught unexpected exception: ", ex);
+ throw new StateManagementException("StateManagement.disableFailed(otherResourceName) Exception: " + ex);
+ }
+ }
+ }
+
+ /**
+ * disableDependency() changes operational state to disabled and adds availability status of
+ * "dependency".
+ *
+ * @throws StateManagementException if an error occurs
+ */
+ public void disableDependency() throws StateManagementException {
+ synchronized (SYNCLOCK) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("\nStateManagement: SYNCLOCK disableDependency() operation for resourceName = {}\n",
+ this.resourceName);
+ logger.debug("StateManagement: disableDependency() operation started, resourceName = {}",
+ this.resourceName);
+ }
+ final EntityManager em = emf.createEntityManager();
+
+ try (EntityMgrCloser emc = new EntityMgrCloser(em); MyTransaction et = new MyTransaction(em)) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("findStateManagementEntity for {}", this.resourceName);
+ }
+ final StateManagementEntity sm = findStateManagementEntity(em, this.resourceName);
+ final StateElement stateElement = st.getEndingState(sm.getAdminState(), sm.getOpState(),
+ sm.getAvailStatus(), sm.getStandbyStatus(), DISABLE_DEPENDENCY);
+ // set transition state
+ sm.setAdminState(stateElement.getEndingAdminState());
+ sm.setOpState(stateElement.getEndingOpState());
+ sm.setAvailStatus(stateElement.getEndingAvailStatus());
+ sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
+
+ em.persist(sm);
+ et.commit();
+ setChanged();
+ notifyObservers(OPERATION_STATE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateManagement: disableDependency() operation completed, resourceName = {}",
+ this.resourceName);
+ }
+ } catch (final Exception ex) {
+ logger.error("StateManagement.disableDependency() caught unexpected exception: ", ex);
+ throw new StateManagementException("StateManagement.disableDependency() Exception: " + ex);
+ }
+ }
+ }
+
+ /**
+ * enableNoDependency() removes the availability status of "dependency " and will change the
+ * operational state to enabled if not otherwise failed.
+ *
+ * @throws StateManagementException if an error occurs
+ */
+ public void enableNoDependency() throws StateManagementException {
+ synchronized (SYNCLOCK) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("\nStateManagement: SYNCLOCK enableNoDependency() operation for resourceName = {}\n",
+ this.resourceName);
+ logger.debug("StateManagement: enableNoDependency() operation started, resourceName = {}",
+ this.resourceName);
+ }
+ final EntityManager em = emf.createEntityManager();
+
+ try (EntityMgrCloser emc = new EntityMgrCloser(em); MyTransaction et = new MyTransaction(em)) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("findStateManagementEntity for {}", this.resourceName);
+ }
+ final StateManagementEntity sm = findStateManagementEntity(em, this.resourceName);
+ final StateElement stateElement = st.getEndingState(sm.getAdminState(), sm.getOpState(),
+ sm.getAvailStatus(), sm.getStandbyStatus(), ENABLE_NO_DEPENDENCY);
+ // set transition state
+ sm.setAdminState(stateElement.getEndingAdminState());
+ sm.setOpState(stateElement.getEndingOpState());
+ sm.setAvailStatus(stateElement.getEndingAvailStatus());
+ sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
+
+ em.persist(sm);
+ et.commit();
+ setChanged();
+ notifyObservers(OPERATION_STATE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateManagement: enableNoDependency() operation completed, resourceName = {}",
+ this.resourceName);
+ }
+ } catch (final Exception ex) {
+ logger.error("StateManagement.enableNoDependency() caught unexpected exception: ", ex);
+ throw new StateManagementException("StateManagement.enableNoDependency() Exception: " + ex);
+ }
+ }
+ }
+
+ /**
+ * promote() changes the standby status to providingservice if not otherwise failed.
+ *
+ * @throws StandbyStatusException if the status fails to change
+ * @throws StateManagementException if an error occurs when promoting the status
+ */
+ public void promote() throws StandbyStatusException, StateManagementException {
+ synchronized (SYNCLOCK) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("\nStateManagement: SYNCLOCK promote() operation for resourceName = {}\n",
+ this.resourceName);
+ logger.debug("StateManagement: promote() operation started, resourceName = {}", this.resourceName);
+ }
+
+ StateManagementEntity sm;
+
+ final EntityManager em = emf.createEntityManager();
+
+ try (EntityMgrCloser emc = new EntityMgrCloser(em); MyTransaction et = new MyTransaction(em)) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("findStateManagementEntity for {}", this.resourceName);
+ }
+ sm = findStateManagementEntity(em, this.resourceName);
+ final StateElement stateElement = st.getEndingState(sm.getAdminState(), sm.getOpState(),
+ sm.getAvailStatus(), sm.getStandbyStatus(), PROMOTE);
+ // set transition state
+ sm.setAdminState(stateElement.getEndingAdminState());
+ sm.setOpState(stateElement.getEndingOpState());
+ sm.setAvailStatus(stateElement.getEndingAvailStatus());
+ sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
+
+ em.persist(sm);
+ et.commit();
+ setChanged();
+ notifyObservers(STANDBY_STATUS);
+ } catch (final Exception ex) {
+ logger.error("StateManagement.promote() caught unexpected exception: ", ex);
+ throw new StateManagementException("StateManagement.promote() Exception: " + ex);
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateManagement: promote() operation completed, resourceName = ", this.resourceName);
+ }
+ if (sm.getStandbyStatus().equals(StateManagement.COLD_STANDBY)) {
+ final String msg =
+ "Failure to promote " + this.resourceName + " StandbyStatus = " + StateManagement.COLD_STANDBY;
+ throw new StandbyStatusException(msg);
+ }
+ }
+ }
+
+ /**
+ * demote() changes standbystatus to hotstandby or, if failed, coldstandby.
+ *
+ * @throws StateManagementException if an error occurs
+ */
+ public void demote() throws StateManagementException {
+ synchronized (SYNCLOCK) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("\nStateManagement: SYNCLOCK demote() operation for resourceName = \n", this.resourceName);
+ logger.debug("StateManagement: demote() operation started, resourceName = {}", this.resourceName);
+ }
+ final EntityManager em = emf.createEntityManager();
+
+ try (EntityMgrCloser emc = new EntityMgrCloser(em); MyTransaction et = new MyTransaction(em)) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("findStateManagementEntity for {}", this.resourceName);
+ }
+ final StateManagementEntity sm = findStateManagementEntity(em, this.resourceName);
+ final StateElement stateElement = st.getEndingState(sm.getAdminState(), sm.getOpState(),
+ sm.getAvailStatus(), sm.getStandbyStatus(), DEMOTE);
+ // set transition state
+ sm.setAdminState(stateElement.getEndingAdminState());
+ sm.setOpState(stateElement.getEndingOpState());
+ sm.setAvailStatus(stateElement.getEndingAvailStatus());
+ sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
+
+ em.persist(sm);
+ et.commit();
+ setChanged();
+ notifyObservers(STANDBY_STATUS);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateManagement: demote() operation completed, resourceName = {}", this.resourceName);
+ }
+ } catch (final Exception ex) {
+ logger.error("StateManagement.demote() caught unexpected exception: ", ex);
+ throw new StateManagementException("StateManagement.demote() Exception: " + ex);
+ }
+ }
+ }
+
+ /**
+ * Only used for a remote resource. It will not notify observers. It is used only in cases where
+ * the remote resource has failed is such a way that it cannot update its own states. In
+ * particular this is observed by PDP-D DroolsPdpsElectionHandler when it is trying to determine
+ * which PDP-D should be designated as the lead.
+ *
+ * @param otherResourceName the resouce name
+ * @throws StateManagementException if an error occurs
+ */
+ public void demote(final String otherResourceName) throws StateManagementException {
+ synchronized (SYNCLOCK) {
+ if (otherResourceName == null) {
+ logger.error(
+ "\nStateManagement: SYNCLOCK demote(otherResourceName) operation: resourceName is NULL.\n");
+ return;
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("\nStateManagement: SYNCLOCK demote(otherResourceName) operation for resourceName = {}\n",
+ otherResourceName);
+ }
+ final EntityManager em = emf.createEntityManager();
+
+ try (EntityMgrCloser emc = new EntityMgrCloser(em); MyTransaction et = new MyTransaction(em)) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateManagement: SYNCLOCK demote(otherResourceName) findStateManagementEntity for {}",
+ otherResourceName);
+ }
+ final StateManagementEntity sm = findStateManagementEntity(em, otherResourceName);
+ final StateElement stateElement = st.getEndingState(sm.getAdminState(), sm.getOpState(),
+ sm.getAvailStatus(), sm.getStandbyStatus(), DEMOTE);
+ // set transition state
+ sm.setAdminState(stateElement.getEndingAdminState());
+ sm.setOpState(stateElement.getEndingOpState());
+ sm.setAvailStatus(stateElement.getEndingAvailStatus());
+ sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
+
+ em.persist(sm);
+ et.commit();
+ // We don't notify observers because this is assumed to be a remote resource
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateManagement: demote(otherResourceName) operation completed, resourceName = {}",
+ otherResourceName);
+ }
+ } catch (final Exception ex) {
+ logger.error("StateManagement.demote(otherResourceName) caught unexpected exception: ", ex);
+ throw new StateManagementException("StateManagement.demote(otherResourceName) Exception: " + ex);
+ }
+ }
+ }
+
+ /**
+ * Get the administration state.
+ *
+ * @return the administration state
+ */
+ public String getAdminState() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateManagement(6/1/16): getAdminState for resourceName {}", this.resourceName);
+ }
+
+ final EntityManager em = emf.createEntityManager();
+ try (final EntityMgrCloser emc = new EntityMgrCloser(em)) {
+ final TypedQuery<StateManagementEntity> query =
+ em.createQuery(GET_STATE_MANAGEMENT_ENTITY_QUERY, StateManagementEntity.class);
+
+ query.setParameter(RESOURCE_NAME, this.resourceName);
+
+ // Just test that we are retrieving the right object
+ final List<StateManagementEntity> resourceList =
+ query.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+ if (!resourceList.isEmpty()) {
+ // exist
+ final StateManagementEntity stateManagementEntity = resourceList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(stateManagementEntity);
+ this.adminState = stateManagementEntity.getAdminState();
+ } else {
+ this.adminState = null;
+ }
+ } catch (final Exception ex) {
+ logger.error("StateManagement: getAdminState exception: {}", ex.toString(), ex);
+ }
+
+ return this.adminState;
+ }
+
+ /**
+ * Get the operational state.
+ *
+ * @return the operational state
+ */
+ public String getOpState() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateManagement(6/1/16): getOpState for resourceName {}", this.resourceName);
+ }
+
+ final EntityManager em = emf.createEntityManager();
+ try (EntityMgrCloser emc = new EntityMgrCloser(em)) {
+ final TypedQuery<StateManagementEntity> query =
+ em.createQuery(GET_STATE_MANAGEMENT_ENTITY_QUERY, StateManagementEntity.class);
+
+ query.setParameter(RESOURCE_NAME, this.resourceName);
+
+ // Just test that we are retrieving the right object
+ final List<StateManagementEntity> resourceList =
+ query.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+ if (!resourceList.isEmpty()) {
+ // exist
+ final StateManagementEntity stateManagementEntity = resourceList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(stateManagementEntity);
+ this.opState = stateManagementEntity.getOpState();
+ } else {
+ this.opState = null;
+ }
+ } catch (final Exception ex) {
+ logger.error("StateManagement: getOpState exception: {}", ex.toString(), ex);
+ }
+
+ return this.opState;
+ }
+
+ /**
+ * Get the availability status.
+ *
+ * @return the availability status
+ */
+ public String getAvailStatus() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateManagement(6/1/16): getAvailStatus for resourceName {}", this.resourceName);
+ }
+
+ final EntityManager em = emf.createEntityManager();
+ try (EntityMgrCloser emc = new EntityMgrCloser(em)) {
+ final TypedQuery<StateManagementEntity> query =
+ em.createQuery(GET_STATE_MANAGEMENT_ENTITY_QUERY, StateManagementEntity.class);
+
+ query.setParameter(RESOURCE_NAME, this.resourceName);
+
+ // Just test that we are retrieving the right object
+ final List<StateManagementEntity> resourceList =
+ query.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+ if (!resourceList.isEmpty()) {
+ // exist
+ final StateManagementEntity stateManagementEntity = resourceList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(stateManagementEntity);
+ this.availStatus = stateManagementEntity.getAvailStatus();
+ } else {
+ this.availStatus = null;
+ }
+ } catch (final Exception ex) {
+ logger.error("StateManagement: getAvailStatus exception: {}", ex.toString(), ex);
+ }
+
+ return this.availStatus;
+ }
+
+ /**
+ * Get the standy status.
+ *
+ * @return the standby status
+ */
+ public String getStandbyStatus() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateManagement(6/1/16): getStandbyStatus for resourceName {}", this.resourceName);
+ }
+
+ final EntityManager em = emf.createEntityManager();
+ try (EntityMgrCloser emc = new EntityMgrCloser(em)) {
+ final TypedQuery<StateManagementEntity> query =
+ em.createQuery(GET_STATE_MANAGEMENT_ENTITY_QUERY, StateManagementEntity.class);
+
+ query.setParameter(RESOURCE_NAME, this.resourceName);
+
+ // Just test that we are retrieving the right object
+ final List<StateManagementEntity> resourceList =
+ query.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+ if (!resourceList.isEmpty()) {
+ // exist
+ final StateManagementEntity stateManagementEntity = resourceList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(stateManagementEntity);
+ this.standbyStatus = stateManagementEntity.getStandbyStatus();
+ } else {
+ this.standbyStatus = null;
+ }
+ } catch (final Exception ex) {
+ logger.error("StateManagement: getStandbyStatus exception: {}", ex.toString(), ex);
+ }
+
+ return this.standbyStatus;
+ }
+
+ /**
+ * Get the standbystatus of a particular resource.
+ *
+ * @param otherResourceName the resource
+ * @return the standby status
+ */
+ public String getStandbyStatus(final String otherResourceName) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateManagement: getStandbyStatus: Entering, resourceName='{}'", otherResourceName);
+ }
+
+ String tempStandbyStatus = null;
+
+ // The transaction is required for the LockModeType
+ final EntityManager em = emf.createEntityManager();
+
+ try (EntityMgrCloser emc = new EntityMgrCloser(em); MyTransaction et = new MyTransaction(em)) {
+
+ final TypedQuery<StateManagementEntity> stateManagementListQuery =
+ em.createQuery(GET_STATE_MANAGEMENT_ENTITY_QUERY, StateManagementEntity.class);
+ stateManagementListQuery.setParameter(RESOURCE_NAME, otherResourceName);
+ final List<StateManagementEntity> stateManagementList = stateManagementListQuery
+ .setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+ if (!stateManagementList.isEmpty()) {
+ final StateManagementEntity stateManagementEntity = stateManagementList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(stateManagementEntity);
+ tempStandbyStatus = stateManagementEntity.getStandbyStatus();
+ if (logger.isDebugEnabled()) {
+ logger.debug("getStandbyStatus: resourceName ={} has standbyStatus={}", otherResourceName,
+ tempStandbyStatus);
+ }
+ } else {
+ logger.error("getStandbyStatus: resourceName ={} not found in statemanagemententity table",
+ otherResourceName);
+ }
+
et.commit();
-
- //Load the StateTransition hash table
- st = new StateTransition();
-
- if(logger.isDebugEnabled()){
- logger.debug("StateManagement: constructor end, resourceName: {}", this.resourceName);
- }
- } catch(final Exception ex) {
- logger.error("StateManagement: constructor caught unexpected exception: ", ex);
- throw new StateManagementException("StateManagement: Exception: " + ex.toString(), ex);
- }
- }
- }
-
- /**
- * initializeState() is called when it is necessary to set the StateManagement to a known initial state.
- * It preserves the Administrative State since it must persist across node reboots.
- * Starting from this state, the IntegrityMonitory will determine the Operational State and the
- * owning application will set the StandbyStatus.
- */
- public void initializeState() throws StateManagementException
- {
- synchronized (SYNCLOCK){
- if(logger.isDebugEnabled()){
- logger.debug("\nStateManagement: SYNCLOCK initializeState() operation for resourceName = {}\n", this.resourceName);
- logger.debug("StateManagement: initializeState() operation started, resourceName = {}", this.resourceName);
- }
- final EntityManager em = emf.createEntityManager();
-
- try(EntityMgrCloser emc = new EntityMgrCloser(em);
- MyTransaction et = new MyTransaction(em)) {
-
- if(logger.isDebugEnabled()){
- logger.debug("findStateManagementEntity for {}", this.resourceName);
- }
- final StateManagementEntity sm = findStateManagementEntity(em, this.resourceName);
- // set state
- sm.setAdminState(sm.getAdminState()); //preserve the Admin state
- sm.setOpState(StateManagement.ENABLED);
- sm.setAvailStatus(StateManagement.NULL_VALUE);
- sm.setStandbyStatus(StateManagement.NULL_VALUE);
-
- em.persist(sm);
- et.commit();
- setChanged();
- notifyObservers(ADMIN_STATE);
-
- if(logger.isDebugEnabled()){
- logger.debug("StateManagement: initializeState() operation completed, resourceName = {}", this.resourceName);
- }
- } catch(final Exception ex) {
- logger.error("StateManagement.initializeState() caught unexpected exception: ", ex);
- throw new StateManagementException("StateManagement.initializeState() Exception: " + ex);
- }
- }
- }
-
- /**
- * lock() changes the administrative state to locked.
- * @throws StateManagementException
- */
- public void lock() throws StateManagementException
- {
- synchronized (SYNCLOCK){
- if(logger.isDebugEnabled()){
- logger.debug("\nStateManagement: SYNCLOCK lock() operation for resourceName = {}\n", this.resourceName);
- logger.debug("StateManagement: lock() operation started, resourceName = {}", this.resourceName);
- }
- final EntityManager em = emf.createEntityManager();
-
- try(EntityMgrCloser emc = new EntityMgrCloser(em);
- MyTransaction et = new MyTransaction(em)) {
-
- if(logger.isDebugEnabled()){
- logger.debug("findStateManagementEntity for {}", this.resourceName);
- }
- final StateManagementEntity sm = findStateManagementEntity(em, this.resourceName);
-
- final StateElement stateElement = st.getEndingState(sm.getAdminState(), sm.getOpState(),
- sm.getAvailStatus(), sm.getStandbyStatus(), LOCK);
-
- sm.setAdminState(stateElement.getEndingAdminState());
- sm.setOpState(stateElement.getEndingOpState());
- sm.setAvailStatus(stateElement.getEndingAvailStatus());
- sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
-
- em.persist(sm);
- et.commit();
- setChanged();
- notifyObservers(ADMIN_STATE);
-
- if(logger.isDebugEnabled()){
- logger.debug("StateManagement: lock() operation completed, resourceName = {}", this.resourceName);
- }
- } catch(final Exception ex) {
- logger.error("StateManagement.lock() caught unexpected exception: ", ex);
- throw new StateManagementException("StateManagement.lock() Exception: " + ex.toString());
- }
- }
- }
-
- /**
- * unlock() changes the administrative state to unlocked.
- * @throws StateManagementException
- */
- public void unlock() throws StateManagementException
- {
- synchronized (SYNCLOCK){
- if(logger.isDebugEnabled()){
- logger.debug("\nStateManagement: SYNCLOCK unlock() operation for resourceName = {}\n", this.resourceName);
- logger.debug("StateManagement: unlock() operation started, resourceName = {}", this.resourceName);
- }
- final EntityManager em = emf.createEntityManager();
-
- try(EntityMgrCloser emc = new EntityMgrCloser(em);
- MyTransaction et = new MyTransaction(em)) {
-
- if(logger.isDebugEnabled()){
- logger.debug("findStateManagementEntity for {}", this.resourceName);
- }
- final StateManagementEntity sm = findStateManagementEntity(em, this.resourceName);
- final StateElement stateElement = st.getEndingState(sm.getAdminState(), sm.getOpState(),
- sm.getAvailStatus(), sm.getStandbyStatus(), UNLOCK);
- // set transition state
- sm.setAdminState(stateElement.getEndingAdminState());
- sm.setOpState(stateElement.getEndingOpState());
- sm.setAvailStatus(stateElement.getEndingAvailStatus());
- sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
-
- em.persist(sm);
- et.commit();
- setChanged();
- notifyObservers(ADMIN_STATE);
-
- if(logger.isDebugEnabled()){
- logger.debug("StateManagement: unlock() operation completed, resourceName = {}", this.resourceName);
- }
- } catch(final Exception ex) {
- logger.error("StateManagement.unlock() caught unexpected exception: ", ex);
- throw new StateManagementException("StateManagement.unlock() Exception: " + ex);
- }
- }
- }
-
- /**
- * enableNotFailed() removes the "failed" availability status and changes the operational
- * state to enabled if no dependency is also failed.
- * @throws StateManagementException
- */
- public void enableNotFailed() throws StateManagementException
- {
- synchronized (SYNCLOCK){
- if(logger.isDebugEnabled()){
- logger.debug("\nStateManagement: SYNCLOCK enabledNotFailed() operation for resourceName = {}\n", this.resourceName);
- logger.debug("StateManagement: enableNotFailed() operation started, resourceName = {}", this.resourceName);
- }
- final EntityManager em = emf.createEntityManager();
-
- try(EntityMgrCloser emc = new EntityMgrCloser(em);
- MyTransaction et = new MyTransaction(em)) {
-
- if(logger.isDebugEnabled()){
- logger.debug("findStateManagementEntity for {}", this.resourceName);
- }
- final StateManagementEntity sm = findStateManagementEntity(em, this.resourceName);
- final StateElement stateElement = st.getEndingState(sm.getAdminState(), sm.getOpState(),
- sm.getAvailStatus(), sm.getStandbyStatus(), ENABLE_NOT_FAILED);
- // set transition state
- sm.setAdminState(stateElement.getEndingAdminState());
- sm.setOpState(stateElement.getEndingOpState());
- sm.setAvailStatus(stateElement.getEndingAvailStatus());
- sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
-
- em.persist(sm);
- et.commit();
-
- setChanged();
- notifyObservers(OPERATION_STATE);
-
- if(logger.isDebugEnabled()){
- logger.debug("StateManagement enableNotFailed() operation completed, resourceName = {}", this.resourceName);
- }
- } catch(final Exception ex) {
- logger.error("StateManagement.enableNotFailed() caught unexpected exception: ", ex);
- throw new StateManagementException("StateManagement.enableNotFailed() Exception: " + ex);
- }
- }
- }
-
- /**
- * disableFailed() changes the operational state to disabled and adds availability status of "failed"
- * @throws StateManagementException
- */
- public void disableFailed() throws StateManagementException
- {
- synchronized (SYNCLOCK){
- if(logger.isDebugEnabled()){
- logger.debug("\nStateManagement: SYNCLOCK disabledFailed() operation for resourceName = {}\n", this.resourceName);
- logger.debug("StateManagement: disableFailed() operation started, resourceName = {}", this.resourceName);
- }
- final EntityManager em = emf.createEntityManager();
-
- try(EntityMgrCloser emc = new EntityMgrCloser(em);
- MyTransaction et = new MyTransaction(em)) {
-
- if(logger.isDebugEnabled()){
- logger.debug("findStateManagementEntity for {}", this.resourceName);
- }
- final StateManagementEntity sm = findStateManagementEntity(em, this.resourceName);
- final StateElement stateElement = st.getEndingState(sm.getAdminState(), sm.getOpState(),
- sm.getAvailStatus(), sm.getStandbyStatus(), DISABLE_FAILED);
- // set transition state
- sm.setAdminState(stateElement.getEndingAdminState());
- sm.setOpState(stateElement.getEndingOpState());
- sm.setAvailStatus(stateElement.getEndingAvailStatus());
- sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
-
- em.persist(sm);
- et.commit();
- setChanged();
- notifyObservers(OPERATION_STATE);
-
- if(logger.isDebugEnabled()){
- logger.debug("StateManagement: disableFailed() operation completed, resourceName = {}", this.resourceName);
- }
- } catch(final Exception ex) {
- logger.error("StateManagement.disableFailed() caught unexpected exception: ", ex);
- throw new StateManagementException("StateManagement.disableFailed() Exception: " + ex);
- }
- }
- }
- /**
- * This version of disableFailed is to be used to manipulate the state of a remote resource in the event
- * that remote resource has failed but its state is still showing that it is viable.
- * @throws StateManagementException
- */
- public void disableFailed(final String otherResourceName) throws StateManagementException
- {
- synchronized (SYNCLOCK){
- if(otherResourceName == null){
- logger.error("\nStateManagement: SYNCLOCK disableFailed(otherResourceName) operation: resourceName is NULL.\n");
- return;
- }
- if(logger.isDebugEnabled()){
- logger.debug("\nStateManagement: SYNCLOCK disabledFailed(otherResourceName) operation for resourceName = {}\n",
- otherResourceName);
- logger.debug("StateManagement: disableFailed(otherResourceName) operation started, resourceName = {}",
- otherResourceName);
- }
- final EntityManager em = emf.createEntityManager();
-
- try(EntityMgrCloser emc = new EntityMgrCloser(em);
- MyTransaction et = new MyTransaction(em)) {
-
- if(logger.isDebugEnabled()){
- logger.debug("findStateManagementEntity for " + otherResourceName);
- }
- final StateManagementEntity sm = findStateManagementEntity(em, otherResourceName);
- final StateElement stateElement = st.getEndingState(sm.getAdminState(), sm.getOpState(),
- sm.getAvailStatus(), sm.getStandbyStatus(), DISABLE_FAILED);
- // set transition state
- sm.setAdminState(stateElement.getEndingAdminState());
- sm.setOpState(stateElement.getEndingOpState());
- sm.setAvailStatus(stateElement.getEndingAvailStatus());
- sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
-
- em.persist(sm);
- et.commit();
- setChanged();
- notifyObservers(OPERATION_STATE);
-
- if(logger.isDebugEnabled()){
- logger.debug("StateManagement: disableFailed(otherResourceName) operation completed, resourceName = {}",
- otherResourceName);
- }
- } catch(final Exception ex) {
- logger.error("StateManagement.disableFailed(otherResourceName) caught unexpected exception: ", ex);
- throw new StateManagementException("StateManagement.disableFailed(otherResourceName) Exception: " + ex);
- }
- }
- }
-
- /**
- * disableDependency() changes operational state to disabled and adds availability status of "dependency"
- * @throws StateManagementException
- */
- public void disableDependency() throws StateManagementException
- {
- synchronized (SYNCLOCK){
- if(logger.isDebugEnabled()){
- logger.debug("\nStateManagement: SYNCLOCK disableDependency() operation for resourceName = {}\n", this.resourceName);
- logger.debug("StateManagement: disableDependency() operation started, resourceName = {}", this.resourceName);
- }
- final EntityManager em = emf.createEntityManager();
-
- try(EntityMgrCloser emc = new EntityMgrCloser(em);
- MyTransaction et = new MyTransaction(em)) {
-
- if(logger.isDebugEnabled()){
- logger.debug("findStateManagementEntity for {}", this.resourceName);
- }
- final StateManagementEntity sm = findStateManagementEntity(em, this.resourceName);
- final StateElement stateElement = st.getEndingState(sm.getAdminState(), sm.getOpState(),
- sm.getAvailStatus(), sm.getStandbyStatus(), DISABLE_DEPENDENCY);
- // set transition state
- sm.setAdminState(stateElement.getEndingAdminState());
- sm.setOpState(stateElement.getEndingOpState());
- sm.setAvailStatus(stateElement.getEndingAvailStatus());
- sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
-
- em.persist(sm);
- et.commit();
- setChanged();
- notifyObservers(OPERATION_STATE);
-
- if(logger.isDebugEnabled()){
- logger.debug("StateManagement: disableDependency() operation completed, resourceName = {}", this.resourceName);
- }
- } catch(final Exception ex) {
- logger.error("StateManagement.disableDependency() caught unexpected exception: ", ex);
- throw new StateManagementException("StateManagement.disableDependency() Exception: " + ex);
- }
- }
- }
-
- /**
- * enableNoDependency() removes the availability status of "dependency " and will change the
- * operational state to enabled if not otherwise failed.
- * @throws StateManagementException
- */
- public void enableNoDependency() throws StateManagementException
- {
- synchronized (SYNCLOCK){
- if(logger.isDebugEnabled()){
- logger.debug("\nStateManagement: SYNCLOCK enableNoDependency() operation for resourceName = {}\n", this.resourceName);
- logger.debug("StateManagement: enableNoDependency() operation started, resourceName = {}", this.resourceName);
- }
- final EntityManager em = emf.createEntityManager();
-
- try(EntityMgrCloser emc = new EntityMgrCloser(em);
- MyTransaction et = new MyTransaction(em)) {
-
- if(logger.isDebugEnabled()){
- logger.debug("findStateManagementEntity for {}", this.resourceName);
- }
- final StateManagementEntity sm = findStateManagementEntity(em, this.resourceName);
- final StateElement stateElement = st.getEndingState(sm.getAdminState(), sm.getOpState(),
- sm.getAvailStatus(), sm.getStandbyStatus(), ENABLE_NO_DEPENDENCY);
- // set transition state
- sm.setAdminState(stateElement.getEndingAdminState());
- sm.setOpState(stateElement.getEndingOpState());
- sm.setAvailStatus(stateElement.getEndingAvailStatus());
- sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
-
- em.persist(sm);
- et.commit();
- setChanged();
- notifyObservers(OPERATION_STATE);
-
- if(logger.isDebugEnabled()){
- logger.debug("StateManagement: enableNoDependency() operation completed, resourceName = {}", this.resourceName);
- }
- } catch(final Exception ex) {
- logger.error("StateManagement.enableNoDependency() caught unexpected exception: ", ex);
- throw new StateManagementException("StateManagement.enableNoDependency() Exception: " + ex);
- }
- }
- }
-
- /**
- * promote() changes the standby status to providingservice if not otherwise failed.
- * @throws StandbyStatusException
- * @throws StateManagementException
- */
- public void promote() throws IntegrityMonitorException
- {
- synchronized (SYNCLOCK){
- if(logger.isDebugEnabled()){
- logger.debug("\nStateManagement: SYNCLOCK promote() operation for resourceName = {}\n", this.resourceName);
- logger.debug("StateManagement: promote() operation started, resourceName = {}", this.resourceName);
- }
-
- StateManagementEntity sm;
-
- final EntityManager em = emf.createEntityManager();
-
- try(EntityMgrCloser emc = new EntityMgrCloser(em);
- MyTransaction et = new MyTransaction(em)) {
-
- if(logger.isDebugEnabled()){
- logger.debug("findStateManagementEntity for {}", this.resourceName);
- }
- sm = findStateManagementEntity(em, this.resourceName);
- final StateElement stateElement = st.getEndingState(sm.getAdminState(), sm.getOpState(),
- sm.getAvailStatus(), sm.getStandbyStatus(), PROMOTE);
- // set transition state
- sm.setAdminState(stateElement.getEndingAdminState());
- sm.setOpState(stateElement.getEndingOpState());
- sm.setAvailStatus(stateElement.getEndingAvailStatus());
- sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
-
- em.persist(sm);
- et.commit();
- setChanged();
- notifyObservers(STANDBY_STATUS);
- }catch(final Exception ex){
- logger.error("StateManagement.promote() caught unexpected exception: ", ex);
- throw new StateManagementException("StateManagement.promote() Exception: " + ex);
- }
-
- if(logger.isDebugEnabled()){
- logger.debug("StateManagement: promote() operation completed, resourceName = ", this.resourceName);
- }
- if (sm.getStandbyStatus().equals(StateManagement.COLD_STANDBY)){
- final String msg = "Failure to promote " + this.resourceName + " StandbyStatus = " + StateManagement.COLD_STANDBY;
- throw new StandbyStatusException(msg);
- }
- }
- }
-
- /**
- * demote() changes standbystatus to hotstandby or, if failed, coldstandby
- * @throws StateManagementException
- */
- public void demote() throws StateManagementException
- {
- synchronized (SYNCLOCK){
- if(logger.isDebugEnabled()){
- logger.debug("\nStateManagement: SYNCLOCK demote() operation for resourceName = \n", this.resourceName);
- logger.debug("StateManagement: demote() operation started, resourceName = {}", this.resourceName);
- }
- final EntityManager em = emf.createEntityManager();
-
- try(EntityMgrCloser emc = new EntityMgrCloser(em);
- MyTransaction et = new MyTransaction(em)) {
-
- if(logger.isDebugEnabled()){
- logger.debug("findStateManagementEntity for {}", this.resourceName);
- }
- final StateManagementEntity sm = findStateManagementEntity(em, this.resourceName);
- final StateElement stateElement = st.getEndingState(sm.getAdminState(), sm.getOpState(),
- sm.getAvailStatus(), sm.getStandbyStatus(), DEMOTE);
- // set transition state
- sm.setAdminState(stateElement.getEndingAdminState());
- sm.setOpState(stateElement.getEndingOpState());
- sm.setAvailStatus(stateElement.getEndingAvailStatus());
- sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
-
- em.persist(sm);
- et.commit();
- setChanged();
- notifyObservers(STANDBY_STATUS);
-
- if(logger.isDebugEnabled()){
- logger.debug("StateManagement: demote() operation completed, resourceName = {}", this.resourceName);
- }
- } catch(final Exception ex) {
- logger.error("StateManagement.demote() caught unexpected exception: ", ex);
- throw new StateManagementException("StateManagement.demote() Exception: " + ex);
- }
- }
- }
-
- /**
- *
- * Only used for a remote resource. It will not notify observers. It is used only in cases where
- * the remote resource has failed is such a way that it cannot update its own states. In particular
- * this is observed by PDP-D DroolsPdpsElectionHandler when it is trying to determine which PDP-D should
- * be designated as the lead.
- * @param otherResourceName
- * @throws StateManagementException
- */
- public void demote(final String otherResourceName) throws StateManagementException
- {
- synchronized (SYNCLOCK){
- if(otherResourceName==null){
- logger.error("\nStateManagement: SYNCLOCK demote(otherResourceName) operation: resourceName is NULL.\n");
- return;
- }
- if(logger.isDebugEnabled()){
- logger.debug("\nStateManagement: SYNCLOCK demote(otherResourceName) operation for resourceName = {}\n", otherResourceName);
- }
- final EntityManager em = emf.createEntityManager();
-
- try(EntityMgrCloser emc = new EntityMgrCloser(em);
- MyTransaction et = new MyTransaction(em)) {
-
- if(logger.isDebugEnabled()){
- logger.debug("StateManagement: SYNCLOCK demote(otherResourceName) findStateManagementEntity for {}", otherResourceName);
- }
- final StateManagementEntity sm = findStateManagementEntity(em, otherResourceName);
- final StateElement stateElement = st.getEndingState(sm.getAdminState(), sm.getOpState(),
- sm.getAvailStatus(), sm.getStandbyStatus(), DEMOTE);
- // set transition state
- sm.setAdminState(stateElement.getEndingAdminState());
- sm.setOpState(stateElement.getEndingOpState());
- sm.setAvailStatus(stateElement.getEndingAvailStatus());
- sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
-
- em.persist(sm);
- et.commit();
- //We don't notify observers because this is assumed to be a remote resource
-
- if(logger.isDebugEnabled()){
- logger.debug("StateManagement: demote(otherResourceName) operation completed, resourceName = {}", otherResourceName);
- }
- } catch(final Exception ex) {
- logger.error("StateManagement.demote(otherResourceName) caught unexpected exception: ", ex);
- throw new StateManagementException("StateManagement.demote(otherResourceName) Exception: " + ex);
- }
- }
- }
-
- /**
- * @return
- */
-public String getAdminState()
- {
- if(logger.isDebugEnabled()){
- logger.debug("StateManagement(6/1/16): getAdminState for resourceName {}", this.resourceName);
- }
-
- final EntityManager em = emf.createEntityManager();
- try(final EntityMgrCloser emc = new EntityMgrCloser(em)) {
- final TypedQuery<StateManagementEntity> query = em.createQuery(GET_STATE_MANAGEMENT_ENTITY_QUERY, StateManagementEntity.class);
-
- query.setParameter(RESOURCE_NAME, this.resourceName);
-
- //Just test that we are retrieving the right object
- final
- List<StateManagementEntity> resourceList = query.setLockMode(
- LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
- if (!resourceList.isEmpty()) {
- // exist
- final StateManagementEntity stateManagementEntity = resourceList.get(0);
- // refresh the object from DB in case cached data was returned
- em.refresh(stateManagementEntity);
- this.adminState = stateManagementEntity.getAdminState();
- } else {
- this.adminState = null;
- }
- } catch(final Exception ex) {
- logger.error("StateManagement: getAdminState exception: {}", ex.toString(), ex);
- }
-
- return this.adminState;
- }
-
- /**
- * @return
- */
-public String getOpState()
- {
- if(logger.isDebugEnabled()){
- logger.debug("StateManagement(6/1/16): getOpState for resourceName {}", this.resourceName);
- }
-
- final EntityManager em = emf.createEntityManager();
- try(EntityMgrCloser emc = new EntityMgrCloser(em)) {
- final TypedQuery<StateManagementEntity> query = em.createQuery(GET_STATE_MANAGEMENT_ENTITY_QUERY, StateManagementEntity.class);
-
- query.setParameter(RESOURCE_NAME, this.resourceName);
-
- //Just test that we are retrieving the right object
- final
- List<StateManagementEntity> resourceList = query.setLockMode(
- LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
- if (!resourceList.isEmpty()) {
- // exist
- final StateManagementEntity stateManagementEntity = resourceList.get(0);
- // refresh the object from DB in case cached data was returned
- em.refresh(stateManagementEntity);
- this.opState = stateManagementEntity.getOpState();
- } else {
- this.opState = null;
- }
- } catch(final Exception ex) {
- logger.error("StateManagement: getOpState exception: {}", ex.toString(), ex);
- }
-
- return this.opState;
- }
-
- /**
- * @return
- */
- public String getAvailStatus()
- {
- if(logger.isDebugEnabled()){
- logger.debug("StateManagement(6/1/16): getAvailStatus for resourceName {}", this.resourceName);
- }
-
- final EntityManager em = emf.createEntityManager();
- try(EntityMgrCloser emc = new EntityMgrCloser(em)) {
- final TypedQuery<StateManagementEntity> query = em.createQuery(GET_STATE_MANAGEMENT_ENTITY_QUERY, StateManagementEntity.class);
-
- query.setParameter(RESOURCE_NAME, this.resourceName);
-
- //Just test that we are retrieving the right object
- final
- List<StateManagementEntity> resourceList = query.setLockMode(
- LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
- if (!resourceList.isEmpty()) {
- // exist
- final StateManagementEntity stateManagementEntity = resourceList.get(0);
- // refresh the object from DB in case cached data was returned
- em.refresh(stateManagementEntity);
- this.availStatus = stateManagementEntity.getAvailStatus();
- } else {
- this.availStatus = null;
- }
- } catch(final Exception ex) {
- logger.error("StateManagement: getAvailStatus exception: {}", ex.toString(), ex);
- }
-
- return this.availStatus;
- }
-
- /**
- * @return
- */
- public String getStandbyStatus()
- {
- if(logger.isDebugEnabled()){
- logger.debug("StateManagement(6/1/16): getStandbyStatus for resourceName {}", this.resourceName);
- }
-
- final EntityManager em = emf.createEntityManager();
- try(EntityMgrCloser emc = new EntityMgrCloser(em)) {
- final TypedQuery<StateManagementEntity> query = em.createQuery(GET_STATE_MANAGEMENT_ENTITY_QUERY, StateManagementEntity.class);
-
- query.setParameter(RESOURCE_NAME, this.resourceName);
-
- //Just test that we are retrieving the right object
- final
- List<StateManagementEntity> resourceList = query.setLockMode(
- LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
- if (!resourceList.isEmpty()) {
- // exist
- final StateManagementEntity stateManagementEntity = resourceList.get(0);
- // refresh the object from DB in case cached data was returned
- em.refresh(stateManagementEntity);
- this.standbyStatus = stateManagementEntity.getStandbyStatus();
- } else {
- this.standbyStatus = null;
- }
- } catch(final Exception ex) {
- logger.error("StateManagement: getStandbyStatus exception: {}", ex.toString(), ex);
- }
-
- return this.standbyStatus;
- }
-
- /**
- * Find a StateManagementEntity
- * @param em
- * @param otherResourceName
- * @return
- */
- private static StateManagementEntity findStateManagementEntity(final EntityManager em, final String otherResourceName)
- {
- if(logger.isDebugEnabled()){
- logger.debug("StateManagementEntity: findStateManagementEntity: Entry");
- }
- try {
- final TypedQuery<StateManagementEntity> query =
- em.createQuery(GET_STATE_MANAGEMENT_ENTITY_QUERY, StateManagementEntity.class);
-
- query.setParameter(RESOURCE_NAME, otherResourceName);
-
- //Just test that we are retrieving the right object
- final
- List<StateManagementEntity> resourceList = query.setLockMode(
- LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
- if (!resourceList.isEmpty()) {
- // exist
- final StateManagementEntity stateManagementEntity = resourceList.get(0);
- // refresh the object from DB in case cached data was returned
- em.refresh(stateManagementEntity);
- stateManagementEntity.setModifiedDate(new Date());
- return stateManagementEntity;
- } else {
- // not exist - create one
- final StateManagementEntity stateManagementEntity = new StateManagementEntity();
- stateManagementEntity.setResourceName(otherResourceName);
- stateManagementEntity.setAdminState(UNLOCKED);
- stateManagementEntity.setOpState(ENABLED);
- stateManagementEntity.setAvailStatus(NULL_VALUE);
- stateManagementEntity.setStandbyStatus(NULL_VALUE); // default
- return stateManagementEntity;
- }
- } catch(final Exception ex) {
- final String message = "findStateManagementEntity exception";
- logger.error("{}: {}", message, ex.toString(), ex);
- throw new EntityRetrievalException(message, ex);
- }
- }
-
- /**
- * Get the standbystatus of a particular resource
- * @param otherResourceName
- * @return
- */
- public String getStandbyStatus(final String otherResourceName) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("StateManagement: getStandbyStatus: Entering, resourceName='{}'", otherResourceName);
- }
-
- String tempStandbyStatus = null;
-
- // The transaction is required for the LockModeType
- final EntityManager em = emf.createEntityManager();
-
- try(EntityMgrCloser emc = new EntityMgrCloser(em);
- MyTransaction et = new MyTransaction(em)) {
-
- final TypedQuery<StateManagementEntity> stateManagementListQuery = em
- .createQuery(GET_STATE_MANAGEMENT_ENTITY_QUERY, StateManagementEntity.class);
- stateManagementListQuery.setParameter(RESOURCE_NAME, otherResourceName);
- final List<StateManagementEntity> stateManagementList = stateManagementListQuery.setLockMode(
- LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
- if (!stateManagementList.isEmpty()) {
- final StateManagementEntity stateManagementEntity = stateManagementList.get(0);
- // refresh the object from DB in case cached data was returned
- em.refresh(stateManagementEntity);
- tempStandbyStatus = stateManagementEntity.getStandbyStatus();
- if (logger.isDebugEnabled()) {
- logger.debug("getStandbyStatus: resourceName ={} has standbyStatus={}", otherResourceName, tempStandbyStatus);
- }
- } else {
- logger.error("getStandbyStatus: resourceName ={} not found in statemanagemententity table", otherResourceName);
- }
-
- et.commit();
- } catch (final Exception e) {
- logger.error("getStandbyStatus: Caught Exception attempting to get statemanagemententity record, message='{}'", e.getMessage(), e);
- }
- if (logger.isDebugEnabled()) {
- logger.debug("getStandbyStatus: Returning standbyStatus={}", tempStandbyStatus);
- }
-
- return tempStandbyStatus;
- }
-
- /**
- * Clean up all the StateManagementEntities
- */
- public void deleteAllStateManagementEntities() {
-
- if(logger.isDebugEnabled()){
- logger.debug("StateManagement: deleteAllStateManagementEntities: Entering");
- }
-
- /*
- * Start transaction
- */
- final EntityManager em = emf.createEntityManager();
-
- try(EntityMgrCloser emc = new EntityMgrCloser(em);
- MyTransaction et = new MyTransaction(em)) {
- final TypedQuery<StateManagementEntity> stateManagementEntityListQuery = em
- .createQuery("SELECT p FROM StateManagementEntity p", StateManagementEntity.class);
- final
- List<StateManagementEntity> stateManagementEntityList = stateManagementEntityListQuery.setLockMode(
- LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
- if(logger.isDebugEnabled()){
- logger.debug("deleteAllStateManagementEntities: Deleting {} StateManagementEntity records", stateManagementEntityList.size());
- }
- for (final StateManagementEntity stateManagementEntity : stateManagementEntityList) {
- if(logger.isDebugEnabled()){
- logger.debug("deleteAllStateManagementEntities: Deleting statemanagemententity with resourceName={} and standbyStatus={}",
- stateManagementEntity.getResourceName(),
- stateManagementEntity.getStandbyStatus());
- }
- em.remove(stateManagementEntity);
- }
-
- et.commit();
- }catch(final Exception ex){
- logger.error("StateManagement.deleteAllStateManagementEntities() caught Exception: ", ex);
- }
- if(logger.isDebugEnabled()){
- logger.debug("deleteAllStateManagementEntities: Exiting");
- }
- }
-
- private static class MyTransaction extends EntityTransCloser {
-
- /**
- * @param em
- */
- public MyTransaction(final EntityManager em) {
- super(em.getTransaction());
- }
-
- @Override
- public void commit() {
- synchronized(FLUSHLOCK){
- if(getTransation().isActive()){
- super.commit();
- }
- }
- }
-
- @Override
- public void rollback() {
- synchronized(FLUSHLOCK){
- if(getTransation().isActive()){
- super.rollback();
- }
- }
- }
-
- }
+ } catch (final Exception e) {
+ logger.error(
+ "getStandbyStatus: Caught Exception attempting to get statemanagemententity record, message='{}'",
+ e.getMessage(), e);
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("getStandbyStatus: Returning standbyStatus={}", tempStandbyStatus);
+ }
+
+ return tempStandbyStatus;
+ }
+
+ /**
+ * Find a StateManagementEntity.
+ *
+ * @param em the entity manager
+ * @param otherResourceName the resource name
+ * @return the StateManagementEntity
+ */
+ private static StateManagementEntity findStateManagementEntity(final EntityManager em,
+ final String otherResourceName) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateManagementEntity: findStateManagementEntity: Entry");
+ }
+ try {
+ final TypedQuery<StateManagementEntity> query =
+ em.createQuery(GET_STATE_MANAGEMENT_ENTITY_QUERY, StateManagementEntity.class);
+
+ query.setParameter(RESOURCE_NAME, otherResourceName);
+
+ // Just test that we are retrieving the right object
+ final List<StateManagementEntity> resourceList =
+ query.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+ if (!resourceList.isEmpty()) {
+ // exist
+ final StateManagementEntity stateManagementEntity = resourceList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(stateManagementEntity);
+ stateManagementEntity.setModifiedDate(new Date());
+ return stateManagementEntity;
+ } else {
+ // not exist - create one
+ final StateManagementEntity stateManagementEntity = new StateManagementEntity();
+ stateManagementEntity.setResourceName(otherResourceName);
+ stateManagementEntity.setAdminState(UNLOCKED);
+ stateManagementEntity.setOpState(ENABLED);
+ stateManagementEntity.setAvailStatus(NULL_VALUE);
+ stateManagementEntity.setStandbyStatus(NULL_VALUE); // default
+ return stateManagementEntity;
+ }
+ } catch (final Exception ex) {
+ final String message = "findStateManagementEntity exception";
+ logger.error("{}: {}", message, ex.toString(), ex);
+ throw new EntityRetrievalException(message, ex);
+ }
+ }
+
+ /**
+ * Clean up all the StateManagementEntities.
+ */
+ public void deleteAllStateManagementEntities() {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateManagement: deleteAllStateManagementEntities: Entering");
+ }
+
+ /*
+ * Start transaction
+ */
+ final EntityManager em = emf.createEntityManager();
+
+ try (EntityMgrCloser emc = new EntityMgrCloser(em); MyTransaction et = new MyTransaction(em)) {
+ final TypedQuery<StateManagementEntity> stateManagementEntityListQuery =
+ em.createQuery("SELECT p FROM StateManagementEntity p", StateManagementEntity.class);
+ final List<StateManagementEntity> stateManagementEntityList = stateManagementEntityListQuery
+ .setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+ if (logger.isDebugEnabled()) {
+ logger.debug("deleteAllStateManagementEntities: Deleting {} StateManagementEntity records",
+ stateManagementEntityList.size());
+ }
+ for (final StateManagementEntity stateManagementEntity : stateManagementEntityList) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "deleteAllStateManagementEntities: Deleting statemanagemententity with resourceName={} and"
+ + " standbyStatus={}",
+ stateManagementEntity.getResourceName(), stateManagementEntity.getStandbyStatus());
+ }
+ em.remove(stateManagementEntity);
+ }
+
+ et.commit();
+ } catch (final Exception ex) {
+ logger.error("StateManagement.deleteAllStateManagementEntities() caught Exception: ", ex);
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("deleteAllStateManagementEntities: Exiting");
+ }
+ }
+
+ private static class MyTransaction extends EntityTransCloser {
+
+ /**
+ * Create an instance.
+ *
+ * @param em the entity manager
+ */
+ public MyTransaction(final EntityManager em) {
+ super(em.getTransaction());
+ }
+
+ @Override
+ public void commit() {
+ synchronized (FLUSHLOCK) {
+ if (getTransation().isActive()) {
+ super.commit();
+ }
+ }
+ }
+
+ @Override
+ public void rollback() {
+ synchronized (FLUSHLOCK) {
+ if (getTransation().isActive()) {
+ super.rollback();
+ }
+ }
+ }
+
+ }
}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransition.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransition.java
index 99c092d0..6ff869f4 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransition.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransition.java
@@ -20,11 +20,11 @@
package org.onap.policy.common.im;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
-
-import org.onap.policy.common.im.StateElement;
-import org.onap.policy.common.im.StateManagement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,712 +32,914 @@ import org.slf4j.LoggerFactory;
* The StateTransition class coordinates all state transitions.
*/
public class StateTransition {
- private static final Logger logger = LoggerFactory.getLogger(StateTransition.class);
-
- public static final String ADMIN_STATE = "adminState";
- public static final String OPERATION_STATE = "opState";
- public static final String AVAILABLE_STATUS= "availStatus";
- public static final String STANDBY_STATUS = "standbyStatus";
- public static final String ACTOIN_NAME = "actionName";
-
- private HashMap<String, String> StateTable = new HashMap<>();
-
- /**
- * StateTransition constructor
- * @throws StateTransitionException
- */
- public StateTransition() throws StateTransitionException
- {
- if(logger.isDebugEnabled()){
- logger.debug("StateTransition constructor");
- }
+ private static final Logger logger = LoggerFactory.getLogger(StateTransition.class);
+
+ public static final String ADMIN_STATE = "adminState";
+ public static final String OPERATION_STATE = "opState";
+ public static final String AVAILABLE_STATUS = "availStatus";
+ public static final String STANDBY_STATUS = "standbyStatus";
+ public static final String ACTOIN_NAME = "actionName";
+
+ private HashMap<String, String> stateTable = new HashMap<>();
+
+ /**
+ * StateTransition constructor.
+ *
+ * @throws StateTransitionException if an error occurs
+ */
+ public StateTransition() throws StateTransitionException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("StateTransition constructor");
+ }
+
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Load StateTable started");
+ }
+
+ setupStateTable();
+ } catch (Exception ex) {
+ logger.error("StateTransition threw exception.", ex);
+ throw new StateTransitionException("StateTransition Exception: " + ex.toString());
+ }
+ }
+
+ /**
+ * Calculates the state transition and returns the end state.
+ *
+ * @param adminState the administration state
+ * @param opState the operational state
+ * @param availStatus the availability status
+ * @param standbyStatus the standby status
+ * @param actionName the action name
+ * @return the StateEement
+ * @throws StateTransitionException if an error occurs
+ */
+ public StateElement getEndingState(String adminState, String opState, String availStatus, String standbyStatus,
+ String actionName) throws StateTransitionException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("getEndingState");
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("adminState=[{}], opState=[{}], availStatus=[{}], standbyStatus=[{}], actionName[{}]",
+ adminState, opState, availStatus, standbyStatus, actionName);
+ }
+ if (availStatus == null) {
+ availStatus = "null";
+ }
+ if (standbyStatus == null) {
+ standbyStatus = "null";
+ }
+ if (adminState == null || opState == null || actionName == null) {
+ throw new StateTransitionException("Exception:StateTransition unable to process state: adminState=["
+ + adminState + "], opState=[" + opState + "], availStatus=[" + availStatus + "], standbyStatus=["
+ + standbyStatus + "], actionName=[" + actionName + "]");
+ } else if (!(adminState.equals(StateManagement.LOCKED) || adminState.equals(StateManagement.UNLOCKED))) {
+ throw new StateTransitionException("Exception:StateTransition unable to process state: adminState=["
+ + adminState + "], opState=[" + opState + "], availStatus=[" + availStatus + "], standbyStatus=["
+ + standbyStatus + "], actionName=[" + actionName + "]");
+ } else if (!(opState.equals(StateManagement.ENABLED) || opState.equals(StateManagement.DISABLED))) {
+ throw new StateTransitionException("Exception:StateTransition unable to process state: adminState=["
+ + adminState + "], opState=[" + opState + "], availStatus=[" + availStatus + "], standbyStatus=["
+ + standbyStatus + "], actionName=[" + actionName + "]");
+ } else if (!(standbyStatus.equals(StateManagement.NULL_VALUE)
+ || standbyStatus.equals(StateManagement.COLD_STANDBY)
+ || standbyStatus.equals(StateManagement.HOT_STANDBY)
+ || standbyStatus.equals(StateManagement.PROVIDING_SERVICE))) {
+ throw new StateTransitionException("Exception:StateTransition unable to process state: adminState=["
+ + adminState + "], opState=[" + opState + "], availStatus=[" + availStatus + "], standbyStatus=["
+ + standbyStatus + "], actionName=[" + actionName + "]");
+ } else if (!(availStatus.equals(StateManagement.NULL_VALUE) || availStatus.equals(StateManagement.DEPENDENCY)
+ || availStatus.equals(StateManagement.DEPENDENCY_FAILED)
+ || availStatus.equals(StateManagement.FAILED))) {
+ throw new StateTransitionException("Exception:StateTransition unable to process state: adminState=["
+ + adminState + "], opState=[" + opState + "], availStatus=[" + availStatus + "], standbyStatus=["
+ + standbyStatus + "], actionName=[" + actionName + "]");
+ } else if (!(actionName.equals(StateManagement.DEMOTE) || actionName.equals(StateManagement.DISABLE_DEPENDENCY)
+ || actionName.equals(StateManagement.DISABLE_FAILED)
+ || actionName.equals(StateManagement.ENABLE_NO_DEPENDENCY)
+ || actionName.equals(StateManagement.ENABLE_NOT_FAILED) || actionName.equals(StateManagement.LOCK)
+ || actionName.equals(StateManagement.PROMOTE) || actionName.equals(StateManagement.UNLOCK))) {
+ throw new StateTransitionException("Exception:StateTransition unable to process state: adminState=["
+ + adminState + "], opState=[" + opState + "], availStatus=[" + availStatus + "], standbyStatus=["
+ + standbyStatus + "], actionName=[" + actionName + "]");
+ }
+
+ StateElement stateElement = new StateElement();
+ try {
+ // dependency,failed is stored as dependency.failed in StateTable
+ String availStatus2 = availStatus;
+ if (availStatus2 != null) {
+ availStatus2 = availStatus.replace(",", ".");
+ }
+ String key = adminState + "," + opState + "," + availStatus2 + "," + standbyStatus + "," + actionName;
+ if (logger.isDebugEnabled()) {
+ logger.debug("Ending State search key: {}", key);
+ }
+ String value = stateTable.get(key);
+
+ if (value != null) {
+ try {
+ String[] parts = value.split(",", 5);
+ stateElement.setEndingAdminState(parts[0].trim());
+ stateElement.setEndingOpState(parts[1].trim());
+ stateElement.setEndingAvailStatus(parts[2].trim().replace(".", ","));
+ stateElement.setEndingStandbyStatus(parts[3].trim());
+ stateElement.setException(parts[4].trim());
+ stateElement.setAdminState(adminState);
+ stateElement.setOpState(opState);
+ stateElement.setAvailStatus(availStatus);
+ stateElement.setStandbyStatus(standbyStatus);
+ stateElement.setActionName(actionName);
+
+ stateElement.displayStateElement();
+ } catch (Exception ex) {
+ logger.error("String split exception: {}", ex.toString(), ex);
+ }
+
+ } else {
+ String msg = "Ending state not found, adminState=[" + adminState + "], opState=[" + opState
+ + "], availStatus=[" + availStatus + "], standbyStatus=[" + standbyStatus + "], actionName=["
+ + actionName + "]";
+ logger.error("{}", msg);
+ throw new StateTransitionException(msg);
+ }
+ } catch (Exception ex) {
+ logger.error("StateTransition threw exception.", ex);
+ throw new StateTransitionException("Exception: " + ex.toString() + ", adminState=[" + adminState
+ + "], opState=[" + opState + "], availStatus=[" + availStatus + "], standbyStatus=[" + standbyStatus
+ + "], actionName=[" + actionName + "]");
+ }
+
+ return stateElement;
+ }
+
+ /**
+ * Adding State Transition info into HashMap. It includes all state/status and action
+ * combinations key : adminState,opState,availStatus,standbyStatus,actionName value:
+ * endingAdminState,endingOpState,endingAvailStatus,endingStandbyStatus,exception Note : Use
+ * period instead of comma as seperator when store multi-value endingStandbyStatus (convert to
+ * comma during retrieval)
+ *
+ * <p>Note on illegal state/status combinations: This table has many state/status combinations
+ * that should never occur. However, they *may* occur due to corruption or manual manipulation
+ * of the DB. So, in each case of an illegal combination, the state/status is first corrected
+ * before applying the action. It is assumed that the administrative and operational states are
+ * always correct. Second, if the availability status is in "agreement" with the operational
+ * state, it is assumed correct. If it is null and the operational state is disabled, the
+ * availability status is left null until a disabledfailed or disableddependency action is
+ * received. Or, if a enableNotFailed or enableNoDependency is received while the availability
+ * status is null, it will remain null, but the Operational state will change to enabled.
+ *
+ * <p>If the standby status is not in agreement with the administrative and/or operational
+ * states, it is brought into agreement. For example, if the administrative state is locked and
+ * the standby status is providingservice, the standby status is changed to coldstandby.
+ *
+ * <p>After bringing the states/status attributes into agreement, *then* the action is applied
+ * to them. For example, if the administrative state is locked, the operational state is
+ * enabled, the availability status is null, the standby status is providingservice and the
+ * action is unlock, the standby status is changed to coldstandby and then the unlock action is
+ * applied. This will change the final state/status to administrative state = unlocked,
+ * operational state = disabled, availability status = null and standby status = hotstandby.
+ *
+ * <p>Note on standby status: If the starting state of standby status is null and either a
+ * promote or demote action is made, the assumption is that standbystatus is supported and
+ * therefore, the standby status will be changed to providingservice, hotstandby or coldstandby
+ * - depending on the value of the administrative and operational states. If an attempt to
+ * promote is made when the administrative state is locked or operational state is disabled, a
+ * StandbyStatusException will be thrown since promotion (state transition) is not possible. If
+ * the standby status is coldstandby and a transition occurs on the administrative or
+ * operational state such that they are unlocked and enabled, the standby status is
+ * automatically transitioned to hotstandby since it is only those two states that can hold the
+ * statndby status in the coldstandby value.
+ */
- try {
- if(logger.isDebugEnabled()){
- logger.debug("Load StateTable started");
- }
-
- setupStateTable();
- } catch(Exception ex) {
- logger.error("StateTransition threw exception.", ex);
- throw new StateTransitionException("StateTransition Exception: " + ex.toString());
- }
- }
-
- /**
- * Calculates the state transition and returns the end state
- * @param adminState
- * @param opState
- * @param availStatus
- * @param standbyStatus
- * @param actionName
- * @return
- * @throws StateTransitionException
- */
- public StateElement getEndingState(String adminState, String opState, String availStatus,
- String standbyStatus, String actionName) throws StateTransitionException
- {
- if(logger.isDebugEnabled()){
- logger.debug("getEndingState");
- }
- if(logger.isDebugEnabled()){
- logger.debug("adminState=[{}], opState=[{}], availStatus=[{}], standbyStatus=[{}], actionName[{}]",
- adminState,
- opState,
- availStatus,
- standbyStatus,
- actionName);
- }
- if(availStatus==null){
- availStatus="null";
- }
- if(standbyStatus==null){
- standbyStatus="null";
- }
- if(adminState==null || opState==null || actionName==null){
- throw new StateTransitionException("Exception:StateTransition unable to process state: adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" +
- availStatus + "], standbyStatus=[" + standbyStatus + "], actionName=[" + actionName + "]");
- }else if(!(adminState.equals(StateManagement.LOCKED) || adminState.equals(StateManagement.UNLOCKED))){
- throw new StateTransitionException("Exception:StateTransition unable to process state: adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" +
- availStatus + "], standbyStatus=[" + standbyStatus + "], actionName=[" + actionName + "]");
- }else if(!(opState.equals(StateManagement.ENABLED) || opState.equals(StateManagement.DISABLED))){
- throw new StateTransitionException("Exception:StateTransition unable to process state: adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" +
- availStatus + "], standbyStatus=[" + standbyStatus + "], actionName=[" + actionName + "]");
- }else if(!(standbyStatus.equals(StateManagement.NULL_VALUE) ||
- standbyStatus.equals(StateManagement.COLD_STANDBY) ||
- standbyStatus.equals(StateManagement.HOT_STANDBY) ||
- standbyStatus.equals(StateManagement.PROVIDING_SERVICE))){
- throw new StateTransitionException("Exception:StateTransition unable to process state: adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" +
- availStatus + "], standbyStatus=[" + standbyStatus + "], actionName=[" + actionName + "]");
- }else if(!(availStatus.equals(StateManagement.NULL_VALUE) ||
- availStatus.equals(StateManagement.DEPENDENCY) ||
- availStatus.equals(StateManagement.DEPENDENCY_FAILED) ||
- availStatus.equals(StateManagement.FAILED))){
- throw new StateTransitionException("Exception:StateTransition unable to process state: adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" +
- availStatus + "], standbyStatus=[" + standbyStatus + "], actionName=[" + actionName + "]");
- }
- else if(!(actionName.equals(StateManagement.DEMOTE) ||
- actionName.equals(StateManagement.DISABLE_DEPENDENCY) ||
- actionName.equals(StateManagement.DISABLE_FAILED) ||
- actionName.equals(StateManagement.ENABLE_NO_DEPENDENCY) ||
- actionName.equals(StateManagement.ENABLE_NOT_FAILED) ||
- actionName.equals(StateManagement.LOCK) ||
- actionName.equals(StateManagement.PROMOTE) ||
- actionName.equals(StateManagement.UNLOCK))){
- throw new StateTransitionException("Exception:StateTransition unable to process state: adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" +
- availStatus + "], standbyStatus=[" + standbyStatus + "], actionName=[" + actionName + "]");
- }
+ private void setupStateTable() {
+ stateTable.put("unlocked,enabled,null,null,lock", "locked,enabled,null,null,");
+ stateTable.put("unlocked,enabled,null,null,unlock", "unlocked,enabled,null,null,");
+ stateTable.put("unlocked,enabled,null,null,disableFailed", "unlocked,disabled,failed,null,");
+ stateTable.put("unlocked,enabled,null,null,enableNotFailed", "unlocked,enabled,null,null,");
+ stateTable.put("unlocked,enabled,null,null,disableDependency", "unlocked,disabled,dependency,null,");
+ stateTable.put("unlocked,enabled,null,null,enableNoDependency", "unlocked,enabled,null,null,");
+ stateTable.put("unlocked,enabled,null,null,promote", "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,null,null,demote", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,null,coldstandby,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("unlocked,enabled,null,coldstandby,unlock", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,null,coldstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,enabled,null,coldstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,null,coldstandby,disableDependency",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,enabled,null,coldstandby,enableNoDependency", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,null,coldstandby,promote", "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,null,coldstandby,demote", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,null,hotstandby,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("unlocked,enabled,null,hotstandby,unlock", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,null,hotstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,enabled,null,hotstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,null,hotstandby,disableDependency",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,enabled,null,hotstandby,enableNoDependency", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,null,hotstandby,promote", "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,null,hotstandby,demote", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,null,providingservice,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("unlocked,enabled,null,providingservice,unlock", "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,null,providingservice,disableFailed", "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,enabled,null,providingservice,enableNotFailed",
+ "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,null,providingservice,disableDependency",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,enabled,null,providingservice,enableNoDependency",
+ "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,null,providingservice,promote", "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,null,providingservice,demote", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,failed,null,lock", "locked,enabled,null,null,");
+ stateTable.put("unlocked,enabled,failed,null,unlock", "unlocked,enabled,null,null,");
+ stateTable.put("unlocked,enabled,failed,null,disableFailed", "unlocked,disabled,failed,null,");
+ stateTable.put("unlocked,enabled,failed,null,enableNotFailed", "unlocked,enabled,null,null,");
+ stateTable.put("unlocked,enabled,failed,null,disableDependency", "unlocked,disabled,dependency,null,");
+ stateTable.put("unlocked,enabled,failed,null,enableNoDependency", "unlocked,enabled,null,null,");
+ stateTable.put("unlocked,enabled,failed,null,promote", "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,failed,null,demote", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,failed,coldstandby,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("unlocked,enabled,failed,coldstandby,unlock", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,failed,coldstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,enabled,failed,coldstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,failed,coldstandby,disableDependency",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,enabled,failed,coldstandby,enableNoDependency", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,failed,coldstandby,promote", "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,failed,coldstandby,demote", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,failed,hotstandby,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("unlocked,enabled,failed,hotstandby,unlock", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,failed,hotstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,enabled,failed,hotstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,failed,hotstandby,disableDependency",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,enabled,failed,hotstandby,enableNoDependency", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,failed,hotstandby,promote", "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,failed,hotstandby,demote", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,failed,providingservice,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("unlocked,enabled,failed,providingservice,unlock", "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,failed,providingservice,disableFailed",
+ "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,enabled,failed,providingservice,enableNotFailed",
+ "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,failed,providingservice,disableDependency",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,enabled,failed,providingservice,enableNoDependency",
+ "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,failed,providingservice,promote", "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,failed,providingservice,demote", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency,null,lock", "locked,enabled,null,null,");
+ stateTable.put("unlocked,enabled,dependency,null,unlock", "unlocked,enabled,null,null,");
+ stateTable.put("unlocked,enabled,dependency,null,disableFailed", "unlocked,disabled,failed,null,");
+ stateTable.put("unlocked,enabled,dependency,null,enableNotFailed", "unlocked,enabled,null,null,");
+ stateTable.put("unlocked,enabled,dependency,null,disableDependency", "unlocked,disabled,dependency,null,");
+ stateTable.put("unlocked,enabled,dependency,null,enableNoDependency", "unlocked,enabled,null,null,");
+ stateTable.put("unlocked,enabled,dependency,null,promote", "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,dependency,null,demote", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency,coldstandby,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("unlocked,enabled,dependency,coldstandby,unlock", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency,coldstandby,disableFailed",
+ "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,enabled,dependency,coldstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency,coldstandby,disableDependency",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,enabled,dependency,coldstandby,enableNoDependency",
+ "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency,coldstandby,promote", "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,dependency,coldstandby,demote", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency,hotstandby,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("unlocked,enabled,dependency,hotstandby,unlock", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency,hotstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,enabled,dependency,hotstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency,hotstandby,disableDependency",
+ "unlocked,disabled,dependency,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency,hotstandby,enableNoDependency",
+ "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency,hotstandby,promote", "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,dependency,hotstandby,demote", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency,providingservice,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("unlocked,enabled,dependency,providingservice,unlock",
+ "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,dependency,providingservice,disableFailed",
+ "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,enabled,dependency,providingservice,enableNotFailed",
+ "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,dependency,providingservice,disableDependency",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,enabled,dependency,providingservice,enableNoDependency",
+ "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,dependency,providingservice,promote",
+ "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,dependency,providingservice,demote", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency.failed,null,lock", "locked,enabled,null,null,");
+ stateTable.put("unlocked,enabled,dependency.failed,null,unlock", "unlocked,enabled,null,null,");
+ stateTable.put("unlocked,enabled,dependency.failed,null,disableFailed", "unlocked,disabled,failed,null,");
+ stateTable.put("unlocked,enabled,dependency.failed,null,enableNotFailed", "unlocked,enabled,null,null,");
+ stateTable.put("unlocked,enabled,dependency.failed,null,disableDependency",
+ "unlocked,disabled,dependency,null,");
+ stateTable.put("unlocked,enabled,dependency.failed,null,enableNoDependency", "unlocked,enabled,null,null,");
+ stateTable.put("unlocked,enabled,dependency.failed,null,promote", "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,dependency.failed,null,demote", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency.failed,coldstandby,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("unlocked,enabled,dependency.failed,coldstandby,unlock", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency.failed,coldstandby,disableFailed",
+ "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,enabled,dependency.failed,coldstandby,enableNotFailed",
+ "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency.failed,coldstandby,disableDependency",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,enabled,dependency.failed,coldstandby,enableNoDependency",
+ "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency.failed,coldstandby,promote",
+ "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,dependency.failed,coldstandby,demote", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency.failed,hotstandby,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("unlocked,enabled,dependency.failed,hotstandby,unlock", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency.failed,hotstandby,disableFailed",
+ "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,enabled,dependency.failed,hotstandby,enableNotFailed",
+ "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency.failed,hotstandby,disableDependency",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,enabled,dependency.failed,hotstandby,enableNoDependency",
+ "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency.failed,hotstandby,promote",
+ "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,dependency.failed,hotstandby,demote", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,enabled,dependency.failed,providingservice,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("unlocked,enabled,dependency.failed,providingservice,unlock",
+ "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,dependency.failed,providingservice,disableFailed",
+ "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,enabled,dependency.failed,providingservice,enableNotFailed",
+ "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,dependency.failed,providingservice,disableDependency",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,enabled,dependency.failed,providingservice,enableNoDependency",
+ "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,dependency.failed,providingservice,promote",
+ "unlocked,enabled,null,providingservice,");
+ stateTable.put("unlocked,enabled,dependency.failed,providingservice,demote",
+ "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,disabled,null,null,lock", "locked,disabled,null,null,");
+ stateTable.put("unlocked,disabled,null,null,unlock", "unlocked,disabled,null,null,");
+ stateTable.put("unlocked,disabled,null,null,disableFailed", "unlocked,disabled,failed,null,");
+ stateTable.put("unlocked,disabled,null,null,enableNotFailed", "unlocked,enabled,null,null,");
+ stateTable.put("unlocked,disabled,null,null,disableDependency", "unlocked,disabled,dependency,null,");
+ stateTable.put("unlocked,disabled,null,null,enableNoDependency", "unlocked,enabled,null,null,");
+ stateTable.put("unlocked,disabled,null,null,promote",
+ "unlocked,disabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("unlocked,disabled,null,null,demote", "unlocked,disabled,null,coldstandby,");
+ stateTable.put("unlocked,disabled,null,coldstandby,lock", "locked,disabled,null,coldstandby,");
+ stateTable.put("unlocked,disabled,null,coldstandby,unlock", "unlocked,disabled,null,coldstandby,");
+ stateTable.put("unlocked,disabled,null,coldstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,null,coldstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,disabled,null,coldstandby,disableDependency",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,null,coldstandby,enableNoDependency", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,disabled,null,coldstandby,promote",
+ "unlocked,disabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("unlocked,disabled,null,coldstandby,demote", "unlocked,disabled,null,coldstandby,");
+ stateTable.put("unlocked,disabled,null,hotstandby,lock", "locked,disabled,null,coldstandby,");
+ stateTable.put("unlocked,disabled,null,hotstandby,unlock", "unlocked,disabled,null,coldstandby,");
+ stateTable.put("unlocked,disabled,null,hotstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,null,hotstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,disabled,null,hotstandby,disableDependency",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,null,hotstandby,enableNoDependency", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,disabled,null,hotstandby,promote",
+ "unlocked,disabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("unlocked,disabled,null,hotstandby,demote", "unlocked,disabled,null,coldstandby,");
+ stateTable.put("unlocked,disabled,null,providingservice,lock", "locked,disabled,null,coldstandby,");
+ stateTable.put("unlocked,disabled,null,providingservice,unlock", "unlocked,disabled,null,coldstandby,");
+ stateTable.put("unlocked,disabled,null,providingservice,disableFailed",
+ "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,null,providingservice,enableNotFailed", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,disabled,null,providingservice,disableDependency",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,null,providingservice,enableNoDependency",
+ "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,disabled,null,providingservice,promote",
+ "unlocked,disabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("unlocked,disabled,null,providingservice,demote", "unlocked,disabled,null,coldstandby,");
+ stateTable.put("unlocked,disabled,failed,null,lock", "locked,disabled,failed,null,");
+ stateTable.put("unlocked,disabled,failed,null,unlock", "unlocked,disabled,failed,null,");
+ stateTable.put("unlocked,disabled,failed,null,disableFailed", "unlocked,disabled,failed,null,");
+ stateTable.put("unlocked,disabled,failed,null,enableNotFailed", "unlocked,enabled,null,null,");
+ stateTable.put("unlocked,disabled,failed,null,disableDependency", "unlocked,disabled,dependency.failed,null,");
+ stateTable.put("unlocked,disabled,failed,null,enableNoDependency", "unlocked,disabled,failed,null,");
+ stateTable.put("unlocked,disabled,failed,null,promote",
+ "unlocked,disabled,failed,coldstandby,StandbyStatusException");
+ stateTable.put("unlocked,disabled,failed,null,demote", "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,failed,coldstandby,lock", "locked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,failed,coldstandby,unlock", "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,failed,coldstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,failed,coldstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,disabled,failed,coldstandby,disableDependency",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,failed,coldstandby,enableNoDependency",
+ "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,failed,coldstandby,promote",
+ "unlocked,disabled,failed,coldstandby,StandbyStatusException");
+ stateTable.put("unlocked,disabled,failed,coldstandby,demote", "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,failed,hotstandby,lock", "locked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,failed,hotstandby,unlock", "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,failed,hotstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,failed,hotstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,disabled,failed,hotstandby,disableDependency",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,failed,hotstandby,enableNoDependency",
+ "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,failed,hotstandby,promote",
+ "unlocked,disabled,failed,coldstandby,StandbyStatusException");
+ stateTable.put("unlocked,disabled,failed,hotstandby,demote", "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,failed,providingservice,lock", "locked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,failed,providingservice,unlock", "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,failed,providingservice,disableFailed",
+ "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,failed,providingservice,enableNotFailed",
+ "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,disabled,failed,providingservice,disableDependency",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,failed,providingservice,enableNoDependency",
+ "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,failed,providingservice,promote",
+ "unlocked,disabled,failed,coldstandby,StandbyStatusException");
+ stateTable.put("unlocked,disabled,failed,providingservice,demote", "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency,null,lock", "locked,disabled,dependency,null,");
+ stateTable.put("unlocked,disabled,dependency,null,unlock", "unlocked,disabled,dependency,null,");
+ stateTable.put("unlocked,disabled,dependency,null,disableFailed", "unlocked,disabled,dependency.failed,null,");
+ stateTable.put("unlocked,disabled,dependency,null,enableNotFailed", "unlocked,disabled,dependency,null,");
+ stateTable.put("unlocked,disabled,dependency,null,disableDependency", "unlocked,disabled,dependency,null,");
+ stateTable.put("unlocked,disabled,dependency,null,enableNoDependency", "unlocked,enabled,null,null,");
+ stateTable.put("unlocked,disabled,dependency,null,promote",
+ "unlocked,disabled,dependency,coldstandby,StandbyStatusException");
+ stateTable.put("unlocked,disabled,dependency,null,demote", "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency,coldstandby,lock", "locked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency,coldstandby,unlock", "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency,coldstandby,disableFailed",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency,coldstandby,enableNotFailed",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency,coldstandby,disableDependency",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency,coldstandby,enableNoDependency",
+ "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,disabled,dependency,coldstandby,promote",
+ "unlocked,disabled,dependency,coldstandby,StandbyStatusException");
+ stateTable.put("unlocked,disabled,dependency,coldstandby,demote", "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency,hotstandby,lock", "locked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency,hotstandby,unlock", "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency,hotstandby,disableFailed",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency,hotstandby,enableNotFailed",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency,hotstandby,disableDependency",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency,hotstandby,enableNoDependency",
+ "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,disabled,dependency,hotstandby,promote",
+ "unlocked,disabled,dependency,coldstandby,StandbyStatusException");
+ stateTable.put("unlocked,disabled,dependency,hotstandby,demote", "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency,providingservice,lock", "locked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency,providingservice,unlock",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency,providingservice,disableFailed",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency,providingservice,enableNotFailed",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency,providingservice,disableDependency",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency,providingservice,enableNoDependency",
+ "unlocked,enabled,null,hotstandby,");
+ stateTable.put("unlocked,disabled,dependency,providingservice,promote",
+ "unlocked,disabled,dependency,coldstandby,StandbyStatusException");
+ stateTable.put("unlocked,disabled,dependency,providingservice,demote",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,null,lock", "locked,disabled,dependency.failed,null,");
+ stateTable.put("unlocked,disabled,dependency.failed,null,unlock", "unlocked,disabled,dependency.failed,null,");
+ stateTable.put("unlocked,disabled,dependency.failed,null,disableFailed",
+ "unlocked,disabled,dependency.failed,null,");
+ stateTable.put("unlocked,disabled,dependency.failed,null,enableNotFailed",
+ "unlocked,disabled,dependency,null,");
+ stateTable.put("unlocked,disabled,dependency.failed,null,disableDependency",
+ "unlocked,disabled,dependency.failed,null,");
+ stateTable.put("unlocked,disabled,dependency.failed,null,enableNoDependency", "unlocked,disabled,failed,null,");
+ stateTable.put("unlocked,disabled,dependency.failed,null,promote",
+ "unlocked,disabled,dependency.failed,coldstandby,StandbyStatusException");
+ stateTable.put("unlocked,disabled,dependency.failed,null,demote",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,coldstandby,lock",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,coldstandby,unlock",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,coldstandby,disableFailed",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,coldstandby,enableNotFailed",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,coldstandby,disableDependency",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,coldstandby,enableNoDependency",
+ "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,coldstandby,promote",
+ "unlocked,disabled,dependency.failed,coldstandby,StandbyStatusException");
+ stateTable.put("unlocked,disabled,dependency.failed,coldstandby,demote",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,hotstandby,lock",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,hotstandby,unlock",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,hotstandby,disableFailed",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,hotstandby,enableNotFailed",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,hotstandby,disableDependency",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,hotstandby,enableNoDependency",
+ "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,hotstandby,promote",
+ "unlocked,disabled,dependency.failed,coldstandby,StandbyStatusException");
+ stateTable.put("unlocked,disabled,dependency.failed,hotstandby,demote",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,providingservice,lock",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,providingservice,unlock",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,providingservice,disableFailed",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,providingservice,enableNotFailed",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,providingservice,disableDependency",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,providingservice,enableNoDependency",
+ "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("unlocked,disabled,dependency.failed,providingservice,promote",
+ "unlocked,disabled,dependency.failed,coldstandby,StandbyStatusException");
+ stateTable.put("unlocked,disabled,dependency.failed,providingservice,demote",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,enabled,null,null,lock", "locked,enabled,null,null,");
+ stateTable.put("locked,enabled,null,null,unlock", "unlocked,enabled,null,null,");
+ stateTable.put("locked,enabled,null,null,disableFailed", "locked,disabled,failed,null,");
+ stateTable.put("locked,enabled,null,null,enableNotFailed", "locked,enabled,null,null,");
+ stateTable.put("locked,enabled,null,null,disableDependency", "locked,disabled,dependency,null,");
+ stateTable.put("locked,enabled,null,null,enableNoDependency", "locked,enabled,null,null,");
+ stateTable.put("locked,enabled,null,null,promote", "locked,enabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("locked,enabled,null,null,demote", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,null,coldstandby,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,null,coldstandby,unlock", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("locked,enabled,null,coldstandby,disableFailed", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,enabled,null,coldstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,null,coldstandby,disableDependency", "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,enabled,null,coldstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,null,coldstandby,promote",
+ "locked,enabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("locked,enabled,null,coldstandby,demote", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,null,hotstandby,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,null,hotstandby,unlock", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("locked,enabled,null,hotstandby,disableFailed", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,enabled,null,hotstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,null,hotstandby,disableDependency", "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,enabled,null,hotstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,null,hotstandby,promote",
+ "locked,enabled,null,coldstandby,StandbyStateException");
+ stateTable.put("locked,enabled,null,hotstandby,demote", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,null,providingservice,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,null,providingservice,unlock", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("locked,enabled,null,providingservice,disableFailed", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,enabled,null,providingservice,enableNotFailed", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,null,providingservice,disableDependency",
+ "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,enabled,null,providingservice,enableNoDependency", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,null,providingservice,promote",
+ "locked,enabled,null,coldstandby,StandbyStateException");
+ stateTable.put("locked,enabled,null,providingservice,demote", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,failed,null,lock", "locked,enabled,null,null,");
+ stateTable.put("locked,enabled,failed,null,unlock", "unlocked,enabled,null,null,");
+ stateTable.put("locked,enabled,failed,null,disableFailed", "locked,disabled,failed,null,");
+ stateTable.put("locked,enabled,failed,null,enableNotFailed", "locked,enabled,null,null,");
+ stateTable.put("locked,enabled,failed,null,disableDependency", "locked,disabled,dependency,null,");
+ stateTable.put("locked,enabled,failed,null,enableNoDependency", "locked,enabled,null,null,");
+ stateTable.put("locked,enabled,failed,null,promote", "locked,enabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("locked,enabled,failed,null,demote", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,failed,coldstandby,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,failed,coldstandby,unlock", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("locked,enabled,failed,coldstandby,disableFailed", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,enabled,failed,coldstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,failed,coldstandby,disableDependency",
+ "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,enabled,failed,coldstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,failed,coldstandby,promote",
+ "locked,enabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("locked,enabled,failed,coldstandby,demote", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,failed,hotstandby,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,failed,hotstandby,unlock", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("locked,enabled,failed,hotstandby,disableFailed", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,enabled,failed,hotstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,failed,hotstandby,disableDependency", "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,enabled,failed,hotstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,failed,hotstandby,promote",
+ "locked,enabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("locked,enabled,failed,hotstandby,demote", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,failed,providingservice,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,failed,providingservice,unlock", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("locked,enabled,failed,providingservice,disableFailed", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,enabled,failed,providingservice,enableNotFailed", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,failed,providingservice,disableDependency",
+ "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,enabled,failed,providingservice,enableNoDependency", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,failed,providingservice,promote",
+ "locked,enabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("locked,enabled,failed,providingservice,demote", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency,null,lock", "locked,enabled,null,null,");
+ stateTable.put("locked,enabled,dependency,null,unlock", "unlocked,enabled,null,null,");
+ stateTable.put("locked,enabled,dependency,null,disableFailed", "locked,disabled,failed,null,");
+ stateTable.put("locked,enabled,dependency,null,enableNotFailed", "locked,enabled,null,null,");
+ stateTable.put("locked,enabled,dependency,null,disableDependency", "locked,disabled,dependency,null,");
+ stateTable.put("locked,enabled,dependency,null,enableNoDependency", "locked,enabled,null,null,");
+ stateTable.put("locked,enabled,dependency,null,promote",
+ "locked,enabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("locked,enabled,dependency,null,demote", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency,coldstandby,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency,coldstandby,unlock", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("locked,enabled,dependency,coldstandby,disableFailed", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,enabled,dependency,coldstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency,coldstandby,disableDependency",
+ "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,enabled,dependency,coldstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency,coldstandby,promote",
+ "locked,enabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("locked,enabled,dependency,coldstandby,demote", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency,hotstandby,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency,hotstandby,unlock", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("locked,enabled,dependency,hotstandby,disableFailed", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,enabled,dependency,hotstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency,hotstandby,disableDependency",
+ "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,enabled,dependency,hotstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency,hotstandby,promote",
+ "locked,enabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("locked,enabled,dependency,hotstandby,demote", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency,providingservice,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency,providingservice,unlock", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("locked,enabled,dependency,providingservice,disableFailed",
+ "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,enabled,dependency,providingservice,enableNotFailed",
+ "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency,providingservice,disableDependency",
+ "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,enabled,dependency,providingservice,enableNoDependency",
+ "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency,providingservice,promote",
+ "locked,enabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("locked,enabled,dependency,providingservice,demote", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency.failed,null,lock", "locked,enabled,null,null,");
+ stateTable.put("locked,enabled,dependency.failed,null,unlock", "unlocked,enabled,null,null,");
+ stateTable.put("locked,enabled,dependency.failed,null,disableFailed", "locked,disabled,failed,null,");
+ stateTable.put("locked,enabled,dependency.failed,null,enableNotFailed", "locked,enabled,null,null,");
+ stateTable.put("locked,enabled,dependency.failed,null,disableDependency", "locked,disabled,dependency,null,");
+ stateTable.put("locked,enabled,dependency.failed,null,enableNoDependency", "locked,enabled,null,null,");
+ stateTable.put("locked,enabled,dependency.failed,null,promote",
+ "locked,enabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("locked,enabled,dependency.failed,null,demote", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency.failed,coldstandby,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency.failed,coldstandby,unlock", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("locked,enabled,dependency.failed,coldstandby,disableFailed",
+ "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,enabled,dependency.failed,coldstandby,enableNotFailed",
+ "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency.failed,coldstandby,disableDependency",
+ "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,enabled,dependency.failed,coldstandby,enableNoDependency",
+ "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency.failed,coldstandby,promote",
+ "locked,enabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("locked,enabled,dependency.failed,coldstandby,demote", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency.failed,hotstandby,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency.failed,hotstandby,unlock", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("locked,enabled,dependency.failed,hotstandby,disableFailed",
+ "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,enabled,dependency.failed,hotstandby,enableNotFailed",
+ "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency.failed,hotstandby,disableDependency",
+ "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,enabled,dependency.failed,hotstandby,enableNoDependency",
+ "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency.failed,hotstandby,promote",
+ "locked,enabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("locked,enabled,dependency.failed,hotstandby,demote", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency.failed,providingservice,lock", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency.failed,providingservice,unlock", "unlocked,enabled,null,hotstandby,");
+ stateTable.put("locked,enabled,dependency.failed,providingservice,disableFailed",
+ "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,enabled,dependency.failed,providingservice,enableNotFailed",
+ "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency.failed,providingservice,disableDependency",
+ "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,enabled,dependency.failed,providingservice,enableNoDependency",
+ "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,enabled,dependency.failed,providingservice,promote",
+ "locked,enabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("locked,enabled,dependency.failed,providingservice,demote", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,disabled,null,null,lock", "locked,disabled,null,null,");
+ stateTable.put("locked,disabled,null,null,unlock", "unlocked,disabled,null,null,");
+ stateTable.put("locked,disabled,null,null,disableFailed", "locked,disabled,failed,null,");
+ stateTable.put("locked,disabled,null,null,enableNotFailed", "locked,enabled,null,null,");
+ stateTable.put("locked,disabled,null,null,disableDependency", "locked,disabled,dependency,null,");
+ stateTable.put("locked,disabled,null,null,enableNoDependency", "locked,enabled,null,null,");
+ stateTable.put("locked,disabled,null,null,promote", "locked,disabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("locked,disabled,null,null,demote", "locked,disabled,null,coldstandby,");
+ stateTable.put("locked,disabled,null,coldstandby,lock", "locked,disabled,null,coldstandby,");
+ stateTable.put("locked,disabled,null,coldstandby,unlock", "unlocked,disabled,null,coldstandby,");
+ stateTable.put("locked,disabled,null,coldstandby,disableFailed", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,null,coldstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,disabled,null,coldstandby,disableDependency", "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,null,coldstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,disabled,null,coldstandby,promote",
+ "locked,disabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("locked,disabled,null,coldstandby,demote", "locked,disabled,null,coldstandby,");
+ stateTable.put("locked,disabled,null,hotstandby,lock", "locked,disabled,null,coldstandby,");
+ stateTable.put("locked,disabled,null,hotstandby,unlock", "unlocked,disabled,null,coldstandby,");
+ stateTable.put("locked,disabled,null,hotstandby,disableFailed", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,null,hotstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,disabled,null,hotstandby,disableDependency", "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,null,hotstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,disabled,null,hotstandby,promote",
+ "locked,disabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("locked,disabled,null,hotstandby,demote", "locked,disabled,null,coldstandby,");
+ stateTable.put("locked,disabled,null,providingservice,lock", "locked,disabled,null,coldstandby,");
+ stateTable.put("locked,disabled,null,providingservice,unlock", "unlocked,disabled,null,coldstandby,");
+ stateTable.put("locked,disabled,null,providingservice,disableFailed", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,null,providingservice,enableNotFailed", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,disabled,null,providingservice,disableDependency",
+ "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,null,providingservice,enableNoDependency", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,disabled,null,providingservice,promote",
+ "locked,disabled,null,coldstandby,StandbyStatusException");
+ stateTable.put("locked,disabled,null,providingservice,demote", "locked,disabled,null,coldstandby,");
+ stateTable.put("locked,disabled,failed,null,lock", "locked,disabled,failed,null,");
+ stateTable.put("locked,disabled,failed,null,unlock", "unlocked,disabled,failed,null,");
+ stateTable.put("locked,disabled,failed,null,disableFailed", "locked,disabled,failed,null,");
+ stateTable.put("locked,disabled,failed,null,enableNotFailed", "locked,enabled,null,null,");
+ stateTable.put("locked,disabled,failed,null,disableDependency", "locked,disabled,dependency.failed,null,");
+ stateTable.put("locked,disabled,failed,null,enableNoDependency", "locked,disabled,failed,null,");
+ stateTable.put("locked,disabled,failed,null,promote",
+ "locked,disabled,failed,coldstandby,StandbyStatusException");
+ stateTable.put("locked,disabled,failed,null,demote", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,failed,coldstandby,lock", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,failed,coldstandby,unlock", "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,failed,coldstandby,disableFailed", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,failed,coldstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,disabled,failed,coldstandby,disableDependency",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,failed,coldstandby,enableNoDependency", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,failed,coldstandby,promote",
+ "locked,disabled,failed,coldstandby,StandbyStatusException");
+ stateTable.put("locked,disabled,failed,coldstandby,demote", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,failed,hotstandby,lock", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,failed,hotstandby,unlock", "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,failed,hotstandby,disableFailed", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,failed,hotstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,disabled,failed,hotstandby,disableDependency",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,failed,hotstandby,enableNoDependency", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,failed,hotstandby,promote",
+ "locked,disabled,failed,coldstandby,StandbyStatusException");
+ stateTable.put("locked,disabled,failed,hotstandby,demote", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,failed,providingservice,lock", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,failed,providingservice,unlock", "unlocked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,failed,providingservice,disableFailed", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,failed,providingservice,enableNotFailed", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,disabled,failed,providingservice,disableDependency",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,failed,providingservice,enableNoDependency",
+ "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,failed,providingservice,promote",
+ "locked,disabled,failed,coldstandby,StandbyStatusException");
+ stateTable.put("locked,disabled,failed,providingservice,demote", "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency,null,lock", "locked,disabled,dependency,null,");
+ stateTable.put("locked,disabled,dependency,null,unlock", "unlocked,disabled,dependency,null,");
+ stateTable.put("locked,disabled,dependency,null,disableFailed", "locked,disabled,dependency.failed,null,");
+ stateTable.put("locked,disabled,dependency,null,enableNotFailed", "locked,disabled,dependency,null,");
+ stateTable.put("locked,disabled,dependency,null,disableDependency", "locked,disabled,dependency,null,");
+ stateTable.put("locked,disabled,dependency,null,enableNoDependency", "locked,enabled,null,null,");
+ stateTable.put("locked,disabled,dependency,null,promote",
+ "locked,disabled,dependency,coldstandby,StandbyStatusException");
+ stateTable.put("locked,disabled,dependency,null,demote", "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,dependency,coldstandby,lock", "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,dependency,coldstandby,unlock", "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,dependency,coldstandby,disableFailed",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency,coldstandby,enableNotFailed",
+ "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,dependency,coldstandby,disableDependency",
+ "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,dependency,coldstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,disabled,dependency,coldstandby,promote",
+ "locked,disabled,dependency,coldstandby,StandbyStatusException");
+ stateTable.put("locked,disabled,dependency,coldstandby,demote", "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,dependency,hotstandby,lock", "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,dependency,hotstandby,unlock", "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,dependency,hotstandby,disableFailed",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency,hotstandby,enableNotFailed",
+ "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,dependency,hotstandby,disableDependency",
+ "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,dependency,hotstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,disabled,dependency,hotstandby,promote",
+ "locked,disabled,dependency,coldstandby,StandbyStatusException");
+ stateTable.put("locked,disabled,dependency,hotstandby,demote", "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,dependency,providingservice,lock", "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,dependency,providingservice,unlock",
+ "unlocked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,dependency,providingservice,disableFailed",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency,providingservice,enableNotFailed",
+ "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,dependency,providingservice,disableDependency",
+ "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,dependency,providingservice,enableNoDependency",
+ "locked,enabled,null,coldstandby,");
+ stateTable.put("locked,disabled,dependency,providingservice,promote",
+ "locked,disabled,dependency,coldstandby,StandbyStatusException");
+ stateTable.put("locked,disabled,dependency,providingservice,demote", "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,null,lock", "locked,disabled,dependency.failed,null,");
+ stateTable.put("locked,disabled,dependency.failed,null,unlock", "unlocked,disabled,dependency.failed,null,");
+ stateTable.put("locked,disabled,dependency.failed,null,disableFailed",
+ "locked,disabled,dependency.failed,null,");
+ stateTable.put("locked,disabled,dependency.failed,null,enableNotFailed", "locked,disabled,dependency,null,");
+ stateTable.put("locked,disabled,dependency.failed,null,disableDependency",
+ "locked,disabled,dependency.failed,null,");
+ stateTable.put("locked,disabled,dependency.failed,null,enableNoDependency", "locked,disabled,failed,null,");
+ stateTable.put("locked,disabled,dependency.failed,null,promote",
+ "locked,disabled,dependency.failed,coldstandby,StandbyStatusException");
+ stateTable.put("locked,disabled,dependency.failed,null,demote",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,coldstandby,lock",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,coldstandby,unlock",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,coldstandby,disableFailed",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,coldstandby,enableNotFailed",
+ "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,coldstandby,disableDependency",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,coldstandby,enableNoDependency",
+ "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,coldstandby,promote",
+ "locked,disabled,dependency.failed,coldstandby,StandbyStatusException");
+ stateTable.put("locked,disabled,dependency.failed,coldstandby,demote",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,hotstandby,lock",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,hotstandby,unlock",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,hotstandby,disableFailed",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,hotstandby,enableNotFailed",
+ "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,hotstandby,disableDependency",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,hotstandby,enableNoDependency",
+ "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,hotstandby,promote",
+ "locked,disabled,dependency.failed,coldstandby,StandbyStatusException");
+ stateTable.put("locked,disabled,dependency.failed,hotstandby,demote",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,providingservice,lock",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,providingservice,unlock",
+ "unlocked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,providingservice,disableFailed",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,providingservice,enableNotFailed",
+ "locked,disabled,dependency,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,providingservice,disableDependency",
+ "locked,disabled,dependency.failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,providingservice,enableNoDependency",
+ "locked,disabled,failed,coldstandby,");
+ stateTable.put("locked,disabled,dependency.failed,providingservice,promote",
+ "locked,disabled,dependency.failed,coldstandby,StandbyStatusException");
+ stateTable.put("locked,disabled,dependency.failed,providingservice,demote",
+ "locked,disabled,dependency.failed,coldstandby,");
+ }
- StateElement stateElement = new StateElement();
- try {
- // dependency,failed is stored as dependency.failed in StateTable
- String availStatus2 = availStatus;
- if (availStatus2 != null) {
- availStatus2 = availStatus.replace(",", ".");
- }
- String key = adminState + "," + opState + "," + availStatus2 + "," + standbyStatus + "," + actionName;
- if(logger.isDebugEnabled()){
- logger.debug("Ending State search key: {}", key);
- }
- String value = StateTable.get(key);
-
- if (value != null) {
- try {
- String[] parts = value.split(",", 5);
- stateElement.setEndingAdminState(parts[0].trim());
- stateElement.setEndingOpState(parts[1].trim());
- stateElement.setEndingAvailStatus(parts[2].trim().replace(".", ","));
- stateElement.setEndingStandbyStatus(parts[3].trim());
- stateElement.setException(parts[4].trim());
- stateElement.setAdminState(adminState);
- stateElement.setOpState(opState);
- stateElement.setAvailStatus(availStatus);
- stateElement.setStandbyStatus(standbyStatus);
- stateElement.setActionName(actionName);
-
- stateElement.displayStateElement();
- } catch(Exception ex) {
- logger.error("String split exception: {}", ex.toString(), ex);
- }
-
- } else {
- String msg = "Ending state not found, adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" +
- availStatus + "], standbyStatus=[" + standbyStatus + "], actionName=[" + actionName + "]";
- logger.error("{}", msg);
- throw new StateTransitionException(msg);
- }
- } catch (Exception ex) {
- logger.error("StateTransition threw exception.", ex);
- throw new StateTransitionException("Exception: " + ex.toString() + ", adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" +
- availStatus + "], standbyStatus=[" + standbyStatus + "], actionName=[" + actionName + "]");
- }
+ /**
+ * Display the state table.
+ */
+ public void displayStateTable() {
+ Set<?> set = stateTable.entrySet();
+ Iterator<?> iter = set.iterator();
- return stateElement;
- }
-
- /**
- * Adding State Transition info into HashMap. It includes all state/status and action combinations
- * key : adminState,opState,availStatus,standbyStatus,actionName
- * value: endingAdminState,endingOpState,endingAvailStatus,endingStandbyStatus,exception
- * Note : Use period instead of comma as seperator when store multi-value endingStandbyStatus (convert to
- * comma during retrieval)
- *
- * Note on illegal state/status combinations: This table has many state/status combinations that should never occur.
- * However, they *may* occur due to corruption or manual manipulation of the DB. So, in each case of an illegal
- * combination, the state/status is first corrected before applying the action. It is assumed that the administrative
- * and operational states are always correct. Second, if the availability status is in "agreement" with the operational
- * state, it is assumed correct. If it is null and the operational state is disabled, the availability status
- * is left null until a disabledfailed or disableddependency action is received. Or, if a enableNotFailed or
- * enableNoDependency is received while the availability status is null, it will remain null, but the Operational state
- * will change to enabled.
- *
- * If the standby status is not in agreement with the administrative and/or operational states, it is brought into
- * agreement. For example, if the administrative state is locked and the standby status is providingservice, the
- * standby status is changed to coldstandby.
- *
- * After bringing the states/status attributes into agreement, *then* the action is applied to them. For example, if
- * the administrative state is locked, the operational state is enabled, the availability status is null, the standby
- * status is providingservice and the action is unlock, the standby status is changed to coldstandby and then the
- * unlock action is applied. This will change the final state/status to administrative state = unlocked, operational
- * state = disabled, availability status = null and standby status = hotstandby.
- *
- * Note on standby status: If the starting state of standby status is null and either a promote or demote action is
- * made, the assumption is that standbystatus is supported and therefore, the standby status will be changed to
- * providingservice, hotstandby or coldstandby - depending on the value of the administrative and operational states.
- * If an attempt to promote is made when the administrative state is locked or operational state is disabled,
- * a StandbyStatusException will be thrown since promotion (state transition) is not possible. If the standby status
- * is coldstandby and a transition occurs on the administrative or operational state such that they are unlocked and
- * enabled, the standby status is automatically transitioned to hotstandby since it is only those two states that can
- * hold the statndby status in the coldstandby value.
- */
-
- private void setupStateTable()
- {
- StateTable.put("unlocked,enabled,null,null,lock", "locked,enabled,null,null,");
- StateTable.put("unlocked,enabled,null,null,unlock", "unlocked,enabled,null,null,");
- StateTable.put("unlocked,enabled,null,null,disableFailed", "unlocked,disabled,failed,null,");
- StateTable.put("unlocked,enabled,null,null,enableNotFailed", "unlocked,enabled,null,null,");
- StateTable.put("unlocked,enabled,null,null,disableDependency", "unlocked,disabled,dependency,null,");
- StateTable.put("unlocked,enabled,null,null,enableNoDependency", "unlocked,enabled,null,null,");
- StateTable.put("unlocked,enabled,null,null,promote", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,null,null,demote", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,null,coldstandby,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("unlocked,enabled,null,coldstandby,unlock", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,null,coldstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,enabled,null,coldstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,null,coldstandby,disableDependency", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,enabled,null,coldstandby,enableNoDependency", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,null,coldstandby,promote", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,null,coldstandby,demote", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,null,hotstandby,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("unlocked,enabled,null,hotstandby,unlock", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,null,hotstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,enabled,null,hotstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,null,hotstandby,disableDependency", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,enabled,null,hotstandby,enableNoDependency", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,null,hotstandby,promote", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,null,hotstandby,demote", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,null,providingservice,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("unlocked,enabled,null,providingservice,unlock", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,null,providingservice,disableFailed", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,enabled,null,providingservice,enableNotFailed", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,null,providingservice,disableDependency", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,enabled,null,providingservice,enableNoDependency", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,null,providingservice,promote", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,null,providingservice,demote", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,failed,null,lock", "locked,enabled,null,null,");
- StateTable.put("unlocked,enabled,failed,null,unlock", "unlocked,enabled,null,null,");
- StateTable.put("unlocked,enabled,failed,null,disableFailed", "unlocked,disabled,failed,null,");
- StateTable.put("unlocked,enabled,failed,null,enableNotFailed", "unlocked,enabled,null,null,");
- StateTable.put("unlocked,enabled,failed,null,disableDependency", "unlocked,disabled,dependency,null,");
- StateTable.put("unlocked,enabled,failed,null,enableNoDependency", "unlocked,enabled,null,null,");
- StateTable.put("unlocked,enabled,failed,null,promote", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,failed,null,demote", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,failed,coldstandby,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("unlocked,enabled,failed,coldstandby,unlock", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,failed,coldstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,enabled,failed,coldstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,failed,coldstandby,disableDependency", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,enabled,failed,coldstandby,enableNoDependency", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,failed,coldstandby,promote", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,failed,coldstandby,demote", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,failed,hotstandby,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("unlocked,enabled,failed,hotstandby,unlock", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,failed,hotstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,enabled,failed,hotstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,failed,hotstandby,disableDependency", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,enabled,failed,hotstandby,enableNoDependency", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,failed,hotstandby,promote", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,failed,hotstandby,demote", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,failed,providingservice,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("unlocked,enabled,failed,providingservice,unlock", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,failed,providingservice,disableFailed", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,enabled,failed,providingservice,enableNotFailed", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,failed,providingservice,disableDependency", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,enabled,failed,providingservice,enableNoDependency", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,failed,providingservice,promote", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,failed,providingservice,demote", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,dependency,null,lock", "locked,enabled,null,null,");
- StateTable.put("unlocked,enabled,dependency,null,unlock", "unlocked,enabled,null,null,");
- StateTable.put("unlocked,enabled,dependency,null,disableFailed", "unlocked,disabled,failed,null,");
- StateTable.put("unlocked,enabled,dependency,null,enableNotFailed", "unlocked,enabled,null,null,");
- StateTable.put("unlocked,enabled,dependency,null,disableDependency", "unlocked,disabled,dependency,null,");
- StateTable.put("unlocked,enabled,dependency,null,enableNoDependency", "unlocked,enabled,null,null,");
- StateTable.put("unlocked,enabled,dependency,null,promote", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,dependency,null,demote", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,dependency,coldstandby,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("unlocked,enabled,dependency,coldstandby,unlock", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,dependency,coldstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,enabled,dependency,coldstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,dependency,coldstandby,disableDependency", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,enabled,dependency,coldstandby,enableNoDependency", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,dependency,coldstandby,promote", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,dependency,coldstandby,demote", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,dependency,hotstandby,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("unlocked,enabled,dependency,hotstandby,unlock", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,dependency,hotstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,enabled,dependency,hotstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,dependency,hotstandby,disableDependency", "unlocked,disabled,dependency,hotstandby,");
- StateTable.put("unlocked,enabled,dependency,hotstandby,enableNoDependency", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,dependency,hotstandby,promote", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,dependency,hotstandby,demote", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,dependency,providingservice,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("unlocked,enabled,dependency,providingservice,unlock", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,dependency,providingservice,disableFailed", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,enabled,dependency,providingservice,enableNotFailed", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,dependency,providingservice,disableDependency", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,enabled,dependency,providingservice,enableNoDependency", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,dependency,providingservice,promote", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,dependency,providingservice,demote", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,dependency.failed,null,lock", "locked,enabled,null,null,");
- StateTable.put("unlocked,enabled,dependency.failed,null,unlock", "unlocked,enabled,null,null,");
- StateTable.put("unlocked,enabled,dependency.failed,null,disableFailed", "unlocked,disabled,failed,null,");
- StateTable.put("unlocked,enabled,dependency.failed,null,enableNotFailed", "unlocked,enabled,null,null,");
- StateTable.put("unlocked,enabled,dependency.failed,null,disableDependency", "unlocked,disabled,dependency,null,");
- StateTable.put("unlocked,enabled,dependency.failed,null,enableNoDependency", "unlocked,enabled,null,null,");
- StateTable.put("unlocked,enabled,dependency.failed,null,promote", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,dependency.failed,null,demote", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,dependency.failed,coldstandby,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("unlocked,enabled,dependency.failed,coldstandby,unlock", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,dependency.failed,coldstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,enabled,dependency.failed,coldstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,dependency.failed,coldstandby,disableDependency", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,enabled,dependency.failed,coldstandby,enableNoDependency", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,dependency.failed,coldstandby,promote", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,dependency.failed,coldstandby,demote", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,dependency.failed,hotstandby,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("unlocked,enabled,dependency.failed,hotstandby,unlock", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,dependency.failed,hotstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,enabled,dependency.failed,hotstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,dependency.failed,hotstandby,disableDependency", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,enabled,dependency.failed,hotstandby,enableNoDependency", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,dependency.failed,hotstandby,promote", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,dependency.failed,hotstandby,demote", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,enabled,dependency.failed,providingservice,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("unlocked,enabled,dependency.failed,providingservice,unlock", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,dependency.failed,providingservice,disableFailed", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,enabled,dependency.failed,providingservice,enableNotFailed", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,dependency.failed,providingservice,disableDependency", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,enabled,dependency.failed,providingservice,enableNoDependency", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,dependency.failed,providingservice,promote", "unlocked,enabled,null,providingservice,");
- StateTable.put("unlocked,enabled,dependency.failed,providingservice,demote", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,disabled,null,null,lock", "locked,disabled,null,null,");
- StateTable.put("unlocked,disabled,null,null,unlock", "unlocked,disabled,null,null,");
- StateTable.put("unlocked,disabled,null,null,disableFailed", "unlocked,disabled,failed,null,");
- StateTable.put("unlocked,disabled,null,null,enableNotFailed", "unlocked,enabled,null,null,");
- StateTable.put("unlocked,disabled,null,null,disableDependency", "unlocked,disabled,dependency,null,");
- StateTable.put("unlocked,disabled,null,null,enableNoDependency", "unlocked,enabled,null,null,");
- StateTable.put("unlocked,disabled,null,null,promote", "unlocked,disabled,null,coldstandby,StandbyStatusException");
- StateTable.put("unlocked,disabled,null,null,demote", "unlocked,disabled,null,coldstandby,");
- StateTable.put("unlocked,disabled,null,coldstandby,lock", "locked,disabled,null,coldstandby,");
- StateTable.put("unlocked,disabled,null,coldstandby,unlock", "unlocked,disabled,null,coldstandby,");
- StateTable.put("unlocked,disabled,null,coldstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,null,coldstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,disabled,null,coldstandby,disableDependency", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,null,coldstandby,enableNoDependency", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,disabled,null,coldstandby,promote", "unlocked,disabled,null,coldstandby,StandbyStatusException");
- StateTable.put("unlocked,disabled,null,coldstandby,demote", "unlocked,disabled,null,coldstandby,");
- StateTable.put("unlocked,disabled,null,hotstandby,lock", "locked,disabled,null,coldstandby,");
- StateTable.put("unlocked,disabled,null,hotstandby,unlock", "unlocked,disabled,null,coldstandby,");
- StateTable.put("unlocked,disabled,null,hotstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,null,hotstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,disabled,null,hotstandby,disableDependency", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,null,hotstandby,enableNoDependency", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,disabled,null,hotstandby,promote", "unlocked,disabled,null,coldstandby,StandbyStatusException");
- StateTable.put("unlocked,disabled,null,hotstandby,demote", "unlocked,disabled,null,coldstandby,");
- StateTable.put("unlocked,disabled,null,providingservice,lock", "locked,disabled,null,coldstandby,");
- StateTable.put("unlocked,disabled,null,providingservice,unlock", "unlocked,disabled,null,coldstandby,");
- StateTable.put("unlocked,disabled,null,providingservice,disableFailed", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,null,providingservice,enableNotFailed", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,disabled,null,providingservice,disableDependency", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,null,providingservice,enableNoDependency", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,disabled,null,providingservice,promote", "unlocked,disabled,null,coldstandby,StandbyStatusException");
- StateTable.put("unlocked,disabled,null,providingservice,demote", "unlocked,disabled,null,coldstandby,");
- StateTable.put("unlocked,disabled,failed,null,lock", "locked,disabled,failed,null,");
- StateTable.put("unlocked,disabled,failed,null,unlock", "unlocked,disabled,failed,null,");
- StateTable.put("unlocked,disabled,failed,null,disableFailed", "unlocked,disabled,failed,null,");
- StateTable.put("unlocked,disabled,failed,null,enableNotFailed", "unlocked,enabled,null,null,");
- StateTable.put("unlocked,disabled,failed,null,disableDependency", "unlocked,disabled,dependency.failed,null,");
- StateTable.put("unlocked,disabled,failed,null,enableNoDependency", "unlocked,disabled,failed,null,");
- StateTable.put("unlocked,disabled,failed,null,promote", "unlocked,disabled,failed,coldstandby,StandbyStatusException");
- StateTable.put("unlocked,disabled,failed,null,demote", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,failed,coldstandby,lock", "locked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,failed,coldstandby,unlock", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,failed,coldstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,failed,coldstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,disabled,failed,coldstandby,disableDependency", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,failed,coldstandby,enableNoDependency", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,failed,coldstandby,promote", "unlocked,disabled,failed,coldstandby,StandbyStatusException");
- StateTable.put("unlocked,disabled,failed,coldstandby,demote", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,failed,hotstandby,lock", "locked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,failed,hotstandby,unlock", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,failed,hotstandby,disableFailed", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,failed,hotstandby,enableNotFailed", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,disabled,failed,hotstandby,disableDependency", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,failed,hotstandby,enableNoDependency", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,failed,hotstandby,promote", "unlocked,disabled,failed,coldstandby,StandbyStatusException");
- StateTable.put("unlocked,disabled,failed,hotstandby,demote", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,failed,providingservice,lock", "locked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,failed,providingservice,unlock", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,failed,providingservice,disableFailed", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,failed,providingservice,enableNotFailed", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,disabled,failed,providingservice,disableDependency", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,failed,providingservice,enableNoDependency", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,failed,providingservice,promote", "unlocked,disabled,failed,coldstandby,StandbyStatusException");
- StateTable.put("unlocked,disabled,failed,providingservice,demote", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency,null,lock", "locked,disabled,dependency,null,");
- StateTable.put("unlocked,disabled,dependency,null,unlock", "unlocked,disabled,dependency,null,");
- StateTable.put("unlocked,disabled,dependency,null,disableFailed", "unlocked,disabled,dependency.failed,null,");
- StateTable.put("unlocked,disabled,dependency,null,enableNotFailed", "unlocked,disabled,dependency,null,");
- StateTable.put("unlocked,disabled,dependency,null,disableDependency", "unlocked,disabled,dependency,null,");
- StateTable.put("unlocked,disabled,dependency,null,enableNoDependency", "unlocked,enabled,null,null,");
- StateTable.put("unlocked,disabled,dependency,null,promote", "unlocked,disabled,dependency,coldstandby,StandbyStatusException");
- StateTable.put("unlocked,disabled,dependency,null,demote", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,dependency,coldstandby,lock", "locked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,dependency,coldstandby,unlock", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,dependency,coldstandby,disableFailed", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency,coldstandby,enableNotFailed", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,dependency,coldstandby,disableDependency", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,dependency,coldstandby,enableNoDependency", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,disabled,dependency,coldstandby,promote", "unlocked,disabled,dependency,coldstandby,StandbyStatusException");
- StateTable.put("unlocked,disabled,dependency,coldstandby,demote", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,dependency,hotstandby,lock", "locked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,dependency,hotstandby,unlock", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,dependency,hotstandby,disableFailed", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency,hotstandby,enableNotFailed", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,dependency,hotstandby,disableDependency", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,dependency,hotstandby,enableNoDependency", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,disabled,dependency,hotstandby,promote", "unlocked,disabled,dependency,coldstandby,StandbyStatusException");
- StateTable.put("unlocked,disabled,dependency,hotstandby,demote", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,dependency,providingservice,lock", "locked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,dependency,providingservice,unlock", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,dependency,providingservice,disableFailed", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency,providingservice,enableNotFailed", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,dependency,providingservice,disableDependency", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,dependency,providingservice,enableNoDependency", "unlocked,enabled,null,hotstandby,");
- StateTable.put("unlocked,disabled,dependency,providingservice,promote", "unlocked,disabled,dependency,coldstandby,StandbyStatusException");
- StateTable.put("unlocked,disabled,dependency,providingservice,demote", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,null,lock", "locked,disabled,dependency.failed,null,");
- StateTable.put("unlocked,disabled,dependency.failed,null,unlock", "unlocked,disabled,dependency.failed,null,");
- StateTable.put("unlocked,disabled,dependency.failed,null,disableFailed", "unlocked,disabled,dependency.failed,null,");
- StateTable.put("unlocked,disabled,dependency.failed,null,enableNotFailed", "unlocked,disabled,dependency,null,");
- StateTable.put("unlocked,disabled,dependency.failed,null,disableDependency", "unlocked,disabled,dependency.failed,null,");
- StateTable.put("unlocked,disabled,dependency.failed,null,enableNoDependency", "unlocked,disabled,failed,null,");
- StateTable.put("unlocked,disabled,dependency.failed,null,promote", "unlocked,disabled,dependency.failed,coldstandby,StandbyStatusException");
- StateTable.put("unlocked,disabled,dependency.failed,null,demote", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,coldstandby,lock", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,coldstandby,unlock", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,coldstandby,disableFailed", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,coldstandby,enableNotFailed", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,coldstandby,disableDependency", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,coldstandby,enableNoDependency", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,coldstandby,promote", "unlocked,disabled,dependency.failed,coldstandby,StandbyStatusException");
- StateTable.put("unlocked,disabled,dependency.failed,coldstandby,demote", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,hotstandby,lock", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,hotstandby,unlock", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,hotstandby,disableFailed", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,hotstandby,enableNotFailed", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,hotstandby,disableDependency", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,hotstandby,enableNoDependency", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,hotstandby,promote", "unlocked,disabled,dependency.failed,coldstandby,StandbyStatusException");
- StateTable.put("unlocked,disabled,dependency.failed,hotstandby,demote", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,providingservice,lock", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,providingservice,unlock", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,providingservice,disableFailed", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,providingservice,enableNotFailed", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,providingservice,disableDependency", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,providingservice,enableNoDependency", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("unlocked,disabled,dependency.failed,providingservice,promote", "unlocked,disabled,dependency.failed,coldstandby,StandbyStatusException");
- StateTable.put("unlocked,disabled,dependency.failed,providingservice,demote", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,enabled,null,null,lock", "locked,enabled,null,null,");
- StateTable.put("locked,enabled,null,null,unlock", "unlocked,enabled,null,null,");
- StateTable.put("locked,enabled,null,null,disableFailed", "locked,disabled,failed,null,");
- StateTable.put("locked,enabled,null,null,enableNotFailed", "locked,enabled,null,null,");
- StateTable.put("locked,enabled,null,null,disableDependency", "locked,disabled,dependency,null,");
- StateTable.put("locked,enabled,null,null,enableNoDependency", "locked,enabled,null,null,");
- StateTable.put("locked,enabled,null,null,promote", "locked,enabled,null,coldstandby,StandbyStatusException");
- StateTable.put("locked,enabled,null,null,demote", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,null,coldstandby,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,null,coldstandby,unlock", "unlocked,enabled,null,hotstandby,");
- StateTable.put("locked,enabled,null,coldstandby,disableFailed", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,enabled,null,coldstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,null,coldstandby,disableDependency", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,enabled,null,coldstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,null,coldstandby,promote", "locked,enabled,null,coldstandby,StandbyStatusException");
- StateTable.put("locked,enabled,null,coldstandby,demote", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,null,hotstandby,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,null,hotstandby,unlock", "unlocked,enabled,null,hotstandby,");
- StateTable.put("locked,enabled,null,hotstandby,disableFailed", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,enabled,null,hotstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,null,hotstandby,disableDependency", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,enabled,null,hotstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,null,hotstandby,promote", "locked,enabled,null,coldstandby,StandbyStateException");
- StateTable.put("locked,enabled,null,hotstandby,demote", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,null,providingservice,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,null,providingservice,unlock", "unlocked,enabled,null,hotstandby,");
- StateTable.put("locked,enabled,null,providingservice,disableFailed", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,enabled,null,providingservice,enableNotFailed", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,null,providingservice,disableDependency", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,enabled,null,providingservice,enableNoDependency", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,null,providingservice,promote", "locked,enabled,null,coldstandby,StandbyStateException");
- StateTable.put("locked,enabled,null,providingservice,demote", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,failed,null,lock", "locked,enabled,null,null,");
- StateTable.put("locked,enabled,failed,null,unlock", "unlocked,enabled,null,null,");
- StateTable.put("locked,enabled,failed,null,disableFailed", "locked,disabled,failed,null,");
- StateTable.put("locked,enabled,failed,null,enableNotFailed", "locked,enabled,null,null,");
- StateTable.put("locked,enabled,failed,null,disableDependency", "locked,disabled,dependency,null,");
- StateTable.put("locked,enabled,failed,null,enableNoDependency", "locked,enabled,null,null,");
- StateTable.put("locked,enabled,failed,null,promote", "locked,enabled,null,coldstandby,StandbyStatusException");
- StateTable.put("locked,enabled,failed,null,demote", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,failed,coldstandby,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,failed,coldstandby,unlock", "unlocked,enabled,null,hotstandby,");
- StateTable.put("locked,enabled,failed,coldstandby,disableFailed", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,enabled,failed,coldstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,failed,coldstandby,disableDependency", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,enabled,failed,coldstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,failed,coldstandby,promote", "locked,enabled,null,coldstandby,StandbyStatusException");
- StateTable.put("locked,enabled,failed,coldstandby,demote", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,failed,hotstandby,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,failed,hotstandby,unlock", "unlocked,enabled,null,hotstandby,");
- StateTable.put("locked,enabled,failed,hotstandby,disableFailed", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,enabled,failed,hotstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,failed,hotstandby,disableDependency", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,enabled,failed,hotstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,failed,hotstandby,promote", "locked,enabled,null,coldstandby,StandbyStatusException");
- StateTable.put("locked,enabled,failed,hotstandby,demote", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,failed,providingservice,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,failed,providingservice,unlock", "unlocked,enabled,null,hotstandby,");
- StateTable.put("locked,enabled,failed,providingservice,disableFailed", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,enabled,failed,providingservice,enableNotFailed", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,failed,providingservice,disableDependency", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,enabled,failed,providingservice,enableNoDependency", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,failed,providingservice,promote", "locked,enabled,null,coldstandby,StandbyStatusException");
- StateTable.put("locked,enabled,failed,providingservice,demote", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency,null,lock", "locked,enabled,null,null,");
- StateTable.put("locked,enabled,dependency,null,unlock", "unlocked,enabled,null,null,");
- StateTable.put("locked,enabled,dependency,null,disableFailed", "locked,disabled,failed,null,");
- StateTable.put("locked,enabled,dependency,null,enableNotFailed", "locked,enabled,null,null,");
- StateTable.put("locked,enabled,dependency,null,disableDependency", "locked,disabled,dependency,null,");
- StateTable.put("locked,enabled,dependency,null,enableNoDependency", "locked,enabled,null,null,");
- StateTable.put("locked,enabled,dependency,null,promote", "locked,enabled,null,coldstandby,StandbyStatusException");
- StateTable.put("locked,enabled,dependency,null,demote", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency,coldstandby,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency,coldstandby,unlock", "unlocked,enabled,null,hotstandby,");
- StateTable.put("locked,enabled,dependency,coldstandby,disableFailed", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,enabled,dependency,coldstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency,coldstandby,disableDependency", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,enabled,dependency,coldstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency,coldstandby,promote", "locked,enabled,null,coldstandby,StandbyStatusException");
- StateTable.put("locked,enabled,dependency,coldstandby,demote", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency,hotstandby,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency,hotstandby,unlock", "unlocked,enabled,null,hotstandby,");
- StateTable.put("locked,enabled,dependency,hotstandby,disableFailed", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,enabled,dependency,hotstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency,hotstandby,disableDependency", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,enabled,dependency,hotstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency,hotstandby,promote", "locked,enabled,null,coldstandby,StandbyStatusException");
- StateTable.put("locked,enabled,dependency,hotstandby,demote", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency,providingservice,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency,providingservice,unlock", "unlocked,enabled,null,hotstandby,");
- StateTable.put("locked,enabled,dependency,providingservice,disableFailed", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,enabled,dependency,providingservice,enableNotFailed", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency,providingservice,disableDependency", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,enabled,dependency,providingservice,enableNoDependency", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency,providingservice,promote", "locked,enabled,null,coldstandby,StandbyStatusException");
- StateTable.put("locked,enabled,dependency,providingservice,demote", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency.failed,null,lock", "locked,enabled,null,null,");
- StateTable.put("locked,enabled,dependency.failed,null,unlock", "unlocked,enabled,null,null,");
- StateTable.put("locked,enabled,dependency.failed,null,disableFailed", "locked,disabled,failed,null,");
- StateTable.put("locked,enabled,dependency.failed,null,enableNotFailed", "locked,enabled,null,null,");
- StateTable.put("locked,enabled,dependency.failed,null,disableDependency", "locked,disabled,dependency,null,");
- StateTable.put("locked,enabled,dependency.failed,null,enableNoDependency", "locked,enabled,null,null,");
- StateTable.put("locked,enabled,dependency.failed,null,promote", "locked,enabled,null,coldstandby,StandbyStatusException");
- StateTable.put("locked,enabled,dependency.failed,null,demote", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency.failed,coldstandby,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency.failed,coldstandby,unlock", "unlocked,enabled,null,hotstandby,");
- StateTable.put("locked,enabled,dependency.failed,coldstandby,disableFailed", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,enabled,dependency.failed,coldstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency.failed,coldstandby,disableDependency", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,enabled,dependency.failed,coldstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency.failed,coldstandby,promote", "locked,enabled,null,coldstandby,StandbyStatusException");
- StateTable.put("locked,enabled,dependency.failed,coldstandby,demote", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency.failed,hotstandby,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency.failed,hotstandby,unlock", "unlocked,enabled,null,hotstandby,");
- StateTable.put("locked,enabled,dependency.failed,hotstandby,disableFailed", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,enabled,dependency.failed,hotstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency.failed,hotstandby,disableDependency", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,enabled,dependency.failed,hotstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency.failed,hotstandby,promote", "locked,enabled,null,coldstandby,StandbyStatusException");
- StateTable.put("locked,enabled,dependency.failed,hotstandby,demote", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency.failed,providingservice,lock", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency.failed,providingservice,unlock", "unlocked,enabled,null,hotstandby,");
- StateTable.put("locked,enabled,dependency.failed,providingservice,disableFailed", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,enabled,dependency.failed,providingservice,enableNotFailed", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency.failed,providingservice,disableDependency", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,enabled,dependency.failed,providingservice,enableNoDependency", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,enabled,dependency.failed,providingservice,promote", "locked,enabled,null,coldstandby,StandbyStatusException");
- StateTable.put("locked,enabled,dependency.failed,providingservice,demote", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,disabled,null,null,lock", "locked,disabled,null,null,");
- StateTable.put("locked,disabled,null,null,unlock", "unlocked,disabled,null,null,");
- StateTable.put("locked,disabled,null,null,disableFailed", "locked,disabled,failed,null,");
- StateTable.put("locked,disabled,null,null,enableNotFailed", "locked,enabled,null,null,");
- StateTable.put("locked,disabled,null,null,disableDependency", "locked,disabled,dependency,null,");
- StateTable.put("locked,disabled,null,null,enableNoDependency", "locked,enabled,null,null,");
- StateTable.put("locked,disabled,null,null,promote", "locked,disabled,null,coldstandby,StandbyStatusException");
- StateTable.put("locked,disabled,null,null,demote", "locked,disabled,null,coldstandby,");
- StateTable.put("locked,disabled,null,coldstandby,lock", "locked,disabled,null,coldstandby,");
- StateTable.put("locked,disabled,null,coldstandby,unlock", "unlocked,disabled,null,coldstandby,");
- StateTable.put("locked,disabled,null,coldstandby,disableFailed", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,null,coldstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,disabled,null,coldstandby,disableDependency", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,null,coldstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,disabled,null,coldstandby,promote", "locked,disabled,null,coldstandby,StandbyStatusException");
- StateTable.put("locked,disabled,null,coldstandby,demote", "locked,disabled,null,coldstandby,");
- StateTable.put("locked,disabled,null,hotstandby,lock", "locked,disabled,null,coldstandby,");
- StateTable.put("locked,disabled,null,hotstandby,unlock", "unlocked,disabled,null,coldstandby,");
- StateTable.put("locked,disabled,null,hotstandby,disableFailed", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,null,hotstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,disabled,null,hotstandby,disableDependency", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,null,hotstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,disabled,null,hotstandby,promote", "locked,disabled,null,coldstandby,StandbyStatusException");
- StateTable.put("locked,disabled,null,hotstandby,demote", "locked,disabled,null,coldstandby,");
- StateTable.put("locked,disabled,null,providingservice,lock", "locked,disabled,null,coldstandby,");
- StateTable.put("locked,disabled,null,providingservice,unlock", "unlocked,disabled,null,coldstandby,");
- StateTable.put("locked,disabled,null,providingservice,disableFailed", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,null,providingservice,enableNotFailed", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,disabled,null,providingservice,disableDependency", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,null,providingservice,enableNoDependency", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,disabled,null,providingservice,promote", "locked,disabled,null,coldstandby,StandbyStatusException");
- StateTable.put("locked,disabled,null,providingservice,demote", "locked,disabled,null,coldstandby,");
- StateTable.put("locked,disabled,failed,null,lock", "locked,disabled,failed,null,");
- StateTable.put("locked,disabled,failed,null,unlock", "unlocked,disabled,failed,null,");
- StateTable.put("locked,disabled,failed,null,disableFailed", "locked,disabled,failed,null,");
- StateTable.put("locked,disabled,failed,null,enableNotFailed", "locked,enabled,null,null,");
- StateTable.put("locked,disabled,failed,null,disableDependency", "locked,disabled,dependency.failed,null,");
- StateTable.put("locked,disabled,failed,null,enableNoDependency", "locked,disabled,failed,null,");
- StateTable.put("locked,disabled,failed,null,promote", "locked,disabled,failed,coldstandby,StandbyStatusException");
- StateTable.put("locked,disabled,failed,null,demote", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,failed,coldstandby,lock", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,failed,coldstandby,unlock", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,failed,coldstandby,disableFailed", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,failed,coldstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,disabled,failed,coldstandby,disableDependency", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,failed,coldstandby,enableNoDependency", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,failed,coldstandby,promote", "locked,disabled,failed,coldstandby,StandbyStatusException");
- StateTable.put("locked,disabled,failed,coldstandby,demote", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,failed,hotstandby,lock", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,failed,hotstandby,unlock", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,failed,hotstandby,disableFailed", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,failed,hotstandby,enableNotFailed", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,disabled,failed,hotstandby,disableDependency", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,failed,hotstandby,enableNoDependency", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,failed,hotstandby,promote", "locked,disabled,failed,coldstandby,StandbyStatusException");
- StateTable.put("locked,disabled,failed,hotstandby,demote", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,failed,providingservice,lock", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,failed,providingservice,unlock", "unlocked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,failed,providingservice,disableFailed", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,failed,providingservice,enableNotFailed", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,disabled,failed,providingservice,disableDependency", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,failed,providingservice,enableNoDependency", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,failed,providingservice,promote", "locked,disabled,failed,coldstandby,StandbyStatusException");
- StateTable.put("locked,disabled,failed,providingservice,demote", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,dependency,null,lock", "locked,disabled,dependency,null,");
- StateTable.put("locked,disabled,dependency,null,unlock", "unlocked,disabled,dependency,null,");
- StateTable.put("locked,disabled,dependency,null,disableFailed", "locked,disabled,dependency.failed,null,");
- StateTable.put("locked,disabled,dependency,null,enableNotFailed", "locked,disabled,dependency,null,");
- StateTable.put("locked,disabled,dependency,null,disableDependency", "locked,disabled,dependency,null,");
- StateTable.put("locked,disabled,dependency,null,enableNoDependency", "locked,enabled,null,null,");
- StateTable.put("locked,disabled,dependency,null,promote", "locked,disabled,dependency,coldstandby,StandbyStatusException");
- StateTable.put("locked,disabled,dependency,null,demote", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,dependency,coldstandby,lock", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,dependency,coldstandby,unlock", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,dependency,coldstandby,disableFailed", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,dependency,coldstandby,enableNotFailed", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,dependency,coldstandby,disableDependency", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,dependency,coldstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,disabled,dependency,coldstandby,promote", "locked,disabled,dependency,coldstandby,StandbyStatusException");
- StateTable.put("locked,disabled,dependency,coldstandby,demote", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,dependency,hotstandby,lock", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,dependency,hotstandby,unlock", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,dependency,hotstandby,disableFailed", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,dependency,hotstandby,enableNotFailed", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,dependency,hotstandby,disableDependency", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,dependency,hotstandby,enableNoDependency", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,disabled,dependency,hotstandby,promote", "locked,disabled,dependency,coldstandby,StandbyStatusException");
- StateTable.put("locked,disabled,dependency,hotstandby,demote", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,dependency,providingservice,lock", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,dependency,providingservice,unlock", "unlocked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,dependency,providingservice,disableFailed", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,dependency,providingservice,enableNotFailed", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,dependency,providingservice,disableDependency", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,dependency,providingservice,enableNoDependency", "locked,enabled,null,coldstandby,");
- StateTable.put("locked,disabled,dependency,providingservice,promote", "locked,disabled,dependency,coldstandby,StandbyStatusException");
- StateTable.put("locked,disabled,dependency,providingservice,demote", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,null,lock", "locked,disabled,dependency.failed,null,");
- StateTable.put("locked,disabled,dependency.failed,null,unlock", "unlocked,disabled,dependency.failed,null,");
- StateTable.put("locked,disabled,dependency.failed,null,disableFailed", "locked,disabled,dependency.failed,null,");
- StateTable.put("locked,disabled,dependency.failed,null,enableNotFailed", "locked,disabled,dependency,null,");
- StateTable.put("locked,disabled,dependency.failed,null,disableDependency", "locked,disabled,dependency.failed,null,");
- StateTable.put("locked,disabled,dependency.failed,null,enableNoDependency", "locked,disabled,failed,null,");
- StateTable.put("locked,disabled,dependency.failed,null,promote", "locked,disabled,dependency.failed,coldstandby,StandbyStatusException");
- StateTable.put("locked,disabled,dependency.failed,null,demote", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,coldstandby,lock", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,coldstandby,unlock", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,coldstandby,disableFailed", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,coldstandby,enableNotFailed", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,coldstandby,disableDependency", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,coldstandby,enableNoDependency", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,coldstandby,promote", "locked,disabled,dependency.failed,coldstandby,StandbyStatusException");
- StateTable.put("locked,disabled,dependency.failed,coldstandby,demote", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,hotstandby,lock", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,hotstandby,unlock", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,hotstandby,disableFailed", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,hotstandby,enableNotFailed", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,hotstandby,disableDependency", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,hotstandby,enableNoDependency", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,hotstandby,promote", "locked,disabled,dependency.failed,coldstandby,StandbyStatusException");
- StateTable.put("locked,disabled,dependency.failed,hotstandby,demote", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,providingservice,lock", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,providingservice,unlock", "unlocked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,providingservice,disableFailed", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,providingservice,enableNotFailed", "locked,disabled,dependency,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,providingservice,disableDependency", "locked,disabled,dependency.failed,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,providingservice,enableNoDependency", "locked,disabled,failed,coldstandby,");
- StateTable.put("locked,disabled,dependency.failed,providingservice,promote", "locked,disabled,dependency.failed,coldstandby,StandbyStatusException");
- StateTable.put("locked,disabled,dependency.failed,providingservice,demote", "locked,disabled,dependency.failed,coldstandby,");
- }
-
- public void displayStateTable()
- {
- Set<?> set = StateTable.entrySet();
- Iterator<?> iter = set.iterator();
-
- while(iter.hasNext()) {
- Map.Entry<?, ?> me = (Map.Entry<?, ?>)iter.next();
- String key = (String)me.getKey() + ((String)me.getValue()).replace(".", ",");
- if(logger.isDebugEnabled()){
- logger.debug("{}", key);
- }
- }
- }
+ while (iter.hasNext()) {
+ Map.Entry<?, ?> me = (Map.Entry<?, ?>) iter.next();
+ String key = (String) me.getKey() + ((String) me.getValue()).replace(".", ",");
+ if (logger.isDebugEnabled()) {
+ logger.debug("{}", key);
+ }
+ }
+ }
}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransitionException.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransitionException.java
index 74998427..0f4ea2fd 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransitionException.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransitionException.java
@@ -21,19 +21,22 @@
package org.onap.policy.common.im;
public class StateTransitionException extends IntegrityMonitorException {
- private static final long serialVersionUID = 1L;
- public StateTransitionException() {
- super();
- }
- public StateTransitionException(String message) {
- super(message);
- }
+ private static final long serialVersionUID = 1L;
- public StateTransitionException(Throwable cause) {
- super(cause);
- }
- public StateTransitionException(String message, Throwable cause) {
- super(message, cause);
- }
+ public StateTransitionException() {
+ super();
+ }
+
+ public StateTransitionException(String message) {
+ super(message);
+ }
+
+ public StateTransitionException(Throwable cause) {
+ super(cause);
+ }
+
+ public StateTransitionException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdmin.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdmin.java
index eb1d9f8b..bd7ed7b5 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdmin.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdmin.java
@@ -32,197 +32,197 @@ import javax.management.MalformedObjectNameException;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.onap.policy.common.im.IntegrityMonitor;
import org.onap.policy.common.im.IntegrityMonitorException;
import org.onap.policy.common.im.StateManagement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Base class for component MBeans.
*/
public class ComponentAdmin implements ComponentAdminMBean {
- private static final String STATE_MANAGER = "stateManager";
-
- private static final Logger logger = LoggerFactory.getLogger(ComponentAdmin.class.getName());
-
- private final String name;
- private MBeanServer registeredMBeanServer;
- private ObjectName registeredObjectName;
- private IntegrityMonitor integrityMonitor = null;
- private StateManagement stateManager = null;
-
- /**
- * Constructor.
- * @param name the MBean name
- * @param integrityMonitor
- * @param stateManager
- * @throws ComponentAdminException
- */
- public ComponentAdmin(String name, IntegrityMonitor integrityMonitor, StateManagement stateManager) throws ComponentAdminException {
- if ((name == null) || (integrityMonitor == null) || (stateManager == null)) {
- logger.error("Error: ComponentAdmin constructor called with invalid input");
- throw new ComponentAdminException("null input");
- }
-
- this.name = "ONAP_POLICY_COMP:name=" + name;
- this.integrityMonitor = integrityMonitor;
- this.stateManager = stateManager;
-
- try {
- register();
- } catch (ComponentAdminException e) {
- logger.debug("Failed to register ComponentAdmin MBean");
- throw e;
- }
- }
-
- /**
- * Registers with the MBean server.
- * @throws ComponentAdminException a JMX exception
- */
- public synchronized void register() throws ComponentAdminException {
-
- try {
- logger.debug("Registering {} MBean", name);
-
- MBeanServer mbeanServer = findMBeanServer();
-
- if (mbeanServer == null) {
- return;
- }
-
- ObjectName objectName = new ObjectName(name);
-
- if (mbeanServer.isRegistered(objectName)) {
- logger.debug("Unregistering a previously registered {} MBean", name);
- mbeanServer.unregisterMBean(objectName);
- }
-
- mbeanServer.registerMBean(this, objectName);
- registeredMBeanServer = mbeanServer;
- registeredObjectName = objectName;
-
- } catch (MalformedObjectNameException | MBeanRegistrationException | InstanceNotFoundException | InstanceAlreadyExistsException | NotCompliantMBeanException e) {
- throw new ComponentAdminException(e);
- }
- }
-
- /**
- * Checks if this MBean is registered with the MBeanServer.
- * @return true if this MBean is registered with the MBeanServer.
- */
- public boolean isRegistered() {
- return registeredObjectName != null;
- }
-
- /**
- * Unregisters with the MBean server.
- * @throws ComponentAdminException a JMX exception
- */
- public synchronized void unregister() throws ComponentAdminException {
-
- if (registeredObjectName == null) {
- return;
- }
-
-
- try {
- registeredMBeanServer.unregisterMBean(registeredObjectName);
-
- } catch (MBeanRegistrationException | InstanceNotFoundException e) {
- throw new ComponentAdminException(e);
- }
-
- registeredMBeanServer = null;
- registeredObjectName = null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return ComponentAdmin.class.getSimpleName() + "[" + name + "]";
- }
-
- /**
- * Finds the MBeanServer.
- * @return the MBeanServer, or null if it is not found
- */
- public static MBeanServer findMBeanServer() {
- ArrayList<MBeanServer> mbeanServers =
- MBeanServerFactory.findMBeanServer(null);
-
- Iterator<MBeanServer> iter = mbeanServers.iterator();
- MBeanServer mbeanServer;
-
- while (iter.hasNext()) {
- mbeanServer = iter.next();
- if ("DefaultDomain".equals(mbeanServer.getDefaultDomain())) {
- return mbeanServer;
- }
- }
-
- return null;
- }
-
- /**
- * Creates the MBeanServer (intended for unit testing only).
- * @return the MBeanServer
- */
- public static MBeanServer createMBeanServer() {
- return MBeanServerFactory.createMBeanServer("DefaultDomain");
- }
-
- /**
- * Get the MBean object name for the specified feature name.
- * @param componentName component name
- * @return the object name
- * @throws MalformedObjectNameException a JMX exception
- */
- public static ObjectName getObjectName(String componentName)
- throws MalformedObjectNameException {
- return new ObjectName("ONAP_POLICY_COMP:name=" + componentName);
- }
-
- @Override
- public void test() throws IntegrityMonitorException {
- // Call evaluateSanity on IntegrityMonitor to run the test
- logger.debug("test() called...");
- if (integrityMonitor != null) {
- integrityMonitor.evaluateSanity();
- }
- else {
- logger.error("Unable to invoke test() - state manager instance is null");
- throw new ComponentAdminException(STATE_MANAGER);
- }
-
- }
-
- @Override
- public void lock() throws IntegrityMonitorException {
- logger.debug("lock() called...");
- if (stateManager != null) {
- stateManager.lock();
- }
- else {
- logger.error("Unable to invoke lock() - state manager instance is null");
- throw new ComponentAdminException(STATE_MANAGER);
- }
- }
-
- @Override
- public void unlock() throws IntegrityMonitorException {
- logger.debug("unlock() called...");
- if (stateManager != null) {
- stateManager.unlock();
- }
- else {
- logger.error("Unable to invoke unlock() - state manager instance is null");
- throw new ComponentAdminException(STATE_MANAGER);
- }
-
- }
+ private static final String STATE_MANAGER = "stateManager";
+
+ private static final Logger logger = LoggerFactory.getLogger(ComponentAdmin.class.getName());
+
+ private final String name;
+ private MBeanServer registeredMBeanServer;
+ private ObjectName registeredObjectName;
+ private IntegrityMonitor integrityMonitor = null;
+ private StateManagement stateManager = null;
+
+ /**
+ * Constructor.
+ *
+ * @param name the MBean name
+ * @param integrityMonitor the integrity monitor
+ * @param stateManager the state manager
+ * @throws ComponentAdminException if an error occurs
+ */
+ public ComponentAdmin(String name, IntegrityMonitor integrityMonitor, StateManagement stateManager)
+ throws ComponentAdminException {
+ if ((name == null) || (integrityMonitor == null) || (stateManager == null)) {
+ logger.error("Error: ComponentAdmin constructor called with invalid input");
+ throw new ComponentAdminException("null input");
+ }
+
+ this.name = "ONAP_POLICY_COMP:name=" + name;
+ this.integrityMonitor = integrityMonitor;
+ this.stateManager = stateManager;
+
+ try {
+ register();
+ } catch (ComponentAdminException e) {
+ logger.debug("Failed to register ComponentAdmin MBean");
+ throw e;
+ }
+ }
+
+ /**
+ * Registers with the MBean server.
+ *
+ * @throws ComponentAdminException a JMX exception
+ */
+ public synchronized void register() throws ComponentAdminException {
+
+ try {
+ logger.debug("Registering {} MBean", name);
+
+ MBeanServer mbeanServer = findMBeanServer();
+
+ if (mbeanServer == null) {
+ return;
+ }
+
+ ObjectName objectName = new ObjectName(name);
+
+ if (mbeanServer.isRegistered(objectName)) {
+ logger.debug("Unregistering a previously registered {} MBean", name);
+ mbeanServer.unregisterMBean(objectName);
+ }
+
+ mbeanServer.registerMBean(this, objectName);
+ registeredMBeanServer = mbeanServer;
+ registeredObjectName = objectName;
+
+ } catch (MalformedObjectNameException | MBeanRegistrationException | InstanceNotFoundException
+ | InstanceAlreadyExistsException | NotCompliantMBeanException e) {
+ throw new ComponentAdminException(e);
+ }
+ }
+
+ /**
+ * Checks if this MBean is registered with the MBeanServer.
+ *
+ * @return true if this MBean is registered with the MBeanServer.
+ */
+ public boolean isRegistered() {
+ return registeredObjectName != null;
+ }
+
+ /**
+ * Unregisters with the MBean server.
+ *
+ * @throws ComponentAdminException a JMX exception
+ */
+ public synchronized void unregister() throws ComponentAdminException {
+
+ if (registeredObjectName == null) {
+ return;
+ }
+
+
+ try {
+ registeredMBeanServer.unregisterMBean(registeredObjectName);
+
+ } catch (MBeanRegistrationException | InstanceNotFoundException e) {
+ throw new ComponentAdminException(e);
+ }
+
+ registeredMBeanServer = null;
+ registeredObjectName = null;
+ }
+
+ @Override
+ public String toString() {
+ return ComponentAdmin.class.getSimpleName() + "[" + name + "]";
+ }
+
+ /**
+ * Finds the MBeanServer.
+ *
+ * @return the MBeanServer, or null if it is not found
+ */
+ public static MBeanServer findMBeanServer() {
+ ArrayList<MBeanServer> mbeanServers = MBeanServerFactory.findMBeanServer(null);
+
+ Iterator<MBeanServer> iter = mbeanServers.iterator();
+ MBeanServer mbeanServer;
+
+ while (iter.hasNext()) {
+ mbeanServer = iter.next();
+ if ("DefaultDomain".equals(mbeanServer.getDefaultDomain())) {
+ return mbeanServer;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Creates the MBeanServer (intended for unit testing only).
+ *
+ * @return the MBeanServer
+ */
+ public static MBeanServer createMBeanServer() {
+ return MBeanServerFactory.createMBeanServer("DefaultDomain");
+ }
+
+ /**
+ * Get the MBean object name for the specified feature name.
+ *
+ * @param componentName component name
+ * @return the object name
+ * @throws MalformedObjectNameException a JMX exception
+ */
+ public static ObjectName getObjectName(String componentName) throws MalformedObjectNameException {
+ return new ObjectName("ONAP_POLICY_COMP:name=" + componentName);
+ }
+
+ @Override
+ public void test() throws IntegrityMonitorException {
+ // Call evaluateSanity on IntegrityMonitor to run the test
+ logger.debug("test() called...");
+ if (integrityMonitor != null) {
+ integrityMonitor.evaluateSanity();
+ } else {
+ logger.error("Unable to invoke test() - state manager instance is null");
+ throw new ComponentAdminException(STATE_MANAGER);
+ }
+
+ }
+
+ @Override
+ public void lock() throws IntegrityMonitorException {
+ logger.debug("lock() called...");
+ if (stateManager != null) {
+ stateManager.lock();
+ } else {
+ logger.error("Unable to invoke lock() - state manager instance is null");
+ throw new ComponentAdminException(STATE_MANAGER);
+ }
+ }
+
+ @Override
+ public void unlock() throws IntegrityMonitorException {
+ logger.debug("unlock() called...");
+ if (stateManager != null) {
+ stateManager.unlock();
+ } else {
+ logger.error("Unable to invoke unlock() - state manager instance is null");
+ throw new ComponentAdminException(STATE_MANAGER);
+ }
+
+ }
}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdminException.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdminException.java
index 5ada6da0..dcc4da0a 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdminException.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdminException.java
@@ -23,22 +23,22 @@ package org.onap.policy.common.im.jmx;
import org.onap.policy.common.im.IntegrityMonitorException;
public class ComponentAdminException extends IntegrityMonitorException {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- public ComponentAdminException() {
- super();
- }
+ public ComponentAdminException() {
+ super();
+ }
- public ComponentAdminException(String message) {
- super(message);
- }
+ public ComponentAdminException(String message) {
+ super(message);
+ }
- public ComponentAdminException(Throwable cause) {
- super(cause);
- }
+ public ComponentAdminException(Throwable cause) {
+ super(cause);
+ }
- public ComponentAdminException(String message, Throwable cause) {
- super(message, cause);
- }
+ public ComponentAdminException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdminMBean.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdminMBean.java
index 2c011935..3276cf63 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdminMBean.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdminMBean.java
@@ -26,27 +26,24 @@ import org.onap.policy.common.im.IntegrityMonitorException;
* Provides operations to test health, lock and unlock components.
*/
public interface ComponentAdminMBean {
- /**
- * Test health of component.
- *
- * @throws IntegrityMonitorException
- * if the component fails the health check
- */
- void test() throws IntegrityMonitorException;
+ /**
+ * Test health of component.
+ *
+ * @throws IntegrityMonitorException if the component fails the health check
+ */
+ void test() throws IntegrityMonitorException;
- /**
- * Administratively lock component.
- *
- * @throws IntegrityMonitorException
- * if the component lock fails
- */
- void lock() throws IntegrityMonitorException;
-
- /**
- * Administratively unlock component.
- *
- * @throws IntegrityMonitorException
- * if the component unlock fails
- */
- void unlock() throws IntegrityMonitorException;
+ /**
+ * Administratively lock component.
+ *
+ * @throws IntegrityMonitorException if the component lock fails
+ */
+ void lock() throws IntegrityMonitorException;
+
+ /**
+ * Administratively unlock component.
+ *
+ * @throws IntegrityMonitorException if the component unlock fails
+ */
+ void unlock() throws IntegrityMonitorException;
}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/JmxAgentConnection.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/JmxAgentConnection.java
index c9a2ce80..b71751f0 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/JmxAgentConnection.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/JmxAgentConnection.java
@@ -18,9 +18,6 @@
* ============LICENSE_END=========================================================
*/
-/**
- *
- */
package org.onap.policy.common.im.jmx;
import java.io.IOException;
@@ -43,93 +40,89 @@ import org.onap.policy.common.logging.flexlogger.Logger;
* Class to create a JMX RMI connection to the JmxAgent.
*/
public final class JmxAgentConnection {
-
+
private static final Logger logger = FlexLogger.getLogger(JmxAgentConnection.class);
- private static final String DEFAULT_HOST = "localhost";
- private static final String DEFAULT_PORT = "9996";
-
- private String host;
- private String port;
- private JMXConnector connector;
- private String jmxUrl = null;
-
- /**
- * Set up the host/port from the properties. Use defaults if missing from the properties.
- * @param properties the properties used to look for host and port
- */
- public JmxAgentConnection() {
- host = DEFAULT_HOST;
- port = DEFAULT_PORT;
- }
-
- public JmxAgentConnection(String url) {
- jmxUrl = url;
- }
-
- /**
- * Generate jmxAgent url.
- * service:jmx:rmi:///jndi/rmi://host.domain:9999/jmxAgent
- *
- * @param host
- * host.domain
- * @param port
- * 9999
- * @return jmxAgent url.
- */
- private static String jmxAgentUrl(String host, String port) {
-
- return "service:jmx:rmi:///jndi/rmi://" + host + ":" + port
- + "/jmxrmi";
- }
-
- /**
- * Get a connection to the jmxAgent MBeanServer.
- * @return the connection
- * @throws IntegrityMonitorException on error
- */
- public MBeanServerConnection getMBeanConnection() throws IntegrityMonitorException {
-
- try {
- JMXServiceURL url;
- if (jmxUrl == null) {
- url = new JMXServiceURL(jmxAgentUrl(host, port));
- }
- else {
- url = new JMXServiceURL(jmxUrl);
- }
- Map<String, Object> env = new HashMap<>();
-
- connector = JMXConnectorFactory.newJMXConnector(url, env);
- connector.connect();
- connector.addConnectionNotificationListener(
- new NotificationListener() {
-
- @Override
- public void handleNotification(
- Notification notification, Object handback) {
- if (notification.getType().equals(
- JMXConnectionNotification.FAILED)) {
- // handle disconnect
- disconnect();
- }
- }
- }, null, null);
-
- return connector.getMBeanServerConnection();
-
- } catch (IOException e) {
- throw new IntegrityMonitorException(e);
- }
- }
-
- /**
- * Disconnect.
- */
- public void disconnect() {
- if (connector != null) {
- try { connector.close(); } catch (IOException e) { logger.debug(e); }
- }
- }
+ private static final String DEFAULT_HOST = "localhost";
+ private static final String DEFAULT_PORT = "9996";
+
+ private String host;
+ private String port;
+ private JMXConnector connector;
+ private String jmxUrl = null;
+
+ /**
+ * Set up the host/port from the properties. Use defaults if missing from the properties.
+ */
+ public JmxAgentConnection() {
+ host = DEFAULT_HOST;
+ port = DEFAULT_PORT;
+ }
+
+ public JmxAgentConnection(String url) {
+ jmxUrl = url;
+ }
+
+ /**
+ * Generate jmxAgent url. service:jmx:rmi:///jndi/rmi://host.domain:9999/jmxAgent
+ *
+ * @param host host.domain
+ * @param port 9999
+ * @return jmxAgent url.
+ */
+ private static String jmxAgentUrl(String host, String port) {
+
+ return "service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/jmxrmi";
+ }
+
+ /**
+ * Get a connection to the jmxAgent MBeanServer.
+ *
+ * @return the connection
+ * @throws IntegrityMonitorException on error
+ */
+ public MBeanServerConnection getMBeanConnection() throws IntegrityMonitorException {
+
+ try {
+ JMXServiceURL url;
+ if (jmxUrl == null) {
+ url = new JMXServiceURL(jmxAgentUrl(host, port));
+ } else {
+ url = new JMXServiceURL(jmxUrl);
+ }
+ Map<String, Object> env = new HashMap<>();
+
+ connector = JMXConnectorFactory.newJMXConnector(url, env);
+ connector.connect();
+ connector.addConnectionNotificationListener(new NotificationListener() {
+
+ @Override
+ public void handleNotification(Notification notification, Object handback) {
+ if (notification.getType().equals(JMXConnectionNotification.FAILED)) {
+ // handle disconnect
+ disconnect();
+ }
+ }
+ }, null, null);
+
+ return connector.getMBeanServerConnection();
+
+ } catch (IOException e) {
+ throw new IntegrityMonitorException(e);
+ }
+ }
+
+ /**
+ * Disconnect.
+ */
+ public void disconnect() {
+ if (connector != null) {
+ try {
+ connector.close();
+ } catch (IOException e) {
+ logger.debug(e);
+ }
+ }
+ }
}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ForwardProgressEntity.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ForwardProgressEntity.java
index 2ef3fa8a..24f36c56 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ForwardProgressEntity.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ForwardProgressEntity.java
@@ -40,92 +40,104 @@ import javax.persistence.TemporalType;
*/
@Entity
-@Table(name="ForwardProgressEntity")
-@NamedQueries({
- @NamedQuery(name=" ForwardProgressEntity.findAll", query="SELECT e FROM ForwardProgressEntity e "),
- @NamedQuery(name="ForwardProgressEntity.deleteAll", query="DELETE FROM ForwardProgressEntity WHERE 1=1")
-})
-//@SequenceGenerator(name="seqForwardProgress", initialValue=1, allocationSize=1)
+@Table(name = "ForwardProgressEntity")
+@NamedQueries({@NamedQuery(name = " ForwardProgressEntity.findAll", query = "SELECT e FROM ForwardProgressEntity e "),
+ @NamedQuery(name = "ForwardProgressEntity.deleteAll", query = "DELETE FROM ForwardProgressEntity WHERE 1=1")})
+// @SequenceGenerator(name="seqForwardProgress", initialValue=1, allocationSize=1)
public class ForwardProgressEntity implements Serializable {
- private static final long serialVersionUID = 1L;
-
- @Id
- //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqForwardProgress")
- @GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="forwardProgressId")
- private long forwardProgressId;
-
- @Column(name="resourceName", nullable=false, length=100, unique=true)
- private String resourceName;
-
- @Column(name="fpc_count", nullable=false)
- private long fpcCount;
-
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
- private Date created_date;
-
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="last_updated")
- private Date lastUpdated;
-
- public ForwardProgressEntity() {
- //default constructor
- }
-
- @PrePersist
- public void prePersist() {
- Date date = new Date();
- this.created_date = date;
- this.lastUpdated = date;
- this.fpcCount = 0;
- }
-
- @PreUpdate
- public void preUpdate() {
- this.lastUpdated = new Date();
- }
-
- /**
- * @return the Id
- */
- public long getForwardProgressId() {
- return forwardProgressId;
- }
-
- public String getResourceName() {
- return this.resourceName;
- }
- public void setResourceName(String resourceName) {
- this.resourceName = resourceName;
- }
-
- /**
- * @return the fpcCount
- */
- public long getFpcCount() {
- return fpcCount;
- }
-
- /**
- * @param fpcCount the fpcCount to set
- */
- public void setFpcCount(long fpcCount) {
- this.fpcCount = fpcCount;
- }
-
- /**
- * @return the lastUpdated
- */
- public Date getLastUpdated() {
- return lastUpdated;
- }
-
- /**
- * @param lastUpdated the lastUpdated to set
- */
- public void setLastUpdated(Date lastUpdated) {
- this.lastUpdated = lastUpdated;
- }
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ // @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqForwardProgress")
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "forwardProgressId")
+ private long forwardProgressId;
+
+ @Column(name = "resourceName", nullable = false, length = 100, unique = true)
+ private String resourceName;
+
+ @Column(name = "fpc_count", nullable = false)
+ private long fpcCount;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "created_date", updatable = false)
+ private Date createdDate;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "last_updated")
+ private Date lastUpdated;
+
+ public ForwardProgressEntity() {
+ // default constructor
+ }
+
+ /**
+ * PrePersist callback method.
+ */
+ @PrePersist
+ public void prePersist() {
+ Date date = new Date();
+ this.createdDate = date;
+ this.lastUpdated = date;
+ this.fpcCount = 0;
+ }
+
+ @PreUpdate
+ public void preUpdate() {
+ this.lastUpdated = new Date();
+ }
+
+ /**
+ * Get the forward progress Id.
+ *
+ * @return the Id
+ */
+ public long getForwardProgressId() {
+ return forwardProgressId;
+ }
+
+ public String getResourceName() {
+ return this.resourceName;
+ }
+
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ /**
+ * Get the fpcCount.
+ *
+ * @return the fpcCount
+ */
+ public long getFpcCount() {
+ return fpcCount;
+ }
+
+ /**
+ * Set the fpcCount.
+ *
+ * @param fpcCount the fpcCount to set
+ */
+ public void setFpcCount(long fpcCount) {
+ this.fpcCount = fpcCount;
+ }
+
+ /**
+ * Get the lastUpdated.
+ *
+ * @return the lastUpdated
+ */
+ public Date getLastUpdated() {
+ return lastUpdated;
+ }
+
+ /**
+ * Set the lastUpdated.
+ *
+ * @param lastUpdated the lastUpdated to set
+ */
+ public void setLastUpdated(Date lastUpdated) {
+ this.lastUpdated = lastUpdated;
+ }
}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ImTestEntity.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ImTestEntity.java
index 454bf7e1..6fb1446e 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ImTestEntity.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ImTestEntity.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -37,105 +37,122 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
-@Table(name="ImTestEntity")
-@NamedQueries({
- @NamedQuery(name=" ImTestEntity.findAll", query="SELECT e FROM ImTestEntity e "),
- @NamedQuery(name="ImTestEntity.deleteAll", query="DELETE FROM ImTestEntity WHERE 1=1")
-})
-//@SequenceGenerator(name="seqImTest", initialValue=1, allocationSize=1)
+@Table(name = "ImTestEntity")
+@NamedQueries({@NamedQuery(name = " ImTestEntity.findAll", query = "SELECT e FROM ImTestEntity e "),
+ @NamedQuery(name = "ImTestEntity.deleteAll", query = "DELETE FROM ImTestEntity WHERE 1=1")})
+// @SequenceGenerator(name="seqImTest", initialValue=1, allocationSize=1)
public class ImTestEntity implements Serializable {
- private static final long serialVersionUID = 1L;
-
- @Id
- //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqImTest")
- @GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="ImTestId")
- private long imTestId;
-
- @Column(name="created_by", nullable=false, length=255)
- private String createdBy = "guest";
-
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
- private Date createdDate;
-
- @Column(name="modified_by", nullable=false, length=255)
- private String modifiedBy = "guest";
-
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
- private Date modifiedDate;
-
- public ImTestEntity() {
- //default constructor
- }
-
- @PrePersist
- public void prePersist() {
- Date date = new Date();
- this.createdDate = date;
- this.modifiedDate = date;
- }
-
- @PreUpdate
- public void preUpdate() {
- this.modifiedDate = new Date();
- }
-
- /**
- * @return the Id
- */
- public long getImTestId() {
- return imTestId;
- }
-
- /**
- * @return the createdBy
- */
- public String getCreatedBy() {
- return createdBy;
- }
-
- /**
- * @param createdBy the createdBy to set
- */
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
-
- /**
- * @return the modifiedBy
- */
- public String getModifiedBy() {
- return modifiedBy;
- }
-
- /**
- * @param modifiedBy the modifiedBy to set
- */
- public void setModifiedBy(String modifiedBy) {
- this.modifiedBy = modifiedBy;
- }
-
- /**
- * @return the modifiedDate
- */
- public Date getModifiedDate() {
- return modifiedDate;
- }
-
- /**
- * @param modifiedDate the modifiedDate to set
- */
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
-
- /**
- * @return the createdDate
- */
- public Date getCreatedDate() {
- return createdDate;
- }
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ // @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqImTest")
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "ImTestId")
+ private long imTestId;
+
+ @Column(name = "created_by", nullable = false, length = 255)
+ private String createdBy = "guest";
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "created_date", updatable = false)
+ private Date createdDate;
+
+ @Column(name = "modified_by", nullable = false, length = 255)
+ private String modifiedBy = "guest";
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "modified_date", nullable = false)
+ private Date modifiedDate;
+
+ public ImTestEntity() {
+ // default constructor
+ }
+
+ /**
+ * PrePersist callback method.
+ */
+ @PrePersist
+ public void prePersist() {
+ Date date = new Date();
+ this.createdDate = date;
+ this.modifiedDate = date;
+ }
+
+ @PreUpdate
+ public void preUpdate() {
+ this.modifiedDate = new Date();
+ }
+
+ /**
+ * Get the Im test Id.
+ *
+ * @return the Id
+ */
+ public long getImTestId() {
+ return imTestId;
+ }
+
+ /**
+ * Get the createdBy.
+ *
+ * @return the createdBy
+ */
+ public String getCreatedBy() {
+ return createdBy;
+ }
+
+ /**
+ * Set the createdBy.
+ *
+ * @param createdBy the createdBy to set
+ */
+ public void setCreatedBy(String createdBy) {
+ this.createdBy = createdBy;
+ }
+
+ /**
+ * Get the modifiedBy.
+ *
+ * @return the modifiedBy
+ */
+ public String getModifiedBy() {
+ return modifiedBy;
+ }
+
+ /**
+ * Set the ModifiedBy.
+ *
+ * @param modifiedBy the modifiedBy to set
+ */
+ public void setModifiedBy(String modifiedBy) {
+ this.modifiedBy = modifiedBy;
+ }
+
+ /**
+ * Get the modifiedDate.
+ *
+ * @return the modifiedDate
+ */
+ public Date getModifiedDate() {
+ return modifiedDate;
+ }
+
+ /**
+ * Set the modifiedDate.
+ *
+ * @param modifiedDate the modifiedDate to set
+ */
+ public void setModifiedDate(Date modifiedDate) {
+ this.modifiedDate = modifiedDate;
+ }
+
+ /**
+ * Get the createdDate.
+ *
+ * @return the createdDate
+ */
+ public Date getCreatedDate() {
+ return createdDate;
+ }
}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ResourceRegistrationEntity.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ResourceRegistrationEntity.java
index bd2ba8ab..cfbf020f 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ResourceRegistrationEntity.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ResourceRegistrationEntity.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -40,111 +40,127 @@ import javax.persistence.TemporalType;
*/
@Entity
-@Table(name="ResourceRegistrationEntity")
+@Table(name = "ResourceRegistrationEntity")
@NamedQueries({
- @NamedQuery(name=" ResourceRegistrationEntity.findAll", query="SELECT e FROM ResourceRegistrationEntity e "),
- @NamedQuery(name="ResourceRegistrationEntity.deleteAll", query="DELETE FROM ResourceRegistrationEntity WHERE 1=1")
-})
-//@SequenceGenerator(name="seqResourceRegistration", initialValue=1, allocationSize=1)
+ @NamedQuery(name = " ResourceRegistrationEntity.findAll",
+ query = "SELECT e FROM ResourceRegistrationEntity e "),
+ @NamedQuery(name = "ResourceRegistrationEntity.deleteAll",
+ query = "DELETE FROM ResourceRegistrationEntity WHERE 1=1")})
+// @SequenceGenerator(name="seqResourceRegistration", initialValue=1, allocationSize=1)
public class ResourceRegistrationEntity implements Serializable {
- private static final long serialVersionUID = 1L;
-
- @Id
- //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqResourceRegistration")
- @GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="ResourceRegistrationId")
- private long resourceRegistrationId;
-
- @Column(name="resourceName", nullable=false, length=100, unique=true)
- private String resourceName;
-
- @Column(name="resourceUrl", nullable=false, length=255, unique=true)
- private String resourceUrl;
-
- @Column(name="site", nullable=true, length=50)
- private String site;
-
- @Column(name="nodeType", nullable=true, length=50)
- private String nodeType;
-
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
- private Date createdDate;
-
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="last_updated")
- private Date lastUpdated;
-
- public ResourceRegistrationEntity() {
- //default constructor
- }
-
- @PrePersist
- public void prePersist() {
- Date date = new Date();
- this.createdDate = date;
- this.lastUpdated = date;
- }
-
- @PreUpdate
- public void preUpdate() {
- this.lastUpdated = new Date();
- }
-
- /**
- * @return the Id
- */
- public long getResourceRegistrationId() {
- return resourceRegistrationId;
- }
-
- public String getResourceName() {
- return this.resourceName;
- }
- public void setResourceName(String resourceName) {
- this.resourceName = resourceName;
- }
-
- public String getResourceUrl() {
- return this.resourceUrl;
- }
- public void setResourceUrl(String resourceUrl) {
- this.resourceUrl = resourceUrl;
- }
-
- public String getSite() {
- return this.site;
- }
- public void setSite(String site) {
- this.site = site;
- }
-
- public String getNodeType() {
- return this.nodeType;
- }
- public void setNodeType(String nodeType) {
- this.nodeType = nodeType;
- }
-
- /**
- * @return the createdDate
- */
- public Date getCreatedDate() {
- return createdDate;
- }
-
- /**
- * @return the lastUpdated
- */
- public Date getLastUpdated() {
- return lastUpdated;
- }
-
- /**
- * @param lastUpdated the lastUpdated to set
- */
- public void setLastUpdated(Date lastUpdated) {
- this.lastUpdated = lastUpdated;
- }
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ // @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqResourceRegistration")
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "ResourceRegistrationId")
+ private long resourceRegistrationId;
+
+ @Column(name = "resourceName", nullable = false, length = 100, unique = true)
+ private String resourceName;
+
+ @Column(name = "resourceUrl", nullable = false, length = 255, unique = true)
+ private String resourceUrl;
+
+ @Column(name = "site", nullable = true, length = 50)
+ private String site;
+
+ @Column(name = "nodeType", nullable = true, length = 50)
+ private String nodeType;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "created_date", updatable = false)
+ private Date createdDate;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "last_updated")
+ private Date lastUpdated;
+
+ public ResourceRegistrationEntity() {
+ // default constructor
+ }
+
+ /**
+ * PrePersist callback method.
+ */
+ @PrePersist
+ public void prePersist() {
+ Date date = new Date();
+ this.createdDate = date;
+ this.lastUpdated = date;
+ }
+
+ @PreUpdate
+ public void preUpdate() {
+ this.lastUpdated = new Date();
+ }
+
+ /**
+ * Get the resource registration Id.
+ *
+ * @return the Id
+ */
+ public long getResourceRegistrationId() {
+ return resourceRegistrationId;
+ }
+
+ public String getResourceName() {
+ return this.resourceName;
+ }
+
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ public String getResourceUrl() {
+ return this.resourceUrl;
+ }
+
+ public void setResourceUrl(String resourceUrl) {
+ this.resourceUrl = resourceUrl;
+ }
+
+ public String getSite() {
+ return this.site;
+ }
+
+ public void setSite(String site) {
+ this.site = site;
+ }
+
+ public String getNodeType() {
+ return this.nodeType;
+ }
+
+ public void setNodeType(String nodeType) {
+ this.nodeType = nodeType;
+ }
+
+ /**
+ * Get the createdDate.
+ *
+ * @return the createdDate
+ */
+ public Date getCreatedDate() {
+ return createdDate;
+ }
+
+ /**
+ * Get the lastUpdated.
+ *
+ * @return the lastUpdated
+ */
+ public Date getLastUpdated() {
+ return lastUpdated;
+ }
+
+ /**
+ * Set the lastUpdated.
+ *
+ * @param lastUpdated the lastUpdated to set
+ */
+ public void setLastUpdated(Date lastUpdated) {
+ this.lastUpdated = lastUpdated;
+ }
}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/StateManagementEntity.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/StateManagementEntity.java
index e177939d..0e96e558 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/StateManagementEntity.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/StateManagementEntity.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -36,108 +36,117 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
-@Table(name="StateManagementEntity")
-@NamedQuery(name="StateManagementEntity.findAll", query="SELECT e FROM StateManagementEntity e")
-//@SequenceGenerator(name="seqSM", initialValue=1, allocationSize=1)
+@Table(name = "StateManagementEntity")
+@NamedQuery(name = "StateManagementEntity.findAll", query = "SELECT e FROM StateManagementEntity e")
+// @SequenceGenerator(name="seqSM", initialValue=1, allocationSize=1)
public class StateManagementEntity implements Serializable {
- private static final long serialVersionUID = 1L;
-
- @Id
- //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqSM")
- @GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
- private long id;
-
- @Column(name="resourceName", nullable=false, length=100, unique=true)
- private String resourceName;
-
- @Column(name="adminState", nullable=false, length=20)
- private String adminState;
-
- @Column(name="opState", nullable=false, length=20)
- private String opState;
-
- @Column(name="availStatus", nullable=false, length=20)
- private String availStatus;
-
- @Column(name="standbyStatus", nullable=false, length=20)
- private String standbyStatus;
-
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_Date", updatable=false)
- private Date created_Date;
-
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="modifiedDate", nullable=false)
- private Date modifiedDate;
-
- @PrePersist
- public void prePersist() {
- this.created_Date = new Date();
- this.modifiedDate = new Date();
- }
-
- @PreUpdate
- public void preUpdate() {
- this.modifiedDate = new Date();
- }
-
- public StateManagementEntity() {
- //default constructor
- }
-
- public String getResourceName() {
- return this.resourceName;
- }
- public void setResourceName(String resourceName) {
- this.resourceName = resourceName;
- }
-
- public String getAdminState() {
- return this.adminState;
- }
-
- public void setAdminState(String adminState) {
- this.adminState = adminState;
- }
- public String getOpState() {
- return this.opState;
- }
-
- public void setOpState(String opState) {
- this.opState = opState;
-
- }
- public String getAvailStatus() {
- return this.availStatus;
- }
-
- public void setAvailStatus(String availStatus) {
- this.availStatus = availStatus;
- }
- public String getStandbyStatus() {
- return this.standbyStatus;
- }
-
- public void setStandbyStatus(String standbyStatus) {
- this.standbyStatus = standbyStatus;
- }
-
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
-
- public static StateManagementEntity clone(StateManagementEntity sm)
- {
- StateManagementEntity newSM = new StateManagementEntity();
- newSM.setResourceName(sm.getResourceName());
- newSM.setAdminState(sm.getResourceName());
- newSM.setOpState(sm.getOpState());
- newSM.setAdminState(sm.getAdminState());
- newSM.setAvailStatus(sm.getAvailStatus());
- newSM.setStandbyStatus(sm.getStandbyStatus());
-
- return newSM;
- }
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ // @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqSM")
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "id")
+ private long id;
+
+ @Column(name = "resourceName", nullable = false, length = 100, unique = true)
+ private String resourceName;
+
+ @Column(name = "adminState", nullable = false, length = 20)
+ private String adminState;
+
+ @Column(name = "opState", nullable = false, length = 20)
+ private String opState;
+
+ @Column(name = "availStatus", nullable = false, length = 20)
+ private String availStatus;
+
+ @Column(name = "standbyStatus", nullable = false, length = 20)
+ private String standbyStatus;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "created_Date", updatable = false)
+ private Date createdDate;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "modifiedDate", nullable = false)
+ private Date modifiedDate;
+
+ @PrePersist
+ public void prePersist() {
+ this.createdDate = new Date();
+ this.modifiedDate = new Date();
+ }
+
+ @PreUpdate
+ public void preUpdate() {
+ this.modifiedDate = new Date();
+ }
+
+ public StateManagementEntity() {
+ // default constructor
+ }
+
+ public String getResourceName() {
+ return this.resourceName;
+ }
+
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ public String getAdminState() {
+ return this.adminState;
+ }
+
+ public void setAdminState(String adminState) {
+ this.adminState = adminState;
+ }
+
+ public String getOpState() {
+ return this.opState;
+ }
+
+ public void setOpState(String opState) {
+ this.opState = opState;
+
+ }
+
+ public String getAvailStatus() {
+ return this.availStatus;
+ }
+
+ public void setAvailStatus(String availStatus) {
+ this.availStatus = availStatus;
+ }
+
+ public String getStandbyStatus() {
+ return this.standbyStatus;
+ }
+
+ public void setStandbyStatus(String standbyStatus) {
+ this.standbyStatus = standbyStatus;
+ }
+
+ public void setModifiedDate(Date modifiedDate) {
+ this.modifiedDate = modifiedDate;
+ }
+
+ /**
+ * Clone a StateManagementEntity.
+ *
+ * @param sm the StateManagementEntity to clone
+ * @return a new StateManagementEntity
+ */
+ public static StateManagementEntity clone(StateManagementEntity sm) {
+ StateManagementEntity newStateManagementEntity = new StateManagementEntity();
+ newStateManagementEntity.setResourceName(sm.getResourceName());
+ newStateManagementEntity.setAdminState(sm.getResourceName());
+ newStateManagementEntity.setOpState(sm.getOpState());
+ newStateManagementEntity.setAdminState(sm.getAdminState());
+ newStateManagementEntity.setAvailStatus(sm.getAvailStatus());
+ newStateManagementEntity.setStandbyStatus(sm.getStandbyStatus());
+
+ return newStateManagementEntity;
+ }
}