X-Git-Url: https://gerrit.onap.org/r/gitweb?p=dmaap%2Fdatarouter.git;a=blobdiff_plain;f=datarouter-prov%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fprovisioning%2FSubscriptionServlet.java;h=715c5e140421e2e95d5daf2527f2a8edb347dbb5;hp=125c50d85379c0e4f6d750ac3df7b41184dc55c4;hb=6c78b3e6a0a67c73f931337356a172cc69cee0e8;hpb=52c5c5ab9ba33755e26f06f41de608f825866a53 diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServlet.java index 125c50d8..715c5e14 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServlet.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServlet.java @@ -24,16 +24,18 @@ package org.onap.dmaap.datarouter.provisioning; +import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import java.io.IOException; import java.io.InvalidObjectException; import java.net.HttpURLConnection; import java.net.URL; +import java.util.ArrayList; import java.util.List; -import java.util.Vector; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - import org.json.JSONException; import org.json.JSONObject; import org.onap.dmaap.datarouter.authz.AuthorizationResponse; @@ -41,11 +43,6 @@ import org.onap.dmaap.datarouter.provisioning.beans.EventLogRecord; import org.onap.dmaap.datarouter.provisioning.beans.Subscription; import org.onap.dmaap.datarouter.provisioning.eelf.EelfMsgs; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError; - /** * This servlet handles provisioning for the <subscriptionURL> which is generated by the provisioning server to * handle the inspection, modification, and deletion of a particular subscription to a feed. It supports DELETE to @@ -515,16 +512,16 @@ public class SubscriptionServlet extends ProxyServlet { * A Thread class used to serially send reset notifications to all nodes in the DR network, when a POST is received * for a subscription. */ - public class SubscriberNotifyThread extends Thread { + public static class SubscriberNotifyThread extends Thread { - public static final String URL_TEMPLATE = "http://%s/internal/resetSubscription/%d"; - private List urls = new Vector<>(); + static final String URL_TEMPLATE = "http://%s/internal/resetSubscription/%d"; + private List urls = new ArrayList<>(); - public SubscriberNotifyThread() { + SubscriberNotifyThread() { setName("SubscriberNotifyThread"); } - public void resetSubscription(int subid) { + void resetSubscription(int subid) { for (String nodename : BaseServlet.getNodes()) { String u = String.format(URL_TEMPLATE, nodename, subid); urls.add(u); @@ -533,23 +530,26 @@ public class SubscriptionServlet extends ProxyServlet { @Override public void run() { - try { while (!urls.isEmpty()) { - String u = urls.remove(0); - try { - URL url = new URL(u); - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.connect(); - conn.getContentLength(); // Force the GET through - conn.disconnect(); - } catch (IOException e) { - intlogger.info("PROV0194 Error accessing URL: " + u + ": " + e.getMessage(), e); - } + String url = urls.remove(0); + forceGetThrough(url); } } catch (Exception e) { intlogger.warn("PROV0195 Caught exception in SubscriberNotifyThread: " + e.getMessage(), e); } } + + private void forceGetThrough(String url) { + try { + URL urlObj = new URL(url); + HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); + conn.connect(); + conn.getContentLength(); // Force the GET through + conn.disconnect(); + } catch (IOException e) { + intlogger.info("PROV0194 Error accessing URL: " + url + ": " + e.getMessage(), e); + } + } } }