streams-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sblack...@apache.org
Subject [3/7] git commit: better comments and more optimal retry logic
Date Fri, 08 Aug 2014 16:49:54 GMT
better comments and more optimal retry logic


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

Branch: refs/heads/master
Commit: b7a65e1eaa9f523e3675361d9acde63906afac10
Parents: 8b12840
Author: Steve Blackmon <sblackmon@w2odigital.com>
Authored: Tue Jul 8 18:37:58 2014 -0500
Committer: Steve Blackmon <sblackmon@w2odigital.com>
Committed: Tue Jul 8 18:37:58 2014 -0500

----------------------------------------------------------------------
 .../streams/twitter/provider/TwitterErrorHandler.java     | 10 +++++-----
 .../streams/twitter/provider/TwitterTimelineProvider.java |  3 +++
 .../twitter/provider/TwitterTimelineProviderTask.java     |  2 +-
 3 files changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/b7a65e1e/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterErrorHandler.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterErrorHandler.java
b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterErrorHandler.java
index 1f00129..3021701 100644
--- a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterErrorHandler.java
+++ b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterErrorHandler.java
@@ -24,14 +24,14 @@ import twitter4j.Twitter;
 import twitter4j.TwitterException;
 
 /**
- * Created by steveblackmon on 2/8/14.
+ *  Handle expected and unexpected exceptions.
  */
 public class TwitterErrorHandler
 {
     private final static Logger LOGGER = LoggerFactory.getLogger(TwitterErrorHandler.class);
 
-    protected static final long initial_backoff = 2*60*1000;
-    protected static long backoff = initial_backoff;
+    // selected because 3 * 5 + n >= 15 for positive n
+    protected static final long retry = 3*60*1000;
 
     public static int handleTwitterError(Twitter twitter, Exception exception)
     {
@@ -42,7 +42,7 @@ public class TwitterErrorHandler
             {
                 LOGGER.warn("Rate Limit Exceeded");
                 try {
-                    Thread.sleep(backoff *= 2);
+                    Thread.sleep(retry);
                 } catch (InterruptedException e1) {}
                 return 1;
             }
@@ -51,7 +51,7 @@ public class TwitterErrorHandler
                 LOGGER.info("Twitter Network Issues Detected. Backing off...");
                 LOGGER.info("{} - {}", e.getExceptionCode(), e.getLocalizedMessage());
                 try {
-                    Thread.sleep(backoff *= 2);
+                    Thread.sleep(retry);
                 } catch (InterruptedException e1) {}
                 return 1;
             }

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/b7a65e1e/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java
b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java
index 73ac03e..538e789 100644
--- a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java
+++ b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java
@@ -43,6 +43,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
+/**
+ *  Retrieve recent posts from a list of user ids or names.
+ */
 public class TwitterTimelineProvider implements StreamsProvider, Serializable {
 
     public final static String STREAMS_ID = "TwitterTimelineProvider";

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/b7a65e1e/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProviderTask.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProviderTask.java
b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProviderTask.java
index 09969d9..22e129e 100644
--- a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProviderTask.java
+++ b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProviderTask.java
@@ -27,7 +27,7 @@ import twitter4j.*;
 import java.util.List;
 
 /**
- * Created by sblackmon on 12/10/13.
+ *  Retrieve recent posts for a single user id.
  */
 public class TwitterTimelineProviderTask implements Runnable {
 


Mime
View raw message