X-Git-Url: https://gerrit.onap.org/r/gitweb?p=dmaap%2Fdatarouter.git;a=blobdiff_plain;f=datarouter-node%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fnode%2FDeliveryTask.java;h=018c3aff778754bff00fe525670cf3d9045ad85f;hp=a3af88fcd127ca9e33b15a6f6636966e61d162a7;hb=5e6a9f65049e8e8d39e8dcab227e5d75b328b173;hpb=58553dd3f01290e5b8acac7cfcb63016d7a037da diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java index a3af88fc..018c3aff 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java @@ -31,7 +31,6 @@ import java.util.zip.GZIPInputStream; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import org.apache.log4j.Logger; import org.onap.dmaap.datarouter.node.eelf.EelfMsgs; import org.slf4j.MDC; @@ -46,8 +45,7 @@ import static org.onap.dmaap.datarouter.node.NodeUtils.isFiletypeGzip; * the file and its delivery data as well as to attempt delivery. */ public class DeliveryTask implements Runnable, Comparable { - private static Logger loggerDeliveryTask = Logger.getLogger("org.onap.dmaap.datarouter.node.DeliveryTask"); - private static EELFLogger eelflogger = EELFManager.getInstance() + private static EELFLogger eelfLogger = EELFManager.getInstance() .getLogger(DeliveryTask.class); private DeliveryTaskHelper deliveryTaskHelper; private String pubid; @@ -64,8 +62,10 @@ public class DeliveryTask implements Runnable, Comparable { private String feedid; private String subid; private int attempts; + private boolean followRedirects; private String[][] hdrs; private String newInvocationId; + private long resumeTime; /** @@ -76,11 +76,12 @@ public class DeliveryTask implements Runnable, Comparable { * the base for the file name in the spool directory and is of * the form . */ - public DeliveryTask(DeliveryTaskHelper deliveryTaskHelper, String pubid) { + DeliveryTask(DeliveryTaskHelper deliveryTaskHelper, String pubid) { this.deliveryTaskHelper = deliveryTaskHelper; this.pubid = pubid; destInfo = deliveryTaskHelper.getDestinationInfo(); subid = destInfo.getSubId(); + this.followRedirects = destInfo.isFollowRedirects(); feedid = destInfo.getLogData(); spool = destInfo.getSpool(); String dfn = spool + "/" + pubid; @@ -89,6 +90,7 @@ public class DeliveryTask implements Runnable, Comparable { metafile = new File(mfn); boolean monly = destInfo.isMetaDataOnly(); date = Long.parseLong(pubid.substring(0, pubid.indexOf('.'))); + resumeTime = System.currentTimeMillis(); Vector hdrv = new Vector<>(); try (BufferedReader br = new BufferedReader(new FileReader(metafile))) { @@ -125,7 +127,7 @@ public class DeliveryTask implements Runnable, Comparable { hdrv.add(new String[]{h, v}); } } catch (Exception e) { - loggerDeliveryTask.error("Exception "+e.getStackTrace(),e); + eelfLogger.error("Exception", e); } hdrs = hdrv.toArray(new String[hdrv.size()][]); url = deliveryTaskHelper.getDestURL(fileid); @@ -165,7 +167,7 @@ public class DeliveryTask implements Runnable, Comparable { /** * Get the publish ID */ - public String getPublishId() { + String getPublishId() { return (pubid); } @@ -245,7 +247,7 @@ public class DeliveryTask implements Runnable, Comparable { } deliveryTaskHelper.reportStatus(this, rc, xpubid, rmsg); } catch (Exception e) { - loggerDeliveryTask.error("Exception " + e.getStackTrace(), e); + eelfLogger.error("Exception "+ Arrays.toString(e.getStackTrace()),e); deliveryTaskHelper.reportException(this, e); } } @@ -270,7 +272,7 @@ public class DeliveryTask implements Runnable, Comparable { outputStream.close(); } catch (IOException e) { httpURLConnection.setRequestProperty("Decompression_Status", "FAILURE"); - loggerDeliveryTask.info("Could not decompress file"); + eelfLogger.info("Could not decompress file", e); sendFile(httpURLConnection); } @@ -324,7 +326,7 @@ public class DeliveryTask implements Runnable, Comparable { } catch (ProtocolException pe) { deliveryTaskHelper.reportDeliveryExtra(this, -1L); // Rcvd error instead of 100-continue - loggerDeliveryTask.error("Exception " + pe.getStackTrace(), pe); + eelfLogger.error("Exception " + Arrays.toString(pe.getStackTrace()), pe); } return outputStream; } @@ -332,18 +334,32 @@ public class DeliveryTask implements Runnable, Comparable { /** * Remove meta and data files */ - public void clean() { + void clean() { datafile.delete(); metafile.delete(); - eelflogger.info(EelfMsgs.INVOKE, newInvocationId); - eelflogger.info(EelfMsgs.EXIT); + eelfLogger.info(EelfMsgs.INVOKE, newInvocationId); + eelfLogger.info(EelfMsgs.EXIT); hdrs = null; } + /** + * Set the resume time for a delivery task. + */ + void setResumeTime(long resumeTime) { + this.resumeTime = resumeTime; + } + + /** + * Get the resume time for a delivery task. + */ + long getResumeTime() { + return resumeTime; + } + /** * Has this delivery task been cleaned? */ - public boolean isCleaned() { + boolean isCleaned() { return (hdrs == null); } @@ -357,7 +373,7 @@ public class DeliveryTask implements Runnable, Comparable { /** * Get creation date as encoded in the publish ID. */ - public long getDate() { + long getDate() { return (date); } @@ -371,42 +387,49 @@ public class DeliveryTask implements Runnable, Comparable { /** * Get the content type */ - public String getCType() { + String getCType() { return (ctype); } /** * Get the method */ - public String getMethod() { + String getMethod() { return (method); } /** * Get the file ID */ - public String getFileId() { + String getFileId() { return (fileid); } /** * Get the number of delivery attempts */ - public int getAttempts() { + int getAttempts() { return (attempts); } /** * Get the (space delimited list of) subscription ID for this delivery task */ - public String getSubId() { + String getSubId() { return (subid); } /** * Get the feed ID for this delivery task */ - public String getFeedId() { + String getFeedId() { return (feedid); } + + /** + * Get the followRedirects for this delivery task + */ + public boolean getFollowRedirects() { + return(followRedirects); + } }