+ private String newInvocationId;
+ private long resumeTime;
+
+
+ /**
+ * Create a delivery task for a given delivery queue and pub ID.
+ *
+ * @param deliveryTaskHelper The delivery task helper for the queue this task is in.
+ * @param pubid The publish ID for this file. This is used as the base for the file name in the spool directory and
+ * is of the form (milliseconds since 1970).(fqdn of initial data router node)
+ */
+ 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;
+ String mfn = dfn + ".M";
+ datafile = new File(spool + "/" + pubid);
+ metafile = new File(mfn);
+ boolean monly = destInfo.isMetaDataOnly();
+ date = Long.parseLong(pubid.substring(0, pubid.indexOf('.')));
+ resumeTime = System.currentTimeMillis();
+ ArrayList<String[]> hdrv = new ArrayList<>();
+
+ try (BufferedReader br = new BufferedReader(new FileReader(metafile))) {
+ String line = br.readLine();
+ int index = line.indexOf('\t');
+ method = line.substring(0, index);
+ NodeUtils.setIpAndFqdnForEelf(method);
+ if (!"DELETE".equals(method) && !monly) {
+ length = datafile.length();
+ }
+ fileid = line.substring(index + 1);
+ while ((line = br.readLine()) != null) {
+ index = line.indexOf('\t');
+ String header = line.substring(0, index);
+ String headerValue = line.substring(index + 1);
+ if ("x-dmaap-dr-routing".equalsIgnoreCase(header)) {
+ subid = headerValue.replaceAll("[^ ]*/", "");
+ feedid = deliveryTaskHelper.getFeedId(subid.replaceAll(" .*", ""));
+ }
+ if (length == 0 && header.toLowerCase().startsWith("content-")) {
+ continue;
+ }
+ if ("content-type".equalsIgnoreCase(header)) {
+ ctype = headerValue;
+ }
+ if ("x-onap-requestid".equalsIgnoreCase(header)) {
+ MDC.put(MDC_KEY_REQUEST_ID, headerValue);
+ }
+ if ("x-invocationid".equalsIgnoreCase(header)) {
+ MDC.put("InvocationId", headerValue);
+ headerValue = UUID.randomUUID().toString();
+ newInvocationId = headerValue;
+ }
+ hdrv.add(new String[]{header, headerValue});
+ }
+ } catch (Exception e) {
+ eelfLogger.error("Exception", e);
+ }
+ hdrs = hdrv.toArray(new String[hdrv.size()][]);
+ url = deliveryTaskHelper.getDestURL(fileid);
+ }