summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java1645
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java967
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/DbAuditException.java29
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java1408
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/DbDaoTransactionException.java29
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java536
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditException.java33
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java52
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditPropertiesException.java29
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java357
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/AuditPeriodTest.java397
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditCompareEntriesTest.java1004
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java436
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/DbDAOTest.java785
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/ExceptionsTest.java42
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditDesignationTest.java1149
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTest.java79
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java1134
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/IaTestEntity.java246
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/PersonSample.java81
-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
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/AllSeemsWellTest.java277
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/ExceptionsTest.java80
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTest.java1722
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java513
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java193
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementTest.java4
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/StateTransitionTest.java3341
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/exceptions/EntityRetrievalExceptionTest.java1
49 files changed, 13085 insertions, 12845 deletions
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java
index efa1b1d3..f1839b12 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java
@@ -35,869 +35,794 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
/**
- * AuditThread is the main thread for the IntegrityAudit
+ * AuditThread is the main thread for the IntegrityAudit.
*
*/
public class AuditThread extends Thread {
- private static final Logger logger = FlexLogger.getLogger(AuditThread.class);
-
- /*
- * Number of milliseconds that must elapse for audit to be considered
- * complete. It's public for access by JUnit test logic.
- */
- public static final long AUDIT_COMPLETION_INTERVAL = 30000;
-
- /*
- * Number of iterations for audit simulation.
- */
- public static final long AUDIT_SIMULATION_ITERATIONS = 3;
-
- /*
- * Number of milliseconds to sleep between audit simulation iterations. It's
- * public for access by JUnit test logic.
- */
- public static final long AUDIT_SIMULATION_SLEEP_INTERVAL = 5000;
-
- /*
- * Unless audit has already been run on this entity, number of milliseconds
- * to sleep between audit thread iterations. If audit has already been run,
- * we sleep integrityAuditPeriodMillis. May be modified by JUnit tests.
- */
- private static long auditThreadSleepIntervalMillis = 5000;
-
- /*
- * Number of milliseconds that must elapse for audit to be considered
- * complete. May be modified by JUnit tests.
- */
- private static long auditCompletionIntervalMillis = AUDIT_COMPLETION_INTERVAL;
-
- /*
- * DB access class.
- */
- private DbDAO dbDAO;
-
- /*
- * E.g. pdp_xacml
- */
- private String nodeType;
-
- /*
- * Persistence unit for which this audit is being run.
- */
- private String persistenceUnit;
-
- /*
- * Name of this resource
- */
- private String resourceName;
-
- /*
- * E.g. DB_DRIVER, SITE_NAME, NODE_TYPE
- */
- private Properties properties;
-
- /*
- * See IntegrityAudit class for usage.
- */
- private long integrityAuditPeriodMillis;
-
- /*
- * The containing IntegrityAudit instance
- */
- private IntegrityAudit integrityAudit;
-
- /**
- * A latch is taken from this queue before starting an audit. May be
- * {@code null}. Used by JUnit tests.
- */
- private BlockingQueue<CountDownLatch> auditLatchQueue;
-
- /**
- * Latch to be decremented when the next audit completes. May be
- * {@code null}. Used by JUnit tests to wait for an audit to complete.
- */
- private CountDownLatch auditCompletionLatch = null;
-
- /**
- * AuditThread constructor
- * @param resourceName
- * @param persistenceUnit
- * @param properties
- * @param integrityAuditPeriodSeconds
- * @param integrityAudit
- * @throws IntegrityAuditException
- */
- public AuditThread(String resourceName, String persistenceUnit,
- Properties properties, int integrityAuditPeriodSeconds, IntegrityAudit integrityAudit)
- throws IntegrityAuditException {
-
- this(resourceName, persistenceUnit, properties, TimeUnit.SECONDS.toMillis(integrityAuditPeriodSeconds),
- integrityAudit, null);
- }
-
- /**
- * AuditThread constructor
- * @param resourceName
- * @param persistenceUnit
- * @param properties
- * @param integrityAuditMillis
- * @param integrityAudit
- * @param queue
- * @throws IntegrityAuditException
- */
- public AuditThread(String resourceName, String persistenceUnit,
- Properties properties, long integrityAuditMillis, IntegrityAudit integrityAudit,
- BlockingQueue<CountDownLatch> queue)
- throws IntegrityAuditException {
- this.resourceName = resourceName;
- this.persistenceUnit = persistenceUnit;
- this.properties = properties;
- this.integrityAuditPeriodMillis = integrityAuditMillis;
- this.integrityAudit = integrityAudit;
- this.auditLatchQueue = queue;
-
- /*
- * The DbDAO Constructor registers this node in the IntegrityAuditEntity
- * table. Each resource (node) inserts its own name, persistenceUnit, DB
- * access properties and other pertinent properties in the table. This
- * allows the audit on each node to compare its own version of the
- * entities for the persistenceUnit in question with the versions from
- * all other nodes of similar type.
- */
- dbDAO = new DbDAO(this.resourceName, this.persistenceUnit,
- this.properties);
- this.nodeType = properties.getProperty(IntegrityAuditProperties.NODE_TYPE);
-
- }
-
- @Override
- public void run() {
-
- logger.info("AuditThread.run: Entering");
-
- try {
- /*
- * For JUnit testing: wait for the first latch, decrement it to
- * indicate that the thread has started, and then wait for the
- * next latch, before we actually start doing anything. These
- * simply return if there is no latch queue defined.
- */
- getNextLatch();
- decrementLatch();
- getNextLatch();
-
- /*
- * Triggers change in designation, unless no other viable candidate.
- */
- boolean auditCompleted = false;
-
- DbAudit dbAudit = new DbAudit(dbDAO);
-
- IntegrityAuditEntity entityCurrentlyDesignated;
- IntegrityAuditEntity thisEntity;
- integrityAudit.setThreadInitialized(true); // An exception will set
- // it to false
-
- while (true) {
- try{
- /*
- * It may have been awhile since we last cycled through this
- * loop, so refresh the list of IntegrityAuditEntities.
- */
- List<IntegrityAuditEntity> integrityAuditEntityList = getIntegrityAuditEntityList();
-
- /*
- * We could've set entityCurrentlyDesignated as a side effect of
- * getIntegrityAuditEntityList(), but then we would've had to
- * make entityCurrentlyDesignated a class level attribute. Using
- * this approach, we can keep it local to the run() method.
- */
- entityCurrentlyDesignated = getEntityCurrentlyDesignated(integrityAuditEntityList);
-
- /*
- * Need to refresh thisEntity each time through loop, because we
- * need a fresh version of lastUpdated.
- */
- thisEntity = getThisEntity(integrityAuditEntityList);
-
- /*
- * If we haven't done the audit yet, note that we're current and
- * see if we're designated.
- */
- if (!auditCompleted) {
- dbDAO.setLastUpdated();
-
- /*
- * If no current designation or currently designated node is
- * stale, see if we're the next node to be designated.
- */
- if (entityCurrentlyDesignated == null
- || isStale(entityCurrentlyDesignated)) {
- IntegrityAuditEntity designationCandidate = getDesignationCandidate(integrityAuditEntityList);
-
- /*
- * If we're the next node to be designated, run the
- * audit.
- */
- if (designationCandidate.getResourceName().equals(
- this.resourceName)) {
- runAudit(dbAudit);
- auditCompleted = true;
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("AuditThread.run: designationCandidate, "
- + designationCandidate
- .getResourceName()
- + ", not this entity, "
- + thisEntity.getResourceName());
- }
- }
-
- /*
- * Application may have been stopped and restarted, in
- * which case we might be designated but auditCompleted
- * will have been reset to false, so account for this.
- */
- } else if (thisEntity.getResourceName().equals(
- entityCurrentlyDesignated.getResourceName())) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("AuditThread.run: Re-running audit for "
- + thisEntity.getResourceName());
- }
- runAudit(dbAudit);
- auditCompleted = true;
-
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("AuditThread.run: Currently designated node, "
- + entityCurrentlyDesignated
- .getResourceName()
- + ", not yet stale and not this node");
- }
- }
-
-
- /*
- * Audit already completed on this node, so allow the node
- * to go stale until twice the AUDIT_COMPLETION_PERIOD has
- * elapsed. This should give plenty of time for another node
- * (if another node is out there) to pick up designation.
- */
- } else {
-
- auditCompleted = resetAuditCompleted(auditCompleted,
- thisEntity);
-
- }
-
- /*
- * If we've just run audit, sleep per the
- * integrity_audit_period_seconds property, otherwise just sleep
- * the normal interval.
- */
- if (auditCompleted) {
- // indicate that an audit has completed
- decrementLatch();
-
- // don't start the next audit cycle until a latch has been provided
- getNextLatch();
-
- if (logger.isDebugEnabled()) {
- logger.debug("AuditThread.run: Audit completed; resourceName="
- + this.resourceName
- + " sleeping "
- + integrityAuditPeriodMillis + "ms");
- }
- Thread.sleep(integrityAuditPeriodMillis);
- if (logger.isDebugEnabled()) {
- logger.debug("AuditThread.run: resourceName="
- + this.resourceName + " awaking from "
- + integrityAuditPeriodMillis + "ms sleep");
- }
-
- } else {
-
- if (logger.isDebugEnabled()) {
- logger.debug("AuditThread.run: resourceName="
- + this.resourceName + ": Sleeping "
- + AuditThread.auditThreadSleepIntervalMillis
- + "ms");
- }
- Thread.sleep(AuditThread.auditThreadSleepIntervalMillis);
- if (logger.isDebugEnabled()) {
- logger.debug("AuditThread.run: resourceName="
- + this.resourceName + ": Awaking from "
- + AuditThread.auditThreadSleepIntervalMillis
- + "ms sleep");
- }
-
- }
-
- } catch (Exception e){
- if(isInterruptedException(e)) {
- String msg = "AuditThread.run loop - Exception thrown: " + e.getMessage()
- + "; Stopping.";
- logger.error(MessageCodes.EXCEPTION_ERROR, e, msg);
- break;
- }
-
- String msg = "AuditThread.run loop - Exception thrown: " + e.getMessage()
- + "; Will try audit again in " + (integrityAuditPeriodMillis/1000) + " seconds";
- logger.error(MessageCodes.EXCEPTION_ERROR, e, msg);
- // Sleep and try again later
- Thread.sleep(integrityAuditPeriodMillis);
- }
-
- }
-
- } catch (Exception e) {
- String msg = "AuditThread.run: Could not start audit loop. Exception thrown; message="+ e.getMessage();
- logger.error(MessageCodes.EXCEPTION_ERROR, e, msg);
- integrityAudit.setThreadInitialized(false);
- }
-
- dbDAO.destroy();
-
- logger.info("AuditThread.run: Exiting");
- }
-
- /**
- * Gets the next audit-completion latch from the queue. Blocks, if the
- * queue is empty.
- * @throws InterruptedException
- */
- private void getNextLatch() throws InterruptedException {
- BlockingQueue<CountDownLatch> queue = this.auditLatchQueue;
- if(queue != null) {
- this.auditCompletionLatch = queue.take();
- }
- }
-
- /**
- * Decrements the current audit-completion latch, if any.
- */
- private void decrementLatch() {
- CountDownLatch latch = this.auditCompletionLatch;
- if(latch != null) {
- this.auditCompletionLatch = null;
- latch.countDown();
- }
- }
-
- /**
- * Determines if an exception is an InterruptedException or was caused
- * by an InterruptedException.
- * @param ex exception to be examined
- * @return {@code true} if it's an InterruptedException, {@code false} otherwise
- */
- private boolean isInterruptedException(Throwable ex) {
- while(ex != null) {
- if(ex instanceof InterruptedException) {
- return true;
- }
-
- ex = ex.getCause();
- }
-
- return false;
- }
-
- /*
- * Used to create a list that is sorted lexicographically by resourceName.
- */
- Comparator<IntegrityAuditEntity> comparator = new Comparator<IntegrityAuditEntity>() {
- @Override
- public int compare(final IntegrityAuditEntity r1,
- final IntegrityAuditEntity r2) {
- return r1.getResourceName().compareTo(r2.getResourceName());
- }
- };
-
- /**
- * getDesignationCandidate()
- * Using round robin algorithm, gets next candidate to be designated. Assumes
- * list is sorted lexicographically by resourceName.
- */
- private IntegrityAuditEntity getDesignationCandidate(
- List<IntegrityAuditEntity> integrityAuditEntityList) {
-
- //Note: assumes integrityAuditEntityList is already lexicographically sorted by resourceName
-
- if (logger.isDebugEnabled()) {
- logger.debug("getDesignationCandidate: Entering, integrityAuditEntityList.size()="
- + integrityAuditEntityList.size());
- }
-
- IntegrityAuditEntity designationCandidate;
- IntegrityAuditEntity thisEntity = null;
-
- int designatedEntityIndex = -1;
- int entityIndex = 0;
- int priorCandidateIndex = -1;
- int subsequentCandidateIndex = -1;
-
- for (IntegrityAuditEntity integrityAuditEntity : integrityAuditEntityList) {
-
- if (logger.isDebugEnabled()) {
- logIntegrityAuditEntity(integrityAuditEntity);
- }
-
- if (integrityAuditEntity.getResourceName()
- .equals(this.resourceName)) {
- if (logger.isDebugEnabled()) {
- logger.debug("getDesignationCandidate: thisEntity="
- + integrityAuditEntity.getResourceName());
- }
- thisEntity = integrityAuditEntity;
- }
-
- if (integrityAuditEntity.isDesignated()) {
- if (logger.isDebugEnabled()) {
- logger.debug("getDesignationCandidate: Currently designated entity resourceName="
- + integrityAuditEntity.getResourceName()
- + ", persistenceUnit="
- + integrityAuditEntity.getPersistenceUnit()
- + ", lastUpdated="
- + integrityAuditEntity.getLastUpdated()
- + ", entityIndex=" + entityIndex);
- }
- designatedEntityIndex = entityIndex;
-
- /*
- * Entity not currently designated
- */
- } else {
-
- /*
- * See if non-designated entity is stale.
- */
- if (isStale(integrityAuditEntity)) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("getDesignationCandidate: Entity is stale; resourceName="
- + integrityAuditEntity.getResourceName()
- + ", persistenceUnit="
- + integrityAuditEntity.getPersistenceUnit()
- + ", lastUpdated="
- + integrityAuditEntity.getLastUpdated()
- + ", entityIndex=" + entityIndex);
- }
-
- /*
- * Entity is current.
- */
- } else {
-
- if (designatedEntityIndex == -1) {
-
- if (priorCandidateIndex == -1) {
- if (logger.isDebugEnabled()) {
- logger.debug("getDesignationCandidate: Prior candidate found, resourceName="
- + integrityAuditEntity
- .getResourceName()
- + ", persistenceUnit="
- + integrityAuditEntity
- .getPersistenceUnit()
- + ", lastUpdated="
- + integrityAuditEntity.getLastUpdated()
- + ", entityIndex=" + entityIndex);
- }
- priorCandidateIndex = entityIndex;
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("getDesignationCandidate: Prior entity current but prior candidate already found; resourceName="
- + integrityAuditEntity
- .getResourceName()
- + ", persistenceUnit="
- + integrityAuditEntity
- .getPersistenceUnit()
- + ", lastUpdated="
- + integrityAuditEntity.getLastUpdated()
- + ", entityIndex=" + entityIndex);
- }
- }
- } else {
- if (subsequentCandidateIndex == -1) {
- if (logger.isDebugEnabled()) {
- logger.debug("getDesignationCandidate: Subsequent candidate found, resourceName="
- + integrityAuditEntity
- .getResourceName()
- + ", persistenceUnit="
- + integrityAuditEntity
- .getPersistenceUnit()
- + ", lastUpdated="
- + integrityAuditEntity.getLastUpdated()
- + ", entityIndex=" + entityIndex);
- }
- subsequentCandidateIndex = entityIndex;
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("getDesignationCandidate: Subsequent entity current but subsequent candidate already found; resourceName="
- + integrityAuditEntity
- .getResourceName()
- + ", persistenceUnit="
- + integrityAuditEntity
- .getPersistenceUnit()
- + ", lastUpdated="
- + integrityAuditEntity.getLastUpdated()
- + ", entityIndex=" + entityIndex);
- }
- }
- }
-
- } // end entity is current
-
- } // end entity not currently designated
-
- entityIndex++;
-
- } // end for loop
-
- /*
- * Per round robin algorithm, if a current entity is found that is
- * lexicographically after the currently designated entity, this entity
- * becomes the designation candidate. If no current entity is found that
- * is lexicographically after currently designated entity, we cycle back
- * to beginning of list and pick the first current entity as the
- * designation candidate.
- */
- if (subsequentCandidateIndex != -1) {
- designationCandidate = integrityAuditEntityList
- .get(subsequentCandidateIndex);
- if (logger.isDebugEnabled()) {
- logger.debug("getDesignationCandidate: Exiting and returning subsequent designationCandidate="
- + designationCandidate.getResourceName());
- }
- } else {
- if (priorCandidateIndex != -1) {
- designationCandidate = integrityAuditEntityList
- .get(priorCandidateIndex);
- if (logger.isDebugEnabled()) {
- logger.debug("getDesignationCandidate: Exiting and returning prior designationCandidate="
- + designationCandidate.getResourceName());
- }
- } else {
- logger.debug("getDesignationCandidate: No subsequent or prior candidate found; designating thisEntity, resourceName="
- + thisEntity.getResourceName());
- designationCandidate = thisEntity;
- }
- }
-
- return designationCandidate;
-
- }
-
- /**
- * getEntityCurrentlyDesignated()
- * Returns entity that is currently designated.
- * @param integrityAuditEntityList
- * @return
- */
- private IntegrityAuditEntity getEntityCurrentlyDesignated(
- List<IntegrityAuditEntity> integrityAuditEntityList) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("getEntityCurrentlyDesignated: Entering, integrityAuditEntityList.size="
- + integrityAuditEntityList.size());
- }
-
- IntegrityAuditEntity entityCurrentlyDesignated = null;
-
- for (IntegrityAuditEntity integrityAuditEntity : integrityAuditEntityList) {
-
- if (integrityAuditEntity.isDesignated()) {
- if (logger.isDebugEnabled()) {
- logger.debug("getEntityCurrentlyDesignated: Currently designated entity resourceName="
- + integrityAuditEntity.getResourceName()
- + ", persistenceUnit="
- + integrityAuditEntity.getPersistenceUnit()
- + ", lastUpdated="
- + integrityAuditEntity.getLastUpdated());
- }
- entityCurrentlyDesignated = integrityAuditEntity;
- }
-
- } // end for loop
-
- if (logger.isDebugEnabled()) {
- if (entityCurrentlyDesignated != null) {
- logger.debug("getEntityCurrentlyDesignated: Exiting and returning entityCurrentlyDesignated="
- + entityCurrentlyDesignated.getResourceName());
- } else {
- logger.debug("getEntityCurrentlyDesignated: Exiting and returning entityCurrentlyDesignated="
- + entityCurrentlyDesignated);
- }
- }
- return entityCurrentlyDesignated;
-
- }
-
- /**
- * getIntegrityAuditEnityList gets the list of IntegrityAuditEntity
- * @return
- * @throws DbDaoTransactionException
- */
- private List<IntegrityAuditEntity> getIntegrityAuditEntityList()
- throws DbDaoTransactionException {
-
- if (logger.isDebugEnabled()) {
- logger.debug("getIntegrityAuditEntityList: Entering");
- }
-
- /*
- * Get all records for this nodeType and persistenceUnit and then sort
- * them lexicographically by resourceName. Get index of designated
- * entity, if any.
- */
- /*
- * Sorted list of entities for a particular nodeType and
- * persistenceUnit.
- */
- List<IntegrityAuditEntity> integrityAuditEntityList = dbDAO.getIntegrityAuditEntities(
- this.persistenceUnit, this.nodeType);
- int listSize = integrityAuditEntityList.size();
- if (logger.isDebugEnabled()) {
- logger.debug("getIntegrityAuditEntityList: Got " + listSize
- + " IntegrityAuditEntity records");
- }
- Collections.sort((List<IntegrityAuditEntity>) integrityAuditEntityList,
- comparator);
-
- if (logger.isDebugEnabled()) {
- logger.debug("getIntegrityAuditEntityList: Exiting and returning integrityAuditEntityList, size="
- + listSize);
- }
- return integrityAuditEntityList;
-
- }
-
-
- /**
- * Returns the IntegrityAuditEntity for this entity.
- * @param integrityAuditEntityList
- * @return
- */
- private IntegrityAuditEntity getThisEntity(
- List<IntegrityAuditEntity> integrityAuditEntityList) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("getThisEntity: Entering, integrityAuditEntityList.size="
- + integrityAuditEntityList.size());
- }
-
- IntegrityAuditEntity thisEntity = null;
-
- for (IntegrityAuditEntity integrityAuditEntity : integrityAuditEntityList) {
-
- if (integrityAuditEntity.getResourceName().equals(this.resourceName)) {
- if (logger.isDebugEnabled()) {
- logger.debug("getThisEntity: For this entity, resourceName="
- + integrityAuditEntity.getResourceName()
- + ", persistenceUnit="
- + integrityAuditEntity.getPersistenceUnit()
- + ", lastUpdated="
- + integrityAuditEntity.getLastUpdated());
- }
- thisEntity = integrityAuditEntity;
- }
-
- } // end for loop
-
- if (logger.isDebugEnabled()) {
- if (thisEntity != null) {
- logger.debug("getThisEntity: Exiting and returning thisEntity="
- + thisEntity.getResourceName());
- } else {
- logger.debug("getThisEntity: Exiting and returning thisEntity="
- + thisEntity);
- }
- }
- return thisEntity;
-
- }
-
-
- /**
- * Returns false if the lastUpdated time for the record in question is more
- * than auditCompletionIntervalMillis seconds ago. During an audit, lastUpdated is updated every five
- * seconds or so, but when an audit finishes, the node doing the audit stops
- * updating lastUpdated.
- * @param integrityAuditEntity
- * @return
- */
- private boolean isStale(IntegrityAuditEntity integrityAuditEntity) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("isStale: Entering, resourceName="
- + integrityAuditEntity.getResourceName()
- + ", persistenceUnit="
- + integrityAuditEntity.getPersistenceUnit()
- + ", lastUpdated=" + integrityAuditEntity.getLastUpdated());
- }
-
- boolean stale = false;
-
- Date currentTime = new Date();
- Date lastUpdated = integrityAuditEntity.getLastUpdated();
-
- /*
- * If lastUpdated is null, we assume that the audit never ran for that
- * node.
- */
- long lastUpdatedTime = 0;
- if (lastUpdated != null) {
- lastUpdatedTime = lastUpdated.getTime();
- }
- long timeDifference = currentTime.getTime() - lastUpdatedTime;
- if (timeDifference > auditCompletionIntervalMillis) {
- stale = true;
- }
-
- if (logger.isDebugEnabled()) {
- logger.debug("isStale: Exiting and returning stale=" + stale
- + ", timeDifference=" + timeDifference);
- }
-
- return stale;
- }
-
- private void logIntegrityAuditEntity(
- IntegrityAuditEntity integrityAuditEntity) {
-
- logger.debug("logIntegrityAuditEntity: id="
- + integrityAuditEntity.getId() + ", jdbcDriver="
- + integrityAuditEntity.getJdbcDriver() + ", jdbcPassword="
- + integrityAuditEntity.getJdbcPassword() + ", jdbcUrl="
- + integrityAuditEntity.getJdbcUrl() + ", jdbcUser="
- + integrityAuditEntity.getJdbcUser() + ", nodeType="
- + integrityAuditEntity.getNodeType() + ", persistenceUnit="
- + integrityAuditEntity.getPersistenceUnit() + ", resourceName="
- + integrityAuditEntity.getResourceName() + ", site="
- + integrityAuditEntity.getSite() + ", createdDate="
- + integrityAuditEntity.getCreatedDate() + ", lastUpdated="
- + integrityAuditEntity.getLastUpdated() + ", designated="
- + integrityAuditEntity.isDesignated());
- }
-
- /*
- * If more than (auditCompletionIntervalMillis * 2) milliseconds have elapsed
- * since we last ran the audit, reset auditCompleted, so
- *
- * 1) we'll eventually re-run the audit, if no other node picks up the
- * designation.
- *
- * or
- *
- * 2) We'll run the audit when the round robin comes back to us.
- */
- private boolean resetAuditCompleted(boolean auditCompleted,
- IntegrityAuditEntity thisEntity) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("resetAuditCompleted: auditCompleted="
- + auditCompleted + "; for thisEntity, resourceName="
- + thisEntity.getResourceName() + ", persistenceUnit="
- + thisEntity.getPersistenceUnit() + ", lastUpdated="
- + thisEntity.getLastUpdated());
- }
-
- long timeDifference;
-
- Date currentTime = new Date();
- Date lastUpdated = thisEntity.getLastUpdated();
-
- long lastUpdatedTime = lastUpdated.getTime();
- timeDifference = currentTime.getTime() - lastUpdatedTime;
-
- if (timeDifference > (auditCompletionIntervalMillis * 2)) {
- if (logger.isDebugEnabled()) {
- logger.debug("resetAuditCompleted: Resetting auditCompleted for resourceName="
- + this.resourceName);
- }
- auditCompleted = false;
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("resetAuditCompleted: For resourceName="
- + resourceName
- + ", time since last update is only "
- + timeDifference + "; retaining current value for auditCompleted");
- }
- }
-
- if (logger.isDebugEnabled()) {
- logger.debug("resetAuditCompleted: Exiting and returning auditCompleted="
- + auditCompleted + ", timeDifference=" + timeDifference);
- }
- return auditCompleted;
- }
-
- private void runAudit(DbAudit dbAudit) throws IntegrityAuditException {
-
- if (logger.isDebugEnabled()) {
- logger.debug("runAudit: Entering, dbAudit=" + dbAudit
- + "; notifying other resources that resourceName="
- + this.resourceName + " is current");
- }
-
- /*
- * changeDesignated marks all other nodes as non-designated and this
- * node as designated.
- */
- dbDAO.changeDesignated(this.resourceName, this.persistenceUnit,
- this.nodeType);
-
- if (logger.isDebugEnabled()) {
- logger.debug("runAudit: Running audit for persistenceUnit="
- + this.persistenceUnit + " on resourceName="
- + this.resourceName);
- }
- if (IntegrityAudit.isUnitTesting()) {
- dbAudit.dbAuditSimulate(this.resourceName, this.persistenceUnit, AuditThread.AUDIT_SIMULATION_ITERATIONS, AuditThread.auditThreadSleepIntervalMillis);
- } else {
- dbAudit.dbAudit(this.resourceName, this.persistenceUnit,
- this.nodeType);
- }
-
- if (logger.isDebugEnabled()) {
- logger.debug("runAudit: Exiting");
- }
-
- }
-
- /**
- * Adjusts the thread-sleep-interval to be used when an audit has
- * <i>not</i> been completed. Used by JUnit tests.
- * @param auditThreadSleepIntervalMillis
- */
- protected static void setAuditThreadSleepIntervalMillis(long auditThreadSleepIntervalMillis) {
- AuditThread.auditThreadSleepIntervalMillis = auditThreadSleepIntervalMillis;
- }
-
- /**
- * Gets the current thread-sleep-interval to be used when an audit has
- * <i>not</i> been completed. Used by JUnit tests.
- * @return the current sleep interval, in milli-seconds
- */
- protected static long getAuditThreadSleepIntervalMillis() {
- return auditThreadSleepIntervalMillis;
- }
-
- /**
- * Adjusts the audit-completion-interval. Used by JUnit tests.
- * @param auditThreadSleepIntervalMillis
- */
- protected static void setAuditCompletionIntervalMillis(long auditThreadSleepIntervalMillis) {
- AuditThread.auditCompletionIntervalMillis = auditThreadSleepIntervalMillis;
- }
-
- /**
- * Gets the audit-completion-interval. Used by JUnit tests.
- * @return the current audit-completion interval, in milli-seconds
- */
- protected static long getAuditCompletionIntervalMillis() {
- return auditCompletionIntervalMillis;
- }
+ private static final Logger logger = FlexLogger.getLogger(AuditThread.class);
+
+ /*
+ * Number of milliseconds that must elapse for audit to be considered complete. It's public for
+ * access by JUnit test logic.
+ */
+ public static final long AUDIT_COMPLETION_INTERVAL = 30000;
+
+ /*
+ * Number of iterations for audit simulation.
+ */
+ public static final long AUDIT_SIMULATION_ITERATIONS = 3;
+
+ /*
+ * Number of milliseconds to sleep between audit simulation iterations. It's public for access
+ * by JUnit test logic.
+ */
+ public static final long AUDIT_SIMULATION_SLEEP_INTERVAL = 5000;
+
+ /*
+ * Unless audit has already been run on this entity, number of milliseconds to sleep between
+ * audit thread iterations. If audit has already been run, we sleep integrityAuditPeriodMillis.
+ * May be modified by JUnit tests.
+ */
+ private static long auditThreadSleepIntervalMillis = 5000;
+
+ /*
+ * Number of milliseconds that must elapse for audit to be considered complete. May be modified
+ * by JUnit tests.
+ */
+ private static long auditCompletionIntervalMillis = AUDIT_COMPLETION_INTERVAL;
+
+ /*
+ * DB access class.
+ */
+ private DbDAO dbDao;
+
+ /*
+ * E.g. pdp_xacml
+ */
+ private String nodeType;
+
+ /*
+ * Persistence unit for which this audit is being run.
+ */
+ private String persistenceUnit;
+
+ /*
+ * Name of this resource
+ */
+ private String resourceName;
+
+ /*
+ * E.g. DB_DRIVER, SITE_NAME, NODE_TYPE
+ */
+ private Properties properties;
+
+ /*
+ * See IntegrityAudit class for usage.
+ */
+ private long integrityAuditPeriodMillis;
+
+ /*
+ * The containing IntegrityAudit instance
+ */
+ private IntegrityAudit integrityAudit;
+
+ /**
+ * A latch is taken from this queue before starting an audit. May be {@code null}. Used by JUnit
+ * tests.
+ */
+ private BlockingQueue<CountDownLatch> auditLatchQueue;
+
+ /**
+ * Latch to be decremented when the next audit completes. May be {@code null}. Used by JUnit
+ * tests to wait for an audit to complete.
+ */
+ private CountDownLatch auditCompletionLatch = null;
+
+ /**
+ * AuditThread constructor.
+ *
+ * @param resourceName the resource name
+ * @param persistenceUnit the persistence unit
+ * @param properties the properties
+ * @param integrityAuditPeriodSeconds the integrity audit period in seconds
+ * @param integrityAudit the integrity audit
+ * @throws IntegrityAuditException if an error occurs
+ */
+ public AuditThread(String resourceName, String persistenceUnit, Properties properties,
+ int integrityAuditPeriodSeconds, IntegrityAudit integrityAudit) throws IntegrityAuditException {
+
+ this(resourceName, persistenceUnit, properties, TimeUnit.SECONDS.toMillis(integrityAuditPeriodSeconds),
+ integrityAudit, null);
+ }
+
+ /**
+ * AuditThread constructor.
+ *
+ * @param resourceName the resource name
+ * @param persistenceUnit the persistence unit
+ * @param properties the properties
+ * @param integrityAuditMillis the integrity audit period in milliseconds
+ * @param integrityAudit the integrity audit
+ * @param queue the queue
+ * @throws IntegrityAuditException if an error occurs
+ */
+ public AuditThread(String resourceName, String persistenceUnit, Properties properties, long integrityAuditMillis,
+ IntegrityAudit integrityAudit, BlockingQueue<CountDownLatch> queue) throws IntegrityAuditException {
+ this.resourceName = resourceName;
+ this.persistenceUnit = persistenceUnit;
+ this.properties = properties;
+ this.integrityAuditPeriodMillis = integrityAuditMillis;
+ this.integrityAudit = integrityAudit;
+ this.auditLatchQueue = queue;
+
+ /*
+ * The DbDAO Constructor registers this node in the IntegrityAuditEntity table. Each
+ * resource (node) inserts its own name, persistenceUnit, DB access properties and other
+ * pertinent properties in the table. This allows the audit on each node to compare its own
+ * version of the entities for the persistenceUnit in question with the versions from all
+ * other nodes of similar type.
+ */
+ dbDao = new DbDAO(this.resourceName, this.persistenceUnit, this.properties);
+ this.nodeType = properties.getProperty(IntegrityAuditProperties.NODE_TYPE);
+
+ }
+
+ @Override
+ public void run() {
+
+ logger.info("AuditThread.run: Entering");
+
+ try {
+ /*
+ * For JUnit testing: wait for the first latch, decrement it to indicate that the thread
+ * has started, and then wait for the next latch, before we actually start doing
+ * anything. These simply return if there is no latch queue defined.
+ */
+ getNextLatch();
+ decrementLatch();
+ getNextLatch();
+
+ /*
+ * Triggers change in designation, unless no other viable candidate.
+ */
+ boolean auditCompleted = false;
+
+ DbAudit dbAudit = new DbAudit(dbDao);
+
+ IntegrityAuditEntity entityCurrentlyDesignated;
+ IntegrityAuditEntity thisEntity;
+ integrityAudit.setThreadInitialized(true); // An exception will set it to false
+
+ while (true) {
+ try {
+ /*
+ * It may have been awhile since we last cycled through this loop, so refresh
+ * the list of IntegrityAuditEntities.
+ */
+ List<IntegrityAuditEntity> integrityAuditEntityList = getIntegrityAuditEntityList();
+
+ /*
+ * We could've set entityCurrentlyDesignated as a side effect of
+ * getIntegrityAuditEntityList(), but then we would've had to make
+ * entityCurrentlyDesignated a class level attribute. Using this approach, we
+ * can keep it local to the run() method.
+ */
+ entityCurrentlyDesignated = getEntityCurrentlyDesignated(integrityAuditEntityList);
+
+ /*
+ * Need to refresh thisEntity each time through loop, because we need a fresh
+ * version of lastUpdated.
+ */
+ thisEntity = getThisEntity(integrityAuditEntityList);
+
+ /*
+ * If we haven't done the audit yet, note that we're current and see if we're
+ * designated.
+ */
+ if (!auditCompleted) {
+ dbDao.setLastUpdated();
+
+ /*
+ * If no current designation or currently designated node is stale, see if
+ * we're the next node to be designated.
+ */
+ if (entityCurrentlyDesignated == null || isStale(entityCurrentlyDesignated)) {
+ IntegrityAuditEntity designationCandidate =
+ getDesignationCandidate(integrityAuditEntityList);
+
+ /*
+ * If we're the next node to be designated, run the audit.
+ */
+ if (designationCandidate.getResourceName().equals(this.resourceName)) {
+ runAudit(dbAudit);
+ auditCompleted = true;
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("AuditThread.run: designationCandidate, "
+ + designationCandidate.getResourceName() + ", not this entity, "
+ + thisEntity.getResourceName());
+ }
+ }
+
+ /*
+ * Application may have been stopped and restarted, in which case we
+ * might be designated but auditCompleted will have been reset to false,
+ * so account for this.
+ */
+ } else if (thisEntity.getResourceName().equals(entityCurrentlyDesignated.getResourceName())) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("AuditThread.run: Re-running audit for " + thisEntity.getResourceName());
+ }
+ runAudit(dbAudit);
+ auditCompleted = true;
+
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("AuditThread.run: Currently designated node, "
+ + entityCurrentlyDesignated.getResourceName()
+ + ", not yet stale and not this node");
+ }
+ }
+
+
+ /*
+ * Audit already completed on this node, so allow the node to go stale until
+ * twice the AUDIT_COMPLETION_PERIOD has elapsed. This should give plenty of
+ * time for another node (if another node is out there) to pick up
+ * designation.
+ */
+ } else {
+
+ auditCompleted = resetAuditCompleted(auditCompleted, thisEntity);
+
+ }
+
+ /*
+ * If we've just run audit, sleep per the integrity_audit_period_seconds
+ * property, otherwise just sleep the normal interval.
+ */
+ if (auditCompleted) {
+ // indicate that an audit has completed
+ decrementLatch();
+
+ // don't start the next audit cycle until a latch has been provided
+ getNextLatch();
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("AuditThread.run: Audit completed; resourceName=" + this.resourceName
+ + " sleeping " + integrityAuditPeriodMillis + "ms");
+ }
+ Thread.sleep(integrityAuditPeriodMillis);
+ if (logger.isDebugEnabled()) {
+ logger.debug("AuditThread.run: resourceName=" + this.resourceName + " awaking from "
+ + integrityAuditPeriodMillis + "ms sleep");
+ }
+
+ } else {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("AuditThread.run: resourceName=" + this.resourceName + ": Sleeping "
+ + AuditThread.auditThreadSleepIntervalMillis + "ms");
+ }
+ Thread.sleep(AuditThread.auditThreadSleepIntervalMillis);
+ if (logger.isDebugEnabled()) {
+ logger.debug("AuditThread.run: resourceName=" + this.resourceName + ": Awaking from "
+ + AuditThread.auditThreadSleepIntervalMillis + "ms sleep");
+ }
+
+ }
+
+ } catch (Exception e) {
+ if (isInterruptedException(e)) {
+ String msg = "AuditThread.run loop - Exception thrown: " + e.getMessage() + "; Stopping.";
+ logger.error(MessageCodes.EXCEPTION_ERROR, e, msg);
+ break;
+ }
+
+ String msg = "AuditThread.run loop - Exception thrown: " + e.getMessage()
+ + "; Will try audit again in " + (integrityAuditPeriodMillis / 1000) + " seconds";
+ logger.error(MessageCodes.EXCEPTION_ERROR, e, msg);
+ // Sleep and try again later
+ Thread.sleep(integrityAuditPeriodMillis);
+ }
+
+ }
+
+ } catch (Exception e) {
+ String msg = "AuditThread.run: Could not start audit loop. Exception thrown; message=" + e.getMessage();
+ logger.error(MessageCodes.EXCEPTION_ERROR, e, msg);
+ integrityAudit.setThreadInitialized(false);
+ }
+
+ dbDao.destroy();
+
+ logger.info("AuditThread.run: Exiting");
+ }
+
+ /**
+ * Gets the next audit-completion latch from the queue. Blocks, if the queue is empty.
+ *
+ * @throws InterruptedException if interrupted while waiting
+ */
+ private void getNextLatch() throws InterruptedException {
+ BlockingQueue<CountDownLatch> queue = this.auditLatchQueue;
+ if (queue != null) {
+ this.auditCompletionLatch = queue.take();
+ }
+ }
+
+ /**
+ * Decrements the current audit-completion latch, if any.
+ */
+ private void decrementLatch() {
+ CountDownLatch latch = this.auditCompletionLatch;
+ if (latch != null) {
+ this.auditCompletionLatch = null;
+ latch.countDown();
+ }
+ }
+
+ /**
+ * Determines if an exception is an InterruptedException or was caused by an
+ * InterruptedException.
+ *
+ * @param ex exception to be examined
+ * @return {@code true} if it's an InterruptedException, {@code false} otherwise
+ */
+ private boolean isInterruptedException(Throwable ex) {
+ while (ex != null) {
+ if (ex instanceof InterruptedException) {
+ return true;
+ }
+
+ ex = ex.getCause();
+ }
+
+ return false;
+ }
+
+ /*
+ * Used to create a list that is sorted lexicographically by resourceName.
+ */
+ Comparator<IntegrityAuditEntity> comparator = new Comparator<IntegrityAuditEntity>() {
+ @Override
+ public int compare(final IntegrityAuditEntity r1, final IntegrityAuditEntity r2) {
+ return r1.getResourceName().compareTo(r2.getResourceName());
+ }
+ };
+
+ /**
+ * getDesignationCandidate() Using round robin algorithm, gets next candidate to be designated.
+ * Assumes list is sorted lexicographically by resourceName.
+ */
+ private IntegrityAuditEntity getDesignationCandidate(List<IntegrityAuditEntity> integrityAuditEntityList) {
+
+ // Note: assumes integrityAuditEntityList is already lexicographically sorted by
+ // resourceName
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("getDesignationCandidate: Entering, integrityAuditEntityList.size()="
+ + integrityAuditEntityList.size());
+ }
+
+ IntegrityAuditEntity designationCandidate;
+ IntegrityAuditEntity thisEntity = null;
+
+ int designatedEntityIndex = -1;
+ int entityIndex = 0;
+ int priorCandidateIndex = -1;
+ int subsequentCandidateIndex = -1;
+
+ for (IntegrityAuditEntity integrityAuditEntity : integrityAuditEntityList) {
+
+ if (logger.isDebugEnabled()) {
+ logIntegrityAuditEntity(integrityAuditEntity);
+ }
+
+ if (integrityAuditEntity.getResourceName().equals(this.resourceName)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("getDesignationCandidate: thisEntity=" + integrityAuditEntity.getResourceName());
+ }
+ thisEntity = integrityAuditEntity;
+ }
+
+ if (integrityAuditEntity.isDesignated()) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("getDesignationCandidate: Currently designated entity resourceName="
+ + integrityAuditEntity.getResourceName() + ", persistenceUnit="
+ + integrityAuditEntity.getPersistenceUnit() + ", lastUpdated="
+ + integrityAuditEntity.getLastUpdated() + ", entityIndex=" + entityIndex);
+ }
+ designatedEntityIndex = entityIndex;
+
+ /*
+ * Entity not currently designated
+ */
+ } else {
+
+ /*
+ * See if non-designated entity is stale.
+ */
+ if (isStale(integrityAuditEntity)) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("getDesignationCandidate: Entity is stale; resourceName="
+ + integrityAuditEntity.getResourceName() + ", persistenceUnit="
+ + integrityAuditEntity.getPersistenceUnit() + ", lastUpdated="
+ + integrityAuditEntity.getLastUpdated() + ", entityIndex=" + entityIndex);
+ }
+
+ /*
+ * Entity is current.
+ */
+ } else {
+
+ if (designatedEntityIndex == -1) {
+
+ if (priorCandidateIndex == -1) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("getDesignationCandidate: Prior candidate found, resourceName="
+ + integrityAuditEntity.getResourceName() + ", persistenceUnit="
+ + integrityAuditEntity.getPersistenceUnit() + ", lastUpdated="
+ + integrityAuditEntity.getLastUpdated() + ", entityIndex=" + entityIndex);
+ }
+ priorCandidateIndex = entityIndex;
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "getDesignationCandidate: Prior entity current but prior candidate already "
+ + "found; resourceName=" + integrityAuditEntity.getResourceName()
+ + ", persistenceUnit=" + integrityAuditEntity.getPersistenceUnit()
+ + ", lastUpdated=" + integrityAuditEntity.getLastUpdated()
+ + ", entityIndex=" + entityIndex);
+ }
+ }
+ } else {
+ if (subsequentCandidateIndex == -1) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("getDesignationCandidate: Subsequent candidate found, resourceName="
+ + integrityAuditEntity.getResourceName() + ", persistenceUnit="
+ + integrityAuditEntity.getPersistenceUnit() + ", lastUpdated="
+ + integrityAuditEntity.getLastUpdated() + ", entityIndex=" + entityIndex);
+ }
+ subsequentCandidateIndex = entityIndex;
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "getDesignationCandidate: Subsequent entity current but subsequent candidate "
+ + "already found; resourceName="
+ + integrityAuditEntity.getResourceName() + ", persistenceUnit="
+ + integrityAuditEntity.getPersistenceUnit() + ", lastUpdated="
+ + integrityAuditEntity.getLastUpdated() + ", entityIndex="
+ + entityIndex);
+ }
+ }
+ }
+
+ } // end entity is current
+
+ } // end entity not currently designated
+
+ entityIndex++;
+
+ } // end for loop
+
+ /*
+ * Per round robin algorithm, if a current entity is found that is lexicographically after
+ * the currently designated entity, this entity becomes the designation candidate. If no
+ * current entity is found that is lexicographically after currently designated entity, we
+ * cycle back to beginning of list and pick the first current entity as the designation
+ * candidate.
+ */
+ if (subsequentCandidateIndex != -1) {
+ designationCandidate = integrityAuditEntityList.get(subsequentCandidateIndex);
+ if (logger.isDebugEnabled()) {
+ logger.debug("getDesignationCandidate: Exiting and returning subsequent designationCandidate="
+ + designationCandidate.getResourceName());
+ }
+ } else {
+ if (priorCandidateIndex != -1) {
+ designationCandidate = integrityAuditEntityList.get(priorCandidateIndex);
+ if (logger.isDebugEnabled()) {
+ logger.debug("getDesignationCandidate: Exiting and returning prior designationCandidate="
+ + designationCandidate.getResourceName());
+ }
+ } else {
+ logger.debug("getDesignationCandidate: No subsequent or prior candidate found; designating thisEntity, "
+ + "resourceName=" + thisEntity.getResourceName());
+ designationCandidate = thisEntity;
+ }
+ }
+
+ return designationCandidate;
+
+ }
+
+ /**
+ * getEntityCurrentlyDesignated() Returns entity that is currently designated.
+ *
+ * @param integrityAuditEntityList the integrity audit entity list
+ * @return the currently designated integrity audit entity
+ */
+ private IntegrityAuditEntity getEntityCurrentlyDesignated(List<IntegrityAuditEntity> integrityAuditEntityList) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("getEntityCurrentlyDesignated: Entering, integrityAuditEntityList.size="
+ + integrityAuditEntityList.size());
+ }
+
+ IntegrityAuditEntity entityCurrentlyDesignated = null;
+
+ for (IntegrityAuditEntity integrityAuditEntity : integrityAuditEntityList) {
+
+ if (integrityAuditEntity.isDesignated()) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("getEntityCurrentlyDesignated: Currently designated entity resourceName="
+ + integrityAuditEntity.getResourceName() + ", persistenceUnit="
+ + integrityAuditEntity.getPersistenceUnit() + ", lastUpdated="
+ + integrityAuditEntity.getLastUpdated());
+ }
+ entityCurrentlyDesignated = integrityAuditEntity;
+ }
+
+ } // end for loop
+
+ if (logger.isDebugEnabled()) {
+ if (entityCurrentlyDesignated != null) {
+ logger.debug("getEntityCurrentlyDesignated: Exiting and returning entityCurrentlyDesignated="
+ + entityCurrentlyDesignated.getResourceName());
+ } else {
+ logger.debug("getEntityCurrentlyDesignated: Exiting and returning entityCurrentlyDesignated="
+ + entityCurrentlyDesignated);
+ }
+ }
+ return entityCurrentlyDesignated;
+
+ }
+
+ /**
+ * getIntegrityAuditEnityList gets the list of IntegrityAuditEntity.
+ *
+ * @return the list of IntegrityAuditEntity
+ * @throws DbDaoTransactionException if an error occurs getting the list of IntegrityAuditEntity
+ */
+ private List<IntegrityAuditEntity> getIntegrityAuditEntityList() throws DbDaoTransactionException {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("getIntegrityAuditEntityList: Entering");
+ }
+
+ /*
+ * Get all records for this nodeType and persistenceUnit and then sort them
+ * lexicographically by resourceName. Get index of designated entity, if any.
+ */
+ /*
+ * Sorted list of entities for a particular nodeType and persistenceUnit.
+ */
+ List<IntegrityAuditEntity> integrityAuditEntityList =
+ dbDao.getIntegrityAuditEntities(this.persistenceUnit, this.nodeType);
+ int listSize = integrityAuditEntityList.size();
+ if (logger.isDebugEnabled()) {
+ logger.debug("getIntegrityAuditEntityList: Got " + listSize + " IntegrityAuditEntity records");
+ }
+ Collections.sort(integrityAuditEntityList, comparator);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "getIntegrityAuditEntityList: Exiting and returning integrityAuditEntityList, size=" + listSize);
+ }
+ return integrityAuditEntityList;
+
+ }
+
+
+ /**
+ * Returns the IntegrityAuditEntity for this entity.
+ *
+ * @param integrityAuditEntityList the list of IntegrityAuditEntity
+ * @return the IntegrityAuditEntity for this entity
+ */
+ private IntegrityAuditEntity getThisEntity(List<IntegrityAuditEntity> integrityAuditEntityList) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("getThisEntity: Entering, integrityAuditEntityList.size=" + integrityAuditEntityList.size());
+ }
+
+ IntegrityAuditEntity thisEntity = null;
+
+ for (IntegrityAuditEntity integrityAuditEntity : integrityAuditEntityList) {
+
+ if (integrityAuditEntity.getResourceName().equals(this.resourceName)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "getThisEntity: For this entity, resourceName=" + integrityAuditEntity.getResourceName()
+ + ", persistenceUnit=" + integrityAuditEntity.getPersistenceUnit()
+ + ", lastUpdated=" + integrityAuditEntity.getLastUpdated());
+ }
+ thisEntity = integrityAuditEntity;
+ }
+
+ } // end for loop
+
+ if (logger.isDebugEnabled()) {
+ if (thisEntity != null) {
+ logger.debug("getThisEntity: Exiting and returning thisEntity=" + thisEntity.getResourceName());
+ } else {
+ logger.debug("getThisEntity: Exiting and returning thisEntity=" + thisEntity);
+ }
+ }
+ return thisEntity;
+
+ }
+
+
+ /**
+ * Returns false if the lastUpdated time for the record in question is more than
+ * auditCompletionIntervalMillis seconds ago. During an audit, lastUpdated is updated every five
+ * seconds or so, but when an audit finishes, the node doing the audit stops updating
+ * lastUpdated.
+ *
+ * @param integrityAuditEntity the integrityAuditEntity
+ * @return false if the lastUpdated time for the record in question is more than
+ * auditCompletionIntervalMillis seconds ago
+ */
+ private boolean isStale(IntegrityAuditEntity integrityAuditEntity) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("isStale: Entering, resourceName=" + integrityAuditEntity.getResourceName()
+ + ", persistenceUnit=" + integrityAuditEntity.getPersistenceUnit() + ", lastUpdated="
+ + integrityAuditEntity.getLastUpdated());
+ }
+
+ boolean stale = false;
+
+ Date currentTime = new Date();
+ Date lastUpdated = integrityAuditEntity.getLastUpdated();
+
+ /*
+ * If lastUpdated is null, we assume that the audit never ran for that node.
+ */
+ long lastUpdatedTime = 0;
+ if (lastUpdated != null) {
+ lastUpdatedTime = lastUpdated.getTime();
+ }
+ long timeDifference = currentTime.getTime() - lastUpdatedTime;
+ if (timeDifference > auditCompletionIntervalMillis) {
+ stale = true;
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("isStale: Exiting and returning stale=" + stale + ", timeDifference=" + timeDifference);
+ }
+
+ return stale;
+ }
+
+ private void logIntegrityAuditEntity(IntegrityAuditEntity integrityAuditEntity) {
+
+ logger.debug("logIntegrityAuditEntity: id=" + integrityAuditEntity.getId() + ", jdbcDriver="
+ + integrityAuditEntity.getJdbcDriver() + ", jdbcPassword=" + integrityAuditEntity.getJdbcPassword()
+ + ", jdbcUrl=" + integrityAuditEntity.getJdbcUrl() + ", jdbcUser=" + integrityAuditEntity.getJdbcUser()
+ + ", nodeType=" + integrityAuditEntity.getNodeType() + ", persistenceUnit="
+ + integrityAuditEntity.getPersistenceUnit() + ", resourceName=" + integrityAuditEntity.getResourceName()
+ + ", site=" + integrityAuditEntity.getSite() + ", createdDate=" + integrityAuditEntity.getCreatedDate()
+ + ", lastUpdated=" + integrityAuditEntity.getLastUpdated() + ", designated="
+ + integrityAuditEntity.isDesignated());
+ }
+
+ /*
+ * If more than (auditCompletionIntervalMillis * 2) milliseconds have elapsed since we last ran
+ * the audit, reset auditCompleted, so
+ *
+ * 1) we'll eventually re-run the audit, if no other node picks up the designation.
+ *
+ * or
+ *
+ * 2) We'll run the audit when the round robin comes back to us.
+ */
+ private boolean resetAuditCompleted(boolean auditCompleted, IntegrityAuditEntity thisEntity) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("resetAuditCompleted: auditCompleted=" + auditCompleted + "; for thisEntity, resourceName="
+ + thisEntity.getResourceName() + ", persistenceUnit=" + thisEntity.getPersistenceUnit()
+ + ", lastUpdated=" + thisEntity.getLastUpdated());
+ }
+
+ long timeDifference;
+
+ Date currentTime = new Date();
+ Date lastUpdated = thisEntity.getLastUpdated();
+
+ long lastUpdatedTime = lastUpdated.getTime();
+ timeDifference = currentTime.getTime() - lastUpdatedTime;
+
+ if (timeDifference > (auditCompletionIntervalMillis * 2)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("resetAuditCompleted: Resetting auditCompleted for resourceName=" + this.resourceName);
+ }
+ auditCompleted = false;
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "resetAuditCompleted: For resourceName=" + resourceName + ", time since last update is only "
+ + timeDifference + "; retaining current value for auditCompleted");
+ }
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("resetAuditCompleted: Exiting and returning auditCompleted=" + auditCompleted
+ + ", timeDifference=" + timeDifference);
+ }
+ return auditCompleted;
+ }
+
+ private void runAudit(DbAudit dbAudit) throws IntegrityAuditException {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("runAudit: Entering, dbAudit=" + dbAudit + "; notifying other resources that resourceName="
+ + this.resourceName + " is current");
+ }
+
+ /*
+ * changeDesignated marks all other nodes as non-designated and this node as designated.
+ */
+ dbDao.changeDesignated(this.resourceName, this.persistenceUnit, this.nodeType);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("runAudit: Running audit for persistenceUnit=" + this.persistenceUnit + " on resourceName="
+ + this.resourceName);
+ }
+ if (IntegrityAudit.isUnitTesting()) {
+ dbAudit.dbAuditSimulate(this.resourceName, this.persistenceUnit, AuditThread.AUDIT_SIMULATION_ITERATIONS,
+ AuditThread.auditThreadSleepIntervalMillis);
+ } else {
+ dbAudit.dbAudit(this.resourceName, this.persistenceUnit, this.nodeType);
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("runAudit: Exiting");
+ }
+
+ }
+
+ /**
+ * Adjusts the thread-sleep-interval to be used when an audit has <i>not</i> been completed.
+ * Used by JUnit tests.
+ *
+ * @param auditThreadSleepIntervalMillis the interval to use in milliseconds
+ */
+ protected static void setAuditThreadSleepIntervalMillis(long auditThreadSleepIntervalMillis) {
+ AuditThread.auditThreadSleepIntervalMillis = auditThreadSleepIntervalMillis;
+ }
+
+ /**
+ * Gets the current thread-sleep-interval to be used when an audit has <i>not</i> been
+ * completed. Used by JUnit tests.
+ *
+ * @return the current sleep interval, in milli-seconds
+ */
+ protected static long getAuditThreadSleepIntervalMillis() {
+ return auditThreadSleepIntervalMillis;
+ }
+
+ /**
+ * Adjusts the audit-completion-interval. Used by JUnit tests.
+ *
+ * @param auditThreadSleepIntervalMillis the interval to use in milliseconds
+ */
+ protected static void setAuditCompletionIntervalMillis(long auditThreadSleepIntervalMillis) {
+ AuditThread.auditCompletionIntervalMillis = auditThreadSleepIntervalMillis;
+ }
+
+ /**
+ * Gets the audit-completion-interval. Used by JUnit tests.
+ *
+ * @return the current audit-completion interval, in milli-seconds
+ */
+ protected static long getAuditCompletionIntervalMillis() {
+ return auditCompletionIntervalMillis;
+ }
}
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java
index 6fb619e4..4c4104f6 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java
@@ -36,492 +36,501 @@ import org.apache.commons.lang3.SerializationUtils;
import org.apache.commons.lang3.builder.RecursiveToStringStyle;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
-
-
-
-
-
import org.onap.policy.common.ia.jpa.IntegrityAuditEntity;
import org.onap.policy.common.logging.eelf.MessageCodes;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
/**
* class DbAudit does actual auditing of DB tables.
*/
public class DbAudit {
-
- private static final Logger logger = FlexLogger.getLogger(DbAudit.class);
-
- private static long dbAuditUpdateMillis = 5000l;
- private static long dbAuditSleepMillis = 2000l;
-
- DbDAO dbDAO = null;
-
- public DbAudit(DbDAO dbDAO) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("Constructor: Entering");
- }
-
- this.dbDAO = dbDAO;
-
- if (logger.isDebugEnabled()) {
- logger.debug("Constructor: Exiting");
- }
-
- }
-
- /**
- * dbAudit actually does the audit
- * @param resourceName
- * @param persistenceUnit
- * @param nodeType
- * @throws Exception
- */
- public void dbAudit(String resourceName, String persistenceUnit, String nodeType) throws IntegrityAuditException {
-
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: Entering, resourceName=" + resourceName
- + ", persistenceUnit=" + persistenceUnit + ", nodeType="
- + nodeType);
- }
-
- // Get all IntegrityAudit entries so we can get the DB access info
- List<IntegrityAuditEntity> iaeList = dbDAO.getIntegrityAuditEntities(persistenceUnit, nodeType);
- if(iaeList == null || iaeList.isEmpty()){
-
- String msg = "DbAudit: for node " + resourceName + " Found no IntegrityAuditEntity entries";
- logger.error(MessageCodes.ERROR_AUDIT, msg);
- throw new DbAuditException(msg);
-
- }else if(iaeList.size() == 1){
-
- Long iaeId = null;
- String iaeRN = null;
- String iaeNT = null;
- String iaeS = null;
- for (IntegrityAuditEntity iae : iaeList){
- iaeId = iae.getId();
- iaeRN = iae.getResourceName();
- iaeNT = iae.getNodeType();
- iaeS = iae.getSite();
- }
- String msg = "DbAudit: Found only one IntegrityAuditEntity entry:"
- + " ID = " + iaeId
- + " ResourceName = " + iaeRN
- + " NodeType = " + iaeNT
- + " Site = " + iaeS;
- logger.warn(msg);
- return;
- }
-
- // Obtain all persistence class names for the PU we are auditing
- Set<String> classNameSet = dbDAO.getPersistenceClassNames();
- if(classNameSet == null || classNameSet.isEmpty()){
-
- String msg = "DbAudit: For node " + resourceName + " Found no persistence class names";
- logger.error(MessageCodes.ERROR_AUDIT, msg);
- throw new DbAuditException(msg);
-
- }
-
- /*
- * Retrieve myIae. We are going to compare the local class entries against
- * all other DB nodes. Since the audit is run in a round-robin, every instance
- * will be compared against every other instance.
- */
- IntegrityAuditEntity myIae = dbDAO.getMyIntegrityAuditEntity();
-
- if(myIae == null){
-
- String msg = "DbAudit: Found no IntegrityAuditEntity entry for resourceName: " + resourceName
- + " persistenceUnit: " + persistenceUnit;
- logger.error(MessageCodes.ERROR_AUDIT, msg);
- throw new DbAuditException(msg);
-
- }
- /*
- * This is the map of mismatched entries indexed by className. For
- * each class name there is a list of mismatched entries
- */
- Map<String,Set<Object>> misMatchedMap = new HashMap<>();
-
- // We need to keep track of how long the audit is taking
- long startTime = System.currentTimeMillis();
-
- // Retrieve all instances of the class for each node
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: Traversing classNameSet, size=" + classNameSet.size());
- }
- for(String clazzName: classNameSet){
-
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: clazzName=" + clazzName);
- }
-
- // all instances of the class for myIae
- Map<Object,Object> myEntries = dbDAO.getAllMyEntries(clazzName);
- //get a map of the objects indexed by id. Does not necessarily have any entries
-
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: Traversing iaeList, size=" + iaeList.size());
- }
- for (IntegrityAuditEntity iae : iaeList){
- if(iae.getId() == myIae.getId()){
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: My Id=" + iae.getId()
- + ", resourceName=" + iae.getResourceName());
- }
- continue; //no need to compare with self
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: Id=" + iae.getId()
- + ", resourceName=" + iae.getResourceName());
- }
- }
- // Create properties for the other db node
- Properties theirProperties = new Properties();
- theirProperties.put(IntegrityAuditProperties.DB_DRIVER, iae.getJdbcDriver());
- theirProperties.put(IntegrityAuditProperties.DB_URL, iae.getJdbcUrl());
- theirProperties.put(IntegrityAuditProperties.DB_USER, iae.getJdbcUser());
- theirProperties.put(IntegrityAuditProperties.DB_PWD, iae.getJdbcPassword());
- theirProperties.put(IntegrityAuditProperties.SITE_NAME, iae.getSite());
- theirProperties.put(IntegrityAuditProperties.NODE_TYPE, iae.getNodeType());
-
- //get a map of the instances for their iae indexed by id
- Map<Object,Object> theirEntries = dbDAO.getAllEntries(persistenceUnit, theirProperties, clazzName);
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: For persistenceUnit="
- + persistenceUnit + ", clazzName=" + clazzName
- + ", theirEntries.size()="
- + theirEntries.size());
- }
-
- /*
- * Compare myEntries with theirEntries and get back a set of mismatched IDs.
- * Collect the IDs for the class where a mismatch occurred. We will check
- * them again for all nodes later.
- */
- Set<Object> misMatchedKeySet = compareEntries(myEntries, theirEntries);
- if(!misMatchedKeySet.isEmpty()){
- Set<Object> misMatchedEntry = misMatchedMap.get(clazzName);
- if(misMatchedEntry == null){
- misMatchedMap.put(clazzName, misMatchedKeySet);
- }else{
- misMatchedEntry.addAll(misMatchedKeySet);
- misMatchedMap.put(clazzName, misMatchedEntry);
- }
- }
- } //end for (IntegrityAuditEntity iae : iaeList)
- //Time check
- if((System.currentTimeMillis() - startTime) >= dbAuditUpdateMillis){
- //update the timestamp
- dbDAO.setLastUpdated();
- //reset the startTime
- startTime=System.currentTimeMillis();
- }else{
- //sleep a couple seconds to break up the activity
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: Sleeping " + dbAuditSleepMillis + "ms");
- }
- sleep();
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: Waking from sleep");
- }
- }
- }//end: for(String clazzName: classNameList)
-
- //check if misMatchedMap is empty
- if(misMatchedMap.isEmpty()){
-
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: Exiting, misMatchedMap is empty");
- }
- //we are done
- return;
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: Doing another comparison; misMatchedMap.size()=" + misMatchedMap.size());
- }
- }
-
- // If misMatchedMap is not empty, retrieve the entries in each misMatched list and compare again
- classNameSet = new HashSet<>(misMatchedMap.keySet());
- // We need to keep track of how long the audit is taking
- startTime = System.currentTimeMillis();
-
- // Retrieve all instances of the class for each node
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: Second comparison; traversing classNameSet, size=" + classNameSet.size());
- }
-
- int errorCount = 0;
-
- for(String clazzName: classNameSet){
-
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: Second comparison; clazzName=" + clazzName);
- }
-
- // all instances of the class for myIae
- Set<Object> keySet = misMatchedMap.get(clazzName);
- Map<Object,Object> myEntries = dbDAO.getAllMyEntries(clazzName, keySet);
- //get a map of the objects indexed by id
-
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: Second comparison; traversing iaeList, size=" + iaeList.size());
- }
- for (IntegrityAuditEntity iae : iaeList){
- if(iae.getId() == myIae.getId()){
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: Second comparison; My Id=" + iae.getId()
- + ", resourceName=" + iae.getResourceName());
- }
- continue; //no need to compare with self
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: Second comparison; Id=" + iae.getId()
- + ", resourceName=" + iae.getResourceName());
- }
- }
- // Create properties for the other db node
- Properties theirProperties = new Properties();
- theirProperties.put(IntegrityAuditProperties.DB_DRIVER, iae.getJdbcDriver());
- theirProperties.put(IntegrityAuditProperties.DB_URL, iae.getJdbcUrl());
- theirProperties.put(IntegrityAuditProperties.DB_USER, iae.getJdbcUser());
- theirProperties.put(IntegrityAuditProperties.DB_PWD, iae.getJdbcPassword());
- theirProperties.put(IntegrityAuditProperties.SITE_NAME, iae.getSite());
- theirProperties.put(IntegrityAuditProperties.NODE_TYPE, iae.getNodeType());
-
- //get a map of the instances for their iae indexed by id
- Map<Object,Object> theirEntries = dbDAO.getAllEntries(persistenceUnit, theirProperties, clazzName, keySet);
-
- /*
- * Compare myEntries with theirEntries and get back a set of mismatched IDs.
- * Collect the IDs for the class where a mismatch occurred. We will now
- * write an error log for each.
- */
- Set<Object> misMatchedKeySet = compareEntries(myEntries, theirEntries);
- if(!misMatchedKeySet.isEmpty()){
- String keysString = "";
- for(Object key: misMatchedKeySet){
- keysString = keysString.concat(key.toString() + ", ");
- errorCount ++;
- }
- writeAuditSummaryLog(clazzName, resourceName, iae.getResourceName(), keysString);
- if(logger.isDebugEnabled()){
- for(Object key : misMatchedKeySet){
- writeAuditDebugLog(clazzName, resourceName, iae.getResourceName(), myEntries.get(key), theirEntries.get(key));
- }
- }
- }
- }
- //Time check
- if((System.currentTimeMillis() - startTime) >= dbAuditUpdateMillis){
- //update the timestamp
- dbDAO.setLastUpdated();
- //reset the startTime
- startTime=System.currentTimeMillis();
- }else{
- //sleep a couple seconds to break up the activity
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: Second comparison; sleeping " + dbAuditSleepMillis + "ms");
- }
- sleep();
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: Second comparison; waking from sleep");
- }
- }
- }//end: for(String clazzName: classNameList)
-
- if(errorCount != 0){
- String msg = " DB Audit: " + errorCount + " errors found. A large number of errors may indicate DB replication has stopped";
- logger.error(MessageCodes.ERROR_AUDIT, msg);
- }
-
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: Exiting");
- }
-
- return; //all done
- }
-
- /**
- * Sleeps a bit.
- * @throws IntegrityAuditException
- */
- private void sleep() throws IntegrityAuditException {
- try {
- Thread.sleep(dbAuditSleepMillis);
-
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- throw new IntegrityAuditException(e);
- }
- }
-
- /**
- * dbAuditSimulate simulates the DB audit
- * @param resourceName
- * @param persistenceUnit
- * @param simulationIterations
- * @param simulationIntervalMs
- * @param nodeType
- * @throws DbAuditException
- */
- public void dbAuditSimulate(String resourceName, String persistenceUnit, long simulationIterations, long simulationIntervalMs) throws DbAuditException {
-
- try {
- logger.info("dbAuditSimulate: Starting audit simulation for resourceName="
- + resourceName + ", persistenceUnit=" + persistenceUnit);
-
- for (int i = 0; i < simulationIterations; i++) {
- dbDAO.setLastUpdated();
- logger.info("dbAuditSimulate: i=" + i + ", sleeping "
- + simulationIntervalMs + "ms");
- Thread.sleep(simulationIntervalMs);
- }
-
- logger.info("dbAuditSimulate: Finished audit simulation for resourceName="
- + resourceName + ", persistenceUnit=" + persistenceUnit);
-
- } catch(DbDaoTransactionException e) {
- throw new DbAuditException(e);
-
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- throw new DbAuditException(e);
- }
- }
-
- /**
- * compareEntries() will compare the lists of entries from the DB
- * @param myEntries
- * @param theirEntries
- * @return
- */
- public Set<Object> compareEntries(Map<Object,Object> myEntries, Map<Object,Object> theirEntries){
- /*
- * Compare the entries for the same key in each of the hashmaps. The comparison will be done by serializing the objects
- * (create a byte array) and then do a byte array comparison. The audit will walk the local repository hash map comparing
- * to the remote cluster hashmap and then turn it around and walk the remote hashmap and look for any entries that are not
- * present in the local cluster hashmap.
- *
- * If the objects are not identical, the audit will put the object IDs on a list to try after completing the audit of the table
- * it is currently working on.
- *
- */
- HashSet<Object> misMatchedKeySet = new HashSet<>();
- for(Entry<Object, Object> ent: myEntries.entrySet()) {
- Object key = ent.getKey();
- byte[] mySerializedEntry = SerializationUtils.serialize((Serializable) ent.getValue());
- byte[] theirSerializedEntry = SerializationUtils.serialize((Serializable) theirEntries.get(key));
- if(!Arrays.equals(mySerializedEntry, theirSerializedEntry)){
- logger.debug("compareEntries: For myEntries.key=" + key + ", entries do not match");
- misMatchedKeySet.add(key);
- } else {
- logger.debug("compareEntries: For myEntries.key=" + key + ", entries match");
- }
- }
- //now compare it in the other direction to catch entries in their set that is not in my set
- for(Entry<Object, Object> ent: theirEntries.entrySet()) {
- Object key = ent.getKey();
- byte[] mySerializedEntry = SerializationUtils.serialize((Serializable) myEntries.get(key));
- byte[] theirSerializedEntry = SerializationUtils.serialize((Serializable) ent.getValue());
- if(!Arrays.equals(mySerializedEntry, theirSerializedEntry)){
- logger.debug("compareEntries: For theirEntries.key=" + key + ", entries do not match");
- misMatchedKeySet.add(key);
- } else {
- logger.debug("compareEntries: For theirEntries.key=" + key + ", entries match");
- }
- }
-
- //return a Set of the object IDs
- logger.debug("compareEntries: misMatchedKeySet.size()=" + misMatchedKeySet.size());
- return misMatchedKeySet;
- }
-
- /**
- * writeAuditDebugLog() writes the mismatched entry details to the debug log
- * @param clazzName
- * @param resourceName1
- * @param resourceName2
- * @param entry1
- * @param entry2
- * @throws IntegrityAuditException
- */
- public void writeAuditDebugLog(String clazzName, String resourceName1,
- String resourceName2, Object entry1, Object entry2) throws IntegrityAuditException{
- try {
- Class<?> entityClass = Class.forName(clazzName);
- String tableName = entityClass.getAnnotation(Table.class).name();
- String msg = "\nDB Audit Error: "
- + "\n Table Name: " + tableName
- + "\n Entry 1 (short prefix style): " + resourceName1 + ": " + new ReflectionToStringBuilder(entry1,ToStringStyle.SHORT_PREFIX_STYLE).toString()
- + "\n Entry 2 (short prefix style): " + resourceName2 + ": " + new ReflectionToStringBuilder(entry2,ToStringStyle.SHORT_PREFIX_STYLE).toString()
- + "\n Entry 1 (recursive style): " + resourceName1 + ": " + new ReflectionToStringBuilder(entry1, new RecursiveToStringStyle()).toString()
- + "\n Entry 2 (recursive style): " + resourceName2 + ": " + new ReflectionToStringBuilder(entry2, new RecursiveToStringStyle()).toString();
- logger.debug(msg);
-
- } catch (ClassNotFoundException e) {
- throw new IntegrityAuditException(e);
- }
-
- }
-
- /**
- * writeAuditSummaryLog() writes a summary of the DB mismatches to the error log
- * @param clazzName
- * @param resourceName1
- * @param resourceName2
- * @param keys
- * @throws IntegrityAuditException
- */
- public void writeAuditSummaryLog(String clazzName, String resourceName1,
- String resourceName2, String keys) throws IntegrityAuditException{
- try {
- Class<?> entityClass = Class.forName(clazzName);
- String tableName = entityClass.getAnnotation(Table.class).name();
- String msg = " DB Audit Error: Table Name: " + tableName
- + "; Mismatch between nodes: " + resourceName1 +" and " + resourceName2
- + "; Mismatched entries (keys): " + keys;
- logger.info(msg);
- } catch (ClassNotFoundException e) {
- throw new IntegrityAuditException(e);
- }
- }
-
- /**
- * Gets the audit-update time.
- * @return the audit-update time, in milliseconds
- */
- protected static long getDbAuditUpdateMillis() {
- return dbAuditUpdateMillis;
- }
-
- /**
- * Sets the audit-update time.
- * @param dbAuditUpdateMillis the new audit update time, in milliseconds
- */
- protected static void setDbAuditUpdateMillis(long dbAuditUpdateMillis) {
- DbAudit.dbAuditUpdateMillis = dbAuditUpdateMillis;
- }
-
- /**
- * Gets the audit-sleep time.
- * @return the audit-sleep time, in milliseconds
- */
- protected static long getDbAuditSleepMillis() {
- return dbAuditSleepMillis;
- }
-
- /**
- * Sets the audit-sleep time.
- * @param dbAuditSleepMillis the new audit sleep time, in milliseconds
- */
- protected static void setDbAuditSleepMillis(long dbAuditSleepMillis) {
- DbAudit.dbAuditSleepMillis = dbAuditSleepMillis;
- }
+
+ private static final Logger logger = FlexLogger.getLogger(DbAudit.class);
+
+ private static long dbAuditUpdateMillis = 5000L;
+ private static long dbAuditSleepMillis = 2000L;
+
+ DbDAO dbDao = null;
+
+ /**
+ * Construct an instance with the given DbDAO.
+ *
+ * @param dbDao the DbDAO
+ */
+ public DbAudit(DbDAO dbDao) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Constructor: Entering");
+ }
+
+ this.dbDao = dbDao;
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Constructor: Exiting");
+ }
+
+ }
+
+ /**
+ * dbAudit actually does the audit.
+ *
+ * @param resourceName the resource name
+ * @param persistenceUnit the persistence unit
+ * @param nodeType the node type
+ * @throws IntegrityAuditException if an error occurs
+ */
+ public void dbAudit(String resourceName, String persistenceUnit, String nodeType) throws IntegrityAuditException {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("dbAudit: Entering, resourceName=" + resourceName + ", persistenceUnit=" + persistenceUnit
+ + ", nodeType=" + nodeType);
+ }
+
+ // Get all IntegrityAudit entries so we can get the DB access info
+ List<IntegrityAuditEntity> iaeList = dbDao.getIntegrityAuditEntities(persistenceUnit, nodeType);
+ if (iaeList == null || iaeList.isEmpty()) {
+
+ String msg = "DbAudit: for node " + resourceName + " Found no IntegrityAuditEntity entries";
+ logger.error(MessageCodes.ERROR_AUDIT, msg);
+ throw new DbAuditException(msg);
+
+ } else if (iaeList.size() == 1) {
+
+ Long iaeId = null;
+ String iaeRn = null;
+ String iaeNt = null;
+ String iaeS = null;
+ for (IntegrityAuditEntity iae : iaeList) {
+ iaeId = iae.getId();
+ iaeRn = iae.getResourceName();
+ iaeNt = iae.getNodeType();
+ iaeS = iae.getSite();
+ }
+ String msg = "DbAudit: Found only one IntegrityAuditEntity entry:" + " ID = " + iaeId + " ResourceName = "
+ + iaeRn + " NodeType = " + iaeNt + " Site = " + iaeS;
+ logger.warn(msg);
+ return;
+ }
+
+ // Obtain all persistence class names for the PU we are auditing
+ Set<String> classNameSet = dbDao.getPersistenceClassNames();
+ if (classNameSet == null || classNameSet.isEmpty()) {
+
+ String msg = "DbAudit: For node " + resourceName + " Found no persistence class names";
+ logger.error(MessageCodes.ERROR_AUDIT, msg);
+ throw new DbAuditException(msg);
+
+ }
+
+ /*
+ * Retrieve myIae. We are going to compare the local class entries against all other DB
+ * nodes. Since the audit is run in a round-robin, every instance will be compared against
+ * every other instance.
+ */
+ IntegrityAuditEntity myIae = dbDao.getMyIntegrityAuditEntity();
+
+ if (myIae == null) {
+
+ String msg = "DbAudit: Found no IntegrityAuditEntity entry for resourceName: " + resourceName
+ + " persistenceUnit: " + persistenceUnit;
+ logger.error(MessageCodes.ERROR_AUDIT, msg);
+ throw new DbAuditException(msg);
+
+ }
+ /*
+ * This is the map of mismatched entries indexed by className. For each class name there is
+ * a list of mismatched entries
+ */
+ Map<String, Set<Object>> misMatchedMap = new HashMap<>();
+
+ // We need to keep track of how long the audit is taking
+ long startTime = System.currentTimeMillis();
+
+ // Retrieve all instances of the class for each node
+ if (logger.isDebugEnabled()) {
+ logger.debug("dbAudit: Traversing classNameSet, size=" + classNameSet.size());
+ }
+ for (String clazzName : classNameSet) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("dbAudit: clazzName=" + clazzName);
+ }
+
+ // all instances of the class for myIae
+ Map<Object, Object> myEntries = dbDao.getAllMyEntries(clazzName);
+ // get a map of the objects indexed by id. Does not necessarily have any entries
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("dbAudit: Traversing iaeList, size=" + iaeList.size());
+ }
+ for (IntegrityAuditEntity iae : iaeList) {
+ if (iae.getId() == myIae.getId()) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("dbAudit: My Id=" + iae.getId() + ", resourceName=" + iae.getResourceName());
+ }
+ continue; // no need to compare with self
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("dbAudit: Id=" + iae.getId() + ", resourceName=" + iae.getResourceName());
+ }
+ }
+ // Create properties for the other db node
+ Properties theirProperties = new Properties();
+ theirProperties.put(IntegrityAuditProperties.DB_DRIVER, iae.getJdbcDriver());
+ theirProperties.put(IntegrityAuditProperties.DB_URL, iae.getJdbcUrl());
+ theirProperties.put(IntegrityAuditProperties.DB_USER, iae.getJdbcUser());
+ theirProperties.put(IntegrityAuditProperties.DB_PWD, iae.getJdbcPassword());
+ theirProperties.put(IntegrityAuditProperties.SITE_NAME, iae.getSite());
+ theirProperties.put(IntegrityAuditProperties.NODE_TYPE, iae.getNodeType());
+
+ // get a map of the instances for their iae indexed by id
+ Map<Object, Object> theirEntries = dbDao.getAllEntries(persistenceUnit, theirProperties, clazzName);
+ if (logger.isDebugEnabled()) {
+ logger.debug("dbAudit: For persistenceUnit=" + persistenceUnit + ", clazzName=" + clazzName
+ + ", theirEntries.size()=" + theirEntries.size());
+ }
+
+ /*
+ * Compare myEntries with theirEntries and get back a set of mismatched IDs. Collect
+ * the IDs for the class where a mismatch occurred. We will check them again for all
+ * nodes later.
+ */
+ Set<Object> misMatchedKeySet = compareEntries(myEntries, theirEntries);
+ if (!misMatchedKeySet.isEmpty()) {
+ Set<Object> misMatchedEntry = misMatchedMap.get(clazzName);
+ if (misMatchedEntry == null) {
+ misMatchedMap.put(clazzName, misMatchedKeySet);
+ } else {
+ misMatchedEntry.addAll(misMatchedKeySet);
+ misMatchedMap.put(clazzName, misMatchedEntry);
+ }
+ }
+ } // end for (IntegrityAuditEntity iae : iaeList)
+
+ // Time check
+ if ((System.currentTimeMillis() - startTime) >= dbAuditUpdateMillis) {
+ // update the timestamp
+ dbDao.setLastUpdated();
+ // reset the startTime
+ startTime = System.currentTimeMillis();
+ } else {
+ // sleep a couple seconds to break up the activity
+ if (logger.isDebugEnabled()) {
+ logger.debug("dbAudit: Sleeping " + dbAuditSleepMillis + "ms");
+ }
+ sleep();
+ if (logger.isDebugEnabled()) {
+ logger.debug("dbAudit: Waking from sleep");
+ }
+ }
+ } // end: for(String clazzName: classNameList)
+
+ // check if misMatchedMap is empty
+ if (misMatchedMap.isEmpty()) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("dbAudit: Exiting, misMatchedMap is empty");
+ }
+ // we are done
+ return;
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("dbAudit: Doing another comparison; misMatchedMap.size()=" + misMatchedMap.size());
+ }
+ }
+
+ // If misMatchedMap is not empty, retrieve the entries in each misMatched list and compare
+ // again
+ classNameSet = new HashSet<>(misMatchedMap.keySet());
+ // We need to keep track of how long the audit is taking
+ startTime = System.currentTimeMillis();
+
+ // Retrieve all instances of the class for each node
+ if (logger.isDebugEnabled()) {
+ logger.debug("dbAudit: Second comparison; traversing classNameSet, size=" + classNameSet.size());
+ }
+
+ int errorCount = 0;
+
+ for (String clazzName : classNameSet) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("dbAudit: Second comparison; clazzName=" + clazzName);
+ }
+
+ // all instances of the class for myIae
+ Set<Object> keySet = misMatchedMap.get(clazzName);
+ Map<Object, Object> myEntries = dbDao.getAllMyEntries(clazzName, keySet);
+ // get a map of the objects indexed by id
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("dbAudit: Second comparison; traversing iaeList, size=" + iaeList.size());
+ }
+ for (IntegrityAuditEntity iae : iaeList) {
+ if (iae.getId() == myIae.getId()) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("dbAudit: Second comparison; My Id=" + iae.getId() + ", resourceName="
+ + iae.getResourceName());
+ }
+ continue; // no need to compare with self
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("dbAudit: Second comparison; Id=" + iae.getId() + ", resourceName="
+ + iae.getResourceName());
+ }
+ }
+ // Create properties for the other db node
+ Properties theirProperties = new Properties();
+ theirProperties.put(IntegrityAuditProperties.DB_DRIVER, iae.getJdbcDriver());
+ theirProperties.put(IntegrityAuditProperties.DB_URL, iae.getJdbcUrl());
+ theirProperties.put(IntegrityAuditProperties.DB_USER, iae.getJdbcUser());
+ theirProperties.put(IntegrityAuditProperties.DB_PWD, iae.getJdbcPassword());
+ theirProperties.put(IntegrityAuditProperties.SITE_NAME, iae.getSite());
+ theirProperties.put(IntegrityAuditProperties.NODE_TYPE, iae.getNodeType());
+
+ // get a map of the instances for their iae indexed by id
+ Map<Object, Object> theirEntries =
+ dbDao.getAllEntries(persistenceUnit, theirProperties, clazzName, keySet);
+
+ /*
+ * Compare myEntries with theirEntries and get back a set of mismatched IDs. Collect
+ * the IDs for the class where a mismatch occurred. We will now write an error log
+ * for each.
+ */
+ Set<Object> misMatchedKeySet = compareEntries(myEntries, theirEntries);
+ if (!misMatchedKeySet.isEmpty()) {
+ String keysString = "";
+ for (Object key : misMatchedKeySet) {
+ keysString = keysString.concat(key.toString() + ", ");
+ errorCount++;
+ }
+ writeAuditSummaryLog(clazzName, resourceName, iae.getResourceName(), keysString);
+ if (logger.isDebugEnabled()) {
+ for (Object key : misMatchedKeySet) {
+ writeAuditDebugLog(clazzName, resourceName, iae.getResourceName(), myEntries.get(key),
+ theirEntries.get(key));
+ }
+ }
+ }
+ }
+ // Time check
+ if ((System.currentTimeMillis() - startTime) >= dbAuditUpdateMillis) {
+ // update the timestamp
+ dbDao.setLastUpdated();
+ // reset the startTime
+ startTime = System.currentTimeMillis();
+ } else {
+ // sleep a couple seconds to break up the activity
+ if (logger.isDebugEnabled()) {
+ logger.debug("dbAudit: Second comparison; sleeping " + dbAuditSleepMillis + "ms");
+ }
+ sleep();
+ if (logger.isDebugEnabled()) {
+ logger.debug("dbAudit: Second comparison; waking from sleep");
+ }
+ }
+ } // end: for(String clazzName: classNameList)
+
+ if (errorCount != 0) {
+ String msg = " DB Audit: " + errorCount
+ + " errors found. A large number of errors may indicate DB replication has stopped";
+ logger.error(MessageCodes.ERROR_AUDIT, msg);
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("dbAudit: Exiting");
+ }
+
+ return; // all done
+ }
+
+ /**
+ * Sleeps a bit.
+ *
+ * @throws IntegrityAuditException if interrupted
+ */
+ private void sleep() throws IntegrityAuditException {
+ try {
+ Thread.sleep(dbAuditSleepMillis);
+
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new IntegrityAuditException(e);
+ }
+ }
+
+ /**
+ * dbAuditSimulate simulates the DB audit.
+ *
+ * @param resourceName the resouce name
+ * @param persistenceUnit the persistence unit
+ * @param simulationIterations the simulations iterations
+ * @param simulationIntervalMs the simulation interval in milliseconds
+ * @throws DbAuditException if an error occurs
+ */
+ public void dbAuditSimulate(String resourceName, String persistenceUnit, long simulationIterations,
+ long simulationIntervalMs) throws DbAuditException {
+
+ try {
+ logger.info("dbAuditSimulate: Starting audit simulation for resourceName=" + resourceName
+ + ", persistenceUnit=" + persistenceUnit);
+
+ for (int i = 0; i < simulationIterations; i++) {
+ dbDao.setLastUpdated();
+ logger.info("dbAuditSimulate: i=" + i + ", sleeping " + simulationIntervalMs + "ms");
+ Thread.sleep(simulationIntervalMs);
+ }
+
+ logger.info("dbAuditSimulate: Finished audit simulation for resourceName=" + resourceName
+ + ", persistenceUnit=" + persistenceUnit);
+
+ } catch (DbDaoTransactionException e) {
+ throw new DbAuditException(e);
+
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new DbAuditException(e);
+ }
+ }
+
+ /**
+ * compareEntries() will compare the lists of entries from the DB.
+ *
+ * @param myEntries the entries
+ * @param theirEntries the entries to compare against myEntries
+ * @return the set of differences
+ */
+ public Set<Object> compareEntries(Map<Object, Object> myEntries, Map<Object, Object> theirEntries) {
+ /*
+ * Compare the entries for the same key in each of the hashmaps. The comparison will be done
+ * by serializing the objects (create a byte array) and then do a byte array comparison. The
+ * audit will walk the local repository hash map comparing to the remote cluster hashmap and
+ * then turn it around and walk the remote hashmap and look for any entries that are not
+ * present in the local cluster hashmap.
+ *
+ * If the objects are not identical, the audit will put the object IDs on a list to try
+ * after completing the audit of the table it is currently working on.
+ *
+ */
+ HashSet<Object> misMatchedKeySet = new HashSet<>();
+ for (Entry<Object, Object> ent : myEntries.entrySet()) {
+ Object key = ent.getKey();
+ byte[] mySerializedEntry = SerializationUtils.serialize((Serializable) ent.getValue());
+ byte[] theirSerializedEntry = SerializationUtils.serialize((Serializable) theirEntries.get(key));
+ if (!Arrays.equals(mySerializedEntry, theirSerializedEntry)) {
+ logger.debug("compareEntries: For myEntries.key=" + key + ", entries do not match");
+ misMatchedKeySet.add(key);
+ } else {
+ logger.debug("compareEntries: For myEntries.key=" + key + ", entries match");
+ }
+ }
+ // now compare it in the other direction to catch entries in their set that is not in my set
+ for (Entry<Object, Object> ent : theirEntries.entrySet()) {
+ Object key = ent.getKey();
+ byte[] mySerializedEntry = SerializationUtils.serialize((Serializable) myEntries.get(key));
+ byte[] theirSerializedEntry = SerializationUtils.serialize((Serializable) ent.getValue());
+ if (!Arrays.equals(mySerializedEntry, theirSerializedEntry)) {
+ logger.debug("compareEntries: For theirEntries.key=" + key + ", entries do not match");
+ misMatchedKeySet.add(key);
+ } else {
+ logger.debug("compareEntries: For theirEntries.key=" + key + ", entries match");
+ }
+ }
+
+ // return a Set of the object IDs
+ logger.debug("compareEntries: misMatchedKeySet.size()=" + misMatchedKeySet.size());
+ return misMatchedKeySet;
+ }
+
+ /**
+ * writeAuditDebugLog() writes the mismatched entry details to the debug log.
+ *
+ * @param clazzName the class name
+ * @param resourceName1 resource name 1
+ * @param resourceName2 resource name 2
+ * @param entry1 entry 1
+ * @param entry2 entry 2
+ * @throws IntegrityAuditException if the given class cannot be found
+ */
+ public void writeAuditDebugLog(String clazzName, String resourceName1, String resourceName2, Object entry1,
+ Object entry2) throws IntegrityAuditException {
+ try {
+ Class<?> entityClass = Class.forName(clazzName);
+ String tableName = entityClass.getAnnotation(Table.class).name();
+ String msg = "\nDB Audit Error: " + "\n Table Name: " + tableName
+ + "\n Entry 1 (short prefix style): " + resourceName1 + ": "
+ + new ReflectionToStringBuilder(entry1, ToStringStyle.SHORT_PREFIX_STYLE).toString()
+ + "\n Entry 2 (short prefix style): " + resourceName2 + ": "
+ + new ReflectionToStringBuilder(entry2, ToStringStyle.SHORT_PREFIX_STYLE).toString()
+ + "\n Entry 1 (recursive style): " + resourceName1 + ": "
+ + new ReflectionToStringBuilder(entry1, new RecursiveToStringStyle()).toString()
+ + "\n Entry 2 (recursive style): " + resourceName2 + ": "
+ + new ReflectionToStringBuilder(entry2, new RecursiveToStringStyle()).toString();
+ logger.debug(msg);
+
+ } catch (ClassNotFoundException e) {
+ throw new IntegrityAuditException(e);
+ }
+
+ }
+
+ /**
+ * writeAuditSummaryLog() writes a summary of the DB mismatches to the error log.
+ *
+ * @param clazzName the name of the class
+ * @param resourceName1 resource name 1
+ * @param resourceName2 resource name 2
+ * @param keys the mismatched entry keys
+ * @throws IntegrityAuditException if the given class cannot be found
+ */
+ public void writeAuditSummaryLog(String clazzName, String resourceName1, String resourceName2, String keys)
+ throws IntegrityAuditException {
+ try {
+ Class<?> entityClass = Class.forName(clazzName);
+ String tableName = entityClass.getAnnotation(Table.class).name();
+ String msg = " DB Audit Error: Table Name: " + tableName + "; Mismatch between nodes: " + resourceName1
+ + " and " + resourceName2 + "; Mismatched entries (keys): " + keys;
+ logger.info(msg);
+ } catch (ClassNotFoundException e) {
+ throw new IntegrityAuditException(e);
+ }
+ }
+
+ /**
+ * Gets the audit-update time.
+ *
+ * @return the audit-update time, in milliseconds
+ */
+ protected static long getDbAuditUpdateMillis() {
+ return dbAuditUpdateMillis;
+ }
+
+ /**
+ * Sets the audit-update time.
+ *
+ * @param dbAuditUpdateMillis the new audit update time, in milliseconds
+ */
+ protected static void setDbAuditUpdateMillis(long dbAuditUpdateMillis) {
+ DbAudit.dbAuditUpdateMillis = dbAuditUpdateMillis;
+ }
+
+ /**
+ * Gets the audit-sleep time.
+ *
+ * @return the audit-sleep time, in milliseconds
+ */
+ protected static long getDbAuditSleepMillis() {
+ return dbAuditSleepMillis;
+ }
+
+ /**
+ * Sets the audit-sleep time.
+ *
+ * @param dbAuditSleepMillis the new audit sleep time, in milliseconds
+ */
+ protected static void setDbAuditSleepMillis(long dbAuditSleepMillis) {
+ DbAudit.dbAuditSleepMillis = dbAuditSleepMillis;
+ }
}
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbAuditException.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbAuditException.java
index dc629c65..a539f6bd 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbAuditException.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbAuditException.java
@@ -21,18 +21,21 @@
package org.onap.policy.common.ia;
public class DbAuditException extends IntegrityAuditException {
- private static final long serialVersionUID = 1L;
- public DbAuditException() {
- super();
- }
- public DbAuditException(String message) {
- super(message);
- }
+ private static final long serialVersionUID = 1L;
- public DbAuditException(Throwable cause) {
- super(cause);
- }
- public DbAuditException(String message, Throwable cause) {
- super(message, cause);
- }
+ public DbAuditException() {
+ super();
+ }
+
+ public DbAuditException(String message) {
+ super(message);
+ }
+
+ public DbAuditException(Throwable cause) {
+ super(cause);
+ }
+
+ public DbAuditException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java
index 73beda78..864adacb 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java
@@ -42,9 +42,8 @@ import javax.persistence.criteria.Root;
import javax.persistence.metamodel.ManagedType;
import javax.persistence.metamodel.Metamodel;
-
import org.onap.policy.common.ia.jpa.IntegrityAuditEntity;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
/**
@@ -52,703 +51,718 @@ import org.onap.policy.common.logging.flexlogger.Logger;
*
*/
public class DbDAO {
- private static final Logger logger = FlexLogger.getLogger(DbDAO.class.getName());
- private String resourceName;
- private String persistenceUnit;
- private String dbDriver;
- private String dbUrl;
- private String dbUser;
- private String siteName;
- private String nodeType;
- private Properties properties=null;
-
- private EntityManagerFactory emf;
-
- /*
- * Supports designation serialization.
- */
+ private static final Logger logger = FlexLogger.getLogger(DbDAO.class.getName());
+ private String resourceName;
+ private String persistenceUnit;
+ private String dbDriver;
+ private String dbUrl;
+ private String dbUser;
+ private String siteName;
+ private String nodeType;
+ private Properties properties = null;
+
+ private EntityManagerFactory emf;
+
+ /*
+ * Supports designation serialization.
+ */
private static final Object lock = new Object();
- /**
- * DbDAO Constructor
- *
- * @param resourceName
- * @param persistenceUnit
- * @param properties
- * @throws IntegrityAuditException
- */
- public DbDAO(String resourceName, String persistenceUnit, Properties properties) throws IntegrityAuditException {
- this(resourceName, persistenceUnit, properties, null);
- }
-
- /**
- * DbDAO Constructor
- *
- * @param resourceName
- * @param persistenceUnit
- * @param properties
- * @param lastUpdateDate may be {@code null}
- * @param altDbUrl may be {@code null}
- * @throws IntegrityAuditException
- */
- protected DbDAO(String resourceName, String persistenceUnit, Properties properties, String altDbUrl)
- throws IntegrityAuditException {
- logger.debug("DbDAO contructor: enter");
-
- validateProperties(resourceName, persistenceUnit, properties);
-
- emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
-
- register(altDbUrl);
-
- logger.debug("DbDAO contructor: exit");
- }
-
- /**
- * Release resources (i.e., the EntityManagerFactory).
- */
- public void destroy() {
- emf.close();
- }
-
- /**
- * validateProperties will validate the properties
- * @param resourceName
- * @param persistenceUnit
- * @param properties
- * @throws IntegrityAuditPropertiesException
- */
- private void validateProperties(String resourceName, String persistenceUnit, Properties properties) throws IntegrityAuditPropertiesException{
- StringBuilder badparams= new StringBuilder();
- if(IntegrityAudit.parmsAreBad(resourceName, persistenceUnit, properties, badparams)){
- String msg = "DbDAO: Bad parameters: badparams" + badparams;
- throw new IntegrityAuditPropertiesException(msg);
- }
- this.resourceName = resourceName;
- this.persistenceUnit = persistenceUnit;
- this.dbDriver = properties.getProperty(IntegrityAuditProperties.DB_DRIVER).trim();
- this.dbUrl = properties.getProperty(IntegrityAuditProperties.DB_URL).trim();
- this.dbUser = properties.getProperty(IntegrityAuditProperties.DB_USER).trim();
- this.siteName = properties.getProperty(IntegrityAuditProperties.SITE_NAME).trim();
- this.nodeType = properties.getProperty(IntegrityAuditProperties.NODE_TYPE).trim();
- this.properties = properties;
- logger.debug("DbDAO.assignProperties: exit:"
- + "\nresourceName: " + this.resourceName
- + "\npersistenceUnit: " + this.persistenceUnit
- + "\nproperties: " + this.properties);
- }
-
- /**
- * getAllMyEntries gets all the DB entries for a particular class
- * @param className
- * @return
- */
- public Map<Object, Object> getAllMyEntries(String className) {
- logger.debug("getAllMyEntries: Entering, className="
- + className);
- HashMap<Object, Object> resultMap = new HashMap<>();
- EntityManager em = emf.createEntityManager();
- try{
- CriteriaBuilder cb = em.getCriteriaBuilder();
- CriteriaQuery<Object> cq = cb.createQuery();
- Root<?> rootEntry = cq.from(Class.forName(className));
- CriteriaQuery<Object> all = cq.select(rootEntry);
- TypedQuery<Object> allQuery = em.createQuery(all);
- List<Object> objectList = allQuery.getResultList();
- //Now create the map
-
- PersistenceUnitUtil util = emf.getPersistenceUnitUtil();
- for (Object o: objectList){
- Object key = util.getIdentifier(o);
- resultMap.put(key, o);
- }
- }catch(Exception e){
- logger.error("getAllEntries encountered exception: ", e);
- }
- em.close();
- logger.debug("getAllMyEntries: Exit, resultMap.keySet()=" + resultMap.keySet());
- return resultMap;
- }
-
- /**
- * getAllMyEntries gets all entries for a class
- * @param className
- * @param keySet
- * @return
- */
- public Map<Object, Object> getAllMyEntries(String className, Set<Object> keySet){
- logger.debug("getAllMyEntries: Entering, className="
- + className + ",\n keySet=" + keySet);
-
- HashMap<Object, Object> resultMap = new HashMap<>();
- EntityManager em = emf.createEntityManager();
- try{
- Class<?> clazz = Class.forName(className);
- for(Object key : keySet){
- Object entry = em.find(clazz, key);
- resultMap.put(key, entry);
- }
- }catch(Exception e){
- logger.error("getAllMyEntries encountered exception: ", e);
- }
- em.close();
-
- logger.debug("getAllMyEntries: Returning resultMap, size=" + resultMap.size());
- return resultMap;
- }
-
- /**
- * getAllEntries gets all entriesfor a particular persistence unit adn className
- * @param persistenceUnit
- * @param properties
- * @param className
- * @return
- */
- public Map<Object,Object> getAllEntries(String persistenceUnit, Properties properties, String className){
-
- logger.debug("getAllEntries: Entering, persistenceUnit="
- + persistenceUnit + ",\n className=" + className);
- HashMap<Object, Object> resultMap = new HashMap<>();
-
- EntityManagerFactory theEmf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
- EntityManager em = theEmf.createEntityManager();
- try{
- CriteriaBuilder cb = em.getCriteriaBuilder();
- CriteriaQuery<Object> cq = cb.createQuery();
- Root<?> rootEntry = cq.from(Class.forName(className));
- CriteriaQuery<Object> all = cq.select(rootEntry);
- TypedQuery<Object> allQuery = em.createQuery(all);
- List<Object> objectList = allQuery.getResultList();
-
- PersistenceUnitUtil util = theEmf.getPersistenceUnitUtil();
- for (Object o: objectList){
- Object key = util.getIdentifier(o);
- resultMap.put(key, o);
- }
- }catch(Exception e){
- logger.error("getAllEntries encountered exception:", e);
- }
- em.close();
- theEmf.close();
-
- logger.debug("getAllEntries: Returning resultMap, size=" + resultMap.size());
-
- return resultMap;
- }
-
-
- /**
- * getAllEntries gest all entries for a persistence unit
- * @param persistenceUnit
- * @param properties
- * @param className
- * @param keySet
- * @return
- */
-
- public Map<Object,Object> getAllEntries(String persistenceUnit, Properties properties, String className, Set<Object> keySet){
- logger.debug("getAllEntries: Entering, persistenceUnit="
- + persistenceUnit + ",\n properties= " + properties + ",\n className=" + className + ",\n keySet= " + keySet);
- EntityManagerFactory theEmf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
- EntityManager em = theEmf.createEntityManager();
- HashMap<Object, Object> resultMap = new HashMap<>();
- try{
- Class<?> clazz = Class.forName(className);
- for(Object key : keySet){
- Object entry = em.find(clazz, key);
- resultMap.put(key, entry);
- }
- }catch(Exception e){
- String msg = "getAllEntries encountered exception: " + e;
- logger.error(msg, e);
- }
- em.close();
- theEmf.close();
- logger.debug("getAllEntries: Exit, resultMap, size=" + resultMap.size());
- return resultMap;
- }
-
- /**
- * getIntegrityAuditEntities() Get all the IntegrityAuditEntities for a particular persistence unit
- * and node type
- * @param persistenceUnit
- * @param nodeType
- * @return
- * @throws DbDaoTransactionException
- */
- @SuppressWarnings("unchecked")
- public List<IntegrityAuditEntity> getIntegrityAuditEntities(String persistenceUnit, String nodeType) throws DbDaoTransactionException {
- logger.debug("getIntegrityAuditEntities: Entering, persistenceUnit="
- + persistenceUnit + ",\n nodeType= " + nodeType);
- try{
- EntityManager em = emf.createEntityManager();
- // Start a transaction
- EntityTransaction et = em.getTransaction();
-
- et.begin();
-
- // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not found, create a new entry
- Query iaequery = em.createQuery("Select i from IntegrityAuditEntity i where i.persistenceUnit=:pu and i.nodeType=:nt");
- iaequery.setParameter("pu", persistenceUnit);
- iaequery.setParameter("nt", nodeType);
-
- List<IntegrityAuditEntity> iaeList = iaequery.getResultList();
-
- // commit transaction
- et.commit();
- em.close();
- logger.debug("getIntegrityAuditEntities: Exit, iaeList=" + iaeList);
- return iaeList;
- }catch (Exception e){
- String msg = "DbDAO: " + "getIntegrityAuditEntities() " + "ecountered a problem in execution: ";
- logger.error(msg, e);
- throw new DbDaoTransactionException(e);
- }
-
- }
-
- /**
- * getMyIntegrityAuditEntity() gets my IntegrityAuditEntity
- * @return
- * @throws DbDaoTransactionException
- */
- public IntegrityAuditEntity getMyIntegrityAuditEntity() throws DbDaoTransactionException{
- try{
- EntityManager em = emf.createEntityManager();
-
- // Start a transaction
- EntityTransaction et = em.getTransaction();
-
- et.begin();
-
- // if IntegrityAuditEntity entry exists for resourceName and PU, retrieve it
- Query iaequery = em.createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
- iaequery.setParameter("rn", this.resourceName);
- iaequery.setParameter("pu", this.persistenceUnit);
-
- @SuppressWarnings("rawtypes")
- List iaeList = iaequery.getResultList();
- IntegrityAuditEntity iae = null;
-
- if(!iaeList.isEmpty()){
- //ignores multiple results
- iae = (IntegrityAuditEntity) iaeList.get(0);
- // refresh the object from DB in case cached data was returned
- em.refresh(iae);
- logger.info("Resource: " + this.resourceName + " with PersistenceUnit: " + this.persistenceUnit
- + " exists");
- }else{
- // If it does not exist, log an error
- logger.error("Attempting to setLastUpdated"
- + " on an entry that does not exist:"
- +" resource " + this.resourceName + " with PersistenceUnit: " + this.persistenceUnit);
- }
-
- // close the transaction
- et.commit();
- // close the EntityManager
- em.close();
-
- return iae;
- }catch (Exception e){
- String msg = "DbDAO: " + "setLastUpdated() " + "ecountered a problem in execution: ";
- logger.error(msg + e);
- throw new DbDaoTransactionException(e);
- }
- }
-
-
- /**
- * getIntegrityAuditEntity() gets the IntegrityAuditEntity with a particular ID
- * @param id
- * @return
- * @throws DbDaoTransactionException
- */
- public IntegrityAuditEntity getIntegrityAuditEntity(long id) throws DbDaoTransactionException{
- try{
- EntityManager em = emf.createEntityManager();
-
- // Start a transaction
- EntityTransaction et = em.getTransaction();
-
- et.begin();
-
- IntegrityAuditEntity iae = em.find(IntegrityAuditEntity.class, id);
-
- et.commit();
- em.close();
-
- return iae;
- }catch (Exception e){
- String msg = "DbDAO: " + "getIntegrityAuditEntity() " + "ecountered a problem in execution: ";
- logger.error(msg + e);
- throw new DbDaoTransactionException(e);
- }
- }
-
- /**
- * getPersistenceClassNames() gets all the persistence class names.
- * @return
- */
- public Set<String> getPersistenceClassNames(){
- logger.debug("DbDAO: getPersistenceClassNames() entry");
- HashSet<String> returnList = new HashSet<>();
- final Metamodel mm = emf.getMetamodel();
- logger.debug("\n" + persistenceUnit +" persistence unit classes:");
- for (final ManagedType<?> managedType : mm.getManagedTypes()) {
- Class<?> c = managedType.getJavaType();
- logger.debug(" " + c.getSimpleName());
- returnList.add(c.getName()); //the full class name needed to make a query using jpa
- }
- logger.debug("DbDAO: getPersistenceClassNames() exit");
- return returnList;
- }
-
- /**
- * Register the IntegrityAudit instance
- * @param altDbUrl alternate DB URL to be placed into the record,
- * or {@code null} to use the default
- */
- private void register(String altDbUrl) throws DbDaoTransactionException {
- try{
- EntityManager em = emf.createEntityManager();
-
- // Start a transaction
- EntityTransaction et = em.getTransaction();
-
- et.begin();
-
- // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not found, create a new entry
- Query iaequery = em.createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
- iaequery.setParameter("rn", this.resourceName);
- iaequery.setParameter("pu", this.persistenceUnit);
-
- @SuppressWarnings("rawtypes")
- List iaeList = iaequery.getResultList();
- IntegrityAuditEntity iae;
-
- //If it already exists, we just want to update the properties and lastUpdated date
- if(!iaeList.isEmpty()){
- //ignores multiple results
- iae = (IntegrityAuditEntity) iaeList.get(0);
- // refresh the object from DB in case cached data was returned
- em.refresh(iae);
- logger.info("Resource: " + this.resourceName + " with PersistenceUnit: " + this.persistenceUnit
- + " exists and entry be updated");
- }else{
- // If it does not exist, we also must add teh resourceName, persistenceUnit and designated values
- logger.info("Adding resource " + resourceName + " with PersistenceUnit: " + this.persistenceUnit
- + " to IntegrityAuditEntity table");
- iae = new IntegrityAuditEntity();
- iae.setResourceName(this.resourceName);
- iae.setPersistenceUnit(this.persistenceUnit);
- iae.setDesignated(false);
- }
- //update/set properties in entry
- iae.setSite(this.siteName);
- iae.setNodeType(this.nodeType);
- iae.setJdbcDriver(this.dbDriver);
- iae.setJdbcPassword(properties.getProperty(IntegrityAuditProperties.DB_PWD).trim());
- iae.setJdbcUrl(altDbUrl == null ? this.dbUrl : altDbUrl);
- iae.setJdbcUser(dbUser);
-
- em.persist(iae);
- // flush to the DB
- em.flush();
-
- // commit transaction
- et.commit();
- em.close();
- }catch (Exception e){
- String msg = "DbDAO: " + "register() " + "encountered a problem in execution: ";
- logger.error(msg + e);
- throw new DbDaoTransactionException(e);
- }
-
- }
-
- public void setDesignated(boolean designated) throws DbDaoTransactionException{
- setDesignated(this.resourceName, this.persistenceUnit, designated);
- }
-
-
- public void setDesignated(String rName, String pUnit, boolean desig) throws DbDaoTransactionException{
- logger.debug("setDesignated: enter, resourceName: " + rName + ", persistenceUnit: "
- + pUnit + ", designated: " + desig);
- try{
-
- EntityManager em = emf.createEntityManager();
-
- // Start a transaction
- EntityTransaction et = em.getTransaction();
-
- et.begin();
-
- // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not found, create a new entry
- Query iaequery = em.createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
- iaequery.setParameter("rn", rName);
- iaequery.setParameter("pu", pUnit);
-
- @SuppressWarnings("rawtypes")
- List iaeList = iaequery.getResultList();
- IntegrityAuditEntity iae;
-
- if(!iaeList.isEmpty()){
- //ignores multiple results
- iae = (IntegrityAuditEntity) iaeList.get(0);
- // refresh the object from DB in case cached data was returned
- em.refresh(iae);
- logger.info("Resource: " + rName + " with PersistenceUnit: " + pUnit
- + " exists and designated be updated");
- iae.setDesignated(desig);
-
- em.persist(iae);
- // flush to the DB
- em.flush();
- }else{
- // If it does not exist, log an error
- logger.error("Attempting to setDesignated("
- + desig + ") on an entry that does not exist:"
- +" resource " + rName + " with PersistenceUnit: " + pUnit);
- }
-
- // close the transaction
- et.commit();
- // close the EntityManager
- em.close();
- }catch (Exception e){
- String msg = "DbDAO: " + "setDesignated() " + "ecountered a problem in execution: ";
- logger.error(msg + e);
- throw new DbDaoTransactionException(e);
- }
-
- }
-
- public void setLastUpdated() throws DbDaoTransactionException{
- logger.debug("setLastUpdated: enter, resourceName: " + this.resourceName + ", persistenceUnit: "
- + this.persistenceUnit);
- try{
- EntityManager em = emf.createEntityManager();
-
- // Start a transaction
- EntityTransaction et = em.getTransaction();
-
- et.begin();
-
- // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not found, create a new entry
- Query iaequery = em.createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
- iaequery.setParameter("rn", this.resourceName);
- iaequery.setParameter("pu", this.persistenceUnit);
-
- @SuppressWarnings("rawtypes")
- List iaeList = iaequery.getResultList();
- IntegrityAuditEntity iae;
-
- if(!iaeList.isEmpty()){
- //ignores multiple results
- iae = (IntegrityAuditEntity) iaeList.get(0);
- // refresh the object from DB in case cached data was returned
- em.refresh(iae);
- logger.info("Resource: " + this.resourceName + " with PersistenceUnit: " + this.persistenceUnit
- + " exists and lastUpdated be updated");
- iae.setLastUpdated(new Date());
-
- em.persist(iae);
- // flush to the DB
- em.flush();
- }else{
- // If it does not exist, log an error
- logger.error("Attempting to setLastUpdated"
- + " on an entry that does not exist:"
- +" resource " + this.resourceName + " with PersistenceUnit: " + this.persistenceUnit);
- }
-
- // close the transaction
- et.commit();
- // close the EntityManager
- em.close();
- }catch (Exception e){
- String msg = "DbDAO: " + "setLastUpdated() " + "ecountered a problem in execution: ";
- logger.error(msg + e);
- throw new DbDaoTransactionException(e);
- }
-
- }
-
- /**
- * Normally this method should only be used in a JUnit test environment.
- * Manually deletes all PDP records in droolspdpentity table.
- */
- public int deleteAllIntegrityAuditEntities() throws DbDaoTransactionException {
-
- try{
-
- if (!IntegrityAudit.isUnitTesting()) {
- String msg = "DbDAO: " + "deleteAllIntegrityAuditEntities() " + "should only be invoked during JUnit testing";
- logger.error(msg);
- throw new DbDaoTransactionException(msg);
- }
-
- EntityManager em = emf.createEntityManager();
- // Start a transaction
- EntityTransaction et = em.getTransaction();
-
- et.begin();
-
- // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not found, create a new entry
- Query iaequery = em.createQuery("Delete from IntegrityAuditEntity");
-
- int returnCode = iaequery.executeUpdate();
-
- // commit transaction
- et.commit();
- em.close();
-
- logger.info("deleteAllIntegrityAuditEntities: returnCode=" + returnCode);
-
- return returnCode;
-
- }catch (Exception e){
- String msg = "DbDAO: " + "deleteAllIntegrityAuditEntities() " + "encountered a problem in execution: ";
- logger.error(msg + e);
- throw new DbDaoTransactionException(e);
- }
-
- }
-
- /**
- * Changes designation to specified resourceName
- *
- * static lock object in conjunction with synchronized keyword ensures that
- * designation changes are done serially within a resource. I.e. static lock
- * ensures that multiple instantiations of DbDAO don't interleave
- * changeDesignated() invocations and potentially produce simultaneous
- * designations.
- *
- * Optimistic locking (the default, versus pessimistic) is sufficient to
- * avoid simultaneous designations from interleaved changeDesignated()
- * invocations from different resources (entities), because it prevents
- * "dirty" and "non-repeatable" reads.
- *
- * See http://www.objectdb.com/api/java/jpa/LockModeType
- *
- * and
- *
- * http://stackoverflow.com/questions/2120248/how-to-synchronize-a-static-
- * variable-among-threads-running-different-instances-o
- */
- public void changeDesignated(String resourceName, String persistenceUnit,
- String nodeType) throws DbDaoTransactionException {
-
- if (logger.isDebugEnabled()) {
- logger.debug("changeDesignated: Entering, resourceName="
- + resourceName + ", persistenceUnit=" + persistenceUnit
- + ", nodeType=" + nodeType);
- }
-
- long startTime = System.currentTimeMillis();
-
- synchronized (lock) {
-
- EntityManager em = null;
- try {
-
- em = emf.createEntityManager();
- em.getTransaction().begin();
-
- /*
- * Define query
- */
- Query query = em
- .createQuery("Select i from IntegrityAuditEntity i where i.persistenceUnit=:pu and i.nodeType=:nt");
- query.setParameter("pu", persistenceUnit);
- query.setParameter("nt", nodeType);
-
- /*
- * Execute query using pessimistic write lock. This ensures that if anyone else is currently reading
- * the records we'll throw a LockTimeoutException.
- */
- @SuppressWarnings("unchecked")
- List<IntegrityAuditEntity> integrityAuditEntityList = (List<IntegrityAuditEntity>) query
- .getResultList();
- for (Object o : integrityAuditEntityList) {
- if (o instanceof IntegrityAuditEntity) {
- IntegrityAuditEntity integrityAuditEntity = (IntegrityAuditEntity) o;
- if (integrityAuditEntity.getResourceName().equals(
- resourceName)) {
- if (logger.isDebugEnabled()) {
- logger.debug("changeDesignated: Designating resourceName="
- + integrityAuditEntity
- .getResourceName());
- }
- integrityAuditEntity.setDesignated(true);
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("changeDesignated: Removing designation from resourceName="
- + integrityAuditEntity
- .getResourceName());
- }
- integrityAuditEntity.setDesignated(false);
- }
- }
- }
-
- if (logger.isDebugEnabled()) {
- logger.debug("changeDesignated: Committing designation to resourceName="
- + resourceName);
- }
- em.getTransaction().commit();
-
- /*
- * If we get a LockTimeoutException, no harm done really. We'll
- * probably be successful on the next attempt. The odds of
- * another DbDAO instance on this entity or another entity
- * attempting a simultaneous IntegrityAuditEntity table
- * read/update are pretty slim (we're only in this method for
- * two or three milliseconds)
- */
- } catch (LockTimeoutException e) {
- if (em != null) {
- em.getTransaction().rollback();
-
- String msg = "DbDAO: " + "changeDesignated() "
- + "caught LockTimeoutException, message=" + e.getMessage();
- logger.error(msg + e);
- throw new DbDaoTransactionException(msg, e);
- }
- else {
- String msg = "DbDAO: " + "changeDesignated() "
- + "caught LockTimeoutException, message=" + e.getMessage()
- + ". Error rolling back transaction.";
- logger.error(msg + e);
- throw new DbDaoTransactionException(msg, e);
- }
- } catch (Exception e) {
- if (em != null) {
- em.getTransaction().rollback();
-
- String msg = "DbDAO: " + "changeDesignated() "
- + "caught Exception, message=" + e.getMessage();
- logger.error(msg + e);
- throw new DbDaoTransactionException(msg, e);
- }
- else {
- String msg = "DbDAO: " + "changeDesignated() "
- + "caught LockTimeoutException, message=" + e.getMessage()
- + ". Error rolling back transaction.";
- logger.error(msg + e);
- throw new DbDaoTransactionException(msg, e);
- }
- }
-
- } // end synchronized block
-
- if (logger.isDebugEnabled()) {
- logger.debug("changeDesignated: Exiting; time expended="
- + (System.currentTimeMillis() - startTime) + "ms");
- }
-
- }
+ /**
+ * DbDAO Constructor.
+ *
+ * @param resourceName the resource name
+ * @param persistenceUnit the persistence unit
+ * @param properties the properties
+ * @throws IntegrityAuditException if an error occurs
+ */
+ public DbDAO(String resourceName, String persistenceUnit, Properties properties) throws IntegrityAuditException {
+ this(resourceName, persistenceUnit, properties, null);
+ }
+
+ /**
+ * DbDAO Constructor.
+ *
+ * @param resourceName the resource name
+ * @param persistenceUnit the persistence unit
+ * @param properties the properties
+ * @param lastUpdateDate may be {@code null}
+ * @param altDbUrl may be {@code null}
+ * @throws IntegrityAuditException if an error occurs
+ */
+ protected DbDAO(String resourceName, String persistenceUnit, Properties properties, String altDbUrl)
+ throws IntegrityAuditException {
+ logger.debug("DbDAO contructor: enter");
+
+ validateProperties(resourceName, persistenceUnit, properties);
+
+ emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+
+ register(altDbUrl);
+
+ logger.debug("DbDAO contructor: exit");
+ }
+
+ /**
+ * Release resources (i.e., the EntityManagerFactory).
+ */
+ public void destroy() {
+ emf.close();
+ }
+
+ /**
+ * validateProperties will validate the properties.
+ *
+ * @param resourceName the rseource name
+ * @param persistenceUnit the persistence unit
+ * @param properties the properties
+ * @throws IntegrityAuditPropertiesException if an error occurs
+ */
+ private void validateProperties(String resourceName, String persistenceUnit, Properties properties)
+ throws IntegrityAuditPropertiesException {
+ StringBuilder badparams = new StringBuilder();
+ if (IntegrityAudit.parmsAreBad(resourceName, persistenceUnit, properties, badparams)) {
+ String msg = "DbDAO: Bad parameters: badparams" + badparams;
+ throw new IntegrityAuditPropertiesException(msg);
+ }
+ this.resourceName = resourceName;
+ this.persistenceUnit = persistenceUnit;
+ this.dbDriver = properties.getProperty(IntegrityAuditProperties.DB_DRIVER).trim();
+ this.dbUrl = properties.getProperty(IntegrityAuditProperties.DB_URL).trim();
+ this.dbUser = properties.getProperty(IntegrityAuditProperties.DB_USER).trim();
+ this.siteName = properties.getProperty(IntegrityAuditProperties.SITE_NAME).trim();
+ this.nodeType = properties.getProperty(IntegrityAuditProperties.NODE_TYPE).trim();
+ this.properties = properties;
+ logger.debug("DbDAO.assignProperties: exit:" + "\nresourceName: " + this.resourceName + "\npersistenceUnit: "
+ + this.persistenceUnit + "\nproperties: " + this.properties);
+ }
+
+ /**
+ * getAllMyEntries gets all the DB entries for a particular class.
+ *
+ * @param className the class name
+ * @return all the DB entries for the given class
+ */
+ public Map<Object, Object> getAllMyEntries(String className) {
+ logger.debug("getAllMyEntries: Entering, className=" + className);
+ HashMap<Object, Object> resultMap = new HashMap<>();
+ EntityManager em = emf.createEntityManager();
+ try {
+ CriteriaBuilder cb = em.getCriteriaBuilder();
+ CriteriaQuery<Object> cq = cb.createQuery();
+ Root<?> rootEntry = cq.from(Class.forName(className));
+ CriteriaQuery<Object> all = cq.select(rootEntry);
+ TypedQuery<Object> allQuery = em.createQuery(all);
+ List<Object> objectList = allQuery.getResultList();
+ // Now create the map
+
+ PersistenceUnitUtil util = emf.getPersistenceUnitUtil();
+ for (Object o : objectList) {
+ Object key = util.getIdentifier(o);
+ resultMap.put(key, o);
+ }
+ } catch (Exception e) {
+ logger.error("getAllEntries encountered exception: ", e);
+ }
+ em.close();
+ logger.debug("getAllMyEntries: Exit, resultMap.keySet()=" + resultMap.keySet());
+ return resultMap;
+ }
+
+ /**
+ * getAllMyEntries gets all entries for a class.
+ *
+ * @param className the name of the class
+ * @param keySet the keys to get the entries for
+ * @return the map of requested entries
+ */
+ public Map<Object, Object> getAllMyEntries(String className, Set<Object> keySet) {
+ logger.debug("getAllMyEntries: Entering, className=" + className + ",\n keySet=" + keySet);
+
+ HashMap<Object, Object> resultMap = new HashMap<>();
+ EntityManager em = emf.createEntityManager();
+ try {
+ Class<?> clazz = Class.forName(className);
+ for (Object key : keySet) {
+ Object entry = em.find(clazz, key);
+ resultMap.put(key, entry);
+ }
+ } catch (Exception e) {
+ logger.error("getAllMyEntries encountered exception: ", e);
+ }
+ em.close();
+
+ logger.debug("getAllMyEntries: Returning resultMap, size=" + resultMap.size());
+ return resultMap;
+ }
+
+ /**
+ * getAllEntries gets all entriesfor a particular persistence unit adn className.
+ *
+ * @param persistenceUnit the persistence unit
+ * @param properties the properties
+ * @param className the class name
+ * @return the map of entries
+ */
+ public Map<Object, Object> getAllEntries(String persistenceUnit, Properties properties, String className) {
+
+ logger.debug("getAllEntries: Entering, persistenceUnit=" + persistenceUnit + ",\n className=" + className);
+ HashMap<Object, Object> resultMap = new HashMap<>();
+
+ EntityManagerFactory theEmf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+ EntityManager em = theEmf.createEntityManager();
+ try {
+ CriteriaBuilder cb = em.getCriteriaBuilder();
+ CriteriaQuery<Object> cq = cb.createQuery();
+ Root<?> rootEntry = cq.from(Class.forName(className));
+ CriteriaQuery<Object> all = cq.select(rootEntry);
+ TypedQuery<Object> allQuery = em.createQuery(all);
+ List<Object> objectList = allQuery.getResultList();
+
+ PersistenceUnitUtil util = theEmf.getPersistenceUnitUtil();
+ for (Object o : objectList) {
+ Object key = util.getIdentifier(o);
+ resultMap.put(key, o);
+ }
+ } catch (Exception e) {
+ logger.error("getAllEntries encountered exception:", e);
+ }
+ em.close();
+ theEmf.close();
+
+ logger.debug("getAllEntries: Returning resultMap, size=" + resultMap.size());
+
+ return resultMap;
+ }
+
+
+ /**
+ * getAllEntries gets all entries for a persistence unit.
+ *
+ * @param persistenceUnit the persistence unit
+ * @param properties the properties
+ * @param className the class name
+ * @param keySet the keys
+ * @return the map of entries
+ */
+
+ public Map<Object, Object> getAllEntries(String persistenceUnit, Properties properties, String className,
+ Set<Object> keySet) {
+ logger.debug("getAllEntries: Entering, persistenceUnit=" + persistenceUnit + ",\n properties= " + properties
+ + ",\n className=" + className + ",\n keySet= " + keySet);
+ EntityManagerFactory theEmf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+ EntityManager em = theEmf.createEntityManager();
+ HashMap<Object, Object> resultMap = new HashMap<>();
+ try {
+ Class<?> clazz = Class.forName(className);
+ for (Object key : keySet) {
+ Object entry = em.find(clazz, key);
+ resultMap.put(key, entry);
+ }
+ } catch (Exception e) {
+ String msg = "getAllEntries encountered exception: " + e;
+ logger.error(msg, e);
+ }
+ em.close();
+ theEmf.close();
+ logger.debug("getAllEntries: Exit, resultMap, size=" + resultMap.size());
+ return resultMap;
+ }
+
+ /**
+ * getIntegrityAuditEntities() Get all the IntegrityAuditEntities for a particular persistence
+ * unit and node type.
+ *
+ * @param persistenceUnit the persistence unit
+ * @param nodeType the node type
+ * @return the list of IntegrityAuditEntity
+ * @throws DbDaoTransactionException if an error occurs
+ */
+ @SuppressWarnings("unchecked")
+ public List<IntegrityAuditEntity> getIntegrityAuditEntities(String persistenceUnit, String nodeType)
+ throws DbDaoTransactionException {
+ logger.debug("getIntegrityAuditEntities: Entering, persistenceUnit=" + persistenceUnit + ",\n nodeType= "
+ + nodeType);
+ try {
+ EntityManager em = emf.createEntityManager();
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ et.begin();
+
+ // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not
+ // found, create a new entry
+ Query iaequery = em
+ .createQuery("Select i from IntegrityAuditEntity i where i.persistenceUnit=:pu and i.nodeType=:nt");
+ iaequery.setParameter("pu", persistenceUnit);
+ iaequery.setParameter("nt", nodeType);
+
+ List<IntegrityAuditEntity> iaeList = iaequery.getResultList();
+
+ // commit transaction
+ et.commit();
+ em.close();
+ logger.debug("getIntegrityAuditEntities: Exit, iaeList=" + iaeList);
+ return iaeList;
+ } catch (Exception e) {
+ String msg = "DbDAO: " + "getIntegrityAuditEntities() " + "ecountered a problem in execution: ";
+ logger.error(msg, e);
+ throw new DbDaoTransactionException(e);
+ }
+
+ }
+
+ /**
+ * getMyIntegrityAuditEntity() gets my IntegrityAuditEntity.
+ *
+ * @return the IntegrityAuditEntity
+ * @throws DbDaoTransactionException if an error occurs
+ */
+ public IntegrityAuditEntity getMyIntegrityAuditEntity() throws DbDaoTransactionException {
+ try {
+ EntityManager em = emf.createEntityManager();
+
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ et.begin();
+
+ // if IntegrityAuditEntity entry exists for resourceName and PU, retrieve it
+ Query iaequery = em.createQuery(
+ "Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", this.resourceName);
+ iaequery.setParameter("pu", this.persistenceUnit);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList = iaequery.getResultList();
+ IntegrityAuditEntity iae = null;
+
+ if (!iaeList.isEmpty()) {
+ // ignores multiple results
+ iae = (IntegrityAuditEntity) iaeList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(iae);
+ logger.info("Resource: " + this.resourceName + " with PersistenceUnit: " + this.persistenceUnit
+ + " exists");
+ } else {
+ // If it does not exist, log an error
+ logger.error("Attempting to setLastUpdated" + " on an entry that does not exist:" + " resource "
+ + this.resourceName + " with PersistenceUnit: " + this.persistenceUnit);
+ }
+
+ // close the transaction
+ et.commit();
+ // close the EntityManager
+ em.close();
+
+ return iae;
+ } catch (Exception e) {
+ String msg = "DbDAO: " + "setLastUpdated() " + "ecountered a problem in execution: ";
+ logger.error(msg + e);
+ throw new DbDaoTransactionException(e);
+ }
+ }
+
+
+ /**
+ * getIntegrityAuditEntity() gets the IntegrityAuditEntity with a particular ID.
+ *
+ * @param id the ID
+ * @return the IntegrityAuditEntity
+ * @throws DbDaoTransactionException if an error occurs
+ */
+ public IntegrityAuditEntity getIntegrityAuditEntity(long id) throws DbDaoTransactionException {
+ try {
+ EntityManager em = emf.createEntityManager();
+
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ et.begin();
+
+ IntegrityAuditEntity iae = em.find(IntegrityAuditEntity.class, id);
+
+ et.commit();
+ em.close();
+
+ return iae;
+ } catch (Exception e) {
+ String msg = "DbDAO: " + "getIntegrityAuditEntity() " + "ecountered a problem in execution: ";
+ logger.error(msg + e);
+ throw new DbDaoTransactionException(e);
+ }
+ }
+
+ /**
+ * getPersistenceClassNames() gets all the persistence class names.
+ *
+ * @return the persistence class names
+ */
+ public Set<String> getPersistenceClassNames() {
+ logger.debug("DbDAO: getPersistenceClassNames() entry");
+ HashSet<String> returnList = new HashSet<>();
+ final Metamodel mm = emf.getMetamodel();
+ logger.debug("\n" + persistenceUnit + " persistence unit classes:");
+ for (final ManagedType<?> managedType : mm.getManagedTypes()) {
+ Class<?> clazz = managedType.getJavaType();
+ logger.debug(" " + clazz.getSimpleName());
+ returnList.add(clazz.getName()); // the full class name needed to make a query using jpa
+ }
+ logger.debug("DbDAO: getPersistenceClassNames() exit");
+ return returnList;
+ }
+
+ /**
+ * Register the IntegrityAudit instance.
+ *
+ * @param altDbUrl alternate DB URL to be placed into the record, or {@code null} to use the
+ * default
+ */
+ private void register(String altDbUrl) throws DbDaoTransactionException {
+ try {
+ EntityManager em = emf.createEntityManager();
+
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ et.begin();
+
+ // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not
+ // found, create a new entry
+ Query iaequery = em.createQuery(
+ "Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", this.resourceName);
+ iaequery.setParameter("pu", this.persistenceUnit);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList = iaequery.getResultList();
+ IntegrityAuditEntity iae;
+
+ // If it already exists, we just want to update the properties and lastUpdated date
+ if (!iaeList.isEmpty()) {
+ // ignores multiple results
+ iae = (IntegrityAuditEntity) iaeList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(iae);
+ logger.info("Resource: " + this.resourceName + " with PersistenceUnit: " + this.persistenceUnit
+ + " exists and entry be updated");
+ } else {
+ // If it does not exist, we also must add teh resourceName, persistenceUnit and
+ // designated values
+ logger.info("Adding resource " + resourceName + " with PersistenceUnit: " + this.persistenceUnit
+ + " to IntegrityAuditEntity table");
+ iae = new IntegrityAuditEntity();
+ iae.setResourceName(this.resourceName);
+ iae.setPersistenceUnit(this.persistenceUnit);
+ iae.setDesignated(false);
+ }
+ // update/set properties in entry
+ iae.setSite(this.siteName);
+ iae.setNodeType(this.nodeType);
+ iae.setJdbcDriver(this.dbDriver);
+ iae.setJdbcPassword(properties.getProperty(IntegrityAuditProperties.DB_PWD).trim());
+ iae.setJdbcUrl(altDbUrl == null ? this.dbUrl : altDbUrl);
+ iae.setJdbcUser(dbUser);
+
+ em.persist(iae);
+ // flush to the DB
+ em.flush();
+
+ // commit transaction
+ et.commit();
+ em.close();
+ } catch (Exception e) {
+ String msg = "DbDAO: " + "register() " + "encountered a problem in execution: ";
+ logger.error(msg + e);
+ throw new DbDaoTransactionException(e);
+ }
+
+ }
+
+ public void setDesignated(boolean designated) throws DbDaoTransactionException {
+ setDesignated(this.resourceName, this.persistenceUnit, designated);
+ }
+
+ /**
+ * Set designated.
+ *
+ * @param resourceName the resource name
+ * @param persistenceUnit the persistence unit
+ * @param desig true if is designated
+ * @throws DbDaoTransactionException if an error occurs
+ */
+ public void setDesignated(String resourceName, String persistenceUnit, boolean desig)
+ throws DbDaoTransactionException {
+ logger.debug("setDesignated: enter, resourceName: " + resourceName + ", persistenceUnit: " + persistenceUnit
+ + ", designated: " + desig);
+ try {
+
+ EntityManager em = emf.createEntityManager();
+
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ et.begin();
+
+ // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not
+ // found, create a new entry
+ Query iaequery = em.createQuery(
+ "Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", resourceName);
+ iaequery.setParameter("pu", persistenceUnit);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList = iaequery.getResultList();
+ IntegrityAuditEntity iae;
+
+ if (!iaeList.isEmpty()) {
+ // ignores multiple results
+ iae = (IntegrityAuditEntity) iaeList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(iae);
+ logger.info("Resource: " + resourceName + " with PersistenceUnit: " + persistenceUnit
+ + " exists and designated be updated");
+ iae.setDesignated(desig);
+
+ em.persist(iae);
+ // flush to the DB
+ em.flush();
+ } else {
+ // If it does not exist, log an error
+ logger.error("Attempting to setDesignated(" + desig + ") on an entry that does not exist:"
+ + " resource " + resourceName + " with PersistenceUnit: " + persistenceUnit);
+ }
+
+ // close the transaction
+ et.commit();
+ // close the EntityManager
+ em.close();
+ } catch (Exception e) {
+ String msg = "DbDAO: " + "setDesignated() " + "ecountered a problem in execution: ";
+ logger.error(msg + e);
+ throw new DbDaoTransactionException(e);
+ }
+
+ }
+
+ /**
+ * Set last updated.
+ *
+ * @throws DbDaoTransactionException if an error occurs
+ */
+ public void setLastUpdated() throws DbDaoTransactionException {
+ logger.debug("setLastUpdated: enter, resourceName: " + this.resourceName + ", persistenceUnit: "
+ + this.persistenceUnit);
+ try {
+ EntityManager em = emf.createEntityManager();
+
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ et.begin();
+
+ // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not
+ // found, create a new entry
+ Query iaequery = em.createQuery(
+ "Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", this.resourceName);
+ iaequery.setParameter("pu", this.persistenceUnit);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList = iaequery.getResultList();
+ IntegrityAuditEntity iae;
+
+ if (!iaeList.isEmpty()) {
+ // ignores multiple results
+ iae = (IntegrityAuditEntity) iaeList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(iae);
+ logger.info("Resource: " + this.resourceName + " with PersistenceUnit: " + this.persistenceUnit
+ + " exists and lastUpdated be updated");
+ iae.setLastUpdated(new Date());
+
+ em.persist(iae);
+ // flush to the DB
+ em.flush();
+ } else {
+ // If it does not exist, log an error
+ logger.error("Attempting to setLastUpdated" + " on an entry that does not exist:" + " resource "
+ + this.resourceName + " with PersistenceUnit: " + this.persistenceUnit);
+ }
+
+ // close the transaction
+ et.commit();
+ // close the EntityManager
+ em.close();
+ } catch (Exception e) {
+ String msg = "DbDAO: " + "setLastUpdated() " + "ecountered a problem in execution: ";
+ logger.error(msg + e);
+ throw new DbDaoTransactionException(e);
+ }
+
+ }
+
+ /**
+ * Normally this method should only be used in a JUnit test environment. Manually deletes all
+ * PDP records in droolspdpentity table.
+ */
+ public int deleteAllIntegrityAuditEntities() throws DbDaoTransactionException {
+
+ try {
+
+ if (!IntegrityAudit.isUnitTesting()) {
+ String msg = "DbDAO: " + "deleteAllIntegrityAuditEntities() "
+ + "should only be invoked during JUnit testing";
+ logger.error(msg);
+ throw new DbDaoTransactionException(msg);
+ }
+
+ EntityManager em = emf.createEntityManager();
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ et.begin();
+
+ // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not
+ // found, create a new entry
+ Query iaequery = em.createQuery("Delete from IntegrityAuditEntity");
+
+ int returnCode = iaequery.executeUpdate();
+
+ // commit transaction
+ et.commit();
+ em.close();
+
+ logger.info("deleteAllIntegrityAuditEntities: returnCode=" + returnCode);
+
+ return returnCode;
+
+ } catch (Exception e) {
+ String msg = "DbDAO: " + "deleteAllIntegrityAuditEntities() " + "encountered a problem in execution: ";
+ logger.error(msg + e);
+ throw new DbDaoTransactionException(e);
+ }
+
+ }
+
+ /**
+ * Changes designation to specified resourceName
+ *
+ * <p>static lock object in conjunction with synchronized keyword ensures that designation
+ * changes are done serially within a resource. I.e. static lock ensures that multiple
+ * instantiations of DbDAO don't interleave changeDesignated() invocations and potentially
+ * produce simultaneous designations.
+ *
+ * <p>Optimistic locking (the default, versus pessimistic) is sufficient to avoid simultaneous
+ * designations from interleaved changeDesignated() invocations from different resources
+ * (entities), because it prevents "dirty" and "non-repeatable" reads.
+ *
+ * <p>See http://www.objectdb.com/api/java/jpa/LockModeType
+ *
+ * <p>and
+ *
+ * <p>http://stackoverflow.com/questions/2120248/how-to-synchronize-a-static-
+ * variable-among-threads-running-different-instances-o
+ */
+ public void changeDesignated(String resourceName, String persistenceUnit, String nodeType)
+ throws DbDaoTransactionException {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("changeDesignated: Entering, resourceName=" + resourceName + ", persistenceUnit="
+ + persistenceUnit + ", nodeType=" + nodeType);
+ }
+
+ long startTime = System.currentTimeMillis();
+
+ synchronized (lock) {
+
+ EntityManager em = null;
+ try {
+
+ em = emf.createEntityManager();
+ em.getTransaction().begin();
+
+ /*
+ * Define query
+ */
+ Query query = em.createQuery(
+ "Select i from IntegrityAuditEntity i where i.persistenceUnit=:pu and i.nodeType=:nt");
+ query.setParameter("pu", persistenceUnit);
+ query.setParameter("nt", nodeType);
+
+ /*
+ * Execute query using pessimistic write lock. This ensures that if anyone else is
+ * currently reading the records we'll throw a LockTimeoutException.
+ */
+ @SuppressWarnings("unchecked")
+ List<IntegrityAuditEntity> integrityAuditEntityList = query.getResultList();
+ for (Object o : integrityAuditEntityList) {
+ if (o instanceof IntegrityAuditEntity) {
+ IntegrityAuditEntity integrityAuditEntity = (IntegrityAuditEntity) o;
+ if (integrityAuditEntity.getResourceName().equals(resourceName)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("changeDesignated: Designating resourceName="
+ + integrityAuditEntity.getResourceName());
+ }
+ integrityAuditEntity.setDesignated(true);
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("changeDesignated: Removing designation from resourceName="
+ + integrityAuditEntity.getResourceName());
+ }
+ integrityAuditEntity.setDesignated(false);
+ }
+ }
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("changeDesignated: Committing designation to resourceName=" + resourceName);
+ }
+ em.getTransaction().commit();
+
+ /*
+ * If we get a LockTimeoutException, no harm done really. We'll probably be
+ * successful on the next attempt. The odds of another DbDAO instance on this entity
+ * or another entity attempting a simultaneous IntegrityAuditEntity table
+ * read/update are pretty slim (we're only in this method for two or three
+ * milliseconds)
+ */
+ } catch (LockTimeoutException e) {
+ if (em != null) {
+ em.getTransaction().rollback();
+
+ String msg = "DbDAO: " + "changeDesignated() " + "caught LockTimeoutException, message="
+ + e.getMessage();
+ logger.error(msg + e);
+ throw new DbDaoTransactionException(msg, e);
+ } else {
+ String msg = "DbDAO: " + "changeDesignated() " + "caught LockTimeoutException, message="
+ + e.getMessage() + ". Error rolling back transaction.";
+ logger.error(msg + e);
+ throw new DbDaoTransactionException(msg, e);
+ }
+ } catch (Exception e) {
+ if (em != null) {
+ em.getTransaction().rollback();
+
+ String msg = "DbDAO: " + "changeDesignated() " + "caught Exception, message=" + e.getMessage();
+ logger.error(msg + e);
+ throw new DbDaoTransactionException(msg, e);
+ } else {
+ String msg = "DbDAO: " + "changeDesignated() " + "caught LockTimeoutException, message="
+ + e.getMessage() + ". Error rolling back transaction.";
+ logger.error(msg + e);
+ throw new DbDaoTransactionException(msg, e);
+ }
+ }
+
+ } // end synchronized block
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("changeDesignated: Exiting; time expended=" + (System.currentTimeMillis() - startTime) + "ms");
+ }
+
+ }
}
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDaoTransactionException.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDaoTransactionException.java
index 72716279..dc1c6f14 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDaoTransactionException.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDaoTransactionException.java
@@ -21,18 +21,21 @@
package org.onap.policy.common.ia;
public class DbDaoTransactionException extends IntegrityAuditException {
- private static final long serialVersionUID = 1L;
- public DbDaoTransactionException() {
- super();
- }
- public DbDaoTransactionException(String message) {
- super(message);
- }
+ private static final long serialVersionUID = 1L;
- public DbDaoTransactionException(Throwable cause) {
- super(cause);
- }
- public DbDaoTransactionException(String message, Throwable cause) {
- super(message, cause);
- }
+ public DbDaoTransactionException() {
+ super();
+ }
+
+ public DbDaoTransactionException(String message) {
+ super(message);
+ }
+
+ public DbDaoTransactionException(Throwable cause) {
+ super(cause);
+ }
+
+ public DbDaoTransactionException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java
index cab08610..9abdbe52 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java
@@ -26,275 +26,277 @@ import java.util.concurrent.CountDownLatch;
import org.onap.policy.common.ia.IntegrityAuditProperties.NodeTypeEnum;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.common.logging.flexlogger.Logger;
/**
- * class IntegrityAudit
- * Audits all persisted entities for all resource clusters for all sites and logs any anomalies.
+ * class IntegrityAudit Audits all persisted entities for all resource clusters for all sites and
+ * logs any anomalies.
*/
public class IntegrityAudit {
-
- private static final Logger logger = FlexLogger.getLogger(IntegrityAudit.class);
-
- private static boolean isUnitTesting;
- private boolean isThreadInitialized = false;
-
- AuditThread auditThread = null;
-
- private String persistenceUnit;
- private Properties properties;
- private String resourceName;
-
-
- /*
- * This is the audit period in milliseconds. For example, if it had a value of 3600000, the audit
- * can only run once per hour. If it has a value of 6000, it can run once per minute.
- *
- * Values:
- * integrityAuditPeriodMillis < 0 (negative number) indicates the audit is off
- * integrityAuditPeriodMillis == 0 indicates the audit is to run continuously
- * integrityAuditPeriodMillis > 0 indicates the audit is to run at most once during the indicated period
- *
- */
- private int integrityAuditPeriodMillis;
-
- /**
- * IntegrityAudit constructor
- * @param resourceName
- * @param persistenceUnit
- * @param properties
- * @throws IntegrityAuditException
- */
- public IntegrityAudit(String resourceName, String persistenceUnit, Properties properties) throws IntegrityAuditException {
-
- logger.info("Constructor: Entering and checking for nulls");
- StringBuilder parmList = new StringBuilder();
- if (parmsAreBad(resourceName, persistenceUnit, properties, parmList)) {
- logger.error("Constructor: Parms contain nulls; cannot run audit for resourceName="
- + resourceName + ", persistenceUnit=" + persistenceUnit
- + ", bad parameters: " + parmList);
- throw new IntegrityAuditException(
- "Constructor: Parms contain nulls; cannot run audit for resourceName="
- + resourceName + ", persistenceUnit="
- + persistenceUnit
- + ", bad parameters: " + parmList);
- }
-
- this.persistenceUnit = persistenceUnit;
- this.properties = properties;
- this.resourceName = resourceName;
-
- if(properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS) != null){ //It is allowed to be null
- this.integrityAuditPeriodMillis= 1000 * Integer.parseInt(properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS).trim());
- } else if(properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_MILLISECONDS) != null){ //It is allowed to be null
- this.integrityAuditPeriodMillis= Integer.parseInt(properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_MILLISECONDS).trim());
- } else{
- //If it is null, set it to the default value
- this.integrityAuditPeriodMillis = 1000 * IntegrityAuditProperties.DEFAULT_AUDIT_PERIOD_SECONDS;
- }
- logger.info("Constructor: Exiting");
-
- }
-
- /**
- * Used during JUnit testing by AuditPeriodTest.java
- */
- public int getIntegrityAuditPeriodSeconds() {
- return (integrityAuditPeriodMillis / 1000);
- }
-
- /**
- * Determine if the nodeType conforms to the required node types
- */
- public static boolean isNodeTypeEnum(String nt) {
- for (NodeTypeEnum n : NodeTypeEnum.values()) {
- if (n.toString().equals(nt)) {
- return true;
- }
- }
- return false;
- }
-
-
- /**
- * Makes sure we don't try to run the audit with bad parameters.
- */
- public static boolean parmsAreBad(String resourceName, String persistenceUnit,
- Properties properties, StringBuilder badparams) {
-
- boolean parmsAreBad = false;
-
- if(resourceName == null || resourceName.isEmpty()){
- badparams.append("resourceName ");
- parmsAreBad = true;
- }
-
- if(persistenceUnit == null || persistenceUnit.isEmpty()){
- badparams.append("persistenceUnit ");
- parmsAreBad = true;
- }
-
- if(properties == null || properties.isEmpty()){
- badparams.append("properties ");
- parmsAreBad = true;
- }
- else{
- String dbDriver = properties.getProperty(IntegrityAuditProperties.DB_DRIVER);
- if(dbDriver == null || dbDriver.isEmpty()){
- badparams.append("dbDriver ");
- parmsAreBad = true;
- }
-
- String dbUrl = properties.getProperty(IntegrityAuditProperties.DB_URL);
- if(dbUrl == null || dbUrl.isEmpty()){
- badparams.append("dbUrl ");
- parmsAreBad = true;
- }
-
- String dbUser = properties.getProperty(IntegrityAuditProperties.DB_USER);
- if(dbUser == null || dbUser.isEmpty()){
- badparams.append("dbUser ");
- parmsAreBad = true;
- }
-
- String dbPwd = properties.getProperty(IntegrityAuditProperties.DB_PWD);
- if(dbPwd == null){ //may be empty
- badparams.append("dbPwd ");
- parmsAreBad = true;
- }
-
- String siteName = properties.getProperty(IntegrityAuditProperties.SITE_NAME);
- if(siteName == null || siteName.isEmpty()){
- badparams.append("siteName ");
- parmsAreBad = true;
- }
-
- String nodeType = properties.getProperty(IntegrityAuditProperties.NODE_TYPE);
- if(nodeType == null || nodeType.isEmpty()){
- badparams.append("nodeType ");
- parmsAreBad = true;
- } else {
- nodeType = nodeType.trim();
- if (!isNodeTypeEnum(nodeType)) {
- String nodetypes = "nodeType must be one of[";
- for (NodeTypeEnum n : NodeTypeEnum.values()) {
- nodetypes = nodetypes.concat(n.toString() + " ");
- }
- badparams.append(nodetypes + "] ");
- parmsAreBad = true;
- }
- }
- if(properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS) != null){ //It is allowed to be null
- try{
- Integer.parseInt(properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS).trim());
- }catch(NumberFormatException nfe){
- badparams.append(", auditPeriodSeconds="
- + properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS).trim());
- parmsAreBad = true;
- }
- }
- else if(properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_MILLISECONDS) != null){ //It is allowed to be null
- try{
- Integer.parseInt(properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_MILLISECONDS).trim());
- }catch(NumberFormatException nfe){
- badparams.append(", auditPeriodMilliSeconds="
- + properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_MILLISECONDS).trim());
- parmsAreBad = true;
- }
- }
- } // End else
- logger.debug("parmsAreBad: exit:"
- + "\nresourceName: " + resourceName
- + "\npersistenceUnit: " + persistenceUnit
- + "\nproperties: " + properties);
-
- return parmsAreBad;
- }
- /**
- * Starts the audit thread
- * @throws IntegrityAuditException
- */
- public void startAuditThread() throws IntegrityAuditException {
- startAuditThread(null);
- }
- /**
- * Starts the audit thread
- * @param queue
- * @return {@code true} if the thread was started, {@code false} otherwise
- * @throws IntegrityAuditException
- */
- protected boolean startAuditThread(BlockingQueue<CountDownLatch> queue) throws IntegrityAuditException {
-
- logger.info("startAuditThread: Entering");
-
- boolean success = false;
-
- if (integrityAuditPeriodMillis >= 0) {
- this.auditThread = new AuditThread(this.resourceName,
- this.persistenceUnit, this.properties,
- integrityAuditPeriodMillis, this, queue);
- logger.info("startAuditThread: Audit started and will run every "
- + integrityAuditPeriodMillis/1000 + " seconds");
- this.auditThread.start();
- success = true;
- } else {
- logger.info("startAuditThread: Suppressing integrity audit, integrityAuditPeriodSeconds="
- + integrityAuditPeriodMillis/1000);
- }
-
- logger.info("startAuditThread: Exiting");
-
- return success;
- }
- /**
- * Stops the audit thread
- */
- public void stopAuditThread() {
-
- logger.info("stopAuditThread: Entering");
-
- if (this.auditThread != null) {
- this.auditThread.interrupt();
- } else {
- logger.info("stopAuditThread: auditThread never instantiated; no need to interrupt");
- }
-
- logger.info("stopAuditThread: Exiting");
- }
-
- public boolean isThreadInitialized() {
- return isThreadInitialized;
- }
-
- public void setThreadInitialized(boolean isThreadInitialized) {
- logger.info("setThreadInitialized: Setting isThreadInitialized=" + isThreadInitialized);
- this.isThreadInitialized = isThreadInitialized;
- }
-
- public static boolean isUnitTesting() {
- return isUnitTesting;
- }
-
- public static void setUnitTesting(boolean isUnitTesting) {
- IntegrityAudit.isUnitTesting = isUnitTesting;
- }
-
- /**
- * Waits a bit for the AuditThread to complete. Used by JUnit tests.
- *
- * @param twaitms
- * wait time, in milliseconds
- * @return {@code true} if the thread stopped within the given time,
- * {@code false} otherwise
- * @throws InterruptedException
- */
- protected boolean joinAuditThread(long twaitms) throws InterruptedException {
- if(this.auditThread == null) {
- return true;
-
- } else {
- this.auditThread.join(twaitms);
- return ! this.auditThread.isAlive();
- }
- }
+
+ private static final Logger logger = FlexLogger.getLogger(IntegrityAudit.class);
+
+ private static boolean isUnitTesting;
+ private boolean isThreadInitialized = false;
+
+ AuditThread auditThread = null;
+
+ private String persistenceUnit;
+ private Properties properties;
+ private String resourceName;
+
+
+ /*
+ * This is the audit period in milliseconds. For example, if it had a value of 3600000, the
+ * audit can only run once per hour. If it has a value of 6000, it can run once per minute.
+ *
+ * Values: integrityAuditPeriodMillis < 0 (negative number) indicates the audit is off
+ * integrityAuditPeriodMillis == 0 indicates the audit is to run continuously
+ * integrityAuditPeriodMillis > 0 indicates the audit is to run at most once during the
+ * indicated period
+ *
+ */
+ private int integrityAuditPeriodMillis;
+
+ /**
+ * IntegrityAudit constructor.
+ *
+ * @param resourceName the resource name
+ * @param persistenceUnit the persistence unit
+ * @param properties the properties
+ * @throws IntegrityAuditException if an error occurs
+ */
+ public IntegrityAudit(String resourceName, String persistenceUnit, Properties properties)
+ throws IntegrityAuditException {
+
+ logger.info("Constructor: Entering and checking for nulls");
+ StringBuilder parmList = new StringBuilder();
+ if (parmsAreBad(resourceName, persistenceUnit, properties, parmList)) {
+ logger.error("Constructor: Parms contain nulls; cannot run audit for resourceName=" + resourceName
+ + ", persistenceUnit=" + persistenceUnit + ", bad parameters: " + parmList);
+ throw new IntegrityAuditException("Constructor: Parms contain nulls; cannot run audit for resourceName="
+ + resourceName + ", persistenceUnit=" + persistenceUnit + ", bad parameters: " + parmList);
+ }
+
+ this.persistenceUnit = persistenceUnit;
+ this.properties = properties;
+ this.resourceName = resourceName;
+
+ // IntegrityAuditProperties.AUDIT_PERIOD_SECONDS and
+ // IntegrityAuditProperties.AUDIT_PERIOD_MILLISECONDS are allowed to be null
+ if (properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS) != null) {
+ this.integrityAuditPeriodMillis = 1000
+ * Integer.parseInt(properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS).trim());
+ } else if (properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_MILLISECONDS) != null) {
+ this.integrityAuditPeriodMillis =
+ Integer.parseInt(properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_MILLISECONDS).trim());
+ } else {
+ // If it is null, set it to the default value
+ this.integrityAuditPeriodMillis = 1000 * IntegrityAuditProperties.DEFAULT_AUDIT_PERIOD_SECONDS;
+ }
+ logger.info("Constructor: Exiting");
+
+ }
+
+ /**
+ * Used during JUnit testing by AuditPeriodTest.java
+ */
+ public int getIntegrityAuditPeriodSeconds() {
+ return (integrityAuditPeriodMillis / 1000);
+ }
+
+ /**
+ * Determine if the nodeType conforms to the required node types.
+ */
+ public static boolean isNodeTypeEnum(String nt) {
+ for (NodeTypeEnum n : NodeTypeEnum.values()) {
+ if (n.toString().equals(nt)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * Makes sure we don't try to run the audit with bad parameters.
+ */
+ public static boolean parmsAreBad(String resourceName, String persistenceUnit, Properties properties,
+ StringBuilder badparams) {
+
+ boolean parmsAreBad = false;
+
+ if (resourceName == null || resourceName.isEmpty()) {
+ badparams.append("resourceName ");
+ parmsAreBad = true;
+ }
+
+ if (persistenceUnit == null || persistenceUnit.isEmpty()) {
+ badparams.append("persistenceUnit ");
+ parmsAreBad = true;
+ }
+
+ if (properties == null || properties.isEmpty()) {
+ badparams.append("properties ");
+ parmsAreBad = true;
+ } else {
+ String dbDriver = properties.getProperty(IntegrityAuditProperties.DB_DRIVER);
+ if (dbDriver == null || dbDriver.isEmpty()) {
+ badparams.append("dbDriver ");
+ parmsAreBad = true;
+ }
+
+ String dbUrl = properties.getProperty(IntegrityAuditProperties.DB_URL);
+ if (dbUrl == null || dbUrl.isEmpty()) {
+ badparams.append("dbUrl ");
+ parmsAreBad = true;
+ }
+
+ String dbUser = properties.getProperty(IntegrityAuditProperties.DB_USER);
+ if (dbUser == null || dbUser.isEmpty()) {
+ badparams.append("dbUser ");
+ parmsAreBad = true;
+ }
+
+ String dbPwd = properties.getProperty(IntegrityAuditProperties.DB_PWD);
+ if (dbPwd == null) { // may be empty
+ badparams.append("dbPwd ");
+ parmsAreBad = true;
+ }
+
+ String siteName = properties.getProperty(IntegrityAuditProperties.SITE_NAME);
+ if (siteName == null || siteName.isEmpty()) {
+ badparams.append("siteName ");
+ parmsAreBad = true;
+ }
+
+ String nodeType = properties.getProperty(IntegrityAuditProperties.NODE_TYPE);
+ if (nodeType == null || nodeType.isEmpty()) {
+ badparams.append("nodeType ");
+ parmsAreBad = true;
+ } else {
+ nodeType = nodeType.trim();
+ if (!isNodeTypeEnum(nodeType)) {
+ String nodetypes = "nodeType must be one of[";
+ for (NodeTypeEnum n : NodeTypeEnum.values()) {
+ nodetypes = nodetypes.concat(n.toString() + " ");
+ }
+ badparams.append(nodetypes + "] ");
+ parmsAreBad = true;
+ }
+ }
+ // IntegrityAuditProperties.AUDIT_PERIOD_SECONDS and
+ // IntegrityAuditProperties.AUDIT_PERIOD_MILLISECONDS are allowed to be null
+ if (properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS) != null) {
+ try {
+ Integer.parseInt(properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS).trim());
+ } catch (NumberFormatException nfe) {
+ badparams.append(", auditPeriodSeconds="
+ + properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS).trim());
+ parmsAreBad = true;
+ }
+ } else if (properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_MILLISECONDS) != null) {
+ try {
+ Integer.parseInt(properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_MILLISECONDS).trim());
+ } catch (NumberFormatException nfe) {
+ badparams.append(", auditPeriodMilliSeconds="
+ + properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_MILLISECONDS).trim());
+ parmsAreBad = true;
+ }
+ }
+ } // End else
+ logger.debug("parmsAreBad: exit:" + "\nresourceName: " + resourceName + "\npersistenceUnit: " + persistenceUnit
+ + "\nproperties: " + properties);
+
+ return parmsAreBad;
+ }
+
+ /**
+ * Starts the audit thread.
+ *
+ * @throws IntegrityAuditException if an error occurs
+ */
+ public void startAuditThread() throws IntegrityAuditException {
+ startAuditThread(null);
+ }
+
+ /**
+ * Starts the audit thread.
+ *
+ * @param queue the queue
+ * @return {@code true} if the thread was started, {@code false} otherwise
+ * @throws IntegrityAuditException if an error occurs
+ */
+ protected boolean startAuditThread(BlockingQueue<CountDownLatch> queue) throws IntegrityAuditException {
+
+ logger.info("startAuditThread: Entering");
+
+ boolean success = false;
+
+ if (integrityAuditPeriodMillis >= 0) {
+ this.auditThread = new AuditThread(this.resourceName, this.persistenceUnit, this.properties,
+ integrityAuditPeriodMillis, this, queue);
+ logger.info("startAuditThread: Audit started and will run every " + integrityAuditPeriodMillis / 1000
+ + " seconds");
+ this.auditThread.start();
+ success = true;
+ } else {
+ logger.info("startAuditThread: Suppressing integrity audit, integrityAuditPeriodSeconds="
+ + integrityAuditPeriodMillis / 1000);
+ }
+
+ logger.info("startAuditThread: Exiting");
+
+ return success;
+ }
+
+ /**
+ * Stops the audit thread.
+ */
+ public void stopAuditThread() {
+
+ logger.info("stopAuditThread: Entering");
+
+ if (this.auditThread != null) {
+ this.auditThread.interrupt();
+ } else {
+ logger.info("stopAuditThread: auditThread never instantiated; no need to interrupt");
+ }
+
+ logger.info("stopAuditThread: Exiting");
+ }
+
+ public boolean isThreadInitialized() {
+ return isThreadInitialized;
+ }
+
+ public void setThreadInitialized(boolean isThreadInitialized) {
+ logger.info("setThreadInitialized: Setting isThreadInitialized=" + isThreadInitialized);
+ this.isThreadInitialized = isThreadInitialized;
+ }
+
+ public static boolean isUnitTesting() {
+ return isUnitTesting;
+ }
+
+ public static void setUnitTesting(boolean isUnitTesting) {
+ IntegrityAudit.isUnitTesting = isUnitTesting;
+ }
+
+ /**
+ * Waits a bit for the AuditThread to complete. Used by JUnit tests.
+ *
+ * @param twaitms wait time, in milliseconds
+ * @return {@code true} if the thread stopped within the given time, {@code false} otherwise
+ * @throws InterruptedException if the thread is interrupted
+ */
+ protected boolean joinAuditThread(long twaitms) throws InterruptedException {
+ if (this.auditThread == null) {
+ return true;
+
+ } else {
+ this.auditThread.join(twaitms);
+ return !this.auditThread.isAlive();
+ }
+ }
}
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditException.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditException.java
index a62c837c..81e8b90c 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditException.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditException.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * 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,19 +20,22 @@
package org.onap.policy.common.ia;
-public class IntegrityAuditException extends Exception{
- private static final long serialVersionUID = 1L;
- public IntegrityAuditException() {
- super();
- }
- public IntegrityAuditException(String message) {
- super(message);
- }
+public class IntegrityAuditException extends Exception {
+ private static final long serialVersionUID = 1L;
- public IntegrityAuditException(Throwable cause) {
- super(cause);
- }
- public IntegrityAuditException(String message, Throwable cause) {
- super(message, cause);
- }
+ public IntegrityAuditException() {
+ super();
+ }
+
+ public IntegrityAuditException(String message) {
+ super(message);
+ }
+
+ public IntegrityAuditException(Throwable cause) {
+ super(cause);
+ }
+
+ public IntegrityAuditException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java
index b8db3ac2..2708c090 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java
@@ -22,34 +22,26 @@ package org.onap.policy.common.ia;
public class IntegrityAuditProperties {
- public static final int DEFAULT_AUDIT_PERIOD_SECONDS = -1; // Audit does not run
-
- 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";
- public static final String AUDIT_PERIOD_SECONDS = "integrity_audit_period_seconds";
- public static final String AUDIT_PERIOD_MILLISECONDS = "integrity_audit_period_milliseconds";
-
-
- public static final String SITE_NAME = "site_name";
- public static final String NODE_TYPE = "node_type";
-
- public enum NodeTypeEnum {
- pdp_xacml,
- pdp_drools,
- pap,
- pap_admin,
- logparser,
- brms_gateway,
- astra_gateway,
- elk_server,
- pypdp
-
- }
-
- private IntegrityAuditProperties() {
-
- }
-
+ public static final int DEFAULT_AUDIT_PERIOD_SECONDS = -1; // Audit does not run
+
+ 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";
+ public static final String AUDIT_PERIOD_SECONDS = "integrity_audit_period_seconds";
+ public static final String AUDIT_PERIOD_MILLISECONDS = "integrity_audit_period_milliseconds";
+
+
+ public static final String SITE_NAME = "site_name";
+ public static final String NODE_TYPE = "node_type";
+
+ public enum NodeTypeEnum {
+ pdp_xacml, pdp_drools, pap, pap_admin, logparser, brms_gateway, astra_gateway, elk_server, pypdp
+
+ }
+
+ private IntegrityAuditProperties() {
+
+ }
+
}
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditPropertiesException.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditPropertiesException.java
index 766268bc..d3c92fa5 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditPropertiesException.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditPropertiesException.java
@@ -21,18 +21,21 @@
package org.onap.policy.common.ia;
public class IntegrityAuditPropertiesException extends IntegrityAuditException {
- private static final long serialVersionUID = 1L;
- public IntegrityAuditPropertiesException() {
- super();
- }
- public IntegrityAuditPropertiesException(String message) {
- super(message);
- }
+ private static final long serialVersionUID = 1L;
- public IntegrityAuditPropertiesException(Throwable cause) {
- super(cause);
- }
- public IntegrityAuditPropertiesException(String message, Throwable cause) {
- super(message, cause);
- }
+ public IntegrityAuditPropertiesException() {
+ super();
+ }
+
+ public IntegrityAuditPropertiesException(String message) {
+ super(message);
+ }
+
+ public IntegrityAuditPropertiesException(Throwable cause) {
+ super(cause);
+ }
+
+ public IntegrityAuditPropertiesException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java
index da69f2de..23b90efc 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java
@@ -42,184 +42,185 @@ import javax.persistence.TemporalType;
*/
@Entity
-@Table(name="IntegrityAuditEntity")
-@NamedQueries({
- @NamedQuery(name=" IntegrityAuditEntity.findAll", query="SELECT e FROM IntegrityAuditEntity e "),
- @NamedQuery(name="IntegrityAuditEntity.deleteAll", query="DELETE FROM IntegrityAuditEntity WHERE 1=1")
-})
+@Table(name = "IntegrityAuditEntity")
+@NamedQueries({@NamedQuery(name = " IntegrityAuditEntity.findAll", query = "SELECT e FROM IntegrityAuditEntity e "),
+ @NamedQuery(name = "IntegrityAuditEntity.deleteAll", query = "DELETE FROM IntegrityAuditEntity WHERE 1=1")})
public class IntegrityAuditEntity implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private static boolean isUnitTesting;
-
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
- private long id;
-
- @Column(name="persistenceUnit", nullable=false)
- private String persistenceUnit;
-
- @Column(name="site", nullable=true)
- private String site;
-
- @Column(name="nodeType", nullable=true)
- private String nodeType;
-
- @Column(name="resourceName", nullable=false, unique=true)
- private String resourceName;
-
- @Column(name="designated", nullable=true)
- private boolean designated = false;
-
- @Column(name="jdbcDriver", nullable=false)
- private String jdbcDriver;
-
- @Column(name="jdbcUrl", nullable=false)
- private String jdbcUrl;
-
- @Column(name="jdbcUser", nullable=false)
- private String jdbcUser;
-
- @Column(name="jdbcPassword", nullable=false)
- private String jdbcPassword;
-
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="createdDate", updatable=true)
- private Date createdDate;
-
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="lastUpdated")
- private Date lastUpdated;
-
-
- public IntegrityAuditEntity() {
- // Empty constructor
- }
-
- @PrePersist
- public void prePersist() {
- Date date = new Date();
- this.createdDate = date;
- this.lastUpdated = date;
- }
-
- @PreUpdate
- public void preUpdate() {
- this.lastUpdated = new Date();
- }
-
- public long getId() {
- return id;
- }
-
- public String getPersistenceUnit() {
- return persistenceUnit;
- }
-
- public void setPersistenceUnit(String persistenceUnit) {
- this.persistenceUnit = persistenceUnit;
- }
-
- public String getSite() {
- return site;
- }
-
- public void setSite(String site) {
- this.site = site;
- }
-
- public String getNodeType() {
- return nodeType;
- }
-
- public void setNodeType(String nodeType) {
- this.nodeType = nodeType;
- }
-
- public String getResourceName() {
- return resourceName;
- }
-
- public void setResourceName(String resourceName) {
- this.resourceName = resourceName;
- }
-
- public boolean isDesignated() {
- return designated;
- }
-
- public void setDesignated(boolean designated) {
- this.designated = designated;
- }
-
- public String getJdbcDriver() {
- return jdbcDriver;
- }
-
- public void setJdbcDriver(String jdbcDriver) {
- this.jdbcDriver = jdbcDriver;
- }
-
- public String getJdbcUrl() {
- return jdbcUrl;
- }
-
- public void setJdbcUrl(String jdbcUrl) {
- this.jdbcUrl = jdbcUrl;
- }
-
- public String getJdbcUser() {
- return jdbcUser;
- }
-
- public void setJdbcUser(String jdbcUser) {
- this.jdbcUser = jdbcUser;
- }
-
- public String getJdbcPassword() {
- return jdbcPassword;
- }
-
- public void setJdbcPassword(String jdbcPassword) {
- this.jdbcPassword = jdbcPassword;
- }
-
- public Date getLastUpdated() {
- return lastUpdated;
- }
-
- public void setLastUpdated(Date lastUpdated) {
- this.lastUpdated = lastUpdated;
- }
-
- public Date getCreatedDate() {
- return createdDate;
- }
-
- public void setCreatedDate(Date created) {
- this.createdDate = created;
- }
-
- public static boolean isUnitTesting() {
- return isUnitTesting;
- }
-
- public static void setUnitTesting(boolean isUnitTesting) {
- IntegrityAuditEntity.isUnitTesting = isUnitTesting;
- }
-
- private void writeObject(ObjectOutputStream out) throws IOException {
- if(isUnitTesting()) {
- /*
- * Note: other fields may be added here, as long as the
- * created-date and last-updated date are not included.
- */
- out.writeObject(jdbcUrl);
-
- } else {
- out.defaultWriteObject();
- }
- }
+ private static final long serialVersionUID = 1L;
+
+ private static boolean isUnitTesting;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "id")
+ private long id;
+
+ @Column(name = "persistenceUnit", nullable = false)
+ private String persistenceUnit;
+
+ @Column(name = "site", nullable = true)
+ private String site;
+
+ @Column(name = "nodeType", nullable = true)
+ private String nodeType;
+
+ @Column(name = "resourceName", nullable = false, unique = true)
+ private String resourceName;
+
+ @Column(name = "designated", nullable = true)
+ private boolean designated = false;
+
+ @Column(name = "jdbcDriver", nullable = false)
+ private String jdbcDriver;
+
+ @Column(name = "jdbcUrl", nullable = false)
+ private String jdbcUrl;
+
+ @Column(name = "jdbcUser", nullable = false)
+ private String jdbcUser;
+
+ @Column(name = "jdbcPassword", nullable = false)
+ private String jdbcPassword;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "createdDate", updatable = true)
+ private Date createdDate;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "lastUpdated")
+ private Date lastUpdated;
+
+
+ public IntegrityAuditEntity() {
+ // Empty constructor
+ }
+
+ /**
+ * Pre persist.
+ */
+ @PrePersist
+ public void prePersist() {
+ Date date = new Date();
+ this.createdDate = date;
+ this.lastUpdated = date;
+ }
+
+ @PreUpdate
+ public void preUpdate() {
+ this.lastUpdated = new Date();
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public String getPersistenceUnit() {
+ return persistenceUnit;
+ }
+
+ public void setPersistenceUnit(String persistenceUnit) {
+ this.persistenceUnit = persistenceUnit;
+ }
+
+ public String getSite() {
+ return site;
+ }
+
+ public void setSite(String site) {
+ this.site = site;
+ }
+
+ public String getNodeType() {
+ return nodeType;
+ }
+
+ public void setNodeType(String nodeType) {
+ this.nodeType = nodeType;
+ }
+
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ public boolean isDesignated() {
+ return designated;
+ }
+
+ public void setDesignated(boolean designated) {
+ this.designated = designated;
+ }
+
+ public String getJdbcDriver() {
+ return jdbcDriver;
+ }
+
+ public void setJdbcDriver(String jdbcDriver) {
+ this.jdbcDriver = jdbcDriver;
+ }
+
+ public String getJdbcUrl() {
+ return jdbcUrl;
+ }
+
+ public void setJdbcUrl(String jdbcUrl) {
+ this.jdbcUrl = jdbcUrl;
+ }
+
+ public String getJdbcUser() {
+ return jdbcUser;
+ }
+
+ public void setJdbcUser(String jdbcUser) {
+ this.jdbcUser = jdbcUser;
+ }
+
+ public String getJdbcPassword() {
+ return jdbcPassword;
+ }
+
+ public void setJdbcPassword(String jdbcPassword) {
+ this.jdbcPassword = jdbcPassword;
+ }
+
+ public Date getLastUpdated() {
+ return lastUpdated;
+ }
+
+ public void setLastUpdated(Date lastUpdated) {
+ this.lastUpdated = lastUpdated;
+ }
+
+ public Date getCreatedDate() {
+ return createdDate;
+ }
+
+ public void setCreatedDate(Date created) {
+ this.createdDate = created;
+ }
+
+ public static boolean isUnitTesting() {
+ return isUnitTesting;
+ }
+
+ public static void setUnitTesting(boolean isUnitTesting) {
+ IntegrityAuditEntity.isUnitTesting = isUnitTesting;
+ }
+
+ private void writeObject(ObjectOutputStream out) throws IOException {
+ if (isUnitTesting()) {
+ /*
+ * Note: other fields may be added here, as long as the created-date and last-updated
+ * date are not included.
+ */
+ out.writeObject(jdbcUrl);
+
+ } else {
+ out.defaultWriteObject();
+ }
+ }
}
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/AuditPeriodTest.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/AuditPeriodTest.java
index b627977b..232468d6 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/AuditPeriodTest.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/AuditPeriodTest.java
@@ -44,217 +44,222 @@ import org.onap.policy.common.utils.test.log.logback.ExtractAppender;
*/
public class AuditPeriodTest extends IntegrityAuditTestBase {
- private static Logger logger = FlexLogger.getLogger(AuditPeriodTest.class);
+ private static Logger logger = FlexLogger.getLogger(AuditPeriodTest.class);
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- IntegrityAuditTestBase.setUpBeforeClass(DEFAULT_DB_URL_PREFIX + AuditPeriodTest.class.getSimpleName());
- }
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ IntegrityAuditTestBase.setUpBeforeClass(DEFAULT_DB_URL_PREFIX + AuditPeriodTest.class.getSimpleName());
+ }
- @AfterClass
- public static void tearDownAfterClass() {
- IntegrityAuditTestBase.tearDownAfterClass();
- }
+ @AfterClass
+ public static void tearDownAfterClass() {
+ IntegrityAuditTestBase.tearDownAfterClass();
+ }
- @Before
- public void setUp() {
- logger.info("setUp: Entering");
+ /**
+ * Set up for test case.
+ */
+ @Override
+ @Before
+ public void setUp() {
+ logger.info("setUp: Entering");
- super.setUp();
+ super.setUp();
- logger.info("setUp: Exiting");
+ logger.info("setUp: Exiting");
- }
+ }
- @After
- public void tearDown() {
- logger.info("tearDown: Entering");
+ /**
+ * Tear down after test cases.
+ */
+ @Override
+ @After
+ public void tearDown() {
+ logger.info("tearDown: Entering");
- super.tearDown();
+ super.tearDown();
- logger.info("tearDown: Exiting");
- }
+ logger.info("tearDown: Exiting");
+ }
- /*
- * Verifies (via log parsing) that when a negative audit period is
- * specified, the audit is suppressed.
- */
- @Test
- public void testNegativeAuditPeriod() throws Exception {
+ /*
+ * Verifies (via log parsing) that when a negative audit period is specified, the audit is
+ * suppressed.
+ */
+ @Test
+ public void testNegativeAuditPeriod() throws Exception {
- logger.info("testNegativeAuditPeriod: Entering");
+ logger.info("testNegativeAuditPeriod: Entering");
- properties.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "-1");
+ properties.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "-1");
- ExtractAppender logA = watch(debugLogger, "Suppressing integrity audit, integrityAuditPeriodSeconds=([^,]*)");
+ ExtractAppender logA = watch(debugLogger, "Suppressing integrity audit, integrityAuditPeriodSeconds=([^,]*)");
- MyIntegrityAudit integrityAudit = makeAuditor("pdp1", A_SEQ_PU);
+ MyIntegrityAudit integrityAudit = makeAuditor("pdp1", A_SEQ_PU);
- /*
- * Sleep long enough to allow
- *
- * 1) audit to immediately terminate.
- */
- waitThread(integrityAudit);
+ /*
+ * Sleep long enough to allow
+ *
+ * 1) audit to immediately terminate.
+ */
+ waitThread(integrityAudit);
- verifyItemsInLog(logA, "-1");
+ verifyItemsInLog(logA, "-1");
- logger.info("testNegativeAuditPeriod: Exiting");
-
- }
-
- /*
- * Verifies (via log parsing) that when an audit period of zero is
- * specified, the audit runs continuously, generating a number of sleep/wake
- * sequences in a short period of time (e.g. 100ms).
- */
- @Test
- public void testZeroAuditPeriod() throws Exception {
-
- logger.info("testZeroAuditPeriod: Entering");
-
- properties.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "0");
-
- ExtractAppender logA = watch(debugLogger, "[Aa]waking from (0ms) sleep");
-
- MyIntegrityAudit integrityAudit = makeAuditor("pdp1", A_SEQ_PU);
-
- /*
- * Wait for
- *
- * 1) audit to generate a bunch of sleep wake sequences.
- */
- String[] awakings = new String[10];
- for (int x = 0; x < awakings.length; ++x) {
- awakings[x] = "0ms";
- runAudit(integrityAudit);
- }
-
- // run a couple more audits
- runAudit(integrityAudit);
- runAudit(integrityAudit);
-
- /*
- * We should get at least 10 sleep/wake sequences.
- */
-
- verifyItemsInLog(logA, awakings);
-
- logger.info("testZeroAuditPeriod: Exiting");
-
- }
-
- /**
- * Verifies that when different audit periods are specified, there is an
- * appropriate interval between the audits.
- */
- @Test
- public void testLongAuditPeriod() throws Exception {
-
- logger.info("testLongAuditPeriod: Entering");
-
- testAuditPeriod(100);
- testAuditPeriod(200);
-
- logger.info("testLongAuditPeriod: Exiting");
- }
-
- /**
- * Verifies that audits actually take as long as expected, even with
- * multiple auditors running simultaneously.
- *
- * @param periodms
- * audit period, in milliseconds
- * @throws Exception
- * @throws InterruptedException
- */
- private void testAuditPeriod(long periodms) throws Exception, InterruptedException {
-
- properties.put(IntegrityAuditProperties.AUDIT_PERIOD_MILLISECONDS, String.valueOf(periodms));
-
- /*
- * Start several auditors.
- */
- MyIntegrityAudit[] ia = new MyIntegrityAudit[3];
- for (int x = 0; x < ia.length; ++x) {
- ia[x] = makeAuditor("pdp" + x, A_SEQ_PU);
- }
-
- /*
- * Run an audit on all of them.
- */
- runAudit(ia);
-
- /*
- * Now run again and ensure it waited long enough between runs.
- */
- long tmin = minAuditTime(ia);
- assertTrue(tmin >= periodms + AUDIT_SIMULATION_MS);
-
- /*
- * Now run again and ensure it waited long enough between runs.
- */
- tmin = minAuditTime(ia);
- assertTrue(tmin >= periodms + AUDIT_SIMULATION_MS);
- }
-
- /**
- * Runs simultaneous audits on several auditors.
- *
- * @param auditors
- * @return the minimum time, in milliseconds, elapsed for any given auditor
- * @throws InterruptedException
- */
- private long minAuditTime(MyIntegrityAudit... auditors) throws InterruptedException {
- List<Thread> threads = new ArrayList<>(auditors.length);
- AtomicLong tfirst = new AtomicLong(Long.MAX_VALUE);
- long tbeg = System.currentTimeMillis();
-
- // create the threads
- for (MyIntegrityAudit p : auditors) {
- Thread t = new Thread() {
-
- @Override
- public void run() {
- try {
- runAudit(p);
- setMinTime(tfirst);
-
- } catch (InterruptedException e) {
- ;
- }
- }
- };
-
- t.setDaemon(true);
- threads.add(t);
- }
-
- // start the threads
- for (Thread t : threads) {
- t.start();
- }
-
- // wait for them to complete
- for (Thread t : threads) {
- t.join();
- }
-
- return (tfirst.get() - tbeg);
- }
-
- /**
- * Sets a value to the minimum between the current value and the current
- * time.
- *
- * @param tmin
- * current minimum value/value to be set
- */
- private static void setMinTime(AtomicLong tmin) {
- long tcur = System.currentTimeMillis();
- long t;
- while ((t = tmin.get()) > tcur) {
- tmin.compareAndSet(t, tcur);
- }
- }
+ logger.info("testNegativeAuditPeriod: Exiting");
+
+ }
+
+ /*
+ * Verifies (via log parsing) that when an audit period of zero is specified, the audit runs
+ * continuously, generating a number of sleep/wake sequences in a short period of time (e.g.
+ * 100ms).
+ */
+ @Test
+ public void testZeroAuditPeriod() throws Exception {
+
+ logger.info("testZeroAuditPeriod: Entering");
+
+ properties.put(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS, "0");
+
+ final ExtractAppender logA = watch(debugLogger, "[Aa]waking from (0ms) sleep");
+
+ MyIntegrityAudit integrityAudit = makeAuditor("pdp1", A_SEQ_PU);
+
+ /*
+ * Wait for
+ *
+ * 1) audit to generate a bunch of sleep wake sequences.
+ */
+ String[] awakings = new String[10];
+ for (int x = 0; x < awakings.length; ++x) {
+ awakings[x] = "0ms";
+ runAudit(integrityAudit);
+ }
+
+ // run a couple more audits
+ runAudit(integrityAudit);
+ runAudit(integrityAudit);
+
+ /*
+ * We should get at least 10 sleep/wake sequences.
+ */
+
+ verifyItemsInLog(logA, awakings);
+
+ logger.info("testZeroAuditPeriod: Exiting");
+
+ }
+
+ /**
+ * Verifies that when different audit periods are specified, there is an appropriate interval
+ * between the audits.
+ */
+ @Test
+ public void testLongAuditPeriod() throws Exception {
+
+ logger.info("testLongAuditPeriod: Entering");
+
+ testAuditPeriod(100);
+ testAuditPeriod(200);
+
+ logger.info("testLongAuditPeriod: Exiting");
+ }
+
+ /**
+ * Verifies that audits actually take as long as expected, even with multiple auditors running
+ * simultaneously.
+ *
+ * @param periodms audit period, in milliseconds
+ * @throws Exception if an error occurs
+ * @throws InterruptedException if the thread is interrupted
+ */
+ private void testAuditPeriod(long periodms) throws Exception, InterruptedException {
+
+ properties.put(IntegrityAuditProperties.AUDIT_PERIOD_MILLISECONDS, String.valueOf(periodms));
+
+ /*
+ * Start several auditors.
+ */
+ MyIntegrityAudit[] ia = new MyIntegrityAudit[3];
+ for (int x = 0; x < ia.length; ++x) {
+ ia[x] = makeAuditor("pdp" + x, A_SEQ_PU);
+ }
+
+ /*
+ * Run an audit on all of them.
+ */
+ runAudit(ia);
+
+ /*
+ * Now run again and ensure it waited long enough between runs.
+ */
+ long tmin = minAuditTime(ia);
+ assertTrue(tmin >= periodms + AUDIT_SIMULATION_MS);
+
+ /*
+ * Now run again and ensure it waited long enough between runs.
+ */
+ tmin = minAuditTime(ia);
+ assertTrue(tmin >= periodms + AUDIT_SIMULATION_MS);
+ }
+
+ /**
+ * Runs simultaneous audits on several auditors.
+ *
+ * @param auditors the auditors
+ * @return the minimum time, in milliseconds, elapsed for any given auditor
+ * @throws InterruptedException if the thread is interrupted
+ */
+ private long minAuditTime(MyIntegrityAudit... auditors) throws InterruptedException {
+ List<Thread> threads = new ArrayList<>(auditors.length);
+ AtomicLong tfirst = new AtomicLong(Long.MAX_VALUE);
+ final long tbeg = System.currentTimeMillis();
+
+ // create the threads
+ for (MyIntegrityAudit p : auditors) {
+ Thread auditThread = new Thread() {
+
+ @Override
+ public void run() {
+ try {
+ runAudit(p);
+ setMinTime(tfirst);
+
+ } catch (InterruptedException e) {
+ ;
+ }
+ }
+ };
+
+ auditThread.setDaemon(true);
+ threads.add(auditThread);
+ }
+
+ // start the threads
+ for (Thread t : threads) {
+ t.start();
+ }
+
+ // wait for them to complete
+ for (Thread t : threads) {
+ t.join();
+ }
+
+ return (tfirst.get() - tbeg);
+ }
+
+ /**
+ * Sets a value to the minimum between the current value and the current time.
+ *
+ * @param tmin current minimum value/value to be set
+ */
+ private static void setMinTime(AtomicLong tmin) {
+ long tcur = System.currentTimeMillis();
+ long time;
+ while ((time = tmin.get()) > tcur) {
+ tmin.compareAndSet(time, tcur);
+ }
+ }
}
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditCompareEntriesTest.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditCompareEntriesTest.java
index 3a48b20c..6335482a 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditCompareEntriesTest.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditCompareEntriesTest.java
@@ -50,505 +50,507 @@ import org.onap.policy.common.logging.flexlogger.Logger;
*/
public class DbAuditCompareEntriesTest extends IntegrityAuditTestBase {
- private static Logger logger = FlexLogger.getLogger(DbAuditCompareEntriesTest.class);
-
- private DbDAO dbDAO;
- private static String resourceName = "pdp1";
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- IntegrityAuditTestBase
- .setUpBeforeClass(DEFAULT_DB_URL_PREFIX + DbAuditCompareEntriesTest.class.getSimpleName());
- }
-
- @AfterClass
- public static void tearDownAfterClass() {
- IntegrityAuditTestBase.tearDownAfterClass();
- }
-
- @Before
- public void setUp() {
-
- logger.info("setUp: Entering");
-
- super.setUp();
-
- truncateTables(makeProperties());
-
- logger.info("setUp: Exiting");
- }
-
- /*
- * Clean up DB after each test.
- */
- @After
- public void tearDown() {
- logger.info("tearDown: Entering");
-
- dbDAO.destroy();
-
- super.tearDown();
-
- logger.info("tearDown: Exiting");
- }
-
- /*
- * Tests that a comparison between hashsets is successful if the entries
- * match
- */
- // @Ignore
- @Test
- public void testSuccessfulComparison() throws Exception {
- logger.info("testSuccessfulComparison: Entering");
-
- dbDAO = new DbDAO(resourceName, A_SEQ_PU, makeProperties());
- DbAudit dbAudit = new DbAudit(dbDAO);
-
- String className = null;
- // There is only one entry IntegrityAuditEntity, but we will check
- // anyway
- Set<String> classNameSet = dbDAO.getPersistenceClassNames();
- for (String c : classNameSet) {
- if (c.equals("org.onap.policy.common.ia.jpa.IntegrityAuditEntity")) {
- className = c;
- }
- }
- String resourceName1 = resourceName;
- String resourceName2 = resourceName;
-
- IntegrityAuditEntity entry1 = new IntegrityAuditEntity();
- IntegrityAuditEntity entry2 = new IntegrityAuditEntity();
- Date date = new Date();
-
- /*
- * Two entries with the same field values
- */
- entry1.setDesignated(false);
- entry1.setJdbcDriver(dbDriver);
- entry1.setJdbcPassword(dbPwd);
- entry1.setJdbcUrl(dbUrl);
- entry1.setJdbcUser(dbUser);
- entry1.setLastUpdated(date);
- entry1.setNodeType(nodeType);
- entry1.setPersistenceUnit(A_SEQ_PU);
- entry1.setResourceName(resourceName1);
- entry1.setSite(siteName);
-
- entry2.setDesignated(false);
- entry2.setJdbcDriver(dbDriver);
- entry2.setJdbcPassword(dbPwd);
- entry2.setJdbcUrl(dbUrl);
- entry2.setJdbcUser(dbUser);
- entry2.setLastUpdated(date);
- entry2.setNodeType(nodeType);
- entry2.setPersistenceUnit(A_SEQ_PU);
- entry2.setResourceName(resourceName2);
- entry2.setSite(siteName);
-
- dbAudit.writeAuditDebugLog(className, resourceName1, resourceName2, entry1, entry2);
-
- HashMap<Object, Object> myEntries = new HashMap<Object, Object>();
- HashMap<Object, Object> theirEntries = new HashMap<Object, Object>();
-
- myEntries.put("pdp1", entry1);
- theirEntries.put("pdp1", entry2);
-
- Set<Object> result = dbAudit.compareEntries(myEntries, theirEntries);
-
- /*
- * Assert that there are no mismatches returned
- */
- assertTrue(result.isEmpty());
-
- logger.info("testSuccessfulComparison: Exit");
- }
-
- /*
- * Tests that an error is detected if an entry in one hashset doesn't match
- * the other
- */
- // @Ignore
- @Test
- public void testComparisonError() throws Exception {
- logger.info("testComparisonError: Entering");
-
- dbDAO = new DbDAO(resourceName, A_SEQ_PU, makeProperties());
- DbAudit dbAudit = new DbAudit(dbDAO);
-
- String resourceName1 = resourceName;
- String resourceName2 = resourceName;
-
- IntegrityAuditEntity entry1 = new IntegrityAuditEntity();
- IntegrityAuditEntity entry2 = new IntegrityAuditEntity();
- Date date = new Date();
-
- /*
- * Create two entries with different designated values
- */
- entry1.setDesignated(false);
- entry1.setJdbcDriver(dbDriver);
- entry1.setJdbcPassword(dbPwd);
- entry1.setJdbcUrl(dbUrl);
- entry1.setJdbcUser(dbUser);
- entry1.setLastUpdated(date);
- entry1.setNodeType(nodeType);
- entry1.setPersistenceUnit(A_SEQ_PU);
- entry1.setResourceName(resourceName1);
- entry1.setSite(siteName);
-
- entry2.setDesignated(true);
- entry2.setJdbcDriver(dbDriver);
- entry2.setJdbcPassword(dbPwd);
- entry2.setJdbcUrl(dbUrl);
- entry2.setJdbcUser(dbUser);
- entry2.setLastUpdated(date);
- entry2.setNodeType(nodeType);
- entry2.setPersistenceUnit(A_SEQ_PU);
- entry2.setResourceName(resourceName2);
- entry2.setSite(siteName);
-
- HashMap<Object, Object> myEntries = new HashMap<Object, Object>();
- HashMap<Object, Object> theirEntries = new HashMap<Object, Object>();
-
- myEntries.put("pdp1", entry1);
- theirEntries.put("pdp1", entry2);
-
- Set<Object> result = dbAudit.compareEntries(myEntries, theirEntries);
-
- /*
- * Assert that there was one mismatch
- */
- assertEquals(1, result.size());
-
- logger.info("testComparisonError: Exit");
- }
-
- /*
- * Tests that a mismatch/miss entry is detected if there are missing entries
- * in one or both of the hashsets
- */
- // @Ignore
- @Test
- public void testCompareMissingEntries() throws Exception {
- logger.info("testCompareMissingEntries: Entering");
-
- dbDAO = new DbDAO(resourceName, A_SEQ_PU, makeProperties());
- DbAudit dbAudit = new DbAudit(dbDAO);
-
- String resourceName1 = resourceName;
- String resourceName2 = resourceName;
-
- IntegrityAuditEntity entry1 = new IntegrityAuditEntity();
- IntegrityAuditEntity entry2 = new IntegrityAuditEntity();
- IntegrityAuditEntity entry3 = new IntegrityAuditEntity();
- IntegrityAuditEntity entry4 = new IntegrityAuditEntity();
-
- Date date = new Date();
-
- /*
- * 4 entries, one mismatch, two miss entries
- */
- entry1.setDesignated(false);
- entry1.setJdbcDriver(dbDriver);
- entry1.setJdbcPassword(dbPwd);
- entry1.setJdbcUrl(dbUrl);
- entry1.setJdbcUser(dbUser);
- entry1.setLastUpdated(date);
- entry1.setNodeType(nodeType);
- entry1.setPersistenceUnit(A_SEQ_PU);
- entry1.setResourceName(resourceName1);
- entry1.setSite(siteName);
-
- entry2.setDesignated(true);
- entry2.setJdbcDriver(dbDriver);
- entry2.setJdbcPassword(dbPwd);
- entry2.setJdbcUrl(dbUrl);
- entry2.setJdbcUser(dbUser);
- entry2.setLastUpdated(date);
- entry2.setNodeType(nodeType);
- entry2.setPersistenceUnit(A_SEQ_PU);
- entry2.setResourceName(resourceName2);
- entry2.setSite(siteName);
-
- entry3.setDesignated(false);
- entry3.setJdbcDriver(dbDriver);
- entry3.setJdbcPassword(dbPwd);
- entry3.setJdbcUrl(dbUrl);
- entry3.setJdbcUser(dbUser);
- entry3.setLastUpdated(date);
- entry3.setNodeType(nodeType);
- entry3.setPersistenceUnit(A_SEQ_PU);
- entry3.setResourceName(resourceName2);
- entry3.setSite("SiteB");
-
- entry4.setDesignated(false);
- entry4.setJdbcDriver(dbDriver);
- entry4.setJdbcPassword(dbPwd);
- entry4.setJdbcUrl(dbUrl);
- entry4.setJdbcUser(dbUser);
- entry4.setLastUpdated(date);
- entry4.setNodeType(nodeType);
- entry4.setPersistenceUnit(A_SEQ_PU);
- entry4.setResourceName(resourceName2);
- entry4.setSite("SiteB");
-
- HashMap<Object, Object> myEntries = new HashMap<Object, Object>();
- HashMap<Object, Object> theirEntries = new HashMap<Object, Object>();
-
- myEntries.put("0", entry1);
- myEntries.put("1", entry3);
- theirEntries.put("0", entry2);
- theirEntries.put("2", entry4);
-
- Set<Object> mismatchResult = dbAudit.compareEntries(myEntries, theirEntries);
-
- /*
- * Assert 3 mismatches/missing entries were found
- */
- assertEquals(3, mismatchResult.size());
-
- logger.info("testCompareMissingEntries: Exit");
- }
-
- /*
- * Tests that comparison algorithm works for each entity in the hashsets
- */
- // @Ignore
- @Test
- public void testCompareAllHashEntities() throws Exception {
- logger.info("testCompareAllHashEntities: Entering");
-
- dbDAO = new DbDAO(resourceName, A_SEQ_PU, makeProperties());
- DbAudit dbAudit = new DbAudit(dbDAO);
-
- Set<String> classNameSet = dbDAO.getPersistenceClassNames();
- Set<Object> mismatchResult = new HashSet<Object>();
- for (String c : classNameSet) {
- if (c.equals("org.onap.policy.common.ia.jpa.IntegrityAuditEntity")) {
- String resourceName1 = resourceName;
- String resourceName2 = resourceName;
-
- IntegrityAuditEntity entry1 = new IntegrityAuditEntity();
- IntegrityAuditEntity entry2 = new IntegrityAuditEntity();
- Date date = new Date();
-
- /*
- * Two entries with the same field values
- */
- entry1.setDesignated(false);
- entry1.setJdbcDriver(dbDriver);
- entry1.setJdbcPassword(dbPwd);
- entry1.setJdbcUrl(dbUrl);
- entry1.setJdbcUser(dbUser);
- entry1.setLastUpdated(date);
- entry1.setNodeType(nodeType);
- entry1.setPersistenceUnit(A_SEQ_PU);
- entry1.setResourceName(resourceName1);
- entry1.setSite(siteName);
-
- entry2.setDesignated(false);
- entry2.setJdbcDriver(dbDriver);
- entry2.setJdbcPassword(dbPwd);
- entry2.setJdbcUrl(dbUrl);
- entry2.setJdbcUser(dbUser);
- entry2.setLastUpdated(date);
- entry2.setNodeType(nodeType);
- entry2.setPersistenceUnit(A_SEQ_PU);
- entry2.setResourceName(resourceName2);
- entry2.setSite(siteName);
-
- HashMap<Object, Object> myEntries = new HashMap<Object, Object>();
- HashMap<Object, Object> theirEntries = new HashMap<Object, Object>();
-
- myEntries.put("pdp1", entry1);
- theirEntries.put("pdp1", entry2);
-
- mismatchResult = dbAudit.compareEntries(myEntries, theirEntries);
-
- /*
- * Assert there was no mismatches
- */
- assertTrue(mismatchResult.isEmpty());
- } else if (c.equals("org.onap.policy.common.ia.jpa.IaTestEntity")) {
- IaTestEntity iate = new IaTestEntity();
- IaTestEntity iate2 = new IaTestEntity();
- IaTestEntity iate3 = new IaTestEntity();
- IaTestEntity iate4 = new IaTestEntity();
-
- Date date = new Date();
-
- /*
- * Four entries, 2 mismatches
- */
- iate.setCreatedBy("Ford");
- iate.setModifiedBy("Ford");
- iate.setModifiedDate(date);
-
- iate2.setCreatedBy("Ford");
- iate2.setModifiedBy("Zaphod");
- iate2.setModifiedDate(date);
-
- iate3.setCreatedBy("Zaphod");
- iate3.setModifiedBy("Ford");
- iate3.setModifiedDate(date);
-
- iate4.setCreatedBy("Ford");
- iate4.setModifiedBy("Ford");
- iate4.setModifiedDate(date);
-
- HashMap<Object, Object> myEntries = new HashMap<Object, Object>();
- HashMap<Object, Object> theirEntries = new HashMap<Object, Object>();
-
- myEntries.put("0", iate);
- myEntries.put("1", iate2);
- theirEntries.put("0", iate3);
- theirEntries.put("1", iate4);
-
- mismatchResult = dbAudit.compareEntries(myEntries, theirEntries);
-
- /*
- * Assert that there is 2 mismatches
- */
- assertEquals(2, mismatchResult.size());
- }
- }
-
- logger.info("testCompareAllHashEntities: Exit");
- }
-
- /*
- * Tests that comparison algorithm works for each entity in the database
- */
- @Ignore
- @Test
- public void testCompareAllDbEntities() throws Exception {
- logger.info("testCompareAllDbEntities: Entering");
-
- logger.info("Setting up DB");
-
- IntegrityAudit.setUnitTesting(true);
-
- Properties properties = makeProperties();
-
- Properties properties2 = makeProperties();
- properties2.put(IntegrityAuditProperties.DB_URL,
- "jdbc:h2:mem:" + DbAuditCompareEntriesTest.class.getSimpleName() + "2");
-
- // Clean up the two DBs
- truncateTables(properties);
- truncateTables(properties2);
-
- // Add entries into DB1
- dbDAO = new DbDAO(resourceName, A_SEQ_PU, properties);
- new DbDAO("pdp2", A_SEQ_PU, properties).destroy();
- DbAudit dbAudit = new DbAudit(dbDAO);
-
- // Add entries into DB2
- DbDAO dbDAO3 = new DbDAO(resourceName, A_SEQ_PU, properties2);
- new DbDAO("pdp2", A_SEQ_PU, properties2).destroy();
-
- // Pull all entries and compare
- Set<String> classNameSet = dbDAO.getPersistenceClassNames();
- Map<Object, Object> myEntries;
- Map<Object, Object> theirEntries;
- Set<Object> mismatchResult = new HashSet<Object>();
- String className;
- for (String c : classNameSet) {
- className = c;
- logger.info("classNameSet entry = " + c);
- myEntries = dbDAO.getAllEntries(A_SEQ_PU, properties, className);
- theirEntries = dbDAO3.getAllEntries(A_SEQ_PU, properties2, className);
- mismatchResult = dbAudit.compareEntries(myEntries, theirEntries);
- if (className.contains("IntegrityAuditEntity")) {
- break;
- }
- }
-
- dbDAO3.destroy();
-
- // Assert that there is 2 mismatches between IntegrityAuditEntity tables
- assertEquals(2, mismatchResult.size());
-
- logger.info("testCompareAllDbEntities: Exit");
- }
-
- /**
- * @param properties
- */
- private void truncateTables(Properties properties) {
- truncateTable(properties, A_SEQ_PU, "IntegrityAuditEntity");
- truncateTable(properties, A_SEQ_PU, "IaTestEntity");
- }
-
- /*
- * Tests that differences in embedded classes are still caught
- */
- // @Ignore
- @Test
- public void testEmbeddedClass() throws Exception {
- logger.info("testEmbeddedClasses: Entering");
-
- dbDAO = new DbDAO(resourceName, A_SEQ_PU, properties);
- DbAudit dbAudit = new DbAudit(dbDAO);
-
- String className = null;
- // There is only one entry IntegrityAuditEntity, but we will check
- // anyway
- Set<String> classNameSet = dbDAO.getPersistenceClassNames();
- for (String c : classNameSet) {
- if (c.equals("org.onap.policy.common.ia.jpa.IaTestEntity")) {
- className = c;
- }
- }
-
- IaTestEntity iate = new IaTestEntity();
- IaTestEntity iate2 = new IaTestEntity();
-
- Date date = new Date();
-
- PersonSample person = new PersonSample("Ford", "Prefect", 21);
- PersonSample person2 = new PersonSample("Zaphod", "Beeblebrox", 25);
-
- /*
- * Silly tests to bump coverage stats, not sure why they are counting
- * PersonSample to begin with. Will have to look into that at some
- * point.
- */
- assertNotEquals(person.getAge(), person2.getAge());
- assertNotEquals(person.getFirstName(), person2.getFirstName());
- assertNotEquals(person.getLasttName(), person2.getLasttName());
- PersonSample personTest = new PersonSample(null, null, 0);
- personTest.setAge(person.getAge());
- personTest.setFirstName(person.getFirstName());
- personTest.setLastName(person.getLasttName());
- /*
- * Two entries, 1 mismatch
- */
- iate.setCreatedBy("Ford");
- iate.setModifiedBy("Zaphod");
- iate.setModifiedDate(date);
- iate.setPersonTest(person);
-
- iate2.setCreatedBy("Ford");
- iate2.setModifiedBy("Zaphod");
- iate2.setModifiedDate(date);
- iate2.setPersonTest(person2);
-
- dbAudit.writeAuditDebugLog(className, "resource1", "resource2", iate, iate2);
-
- HashMap<Object, Object> myEntries = new HashMap<Object, Object>();
- HashMap<Object, Object> theirEntries = new HashMap<Object, Object>();
-
- myEntries.put("0", iate);
- theirEntries.put("0", iate2);
-
- Set<Object> result = dbAudit.compareEntries(myEntries, theirEntries);
-
- /*
- * Assert that there are no mismatches returned
- */
- assertTrue(!result.isEmpty());
-
- logger.info("testEmbeddedClasses: Exit");
- }
+ private static Logger logger = FlexLogger.getLogger(DbAuditCompareEntriesTest.class);
+
+ private DbDAO dbDao;
+ private static String resourceName = "pdp1";
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ IntegrityAuditTestBase
+ .setUpBeforeClass(DEFAULT_DB_URL_PREFIX + DbAuditCompareEntriesTest.class.getSimpleName());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ IntegrityAuditTestBase.tearDownAfterClass();
+ }
+
+ /**
+ * Set up for test cases.
+ */
+ @Override
+ @Before
+ public void setUp() {
+
+ logger.info("setUp: Entering");
+
+ super.setUp();
+
+ truncateTables(makeProperties());
+
+ logger.info("setUp: Exiting");
+ }
+
+ /**
+ * Clean up DB after each test.
+ */
+ @Override
+ @After
+ public void tearDown() {
+ logger.info("tearDown: Entering");
+
+ dbDao.destroy();
+
+ super.tearDown();
+
+ logger.info("tearDown: Exiting");
+ }
+
+ /*
+ * Tests that a comparison between hashsets is successful if the entries match
+ */
+ // @Ignore
+ @Test
+ public void testSuccessfulComparison() throws Exception {
+ logger.info("testSuccessfulComparison: Entering");
+
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, makeProperties());
+ final DbAudit dbAudit = new DbAudit(dbDao);
+
+ String className = null;
+ // There is only one entry IntegrityAuditEntity, but we will check
+ // anyway
+ Set<String> classNameSet = dbDao.getPersistenceClassNames();
+ for (String c : classNameSet) {
+ if (c.equals("org.onap.policy.common.ia.jpa.IntegrityAuditEntity")) {
+ className = c;
+ }
+ }
+ final String resourceName1 = resourceName;
+ final String resourceName2 = resourceName;
+
+ final IntegrityAuditEntity entry1 = new IntegrityAuditEntity();
+ final IntegrityAuditEntity entry2 = new IntegrityAuditEntity();
+ Date date = new Date();
+
+ /*
+ * Two entries with the same field values
+ */
+ entry1.setDesignated(false);
+ entry1.setJdbcDriver(dbDriver);
+ entry1.setJdbcPassword(dbPwd);
+ entry1.setJdbcUrl(dbUrl);
+ entry1.setJdbcUser(dbUser);
+ entry1.setLastUpdated(date);
+ entry1.setNodeType(nodeType);
+ entry1.setPersistenceUnit(A_SEQ_PU);
+ entry1.setResourceName(resourceName1);
+ entry1.setSite(siteName);
+
+ entry2.setDesignated(false);
+ entry2.setJdbcDriver(dbDriver);
+ entry2.setJdbcPassword(dbPwd);
+ entry2.setJdbcUrl(dbUrl);
+ entry2.setJdbcUser(dbUser);
+ entry2.setLastUpdated(date);
+ entry2.setNodeType(nodeType);
+ entry2.setPersistenceUnit(A_SEQ_PU);
+ entry2.setResourceName(resourceName2);
+ entry2.setSite(siteName);
+
+ dbAudit.writeAuditDebugLog(className, resourceName1, resourceName2, entry1, entry2);
+
+ HashMap<Object, Object> myEntries = new HashMap<Object, Object>();
+ HashMap<Object, Object> theirEntries = new HashMap<Object, Object>();
+
+ myEntries.put("pdp1", entry1);
+ theirEntries.put("pdp1", entry2);
+
+ Set<Object> result = dbAudit.compareEntries(myEntries, theirEntries);
+
+ /*
+ * Assert that there are no mismatches returned
+ */
+ assertTrue(result.isEmpty());
+
+ logger.info("testSuccessfulComparison: Exit");
+ }
+
+ /*
+ * Tests that an error is detected if an entry in one hashset doesn't match the other
+ */
+ // @Ignore
+ @Test
+ public void testComparisonError() throws Exception {
+ logger.info("testComparisonError: Entering");
+
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, makeProperties());
+ final DbAudit dbAudit = new DbAudit(dbDao);
+
+ final String resourceName1 = resourceName;
+ final String resourceName2 = resourceName;
+
+ final IntegrityAuditEntity entry1 = new IntegrityAuditEntity();
+ final IntegrityAuditEntity entry2 = new IntegrityAuditEntity();
+ Date date = new Date();
+
+ /*
+ * Create two entries with different designated values
+ */
+ entry1.setDesignated(false);
+ entry1.setJdbcDriver(dbDriver);
+ entry1.setJdbcPassword(dbPwd);
+ entry1.setJdbcUrl(dbUrl);
+ entry1.setJdbcUser(dbUser);
+ entry1.setLastUpdated(date);
+ entry1.setNodeType(nodeType);
+ entry1.setPersistenceUnit(A_SEQ_PU);
+ entry1.setResourceName(resourceName1);
+ entry1.setSite(siteName);
+
+ entry2.setDesignated(true);
+ entry2.setJdbcDriver(dbDriver);
+ entry2.setJdbcPassword(dbPwd);
+ entry2.setJdbcUrl(dbUrl);
+ entry2.setJdbcUser(dbUser);
+ entry2.setLastUpdated(date);
+ entry2.setNodeType(nodeType);
+ entry2.setPersistenceUnit(A_SEQ_PU);
+ entry2.setResourceName(resourceName2);
+ entry2.setSite(siteName);
+
+ HashMap<Object, Object> myEntries = new HashMap<Object, Object>();
+ HashMap<Object, Object> theirEntries = new HashMap<Object, Object>();
+
+ myEntries.put("pdp1", entry1);
+ theirEntries.put("pdp1", entry2);
+
+ Set<Object> result = dbAudit.compareEntries(myEntries, theirEntries);
+
+ /*
+ * Assert that there was one mismatch
+ */
+ assertEquals(1, result.size());
+
+ logger.info("testComparisonError: Exit");
+ }
+
+ /*
+ * Tests that a mismatch/miss entry is detected if there are missing entries in one or both of
+ * the hashsets
+ */
+ // @Ignore
+ @Test
+ public void testCompareMissingEntries() throws Exception {
+ logger.info("testCompareMissingEntries: Entering");
+
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, makeProperties());
+ final DbAudit dbAudit = new DbAudit(dbDao);
+
+ final String resourceName1 = resourceName;
+ final String resourceName2 = resourceName;
+
+ final IntegrityAuditEntity entry1 = new IntegrityAuditEntity();
+ final IntegrityAuditEntity entry2 = new IntegrityAuditEntity();
+ final IntegrityAuditEntity entry3 = new IntegrityAuditEntity();
+ final IntegrityAuditEntity entry4 = new IntegrityAuditEntity();
+
+ Date date = new Date();
+
+ /*
+ * 4 entries, one mismatch, two miss entries
+ */
+ entry1.setDesignated(false);
+ entry1.setJdbcDriver(dbDriver);
+ entry1.setJdbcPassword(dbPwd);
+ entry1.setJdbcUrl(dbUrl);
+ entry1.setJdbcUser(dbUser);
+ entry1.setLastUpdated(date);
+ entry1.setNodeType(nodeType);
+ entry1.setPersistenceUnit(A_SEQ_PU);
+ entry1.setResourceName(resourceName1);
+ entry1.setSite(siteName);
+
+ entry2.setDesignated(true);
+ entry2.setJdbcDriver(dbDriver);
+ entry2.setJdbcPassword(dbPwd);
+ entry2.setJdbcUrl(dbUrl);
+ entry2.setJdbcUser(dbUser);
+ entry2.setLastUpdated(date);
+ entry2.setNodeType(nodeType);
+ entry2.setPersistenceUnit(A_SEQ_PU);
+ entry2.setResourceName(resourceName2);
+ entry2.setSite(siteName);
+
+ entry3.setDesignated(false);
+ entry3.setJdbcDriver(dbDriver);
+ entry3.setJdbcPassword(dbPwd);
+ entry3.setJdbcUrl(dbUrl);
+ entry3.setJdbcUser(dbUser);
+ entry3.setLastUpdated(date);
+ entry3.setNodeType(nodeType);
+ entry3.setPersistenceUnit(A_SEQ_PU);
+ entry3.setResourceName(resourceName2);
+ entry3.setSite("SiteB");
+
+ entry4.setDesignated(false);
+ entry4.setJdbcDriver(dbDriver);
+ entry4.setJdbcPassword(dbPwd);
+ entry4.setJdbcUrl(dbUrl);
+ entry4.setJdbcUser(dbUser);
+ entry4.setLastUpdated(date);
+ entry4.setNodeType(nodeType);
+ entry4.setPersistenceUnit(A_SEQ_PU);
+ entry4.setResourceName(resourceName2);
+ entry4.setSite("SiteB");
+
+ HashMap<Object, Object> myEntries = new HashMap<Object, Object>();
+ HashMap<Object, Object> theirEntries = new HashMap<Object, Object>();
+
+ myEntries.put("0", entry1);
+ myEntries.put("1", entry3);
+ theirEntries.put("0", entry2);
+ theirEntries.put("2", entry4);
+
+ Set<Object> mismatchResult = dbAudit.compareEntries(myEntries, theirEntries);
+
+ /*
+ * Assert 3 mismatches/missing entries were found
+ */
+ assertEquals(3, mismatchResult.size());
+
+ logger.info("testCompareMissingEntries: Exit");
+ }
+
+ /*
+ * Tests that comparison algorithm works for each entity in the hashsets
+ */
+ // @Ignore
+ @Test
+ public void testCompareAllHashEntities() throws Exception {
+ logger.info("testCompareAllHashEntities: Entering");
+
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, makeProperties());
+ DbAudit dbAudit = new DbAudit(dbDao);
+
+ Set<String> classNameSet = dbDao.getPersistenceClassNames();
+ Set<Object> mismatchResult = new HashSet<Object>();
+ for (String className : classNameSet) {
+ if (className.equals("org.onap.policy.common.ia.jpa.IntegrityAuditEntity")) {
+ final String resourceName1 = resourceName;
+ final String resourceName2 = resourceName;
+
+ final IntegrityAuditEntity entry1 = new IntegrityAuditEntity();
+ final IntegrityAuditEntity entry2 = new IntegrityAuditEntity();
+ Date date = new Date();
+
+ /*
+ * Two entries with the same field values
+ */
+ entry1.setDesignated(false);
+ entry1.setJdbcDriver(dbDriver);
+ entry1.setJdbcPassword(dbPwd);
+ entry1.setJdbcUrl(dbUrl);
+ entry1.setJdbcUser(dbUser);
+ entry1.setLastUpdated(date);
+ entry1.setNodeType(nodeType);
+ entry1.setPersistenceUnit(A_SEQ_PU);
+ entry1.setResourceName(resourceName1);
+ entry1.setSite(siteName);
+
+ entry2.setDesignated(false);
+ entry2.setJdbcDriver(dbDriver);
+ entry2.setJdbcPassword(dbPwd);
+ entry2.setJdbcUrl(dbUrl);
+ entry2.setJdbcUser(dbUser);
+ entry2.setLastUpdated(date);
+ entry2.setNodeType(nodeType);
+ entry2.setPersistenceUnit(A_SEQ_PU);
+ entry2.setResourceName(resourceName2);
+ entry2.setSite(siteName);
+
+ HashMap<Object, Object> myEntries = new HashMap<Object, Object>();
+ HashMap<Object, Object> theirEntries = new HashMap<Object, Object>();
+
+ myEntries.put("pdp1", entry1);
+ theirEntries.put("pdp1", entry2);
+
+ mismatchResult = dbAudit.compareEntries(myEntries, theirEntries);
+
+ /*
+ * Assert there was no mismatches
+ */
+ assertTrue(mismatchResult.isEmpty());
+ } else if (className.equals("org.onap.policy.common.ia.jpa.IaTestEntity")) {
+ final IaTestEntity iate = new IaTestEntity();
+ final IaTestEntity iate2 = new IaTestEntity();
+ final IaTestEntity iate3 = new IaTestEntity();
+ final IaTestEntity iate4 = new IaTestEntity();
+
+ Date date = new Date();
+
+ /*
+ * Four entries, 2 mismatches
+ */
+ iate.setCreatedBy("Ford");
+ iate.setModifiedBy("Ford");
+ iate.setModifiedDate(date);
+
+ iate2.setCreatedBy("Ford");
+ iate2.setModifiedBy("Zaphod");
+ iate2.setModifiedDate(date);
+
+ iate3.setCreatedBy("Zaphod");
+ iate3.setModifiedBy("Ford");
+ iate3.setModifiedDate(date);
+
+ iate4.setCreatedBy("Ford");
+ iate4.setModifiedBy("Ford");
+ iate4.setModifiedDate(date);
+
+ HashMap<Object, Object> myEntries = new HashMap<Object, Object>();
+ HashMap<Object, Object> theirEntries = new HashMap<Object, Object>();
+
+ myEntries.put("0", iate);
+ myEntries.put("1", iate2);
+ theirEntries.put("0", iate3);
+ theirEntries.put("1", iate4);
+
+ mismatchResult = dbAudit.compareEntries(myEntries, theirEntries);
+
+ /*
+ * Assert that there is 2 mismatches
+ */
+ assertEquals(2, mismatchResult.size());
+ }
+ }
+
+ logger.info("testCompareAllHashEntities: Exit");
+ }
+
+ /*
+ * Tests that comparison algorithm works for each entity in the database
+ */
+ @Ignore
+ @Test
+ public void testCompareAllDbEntities() throws Exception {
+ logger.info("testCompareAllDbEntities: Entering");
+
+ logger.info("Setting up DB");
+
+ IntegrityAudit.setUnitTesting(true);
+
+ Properties properties = makeProperties();
+
+ Properties properties2 = makeProperties();
+ properties2.put(IntegrityAuditProperties.DB_URL,
+ "jdbc:h2:mem:" + DbAuditCompareEntriesTest.class.getSimpleName() + "2");
+
+ // Clean up the two DBs
+ truncateTables(properties);
+ truncateTables(properties2);
+
+ // Add entries into DB1
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, properties);
+ new DbDAO("pdp2", A_SEQ_PU, properties).destroy();
+ DbAudit dbAudit = new DbAudit(dbDao);
+
+ // Add entries into DB2
+ DbDAO dbDao3 = new DbDAO(resourceName, A_SEQ_PU, properties2);
+ new DbDAO("pdp2", A_SEQ_PU, properties2).destroy();
+
+ // Pull all entries and compare
+ Set<String> classNameSet = dbDao.getPersistenceClassNames();
+ Map<Object, Object> myEntries;
+ Map<Object, Object> theirEntries;
+ Set<Object> mismatchResult = new HashSet<Object>();
+ for (String className : classNameSet) {
+ logger.info("classNameSet entry = " + className);
+ myEntries = dbDao.getAllEntries(A_SEQ_PU, properties, className);
+ theirEntries = dbDao3.getAllEntries(A_SEQ_PU, properties2, className);
+ mismatchResult = dbAudit.compareEntries(myEntries, theirEntries);
+ if (className.contains("IntegrityAuditEntity")) {
+ break;
+ }
+ }
+
+ dbDao3.destroy();
+
+ // Assert that there is 2 mismatches between IntegrityAuditEntity tables
+ assertEquals(2, mismatchResult.size());
+
+ logger.info("testCompareAllDbEntities: Exit");
+ }
+
+ /**
+ * Truncate the tables.
+ *
+ * @param properties the properties
+ */
+ private void truncateTables(Properties properties) {
+ truncateTable(properties, A_SEQ_PU, "IntegrityAuditEntity");
+ truncateTable(properties, A_SEQ_PU, "IaTestEntity");
+ }
+
+ /*
+ * Tests that differences in embedded classes are still caught
+ */
+ // @Ignore
+ @Test
+ public void testEmbeddedClass() throws Exception {
+ logger.info("testEmbeddedClasses: Entering");
+
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, properties);
+ final DbAudit dbAudit = new DbAudit(dbDao);
+
+ String className = null;
+ // There is only one entry IntegrityAuditEntity, but we will check
+ // anyway
+ Set<String> classNameSet = dbDao.getPersistenceClassNames();
+ for (String classNameInClassNameSet : classNameSet) {
+ if (classNameInClassNameSet.equals("org.onap.policy.common.ia.jpa.IaTestEntity")) {
+ className = classNameInClassNameSet;
+ }
+ }
+
+ final IaTestEntity iate = new IaTestEntity();
+ final IaTestEntity iate2 = new IaTestEntity();
+
+ final Date date = new Date();
+
+ PersonSample person = new PersonSample("Ford", "Prefect", 21);
+ PersonSample person2 = new PersonSample("Zaphod", "Beeblebrox", 25);
+
+ /*
+ * Silly tests to bump coverage stats, not sure why they are counting PersonSample to begin
+ * with. Will have to look into that at some point.
+ */
+ assertNotEquals(person.getAge(), person2.getAge());
+ assertNotEquals(person.getFirstName(), person2.getFirstName());
+ assertNotEquals(person.getLasttName(), person2.getLasttName());
+ PersonSample personTest = new PersonSample(null, null, 0);
+ personTest.setAge(person.getAge());
+ personTest.setFirstName(person.getFirstName());
+ personTest.setLastName(person.getLasttName());
+ /*
+ * Two entries, 1 mismatch
+ */
+ iate.setCreatedBy("Ford");
+ iate.setModifiedBy("Zaphod");
+ iate.setModifiedDate(date);
+ iate.setPersonTest(person);
+
+ iate2.setCreatedBy("Ford");
+ iate2.setModifiedBy("Zaphod");
+ iate2.setModifiedDate(date);
+ iate2.setPersonTest(person2);
+
+ dbAudit.writeAuditDebugLog(className, "resource1", "resource2", iate, iate2);
+
+ HashMap<Object, Object> myEntries = new HashMap<Object, Object>();
+ HashMap<Object, Object> theirEntries = new HashMap<Object, Object>();
+
+ myEntries.put("0", iate);
+ theirEntries.put("0", iate2);
+
+ Set<Object> result = dbAudit.compareEntries(myEntries, theirEntries);
+
+ /*
+ * Assert that there are no mismatches returned
+ */
+ assertTrue(!result.isEmpty());
+
+ logger.info("testEmbeddedClasses: Exit");
+ }
}
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java
index ad4041f5..cfbf90cb 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java
@@ -53,230 +53,236 @@ import org.onap.policy.common.utils.test.log.logback.ExtractAppender;
*/
public class DbAuditTest extends IntegrityAuditTestBase {
- private static Logger logger = FlexLogger.getLogger(DbAuditTest.class);
+ private static Logger logger = FlexLogger.getLogger(DbAuditTest.class);
+
+ private static final String resourceName = "pdp1";
+
+ private EntityManagerFactory emf2;
+ private EntityManager em2;
+ private DbDAO dbDao;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ IntegrityAuditTestBase.setUpBeforeClass(DEFAULT_DB_URL_PREFIX + DbAuditTest.class.getSimpleName());
+ IntegrityAuditEntity.setUnitTesting(true);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ IntegrityAuditTestBase.tearDownAfterClass();
+ IntegrityAuditEntity.setUnitTesting(false);
+ }
+
+ /**
+ * Set up for test cases.
+ */
+ @Override
+ @Before
+ public void setUp() {
+ logger.info("setUp: Entering");
+
+ super.setUp();
+
+ dbDao = null;
+ emf2 = null;
+ em2 = null;
+
+ logger.info("setUp: Exiting");
+ }
+
+ /**
+ * Tear down after test cases.
+ */
+ @Override
+ @After
+ public void tearDown() {
+ logger.info("tearDown: Entering");
+
+ if (dbDao != null) {
+ dbDao.destroy();
+ }
+
+ if (em2 != null) {
+ em2.close();
+ }
+
+ if (emf2 != null) {
+ emf2.close();
+ }
+
+ super.tearDown();
- private static final String resourceName = "pdp1";
+ logger.info("tearDown: Exiting");
+ }
+
+ private void createDb(Properties properties) {
+ if (emf2 != null) {
+ throw new IllegalStateException("DB2 has already been created");
+ }
+
+ // open the DB and ensure it stays open until the test completes
+ emf2 = Persistence.createEntityManagerFactory(A_SEQ_PU, properties);
+ em2 = emf2.createEntityManager();
+
+ truncateTable(properties, A_SEQ_PU, "IntegrityAuditEntity");
+ }
+
+ /*
+ * Tests printing an error to the log in the event where there are no entities saved in the
+ * database
+ */
+ @Test
+ public void noEntitiesTest() throws Exception {
+ Properties properties = makeProperties();
+
+ logger.info("noEntitiesTest: Entering");
+
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, properties);
+ dbDao.deleteAllIntegrityAuditEntities();
+ try {
+ DbAudit dbAudit = new DbAudit(dbDao);
+ dbAudit.dbAudit(resourceName, A_SEQ_PU, nodeType);
+ fail("found unexpected entities");
+
+ } catch (DbAuditException e) {
+ // Ignore expected exception
+ }
+
+ logger.info("noEntitiesTest: Exit");
+ }
+
+ /*
+ * Tests the detection of only one entry in the database
+ */
+ @Test
+ public void oneEntityTest() throws Exception {
+ Properties properties = makeProperties();
+
+ logger.info("oneEntityTest: Entering");
+
+ final ExtractAppender log = watch(debugLogger, "DbAudit: Found only (one) IntegrityAuditEntity entry:");
+
+ // Add one entry in the database
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, properties);
+ DbAudit dbAudit = new DbAudit(dbDao);
+ dbAudit.dbAudit(resourceName, A_SEQ_PU, nodeType);
+
+ List<IntegrityAuditEntity> iaeList = dbDao.getIntegrityAuditEntities(A_SEQ_PU, nodeType);
+ logger.info("List size: " + iaeList.size());
+
+ verifyItemsInLog(log, "one");
+
+ logger.info("oneEntityTest: Exit");
+ }
+
+ /*
+ * Tests reporting mismatches and missing entries using the error log
+ */
+ @Test
+ public void mismatchTest() throws Exception {
+ logger.info("mismatchTest: Entering");
+
+ // use new URLs so we get a completely new DB
+ String dbUrl = DbAuditTest.dbUrl + "_mismatchTest";
+ String dbUrl2 = dbUrl + "2";
+
+ Properties properties = makeProperties();
+ properties.put(IntegrityAuditProperties.DB_URL, dbUrl);
+
+ // Properties for DB2
+ Properties properties2 = makeProperties();
+ properties2.put(IntegrityAuditProperties.DB_URL, dbUrl2);
+
+ /*
+ * We must drop and re-create DB1 so that it's sequence generator is in step with the
+ * sequence generator for DB2.
+ */
+ recreateDb1(properties);
+
+ // create/open DB2
+ createDb(properties2);
- private EntityManagerFactory emf2;
- private EntityManager em2;
- private DbDAO dbDAO;
+ final ExtractAppender dbglog = watch(debugLogger, "Mismatched entries [(]keys[)]:(.*)");
+ final ExtractAppender errlog = watch(errorLogger, "DB Audit: ([0-9])");
+
+ /*
+ * Create entries in DB1 & DB2 for the resource of interest
+ */
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, properties);
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- IntegrityAuditTestBase.setUpBeforeClass(DEFAULT_DB_URL_PREFIX + DbAuditTest.class.getSimpleName());
- IntegrityAuditEntity.setUnitTesting(true);
- }
+ new DbDAO(resourceName, A_SEQ_PU, properties2).destroy();
+
+ /*
+ * Entries in DB1, pointing to DB2, except for pdp3
+ */
+ new DbDAO("pdp2", A_SEQ_PU, properties, dbUrl2).destroy();
+ new DbDAO("pdp1", A_SEQ_PU, properties, dbUrl2).destroy();
+ new DbDAO("pdp3", A_SEQ_PU, properties).destroy(); // mismatched URL
+ new DbDAO("pdp4", A_SEQ_PU, properties, dbUrl2).destroy();
+
+ /*
+ * Identical entries in DB2, all pointing to DB2, including pdp3, but leaving out pdp4
+ */
+ new DbDAO("pdp2", A_SEQ_PU, properties2).destroy();
+ new DbDAO("pdp1", A_SEQ_PU, properties2).destroy();
+ new DbDAO("pdp3", A_SEQ_PU, properties2).destroy();
+
+ /*
+ * Run the DB Audit, once it finds a mismatch and sleeps, update DB1 to have the same entry
+ * as DB2 it can be confirmed that the mismatch is resolved
+ */
+ DbAudit dbAudit = new DbAudit(dbDao);
+ dbAudit.dbAudit(resourceName, A_SEQ_PU, nodeType);
- @AfterClass
- public static void tearDownAfterClass() {
- IntegrityAuditTestBase.tearDownAfterClass();
- IntegrityAuditEntity.setUnitTesting(false);
- }
+ // update pdp3 entry in DB1 to point to DB2
+ new DbDAO("pdp3", A_SEQ_PU, properties, dbUrl2).destroy();
+
+ /*
+ * Run the audit again and correct the mismatch, the result should be one entry in the
+ * mismatchKeySet because of the missing entry from the beginning of the test
+ */
+ dbAudit.dbAudit(resourceName, A_SEQ_PU, nodeType);
- @Before
- public void setUp() {
- logger.info("setUp: Entering");
+ assertFalse(dbglog.getExtracted().isEmpty());
+
+ String mismatchIndex = dbglog.getExtracted().get(dbglog.getExtracted().size() - 1);
+ int mismatchEntries = mismatchIndex.trim().split(",").length;
+ logger.info("mismatchTest: mismatchIndex found: '" + mismatchIndex + "'" + " mismatachEntries = "
+ + mismatchEntries);
- super.setUp();
+ // Assert there is only one entry index
+ assertEquals(1, mismatchEntries);
+
+ // Now check the entry in the error.log
+ assertFalse(errlog.getExtracted().isEmpty());
- dbDAO = null;
- emf2 = null;
- em2 = null;
+ String mismatchNum = errlog.getExtracted().get(errlog.getExtracted().size() - 1);
- logger.info("setUp: Exiting");
- }
+ logger.info("mismatchTest: mismatchNum found: '" + mismatchNum + "'");
- @After
- public void tearDown() {
- logger.info("tearDown: Entering");
+ // Assert that there are a total of 3 mismatches - 1 between each
+ // comparison node.
+ assertEquals("3", mismatchNum);
+
+ logger.info("mismatchTest: Exit");
+ }
- if (dbDAO != null) {
- dbDAO.destroy();
- }
-
- if (em2 != null) {
- em2.close();
- }
-
- if (emf2 != null) {
- emf2.close();
- }
-
- super.tearDown();
-
- logger.info("tearDown: Exiting");
- }
-
- private void createDb(Properties properties) {
- if (emf2 != null) {
- throw new IllegalStateException("DB2 has already been created");
- }
-
- // open the DB and ensure it stays open until the test completes
- emf2 = Persistence.createEntityManagerFactory(A_SEQ_PU, properties);
- em2 = emf2.createEntityManager();
-
- truncateTable(properties, A_SEQ_PU, "IntegrityAuditEntity");
- }
-
- /*
- * Tests printing an error to the log in the event where there are no
- * entities saved in the database
- */
- @Test
- public void noEntitiesTest() throws Exception {
- Properties properties = makeProperties();
-
- logger.info("noEntitiesTest: Entering");
-
- dbDAO = new DbDAO(resourceName, A_SEQ_PU, properties);
- dbDAO.deleteAllIntegrityAuditEntities();
- try {
- DbAudit dbAudit = new DbAudit(dbDAO);
- dbAudit.dbAudit(resourceName, A_SEQ_PU, nodeType);
- fail("found unexpected entities");
-
- } catch (DbAuditException e) {
-
- }
-
- logger.info("noEntitiesTest: Exit");
- }
-
- /*
- * Tests the detection of only one entry in the database
- */
- @Test
- public void oneEntityTest() throws Exception {
- Properties properties = makeProperties();
-
- logger.info("oneEntityTest: Entering");
-
- ExtractAppender log = watch(debugLogger, "DbAudit: Found only (one) IntegrityAuditEntity entry:");
-
- // Add one entry in the database
- dbDAO = new DbDAO(resourceName, A_SEQ_PU, properties);
- DbAudit dbAudit = new DbAudit(dbDAO);
- dbAudit.dbAudit(resourceName, A_SEQ_PU, nodeType);
-
- List<IntegrityAuditEntity> iaeList = dbDAO.getIntegrityAuditEntities(A_SEQ_PU, nodeType);
- logger.info("List size: " + iaeList.size());
-
- verifyItemsInLog(log, "one");
-
- logger.info("oneEntityTest: Exit");
- }
-
- /*
- * Tests reporting mismatches and missing entries using the error log
- */
- @Test
- public void mismatchTest() throws Exception {
- logger.info("mismatchTest: Entering");
-
- // use new URLs so we get a completely new DB
- String dbUrl = DbAuditTest.dbUrl + "_mismatchTest";
- String dbUrl2 = dbUrl + "2";
-
- Properties properties = makeProperties();
- properties.put(IntegrityAuditProperties.DB_URL, dbUrl);
-
- // Properties for DB2
- Properties properties2 = makeProperties();
- properties2.put(IntegrityAuditProperties.DB_URL, dbUrl2);
-
- /*
- * We must drop and re-create DB1 so that it's sequence generator is in
- * step with the sequence generator for DB2.
- */
- recreateDb1(properties);
-
- // create/open DB2
- createDb(properties2);
-
- ExtractAppender dbglog = watch(debugLogger, "Mismatched entries [(]keys[)]:(.*)");
- ExtractAppender errlog = watch(errorLogger, "DB Audit: ([0-9])");
-
- /*
- * Create entries in DB1 & DB2 for the resource of interest
- */
- dbDAO = new DbDAO(resourceName, A_SEQ_PU, properties);
-
- new DbDAO(resourceName, A_SEQ_PU, properties2).destroy();
-
- /*
- * Entries in DB1, pointing to DB2, except for pdp3
- */
- new DbDAO("pdp2", A_SEQ_PU, properties, dbUrl2).destroy();
- new DbDAO("pdp1", A_SEQ_PU, properties, dbUrl2).destroy();
- new DbDAO("pdp3", A_SEQ_PU, properties).destroy(); // mismatched URL
- new DbDAO("pdp4", A_SEQ_PU, properties, dbUrl2).destroy();
-
- /*
- * Identical entries in DB2, all pointing to DB2, including pdp3, but
- * leaving out pdp4
- */
- new DbDAO("pdp2", A_SEQ_PU, properties2).destroy();
- new DbDAO("pdp1", A_SEQ_PU, properties2).destroy();
- new DbDAO("pdp3", A_SEQ_PU, properties2).destroy();
-
- /*
- * Run the DB Audit, once it finds a mismatch and sleeps, update DB1 to
- * have the same entry as DB2 it can be confirmed that the mismatch is
- * resolved
- */
- DbAudit dbAudit = new DbAudit(dbDAO);
- dbAudit.dbAudit(resourceName, A_SEQ_PU, nodeType);
-
- // update pdp3 entry in DB1 to point to DB2
- new DbDAO("pdp3", A_SEQ_PU, properties, dbUrl2).destroy();
-
- /*
- * Run the audit again and correct the mismatch, the result should be
- * one entry in the mismatchKeySet because of the missing entry from the
- * beginning of the test
- */
- dbAudit.dbAudit(resourceName, A_SEQ_PU, nodeType);
-
- assertFalse(dbglog.getExtracted().isEmpty());
-
- String mismatchIndex = dbglog.getExtracted().get(dbglog.getExtracted().size() - 1);
- int mismatchEntries = mismatchIndex.trim().split(",").length;
- logger.info("mismatchTest: mismatchIndex found: '" + mismatchIndex + "'" + " mismatachEntries = "
- + mismatchEntries);
-
- // Assert there is only one entry index
- assertEquals(1, mismatchEntries);
-
- // Now check the entry in the error.log
- assertFalse(errlog.getExtracted().isEmpty());
-
- String mismatchNum = errlog.getExtracted().get(errlog.getExtracted().size() - 1);
-
- logger.info("mismatchTest: mismatchNum found: '" + mismatchNum + "'");
-
- // Assert that there are a total of 3 mismatches - 1 between each
- // comparison node.
- assertEquals("3", mismatchNum);
-
- logger.info("mismatchTest: Exit");
- }
-
- /**
- * Re-creates DB1, using the specified properties.
- * @param properties
- */
- private void recreateDb1(Properties properties) {
- em.close();
- emf.close();
-
- createDb(properties);
-
- em = em2;
- emf = emf2;
-
- em2 = null;
- emf2 = null;
- }
+ /**
+ * Re-creates DB1, using the specified properties.
+ *
+ * @param properties the properties
+ */
+ private void recreateDb1(Properties properties) {
+ em.close();
+ emf.close();
+
+ createDb(properties);
+
+ em = em2;
+ emf = emf2;
+
+ em2 = null;
+ emf2 = null;
+ }
}
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbDAOTest.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbDAOTest.java
index c4cba280..01e2f2b0 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbDAOTest.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbDAOTest.java
@@ -30,6 +30,7 @@ import static org.junit.Assert.assertTrue;
* where they have write privileges and can execute time-sensitive
* tasks.
*/
+
import java.util.Date;
import java.util.HashSet;
import java.util.List;
@@ -58,393 +59,399 @@ import org.onap.policy.common.utils.jpa.EntityTransCloser;
* tasks.
*/
public class DbDAOTest extends IntegrityAuditTestBase {
- private static String resourceName = "pdp0";
-
- private DbDAO d;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- IntegrityAuditTestBase.setUpBeforeClass(DEFAULT_DB_URL_PREFIX + DbDAOTest.class.getSimpleName());
- }
-
- @AfterClass
- public static void tearDownAfterClass() {
- IntegrityAuditTestBase.tearDownAfterClass();
- }
-
- @Before
- public void setUp() {
- super.setUp();
- d = null;
- }
-
- @After
- public void tearDown() {
- if(d != null) {
- d.destroy();
- }
-
- super.tearDown();
- }
-
- /* Tests registering a new IntegrityAuditEntity object in the DB */
- @Test
- public void testNewRegistration() throws Exception {
- Properties properties = makeProperties();
-
- try(EntityTransCloser et = new EntityTransCloser(em.getTransaction())) {
- d = new DbDAO(resourceName, A_SEQ_PU, properties);
-
- // Find the proper entry in the database
- Query iaequery = em
- .createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
- iaequery.setParameter("rn", DbDAOTest.resourceName);
- iaequery.setParameter("pu", DbDAOTest.A_SEQ_PU);
-
- @SuppressWarnings("rawtypes")
- List iaeList = iaequery.getResultList();
-
- // Assert that the IntegrityAuditEntity object was found
- assertNotNull(iaeList);
-
- // flush to the DB
- em.flush();
- et.commit();
- }
- }
-
- /*
- * Tests updating an IntegrityAuditEntity if it has already been registered
- */
- @Test
- public void testUpdateRegistration() throws Exception {
- Properties properties = makeProperties();
-
- d = new DbDAO(resourceName, A_SEQ_PU, properties);
-
- // Change site_name in properties to test that an update was made to
- // an existing entry in the table
- properties.put(IntegrityAuditProperties.SITE_NAME, "SiteB");
- d = new DbDAO(resourceName, A_SEQ_PU, properties);
-
- try(EntityTransCloser et = new EntityTransCloser(em.getTransaction())) {
- // Find the proper entry in the database
- Query iaequery = em
- .createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
- iaequery.setParameter("rn", DbDAOTest.resourceName);
- iaequery.setParameter("pu", DbDAOTest.A_SEQ_PU);
-
- @SuppressWarnings("rawtypes")
- List iaeList = iaequery.getResultList();
- IntegrityAuditEntity iae = null;
- if (!iaeList.isEmpty()) {
- // ignores multiple results
- iae = (IntegrityAuditEntity) iaeList.get(0);
-
- em.refresh(iae);
- em.persist(iae);
-
- // flush to the DB
- em.flush();
-
- // commit transaction
- et.commit();
-
- // Assert that the site_name for the existing entry was updated
- assertEquals("SiteB", iae.getSite());
- }
- }
- }
-
- /* Tests obtaining all Integrity Audit Entities from a table */
- @Test
- public void testGetIntegrityAuditEntities() throws Exception {
- Properties properties = makeProperties();
-
- // Add some entries to the DB
- d = new DbDAO(resourceName, A_SEQ_PU, properties);
- new DbDAO("pdp1", A_SEQ_PU, properties).destroy();
- properties.put(IntegrityAuditProperties.NODE_TYPE, "pdp_drools");
- new DbDAO("pdp2", A_SEQ_PU, properties).destroy();
-
- List<IntegrityAuditEntity> entities;
- // Obtain entries based on persistenceUnit and nodeType
- entities = d.getIntegrityAuditEntities(A_SEQ_PU, "pdp_xacml");
- assertEquals(2, entities.size());
- }
-
- /* Tests retrieving a DbDAO instance's IntegrityAuditEntity */
- @Test
- public void testGetMyIntegrityAuditEntity() throws Exception {
- Properties properties = makeProperties();
-
- d = new DbDAO(resourceName, A_SEQ_PU, properties);
- IntegrityAuditEntity iae = d.getMyIntegrityAuditEntity();
- // assertEquals("integrityAuditPU", iae.getPersistenceUnit());
- assertEquals(A_SEQ_PU, iae.getPersistenceUnit());
- }
-
- /* Tests obtaining an IntegrityAuditEntity by ID */
- @Test
- public void testGetIntegrityAuditEntity() throws Exception {
- Properties properties = makeProperties();
-
- // Obtain an entry from the database based on ID
- d = new DbDAO(resourceName, A_SEQ_PU, properties);
-
- // Find the proper database entry
- Query iaequery = em
- .createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
- iaequery.setParameter("rn", DbDAOTest.resourceName);
- iaequery.setParameter("pu", DbDAOTest.A_SEQ_PU);
-
- @SuppressWarnings("rawtypes")
- List iaeList = iaequery.getResultList();
- IntegrityAuditEntity iae = null;
- if (!iaeList.isEmpty()) {
- // ignores multiple results
- iae = (IntegrityAuditEntity) iaeList.get(0);
-
- // refresh the object from DB in case cached data was returned
- em.refresh(iae);
-
- // Obtain ID for an IntegrityAuditEntity
- PersistenceUnitUtil util = emf.getPersistenceUnitUtil();
- Object iaeId = util.getIdentifier(iae);
-
- // Obtain the same IntegrityAuditEntity based on ID
- IntegrityAuditEntity iaeDuplicate = d.getIntegrityAuditEntity((long) iaeId);
- Object duplicateId = util.getIdentifier(iaeDuplicate);
-
- // Assert that the proper entry was retrieved based on ID
- assertEquals((long) iaeId, (long) duplicateId);
- }
- }
-
- /* Tests setting an IntegrityAuditEntity as the designated node */
- @Test
- public void testSetDesignated() throws Exception {
- Properties properties = makeProperties();
-
- try(EntityTransCloser et = new EntityTransCloser(em.getTransaction())) {
- // Create an entry and set it's designated field to true
- d = new DbDAO(resourceName, A_SEQ_PU, properties);
- d.setDesignated(resourceName, A_SEQ_PU, true);
-
- // Find the proper entry in the database
- Query iaequery = em
- .createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
- iaequery.setParameter("rn", resourceName);
- iaequery.setParameter("pu", A_SEQ_PU);
-
- @SuppressWarnings("rawtypes")
- List iaeList = iaequery.getResultList();
- IntegrityAuditEntity iae = null;
-
- if (!iaeList.isEmpty()) {
- // ignores multiple results
- iae = (IntegrityAuditEntity) iaeList.get(0);
- em.refresh(iae);
-
- // Check if the node is designated
- boolean result = iae.isDesignated();
-
- // Assert that it is designated
- assertTrue(result);
- }
-
- // flush to the DB
- em.flush();
-
- // close the transaction
- et.commit();
- }
- }
-
- /* Tests that the lastUpdated column in the database is updated properly */
- @Test
- public void testSetLastUpdated() throws Exception {
- Properties properties = makeProperties();
-
- try(EntityTransCloser et = new EntityTransCloser(em.getTransaction())) {
- // Create an entry
- d = new DbDAO(resourceName, A_SEQ_PU, properties);
-
- // Find the proper entry in the database
- Query iaequery = em
- .createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
- iaequery.setParameter("rn", resourceName);
- iaequery.setParameter("pu", A_SEQ_PU);
-
- @SuppressWarnings("rawtypes")
- List iaeList = iaequery.getResultList();
- IntegrityAuditEntity iae = null;
-
- if (!iaeList.isEmpty()) {
- // ignores multiple results
- iae = (IntegrityAuditEntity) iaeList.get(0);
- // refresh the object from DB in case cached data was returned
- em.refresh(iae);
-
- // Obtain old update value and set new update value
- Date oldDate = iae.getLastUpdated();
-
- // ensure dates are different by sleeping for a bit
- Thread.sleep(1);
-
- iae.setSite("SiteB");
- iae.setLastUpdated(new Date());
- Date newDate = iae.getLastUpdated();
-
- em.persist(iae);
- // flush to the DB
- em.flush();
- // close the transaction
- et.commit();
-
- // Assert that the old and new update times are different
- assertNotEquals(oldDate, newDate);
- }
- }
- }
-
- /* Tests that all the entries from a class can be retrieved */
- @Test
- public void testGetAllMyEntriesString() throws Exception {
- Properties properties = makeProperties();
-
- // create entries for the IntegrityAuditEntity table
- d = new DbDAO(resourceName, A_SEQ_PU, properties);
- new DbDAO("pdp1", A_SEQ_PU, properties).destroy();
- new DbDAO("pdp2", A_SEQ_PU, properties).destroy();
-
- // Obtain a hash with the persisted objects
- Map<Object, Object> entries = d.getAllMyEntries("org.onap.policy.common.ia.jpa.IntegrityAuditEntity");
-
- // Assert there were 3 entries for that class
- assertEquals(3, entries.size());
- }
-
- /*
- * Tests retrieving all entities in a Persistence Unit using the class name
- * and a hashset of IDs
- */
- @Test
- public void testGetAllMyEntriesStringHashSet() throws Exception {
- Properties properties = makeProperties();
-
- // create entries for the IntegrityAuditEntity table
- d = new DbDAO(resourceName, A_SEQ_PU, properties);
- new DbDAO("pdp1", A_SEQ_PU, properties).destroy();
- new DbDAO("pdp2", A_SEQ_PU, properties).destroy();
-
- // Obtain all entity keys
- CriteriaBuilder cb = em.getCriteriaBuilder();
- CriteriaQuery<Object> cq = cb.createQuery();
- Root<?> rootEntry = cq.from(Class.forName("org.onap.policy.common.ia.jpa.IntegrityAuditEntity"));
- CriteriaQuery<Object> all = cq.select(rootEntry);
- TypedQuery<Object> allQuery = em.createQuery(all);
- List<Object> objectList = allQuery.getResultList();
- HashSet<Object> resultSet = new HashSet<Object>();
- PersistenceUnitUtil util = emf.getPersistenceUnitUtil();
- for (Object o : objectList) {
- Object key = util.getIdentifier(o);
- resultSet.add(key);
- }
-
- // Obtain a hash with the persisted objects
- Map<Object, Object> entries = d.getAllMyEntries("org.onap.policy.common.ia.jpa.IntegrityAuditEntity",
- resultSet);
-
- // Assert there were 3 entries for that class
- assertEquals(3, entries.size());
- }
-
- /*
- * Tests retrieving all entities in a Persistence Unit using the persistence
- * unit, properties, and class name
- */
- @Test
- public void testGetAllEntriesStringPropertiesString() throws Exception {
- Properties properties = makeProperties();
-
- // create entries for the IntegrityAuditEntity table
- d = new DbDAO(resourceName, A_SEQ_PU, properties);
- new DbDAO("pdp1", A_SEQ_PU, properties).destroy();
- new DbDAO("pdp2", A_SEQ_PU, properties).destroy();
-
- // Obtain a hash with the persisted objects
- Map<Object, Object> entries = d.getAllEntries("integrityAuditPU", properties,
- "org.onap.policy.common.ia.jpa.IntegrityAuditEntity");
-
- // Assert there were 3 entries for that class
- assertEquals(3, entries.size());
- }
-
- /*
- * Tests retrieving all entities in a Persistence Unit using the persistence
- * unit, properties, class name, and a hashset of IDs
- */
- @Test
- public void testGetAllEntriesStringPropertiesStringHashSet() throws Exception {
- Properties properties = makeProperties();
-
- // create entries for the IntegrityAuditEntity table
- d = new DbDAO(resourceName, A_SEQ_PU, properties);
- new DbDAO("pdp1", A_SEQ_PU, properties).destroy();
- new DbDAO("pdp2", A_SEQ_PU, properties).destroy();
-
- // Obtain all entity keys
- CriteriaBuilder cb = em.getCriteriaBuilder();
- CriteriaQuery<Object> cq = cb.createQuery();
- Root<?> rootEntry = cq.from(Class.forName("org.onap.policy.common.ia.jpa.IntegrityAuditEntity"));
- CriteriaQuery<Object> all = cq.select(rootEntry);
- TypedQuery<Object> allQuery = em.createQuery(all);
- List<Object> objectList = allQuery.getResultList();
- HashSet<Object> resultSet = new HashSet<Object>();
- PersistenceUnitUtil util = emf.getPersistenceUnitUtil();
- for (Object o : objectList) {
- Object key = util.getIdentifier(o);
- resultSet.add(key);
- }
-
- // Obtain a hash with the persisted objects
- Map<Object, Object> entries = d.getAllEntries("integrityAuditPU", properties,
- "org.onap.policy.common.ia.jpa.IntegrityAuditEntity", resultSet);
-
- // Assert there were 3 entries for that class
- assertEquals(3, entries.size());
- }
-
- /*
- * Tests getting all the entries from a class based on persistenceUnit,
- * properties, and className
- */
- @Test
- public void testGetAllEntries() throws Exception {
- Properties properties = makeProperties();
-
- // create entries for the IntegrityAuditEntity table
- d = new DbDAO(resourceName, A_SEQ_PU, properties);
- new DbDAO("pdp1", A_SEQ_PU, properties).destroy();
- new DbDAO("pdp2", A_SEQ_PU, properties).destroy();
-
- // Obtain a hash with the persisted objects
- Map<Object, Object> entries = d.getAllEntries(A_SEQ_PU, properties,
- "org.onap.policy.common.ia.jpa.IntegrityAuditEntity");
-
- // Assert there were 3 entries for that class
- assertEquals(3, entries.size());
- }
-
- /* Tests obtaining all class names of persisted classes */
- public void testGetPersistenceClassNames() throws Exception {
- Properties properties = makeProperties();
-
- d = new DbDAO(resourceName, A_SEQ_PU, properties);
-
- // Retrieve persistence class names
- Set<String> result = d.getPersistenceClassNames();
- assertEquals(1, result.size());
- }
+ private static String resourceName = "pdp0";
+
+ private DbDAO dbDao;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ IntegrityAuditTestBase.setUpBeforeClass(DEFAULT_DB_URL_PREFIX + DbDAOTest.class.getSimpleName());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ IntegrityAuditTestBase.tearDownAfterClass();
+ }
+
+ @Override
+ @Before
+ public void setUp() {
+ super.setUp();
+ dbDao = null;
+ }
+
+ /**
+ * Tear down after test cases.
+ */
+ @Override
+ @After
+ public void tearDown() {
+ if (dbDao != null) {
+ dbDao.destroy();
+ }
+
+ super.tearDown();
+ }
+
+ /* Tests registering a new IntegrityAuditEntity object in the DB */
+ @Test
+ public void testNewRegistration() throws Exception {
+ Properties properties = makeProperties();
+
+ try (EntityTransCloser et = new EntityTransCloser(em.getTransaction())) {
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, properties);
+
+ // Find the proper entry in the database
+ Query iaequery = em.createQuery(
+ "Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", DbDAOTest.resourceName);
+ iaequery.setParameter("pu", DbDAOTest.A_SEQ_PU);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList = iaequery.getResultList();
+
+ // Assert that the IntegrityAuditEntity object was found
+ assertNotNull(iaeList);
+
+ // flush to the DB
+ em.flush();
+ et.commit();
+ }
+ }
+
+ /*
+ * Tests updating an IntegrityAuditEntity if it has already been registered
+ */
+ @Test
+ public void testUpdateRegistration() throws Exception {
+ Properties properties = makeProperties();
+
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, properties);
+
+ // Change site_name in properties to test that an update was made to
+ // an existing entry in the table
+ properties.put(IntegrityAuditProperties.SITE_NAME, "SiteB");
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, properties);
+
+ try (EntityTransCloser et = new EntityTransCloser(em.getTransaction())) {
+ // Find the proper entry in the database
+ Query iaequery = em.createQuery(
+ "Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", DbDAOTest.resourceName);
+ iaequery.setParameter("pu", DbDAOTest.A_SEQ_PU);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList = iaequery.getResultList();
+ IntegrityAuditEntity iae = null;
+ if (!iaeList.isEmpty()) {
+ // ignores multiple results
+ iae = (IntegrityAuditEntity) iaeList.get(0);
+
+ em.refresh(iae);
+ em.persist(iae);
+
+ // flush to the DB
+ em.flush();
+
+ // commit transaction
+ et.commit();
+
+ // Assert that the site_name for the existing entry was updated
+ assertEquals("SiteB", iae.getSite());
+ }
+ }
+ }
+
+ /* Tests obtaining all Integrity Audit Entities from a table */
+ @Test
+ public void testGetIntegrityAuditEntities() throws Exception {
+ Properties properties = makeProperties();
+
+ // Add some entries to the DB
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, properties);
+ new DbDAO("pdp1", A_SEQ_PU, properties).destroy();
+ properties.put(IntegrityAuditProperties.NODE_TYPE, "pdp_drools");
+ new DbDAO("pdp2", A_SEQ_PU, properties).destroy();
+
+ List<IntegrityAuditEntity> entities;
+ // Obtain entries based on persistenceUnit and nodeType
+ entities = dbDao.getIntegrityAuditEntities(A_SEQ_PU, "pdp_xacml");
+ assertEquals(2, entities.size());
+ }
+
+ /* Tests retrieving a DbDAO instance's IntegrityAuditEntity */
+ @Test
+ public void testGetMyIntegrityAuditEntity() throws Exception {
+ Properties properties = makeProperties();
+
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, properties);
+ IntegrityAuditEntity iae = dbDao.getMyIntegrityAuditEntity();
+ // assertEquals("integrityAuditPU", iae.getPersistenceUnit());
+ assertEquals(A_SEQ_PU, iae.getPersistenceUnit());
+ }
+
+ /* Tests obtaining an IntegrityAuditEntity by ID */
+ @Test
+ public void testGetIntegrityAuditEntity() throws Exception {
+ Properties properties = makeProperties();
+
+ // Obtain an entry from the database based on ID
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, properties);
+
+ // Find the proper database entry
+ Query iaequery = em
+ .createQuery("Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", DbDAOTest.resourceName);
+ iaequery.setParameter("pu", DbDAOTest.A_SEQ_PU);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList = iaequery.getResultList();
+ IntegrityAuditEntity iae = null;
+ if (!iaeList.isEmpty()) {
+ // ignores multiple results
+ iae = (IntegrityAuditEntity) iaeList.get(0);
+
+ // refresh the object from DB in case cached data was returned
+ em.refresh(iae);
+
+ // Obtain ID for an IntegrityAuditEntity
+ PersistenceUnitUtil util = emf.getPersistenceUnitUtil();
+ Object iaeId = util.getIdentifier(iae);
+
+ // Obtain the same IntegrityAuditEntity based on ID
+ IntegrityAuditEntity iaeDuplicate = dbDao.getIntegrityAuditEntity((long) iaeId);
+ Object duplicateId = util.getIdentifier(iaeDuplicate);
+
+ // Assert that the proper entry was retrieved based on ID
+ assertEquals((long) iaeId, (long) duplicateId);
+ }
+ }
+
+ /* Tests setting an IntegrityAuditEntity as the designated node */
+ @Test
+ public void testSetDesignated() throws Exception {
+ Properties properties = makeProperties();
+
+ try (EntityTransCloser et = new EntityTransCloser(em.getTransaction())) {
+ // Create an entry and set it's designated field to true
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, properties);
+ dbDao.setDesignated(resourceName, A_SEQ_PU, true);
+
+ // Find the proper entry in the database
+ Query iaequery = em.createQuery(
+ "Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", resourceName);
+ iaequery.setParameter("pu", A_SEQ_PU);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList = iaequery.getResultList();
+ IntegrityAuditEntity iae = null;
+
+ if (!iaeList.isEmpty()) {
+ // ignores multiple results
+ iae = (IntegrityAuditEntity) iaeList.get(0);
+ em.refresh(iae);
+
+ // Check if the node is designated
+ boolean result = iae.isDesignated();
+
+ // Assert that it is designated
+ assertTrue(result);
+ }
+
+ // flush to the DB
+ em.flush();
+
+ // close the transaction
+ et.commit();
+ }
+ }
+
+ /* Tests that the lastUpdated column in the database is updated properly */
+ @Test
+ public void testSetLastUpdated() throws Exception {
+ Properties properties = makeProperties();
+
+ try (EntityTransCloser et = new EntityTransCloser(em.getTransaction())) {
+ // Create an entry
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, properties);
+
+ // Find the proper entry in the database
+ Query iaequery = em.createQuery(
+ "Select i from IntegrityAuditEntity i where i.resourceName=:rn and i.persistenceUnit=:pu");
+ iaequery.setParameter("rn", resourceName);
+ iaequery.setParameter("pu", A_SEQ_PU);
+
+ @SuppressWarnings("rawtypes")
+ List iaeList = iaequery.getResultList();
+ IntegrityAuditEntity iae = null;
+
+ if (!iaeList.isEmpty()) {
+ // ignores multiple results
+ iae = (IntegrityAuditEntity) iaeList.get(0);
+ // refresh the object from DB in case cached data was returned
+ em.refresh(iae);
+
+ // Obtain old update value and set new update value
+ final Date oldDate = iae.getLastUpdated();
+
+ // ensure dates are different by sleeping for a bit
+ Thread.sleep(1);
+
+ iae.setSite("SiteB");
+ iae.setLastUpdated(new Date());
+ final Date newDate = iae.getLastUpdated();
+
+ em.persist(iae);
+ // flush to the DB
+ em.flush();
+ // close the transaction
+ et.commit();
+
+ // Assert that the old and new update times are different
+ assertNotEquals(oldDate, newDate);
+ }
+ }
+ }
+
+ /* Tests that all the entries from a class can be retrieved */
+ @Test
+ public void testGetAllMyEntriesString() throws Exception {
+ Properties properties = makeProperties();
+
+ // create entries for the IntegrityAuditEntity table
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, properties);
+ new DbDAO("pdp1", A_SEQ_PU, properties).destroy();
+ new DbDAO("pdp2", A_SEQ_PU, properties).destroy();
+
+ // Obtain a hash with the persisted objects
+ Map<Object, Object> entries = dbDao.getAllMyEntries("org.onap.policy.common.ia.jpa.IntegrityAuditEntity");
+
+ // Assert there were 3 entries for that class
+ assertEquals(3, entries.size());
+ }
+
+ /*
+ * Tests retrieving all entities in a Persistence Unit using the class name and a hashset of IDs
+ */
+ @Test
+ public void testGetAllMyEntriesStringHashSet() throws Exception {
+ Properties properties = makeProperties();
+
+ // create entries for the IntegrityAuditEntity table
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, properties);
+ new DbDAO("pdp1", A_SEQ_PU, properties).destroy();
+ new DbDAO("pdp2", A_SEQ_PU, properties).destroy();
+
+ // Obtain all entity keys
+ CriteriaBuilder cb = em.getCriteriaBuilder();
+ CriteriaQuery<Object> cq = cb.createQuery();
+ Root<?> rootEntry = cq.from(Class.forName("org.onap.policy.common.ia.jpa.IntegrityAuditEntity"));
+ CriteriaQuery<Object> all = cq.select(rootEntry);
+ TypedQuery<Object> allQuery = em.createQuery(all);
+ List<Object> objectList = allQuery.getResultList();
+ HashSet<Object> resultSet = new HashSet<Object>();
+ PersistenceUnitUtil util = emf.getPersistenceUnitUtil();
+ for (Object o : objectList) {
+ Object key = util.getIdentifier(o);
+ resultSet.add(key);
+ }
+
+ // Obtain a hash with the persisted objects
+ Map<Object, Object> entries =
+ dbDao.getAllMyEntries("org.onap.policy.common.ia.jpa.IntegrityAuditEntity", resultSet);
+
+ // Assert there were 3 entries for that class
+ assertEquals(3, entries.size());
+ }
+
+ /*
+ * Tests retrieving all entities in a Persistence Unit using the persistence unit, properties,
+ * and class name
+ */
+ @Test
+ public void testGetAllEntriesStringPropertiesString() throws Exception {
+ Properties properties = makeProperties();
+
+ // create entries for the IntegrityAuditEntity table
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, properties);
+ new DbDAO("pdp1", A_SEQ_PU, properties).destroy();
+ new DbDAO("pdp2", A_SEQ_PU, properties).destroy();
+
+ // Obtain a hash with the persisted objects
+ Map<Object, Object> entries = dbDao.getAllEntries("integrityAuditPU", properties,
+ "org.onap.policy.common.ia.jpa.IntegrityAuditEntity");
+
+ // Assert there were 3 entries for that class
+ assertEquals(3, entries.size());
+ }
+
+ /*
+ * Tests retrieving all entities in a Persistence Unit using the persistence unit, properties,
+ * class name, and a hashset of IDs
+ */
+ @Test
+ public void testGetAllEntriesStringPropertiesStringHashSet() throws Exception {
+ Properties properties = makeProperties();
+
+ // create entries for the IntegrityAuditEntity table
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, properties);
+ new DbDAO("pdp1", A_SEQ_PU, properties).destroy();
+ new DbDAO("pdp2", A_SEQ_PU, properties).destroy();
+
+ // Obtain all entity keys
+ CriteriaBuilder cb = em.getCriteriaBuilder();
+ CriteriaQuery<Object> cq = cb.createQuery();
+ Root<?> rootEntry = cq.from(Class.forName("org.onap.policy.common.ia.jpa.IntegrityAuditEntity"));
+ CriteriaQuery<Object> all = cq.select(rootEntry);
+ TypedQuery<Object> allQuery = em.createQuery(all);
+ List<Object> objectList = allQuery.getResultList();
+ HashSet<Object> resultSet = new HashSet<Object>();
+ PersistenceUnitUtil util = emf.getPersistenceUnitUtil();
+ for (Object o : objectList) {
+ Object key = util.getIdentifier(o);
+ resultSet.add(key);
+ }
+
+ // Obtain a hash with the persisted objects
+ Map<Object, Object> entries = dbDao.getAllEntries("integrityAuditPU", properties,
+ "org.onap.policy.common.ia.jpa.IntegrityAuditEntity", resultSet);
+
+ // Assert there were 3 entries for that class
+ assertEquals(3, entries.size());
+ }
+
+ /*
+ * Tests getting all the entries from a class based on persistenceUnit, properties, and
+ * className
+ */
+ @Test
+ public void testGetAllEntries() throws Exception {
+ Properties properties = makeProperties();
+
+ // create entries for the IntegrityAuditEntity table
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, properties);
+ new DbDAO("pdp1", A_SEQ_PU, properties).destroy();
+ new DbDAO("pdp2", A_SEQ_PU, properties).destroy();
+
+ // Obtain a hash with the persisted objects
+ Map<Object, Object> entries =
+ dbDao.getAllEntries(A_SEQ_PU, properties, "org.onap.policy.common.ia.jpa.IntegrityAuditEntity");
+
+ // Assert there were 3 entries for that class
+ assertEquals(3, entries.size());
+ }
+
+ /**
+ * Tests obtaining all class names of persisted classes.
+ */
+ public void testGetPersistenceClassNames() throws Exception {
+ Properties properties = makeProperties();
+
+ dbDao = new DbDAO(resourceName, A_SEQ_PU, properties);
+
+ // Retrieve persistence class names
+ Set<String> result = dbDao.getPersistenceClassNames();
+ assertEquals(1, result.size());
+ }
}
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/ExceptionsTest.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/ExceptionsTest.java
index b02b0c7f..3c8ce528 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/ExceptionsTest.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/ExceptionsTest.java
@@ -23,10 +23,6 @@ package org.onap.policy.common.ia;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
-import org.onap.policy.common.ia.DbAuditException;
-import org.onap.policy.common.ia.DbDaoTransactionException;
-import org.onap.policy.common.ia.IntegrityAuditException;
-import org.onap.policy.common.ia.IntegrityAuditPropertiesException;
import org.onap.policy.common.utils.test.ExceptionsTester;
/**
@@ -34,23 +30,23 @@ import org.onap.policy.common.utils.test.ExceptionsTester;
*/
public class ExceptionsTest extends ExceptionsTester {
- @Test
- public void testDbAuditException() throws Exception {
- assertEquals(4, test(DbAuditException.class));
- }
-
- @Test
- public void testDbDaoTransactionException() throws Exception {
- assertEquals(4, test(DbDaoTransactionException.class));
- }
-
- @Test
- public void testIntegrityAuditException() throws Exception {
- assertEquals(4, test(IntegrityAuditException.class));
- }
-
- @Test
- public void testIntegrityAuditPropertiesException() throws Exception {
- assertEquals(4, test(IntegrityAuditPropertiesException.class));
- }
+ @Test
+ public void testDbAuditException() throws Exception {
+ assertEquals(4, test(DbAuditException.class));
+ }
+
+ @Test
+ public void testDbDaoTransactionException() throws Exception {
+ assertEquals(4, test(DbDaoTransactionException.class));
+ }
+
+ @Test
+ public void testIntegrityAuditException() throws Exception {
+ assertEquals(4, test(IntegrityAuditException.class));
+ }
+
+ @Test
+ public void testIntegrityAuditPropertiesException() throws Exception {
+ assertEquals(4, test(IntegrityAuditPropertiesException.class));
+ }
}
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditDesignationTest.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditDesignationTest.java
index 1861787a..69f37da5 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditDesignationTest.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditDesignationTest.java
@@ -30,590 +30,573 @@ import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.common.utils.test.log.logback.ExtractAppender;
/**
- * All JUnits are designed to run in the local development environment where
- * they have write privileges and can execute time-sensitive tasks.
- * <p/>
- * Many of the test verification steps are performed by scanning for items
- * written to the log file. Rather than actually scan the log file, an
- * {@link ExtractAppender} is used to monitor events that are logged and extract
- * relevant items. In order to attach the appender to the debug log, it assumes
- * that the debug log is a <i>logback</i> Logger configured per EELF.
- * <p/>
- * These tests use a temporary, in-memory DB, which is dropped once the tests
- * complete.
+ * All JUnits are designed to run in the local development environment where they have write
+ * privileges and can execute time-sensitive tasks.
+ *
+ * <p>Many of the test verification steps are performed by scanning for items written to the log
+ * file. Rather than actually scan the log file, an {@link ExtractAppender} is used to monitor
+ * events that are logged and extract relevant items. In order to attach the appender to the debug
+ * log, it assumes that the debug log is a <i>logback</i> Logger configured per EELF.
+ *
+ * <p>These tests use a temporary, in-memory DB, which is dropped once the tests complete.
*/
public class IntegrityAuditDesignationTest extends IntegrityAuditTestBase {
- private static Logger logger = FlexLogger.getLogger(IntegrityAuditDesignationTest.class);
-
- /**
- * Matches specified PDPs in the debug log. A regular expression matching
- * the desired PDPs should be appended, followed by a right parenthesis. For
- * example:
- *
- * <pre>
- * <code>new ExtractAppender(START_AUDIT_RE_PREFIX + "pdp[124])")
- * </code>
- * </pre>
- */
- private static final String START_AUDIT_RE_PREFIX = "Starting audit simulation for resourceName=(";
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- IntegrityAuditTestBase
- .setUpBeforeClass(DEFAULT_DB_URL_PREFIX + IntegrityAuditDesignationTest.class.getSimpleName());
- }
-
- @AfterClass
- public static void tearDownAfterClass() {
- IntegrityAuditTestBase.tearDownAfterClass();
- }
-
- @Before
- public void setUp() {
- logger.info("setUp: Entering");
-
- super.setUp();
-
- logger.info("setUp: Exiting");
- }
-
- @After
- public void tearDown() {
- logger.info("tearDown: Entering");
-
- super.tearDown();
-
- logger.info("tearDown: Exiting");
-
- }
-
- /*
- * Tests designation logic when only one functioning resource is in play.
- * Designation should stay with single resource.
- *
- * Note: console.log must be examined to ascertain whether or not this test
- * was successful.
- */
- @Test
- public void testOneResource() throws Exception {
-
- logger.info("testOneResource: Entering");
-
- ExtractAppender logA = watch(debugLogger, START_AUDIT_RE);
-
- MyIntegrityAudit integrityAudit = makeAuditor("pdp1", A_SEQ_PU);
-
- /*
- * Wait for
- *
- * 1) pdp1 to run audit
- *
- * 2) Logic to detect that no other node is available for designation
- *
- * 3) pdp1 to run audit again
- */
- runAudit(integrityAudit);
- waitStaleAndRun(integrityAudit);
-
- logger.info("testOneResource: Stopping audit thread");
- integrityAudit.stopAuditThread();
-
- verifyItemsInLog(logA, "pdp1");
-
- /*
- * Test fix for ONAPD2TD-783: Audit fails to run when application is
- * restarted.
- */
- integrityAudit.startAuditThread();
-
- /*
- * Sleep long enough to allow
- *
- * 1) pdp1 to run audit
- *
- * 2) Logic to detect that no other node is available for designation
- *
- * 3) pdp1 to run audit again
- */
- runAudit(integrityAudit);
- waitStaleAndRun(integrityAudit);
-
- verifyItemsInLog(logA, "pdp1");
-
- logger.info("testOneResource: Exiting");
-
- }
-
- /*
- * Tests designation logic when two functioning resources are in play.
- * Designation should alternate between resources.
- *
- * Note: console.log must be examined to ascertain whether or not this test
- * was successful. A quick way of examining the log is to search for the
- * string "audit simulation":
- *
- * As you can see from the "dbAuditSimulate" method, when it executes, it
- * logs the "Starting audit simulation..." message and when it finishes, it
- * logs the "Finished audit simulation..." message. By looking for these
- * messages, you can verify that the audits are run by the proper resource.
- * For example, when testFourResourcesOneDead is run, you should see a
- * Starting.../Finished... sequence for "pdp1", followed by a
- * Starting.../Finished... sequence for pdp2, followed by a
- * Starting.../Finished... sequence for pdp4 (pdp3 is skipped as it's
- * dead/hung), followed by a Starting.../Finished... sequence for "pdp1",
- * etc.
- */
- @Test
- public void testTwoResources() throws Exception {
-
- logger.info("testTwoResources: Entering");
-
- ExtractAppender logA = watch(debugLogger, START_AUDIT_RE);
-
- /*
- * Start audit for pdp1.
- */
- MyIntegrityAudit integrityAudit = makeAuditor("pdp1", A_SEQ_PU);
-
- /*
- * Start audit for pdp2.
- */
- MyIntegrityAudit integrityAudit2 = makeAuditor("pdp2", A_SEQ_PU);
-
- /*
- * Sleep long enough to allow
- *
- * 1) pdp1 to run audit
- *
- * 2) Logic to detect that pdp1 is stale and designate pdp2
- *
- * 3) pdp2 to run audit
- *
- * 4) Logic to detect that pdp2 is stale and designate pdp1
- *
- * 5) pdp1 to run audit
- */
- runAudit(integrityAudit);
- waitStaleAndRun(integrityAudit2);
- waitStaleAndRun(integrityAudit);
-
- verifyItemsInLog(logA, "pdp1", "pdp2", "pdp1");
-
- logger.info("testTwoResources: Exiting");
-
- }
-
- /*
- * Tests designation logic when two functioning resources are in play, each
- * with different PUs. Audits for persistenceUnit and PU_B should run
- * simultaneously. Designation should not alternate.
- *
- * Note: console.log must be examined to ascertain whether or not this test
- * was successful.
- */
- @Test
- public void testTwoResourcesDifferentPus() throws Exception {
-
- logger.info("testTwoResourcesDifferentPus: Entering");
-
- ExtractAppender logA = watch(debugLogger, START_AUDIT_RE_PREFIX + "pdp1)");
- ExtractAppender logB = watch(debugLogger, START_AUDIT_RE_PREFIX + "pdp2)");
-
- /*
- * Start audit for pdp1.
- */
- MyIntegrityAudit integrityAudit = makeAuditor("pdp1", A_SEQ_PU);
-
- /*
- * Start audit for pdp2.
- */
- MyIntegrityAudit integrityAudit2 = makeAuditor("pdp2", B_SEQ_PU);
-
- /*
- * Sleep long enough to allow
- *
- * 1) pdp1 and pdp2 to run audit simultaneously
- *
- * 2) Logic to detect that no other node is available for designation
- * for either pdp1 or pdp2
- *
- * 3) pdp1 and pdp2 to again run audit simultaneously
- */
- runAudit(integrityAudit, integrityAudit2);
- waitStaleAndRun(integrityAudit, integrityAudit2);
-
- verifyItemsInLog(logA, "pdp1", "pdp1");
- verifyItemsInLog(logB, "pdp2", "pdp2");
-
- logger.info("testTwoResourcesDifferentPus: Exiting");
-
- }
-
- /*
- * Tests designation logic when two resources are in play but one of them is
- * dead/hung. Designation should move to second resource but then get
- * restored back to original resource when it's discovered that second
- * resource is dead.
- *
- * Note: console.log must be examined to ascertain whether or not this test
- * was successful.
- */
- @Test
- public void testTwoResourcesOneDead() throws Exception {
-
- logger.info("testTwoResourcesOneDead: Entering");
-
- ExtractAppender logA = watch(debugLogger, START_AUDIT_RE);
-
- /*
- * Start audit for pdp1.
- */
- MyIntegrityAudit integrityAudit = makeAuditor("pdp1", A_SEQ_PU);
-
- /*
- * Populate DB for pdp2, which will simulate it having registered but
- * then having died.
- */
- new DbDAO("pdp2", A_SEQ_PU, makeProperties()).destroy();
-
- /*
- * Sleep long enough to allow
- *
- * 1) pdp1 to run audit
- *
- * 2) Logic to detect that other node, pdp2, is not available for
- * designation
- *
- * 3) pdp1 to run audit again
- */
- runAudit(integrityAudit);
- waitStaleAndRun(integrityAudit);
-
- verifyItemsInLog(logA, "pdp1", "pdp1");
-
- logger.info("testTwoResourcesOneDead: Exiting");
-
- }
-
- /*
- * Tests designation logic when three functioning resources are in play.
- * Designation should round robin among resources.
- *
- * Note: console.log must be examined to ascertain whether or not this test
- * was successful.
- */
- @Test
- public void testThreeResources() throws Exception {
-
- logger.info("testThreeResources: Entering");
-
- ExtractAppender logA = watch(debugLogger, START_AUDIT_RE);
-
- /*
- * Start audit for pdp1.
- */
- MyIntegrityAudit integrityAudit = makeAuditor("pdp1", A_SEQ_PU);
-
- /*
- * Start audit for pdp2.
- */
- MyIntegrityAudit integrityAudit2 = makeAuditor("pdp2", A_SEQ_PU);
-
- /*
- * Start audit for pdp3.
- */
- MyIntegrityAudit integrityAudit3 = makeAuditor("pdp3", A_SEQ_PU);
-
- /*
- * Sleep long enough to allow
- *
- * 1) pdp1 to run audit
- *
- * 2) Logic to detect that pdp1 is stale and designate pdp2
- *
- * 3) pdp2 to run audit
- *
- * 4) Logic to detect that pdp2 is stale and designate pdp3
- *
- * 5) pdp3 to run audit
- *
- * 6) Logic to detect that pdp3 is stale and designate pdp1
- *
- * 7) pdp1 to run audit
- */
- runAudit(integrityAudit);
- waitStaleAndRun(integrityAudit2);
- waitStaleAndRun(integrityAudit3);
- waitStaleAndRun(integrityAudit);
-
- verifyItemsInLog(logA, "pdp1", "pdp2", "pdp3", "pdp1");
-
- logger.info("testThreeResources: Exiting");
-
- }
-
- /*
- * Tests designation logic when four functioning resources are in play, two
- * with one PU, two with another. Audits for persistenceUnit and PU_B should
- * run simultaneously. Designation should alternate between resources for
- * each of the two persistence units.
- *
- * Note: console.log must be examined to ascertain whether or not this test
- * was successful.
- */
- @Test
- public void testFourResourcesDifferentPus() throws Exception {
-
- logger.info("testFourResourcesDifferentPus: Entering");
-
- ExtractAppender logA = watch(debugLogger, START_AUDIT_RE_PREFIX + "pdp1|pdp3)");
- ExtractAppender logB = watch(debugLogger, START_AUDIT_RE_PREFIX + "pdp2|pdp4)");
-
- /*
- * Start audit for "pdp1", testPU.
- */
- MyIntegrityAudit integrityAudit = makeAuditor("pdp1", A_SEQ_PU);
-
- /*
- * Start audit for pdp2, integrityAuditPU.
- */
- MyIntegrityAudit integrityAudit2 = makeAuditor("pdp2", B_SEQ_PU);
-
- /*
- * Start audit for pdp3, testPU.
- */
- MyIntegrityAudit integrityAudit3 = makeAuditor("pdp3", A_SEQ_PU);
-
- /*
- * Start audit for pdp4, integrityAuditPU.
- */
- MyIntegrityAudit integrityAudit4 = makeAuditor("pdp4", B_SEQ_PU);
-
- /*
- * Sleep long enough to allow
- *
- * 1) pdp1 and pdp2 to run audit simultaneously
- *
- * 2) Logic to detect that pdp1 and pdp2 are stale and designate pdp3
- * (one's counterpart) and pdp4 (two's counterpart)
- *
- * 3) pdp3 and pdp4 to run audit simultaneously
- *
- * 4) Logic to detect that pdp3 and pdp4 are stale and designate pdp1
- * (three's counterpart) and pdp2 (four's counterpart)
- *
- * 5) pdp1 and pdp2 to run audit simultaneously
- */
- runAudit(integrityAudit, integrityAudit2);
- waitStaleAndRun(integrityAudit3, integrityAudit4);
- waitStaleAndRun(integrityAudit, integrityAudit2);
-
- /*
- * These sequences may be intermingled, so we extract and compare one
- * sequence at a time.
- */
-
- // only care about pdp1 & pdp3 in this sequence
- verifyItemsInLog(logA, "pdp1", "pdp3", "pdp1");
-
- // only care about pdp2 & pdp4 in this sequence
- verifyItemsInLog(logB, "pdp2", "pdp4", "pdp2");
-
- logger.info("testFourResourcesDifferentPus: Exiting");
-
- }
-
- /*
- * Tests designation logic when four resources are in play but one is not
- * functioning. Designation should round robin among functioning resources
- * only.
- *
- * Note: console.log must be examined to ascertain whether or not this test
- * was successful.
- */
- @Test
- public void testFourResourcesOneDead() throws Exception {
-
- logger.info("testFourResourcesOneDead: Entering");
-
- ExtractAppender logA = watch(debugLogger, START_AUDIT_RE);
-
- /*
- * Start audit for pdp1.
- */
- MyIntegrityAudit integrityAudit = makeAuditor("pdp1", A_SEQ_PU);
-
- /*
- * Start audit for pdp2.
- */
- MyIntegrityAudit integrityAudit2 = makeAuditor("pdp2", A_SEQ_PU);
-
- /*
- * Populate DB for pdp3, which will simulate it having registered but
- * then having died.
- */
- new DbDAO("pdp3", A_SEQ_PU, makeProperties()).destroy();
-
- /*
- * Start audit for pdp4.
- */
- MyIntegrityAudit integrityAudit4 = makeAuditor("pdp4", A_SEQ_PU);
-
- /*
- * Sleep long enough to allow
- *
- * 1) pdp1 to run audit
- *
- * 2) Logic to detect that pdp1 is stale and designate pdp2
- *
- * 3) pdp2 to run audit
- *
- * 4) Logic to detect that pdp2 is stale and designate pdp4
- *
- * 5) pdp4 to run audit
- *
- * 6) Logic to detect that pdp4 is stale and designate pdp1
- *
- * 7) pdp1 to run audit
- *
- * 8) Logic to detect that pdp1 is stale and designate pdp2
- *
- * 7) pdp2 to run audit
- */
- runAudit(integrityAudit);
- waitStaleAndRun(integrityAudit2);
- waitStaleAndRun(integrityAudit4);
- waitStaleAndRun(integrityAudit);
- waitStaleAndRun(integrityAudit2);
- waitStaleAndRun(integrityAudit4);
-
- verifyItemsInLog(logA, "pdp1", "pdp2", "pdp4", "pdp1", "pdp2", "pdp4");
-
- logger.info("testFourResourcesOneDead: Exiting");
-
- }
-
- /*
- * Tests designation logic when four resources are in play but only one is
- * functioning. Designation should remain with sole functioning resource.
- *
- * Note: console.log must be examined to ascertain whether or not this test
- * was successful.
- */
- @Test
- public void testFourResourcesThreeDead() throws Exception {
-
- logger.info("testFourResourcesThreeDead: Entering");
-
- ExtractAppender logA = watch(debugLogger, START_AUDIT_RE);
-
- /*
- * Populate DB for "pdp1", which will simulate it having registered but
- * then having died.
- */
- new DbDAO("pdp1", A_SEQ_PU, makeProperties()).destroy();
-
- /*
- * Populate DB for pdp2, which will simulate it having registered but
- * then having died.
- */
- new DbDAO("pdp2", A_SEQ_PU, makeProperties()).destroy();
-
- /*
- * Start audit for pdp3.
- */
- MyIntegrityAudit integrityAudit3 = makeAuditor("pdp3", A_SEQ_PU);
-
- /*
- * Populate DB for pdp4, which will simulate it having registered but
- * then having died.
- */
- new DbDAO("pdp4", A_SEQ_PU, makeProperties()).destroy();
-
- /*
- * Sleep long enough to allow
- *
- * 1) pdp3 to discover that all other designation candidates are stale
- *
- * 1) pdp3 to run audit
- *
- * 2) Logic to detect that no other nodes are available for designation
- *
- * 3) pdp3 to run audit again
- */
- runAudit(integrityAudit3);
- waitStaleAndRun(integrityAudit3);
-
- verifyItemsInLog(logA, "pdp3", "pdp3");
-
- logger.info("testFourResourcesThreeDead: Exiting");
-
- }
-
- /*
- * Tests designation logic when the designated node dies and is no longer
- * current
- *
- * Note: console.log must be examined to ascertain whether or not this test
- * was successful.
- */
- @Test
- public void testDesignatedNodeDead() throws Exception {
- logger.info("testDesignatedNodeDead: Entering");
-
- ExtractAppender logA = watch(debugLogger, START_AUDIT_RE);
-
- /*
- * Instantiate audit object for pdp1.
- */
- MyIntegrityAudit integrityAudit = makeAuditor("pdp1", A_SEQ_PU);
-
- /*
- * Start audit for pdp2.
- */
- MyIntegrityAudit integrityAudit2 = makeAuditor("pdp2", A_SEQ_PU);
-
- /*
- * Instantiate audit object for pdp3.
- */
- MyIntegrityAudit integrityAudit3 = makeAuditor("pdp3", A_SEQ_PU);
-
- // Start audit on pdp1
- logger.info("testDesignatedNodeDead: Start audit on pdp1");
- runAudit(integrityAudit);
-
- // Start the auditing threads on other nodes.
- logger.info("testDesignatedNodeDead: Start audit on pdp2");
- runAudit(integrityAudit2);
-
- // Kill audit on pdp1
- logger.info("testDesignatedNodeDead: Kill audit on pdp1");
- integrityAudit.stopAuditThread();
-
- // Wait long enough for pdp1 to get stale and pdp2 to take over
- waitStaleAndRun(integrityAudit2);
-
- // Start audit thread on pdp1 again.
- logger.info("testDesignatedNodeDead: Start audit thread on pdp1 again.");
- integrityAudit.startAuditThread();
-
- // Wait long enough for pdp2 to complete its audit and get stale, at
- // which point pdp3 should take over
- logger.info(
- "testDesignatedNodeDead: Wait long enough for pdp2 to complete its audit and get stale, at which point pdp3 should take over");
- waitStaleAndRun(integrityAudit3);
-
- // Kill audit on pdp3
- logger.info("testDesignatedNodeDead: Killing audit on pdp3");
- integrityAudit3.stopAuditThread();
-
- // Wait long enough for pdp3 to get stale and pdp1 to take over
- logger.info("testDesignatedNodeDead: Wait long enough for pdp3 to get stale and pdp1 to take over");
- waitStaleAndRun(integrityAudit);
-
- verifyItemsInLog(logA, "pdp1", "pdp2", "pdp3", "pdp1");
-
- logger.info("testDesignatedNodeDead: Exiting");
- }
+ private static Logger logger = FlexLogger.getLogger(IntegrityAuditDesignationTest.class);
+
+ /**
+ * Matches specified PDPs in the debug log. A regular expression matching the desired PDPs
+ * should be appended, followed by a right parenthesis. For example:
+ *
+ * <pre>
+ * <code>new ExtractAppender(START_AUDIT_RE_PREFIX + "pdp[124])")
+ * </code>
+ * </pre>
+ */
+ private static final String START_AUDIT_RE_PREFIX = "Starting audit simulation for resourceName=(";
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ IntegrityAuditTestBase
+ .setUpBeforeClass(DEFAULT_DB_URL_PREFIX + IntegrityAuditDesignationTest.class.getSimpleName());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ IntegrityAuditTestBase.tearDownAfterClass();
+ }
+
+ /**
+ * Set up before test cases.
+ */
+ @Override
+ @Before
+ public void setUp() {
+ logger.info("setUp: Entering");
+
+ super.setUp();
+
+ logger.info("setUp: Exiting");
+ }
+
+ /**
+ * Tear down after test cases.
+ */
+ @Override
+ @After
+ public void tearDown() {
+ logger.info("tearDown: Entering");
+
+ super.tearDown();
+
+ logger.info("tearDown: Exiting");
+
+ }
+
+ /*
+ * Tests designation logic when only one functioning resource is in play. Designation should
+ * stay with single resource.
+ *
+ * Note: console.log must be examined to ascertain whether or not this test was successful.
+ */
+ @Test
+ public void testOneResource() throws Exception {
+
+ logger.info("testOneResource: Entering");
+
+ final ExtractAppender logA = watch(debugLogger, START_AUDIT_RE);
+
+ MyIntegrityAudit integrityAudit = makeAuditor("pdp1", A_SEQ_PU);
+
+ /*
+ * Wait for
+ *
+ * 1) pdp1 to run audit
+ *
+ * 2) Logic to detect that no other node is available for designation
+ *
+ * 3) pdp1 to run audit again
+ */
+ runAudit(integrityAudit);
+ waitStaleAndRun(integrityAudit);
+
+ logger.info("testOneResource: Stopping audit thread");
+ integrityAudit.stopAuditThread();
+
+ verifyItemsInLog(logA, "pdp1");
+
+ /*
+ * Test fix for ONAPD2TD-783: Audit fails to run when application is restarted.
+ */
+ integrityAudit.startAuditThread();
+
+ /*
+ * Sleep long enough to allow
+ *
+ * 1) pdp1 to run audit
+ *
+ * 2) Logic to detect that no other node is available for designation
+ *
+ * 3) pdp1 to run audit again
+ */
+ runAudit(integrityAudit);
+ waitStaleAndRun(integrityAudit);
+
+ verifyItemsInLog(logA, "pdp1");
+
+ logger.info("testOneResource: Exiting");
+
+ }
+
+ /*
+ * Tests designation logic when two functioning resources are in play. Designation should
+ * alternate between resources.
+ *
+ * Note: console.log must be examined to ascertain whether or not this test was successful. A
+ * quick way of examining the log is to search for the string "audit simulation":
+ *
+ * As you can see from the "dbAuditSimulate" method, when it executes, it logs the
+ * "Starting audit simulation..." message and when it finishes, it logs the
+ * "Finished audit simulation..." message. By looking for these messages, you can verify that
+ * the audits are run by the proper resource. For example, when testFourResourcesOneDead is run,
+ * you should see a Starting.../Finished... sequence for "pdp1", followed by a
+ * Starting.../Finished... sequence for pdp2, followed by a Starting.../Finished... sequence for
+ * pdp4 (pdp3 is skipped as it's dead/hung), followed by a Starting.../Finished... sequence for
+ * "pdp1", etc.
+ */
+ @Test
+ public void testTwoResources() throws Exception {
+
+ logger.info("testTwoResources: Entering");
+
+ final ExtractAppender logA = watch(debugLogger, START_AUDIT_RE);
+
+ /*
+ * Start audit for pdp1.
+ */
+ MyIntegrityAudit integrityAudit = makeAuditor("pdp1", A_SEQ_PU);
+
+ /*
+ * Start audit for pdp2.
+ */
+ MyIntegrityAudit integrityAudit2 = makeAuditor("pdp2", A_SEQ_PU);
+
+ /*
+ * Sleep long enough to allow
+ *
+ * 1) pdp1 to run audit
+ *
+ * 2) Logic to detect that pdp1 is stale and designate pdp2
+ *
+ * 3) pdp2 to run audit
+ *
+ * 4) Logic to detect that pdp2 is stale and designate pdp1
+ *
+ * 5) pdp1 to run audit
+ */
+ runAudit(integrityAudit);
+ waitStaleAndRun(integrityAudit2);
+ waitStaleAndRun(integrityAudit);
+
+ verifyItemsInLog(logA, "pdp1", "pdp2", "pdp1");
+
+ logger.info("testTwoResources: Exiting");
+
+ }
+
+ /*
+ * Tests designation logic when two functioning resources are in play, each with different PUs.
+ * Audits for persistenceUnit and PU_B should run simultaneously. Designation should not
+ * alternate.
+ *
+ * Note: console.log must be examined to ascertain whether or not this test was successful.
+ */
+ @Test
+ public void testTwoResourcesDifferentPus() throws Exception {
+
+ logger.info("testTwoResourcesDifferentPus: Entering");
+
+ final ExtractAppender logA = watch(debugLogger, START_AUDIT_RE_PREFIX + "pdp1)");
+ final ExtractAppender logB = watch(debugLogger, START_AUDIT_RE_PREFIX + "pdp2)");
+
+ /*
+ * Start audit for pdp1.
+ */
+ MyIntegrityAudit integrityAudit = makeAuditor("pdp1", A_SEQ_PU);
+
+ /*
+ * Start audit for pdp2.
+ */
+ MyIntegrityAudit integrityAudit2 = makeAuditor("pdp2", B_SEQ_PU);
+
+ /*
+ * Sleep long enough to allow
+ *
+ * 1) pdp1 and pdp2 to run audit simultaneously
+ *
+ * 2) Logic to detect that no other node is available for designation for either pdp1 or
+ * pdp2
+ *
+ * 3) pdp1 and pdp2 to again run audit simultaneously
+ */
+ runAudit(integrityAudit, integrityAudit2);
+ waitStaleAndRun(integrityAudit, integrityAudit2);
+
+ verifyItemsInLog(logA, "pdp1", "pdp1");
+ verifyItemsInLog(logB, "pdp2", "pdp2");
+
+ logger.info("testTwoResourcesDifferentPus: Exiting");
+
+ }
+
+ /*
+ * Tests designation logic when two resources are in play but one of them is dead/hung.
+ * Designation should move to second resource but then get restored back to original resource
+ * when it's discovered that second resource is dead.
+ *
+ * Note: console.log must be examined to ascertain whether or not this test was successful.
+ */
+ @Test
+ public void testTwoResourcesOneDead() throws Exception {
+
+ logger.info("testTwoResourcesOneDead: Entering");
+
+ final ExtractAppender logA = watch(debugLogger, START_AUDIT_RE);
+
+ /*
+ * Start audit for pdp1.
+ */
+ MyIntegrityAudit integrityAudit = makeAuditor("pdp1", A_SEQ_PU);
+
+ /*
+ * Populate DB for pdp2, which will simulate it having registered but then having died.
+ */
+ new DbDAO("pdp2", A_SEQ_PU, makeProperties()).destroy();
+
+ /*
+ * Sleep long enough to allow
+ *
+ * 1) pdp1 to run audit
+ *
+ * 2) Logic to detect that other node, pdp2, is not available for designation
+ *
+ * 3) pdp1 to run audit again
+ */
+ runAudit(integrityAudit);
+ waitStaleAndRun(integrityAudit);
+
+ verifyItemsInLog(logA, "pdp1", "pdp1");
+
+ logger.info("testTwoResourcesOneDead: Exiting");
+
+ }
+
+ /*
+ * Tests designation logic when three functioning resources are in play. Designation should
+ * round robin among resources.
+ *
+ * Note: console.log must be examined to ascertain whether or not this test was successful.
+ */
+ @Test
+ public void testThreeResources() throws Exception {
+
+ logger.info("testThreeResources: Entering");
+
+ final ExtractAppender logA = watch(debugLogger, START_AUDIT_RE);
+
+ /*
+ * Start audit for pdp1.
+ */
+ MyIntegrityAudit integrityAudit = makeAuditor("pdp1", A_SEQ_PU);
+
+ /*
+ * Start audit for pdp2.
+ */
+ MyIntegrityAudit integrityAudit2 = makeAuditor("pdp2", A_SEQ_PU);
+
+ /*
+ * Start audit for pdp3.
+ */
+ MyIntegrityAudit integrityAudit3 = makeAuditor("pdp3", A_SEQ_PU);
+
+ /*
+ * Sleep long enough to allow
+ *
+ * 1) pdp1 to run audit
+ *
+ * 2) Logic to detect that pdp1 is stale and designate pdp2
+ *
+ * 3) pdp2 to run audit
+ *
+ * 4) Logic to detect that pdp2 is stale and designate pdp3
+ *
+ * 5) pdp3 to run audit
+ *
+ * 6) Logic to detect that pdp3 is stale and designate pdp1
+ *
+ * 7) pdp1 to run audit
+ */
+ runAudit(integrityAudit);
+ waitStaleAndRun(integrityAudit2);
+ waitStaleAndRun(integrityAudit3);
+ waitStaleAndRun(integrityAudit);
+
+ verifyItemsInLog(logA, "pdp1", "pdp2", "pdp3", "pdp1");
+
+ logger.info("testThreeResources: Exiting");
+
+ }
+
+ /*
+ * Tests designation logic when four functioning resources are in play, two with one PU, two
+ * with another. Audits for persistenceUnit and PU_B should run simultaneously. Designation
+ * should alternate between resources for each of the two persistence units.
+ *
+ * Note: console.log must be examined to ascertain whether or not this test was successful.
+ */
+ @Test
+ public void testFourResourcesDifferentPus() throws Exception {
+
+ logger.info("testFourResourcesDifferentPus: Entering");
+
+ final ExtractAppender logA = watch(debugLogger, START_AUDIT_RE_PREFIX + "pdp1|pdp3)");
+ final ExtractAppender logB = watch(debugLogger, START_AUDIT_RE_PREFIX + "pdp2|pdp4)");
+
+ /*
+ * Start audit for "pdp1", testPU.
+ */
+ MyIntegrityAudit integrityAudit = makeAuditor("pdp1", A_SEQ_PU);
+
+ /*
+ * Start audit for pdp2, integrityAuditPU.
+ */
+ MyIntegrityAudit integrityAudit2 = makeAuditor("pdp2", B_SEQ_PU);
+
+ /*
+ * Start audit for pdp3, testPU.
+ */
+ MyIntegrityAudit integrityAudit3 = makeAuditor("pdp3", A_SEQ_PU);
+
+ /*
+ * Start audit for pdp4, integrityAuditPU.
+ */
+ MyIntegrityAudit integrityAudit4 = makeAuditor("pdp4", B_SEQ_PU);
+
+ /*
+ * Sleep long enough to allow
+ *
+ * 1) pdp1 and pdp2 to run audit simultaneously
+ *
+ * 2) Logic to detect that pdp1 and pdp2 are stale and designate pdp3 (one's counterpart)
+ * and pdp4 (two's counterpart)
+ *
+ * 3) pdp3 and pdp4 to run audit simultaneously
+ *
+ * 4) Logic to detect that pdp3 and pdp4 are stale and designate pdp1 (three's counterpart)
+ * and pdp2 (four's counterpart)
+ *
+ * 5) pdp1 and pdp2 to run audit simultaneously
+ */
+ runAudit(integrityAudit, integrityAudit2);
+ waitStaleAndRun(integrityAudit3, integrityAudit4);
+ waitStaleAndRun(integrityAudit, integrityAudit2);
+
+ /*
+ * These sequences may be intermingled, so we extract and compare one sequence at a time.
+ */
+
+ // only care about pdp1 & pdp3 in this sequence
+ verifyItemsInLog(logA, "pdp1", "pdp3", "pdp1");
+
+ // only care about pdp2 & pdp4 in this sequence
+ verifyItemsInLog(logB, "pdp2", "pdp4", "pdp2");
+
+ logger.info("testFourResourcesDifferentPus: Exiting");
+
+ }
+
+ /*
+ * Tests designation logic when four resources are in play but one is not functioning.
+ * Designation should round robin among functioning resources only.
+ *
+ * Note: console.log must be examined to ascertain whether or not this test was successful.
+ */
+ @Test
+ public void testFourResourcesOneDead() throws Exception {
+
+ logger.info("testFourResourcesOneDead: Entering");
+
+ final ExtractAppender logA = watch(debugLogger, START_AUDIT_RE);
+
+ /*
+ * Start audit for pdp1.
+ */
+ MyIntegrityAudit integrityAudit = makeAuditor("pdp1", A_SEQ_PU);
+
+ /*
+ * Start audit for pdp2.
+ */
+ MyIntegrityAudit integrityAudit2 = makeAuditor("pdp2", A_SEQ_PU);
+
+ /*
+ * Populate DB for pdp3, which will simulate it having registered but then having died.
+ */
+ new DbDAO("pdp3", A_SEQ_PU, makeProperties()).destroy();
+
+ /*
+ * Start audit for pdp4.
+ */
+ MyIntegrityAudit integrityAudit4 = makeAuditor("pdp4", A_SEQ_PU);
+
+ /*
+ * Sleep long enough to allow
+ *
+ * 1) pdp1 to run audit
+ *
+ * 2) Logic to detect that pdp1 is stale and designate pdp2
+ *
+ * 3) pdp2 to run audit
+ *
+ * 4) Logic to detect that pdp2 is stale and designate pdp4
+ *
+ * 5) pdp4 to run audit
+ *
+ * 6) Logic to detect that pdp4 is stale and designate pdp1
+ *
+ * 7) pdp1 to run audit
+ *
+ * 8) Logic to detect that pdp1 is stale and designate pdp2
+ *
+ * 7) pdp2 to run audit
+ */
+ runAudit(integrityAudit);
+ waitStaleAndRun(integrityAudit2);
+ waitStaleAndRun(integrityAudit4);
+ waitStaleAndRun(integrityAudit);
+ waitStaleAndRun(integrityAudit2);
+ waitStaleAndRun(integrityAudit4);
+
+ verifyItemsInLog(logA, "pdp1", "pdp2", "pdp4", "pdp1", "pdp2", "pdp4");
+
+ logger.info("testFourResourcesOneDead: Exiting");
+
+ }
+
+ /*
+ * Tests designation logic when four resources are in play but only one is functioning.
+ * Designation should remain with sole functioning resource.
+ *
+ * Note: console.log must be examined to ascertain whether or not this test was successful.
+ */
+ @Test
+ public void testFourResourcesThreeDead() throws Exception {
+
+ logger.info("testFourResourcesThreeDead: Entering");
+
+ final ExtractAppender logA = watch(debugLogger, START_AUDIT_RE);
+
+ /*
+ * Populate DB for "pdp1", which will simulate it having registered but then having died.
+ */
+ new DbDAO("pdp1", A_SEQ_PU, makeProperties()).destroy();
+
+ /*
+ * Populate DB for pdp2, which will simulate it having registered but then having died.
+ */
+ new DbDAO("pdp2", A_SEQ_PU, makeProperties()).destroy();
+
+ /*
+ * Start audit for pdp3.
+ */
+ MyIntegrityAudit integrityAudit3 = makeAuditor("pdp3", A_SEQ_PU);
+
+ /*
+ * Populate DB for pdp4, which will simulate it having registered but then having died.
+ */
+ new DbDAO("pdp4", A_SEQ_PU, makeProperties()).destroy();
+
+ /*
+ * Sleep long enough to allow
+ *
+ * 1) pdp3 to discover that all other designation candidates are stale
+ *
+ * 1) pdp3 to run audit
+ *
+ * 2) Logic to detect that no other nodes are available for designation
+ *
+ * 3) pdp3 to run audit again
+ */
+ runAudit(integrityAudit3);
+ waitStaleAndRun(integrityAudit3);
+
+ verifyItemsInLog(logA, "pdp3", "pdp3");
+
+ logger.info("testFourResourcesThreeDead: Exiting");
+
+ }
+
+ /*
+ * Tests designation logic when the designated node dies and is no longer current
+ *
+ * Note: console.log must be examined to ascertain whether or not this test was successful.
+ */
+ @Test
+ public void testDesignatedNodeDead() throws Exception {
+ logger.info("testDesignatedNodeDead: Entering");
+
+ final ExtractAppender logA = watch(debugLogger, START_AUDIT_RE);
+
+ /*
+ * Instantiate audit object for pdp1.
+ */
+ final MyIntegrityAudit integrityAudit = makeAuditor("pdp1", A_SEQ_PU);
+
+ /*
+ * Start audit for pdp2.
+ */
+ final MyIntegrityAudit integrityAudit2 = makeAuditor("pdp2", A_SEQ_PU);
+
+ /*
+ * Instantiate audit object for pdp3.
+ */
+ final MyIntegrityAudit integrityAudit3 = makeAuditor("pdp3", A_SEQ_PU);
+
+ // Start audit on pdp1
+ logger.info("testDesignatedNodeDead: Start audit on pdp1");
+ runAudit(integrityAudit);
+
+ // Start the auditing threads on other nodes.
+ logger.info("testDesignatedNodeDead: Start audit on pdp2");
+ runAudit(integrityAudit2);
+
+ // Kill audit on pdp1
+ logger.info("testDesignatedNodeDead: Kill audit on pdp1");
+ integrityAudit.stopAuditThread();
+
+ // Wait long enough for pdp1 to get stale and pdp2 to take over
+ waitStaleAndRun(integrityAudit2);
+
+ // Start audit thread on pdp1 again.
+ logger.info("testDesignatedNodeDead: Start audit thread on pdp1 again.");
+ integrityAudit.startAuditThread();
+
+ // Wait long enough for pdp2 to complete its audit and get stale, at
+ // which point pdp3 should take over
+ logger.info(
+ "testDesignatedNodeDead: Wait long enough for pdp2 to complete its audit and get stale, at which point"
+ + " pdp3 should take over");
+ waitStaleAndRun(integrityAudit3);
+
+ // Kill audit on pdp3
+ logger.info("testDesignatedNodeDead: Killing audit on pdp3");
+ integrityAudit3.stopAuditThread();
+
+ // Wait long enough for pdp3 to get stale and pdp1 to take over
+ logger.info("testDesignatedNodeDead: Wait long enough for pdp3 to get stale and pdp1 to take over");
+ waitStaleAndRun(integrityAudit);
+
+ verifyItemsInLog(logA, "pdp1", "pdp2", "pdp3", "pdp1");
+
+ logger.info("testDesignatedNodeDead: Exiting");
+ }
}
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTest.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTest.java
index 344ac34e..5adbb561 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTest.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTest.java
@@ -20,53 +20,52 @@
package org.onap.policy.common.ia;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import java.util.Properties;
import org.junit.Test;
-import org.onap.policy.common.ia.IntegrityAudit;
-import org.onap.policy.common.ia.IntegrityAuditProperties;
public class IntegrityAuditTest {
- @Test
- /**
- * Test if we can access the updated bad params outside of the parmsAreBad method
- */
- public void parmsAreBadTest() {
- // Try with 2 null params
- StringBuilder badParams = new StringBuilder();
- IntegrityAudit.parmsAreBad(null, "something", null, badParams);
-
- assertFalse("".equals(badParams.toString()));
- assertTrue(badParams.toString().contains("resourceName"));
- assertTrue(badParams.toString().contains("properties"));
-
- // Try with 1 null params
- badParams = new StringBuilder();
- Properties props = new Properties();
- props.put(IntegrityAuditProperties.DB_DRIVER, "test_db_driver");
- IntegrityAudit.parmsAreBad(null, "something", props, badParams);
-
- assertFalse("".equals(badParams.toString()));
- assertTrue(badParams.toString().contains("resourceName"));
- assertFalse(badParams.toString().contains("properties"));
-
- // Try with 0 null params
- badParams = new StringBuilder();
- IntegrityAudit.parmsAreBad("someting", "something", props, badParams);
- assertFalse("".equals(badParams.toString()));
- assertFalse(badParams.toString().contains("resourceName"));
- assertFalse(badParams.toString().contains("properties"));
-
- // Try with invalid node type
- props.put(IntegrityAuditProperties.NODE_TYPE, "bogus");
- badParams = new StringBuilder();
- IntegrityAudit.parmsAreBad("someting", "something", props, badParams);
- assertFalse("".equals(badParams.toString()));
- assertTrue(badParams.toString().contains("nodeType"));
+ @Test
+ /**
+ * Test if we can access the updated bad params outside of the parmsAreBad method.
+ */
+ public void parmsAreBadTest() {
+ // Try with 2 null params
+ StringBuilder badParams = new StringBuilder();
+ IntegrityAudit.parmsAreBad(null, "something", null, badParams);
- }
+ assertFalse("".equals(badParams.toString()));
+ assertTrue(badParams.toString().contains("resourceName"));
+ assertTrue(badParams.toString().contains("properties"));
+
+ // Try with 1 null params
+ badParams = new StringBuilder();
+ Properties props = new Properties();
+ props.put(IntegrityAuditProperties.DB_DRIVER, "test_db_driver");
+ IntegrityAudit.parmsAreBad(null, "something", props, badParams);
+
+ assertFalse("".equals(badParams.toString()));
+ assertTrue(badParams.toString().contains("resourceName"));
+ assertFalse(badParams.toString().contains("properties"));
+
+ // Try with 0 null params
+ badParams = new StringBuilder();
+ IntegrityAudit.parmsAreBad("someting", "something", props, badParams);
+ assertFalse("".equals(badParams.toString()));
+ assertFalse(badParams.toString().contains("resourceName"));
+ assertFalse(badParams.toString().contains("properties"));
+
+ // Try with invalid node type
+ props.put(IntegrityAuditProperties.NODE_TYPE, "bogus");
+ badParams = new StringBuilder();
+ IntegrityAudit.parmsAreBad("someting", "something", props, badParams);
+ assertFalse("".equals(badParams.toString()));
+ assertTrue(badParams.toString().contains("nodeType"));
+
+ }
}
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java
index e30c5631..afbcc452 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java
@@ -23,6 +23,9 @@ package org.onap.policy.common.ia;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
@@ -47,587 +50,560 @@ import org.onap.policy.common.utils.jpa.EntityTransCloser;
import org.onap.policy.common.utils.test.log.logback.ExtractAppender;
import org.slf4j.LoggerFactory;
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.Logger;
-
/**
- * All JUnits are designed to run in the local development environment where
- * they have write privileges and can execute time-sensitive tasks.
- * <p/>
- * Many of the test verification steps are performed by scanning for items
- * written to the log file. Rather than actually scan the log file, an
- * {@link ExtractAppender} is used to monitor events that are logged and extract
- * relevant items. In order to attach the appender to the debug log, it assumes
- * that the debug log is a <i>logback</i> Logger configured per EELF.
- * <p/>
- * These tests use a temporary, in-memory DB, which is dropped once the tests
- * complete.
+ * All JUnits are designed to run in the local development environment where they have write
+ * privileges and can execute time-sensitive tasks.
+ *
+ * <p>Many of the test verification steps are performed by scanning for items written to the log
+ * file. Rather than actually scan the log file, an {@link ExtractAppender} is used to monitor
+ * events that are logged and extract relevant items. In order to attach the appender to the debug
+ * log, it assumes that the debug log is a <i>logback</i> Logger configured per EELF.
+ *
+ * <p>These tests use a temporary, in-memory DB, which is dropped once the tests complete.
*/
public class IntegrityAuditTestBase {
- /**
- * Root of the debug logger, as defined in the logback-test.xml.
- */
- protected static final Logger debugLogger = (Logger) LoggerFactory.getLogger("com.att.eelf.debug");
-
- /**
- * Root of the error logger, as defined in the logback-test.xml.
- */
- protected static final Logger errorLogger = (Logger) LoggerFactory.getLogger("com.att.eelf.error");
-
- /**
- * Directory containing the log files.
- */
- private static final String LOG_DIR = "testingLogs/common-modules/integrity-audit";
-
- /**
- * Max time, in milliseconds, to wait for a latch to be triggered.
- */
- protected static final long WAIT_MS = 5000l;
-
- /**
- * Milliseconds that auditor should sleep between audit steps.
- */
- protected static final long SLEEP_INTERVAL_MS = 2l;
-
- /**
- * Milliseconds that auditor should sleep when an audit completes.
- */
- protected static final long COMPLETION_INTERVAL_MS = 5l;
-
- /**
- * Milliseconds that an entire audit-simulation cycles takes.
- */
- protected static final long AUDIT_SIMULATION_MS = SLEEP_INTERVAL_MS * AuditThread.AUDIT_SIMULATION_ITERATIONS;
-
- /**
- * Milliseconds that it takes for an auditor's last update to become stale.
- * Includes a 1ms fudge factor.
- */
- protected static final long STALE_MS = 1 + 2 * Math.max(COMPLETION_INTERVAL_MS, AUDIT_SIMULATION_MS);
-
- /**
- * Milliseconds that the db-audit should wait between makings updates.
- */
- private static final long DB_AUDIT_UPDATE_MS = 10l;
-
- /**
- * Milliseconds that the db-audit should sleep between cycles.
- */
- private static final long DB_AUDIT_SLEEP_MS = 3l;
-
- public static final String DEFAULT_DB_URL_PREFIX = "jdbc:h2:mem:";
-
- protected static final String dbDriver = "org.h2.Driver";
- protected static final String dbUser = "testu";
- protected static final String dbPwd = "testp";
- protected static final String siteName = "SiteA";
- protected static final String nodeType = "pdp_xacml";
-
- // will be defined by the test *Classes*
- protected static String dbUrl;
-
- /**
- * Persistence unit for PDP sequence A.
- */
- protected static final String A_SEQ_PU = "testPU";
-
- /**
- * Persistence unit for PDP sequence B.
- */
- protected static final String B_SEQ_PU = "integrityAuditPU";
-
- /**
- * Matches the start of an audit for arbitrary PDPs in the debug log.
- */
- protected static final String START_AUDIT_RE = "Starting audit simulation for resourceName=([^,]*)";
-
- /**
- * Properties to be used in all tests.
- */
- protected static Properties properties;
-
- /**
- * Entity manager factory pointing to the in-memory DB for A_SEQ_PU.
- */
- protected static EntityManagerFactory emf;
-
- /**
- * Entity manager factory pointing to the in-memory DB associated with emf.
- */
- protected static EntityManager em;
-
- /**
- * Saved debug logger level, to be restored once all tests complete.
- */
- private static Level savedDebugLevel;
-
- /**
- * Saved error logger level, to be restored once all tests complete.
- */
- private static Level savedErrorLevel;
-
- /**
- * Saved audit sleep interval, to be restored once all tests complete.
- */
- private static long savedSleepIntervalMs;
-
- /**
- * Saved audit completion interval, to be restored once all tests complete.
- */
- private static long savedCompletionIntervalMs;
-
- /**
- * Saved db audit update time, to be restored once all tests complete.
- */
- private static long savedDbAuditUpdateMs;
-
- /**
- * Saved db audit sleep time, to be restored once all tests complete.
- */
- private static long savedDbAuditSleepMs;
-
- /**
- * List of auditors whose threads must be stopped when a given test case
- * ends.
- */
- private List<MyIntegrityAudit> auditors;
-
- /**
- * List of appenders that must be removed from loggers when a given test
- * case ends.
- */
- private List<LogApp> appenders;
-
- /**
- * Saves current configuration information and then sets new values.
- *
- * @param dbDriver
- * the name of the DB Driver class
- * @param dbUrl
- * the URL to the DB
- * @throws IOException
- * @throws Exception
- */
- protected static void setUpBeforeClass(String dbUrl) throws IOException {
-
- // truncate the logs
- new FileOutputStream(LOG_DIR + "/audit.log").close();
- new FileOutputStream(LOG_DIR + "/debug.log").close();
- new FileOutputStream(LOG_DIR + "/error.log").close();
- new FileOutputStream(LOG_DIR + "/metrics.log").close();
-
- IntegrityAuditTestBase.dbUrl = dbUrl;
-
- // save data that we have to restore at the end of the test
- savedDebugLevel = debugLogger.getLevel();
- savedErrorLevel = errorLogger.getLevel();
- savedSleepIntervalMs = AuditThread.getAuditThreadSleepIntervalMillis();
- savedCompletionIntervalMs = AuditThread.getAuditCompletionIntervalMillis();
- savedDbAuditUpdateMs = DbAudit.getDbAuditUpdateMillis();
- savedDbAuditSleepMs = DbAudit.getDbAuditSleepMillis();
-
- AuditThread.setAuditThreadSleepIntervalMillis(SLEEP_INTERVAL_MS);
- AuditThread.setAuditCompletionIntervalMillis(COMPLETION_INTERVAL_MS);
-
- DbAudit.setDbAuditUpdateMillis(DB_AUDIT_UPDATE_MS);
- DbAudit.setDbAuditSleepMillis(DB_AUDIT_SLEEP_MS);
-
- IntegrityAudit.setUnitTesting(true);
-
- properties = new Properties();
- properties.put(IntegrityAuditProperties.DB_DRIVER, dbDriver);
- properties.put(IntegrityAuditProperties.DB_URL, dbUrl);
- properties.put(IntegrityAuditProperties.DB_USER, dbUser);
- properties.put(IntegrityAuditProperties.DB_PWD, dbPwd);
- properties.put(IntegrityAuditProperties.SITE_NAME, siteName);
- properties.put(IntegrityAuditProperties.NODE_TYPE, nodeType);
-
- emf = Persistence.createEntityManagerFactory(A_SEQ_PU, makeProperties());
-
- // keep this open so the in-memory DB stays around until all tests are
- // done
- em = emf.createEntityManager();
-
- debugLogger.setLevel(Level.DEBUG);
- errorLogger.setLevel(Level.ERROR);
- }
-
- /**
- * Restores the configuration to what it was before the test.
- */
- protected static void tearDownAfterClass() {
- AuditThread.setAuditThreadSleepIntervalMillis(savedSleepIntervalMs);
- AuditThread.setAuditCompletionIntervalMillis(savedCompletionIntervalMs);
-
- DbAudit.setDbAuditUpdateMillis(savedDbAuditUpdateMs);
- DbAudit.setDbAuditSleepMillis(savedDbAuditSleepMs);
-
- IntegrityAudit.setUnitTesting(false);
-
- debugLogger.setLevel(savedDebugLevel);
- errorLogger.setLevel(savedErrorLevel);
-
- // this should result in the in-memory DB being deleted
- em.close();
- emf.close();
- }
-
- /**
- * Sets up for a test, which includes deleting all records from the
- * IntegrityAuditEntity table.
- */
- protected void setUp() {
- auditors = new LinkedList<>();
- appenders = new LinkedList<>();
-
- properties.put(IntegrityAuditProperties.AUDIT_PERIOD_MILLISECONDS, String.valueOf(SLEEP_INTERVAL_MS));
-
- // Clean up the DB
- try (EntityTransCloser etc = new EntityTransCloser(em.getTransaction())) {
- EntityTransaction et = etc.getTransation();
-
- em.createQuery("Delete from IntegrityAuditEntity").executeUpdate();
-
- // commit transaction
- et.commit();
- }
- }
-
- /**
- * Cleans up after a test, removing any ExtractAppenders from the logger and
- * stopping any AuditThreads.
- */
- protected void tearDown() {
- for (LogApp p : appenders) {
- p.detach();
- }
-
- for (MyIntegrityAudit p : auditors) {
- p.stopAuditThread();
- }
- }
-
- /**
- *
- * @param properties
- * @param persistenceUnit
- * @param tableName
- */
- public void truncateTable(Properties properties, String persistenceUnit, String tableName) {
-
- try (EntityMgrFactoryCloser emfc = new EntityMgrFactoryCloser(
- Persistence.createEntityManagerFactory(persistenceUnit, properties));
- EntityMgrCloser emc = new EntityMgrCloser(emfc.getFactory().createEntityManager());
- EntityTransCloser etc = new EntityTransCloser(emc.getManager().getTransaction())) {
-
- EntityManager em = emc.getManager();
- EntityTransaction et = etc.getTransation();
-
- // Clean up the DB
- em.createQuery("Delete from " + tableName).executeUpdate();
-
- // commit transaction
- et.commit();
- }
- }
-
- /**
- * Verifies that items appear within the log, in order. A given item may
- * appear more than once. In addition, the log may contain extra items;
- * those are ignored.
- *
- * @param textre
- * regular expression used to extract an item from a line in the
- * log. The first "capture" group of the regular expression is
- * assumed to contain the extracted item
- * @param items
- * items that should be matched by the items extracted from the
- * log, in order
- * @throws IOException
- * @throws AssertionError
- * if the desired items were not all found
- */
- protected void verifyItemsInLog(ExtractAppender app, String... items) throws IOException {
-
- Iterator<String> it = new ArrayList<>(Arrays.asList(items)).iterator();
- if (!it.hasNext()) {
- return;
- }
-
- String expected = it.next();
- String last = null;
-
- for (String rName : app.getExtracted()) {
- if (rName.equals(expected)) {
- if (!it.hasNext()) {
- // matched all of the items
- return;
- }
-
- last = expected;
- expected = it.next();
-
- } else if (!rName.equals(last)) {
- List<String> remaining = getRemaining(expected, it);
- fail("missing items " + remaining + ", but was: " + rName);
- }
- }
-
- List<String> remaining = getRemaining(expected, it);
- assertTrue("missing items " + remaining, remaining.isEmpty());
- }
-
- /**
- * Gets the remaining items from an iterator
- *
- * @param current
- * the current item, to be included within the list
- * @param it
- * iterator from which to get the remaining items
- * @return a list of the remaining items
- */
- private LinkedList<String> getRemaining(String current, Iterator<String> it) {
- LinkedList<String> remaining = new LinkedList<>();
- remaining.add(current);
-
- while (it.hasNext()) {
- remaining.add(it.next());
- }
- return remaining;
- }
-
- /**
- * Waits for a thread to stop. If the thread doesn't complete in the
- * allotted time, then it interrupts it and waits again.
- *
- * @param auditor
- * the thread for which to wait
- * @return {@code true} if the thread stopped, {@code false} otherwise
- */
- public boolean waitThread(MyIntegrityAudit auditor) {
- if (auditor != null) {
- try {
- auditor.interrupt();
-
- if (!auditor.joinAuditThread(WAIT_MS)) {
- System.out.println("failed to stop audit thread");
- return false;
- }
-
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- }
-
- return true;
- }
-
- /**
- * Makes a new auditor.
- *
- * @param resourceName2
- * @param persistenceUnit2
- * @return a new auditor
- * @throws Exception
- */
- protected MyIntegrityAudit makeAuditor(String resourceName2, String persistenceUnit2) throws Exception {
- return new MyIntegrityAudit(resourceName2, persistenceUnit2, makeProperties());
- }
-
- /**
- * Watches for patterns in a logger by attaching a ExtractAppender to it.
- *
- * @param logger
- * the logger to watch
- * @param regex
- * regular expression used to extract relevant text
- * @return a new appender
- */
- protected ExtractAppender watch(Logger logger, String regex) {
- ExtractAppender app = new ExtractAppender(regex);
- appenders.add(new LogApp(logger, app));
-
- return app;
- }
-
- /**
- * Makes a new Property set that's a clone of {@link #properties}.
- *
- * @return a new Property set containing all of a copy of all of the
- * {@link #properties}
- */
- protected static Properties makeProperties() {
- Properties props = new Properties();
- props.putAll(properties);
- return props;
- }
-
- /**
- * Waits for data to become stale and then runs an audit on several auditors
- * in parallel.
- *
- * @param auditors
- * @throws InterruptedException
- */
- protected void waitStaleAndRun(MyIntegrityAudit... auditors) throws InterruptedException {
- waitStale();
- runAudit(auditors);
- }
-
- /**
- * Runs an audit on several auditors in parallel.
- *
- * @param auditors
- * @throws InterruptedException
- */
- protected void runAudit(MyIntegrityAudit... auditors) throws InterruptedException {
-
- // start an audit cycle on each auditor
- List<CountDownLatch> latches = new ArrayList<>(auditors.length);
- for (MyIntegrityAudit p : auditors) {
- latches.add(p.startAudit());
- }
-
- // wait for each auditor to complete its cycle
- for (CountDownLatch latch : latches) {
- waitLatch(latch);
- }
- }
-
- /**
- * Waits for a latch to reach zero.
- *
- * @param latch
- * @throws InterruptedException
- * @throws AssertionError
- * if the latch did not reach zero in the allotted time
- */
- protected void waitLatch(CountDownLatch latch) throws InterruptedException {
- assertTrue(latch.await(WAIT_MS, TimeUnit.SECONDS));
- }
-
- /**
- * Sleep a bit so that the currently designated pdp becomes stale.
- *
- * @throws InterruptedException
- */
- protected void waitStale() throws InterruptedException {
- Thread.sleep(STALE_MS);
- }
-
- /**
- * Tracks which appender has been added to a logger.
- */
- private static class LogApp {
- private final Logger logger;
- private final ExtractAppender appender;
-
- public LogApp(Logger logger, ExtractAppender appender) {
- this.logger = logger;
- this.appender = appender;
-
- logger.addAppender(appender);
-
- appender.start();
- }
-
- public void detach() {
- logger.detachAppender(appender);
- }
- }
-
- /**
- * Manages audits by inserting latches into a queue for the AuditThread to
- * count.
- */
- protected class MyIntegrityAudit extends IntegrityAudit {
-
- /**
- * Queue from which the AuditThread will take latches.
- */
- private BlockingQueue<CountDownLatch> queue = null;
-
- /**
- * Constructs an auditor and starts the AuditThread.
- *
- * @param resourceName
- * @param persistenceUnit
- * @param properties
- * @throws Exception
- */
- public MyIntegrityAudit(String resourceName, String persistenceUnit, Properties properties) throws Exception {
- super(resourceName, persistenceUnit, properties);
-
- auditors.add(this);
-
- startAuditThread();
- }
-
- /**
- * Interrupts the AuditThread.
- */
- public void interrupt() {
- super.stopAuditThread();
- }
-
- /**
- * Triggers an audit by adding a latch to the queue.
- *
- * @return the latch that was added
- * @throws InterruptedException
- */
- public CountDownLatch startAudit() throws InterruptedException {
- CountDownLatch latch = new CountDownLatch(1);
- queue.add(latch);
-
- return latch;
- }
-
- /**
- * Starts a new AuditThread. Creates a new latch queue and associates it
- * with the thread.
- */
- @Override
- public final void startAuditThread() throws IntegrityAuditException {
- if (queue != null) {
- // queue up a bogus latch, in case a thread is still running
- queue.add(new CountDownLatch(1) {
- @Override
- public void countDown() {
- throw new RuntimeException("auditor has multiple threads");
- }
- });
- }
-
- queue = new LinkedBlockingQueue<>();
-
- if (super.startAuditThread(queue)) {
- // wait for the thread to start
- CountDownLatch latch = new CountDownLatch(1);
- queue.add(latch);
-
- try {
- waitLatch(latch);
-
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- throw new IntegrityAuditException(e);
- }
- }
- }
-
- /**
- * Stops the AuditThread and waits for it to stop.
- *
- * @throws AssertionError
- * if the thread is still running
- */
- @Override
- public void stopAuditThread() {
- super.stopAuditThread();
-
- assertTrue(waitThread(this));
- }
- }
+ /**
+ * Root of the debug logger, as defined in the logback-test.xml.
+ */
+ protected static final Logger debugLogger = (Logger) LoggerFactory.getLogger("com.att.eelf.debug");
+
+ /**
+ * Root of the error logger, as defined in the logback-test.xml.
+ */
+ protected static final Logger errorLogger = (Logger) LoggerFactory.getLogger("com.att.eelf.error");
+
+ /**
+ * Directory containing the log files.
+ */
+ private static final String LOG_DIR = "testingLogs/common-modules/integrity-audit";
+
+ /**
+ * Max time, in milliseconds, to wait for a latch to be triggered.
+ */
+ protected static final long WAIT_MS = 5000L;
+
+ /**
+ * Milliseconds that auditor should sleep between audit steps.
+ */
+ protected static final long SLEEP_INTERVAL_MS = 2L;
+
+ /**
+ * Milliseconds that auditor should sleep when an audit completes.
+ */
+ protected static final long COMPLETION_INTERVAL_MS = 5L;
+
+ /**
+ * Milliseconds that an entire audit-simulation cycles takes.
+ */
+ protected static final long AUDIT_SIMULATION_MS = SLEEP_INTERVAL_MS * AuditThread.AUDIT_SIMULATION_ITERATIONS;
+
+ /**
+ * Milliseconds that it takes for an auditor's last update to become stale. Includes a 1ms fudge
+ * factor.
+ */
+ protected static final long STALE_MS = 1 + 2 * Math.max(COMPLETION_INTERVAL_MS, AUDIT_SIMULATION_MS);
+
+ /**
+ * Milliseconds that the db-audit should wait between makings updates.
+ */
+ private static final long DB_AUDIT_UPDATE_MS = 10L;
+
+ /**
+ * Milliseconds that the db-audit should sleep between cycles.
+ */
+ private static final long DB_AUDIT_SLEEP_MS = 3L;
+
+ public static final String DEFAULT_DB_URL_PREFIX = "jdbc:h2:mem:";
+
+ protected static final String dbDriver = "org.h2.Driver";
+ protected static final String dbUser = "testu";
+ protected static final String dbPwd = "testp";
+ protected static final String siteName = "SiteA";
+ protected static final String nodeType = "pdp_xacml";
+
+ // will be defined by the test *Classes*
+ protected static String dbUrl;
+
+ /**
+ * Persistence unit for PDP sequence A.
+ */
+ protected static final String A_SEQ_PU = "testPU";
+
+ /**
+ * Persistence unit for PDP sequence B.
+ */
+ protected static final String B_SEQ_PU = "integrityAuditPU";
+
+ /**
+ * Matches the start of an audit for arbitrary PDPs in the debug log.
+ */
+ protected static final String START_AUDIT_RE = "Starting audit simulation for resourceName=([^,]*)";
+
+ /**
+ * Properties to be used in all tests.
+ */
+ protected static Properties properties;
+
+ /**
+ * Entity manager factory pointing to the in-memory DB for A_SEQ_PU.
+ */
+ protected static EntityManagerFactory emf;
+
+ /**
+ * Entity manager factory pointing to the in-memory DB associated with emf.
+ */
+ protected static EntityManager em;
+
+ /**
+ * Saved debug logger level, to be restored once all tests complete.
+ */
+ private static Level savedDebugLevel;
+
+ /**
+ * Saved error logger level, to be restored once all tests complete.
+ */
+ private static Level savedErrorLevel;
+
+ /**
+ * Saved audit sleep interval, to be restored once all tests complete.
+ */
+ private static long savedSleepIntervalMs;
+
+ /**
+ * Saved audit completion interval, to be restored once all tests complete.
+ */
+ private static long savedCompletionIntervalMs;
+
+ /**
+ * Saved db audit update time, to be restored once all tests complete.
+ */
+ private static long savedDbAuditUpdateMs;
+
+ /**
+ * Saved db audit sleep time, to be restored once all tests complete.
+ */
+ private static long savedDbAuditSleepMs;
+
+ /**
+ * List of auditors whose threads must be stopped when a given test case ends.
+ */
+ private List<MyIntegrityAudit> auditors;
+
+ /**
+ * List of appenders that must be removed from loggers when a given test case ends.
+ */
+ private List<LogApp> appenders;
+
+ /**
+ * Saves current configuration information and then sets new values.
+ *
+ * @param dbDriver the name of the DB Driver class
+ * @param dbUrl the URL to the DB
+ * @throws IOException if an IO error occurs
+ */
+ protected static void setUpBeforeClass(String dbUrl) throws IOException {
+
+ // truncate the logs
+ new FileOutputStream(LOG_DIR + "/audit.log").close();
+ new FileOutputStream(LOG_DIR + "/debug.log").close();
+ new FileOutputStream(LOG_DIR + "/error.log").close();
+ new FileOutputStream(LOG_DIR + "/metrics.log").close();
+
+ IntegrityAuditTestBase.dbUrl = dbUrl;
+
+ // save data that we have to restore at the end of the test
+ savedDebugLevel = debugLogger.getLevel();
+ savedErrorLevel = errorLogger.getLevel();
+ savedSleepIntervalMs = AuditThread.getAuditThreadSleepIntervalMillis();
+ savedCompletionIntervalMs = AuditThread.getAuditCompletionIntervalMillis();
+ savedDbAuditUpdateMs = DbAudit.getDbAuditUpdateMillis();
+ savedDbAuditSleepMs = DbAudit.getDbAuditSleepMillis();
+
+ AuditThread.setAuditThreadSleepIntervalMillis(SLEEP_INTERVAL_MS);
+ AuditThread.setAuditCompletionIntervalMillis(COMPLETION_INTERVAL_MS);
+
+ DbAudit.setDbAuditUpdateMillis(DB_AUDIT_UPDATE_MS);
+ DbAudit.setDbAuditSleepMillis(DB_AUDIT_SLEEP_MS);
+
+ IntegrityAudit.setUnitTesting(true);
+
+ properties = new Properties();
+ properties.put(IntegrityAuditProperties.DB_DRIVER, dbDriver);
+ properties.put(IntegrityAuditProperties.DB_URL, dbUrl);
+ properties.put(IntegrityAuditProperties.DB_USER, dbUser);
+ properties.put(IntegrityAuditProperties.DB_PWD, dbPwd);
+ properties.put(IntegrityAuditProperties.SITE_NAME, siteName);
+ properties.put(IntegrityAuditProperties.NODE_TYPE, nodeType);
+
+ emf = Persistence.createEntityManagerFactory(A_SEQ_PU, makeProperties());
+
+ // keep this open so the in-memory DB stays around until all tests are
+ // done
+ em = emf.createEntityManager();
+
+ debugLogger.setLevel(Level.DEBUG);
+ errorLogger.setLevel(Level.ERROR);
+ }
+
+ /**
+ * Restores the configuration to what it was before the test.
+ */
+ protected static void tearDownAfterClass() {
+ AuditThread.setAuditThreadSleepIntervalMillis(savedSleepIntervalMs);
+ AuditThread.setAuditCompletionIntervalMillis(savedCompletionIntervalMs);
+
+ DbAudit.setDbAuditUpdateMillis(savedDbAuditUpdateMs);
+ DbAudit.setDbAuditSleepMillis(savedDbAuditSleepMs);
+
+ IntegrityAudit.setUnitTesting(false);
+
+ debugLogger.setLevel(savedDebugLevel);
+ errorLogger.setLevel(savedErrorLevel);
+
+ // this should result in the in-memory DB being deleted
+ em.close();
+ emf.close();
+ }
+
+ /**
+ * Sets up for a test, which includes deleting all records from the IntegrityAuditEntity table.
+ */
+ protected void setUp() {
+ auditors = new LinkedList<>();
+ appenders = new LinkedList<>();
+
+ properties.put(IntegrityAuditProperties.AUDIT_PERIOD_MILLISECONDS, String.valueOf(SLEEP_INTERVAL_MS));
+
+ // Clean up the DB
+ try (EntityTransCloser etc = new EntityTransCloser(em.getTransaction())) {
+ EntityTransaction et = etc.getTransation();
+
+ em.createQuery("Delete from IntegrityAuditEntity").executeUpdate();
+
+ // commit transaction
+ et.commit();
+ }
+ }
+
+ /**
+ * Cleans up after a test, removing any ExtractAppenders from the logger and stopping any
+ * AuditThreads.
+ */
+ protected void tearDown() {
+ for (LogApp p : appenders) {
+ p.detach();
+ }
+
+ for (MyIntegrityAudit p : auditors) {
+ p.stopAuditThread();
+ }
+ }
+
+ /**
+ * Truncate the table.
+ *
+ * @param properties the properties
+ * @param persistenceUnit the persistence unit
+ * @param tableName the name of the table
+ */
+ public void truncateTable(Properties properties, String persistenceUnit, String tableName) {
+
+ try (EntityMgrFactoryCloser emfc =
+ new EntityMgrFactoryCloser(Persistence.createEntityManagerFactory(persistenceUnit, properties));
+ EntityMgrCloser emc = new EntityMgrCloser(emfc.getFactory().createEntityManager());
+ EntityTransCloser etc = new EntityTransCloser(emc.getManager().getTransaction())) {
+
+ EntityManager em = emc.getManager();
+ EntityTransaction et = etc.getTransation();
+
+ // Clean up the DB
+ em.createQuery("Delete from " + tableName).executeUpdate();
+
+ // commit transaction
+ et.commit();
+ }
+ }
+
+ /**
+ * Verifies that items appear within the log, in order. A given item may appear more than once.
+ * In addition, the log may contain extra items; those are ignored.
+ *
+ * @param textre regular expression used to extract an item from a line in the log. The first
+ * "capture" group of the regular expression is assumed to contain the extracted item
+ * @param items items that should be matched by the items extracted from the log, in order
+ * @throws IOException if an IO error occurs
+ * @throws AssertionError if the desired items were not all found
+ */
+ protected void verifyItemsInLog(ExtractAppender app, String... items) throws IOException {
+
+ Iterator<String> it = new ArrayList<>(Arrays.asList(items)).iterator();
+ if (!it.hasNext()) {
+ return;
+ }
+
+ String expected = it.next();
+ String last = null;
+
+ for (String extractedText : app.getExtracted()) {
+ if (extractedText.equals(expected)) {
+ if (!it.hasNext()) {
+ // matched all of the items
+ return;
+ }
+
+ last = expected;
+ expected = it.next();
+
+ } else if (!extractedText.equals(last)) {
+ List<String> remaining = getRemaining(expected, it);
+ fail("missing items " + remaining + ", but was: " + extractedText);
+ }
+ }
+
+ List<String> remaining = getRemaining(expected, it);
+ assertTrue("missing items " + remaining, remaining.isEmpty());
+ }
+
+ /**
+ * Gets the remaining items from an iterator.
+ *
+ * @param current the current item, to be included within the list
+ * @param it iterator from which to get the remaining items
+ * @return a list of the remaining items
+ */
+ private LinkedList<String> getRemaining(String current, Iterator<String> it) {
+ LinkedList<String> remaining = new LinkedList<>();
+ remaining.add(current);
+
+ while (it.hasNext()) {
+ remaining.add(it.next());
+ }
+ return remaining;
+ }
+
+ /**
+ * Waits for a thread to stop. If the thread doesn't complete in the allotted time, then it
+ * interrupts it and waits again.
+ *
+ * @param auditor the thread for which to wait
+ * @return {@code true} if the thread stopped, {@code false} otherwise
+ */
+ public boolean waitThread(MyIntegrityAudit auditor) {
+ if (auditor != null) {
+ try {
+ auditor.interrupt();
+
+ if (!auditor.joinAuditThread(WAIT_MS)) {
+ System.out.println("failed to stop audit thread");
+ return false;
+ }
+
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Makes a new auditor.
+ *
+ * @param resourceName2 the name of the resource
+ * @param persistenceUnit2 the persistence unit
+ * @return a new auditor
+ * @throws Exception if an error occurs
+ */
+ protected MyIntegrityAudit makeAuditor(String resourceName2, String persistenceUnit2) throws Exception {
+ return new MyIntegrityAudit(resourceName2, persistenceUnit2, makeProperties());
+ }
+
+ /**
+ * Watches for patterns in a logger by attaching a ExtractAppender to it.
+ *
+ * @param logger the logger to watch
+ * @param regex regular expression used to extract relevant text
+ * @return a new appender
+ */
+ protected ExtractAppender watch(Logger logger, String regex) {
+ ExtractAppender app = new ExtractAppender(regex);
+ appenders.add(new LogApp(logger, app));
+
+ return app;
+ }
+
+ /**
+ * Makes a new Property set that's a clone of {@link #properties}.
+ *
+ * @return a new Property set containing all of a copy of all of the {@link #properties}
+ */
+ protected static Properties makeProperties() {
+ Properties props = new Properties();
+ props.putAll(properties);
+ return props;
+ }
+
+ /**
+ * Waits for data to become stale and then runs an audit on several auditors in parallel.
+ *
+ * @param auditors the auditors
+ * @throws InterruptedException if a thread is interrupted
+ */
+ protected void waitStaleAndRun(MyIntegrityAudit... auditors) throws InterruptedException {
+ waitStale();
+ runAudit(auditors);
+ }
+
+ /**
+ * Runs an audit on several auditors in parallel.
+ *
+ * @param auditors the auditors
+ * @throws InterruptedException if a thread is interrupted
+ */
+ protected void runAudit(MyIntegrityAudit... auditors) throws InterruptedException {
+
+ // start an audit cycle on each auditor
+ List<CountDownLatch> latches = new ArrayList<>(auditors.length);
+ for (MyIntegrityAudit p : auditors) {
+ latches.add(p.startAudit());
+ }
+
+ // wait for each auditor to complete its cycle
+ for (CountDownLatch latch : latches) {
+ waitLatch(latch);
+ }
+ }
+
+ /**
+ * Waits for a latch to reach zero.
+ *
+ * @param latch the latch to wait for
+ * @throws InterruptedException if the thread is interrupted
+ * @throws AssertionError if the latch did not reach zero in the allotted time
+ */
+ protected void waitLatch(CountDownLatch latch) throws InterruptedException {
+ assertTrue(latch.await(WAIT_MS, TimeUnit.SECONDS));
+ }
+
+ /**
+ * Sleep a bit so that the currently designated pdp becomes stale.
+ *
+ * @throws InterruptedException if the thread is interrupted
+ */
+ protected void waitStale() throws InterruptedException {
+ Thread.sleep(STALE_MS);
+ }
+
+ /**
+ * Tracks which appender has been added to a logger.
+ */
+ private static class LogApp {
+ private final Logger logger;
+ private final ExtractAppender appender;
+
+ public LogApp(Logger logger, ExtractAppender appender) {
+ this.logger = logger;
+ this.appender = appender;
+
+ logger.addAppender(appender);
+
+ appender.start();
+ }
+
+ public void detach() {
+ logger.detachAppender(appender);
+ }
+ }
+
+ /**
+ * Manages audits by inserting latches into a queue for the AuditThread to count.
+ */
+ protected class MyIntegrityAudit extends IntegrityAudit {
+
+ /**
+ * Queue from which the AuditThread will take latches.
+ */
+ private BlockingQueue<CountDownLatch> queue = null;
+
+ /**
+ * Constructs an auditor and starts the AuditThread.
+ *
+ * @param resourceName the resource name
+ * @param persistenceUnit the persistence unit
+ * @param properties the properties
+ * @throws Exception if an error occurs
+ */
+ public MyIntegrityAudit(String resourceName, String persistenceUnit, Properties properties) throws Exception {
+ super(resourceName, persistenceUnit, properties);
+
+ auditors.add(this);
+
+ startAuditThread();
+ }
+
+ /**
+ * Interrupts the AuditThread.
+ */
+ public void interrupt() {
+ super.stopAuditThread();
+ }
+
+ /**
+ * Triggers an audit by adding a latch to the queue.
+ *
+ * @return the latch that was added
+ * @throws InterruptedException if the thread is interrupted
+ */
+ public CountDownLatch startAudit() throws InterruptedException {
+ CountDownLatch latch = new CountDownLatch(1);
+ queue.add(latch);
+
+ return latch;
+ }
+
+ /**
+ * Starts a new AuditThread. Creates a new latch queue and associates it with the thread.
+ */
+ @Override
+ public final void startAuditThread() throws IntegrityAuditException {
+ if (queue != null) {
+ // queue up a bogus latch, in case a thread is still running
+ queue.add(new CountDownLatch(1) {
+ @Override
+ public void countDown() {
+ throw new RuntimeException("auditor has multiple threads");
+ }
+ });
+ }
+
+ queue = new LinkedBlockingQueue<>();
+
+ if (super.startAuditThread(queue)) {
+ // wait for the thread to start
+ CountDownLatch latch = new CountDownLatch(1);
+ queue.add(latch);
+
+ try {
+ waitLatch(latch);
+
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new IntegrityAuditException(e);
+ }
+ }
+ }
+
+ /**
+ * Stops the AuditThread and waits for it to stop.
+ *
+ * @throws AssertionError if the thread is still running
+ */
+ @Override
+ public void stopAuditThread() {
+ super.stopAuditThread();
+
+ assertTrue(waitThread(this));
+ }
+ }
}
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/IaTestEntity.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/IaTestEntity.java
index 43277a71..36b9ef66 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/IaTestEntity.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/IaTestEntity.java
@@ -37,119 +37,139 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
-@Table(name="IaTestEntity")
-@NamedQueries({
- @NamedQuery(name=" IaTestEntity.findAll", query="SELECT e FROM IaTestEntity e "),
- @NamedQuery(name="IaTestEntity.deleteAll", query="DELETE FROM IaTestEntity WHERE 1=1")
-})
+@Table(name = "IaTestEntity")
+@NamedQueries({@NamedQuery(name = " IaTestEntity.findAll", query = "SELECT e FROM IaTestEntity e "),
+ @NamedQuery(name = "IaTestEntity.deleteAll", query = "DELETE FROM IaTestEntity WHERE 1=1")})
public class IaTestEntity implements Serializable {
- private static final long serialVersionUID = 1L;
-
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="ImTestId")
- private long imTestId;
-
- @Column(name="created_by", nullable=false, length=255)
- private String createdBy = "guest";
-
- @Column(name="person", nullable=false, length=255)
- private PersonSample person;
-
- @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 IaTestEntity() {
- }
-
- @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;
- }
-
- /**
- * @param the person to set
- */
- public void setPersonTest(PersonSample p) {
- this.person = p;
- }
-
- /**
- * @return the person
- */
- public PersonSample getPersonTest() {
- return person;
- }
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "ImTestId")
+ private long imTestId;
+
+ @Column(name = "created_by", nullable = false, length = 255)
+ private String createdBy = "guest";
+
+ @Column(name = "person", nullable = false, length = 255)
+ private PersonSample person;
+
+ @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 IaTestEntity() {}
+
+ /**
+ * PrePersist call back method.
+ */
+ @PrePersist
+ public void prePersist() {
+ Date date = new Date();
+ this.createdDate = date;
+ this.modifiedDate = date;
+ }
+
+ @PreUpdate
+ public void preUpdate() {
+ this.modifiedDate = new Date();
+ }
+
+ /**
+ * The 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;
+ }
+
+ /**
+ * Set the person.
+ *
+ * @param person the person to set
+ */
+ public void setPersonTest(PersonSample person) {
+ this.person = person;
+ }
+
+ /**
+ * Get the person.
+ *
+ * @return the person
+ */
+ public PersonSample getPersonTest() {
+ return person;
+ }
}
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/PersonSample.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/PersonSample.java
index d7fcf330..47fa843b 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/PersonSample.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/PersonSample.java
@@ -23,42 +23,47 @@ package org.onap.policy.common.ia.jpa;
import java.io.Serializable;
public class PersonSample implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private String firstName;
- private String lastName;
- private int age;
-
- public PersonSample(String first, String last, int age) {
- this.firstName = first;
- this.lastName = last;
- this.age = age;
- }
-
- public String getFirstName() {
- return this.firstName;
- }
-
- public void setFirstName(String name) {
- this.firstName = name;
- }
-
- public String getLasttName() {
- return this.lastName;
- }
-
- public void setLastName(String name) {
- this.lastName = name;
- }
-
- public int getAge() {
- return this.age;
- }
-
- public void setAge(int age) {
- this.age = age;
- }
-
+
+ private static final long serialVersionUID = 1L;
+ private String firstName;
+ private String lastName;
+ private int age;
+
+ /**
+ * Create an instance.
+ *
+ * @param first first name
+ * @param last last name
+ * @param age age
+ */
+ public PersonSample(String first, String last, int age) {
+ this.firstName = first;
+ this.lastName = last;
+ this.age = age;
+ }
+
+ public String getFirstName() {
+ return this.firstName;
+ }
+
+ public void setFirstName(String name) {
+ this.firstName = name;
+ }
+
+ public String getLasttName() {
+ return this.lastName;
+ }
+
+ public void setLastName(String name) {
+ this.lastName = name;
+ }
+
+ public int getAge() {
+ return this.age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
}
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;
+ }
}
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/AllSeemsWellTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/AllSeemsWellTest.java
index 967ca739..806c404c 100644
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/AllSeemsWellTest.java
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/AllSeemsWellTest.java
@@ -35,139 +35,148 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AllSeemsWellTest extends IntegrityMonitorTestBase {
- private static Logger logger = LoggerFactory.getLogger(AllSeemsWellTest.class);
-
- private static final long STATE_CYCLE_MS = 3 * CYCLE_INTERVAL_MS;
-
- private static Properties myProp;
- private static String resourceName;
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- IntegrityMonitorTestBase.setUpBeforeClass(DEFAULT_DB_URL_PREFIX + AllSeemsWellTest.class.getSimpleName());
-
- resourceName = IntegrityMonitorTestBase.siteName + "." + IntegrityMonitorTestBase.nodeType;
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- IntegrityMonitorTestBase.tearDownAfterClass();
- }
-
- @Before
- public void setUp() {
- super.setUpTest();
-
- myProp = makeProperties();
-
- }
-
- @After
- public void tearDown() {
- super.tearDownTest();
- }
-
- // Ignore
- @Test
- public void testAllSeemsWell() throws Exception {
- logger.debug("\nIntegrityMonitorTest: Entering testAllSeemsWell\n\n");
-
- // parameters are passed via a properties file
- myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
- myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
- myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
- myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
- myProp.put(IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD, "1");
- myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "5");
- myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "1");
- myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "1");
-
- IntegrityMonitor.updateProperties(myProp);
- /*
- * The monitorInterval is 5 and the failedCounterThreshold is 1 A
- * forward progress will be stale after 5 seconds.
- */
-
- IntegrityMonitor im = IntegrityMonitor.getInstance(resourceName, myProp);
-
- StateManagement sm = im.getStateManager();
-
- // Give it time to set the states in the DB
- Thread.sleep(STATE_CYCLE_MS);
-
- // Check the state
- logger.debug(
- "\n\ntestAllSeemsWell starting im state \nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
-
- assertEquals(StateManagement.ENABLED, sm.getOpState());
-
- // Indicate a failure
- im.allSeemsWell(this.getClass().getName(), IntegrityMonitorProperties.ALLNOTWELL,
- "'AllSeemsWellTest - ALLNOTWELL'");
-
- // Wait for the state to change due to ALLNOTWELL
- Thread.sleep(STATE_CYCLE_MS);
- // Check the state
- logger.debug(
- "\n\ntestAllSeemsWell after ALLNOTWELL: im state \nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
-
- // assertEquals(StateManagement.DISABLED, sm.getOpState());
-
- Map<String, String> allNotWellMap = im.getAllNotWellMap();
- for (String key : allNotWellMap.keySet()) {
- logger.debug("AllSeemsWellTest: allNotWellMap: key = {} msg = {}", key, allNotWellMap.get(key));
- }
- // assertEquals(1, allNotWellMap.size());
-
- Map<String, String> allSeemsWellMap = im.getAllSeemsWellMap();
- // assertTrue(allSeemsWellMap.isEmpty());
-
- // Return to normal
- im.allSeemsWell(this.getClass().getName(), IntegrityMonitorProperties.ALLSEEMSWELL,
- "'AllSeemsWellTest - ALLSEEMSWELL'");
-
- // Wait for the state to change due to ALLNOTWELL
- Thread.sleep(STATE_CYCLE_MS);
- // Check the state
- logger.debug(
- "\n\ntestAllSeemsWell after ALLSEEMSWELL: im state \nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
-
- // assertEquals(StateManagement.ENABLED, sm.getOpState());
-
- allNotWellMap = im.getAllNotWellMap();
- assertTrue(allNotWellMap.isEmpty());
-
- allSeemsWellMap = im.getAllSeemsWellMap();
- assertEquals(1, allSeemsWellMap.size());
- for (String key : allSeemsWellMap.keySet()) {
- logger.debug("AllSeemsWellTest: allSeemsWellMap: key = {} msg = {}", key, allSeemsWellMap.get(key));
- }
-
- // Check for null parameters
- assertException(im, imx -> {
- imx.allSeemsWell(null, IntegrityMonitorProperties.ALLSEEMSWELL, "'AllSeemsWellTest - ALLSEEMSWELL'");
- });
-
- assertException(im, imx -> {
- im.allSeemsWell("", IntegrityMonitorProperties.ALLSEEMSWELL, "'AllSeemsWellTest - ALLSEEMSWELL'");
- });
-
- assertException(im, imx -> {
- im.allSeemsWell(this.getClass().getName(), null, "'AllSeemsWellTest - ALLSEEMSWELL'");
- });
-
- assertException(im, imx -> {
- im.allSeemsWell(this.getClass().getName(), IntegrityMonitorProperties.ALLSEEMSWELL, null);
- });
-
- assertException(im, imx -> {
- im.allSeemsWell(this.getClass().getName(), IntegrityMonitorProperties.ALLSEEMSWELL, "");
- });
-
- logger.debug("\n\ntestAllSeemsWell: Exit\n\n");
- }
+ private static Logger logger = LoggerFactory.getLogger(AllSeemsWellTest.class);
+
+ private static final long STATE_CYCLE_MS = 3 * CYCLE_INTERVAL_MS;
+
+ private static Properties myProp;
+ private static String resourceName;
+
+ /**
+ * Set up for test class.
+ */
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ IntegrityMonitorTestBase.setUpBeforeClass(DEFAULT_DB_URL_PREFIX + AllSeemsWellTest.class.getSimpleName());
+
+ resourceName = IntegrityMonitorTestBase.siteName + "." + IntegrityMonitorTestBase.nodeType;
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ IntegrityMonitorTestBase.tearDownAfterClass();
+ }
+
+ /**
+ * Set up for test cases.
+ */
+ @Before
+ public void setUp() {
+ super.setUpTest();
+
+ myProp = makeProperties();
+
+ }
+
+ @After
+ public void tearDown() {
+ super.tearDownTest();
+ }
+
+ // Ignore
+ @Test
+ public void testAllSeemsWell() throws Exception {
+ logger.debug("\nIntegrityMonitorTest: Entering testAllSeemsWell\n\n");
+
+ // parameters are passed via a properties file
+ myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
+ myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
+ myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
+ myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
+ myProp.put(IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD, "1");
+ myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "5");
+ myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "1");
+ myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "1");
+
+ IntegrityMonitor.updateProperties(myProp);
+ /*
+ * The monitorInterval is 5 and the failedCounterThreshold is 1 A forward progress will be
+ * stale after 5 seconds.
+ */
+
+ IntegrityMonitor im = IntegrityMonitor.getInstance(resourceName, myProp);
+
+ StateManagement sm = im.getStateManager();
+
+ // Give it time to set the states in the DB
+ Thread.sleep(STATE_CYCLE_MS);
+
+ // Check the state
+ logger.debug(
+ "\n\ntestAllSeemsWell starting im state \nAdminState = {}\nOpState() = {}\nAvailStatus = {}\n"
+ + "StandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ assertEquals(StateManagement.ENABLED, sm.getOpState());
+
+ // Indicate a failure
+ im.allSeemsWell(this.getClass().getName(), IntegrityMonitorProperties.ALLNOTWELL,
+ "'AllSeemsWellTest - ALLNOTWELL'");
+
+ // Wait for the state to change due to ALLNOTWELL
+ Thread.sleep(STATE_CYCLE_MS);
+ // Check the state
+ logger.debug(
+ "\n\ntestAllSeemsWell after ALLNOTWELL: im state \nAdminState = {}\nOpState() = {}\nAvailStatus = "
+ + "{}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ // assertEquals(StateManagement.DISABLED, sm.getOpState());
+
+ Map<String, String> allNotWellMap = im.getAllNotWellMap();
+ for (String key : allNotWellMap.keySet()) {
+ logger.debug("AllSeemsWellTest: allNotWellMap: key = {} msg = {}", key, allNotWellMap.get(key));
+ }
+ // assertEquals(1, allNotWellMap.size());
+
+ im.getAllSeemsWellMap();
+ // assertTrue(allSeemsWellMap.isEmpty());
+
+ // Return to normal
+ im.allSeemsWell(this.getClass().getName(), IntegrityMonitorProperties.ALLSEEMSWELL,
+ "'AllSeemsWellTest - ALLSEEMSWELL'");
+
+ // Wait for the state to change due to ALLNOTWELL
+ Thread.sleep(STATE_CYCLE_MS);
+ // Check the state
+ logger.debug(
+ "\n\ntestAllSeemsWell after ALLSEEMSWELL: im state \nAdminState = {}\nOpState() = {}\nAvailStatus = "
+ + "{}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ // assertEquals(StateManagement.ENABLED, sm.getOpState());
+
+ allNotWellMap = im.getAllNotWellMap();
+ assertTrue(allNotWellMap.isEmpty());
+
+ Map<String, String> allSeemsWellMap = im.getAllSeemsWellMap();
+ assertEquals(1, allSeemsWellMap.size());
+ for (String key : allSeemsWellMap.keySet()) {
+ logger.debug("AllSeemsWellTest: allSeemsWellMap: key = {} msg = {}", key, allSeemsWellMap.get(key));
+ }
+
+ // Check for null parameters
+ assertException(im, imx -> {
+ imx.allSeemsWell(null, IntegrityMonitorProperties.ALLSEEMSWELL, "'AllSeemsWellTest - ALLSEEMSWELL'");
+ });
+
+ assertException(im, imx -> {
+ im.allSeemsWell("", IntegrityMonitorProperties.ALLSEEMSWELL, "'AllSeemsWellTest - ALLSEEMSWELL'");
+ });
+
+ assertException(im, imx -> {
+ im.allSeemsWell(this.getClass().getName(), null, "'AllSeemsWellTest - ALLSEEMSWELL'");
+ });
+
+ assertException(im, imx -> {
+ im.allSeemsWell(this.getClass().getName(), IntegrityMonitorProperties.ALLSEEMSWELL, null);
+ });
+
+ assertException(im, imx -> {
+ im.allSeemsWell(this.getClass().getName(), IntegrityMonitorProperties.ALLSEEMSWELL, "");
+ });
+
+ logger.debug("\n\ntestAllSeemsWell: Exit\n\n");
+ }
}
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/ExceptionsTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/ExceptionsTest.java
index 90de7c66..f3cb1eff 100644
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/ExceptionsTest.java
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/ExceptionsTest.java
@@ -23,14 +23,6 @@ package org.onap.policy.common.im;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
-import org.onap.policy.common.im.AdministrativeStateException;
-import org.onap.policy.common.im.AllSeemsWellException;
-import org.onap.policy.common.im.ForwardProgressException;
-import org.onap.policy.common.im.IntegrityMonitorException;
-import org.onap.policy.common.im.IntegrityMonitorPropertiesException;
-import org.onap.policy.common.im.StandbyStatusException;
-import org.onap.policy.common.im.StateManagementException;
-import org.onap.policy.common.im.StateTransitionException;
import org.onap.policy.common.im.jmx.ComponentAdminException;
import org.onap.policy.common.utils.test.ExceptionsTester;
@@ -39,48 +31,48 @@ import org.onap.policy.common.utils.test.ExceptionsTester;
*/
public class ExceptionsTest extends ExceptionsTester {
- @Test
- public void testStateTransitionException() throws Exception {
- assertEquals(4, test(StateTransitionException.class));
- }
+ @Test
+ public void testStateTransitionException() throws Exception {
+ assertEquals(4, test(StateTransitionException.class));
+ }
- @Test
- public void testStateManagementException() throws Exception {
- assertEquals(4, test(StateManagementException.class));
- }
+ @Test
+ public void testStateManagementException() throws Exception {
+ assertEquals(4, test(StateManagementException.class));
+ }
- @Test
- public void testStandbyStatusException() throws Exception {
- assertEquals(5, test(StandbyStatusException.class));
- }
+ @Test
+ public void testStandbyStatusException() throws Exception {
+ assertEquals(5, test(StandbyStatusException.class));
+ }
- @Test
- public void testIntegrityMonitorPropertiesException() throws Exception {
- assertEquals(4, test(IntegrityMonitorPropertiesException.class));
- }
+ @Test
+ public void testIntegrityMonitorPropertiesException() throws Exception {
+ assertEquals(4, test(IntegrityMonitorPropertiesException.class));
+ }
- @Test
- public void testIntegrityMonitorException() throws Exception {
- assertEquals(5, test(IntegrityMonitorException.class));
- }
+ @Test
+ public void testIntegrityMonitorException() throws Exception {
+ assertEquals(5, test(IntegrityMonitorException.class));
+ }
- @Test
- public void testForwardProgressException() throws Exception {
- assertEquals(4, test(ForwardProgressException.class));
- }
+ @Test
+ public void testForwardProgressException() throws Exception {
+ assertEquals(4, test(ForwardProgressException.class));
+ }
- @Test
- public void testAllSeemsWellException() throws Exception {
- assertEquals(4, test(AllSeemsWellException.class));
- }
+ @Test
+ public void testAllSeemsWellException() throws Exception {
+ assertEquals(4, test(AllSeemsWellException.class));
+ }
- @Test
- public void testAdministrativeStateException() throws Exception {
- assertEquals(4, test(AdministrativeStateException.class));
- }
+ @Test
+ public void testAdministrativeStateException() throws Exception {
+ assertEquals(4, test(AdministrativeStateException.class));
+ }
- @Test
- public void testComponentAdminException() throws Exception {
- assertEquals(4, test(ComponentAdminException.class));
- }
+ @Test
+ public void testComponentAdminException() throws Exception {
+ assertEquals(4, test(ComponentAdminException.class));
+ }
}
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTest.java
index 3704b07d..7f1e5516 100644
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTest.java
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTest.java
@@ -51,857 +51,873 @@ import org.slf4j.LoggerFactory;
* tasks.
*/
public class IntegrityMonitorTest extends IntegrityMonitorTestBase {
- private static Logger logger = LoggerFactory.getLogger(IntegrityMonitorTest.class);
-
- private static Properties myProp;
- private static EntityTransaction et;
- private static String resourceName;
-
- private BlockingQueue<CountDownLatch> queue;
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- IntegrityMonitorTestBase.setUpBeforeClass(DEFAULT_DB_URL_PREFIX + IntegrityMonitorTest.class.getSimpleName());
-
- resourceName = IntegrityMonitorTestBase.siteName + "." + IntegrityMonitorTestBase.nodeType;
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- IntegrityMonitorTestBase.tearDownAfterClass();
- }
-
- @Before
- public void setUp() throws Exception {
- super.setUpTest();
-
- myProp = makeProperties();
- et = null;
- }
-
- @After
- public void tearDown() throws Exception {
- if (et != null && et.isActive()) {
- try {
- et.rollback();
-
- } catch (RuntimeException e) {
- logger.error("cannot rollback transaction", e);
- }
- }
-
- super.tearDownTest();
- }
-
- /*
- * The following test verifies the following test cases: New Install New
- * Install - Bad Dependency data Recovery from bad dependency data Lock Lock
- * restart Unlock Unlock restart
- */
- @Test
- public void testSanityJmx() throws Exception {
- logger.debug("\nIntegrityMonitorTest: Entering testSanityJmx\n\n");
-
- String dependent = "group1_logparser";
-
- // parameters are passed via a properties file
- myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, dependent);
- myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "true");
- // Disable the integrity monitor so it will not interfere
- myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "-1");
- // Disable the refresh state audit
- myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
- // Disable the state audit
- myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
- // Disable the test transaction
- myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "-1");
- // Disable the write FPC
- myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "-1");
- // Speed up the check
- myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "1");
- // Fail dependencies after three seconds
- myProp.put(IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL, "3");
-
- IntegrityMonitor im = makeMonitor(resourceName, myProp);
- logger.debug(
- "\n\ntestSanityJmx starting im state \nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- im.getStateManager().getAdminState(), im.getStateManager().getOpState(),
- im.getStateManager().getAvailStatus(), im.getStateManager().getStandbyStatus());
- // add an entry to Resource registration table in the DB for the
- // dependent resource
-
- et = em.getTransaction();
- et.begin();
- Query rquery = em.createQuery("Select r from ResourceRegistrationEntity r where r.resourceName=:rn");
- rquery.setParameter("rn", dependent);
-
- @SuppressWarnings("rawtypes")
- List rrList = rquery.getResultList();
- ResourceRegistrationEntity rrx = null;
- if (rrList.isEmpty()) {
- // register resource by adding entry to table in DB
- logger.debug("Adding resource {} to ResourceRegistration table", dependent);
- rrx = new ResourceRegistrationEntity();
- // set columns in entry
- rrx.setResourceName(dependent);
- rrx.setResourceUrl("service:jmx:somewhere:9999");
- rrx.setNodeType("logparser");
- rrx.setSite("siteA");
- }
- em.persist(rrx);
- // flush to the DB
- em.flush();
-
- // commit transaction
- et.commit();
-
- // wait for the FPManager to check dependency health
- waitStep();
-
- assertException(im, imx -> {
- imx.evaluateSanity();
- });
-
- // undo dependency groups and jmx test properties settings
- myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
- myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
- IntegrityMonitor.updateProperties(myProp);
-
- logger.debug("\ntestSantityJmx ending properties: {}", myProp);
-
- // We know at this point that the IM is disable-dependency. We want to
- // be
- // sure it will recover from this condition since the properties were
- // updated.
-
- logger.debug(
- "\n\ntestSanityJmx ending im state\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- im.getStateManager().getAdminState(), im.getStateManager().getOpState(),
- im.getStateManager().getAvailStatus(), im.getStateManager().getStandbyStatus());
-
- logger.debug("\ntestSanityJmx restarting the IntegrityMonitor");
- // Create a new instance. It should recover from the disabled-dependency
- // condition
- im = makeMonitor(resourceName, myProp);
-
- logger.debug(
- "\n\ntestSanityJmx state after creating new im\n"
- + "AdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- im.getStateManager().getAdminState(), im.getStateManager().getOpState(),
- im.getStateManager().getAvailStatus(), im.getStateManager().getStandbyStatus());
-
- // Verify the state
- assertEquals(StateManagement.UNLOCKED, im.getStateManager().getAdminState());
- assertEquals(StateManagement.ENABLED, im.getStateManager().getOpState());
- assertEquals(StateManagement.NULL_VALUE, im.getStateManager().getAvailStatus());
- assertEquals(StateManagement.NULL_VALUE, im.getStateManager().getStandbyStatus());
-
- // Test state manager via the IntegrityMonitor
- StateManagement sm = im.getStateManager();
-
- // Verify lock state
- sm.lock();
- logger.debug("\n\nsm.lock()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
- assertEquals(StateManagement.LOCKED, sm.getAdminState());
-
- // Verify lock persists across a restart
- logger.debug("\ntestSanityJmx restarting the IntegrityMonitor");
- // Create a new instance. It should come up with the admin state locked
- im = makeMonitor(resourceName, myProp);
- sm = im.getStateManager();
- logger.debug(
- "\n\ntestSanityJmx restart with AdminState=locked"
- + "\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
- assertEquals(StateManagement.LOCKED, sm.getAdminState());
-
- // Verify unlock
- sm.unlock();
- logger.debug(
- "\n\ntestSanityJmx sm.unlock\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
- assertEquals(StateManagement.UNLOCKED, sm.getAdminState());
-
- // Verify unlock restart
- logger.debug("\ntestSanityJmx restarting the IntegrityMonitor");
- // Create a new instance. It should come up with the admin state locked
- im = makeMonitor(resourceName, myProp);
- sm = im.getStateManager();
- logger.debug(
- "\n\ntestSanityJmx restart with AdminState=unlocked\n"
- + "AdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
-
- assertEquals(StateManagement.UNLOCKED, sm.getAdminState());
-
- logger.debug("\n\ntestSanityJmx: Exit\n\n");
- }
-
- @Test
- public void testIM() throws Exception {
- logger.debug("\nIntegrityMonitorTest: Entering testIM\n\n");
-
- // Disable the integrity monitor so it will not interfere
- myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "-1");
- // Disable dependency checking
- myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "-1");
- // Disable the refresh state audit
- myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
- // Disable the state audit
- myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
- // Disable the test transaction
- myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "-1");
- // Disable writing the FPC
- myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "-1");
-
- IntegrityMonitor im = makeMonitor(resourceName, myProp);
-
- logger.debug("\n\nim initial state: \nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- im.getStateManager().getAdminState(), im.getStateManager().getOpState(),
- im.getStateManager().getAvailStatus(), im.getStateManager().getStandbyStatus());
-
- waitStep();
-
- // test evaluate sanity
- assertNoException(im, imx -> {
- imx.evaluateSanity();
- });
-
- // Test startTransaction - should work since it is unlocked
- assertNoException(im, imx -> {
- imx.startTransaction();
- });
-
- // Test state manager via the IntegrityMonitor
- StateManagement sm = im.getStateManager();
-
- sm.lock();
-
- logger.debug("\n\nsm.lock()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
-
- assertEquals(StateManagement.LOCKED, sm.getAdminState());
-
- // test startTransaction. It should fail since it is locked
- assertException(im, imx -> {
- imx.startTransaction();
- });
-
- sm.unlock();
- logger.debug("\n\nsm.unlock()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
- assertEquals(StateManagement.UNLOCKED, sm.getAdminState());
-
- // test startTransaction. It should succeed
- assertNoException(im, imx -> {
- imx.startTransaction();
- });
-
- sm.disableDependency();
- logger.debug(
- "\n\nsm.disableDependency()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
-
- assertEquals(StateManagement.DISABLED, sm.getOpState());
- assertEquals(StateManagement.DEPENDENCY, sm.getAvailStatus());
-
- // test startTransaction. It should succeed since standby status is null
- // and unlocked
- assertNoException(im, imx -> {
- imx.startTransaction();
- });
-
- sm.enableNoDependency();
-
- logger.debug(
- "\n\nsm.enableNoDependency()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
- assertEquals(StateManagement.ENABLED, sm.getOpState());
- // test startTransaction. It should succeed since standby status is null
- // and unlocked
- assertNoException(im, imx -> {
- imx.startTransaction();
- });
-
- sm.disableFailed();
- logger.debug("\n\nsm.disableFailed()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
-
- assertEquals(StateManagement.DISABLED, sm.getOpState());
- assertEquals(StateManagement.FAILED, sm.getAvailStatus());
- // test startTransaction. It should succeed since standby status is null
- // and unlocked
- assertNoException(im, imx -> {
- imx.startTransaction();
- });
-
- sm.enableNotFailed();
-
- logger.debug(
- "\n\nsm.enabledNotFailed()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
-
- assertEquals(StateManagement.ENABLED, sm.getOpState());
- // test startTransaction. It should succeed since standby status is null
- // and unlocked
- assertNoException(im, imx -> {
- imx.startTransaction();
- });
-
- sm.demote();
-
- logger.debug("\n\nsm.demote()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
-
- assertEquals(StateManagement.HOT_STANDBY, sm.getStandbyStatus());
-
- // test startTransaction. It should fail since it is standby
- assertException(im, imx -> {
- imx.startTransaction();
- });
-
- sm.promote();
-
- logger.debug("\n\nsm.promote()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
-
- assertEquals(StateManagement.PROVIDING_SERVICE, sm.getStandbyStatus());
-
- // test startTransaction. It should succeed since it is providing
- // service
- assertNoException(im, imx -> {
- imx.startTransaction();
- });
-
- // Test the multi-valued availability status
- sm.disableDependency();
- sm.disableFailed();
-
- logger.debug(
- "\n\nsm.disableDependency(), sm.disableFailed\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
-
- assertEquals(StateManagement.DEPENDENCY_FAILED, sm.getAvailStatus());
-
- // Test startTransaction. Should fail since standby status is cold
- // standby
- assertException(im, imx -> {
- imx.startTransaction();
- });
-
- sm.enableNoDependency();
-
- logger.debug(
- "\n\nsm.enableNoDependency()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
- assertEquals(StateManagement.FAILED, sm.getAvailStatus());
- // Test startTransaction. Should fail since standby status is cold
- // standby
- assertException(im, imx -> {
- imx.startTransaction();
- });
-
- sm.disableDependency();
- sm.enableNotFailed();
-
- logger.debug(
- "\n\nsm.disableDependency(),sm.enableNotFailed()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
-
- assertEquals(StateManagement.DEPENDENCY, sm.getAvailStatus());
- // Test startTransaction. Should fail since standby status is cold
- // standby
- assertException(im, imx -> {
- imx.startTransaction();
- });
-
- sm.enableNoDependency();
- logger.debug(
- "\n\nsm.enableNoDependency()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
- assertEquals(StateManagement.ENABLED, sm.getOpState());
- // test startTransaction. It should fail since standby status is hot
- // standby
- assertException(im, imx -> {
- imx.startTransaction();
- });
-
- logger.debug("\n\ntestIM: Exit\n\n");
- }
-
- @Test
- public void testSanityState() throws Exception {
- logger.debug("\nIntegrityMonitorTest: Entering testSanityState\n\n");
-
- // parameters are passed via a properties file
- myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "group1_dep1,group1_dep2; group2_dep1");
- // Disable the integrity monitor so it will not interfere
- myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "-1");
- // Disable the refresh state audit
- myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
- // Disable dependency checking so it does not interfere
- myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "-1");
- // Disable the state audit
- myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
- // Disable the test transaction
- myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "-1");
- // Disable writing the FPC
- myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "-1");
- // Max interval for use in deciding if a FPC entry is stale in seconds
- myProp.put(IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL, "120");
-
- IntegrityMonitor im = makeMonitor(resourceName, myProp);
-
- waitStep();
-
- // Add a group1 dependent resources to put an entry in the forward
- // progress table
- ForwardProgressEntity fpe = new ForwardProgressEntity();
- ForwardProgressEntity fpe2 = new ForwardProgressEntity();
- fpe.setFpcCount(0);
- fpe.setResourceName("group1_dep1");
- fpe2.setFpcCount(0);
- fpe2.setResourceName("group1_dep2");
- et = em.getTransaction();
- et.begin();
- em.persist(fpe);
- em.persist(fpe2);
- em.flush();
- et.commit();
-
- // Add a group2 dependent resource to the StateManagementEntity DB table
- // and set its admin state to locked
- // Expect sanity test to fail.
- StateManagement stateManager = new StateManagement(emf, "group2_dep1");
- stateManager.lock();
-
- new StateManagement(emf, "group1_dep1");
- new StateManagement(emf, "group1_dep2");
-
- // Call the dependency check directly instead of waiting for FPManager
- // to do it.
- logger.debug("\n\nIntegrityMonitor.testSanityState: calling im.dependencyCheck()\n\n");
- im.dependencyCheck();
- assertException(im, imx -> {
- imx.evaluateSanity();
- });
-
- logger.debug("\n\ntestSanityState: Exit\n\n");
- }
-
- @Test
- public void testRefreshStateAudit() throws Exception {
- logger.debug("\nIntegrityMonitorTest: testRefreshStateAudit Enter\n\n");
-
- // parameters are passed via a properties file
- myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
- myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
- // Disable the integrity monitor so it will not interfere
- myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "-1");
- // Disable the refresh state audit
- myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
- // Disable dependency checking so it does not interfere
- myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "-1");
- // Disable the state audit
- myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
- // Disable the test transaction
- myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "-1");
- // Disable writing the FPC
- myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "-1");
-
- IntegrityMonitor im = makeMonitor(resourceName, myProp);
-
- waitStep();
-
- // the state here is unlocked, enabled, null, null
- StateManagementEntity sme = null;
-
- Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
-
- query.setParameter("resource", resourceName);
-
- // Just test that we are retrieving the right object
- @SuppressWarnings("rawtypes")
- List resourceList = query.getResultList();
- if (!resourceList.isEmpty()) {
- // exist
- sme = (StateManagementEntity) resourceList.get(0);
- em.refresh(sme);
-
- logger.debug(
- "??? -- Retrieve StateManagementEntity from database --\nsme.getResourceName() = {}\n"
- + "sme.getAdminState() = {}\nsme.getOpState() = {}\nsme.getAvailStatus() = {}\nsme.getStandbyStatus() = {}",
- sme.getResourceName(), sme.getAdminState(), sme.getOpState(), sme.getAvailStatus(),
- sme.getStandbyStatus());
-
- assertEquals(StateManagement.UNLOCKED, sme.getAdminState());
- assertEquals(StateManagement.ENABLED, sme.getOpState());
- assertEquals(StateManagement.NULL_VALUE, sme.getAvailStatus());
- assertEquals(StateManagement.NULL_VALUE, sme.getStandbyStatus());
- logger.debug("--");
- } else {
- logger.debug("Record not found, resourceName: " + resourceName);
- fail("missing record");
- }
-
- et = em.getTransaction();
- et.begin();
-
- sme.setStandbyStatus(StateManagement.COLD_STANDBY);
- em.persist(sme);
- em.flush();
- et.commit();
-
- // Run the refreshStateAudit
- im.executeRefreshStateAudit();
-
- // The refreshStateAudit should run and change the state to
- // unlocked,enabled,null,hotstandby
- StateManagementEntity sme1 = null;
-
- Query query1 = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
-
- query1.setParameter("resource", resourceName);
-
- @SuppressWarnings("rawtypes")
- List resourceList1 = query1.getResultList();
- if (!resourceList1.isEmpty()) {
- // exist
- sme1 = (StateManagementEntity) resourceList1.get(0);
- em.refresh(sme1);
- logger.debug(
- "??? -- Retrieve StateManagementEntity from database --\nsme1.getResourceName() = {}\n"
- + "sme1.getAdminState() = {}\nsme1.getOpState() = {}\nsme1.getAvailStatus() = {}\nsme1.getStandbyStatus() = {}",
- sme1.getResourceName(), sme1.getAdminState(), sme1.getOpState(), sme1.getAvailStatus(),
- sme1.getStandbyStatus());
-
- assertEquals(StateManagement.UNLOCKED, sme1.getAdminState());
- assertEquals(StateManagement.ENABLED, sme1.getOpState());
- assertEquals(StateManagement.NULL_VALUE, sme1.getAvailStatus());
- assertEquals(StateManagement.HOT_STANDBY, sme1.getStandbyStatus());
- logger.debug("--");
- } else {
- logger.debug("Record not found, resourceName: " + resourceName);
- fail("record not found");
- }
-
- logger.debug("\nIntegrityMonitorTest: testRefreshStateAudit Exit\n\n");
- }
-
- @Test
- public void testStateCheck() throws Exception {
- logger.debug("\nIntegrityMonitorTest: Entering testStateCheck\n\n");
-
- // parameters are passed via a properties file
- myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "group1_dep1");
- myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
- myProp.put(IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD, "1");
- /*
- * The monitorInterval is set to 10 and the failedCounterThreshold is 1
- * because stateCheck() uses the faileCounterThreshold * monitorInterval
- * to determine if an entry is stale, it will be stale after 10 seconds.
- */
- myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "5");
- /*
- * We accelerate the test transaction and write FPC intervals because we
- * don't want there to be any chance of a FPC failure because of the
- * short monitor interval
- */
- myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "1");
- myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "2");
- // Disable the refresh state audit
- myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
- // The maximum time in seconds to determine that a FPC entry is stale
- myProp.put(IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL, "5");
- myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "5");
-
- IntegrityMonitor im = makeMonitor(resourceName, myProp);
-
- // Note: do ***NOT*** do waitStep() here
-
- // Add a group1 dependent resources to put an entry in the forward
- // progress table
- // This sets lastUpdated to the current time
- ForwardProgressEntity fpe = new ForwardProgressEntity();
- fpe.setFpcCount(0);
- fpe.setResourceName("group1_dep1");
- et = em.getTransaction();
- et.begin();
- em.persist(fpe);
- em.flush();
- et.commit();
-
- new StateManagement(emf, "group1_dep1");
-
- assertNoException(im, imx -> {
- imx.evaluateSanity();
- });
-
- // wait for FPManager to perform dependency health check. Once that's
- // done,
- // it should now be stale and the sanity check should fail
- waitStep();
-
- assertException(im, imx -> {
- imx.evaluateSanity();
- });
-
- logger.debug("\n\ntestStateCheck: Exit\n\n");
- }
-
- @Test
- public void testGetAllForwardProgressEntity() throws Exception {
- logger.debug("\nIntegrityMonitorTest: Entering testGetAllForwardProgressEntity\n\n");
- // parameters are passed via a properties file
- myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
- myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
- // Disable the integrity monitor so it will not interfere
- myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "-1");
- // Disable the refresh state audit
- myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
- // Disable dependency checking so it does not interfere
- myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "-1");
- // Disable the state audit
- myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
- // Disable the test transaction
- myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "-1");
- // Disable writing the FPC
- myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "-1");
-
- IntegrityMonitor im = makeMonitor(resourceName, myProp);
- waitStep();
-
- logger.debug("\nIntegrityMonitorTest: Creating ForwardProgressEntity entries\n\n");
- // Add resource entries in the forward progress table
- ForwardProgressEntity fpe = new ForwardProgressEntity();
- ForwardProgressEntity fpe2 = new ForwardProgressEntity();
- ForwardProgressEntity fpe3 = new ForwardProgressEntity();
- fpe.setFpcCount(0);
- fpe.setResourceName("siteA_pap2");
- fpe2.setFpcCount(0);
- fpe2.setResourceName("siteB_pap1");
- fpe3.setFpcCount(0);
- fpe3.setResourceName("siteB_pap2");
- et = em.getTransaction();
- et.begin();
- em.persist(fpe);
- em.persist(fpe2);
- em.persist(fpe3);
- em.flush();
- et.commit();
-
- logger.debug(
- "\nIntegrityMonitorTest:testGetAllForwardProgressEntity Calling im.getAllForwardProgressEntity()\n\n");
- List<ForwardProgressEntity> fpeList = im.getAllForwardProgressEntity();
-
- assertEquals(4, fpeList.size());
-
- logger.debug("\nIntegrityMonitorTest: Exit testGetAllForwardProgressEntity\n\n");
- }
-
- @Test
- public void testStateAudit() throws Exception {
- logger.debug("\nIntegrityMonitorTest: Entering testStateAudit\n\n");
-
- // parameters are passed via a properties file
-
- // No Dependency Groups
- myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
- // Don't use JMX
- myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
- // Disable the internal sanity monitoring.
- myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "-1");
- // Disable the dependency monitoring.
- myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "-1");
- // Disable the refresh state audit
- myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
- // Disable the test transaction
- myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "-1");
- // Disable the write FPC
- myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "-1");
- // Disable the State Audit we will call it directly
- myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
- // Max interval for use in deciding if a FPC entry is stale in seconds
- myProp.put(IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL, "120");
-
- IntegrityMonitor im = makeMonitor(resourceName, myProp);
- waitStep();
-
- logger.debug("\nIntegrityMonitorTest: Creating ForwardProgressEntity entries\n\n");
- // Add resources to put an entry in the forward progress table
- Date staleDate = new Date(0);
- ForwardProgressEntity fpe1 = new ForwardProgressEntity();
- ForwardProgressEntity fpe2 = new ForwardProgressEntity();
- ForwardProgressEntity fpe3 = new ForwardProgressEntity();
- fpe1.setFpcCount(0);
- fpe1.setResourceName("siteA_pap2");
- fpe2.setFpcCount(0);
- fpe2.setResourceName("siteB_pap1");
- fpe3.setFpcCount(0);
- fpe3.setResourceName("siteB_pap2");
- logger.debug("\nIntegrityMonitorTest: Creating StateManagementEntity entries\n\n");
- StateManagementEntity sme1 = new StateManagementEntity();
- StateManagementEntity sme2 = new StateManagementEntity();
- StateManagementEntity sme3 = new StateManagementEntity();
- sme1.setResourceName("siteA_pap2");
- sme1.setAdminState(StateManagement.UNLOCKED);
- sme1.setOpState(StateManagement.ENABLED);
- sme1.setAvailStatus(StateManagement.NULL_VALUE);
- sme1.setStandbyStatus(StateManagement.NULL_VALUE);
- sme2.setResourceName("siteB_pap1");
- sme2.setAdminState(StateManagement.UNLOCKED);
- sme2.setOpState(StateManagement.ENABLED);
- sme2.setAvailStatus(StateManagement.NULL_VALUE);
- sme2.setStandbyStatus(StateManagement.NULL_VALUE);
- sme3.setResourceName("siteB_pap2");
- sme3.setAdminState(StateManagement.UNLOCKED);
- sme3.setOpState(StateManagement.ENABLED);
- sme3.setAvailStatus(StateManagement.NULL_VALUE);
- sme3.setStandbyStatus(StateManagement.NULL_VALUE);
- et = em.getTransaction();
- et.begin();
- em.persist(fpe1);
- em.persist(fpe2);
- em.persist(fpe3);
- em.persist(sme1);
- em.persist(sme2);
- em.persist(sme3);
- em.flush();
- et.commit();
-
- Query updateQuery = em.createQuery(
- "UPDATE ForwardProgressEntity f " + "SET f.lastUpdated = :newDate " + "WHERE f.resourceName=:resource");
- updateQuery.setParameter("newDate", staleDate, TemporalType.TIMESTAMP);
- updateQuery.setParameter("resource", fpe1.getResourceName());
-
- et = em.getTransaction();
- et.begin();
- updateQuery.executeUpdate();
- et.commit();
-
- logger.debug("\nIntegrityMonitorTest:testStateAudit Calling im.getAllForwardProgressEntity()\n\n");
- List<ForwardProgressEntity> fpeList = im.getAllForwardProgressEntity();
-
- logger.debug("\n\n");
- logger.debug("IntegrityMonitorTest:testStateAudit:ForwardProgressEntity entries");
- for (ForwardProgressEntity myFpe : fpeList) {
- logger.debug("\n ResourceName: {}" + "\n LastUpdated: {}", myFpe.getResourceName(),
- myFpe.getLastUpdated());
- }
- logger.debug("\n\n");
-
- logger.debug("\nIntegrityMonitorTest:testStateAudit getting list of StateManagementEntity entries\n\n");
- Query query = em.createQuery("SELECT s FROM StateManagementEntity s");
- List<?> smeList = query.getResultList();
-
- logger.debug("\n\n");
- logger.debug("IntegrityMonitorTest:testStateAudit:StateManagementEntity entries");
- for (Object mySme : smeList) {
- StateManagementEntity tmpSme = (StateManagementEntity) mySme;
- em.refresh(tmpSme);
- logger.debug(
- "\n ResourceName: {}" + "\n AdminState: {}" + "\n OpState: {}"
- + "\n AvailStatus: {}" + "\n StandbyStatus: {}",
- tmpSme.getResourceName(), tmpSme.getAdminState(), tmpSme.getOpState(), tmpSme.getAvailStatus(),
- tmpSme.getStandbyStatus());
- }
- logger.debug("\n\n");
-
- em.refresh(sme1);
- assertEquals(StateManagement.ENABLED, sme1.getOpState());
-
- logger.debug("IntegrityMonitorTest:testStateAudit: calling stateAudit()");
- im.executeStateAudit();
- logger.debug("IntegrityMonitorTest:testStateAudit: call to stateAudit() complete");
-
- logger.debug("\nIntegrityMonitorTest:testStateAudit getting list of StateManagementEntity entries\n\n");
- smeList = query.getResultList();
-
- logger.debug("\n\n");
- logger.debug("IntegrityMonitorTest:testStateAudit:StateManagementEntity entries");
- for (Object mySme : smeList) {
- StateManagementEntity tmpSme = (StateManagementEntity) mySme;
- em.refresh(tmpSme);
- logger.debug(
- "\n ResourceName: {}" + "\n AdminState: {}" + "\n OpState: {}"
- + "\n AvailStatus: {}" + "\n StandbyStatus: {}",
- tmpSme.getResourceName(), tmpSme.getAdminState(), tmpSme.getOpState(), tmpSme.getAvailStatus(),
- tmpSme.getStandbyStatus());
- }
- logger.debug("\n\n");
-
- em.refresh(sme1);
- assertEquals(StateManagement.DISABLED, sme1.getOpState());
-
- // Now let's add sme2 to the mix
- updateQuery = em.createQuery(
- "UPDATE ForwardProgressEntity f " + "SET f.lastUpdated = :newDate " + "WHERE f.resourceName=:resource");
- updateQuery.setParameter("newDate", staleDate, TemporalType.TIMESTAMP);
- updateQuery.setParameter("resource", fpe2.getResourceName());
-
- et = em.getTransaction();
- et.begin();
- updateQuery.executeUpdate();
- et.commit();
-
- // Give it a chance to write the DB and run the audit
- logger.debug("IntegrityMonitorTest:testStateAudit: (restart4) Running State Audit");
- waitStep();
- im.executeStateAudit();
- waitStep();
- logger.debug("IntegrityMonitorTest:testStateAudit: (restart4) State Audit complete");
-
- // Now check its state
- logger.debug(
- "\nIntegrityMonitorTest:testStateAudit (restart4) getting list of StateManagementEntity entries\n\n");
- smeList = query.getResultList();
-
- logger.debug("\n\n");
- logger.debug("IntegrityMonitorTest:testStateAudit:StateManagementEntity (restart4) entries");
- for (Object mySme : smeList) {
- StateManagementEntity tmpSme = (StateManagementEntity) mySme;
- em.refresh(tmpSme);
-
- logger.debug(
- "\n (restart4) ResourceName: {}" + "\n AdminState: {}" + "\n OpState: {}"
- + "\n AvailStatus: {}" + "\n StandbyStatus: {}",
- tmpSme.getResourceName(), tmpSme.getAdminState(), tmpSme.getOpState(), tmpSme.getAvailStatus(),
- tmpSme.getStandbyStatus());
- }
- logger.debug("\n\n");
-
- em.refresh(sme1);
- assertEquals(StateManagement.DISABLED, sme1.getOpState());
-
- em.refresh(sme2);
- assertEquals(StateManagement.DISABLED, sme2.getOpState());
-
- logger.debug("\nIntegrityMonitorTest: Exit testStateAudit\n\n");
- System.out.println("\n\ntestStateAudit: Exit\n\n");
- }
-
- private IntegrityMonitor makeMonitor(String resourceName, Properties myProp) throws Exception {
- IntegrityMonitor.deleteInstance();
-
- queue = new LinkedBlockingQueue<>();
-
- IntegrityMonitor im = IntegrityMonitor.getInstance(resourceName, myProp, queue);
-
- // wait for the monitor thread to start
- waitStep();
-
- return im;
- }
-
- /**
- * Waits for the FPManager to complete another cycle.
- *
- * @throws InterruptedException
- */
- private void waitStep() throws InterruptedException {
- CountDownLatch latch = new CountDownLatch(1);
- queue.offer(latch);
- waitLatch(latch);
- }
+ private static Logger logger = LoggerFactory.getLogger(IntegrityMonitorTest.class);
+
+ private static Properties myProp;
+ private static EntityTransaction et;
+ private static String resourceName;
+
+ private BlockingQueue<CountDownLatch> queue;
+
+ /**
+ * Set up for test class.
+ */
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ IntegrityMonitorTestBase.setUpBeforeClass(DEFAULT_DB_URL_PREFIX + IntegrityMonitorTest.class.getSimpleName());
+
+ resourceName = IntegrityMonitorTestBase.siteName + "." + IntegrityMonitorTestBase.nodeType;
+ }
+
+ /**
+ * Tear down after test class.
+ */
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ IntegrityMonitorTestBase.tearDownAfterClass();
+ }
+
+ /**
+ * Set up for test cases.
+ */
+ @Before
+ public void setUp() throws Exception {
+ super.setUpTest();
+
+ myProp = makeProperties();
+ et = null;
+ }
+
+ /**
+ * Tear down after test cases.
+ */
+ @After
+ public void tearDown() throws Exception {
+ if (et != null && et.isActive()) {
+ try {
+ et.rollback();
+
+ } catch (RuntimeException e) {
+ logger.error("cannot rollback transaction", e);
+ }
+ }
+
+ super.tearDownTest();
+ }
+
+ /*
+ * The following test verifies the following test cases: New Install New Install - Bad
+ * Dependency data Recovery from bad dependency data Lock Lock restart Unlock Unlock restart
+ */
+ @Test
+ public void testSanityJmx() throws Exception {
+ logger.debug("\nIntegrityMonitorTest: Entering testSanityJmx\n\n");
+
+ String dependent = "group1_logparser";
+
+ // parameters are passed via a properties file
+ myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, dependent);
+ myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "true");
+ // Disable the integrity monitor so it will not interfere
+ myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "-1");
+ // Disable the refresh state audit
+ myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable the state audit
+ myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable the test transaction
+ myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "-1");
+ // Disable the write FPC
+ myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "-1");
+ // Speed up the check
+ myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "1");
+ // Fail dependencies after three seconds
+ myProp.put(IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL, "3");
+
+ IntegrityMonitor im = makeMonitor(resourceName, myProp);
+ logger.debug(
+ "\n\ntestSanityJmx starting im state \nAdminState = {}\nOpState() = {}\nAvailStatus = {}\n"
+ + "StandbyStatus = {}\n",
+ im.getStateManager().getAdminState(), im.getStateManager().getOpState(),
+ im.getStateManager().getAvailStatus(), im.getStateManager().getStandbyStatus());
+ // add an entry to Resource registration table in the DB for the
+ // dependent resource
+
+ et = em.getTransaction();
+ et.begin();
+ Query rquery = em.createQuery("Select r from ResourceRegistrationEntity r where r.resourceName=:rn");
+ rquery.setParameter("rn", dependent);
+
+ @SuppressWarnings("rawtypes")
+ List rrList = rquery.getResultList();
+ ResourceRegistrationEntity rrx = null;
+ if (rrList.isEmpty()) {
+ // register resource by adding entry to table in DB
+ logger.debug("Adding resource {} to ResourceRegistration table", dependent);
+ rrx = new ResourceRegistrationEntity();
+ // set columns in entry
+ rrx.setResourceName(dependent);
+ rrx.setResourceUrl("service:jmx:somewhere:9999");
+ rrx.setNodeType("logparser");
+ rrx.setSite("siteA");
+ }
+ em.persist(rrx);
+ // flush to the DB
+ em.flush();
+
+ // commit transaction
+ et.commit();
+
+ // wait for the FPManager to check dependency health
+ waitStep();
+
+ assertException(im, imx -> {
+ imx.evaluateSanity();
+ });
+
+ // undo dependency groups and jmx test properties settings
+ myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
+ myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
+ IntegrityMonitor.updateProperties(myProp);
+
+ logger.debug("\ntestSantityJmx ending properties: {}", myProp);
+
+ // We know at this point that the IM is disable-dependency. We want to
+ // be
+ // sure it will recover from this condition since the properties were
+ // updated.
+
+ logger.debug(
+ "\n\ntestSanityJmx ending im state\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\n"
+ + "StandbyStatus = {}\n",
+ im.getStateManager().getAdminState(), im.getStateManager().getOpState(),
+ im.getStateManager().getAvailStatus(), im.getStateManager().getStandbyStatus());
+
+ logger.debug("\ntestSanityJmx restarting the IntegrityMonitor");
+ // Create a new instance. It should recover from the disabled-dependency
+ // condition
+ im = makeMonitor(resourceName, myProp);
+
+ logger.debug(
+ "\n\ntestSanityJmx state after creating new im\n"
+ + "AdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ im.getStateManager().getAdminState(), im.getStateManager().getOpState(),
+ im.getStateManager().getAvailStatus(), im.getStateManager().getStandbyStatus());
+
+ // Verify the state
+ assertEquals(StateManagement.UNLOCKED, im.getStateManager().getAdminState());
+ assertEquals(StateManagement.ENABLED, im.getStateManager().getOpState());
+ assertEquals(StateManagement.NULL_VALUE, im.getStateManager().getAvailStatus());
+ assertEquals(StateManagement.NULL_VALUE, im.getStateManager().getStandbyStatus());
+
+ // Test state manager via the IntegrityMonitor
+ StateManagement sm = im.getStateManager();
+
+ // Verify lock state
+ sm.lock();
+ logger.debug("\n\nsm.lock()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+ assertEquals(StateManagement.LOCKED, sm.getAdminState());
+
+ // Verify lock persists across a restart
+ logger.debug("\ntestSanityJmx restarting the IntegrityMonitor");
+ // Create a new instance. It should come up with the admin state locked
+ im = makeMonitor(resourceName, myProp);
+ sm = im.getStateManager();
+ logger.debug(
+ "\n\ntestSanityJmx restart with AdminState=locked"
+ + "\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+ assertEquals(StateManagement.LOCKED, sm.getAdminState());
+
+ // Verify unlock
+ sm.unlock();
+ logger.debug(
+ "\n\ntestSanityJmx sm.unlock\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+ assertEquals(StateManagement.UNLOCKED, sm.getAdminState());
+
+ // Verify unlock restart
+ logger.debug("\ntestSanityJmx restarting the IntegrityMonitor");
+ // Create a new instance. It should come up with the admin state locked
+ im = makeMonitor(resourceName, myProp);
+ sm = im.getStateManager();
+ logger.debug(
+ "\n\ntestSanityJmx restart with AdminState=unlocked\n"
+ + "AdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ assertEquals(StateManagement.UNLOCKED, sm.getAdminState());
+
+ logger.debug("\n\ntestSanityJmx: Exit\n\n");
+ }
+
+ @Test
+ public void testIm() throws Exception {
+ logger.debug("\nIntegrityMonitorTest: Entering testIM\n\n");
+
+ // Disable the integrity monitor so it will not interfere
+ myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "-1");
+ // Disable dependency checking
+ myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "-1");
+ // Disable the refresh state audit
+ myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable the state audit
+ myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable the test transaction
+ myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "-1");
+ // Disable writing the FPC
+ myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "-1");
+
+ IntegrityMonitor im = makeMonitor(resourceName, myProp);
+
+ logger.debug("\n\nim initial state: \nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ im.getStateManager().getAdminState(), im.getStateManager().getOpState(),
+ im.getStateManager().getAvailStatus(), im.getStateManager().getStandbyStatus());
+
+ waitStep();
+
+ // test evaluate sanity
+ assertNoException(im, imx -> {
+ imx.evaluateSanity();
+ });
+
+ // Test startTransaction - should work since it is unlocked
+ assertNoException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ // Test state manager via the IntegrityMonitor
+ StateManagement sm = im.getStateManager();
+
+ sm.lock();
+
+ logger.debug("\n\nsm.lock()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ assertEquals(StateManagement.LOCKED, sm.getAdminState());
+
+ // test startTransaction. It should fail since it is locked
+ assertException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ sm.unlock();
+ logger.debug("\n\nsm.unlock()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+ assertEquals(StateManagement.UNLOCKED, sm.getAdminState());
+
+ // test startTransaction. It should succeed
+ assertNoException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ sm.disableDependency();
+ logger.debug(
+ "\n\nsm.disableDependency()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ assertEquals(StateManagement.DISABLED, sm.getOpState());
+ assertEquals(StateManagement.DEPENDENCY, sm.getAvailStatus());
+
+ // test startTransaction. It should succeed since standby status is null
+ // and unlocked
+ assertNoException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ sm.enableNoDependency();
+
+ logger.debug(
+ "\n\nsm.enableNoDependency()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+ assertEquals(StateManagement.ENABLED, sm.getOpState());
+ // test startTransaction. It should succeed since standby status is null
+ // and unlocked
+ assertNoException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ sm.disableFailed();
+ logger.debug("\n\nsm.disableFailed()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ assertEquals(StateManagement.DISABLED, sm.getOpState());
+ assertEquals(StateManagement.FAILED, sm.getAvailStatus());
+ // test startTransaction. It should succeed since standby status is null
+ // and unlocked
+ assertNoException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ sm.enableNotFailed();
+
+ logger.debug(
+ "\n\nsm.enabledNotFailed()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ assertEquals(StateManagement.ENABLED, sm.getOpState());
+ // test startTransaction. It should succeed since standby status is null
+ // and unlocked
+ assertNoException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ sm.demote();
+
+ logger.debug("\n\nsm.demote()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ assertEquals(StateManagement.HOT_STANDBY, sm.getStandbyStatus());
+
+ // test startTransaction. It should fail since it is standby
+ assertException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ sm.promote();
+
+ logger.debug("\n\nsm.promote()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ assertEquals(StateManagement.PROVIDING_SERVICE, sm.getStandbyStatus());
+
+ // test startTransaction. It should succeed since it is providing
+ // service
+ assertNoException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ // Test the multi-valued availability status
+ sm.disableDependency();
+ sm.disableFailed();
+
+ logger.debug(
+ "\n\nsm.disableDependency(), sm.disableFailed\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\n"
+ + "StandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ assertEquals(StateManagement.DEPENDENCY_FAILED, sm.getAvailStatus());
+
+ // Test startTransaction. Should fail since standby status is cold
+ // standby
+ assertException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ sm.enableNoDependency();
+
+ logger.debug(
+ "\n\nsm.enableNoDependency()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+ assertEquals(StateManagement.FAILED, sm.getAvailStatus());
+ // Test startTransaction. Should fail since standby status is cold
+ // standby
+ assertException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ sm.disableDependency();
+ sm.enableNotFailed();
+
+ logger.debug(
+ "\n\nsm.disableDependency(),sm.enableNotFailed()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\n"
+ + "StandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ assertEquals(StateManagement.DEPENDENCY, sm.getAvailStatus());
+ // Test startTransaction. Should fail since standby status is cold
+ // standby
+ assertException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ sm.enableNoDependency();
+ logger.debug(
+ "\n\nsm.enableNoDependency()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+ assertEquals(StateManagement.ENABLED, sm.getOpState());
+ // test startTransaction. It should fail since standby status is hot
+ // standby
+ assertException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ logger.debug("\n\ntestIM: Exit\n\n");
+ }
+
+ @Test
+ public void testSanityState() throws Exception {
+ logger.debug("\nIntegrityMonitorTest: Entering testSanityState\n\n");
+
+ // parameters are passed via a properties file
+ myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "group1_dep1,group1_dep2; group2_dep1");
+ // Disable the integrity monitor so it will not interfere
+ myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "-1");
+ // Disable the refresh state audit
+ myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable dependency checking so it does not interfere
+ myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "-1");
+ // Disable the state audit
+ myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable the test transaction
+ myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "-1");
+ // Disable writing the FPC
+ myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "-1");
+ // Max interval for use in deciding if a FPC entry is stale in seconds
+ myProp.put(IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL, "120");
+
+ final IntegrityMonitor im = makeMonitor(resourceName, myProp);
+
+ waitStep();
+
+ // Add a group1 dependent resources to put an entry in the forward
+ // progress table
+ ForwardProgressEntity fpe = new ForwardProgressEntity();
+ ForwardProgressEntity fpe2 = new ForwardProgressEntity();
+ fpe.setFpcCount(0);
+ fpe.setResourceName("group1_dep1");
+ fpe2.setFpcCount(0);
+ fpe2.setResourceName("group1_dep2");
+ et = em.getTransaction();
+ et.begin();
+ em.persist(fpe);
+ em.persist(fpe2);
+ em.flush();
+ et.commit();
+
+ // Add a group2 dependent resource to the StateManagementEntity DB table
+ // and set its admin state to locked
+ // Expect sanity test to fail.
+ StateManagement stateManager = new StateManagement(emf, "group2_dep1");
+ stateManager.lock();
+
+ new StateManagement(emf, "group1_dep1");
+ new StateManagement(emf, "group1_dep2");
+
+ // Call the dependency check directly instead of waiting for FPManager
+ // to do it.
+ logger.debug("\n\nIntegrityMonitor.testSanityState: calling im.dependencyCheck()\n\n");
+ im.dependencyCheck();
+ assertException(im, imx -> {
+ imx.evaluateSanity();
+ });
+
+ logger.debug("\n\ntestSanityState: Exit\n\n");
+ }
+
+ @Test
+ public void testRefreshStateAudit() throws Exception {
+ logger.debug("\nIntegrityMonitorTest: testRefreshStateAudit Enter\n\n");
+
+ // parameters are passed via a properties file
+ myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
+ myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
+ // Disable the integrity monitor so it will not interfere
+ myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "-1");
+ // Disable the refresh state audit
+ myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable dependency checking so it does not interfere
+ myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "-1");
+ // Disable the state audit
+ myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable the test transaction
+ myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "-1");
+ // Disable writing the FPC
+ myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "-1");
+
+ final IntegrityMonitor im = makeMonitor(resourceName, myProp);
+
+ waitStep();
+
+ // the state here is unlocked, enabled, null, null
+ StateManagementEntity sme = null;
+
+ Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
+
+ query.setParameter("resource", resourceName);
+
+ // Just test that we are retrieving the right object
+ @SuppressWarnings("rawtypes")
+ List resourceList = query.getResultList();
+ if (!resourceList.isEmpty()) {
+ // exist
+ sme = (StateManagementEntity) resourceList.get(0);
+ em.refresh(sme);
+
+ logger.debug(
+ "??? -- Retrieve StateManagementEntity from database --\nsme.getResourceName() = {}\n"
+ + "sme.getAdminState() = {}\nsme.getOpState() = {}\nsme.getAvailStatus() = {}\n"
+ + "sme.getStandbyStatus() = {}",
+ sme.getResourceName(), sme.getAdminState(), sme.getOpState(), sme.getAvailStatus(),
+ sme.getStandbyStatus());
+
+ assertEquals(StateManagement.UNLOCKED, sme.getAdminState());
+ assertEquals(StateManagement.ENABLED, sme.getOpState());
+ assertEquals(StateManagement.NULL_VALUE, sme.getAvailStatus());
+ assertEquals(StateManagement.NULL_VALUE, sme.getStandbyStatus());
+ logger.debug("--");
+ } else {
+ logger.debug("Record not found, resourceName: " + resourceName);
+ fail("missing record");
+ }
+
+ et = em.getTransaction();
+ et.begin();
+
+ sme.setStandbyStatus(StateManagement.COLD_STANDBY);
+ em.persist(sme);
+ em.flush();
+ et.commit();
+
+ // Run the refreshStateAudit
+ im.executeRefreshStateAudit();
+
+ // The refreshStateAudit should run and change the state to
+ // unlocked,enabled,null,hotstandby
+ StateManagementEntity sme1 = null;
+
+ Query query1 = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
+
+ query1.setParameter("resource", resourceName);
+
+ @SuppressWarnings("rawtypes")
+ List resourceList1 = query1.getResultList();
+ if (!resourceList1.isEmpty()) {
+ // exist
+ sme1 = (StateManagementEntity) resourceList1.get(0);
+ em.refresh(sme1);
+ logger.debug(
+ "??? -- Retrieve StateManagementEntity from database --\nsme1.getResourceName() = {}\n"
+ + "sme1.getAdminState() = {}\nsme1.getOpState() = {}\nsme1.getAvailStatus() = {}\n"
+ + "sme1.getStandbyStatus() = {}",
+ sme1.getResourceName(), sme1.getAdminState(), sme1.getOpState(), sme1.getAvailStatus(),
+ sme1.getStandbyStatus());
+
+ assertEquals(StateManagement.UNLOCKED, sme1.getAdminState());
+ assertEquals(StateManagement.ENABLED, sme1.getOpState());
+ assertEquals(StateManagement.NULL_VALUE, sme1.getAvailStatus());
+ assertEquals(StateManagement.HOT_STANDBY, sme1.getStandbyStatus());
+ logger.debug("--");
+ } else {
+ logger.debug("Record not found, resourceName: " + resourceName);
+ fail("record not found");
+ }
+
+ logger.debug("\nIntegrityMonitorTest: testRefreshStateAudit Exit\n\n");
+ }
+
+ @Test
+ public void testStateCheck() throws Exception {
+ logger.debug("\nIntegrityMonitorTest: Entering testStateCheck\n\n");
+
+ // parameters are passed via a properties file
+ myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "group1_dep1");
+ myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
+ myProp.put(IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD, "1");
+ /*
+ * The monitorInterval is set to 10 and the failedCounterThreshold is 1 because stateCheck()
+ * uses the faileCounterThreshold * monitorInterval to determine if an entry is stale, it
+ * will be stale after 10 seconds.
+ */
+ myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "5");
+ /*
+ * We accelerate the test transaction and write FPC intervals because we don't want there to
+ * be any chance of a FPC failure because of the short monitor interval
+ */
+ myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "1");
+ myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "2");
+ // Disable the refresh state audit
+ myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
+ // The maximum time in seconds to determine that a FPC entry is stale
+ myProp.put(IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL, "5");
+ myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "5");
+
+ IntegrityMonitor im = makeMonitor(resourceName, myProp);
+
+ // Note: do ***NOT*** do waitStep() here
+
+ // Add a group1 dependent resources to put an entry in the forward
+ // progress table
+ // This sets lastUpdated to the current time
+ ForwardProgressEntity fpe = new ForwardProgressEntity();
+ fpe.setFpcCount(0);
+ fpe.setResourceName("group1_dep1");
+ et = em.getTransaction();
+ et.begin();
+ em.persist(fpe);
+ em.flush();
+ et.commit();
+
+ new StateManagement(emf, "group1_dep1");
+
+ assertNoException(im, imx -> {
+ imx.evaluateSanity();
+ });
+
+ // wait for FPManager to perform dependency health check. Once that's
+ // done,
+ // it should now be stale and the sanity check should fail
+ waitStep();
+
+ assertException(im, imx -> {
+ imx.evaluateSanity();
+ });
+
+ logger.debug("\n\ntestStateCheck: Exit\n\n");
+ }
+
+ @Test
+ public void testGetAllForwardProgressEntity() throws Exception {
+ logger.debug("\nIntegrityMonitorTest: Entering testGetAllForwardProgressEntity\n\n");
+ // parameters are passed via a properties file
+ myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
+ myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
+ // Disable the integrity monitor so it will not interfere
+ myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "-1");
+ // Disable the refresh state audit
+ myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable dependency checking so it does not interfere
+ myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "-1");
+ // Disable the state audit
+ myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable the test transaction
+ myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "-1");
+ // Disable writing the FPC
+ myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "-1");
+
+ final IntegrityMonitor im = makeMonitor(resourceName, myProp);
+ waitStep();
+
+ logger.debug("\nIntegrityMonitorTest: Creating ForwardProgressEntity entries\n\n");
+ // Add resource entries in the forward progress table
+ final ForwardProgressEntity fpe = new ForwardProgressEntity();
+ final ForwardProgressEntity fpe2 = new ForwardProgressEntity();
+ final ForwardProgressEntity fpe3 = new ForwardProgressEntity();
+ fpe.setFpcCount(0);
+ fpe.setResourceName("siteA_pap2");
+ fpe2.setFpcCount(0);
+ fpe2.setResourceName("siteB_pap1");
+ fpe3.setFpcCount(0);
+ fpe3.setResourceName("siteB_pap2");
+ et = em.getTransaction();
+ et.begin();
+ em.persist(fpe);
+ em.persist(fpe2);
+ em.persist(fpe3);
+ em.flush();
+ et.commit();
+
+ logger.debug(
+ "\nIntegrityMonitorTest:testGetAllForwardProgressEntity Calling im.getAllForwardProgressEntity()\n\n");
+ List<ForwardProgressEntity> fpeList = im.getAllForwardProgressEntity();
+
+ assertEquals(4, fpeList.size());
+
+ logger.debug("\nIntegrityMonitorTest: Exit testGetAllForwardProgressEntity\n\n");
+ }
+
+ @Test
+ public void testStateAudit() throws Exception {
+ logger.debug("\nIntegrityMonitorTest: Entering testStateAudit\n\n");
+
+ // parameters are passed via a properties file
+
+ // No Dependency Groups
+ myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
+ // Don't use JMX
+ myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
+ // Disable the internal sanity monitoring.
+ myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "-1");
+ // Disable the dependency monitoring.
+ myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "-1");
+ // Disable the refresh state audit
+ myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable the test transaction
+ myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "-1");
+ // Disable the write FPC
+ myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "-1");
+ // Disable the State Audit we will call it directly
+ myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
+ // Max interval for use in deciding if a FPC entry is stale in seconds
+ myProp.put(IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL, "120");
+
+ final IntegrityMonitor im = makeMonitor(resourceName, myProp);
+ waitStep();
+
+ logger.debug("\nIntegrityMonitorTest: Creating ForwardProgressEntity entries\n\n");
+ // Add resources to put an entry in the forward progress table
+ final Date staleDate = new Date(0);
+ final ForwardProgressEntity fpe1 = new ForwardProgressEntity();
+ final ForwardProgressEntity fpe2 = new ForwardProgressEntity();
+ final ForwardProgressEntity fpe3 = new ForwardProgressEntity();
+ fpe1.setFpcCount(0);
+ fpe1.setResourceName("siteA_pap2");
+ fpe2.setFpcCount(0);
+ fpe2.setResourceName("siteB_pap1");
+ fpe3.setFpcCount(0);
+ fpe3.setResourceName("siteB_pap2");
+ logger.debug("\nIntegrityMonitorTest: Creating StateManagementEntity entries\n\n");
+ final StateManagementEntity sme1 = new StateManagementEntity();
+ final StateManagementEntity sme2 = new StateManagementEntity();
+ final StateManagementEntity sme3 = new StateManagementEntity();
+ sme1.setResourceName("siteA_pap2");
+ sme1.setAdminState(StateManagement.UNLOCKED);
+ sme1.setOpState(StateManagement.ENABLED);
+ sme1.setAvailStatus(StateManagement.NULL_VALUE);
+ sme1.setStandbyStatus(StateManagement.NULL_VALUE);
+ sme2.setResourceName("siteB_pap1");
+ sme2.setAdminState(StateManagement.UNLOCKED);
+ sme2.setOpState(StateManagement.ENABLED);
+ sme2.setAvailStatus(StateManagement.NULL_VALUE);
+ sme2.setStandbyStatus(StateManagement.NULL_VALUE);
+ sme3.setResourceName("siteB_pap2");
+ sme3.setAdminState(StateManagement.UNLOCKED);
+ sme3.setOpState(StateManagement.ENABLED);
+ sme3.setAvailStatus(StateManagement.NULL_VALUE);
+ sme3.setStandbyStatus(StateManagement.NULL_VALUE);
+ et = em.getTransaction();
+ et.begin();
+ em.persist(fpe1);
+ em.persist(fpe2);
+ em.persist(fpe3);
+ em.persist(sme1);
+ em.persist(sme2);
+ em.persist(sme3);
+ em.flush();
+ et.commit();
+
+ Query updateQuery = em.createQuery(
+ "UPDATE ForwardProgressEntity f " + "SET f.lastUpdated = :newDate " + "WHERE f.resourceName=:resource");
+ updateQuery.setParameter("newDate", staleDate, TemporalType.TIMESTAMP);
+ updateQuery.setParameter("resource", fpe1.getResourceName());
+
+ et = em.getTransaction();
+ et.begin();
+ updateQuery.executeUpdate();
+ et.commit();
+
+ logger.debug("\nIntegrityMonitorTest:testStateAudit Calling im.getAllForwardProgressEntity()\n\n");
+ List<ForwardProgressEntity> fpeList = im.getAllForwardProgressEntity();
+
+ logger.debug("\n\n");
+ logger.debug("IntegrityMonitorTest:testStateAudit:ForwardProgressEntity entries");
+ for (ForwardProgressEntity myFpe : fpeList) {
+ logger.debug("\n ResourceName: {}" + "\n LastUpdated: {}", myFpe.getResourceName(),
+ myFpe.getLastUpdated());
+ }
+ logger.debug("\n\n");
+
+ logger.debug("\nIntegrityMonitorTest:testStateAudit getting list of StateManagementEntity entries\n\n");
+ Query query = em.createQuery("SELECT s FROM StateManagementEntity s");
+ List<?> smeList = query.getResultList();
+
+ logger.debug("\n\n");
+ logger.debug("IntegrityMonitorTest:testStateAudit:StateManagementEntity entries");
+ for (Object mySme : smeList) {
+ StateManagementEntity tmpSme = (StateManagementEntity) mySme;
+ em.refresh(tmpSme);
+ logger.debug(
+ "\n ResourceName: {}" + "\n AdminState: {}" + "\n OpState: {}"
+ + "\n AvailStatus: {}" + "\n StandbyStatus: {}",
+ tmpSme.getResourceName(), tmpSme.getAdminState(), tmpSme.getOpState(), tmpSme.getAvailStatus(),
+ tmpSme.getStandbyStatus());
+ }
+ logger.debug("\n\n");
+
+ em.refresh(sme1);
+ assertEquals(StateManagement.ENABLED, sme1.getOpState());
+
+ logger.debug("IntegrityMonitorTest:testStateAudit: calling stateAudit()");
+ im.executeStateAudit();
+ logger.debug("IntegrityMonitorTest:testStateAudit: call to stateAudit() complete");
+
+ logger.debug("\nIntegrityMonitorTest:testStateAudit getting list of StateManagementEntity entries\n\n");
+ smeList = query.getResultList();
+
+ logger.debug("\n\n");
+ logger.debug("IntegrityMonitorTest:testStateAudit:StateManagementEntity entries");
+ for (Object mySme : smeList) {
+ StateManagementEntity tmpSme = (StateManagementEntity) mySme;
+ em.refresh(tmpSme);
+ logger.debug(
+ "\n ResourceName: {}" + "\n AdminState: {}" + "\n OpState: {}"
+ + "\n AvailStatus: {}" + "\n StandbyStatus: {}",
+ tmpSme.getResourceName(), tmpSme.getAdminState(), tmpSme.getOpState(), tmpSme.getAvailStatus(),
+ tmpSme.getStandbyStatus());
+ }
+ logger.debug("\n\n");
+
+ em.refresh(sme1);
+ assertEquals(StateManagement.DISABLED, sme1.getOpState());
+
+ // Now let's add sme2 to the mix
+ updateQuery = em.createQuery(
+ "UPDATE ForwardProgressEntity f " + "SET f.lastUpdated = :newDate " + "WHERE f.resourceName=:resource");
+ updateQuery.setParameter("newDate", staleDate, TemporalType.TIMESTAMP);
+ updateQuery.setParameter("resource", fpe2.getResourceName());
+
+ et = em.getTransaction();
+ et.begin();
+ updateQuery.executeUpdate();
+ et.commit();
+
+ // Give it a chance to write the DB and run the audit
+ logger.debug("IntegrityMonitorTest:testStateAudit: (restart4) Running State Audit");
+ waitStep();
+ im.executeStateAudit();
+ waitStep();
+ logger.debug("IntegrityMonitorTest:testStateAudit: (restart4) State Audit complete");
+
+ // Now check its state
+ logger.debug(
+ "\nIntegrityMonitorTest:testStateAudit (restart4) getting list of StateManagementEntity entries\n\n");
+ smeList = query.getResultList();
+
+ logger.debug("\n\n");
+ logger.debug("IntegrityMonitorTest:testStateAudit:StateManagementEntity (restart4) entries");
+ for (Object mySme : smeList) {
+ StateManagementEntity tmpSme = (StateManagementEntity) mySme;
+ em.refresh(tmpSme);
+
+ logger.debug(
+ "\n (restart4) ResourceName: {}" + "\n AdminState: {}" + "\n OpState: {}"
+ + "\n AvailStatus: {}" + "\n StandbyStatus: {}",
+ tmpSme.getResourceName(), tmpSme.getAdminState(), tmpSme.getOpState(), tmpSme.getAvailStatus(),
+ tmpSme.getStandbyStatus());
+ }
+ logger.debug("\n\n");
+
+ em.refresh(sme1);
+ assertEquals(StateManagement.DISABLED, sme1.getOpState());
+
+ em.refresh(sme2);
+ assertEquals(StateManagement.DISABLED, sme2.getOpState());
+
+ logger.debug("\nIntegrityMonitorTest: Exit testStateAudit\n\n");
+ System.out.println("\n\ntestStateAudit: Exit\n\n");
+ }
+
+ private IntegrityMonitor makeMonitor(String resourceName, Properties myProp) throws Exception {
+ IntegrityMonitor.deleteInstance();
+
+ queue = new LinkedBlockingQueue<>();
+
+ IntegrityMonitor im = IntegrityMonitor.getInstance(resourceName, myProp, queue);
+
+ // wait for the monitor thread to start
+ waitStep();
+
+ return im;
+ }
+
+ /**
+ * Waits for the FPManager to complete another cycle.
+ *
+ * @throws InterruptedException if the thread is interrupted
+ */
+ private void waitStep() throws InterruptedException {
+ CountDownLatch latch = new CountDownLatch(1);
+ queue.offer(latch);
+ waitLatch(latch);
+ }
}
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java
index 84d0b51a..0c8259b7 100644
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java
@@ -39,268 +39,257 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * All JUnits are designed to run in the local development environment where
- * they have write privileges and can execute time-sensitive tasks.
- * <p/>
- * Many of the test verification steps are performed by scanning for items
- * written to the log file. Rather than actually scan the log file, an
- * {@link ExtractAppender} is used to monitor events that are logged and extract
- * relevant items. In order to attach the appender to the debug log, it assumes
- * that the debug log is a <i>logback</i> Logger configured per EELF.
- * <p/>
- * These tests use a temporary, in-memory DB, which is dropped once the tests
- * complete.
+ * All JUnits are designed to run in the local development environment where they have write
+ * privileges and can execute time-sensitive tasks. <p/> Many of the test verification steps are
+ * performed by scanning for items written to the log file. Rather than actually scan the log file,
+ * an {@link ExtractAppender} is used to monitor events that are logged and extract relevant items.
+ * In order to attach the appender to the debug log, it assumes that the debug log is a
+ * <i>logback</i> Logger configured per EELF. <p/> These tests use a temporary, in-memory DB, which
+ * is dropped once the tests complete.
*/
public class IntegrityMonitorTestBase {
- private static Logger logger = LoggerFactory.getLogger(IntegrityMonitorTestBase.class);
-
- /**
- * Directory containing the slf4j log files.
- */
- private static final String SLF4J_LOG_DIR = "logs";
-
- private static final String JMX_PORT_PROP = "com.sun.management.jmxremote.port";
-
- /**
- * Max time, in milliseconds, to wait for a latch to be triggered.
- */
- protected static final long WAIT_MS = 5000l;
-
- /**
- * Milliseconds that monitor should sleep between cycles.
- */
- protected static final long CYCLE_INTERVAL_MS = 2l;
-
- public static final String DEFAULT_DB_URL_PREFIX = "jdbc:h2:mem:";
-
- protected static final String dbDriver = "org.h2.Driver";
- protected static final String dbUser = "testu";
- protected static final String dbPwd = "testp";
- protected static final String siteName = "SiteA";
- protected static final String nodeType = "pap";
-
- // will be defined by the test *Classes*
- protected static String dbUrl;
-
- /**
- * Persistence unit.
- */
- protected static final String PERSISTENCE_UNIT = "schemaPU";
-
- /**
- * Properties to be used in all tests.
- */
- protected static Properties properties;
-
- /**
- * Entity manager factory pointing to the in-memory DB for A_SEQ_PU.
- */
- protected static EntityManagerFactory emf;
-
- /**
- * Entity manager factory pointing to the in-memory DB associated with emf.
- */
- protected static EntityManager em;
-
- /**
- * Saved JMX port from system properties, to be restored once all tests
- * complete.
- */
- private static Object savedJmxPort;
-
- /**
- * Saved IM persistence unit, to be restored once all tests complete.
- */
- private static String savedPU;
-
- /**
- * Saved monitor cycle interval, to be restored once all tests complete.
- */
- private static long savedCycleIntervalMillis;
-
- /**
- * Saved property time units, to be restored once all tests complete.
- */
- private static TimeUnit savedPropertyUnits;
-
- /**
- * Saves current configuration information and then sets new values.
- *
- * @param dbDriver
- * the name of the DB Driver class
- * @param dbUrl
- * the URL to the DB
- * @throws IOException
- * @throws Exception
- */
- protected static void setUpBeforeClass(String dbUrl) throws IOException {
- logger.info("setup");
-
- Properties systemProps = System.getProperties();
-
- // truncate the logs
- new FileOutputStream(SLF4J_LOG_DIR + "/audit.log").close();
- new FileOutputStream(SLF4J_LOG_DIR + "/debug.log").close();
- new FileOutputStream(SLF4J_LOG_DIR + "/error.log").close();
- new FileOutputStream(SLF4J_LOG_DIR + "/metrics.log").close();
-
- IntegrityMonitorTestBase.dbUrl = dbUrl;
-
- // save data that we have to restore at the end of the test
- savedJmxPort = systemProps.get(JMX_PORT_PROP);
- savedPU = IntegrityMonitor.getPersistenceUnit();
- savedCycleIntervalMillis = IntegrityMonitor.getCycleIntervalMillis();
- savedPropertyUnits = IntegrityMonitor.getPropertyUnits();
-
- systemProps.put(JMX_PORT_PROP, "9797");
-
- IntegrityMonitor.setPersistenceUnit(PERSISTENCE_UNIT);
- IntegrityMonitor.setCycleIntervalMillis(CYCLE_INTERVAL_MS);
- IntegrityMonitor.setPropertyUnits(TimeUnit.MILLISECONDS);
-
- IntegrityMonitor.setUnitTesting(true);
-
- properties = new Properties();
- properties.put(IntegrityMonitorProperties.DB_DRIVER, dbDriver);
- properties.put(IntegrityMonitorProperties.DB_URL, dbUrl);
- properties.put(IntegrityMonitorProperties.DB_USER, dbUser);
- properties.put(IntegrityMonitorProperties.DB_PWD, dbPwd);
- properties.put(IntegrityMonitorProperties.SITE_NAME, siteName);
- properties.put(IntegrityMonitorProperties.NODE_TYPE, nodeType);
- properties.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS,
- String.valueOf(100L * CYCLE_INTERVAL_MS));
-
- emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT, makeProperties());
-
- // keep this open so the in-memory DB stays around until all tests are
- // done
- em = emf.createEntityManager();
-
- stopMonitor();
- }
-
- /**
- * Restores the configuration to what it was before the test.
- */
- protected static void tearDownAfterClass() {
- Properties systemProps = System.getProperties();
- if (savedJmxPort == null) {
- systemProps.remove(JMX_PORT_PROP);
-
- } else {
- systemProps.put(JMX_PORT_PROP, savedJmxPort);
- }
-
- IntegrityMonitor.setPersistenceUnit(savedPU);
- IntegrityMonitor.setCycleIntervalMillis(savedCycleIntervalMillis);
- IntegrityMonitor.setPropertyUnits(savedPropertyUnits);
-
- IntegrityMonitor.setUnitTesting(false);
-
- // this should result in the in-memory DB being deleted
- em.close();
- emf.close();
- }
-
- /**
- * Sets up for a test, which includes deleting all records from the
- * IntegrityAuditEntity table.
- */
- protected void setUpTest() {
-
- // Clean up the DB
- try (EntityTransCloser et = new EntityTransCloser(em.getTransaction())) {
-
- em.createQuery("Delete from StateManagementEntity").executeUpdate();
- em.createQuery("Delete from ForwardProgressEntity").executeUpdate();
- em.createQuery("Delete from ResourceRegistrationEntity").executeUpdate();
-
- // commit transaction
- et.commit();
- }
- }
-
- /**
- * Cleans up after a test, removing any ExtractAppenders from the logger and
- * stopping any AuditThreads.
- */
- protected void tearDownTest() {
- stopMonitor();
- }
-
- /**
- * Stops the IntegrityMonitor instance.
- */
- private static void stopMonitor() {
- try {
- IntegrityMonitor.deleteInstance();
-
- } catch (IntegrityMonitorException e) {
- // no need to log, as exception was already logged
- }
- }
-
- /**
- * Makes a new Property set that's a clone of {@link #properties}.
- *
- * @return a new Property set containing all of a copy of all of the
- * {@link #properties}
- */
- protected static Properties makeProperties() {
- Properties props = new Properties();
- props.putAll(properties);
- return props;
- }
-
- /**
- * Waits for a latch to reach zero.
- *
- * @param latch
- * @throws InterruptedException
- * @throws AssertionError
- * if the latch did not reach zero in the allotted time
- */
- protected void waitLatch(CountDownLatch latch) throws InterruptedException {
- assertTrue(latch.await(WAIT_MS, TimeUnit.SECONDS));
- }
-
- /**
- * Applies a function on an object, expecting it to succeed. Catches any
- * exceptions thrown by the function.
- *
- * @param arg
- * @param func
- * @throws AssertionError
- */
- protected <T> void assertNoException(T arg, VoidFunction<T> func) {
- try {
- func.apply(arg);
-
- } catch (Exception e) {
- System.out.println("startTransaction exception: " + e);
- fail("action failed");
- }
- }
-
- /**
- * Applies a function on an object, expecting it to fail. Catches any
- * exceptions thrown by the function.
- *
- * @param arg
- * @param func
- * @throws AssertionError
- */
- protected <T> void assertException(T arg, VoidFunction<T> func) {
- try {
- func.apply(arg);
- fail("missing exception");
- } catch (Exception e) {
- System.out.println("action found expected exception: " + e);
- }
- }
-
- @FunctionalInterface
- protected static interface VoidFunction<T> {
- public void apply(T arg) throws Exception;
- }
+ private static Logger logger = LoggerFactory.getLogger(IntegrityMonitorTestBase.class);
+
+ /**
+ * Directory containing the slf4j log files.
+ */
+ private static final String SLF4J_LOG_DIR = "logs";
+
+ private static final String JMX_PORT_PROP = "com.sun.management.jmxremote.port";
+
+ /**
+ * Max time, in milliseconds, to wait for a latch to be triggered.
+ */
+ protected static final long WAIT_MS = 5000L;
+
+ /**
+ * Milliseconds that monitor should sleep between cycles.
+ */
+ protected static final long CYCLE_INTERVAL_MS = 2L;
+
+ public static final String DEFAULT_DB_URL_PREFIX = "jdbc:h2:mem:";
+
+ protected static final String dbDriver = "org.h2.Driver";
+ protected static final String dbUser = "testu";
+ protected static final String dbPwd = "testp";
+ protected static final String siteName = "SiteA";
+ protected static final String nodeType = "pap";
+
+ // will be defined by the test *Classes*
+ protected static String dbUrl;
+
+ /**
+ * Persistence unit.
+ */
+ protected static final String PERSISTENCE_UNIT = "schemaPU";
+
+ /**
+ * Properties to be used in all tests.
+ */
+ protected static Properties properties;
+
+ /**
+ * Entity manager factory pointing to the in-memory DB for A_SEQ_PU.
+ */
+ protected static EntityManagerFactory emf;
+
+ /**
+ * Entity manager factory pointing to the in-memory DB associated with emf.
+ */
+ protected static EntityManager em;
+
+ /**
+ * Saved JMX port from system properties, to be restored once all tests complete.
+ */
+ private static Object savedJmxPort;
+
+ /**
+ * Saved IM persistence unit, to be restored once all tests complete.
+ */
+ private static String savedPU;
+
+ /**
+ * Saved monitor cycle interval, to be restored once all tests complete.
+ */
+ private static long savedCycleIntervalMillis;
+
+ /**
+ * Saved property time units, to be restored once all tests complete.
+ */
+ private static TimeUnit savedPropertyUnits;
+
+ /**
+ * Saves current configuration information and then sets new values.
+ *
+ * @param dbDriver the name of the DB Driver class
+ * @param dbUrl the URL to the DB
+ * @throws IOException if an IO error occurs
+ */
+ protected static void setUpBeforeClass(String dbUrl) throws IOException {
+ logger.info("setup");
+
+ final Properties systemProps = System.getProperties();
+
+ // truncate the logs
+ new FileOutputStream(SLF4J_LOG_DIR + "/audit.log").close();
+ new FileOutputStream(SLF4J_LOG_DIR + "/debug.log").close();
+ new FileOutputStream(SLF4J_LOG_DIR + "/error.log").close();
+ new FileOutputStream(SLF4J_LOG_DIR + "/metrics.log").close();
+
+ IntegrityMonitorTestBase.dbUrl = dbUrl;
+
+ // save data that we have to restore at the end of the test
+ savedJmxPort = systemProps.get(JMX_PORT_PROP);
+ savedPU = IntegrityMonitor.getPersistenceUnit();
+ savedCycleIntervalMillis = IntegrityMonitor.getCycleIntervalMillis();
+ savedPropertyUnits = IntegrityMonitor.getPropertyUnits();
+
+ systemProps.put(JMX_PORT_PROP, "9797");
+
+ IntegrityMonitor.setPersistenceUnit(PERSISTENCE_UNIT);
+ IntegrityMonitor.setCycleIntervalMillis(CYCLE_INTERVAL_MS);
+ IntegrityMonitor.setPropertyUnits(TimeUnit.MILLISECONDS);
+
+ IntegrityMonitor.setUnitTesting(true);
+
+ properties = new Properties();
+ properties.put(IntegrityMonitorProperties.DB_DRIVER, dbDriver);
+ properties.put(IntegrityMonitorProperties.DB_URL, dbUrl);
+ properties.put(IntegrityMonitorProperties.DB_USER, dbUser);
+ properties.put(IntegrityMonitorProperties.DB_PWD, dbPwd);
+ properties.put(IntegrityMonitorProperties.SITE_NAME, siteName);
+ properties.put(IntegrityMonitorProperties.NODE_TYPE, nodeType);
+ properties.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS,
+ String.valueOf(100L * CYCLE_INTERVAL_MS));
+
+ emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT, makeProperties());
+
+ // keep this open so the in-memory DB stays around until all tests are
+ // done
+ em = emf.createEntityManager();
+
+ stopMonitor();
+ }
+
+ /**
+ * Restores the configuration to what it was before the test.
+ */
+ protected static void tearDownAfterClass() {
+ Properties systemProps = System.getProperties();
+ if (savedJmxPort == null) {
+ systemProps.remove(JMX_PORT_PROP);
+
+ } else {
+ systemProps.put(JMX_PORT_PROP, savedJmxPort);
+ }
+
+ IntegrityMonitor.setPersistenceUnit(savedPU);
+ IntegrityMonitor.setCycleIntervalMillis(savedCycleIntervalMillis);
+ IntegrityMonitor.setPropertyUnits(savedPropertyUnits);
+
+ IntegrityMonitor.setUnitTesting(false);
+
+ // this should result in the in-memory DB being deleted
+ em.close();
+ emf.close();
+ }
+
+ /**
+ * Sets up for a test, which includes deleting all records from the IntegrityAuditEntity table.
+ */
+ protected void setUpTest() {
+
+ // Clean up the DB
+ try (EntityTransCloser et = new EntityTransCloser(em.getTransaction())) {
+
+ em.createQuery("Delete from StateManagementEntity").executeUpdate();
+ em.createQuery("Delete from ForwardProgressEntity").executeUpdate();
+ em.createQuery("Delete from ResourceRegistrationEntity").executeUpdate();
+
+ // commit transaction
+ et.commit();
+ }
+ }
+
+ /**
+ * Cleans up after a test, removing any ExtractAppenders from the logger and stopping any
+ * AuditThreads.
+ */
+ protected void tearDownTest() {
+ stopMonitor();
+ }
+
+ /**
+ * Stops the IntegrityMonitor instance.
+ */
+ private static void stopMonitor() {
+ try {
+ IntegrityMonitor.deleteInstance();
+
+ } catch (IntegrityMonitorException e) {
+ // no need to log, as exception was already logged
+ }
+ }
+
+ /**
+ * Makes a new Property set that's a clone of {@link #properties}.
+ *
+ * @return a new Property set containing all of a copy of all of the {@link #properties}
+ */
+ protected static Properties makeProperties() {
+ Properties props = new Properties();
+ props.putAll(properties);
+ return props;
+ }
+
+ /**
+ * Waits for a latch to reach zero.
+ *
+ * @param latch the latch
+ * @throws InterruptedException if the thread is interrupted
+ * @throws AssertionError if the latch did not reach zero in the allotted time
+ */
+ protected void waitLatch(CountDownLatch latch) throws InterruptedException {
+ assertTrue(latch.await(WAIT_MS, TimeUnit.SECONDS));
+ }
+
+ /**
+ * Applies a function on an object, expecting it to succeed. Catches any exceptions thrown by
+ * the function.
+ *
+ * @param arg the object to apply the function on
+ * @param func the function
+ * @throws AssertionError if an exception is thrown by the function
+ */
+ protected <T> void assertNoException(T arg, VoidFunction<T> func) {
+ try {
+ func.apply(arg);
+
+ } catch (Exception e) {
+ System.out.println("startTransaction exception: " + e);
+ fail("action failed");
+ }
+ }
+
+ /**
+ * Applies a function on an object, expecting it to fail. Catches any exceptions thrown by the
+ * function.
+ *
+ * @param arg the object to apply the function on
+ * @param func the function
+ * @throws AssertionError if no exception is thrown by the function
+ */
+ protected <T> void assertException(T arg, VoidFunction<T> func) {
+ try {
+ func.apply(arg);
+ fail("missing exception");
+ } catch (Exception e) {
+ System.out.println("action found expected exception: " + e);
+ }
+ }
+
+ @FunctionalInterface
+ protected static interface VoidFunction<T> {
+ public void apply(T arg) throws Exception;
+ }
}
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java
index 44faa58f..d098af99 100644
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java
@@ -37,94 +37,107 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class StateManagementEntityTest extends IntegrityMonitorTestBase {
- private static Logger logger = LoggerFactory.getLogger(StateManagementEntityTest.class);
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- IntegrityMonitorTestBase.setUpBeforeClass(DEFAULT_DB_URL_PREFIX + StateManagementEntityTest.class.getSimpleName());
-
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- IntegrityMonitorTestBase.tearDownAfterClass();
- }
-
- @Before
- public void setUp() {
- super.setUpTest();
- }
-
- @After
- public void tearDown() {
- super.tearDownTest();
- }
-
- @Test
- public void testJPA() throws Exception {
- logger.debug("\n??? logger.infor StateManagementEntityTest: Entering\n\n");
-
- //Define the resourceName for the StateManagement constructor
- String resourceName = "test_resource1";
-
- //
- logger.debug("Create StateManagementEntity, resourceName: {}", resourceName);
- logger.debug("??? instantiate StateManagementEntity object");
- StateManagementEntity sme = new StateManagementEntity();
-
- logger.debug("??? setResourceName : {}", resourceName);
- sme.setResourceName(resourceName);
- logger.debug("??? getResourceName : {}", sme.getResourceName());
-
- sme.setAdminState(StateManagement.UNLOCKED);
- assertEquals(StateManagement.UNLOCKED, sme.getAdminState());
-
- sme.setOpState(StateManagement.ENABLED);
- assertEquals(StateManagement.ENABLED, sme.getOpState());
-
- sme.setAvailStatus(StateManagement.NULL_VALUE);
- assertEquals(StateManagement.NULL_VALUE, sme.getAvailStatus());
-
- sme.setStandbyStatus(StateManagement.COLD_STANDBY);
- assertEquals(StateManagement.COLD_STANDBY, sme.getStandbyStatus());
-
- try(EntityTransCloser et = new EntityTransCloser(em.getTransaction())) {
- logger.debug("??? before persist");
- em.persist(sme);
- logger.debug("??? after persist");
-
- em.flush();
- logger.debug("??? after flush");
-
- et.commit();
- logger.debug("??? after commit");
- }
-
- try {
- Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
-
- query.setParameter("resource", resourceName);
-
- //Just test that we are retrieving the right object
- @SuppressWarnings("rawtypes")
- List resourceList = query.getResultList();
- if (!resourceList.isEmpty()) {
- // exist
- StateManagementEntity sme2 = (StateManagementEntity) resourceList.get(0);
-
- assertEquals(sme.getResourceName(), sme2.getResourceName());
- assertEquals(sme.getAdminState(), sme2.getAdminState());
- assertEquals(sme.getOpState(), sme2.getOpState());
- assertEquals(sme.getAvailStatus(), sme2.getAvailStatus());
- assertEquals(sme.getStandbyStatus(), sme2.getStandbyStatus());
- logger.debug("--");
- } else {
- logger.debug("Record not found, resourceName: {}", resourceName);
- }
- } catch(Exception ex) {
- logger.error("Exception on select query: " + ex.toString());
- }
-
- logger.debug("\n\nJpaTest: Exit\n\n");
- }
+ private static Logger logger = LoggerFactory.getLogger(StateManagementEntityTest.class);
+
+ /**
+ * Set up for the test class.
+ */
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ IntegrityMonitorTestBase
+ .setUpBeforeClass(DEFAULT_DB_URL_PREFIX + StateManagementEntityTest.class.getSimpleName());
+
+ }
+
+ /**
+ * Tear down after the test class.
+ */
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ IntegrityMonitorTestBase.tearDownAfterClass();
+ }
+
+ /**
+ * Set up for the test cases.
+ */
+ @Before
+ public void setUp() {
+ super.setUpTest();
+ }
+
+ /**
+ * Tear down after the test cases.
+ */
+ @After
+ public void tearDown() {
+ super.tearDownTest();
+ }
+
+ @Test
+ public void testJpa() throws Exception {
+ logger.debug("\n??? logger.infor StateManagementEntityTest: Entering\n\n");
+
+ // Define the resourceName for the StateManagement constructor
+ String resourceName = "test_resource1";
+
+ //
+ logger.debug("Create StateManagementEntity, resourceName: {}", resourceName);
+ logger.debug("??? instantiate StateManagementEntity object");
+ StateManagementEntity sme = new StateManagementEntity();
+
+ logger.debug("??? setResourceName : {}", resourceName);
+ sme.setResourceName(resourceName);
+ logger.debug("??? getResourceName : {}", sme.getResourceName());
+
+ sme.setAdminState(StateManagement.UNLOCKED);
+ assertEquals(StateManagement.UNLOCKED, sme.getAdminState());
+
+ sme.setOpState(StateManagement.ENABLED);
+ assertEquals(StateManagement.ENABLED, sme.getOpState());
+
+ sme.setAvailStatus(StateManagement.NULL_VALUE);
+ assertEquals(StateManagement.NULL_VALUE, sme.getAvailStatus());
+
+ sme.setStandbyStatus(StateManagement.COLD_STANDBY);
+ assertEquals(StateManagement.COLD_STANDBY, sme.getStandbyStatus());
+
+ try (EntityTransCloser et = new EntityTransCloser(em.getTransaction())) {
+ logger.debug("??? before persist");
+ em.persist(sme);
+ logger.debug("??? after persist");
+
+ em.flush();
+ logger.debug("??? after flush");
+
+ et.commit();
+ logger.debug("??? after commit");
+ }
+
+ try {
+ Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
+
+ query.setParameter("resource", resourceName);
+
+ // Just test that we are retrieving the right object
+ @SuppressWarnings("rawtypes")
+ List resourceList = query.getResultList();
+ if (!resourceList.isEmpty()) {
+ // exist
+ StateManagementEntity sme2 = (StateManagementEntity) resourceList.get(0);
+
+ assertEquals(sme.getResourceName(), sme2.getResourceName());
+ assertEquals(sme.getAdminState(), sme2.getAdminState());
+ assertEquals(sme.getOpState(), sme2.getOpState());
+ assertEquals(sme.getAvailStatus(), sme2.getAvailStatus());
+ assertEquals(sme.getStandbyStatus(), sme2.getStandbyStatus());
+ logger.debug("--");
+ } else {
+ logger.debug("Record not found, resourceName: {}", resourceName);
+ }
+ } catch (Exception ex) {
+ logger.error("Exception on select query: " + ex.toString());
+ }
+
+ logger.debug("\n\nJpaTest: Exit\n\n");
+ }
}
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementTest.java
index 377fed91..1d0d34ea 100644
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementTest.java
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementTest.java
@@ -26,12 +26,14 @@ import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.PersistenceException;
import javax.persistence.QueryTimeoutException;
import javax.persistence.TypedQuery;
+
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -226,7 +228,7 @@ public class StateManagementTest extends IntegrityMonitorTestBase {
@Test(expected = StateManagementException.class)
@SuppressWarnings("unchecked")
- public void test_StateManagementInitialization_ThrowStateManagementException_ifEntityManagerCreateQuerythrowsAnyException()
+ public void test_StateManagementInitialization_ThrowException_ifEntityManagerCreateQuerythrowsAnyException()
throws Exception {
final EntityManager mockedEm = getMockedEntityManager();
final EntityManagerFactory mockedEmf = getMockedEntityManagerFactory(mockedEm);
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/StateTransitionTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/StateTransitionTest.java
index 177a4489..ff7cc3bd 100644
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/StateTransitionTest.java
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/StateTransitionTest.java
@@ -29,2132 +29,2143 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
/*
* All JUnits are designed to run in the local development environment
* where they have write privileges and can execute time-sensitive
* tasks.
*/
public class StateTransitionTest {
- private static Logger logger = LoggerFactory.getLogger(StateTransitionTest.class);
-
- @BeforeClass
- public static void setUpClass() throws Exception {
-
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void test() throws Exception {
- logger.info("\n\nlogger.infor StateTransitionTest: Entering\n\n");
- try {
- logger.info("??? create a new StateTransition");
- StateTransition st = new StateTransition();
-
- StateElement se = null;
- try {
- // bad test case
- se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "lock");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 1");
- se = st.getEndingState("unlocked", "enabled", "null", "null", "lock");
- assertEquals("null,locked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 2");
- se = st.getEndingState("unlocked", "enabled", "null", "null", "unlock");
- assertEquals("null,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 3");
- se = st.getEndingState("unlocked", "enabled", "null", "null", "disableFailed");
- assertEquals("null,unlocked,disabled,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 4");
- se = st.getEndingState("unlocked", "enabled", "null", "null", "enableNotFailed");
- assertEquals("null,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 5");
- se = st.getEndingState("unlocked", "enabled", "null", "null", "disableDependency");
- assertEquals("null,unlocked,disabled,dependency,", makeString(se));
-
- logger.info("??? StateTransition testcase 6");
- se = st.getEndingState("unlocked", "enabled", "null", "null", "enableNoDependency");
- assertEquals("null,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 7");
- se = st.getEndingState("unlocked", "enabled", "null", "null", "promote");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 8");
- se = st.getEndingState("unlocked", "enabled", "null", "null", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 9");
- se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 10");
- se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "unlock");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 11");
- se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 12");
- se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "enableNotFailed");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 13");
- se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
-
- logger.info("??? StateTransition testcase 14");
- se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "enableNoDependency");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 15");
- se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "promote");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 16");
- se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 17");
- se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 18");
- se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "unlock");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 19");
- se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 20");
- se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "enableNotFailed");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 21");
- se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
-
- logger.info("??? StateTransition testcase 22");
- se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "enableNoDependency");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 23");
- se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "promote");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 24");
- se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 25");
- se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 26");
- se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "unlock");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 27");
- se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 28");
- se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "enableNotFailed");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 29");
- se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
-
- logger.info("??? StateTransition testcase 30");
- se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "enableNoDependency");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
-
- logger.info("??? StateTransition testcase 31");
- se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "promote");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ private static Logger logger = LoggerFactory.getLogger(StateTransitionTest.class);
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {}
+
+ @Before
+ public void setUp() throws Exception {}
+
+ @After
+ public void tearDown() throws Exception {}
- logger.info("??? StateTransition testcase 32");
- se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ @Test
+ public void test() throws Exception {
+ logger.info("\n\nlogger.infor StateTransitionTest: Entering\n\n");
+ try {
+ logger.info("??? create a new StateTransition");
+ StateTransition st = new StateTransition();
- logger.info("??? StateTransition testcase 33");
- se = st.getEndingState("unlocked", "enabled", "failed", "null", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ StateElement se = null;
+ try {
+ // bad test case
+ se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "lock");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 34");
- se = st.getEndingState("unlocked", "enabled", "failed", "null", "unlock");
- assertEquals("null,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 1");
+ se = st.getEndingState("unlocked", "enabled", "null", "null", "lock");
+ assertEquals("null,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 35");
- se = st.getEndingState("unlocked", "enabled", "failed", "null", "disableFailed");
- assertEquals("null,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 2");
+ se = st.getEndingState("unlocked", "enabled", "null", "null", "unlock");
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 36");
- se = st.getEndingState("unlocked", "enabled", "failed", "null", "enableNotFailed");
- assertEquals("null,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 3");
+ se = st.getEndingState("unlocked", "enabled", "null", "null", "disableFailed");
+ assertEquals("null,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 37");
- se = st.getEndingState("unlocked", "enabled", "failed", "null", "disableDependency");
- assertEquals("null,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 4");
+ se = st.getEndingState("unlocked", "enabled", "null", "null", "enableNotFailed");
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 38");
- se = st.getEndingState("unlocked", "enabled", "failed", "null", "enableNoDependency");
- assertEquals("null,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 5");
+ se = st.getEndingState("unlocked", "enabled", "null", "null", "disableDependency");
+ assertEquals("null,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 39");
- se = st.getEndingState("unlocked", "enabled", "failed", "null", "promote");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 6");
+ se = st.getEndingState("unlocked", "enabled", "null", "null", "enableNoDependency");
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 40");
- se = st.getEndingState("unlocked", "enabled", "failed", "null", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 7");
+ se = st.getEndingState("unlocked", "enabled", "null", "null", "promote");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 41");
- se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 8");
+ se = st.getEndingState("unlocked", "enabled", "null", "null", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 42");
- se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "unlock");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 9");
+ se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 43");
- se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 10");
+ se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "unlock");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 44");
- se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "enableNotFailed");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 11");
+ se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 45");
- se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 12");
+ se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "enableNotFailed");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 46");
- se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "enableNoDependency");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 13");
+ se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 47");
- se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "promote");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 14");
+ se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "enableNoDependency");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 48");
- se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 15");
+ se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "promote");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 49");
- se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 16");
+ se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 50");
- se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "unlock");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 17");
+ se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 51");
- se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 18");
+ se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "unlock");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 52");
- se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "enableNotFailed");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 19");
+ se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 53");
- se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 20");
+ se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "enableNotFailed");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 54");
- se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "enableNoDependency");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 21");
+ se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 55");
- se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "promote");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 22");
+ se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "enableNoDependency");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+
+ logger.info("??? StateTransition testcase 23");
+ se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "promote");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 56");
- se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 24");
+ se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 57");
- se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 25");
+ se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 58");
- se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "unlock");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 26");
+ se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "unlock");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 59");
- se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 27");
+ se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 60");
- se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "enableNotFailed");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 28");
+ se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "enableNotFailed");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 61");
- se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 29");
+ se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 62");
- se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "enableNoDependency");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 30");
+ se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "enableNoDependency");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 63");
- se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "promote");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 31");
+ se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "promote");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 64");
- se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 32");
+ se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 65");
- se = st.getEndingState("unlocked", "enabled", "dependency", "null", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 33");
+ se = st.getEndingState("unlocked", "enabled", "failed", "null", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 66");
- se = st.getEndingState("unlocked", "enabled", "dependency", "null", "unlock");
- assertEquals("null,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 34");
+ se = st.getEndingState("unlocked", "enabled", "failed", "null", "unlock");
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 67");
- se = st.getEndingState("unlocked", "enabled", "dependency", "null", "disableFailed");
- assertEquals("null,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 35");
+ se = st.getEndingState("unlocked", "enabled", "failed", "null", "disableFailed");
+ assertEquals("null,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 68");
- se = st.getEndingState("unlocked", "enabled", "dependency", "null", "enableNotFailed");
- assertEquals("null,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 36");
+ se = st.getEndingState("unlocked", "enabled", "failed", "null", "enableNotFailed");
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 69");
- se = st.getEndingState("unlocked", "enabled", "dependency", "null", "disableDependency");
- assertEquals("null,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 37");
+ se = st.getEndingState("unlocked", "enabled", "failed", "null", "disableDependency");
+ assertEquals("null,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 70");
- se = st.getEndingState("unlocked", "enabled", "dependency", "null", "enableNoDependency");
- assertEquals("null,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 38");
+ se = st.getEndingState("unlocked", "enabled", "failed", "null", "enableNoDependency");
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 71");
- se = st.getEndingState("unlocked", "enabled", "dependency", "null", "promote");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 39");
+ se = st.getEndingState("unlocked", "enabled", "failed", "null", "promote");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 72");
- se = st.getEndingState("unlocked", "enabled", "dependency", "null", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 40");
+ se = st.getEndingState("unlocked", "enabled", "failed", "null", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 73");
- se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 41");
+ se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 74");
- se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "unlock");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 42");
+ se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "unlock");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 75");
- se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 43");
+ se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 76");
- se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "enableNotFailed");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 44");
+ se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "enableNotFailed");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 77");
- se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 45");
+ se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 78");
- se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "enableNoDependency");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 46");
+ se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "enableNoDependency");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 79");
- se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "promote");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 47");
+ se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "promote");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 80");
- se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 48");
+ se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 81");
- se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 49");
+ se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 82");
- se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "unlock");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 50");
+ se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "unlock");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 83");
- se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 51");
+ se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 84");
- se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "enableNotFailed");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 52");
+ se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "enableNotFailed");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 85");
- se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "disableDependency");
- assertEquals("hotstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 53");
+ se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 86");
- se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "enableNoDependency");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 54");
+ se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "enableNoDependency");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 87");
- se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "promote");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 55");
+ se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "promote");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 88");
- se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 56");
+ se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 89");
- se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 57");
+ se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 90");
- se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "unlock");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 58");
+ se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "unlock");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 91");
- se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 59");
+ se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 92");
- se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "enableNotFailed");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 60");
+ se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "enableNotFailed");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 93");
- se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 61");
+ se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 94");
- se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "enableNoDependency");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 62");
+ se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "enableNoDependency");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 95");
- se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "promote");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 63");
+ se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "promote");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 96");
- se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 64");
+ se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 97");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 65");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "null", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 98");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "unlock");
- assertEquals("null,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 66");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "null", "unlock");
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 99");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "disableFailed");
- assertEquals("null,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 67");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "null", "disableFailed");
+ assertEquals("null,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 100");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "enableNotFailed");
- assertEquals("null,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 68");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "null", "enableNotFailed");
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 101");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "disableDependency");
- assertEquals("null,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 69");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "null", "disableDependency");
+ assertEquals("null,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 102");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "enableNoDependency");
- assertEquals("null,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 70");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "null", "enableNoDependency");
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 103");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "promote");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 71");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "null", "promote");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 104");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 72");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "null", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 105");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 73");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 106");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "unlock");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 74");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "unlock");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 107");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 75");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 108");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "enableNotFailed");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 76");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "enableNotFailed");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 109");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 77");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 110");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "enableNoDependency");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 78");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "enableNoDependency");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 111");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "promote");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 79");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "promote");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 112");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 80");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 113");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 81");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 114");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "unlock");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 82");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "unlock");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 115");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 83");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 116");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "enableNotFailed");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 84");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "enableNotFailed");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 117");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 85");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "disableDependency");
+ assertEquals("hotstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 118");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "enableNoDependency");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 86");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "enableNoDependency");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 119");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "promote");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 87");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "promote");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 120");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 88");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 121");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 89");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 122");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "unlock");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 90");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "unlock");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 123");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 91");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 124");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "enableNotFailed");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 92");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "enableNotFailed");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 125");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 93");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 126");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "enableNoDependency");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 94");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "enableNoDependency");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 127");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "promote");
- assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 95");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "promote");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 128");
- se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "demote");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 96");
+ se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 129");
- se = st.getEndingState("unlocked", "disabled", "null", "null", "demote");
- assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 97");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 130");
- se = st.getEndingState("unlocked", "disabled", "null", "null", "unlock");
- assertEquals("null,unlocked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 98");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "unlock");
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 131");
- se = st.getEndingState("unlocked", "disabled", "null", "null", "disableFailed");
- assertEquals("null,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 99");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "disableFailed");
+ assertEquals("null,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 132");
- se = st.getEndingState("unlocked", "disabled", "null", "null", "enableNotFailed");
- assertEquals("null,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 100");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "enableNotFailed");
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 133");
- se = st.getEndingState("unlocked", "disabled", "null", "null", "disableDependency");
- assertEquals("null,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 101");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "disableDependency");
+ assertEquals("null,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 134");
- se = st.getEndingState("unlocked", "disabled", "null", "null", "enableNoDependency");
- assertEquals("null,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 102");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "enableNoDependency");
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 135");
- se = st.getEndingState("unlocked", "disabled", "null", "null", "promote");
- assertEquals("coldstandby,unlocked,disabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 103");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "promote");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 136");
- se = st.getEndingState("unlocked", "disabled", "null", "null", "demote");
- assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 104");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 137");
- se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "demote");
- assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 105");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 138");
- se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "unlock");
- assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 106");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "unlock");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 139");
- se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 107");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 140");
- se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "enableNotFailed");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 108");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "enableNotFailed");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 141");
- se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 109");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 142");
- se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "enableNoDependency");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 110");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "enableNoDependency");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 143");
- se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "promote");
- assertEquals("coldstandby,unlocked,disabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 111");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "promote");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 144");
- se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "demote");
- assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 112");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 145");
- se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "demote");
- assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 113");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 146");
- se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "unlock");
- assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 114");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "unlock");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 147");
- se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 115");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 148");
- se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "enableNotFailed");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 116");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "enableNotFailed");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 149");
- se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 117");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 150");
- se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "enableNoDependency");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 118");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "enableNoDependency");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 151");
- se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "promote");
- assertEquals("coldstandby,unlocked,disabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 119");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "promote");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 152");
- se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "demote");
- assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 120");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 153");
- se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "demote");
- assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 121");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 154");
- se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "unlock");
- assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 122");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "unlock");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 155");
- se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 123");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 156");
- se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "enableNotFailed");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 124");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice",
+ "enableNotFailed");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+
+ logger.info("??? StateTransition testcase 125");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice",
+ "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+
+ logger.info("??? StateTransition testcase 126");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice",
+ "enableNoDependency");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 157");
- se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 127");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "promote");
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 158");
- se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "enableNoDependency");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 128");
+ se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "demote");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 159");
- se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "promote");
- assertEquals("coldstandby,unlocked,disabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 129");
+ se = st.getEndingState("unlocked", "disabled", "null", "null", "demote");
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 160");
- se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "demote");
- assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 130");
+ se = st.getEndingState("unlocked", "disabled", "null", "null", "unlock");
+ assertEquals("null,unlocked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 161");
- se = st.getEndingState("unlocked", "disabled", "failed", "null", "demote");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 131");
+ se = st.getEndingState("unlocked", "disabled", "null", "null", "disableFailed");
+ assertEquals("null,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 162");
- se = st.getEndingState("unlocked", "disabled", "failed", "null", "unlock");
- assertEquals("null,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 132");
+ se = st.getEndingState("unlocked", "disabled", "null", "null", "enableNotFailed");
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 163");
- se = st.getEndingState("unlocked", "disabled", "failed", "null", "disableFailed");
- assertEquals("null,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 133");
+ se = st.getEndingState("unlocked", "disabled", "null", "null", "disableDependency");
+ assertEquals("null,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 164");
- se = st.getEndingState("unlocked", "disabled", "failed", "null", "enableNotFailed");
- assertEquals("null,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 134");
+ se = st.getEndingState("unlocked", "disabled", "null", "null", "enableNoDependency");
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 165");
- se = st.getEndingState("unlocked", "disabled", "failed", "null", "disableDependency");
- assertEquals("null,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 135");
+ se = st.getEndingState("unlocked", "disabled", "null", "null", "promote");
+ assertEquals("coldstandby,unlocked,disabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 166");
- se = st.getEndingState("unlocked", "disabled", "failed", "null", "enableNoDependency");
- assertEquals("null,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 136");
+ se = st.getEndingState("unlocked", "disabled", "null", "null", "demote");
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 167");
- se = st.getEndingState("unlocked", "disabled", "failed", "null", "promote");
- assertEquals("coldstandby,unlocked,disabled,failed,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 137");
+ se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "demote");
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 168");
- se = st.getEndingState("unlocked", "disabled", "failed", "null", "demote");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 138");
+ se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 169");
- se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "demote");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 139");
+ se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 170");
- se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "unlock");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 140");
+ se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "enableNotFailed");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 171");
- se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 141");
+ se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 172");
- se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "enableNotFailed");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 142");
+ se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "enableNoDependency");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 173");
- se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 143");
+ se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "promote");
+ assertEquals("coldstandby,unlocked,disabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 174");
- se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "enableNoDependency");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 144");
+ se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "demote");
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 175");
- se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "promote");
- assertEquals("coldstandby,unlocked,disabled,failed,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 145");
+ se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "demote");
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 176");
- se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "demote");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 146");
+ se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 177");
- se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "demote");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 147");
+ se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 178");
- se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "unlock");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 148");
+ se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "enableNotFailed");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 179");
- se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 149");
+ se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 180");
- se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "enableNotFailed");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 150");
+ se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "enableNoDependency");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 181");
- se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 151");
+ se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "promote");
+ assertEquals("coldstandby,unlocked,disabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 182");
- se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "enableNoDependency");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 152");
+ se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "demote");
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 183");
- se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "promote");
- assertEquals("coldstandby,unlocked,disabled,failed,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 153");
+ se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "demote");
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 184");
- se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "demote");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 154");
+ se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 185");
- se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "demote");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 155");
+ se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 186");
- se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "unlock");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 156");
+ se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "enableNotFailed");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 187");
- se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 157");
+ se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 188");
- se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "enableNotFailed");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 158");
+ se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "enableNoDependency");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 189");
- se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 159");
+ se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "promote");
+ assertEquals("coldstandby,unlocked,disabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 190");
- se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "enableNoDependency");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 160");
+ se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "demote");
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 191");
- se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "promote");
- assertEquals("coldstandby,unlocked,disabled,failed,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 161");
+ se = st.getEndingState("unlocked", "disabled", "failed", "null", "demote");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 192");
- se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "demote");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 162");
+ se = st.getEndingState("unlocked", "disabled", "failed", "null", "unlock");
+ assertEquals("null,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 193");
- se = st.getEndingState("unlocked", "disabled", "dependency", "null", "demote");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 163");
+ se = st.getEndingState("unlocked", "disabled", "failed", "null", "disableFailed");
+ assertEquals("null,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 194");
- se = st.getEndingState("unlocked", "disabled", "dependency", "null", "unlock");
- assertEquals("null,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 164");
+ se = st.getEndingState("unlocked", "disabled", "failed", "null", "enableNotFailed");
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 195");
- se = st.getEndingState("unlocked", "disabled", "dependency", "null", "disableFailed");
- assertEquals("null,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 165");
+ se = st.getEndingState("unlocked", "disabled", "failed", "null", "disableDependency");
+ assertEquals("null,unlocked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 196");
- se = st.getEndingState("unlocked", "disabled", "dependency", "null", "enableNotFailed");
- assertEquals("null,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 166");
+ se = st.getEndingState("unlocked", "disabled", "failed", "null", "enableNoDependency");
+ assertEquals("null,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 197");
- se = st.getEndingState("unlocked", "disabled", "dependency", "null", "disableDependency");
- assertEquals("null,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 167");
+ se = st.getEndingState("unlocked", "disabled", "failed", "null", "promote");
+ assertEquals("coldstandby,unlocked,disabled,failed,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 198");
- se = st.getEndingState("unlocked", "disabled", "dependency", "null", "enableNoDependency");
- assertEquals("null,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 168");
+ se = st.getEndingState("unlocked", "disabled", "failed", "null", "demote");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 199");
- se = st.getEndingState("unlocked", "disabled", "dependency", "null", "promote");
- assertEquals("coldstandby,unlocked,disabled,dependency,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 169");
+ se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "demote");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 200");
- se = st.getEndingState("unlocked", "disabled", "dependency", "null", "demote");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 170");
+ se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 201");
- se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "demote");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 171");
+ se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 202");
- se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "unlock");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 172");
+ se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "enableNotFailed");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 203");
- se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 173");
+ se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 204");
- se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "enableNotFailed");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 174");
+ se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "enableNoDependency");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 205");
- se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 175");
+ se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "promote");
+ assertEquals("coldstandby,unlocked,disabled,failed,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 206");
- se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "enableNoDependency");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 176");
+ se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "demote");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 207");
- se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "promote");
- assertEquals("coldstandby,unlocked,disabled,dependency,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 177");
+ se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "demote");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 208");
- se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "demote");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 178");
+ se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 209");
- se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "demote");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 179");
+ se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 210");
- se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "unlock");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 180");
+ se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "enableNotFailed");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 211");
- se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 181");
+ se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 212");
- se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "enableNotFailed");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 182");
+ se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "enableNoDependency");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 213");
- se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 183");
+ se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "promote");
+ assertEquals("coldstandby,unlocked,disabled,failed,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 214");
- se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "enableNoDependency");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 184");
+ se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "demote");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 215");
- se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "promote");
- assertEquals("coldstandby,unlocked,disabled,dependency,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 185");
+ se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "demote");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 216");
- se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "demote");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 186");
+ se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 217");
- se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "demote");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 187");
+ se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 218");
- se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "unlock");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 188");
+ se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "enableNotFailed");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 219");
- se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 189");
+ se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 220");
- se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "enableNotFailed");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 190");
+ se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "enableNoDependency");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 221");
- se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 191");
+ se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "promote");
+ assertEquals("coldstandby,unlocked,disabled,failed,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 222");
- se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "enableNoDependency");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 192");
+ se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "demote");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 223");
- se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "promote");
- assertEquals("coldstandby,unlocked,disabled,dependency,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 193");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "null", "demote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 224");
- se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "demote");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 194");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "null", "unlock");
+ assertEquals("null,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 225");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "demote");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 195");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "null", "disableFailed");
+ assertEquals("null,unlocked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 226");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "unlock");
- assertEquals("null,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 196");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "null", "enableNotFailed");
+ assertEquals("null,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 227");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "disableFailed");
- assertEquals("null,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 197");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "null", "disableDependency");
+ assertEquals("null,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 228");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "enableNotFailed");
- assertEquals("null,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 198");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "null", "enableNoDependency");
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 229");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "disableDependency");
- assertEquals("null,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 199");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "null", "promote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 230");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "enableNoDependency");
- assertEquals("null,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 200");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "null", "demote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 231");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "promote");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 201");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "demote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 232");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "demote");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 202");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 233");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "demote");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 203");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 234");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "unlock");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 204");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "enableNotFailed");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 235");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 205");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 236");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "enableNotFailed");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 206");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "enableNoDependency");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 237");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 207");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "promote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 238");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "enableNoDependency");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 208");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "demote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 239");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "promote");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 209");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "demote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 240");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "demote");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 210");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 241");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "demote");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 211");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 242");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "unlock");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 212");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "enableNotFailed");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 243");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 213");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 244");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "enableNotFailed");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 214");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "enableNoDependency");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 245");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 215");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "promote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 246");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "enableNoDependency");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 216");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "demote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 247");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "promote");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 217");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "demote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 248");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "demote");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 218");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 249");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "demote");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 219");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 250");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "unlock");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 220");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "enableNotFailed");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 251");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "disableFailed");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 221");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 252");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "enableNotFailed");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 222");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "enableNoDependency");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 253");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "disableDependency");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 223");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "promote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 254");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "enableNoDependency");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 224");
+ se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "demote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 255");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "promote");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 225");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "demote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 256");
- se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "demote");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 226");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "unlock");
+ assertEquals("null,unlocked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 257");
- se = st.getEndingState("locked", "enabled", "null", "null", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 227");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "disableFailed");
+ assertEquals("null,unlocked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 258");
- se = st.getEndingState("locked", "enabled", "null", "null", "unlock");
- assertEquals("null,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 228");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "enableNotFailed");
+ assertEquals("null,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 259");
- se = st.getEndingState("locked", "enabled", "null", "null", "disableFailed");
- assertEquals("null,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 229");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "disableDependency");
+ assertEquals("null,unlocked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 260");
- se = st.getEndingState("locked", "enabled", "null", "null", "enableNotFailed");
- assertEquals("null,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 230");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "enableNoDependency");
+ assertEquals("null,unlocked,disabled,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 231");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "promote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,StandbyStatusException", makeString(se));
+
+ logger.info("??? StateTransition testcase 232");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "demote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 233");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "demote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 234");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 235");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 236");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "enableNotFailed");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+
+ logger.info("??? StateTransition testcase 237");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 238");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby",
+ "enableNoDependency");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 239");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "promote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,StandbyStatusException", makeString(se));
+
+ logger.info("??? StateTransition testcase 240");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "demote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 241");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "demote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 242");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 243");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 244");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "enableNotFailed");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+
+ logger.info("??? StateTransition testcase 245");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 246");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "enableNoDependency");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 247");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "promote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,StandbyStatusException", makeString(se));
+
+ logger.info("??? StateTransition testcase 248");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "demote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 249");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "demote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 250");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 251");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice",
+ "disableFailed");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 252");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice",
+ "enableNotFailed");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+
+ logger.info("??? StateTransition testcase 253");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice",
+ "disableDependency");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 254");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice",
+ "enableNoDependency");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 255");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "promote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,StandbyStatusException", makeString(se));
+
+ logger.info("??? StateTransition testcase 256");
+ se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "demote");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 257");
+ se = st.getEndingState("locked", "enabled", "null", "null", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+
+ logger.info("??? StateTransition testcase 258");
+ se = st.getEndingState("locked", "enabled", "null", "null", "unlock");
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
+
+ logger.info("??? StateTransition testcase 259");
+ se = st.getEndingState("locked", "enabled", "null", "null", "disableFailed");
+ assertEquals("null,locked,disabled,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 260");
+ se = st.getEndingState("locked", "enabled", "null", "null", "enableNotFailed");
+ assertEquals("null,locked,enabled,null,", makeString(se));
+
+ logger.info("??? StateTransition testcase 261");
+ se = st.getEndingState("locked", "enabled", "null", "null", "disableDependency");
+ assertEquals("null,locked,disabled,dependency,", makeString(se));
+
+ logger.info("??? StateTransition testcase 262");
+ se = st.getEndingState("locked", "enabled", "null", "null", "enableNoDependency");
+ assertEquals("null,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 261");
- se = st.getEndingState("locked", "enabled", "null", "null", "disableDependency");
- assertEquals("null,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 263");
+ se = st.getEndingState("locked", "enabled", "null", "null", "promote");
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 262");
- se = st.getEndingState("locked", "enabled", "null", "null", "enableNoDependency");
- assertEquals("null,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 264");
+ se = st.getEndingState("locked", "enabled", "null", "null", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 263");
- se = st.getEndingState("locked", "enabled", "null", "null", "promote");
- assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 265");
+ se = st.getEndingState("locked", "enabled", "null", "coldstandby", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 264");
- se = st.getEndingState("locked", "enabled", "null", "null", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 266");
+ se = st.getEndingState("locked", "enabled", "null", "coldstandby", "unlock");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 265");
- se = st.getEndingState("locked", "enabled", "null", "coldstandby", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 267");
+ se = st.getEndingState("locked", "enabled", "null", "coldstandby", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 266");
- se = st.getEndingState("locked", "enabled", "null", "coldstandby", "unlock");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 268");
+ se = st.getEndingState("locked", "enabled", "null", "coldstandby", "enableNotFailed");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 267");
- se = st.getEndingState("locked", "enabled", "null", "coldstandby", "disableFailed");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 269");
+ se = st.getEndingState("locked", "enabled", "null", "coldstandby", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 268");
- se = st.getEndingState("locked", "enabled", "null", "coldstandby", "enableNotFailed");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 270");
+ se = st.getEndingState("locked", "enabled", "null", "coldstandby", "enableNoDependency");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 269");
- se = st.getEndingState("locked", "enabled", "null", "coldstandby", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 271");
+ se = st.getEndingState("locked", "enabled", "null", "coldstandby", "promote");
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 270");
- se = st.getEndingState("locked", "enabled", "null", "coldstandby", "enableNoDependency");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 272");
+ se = st.getEndingState("locked", "enabled", "null", "coldstandby", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 271");
- se = st.getEndingState("locked", "enabled", "null", "coldstandby", "promote");
- assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 273");
+ se = st.getEndingState("locked", "enabled", "null", "hotstandby", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 272");
- se = st.getEndingState("locked", "enabled", "null", "coldstandby", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 274");
+ se = st.getEndingState("locked", "enabled", "null", "hotstandby", "unlock");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 273");
- se = st.getEndingState("locked", "enabled", "null", "hotstandby", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 275");
+ se = st.getEndingState("locked", "enabled", "null", "hotstandby", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 274");
- se = st.getEndingState("locked", "enabled", "null", "hotstandby", "unlock");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 276");
+ se = st.getEndingState("locked", "enabled", "null", "hotstandby", "enableNotFailed");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 275");
- se = st.getEndingState("locked", "enabled", "null", "hotstandby", "disableFailed");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 277");
+ se = st.getEndingState("locked", "enabled", "null", "hotstandby", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 276");
- se = st.getEndingState("locked", "enabled", "null", "hotstandby", "enableNotFailed");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 278");
+ se = st.getEndingState("locked", "enabled", "null", "hotstandby", "enableNoDependency");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 277");
- se = st.getEndingState("locked", "enabled", "null", "hotstandby", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 279");
+ se = st.getEndingState("locked", "enabled", "null", "hotstandby", "promote");
+ assertEquals("coldstandby,locked,enabled,null,StandbyStateException", makeString(se));
- logger.info("??? StateTransition testcase 278");
- se = st.getEndingState("locked", "enabled", "null", "hotstandby", "enableNoDependency");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 280");
+ se = st.getEndingState("locked", "enabled", "null", "hotstandby", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 279");
- se = st.getEndingState("locked", "enabled", "null", "hotstandby", "promote");
- assertEquals("coldstandby,locked,enabled,null,StandbyStateException", makeString(se));
+ logger.info("??? StateTransition testcase 281");
+ se = st.getEndingState("locked", "enabled", "null", "providingservice", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 280");
- se = st.getEndingState("locked", "enabled", "null", "hotstandby", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 282");
+ se = st.getEndingState("locked", "enabled", "null", "providingservice", "unlock");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 281");
- se = st.getEndingState("locked", "enabled", "null", "providingservice", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 283");
+ se = st.getEndingState("locked", "enabled", "null", "providingservice", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 282");
- se = st.getEndingState("locked", "enabled", "null", "providingservice", "unlock");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 284");
+ se = st.getEndingState("locked", "enabled", "null", "providingservice", "enableNotFailed");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 283");
- se = st.getEndingState("locked", "enabled", "null", "providingservice", "disableFailed");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 285");
+ se = st.getEndingState("locked", "enabled", "null", "providingservice", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 284");
- se = st.getEndingState("locked", "enabled", "null", "providingservice", "enableNotFailed");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 286");
+ se = st.getEndingState("locked", "enabled", "null", "providingservice", "enableNoDependency");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 285");
- se = st.getEndingState("locked", "enabled", "null", "providingservice", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 287");
+ se = st.getEndingState("locked", "enabled", "null", "providingservice", "promote");
+ assertEquals("coldstandby,locked,enabled,null,StandbyStateException", makeString(se));
- logger.info("??? StateTransition testcase 286");
- se = st.getEndingState("locked", "enabled", "null", "providingservice", "enableNoDependency");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 288");
+ se = st.getEndingState("locked", "enabled", "null", "providingservice", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 287");
- se = st.getEndingState("locked", "enabled", "null", "providingservice", "promote");
- assertEquals("coldstandby,locked,enabled,null,StandbyStateException", makeString(se));
+ logger.info("??? StateTransition testcase 289");
+ se = st.getEndingState("locked", "enabled", "failed", "null", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 288");
- se = st.getEndingState("locked", "enabled", "null", "providingservice", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 290");
+ se = st.getEndingState("locked", "enabled", "failed", "null", "unlock");
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 289");
- se = st.getEndingState("locked", "enabled", "failed", "null", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 291");
+ se = st.getEndingState("locked", "enabled", "failed", "null", "disableFailed");
+ assertEquals("null,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 290");
- se = st.getEndingState("locked", "enabled", "failed", "null", "unlock");
- assertEquals("null,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 292");
+ se = st.getEndingState("locked", "enabled", "failed", "null", "enableNotFailed");
+ assertEquals("null,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 291");
- se = st.getEndingState("locked", "enabled", "failed", "null", "disableFailed");
- assertEquals("null,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 293");
+ se = st.getEndingState("locked", "enabled", "failed", "null", "disableDependency");
+ assertEquals("null,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 292");
- se = st.getEndingState("locked", "enabled", "failed", "null", "enableNotFailed");
- assertEquals("null,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 294");
+ se = st.getEndingState("locked", "enabled", "failed", "null", "enableNoDependency");
+ assertEquals("null,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 293");
- se = st.getEndingState("locked", "enabled", "failed", "null", "disableDependency");
- assertEquals("null,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 295");
+ se = st.getEndingState("locked", "enabled", "failed", "null", "promote");
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 294");
- se = st.getEndingState("locked", "enabled", "failed", "null", "enableNoDependency");
- assertEquals("null,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 296");
+ se = st.getEndingState("locked", "enabled", "failed", "null", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 295");
- se = st.getEndingState("locked", "enabled", "failed", "null", "promote");
- assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 297");
+ se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 296");
- se = st.getEndingState("locked", "enabled", "failed", "null", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 298");
+ se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "unlock");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 297");
- se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 299");
+ se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 298");
- se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "unlock");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 300");
+ se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "enableNotFailed");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 299");
- se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "disableFailed");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 301");
+ se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 300");
- se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "enableNotFailed");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 302");
+ se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "enableNoDependency");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 301");
- se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 303");
+ se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "promote");
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 302");
- se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "enableNoDependency");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 304");
+ se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 303");
- se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "promote");
- assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 305");
+ se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 304");
- se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 306");
+ se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "unlock");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 305");
- se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 307");
+ se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 306");
- se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "unlock");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 308");
+ se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "enableNotFailed");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 307");
- se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "disableFailed");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 309");
+ se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 308");
- se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "enableNotFailed");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 310");
+ se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "enableNoDependency");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 309");
- se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 311");
+ se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "promote");
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 310");
- se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "enableNoDependency");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 312");
+ se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 311");
- se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "promote");
- assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 313");
+ se = st.getEndingState("locked", "enabled", "failed", "providingservice", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 312");
- se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 314");
+ se = st.getEndingState("locked", "enabled", "failed", "providingservice", "unlock");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 313");
- se = st.getEndingState("locked", "enabled", "failed", "providingservice", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 315");
+ se = st.getEndingState("locked", "enabled", "failed", "providingservice", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 314");
- se = st.getEndingState("locked", "enabled", "failed", "providingservice", "unlock");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 316");
+ se = st.getEndingState("locked", "enabled", "failed", "providingservice", "enableNotFailed");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 315");
- se = st.getEndingState("locked", "enabled", "failed", "providingservice", "disableFailed");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 317");
+ se = st.getEndingState("locked", "enabled", "failed", "providingservice", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 316");
- se = st.getEndingState("locked", "enabled", "failed", "providingservice", "enableNotFailed");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 318");
+ se = st.getEndingState("locked", "enabled", "failed", "providingservice", "enableNoDependency");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 317");
- se = st.getEndingState("locked", "enabled", "failed", "providingservice", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 319");
+ se = st.getEndingState("locked", "enabled", "failed", "providingservice", "promote");
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 318");
- se = st.getEndingState("locked", "enabled", "failed", "providingservice", "enableNoDependency");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 320");
+ se = st.getEndingState("locked", "enabled", "failed", "providingservice", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 319");
- se = st.getEndingState("locked", "enabled", "failed", "providingservice", "promote");
- assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 321");
+ se = st.getEndingState("locked", "enabled", "dependency", "null", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 320");
- se = st.getEndingState("locked", "enabled", "failed", "providingservice", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 322");
+ se = st.getEndingState("locked", "enabled", "dependency", "null", "unlock");
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 321");
- se = st.getEndingState("locked", "enabled", "dependency", "null", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 323");
+ se = st.getEndingState("locked", "enabled", "dependency", "null", "disableFailed");
+ assertEquals("null,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 322");
- se = st.getEndingState("locked", "enabled", "dependency", "null", "unlock");
- assertEquals("null,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 324");
+ se = st.getEndingState("locked", "enabled", "dependency", "null", "enableNotFailed");
+ assertEquals("null,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 323");
- se = st.getEndingState("locked", "enabled", "dependency", "null", "disableFailed");
- assertEquals("null,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 325");
+ se = st.getEndingState("locked", "enabled", "dependency", "null", "disableDependency");
+ assertEquals("null,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 324");
- se = st.getEndingState("locked", "enabled", "dependency", "null", "enableNotFailed");
- assertEquals("null,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 326");
+ se = st.getEndingState("locked", "enabled", "dependency", "null", "enableNoDependency");
+ assertEquals("null,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 325");
- se = st.getEndingState("locked", "enabled", "dependency", "null", "disableDependency");
- assertEquals("null,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 327");
+ se = st.getEndingState("locked", "enabled", "dependency", "null", "promote");
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 326");
- se = st.getEndingState("locked", "enabled", "dependency", "null", "enableNoDependency");
- assertEquals("null,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 328");
+ se = st.getEndingState("locked", "enabled", "dependency", "null", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 327");
- se = st.getEndingState("locked", "enabled", "dependency", "null", "promote");
- assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 329");
+ se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 328");
- se = st.getEndingState("locked", "enabled", "dependency", "null", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 330");
+ se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "unlock");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 329");
- se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 331");
+ se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 330");
- se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "unlock");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 332");
+ se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "enableNotFailed");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 331");
- se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "disableFailed");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 333");
+ se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 332");
- se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "enableNotFailed");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 334");
+ se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "enableNoDependency");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 333");
- se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 335");
+ se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "promote");
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 334");
- se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "enableNoDependency");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 336");
+ se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 335");
- se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "promote");
- assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 337");
+ se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 336");
- se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 338");
+ se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "unlock");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 337");
- se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 339");
+ se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 338");
- se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "unlock");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 340");
+ se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "enableNotFailed");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 339");
- se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "disableFailed");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 341");
+ se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 340");
- se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "enableNotFailed");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 342");
+ se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "enableNoDependency");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 341");
- se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 343");
+ se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "promote");
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 342");
- se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "enableNoDependency");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 344");
+ se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 343");
- se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "promote");
- assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 345");
+ se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 344");
- se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 346");
+ se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "unlock");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 345");
- se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 347");
+ se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 346");
- se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "unlock");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 348");
+ se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "enableNotFailed");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 347");
- se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "disableFailed");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 349");
+ se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 348");
- se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "enableNotFailed");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 350");
+ se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "enableNoDependency");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 349");
- se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 351");
+ se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "promote");
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 350");
- se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "enableNoDependency");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 352");
+ se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 351");
- se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "promote");
- assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 353");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 352");
- se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 354");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "unlock");
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 353");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 355");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "disableFailed");
+ assertEquals("null,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 354");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "unlock");
- assertEquals("null,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 356");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "enableNotFailed");
+ assertEquals("null,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 355");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "disableFailed");
- assertEquals("null,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 357");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "disableDependency");
+ assertEquals("null,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 356");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "enableNotFailed");
- assertEquals("null,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 358");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "enableNoDependency");
+ assertEquals("null,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 357");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "disableDependency");
- assertEquals("null,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 359");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "promote");
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 358");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "enableNoDependency");
- assertEquals("null,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 360");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 359");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "promote");
- assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 361");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 360");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 362");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "unlock");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 361");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 363");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 362");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "unlock");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 364");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "enableNotFailed");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 363");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "disableFailed");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 365");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 364");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "enableNotFailed");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 366");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "enableNoDependency");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 365");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 367");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "promote");
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 366");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "enableNoDependency");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 368");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 367");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "promote");
- assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 369");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 368");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 370");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "unlock");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 369");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 371");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 370");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "unlock");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 372");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "enableNotFailed");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 371");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "disableFailed");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 373");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 372");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "enableNotFailed");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 374");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "enableNoDependency");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 373");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 375");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "promote");
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 374");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "enableNoDependency");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 376");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 375");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "promote");
- assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 377");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 376");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 378");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "unlock");
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 377");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 379");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 378");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "unlock");
- assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 380");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "enableNotFailed");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 379");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "disableFailed");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 381");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice",
+ "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+
+ logger.info("??? StateTransition testcase 382");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice",
+ "enableNoDependency");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 380");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "enableNotFailed");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 383");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "promote");
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 381");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 384");
+ se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "demote");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 382");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "enableNoDependency");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 385");
+ se = st.getEndingState("locked", "disabled", "null", "null", "demote");
+ assertEquals("coldstandby,locked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 383");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "promote");
- assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 386");
+ se = st.getEndingState("locked", "disabled", "null", "null", "unlock");
+ assertEquals("null,unlocked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 384");
- se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "demote");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 387");
+ se = st.getEndingState("locked", "disabled", "null", "null", "disableFailed");
+ assertEquals("null,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 385");
- se = st.getEndingState("locked", "disabled", "null", "null", "demote");
- assertEquals("coldstandby,locked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 388");
+ se = st.getEndingState("locked", "disabled", "null", "null", "enableNotFailed");
+ assertEquals("null,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 386");
- se = st.getEndingState("locked", "disabled", "null", "null", "unlock");
- assertEquals("null,unlocked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 389");
+ se = st.getEndingState("locked", "disabled", "null", "null", "disableDependency");
+ assertEquals("null,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 387");
- se = st.getEndingState("locked", "disabled", "null", "null", "disableFailed");
- assertEquals("null,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 390");
+ se = st.getEndingState("locked", "disabled", "null", "null", "enableNoDependency");
+ assertEquals("null,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 388");
- se = st.getEndingState("locked", "disabled", "null", "null", "enableNotFailed");
- assertEquals("null,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 391");
+ se = st.getEndingState("locked", "disabled", "null", "null", "promote");
+ assertEquals("coldstandby,locked,disabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 389");
- se = st.getEndingState("locked", "disabled", "null", "null", "disableDependency");
- assertEquals("null,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 392");
+ se = st.getEndingState("locked", "disabled", "null", "null", "demote");
+ assertEquals("coldstandby,locked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 390");
- se = st.getEndingState("locked", "disabled", "null", "null", "enableNoDependency");
- assertEquals("null,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 393");
+ se = st.getEndingState("locked", "disabled", "null", "coldstandby", "demote");
+ assertEquals("coldstandby,locked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 391");
- se = st.getEndingState("locked", "disabled", "null", "null", "promote");
- assertEquals("coldstandby,locked,disabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 394");
+ se = st.getEndingState("locked", "disabled", "null", "coldstandby", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 392");
- se = st.getEndingState("locked", "disabled", "null", "null", "demote");
- assertEquals("coldstandby,locked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 395");
+ se = st.getEndingState("locked", "disabled", "null", "coldstandby", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 393");
- se = st.getEndingState("locked", "disabled", "null", "coldstandby", "demote");
- assertEquals("coldstandby,locked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 396");
+ se = st.getEndingState("locked", "disabled", "null", "coldstandby", "enableNotFailed");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 394");
- se = st.getEndingState("locked", "disabled", "null", "coldstandby", "unlock");
- assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 397");
+ se = st.getEndingState("locked", "disabled", "null", "coldstandby", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 395");
- se = st.getEndingState("locked", "disabled", "null", "coldstandby", "disableFailed");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 398");
+ se = st.getEndingState("locked", "disabled", "null", "coldstandby", "enableNoDependency");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 396");
- se = st.getEndingState("locked", "disabled", "null", "coldstandby", "enableNotFailed");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 399");
+ se = st.getEndingState("locked", "disabled", "null", "coldstandby", "promote");
+ assertEquals("coldstandby,locked,disabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 397");
- se = st.getEndingState("locked", "disabled", "null", "coldstandby", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 400");
+ se = st.getEndingState("locked", "disabled", "null", "coldstandby", "demote");
+ assertEquals("coldstandby,locked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 398");
- se = st.getEndingState("locked", "disabled", "null", "coldstandby", "enableNoDependency");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 401");
+ se = st.getEndingState("locked", "disabled", "null", "hotstandby", "demote");
+ assertEquals("coldstandby,locked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 399");
- se = st.getEndingState("locked", "disabled", "null", "coldstandby", "promote");
- assertEquals("coldstandby,locked,disabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 402");
+ se = st.getEndingState("locked", "disabled", "null", "hotstandby", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 400");
- se = st.getEndingState("locked", "disabled", "null", "coldstandby", "demote");
- assertEquals("coldstandby,locked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 403");
+ se = st.getEndingState("locked", "disabled", "null", "hotstandby", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 401");
- se = st.getEndingState("locked", "disabled", "null", "hotstandby", "demote");
- assertEquals("coldstandby,locked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 404");
+ se = st.getEndingState("locked", "disabled", "null", "hotstandby", "enableNotFailed");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 402");
- se = st.getEndingState("locked", "disabled", "null", "hotstandby", "unlock");
- assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 405");
+ se = st.getEndingState("locked", "disabled", "null", "hotstandby", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 403");
- se = st.getEndingState("locked", "disabled", "null", "hotstandby", "disableFailed");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 406");
+ se = st.getEndingState("locked", "disabled", "null", "hotstandby", "enableNoDependency");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 404");
- se = st.getEndingState("locked", "disabled", "null", "hotstandby", "enableNotFailed");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 407");
+ se = st.getEndingState("locked", "disabled", "null", "hotstandby", "promote");
+ assertEquals("coldstandby,locked,disabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 405");
- se = st.getEndingState("locked", "disabled", "null", "hotstandby", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 408");
+ se = st.getEndingState("locked", "disabled", "null", "hotstandby", "demote");
+ assertEquals("coldstandby,locked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 406");
- se = st.getEndingState("locked", "disabled", "null", "hotstandby", "enableNoDependency");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 409");
+ se = st.getEndingState("locked", "disabled", "null", "providingservice", "demote");
+ assertEquals("coldstandby,locked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 407");
- se = st.getEndingState("locked", "disabled", "null", "hotstandby", "promote");
- assertEquals("coldstandby,locked,disabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 410");
+ se = st.getEndingState("locked", "disabled", "null", "providingservice", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 408");
- se = st.getEndingState("locked", "disabled", "null", "hotstandby", "demote");
- assertEquals("coldstandby,locked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 411");
+ se = st.getEndingState("locked", "disabled", "null", "providingservice", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 409");
- se = st.getEndingState("locked", "disabled", "null", "providingservice", "demote");
- assertEquals("coldstandby,locked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 412");
+ se = st.getEndingState("locked", "disabled", "null", "providingservice", "enableNotFailed");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 410");
- se = st.getEndingState("locked", "disabled", "null", "providingservice", "unlock");
- assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 413");
+ se = st.getEndingState("locked", "disabled", "null", "providingservice", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 411");
- se = st.getEndingState("locked", "disabled", "null", "providingservice", "disableFailed");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 414");
+ se = st.getEndingState("locked", "disabled", "null", "providingservice", "enableNoDependency");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 412");
- se = st.getEndingState("locked", "disabled", "null", "providingservice", "enableNotFailed");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 415");
+ se = st.getEndingState("locked", "disabled", "null", "providingservice", "promote");
+ assertEquals("coldstandby,locked,disabled,null,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 413");
- se = st.getEndingState("locked", "disabled", "null", "providingservice", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 416");
+ se = st.getEndingState("locked", "disabled", "null", "providingservice", "demote");
+ assertEquals("coldstandby,locked,disabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 414");
- se = st.getEndingState("locked", "disabled", "null", "providingservice", "enableNoDependency");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 417");
+ se = st.getEndingState("locked", "disabled", "failed", "null", "demote");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 415");
- se = st.getEndingState("locked", "disabled", "null", "providingservice", "promote");
- assertEquals("coldstandby,locked,disabled,null,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 418");
+ se = st.getEndingState("locked", "disabled", "failed", "null", "unlock");
+ assertEquals("null,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 416");
- se = st.getEndingState("locked", "disabled", "null", "providingservice", "demote");
- assertEquals("coldstandby,locked,disabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 419");
+ se = st.getEndingState("locked", "disabled", "failed", "null", "disableFailed");
+ assertEquals("null,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 417");
- se = st.getEndingState("locked", "disabled", "failed", "null", "demote");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 420");
+ se = st.getEndingState("locked", "disabled", "failed", "null", "enableNotFailed");
+ assertEquals("null,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 418");
- se = st.getEndingState("locked", "disabled", "failed", "null", "unlock");
- assertEquals("null,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 421");
+ se = st.getEndingState("locked", "disabled", "failed", "null", "disableDependency");
+ assertEquals("null,locked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 419");
- se = st.getEndingState("locked", "disabled", "failed", "null", "disableFailed");
- assertEquals("null,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 422");
+ se = st.getEndingState("locked", "disabled", "failed", "null", "enableNoDependency");
+ assertEquals("null,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 420");
- se = st.getEndingState("locked", "disabled", "failed", "null", "enableNotFailed");
- assertEquals("null,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 423");
+ se = st.getEndingState("locked", "disabled", "failed", "null", "promote");
+ assertEquals("coldstandby,locked,disabled,failed,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 421");
- se = st.getEndingState("locked", "disabled", "failed", "null", "disableDependency");
- assertEquals("null,locked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 424");
+ se = st.getEndingState("locked", "disabled", "failed", "null", "demote");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 422");
- se = st.getEndingState("locked", "disabled", "failed", "null", "enableNoDependency");
- assertEquals("null,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 425");
+ se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "demote");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 423");
- se = st.getEndingState("locked", "disabled", "failed", "null", "promote");
- assertEquals("coldstandby,locked,disabled,failed,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 426");
+ se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 424");
- se = st.getEndingState("locked", "disabled", "failed", "null", "demote");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 427");
+ se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 425");
- se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "demote");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 428");
+ se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "enableNotFailed");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 426");
- se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "unlock");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 429");
+ se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 427");
- se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "disableFailed");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 430");
+ se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "enableNoDependency");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 428");
- se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "enableNotFailed");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 431");
+ se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "promote");
+ assertEquals("coldstandby,locked,disabled,failed,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 429");
- se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 432");
+ se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "demote");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 430");
- se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "enableNoDependency");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 433");
+ se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "demote");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 431");
- se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "promote");
- assertEquals("coldstandby,locked,disabled,failed,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 434");
+ se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 432");
- se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "demote");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 435");
+ se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 433");
- se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "demote");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 436");
+ se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "enableNotFailed");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 434");
- se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "unlock");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 437");
+ se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 435");
- se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "disableFailed");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 438");
+ se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "enableNoDependency");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 436");
- se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "enableNotFailed");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 439");
+ se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "promote");
+ assertEquals("coldstandby,locked,disabled,failed,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 437");
- se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 440");
+ se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "demote");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 438");
- se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "enableNoDependency");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 441");
+ se = st.getEndingState("locked", "disabled", "failed", "providingservice", "demote");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 439");
- se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "promote");
- assertEquals("coldstandby,locked,disabled,failed,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 442");
+ se = st.getEndingState("locked", "disabled", "failed", "providingservice", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 440");
- se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "demote");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 443");
+ se = st.getEndingState("locked", "disabled", "failed", "providingservice", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 441");
- se = st.getEndingState("locked", "disabled", "failed", "providingservice", "demote");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 444");
+ se = st.getEndingState("locked", "disabled", "failed", "providingservice", "enableNotFailed");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 442");
- se = st.getEndingState("locked", "disabled", "failed", "providingservice", "unlock");
- assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 445");
+ se = st.getEndingState("locked", "disabled", "failed", "providingservice", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 443");
- se = st.getEndingState("locked", "disabled", "failed", "providingservice", "disableFailed");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 446");
+ se = st.getEndingState("locked", "disabled", "failed", "providingservice", "enableNoDependency");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 444");
- se = st.getEndingState("locked", "disabled", "failed", "providingservice", "enableNotFailed");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 447");
+ se = st.getEndingState("locked", "disabled", "failed", "providingservice", "promote");
+ assertEquals("coldstandby,locked,disabled,failed,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 445");
- se = st.getEndingState("locked", "disabled", "failed", "providingservice", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 448");
+ se = st.getEndingState("locked", "disabled", "failed", "providingservice", "demote");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 446");
- se = st.getEndingState("locked", "disabled", "failed", "providingservice", "enableNoDependency");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 449");
+ se = st.getEndingState("locked", "disabled", "dependency", "null", "demote");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 447");
- se = st.getEndingState("locked", "disabled", "failed", "providingservice", "promote");
- assertEquals("coldstandby,locked,disabled,failed,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 450");
+ se = st.getEndingState("locked", "disabled", "dependency", "null", "unlock");
+ assertEquals("null,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 448");
- se = st.getEndingState("locked", "disabled", "failed", "providingservice", "demote");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 451");
+ se = st.getEndingState("locked", "disabled", "dependency", "null", "disableFailed");
+ assertEquals("null,locked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 449");
- se = st.getEndingState("locked", "disabled", "dependency", "null", "demote");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 452");
+ se = st.getEndingState("locked", "disabled", "dependency", "null", "enableNotFailed");
+ assertEquals("null,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 450");
- se = st.getEndingState("locked", "disabled", "dependency", "null", "unlock");
- assertEquals("null,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 453");
+ se = st.getEndingState("locked", "disabled", "dependency", "null", "disableDependency");
+ assertEquals("null,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 451");
- se = st.getEndingState("locked", "disabled", "dependency", "null", "disableFailed");
- assertEquals("null,locked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 454");
+ se = st.getEndingState("locked", "disabled", "dependency", "null", "enableNoDependency");
+ assertEquals("null,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 452");
- se = st.getEndingState("locked", "disabled", "dependency", "null", "enableNotFailed");
- assertEquals("null,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 455");
+ se = st.getEndingState("locked", "disabled", "dependency", "null", "promote");
+ assertEquals("coldstandby,locked,disabled,dependency,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 453");
- se = st.getEndingState("locked", "disabled", "dependency", "null", "disableDependency");
- assertEquals("null,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 456");
+ se = st.getEndingState("locked", "disabled", "dependency", "null", "demote");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 454");
- se = st.getEndingState("locked", "disabled", "dependency", "null", "enableNoDependency");
- assertEquals("null,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 457");
+ se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "demote");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 455");
- se = st.getEndingState("locked", "disabled", "dependency", "null", "promote");
- assertEquals("coldstandby,locked,disabled,dependency,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 458");
+ se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 456");
- se = st.getEndingState("locked", "disabled", "dependency", "null", "demote");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 459");
+ se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 457");
- se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "demote");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 460");
+ se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "enableNotFailed");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 458");
- se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "unlock");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 461");
+ se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 459");
- se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "disableFailed");
- assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 462");
+ se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "enableNoDependency");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 460");
- se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "enableNotFailed");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 463");
+ se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "promote");
+ assertEquals("coldstandby,locked,disabled,dependency,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 461");
- se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 464");
+ se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "demote");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 462");
- se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "enableNoDependency");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 465");
+ se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "demote");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 463");
- se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "promote");
- assertEquals("coldstandby,locked,disabled,dependency,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 466");
+ se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 464");
- se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "demote");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 467");
+ se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 465");
- se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "demote");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 468");
+ se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "enableNotFailed");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 466");
- se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "unlock");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 469");
+ se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 467");
- se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "disableFailed");
- assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 470");
+ se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "enableNoDependency");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 468");
- se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "enableNotFailed");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 471");
+ se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "promote");
+ assertEquals("coldstandby,locked,disabled,dependency,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 469");
- se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 472");
+ se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "demote");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 470");
- se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "enableNoDependency");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 473");
+ se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "demote");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 471");
- se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "promote");
- assertEquals("coldstandby,locked,disabled,dependency,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 474");
+ se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 472");
- se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "demote");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 475");
+ se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 473");
- se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "demote");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 476");
+ se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "enableNotFailed");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 474");
- se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "unlock");
- assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 477");
+ se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 475");
- se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "disableFailed");
- assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 478");
+ se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "enableNoDependency");
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
- logger.info("??? StateTransition testcase 476");
- se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "enableNotFailed");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 479");
+ se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "promote");
+ assertEquals("coldstandby,locked,disabled,dependency,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 477");
- se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 480");
+ se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "demote");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 478");
- se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "enableNoDependency");
- assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+ logger.info("??? StateTransition testcase 481");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "demote");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 479");
- se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "promote");
- assertEquals("coldstandby,locked,disabled,dependency,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 482");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "unlock");
+ assertEquals("null,unlocked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 480");
- se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "demote");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 483");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "disableFailed");
+ assertEquals("null,locked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 481");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "demote");
- assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 484");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "enableNotFailed");
+ assertEquals("null,locked,disabled,dependency,", makeString(se));
- logger.info("??? StateTransition testcase 482");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "unlock");
- assertEquals("null,unlocked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 485");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "disableDependency");
+ assertEquals("null,locked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 483");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "disableFailed");
- assertEquals("null,locked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 486");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "enableNoDependency");
+ assertEquals("null,locked,disabled,failed,", makeString(se));
- logger.info("??? StateTransition testcase 484");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "enableNotFailed");
- assertEquals("null,locked,disabled,dependency,", makeString(se));
+ logger.info("??? StateTransition testcase 487");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "promote");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,StandbyStatusException", makeString(se));
- logger.info("??? StateTransition testcase 485");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "disableDependency");
- assertEquals("null,locked,disabled,dependency,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 488");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "demote");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 486");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "enableNoDependency");
- assertEquals("null,locked,disabled,failed,", makeString(se));
+ logger.info("??? StateTransition testcase 489");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "demote");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 487");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "promote");
- assertEquals("coldstandby,locked,disabled,dependency,failed,StandbyStatusException", makeString(se));
+ logger.info("??? StateTransition testcase 490");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 491");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
- logger.info("??? StateTransition testcase 488");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "demote");
- assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 489");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "demote");
- assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 490");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "unlock");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 491");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "disableFailed");
- assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 492");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "enableNotFailed");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
-
- logger.info("??? StateTransition testcase 493");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 494");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "enableNoDependency");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 495");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "promote");
- assertEquals("coldstandby,locked,disabled,dependency,failed,StandbyStatusException", makeString(se));
-
- logger.info("??? StateTransition testcase 496");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "demote");
- assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 497");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "demote");
- assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 498");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "unlock");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 499");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "disableFailed");
- assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 500");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "enableNotFailed");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
-
- logger.info("??? StateTransition testcase 501");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 502");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "enableNoDependency");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 503");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "promote");
- assertEquals("coldstandby,locked,disabled,dependency,failed,StandbyStatusException", makeString(se));
-
- logger.info("??? StateTransition testcase 504");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "demote");
- assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 505");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "demote");
- assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 506");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "unlock");
- assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 507");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "disableFailed");
- assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 508");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "enableNotFailed");
- assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
-
- logger.info("??? StateTransition testcase 509");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "disableDependency");
- assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 510");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "enableNoDependency");
- assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
-
- logger.info("??? StateTransition testcase 511");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "promote");
- assertEquals("coldstandby,locked,disabled,dependency,failed,StandbyStatusException", makeString(se));
-
- logger.info("??? StateTransition testcase 512");
- se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "demote");
- assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
-
- } catch (Exception ex) {
- logger.error("EndingState NOT found");
- throw new Exception("EndingState NOT found. " + ex);
- }
-
- } catch(Exception ex) {
- logger.error("Exception: {}" + ex.toString());
- throw new Exception("Failure getting ending state. " + ex );
- }
-
- logger.info("\n\nStateTransitionTest: Exit\n\n");
- }
-
- /**
- * Converts a state element to a comma-separated string.
- * @param se element to be converted
- * @return a string representing the element
- */
- private String makeString(StateElement se)
- {
- if(se == null) {
- return null;
- }
-
- StringBuilder b = new StringBuilder();
-
- String endingStandbyStatus = se.getEndingStandbyStatus();
- if (endingStandbyStatus != null) {
- b.append(endingStandbyStatus.replace(".", ","));
- b.append(',');
- }
-
- b.append(se.getEndingAdminState());
- b.append(',');
- b.append(se.getEndingOpState());
- b.append(',');
- b.append(se.getEndingAvailStatus());
- b.append(',');
- b.append(se.getException());
-
- return b.toString();
- }
+ logger.info("??? StateTransition testcase 492");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "enableNotFailed");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+
+ logger.info("??? StateTransition testcase 493");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 494");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "enableNoDependency");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 495");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "promote");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,StandbyStatusException", makeString(se));
+
+ logger.info("??? StateTransition testcase 496");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "demote");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 497");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "demote");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 498");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 499");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 500");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "enableNotFailed");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+
+ logger.info("??? StateTransition testcase 501");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 502");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "enableNoDependency");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 503");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "promote");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,StandbyStatusException", makeString(se));
+
+ logger.info("??? StateTransition testcase 504");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "demote");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 505");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "demote");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 506");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "unlock");
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 507");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "disableFailed");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 508");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice",
+ "enableNotFailed");
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
+
+ logger.info("??? StateTransition testcase 509");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice",
+ "disableDependency");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 510");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice",
+ "enableNoDependency");
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
+
+ logger.info("??? StateTransition testcase 511");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "promote");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,StandbyStatusException", makeString(se));
+
+ logger.info("??? StateTransition testcase 512");
+ se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "demote");
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
+
+ } catch (Exception ex) {
+ logger.error("EndingState NOT found");
+ throw new Exception("EndingState NOT found. " + ex);
+ }
+
+ } catch (Exception ex) {
+ logger.error("Exception: {}" + ex.toString());
+ throw new Exception("Failure getting ending state. " + ex);
+ }
+
+ logger.info("\n\nStateTransitionTest: Exit\n\n");
+ }
+
+ /**
+ * Converts a state element to a comma-separated string.
+ *
+ * @param se element to be converted
+ * @return a string representing the element
+ */
+ private String makeString(StateElement se) {
+ if (se == null) {
+ return null;
+ }
+
+ StringBuilder stringBuilder = new StringBuilder();
+
+ String endingStandbyStatus = se.getEndingStandbyStatus();
+ if (endingStandbyStatus != null) {
+ stringBuilder.append(endingStandbyStatus.replace(".", ","));
+ stringBuilder.append(',');
+ }
+
+ stringBuilder.append(se.getEndingAdminState());
+ stringBuilder.append(',');
+ stringBuilder.append(se.getEndingOpState());
+ stringBuilder.append(',');
+ stringBuilder.append(se.getEndingAvailStatus());
+ stringBuilder.append(',');
+ stringBuilder.append(se.getException());
+
+ return stringBuilder.toString();
+ }
}
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/exceptions/EntityRetrievalExceptionTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/exceptions/EntityRetrievalExceptionTest.java
index 8d948241..48ec3b86 100644
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/exceptions/EntityRetrievalExceptionTest.java
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/exceptions/EntityRetrievalExceptionTest.java
@@ -21,6 +21,7 @@
package org.onap.policy.common.im.exceptions;
import static org.junit.Assert.assertEquals;
+
import org.junit.Test;
import org.onap.policy.common.utils.test.ExceptionsTester;