summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors00370346 <swarup.nayak1@huawei.com>2019-07-02 11:09:44 +0530
committers00370346 <swarup.nayak1@huawei.com>2019-07-03 14:51:45 +0530
commit20d8093fd688f0385b7bb9b8e4b09ff60ef23f26 (patch)
tree55370e9544dcb3aaf47247647b64331a75225a22
parent69d6b8580efc61f4c4423d0039a0a28206b09b85 (diff)
Issue-ID: DCAEGEN2-1644 Restconf Collector updating configuration again and again
Signed-off-by: s00370346 <swarup.nayak1@huawei.com> Change-Id: I9adda683cfe63edf4275e9bbe32b6d2acacd15fd
-rwxr-xr-xdpo/blueprints/k8s-rcc-policy.yaml-template2
-rw-r--r--src/main/java/org/onap/dcae/RestConfCollector.java9
-rwxr-xr-xsrc/main/java/org/onap/dcae/common/DataChangeEventListener.java1
-rw-r--r--src/main/java/org/onap/dcae/controller/AccessController.java10
-rw-r--r--src/main/java/org/onap/dcae/controller/PersistentEventConnection.java19
5 files changed, 36 insertions, 5 deletions
diff --git a/dpo/blueprints/k8s-rcc-policy.yaml-template b/dpo/blueprints/k8s-rcc-policy.yaml-template
index eed2874..5c9552b 100755
--- a/dpo/blueprints/k8s-rcc-policy.yaml-template
+++ b/dpo/blueprints/k8s-rcc-policy.yaml-template
@@ -94,7 +94,7 @@ node_templates:
topic_url:
get_input: notification_publish_url
type: message_router
- rcc_policy: '[{"controller_name":"AccessM&C","controller_restapiUrl":"172.30.0.55:26335","controller_restapiUser":"access","controller_restapiPassword":"Huawei@123","controller_accessTokenUrl":"/rest/plat/smapp/v1/oauth/token","controller_accessTokenFile":"./etc/access-token.json","controller_accessTokenMethod":"put","controller_subsMethod":"post","controller_subscriptionUrl":"/restconf/v1/operations/huawei-nce-notification-action:establish-subscription","controller_disableSsl":"true","event_details":[{"event_name":"ONT_registration","event_description":"ONTregistartionevent","event_sseventUrlEmbed":"true","event_sseventsField":"output.url","event_sseventsUrl":"null","event_subscriptionTemplate":"./etc/ont_registartion_subscription_template.json","event_unSubscriptionTemplate":"./etc/ont_registartion_unsubscription_template.json","event_ruleId":"12345678", "modifyData": "true", "modifyMethod": "modifyOntEvent", "userData": "remote_id=AC9.0234.0337;svlan=100;cvlan=10;"}]}]'
+ rcc_policy: '[{"controller_name":"AccessM&C","controller_restapiUrl":"172.30.0.55:26335","controller_restapiUser":"access","controller_restapiPassword":"Huawei@123","controller_accessTokenUrl":"/rest/plat/smapp/v1/oauth/token","controller_accessTokenFile":"./etc/access-token.json","controller_accessTokenMethod":"put","controller_subsMethod":"post","controller_subscriptionUrl":"/restconf/v1/operations/huawei-nce-notification-action:establish-subscription","controller_disableSsl":"true","event_details":[{"event_name":"ONT_registration","event_description":"ONTregistartionevent","event_sseventUrlEmbed":"true","event_sseventsField":"output.url","event_sseventsUrl":"null","event_subscriptionTemplate":"./etc/ont_registartion_subscription_template.json","event_unSubscriptionTemplate":"./etc/ont_registartion_unsubscription_template.json","event_ruleId":"12345678","modifyData": "true","modifyMethod": "modifyOntEvent","userData": "remote_id=AC9.0234.0337;svlan=100;cvlan=10;"}]}]'
interfaces:
cloudify.interfaces.lifecycle:
start:
diff --git a/src/main/java/org/onap/dcae/RestConfCollector.java b/src/main/java/org/onap/dcae/RestConfCollector.java
index 05c299e..545bfd4 100644
--- a/src/main/java/org/onap/dcae/RestConfCollector.java
+++ b/src/main/java/org/onap/dcae/RestConfCollector.java
@@ -78,8 +78,8 @@ public class RestConfCollector {
init();
app.setAddCommandLineProperties(true);
context = app.run();
- configLoader.updateConfig();
controllerConfig(properties);
+ configLoader.updateConfig();
oplog.info("RestConfController running .....");
}
@@ -153,6 +153,13 @@ public class RestConfCollector {
}
private static void controllerConfigCleanup() {
+ log.info("controller ConfigCleanup!");
+ for (java.util.Map.Entry<String, AccessController> entry : controllerStore.entrySet()) {
+ AccessController acstlr = entry.getValue();
+ log.info("controller detail " + acstlr.getCfgInfo().getController_restapiUrl());
+ acstlr.clearAllPersistentConnectios();
+ controllerStore.remove(acstlr);
+ }
controllerStore.clear();
}
diff --git a/src/main/java/org/onap/dcae/common/DataChangeEventListener.java b/src/main/java/org/onap/dcae/common/DataChangeEventListener.java
index 2492c21..6cf2291 100755
--- a/src/main/java/org/onap/dcae/common/DataChangeEventListener.java
+++ b/src/main/java/org/onap/dcae/common/DataChangeEventListener.java
@@ -41,7 +41,6 @@ public class DataChangeEventListener implements EventListener {
@Override
public void onEvent(InboundEvent event) {
try {
- log.info("SSE Event is received");
String s = event.readData();
jsonType type = isJSONValid(s);
if (type == jsonType.OBJECT) {
diff --git a/src/main/java/org/onap/dcae/controller/AccessController.java b/src/main/java/org/onap/dcae/controller/AccessController.java
index daf6237..5050b4b 100644
--- a/src/main/java/org/onap/dcae/controller/AccessController.java
+++ b/src/main/java/org/onap/dcae/controller/AccessController.java
@@ -294,4 +294,14 @@ public class AccessController {
fetchTokenId();
}
}
+
+ public void clearAllPersistentConnectios() {
+ log.info("clearAll PersistentConnectios !");
+ for (java.util.Map.Entry<String, PersistentEventConnection> entry : eventList.entrySet()) {
+ PersistentEventConnection conn = entry.getValue();
+ conn.shutdown();
+ }
+ accesstokenRenewal.cancel(true);
+ scheduledThreadPoolExecutor.shutdown();
+ }
}
diff --git a/src/main/java/org/onap/dcae/controller/PersistentEventConnection.java b/src/main/java/org/onap/dcae/controller/PersistentEventConnection.java
index 14eb2e3..ecbec31 100644
--- a/src/main/java/org/onap/dcae/controller/PersistentEventConnection.java
+++ b/src/main/java/org/onap/dcae/controller/PersistentEventConnection.java
@@ -193,7 +193,6 @@ public class PersistentEventConnection implements Runnable {
openState = eventSrc.isOpen();
log.info("SSE state " + eventSrc.isOpen());
}
- log.info("SSE state " + openState);
if (eventSrc != null && !openState)
{
log.info("SSE state " + eventSrc.isOpen() + " Resubscribing after 1 minute...");
@@ -201,10 +200,15 @@ public class PersistentEventConnection implements Runnable {
/* Resubscribe again */
subscribe = true;
}
+ } catch (InterruptedException ie) {
+ log.info("Exception: " + ie.getMessage());
+ running = false;
+ eventSrc.close();
+ Thread.currentThread().interrupt();
+ return;
} catch (Exception e){
/* Other exception we can keep on retrying */
log.info("Connection failed: " + e.getMessage());
- running = true;
subscribe = true;
if (eventSrc != null) {
eventSrc.close();
@@ -212,6 +216,13 @@ public class PersistentEventConnection implements Runnable {
}
}
}
+ try {
+ if (eventSrc.isOpen()) {
+ eventSrc.close();
+ }
+ }catch (Exception e) {
+ log.info("Connection close failed: " + e.getMessage());
+ }
log.info("Closed connection to SSE source");
}
@@ -349,4 +360,8 @@ public class PersistentEventConnection implements Runnable {
public RestConfContext getCtx() {
return ctx;
}
+
+ public void shutdown() {
+ running = false;
+ }
}