aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl/vfc
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2017-09-22 15:08:34 +0000
committerGerrit Code Review <gerrit@onap.org>2017-09-22 15:08:34 +0000
commit7d39eea7a0537b4a1dd6f0d1ac9d30b268e1d91d (patch)
treebd84bd4e32f6f3ff3ec48d56bc01a86adbfd2530 /controlloop/common/model-impl/vfc
parentb2b8f46ab3a524eae487fa932d9ceb2b884a68f5 (diff)
parent1aa30b7d83f97103097c7f5d3e4cbd2fad92f659 (diff)
Merge "Add VFC Response in Working Memory & JUNIT"
Diffstat (limited to 'controlloop/common/model-impl/vfc')
-rw-r--r--controlloop/common/model-impl/vfc/pom.xml6
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java8
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java4
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java4
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java6
5 files changed, 24 insertions, 4 deletions
diff --git a/controlloop/common/model-impl/vfc/pom.xml b/controlloop/common/model-impl/vfc/pom.xml
index db86345e8..7672b1bc9 100644
--- a/controlloop/common/model-impl/vfc/pom.xml
+++ b/controlloop/common/model-impl/vfc/pom.xml
@@ -45,5 +45,11 @@
<artifactId>rest</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-core</artifactId>
+ <version>6.5.0.Final</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java
index 4797ab906..5cb6d6624 100644
--- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java
@@ -21,6 +21,7 @@ package org.onap.policy.vfc;
import java.util.HashMap;
import java.util.Map;
+import org.drools.core.WorkingMemory;
import org.onap.policy.vfc.util.Serialization;
import org.onap.policy.rest.RESTManager;
import org.onap.policy.rest.RESTManager.Pair;
@@ -35,9 +36,11 @@ public final class VFCManager implements Runnable {
private String username;
private String password;
private VFCRequest vfcRequest;
+ WorkingMemory workingMem;
private static final Logger logger = LoggerFactory.getLogger(VFCManager.class);
- public VFCManager(VFCRequest request) {
+ public VFCManager(WorkingMemory wm, VFCRequest request) {
+ workingMem = wm;
vfcRequest = request;
// TODO: Get base URL, username and password from MSB?
// TODO: Following code is a placeholder, needs to be updated
@@ -83,6 +86,7 @@ public final class VFCManager implements Runnable {
Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers);
responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, VFCResponse.class);
+ responseGet.requestId = vfcRequest.requestId.toString();
body = Serialization.gsonPretty.toJson(responseGet);
logger.debug("Response to VFC Heal get:");
logger.debug(body);
@@ -91,6 +95,7 @@ public final class VFCManager implements Runnable {
if (responseGet.responseDescriptor.status.equalsIgnoreCase("finished") ||
responseGet.responseDescriptor.status.equalsIgnoreCase("error")) {
logger.debug("VFC Heal Status {}", responseGet.responseDescriptor.status);
+ workingMem.insert(responseGet);
break;
}
}
@@ -102,6 +107,7 @@ public final class VFCManager implements Runnable {
&& (responseGet.responseDescriptor.status != null)
&& (!responseGet.responseDescriptor.status.isEmpty())) {
logger.debug("VFC timeout. Status: ({})", responseGet.responseDescriptor.status);
+ workingMem.insert(responseGet);
}
} catch (JsonSyntaxException e) {
logger.error("Failed to deserialize into VFCResponse {}",e.getLocalizedMessage(),e);
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java
index 9e3a77a2b..89c9b08ff 100644
--- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java
@@ -19,14 +19,16 @@
package org.onap.policy.vfc;
import java.io.Serializable;
+import java.util.UUID;
import com.google.gson.annotations.SerializedName;
public class VFCRequest implements Serializable {
private static final long serialVersionUID = 3736300970326332512L;
- // This field is not serialized and not part of JSON
+ // These fields are not serialized and not part of JSON
public transient String nsInstanceId;
+ public transient UUID requestId;
@SerializedName("healVnfData")
public VFCHealRequest healRequest;
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java
index 775d78f1d..5d6efa0ce 100644
--- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java
@@ -30,7 +30,9 @@ public class VFCResponse implements Serializable {
public String jobId;
@SerializedName("responseDescriptor")
- VFCResponseDescriptor responseDescriptor;
+ public VFCResponseDescriptor responseDescriptor;
+
+ public transient String requestId;
public VFCResponse() {
}
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java
index 9bf77c57c..62c61a7f6 100644
--- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java
@@ -27,7 +27,7 @@ public class VFCResponseDescriptor implements Serializable {
private static final long serialVersionUID = 6827782899144150158L;
@SerializedName("progress")
- public String progress;
+ String progress;
@SerializedName("status")
String status;
@@ -47,4 +47,8 @@ public class VFCResponseDescriptor implements Serializable {
public VFCResponseDescriptor() {
}
+ public String getStatus() {
+ return status;
+ }
+
}