summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java52
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java83
2 files changed, 95 insertions, 40 deletions
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 64c01931..0db43bbc 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
@@ -709,21 +709,45 @@ public class DbDAO {
* two or three milliseconds)
*/
} catch (LockTimeoutException e) {
- em.getTransaction().rollback();
- String msg = "DbDAO: " + "changeDesignated() "
- + "caught LockTimeoutException, message=" + e.getMessage();
- logger.error(msg + e);
- System.out.println(new Date());
- e.printStackTrace();
- throw new DbDaoTransactionException(msg, e);
+ if (em != null) {
+ em.getTransaction().rollback();
+
+ String msg = "DbDAO: " + "changeDesignated() "
+ + "caught LockTimeoutException, message=" + e.getMessage();
+ logger.error(msg + e);
+ System.out.println(new Date());
+ e.printStackTrace();
+ throw new DbDaoTransactionException(msg, e);
+ }
+ else {
+ String msg = "DbDAO: " + "changeDesignated() "
+ + "caught LockTimeoutException, message=" + e.getMessage()
+ + ". Error rolling back transaction.";
+ logger.error(msg + e);
+ System.out.println(new Date());
+ e.printStackTrace();
+ throw new DbDaoTransactionException(msg, e);
+ }
} catch (Exception e) {
- em.getTransaction().rollback();
- String msg = "DbDAO: " + "changeDesignated() "
- + "caught Exception, message=" + e.getMessage();
- logger.error(msg + e);
- System.out.println(new Date());
- e.printStackTrace();
- throw new DbDaoTransactionException(msg, e);
+ if (em != null) {
+ em.getTransaction().rollback();
+
+ String msg = "DbDAO: " + "changeDesignated() "
+ + "caught Exception, message=" + e.getMessage();
+ logger.error(msg + e);
+ System.out.println(new Date());
+ e.printStackTrace();
+ throw new DbDaoTransactionException(msg, e);
+ }
+ else {
+ String msg = "DbDAO: " + "changeDesignated() "
+ + "caught LockTimeoutException, message=" + e.getMessage()
+ + ". Error rolling back transaction.";
+ logger.error(msg + e);
+ System.out.println(new Date());
+ e.printStackTrace();
+ throw new DbDaoTransactionException(msg, e);
+ }
}
} // end synchronized block
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 06e9b3de..fef1dd54 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
@@ -544,42 +544,75 @@ public class IntegrityMonitor {
//verify that the ForwardProgress is current (check last_updated)
if(error_msg==null){
- Date date = new Date();
- long diffMs = date.getTime() - forwardProgressEntity.getLastUpdated().getTime();
- logger.debug("IntegrityMonitor.stateCheck(): diffMs = " + diffMs);
+ 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 = failedCounterThreshold * monitorInterval * 1000;
- logger.debug("IntegrityMonitor.stateCheck(): staleMs = " + staleMs);
+ //Threshold for a stale entry
+ long staleMs = failedCounterThreshold * monitorInterval * 1000;
+ 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);
+ 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.debug(msg);
+ logger.error(msg);
}
- } catch (Exception e) {
+ }
+ }
+ else {
+
+ if(forwardProgressEntity == null) {
+ String msg = "IntegrityMonitor.stateCheck(): Failed to diableFail dependent resource = " + dep
+ + "; " + " forwardProgressEntity == null.";
+ logger.debug(msg);
+ logger.error(msg);
+ }
+
+ else if(stateManagementEntity == null) {
String msg = "IntegrityMonitor.stateCheck(): Failed to diableFail dependent resource = " + dep
- + "; " + e.getMessage();
+ + "; " + " stateManagementEntity == null.";
logger.debug(msg);
logger.error(msg);
}
+
+ else {
+ String msg = "IntegrityMonitor.stateCheck(): Failed to diableFail dependent resource = " + dep
+ + "; " + " forwardProgressEntity or stateManagementEntity == null.";
+ logger.debug(msg);
+ logger.error(msg);
+
+ }
}
}
// check operation, admin and standby states of dependent resource
if (error_msg == null) {
- if ((stateManager.getAdminState() != null) && stateManagementEntity.getAdminState().equals(StateManagement.LOCKED)) {
- error_msg = dep + ": resource is administratively locked";
- logger.debug(error_msg);
- logger.error(error_msg);
- } else if ((stateManager.getOpState() != null) && stateManagementEntity.getOpState().equals(StateManagement.DISABLED)) {
- error_msg = dep + ": resource is operationally disabled";
- logger.debug(error_msg);
- logger.error(error_msg);
- } else if ((stateManager.getStandbyStatus() != null) && stateManagementEntity.getStandbyStatus().equals(StateManagement.COLD_STANDBY)) {
- error_msg = dep + ": resource is cold standby";
+ if(stateManagementEntity != null) {
+ if ((stateManager.getAdminState() != null) && stateManagementEntity.getAdminState().equals(StateManagement.LOCKED)) {
+ error_msg = dep + ": resource is administratively locked";
+ logger.debug(error_msg);
+ logger.error(error_msg);
+ } else if ((stateManager.getOpState() != null) && stateManagementEntity.getOpState().equals(StateManagement.DISABLED)) {
+ error_msg = dep + ": resource is operationally disabled";
+ logger.debug(error_msg);
+ logger.error(error_msg);
+ } else if ((stateManager.getStandbyStatus() != null) && stateManagementEntity.getStandbyStatus().equals(StateManagement.COLD_STANDBY)) {
+ error_msg = dep + ": resource is cold standby";
+ logger.debug(error_msg);
+ logger.error(error_msg);
+ }
+ }
+ else {
+ error_msg = dep + ": could not check standy state of resource. stateManagementEntity == null.";
logger.debug(error_msg);
logger.error(error_msg);
}
@@ -622,12 +655,10 @@ public class IntegrityMonitor {
try {
// create instance of StateMangement class for dependent
StateManagement depStateManager = new StateManagement(emf, dep);
- if (depStateManager != null) {
if(!depStateManager.getOpState().equals(StateManagement.DISABLED)){
logger.info("Forward progress not detected for dependent resource " + dep + ". Setting dependent's state to disable failed.");
depStateManager.disableFailed();
}
- }
} catch (Exception e) {
// ignore errors
logger.info("Update dependent state failed with exception: " + e);