Code Review
/
dmaap
/
datarouter.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Remove datarouter-node critical code smells
[dmaap/datarouter.git]
/
datarouter-node
/
src
/
main
/
java
/
org
/
onap
/
dmaap
/
datarouter
/
node
/
DeliveryTask.java
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
b64396b
..
018c3af
100644
(file)
--- 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 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;
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<DeliveryTask> {
* the file and its delivery data as well as to attempt delivery.
*/
public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
- 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;
.getLogger(DeliveryTask.class);
private DeliveryTaskHelper deliveryTaskHelper;
private String pubid;
@@
-67,6
+65,7
@@
public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
private boolean followRedirects;
private String[][] hdrs;
private String newInvocationId;
private boolean followRedirects;
private String[][] hdrs;
private String newInvocationId;
+ private long resumeTime;
/**
/**
@@
-77,7
+76,7
@@
public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
* the base for the file name in the spool directory and is of
* the form <milliseconds since 1970>.<fqdn of initial data router node>
*/
* the base for the file name in the spool directory and is of
* the form <milliseconds since 1970>.<fqdn of initial data router node>
*/
-
public
DeliveryTask(DeliveryTaskHelper deliveryTaskHelper, String pubid) {
+ DeliveryTask(DeliveryTaskHelper deliveryTaskHelper, String pubid) {
this.deliveryTaskHelper = deliveryTaskHelper;
this.pubid = pubid;
destInfo = deliveryTaskHelper.getDestinationInfo();
this.deliveryTaskHelper = deliveryTaskHelper;
this.pubid = pubid;
destInfo = deliveryTaskHelper.getDestinationInfo();
@@
-91,6
+90,7
@@
public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
metafile = new File(mfn);
boolean monly = destInfo.isMetaDataOnly();
date = Long.parseLong(pubid.substring(0, pubid.indexOf('.')));
metafile = new File(mfn);
boolean monly = destInfo.isMetaDataOnly();
date = Long.parseLong(pubid.substring(0, pubid.indexOf('.')));
+ resumeTime = System.currentTimeMillis();
Vector<String[]> hdrv = new Vector<>();
try (BufferedReader br = new BufferedReader(new FileReader(metafile))) {
Vector<String[]> hdrv = new Vector<>();
try (BufferedReader br = new BufferedReader(new FileReader(metafile))) {
@@
-127,7
+127,7
@@
public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
hdrv.add(new String[]{h, v});
}
} catch (Exception e) {
hdrv.add(new String[]{h, v});
}
} catch (Exception e) {
-
loggerDeliveryTask.error("Exception "+ Arrays.toString(e.getStackTrace())
, e);
+
eelfLogger.error("Exception"
, e);
}
hdrs = hdrv.toArray(new String[hdrv.size()][]);
url = deliveryTaskHelper.getDestURL(fileid);
}
hdrs = hdrv.toArray(new String[hdrv.size()][]);
url = deliveryTaskHelper.getDestURL(fileid);
@@
-167,7
+167,7
@@
public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
/**
* Get the publish ID
*/
/**
* Get the publish ID
*/
-
public
String getPublishId() {
+ String getPublishId() {
return (pubid);
}
return (pubid);
}
@@
-247,7
+247,7
@@
public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
}
deliveryTaskHelper.reportStatus(this, rc, xpubid, rmsg);
} catch (Exception e) {
}
deliveryTaskHelper.reportStatus(this, rc, xpubid, rmsg);
} catch (Exception e) {
-
loggerDeliveryTask.error("Exception " + Arrays.toString(e.getStackTrace()),
e);
+
eelfLogger.error("Exception "+ Arrays.toString(e.getStackTrace()),
e);
deliveryTaskHelper.reportException(this, e);
}
}
deliveryTaskHelper.reportException(this, e);
}
}
@@
-272,7
+272,7
@@
public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
outputStream.close();
} catch (IOException e) {
httpURLConnection.setRequestProperty("Decompression_Status", "FAILURE");
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);
}
sendFile(httpURLConnection);
}
@@
-326,7
+326,7
@@
public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
} catch (ProtocolException pe) {
deliveryTaskHelper.reportDeliveryExtra(this, -1L);
// Rcvd error instead of 100-continue
} catch (ProtocolException pe) {
deliveryTaskHelper.reportDeliveryExtra(this, -1L);
// Rcvd error instead of 100-continue
-
loggerDeliveryTask
.error("Exception " + Arrays.toString(pe.getStackTrace()), pe);
+
eelfLogger
.error("Exception " + Arrays.toString(pe.getStackTrace()), pe);
}
return outputStream;
}
}
return outputStream;
}
@@
-334,18
+334,32
@@
public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
/**
* Remove meta and data files
*/
/**
* Remove meta and data files
*/
-
public
void clean() {
+ void clean() {
datafile.delete();
metafile.delete();
datafile.delete();
metafile.delete();
- eelf
l
ogger.info(EelfMsgs.INVOKE, newInvocationId);
- eelf
l
ogger.info(EelfMsgs.EXIT);
+ eelf
L
ogger.info(EelfMsgs.INVOKE, newInvocationId);
+ eelf
L
ogger.info(EelfMsgs.EXIT);
hdrs = null;
}
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?
*/
/**
* Has this delivery task been cleaned?
*/
-
public
boolean isCleaned() {
+ boolean isCleaned() {
return (hdrs == null);
}
return (hdrs == null);
}
@@
-359,7
+373,7
@@
public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
/**
* Get creation date as encoded in the publish ID.
*/
/**
* Get creation date as encoded in the publish ID.
*/
-
public
long getDate() {
+ long getDate() {
return (date);
}
return (date);
}
@@
-373,42
+387,42
@@
public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
/**
* Get the content type
*/
/**
* Get the content type
*/
-
public
String getCType() {
+ String getCType() {
return (ctype);
}
/**
* Get the method
*/
return (ctype);
}
/**
* Get the method
*/
-
public
String getMethod() {
+ String getMethod() {
return (method);
}
/**
* Get the file ID
*/
return (method);
}
/**
* Get the file ID
*/
-
public
String getFileId() {
+ String getFileId() {
return (fileid);
}
/**
* Get the number of delivery attempts
*/
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
*/
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
*/
return (subid);
}
/**
* Get the feed ID for this delivery task
*/
-
public
String getFeedId() {
+ String getFeedId() {
return (feedid);
}
return (feedid);
}