Merge "Update INFO.yaml file"
[dmaap/datarouter.git] / datarouter-node / src / main / java / org / onap / dmaap / datarouter / node / NodeConfigManager.java
index 7ecbaaf..d98c47a 100644 (file)
 
 package org.onap.dmaap.datarouter.node;
 
-import java.net.*;
-import java.util.*;
-import java.io.*;
-
-import org.apache.log4j.Logger;
-import org.onap.dmaap.datarouter.node.eelf.EelfMsgs;
-
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+import java.util.Properties;
+import java.util.Timer;
+import org.apache.log4j.Logger;
+import org.onap.dmaap.datarouter.node.eelf.EelfMsgs;
 
 
 /**
@@ -48,13 +50,14 @@ import com.att.eelf.configuration.EELFManager;
 public class NodeConfigManager implements DeliveryQueueHelper {
 
     private static EELFLogger eelflogger = EELFManager.getInstance()
-        .getLogger("org.onap.dmaap.datarouter.node.NodeConfigManager");
+            .getLogger(NodeConfigManager.class);
     private static Logger logger = Logger.getLogger("org.onap.dmaap.datarouter.node.NodeConfigManager");
     private static NodeConfigManager base = new NodeConfigManager();
 
     private Timer timer = new Timer("Node Configuration Timer", true);
     private long maxfailuretimer;
     private long initfailuretimer;
+    private long waitForFileProcessFailureTimer;
     private long expirationtimer;
     private double failurebackoff;
     private long fairtimelimit;
@@ -108,13 +111,14 @@ public class NodeConfigManager implements DeliveryQueueHelper {
         Properties p = new Properties();
         try {
             p.load(new FileInputStream(System
-                .getProperty("org.onap.dmaap.datarouter.node.properties", "/opt/app/datartr/etc/node.properties")));
+                    .getProperty("org.onap.dmaap.datarouter.node.properties", "/opt/app/datartr/etc/node.properties")));
         } catch (Exception e) {
 
             NodeUtils.setIpAndFqdnForEelf("NodeConfigManager");
             eelflogger.error(EelfMsgs.MESSAGE_PROPERTIES_LOAD_ERROR);
             logger.error("NODE0301 Unable to load local configuration file " + System
-                .getProperty("org.onap.dmaap.datarouter.node.properties", "/opt/app/datartr/etc/node.properties"), e);
+                            .getProperty("org.onap.dmaap.datarouter.node.properties", "/opt/app/datartr/etc/node.properties"),
+                    e);
         }
         provurl = p.getProperty("ProvisioningURL", "https://feeds-drtr.web.att.com/internal/prov");
         try {
@@ -182,8 +186,9 @@ public class NodeConfigManager implements DeliveryQueueHelper {
 
     private void localconfig() {
         followredirects = Boolean.parseBoolean(getProvParam("FOLLOW_REDIRECTS", "false"));
-        eventloginterval = getProvParam("LOGROLL_INTERVAL", "5m");
+        eventloginterval = getProvParam("LOGROLL_INTERVAL", "30s");
         initfailuretimer = 10000;
+        waitForFileProcessFailureTimer = 600000;
         maxfailuretimer = 3600000;
         expirationtimer = 86400000;
         failurebackoff = 2.0;
@@ -196,6 +201,10 @@ public class NodeConfigManager implements DeliveryQueueHelper {
             initfailuretimer = (long) (Double.parseDouble(getProvParam("DELIVERY_INIT_RETRY_INTERVAL")) * 1000);
         } catch (Exception e) {
         }
+        try {
+            waitForFileProcessFailureTimer = (long) (Double.parseDouble(getProvParam("DELIVERY_FILE_PROCESS_INTERVAL")) * 1000);
+        } catch (Exception e) {
+        }
         try {
             maxfailuretimer = (long) (Double.parseDouble(getProvParam("DELIVERY_MAX_RETRY_INTERVAL")) * 1000);
         } catch (Exception e) {
@@ -325,6 +334,16 @@ public class NodeConfigManager implements DeliveryQueueHelper {
         return (config.isPublishPermitted(feedid, credentials, ip));
     }
 
+    /**
+     * Check whether delete file is allowed.
+     *
+     * @param subId The ID of the subscription being requested
+     * @return True if the delete file is permitted for the subscriber.
+     */
+    public boolean isDeletePermitted(String subId) {
+        return (config.isDeletePermitted(subId));
+    }
+
     /**
      * Check who the user is given the feed ID and the offered credentials.
      *
@@ -362,13 +381,13 @@ public class NodeConfigManager implements DeliveryQueueHelper {
      * Get a provisioned configuration parameter (from the provisioning server configuration)
      *
      * @param name The name of the parameter
-     * @param deflt The value to use if the parameter is not defined
+     * @param defaultValue The value to use if the parameter is not defined
      * @return The value of the parameter or deflt if it is not defined.
      */
