From 70d47ae38a0327a0fda87137c5d4e8e8fcd6e247 Mon Sep 17 00:00:00 2001 From: reger Date: Mon, 8 Aug 2016 02:19:48 +0200 Subject: [PATCH] keep scheduler selection by repeat entry from https://github.com/yacy/yacy_search_server/commit/07311020d47d42000d5d2488489a7927020739a9 to allow exec schedule on actual exec event. Iterate on exec date (of advantage after interruption/shutdown) to schedule older or missed events first. --- source/net/yacy/search/Switchboard.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.java index b5ccadbf7..dc3af0bf6 100644 --- a/source/net/yacy/search/Switchboard.java +++ b/source/net/yacy/search/Switchboard.java @@ -2198,15 +2198,22 @@ public final class Switchboard extends serverSwitch { final Date now = new Date(); try { final Iterator plainIterator = this.tables.iterator(WorkTables.TABLE_API_NAME); - final Iterator mapIterator = Tables.orderBy(plainIterator, -1, WorkTables.TABLE_API_COL_DATE_RECORDING).iterator(); + final Iterator mapIterator = Tables.orderBy(plainIterator, -1, WorkTables.TABLE_API_COL_DATE_LAST_EXEC).iterator(); while (mapIterator.hasNext()) { row = mapIterator.next(); if (row == null) continue; // select api calls according to scheduler settings - final Date date_next_exec = row.get(WorkTables.TABLE_API_COL_DATE_NEXT_EXEC, (Date) null); - if (date_next_exec != null && now.after(date_next_exec)) pks.add(UTF8.String(row.getPK())); - + final int stime = row.get(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 0); + if (stime > 0) { // has scheduled repeat + final Date date_next_exec = row.get(WorkTables.TABLE_API_COL_DATE_NEXT_EXEC, (Date) null); + if (date_next_exec != null) { // has been executed before + if (now.after(date_next_exec)) pks.add(UTF8.String(row.getPK())); + } else { // was never executed before + pks.add(UTF8.String(row.getPK())); + } + } + // select api calls according to event settings final String kind = row.get(WorkTables.TABLE_API_COL_APICALL_EVENT_KIND, "off"); if (!"off".equals(kind)) {