- public String getSpoolDir(String subid, String remoteaddr) {
- if (provcheck.isFrom(remoteaddr)) {
- String sdir = config.getSpoolDir(subid);
- if (sdir != null) {
- logger.info("NODE0310 Received subscription reset request for subscription " + subid
- + " from provisioning server " + remoteaddr);
- } else {
- logger.info("NODE0311 Received subscription reset request for unknown subscription " + subid
- + " from provisioning server " + remoteaddr);
+ static class PublishId {
+
+ private long nextuid;
+ private final String myname;
+
+ /**
+ * Generate publish IDs for the specified name.
+ *
+ * @param myname Unique identifier for this publish ID generator (usually fqdn of server)
+ */
+ public PublishId(String myname) {
+ this.myname = myname;
+ }
+
+ /**
+ * Generate a Data Router Publish ID that uniquely identifies the particular invocation of the Publish API for log
+ * correlation purposes.
+ */
+ public synchronized String next() {
+ long now = System.currentTimeMillis();
+ if (now < nextuid) {
+ now = nextuid;
+ }
+ nextuid = now + 1;
+ return (now + "." + myname);
+ }
+ }
+
+ /**
+ * Manage a list of tasks to be executed when an event occurs. This makes the following guarantees:
+ * <ul>
+ * <li>Tasks can be safely added and removed in the middle of a run.</li>
+ * <li>No task will be returned more than once during a run.</li>
+ * <li>No task will be returned when it is not, at that moment, in the list of tasks.</li>
+ * <li>At the moment when next() returns null, all tasks on the list have been returned during the run.</li>
+ * <li>Initially and once next() returns null during a run, next() will continue to return null until startRun() is
+ * called.
+ * </ul>
+ */
+ static class TaskList {
+
+ private Iterator<Runnable> runlist;
+ private final HashSet<Runnable> tasks = new HashSet<>();
+ private HashSet<Runnable> togo;
+ private HashSet<Runnable> sofar;
+ private HashSet<Runnable> added;
+ private HashSet<Runnable> removed;
+
+ /**
+ * Start executing the sequence of tasks.
+ */
+ synchronized void startRun() {
+ sofar = new HashSet<>();
+ added = new HashSet<>();
+ removed = new HashSet<>();
+ togo = new HashSet<>(tasks);
+ runlist = togo.iterator();
+ }
+
+ /**
+ * Get the next task to execute.
+ */
+ synchronized Runnable next() {
+ while (runlist != null) {
+ if (runlist.hasNext()) {
+ Runnable task = runlist.next();
+ if (addTaskToSoFar(task)) {
+ return task;
+ }
+ }
+ if (!added.isEmpty()) {
+ togo = added;
+ added = new HashSet<>();
+ removed.clear();
+ runlist = togo.iterator();
+ continue;
+ }
+ togo = null;
+ added = null;
+ removed = null;
+ sofar = null;
+ runlist = null;