aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2017-10-30 14:12:57 +0000
committerGerrit Code Review <gerrit@onap.org>2017-10-30 14:12:57 +0000
commit039c4d4d3bc00c129554b3761258d06e6ef87b58 (patch)
tree2049268babc44b7591b252cea42abd510f51ca7a /controlloop/common/eventmanager
parente5fad68d3ab3b79d4e69820e485e50bece16494f (diff)
parent08c54826db08f104359e36a67e4a3affb477a245 (diff)
Merge "Fix Final Failure on AAI Queries"
Diffstat (limited to 'controlloop/common/eventmanager')
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java48
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java20
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java20
3 files changed, 65 insertions, 23 deletions
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
index d320b75ee..b1674206b 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
@@ -149,7 +149,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
// Syntax check the event
//
checkEventSyntax(event);
- checkEventAAISyntax(event);
+
//
// At this point we are good to go with this event
//
@@ -184,7 +184,6 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
// Syntax check the event
//
checkEventSyntax(event);
- checkEventAAISyntax(event);
//
// Check the YAML
@@ -437,7 +436,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
;
}
- public NEW_EVENT_STATUS onNewEvent(VirtualControlLoopEvent event) {
+ public NEW_EVENT_STATUS onNewEvent(VirtualControlLoopEvent event) throws AAIException {
try {
this.checkEventSyntax(event);
if (event.closedLoopEventStatus == ControlLoopEventStatus.ONSET) {
@@ -445,6 +444,11 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
// Check if this is our original ONSET
//
if (event.equals(this.onset)) {
+ //
+ // Query A&AI if needed
+ //
+ queryAai(event);
+
//
// DO NOT retract it
//
@@ -546,58 +550,58 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
! "generic-vnf.vnf-name".equalsIgnoreCase(event.target) ) {
throw new ControlLoopException("target field invalid - expecting VM_NAME or VNF_NAME");
}
+ if (event.AAI == null) {
+ throw new ControlLoopException("AAI is null");
+ }
+ if (event.AAI.get("generic-vnf.vnf-id") == null && event.AAI.get("vserver.vserver-name") == null &&
+ event.AAI.get("generic-vnf.vnf-name") == null) {
+ throw new ControlLoopException("generic-vnf.vnf-id or generic-vnf.vnf-name or vserver.vserver-name information missing");
+ }
}
- public void checkEventAAISyntax(VirtualControlLoopEvent event) throws ControlLoopException {
- if (event.AAI == null) {
- throw new ControlLoopException("AAI is null");
- }
- if (event.AAI.get("generic-vnf.vnf-id") == null && event.AAI.get("vserver.vserver-name") == null &&
- event.AAI.get("generic-vnf.vnf-name") == null) {
- throw new ControlLoopException("generic-vnf.vnf-id or generic-vnf.vnf-name or vserver.vserver-name information missing");
- }
+ public void queryAai(VirtualControlLoopEvent event) throws AAIException {
if (event.AAI.get("vserver.is-closed-loop-disabled") == null) {
try {
if (event.AAI.get("generic-vnf.vnf-id") != null) {
vnfResponse = getAAIVnfInfo(event);
if (vnfResponse == null) {
- throw new ControlLoopException("AAI Response is null (query by vnf-id)");
+ throw new AAIException("AAI Response is null (query by vnf-id)");
}
if (vnfResponse.requestError != null) {
- throw new ControlLoopException("AAI Responded with a request error (query by vnf-id)");
+ throw new AAIException("AAI Responded with a request error (query by vnf-id)");
}
if (isClosedLoopDisabled(vnfResponse) == true) {
- throw new ControlLoopException("is-closed-loop-disabled is set to true");
+ throw new AAIException("is-closed-loop-disabled is set to true");
}
} else if (event.AAI.get("generic-vnf.vnf-name") != null) {
vnfResponse = getAAIVnfInfo(event);
if (vnfResponse == null) {
- throw new ControlLoopException("AAI Response is null (query by vnf-name)");
+ throw new AAIException("AAI Response is null (query by vnf-name)");
}
if (vnfResponse.requestError != null) {
- throw new ControlLoopException("AAI Responded with a request error (query by vnf-name)");
+ throw new AAIException("AAI Responded with a request error (query by vnf-name)");
}
if (isClosedLoopDisabled(vnfResponse) == true) {
- throw new ControlLoopException("is-closed-loop-disabled is set to true");
+ throw new AAIException("is-closed-loop-disabled is set to true");
}
} else if (event.AAI.get("vserver.vserver-name") != null) {
vserverResponse = getAAIVserverInfo(event);
if (vserverResponse == null) {
- throw new ControlLoopException("AAI Response is null (query by vserver-name)");
+ throw new AAIException("AAI Response is null (query by vserver-name)");
}
if (vserverResponse.requestError != null) {
- throw new ControlLoopException("AAI responded with a request error (query by vserver-name)");
+ throw new AAIException("AAI responded with a request error (query by vserver-name)");
}
if (isClosedLoopDisabled(vserverResponse) == true) {
- throw new ControlLoopException("is-closed-loop-disabled is set to true");
+ throw new AAIException("is-closed-loop-disabled is set to true");
}
}
} catch (Exception e) {
logger.error("Exception from getAAIInfo: ", e);
- throw new ControlLoopException("Exception from getAAIInfo: " + e.toString());
+ throw new AAIException("Exception from getAAIInfo: " + e.toString());
}
} else if (isClosedLoopDisabled(event)) {
- throw new ControlLoopException("is-closed-loop-disabled is set to true");
+ throw new AAIException("is-closed-loop-disabled is set to true");
}
}
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
index 223361505..be0eb2bc3 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
@@ -40,6 +40,7 @@ import org.onap.policy.aai.Relationship;
import org.onap.policy.aai.RelationshipData;
import org.onap.policy.aai.RelationshipDataItem;
import org.onap.policy.aai.RelationshipList;
+import org.onap.policy.aai.util.AAIException;
import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopException;
import org.onap.policy.controlloop.ControlLoopNotificationType;
@@ -227,6 +228,17 @@ public class ControlLoopEventManagerTest {
assertNotNull(notification);
assertEquals(ControlLoopNotificationType.ACTIVE, notification.notification);
+
+ ControlLoopEventManager.NEW_EVENT_STATUS status = null;
+ try {
+ status = manager.onNewEvent(event);
+ } catch (AAIException e) {
+ logger.warn(e.toString());
+ fail("A&AI Query Failed");
+ }
+ assertNotNull(status);
+ assertEquals(ControlLoopEventManager.NEW_EVENT_STATUS.FIRST_ONSET, status);
+
AAIGETVnfResponse response = manager.getVnfResponse();
assertNotNull(response);
assertNull(manager.getVserverResponse());
@@ -240,7 +252,13 @@ public class ControlLoopEventManagerTest {
event2.AAI = new HashMap<>();
event2.AAI.put("generic-vnf.vnf-name", "onsetTwo");
- ControlLoopEventManager.NEW_EVENT_STATUS status = manager.onNewEvent(event2);
+
+ try {
+ status = manager.onNewEvent(event2);
+ } catch (AAIException e) {
+ logger.warn(e.toString());
+ fail("A&AI Query Failed");
+ }
assertEquals(ControlLoopEventManager.NEW_EVENT_STATUS.SUBSEQUENT_ONSET, status);
AAIGETVnfResponse response2 = manager.getVnfResponse();
assertNotNull(response2);
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
index e7a31190e..1714d3e26 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
@@ -107,6 +107,16 @@ public class ControlLoopOperationManagerTest {
assertNotNull(notification);
assertEquals(ControlLoopNotificationType.ACTIVE, notification.notification);
+ ControlLoopEventManager.NEW_EVENT_STATUS status = null;
+ try {
+ status = eventManager.onNewEvent(onset);
+ } catch (AAIException e) {
+ logger.warn(e.toString());
+ fail("A&AI Query Failed");
+ }
+ assertNotNull(status);
+ assertEquals(ControlLoopEventManager.NEW_EVENT_STATUS.FIRST_ONSET, status);
+
ControlLoopOperationManager manager = new ControlLoopOperationManager(onset, processor.getCurrentPolicy(), eventManager);
logger.debug("{}",manager);
//
@@ -226,6 +236,16 @@ public class ControlLoopOperationManagerTest {
assertNotNull(notification);
assertEquals(ControlLoopNotificationType.ACTIVE, notification.notification);
+ ControlLoopEventManager.NEW_EVENT_STATUS status = null;
+ try {
+ status = eventManager.onNewEvent(onset);
+ } catch (AAIException e) {
+ logger.warn(e.toString());
+ fail("A&AI Query Failed");
+ }
+ assertNotNull(status);
+ assertEquals(ControlLoopEventManager.NEW_EVENT_STATUS.FIRST_ONSET, status);
+
ControlLoopOperationManager manager = new ControlLoopOperationManager(onset, processor.getCurrentPolicy(), eventManager);
//
//