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%2FDeliveryQueue.java;h=4d336b733aebf7f2943c16baa5f2ab79e4027751;hp=b7699e53b4393e9dcb24dd59953566b6f928e10f;hb=8280a5e1a6cfd155edfafe882439b8c04c6a4509;hpb=7fdcc68d546fe95a7863de512bcda09f01e5d39e diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryQueue.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryQueue.java index b7699e53..4d336b73 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryQueue.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryQueue.java @@ -27,9 +27,10 @@ package org.onap.dmaap.datarouter.node; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import java.io.File; +import java.util.ArrayList; import java.util.Arrays; -import java.util.Hashtable; -import java.util.Vector; +import java.util.HashMap; +import java.util.List; import org.jetbrains.annotations.Nullable; /** @@ -52,16 +53,15 @@ import org.jetbrains.annotations.Nullable; * delivery fails while the delay was active, it will not change the delay * or change the duration of any subsequent delay. * If, however, it succeeds, it will cancel the delay. - * - *

The queue maintains 3 collections of files to deliver: A todo list of + * The queue maintains 3 collections of files to deliver: A todoList of * files that will be attempted, a working set of files that are being * attempted, and a retry set of files that were attempted and failed. - * Whenever the todo list is empty and needs to be refilled, a scan of the + * Whenever the todoList is empty and needs to be refilled, a scan of the * spool directory is made and the file names sorted. Any files in the working set are ignored. * If a DeliveryTask for the file is in the retry set, then that delivery - * task is placed on the todo list. Otherwise, a new DeliveryTask for the - * file is created and placed on the todo list. - * If, when a DeliveryTask is about to be removed from the todo list, its + * task is placed on the todoList. Otherwise, a new DeliveryTask for the + * file is created and placed on the todoList. + * If, when a DeliveryTask is about to be removed from the todoList, its * age exceeds DeliveryQueueHelper.getExpirationTimer(), then it is instead * marked as expired. * @@ -73,14 +73,24 @@ public class DeliveryQueue implements Runnable, DeliveryTaskHelper { private DeliveryQueueHelper deliveryQueueHelper; private DestInfo destinationInfo; - private Hashtable working = new Hashtable<>(); - private Hashtable retry = new Hashtable<>(); + private HashMap working = new HashMap<>(); + private HashMap retry = new HashMap<>(); private int todoindex; private boolean failed; private long failduration; private long resumetime; private File dir; - private Vector todo = new Vector<>(); + private List todoList = new ArrayList<>(); + + /** + * Create a delivery queue for a given destination info. + */ + DeliveryQueue(DeliveryQueueHelper deliveryQueueHelper, DestInfo destinationInfo) { + this.deliveryQueueHelper = deliveryQueueHelper; + this.destinationInfo = destinationInfo; + dir = new File(destinationInfo.getSpool()); + dir.mkdirs(); + } /** * Try to cancel a delivery task. @@ -93,8 +103,8 @@ public class DeliveryQueue implements Runnable, DeliveryTaskHelper { } DeliveryTask dt = retry.get(pubid); if (dt == null) { - for (int i = todoindex; i < todo.size(); i++) { - DeliveryTask xdt = todo.get(i); + for (int i = todoindex; i < todoList.size(); i++) { + DeliveryTask xdt = todoList.get(i); if (xdt.getPublishId().equals(pubid)) { dt = xdt; break; @@ -210,13 +220,13 @@ public class DeliveryQueue implements Runnable, DeliveryTaskHelper { } } while (true) { - if (todoindex >= todo.size()) { + if (todoindex >= todoList.size()) { todoindex = 0; - todo = new Vector<>(); + todoList = new ArrayList<>(); String[] files = dir.list(); Arrays.sort(files); scanForNextTask(files); - retry = new Hashtable<>(); + retry = new HashMap<>(); } DeliveryTask dt = getDeliveryTask(mindate); if (dt != null) { @@ -227,16 +237,6 @@ public class DeliveryQueue implements Runnable, DeliveryTaskHelper { } } - /** - * Create a delivery queue for a given destination info. - */ - DeliveryQueue(DeliveryQueueHelper deliveryQueueHelper, DestInfo destinationInfo) { - this.deliveryQueueHelper = deliveryQueueHelper; - this.destinationInfo = destinationInfo; - dir = new File(destinationInfo.getSpool()); - dir.mkdirs(); - } - /** * Update the destination info for this delivery queue. */ @@ -401,14 +401,14 @@ public class DeliveryQueue implements Runnable, DeliveryTaskHelper { if (dt == null) { dt = new DeliveryTask(this, pubId); } - todo.add(dt); + todoList.add(dt); } } @Nullable private DeliveryTask getDeliveryTask(long mindate) { - if (todoindex < todo.size()) { - DeliveryTask dt = todo.get(todoindex); + if (todoindex < todoList.size()) { + DeliveryTask dt = todoList.get(todoindex); if (dt.isCleaned()) { todoindex++; } @@ -449,4 +449,4 @@ public class DeliveryQueue implements Runnable, DeliveryTaskHelper { } return fname2; } -} +} \ No newline at end of file