diff options
author | Steve Smokowski <ss835w@att.com> | 2019-09-09 18:02:15 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-09-09 18:02:15 +0000 |
commit | 42b399ea943940ef1e37c267a9aea03b5f01f2d0 (patch) | |
tree | a0897a9888ea2ba45102b79e76207e01adf0ca9f /asdc-controller/src/main | |
parent | d9a8e5a77e5c7857225704d81189583d78c26d2f (diff) | |
parent | cf77e72ced2f815b3d011afcba17b91ae45d1858 (diff) |
Merge "Add SO Update Check if SDC activities deployment end point for custom worlflows is alive"
Diffstat (limited to 'asdc-controller/src/main')
-rw-r--r-- | asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java b/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java index 0fc94c8bd6..7f1c1968c1 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java @@ -20,6 +20,8 @@ package org.onap.so.asdc.activity; +import java.net.HttpURLConnection; +import java.net.URL; import java.util.ArrayList; import java.util.List; import org.onap.so.logger.LoggingAnchor; @@ -27,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; +import org.apache.http.HttpStatus; import org.onap.so.asdc.activity.beans.ActivitySpec; import org.onap.so.asdc.activity.beans.Input; import org.onap.so.asdc.activity.beans.Output; @@ -59,6 +62,11 @@ public class DeployActivitySpecs { String hostname = env.getProperty(SDC_ENDPOINT); logger.debug("{} {}", "SDC ActivitySpec endpoint: ", hostname); if (hostname == null || hostname.isEmpty()) { + logger.warn("The hostname for SDC activities deployment is not configured in SO"); + return; + } + if (!checkHttpOk(hostname)) { + logger.warn("The sdc end point is not alive"); return; } List<org.onap.so.db.catalog.beans.ActivitySpec> activitySpecsFromCatalog = activitySpecRepository.findAll(); @@ -135,4 +143,22 @@ public class DeployActivitySpecs { activitySpec.setOutputs(outputs); return; } + + public boolean checkHttpOk(String host) { + URL url = null; + boolean isOk = false; + + int responseCode = 0; + try { + url = new URL(host); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + responseCode = connection.getResponseCode(); + } catch (Exception e) { + logger.warn("Exception on connecting to SDC WFD endpoint: " + e.getMessage()); + } + if (responseCode == HttpStatus.SC_OK) { + isOk = true; + } + return isOk; + } } |