-    public String getProvParam(String name, String deflt) {
+    public String getProvParam(String name, String defaultValue) {
         name = config.getProvParam(name);
         if (name == null) {
-            name = deflt;
+            name = defaultValue;
         }
         return (name);
     }
@@ -404,13 +423,13 @@ public class NodeConfigManager implements DeliveryQueueHelper {
     /**
      * Get the URL to deliver a message to.
      *
-     * @param destinfo The destination information
+     * @param destinationInfo The destination information
      * @param fileid The file ID
      * @return The URL to deliver to
      */
-    public String getDestURL(DestInfo destinfo, String fileid) {
-        String subid = destinfo.getSubId();
-        String purl = destinfo.getURL();
+    public String getDestURL(DestInfo destinationInfo, String fileid) {
+        String subid = destinationInfo.getSubId();
+        String purl = destinationInfo.getURL();
         if (followredirects && subid != null) {
             purl = rdmgr.lookup(subid, purl);
         }
@@ -427,10 +446,10 @@ public class NodeConfigManager implements DeliveryQueueHelper {
     /**
      * Set up redirection on receipt of a 3XX from a target URL
      */
-    public boolean handleRedirection(DestInfo destinfo, String redirto, String fileid) {
+    public boolean handleRedirection(DestInfo destinationInfo, String redirto, String fileid) {
         fileid = "/" + fileid;
-        String subid = destinfo.getSubId();
-        String purl = destinfo.getURL();
+        String subid = destinationInfo.getSubId();
+        String purl = destinationInfo.getURL();
         if (followredirects && subid != null && redirto.endsWith(fileid)) {
             redirto = redirto.substring(0, redirto.length() - fileid.length());
             if (!redirto.equals(purl)) {
@@ -444,8 +463,8 @@ public class NodeConfigManager implements DeliveryQueueHelper {
     /**
      * Handle unreachable target URL
      */
-    public void handleUnreachable(DestInfo destinfo) {
-        String subid = destinfo.getSubId();
+    public void handleUnreachable(DestInfo destinationInfo) {
+        String subid = destinationInfo.getSubId();
         if (followredirects && subid != null) {
             rdmgr.forget(subid);
         }
@@ -458,6 +477,13 @@ public class NodeConfigManager implements DeliveryQueueHelper {
         return (initfailuretimer);
     }
 
+    /**
+     * Get the timeout before retrying after delivery and wait for file processing
+     */
+    public long getWaitForFileProcessFailureTimer() {
+        return (waitForFileProcessFailureTimer);
+    }
+
     /**
      * Get the maximum timeout between delivery attempts
      */
@@ -679,10 +705,10 @@ public class NodeConfigManager implements DeliveryQueueHelper {
             String sdir = config.getSpoolDir(subid);
             if (sdir != null) {
                 logger.info("NODE0310 Received subscription reset request for subscription " + subid
-                    + " from provisioning server " + remoteaddr);
+                        + " from provisioning server " + remoteaddr);
             } else {
                 logger.info("NODE0311 Received subscription reset request for unknown subscription " + subid
-                    + " from provisioning server " + remoteaddr);
+                        + " from provisioning server " + remoteaddr);
             }
             return (sdir);
         } else {