diff options
author | 2019-05-20 11:02:43 +0530 | |
---|---|---|
committer | 2019-05-20 11:02:43 +0530 | |
commit | 45762e8d8a1555957c99f9c8dd995e8542f5d5c3 (patch) | |
tree | 7bd6e61fc6a000ea86b6533f710cc5c44ba58372 /src/main/java/org/onap/dcae/controller/AccessController.java | |
parent | d9fc78bff47ad1afa62cec487774a7edbf40147c (diff) |
Issue-ID: DCAEGEN2-1511 Restconfcollector Access Token Renewal
Signed-off-by: s00370346 <swarup.nayak1@huawei.com>
Change-Id: I1b344e734221038bf0b843543f9bf317e9bc09fd
Diffstat (limited to 'src/main/java/org/onap/dcae/controller/AccessController.java')
-rw-r--r-- | src/main/java/org/onap/dcae/controller/AccessController.java | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/main/java/org/onap/dcae/controller/AccessController.java b/src/main/java/org/onap/dcae/controller/AccessController.java index b82b757..daf6237 100644 --- a/src/main/java/org/onap/dcae/controller/AccessController.java +++ b/src/main/java/org/onap/dcae/controller/AccessController.java @@ -19,6 +19,9 @@ */ package org.onap.dcae.controller; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; import org.json.JSONArray; import org.json.JSONObject; import org.onap.dcae.ApplicationException; @@ -59,6 +62,10 @@ public class AccessController { ControllerActivationState state; + private static ScheduledFuture<?> accesstokenRenewal; + private static ScheduledThreadPoolExecutor scheduledThreadPoolExecutor; + + public AccessController(JSONObject controller, ApplicationSettings properties) { this.cfgInfo = new ControllerConfigInfo.ControllerConfigInfoBuilder() @@ -79,7 +86,7 @@ public class AccessController { this.paraMap = new HashMap<>(); this.state = ControllerActivationState.INIT; prepareControllerParamMap(); - + this.scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(1); log.info("AccesController Created {} {} {} {} {} {}", this.cfgInfo.getController_name(), this.cfgInfo.getController_restapiUrl(), this.cfgInfo.getController_restapiPassword(), this.cfgInfo.getController_restapiUser(), this.cfgInfo.getController_accessTokenUrl(), @@ -153,7 +160,11 @@ public class AccessController { public void activate() { fetchTokenId(); - + AccessTokenRenewalTask task = new AccessTokenRenewalTask(); + accesstokenRenewal = scheduledThreadPoolExecutor.scheduleAtFixedRate(task, + 5, + 10, + TimeUnit.MINUTES); if (getState() == ControllerActivationState.ACTIVE) { printControllerParamMap(); /* Create eventlist from properties */ @@ -270,4 +281,17 @@ public class AccessController { log.info(name + " : " + value); } } + + private class AccessTokenRenewalTask implements Runnable + { + public AccessTokenRenewalTask() { + } + + @Override + public void run() + { + /* Renew token Id */ + fetchTokenId(); + } + } } |