You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streams.apache.org by mf...@apache.org on 2014/05/27 02:00:32 UTC

[6/6] git commit: Fixed issue where lastID is set incorrectly during a backfill

Fixed issue where lastID is set incorrectly during a backfill


Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/ced9d241
Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/ced9d241
Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/ced9d241

Branch: refs/heads/master
Commit: ced9d241e633f4c1747f0f8a2044944fb8a0d66b
Parents: d93f956
Author: mfranklin <mf...@apache.org>
Authored: Mon May 26 11:43:12 2014 -0400
Committer: mfranklin <mf...@apache.org>
Committed: Mon May 26 20:00:14 2014 -0400

----------------------------------------------------------------------
 .../streams/sysomos/provider/SysomosHeartbeatStream.java     | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/ced9d241/streams-contrib/streams-provider-sysomos/src/main/java/org/apache/streams/sysomos/provider/SysomosHeartbeatStream.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-sysomos/src/main/java/org/apache/streams/sysomos/provider/SysomosHeartbeatStream.java b/streams-contrib/streams-provider-sysomos/src/main/java/org/apache/streams/sysomos/provider/SysomosHeartbeatStream.java
index 22c9c76..04f6647 100644
--- a/streams-contrib/streams-provider-sysomos/src/main/java/org/apache/streams/sysomos/provider/SysomosHeartbeatStream.java
+++ b/streams-contrib/streams-provider-sysomos/src/main/java/org/apache/streams/sysomos/provider/SysomosHeartbeatStream.java
@@ -58,15 +58,21 @@ public class SysomosHeartbeatStream implements Runnable {
     @Override
     public void run() {
         QueryResult result;
+        String mostCurrentId = null;
         //Iff we are trying to get to a specific document ID, continue to query after minimum delay
         do {
             LOGGER.debug("Querying API to match last ID of {}", lastID);
             result = executeAPIRequest();
+            //Ensure that we are only assigning lastID to the latest ID, even if there is backfill query.
+            //Since offset is calcuated at the end of the run, if we detect the need to backfill, it will increment to 1
+            if(offsetCount == 1) {
+                mostCurrentId = result.getCurrentId();
+            }
             sleep();
         } while (lastID != null && !result.isMatchedLastId());
         //Set the last ID so that the next time we are executed we will continue to query only so long as we haven't
         //found the specific ID
-        lastID = result.getCurrentId();
+        lastID = mostCurrentId == null ? result.getCurrentId() : mostCurrentId;
 
         if(SysomosProvider.Mode.BACKFILL_AND_TERMINATE.equals(provider.getMode())) {
             provider.signalComplete(heartbeatId);